Commit 7ed7b69e authored by Sven Greiner's avatar Sven Greiner
Browse files

Fix wrong recalculation of slope and speed

Also use a copy for dp and recalculation
parent 7277a368
......@@ -4,6 +4,7 @@ from matplotlib.pyplot import plot, show
from pylab import polyfit, polyval
from tkFileDialog import askopenfilename
from math import pi, sin, sqrt, cos, atan, fabs
import copy
#-------------------------------------------------------------------------------
......@@ -38,7 +39,8 @@ class Point:
@staticmethod
def speed(p1, p2):
return p2.segmentlength / (p2.time - p1.time)
# don't use segmentlength, it might be outdated. distance is accumulated during loading of the track
return (p2.distance - p1.distance) / (p2.time - p1.time)
@staticmethod
def vspeed(p1, p2):
......@@ -46,7 +48,8 @@ class Point:
@staticmethod
def slope(p1, p2):
return (p2.elevation - p1.elevation) / p2.segmentlength
# don't use segmentlength, it might be outdated. distance is accumulated during loading of the track
return (p2.elevation - p1.elevation) / (p2.distance - p1.distance)
def distanceTo(self, point):
return Point.distance(self, point)
......@@ -169,7 +172,7 @@ if __name__ == "__main__":
shapename = "result.shp"
track = parseTrack(xml.dom.minidom.parse(gpxname))
simplified = dp(track, "distance", "elevation", 5)
simplified = dp(copy.deepcopy(track), "distance", "elevation", 5)
recalculateTrack(simplified)
printTrack(simplified)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment