4 example program to extract GPS data from a waypoint file, and create a GPX 5 file, for loading into google earth 7 from __future__
import print_function
8 from builtins
import range
12 from argparse
import ArgumentParser
13 parser = ArgumentParser(description=__doc__)
14 parser.add_argument(
"wpfiles", metavar=
"WP_FILE", nargs=
"+")
15 args = parser.parse_args()
17 from pymavlink
import mavwp
21 '''convert a wp file to a GPX file''' 25 outf = open(outfilename, mode=
'w')
29 outf.write(
'''<wpt lat="%s" lon="%s"> 33 ''' % (w.x, w.y, w.z, i))
36 outf.write(
'''<?xml version="1.0" encoding="UTF-8"?> 40 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 41 xmlns="http://www.topografix.com/GPX/1/0" 42 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> 53 for i
in range(wp.count()):
61 print(
"Created %s with %u points" % (outfilename, count))
64 for infilename
in args.wpfiles:
65 outfilename = infilename +
'.gpx'
def wp_to_gpx(infilename, outfilename)