X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/blobdiff_plain/a9681d2ccd4cc22ddb864e8ffa2487cffa9f0a68..8d02e0732385ce5e6ae00311946ffdb0545f379b:/wrpylib/wrmwmarkup.py?ds=sidebyside
diff --git a/wrpylib/wrmwmarkup.py b/wrpylib/wrmwmarkup.py
index 7c63e27..bebca6d 100644
--- a/wrpylib/wrmwmarkup.py
+++ b/wrpylib/wrmwmarkup.py
@@ -10,7 +10,7 @@ import formencode
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']
@@ -324,7 +324,7 @@ def find_all_templates(wikitext, find_func):
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)
"""
@@ -361,7 +361,7 @@ def googlemap_to_wrmap(center, zoom, coords, paths):
geojson = {
'type': 'FeatureCollection',
'features': json_features,
- 'properties': {'lon': center[0], 'lat': center[1], 'zoom': zoom}}
+ 'properties': attributes}
return geojson
@@ -386,7 +386,7 @@ def parse_wrmap_coordinates(coords):
def parse_wrmap(wikitext):
"""Parses the (unicode) u'content' of the Winterrodeln wrmap extension.
- If wikitext does not contain the tax or if the tag contains
+ If wikitext does not contain the tag or if the 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.
@@ -498,7 +498,10 @@ def create_wrmap(geojson):
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']