chore: clean up remaining OSRM references and update settings
Some checks are pending
Security Scan / scout (push) Waiting to run
Some checks are pending
Security Scan / scout (push) Waiting to run
- Add 'amap' to map_provider valid values in settingsService - Remove outdated OSRM comments from useRouteCalculation, useTransportRoutes, DayPlanSidebar
This commit is contained in:
parent
536a43b75e
commit
29f6c4275d
@ -419,7 +419,7 @@ function useDayPlanSidebar(props: DayPlanSidebarProps) {
|
||||
const routeDayKey = routeDayIds.join(',')
|
||||
|
||||
// Per-segment travel times shown as connectors between a day's located stops.
|
||||
// Groups located places into runs (split at transports), one cached OSRM call per
|
||||
// Groups located places into runs (split at transports), one cached API call per
|
||||
// run keyed by the start place's assignment id, plus the hotel bookend legs. Shares
|
||||
// RouteCalculator's cache with the map. Runs for every day in routeDayIds — one
|
||||
// selected day on desktop, each Route-toggled day on mobile (#1374).
|
||||
@ -430,7 +430,7 @@ function useDayPlanSidebar(props: DayPlanSidebarProps) {
|
||||
const hotelName = (a: Accommodation) => (a as any).place_name || (a as any).reservation_title || ''
|
||||
|
||||
// Pure per-day plan: the drive runs (each ≥2 waypoints) and which hotel bookend
|
||||
// legs to draw. Side-effect free, so the async loop below only does OSRM I/O.
|
||||
// legs to draw. Side-effect free, so the async loop below only does routing I/O.
|
||||
const planDay = (dayId: number) => {
|
||||
const merged = mergedItemsMap[dayId] || []
|
||||
const runs: { id: number; lat: number; lng: number }[][] = []
|
||||
@ -500,7 +500,7 @@ function useDayPlanSidebar(props: DayPlanSidebarProps) {
|
||||
const legsByDay: Record<number, Record<number, RouteSegment>> = {}
|
||||
const hotelByDay: Record<number, { top?: { seg: RouteSegment; name: string }; bottom?: { seg: RouteSegment; name: string } }> = {}
|
||||
|
||||
// One cached OSRM call per waypoint pair; shares RouteCalculator's cache.
|
||||
// One cached API call per waypoint pair; shares RouteCalculator's cache.
|
||||
const legBetween = async (a: { lat: number; lng: number }, b: { lat: number; lng: number }): Promise<RouteSegment | undefined> => {
|
||||
try {
|
||||
const r = await calculateRouteWithLegs([a, b], { signal: controller.signal, profile: routeProfile })
|
||||
|
||||
@ -13,7 +13,7 @@ const NO_ACCOMMODATIONS: Accommodation[] = []
|
||||
|
||||
/**
|
||||
* Manages route calculation state for a selected day. Extracts geo-coded waypoints from
|
||||
* day assignments, draws a straight-line route immediately, then upgrades it to real OSRM
|
||||
* day assignments, draws a straight-line route immediately, then upgrades it to real
|
||||
* road geometry with per-segment durations. Aborts in-flight requests when the day changes.
|
||||
*/
|
||||
export function useRouteCalculation(tripStore: TripStoreState, selectedDayId: number | null, enabled: boolean = true, profile: 'driving' | 'walking' | 'cycling' = 'driving', accommodations: Accommodation[] = NO_ACCOMMODATIONS) {
|
||||
@ -161,7 +161,7 @@ export function useRouteCalculation(tripStore: TripStoreState, selectedDayId: nu
|
||||
if (runsWithHotel.length === 0) { setRoute(null); setRouteSegments([]); return }
|
||||
|
||||
// Draw straight lines immediately for snappiness, then upgrade to the real
|
||||
// OSRM road geometry.
|
||||
// road geometry.
|
||||
setRoute(straightLines())
|
||||
|
||||
const controller = new AbortController()
|
||||
@ -176,7 +176,7 @@ export function useRouteCalculation(tripStore: TripStoreState, selectedDayId: nu
|
||||
allLegs.push(...r.legs)
|
||||
} catch (err) {
|
||||
if (err instanceof Error && err.name === 'AbortError') throw err
|
||||
// OSRM failed for this run — fall back to a straight line, no times.
|
||||
// Routing failed for this run — fall back to a straight line, no times.
|
||||
polylines.push(run.map(p => [p.lat, p.lng] as [number, number]))
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ const ROAD_PROFILE: Record<string, 'driving' | 'cycling'> = {
|
||||
|
||||
// Beyond this straight-line distance a car/taxi/bike (or even coach) booking is
|
||||
// almost always a data quirk or an inter-continental hop the road router can't
|
||||
// resolve — keep the straight line and don't hammer the public OSRM demo.
|
||||
// resolve — keep the straight line and don't hammer the routing API.
|
||||
const MAX_ROUTE_KM = 2000
|
||||
|
||||
function haversineKm(a: { lat: number; lng: number }, b: { lat: number; lng: number }): number {
|
||||
|
||||
@ -41,7 +41,7 @@ const VALID_VALUES: Partial<Record<DefaultableKey, unknown[]>> = {
|
||||
distance_unit: ['metric', 'imperial'],
|
||||
time_format: ['12h', '24h'],
|
||||
dark_mode: [true, false, 'light', 'dark', 'auto'],
|
||||
map_provider: ['leaflet', 'mapbox-gl', 'maplibre-gl'],
|
||||
map_provider: ['leaflet', 'mapbox-gl', 'maplibre-gl', 'amap'],
|
||||
llm_provider: ['local', 'openai', 'anthropic'],
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user