[GraphHopper] finding correct offline tile folder to use
Paulo Tubbert-Semiao
paulotubbert at gmail.com
Tue Feb 11 15:11:57 UTC 2014
Hi Jamie,
I've never used this personally but I previously came across this on the
OpenStreetMap Wiki:
n = 2 ^ zoom
lon_deg = xtile / n * 360.0 - 180.0
lat_rad = arctan(sinh(π * (1 - 2 * ytile / n)))
lat_deg = lat_rad * 180.0 / π
The full page is here:
http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
I hope this helps!
On Tue, Feb 11, 2014 at 2:32 PM, Jamie Morken <jmorken at shaw.ca> wrote:
> Hi,
>
> I am making some code to view offline tile folders, and need to find the
> correct
> folder and file using the GPS coordinates. I "reverse engineered" an
> offline tile
> format, and noticed that the folders are determined by longitude and the
> files in each
> folder are determined by latitude. I came up with this formula for
> longitude to find
> which folder to access given a longitude from GPS:
>
> correctLongitudeFolderToUse = (inputLongitude+180)*((2^currentScale)/360)
>
> so if the input longitude is say -120 degrees (west coast) then at a scale
> of 16 the formula works out to:
>
> correctLongitudeFolderToUse =(-120+180)*((2^16)/360)
>
> correctLongitudeFolderToUse = 10922.66
>
> This works properly, if I go to the folder with name 10922 the longitude
> is correct.
>
> I have an error for finding which file to access for latitude though. I
> use this
> formula for latitude:
>
> correctLatitudeFileToUse = (-inputLatitude+90)*((2^currentScale)/180)
>
> so if the input latitude is 40 and the scale is again 16 this is the
> result:
>
> correctLatitudeFileToUse = (-40+90)*((65536)/180)
>
> correctLongitudeFolderToUse = 18204.44
>
> so in this case it would say the file name should be 18204.jpg in the
> folder 10922,
> however the latitude is incorrect. I think it is a scaling error since
> for the two poles
> and equator the formula works correctly, and also for 30degrees latitude I
> think it may
> work correctly. I think I need a sin or cos term in the formula but not
> sure.
>
> Any ideas on how to fix the latitude formula?
>
> cheers,
> Jamie
>
>
> _______________________________________________
> GraphHopper mailing list
> GraphHopper at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/graphhopper
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20140211/c9261aaa/attachment.html>
More information about the GraphHopper
mailing list