It suddenly dawned on me that a slippy coordinate should just be two ints x and y and an int zoom.
This can be done in such a way that at zoom level one the MSB is the tile index, and at zoom level 2 the two most significant bits are the tile index. The rest of the integer is then the tile offset.
This means that we can go from mercator position to slippycoordinates by doing slippy.x = mercator.x * INT_MAX. It also means that zooming in does not change the x and y.
But mostly, it will make the calculations a lot faster.
It suddenly dawned on me that a slippy coordinate should just be two
int
s x and y and anint
zoom. This can be done in such a way that at zoom level one the MSB is the tile index, and at zoom level 2 the two most significant bits are the tile index. The rest of the integer is then the tile offset. This means that we can go from mercator position to slippycoordinates by doingslippy.x = mercator.x * INT_MAX
. It also means that zooming in does not change thex
andy
. But mostly, it will make the calculations a lot faster.