Add GPX generation
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
from html import escape
|
||||
|
||||
with open('data.json') as data_file:
|
||||
data = json.load(data_file)
|
||||
|
||||
with open('Megaliths.gpx', 'w') as gpx_file:
|
||||
gpx_file.write('''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gpx xmlns="http://www.topografix.com/GPX/1/1"
|
||||
version="1.1"
|
||||
creator="megalithosm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
|
||||
<metadata>
|
||||
<name>Megalith sites</name>
|
||||
<author>
|
||||
<name>Jude Southworth</name>
|
||||
</author>
|
||||
</metadata>''')
|
||||
|
||||
for poi in data:
|
||||
gpx_file.write(
|
||||
'''
|
||||
<wpt lat="{}" lon="{}">
|
||||
<name>{}</name>
|
||||
<type>{}</type>
|
||||
<url>{}</url>
|
||||
</wpt>'''.format(poi['lat'], poi['lng'], escape(poi['name']), poi['type'], poi['url'])
|
||||
)
|
||||
gpx_file.write('</gpx>')
|
||||
Reference in New Issue
Block a user