Skip to content

Commit

Permalink
Merge pull request #24 from eodaGmbH/release/v0.1.2
Browse files Browse the repository at this point in the history
Release/v0.1.2
  • Loading branch information
crazycapivara authored Jan 22, 2024
2 parents 6e12a11 + 43c9d5f commit 1cccfde
Show file tree
Hide file tree
Showing 71 changed files with 1,712 additions and 142 deletions.
11 changes: 2 additions & 9 deletions examples/airports/marker.py → .examples/airports/marker.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import json

import pandas as pd
from maplibre import (
Layer,
LayerType,
Map,
MapContext,
MapOptions,
output_maplibregl,
render_maplibregl,
)
from maplibre import (Layer, LayerType, Map, MapContext, MapOptions,
output_maplibregl, render_maplibregl)
from maplibre.basemaps import Carto
from maplibre.controls import Marker, MarkerOptions, Popup, PopupOptions
from maplibre.sources import GeoJSONSource
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

import pandas as pd
import shapely
from maplibre import (Layer, LayerType, Map, MapContext, MapOptions,
output_maplibregl, render_maplibregl)
from maplibre import (
Layer,
LayerType,
Map,
MapContext,
MapOptions,
output_maplibregl,
render_maplibregl,
)
from maplibre.basemaps import Carto
from maplibre.utils import df_to_geojson
from shiny import App, reactive, ui
Expand Down
77 changes: 77 additions & 0 deletions .examples/every_person_in_manhattan/app2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import geopandas as gpd
import pandas as pd
from maplibre import (
Layer,
LayerType,
Map,
MapContext,
MapOptions,
output_maplibregl,
render_maplibregl,
)
from maplibre.basemaps import Carto
from maplibre.controls import ScaleControl
from maplibre.sources import GeoJSONSource
from maplibre.utils import geopandas_to_geojson
from shiny import App, reactive, ui

MALE_COLOR = "rgb(0, 128, 255)"
FEMALE_COLOR = "rgb(255, 0, 128)"
LAYER_ID = "every-person-in-manhattan-circles"
CIRCLE_RADIUS = 2

point_data = pd.read_json(
"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/scatterplot/manhattan.json"
)

point_data.columns = ["lng", "lat", "sex"]

point_data = gpd.GeoDataFrame(
point_data["sex"], geometry=gpd.points_from_xy(point_data.lng, point_data.lat)
)

every_person_in_manhattan_source = GeoJSONSource(data=geopandas_to_geojson(point_data))


every_person_in_manhattan_circles = Layer(
type=LayerType.CIRCLE,
id=LAYER_ID,
source=every_person_in_manhattan_source,
paint={
"circle-color": ["match", ["get", "sex"], 1, MALE_COLOR, FEMALE_COLOR],
"circle-radius": CIRCLE_RADIUS,
},
)

map_options = MapOptions(
style=Carto.POSITRON,
bounds=point_data.total_bounds,
fit_bounds_options={"padding": 20},
)

app_ui = ui.page_fluid(
ui.panel_title("Every Person in Manhattan"),
output_maplibregl("maplibre", height=600),
ui.input_slider("radius", "Radius", value=CIRCLE_RADIUS, min=1, max=5),
)


def server(input, output, session):
@render_maplibregl
def maplibre():
m = Map(map_options)
m.add_control(ScaleControl(), position="bottom-left")
m.add_layer(every_person_in_manhattan_circles)
return m

@reactive.Effect
@reactive.event(input.radius, ignore_init=True)
async def radius():
async with MapContext("maplibre") as m:
m.set_paint_property(LAYER_ID, "circle-radius", input.radius())


app = App(app_ui, server)

if __name__ == "__main__":
app.run()
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

import pandas as pd
import shapely
from maplibre import (Layer, LayerType, Map, MapContext, output_maplibregl,
render_maplibregl)
from maplibre import (
Layer,
LayerType,
Map,
MapContext,
output_maplibregl,
render_maplibregl,
)
from maplibre.basemaps import Carto
from maplibre.utils import GeometryType, df_to_geojson
from shiny import App, reactive, ui
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 2 additions & 9 deletions examples/h3_hexagons/app.py → .examples/h3_hexagons/app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import h3
import pandas as pd

