Geo::OSM::Tiles(3pm)

πŸ“¦
version 0.04 Β· 2 versions
  • 0.04 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.04 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 18 for 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 (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