GPS::Point - Provides an object interface for a GPS point.
use GPS::Point; my $obj=GPS::Point->newGPSD($GPSD_O_line);#e.g. GPSD,O=.... my $obj=GPS::Point->new( time => $time, #float seconds from the unix epoch lat => $lat, #signed degrees lon => $lon, #signed degrees alt => $hae, #meters above the WGS-84 ellipsoid speed => $speed, #meters/second (over ground) heading => $heading, #degrees clockwise from North climb => $climb, #meters/second etime => $etime, #float seconds ehorizontal => $ehz, #float meters evertical => $evert, #float meters espeed => $espeed, #meters/second eheading => $ehead, #degrees eclimb => $eclimb, #meters/second mode => $mode, #GPS mode [?=>undef,None=>1,2D=>2,3D=>3] tag => $tag, #Name of the GPS message for data );
This is a re-write of the Net::GPSD::Point manpage with a goal of being more re-usable.
GPS::Point - Provides an object interface for a GPS fix (e.g. Position, Velocity and Time).
Note: Please use Geo::Point, if you want 2D or projection support.
print scalar($point->latlon), "\n"; #latlon in scalar context my ($x,$y,$z)=$point->ecef; #if Geo::ECEF is available my $GeoPointObject=$point->GeoPoint; #if Geo::Point is available my @distance=$point->distance($point2); #if Geo::Inverse is available my $distance=$point->distance($point2); #if Geo::Inverse->VERSION >=0.05
my $obj=GPS::Point->newNMEA($NMEA_lines); #e.g. GGA+GSA+RMC
my $obj = GPS::Point->new();
my $obj=GPS::Point->newGPSD($GPSD_O_line);#e.g. GPSD,O=....
Constructs a GPS::Point from a Multitude of arguments. Arguments can be a the GPS::Point manpage, the Geo::Point manpage, {lat=>$lat,lon=>$lon} (can be blessed), [$lat, $lon] (can be blessed) or a ($lat, $lon) pair.
my $point=GPS::Point->newMulti( $lat, $lon, $alt ); #supports lat, lon and alt my $point=GPS::Point->newMulti([$lat, $lon, $alt]); #supports lat, lon and alt my $point=GPS::Point->newMulti({lat=>$lat, lon=>$lon, ...}); my $point=GPS::Point->newMulti(GPS::Point->new(lat=>$lat, lon=>$lon)); my $point=GPS::Point->newMulti(Geo::Point->new(lat=>$lat, long=>$lon, proj=>'wgs84')); my $point=GPS::Point->newMulti({latitude=>$lat, longtude=>$lon});
Note: Hash reference context supports the following keys lat, lon, alt, latitude, longitude, long, altitude, elevation, hae, elev.
Note: Units are always decimal degrees for latitude and longitude and meters above the WGS-84 ellipsoid for altitude.
Sets or returns seconds since the Unix epoch, UTC (float, seconds)
print $obj->time, "\n";
Sets or returns Latitude (float, degrees)
print $obj->lat, "\n";
Sets or returns Longitude (float, degrees)
print $obj->lon, "\n";
Sets or returns Altitude (float, meters)
print $obj->alt, "\n";
Sets or returns speed (float, meters/sec)
print $obj->speed, "\n";
Sets or returns heading (float, degrees)
print $obj->heading, "\n";
Sets or returns vertical velocity (float, meters/sec)
print $obj->climb, "\n";
Sets or returns estimated timestamp error (float, seconds, 95% confidence)
print $obj->etime, "\n";
Sets or returns horizontal error estimate (float, meters)
print $obj->ehorizontal, "\n";
Sets or returns vertical error estimate (float, meters)
print $obj->evertical, "\n";
Sets or returns error estimate for speed (float, meters/sec, 95% confidence)
print $obj->espeed, "\n";
Sets or returns error estimate for course (float, degrees, 95% confidence)
print $obj->eheading, "\n";
Sets or returns Estimated error for climb/sink (float, meters/sec, 95% confidence)
print $obj->eclimb, "\n";
Sets or returns the NMEA mode (integer; undef=>no mode value yet seen, 1=>no fix, 2=>2D, 3=>3D)
print $obj->mode, "\n";
Sets or returns a tag identifying the last sentence received. For NMEA devices this is just the NMEA sentence name; the talker-ID portion may be useful for distinguishing among results produced by different NMEA talkers in the same wire. (string)
print $obj->tag, "\n";
Returns either 1 or 0 based upon if the GPS point is from a valid fix or not.
print $obj->fix, "\n";
At a minimum this method requires mode to be set.
Returns a the DateTime manpage object from time
my $dt=$point->datetime;
At a minimum this method requires time to be set.
Returns Latitude, Longitude as an array in array context and as a space joined string in scalar context
my @latlon=$point->latlon; my $latlon=$point->latlon;
At a minimum this method requires lat and lon to be set.
Sets altitude from USGS web service and then returns the GPS::Point object. This method is a wrapper around the Geo::WebService::Elevation::USGS manpage.
my $point=GPS::Point->new(lat=>$lat, lon=>$lon)->setAltitude; $point->setAltitude; my $alt=$point->alt;
At a minimum this method requires lat and lon to be set and alt to be undef.
Returns ECEF coordinates. This method is a warpper around the Geo::ECEF manpage.
my ($x,$y,$z) = $point->ecef; my @xyz = $point->ecef; my $xyz_aref = $point->ecef; #if Geo::ECEF->VERSION >= 0.08
At a minimum this method requires lat and lon to be set. (alt of 0 is assumed by Geo::ECEF->ecef).
Returns a the Geo::Point manpage Object in the WGS-84 projection.
my $GeoPointObject = $point->GeoPoint;
At a minimum this method requires lat and lon to be set.
Returns distance in meters between the object point and the argument point. The argument can be any valid argument of newMulti constructor. This method is a wrapper around Geo::Inverse.
my ($faz, $baz, $dist) = $point->distance($pt2); #Array context my $dist = $point->distance($lat, $lon); #if Geo::Inverse->VERSION >=0.05
At a minimum this method requires lat and lon to be set.
Returns a point object at the predicted location in time seconds assuming constant velocity. Using the Geo::Forward manpage calculation.
my $new_point=$point->track($seconds);
At a minimum this method requires lat and lon to be set. It might be very usefull to have speed, heading and time set although they all default to zero.
Send to GPSD-DEV or GEO-PERL email lists
Try GPSD-DEV or GEO-PERL email lists
Michael R. Davis
CPAN ID: MRDVT
DavisNetworks.com
account=>perl,tld=>com,domain=>michaelrdavis
http://www.davisnetworks.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.
the Geo::Point manpage, the Net::GPSD manpage, the Net::GPSD::Point manpage, the Geo::ECEF manpage, the Geo::Functions manpage, the Geo::Forward manpage, the Geo::Inverse manpage, the Geo::Distance manpage, the Geo::Ellipsoids manpage, the Geo::WebService::Elevation::USGS manpage, the DateTime manpage