I am using mapproxy to serve slippy map tiles. I noticed that there are several URLs which return the same tile.
Example I
Below is slovakia.yaml
(based on this thread). Local service can be launched via mapproxy-util serve-develop slovakia.yaml
.
services:
tms:
use_grid_names: true
origin: 'nw'
layers:
- name: slovakia
title: Slovakia example
sources: [slovakia_cache]
caches:
slovakia_cache:
grids: [webmercator]
sources: [slovakia_wms]
sources:
slovakia_wms:
type: wms
req:
url: https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?
layers: 1
grids:
webmercator:
base: GLOBAL_WEBMERCATOR
globals:
After the service is running, both
http://localhost:8080/tiles/slovakia/webmercator/8/140/88.png
and
http://localhost:8080/tms/1.0.0/slovakia/webmercator/7/140/167.png
return the same tile:
Example II
Below is italy.yaml
(based on this thread). Local service can be launched via mapproxy-util serve-develop italy.yaml
.
services:
tms:
use_grid_names: true
origin: 'nw'
layers:
- name: italyparcels
title: italyparcels
sources: [ItalyCache]
caches:
ItalyCache:
grids: [webmercator]
sources: [ItalyWMS]
cache:
type: file
directory: cached_tms
directory_layout: tms
sources:
ItalyWMS:
type: wms
req:
url: https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?language=ita&
layers: CP.CadastralParcel,strade,vestizioni,province,codice_plla,fabbricati,CP.CadastralZoning,acque,simbolo_graffa,copyright
supported_srs: ['EPSG:25832']
grids:
webmercator:
base: GLOBAL_WEBMERCATOR
globals:
Both
http://localhost:8080/tiles/italyparcels/webmercator/6/34/23.png
and
http://localhost:8080/tms/1.0.0/italyparcels/webmercator/5/34/40.png
return the same tile:
I can observe that the y coordinates of the 2 URLs in the Slovak example add up to 255 (88+167=255). 2^8=256, and 8 is the zoom level in the first Slovak URL.
I can observe that the y coordinates of the 2 URLs in the Italian example add up to 63 (23+40=63). 2^6=64, and 6 is the zoom level in the first Italian URL.
I am aware that the y axis of TMS points northwards, unlike standard XYZ layers (source).
Based on the above, it seems that given a mapproxy-served URL:
http://localhost:8080/tiles/some-layer/webmercator/{z}/{x}/{y}.png
we can construct another URL which returns the same tile:
http://localhost:8080/tms/1.0.0/some-layer/webmercator/{z-1}/{x}/{2**z-1-y}.png
I am looking for an explanation on why exactly the above pairs of URLs return the same tile. The more the explanation is supported by documentation, and not mere observation, the better (as reading those docs might also help getting closer to a solution to this and this question).
Why is tiles/.../{z}/{x}/{y}
equivalent to tms/1.0.0/.../{z-1}/{x}/{2**z-1-y}
?