Exemplo n.º 1
0
    def _updateLogCB(self):
        """add current position at the end of the log"""
        pos = self.get('pos', None)
        if pos and not self.loggingPaused:
            timestamp = geo.timestampUTC()
            lat, lon = pos
            elevation = self.get('elevation', None)
            self.log1.addPointLLET(lat, lon, elevation, timestamp)
            self.log2.addPointLLET(lat, lon, elevation, timestamp)

            # update statistics for the current log
            if self.loggingEnabled and not self.loggingPaused:
                # update the current log speed statistics
                currentSpeed = self.get('speed', None)
                if currentSpeed:
                    # max speed
                    if currentSpeed > self.maxSpeed:
                        self.maxSpeed = currentSpeed
                        # avg speed
                    self.avg1 += currentSpeed
                    self.avg2 += (time.time() - self.lastUpdateTimestamp)
                    self.avgSpeed = self.avg1 / self.avg2
                    self.lastUpdateTimestamp = time.time()

                # update traveled distance
                if self.lastCoords:
                    lLat, lLon = self.lastCoords
                    self.distance += geo.distance(lLat, lLon, lat, lon)
                    self.lastCoords = lat, lon

                # update the on-map trace
                if self.lastTracePoint:
                    lat1, lon1 = self.lastTracePoint
                    # check if the point is distant enough from the last added point
                    # (which was either the first point or also passed the test)
                    addToTrace = True
                    try:
                        addToTrace = geo.distanceApprox(
                            lat, lon, lat1,
                            lon1) * 1000 >= DONT_ADD_TO_TRACE_THRESHOLD
                    except Exception:
                        self.log.exception(
                            "measuring distance failed (yeah, really! :P), adding point anyway"
                        )

                    if addToTrace:
                        self._addLL2Trace(lat, lon)
                else:  # this is the first known log point, just add it
                    self._addLL2Trace(lat, lon)
        # done, trigger the tracklog updated signal
        self.tracklogUpdated()
Exemplo n.º 2
0
    def _updateLogCB(self):
        """add current position at the end of the log"""
        pos = self.get("pos", None)
        if pos and not self.loggingPaused:
            timestamp = geo.timestampUTC()
            lat, lon = pos
            elevation = self.get("elevation", None)
            self.log1.addPointLLET(lat, lon, elevation, timestamp)
            self.log2.addPointLLET(lat, lon, elevation, timestamp)

            # update statistics for the current log
            if self.loggingEnabled and not self.loggingPaused:
                # update the current log speed statistics
                currentSpeed = self.get("speed", None)
                if currentSpeed:
                    # max speed
                    if currentSpeed > self.maxSpeed:
                        self.maxSpeed = currentSpeed
                        # avg speed
                    self.avg1 += currentSpeed
                    self.avg2 += time.time() - self.lastUpdateTimestamp
                    self.avgSpeed = self.avg1 / self.avg2
                    self.lastUpdateTimestamp = time.time()

                # update traveled distance
                if self.lastCoords:
                    lLat, lLon = self.lastCoords
                    self.distance += geo.distance(lLat, lLon, lat, lon)
                    self.lastCoords = lat, lon

                # update the on-map trace
                if self.lastTracePoint:
                    lat1, lon1 = self.lastTracePoint
                    # check if the point is distant enough from the last added point
                    # (which was either the first point or also passed the test)
                    addToTrace = True
                    try:
                        addToTrace = geo.distanceApprox(lat, lon, lat1, lon1) * 1000 >= DONT_ADD_TO_TRACE_THRESHOLD
                    except Exception:
                        import sys

                        e = sys.exc_info()[1]
                        print("tracklog: measuring distance failed (yeah, really! :P), adding point anyway")
                        print(e)
                    if addToTrace:
                        self._addLL2Trace(lat, lon)
                else:  # this is the first known log point, just add it
                    self._addLL2Trace(lat, lon)
Exemplo n.º 3
0
 def saveToCSV(self, path, append=False):
     """save all points to a CSV file
     NOTE: message points are not (yet) handled
     TODO: message point support"""
     timestamp = geo.timestampUTC()
     try:
         f = open(path, "w")
         writer = csv.writer(f, dialect=csv.excel)
         points = self.getPointsLLE()
         for p in points:
             writer.writeRow(p[0], p[1], p[2], timestamp)
         f.close()
         log.info('%d points saved to %s as CSV', path, len(points))
         return True
     except Exception:
         log.exception('saving to CSV failed')
         return False
Exemplo n.º 4
0
 def saveToCSV(self, path, append=False):
     """save all points to a CSV file
     NOTE: message points are not (yet) handled
     TODO: message point support"""
     timestamp = geo.timestampUTC()
     try:
         f = open(path, "w")
         writer = csv.writer(f, dialect=csv.excel)
         points = self.getPointsLLE()
         for p in points:
             writer.writeRow(p[0], p[1], p[2], timestamp)
         f.close()
         log.info('%d points saved to %s as CSV', path, len(points))
         return True
     except Exception:
         log.exception('saving to CSV failed')
         return False
