OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.81k stars 2.52k forks source link

Support default zoom level for vector tiles in OGC API Tiles Driver #7969

Open doublebyte1 opened 1 year ago

doublebyte1 commented 1 year ago

As discussed in this issue , the OGC API Tiles driver is not able to read vector tiles.

Expected behavior and actual behavior.

The expected behavior should be to request OGC API vector tiles, and receive back a dataset:

ogr2ogr -oo API=TILES test.geojson "OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf"

Instead, the response is:

ERROR 1: Layer 'Zoom level 1' does not already exist in the output dataset, and cannot be created by the output driver.
ERROR 1: Terminating translation prematurely after failed

ogrinfo tells us that the dataset is available in multiple zoom levels:

ogrinfo -oo API=TILES "OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf"
INFO: Open of OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf' using driver OGCAPI' successful.
Metadata:
TITLE=AgricultureSrf
1: Zoom level 0
2: Zoom level 1
3: Zoom level 2
4: Zoom level 3
5: Zoom level 4
6: Zoom level 5
7: Zoom level 6
8: Zoom level 7
9: Zoom level 8
10: Zoom level 9
11: Zoom level 10
12: Zoom level 11
13: Zoom level 12
14: Zoom level 13
15: Zoom level 14
16: Zoom level 15
17: Zoom level 16

Most likely, OGR does not know which zoom to pick and throws back an error, terminating the task.

This could be avoided by picking a zoom level by default (perhaps the lowest resolution). In addition, we could also support the option TILEMATRIX=, which allows to specify a specific zoom level and currently only works for raster datasets.

Operating system

Ubuntu 22.04.2 LTS

GDAL version and provenance

GDAL 3.8.0dev-23d309f3f4, released 2023/05/02 (debug build)

jerstlouis commented 1 year ago

Suggesting to default to the most detailed tile matrix rather than the least detailed one, since lowest 0 resolution will be quite horrible for any detailed dataset. Or perhaps the driver could be smarter and pick a default n of levels from most detailed resolution, and/or analyze both the extent and most detiled level of the data to compute a good default.