Profiles in a dialog, the chip in the map's bottom-left corner picks one (the Design canvas' Vehicle): a car gains fuel, Euro class, stickers and vignettes / toll units with dates; drive mode's Menu steps through them. Speed limits by country for cars and over 3.5 t (public/js/speed_limits.js, sources in it): the route's roads (km, road class, country), the limit shown the lower of the sign and the profile's; the Route panel's countries with their limits and how the motorways are paid; past a border a card in drive mode (GridBorder). The itinerary in the Route panel (Itinerary): the trip's name, leave time, days start; per stop a night, stay and note, planned times, day headers; another screen's change shown where it happened with Undo
This commit is contained in:
1 parent
a6158f4083
commit
5e31dfaba9
15 files changed
+733
-169
No files matched your search
+18
-7
@@ -1,5 +1,6 @@
|
||||
import { isLoggedIn } from "/js/auth.js";
|
||||
import { onRouteChanged, requestReroute, notifyRouteProgress } from "/js/panels.js";
|
||||
import { onRouteChanged, requestReroute, notifyRouteProgress, currentVehicle } from "/js/panels.js";
|
||||
import { effectiveLimit } from "/js/speed_limits.js";
|
||||
import { elevationAt } from "/js/dem.js";
|
||||
|
||||
// The car's dashboard over the map, off the CAN signals (GET /api/can,
|
||||
@@ -108,7 +109,7 @@ function prepareRoute(route) {
|
||||
const maneuvers = route.properties.maneuvers.map((m) => { const at = start; start += m.km; return { ...m, at }; });
|
||||
let leg = 0;
|
||||
const viaKm = (route.properties.legs_km || []).slice(0, -1).map((length) => (leg += length)); // km at each via point
|
||||
return { coords, km, limits: route.properties.speed_limits, signals: route.properties.signals || [], maneuvers, viaKm };
|
||||
return { coords, km, limits: route.properties.speed_limits, roads: route.properties.roads || [], signals: route.properties.signals || [], maneuvers, viaKm };
|
||||
}
|
||||
|
||||
// Nearest point on the route: [km along it, meters off it]. Near the last
|
||||
@@ -282,9 +283,16 @@ export class DashboardControl {
|
||||
if (fresh && this._route && off > ON_ROUTE_M && (this._values.hdop ?? 0) <= MAX_HDOP) this._offFixes++;
|
||||
else if (off <= ON_ROUTE_M) this._offFixes = 0;
|
||||
if (this._route && this._offFixes < OFF_ROUTE_FIXES) {
|
||||
const { limits, signals, maneuvers } = this._route;
|
||||
const current = limits.findLast(([km]) => km <= at);
|
||||
const next = limits.find(([km, limit]) => km > at && limit !== current?.[1]);
|
||||
const { limits, roads, signals, maneuvers } = this._route;
|
||||
// the road's sign capped by the profile's own limit for that country and road class
|
||||
const limitAt = (k) => {
|
||||
const road = roads.findLast(([km]) => km <= k);
|
||||
const sign = limits.findLast(([km]) => km <= k)?.[1] ?? null;
|
||||
return road ? effectiveLimit(sign, road[2], road[1], currentVehicle) : sign;
|
||||
};
|
||||
const limit = limitAt(at);
|
||||
const nextKm = [...limits, ...roads].map(([km]) => km).filter((km) => km > at).sort((a, b) => a - b).find((km) => limitAt(km) !== limit);
|
||||
const next = nextKm != null ? [nextKm, limitAt(nextKm)] : null;
|
||||
const signal = signals.find(([, , km]) => km > at);
|
||||
const index = maneuvers.findIndex((m) => m.at > at + 0.005);
|
||||
const maneuver = maneuvers[index];
|
||||
@@ -295,8 +303,9 @@ export class DashboardControl {
|
||||
this._progress(at);
|
||||
}
|
||||
this._nav = {
|
||||
limit: current?.[1] ?? null,
|
||||
limit,
|
||||
next: next && { limit: next[1], m: (next[0] - at) * 1000 },
|
||||
country: roads.findLast(([km]) => km <= at)?.[2] ?? null,
|
||||
signal: signal && (signal[2] - at) * 1000,
|
||||
maneuver: maneuver && { ...maneuver, m: (maneuver.at - at) * 1000 },
|
||||
then: maneuver && then && then.at - maneuver.at <= THEN_M / 1000 ? then : null,
|
||||
@@ -308,7 +317,9 @@ export class DashboardControl {
|
||||
return;
|
||||
}
|
||||
this._progress(null);
|
||||
this._nav = { limit: this._road?.speed_limit ?? null, offRoute: !!this._route, street: this._road?.name, signal: this._signalAhead(position) };
|
||||
const road = this._road;
|
||||
this._nav = { limit: road ? effectiveLimit(road.speed_limit ?? null, road.country, road.road_class, currentVehicle) : null,
|
||||
offRoute: !!this._route, street: road?.name, signal: this._signalAhead(position), country: road?.country ?? null };
|
||||
if (this._route && (speed ?? 0) >= MOVING_MS && Date.now() - this._rerouteAt >= REROUTE_EVERY_MS) {
|
||||
this._rerouteAt = Date.now();
|
||||
requestReroute(position, this._route.viaKm.filter((km) => km <= this._lastAt).length);
|
||||
|
||||
Reference in new issue
Block a user