[Openstreetmap] Converting x,y to latitude,longitude and back

SteveC steve at asklater.com
Wed Feb 1 01:47:12 GMT 2006


* @ 31/01/06 11:56:17 PM nick at hogweed.org wrote:
> Hello everyone,
> 
> As part of the new version of Freemap using the slippy map I would like to get 
> hold of some code which converts between x,y pixel coordinates and lat/long 
> and vice/versa, where the map is defined by bottom left lat,long, scale and 
> pixel width/height.
> 
> Does anyone know any good open source code that will do that? Any language 
> will do, I will convert it to JavaScript. Tried to fathom out what was going 
> on in the slippy map code but it's hard to locate any code which does the 
> conversion.

the applet, Tile.java has code to get to and from the reference frames.

> A related point - what scales (in pixels per lat/lon unit) do the zoom levels 
> in the slippy map translate to?

off the top of my head... at zoom 1 (I think, the lowest level) the
world is 512 pixels wide (two tiles). Each zoom doubles that IIRC. So
you have that simple degrees / pixel ration from there.

have fun,

SteveC steve at asklater.com http://www.asklater.com/steve/




More information about the talk mailing list