NAME

GPS::Track::Point - Represent a Point of a GPS::Track

SYNOPSIS

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

DESCRIPTION

GPS::Track::Point is a thin module representing a Point as parsed by GPS::Track.

ATTRIBUTES

lon

my $lon = $point->lon;
$point = $point->lon(48);

lat

my $lat = $point->lat;
$point = $point->lat(9);

time

Accepts/Returns a DateTime-Object or undef (if no time information is present)

my $time = $point->time;
my $point = $point->time(DateTime->now());

ele

my $ele = $point->ele;
$point = $point->ele(8848);

spd

The speed at this point, measured in meter per second.

my $spd = $point->spd;
my $point = $point->spd(10);

cad

my $cad = $point->cad;
$point = $point->cad(75);

bpm

my $bpm = $point->bpm;
$point = $point->bpm(180);

METHODS

distanceTo($otherPoint)

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

distanceTo( { lon => X, lat => Y } )

Shorthand method to get the 2D distance to a known lon-lat-pair.

my $distance = $pointA->distanceTo( { lon => 12, lat => 6 } );

equals($otherPoint)

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

toHash()

Convert the point to a plain hash ref. Only defined attributes are included as keys in the hash.

my $point = GPS::Track::Point->new(lon => 1, lat => 2);
my $ref = $point->toHash();
# { lon => 1, lat => 2 }

toString()

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

OPERATORS

==

Shorthand operator to call "equals-otherPoint" on $pointA with $pointB as argument.

my $areEqual = $pointA == $pointB;
# Equivalent to $pointA->equals($pointB);