Skip to content

Commit

Permalink
improve Flight.moving for stop detection of inbound traffic (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelDELAIR authored Jun 21, 2021
1 parent 8f65a97 commit 05681c9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions traffic/algorithms/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,18 +908,17 @@ def moving(
if moving is None:
return None

first_segment = next(
(
segment
for segment in moving.split("1T")
if segment.longer_than(time_threshold)
),
None,
)
if first_segment is None:
segment = None
first_segment = None
for segment in moving.split("1T"):
if segment.longer_than(time_threshold) and first_segment is None:
first_segment = segment
last_segment = segment

if first_segment is None or last_segment is None:
return None

return self.after(first_segment.start)
return self.between(first_segment.start, last_segment.stop)

def pushback(
self,
Expand Down

0 comments on commit 05681c9

Please sign in to comment.