Image-Synchronize
view release on metacpan or search on metacpan
lib/Image/Synchronize/GpsPositionCollection.pm view on Meta::CPAN
package Image::Synchronize::GpsPositionCollection;
use Modern::Perl;
#use parent 'Exporter';
use Carp;
use Image::Synchronize::Timerange;
use Scalar::Util qw(
looks_like_number
);
use YAML::Any qw(
Dump
);
use overload '""' => \&stringify;
=head1 NAME
Image::Synchronize::GpsPositionCollection - Manage a collection of GPS
positions
=head1 METHODS
The module provides the following methods:
=head2 new
$gpc = Image::Synchronize::GpsPositionCollection->new;
Creates and returns a new instance of the class.
=cut
sub new {
my ($class) = @_;
bless { data => [], reduced => 0 }, $class;
}
=head2 add
$gpc->add($time, $latitude, $longitude, $altitude, $id, $scope);
Adds a point to the track with the specified C<$id>, for the specified
C<$scope>. The data of the point include the C<$time> (as from
L<gmtime>), the C<$latitude> in degrees (positive to the north,
negative to the south), the C<$longitude> in degrees (positive to the
east, negative to the west), and the C<$altitude> in meters.
Returns the C<Image::Synchronize::GpsPositionCollection> itself.
=cut
sub add {
my ( $self, $time, $latitude, $longitude, $altitude, $id, $scope ) = @_;
$self->{tracks}->{$scope}->{$id} //=
{ data => [], min_time => undef, max_time => undef };
$self->{track_id2scope}->{$id} = $scope;
my $track = $self->{tracks}->{$scope}->{$id};
push @{ $track->{data} }, [ $time, $latitude, $longitude, $altitude ];
if ( defined $track->{max_time} and $time < $track->{max_time} ) {
$track->{needs_reduction} = 1;
$self->{reduced} = 0;
( run in 0.736 second using v1.01-cache-2.11-cpan-d8267643d1d )