traffic/algorithms/navigation.py
def aligned_on_runway(
        self, airport: Union[str, "Airport"]
    ) -> Iterator["Flight"]:
        """Iterates on all segments of trajectory matching a runway of the
        given airport.

        Example usage:

        >>> sum(1 for _ in belevingsvlucht.aligned_on_runway("EHAM"))
        2
        """

        from ..data import airports

        # The following cast secures the typing
        self = cast("Flight", self)

        _airport = airports[airport] if isinstance(airport, str) else airport
        if _airport is None or _airport.runways.shape.is_empty:
            return None

        if isinstance(_airport.runways.shape, LineString):
            candidate_shapes = [
                LineString(list(self.xy_time)).intersection(
                    _airport.runways.shape.buffer(5e-4)
                )
            ]
        else:
            candidate_shapes = [
                LineString(list(self.xy_time)).intersection(
                    on_runway.buffer(5e-4)
                )
                for on_runway in _airport.runways.shape
            ]

        for intersection in candidate_shapes:
            if intersection.is_empty:
                continue
            if isinstance(intersection, LineString):
                (*_, start), *_, (*_, stop) = intersection.coords
                segment = self.between(start, stop, strict=False)
                if segment is not None:
                    yield segment
            if isinstance(intersection, MultiLineString):
                (*_, start), *_, (*_, stop) = intersection[0].coords
                for chunk in intersection:
                    (*_, start_bak), *_, (*_, stop) = chunk.coords
                    if stop - start > 40:  # crossing runways and back
                        start = start_bak
                segment = self.between(start, stop, strict=False)
                if segment is not None:
                    yield segment
Iterates on all segments of trajectory matching a runway of the
        given airport.

        Example usage:

        >>> sum(1 for _ in belevingsvlucht.aligned_on_runway("EHAM"))
        2
        
Iterates on all segments of trajectory matching a runway of the
given airport.

Example usage.


Iterates on all segments of trajectory matching a runway of the given airport . Example usage .
def aligned_on_runway(
        self, airport: Union[str, "Airport"]
    ) -> Iterator["Flight"]:
        from ..data import airports
        self = cast("Flight", self)
        _airport = airports[airport] if isinstance(airport, str) else airport
        if _airport is None or _airport.runways.shape.is_empty:
            return None
        if isinstance(_airport.runways.shape, LineString):
            candidate_shapes = [
                LineString(list(self.xy_time)).intersection(
                    _airport.runways.shape.buffer(5e-4)
                )
            ]
        else:
            candidate_shapes = [
                LineString(list(self.xy_time)).intersection(
                    on_runway.buffer(5e-4)
                )
                for on_runway in _airport.runways.shape
            ]
        for intersection in candidate_shapes:
            if intersection.is_empty:
                continue
            if isinstance(intersection, LineString):
                (*_, start), *_, (*_, stop) = intersection.coords
                segment = self.between(start, stop, strict=False)
                if segment is not None:
                    yield segment
            if isinstance(intersection, MultiLineString):
                (*_, start), *_, (*_, stop) = intersection[0].coords
                for chunk in intersection:
                    (*_, start_bak), *_, (*_, stop) = chunk.coords
                    if stop - start > 40:  
                        start = start_bak
                segment = self.between(start, stop, strict=False)
                if segment is not None:
                    yield segment
def aligned_on_runway ( self , airport : Union [ str , "Airport" ] ) -> Iterator [ "Flight" ] : from . . data import airports self = cast ( "Flight" , self ) _airport = airports [ airport ] if isinstance ( airport , str ) else airport if _airport is None or _airport . runways . shape . is_empty : return None if isinstance ( _airport . runways . shape , LineString ) : candidate_shapes = [ LineString ( list ( self . xy_time ) ) . intersection ( _airport . runways . shape . buffer ( 5e-4 ) ) ] else : candidate_shapes = [ LineString ( list ( self . xy_time ) ) . intersection ( on_runway . buffer ( 5e-4 ) ) for on_runway in _airport . runways . shape ] for intersection in candidate_shapes : if intersection . is_empty : continue if isinstance ( intersection , LineString ) : ( * _ , start ) , * _ , ( * _ , stop ) = intersection . coords segment = self . between ( start , stop , strict = False ) if segment is not None : yield segment if isinstance ( intersection , MultiLineString ) : ( * _ , start ) , * _ , ( * _ , stop ) = intersection [ 0 ] . coords for chunk in intersection : ( * _ , start_bak ) , * _ , ( * _ , stop ) = chunk . coords if stop - start > 40 : start = start_bak segment = self . between ( start , stop , strict = False ) if segment is not None : yield segment
Iterates on all segments of trajectory matching a runway of the
given airport.
Iterates on all segments of trajectory matching a runway of the given airport .
"""Iterates on all segments of trajectory matching a runway of the
        given airport.

        Example usage:

        >>> sum(1 for _ in belevingsvlucht.aligned_on_runway("EHAM"))
        2
        """ # The following cast secures the typing # crossing runways and back
self
airport
Union[str, "Airport"]