summaryrefslogtreecommitdiff
path: root/gpsprof
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-09-29 13:17:16 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-09-29 13:17:16 -0400
commitd2079626a85bfc61fe5c14faf9ebbf9ea9201be4 (patch)
treecd93ba8d311b151e5672f133f6abf6774b065ca8 /gpsprof
parent885b9c1d796ab28ca8e5ffe020ee023a98a44119 (diff)
downloadgpsd-d2079626a85bfc61fe5c14faf9ebbf9ea9201be4.tar.gz
Fix bug in data() method for spaceplotting.
Diffstat (limited to 'gpsprof')
-rwxr-xr-xgpsprof17
1 files changed, 8 insertions, 9 deletions
diff --git a/gpsprof b/gpsprof
index ce3d85cb..8d9b4ac9 100755
--- a/gpsprof
+++ b/gpsprof
@@ -116,6 +116,7 @@ class spaceplot(plotter):
requires_time = False
def __init__(self):
plotter.__init__(self)
+ self.recentered = []
def d(self, a, b):
return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
def sample(self):
@@ -125,6 +126,13 @@ class spaceplot(plotter):
def header(self):
return "# Position uncertainty, %s\n" % self.whatami()
def data(self):
+ if not self.recentered:
+ # centroid is just arithmetic avg of lat,lon
+ self.centroid = (sum(map(lambda x:x[0], self.fixes))/len(self.fixes), sum(map(lambda x:x[1], self.fixes))/len(self.fixes))
+ # Sort fixes by distance from centroid
+ self.fixes.sort(lambda x, y: cmp(self.d(self.centroid, x), self.d(self.centroid, y)))
+ # Convert fixes to offsets from centroid in meters
+ self.recentered = map(lambda fix: gps.MeterOffset(self.centroid, fix[:2]), self.fixes)
res = ""
for i in range(len(self.recentered)):
(lat, lon) = self.recentered[i][:2]
@@ -132,15 +140,6 @@ class spaceplot(plotter):
res += "%f\t%f\t%f\t%f\t%f\n" % (lat, lon, raw1, raw2, alt)
return res
def plot(self):
- if len(self.fixes) == 0:
- sys.stderr.write("No fixes collected, can't estimate accuracy.")
- sys.exit(1)
- # centroid is just arithmetic avg of lat,lon
- self.centroid = (sum(map(lambda x:x[0], self.fixes))/len(self.fixes), sum(map(lambda x:x[1], self.fixes))/len(self.fixes))
- # Sort fixes by distance from centroid
- self.fixes.sort(lambda x, y: cmp(self.d(self.centroid, x), self.d(self.centroid, y)))
- # Convert fixes to offsets from centroid in meters
- self.recentered = map(lambda fix: gps.MeterOffset(self.centroid, fix[:2]), self.fixes)
# Compute CEP(50%)
cep_meters = gps.EarthDistance(self.centroid[:2], self.fixes[int(len(self.fixes)*0.50)][:2])
cep95_meters = gps.EarthDistance(self.centroid[:2], self.fixes[int(len(self.fixes)*0.95)][:2])