diff conv.py @ 0:fb5784aa45e6 default tip

from monotone. problematic https vs v2 API
author Matt Johnston <matt@ucc.asn.au>
date Sun, 21 Oct 2012 23:03:51 +0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/conv.py	Sun Oct 21 23:03:51 2012 +0800
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# This Python file uses the following encoding: utf-8
+
+import re
+import sys
+
+s = """
+PerthAP: 31°57'34.78"S 115°52'20.29"E
+WannerooAP: 31°47'26.03"S 115°49'12.34"E
+Belmont2: 31°57'34.19"S 115°55'42.52"E
+MitchLand: 31°47'17.81"S 115°46'10.70"E
+Mystic: 31°46'19.51"S 115°45'43.89"E
+NHE (Welvis): 31°46'29.52"S 115°49'7.87"E
+Doubleview: 31°53'41.14"S 115°46'50.86"E
+BelmontAP: 31°57'4.63"S 115°55'15.38"E
+Zaphod: 31°46'13.77"S 115°46'11.24"E
+TIC Hill: 31°49'32.77"S 116°3'51.87"E
+kaelnorr: 31°40'40.79"S 115°42'58.29"E
+"""
+
+l = s.split('\n')
+
+r = re.compile(r'(\d+)°(\d+)\'([\d\.]+)".')
+
+def coord_to_decimal(coord):
+		lparts = r.match(coord)
+		deg, min, sec = map(float, lparts.groups())
+		val = deg + min/60.0 + sec/(60.0**2)
+
+		return val
+
+for i in l:
+	try:
+		name, coords = i.split(':')
+
+		lat, long = coords.strip().split()
+
+		lat_dec = -coord_to_decimal(lat)
+		long_dec = coord_to_decimal(long)
+
+		print '"%s": [%f, %f, "%s", ""],' % (name.lower(), lat_dec, long_dec, name)
+		
+	except Exception, e:
+		print>>sys.stderr, "Error for line '%s': %s" % (i, e)
+		continue
+
+