17import xml.etree.ElementTree
as ET
25 Convert the point data located in filename into a lane element
29 xml = ET.parse(filename)
32 for coord
in root.findall(
".//{http://www.opengis.net/kml/2.2}coordinates"):
33 (lon, lat, _) = coord.text.split(
",")
34 out.append((lat.strip(), lon.strip()))
39 parser = argparse.ArgumentParser(
"Convert a KML file into a CSV file, to further process with RouteCreation_CSV2Yaml.py")
40 parser.add_argument(
"kml_input", help=
"KML input containing the desired route geometry")
41 parser.add_argument(
"default_speed", help=
"The default speed limit along the route")
42 parser.add_argument(
"csv_output", help=
"The file to write the CSV out to")
43 args = parser.parse_args()
44 print(
"Converting {} to CSV as {}".format(args.kml_input, args.csv_output))
45 output = open(args.csv_output,
"w")
46 output.write(
"Latitude,Longitude,Speed\n")
49 print(
"{} waypoints found. Using speed {} for all. Writing output...".format(len(waypoints), args.default_speed))
51 for waypoint
in waypoints:
52 output.write(
"{},{},{}\n".format(waypoint[0], waypoint[1], args.default_speed))
54 print(
"Wrote {} entries to {}.".format(count, args.csv_output))
57if __name__ ==
"__main__":
58 print(
"Running RouteCreation_KML2CSV.py...")
def convertKMLToWaypoints(filename)