GPS::Track::Point - Represent a Point of a GPS::Track
# Construct an empty point my $point = GPS::Track::Point->new(); # Construct a simple point my $point = GPS::Track::Point->new(lon => 12, lat => 13, ele => 8848); my $point = GPS::Track::Point->new( { lon => 12, lat => 13 } ); # Hashref Construction supported too my $pointsEqual = $pointA == $pointB; # Watch out for floating point troubles! my $distance = $pointA->distanceTo($pointB); my $distance = $pointaA->distanceTo( { lon => 12, lat => 13 } );
GPS::Track::Point is a thin module representing a Point as parsed by GPS::Track.
GPS::Track::Point
my $lon = $point->lon; $point = $point->lon(48);
my $lat = $point->lat; $point = $point->lat(9);
Accepts/Returns a DateTime-Object or undef (if no time information is present)
my $time = $point->time; my $point = $point->time(DateTime->now());
my $ele = $point->ele; $point = $point->ele(8848);
The speed at this point, measured in meter per second.
my $spd = $point->spd; my $point = $point->spd(10);
my $cad = $point->cad; $point = $point->cad(75);
my $bpm = $point->bpm; $point = $point->bpm(180);
Return the 2D distance to the other point in meters.
Dies if one of the points is missing lon/lat.
my $distance = $pointA->distanceTo($pointB);
Shorthand method to get the 2D distance to a known lon-lat-pair.
my $distance = $pointA->distanceTo( { lon => 12, lat => 6 } );
Compares to point object attribute by attribute.
Equal means, that ALL atributes of both points are equal in the sense of perl. You may experience troubles with floating point precision!
Return 1 for equal points, otherwise 0.
my $equal = $pointA->equals($pointB);
Convert the point to a plain hash ref. Only defined attributes are included as keys in the hash.
defined
my $point = GPS::Track::Point->new(lon => 1, lat => 2); my $ref = $point->toHash(); # { lon => 1, lat => 2 }
Converts the point to a string representation.
my $point = GPS::Trakc::Point->new(lon => 1, lat => 2, ele => 8848); say $point->toString(); # lon=1 lat=2 ele=8848 time=undef cad=undef bpm=undef spd=undef
Shorthand operator to call "equals-otherPoint" on $pointA with $pointB as argument.
my $areEqual = $pointA == $pointB; # Equivalent to $pointA->equals($pointB);
To install GPS::Track, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GPS::Track
CPAN shell
perl -MCPAN -e shell install GPS::Track
For more information on module installation, please visit the detailed CPAN module installation guide.