[OSM-dev] tile calculation

Jon Burgess jburgess777 at googlemail.com
Sun Jul 29 19:00:23 BST 2007


On Sun, 2007-07-29 at 19:12 +0200, Rob Aerts wrote:
> i try to calculate the x and y tile url in c
> 
> the example on the wiki (in perl code) looks like 
> my $xtile = int( ($lon+180)/360 *2**$z ) ;
> my $ytile = int( (1 - log(tan($lat*pi/180) + sec($lat*pi/180))/pi)/2
> *2**$z ) ; 
> 
> i can't figure out the sec formula in the $ytile 
> 
> wiki : http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames 

sec(x) = 1/cos(x)


One C example is in this code, although it might be a bit tricky to
follow:
http://trac.openstreetmap.org/browser/applications/rendering/mapnik/all_tiles/C/tilecount.c


	Jon








More information about the dev mailing list