GPS::Point::Cluster - Groups GPS Points in to clusters
use GPS::Point::Cluster; my $cluster=GPS::Point::Cluster->new( separation => 500, #meters interlude => 600, #seconds ); my @pt=({}, {}, {}, ...); #{lat=>39, lon=>-77, time=>$epoch_seconds} foreach my $pt (@pt) { my $obj=$cluster->merge_attempt($pt); if (defined $obj) { print join(",", $cluster->index, $cluster->start_dt, $cluster->end_dt, $cluster->lat, $cluster->lon, $cluster->weight), "\n"; $cluster=$obj; } }
my $cluster = GPS::Point::Cluster->new(separation=>500);
Returns a hash of default settings to transfer from one cluster to the next.
my $hash=$cluster->settings; my %hash=$cluster->settings;
Returns the cluster index which is a running integer.
The threshold distance in meters between the cluster and the test point.
The threshold duration in seconds between the cluster end time and the test point.
Latitude in decimal degrees WGS-84. The latitude is calculated as a mathimatical average of all latitudes that constitute the cluster.
Longitude in decimal degrees WGS-84. The longitude is calculated as a mathimatical average of all longitudes that constitute the cluster.
The count of points that constitute the cluster.
Returns the cluster start date time as seconds from epoch
Returns the cluster start date time as a DateTime object
Returns the cluster end date time as seconds from epoch
Returns the cluster end date time as a DateTime object
Returns a Geo::Inverse object which is used to calculate geodetic distances.
Attempts to merge the point into the cluster. If the point does not fit in the cluster then the method returns a new cluster. If it merged, then it returns undef.
my $new_cluster=$cluster->merge_attempt($pt); if (defined $new_cluster) { #New cluster is constructed with $pt as the only member. $cluster is unmodified. } else { #$pt is added the cluster. The cluster is updated appropriately. }
Returns the distance in meters between the cluster and the point.
my $distance=$cluster->distance($pt);
Returns the duration in seconds between the cluster and the point.
my $duration=$cluster->duration($pt);
Merges point into cluster returns cluster.
my $cluster->merge($pt);
Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
Algorithm::Cluster, Algorithm::ClusterPoints
To install GPS::Point::Cluster, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GPS::Point::Cluster
CPAN shell
perl -MCPAN -e shell install GPS::Point::Cluster
For more information on module installation, please visit the detailed CPAN module installation guide.