URL:
https://docs.microsoft.com/en-us/azure/azure-maps/zoom-levels-and-tile-grid
Some values for "Meters/tile side" column at "Zoom levels" table are incorrect and can lead to a wrong tile when used to calculate tile position (probably, up to zoom level 17).
This error showed up when I was calculating the tile for position:
Latitude: 23° 35' 39'' S, Longitude: 46° 40' 51'' W
In meters from origin => (22741541.295482, 14841021.746317)
For zoom level 13, the "tile side" value from table is: 4889.6, so:
trunc((22741541.295482, 14841021.746317) ./ 4889.6) = (4651, 3035)
Tile (4651, 3035) is about 15km far away from the position queryied.
This value should be 4891.96981:
trunc((22741541.295482, 14841021.746317) ./ 4891.9698) = (4648, 3033)
And (4648, 3033) is the correct tile.
The values for this column are easely calculated through (pseudo-code):
// Earth perimeter
perimeter = 6378137.0 * 2.0 * PI
// zoom levels from 0 to 24
for i in 0:24
tile_side[i] = perimeter / (2.0^i)
end
And the differences are listed below correct (calculated) X incorrect (from docs):
Zoom level | Meters/tile side (correct) | Meters/tile side (incorrect!)
-----------|----------------------------|-----------------------------
0 |40075016.685578 |40075008
1 |20037508.342789 |20037504
2 |10018754.171395 |10018764.8
3 |5009377.085697 |5009382.4
4 |2504688.542849 |2504678.4
5 |1252344.271424 |1252352
6 |626172.135712 |626176
7 |313086.067856 |313088
8 |156543.033928 |156544
9 |78271.516964 |78259.2
10 |39135.758482 |39142.4
11 |19567.879241 |19558.4
12 |9783.939621 |9779.2
13 |4891.969810 |4889.6
14 |2445.984905 |2457.6
15 |1222.992453 |1228.8
16 |611.496226 |614.4
17 |305.748113 |307.2
18 |152.874057 |152.8
19 |76.437028 |76.4
20 |38.218514 |38.2
21 |19.109257 |19.1
22 |9.554629 |9.55
23 |4.777314 |4.775
24 |2.388657 |2.3875
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@gomiero Thank you for your feedback . We will engage the content author to have this reviewed with engineering and update as necessary.
@jinzh-azureiot Could you please take a look at this issue and help review the content on the document ?
This is an article copied from our data provider TomTom https://developer.tomtom.com/maps-api/maps-api-documentation/zoom-levels-and-tile-grid. I'll follow up with my colleague who has been working with TomTom as well as our contact in TomTom regarding this feedback
It's not advisable to use that table to do calculations for distances at zoom levels. That table is based on latitude being 0, but your latitude value is 23° 35' 39'' S. The Mercator projection stretches the pixel distance horizontally as latitude increases/decreases from 0. All the code in that document is correct. You should be using the PositionToGlobalPixel and GlobalPixelToTileXY calculations to get the tile for a specific coordinate.
Yes, I agree about the stretch of the pixels on a Mercator projection, and the code at that document is correct.
My point, at the time when I opened this issue, was only that the table's values were incorrect.
And sure they were incorrect, since the table was fixed up with the values I mentioned on this issue, at commit: 53b76605af057a362436ce932b75001058559bb6
Even at TomTom's page, they were fixed the same way, as well.
Thank you very much for your reply and you may close this issue if you wish, since the values are ok now.