Commit d8bfe985 authored by Sven Greiner's avatar Sven Greiner
Browse files

Improve output and add recalculate method

parent 157e5a73
......@@ -5,14 +5,16 @@ from tkFileDialog import askopenfilename
from math import pi, sin, sqrt, cos, atan, fabs
class Point:
def __init__(self, latitude, longitude, time, elevation, speed=0, distance=0, segmentlength=0):
def __init__(self, latitude, longitude, time, elevation, speed=0, distance=0, segmentlength=0, vspeed=0, slope=0):
self.latitude = latitude
self.longitude = longitude
self.time = time
self.elevation = elevation
self.distance = distance
self.speed = speed
self.distance = distance
self.segmentlength = segmentlength
self.vspeed=0
self.slope=0
@staticmethod
def distanceBetween(p1, p2):
......@@ -34,11 +36,16 @@ class Point:
def distanceTo(self, point):
return Point.distanceBetween(self, point)
# def dms(time):
# s=int(time%60)
# m=int(time/60%60)
# h=int(time/3600)
# return (h,m,s)
def recalculatePointlist(points):
for i in xrange(len(points)):
point = points[i]
if i>0:
point.segmentlength = point.distanceTo(points[i-1])
point.distance = points[i-1].distance + point.segmentlength
point.speed = point.segmentlength / (point.time - points[i-1].time)
point.slope = (point.elevation - points[i-1].elevation) / point.segmentlength
point.vspeed = (point.elevation - points[i-1].elevation) / (point.time - points[i-1].time)
return points
def interpol(x, y, lx):
i=0
......@@ -64,12 +71,9 @@ def handleGpx(gpx):
(tim,ele,lat,lon) = handleTrackpoint(tp)
point = Point(latitude=lat, longitude=lon, elevation=ele, time=tim)
if i>0:
point.segmentlength = point.distanceTo(points[i-1])
point.distance = points[i-1].distance + point.segmentlength
point.speed = point.segmentlength / (point.time - points[i-1].time)
point.slope = (point.elevation - points[i-1]) / segmentlength
point.verticalSpeed = (point.elevation - points[i-1]) / segmentlength
point.distance = points[i-1].distance + point.distanceTo(points[i-1])
points.append(point)
recalculatePointlist(points)
return points
def handleTrackpoint(tp):
......@@ -109,9 +113,12 @@ def dp(x,y,eps,xs,ys,iu,io):
dp(x,y,eps,xs,ys,maxi,io)
filename = "ol_egestorf.gpx"
filename = "samples/ol_egestorf.gpx"
dom = xml.dom.minidom.parse(filename)
data = handleGpx(dom)
print " lat | lon | distance | seglen | speed | slope | vspeed | elevation "
print "------------+------------+------------+------------+------------+------------+------------+------------"
for p in data:
print p.segmentlength, p.speed
print " %10.6f | %10.6f | %10.2f | %10.2f | %10.2f | %10.2f | %10.2f | %10.2f" % (p.latitude, p.longitude, p.distance, p.segmentlength, p.speed, p.slope, p.vspeed, p.elevation)
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