staticlatitude-longitudeopenstreetmapbounding

OpenStreetMap get latitude and longitude of a generated static map tile


I try to create an open street maps application, which uses self generated static maps. Such a map is composed by up to four tiles, depending on the users position on the base tile.

An example: there is a map (red), generated by four tiles (black): http://s15.postimg.org/jtdhx65gr/tiles.jpg

I have the longitude and latitude of the generated maps center position and I know the horizontal and vertical offset in pixels from the center to every edge. The generated maps size is 256x256 pixels, which applies to each tile, it is generated by.

How can I get the bounding latitudes and longitudes of a generated map? (latitude and longitude of each edge of the red, generated map)

That's what I have created so far to get an edges latitude and longitude: http://pastebin.com/wKyd1tXG


Solution

  • The OSM wiki has a page about slippy map tilenames. It explains how to calculate the tile name for given coordinates and also the reverse operation. It even includes a table containing the resolution (meters per pixel) for different zoom levels. And there is another wiki page about zoom levels containing a meters per pixel formula.