Michael R. Davis > GPS-Point-Cluster-0.05 > GPS::Point::Cluster

Download:
GPS-Point-Cluster-0.05.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.05   Source  

NAME ^

GPS::Point::Cluster - Groups GPS Points in to clusters

SYNOPSIS ^

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

DESCRIPTION ^

USAGE ^

CONSTRUCTOR ^

new

  my $cluster = GPS::Point::Cluster->new(separation=>500);

METHODS ^

initialize

settings

Returns a hash of default settings to transfer from one cluster to the next.

  my $hash=$cluster->settings;
  my %hash=$cluster->settings;

index

Returns the cluster index which is a running integer.

separation

The threshold distance in meters between the cluster and the test point.

interlude

The threshold duration in seconds between the cluster end time and the test point.

lat

Latitude in decimal degrees WGS-84. The latitude is calculated as a mathimatical average of all latitudes that constitute the cluster.

lon

Longitude in decimal degrees WGS-84. The longitude is calculated as a mathimatical average of all longitudes that constitute the cluster.

weight

The count of points that constitute the cluster.

start

Returns the cluster start date time as seconds from epoch

start_dt

Returns the cluster start date time as a DateTime object

end

Returns the cluster end date time as seconds from epoch

end_dt

Returns the cluster end date time as a DateTime object

GeoInverse

Returns a Geo::Inverse object which is used to calculate geodetic distances.

merge_attempt

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.
  }

distance

Returns the distance in meters between the cluster and the point.

  my $distance=$cluster->distance($pt);

duration

Returns the duration in seconds between the cluster and the point.

  my $duration=$cluster->duration($pt);

merge

Merges point into cluster returns cluster.

  my $cluster->merge($pt);

BUGS ^

SUPPORT ^

AUTHOR ^

    Michael R. Davis
    CPAN ID: MRDVT
    STOP, LLC
    domain=>michaelrdavis,tld=>com,account=>perl
    http://www.stopllc.com/

COPYRIGHT ^

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.

SEE ALSO ^

Algorithm::Cluster, Algorithm::ClusterPoints

syntax highlighting: