예제 #1
0
    def _gpx_for_logs(self, logs):
        g = GPX()
        track = GPXTrack()
        track.source = 'pizero-gpslog %s' % VERSION
        g.tracks.append(track)
        seg = GPXTrackSegment()
        track.segments.append(seg)

        for item in logs:
            try:
                tpv = item['tpv'][0]
                sky = item['sky'][0]
                p = GPXTrackPoint(latitude=tpv['lat'],
                                  longitude=tpv['lon'],
                                  elevation=tpv['alt'],
                                  time=TIME_TYPE.from_string(tpv['time']),
                                  speed=tpv['speed'],
                                  horizontal_dilution=sky.get('hdop', None),
                                  vertical_dilution=sky.get('vdop', None),
                                  position_dilution=sky.get('pdop', None))
                if tpv['mode'] == 2:
                    p.type_of_gpx_fix = '2d'
                elif tpv['mode'] == 3:
                    p.type_of_gpx_fix = '3d'
                if 'satellites' in sky:
                    p.satellites = len(sky['satellites'])
                seg.points.append(p)
            except Exception:
                sys.stderr.write('Exception loading line %d:\n' %
                                 item['lineno'])
                raise
        return g
예제 #2
0
    def _gpx_for_logs(self):
        g = GPX()
        track = GPXTrack()
        track.source = 'pizero-gpslog gmc-500'
        g.tracks.append(track)
        seg = GPXTrackSegment()
        track.segments.append(seg)
        prev_alt = 0.0

        for idx, item in enumerate(self.lines):
            try:
                tpv = item['tpv'][0]
                sky = item['sky'][0]
                alt = tpv.get(
                    'alt', item['gst'][0].get('alt', prev_alt)
                )
                prev_alt = alt
                p = GPXTrackPoint(
                    latitude=tpv['lat'],
                    longitude=tpv['lon'],
                    elevation=alt,
                    time=TIME_TYPE.from_string(tpv['time']),
                    speed=tpv['speed'],
                    horizontal_dilution=sky.get('hdop', None),
                    vertical_dilution=sky.get('vdop', None),
                    position_dilution=sky.get('pdop', None)
                )
                if tpv['mode'] == 2:
                    p.type_of_gpx_fix = '2d'
                elif tpv['mode'] == 3:
                    p.type_of_gpx_fix = '3d'
                if 'satellites' in sky:
                    p.satellites = len(sky['satellites'])
                cpm = item.get('_extra_data', {}).get('data', {}).get('cpm', 0)
                seg.points.append(p)
            except Exception:
                logger.error(
                    'Error loading line %d: %s', idx, item
                )
                raise
        return g