upoints.nmea.Locations

Package upoints :: Module nmea :: Class Locations |
[hide private]
[frames] | no frames]

# Class Locations

    object --+
             |
          list --+
                 |
      point.Points --+
                     |
                    Locations

Class for representing a group of GPS location objects

Since: 0.8.0

Instance Methods | [hide private]
new list |
__init__(self, gpsdata_file=None) Initialise a new Locations object |
`list` |
import_locations(self, gpsdata_file, checksum=True) Import GPS NMEA-formatted data files |
Inherited from `point.Points`: `__repr__`, `bearing`, `destination`, `distance`, `final_bearing`, `forward`, `inverse`, `midpoint`, `range`, `sun_events`, `sunrise`, `sunset`, `to_grid_locator` Inherited from `list`: `__add__`, `__contains__`, `__delitem__`, `__delslice__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__iadd__`, `__imul__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__mul__`, `__ne__`, `__new__`, `__reversed__`, `__rmul__`, `__setitem__`, `__setslice__`, `append`, `count`, `extend`, `index`, `insert`, `pop`, `remove`, `reverse`, `sort` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, gpsdata_file=None) (Constructor) |
Initialise a new Locations object Parameters: `points` - Point objects to wrap `parse` - Whether to attempt import of `points` `units` - Unit type to be used for distances when parsing string locations Returns: new list Overrides: object.__init__

### 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