mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 03:27:33 +08:00
[Flightplan lib] Retrieve flight plan over http if needed. (#3431)
Doxygen / build (push) Waiting to run
Doxygen / build (push) Waiting to run
Co-authored-by: Fabien-B <Fabien-B@github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ from lxml import etree
|
|||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
import sys
|
import sys
|
||||||
from xml_utils import get_attrib, get_attrib_default
|
from xml_utils import get_attrib, get_attrib_default
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
class FlightPlan:
|
class FlightPlan:
|
||||||
|
|
||||||
@@ -42,11 +42,15 @@ class FlightPlan:
|
|||||||
self.alt = None
|
self.alt = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(fp_xml):
|
def parse(fp_xml: str):
|
||||||
fp = FlightPlan()
|
if fp_xml.startswith("file://"):
|
||||||
fp_tree = etree.parse(fp_xml)
|
fp_tree = etree.parse(fp_xml)
|
||||||
|
elif fp_xml.startswith("http://"):
|
||||||
|
tmp_file, _ = urllib.request.urlretrieve(fp_xml)
|
||||||
|
fp_tree = etree.parse(tmp_file)
|
||||||
fp_element = fp_tree.find("flight_plan")
|
fp_element = fp_tree.find("flight_plan")
|
||||||
|
|
||||||
|
fp = FlightPlan()
|
||||||
fp.name = get_attrib(fp_element, "name")
|
fp.name = get_attrib(fp_element, "name")
|
||||||
fp.lat0 = get_attrib(fp_element, "lat0")
|
fp.lat0 = get_attrib(fp_element, "lat0")
|
||||||
fp.lon0 = get_attrib(fp_element, "lon0")
|
fp.lon0 = get_attrib(fp_element, "lon0")
|
||||||
|
|||||||
Reference in New Issue
Block a user