Skip to content

Commit 350aec1

Browse files
authored
Implement native SQL Alchemy MVT (#2022)
* Implement SQLAlchemy native MVT query Fix typo Rename base tile provider Fix Tile HTML highlighting Fix missing tile rename Update CRS conversion Change fallback for vector tile id Undo rename tile provider Reduce diff Cleanup mvt-postgres provider Re-add ST_CurveToLine 97ba024 * Add ST_CurveToLine for output geom * Set id field for vector files * Add MVT Postgres Provider test Fix Flake8 * Fix indentation in MVT-Postgres docs * Fix get_metadata() - Fix get_metadata function - Add unit test for get_metadata * Fix MVT feature properties - Fix MVT field selection - Add test for vector tile properties * Fix flake8 * Add storage_crs information to docs * Add test_postgresql_mvt_provider to GitHub CI * Bump GitHub Action Postgis version Bump GitHub Postgis engine to >3 * Filter SQL connection options Prevent passing dict to SQL connection which throws an error because it cannot be cached * Use geoalchemy2 functions * Amend WorldCRS84Quad Tile bbox Align with WorldCRS84Quad spec using #2042 * Support WorldCRS84Quad in default tile html Add minimal support stretching EPSG3857 TileLayer to EPSG4326. Really should be a CRS84 based layer like: L.tileLayer.wms("https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi", { layers: "BlueMarble_ShadedRelief_Bathymetry", attribution: "NASA GIBS", }) .addTo(map);
1 parent 31c28bb commit 350aec1

File tree

8 files changed

+503
-147
lines changed

8 files changed

+503
-147
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ jobs:
2424
- python-version: '3.10'
2525
env:
2626
PYGEOAPI_CONFIG: "$(pwd)/pygeoapi-config.yml"
27+
28+
services:
29+
postgres:
30+
image: postgis/postgis:14-3.2
31+
ports:
32+
- 5432:5432
33+
env:
34+
POSTGRES_DB: test
35+
POSTGRES_PASSWORD: ${{ secrets.DatabasePassword || 'postgres' }}
2736

2837
steps:
2938
- name: Pre-pull Docker Images
@@ -32,7 +41,6 @@ jobs:
3241
docker pull appropriate/curl:latest &
3342
docker pull elasticsearch:8.17.0 &
3443
docker pull opensearchproject/opensearch:2.18.0 &
35-
docker pull mdillon/postgis:latest &
3644
docker pull mongo:8.0.4 &
3745
docker pull ghcr.io/cgs-earth/sensorthings-action:0.1.0 &
3846
docker pull postgis/postgis:14-3.2 &
@@ -58,12 +66,6 @@ jobs:
5866
sudo sysctl -w vm.swappiness=1
5967
sudo sysctl -w fs.file-max=262144
6068
sudo sysctl -w vm.max_map_count=262144
61-
- name: Install and run PostgreSQL/PostGIS 📦
62-
uses: huaxk/postgis-action@v1
63-
with:
64-
postgresql password: ${{ secrets.DatabasePassword || 'postgres' }}
65-
postgresql db: 'test'
66-
6769
- name: "Install and run MySQL 📦"
6870
uses: mirromutth/mysql-action@v1.1
6971
with:
@@ -164,6 +166,7 @@ jobs:
164166
pytest tests/test_oracle_provider.py
165167
pytest tests/test_parquet_provider.py
166168
pytest tests/test_postgresql_provider.py
169+
pytest tests/test_postgresql_mvt_provider.py
167170
pytest tests/test_mysql_provider.py
168171
pytest tests/test_rasterio_provider.py
169172
pytest tests/test_sensorthings_edr_provider.py

docs/source/data-publishing/ogcapi-tiles.rst

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ MVT-postgresql
140140
.. note::
141141
Must have PostGIS installed with protobuf-c support
142142

143-
.. note::
144-
Geometry must be using EPSG:4326
145-
146143
This provider gives support to serving tiles generated using `PostgreSQL <https://www.postgresql.org/>`_ with `PostGIS <https://postgis.net/>`_.
147144
The tiles are rendered on-the-fly using `ST_AsMVT <https://postgis.net/docs/ST_AsMVT.html>`_ and related methods.
148145

@@ -152,24 +149,28 @@ This code block shows how to configure pygeoapi to render Mapbox vector tiles fr
152149
153150
providers:
154151
- type: tile
155-
name: MVT-postgresql
156-
data:
157-
host: 127.0.0.1
158-
port: 3010 # Default 5432 if not provided
159-
dbname: test
160-
user: postgres
161-
password: postgres
162-
search_path: [osm, public]
163-
id_field: osm_id
164-
table: hotosm_bdi_waterways
165-
geom_field: foo_geom
166-
options:
167-
zoom:
168-
min: 0
169-
max: 15
170-
format:
171-
name: pbf
172-
mimetype: application/vnd.mapbox-vector-tile
152+
name: MVT-postgresql
153+
data:
154+
host: 127.0.0.1
155+
port: 3010 # Default 5432 if not provided
156+
dbname: test
157+
user: postgres
158+
password: postgres
159+
search_path: [osm, public]
160+
id_field: osm_id
161+
table: hotosm_bdi_waterways
162+
geom_field: foo_geom
163+
storage_crs: http://www.opengis.net/def/crs/EPSG/0/4326
164+
options:
165+
zoom:
166+
min: 0
167+
max: 15
168+
format:
169+
name: pbf
170+
mimetype: application/vnd.mapbox-vector-tile
171+
172+
.. tip::
173+
Geometry must have correctly defined :ref:`storage_crs<crs>`
173174

174175
PostgreSQL-related connection options can also be added to `options`. Please refer to the :ref:`PostgreSQL OGC Features Provider<PostgreSQL>` documentation for more information.
175176

pygeoapi/api/tiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def get_collection_tiles_data(
246246
if content is None:
247247
msg = 'identifier not found'
248248
return api.get_exception(
249-
HTTPStatus.NO_CONTENT, headers, format_, 'NocContent', msg)
249+
HTTPStatus.NO_CONTENT, headers, format_, 'NoContent', msg)
250250
else:
251251
return headers, HTTPStatus.OK, content
252252

0 commit comments

Comments
 (0)