Pure zone geometry: point in polygon, geodesic circles and service-ring bands, spherical area and its words, centroids, zone features with status, the worst status inside a zone, and enter/exit diffs of a vehicle feed.
$ npx shadcn@latest add @highcommand/zones-libCopies the source into your project and pulls in what it needs (3 other items). First time? Add the registry to components.json.
openRing(ring: readonly LngLat[]): LngLat[]Drops a repeated closing point so every vertex is unique.
closeRing(ring: readonly LngLat[]): LngLat[]Repeats the first point at the end, as GeoJSON polygons require.
pointInPolygon([x, y]: LngLat, ring: readonly LngLat[]): booleanRay-casting point in polygon. A point exactly on an edge may go either way.
destination([lng, lat]: LngLat, meters: number, bearingDeg: number): LngLatThe point `meters` from `from` along `bearingDeg` (great circle).
circlePolygon(center: LngLat, radiusM: number, steps?: number): LngLat[]A geodesic circle as a closed ring: the true radius on the ground, not a screen circle.
polygonArea(ring: readonly LngLat[]): numberPolygon area in square metres on a sphere.
areaText(m2: number, unit?: "mi" | "km"): string"2.4 mi²", "0.31 km²".
polygonCentroid(ring: readonly LngLat[]): LngLatArea-weighted centroid (where a city-sized zone's name goes).
geofenceFeatures(fences: readonly Geofence[], selectedId?: string | null): Feature[]Each zone's polygon and a label point at its centroid. `c` is the status, `off` 1 when inactive, `sel` 1 when selected.
ringFeatures(center: LngLat, radii: readonly number[], unit?: "mi" | "km"): Feature[]Service-area rings around a hub: one band per radius (each a donut, so stacked bands never double their fill), and a label point at the top of each ring. `band` counts out from 0.
zoneStatus(fence: Geofence, points: readonly { p: LngLat; status: StatusColor; }[]): StatusColorThe zone's status from what is inside it: the worst status of the points in it (its own status when nothing is).
diffGeofences(prev: GeofenceMembership | null, vehicles: readonly Tracked[], fences: readonly Geofence[]): { membership: GeofenceMembership; events: GeofenceEvent[]; }Point in polygon for every vehicle, diffed against the previous snapshot. The first snapshot (prev null), zones just added and vehicles just appeared seed without events; a vehicle that drops out of the feed emits nothing; inactive zones are skipped.
countInside(m: GeofenceMembership): Record<string, number>Vehicles inside each zone, by zone id.
worstStatus(list: Iterable<StatusColor>): StatusColorThe worst of the statuses (neutral when there are none).
Install this free piece now; the Pro pieces drop in on top of it, in the same app. Pro is $79 once.