import_locations(self,
gpsdata_file,
checksum=True)
|
|
Import GPS NMEA-formatted data files
import_locations() returns a list of Fix objects representing
the fix sentences found in the GPS data.
It expects data files in NMEA 0183 format, as specified in the
official documentation, which is
ASCII text such as:
$GPGSV,6,6,21,32,65,170,35*48
$GPGGA,142058,5308.6414,N,00300.9257,W,1,04,5.6,1374.6,M,34.5,M,,*6B
$GPRMC,142058,A,5308.6414,N,00300.9257,W,109394.7,202.9,191107,5,E,A*2C
$GPGSV,6,1,21,02,76,044,43,03,84,156,49,06,89,116,51,08,60,184,30*7C
$GPGSV,6,2,21,09,87,321,50,10,77,243,44,11,85,016,49,12,89,100,52*7A
$GPGSV,6,3,21,13,70,319,39,14,90,094,52,16,85,130,49,17,88,136,51*7E
$GPGSV,6,4,21,18,57,052,27,24,65,007,34,25,62,142,32,26,88,031,51*73
$GPGSV,6,5,21,27,64,343,33,28,45,231,16,30,84,198,49,31,90,015,52*7C
$GPGSV,6,6,21,32,65,170,34*49
$GPWPL,5200.9000,N,00013.2600,W,HOME*5E
$GPGGA,142100,5200.9000,N,00316.6600,W,1,04,5.6,1000.0,M,34.5,M,,*68
$GPRMC,142100,A,5200.9000,N,00316.6600,W,123142.7,188.1,191107,5,E,A*21
The reader only imports the GGA, or GPS fix, sentences currently but
future versions will probably support tracks and waypoints. Other than
that the data is out of scope for upoints.
The above file when processed by import_locations() will return
the following list object:
[Fix(datetime.time(14, 20, 58), 53.1440233333, -3.01542833333, 1, 4,
5.6, 1374.6, 34.5, None, None),
Position(datetime.time(14, 20, 58), True, 53.1440233333,
-3.01542833333, 109394.7, 202.9,
datetime.date(2007, 11, 19), 5.0, 'A'),
Waypoint(52.015, -0.221, 'Home'),
Fix(datetime.time(14, 21), 52.015, -3.27766666667, 1, 4, 5.6,
1000.0, 34.5, None, None),
Position(datetime.time(14, 21), True, 52.015, -3.27766666667,
123142.7, 188.1, datetime.date(2007, 11, 19), 5.0, 'A')]
>>> locations = Locations(open("gpsdata"))
>>> for value in locations:
... print(value)
$GPGGA,142058,5308.6414,N,00300.9257,W,1,04,5.6,1374.6,M,34.5,M,,*6B
$GPRMC,142058,A,5308.6414,N,00300.9257,W,109394.7,202.9,191107,5,E,A*2C
$GPWPL,5200.9000,N,00013.2600,W,HOME*5E
$GPGGA,142100,5200.9000,N,00316.6600,W,1,04,5.6,1000.0,M,34.5,M,,*68
$GPRMC,142100,A,5200.9000,N,00316.6600,W,123142.7,188.1,191107,5,E,A*21
- Parameters:
gpsdata_file (file , list or str ) - NMEA data to read
checksum (bool ) - Whether checksums should be tested
- Returns:
list
- Series of locations taken from the data
- Overrides:
point.Points.import_locations
Note:
The standard is quite specific in that sentences must be less
than 82 bytes, while it would be nice to add yet another validity
check it isn't all that uncommon for devices to break this
requirement in their "extensions" to the standard.
To Do:
Add optional check for message length, on by default
|