Renamed function parse_googlemap to googlemap_to_wrmap and changed input parameters.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 8 Sep 2013 21:14:24 +0000 (21:14 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 8 Sep 2013 21:14:24 +0000 (21:14 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@1536 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_wrmwmarkup.py
wrpylib/wrmwmarkup.py

index 393db5c299b01f92bc1180ea6492ca47ff175cd3..c38c823ee8a63e86f362532526171da190c82694 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python2.7
 # -*- coding: iso-8859-15 -*-
 import wrpylib.wrmwmarkup
+import wrpylib.mwmarkup
 import formencode
 import textwrap
 
@@ -58,7 +59,7 @@ def test_gasthausbox_to_inn():
     wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
 
 
-def test_parse_googlemap():
+def test_googlemap_to_wrmap():
     wikitext = u'''
     <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
     (Parkplatz)47.114958,11.266026
@@ -73,7 +74,8 @@ def test_parse_googlemap():
     47.112408,11.271119
     </googlemap>
     '''
-    json = wrpylib.wrmwmarkup.parse_googlemap(wikitext)
+    center, zoom, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
+    json = wrpylib.wrmwmarkup.googlemap_to_wrmap(center, zoom, coords, paths)
     assert json['properties']['lon'] == 11.272337
     assert json['properties']['lat'] == 47.113291
     assert json['properties']['zoom'] == 15
index 715dbac2fe8307a34a6d82633c6a15f1d3145d7d..6877f472a67c942c9b180ea293517bd542d0a3b0 100644 (file)
@@ -324,30 +324,10 @@ def find_all_templates(wikitext, find_func):
     return results
 
 
-def parse_googlemap(wikitext):
-    """Parses the (unicode) u'<googlemap ...>content</googlemap>' of the googlemap extension
-    out of a page. If wikitext does not contain the googlemaps extension text None is returned.
-    If the googlemap contains invalid formatted lines, a ParseError is raised.
-
-    :param wikitext: wikitext containing the template. Example:
-
-    wikitext = '''
-    <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
-    (Parkplatz)47.114958,11.266026
-    Parkplatz
-    
-    (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
-    6#FF014E9A
-    47.114715,11.266262
-    47.114135,11.268381
-    47.113421,11.269322
-    47.11277,11.269979
-    47.112408,11.271119
-    </googlemap>
-    '''
+def googlemap_to_wrmap(center, zoom, coords, paths):
+    """Converts the output of parse_googlemap to the GeoJSON format wrmap uses.
     :returns: (GeoJSON as nested Python datatypes)
     """
-    center, zoom, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
     json_features = []
 
     # point