summaryrefslogtreecommitdiff
path: root/test_maidenhead.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-05-06 16:03:58 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-05-06 16:03:58 -0400
commit1956ff35d239d9bb33fefe31ee374934952e5076 (patch)
tree61f487a1e4d7f886e69e01ace5503a282a687c97 /test_maidenhead.py
parentb6462462697e60c8d921988c4760cd66a3b43579 (diff)
downloadgpsd-1956ff35d239d9bb33fefe31ee374934952e5076.tar.gz
Fixes for the Maidehead locator code, and a better regression test.
Diffstat (limited to 'test_maidenhead.py')
-rwxr-xr-xtest_maidenhead.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test_maidenhead.py b/test_maidenhead.py
new file mode 100755
index 00000000..39010b62
--- /dev/null
+++ b/test_maidenhead.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+#
+# Test grid locator conversion.
+#
+# Midenhead specification at
+# http://en.wikipedia.org/wiki/Maidenhead_Locator_System
+# Test conversions generated using
+# http://f6fvy.free.fr/qthLocator/
+
+import sys, gps.clienthelpers
+
+errors = 0
+for (lat, lon, maidenhead, location) in [
+ (48.86471, 2.37305, "JN18eu", "Paris"),
+ (41.93498, 12.43652, "JN61fw", "Rome"),
+ (39.9771, -75.1685, "FM29jx", "Philadelphia"),
+ (-23.4028, -50.9766, "GG46mo", "Sao Paulo"),
+ ]:
+ converted = gps.clienthelpers.maidenhead(lat, lon)
+ if converted != maidenhead:
+ print >>sys.stderr, "maidenhead test: from %s %s (%s) expected %s got %s" \
+ % (lat, lon, location, maidenhead, converted)
+ else:
+ print "%s OK" % location
+
+if errors:
+ sys.exit(1)
+else:
+ sys.exit(0)
+