[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH 4/6] webgps.py: move the track drawing into class Trac
From: |
Beat Bolli |
Subject: |
[gpsd-dev] [PATCH 4/6] webgps.py: move the track drawing into class Track |
Date: |
Mon, 21 Oct 2013 20:34:59 +0200 |
---
contrib/webgps.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/contrib/webgps.py b/contrib/webgps.py
index 91fc668..5e437c5 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("""
--
1.8.4.rc3