unsanded / harbour-mapp

Slippy map component/app for SailfishOS
GNU General Public License v3.0
8 stars 0 forks source link

Refactor SlippyCoordinates #5

Open unsanded opened 8 years ago

unsanded commented 8 years ago

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.