Skip to content

Commit 4674f9b

Browse files
authored
Correct MVT tile indices when fetching tiles from providers + fix tile indices in MVT UI preview (#1989)
* Corrected tile indices in `MVTElasticProvider` when fetching tiles from Elastic - Elastic by default serves vector tiles in the `/z/x/y` index order * Correct tile indices in `MVTProxyProvider` when fetching tiles from the proxied Martin/pg_tileserv server - Both Martin and pg_tileserv by default serve tiles in the `/z/x/y` index order * Correct tile indices in `MVTTippecanoeProvider` when fetching tiles generated by Tippecanoe - Tippecanoe generates tiles in `z/x/y` index directory order * Fix incorrect tile index order in MVT tile HTML preview The wrong index order in the preview + using `/{z}/{y}/{x}` when fetching tiles from existing MVT providers made tiles visible on the pygeoapi UI, but external clients needed to use `/{z}/{x}/{y}` to fetch tiles, which is contrary to the OGC Tiles specification of `/{z}/{y}/{x}` This commit along with commits 5b8b179, 3f35fd3, c24cf56 fixes the issue
1 parent bfeb0c3 commit 4674f9b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Diff for: pygeoapi/provider/mvt_elastic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def get_tiles(self, layer=None, tileset=None,
176176
with requests.Session() as session:
177177
data = {'fields': ['*']}
178178
session.get(base_url)
179-
resp = session.get(f'{base_url}/{layer}/{z}/{y}/{x}{url_query}', json=data) # noqa
179+
resp = session.get(f'{base_url}/{layer}/{z}/{x}/{y}{url_query}', json=data) # noqa
180180

181181
if resp.status_code == 404:
182182
if (self.is_in_limits(TileMatrixSetEnum.WEBMERCATORQUAD.value, z, x, y)): # noqa

Diff for: pygeoapi/provider/mvt_proxy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ def get_tiles(self, layer=None, tileset=None,
170170
with requests.Session() as session:
171171
session.get(base_url)
172172
if '.' in url.path:
173-
resp = session.get(f'{base_url}/{layer}/{z}/{y}/{x}.{format_}{url_query}') # noqa
173+
resp = session.get(f'{base_url}/{layer}/{z}/{x}/{y}.{format_}{url_query}') # noqa
174174
else:
175-
resp = session.get(f'{base_url}/{layer}/{z}/{y}/{x}{url_query}') # noqa
175+
resp = session.get(f'{base_url}/{layer}/{z}/{x}/{y}{url_query}') # noqa
176176

177177
if resp.status_code == 404:
178178
if (self.is_in_limits(self.get_tilematrixset(tileset), z, x, y)): # noqa

Diff for: pygeoapi/provider/mvt_tippecanoe.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def get_tiles_from_url(self, layer=None, tileset=None,
184184
try:
185185
with requests.Session() as session:
186186
session.get(base_url)
187-
resp = session.get(f'{base_url}/{layer}/{z}/{y}/{x}{extension}') # noqa
187+
resp = session.get(f'{base_url}/{layer}/{z}/{x}/{y}{extension}') # noqa
188188

189189
if resp.status_code == 404:
190190
if (self.is_in_limits(TileMatrixSetEnum.WEBMERCATORQUAD.value, z, x, y)): # noqa
@@ -215,7 +215,7 @@ def get_tiles_from_disk(self, layer=None, tileset=None,
215215
"""
216216

217217
try:
218-
service_url_path = self.service_url.joinpath(f'{z}/{y}/{x}.{format_}') # noqa
218+
service_url_path = self.service_url.joinpath(f'{z}/{x}/{y}.{format_}') # noqa
219219
with open(service_url_path, mode='rb') as tile:
220220
return tile.read()
221221
except FileNotFoundError as err:

Diff for: pygeoapi/templates/collections/tiles/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ <h3>Tiles</h3>
100100
));
101101
{% elif data['tile_type'] == 'vector' %}
102102
url = url
103-
.replace("tileRow", "x")
104-
.replace("tileCol", "y");
103+
.replace("tileRow", "y")
104+
.replace("tileCol", "x");
105105
var VectorTileOptions = {
106106
interactive: true,
107107
rendererFactory: L.canvas.tile,

0 commit comments

Comments
 (0)