Add GPX generation

This commit is contained in:
jude
2024-02-25 15:11:38 +00:00
parent 3a0a59c76f
commit 0c69ba5d9e
4 changed files with 47 additions and 2 deletions
+30
View File
@@ -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>')