Geo::Gpx::Point - Class to store and edit GPX Waypoints
use Geo::Gpx::Point;
Geo::Gpx::Point provides a data structure for GPX points and provides accessor methods to read and edit point data.
Create and return a new point as per the fields provided, which can be any of lat lon ele time magvar geoidheight name cmt desc src link sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid. Most expect numberial values except: name, cmt, desc, src, sym, type, fix that can contain strings.
lat lon ele time magvar geoidheight name cmt desc src link sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid
name
cmt
desc
src
sym
type
fix
lat and lon are required, all others keys are optional.
lat
lon
%fields = ( lat => 47.0871, lon => 70.9318, ele => 808.000, name => 'MSA', desc => 'A nice view of the River at the top'); $pt = Geo::Gpx::Point->new( %fields );
The link field is expected to be structured as:
link
link => { href => 'http://hexten.net/', text => 'Hexten', type => 'Blah' },
Takes latitude and longitude decimal values or strings and returns a Geo::Gpx::Point object. The latitude should always appear before the longitude and both can be in formatted form (i.e Degrees, Minutes, Seconds or "dms") and the constructor will attempt to convert them to decimals. Any other %fields are optional.
Geo::Gpx::Point
$pt = Geo::Gpx::Point->flex_coordinates( '47.0871', '-70.9318', desc => 'Mont Ste-Anne' );
If a string reference is passed as the first argument (instead of $lat and $lon), the constructor will attempt to parse it as coordinates (decimal-form only). For instance you can simply call flex_coordinates( '47.0871 -70.9318' ) with or without a comma along with optional fields.
flex_coordinates( '47.0871 -70.9318' )
$str_ref = \'47.0871 -70.9318'; $pt = Geo::Gpx::Point->flex_coordinates($str_ref, desc => 'Mont Ste-Anne' );
Returns a deep copy of the Geo::Gpx::Point.
$clone = $ggp->clone;
Methods with respect to fields of the object can be autoloaded.
Possible fields consist of those listed and accepted by new(), specifically: lat, lon, ele, time, magvar, geoidheight, name, cmt, desc, src, link, sym, type, fix, sat, hdop, vdop, pdop, ageofdgpsdata, and dgpsid.
new()
Some fields may contain a value of 0. It is safer to check if a field is defined with if (defined $point->ele) rather than if ($point->ele).
if (defined $point->ele)
if ($point->ele)
Caution should be used if setting a $value as no checks are performed to ensure the value is appropriate or in the proper format.
Returns the distance in meters from the Geo::Gpx::Point $pt or from the coordinates provided by $lat and $lon. The distance is calculated as the straight-line distance, ignoring any topography. $pt must be the first argument if specified.
%options may be any of the following key/value pairs (all optional):
dec => $decimals: how many digits to return after the decimal point. Defaults to 6 but this will change to 1 or 2 in the future. km => boole: scale the return value to kilometers rather than meters (default is false). rad => $radius: the earth's radius in kilometers (see below).
dec => $decimals
km => boole
rad => $radius
$radius should rarely be specified unless the user knows what they are doing. The default is the global average of 6371 kilometers and any value outside the 6357 to 6378 range will be ignored. This implies that a given value would affect the returned distance by at most 0.16 percent versus the global average.
Returns a point as a Geo::Calc object. (Requires that the Geo::Calc module be installed.)
Returns a point as a basic Geo::TCX::Trackpoint object, i.e. a point with only Position information. (Requires that the Geo::TCX module be installed.)
Return a DateTime object corresponding to the time of the point. The time_zone of the object will be 'UTC'. Specify time_zone => $tz to set a different one.
time_zone
'UTC'
time_zone => $tz
For debugging purposes mostly. Summarizes the fields of point by printing to screen. Returns nothing.
Returns a string with the coordinates e.g. lat="47.0871" lon="-70.9318".
lat="47.0871" lon="-70.9318"
as_string() is called when using a Geo::Gpx::Point instance as a string.
as_string()
Coming soon.
Patrick Joly <patjol@cpan.org>.
<patjol@cpan.org>
1.10
perl(1).
To install Geo::Gpx, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::Gpx
CPAN shell
perl -MCPAN -e shell install Geo::Gpx
For more information on module installation, please visit the detailed CPAN module installation guide.