The wrmappathcache table is updated now.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 3 Jul 2011 21:23:57 +0000 (21:23 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 3 Jul 2011 21:23:57 +0000 (21:23 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/wrpylib@864 7aebc617-e5e2-0310-91dc-80fb5f6d2477

setup.py
wrpylib/wrmwcache.py

index 534cab975fec34088a2ddda00ba17661fe5b5bb5..982a8d02f63c921c56e32630c398a38eeed3d77f 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
 from setuptools import setup
 
 setup(name='wrpylib',
-    version='0.0.13',
+    version='0.0.14',
     description='Winterrodeln Python Library',
     author='Philipp Spitzer',
     author_email='philipp.spitzer@winterrodeln.org',
index f71566f9ef75a129099d511d1a17ae54e30767bc..97faa60391e6dc54aceec1868f811d6f7261951d 100644 (file)
@@ -184,14 +184,25 @@ def update_wrmapcache(connection):
             result = mwmarkup.parse_googlemap(sledrun_page.old_text)
             if not result is None:
                 center, zoom, coords, paths = result
+                # Points
                 for coord in coords:
                     lon, lat, point_type, label = coord
                     point_types = {u'Gasthaus': u'hut', u'Haltestelle': u'busstop', u'Parkplatz': u'carpark', u'Achtung': u'warning'}
                     if not point_type is None:
-                        if not point_types.has_key(point_type): raise RuntimeError('Unknown point type {0}'.format(point_type))
+                        if not point_types.has_key(point_type): raise RuntimeError(u'Unknown point type {0}'.format(point_type))
                         point_type = point_types[point_type]
-                        sql = 'insert into wrmappointcache (page_id, type, point, label) values (%s, %s, POINT(%s, %s), %s)'
+                        sql = u'insert into wrmappointcache (page_id, type, point, label) values (%s, %s, POINT(%s, %s), %s)'
                         connection.execute(sql, (sledrun_page.page_id, point_type, lon, lat, None))
+                # Paths
+                for path_type, coords in paths:
+                    path_type = path_type.lower()
+                    path_types = {u'6#ff014e9a': u'sledrun', u'6#ffe98401': u'walkup', u'6#ff7f7fff': u'alternative', u'3#ff000000': u'lift'}
+                    if not path_types.has_key(path_type): raise RuntimeError(u'Unknown path type {0}'.format(path_type))
+                    path_type = path_types[path_type]
+                    path = u", ".join(["{0} {1}".format(lon, lat) for lon, lat, symbol, title in coords])
+                    path = u'LineString({0})'.format(path)
+                    sql = u'insert into wrmappathcache (path, page_id, type) values (GeomFromText(%s), %s, %s)'
+                    connection.execute(sql, (path, sledrun_page.page_id, path_type))
         except RuntimeError as e:
             error_msg = u"Error at sledrun '{0}': {1}".format(sledrun_page.page_title, unicode(e))
             transaction.rollback()