NAME
URI::geo - URI scheme for geo Identifiers
SYNOPSIS
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 );
DESCRIPTION
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.
SUBROUTINES/METHODS
new
Create a new URI::geo. The arguments should be either
latitude, longitude and optionally altitude
a reference to an array containing lat, lon, alt
a reference to a hash with suitably named keys or
a reference to an object with suitably named accessors
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' );
location
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
.
latitude
Get or set the latitude of this geo URI.
longitude
Get or set the longitude of this geo URI.
altitude
Get or set the altitude of this geo URI. To delete the altitude set it to undef
.
crs
Get or set the Coordinate Reference System of this geo URI. To delete the CRS set it to undef
.
uncertainty
Get or set the uncertainty of this geo URI. To delete the uncertainty set it to undef
.
field
CONFIGURATION AND ENVIRONMENT
URI::geo requires no configuration files or environment variables.
DEPENDENCIES
DIAGNOSTICS
Too many arguments
-
The new method can only accept three parameters; latitude, longitude and altitude.
Don't know how to convert point
-
The new method doesn't know how to convert the supplied parameters into a URI::geo object.
Need lat, lon or lat, lon, alt
-
The new method needs two (latitude and longitude) or three (latitude, longitude and altitude) parameters in a list. Any less or more than this is an error.
No such field: %s
-
This field is not a known field for the URI::geo object.
Badly formed geo uri
-
The URI cannot be parsed as a URI
Badly formed geo uri
-
The URI cannot be parsed as a URI
Latitude out of range
-
Latitude may only be from -90 to +90
Longitude out of range
-
Longitude may only be from -180 to +180
INCOMPATIBILITIES
None reported.
BUGS AND LIMITATIONS
To report a bug, or view the current list of bugs, please visit https://github.com/libwww-perl/URI/issues
AUTHOR
Andy Armstrong <andy@hexten.net>
LICENSE AND COPYRIGHT
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.