Documentation Index
Fetch the complete documentation index at: https://mintlify.com/V3RNE42/helios/llms.txt
Use this file to discover all available pages before exploring further.
computeRouteSections is the core algorithm of Helios, extracted from the UI layer into routeSolar.js so it can be tested in isolation. It takes all its dependencies as parameters — no DOM, no global state — and returns the sunrise/sunset event array that the UI renders into seat recommendations.
Function signature
Parameters
Origin coordinates
{ lat: number, lon: number }.Destination coordinates
{ lat: number, lon: number }.Departure date/time as a JavaScript
Date object.Arrival date/time as a JavaScript
Date object.Whether to look up UTC offsets for local-time display. When
true, getOffset is called for each section’s coordinates and the result is stored in offset.Injected solar calculator with the signature
(date, lat, lon) → { sunrise: { end }, sunset: { start } }. Provides the sunrise and sunset times at any point along the route.Async injected UTC offset resolver with the signature
async (coords) → number. Called only when local is true.Return value
ReturnsPromise<{ sections: Array, night: Boolean }>.
true if the entire journey falls in darkness — the vehicle never experiences daylight between departure and arrival.Ordered array of solar event objects spanning from departure to arrival. Each object in the array has the following shape:
| Property | Type | Description |
|---|---|---|
event | "sunrise" | "sunset" | Type of solar event. Absent on the synthetic departure and arrival boundary entries. |
date | Date | When the event occurs (or the departure/arrival time for boundary entries). |
coords | { lat, lon } | Geographic position of the vehicle at event time. |
offset | number | null | UTC offset in hours at that position. Populated only when local: true; otherwise null. |
rate | number | Progress fraction 0–1 along the journey. 0 for the departure entry, 1 for the arrival entry. |
Constants
| Name | Value | Purpose |
|---|---|---|
MAX_DIFF | 2500 ms | Maximum acceptable convergence error for the iterative solar event search. |
MAX_INNER_ITERATIONS | 100,000 | Cap on the inner convergence loop; prevents an infinite loop from hanging the browser tab. |
MAX_LOOPS | Dynamic | Outer loop cap, computed as limit ** 2 where limit = Math.floor(total_time × 2 / ONE_DAY) and total_time is the trip duration in milliseconds. limit falls back to 2 only when the floor result is 0 (trip shorter than half a day); otherwise the floor result is used as-is. |
Error conditions
The function throws anError in three situations:
-
"El cálculo solar del trayecto no convergió (bucle interno)"— The inner convergence loop exceededMAX_INNER_ITERATIONSiterations without satisfying theMAX_DIFFthreshold. This indicates a degenerategetDayInfoinput. -
"El cálculo solar del trayecto no convergió"— The outer loop exhaustedMAX_LOOPSiterations before the date pointer reached the arrival time. The result would be incomplete and is not returned. -
"Ha habido algún error con las fechas!"— Duplicate timestamps were detected in thesectionsarray after the main loop completed. This guards against an inconsistent internal state.
computeRouteSections is fully covered by Vitest tests in routeSolar.test.js. The test suite exercises daytime journeys, overnight journeys, multi-day journeys, and the convergence failure case. No API keys are required to run the tests.