Skip to content

Commit ede0b4e

Browse files
authored
enable custom tile matrix sets (geopython#2074) (geopython#2092)
* leverage custom tiling schemes in MVT tile providers * use tile schemes if exists * fix ref, docstrings/comments (thanks @lindakarlovska) * fix doc ref
1 parent 56dccfc commit ede0b4e

6 files changed

Lines changed: 26 additions & 15 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ Following block shows how to configure pygeoapi to read Mapbox vector tiles from
103103
- type: tile
104104
name: MVT-proxy
105105
data: http://localhost:7800/public.ne_50m_admin_0_countries/{z}/{x}/{y}.mvt
106-
options:
107-
zoom:
108-
min: 0
109-
max: 15
110-
schemes:
111-
- WebMercatorQuad # this option is needed in the MVT-proxy provider
106+
options:
107+
zoom:
108+
min: 0
109+
max: 15
110+
schemes:
111+
- WebMercatorQuad # this option is needed in the MVT-proxy provider
112112
format:
113113
name: pbf
114114
mimetype: application/vnd.mapbox-vector-tile

pygeoapi/provider/base_mvt.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,18 @@ def get_layer(self):
7171
raise NotImplementedError()
7272

7373
def get_tiling_schemes(self):
74+
if self.schemes:
75+
LOGGER.debug('Using custom TMS definition')
76+
tile_matrix_set_links = [
77+
item.value for item in TileMatrixSetEnum
78+
if item.value.tileMatrixSet in self.schemes]
7479

75-
tile_matrix_set_links_list = [
76-
TileMatrixSetEnum.WORLDCRS84QUAD.value,
77-
TileMatrixSetEnum.WEBMERCATORQUAD.value
78-
]
79-
tile_matrix_set_links = [
80-
item for item in tile_matrix_set_links_list
81-
if item.tileMatrixSet in self.options['schemes']]
80+
else:
81+
LOGGER.debug('Using default TMS definitions')
82+
tile_matrix_set_links = [
83+
TileMatrixSetEnum.WORLDCRS84QUAD.value,
84+
TileMatrixSetEnum.WEBMERCATORQUAD.value
85+
]
8286

8387
return tile_matrix_set_links
8488

pygeoapi/provider/mvt_elastic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def get_layer(self):
122122

123123
def get_tiling_schemes(self):
124124

125-
"Only WebMercatorQuad tiling scheme is supported in elastic"
125+
"Only WebMercatorQuad tiling scheme is supported in Elasticsearch"
126126
return [
127127
TileMatrixSetEnum.WEBMERCATORQUAD.value
128128
]

pygeoapi/provider/mvt_postgresql.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ def get_layer(self):
9999
return self.table
100100

101101
def get_tiling_schemes(self):
102+
"""
103+
Only WebMercatorQuad and WorldCRS84Quad tiling schemes
104+
are supported for PostgreSQL
105+
"""
106+
102107
return [
103108
TileMatrixSetEnum.WEBMERCATORQUAD.value,
104109
TileMatrixSetEnum.WORLDCRS84QUAD.value

pygeoapi/provider/mvt_tippecanoe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def get_layer(self):
139139
return Path(self.data).name
140140

141141
def get_tiling_schemes(self):
142-
"Only WebMercatorQuad tiling scheme is supported in elastic"
142+
"Only WebMercatorQuad tiling scheme is supported in tippecanoe"
143+
143144
return [TileMatrixSetEnum.WEBMERCATORQUAD.value]
144145

145146
def get_tiles_service(self, baseurl=None, servicepath=None,

pygeoapi/provider/tile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(self, provider_def):
5858
self.format_type = provider_def['format']['name']
5959
self.mimetype = provider_def['format']['mimetype']
6060
self.options = provider_def.get('options')
61+
self.schemes = self.options.get('schemes', [])
6162
self.tile_type = None
6263

6364
def get_layer(self):

0 commit comments

Comments
 (0)