URI::geo(3pm) | User Contributed Perl Documentation | URI::geo(3pm) |
URI::geo - URI scheme for geo Identifiers
use URI; # Geo URI from textual uri my $guri = URI->new( 'geo:54.786989,-2.344214' ); # From coordinates my $guri = URI::geo->new( 54.786989, -2.344214 ); # Decode my ( $lat, $lon, $alt ) = $guri->location; my $latitude = $guri->latitude; # Update $guri->location( 55, -1 ); $guri->longitude( -43.23 );
From <http://geouri.org/>:
More and more protocols and data formats are being extended by methods to add geographic information. However, all of those options are tied to that specific protocol or data format. A dedicated Uniform Resource Identifier (URI) scheme for geographic locations would be independent from any protocol, usable by any software/data format that can handle generich URIs. Like a "mailto:" URI launches your favourite mail application today, a "geo:" URI could soon launch your favourite mapping service, or queue that location for a navigation device.
Create a new URI::geo. The arguments should be either
To maximize the likelihood that you can pass in some object that represents a geographical location and have URI::geo do the right thing we try a number of different accessor names.
If the object has a "latlong" method (e.g. Geo::Point) we'll use that. If there's a "location" method we call that. Otherwise we look for accessors called "lat", "latitude", "lon", "long", "longitude", "ele", "alt", "elevation" or "altitude" and use them.
Often if you have an object or hash reference that represents a point you can pass it directly to "new"; so for example this will work:
use URI::geo; use Geo::Point; my $pt = Geo::Point->latlong( 48.208333, 16.372778 ); my $guri = URI::geo->new( $pt );
As will this:
my $guri = URI::geo->new( { lat => 55, lon => -1 } );
and this:
my $guri = URI::geo->new( 55, -1 );
Note that you can also create a new "URI::geo" by passing a Geo URI to "URI::new":
use URI; my $guri = URI->new( 'geo:55,-1' );
Get or set the location of this geo URI.
my ( $lat, $lon, $alt ) = $guri->location; $guri->location( 55.3, -3.7, 120 );
When setting the location it is possible to pass any of the argument types that can be passed to "new".
Get or set the latitude of this geo URI.
Get or set the longitude of this geo URI.
Get or set the altitude <https://en.wikipedia.org/wiki/Geo_URI_scheme#Altitude> of this geo URI. To delete the altitude set it to "undef".
Get or set the Coordinate Reference System <https://en.wikipedia.org/wiki/Geo_URI_scheme#Coordinate_reference_systems> of this geo URI. To delete the CRS set it to "undef".
Get or set the uncertainty <https://en.wikipedia.org/wiki/Geo_URI_scheme#Uncertainty> of this geo URI. To delete the uncertainty set it to "undef".
URI::geo requires no configuration files or environment variables.
URI
None reported.
To report a bug, or view the current list of bugs, please visit <https://github.com/libwww-perl/URI/issues>
Andy Armstrong "<andy@hexten.net>"
Copyright (c) 2009, Andy Armstrong "<andy@hexten.net>".
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
2024-02-14 | perl v5.38.2 |