# import shapely
from maplibre import (
Layer,
LayerType,
Map,
MapContext,
output_maplibregl,
render_maplibregl,
)
from maplibre import (Layer, LayerType, Map, MapContext, output_maplibregl,
render_maplibregl)
from maplibre.basemaps import Carto
from maplibre.utils import GeometryType, df_to_geojson, get_bounds
from shiny import App, reactive, ui
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions .github/workflows/docker-image-animation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docker Image CI

on:
push:
branches: [ "feature/examples" ]
pull_request:
branches: [ "main" ]

env:
IMAGE_NAME: hike-animation
VERSION: latest

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
cd docs/examples/hike
docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/$GITHUB_REPOSITORY/$IMAGE_NAME
# repository name must be lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
17 changes: 15 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
pull_request:
branches: [ "main" ]

env:
IMAGE_NAME: vancouver-blocks
VERSION: latest

jobs:

build:
Expand All @@ -16,5 +20,14 @@ jobs:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
cd docs/examples/vancouver-blocks
docker build . --file Dockerfile --tag my-image-name:$(date +%s)
cd docs/examples/vancouver_blocks
docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/$GITHUB_REPOSITORY/$IMAGE_NAME
# repository name must be lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
33 changes: 33 additions & 0 deletions .github/workflows/docker-image2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docker Image CI

on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "main" ]

env:
IMAGE_NAME: airports
VERSION: latest

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
cd docs/examples/airports
docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/$GITHUB_REPOSITORY/$IMAGE_NAME
# repository name must be lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
30 changes: 30 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Python package

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install Poetry and pytest
run: pip install poetry pytest
- name: Install package
run: poetry install
- name: Test package
run: |
poetry run pytest
poetry run pytest --doctest-modules maplibre --ignore maplibre/ipywidget.py
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog for MapLibre for Python

## maplibre v0.1.2

* Add `Map.set_data`
* Add `Map.set_visibility`
* Do not import `ipywidget.MapWidget` in `__init__` and skip tests for `MapWidget`, because it causes a `core dumped` error, see [anywidget issue](https://github.com/manzt/anywidget/issues/374)
* Remove `requests` dependency
* Remove dead code
* Add more examples

## maplibre v0.1.1

* Initial PyPI release
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# MapLibre for Python

[![Release](https://img.shields.io/github/v/release/eodaGmbH/py-maplibregl)](https://img.shields.io/github/v/release/eodaGmbH/py-maplibregl)
[![Build status](https://img.shields.io/github/actions/workflow/status/eodaGmbH/py-maplibregl/pytest.yaml?branch=main)](https://img.shields.io/github/actions/workflow/status/eodaGmbH/py-maplibregl/pytest.yaml?branch=main)
[![License](https://img.shields.io/github/license/eodaGmbH/py-maplibregl)](https://img.shields.io/github/license/eodaGmbH/py-maplibregl)

MapLibre for Python provides Python bindings for [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js).

It integrates seamlessly into [Shiny for Python](https://github.com/posit-dev/py-shiny) and [Jupyter](https://jupyter.org/).
Expand All @@ -20,6 +24,10 @@ pip install "maplibre[all] @ git+https://github.com/eodaGmbH/py-maplibregl@dev"

## Getting started

```bash
docker run --rm -p 8050:8050 ghcr.io/eodagmbh/py-maplibregl/vancouver-blocks:latest
```

* [Basic usage](https://eodagmbh.github.io/py-maplibregl/)
* [API Documentation](https://eodagmbh.github.io/py-maplibregl/api/map/)
* [Examples](https://eodagmbh.github.io/py-maplibregl/examples/every_person_in_manhattan/)
Expand Down
6 changes: 6 additions & 0 deletions docs/api/controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
docstring_section_style: list

::: maplibre.controls.FullscreenControl

::: maplibre.controls.ScaleControl

::: maplibre.controls.NavigationControl

::: maplibre.controls.GeolocateControl
4 changes: 3 additions & 1 deletion docs/api/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

::: maplibre.MapOptions

::: maplibre.MapContext

::: maplibre.ipywidget.MapWidget
options:
inherited_members: true
inherited_members: false

Loading

0 comments on commit 1cccfde

Please sign in to comment.