How to use the traffic.data.navaids.extent function in traffic

To help you get started, we’ve selected a few traffic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xoolive / traffic / tests / test_flight.py View on Github external
def test_bearing() -> None:
    ajaccio: Flight = get_sample(calibration, "ajaccio")
    ext_navaids = navaids.extent(ajaccio)
    assert ext_navaids is not None
    vor = ext_navaids["AJO"]
    assert vor is not None
    subset = ajaccio.bearing(vor).query("bearing.diff().abs() < .01")
    assert subset is not None
    assert (
        sum(
            1
            for chunk in subset.split("1T")
            if chunk.duration > pd.Timedelta("5 minutes")
        )
        == 7
    )
github xoolive / traffic / tests / test_navaid.py View on Github external
def test_iter() -> None:
    extent = (1, 2, 43, 44)
    nav_ext = navaids.extent(extent)
    assert nav_ext is not None
    assert sum(1 for n in nav_ext if n.name == "GAI") == 1
github xoolive / traffic / tests / test_navaid.py View on Github external
def test_extent() -> None:
    gaithersburg = navaids["GAI"]
    assert gaithersburg is not None
    assert gaithersburg.type == "NDB"
    nav_ext = navaids.extent(eurofirs["LFBB"])
    assert nav_ext is not None
    gaillac = nav_ext["GAI"]
    assert gaillac is not None
    assert gaillac.type == "VOR"
    assert gaillac.latlon == (43.95405556, 1.82416667)
github xoolive / traffic / traffic / core / flightplan.py View on Github external
if previous is None or next_ is None:
                    warnings.warn(f"Missing information around {elts[i]}")
                    continue

                if len(cumul) > 0:
                    # avoid obvious duplicates
                    elt1, *_, elt2 = cumul[-1].shape.coords
                    lon1, lat1, *_ = elt1
                    lon2, lat2, *_ = elt2
                    lon1, lon2 = min(lon1, lon2), max(lon1, lon2)
                    lat1, lat2 = min(lat1, lat2), max(lat1, lat2)
                    buf = 10  # conservative
                    # this one may return None
                    # (probably no, but mypy is whining)
                    n = navaids.extent(
                        (lon1 - buf, lon2 + buf, lat1 - buf, lat2 + buf,)
                    )
                else:
                    n = None

                if n is None:
                    n = navaids

                p1, p2 = n[previous.name], n[next_.name]
                if p1 is None or p2 is None:
                    warnings.warn(
                        f"Could not find {previous.name} or {next_.name}"
                    )
                    continue
                coords = [(p1.lon, p1.lat), (p2.lon, p2.lat)]
                cumul.append(
github xoolive / traffic / traffic / data / eurocontrol / b2b / flight.py View on Github external
def point(self, point: ElementTree.Element) -> Dict[str, Any]:
        pointId = point.find("pointId")
        if pointId is not None:
            from ....data import airways, navaids

            rep: Dict[str, Any] = {"FIX": pointId.text}
            if self.route is not None:
                airway = airways[self.route]
                if airway is not None:
                    nx = navaids.extent(airway)
                    if nx is not None:
                        fix = nx[pointId.text]
                        if fix is not None:
                            rep["latitude"] = fix.latitude
                            rep["longitude"] = fix.longitude
            return rep
        dbePoint = point.find("nonPublishedPoint-DBEPoint")
        if dbePoint is not None:
            return {"FIX": dbePoint.text}
        geopoint = point.find("nonPublishedPoint-GeoPoint")
        if geopoint is not None:
            angle = geopoint.find("position/latitude/angle")
            side = geopoint.find("position/latitude/side")
            assert angle is not None and side is not None
            lat = int(angle.text) / 10000  # type: ignore
            if side.text == "SOUTH":