NAME
Image::Synchronize::GpsPositionCollection - Manage a collection of GPS positions
METHODS
The module provides the following methods:
new
$gpc = Image::Synchronize::GpsPositionCollection->new;
Creates and returns a new instance of the class.
add
$gpc->add($time, $latitude, $longitude, $altitude, $id, $scope);
Adds a point to the track with the specified $id
, for the specified $scope
. The data of the point include the $time
(as from gmtime), the $latitude
in degrees (positive to the north, negative to the south), the $longitude
in degrees (positive to the east, negative to the west), and the $altitude
in meters.
Returns the Image::Synchronize::GpsPositionCollection
itself.
ids_for_track
@ids_for_track = $gpc->ids_for_track($scope);
@ids_for_track = $gpc->ids_for_track; # all scopes
Returns a list of track IDs for the specified $scope
, or for all scopes.
Note that a given $scope
includes all other scopes whose names have $scope
as their prefix. So, scope 'foo/bar' includes scopes 'foo/barbar' and 'foo/bar/bar', but not scope 'foo/fie'.
points_for_track
$points = $gpc->points_for_track($track_id);
Returns a reference to the array of track points for the track with the specified $track_id
, or undef
if that track is not known.
extreme_times_for_track
($min_time, $max_time) = $gpc->extreme_times_for_track($track_id);
Returns the least and greatest times of any points in the track with the specified $track_id
, or undef
if that track is not known.
middle_bounding_box_for_track
($latitude, $longitude) = $gpc->middle_bounding_box_for_track($track_id);
Returns the coordinates of the middle of the bounding box of the track with the specified $track_id
, or undef
if that track is not known.
The bounding box touches the points with the least and greatest longitudes and latitudes.
reduce
$gpc->reduce;
Ensures that for each GPS track the points are sorted in ascending order of time, and that there are no duplicate times. This is needed by position_for_time.
tracks_for_time
@ids_for_track = $gpc->tracks_for_time($time, $scope);
@ids_for_track = $gpc->tracks_for_time($time); # all scopes
Returns the @ids_for_track
, for the specified $scope
or all scopes, that cover the $time
, i.e., for which the $time
is greater than or equal to the oldest time of the track and the $time
is less than or equal to the youngest time of the track.
Note that a given $scope
includes all other scopes whose names have $scope
as their prefix. So, scope 'foo/bar' includes scopes 'foo/barbar' and 'foo/bar/bar', but not scope 'foo/fie'.
Returns the empty list if no tracks cover the time (within the scope, if specified).
position_for_time
%positions = $gpc->position_for_time($time,
scope => $scope,
track => $track_id);
Returns the GPS positions for the indicated $time
, $scope
, and/or $track_id
, or an empty list if no matching positions are known.
The returned @positions
contains a reference to a hash for each found position. The hash contains keys 'track'
, 'scope'
, and 'position'
. The value for the first key is the track ID. The value for the second key is the scope. The value for the last key is a reference to an array with elements [$longitude, $latitude, $altitude]
. The positions are sorted by decreasing scope length.
search
$index = search($target, $count, $get);
Searches for the $target
in an array of $count
elements sorted in non-descending order. The array elements are accessed through $get
, which may be an array reference or a code reference. If it is a code reference, then the elements of the array are accessed through $get->($index)
.
Returns the greatest element $index
for which the element is equal to or less than the $target
. If the $target
is less than the first element of the array, then returns -1.
DEPENDENCIES
This module uses the following non-core Perl module:
Image::Synchronize::Timerange;
namespace::clean
YAML::Any
AUTHOR
Louis Strous <LS@quae.nl>
LICENSE AND COPYRIGHT
Copyright (c) 2018 - 2020 Louis Strous.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.