Here is the script if interested - needs python 2.7 installed
DEST = '{PATH TO XPLANE HERE}/Output/FMS plans/'
SOURCE = '{PATH TO SKYDEMON GPX HERE}/SkyDemon/Routes/*.gpx'
import xml.etree.ElementTree as ET
import os
#ref GPX:
http://www.topografix.com/GPX/1/1/import glob
ELEVATION = 'ele'
LATITUDE = 'lat'
LONGITUDE = 'lon'
SYM = 'sym'
#*******************************************************************************
#*******************************************************************************
#*******************************************************************************
class GPX2FSM:
#***************************************************************************
#***************************************************************************
#***************************************************************************
def __init__ (self):
pass
#***************************************************************************
#***************************************************************************
#***************************************************************************
def Convert(self, fn):
tree = ET.parse(fn)
root = tree.getroot()
fms = []
route = root.getchildren()[0]
fms.append('I')
fms.append('3 version')
fms.append('1')
fms.append('1')
index = 0
for wp in route:
d = wp.attrib
if LATITUDE in d and LONGITUDE in d:
lat = d[LATITUDE]
lon = d[LONGITUDE]
ele = '3000'
waypoint = 'WP%d' % index
wp_found = False
for c in wp.getchildren():
if -1 != c.tag.find(ELEVATION):
ele = c.text
if -1 != c.tag.find(SYM):
wp_found = True
waypoint = c.text
#fms.append('1 %s%d 3000 %s %s' % (WAYPOINT, index, lat, lon))
fms.append('1 %s %s %s %s' % (waypoint, ele, lat, lon))
if not wp_found:
index += 1
return fms
#*******************************************************************************
#*******************************************************************************
#*******************************************************************************
if __name__ == "__main__":
o = GPX2FSM()
files = glob.glob(SOURCE)
for src in files:
fms = o.Convert(src)
dst = DEST + 'conv-' + os.path.basename(src).split('.')[0] + '.fms'
print 'writing ' + dst
f = open (dst,'w')
for i in fms:
f.write(i + '\n')
f.close()