[OSM-talk] calculating lon/lat bounds from tilename

Jon Burgess jburgess777 at googlemail.com
Fri Jun 22 19:11:01 BST 2007


On Fri, 2007-06-22 at 19:51 +0200, Ralf Zimmermann wrote:
> Daniel Would wrote:
>  > Hi, not sure if this is the right place to post this question, so
>  > forgive me if it's off topic...
>  > I've been working on a script that takes a lon/lat position, zoom level
>  > and a size of grid to capture.
>  > and it retrieves all the tiles in a grid of your size centered around
>  > the lon/lat provided.
>  > so I might say zoom=15, gridsize=4 and it will get me a 4x4 grid of
>  > tiles at that zoom level around my lon/lat.
>  > Now I'm doing this to use with TrekBuddy which is very cool. And I want
>  > a script that will build me the Atlas inputs it requires using the
>  > openstreetmap images.
>  > Everything works great.. however I need to generate a file that
>  > specifies the lon/lat of the top left corner and bottom right corner of
>  > my grid. I have no idea how to do that (I stole the calculation for
>  > lon/lat -> mercator tile from the osm page that contained a perl
>  > example.
> 
> 
> I was following the same idea a few weeks ago.
> The issue that stopped me from following this path is the following:
> 
> If you download tiles from OSM, you will find that the scale in 
> North/South direction of the tiles will change with different y values 
> of the tiles. This is a specialty of the like-Google way of doing tiles.
> 
>  > ... however I need to generate a file that
>  > specifies the lon/lat of the top left corner and bottom right corner
>  > of my grid.
> 
> I think you have the same misunderstanding that I had:
> 
> If you download lots of OSM tiles and re-assemble them as a nice 
> picture, then you would need the longitude of the left and right side of 
> the assembled picture. This is according to your idea.
> 
> But for North/South, you would need the upper/lower latitude of every 
> row of tiles that you are using - because the scale changes.
> So the problem is a bit more complex than you might have thought.
> 
> In order to have large areas of OSM data geo-referenced with just 
> geo-referencing the upper-left and lower-right corner (4 values), I am 
> currently using plain OSM data and then rendering it via osmarender. 
> That way, I am bringing the maps onto my Palm PDA, using Pathaway for 
> using the maps.
> 

Would the proper solution be to provide OSM tiles in a latlong
projection? Mapnik is certainly capable of rendering these. 

If there was demand for this then I suppose we could render tiles in
latlong and make them available via a different URL (provided we can
derive another simple tiling scheme).

	Jon






More information about the talk mailing list