fix: detect flights via stop-to-stop speed (catches gaps with no activity segment)
This commit is contained in:
@@ -230,6 +230,19 @@ class WtImportTimelineWizard(models.TransientModel):
|
|||||||
stop['distance_from_previous'] = 0.0
|
stop['distance_from_previous'] = 0.0
|
||||||
stop['travel_time_from_previous'] = 0.0
|
stop['travel_time_from_previous'] = 0.0
|
||||||
|
|
||||||
|
# Post-processing: reclassify likely flights using stop-to-stop speed.
|
||||||
|
# Many flights have no activity segment or timelinePath data — Google just
|
||||||
|
# records a large gap between two distant visits. We catch those here.
|
||||||
|
for stop in stops[1:]:
|
||||||
|
dist = stop.get('distance_from_previous', 0.0)
|
||||||
|
tt = stop.get('travel_time_from_previous', 0.0)
|
||||||
|
if (dist >= MIN_FLIGHT_DISTANCE_MILES
|
||||||
|
and tt >= MIN_FLIGHT_DURATION_HOURS
|
||||||
|
and tt > 0):
|
||||||
|
implied_speed = dist / tt
|
||||||
|
if implied_speed > 150:
|
||||||
|
stop['travel_mode'] = 'flying'
|
||||||
|
|
||||||
LocationLog = self.env['wt.location.log']
|
LocationLog = self.env['wt.location.log']
|
||||||
existing = set(
|
existing = set(
|
||||||
r.arrived_at.strftime('%Y-%m-%d %H:%M:%S')
|
r.arrived_at.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|||||||
Reference in New Issue
Block a user