import wrpylib.wrvalidators
import wrpylib.mwmarkup
-WRMAP_POINT_TYPES = ['gasthaus', 'haltestelle', 'parkplatz', 'achtung', 'punkt']
+WRMAP_POINT_TYPES = ['gasthaus', 'haltestelle', 'parkplatz', 'achtung', 'foto', 'verleih', 'punkt']
WRMAP_LINE_TYPES = ['rodelbahn', 'gehweg', 'alternative', 'lift', 'anfahrt', 'linie']
return results
-def googlemap_to_wrmap(center, zoom, coords, paths):
+def googlemap_to_wrmap(attributes, coords, paths):
"""Converts the output of parse_googlemap to the GeoJSON format wrmap uses.
:returns: (GeoJSON as nested Python datatypes)
"""
geojson = {
'type': 'FeatureCollection',
'features': json_features,
- 'properties': {'lon': center[0], 'lat': center[1], 'zoom': zoom}}
+ 'properties': attributes}
return geojson
def parse_wrmap(wikitext):
- """Parses the (unicode) u'<wrmap ...>content</wrmap>' of the Winterrodeln wrmap extension
- out of a page. If wikitext does not contain the wrmap extension text None is returned.
- If the wrmap contains invalid formatted lines, a ParseError is raised.
+ """Parses the (unicode) u'<wrmap ...>content</wrmap>' of the Winterrodeln wrmap extension.
+ If wikitext does not contain the <wrmap> tag or if the <wrmap> tag contains
+ invalid formatted lines, a ParseError is raised.
+ Use wrpylib.mwmarkup.find_tag(wikitext, 'wrmap') to find the wrmap tag within an arbitrary
+ wikitext before using this function.
- :param wikitext: wikitext containing the template. Example:
+ :param wikitext: wikitext containing only the template. Example:
wikitext = u'''
<wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
wrmap_xml = xml.etree.ElementTree.Element('wrmap')
wrmap_xml.text = '\n\n'
for k, v in geojson['properties'].iteritems():
- wrmap_xml.attrib[k] = str(v)
+ if k in ['lon', 'lat']:
+ wrmap_xml.attrib[k] = '{:.6f}'.format(v)
+ else:
+ wrmap_xml.attrib[k] = str(v)
assert geojson['type'] == 'FeatureCollection'
json_features = geojson['features']