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'][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'][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],
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:
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 = []
# 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({
- 'type': 'feature',
+ 'type': 'Feature',
'geometry': {'type': 'Point', 'coordinates': [lon, lat]},
'properties': properties})
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})
- 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):