<div dir="ltr">Hi Jamie,<div><br></div><div>I've never used this personally but I previously came across this on the OpenStreetMap Wiki:</div><div><pre style="font-family:monospace,Courier;padding:1em;border:1px dashed rgb(47,111,171);color:rgb(0,0,0);background-color:rgb(249,249,249);line-height:1.3em;font-size:1.2em">
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 / π</pre></div><div><br></div><div>The full page is here:</div><div><br></div><div><a href="http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames">http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames</a><br>
</div><div><br></div><div>I hope this helps!</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 11, 2014 at 2:32 PM, Jamie Morken <span dir="ltr"><<a href="mailto:jmorken@shaw.ca" target="_blank">jmorken@shaw.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am making some code to view offline tile folders, and need to find the correct<br>
folder and file using the GPS coordinates.  I "reverse engineered" an offline tile<br>
format, and noticed that the folders are determined by longitude and the files in each<br>
folder are determined by latitude.  I came up with this formula for longitude to find<br>
which folder to access given a longitude from GPS:<br>
<br>
correctLongitudeFolderToUse = (inputLongitude+180)*((2^currentScale)/360)<br>
<br>
so if the input longitude is say -120 degrees (west coast) then at a scale<br>
of 16 the formula works out to:<br>
<br>
correctLongitudeFolderToUse =(-120+180)*((2^16)/360)<br>
<br>
correctLongitudeFolderToUse = 10922.66<br>
<br>
This works properly, if I go to the folder with name 10922 the longitude is correct.<br>
<br>
I have an error for finding which file to access for latitude though.  I use this<br>
formula for latitude:<br>
<br>
correctLatitudeFileToUse = (-inputLatitude+90)*((2^currentScale)/180)<br>
<br>
so if the input latitude is 40 and the scale is again 16 this is the result:<br>
<br>
correctLatitudeFileToUse = (-40+90)*((65536)/180)<br>
<br>
correctLongitudeFolderToUse = 18204.44<br>
<br>
so in this case it would say the file name should be 18204.jpg in the folder 10922,<br>
however the latitude is incorrect.  I think it is a scaling error since for the two poles<br>
and equator the formula works correctly, and also for 30degrees latitude I think it may<br>
work correctly.  I think I need a sin or cos term in the formula but not sure.<br>
<br>
Any ideas on how to fix the latitude formula?<br>
<br>
cheers,<br>
Jamie<br>
<br>
<br>
_______________________________________________<br>
GraphHopper mailing list<br>
<a href="mailto:GraphHopper@openstreetmap.org">GraphHopper@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/graphhopper" target="_blank">https://lists.openstreetmap.org/listinfo/graphhopper</a><br>
</blockquote></div><br></div>