[OSM-talk] find corners of exported maps

Olav Kvittem Olav.Kvittem at uninett.no
Thu Dec 4 15:12:25 GMT 2008


I wonder how I compute the coordinates of the corners of the images 
received from the web export function
for an osmarender image. I specify geodetic center position(degrees), 
zoom level and image size and get at nice map image.
The projection is of cource Mercator and I can linearly map mercator 
coordinates onto the image.
But how do I know the coordinates of the corners of the returned image ?

The url I use is :

The tile-size for each level is 256x256 so given the zoom-level I could 
compute the pixel density from the
world map size in mercator projection.
That works for east direction which is linear, but for the northern 
direction the projection is nonlinear and
I am not sure if the geodetic center that I specify is at the center of 
the returned image or not.


perl code for computing the pixel density

      # $ol = east length of map section
       # pix,$piy = pixel size of image
      # find zoom level
      my $dnmax=85.0511; # max for osmarender
      my ($momax, $mnmax)=mercate($dnmax, 180);             my 
$zlevel=int( log( 2*$momax / $ol ) / log(2) + 1);  # osm zoom

      # find real size of map
      my $ompp=2*$momax/(2**$zlevel)/256; # east meters per pixel for 
this level
      my $nmpp=2*$mnmax/(2**$zlevel)/256; # north meters per pixel for 
this level

More information about the talk mailing list