fix: require >= 30 min duration for flying classification
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
2026-03-14 05:08:16 +00:00
parent fa177e0342
commit 67449c3047

View File

@@ -114,7 +114,8 @@ def _max_speed_from_path(timeline_path):
return max_speed
MIN_FLIGHT_DISTANCE_MILES = 50 # Shorter than this cannot be a flight
MIN_FLIGHT_DISTANCE_MILES = 50 # Shorter than this cannot be a flight
MIN_FLIGHT_DURATION_HOURS = 0.5 # Less than 30 minutes cannot be a flight
def _speed_from_activity_segment(activity, seg_start_ts, seg_end_ts):
"""Detect flights from an activity segment's start/end coords and timestamps.
@@ -140,7 +141,7 @@ def _speed_from_activity_segment(activity, seg_start_ts, seg_end_ts):
return 0.0, 0.0
dist_miles = _haversine_miles(slat, slng, elat, elng)
speed = dist_miles / dt_hours
return dist_miles, speed
return dist_miles, speed, dt_hours
class WtImportTimelineWizard(models.TransientModel):
@@ -310,8 +311,10 @@ class WtImportTimelineWizard(models.TransientModel):
# to rule out GPS drift (short jumps can look fast due to imprecise timestamps)
seg_start = _parse_ts(seg.get('startTime'))
seg_end = _parse_ts(seg.get('endTime'))
dist, speed = _speed_from_activity_segment(activity, seg_start, seg_end)
if dist >= MIN_FLIGHT_DISTANCE_MILES and speed > 150:
dist, speed, dt_hours = _speed_from_activity_segment(activity, seg_start, seg_end)
if (dist >= MIN_FLIGHT_DISTANCE_MILES
and speed > 150
and dt_hours >= MIN_FLIGHT_DURATION_HOURS):
pending_mode = 'flying'
continue