Problems with serving vector tiles (Mapbox)

Hello everyone,

I am working on my own tile server. I have weird problems with displaying tiles in the correct order. Tiles were created using OSM data.
When I use tileserver-gl-light as a tiles server everything seems to be ok, but when I try to serve tiles by my own server they do not appear in correct order after zooming. I use the same page to render the map so I think the problem is connected with server.
The tiles look like this (Zoom 1):

I appreciate any help.
Best regards,
Marek

I don’t know the reason why but there was a need for correction y axis value before fetching data from mbtiles database.

If your tiles url looks like:

http://host:port/data/{z}/{x}/{y}

you need to recalculate y value before fetching tile data in pbf format from database:

 y = pow(2, z) - 1 - y

There is no mention about this in mbtiles specification but I found the solution in Tileserver-PHP source code:

https://github.com/maptiler/tileserver-php/blob/master/tileserver.php

https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md says

“Note that in the TMS tiling scheme, the Y axis is reversed from the “XYZ” coordinate system commonly used in the URLs to request individual tiles, so the tile commonly referred to as 11/327/791 is inserted as zoom_level 11, tile_column 327, and tile_row 1256, since 1256 is 2^11 - 1 - 791.”