[OSM-dev] Calculate Latitude coordinate in map
Jon Burgess
jburgess777 at googlemail.com
Sun Jan 6 16:00:40 GMT 2008
On Sun, 2008-01-06 at 16:39 +0100, al_ku at web.de wrote:
> Hello guys,
>
>
>
> I just started to work a little with your map and wanted to write a
> small test application to see it in action (I wanted to used it later
> for easier map editing on OSM).
>
>
>
> Now I have a little problem. Your map is a rectangular with the same
> width as height. So for the Longitude (width) it’s pretty easy for me
> to convert the pixel-coordinates to actual geographical coordinates:
>
>
>
> (x/width)*360.0f-180.0f
>
>
>
> This gives me the coordinate of x (my mouse pointer on the map).
>
>
>
> I tried to do the same for the Latitude (height):
>
>
>
> ((y/height)*180.0f-90.0f)*-1.0f
>
>
>
> Well, it doesn’t seem to give me the correct results. This is probably
> because the earth is an ellipse and you display it as a rect. So the
> distance between each degree Latitude decrease in your rectangular
> map, but I absolutely have no idea of how to correctly calculate it.
>
> I’ve spent some time searching and the best I’ve come up so far are
> these formulars:
>
>
>
> http://en.wikipedia.org/wiki/Latitude#Common_.22latitude.22
>
>
>
> But there are so many of them and I don’t know which to use (if any of
> these is even the right one). I tested some but nothing good came out
> of it L
>
>
>
>
>
> Please guys, can someone put me in the right direction?
The overall tile layout and projection is described here
http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames
also this email thread:
http://lists.openstreetmap.org/pipermail/dev/2007-November/007969.html
Jon
More information about the dev
mailing list