0

I have spent a lot of time trying to figure out the correct WMTS call to make to my GeoServer to get vector tiles (from my Leaflet web app), which I eventually found from the GetCapabilities: http://localhost:8000/geoserver/gwc/service/wmts?REQUEST=getcapabilities, where I was able to Ctrl+F to find ".pbf" which led me to this line:

<ResourceURL format="application/json" resourceType="TileJSON" template="localhost:8000/geoserver/gwc/service/wmts/rest/city:roads/{style}/tilejson/pbf?format=application/json"/>

Following the "template" value given here, it gave me 2 new URLs: http://localhost:8000/geoserver/gwc/service/wmts/rest/city:roads/{style}/EPSG:4326/EPSG:4326:{z}/{y}/{x}?format=application/vnd.mapbox-vector-tile, while the other URL just had EPSG:900913 instead of 4326.

My process was similar for the TMS server to find something with the format, but then I saw that the additional /{z}/{x}/{-y}.pbf values needed to be added from this post online:

http://localhost:8000/geoserver/gwc/service/tms/1.0.0/city:roads@EPSG:900913@pbf/{z}/{x}/{-y}.pbf

How are you properly supposed to find the URLs to WMTS and TMS services usually? I feel like I just stumbled upon this. New to this area.

2 Answers 2

1

For any OGC service you are correct to look in the getCapabilites response, it probably also helps to read the standards if you need to know more. A well designed client however should "know" all this and work it out for you.

0

From https://docs.mapbox.com/ios/maps/api/6.4.1/tile-url-templates.html :

{x} The index of the tile along the map’s x axis according to Spherical Mercator projection. If the value is 0, the tile’s left edge corresponds to the 180th meridian west. If the value is 2z−1, the tile’s right edge corresponds to the 180th meridian east.

{y} The index of the tile along the map’s y axis according to Spherical Mercator projection. If the value is 0, the tile’s tile edge corresponds to arctan(sinh(π)), or approximately 85.0511 degrees north. If the value is 2z−1, the tile’s bottom edge corresponds to −arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is inverted if the options parameter contains MGLTileSourceOptionTileCoordinateSystem with a value of MGLTileCoordinateSystemTMS.

So if you have langitude and longitude you can calculate x and y as follows (python):

x = int((lon + 180) / 360 * (2 ** z))
y = int((1 - (math.log(math.tan(math.radians(lan)) + 1 / math.cos(math.radians(lan)))) / math.pi) / 2 * (2 ** z))

while z is you zoom level

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.