fix distance calculation
This commit is contained in:
@@ -130,7 +130,11 @@ def _gps_stats(
|
||||
if not has_data:
|
||||
return device_dist, None, None, None
|
||||
|
||||
distance_m = device_dist if device_dist is not None else round(total_dist_m, 1)
|
||||
# Fall back to haversine distance if device recorded 0 but we computed real GPS distance
|
||||
if device_dist is not None and device_dist > 0:
|
||||
distance_m = device_dist
|
||||
else:
|
||||
distance_m = round(total_dist_m, 1) if total_dist_m > 0 else device_dist
|
||||
moving_time_s = moving_s if moving_s > 0 else None
|
||||
avg_speed_kmh = (moving_dist_m / moving_s) * 3.6 if moving_s > 0 else None
|
||||
# Prefer device speed for max (more stable than GPS-derived per-second spikes)
|
||||
|
||||
Reference in New Issue
Block a user