Geo::OSM::Tiles(3pm)
β¨ Geo::OSM::Tiles β¨
okay so bestie, welcome to Geo::OSM::Tiles β it's a Perl module (you'll see it filed under the 3pm manual section, "User Contributed Perl Documentation", which is exactly as glamorous as it sounds π
) and it does one thing and does it gorgeously: it turns geographic coordinates into OpenStreetMap tile numbers. that's it. that's the whole vibe. slay.
πΈ NAME πΈ
Geo::OSM::Tiles β Calculate tile numbers for OpenStreetMap πΊοΈβ¨
π SYNOPSIS π
okay so here's the whole thing in action, look at her go:
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";
literally four function calls and you've got a URL. main character energy fr fr π
π¦ DESCRIPTION π¦
So this module hands you functions for calculating the path to a map tile at OpenStreetMap from geographic coordinates. The path of a tile at OSM looks like "$zoom/$tilex/$tiley.png" β that's the shape of it, no cap. The numbering scheme is documented over on the OSM wiki, link's down in SEE ALSO if you wanna go read the lore π
π 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
that's the rules bestie, we don't make them, we just respect them π
π 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
same deal, different axis. the poles just aren't invited to this party π§
π 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 β so like, ask your server, not me:
- the maximum zoom for the Osmarender layer is
17 - it is
18for the Mapnik layer
ngl this is the part where people get humbled. don't go asking for zoom 22 and then act surprised π
π 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. so it's not gonna yell at you, it's gonna fix you. glow-up service π«Ά
π 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. same energy, other axis π
π SEE ALSO π
go read it, it's giving educational β¨
π AUTHOR π
Rolf Krahl <rotkraut@cpan.org>
π COPYRIGHT AND LICENCE π
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.
and that's the whole page, bestie π this little gem was served up by perl v5.36.0 on 2022-11-19 under the name Geo::OSM::Tiles(3pm) β go forth and tile, you absolute icon π
πΈπ¦
π¦ where this page comes from
- debian bookworm: libgeo-osm-tiles-perl 0.04-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgeo-osm-tiles-perl 0.04-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgeo-osm-tiles-perl 0.04-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgeo-osm-tiles-perl 0.04-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgeo-osm-tiles-perl 0.04-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms