def UpdatePanel(self, trackId): self.trackId = trackId trackPoints = self.db.ListTrackPoints(self.trackId) p2 = False totalDistance = 0 for tp in trackPoints: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] if p2: totalDistance += garmin.distance(p1, p2) p2 = p1 self.totalDistance = totalDistance self.totalTime = int(trackPoints[-1][4]) - int(trackPoints[0][4]) if self.totalTime != 0: self.averageSpeed = (totalDistance / 1000.0) / (self.totalTime / 3600.0) else: self.averageSpeed = 0 self.totalDistanceLabel.SetLabel("%7.1f m" % (self.totalDistance, )) self.totalTimeLabel.SetLabel("%d h %d min %d s" % (self.totalTime / 3600, self.totalTime % 3600 / 60, self.totalTime % 60)) self.averageSpeedLabel.SetLabel("%7.1f km/h" % (self.averageSpeed, ))
def plotTimeSpeed(self): """ Plot a Time / Speed Graph with """ time = [] speed = [] tplist = self.db.ListTrackPoints(self.trackId) p2 = False for tp in tplist: currentTime = int(tp[4])-int(tplist[0][4]) if not p2: #if p2 does not exist yet, we are at the first point p2 = garmin.D301() p2.slon = tp[1] p2.slat = tp[2] p2.alt = tp[3] speed.append(0) else: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] #check that we don't divide by 0 if currentTime-lastTime > 0: speed.append(3.6*garmin.distance(p1, p2)/(currentTime-lastTime)) else: speed.append(0) p2=p1 lastTime = currentTime time.append(currentTime) self.PlotData("Time / Speed", "Time in min", "Speed in km/h", time, speed)
def plotTimeSpeed(self): """ Plot a Time / Speed Graph with """ time = [] speed = [] tplist = self.db.ListTrackPoints(self.trackId) p2 = False for tp in tplist: currentTime = int(tp[4]) - int(tplist[0][4]) if not p2: #if p2 does not exist yet, we are at the first point p2 = garmin.D301() p2.slon = tp[1] p2.slat = tp[2] p2.alt = tp[3] speed.append(0) else: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] #check that we don't divide by 0 if currentTime - lastTime > 0: speed.append(3.6 * garmin.distance(p1, p2) / (currentTime - lastTime)) else: speed.append(0) p2 = p1 lastTime = currentTime time.append(currentTime) self.PlotData("Time / Speed", "Time in min", "Speed in km/h", time, speed)
def plotTimeTotalDistance(self): """ Plot a Time / Total Distance Graph """ time = [] distance = [] tplist = self.db.ListTrackPoints(self.trackId) p2 = False for tp in tplist: time.append(int(tp[4]) - int(tplist[0][4])) if not p2: lastDistance = 0 p2 = garmin.D301() p2.slon = tp[1] p2.slat = tp[2] p2.alt = tp[3] else: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] lastDistance += garmin.distance(p1, p2) p2 = p1 distance.append(lastDistance) self.PlotData("Time / Distance", "Time in min", "Distance in m", time, distance)
def plotDistanceAltitude(self): """ Plot a Distance / Altitude Graph """ distance = [] alt = [] tplist = self.db.ListTrackPoints(self.trackId) p2 = False for tp in tplist: alt.append(int(tp[3])) if not p2: lastDistance = 0 p2 = garmin.D301() p2.slon = tp[1] p2.slat = tp[2] p2.alt = tp[3] else: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] lastDistance += garmin.distance(p1, p2) p2 = p1 distance.append(lastDistance) self.PlotData("Distance / Altitude", "Distance in m", "Altitude in m", distance, alt)
def UpdatePanel(self, trackId): self.trackId = trackId trackPoints = self.db.ListTrackPoints(self.trackId) p2 = False totalDistance = 0 for tp in trackPoints: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] if p2: totalDistance += garmin.distance(p1, p2) p2 = p1 self.totalDistance = totalDistance self.totalTime = int(trackPoints[-1][4]) - int(trackPoints[0][4]) if self.totalTime != 0: self.averageSpeed = (totalDistance / 1000.0) / (self.totalTime / 3600.0) else: self.averageSpeed = 0 self.totalDistanceLabel.SetLabel("%7.1f m" % (self.totalDistance,)) self.totalTimeLabel.SetLabel( "%d h %d min %d s" % (self.totalTime / 3600, self.totalTime % 3600 / 60, self.totalTime % 60) ) self.averageSpeedLabel.SetLabel("%7.1f km/h" % (self.averageSpeed,))
def plotTimeTotalDistance(self): """ Plot a Time / Total Distance Graph """ time = [] distance = [] tplist = self.db.ListTrackPoints(self.trackId) p2 = False for tp in tplist: time.append(int(tp[4]) - int(tplist[0][4])) if not p2: lastDistance=0 p2 = garmin.D301() p2.slon = tp[1] p2.slat = tp[2] p2.alt = tp[3] else: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] lastDistance+=garmin.distance(p1, p2) p2=p1 distance.append(lastDistance) self.PlotData("Time / Distance", "Time in min", "Distance in m", time, distance)
def plotDistanceAltitude(self): """ Plot a Distance / Altitude Graph """ distance = [] alt = [] tplist = self.db.ListTrackPoints(self.trackId) p2 = False for tp in tplist: alt.append(int(tp[3])) if not p2: lastDistance=0 p2 = garmin.D301() p2.slon = tp[1] p2.slat = tp[2] p2.alt = tp[3] else: p1 = garmin.D301() p1.slon = tp[1] p1.slat = tp[2] p1.alt = tp[3] lastDistance+=garmin.distance(p1, p2) p2=p1 distance.append(lastDistance) self.PlotData("Distance / Altitude", "Distance in m", "Altitude in m", distance, alt)