Geo::OSM::Tiles - Calculate tile numbers for OpenStreetMap
use Geo::OSM::Tiles qw( :all ); $zoom = 13; $lat = 49.60055; $lon = 11.01296; $tilex = lon2tilex($lon, $zoom); $tiley = lat2tiley($lat, $zoom); $path = tile2path($tilex, $tiley, $zoom); $tileurl = "http://tile.openstreetmap.org/$path";
This module provides functions for calculating the path to a map tile at OpenStreetMap out of geographic coordinates. The path of a tile at OSM has the form $zoom/$tilex/$tiley.png. The numbering scheme is documented in the OSM wiki, see the link below.
$zoom/$tilex/$tiley.png
lon2tilex($lon, $zoom)
Returns $tilex for the tile at longitude $lon and zoom level $zoom. The longitude must be in the range -180.0 <= $lon < 180.0. The zoom level must be a non-negative integer.
$tilex
$lon
$zoom
-180.0 <= $lon < 180.0
lat2tiley($lat, $zoom)
Returns $tiley for the tile at latitude $lat and zoom level $zoom. The latitude must be in the range -85.0511 <= $lat <= 85.0511. The zoom level must be a non-negative integer.
$tiley
$lat
-85.0511 <= $lat <= 85.0511
tile2path($tilex, $tiley, $zoom)
Composes the path to the tile at $tilex, $tiley, and $zoom at the OSM server. $tilex and $tiley must be integers in the range 0..2**$zoom-1. The supported range of zoom levels depends on the tile server. The maximum zoom for the Osmarender layer is 17, it is 18 for the Mapnik layer.
0..2**$zoom-1
checklonrange($lonmin, $lonmax)
Checks whether $lonmin and $lonmax are within the allowed range of the longitude argument to lon2tilex. Returns ($lonmin, $lonmax) unchanged if they are ok or corrected values if not.
$lonmin
$lonmax
lon2tilex
($lonmin, $lonmax)
checklatrange($latmin, $latmax)
Checks whether $latmin and $latmax are within the allowed range of the latitude argument to lat2tiley. Returns ($latmin, $latmax) unchanged if they are ok or corrected values if not.
$latmin
$latmax
lat2tiley
($latmin, $latmax)
http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
Rolf Krahl <rotkraut@cpan.org>
Copyright (C) 2008-2010 by Rolf Krahl
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Geo::OSM::Tiles, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::OSM::Tiles
CPAN shell
perl -MCPAN -e shell install Geo::OSM::Tiles
For more information on module installation, please visit the detailed CPAN module installation guide.