Exemplo n.º 5
0
    def __init__(self, points=None):
        if not points: points = []
        Way.__init__(self)

        self._points = [] # stored as (lat, lon, elevation, timestamp) tuples
        self.increment = [] # not yet saved increment, also LLET
        self.file = None
        self.filePath = None
        self.writer = None

        if points:
            with self._points_lock:
                # mark all points added on startup with a single timestamp
                timestamp = geo.timestampUTC()
                # convert to LLET
                points = [(x[0], x[1], x[2], timestamp) for x in points]

                # mark points as not yet saved
                self.increment = points
                # and also add to main point list
                self._points = points
Exemplo n.º 6
0
    def __init__(self, points=None):
        if not points: points = []
        Way.__init__(self)

        self._points = [] # stored as (lat, lon, elevation, timestamp) tuples
        self.increment = [] # not yet saved increment, also LLET
        self.file = None
        self.filePath = None
        self.writer = None

        if points:
            with self._points_lock:
                # mark all points added on startup with a single timestamp
                timestamp = geo.timestampUTC()
                # convert to LLET
                points = [(x[0], x[1], x[2], timestamp) for x in points]

                # mark points as not yet saved
                self.increment = points
                # and also add to main point list
                self._points = points
Exemplo n.º 7
0
    def _updateLogCB(self):
        """add current position at the end of the log"""
        pos = self.get('pos', None)
        if pos and not self.loggingPaused:
            timestamp = geo.timestampUTC()
            lat, lon = pos
            elevation = self.get('elevation', None)
            self.log1.addPointLLET(lat, lon, elevation, timestamp)
            self.log2.addPointLLET(lat, lon, elevation, timestamp)

            # update statistics for the current log
            if self.loggingEnabled and not self.loggingPaused:
                # update the current log speed statistics
                currentSpeed = self.get('speed', None)
                if currentSpeed:
                    # max speed
                    if currentSpeed > self.maxSpeed:
                        self.maxSpeed = currentSpeed
                        # avg speed
                    self.avg1 += currentSpeed
                    self.avg2 += (time.time() - self.lastUpdateTimestamp)
                    self.avgSpeed = self.avg1 / self.avg2
                    self.lastUpdateTimestamp = time.time()

                # update traveled distance
                if self.lastCoords:
                    lLat, lLon = self.lastCoords
                    self.distance += geo.distance(lLat, lLon, lat, lon)
                    self.lastCoords = lat, lon

                # update the on-map trace
                if self.lastTracePoint:
                    lat1, lon1 = self.lastTracePoint
                    # check if the point is distant enough from the last added point
                    # (which was either the first point or also passed the test)
                    if geo.distanceApprox(lat, lon, lat1, lon1) * 1000 >= DONT_ADD_TO_TRACE_THRESHOLD:
                        self._addLL2Trace(lat, lon)
                else: # this is the first known log point, just add it
                    self._addLL2Trace(lat, lon)
Exemplo n.º 8
0
 def add_point_lle(self, lat, lon, elevation=None):
     with self._points_lock:
         self._points.append((lat, lon, elevation, geo.timestampUTC()))
         self.increment.append((lat, lon, elevation, geo.timestampUTC()))
Exemplo n.º 9
0
 def add_point(self, point):
     with self._points_lock:
         lat, lon, elevation = point.getLLE()
         self._points.append((lat, lon, elevation, geo.timestampUTC()))
         self.increment.append((lat, lon, elevation, geo.timestampUTC()))
Exemplo n.º 10
0
 def addPointLLE(self, lat, lon, elevation=None):
     with self.pointsLock:
         self.points.append((lat, lon, elevation, geo.timestampUTC()))
         self.increment.append((lat, lon, elevation, geo.timestampUTC()))
Exemplo n.º 11
0
 def add_point_lle(self, lat, lon, elevation=None):
     with self._points_lock:
         self._points.append((lat, lon, elevation, geo.timestampUTC()))
         self.increment.append((lat, lon, elevation, geo.timestampUTC()))
Exemplo n.º 12
0
 def add_point(self, point):
     with self._points_lock:
         lat, lon, elevation = point.getLLE()
         self._points.append((lat, lon, elevation, geo.timestampUTC()))
         self.increment.append((lat, lon, elevation, geo.timestampUTC()))
Exemplo n.º 13
0
 def addPointLLE(self, lat, lon, elevation=None):
     with self.pointsLock:
         self.points.append((lat, lon, elevation, geo.timestampUTC()))
         self.increment.append((lat, lon, elevation, geo.timestampUTC()))