Skip to content

Commit 034cc49

Browse files
Merge pull request #8 from eoda-dev/dev
Dev
2 parents 5c295cc + 017ecdb commit 034cc49

File tree

131 files changed

+14771
-1805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+14771
-1805
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and deploy docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- "*"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Install package
25+
run: pip install -e .
26+
27+
- name: Install dependencies
28+
run: pip install -r requirements.docs.txt
29+
30+
- name: Build docs
31+
run: mkdocs build -d dist
32+
33+
- name: Upload artifact
34+
uses: actions/upload-pages-artifact@v3
35+
with:
36+
path: ./dist
37+
38+
deploy:
39+
needs: build
40+
if: github.ref == 'refs/heads/main'
41+
permissions:
42+
pages: write
43+
id-token: write
44+
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.github/workflows/pytest.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.10", "3.11", "3.12"]
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
20+
# You can test your matrix by printing the current Python version
21+
- name: Display Python version
22+
run: python -c "import sys; print(sys.version)"
23+
24+
- name: Install package
25+
run: pip install -e .
26+
27+
- name: Install dev dependencies
28+
run: pip install -r requirements.dev.txt
29+
30+
- name: Test package
31+
run: pytest

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1-
# OpenLayers for Python
1+
# py-openlayers: OpenLayers for Python
2+
3+
[![Release](https://img.shields.io/github/v/release/eoda-dev/py-openlayers)](https://img.shields.io/github/v/release/eoda-dev/py-openlayers)
4+
[![pypi](https://img.shields.io/pypi/v/openlayers.svg)](https://pypi.python.org/pypi/openlayers)
5+
[![License](https://img.shields.io/github/license/eoda-dev/py-openlayers)](https://img.shields.io/github/license/eoda-dev/py-openlayers)
6+
[![OpenLayers JS](https://img.shields.io/badge/OpenLayers-v10.5.0-blue.svg)](https://github.com/openlayers/openlayers/releases//tag/v10.5.0)
7+
8+
Provides Python bindings for [Openlayers](https://openlayers.org/), a high-performance, full-featured web mapping library that displays maps from various sources and formats. It makes it a easy to create interactive maps in [Marimo](https://marimo.io/) and [Jupyter](https://jupyter.org/) notebbooks with a few lines of code in a pydantic way.
9+
10+
## Features
11+
12+
### Tiled Layers
13+
14+
Pull tiles from OSM, CartoDB, MapTiler and any other XYZ source.
15+
16+
17+
### Vector Layers
18+
19+
Render vector data from GeoJSON, TopoJSON, KML, GML and other formats.
20+
21+
### Controls
22+
23+
Add geocoding, draw, full screen and other controls to your map.
24+
25+
### WebGL
26+
27+
Render large data sets using WebGL.
28+
29+
### PMTiles
30+
31+
Render PMTiles from vector and raster sources.
32+
33+
### Interactions
34+
35+
Drag and drop GPX, GeoJSON, KML or TopoJSON files on to the map. Modify, draw and select features.
236

337
## Installation
438

@@ -7,3 +41,21 @@ uv init
741

842
uv add "git+https://github.com/eoda-dev/py-openlayers@main"
943
```
44+
45+
## Quickstart
46+
47+
```python
48+
import openlayers as ol
49+
50+
# Jupyter or Marimo
51+
m = ol.MapWidget()
52+
m # Display map
53+
54+
# Standalone
55+
m = ol.Map()
56+
m.save()
57+
```
58+
59+
## Note
60+
61+
The documentation is still in an early stage, more examples will be added as soon as possible.

TODOS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# TODOS
2+
3+
## STAC layers
4+
5+
https://openlayers.org/en/latest/examples/stac-item.html

docs/api/basemaps.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Basemaps
2+
3+
::: openlayers.basemaps.BasemapLayer
4+
5+
::: openlayers.basemaps.CartoBasemapLayer
6+
7+
::: openlayers.basemaps.MapTilerBasemapLayer

docs/api/controls.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Controls
2+
3+
::: openlayers.controls

docs/api/express.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# OpenLayersExpress
2+
3+
::: openlayers.express.GeoJSONLayer

docs/api/geopandas.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# GeoPandas
2+
3+
::: openlayers.geopandas.OLAccessor
4+
5+
::: openlayers.geopandas.GeoDataFrame

docs/api/layers.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Layers
2+
3+
::: openlayers.layers.Layer
4+
5+
::: openlayers.layers.VectorLayer
6+
7+
::: openlayers.layers.VectorTileLayer
8+
9+
::: openlayers.layers.TileLayer
10+
11+
::: openlayers.layers.WebGLVectorLayer
12+
13+
::: openlayers.layers.WebGLVectorTileLayer
14+
15+
::: openlayers.layers.WebGLTileLayer

docs/api/map.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Map
2+
3+
::: openlayers.Map
4+
5+
::: openlayers.view.View
6+
7+
::: openlayers.MapWidget
8+

docs/api/sources.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Sources
2+
3+
::: openlayers.sources

docs/api/styles.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Styles
2+
3+
::: openlayers.styles.FlatStyle
4+
5+
::: openlayers.styles.default_style

docs/concepts/controls.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Controls
2+
3+
Controls are user interface elements that you can add to your map:
4+
5+
```python
6+
-8<-- "concepts/controls.py"
7+
```
8+
9+
> See [Controls API](../../api/controls/)

docs/concepts/geopandas.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# GeoPandas
2+
3+
Python-OpenLayers shipes with a [GeoPandas](https://geopandas.org/) extension:
4+
5+
```python
6+
-8<-- "concepts/geopandas.py"
7+
```
File renamed without changes.

docs/concepts/layers.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Layers and sources
2+
3+
Sources and layers are used to display _raster_ or _vector_ data on your map.
4+
5+
## Sources
6+
7+
Sources state which data the map should display.
8+
9+
```python
10+
-8<-- "concepts/sources.py"
11+
```
12+
13+
> See [Sources API](../../api/sources/)
14+
15+
## Layers
16+
17+
A layer defines how a source is displayed on the map:
18+
19+
```python
20+
-8<-- "concepts/layers.py"
21+
```
22+
23+
> See [Layers API](../../api/layers/)
24+
25+
## Styles
26+
27+
Vector layers are styled with an object containing properties for the different styles, such as _stroke_, _fill_, _circle_ or _icon_:
28+
29+
```python
30+
style = ol.FlatStyle(
31+
stroke_color = "yellow",
32+
stroke_width = 1.5,
33+
fill_color = "orange"
34+
)
35+
```
36+
37+
It is also possible to use a simple dictonary instead. In this case property names must use hyphens instead
38+
of underscores:
39+
40+
```python
41+
const style = {
42+
"stroke-color": "yellow",
43+
"stroke-width": 1.5,
44+
"fill-color": "orange",
45+
}
46+
```
47+
48+
> See [Styles API](../../api/styles/) and [ol/style/flat](https://openlayers.org/en/latest/apidoc/module-ol_style_flat.html) for details.

docs/concepts/map.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Map
2+
3+
The [Map](../../api/map/#openlayers.Map) is the core component of your visualization, to which other components such as [controls](../controls), [layers](../layers) or overlays are added. Components can be added either during initialization or afterwards:
4+
5+
```python
6+
-8<-- "concepts/basic_map.py"
7+
```
8+
9+
## View state
10+
11+
Properties such as _center_, _zoom level_ and _projection_ are managed by the [View](../../api/map/#openlayers.view.View) instance:
12+
13+
```python
14+
-8<-- "concepts/view.py"
15+
```
16+
17+
## Basemaps
18+
19+
A basemap in openlayers consists of one or more layers from your layer stack:
20+
21+
```python
22+
-8<-- "concepts/basemaps.py"
23+
```
24+
25+
> See [BasemapLayer API](../../api/basemaps/#openlayers.Basemaps.BasemapLayer)
26+
27+
If you hand over an empty layer stack to your map, a blank background is displayed:
28+
29+
```python
30+
m = ol.Map(layers=[])
31+
```

docs/examples/concepts/basemaps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import openlayers as ol
2+
from openlayers.basemaps import CartoBasemapLayer, Carto
3+
4+
# Use default OSM basemap
5+
m = ol.Map(layers=[ol.BasemapLayer()])
6+
7+
# Use a CartoDB basemap
8+
m = ol.Map(layers=[CartoBasemapLayer(Carto.DARK_NO_LABELS)])

docs/examples/concepts/basic_map.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import openlayers as ol
2+
3+
# Add components during initialization
4+
m = ol.Map(controls=[ol.ZoomSliderControl()])
5+
6+
# Add components after initialization
7+
m.add_control(ol.FullScreenControl())

docs/examples/concepts/controls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import openlayers as ol
2+
3+
# Add controls during initialization
4+
m = ol.Map(controls=[ol.ZoomSliderControl(), ol.OverviewMapControl()])
5+
6+
# Add components after initialization
7+
m.add_control(ol.ScaleLineControl(units="degrees"))

docs/examples/concepts/geopandas.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import openlayers as ol
2+
from openlayers.geopandas import GeoDataFrame
3+
4+
data = "https://openlayers.org/en/latest/examples/data/geojson/roads-seoul.geojson"
5+
6+
m = GeoDataFrame.from_file(data).ol.explore(tooltip=True)
7+
m.add_control(ol.ScaleLineControl())

docs/examples/concepts/layers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import openlayers as ol
2+
3+
data = "https://openlayers.org/en/latest/examples/data/geojson/roads-seoul.geojson"
4+
5+
vector = ol.VectorLayer(
6+
id="roads",
7+
source=ol.VectorSource(url=data),
8+
fit_bounds=True,
9+
)
10+
11+
12+
m = ol.Map(
13+
ol.View(rotation=3.14 / 8),
14+
layers=[ol.BasemapLayer(), vector]
15+
)
16+
m.add_default_tooltip()

docs/examples/concepts/sources.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import openlayers as ol
2+
3+
geojson = ol.VectorSource(
4+
url="https://openlayers.org/en/latest/examples/data/geojson/roads-seoul.geojson"
5+
)
6+
7+
geotiff = ol.GeoTIFFSource(
8+
sources=[{"url": "https://s2downloads.eox.at/demo/EOxCloudless/2020/rgbnir/s2cloudless2020-16bits_sinlge-file_z0-4.tif"}]
9+
)
10+
11+
pmtiles = ol.PMTilesVectorSource(
12+
url="https://r2-public.protomaps.com/protomaps-sample-datasets/nz-buildings-v3.pmtiles",
13+
attributions=["© Land Information New Zealand"]
14+
)

docs/examples/concepts/view.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import openlayers as ol
2+
3+
initial_view = ol.View(center=(9.5, 51.31667), zoom=14)
4+
5+
m = ol.Map(initial_view)
6+
7+
# Change view settings afterwards
8+
m.set_center(lon=172.606201, lat=-43.556510)
9+
m.set_zoom(14)
10+
11+
m.set_view(ol.View(center=(172.606201, -43.556510), zoom=12))

0 commit comments

Comments
 (0)