Commit 0b4518a0 authored by Sven Greiner's avatar Sven Greiner
Browse files

Draft, does not really work, not enough time

parent 87231b99
......@@ -119,7 +119,7 @@ def dp(points,eps,xs,ys,iu,io):
#-------------------------------------------------------------------------------
def writeToShape(tracks):
def writeToShape(track, filename):
w = shapefile.Writer(shapefile.POLYLINE)
w.autoBalance = 1
w.field('ID', 'N', '16')
......@@ -129,24 +129,42 @@ def writeToShape(tracks):
w.field('Speed', 'N', '16')
w.field('Slope', 'N', '16')
w.field('VerticalSpeed', 'N', '16')
parts = []
for i in xrange(len(tracks)):
track = tracks[i]
for j in xrange(len(track)):
point = track[j]
parts.append([point.latitude, point.longitude])
w.line([parts])
w.record(ID=i,Time=track.time,Distance=track.distance,Elevation=track.elevation,Speed=track.speed,Slope=track.slope,VerticalSpeed=track.vspeed)
w.save('result')
if __name__ == "__main__":
filename = "samples/ol_egestorf.gpx"
dom = xml.dom.minidom.parse(filename)
track = parseTrack(dom)
for p1, p2 in zip(track[:-1], track[1:]):
w.line([
[p1.latitude, p1.longitude],
[p2.latitude, p2.longitude]
])
w.record(
ID=1,
Time=p2.time,
Distance=p2.distance,
Elevation=p2.elevation,
Speed=p2.speed,
Slope=p2.slope,
VerticalSpeed=p2.vspeed
)
w.save(filename)
#-------------------------------------------------------------------------------
def printTrack(track):
print " lat | lon | distance | seglen | speed | slope | vspeed | elevation "
print "------------+------------+------------+------------+------------+------------+------------+------------"
for p in track:
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)
#-------------------------------------------------------------------------------
if __name__ == "__main__":
gpxname = "samples/ol_egestorf.gpx"
shapename = "result.shp"
# track = parseTrack(xml.dom.minidom.parse(gpxname))
# simplified = dpeuker(track)
# recalculateTrack(simplified)
simplified = parseTrack(xml.dom.minidom.parse(gpxname))
writeToShape(simplified, shapename)
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