X-Git-Url: https://source.tree.se/git?p=treecutter.git;a=blobdiff_plain;f=xinclude%2Fcontact.py;h=379a33607fff3e10a1da373c831600ab1474f5c8;hp=879fd66fc8ef05a903dfdcead8405501f8348d0a;hb=9b3290832eabbc01e6deccd6202a8e26b9ec507d;hpb=f0d3afa87c42104aaa795e0c2c0ad1f767b2768a
diff --git a/xinclude/contact.py b/xinclude/contact.py
index 879fd66..379a336 100755
--- a/xinclude/contact.py
+++ b/xinclude/contact.py
@@ -3,6 +3,38 @@
from vobject import readComponents
import sys
+from addr import mapimage, geocode
+from geohash import encode
+
+def coord2dms(coord):
+ ns = coord[0]
+ ew = coord[1]
+ mnt,sec = divmod(ns*3600,60)
+ deg,mnt = divmod(mnt,60)
+ out = u'''%d°%2d'%5.2f"%s''' % ( deg,mnt,sec,'N')
+ mnt,sec = divmod(ew*3600,60)
+ deg,mnt = divmod(mnt,60)
+ out += u''' %d°%2d'%05.2f"%s''' % ( deg,mnt,sec,'E')
+ return out
+
+
+def maplink(lat,lon):
+ return '''
+
+
+
+
+
+
+
+ geo:%s,%s
+
+
+ %s
+
+
+''' % (lat, lon, encode(float(lat), float(lon)), lat, lon, coord2dms((lat, lon)))
for arg in sys.argv[1:]:
al = arg.split("=")
@@ -11,6 +43,7 @@ for arg in sys.argv[1:]:
if al[0] == "xptr":
argument = al[1]
+
(cards,query) = argument.split('?')
(key, name) = query.split(':')
with open(cards, 'r') as f:
@@ -71,6 +104,10 @@ if 'adr' in found.contents.keys():
if t.value != '':
ad += ''+t.value+''
ad += ''
+ geostr = u''+a.value.street+', '+a.value.city+', '+a.value.country
+ (lat,lon) = geocode(geostr.encode('utf-8'))
+ mapimage([(float(lat),float(lon))])
+ ad += maplink(lat,lon)
o = ''
if 'org' in found.contents.keys():
@@ -85,10 +122,12 @@ url = ''
if 'url' in found.contents.keys():
url += ''
geo = ''
-if 'geo' in found.contents.keys():
- (lat,lon) = found.geo.value.split(';')
- geo += 'geo:'+lat+','+lon+''
+#if 'geo' in found.contents.keys():
+# (lat,lon) = found.geo.value.split(';')
+# mapimage([(float(lat),float(lon))])
+# # create picture
+# geo += maplink(lat,lon)
+
# Turn off email for now
email = ''