[OSM-dev] Good explanation of latitude-to-pixel conversion?
ojwlists at googlemail.com
Sat May 17 17:24:31 BST 2008
This set of functions might be more readable
and covers stuff like finding the edges of tiles, as well as just the
On Sat, May 17, 2008 at 4:11 PM, David MENTRE <dmentre at linux-france.org> wrote:
>> On Sat, May 17, 2008 at 2:29 PM, Nick Whitelegg
>> <Nick.Whitelegg at solent.ac.uk> wrote:
>>> I have the code to do this, but I guess I'm one of these people that like
>>> to understand what's actually going on :-)
> You are not the only one. I followed the same path (pun intended) a few
> weeks ago.
>>> The specific formula I mean (represented in Java) is:
>>> public static int latToY(double lat,int zoom)
>>> double f = Math.sin((Math.PI/180)*lat);
>>> int y = (int)Math.round
>>> (Math.pow(2,zoom+7) + 0.5*Math.log((1+f)/(1-f)) *
>>> return y;
> The code you give is to translate a (lat, zoom) to x coordinate, you
> have a more direct formula applying the Mercator projection to the lat
> In the above page, it helps to know that r_minor and r_major are Earth
> Equatorial and Polar radii.
> The original post helps to understand why taking into account the
> variation of radius was necessary:
> "OJ W" <ojwlists at googlemail.com> writes:
>> e.g. wikipedia will tell you all about how mercator itself works:
> This is a very useful page.
>> and for the tiles, alll you do is say "select the bit of
>> mercator-projected map between two arbitrary latitudes (which happen
>> to be numerically special but you don't need to care about that) and
>> call that range the limits of your map in Y.
>> you then just start dividing Y into halves and quarters etc. to do the tiles.
> In fact, I found explanation in
> http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames sufficient
> after thinking a little about it.
> I hope it helps,
>  http://en.wikipedia.org/wiki/Earth
> GPG/PGP key: A3AD7A2A David MENTRE <dmentre at linux-france.org>
> 5996 CC46 4612 9CA4 3562 D7AC 6C67 9E96 A3AD 7A2A
More information about the dev