Updated parse_googlemap but the test doesn't pass yet.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Mon, 26 Aug 2013 20:58:07 +0000 (20:58 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Mon, 26 Aug 2013 20:58:07 +0000 (20:58 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@1528 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_wrmwmarkup.py
wrpylib/wrmwmarkup.py

index 5ebfe1f6980f0c4f512ddefa854654ace5b84278..189c7c152f8fcad01b85bcf07b1032e3810b4e17 100644 (file)
@@ -72,17 +72,17 @@ def test_parse_googlemap():
     47.112408,11.271119
     </googlemap>
     '''
     47.112408,11.271119
     </googlemap>
     '''
-    attributes, json = wrpylib.wrmwmarkup.parse_googlemap(wikitext)
-    assert attributes['lon'] == 11.272337
-    assert attributes['lat'] == 47.113291
-    assert attributes['zoom'] == 15
-    assert json['features'][0]['properties']['type'] == 'carpark'
+    json = wrpylib.wrmwmarkup.parse_googlemap(wikitext)
+    assert json['properties']['lon'] == 11.272337
+    assert json['properties']['lat'] == 47.113291
+    assert json['properties']['zoom'] == 15
+    assert json['features'][0]['properties']['type'] == 'parkplatz'
     assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
     assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
     assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
     assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
-    assert json['features'][1]['properties']['type'] == 'inn'
+    assert json['features'][1]['properties']['type'] == 'gasthaus'
     assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
     assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
     assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
     assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
-    assert json['features'][2]['properties']['type'] == 'sledrun'
+    assert json['features'][2]['properties']['type'] == 'rodelbahn'
     assert json['features'][2]['geometry']['coordinates'] == [
         [11.266262, 47.114715],
         [11.268381, 47.114135],
     assert json['features'][2]['geometry']['coordinates'] == [
         [11.266262, 47.114715],
         [11.268381, 47.114135],
index a27525b292ad21ee3b4e03c53520beff36d34a04..1e9127bf185df8701cffcd7d8bec6f0e95c72a62 100644 (file)
@@ -327,7 +327,7 @@ def find_all_templates(wikitext, find_func):
 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.
 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 RuntimeError is raised.
+    If the googlemap contains invalid formatted lines, a ParseError is raised.
 
     :param wikitext: wikitext containing the template. Example:
 
 
     :param wikitext: wikitext containing the template. Example:
 
@@ -345,7 +345,7 @@ def parse_googlemap(wikitext):
     47.112408,11.271119
     </googlemap>
     '''
     47.112408,11.271119
     </googlemap>
     '''
-    :returns: (attributes, GeoJSON as Python datatypes)
+    :returns: (GeoJSON as nested Python datatypes)
     """
     center, zoom, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
     json_features = []
     """
     center, zoom, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
     json_features = []
@@ -353,10 +353,10 @@ def parse_googlemap(wikitext):
     # point
     for point in coords:
         lon, lat, symbol, title = point
     # point
     for point in coords:
         lon, lat, symbol, title = point
-        properties = {'type': symbol}
+        properties = {'type': symbol.lower()}
         if title: properties['name'] = title
         json_features.append({
         if title: properties['name'] = title
         json_features.append({
-            'type': 'feature',
+            'type': 'Feature',
             'geometry': {'type': 'Point', 'coordinates': [lon, lat]},
             'properties': properties})
         
             'geometry': {'type': 'Point', 'coordinates': [lon, lat]},
             'properties': properties})
         
@@ -365,14 +365,17 @@ def parse_googlemap(wikitext):
         style, entries = path
         properties = {'type': 'line'}
         json_features.append({
         style, entries = path
         properties = {'type': 'line'}
         json_features.append({
-            'type': 'feature',
+            'type': 'Feature',
             'geometry': {
                 'type': 'LineString',
                 'coordinates': [[lon, lat] for lon, lat, symbol, title in entries]},
             'properties': properties})
 
             'geometry': {
                 'type': 'LineString',
                 'coordinates': [[lon, lat] for lon, lat, symbol, title in entries]},
             'properties': properties})
 
-    geojson = {'type': 'FeatureCollection', 'features': json_features}
-    return {'lon': center[0], 'lat': center[1], 'zoom': zoom}, geojson
+    geojson = {
+            'type': 'FeatureCollection',
+            'features': json_features,
+            'properties': {'lon': center[0], 'lat': center[1], 'zoom': zoom}}
+    return geojson
 
 
 def parse_wrmap_coordinates(coords):
 
 
 def parse_wrmap_coordinates(coords):