How are the WMTS server requests for ESPG25832 projection created?

Hello there,

I have a question regarding the creation of the WMTS server requests.

From this german governmental-website: I can get the address for their WMTS server: I can successfully integrate it into josm as an image layer (wmts: and it gets displayed correctly.

I can watch the server request made by josm in the terminal, which is something like:

2019-09-26 18:54:31.651 INFO: GET -> HTTP_1 200 (13.3 kB)

You can view this tile @

Now I want to know how these requests are created, because for another project(which uses this library: I need the string for the request in the format:{z}/{y}/{x}

If I let the library figure out the y and x, I’m getting trash in rviz(which is the visualization program):

I think this is because the images/tiles are in EPSG25832-projection method, but the library thinks in Mercator-projection. And I need the images to be in EPSG25832, because of other data which gets displayed.

If you look at the WMTSCapabilities.xml of the map-server you can see there are images avaible up to zoom level 16 and other info:

I had a look at the methods, which the library seems to use to calculate the x and y:…2Flat._to_tile_numbers
which is something like this:

// in Coordinates.h:
int const n = 1 << zoom;
double x = n * ((coord.lon + 180) / 360.0);
double y = n * (1 - (std::log(std::tan(lat_rad) + 1 / std::cos(lat_rad)) / M_PI)) / 2;

But I think I need to do something like this, because of the EPSG25832/UTM projection:

I already had a look at to see how openstreetmap does it, but I didn’t find anything.

So all in all: How to calculate the x,y-tile-coordinates from lat,long if given images in EPSG25832-projection method (which josm/osm does succesfully)?