The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


URI::geo - The geo URI scheme.


This document describes URI::geo version 0.05


  use URI;

  # GeoURI 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 );



  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

  • 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 maximise the likelyhood 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 (eg 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 GeoURI 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 of this geo URI. To delete the altitude set it to undef.




Please report any bugs or feature requests to, or through the web interface at


Andy Armstrong <>


Copyright (c) 2009, Andy Armstrong <>.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.