Adding classes Address and Coord, moving functions into the classes.
[treecutter.git] / xinclude / contact.py
index 879fd66fc8ef05a903dfdcead8405501f8348d0a..e7e0ab32820a0127f7344fd8b88b310cde60e5c1 100755 (executable)
@@ -3,6 +3,8 @@
 
 from vobject import readComponents
 import sys
+from address import Address
+from geohash import encode
 
 for arg in sys.argv[1:]:
   al = arg.split("=")
@@ -45,25 +47,25 @@ if 'n' in found.contents.keys():
   if not empty:
     pn += '<personname>'
     if n.prefix != '':
-      pn += '<honorific>'+n.prefix+'</honorific>'
+      pn += '<honorific>'+n.prefix+'</honorific> '
     if n.given != '':
-      pn += '<firstname>'+n.given+'</firstname>'
+      pn += '<firstname>'+n.given+'</firstname> '
     if n.additional != '':
-      pn += '<othername>'+n.additional+'</othername>'
+      pn += '<othername>'+n.additional+'</othername> '
     if n.family != '':
-      pn += '<surname>'+n.family+'</surname>'
+      pn += '<surname>'+n.family+'</surname> '
     if n.suffix != '':
-      pn += '<lineage>'+n.suffix+'</lineage>'
+      pn += '<lineage>'+n.suffix+'</lineage> '
     pn += '</personname>'
 
 ad = ''
 if 'adr' in found.contents.keys():
   for a, t in zip(found.contents['adr'],found.contents['tel']):
-    ad += '\n<address type="'+a.type_param+'">'
+    ad += '\n<address type="'+a.type_param+'"> '
     if a.value.street != '':
       ad += '<street>'+a.value.street+'</street>'
     if a.value.code != '':
-      ad += '<postcode>'+a.value.code+'</postcode>'
+      ad += '<postcode>'+a.value.code+'</postcode> '
     if a.value.city != '':
       ad += '<city>'+a.value.city+'</city>'
     if a.value.country != '':
@@ -71,6 +73,10 @@ if 'adr' in found.contents.keys():
     if t.value != '':
       ad += '<phone>'+t.value+'</phone>'
     ad += '</address>'
+    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():
@@ -83,12 +89,15 @@ if 'org' in found.contents.keys():
 
 url = ''
 if 'url' in found.contents.keys():
-  url += '<uri type="website"><link xlink:href="'+found.url.value+'"/></uri>'
+  url += '<uri type="website"><link xlink:href="'+found.url.value+'"/></uri> '
+
 geo = ''
-if 'geo' in found.contents.keys():
-  (lat,lon) = found.geo.value.split(';')
-  geo += '<uri type="location"><link xlink:href="http://www.openstreetmap.org/'+ \
-      '?mlat='+lat+'&amp;mlon='+lon+'&amp;zoom=18&amp;layers=M">geo:'+lat+','+lon+'</link></uri>'
+#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 = ''