Great-circle lanes, antimeridian-safe framing, playback tracks, risk contours (marching squares), edge-chip spreading and Fleet map features.
$ npx shadcn@latest add @highcommand/map-geoCopies the source into your project and pulls in what it needs (1 other item). First time? Add the registry to components.json.
nearestSegment(path: LngLat[], p: LngLat): numberSquared distance in degrees from p to the nearest segment of `path`; returns that segment's index.
greatCircle(a: LngLat, b: LngLat, maxSegments?: number): LngLat[]Points along the great circle a -> b (inclusive). Longitudes are unwrapped (they may run past ±180) so a trans-Pacific arc is one continuous line, not a stroke across the whole map. Short hops (< ~50 km) stay two points.
unwrap(line: LngLat[]): LngLat[]Make longitudes continuous along a line (each step < 180 degrees).
arcPath(points: LngLat[]): LngLat[]A polyline whose every segment is a great-circle arc (unwrapped end to end).
legLine(a: LngLat, b: LngLat, roads?: Roads | null | undefined): LngLat[]One leg as the map draws it: on its stored road when the company has one, else as a great-circle arc.
routeLine(path: readonly LngLat[], roads?: Roads | null | undefined): LngLat[]A shipment's planned route as one line, leg by leg (legLine).
laneLine(l: Pick<Lane, "from" | "to" | "keys">, roads?: Roads | null | undefined): { line: LngLat[]; road: boolean; }A lane's line: the stored road of the first of its legs that has one (one canonical road per lane), else the arc between its ends.
lanesOf(shipments: readonly LaneShipment[]): { lanes: Lane[]; byShipment: Map<string, string[]>; }Lanes: every leg of every shipment's planned path, merged when both ends round to the same 0.1 degree. Volume is the number of shipments on it; colour is its worst status (a lane of only not-moving shipments is neutral).
wrapBounds(points: readonly { lat: number; lng: number; }[]): { west: number; east: number; south: number; north: number; } | nullThe smallest longitude window that holds every point (it may cross the antimeridian: west < 180 < east), plus the latitude range. A network from Shenzhen through Long Beach to Rotterdam frames the Pacific and the Americas, not the empty Atlantic view.
trackAt(tr: Track | undefined, t: number): { lat: number; lng: number; } | nullWhere a track was at time `t`: between two close samples, the straight line between them; across a gap, the last known point; outside, its first or last sample.
roadKeyOf(a: LngLat, b: LngLat): stringA stored road's key: both endpoints as "lat,lng" rounded to 4 decimals (about 11 m), from>to.
densityGrid(pts: ScreenPt[], cols: number, rows: number, cell: number, sigma?: number): Float32Array<ArrayBufferLike>A grid of `cols` × `rows` cells of `cell` px: each point adds a Gaussian bump (σ px) weighted by how much needs attention there.
isoSegments(g: Float32Array<ArrayBufferLike>, cols: number, rows: number, cell: number, level: number): [number, number, number, number][]Marching squares: the iso-line at `level` through the grid, as segments in px ([x1, y1, x2, y2]). Saddles take the centre's side.
spreadAlong(want: readonly number[], len: readonly number[], lo: number, hi: number, blocked: readonly Span[]): number[]Centres along one side for chips of the given lengths, wanted at `want` (same order), within [lo, hi]: in order along the side, each at least its half-length plus the gap from the one before, and off every blocked span. Where the side runs out, they are packed back from its end. Returns the centres in the input order.
edgeChipSize(n: number): { w: number; h: number; }A chip's size: an arrow, the count, the padding (command.css .cmd-edge).
vehicleFeatures(vehicles: readonly FleetMapVehicle[], selectedVehicle: string | null): Feature[]One point per vehicle that has a fix. `c` is the display status, `k` the vehicle kind (the glyph), `h` the heading (degrees; -1 when unknown).
routeFeatures(d: { planned_path: readonly LngLat[]; breadcrumb: readonly LngLat[]; stops: readonly FleetMapStop[]; depot?: { lat: number; lng: number; name: string; } | null | undefined; display: StatusColor; }): { ...; }The planned path (dashed), the driven breadcrumb (solid) and each stop (numbered) for one route.
stopFeatures(stops: readonly FleetMapStop[], depot?: { lat: number; lng: number; name: string; } | null | undefined): Feature[]Point features for a route's stops (numbered by sequence, the next open stop flagged `key`, depot returns skipped), plus the depot when given.
simplifyPath(pts: readonly LngLat[], tol?: number): LngLat[]Douglas-Peucker in degrees: keeps the shape of a line with far fewer points.
breadcrumbLine(crumbs: readonly (readonly [number, number, ...number[]])[]): LngLat[]The breadcrumb as a line, thinned so a day's pings do not become thousands of vertices.
boundsOf(points: readonly LngLat[]): [LngLat, LngLat] | null[[west, south], [east, north]] of some points, or null when there are none. A single point gets a small box so the map can still frame it.
kindLabel(k: string): stringDisplay name for a vehicle kind ("Box truck"); an unknown kind comes back as is.
Install this free piece now; the Pro pieces drop in on top of it, in the same app. Pro is $79 once.