[OSM-dev] Projection calculation

Wayne Walker wwalker at bybent.com
Tue May 13 15:32:47 BST 2008


I'm not using slippy map.  For the project I'm doing I need static
images.  I just can't sort out the math to find the veritcal position in
the tile map.  I've tried mercator projection but I'm missing something.

I've tried to follow the logic in the javascript of the slippy map, but
without comments and with short var/function names I get lost.

Does anyone have a simple formula such that:

y = ....(lat)?

I've tried things like:

k = 4.0
y = log(tan(y*Math::PI/180.0) + 1/cos(y*Math::PI/180.0))/k

Which is the mercator projection formula (substituting 1/cos for sec)
from wikipedia.

Also tried a Miller cylindrical projection as that seems much more like
what the main tile looks like.

miller=2.30341254337639                                                                                                                                     
y = 1.25 * log(tan(Math::PI/4 + 0.8 * (y*Math::PI/180.0)/2))/miller                                                                                         


No joy there either.

Any ideas?

-- 

Wayne Walker

wwalker at bybent.com                    Do you use Linux?!
http://www.bybent.com                 Get Counted!  http://counter.li.org/
Perl - http://www.perl.org/           Perl User Groups - http://www.pm.org/
Jabber:  wwalker at jabber.bybent.com   AIM:     lwwalkerbybent
IRC:     wwalker on freenode.net




More information about the dev mailing list