Dead reckoning in a tunnel: no fix for 3 s (or mode < 2) on the trip's route, the position carried along it (estimated: true, a grey arrow) by the car's CAN speed (vehicle.speed) when there is one, the average speed of the last ~20 s otherwise, up to 10 min (App.gnss_position, TripStore.ahead)

This commit is contained in:
randy committed 2026-12-02 18:24:47 +01:00
1 parent 7fdc0114e6
commit 7204355510
8 files changed
+143 -18

No files matched your search

+14
View File
@@ -97,6 +97,20 @@ module Maptool
best
end
# Dead reckoning along the line: from the point nearest `position`,
# `meters` further on — [[lon, lat], bearing °], or nil if `position`
# is more than ON_ROUTE_M off it (no telling where the car went then).
# Stops at the line's end.
def self.ahead(coords, position, meters)
at, off = locate(coords, position)
return nil if off > ON_ROUTE_M
km = coords.each_cons(2).reduce([0.0]) { |acc, (a, b)| acc << acc.last + GnssSim.meters(a, b) / 1000 }
to = [at + meters / 1000.0, km.last].min
here = GnssSim.point_at(coords, km, to)
[here, GnssSim.bearing(GnssSim.point_at(coords, km, [to - 0.02, 0].max), GnssSim.point_at(coords, km, [to + 0.02, km.last].min)).round(1)]
end
# points: [{ lngLat: [lon, lat], name:, nav:, passed: }]. Routes through
# the ones not passed with the block (locations, vehicle id, avoid → the
# /api/route Feature, may raise Routing errors) unless only names/nav