diff options
author | Beat Bolli <bbolli@ewanet.ch> | 2013-10-21 20:34:59 +0200 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-10-22 13:37:42 -0400 |
commit | be17a5d3f2770e17f182bbf4233f6da78bd50eae (patch) | |
tree | 5e4b82f0c8b18280d475aba5ac3955381adebcf5 /contrib/webgps.py | |
parent | df3c5a442c13591fdf557bb2df3df9f6d243d99a (diff) | |
download | gpsd-be17a5d3f2770e17f182bbf4233f6da78bd50eae.tar.gz |
webgps.py: move the track drawing into class Track
Diffstat (limited to 'contrib/webgps.py')
-rwxr-xr-x | contrib/webgps.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/contrib/webgps.py b/contrib/webgps.py index 91fc668d..5e437c57 100755 --- a/contrib/webgps.py +++ b/contrib/webgps.py @@ -46,6 +46,10 @@ class Track: return 1 return 0 + def track(self): + '''Return the track as canvas drawing operations.''' + return 'M(%d,%d); ' % self.posn[0] + ''.join(['L(%d,%d); ' % p for p in self.posn[1:]]) + class SatTracks(gps): '''gpsd client writing HTML5 and <canvas> output.''' @@ -196,17 +200,11 @@ function draw_satview() { ctx.strokeStyle = 'red'; """); - def M(p): - return 'M(%d,%d); ' % p - def L(p): - return 'L(%d,%d); ' % p - # Draw the tracks for t in self.sattrack.values(): if t.posn: - fh.write(" ctx.globalAlpha = %s; ctx.beginPath(); %s%sctx.stroke();\n" % ( - t.stale == 0 and '0.66' or '1', M(t.posn[0]), - ''.join([L(p) for p in t.posn[1:]]) + fh.write(" ctx.globalAlpha = %s; ctx.beginPath(); %sctx.stroke();\n" % ( + t.stale == 0 and '0.66' or '1', t.track() )) fh.write(""" |