mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
feat(client): route every day through Valhalla where the TREK services or an own Valhalla answer
With the TREK services or an own Valhalla, the day plan, the road trip and the other ways of a leg are routed by Valhalla on foot, by bike and by car, twenty locations a request. A day it cannot answer (relay refusal, time out, no way for a leg) goes to OSRM whole and without a word; it is never handed to FOSSGIS unless it avoids something only Valhalla can avoid. With FOSSGIS nothing changes: OSRM routes the days and Valhalla the avoidances. A Valhalla answer is cached under its own key beside the OSRM one, so switching engines never serves a day from the other engine. The Valhalla day routing moves out of RouteCalculator into valhallaDayRoute.ts.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
import type { DistanceUnit } from '../../types';
|
||||
import { formatDistance } from '../../utils/units';
|
||||
|
||||
/** The unit a route's texts are written in, which is why it is part of the route cache key. */
|
||||
export function getDistanceUnit(): DistanceUnit {
|
||||
return useSettingsStore.getState().settings.distance_unit === 'imperial' ? 'imperial' : 'metric';
|
||||
}
|
||||
|
||||
/** A routed distance as the connectors show it: metres below a kilometre, else the user's unit. */
|
||||
export function formatRouteDistance(meters: number): string {
|
||||
const unit = getDistanceUnit();
|
||||
if (unit === 'metric' && meters < 1000) {
|
||||
return `${Math.round(meters)} m`;
|
||||
}
|
||||
return formatDistance(meters / 1000, unit);
|
||||
}
|
||||
|
||||
/** A routed time in hours and minutes, the minutes rounded down. */
|
||||
export function formatDuration(seconds: number): string {
|
||||
const h = Math.floor(seconds / 3600);
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
if (h > 0) {
|
||||
return `${h} h ${m} min`;
|
||||
}
|
||||
return `${m} min`;
|
||||
}
|
||||
Reference in New Issue
Block a user