+ """Creates a <wrmap> wikitext from geojson (as python types)."""
+ 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)
+
+ assert geojson['type'] == 'FeatureCollection'
+ json_features = geojson['features']
+ last_json_feature = None
+ for json_feature in json_features:
+ feature_xml = xml.etree.ElementTree.SubElement(wrmap_xml, json_feature['properties']['type'])
+ geo = json_feature['geometry']
+ if geo['type'] == 'Point':
+ feature_xml.text = create_wrmap_coordinates([geo['coordinates']])
+ if last_json_feature is not None:
+ last_json_feature.tail = '\n'
+ else:
+ if last_json_feature is not None:
+ last_json_feature.tail = '\n\n'
+ feature_xml.text = '\n' + create_wrmap_coordinates(geo['coordinates']) + '\n'
+ last_json_feature = feature_xml
+ feature_xml.attrib = json_feature['properties']
+ del feature_xml.attrib['type']
+
+ if last_json_feature is not None:
+ last_json_feature.tail = '\n\n'
+ return xml.etree.ElementTree.tostring(wrmap_xml, encoding='utf-8').decode('utf-8')