- routeAstar: allocation-free hot loop — binary heap of node indices over preallocated typed arrays (grown by doubling), typed-array g/closed/ came-from, on-demand cached haversine/maxSpeed heuristic (admissible + consistent); oneway-reverse edges never relaxed; unreachable -> null - A1 proves A* == brute-force Dijkstra on ALL 625 mini-graph pairs - classifyTurn: the one turn authority (compass convention — negative delta = left; plan's (0,40)->slight-left case contradicted its own (0,-90)/(0,90) pins, documented deviation); TURN_* constants exported for plan 07's cron projection - deriveSteps: splits at non-straight bearings or name changes; steps carry kind/name/distanceM + polyline6; depart-first, arrive-last - index.ts: engine-A named exports + ladder note updated — backend #2 is now 'engine-a' (D-01 supersedes the wasm-router note; Valhalla port infeasible + geojson-path-finder rejected, engine B = post-v1 evolution, D-02); createHttpRoutingSource deliberately absent (plan 04)
66 lines
2.8 KiB
TypeScript
66 lines
2.8 KiB
TypeScript
/*
|
|
* index.ts — the public API surface of @araharah/routing (D-01, D-03, D-07).
|
|
* ---------------------------------------------------------------------------
|
|
* Named exports ONLY (no default export). The package has NO exports /
|
|
* main field (the @araharah/theme + @araharah/search precedent), so
|
|
* consumers import the EXPLICIT SUBPATH WITH EXTENSION —
|
|
* import { snapToGraph } from "@araharah/routing/src/index.ts";
|
|
* (both tsconfigs carry allowImportingTsExtensions + bundler resolution;
|
|
* esbuild and Vite compile the .ts source; Node 24 type-stripping handles
|
|
* the corpus runner's relative form). A bare "@araharah/routing" specifier
|
|
* resolves to NOTHING — never use it.
|
|
*
|
|
* THE BACKEND LADDER (D-01 supersedes the phase-5 "wasm-router" note):
|
|
* #1 "fixture" — createFixtureRoutingSource: the golden-pairs demo
|
|
* corpus (15 committed KL pairs).
|
|
* #2 "engine-a" — the Worker-side router built on THIS plan's data
|
|
* plane: decodeGraph + snapToGraph + routeAstar over an
|
|
* R2-hosted CSR graph binary. Engine B (a fully
|
|
* client-side webview router — graph on the phone) is
|
|
* engine A's documented post-v1 evolution (D-02). The
|
|
* Valhalla-to-JS port was ruled infeasible and
|
|
* geojson-path-finder rejected (demo-grade: no
|
|
* alternatives/one-ways) — recorded so neither is ever
|
|
* re-proposed (D-02).
|
|
* Plan 04 adds `createHttpRoutingSource` (the /api/route surface that
|
|
* plugs engine A beneath the RoutingSource seam) — deliberately absent
|
|
* here.
|
|
*
|
|
* The module reads NO environment, NO secrets, and NO network (D-05/D-12):
|
|
* the whole routing stack is V8-native and dependency-free — fixtures ride
|
|
* the bundle, requests never leave the caller's frame.
|
|
*/
|
|
|
|
export type {
|
|
RoutePoint, RouteRequest, RouteSummary, RouteStep,
|
|
RouteGeometry, RouteOption, RouteResult, RoutingSource,
|
|
FixturePair, FixtureRoute,
|
|
} from "./types.ts";
|
|
export { decodePolyline6, encodePolyline6 } from "./polyline.ts";
|
|
export { haversineM, deriveCumulativeDistanceM } from "./geo.ts";
|
|
export {
|
|
ORIGIN_TOLERANCE_M,
|
|
createFixtureRoutingSource,
|
|
getPairOrigin,
|
|
getPairs,
|
|
} from "./fixture-source.ts";
|
|
export type { RoadGraph, GraphEdgeInput, GraphInput } from "./graph.ts";
|
|
export {
|
|
decodeGraph,
|
|
encodeGraph,
|
|
GRAPH_MAGIC,
|
|
GRAPH_VERSION,
|
|
UNNAMED_NAME_ID,
|
|
} from "./graph.ts";
|
|
export type { SnapResult } from "./snap.ts";
|
|
export { snapToGraph, SNAP_BBOX_MARGIN_DEG } from "./snap.ts";
|
|
export type { AstarResult, GuidanceTurnKind } from "./astar.ts";
|
|
export {
|
|
routeAstar,
|
|
deriveSteps,
|
|
classifyTurn,
|
|
TURN_STRAIGHT_MAX_DEG,
|
|
TURN_SLIGHT_MAX_DEG,
|
|
TURN_UTURN_MIN_DEG,
|
|
} from "./astar.ts";
|