Beispiel #1
0
def test_extent() -> None:
    gaithersburg = navaids["GAI"]
    assert gaithersburg is not None
    assert gaithersburg.type == "NDB"
    gaillac = navaids.extent(eurofirs["LFBB"])["GAI"]
    assert gaillac is not None
    assert gaillac.type == "VOR"
    assert gaillac.latlon == (43.95405556, 1.82416667)
Beispiel #2
0
def test_bearing() -> None:
    ajaccio: Flight = get_sample(calibration, "ajaccio")

    vor = navaids.extent(ajaccio)["AJO"]
    assert vor is not None
    gen = ajaccio.bearing(vor).query("bearing.diff().abs() < .01").split("1T")
    assert (sum(1 for chunk in gen
                if chunk.duration > pd.Timedelta("5 minutes")) == 7)
Beispiel #3
0
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)
Beispiel #4
0
    def _parse(self) -> List[Any]:
        cumul: List[Any] = list()  # List[ShapelyMixin] ?
        elts = self.decompose()

        for i, e in enumerate(elts):
            if isinstance(e, Airway):
                if isinstance(e, SID):
                    cumul.append(e.get(self.origin))
                elif isinstance(e, STAR):
                    cumul.append(e.get(self.destination))
                else:
                    handle = e.get()
                    if handle is None:
                        warnings.warn(f"Missing information about {elts[i]}")
                        continue

                    previous, next_ = elts[i - 1], elts[i + 1]
                    if previous is None or next_ is None:
                        warnings.warn(f"Missing information around {elts[i]}")
                        continue

                    try:
                        cumul.append(handle[previous.name, next_.name])
                    except Exception as ex:
                        warnings.warn(
                            f"Missing information around {elts[i]}: {ex}")
                        continue

            if isinstance(e, DirectPoint):
                from traffic.data import navaids

                previous, next_ = elts[i - 1], elts[i]

                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(
                    Route(
                        LineString(coordinates=coords),
                        "DCT",
                        [previous.name, next_.name],
                    ))
                continue

            if isinstance(e, Direct):
                from traffic.data import navaids

                previous, next_ = elts[i - 1], elts[i + 1]
                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(
                    Route(
                        LineString(coordinates=coords),
                        "DCT",
                        [previous.name, next_.name],
                    ))

        return cumul
Beispiel #5
0
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
Beispiel #6
0
def test_iter() -> None:
    extent = (1, 2, 43, 44)
    short_navaids = navaids.extent(extent)
    assert sum(1 for n in short_navaids if n.name == "GAI") == 1