By philippecmartin - 3/15/2016 1:51:58 PM
Hi, I was delighted to find out that SkyDemon connected to X-Plane after purchasing it. I noticed though that none of the export formats were fsm.
I wrote a small script that converts GPX to FSM (not perfect but working) and my question is.
I chose GPX since it is a documented format and I assume I can legally do that; is there a SkyDemon policy that says otherwise ?
Also: would it make more sense to use one of the other formats as input instead.
Note that I would be glad to share that script once stable.
Regards, Philippe
|
By philippecmartin - 3/24/2016 10:28:46 PM
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()
|
|