feat: build the Cool City public route demo
ci / check (push) Successful in 55s

- add /cool, /cool?vote=1, /cool/stage and /cool/city on the existing Nuxt/Onyx stack
- wire real route/shade metrics and OSM geometry from the route bundle; city-gap data for the city view
- show shade % and direct-sun minutes together; recommend Accessible for Ruth with the 15% ramp trade-off
- add in-memory time/scene/round state and one anonymous vote per session, polled every 2 s
- keep the retail module linked but out of the Cool City story
This commit is contained in:
Noel Sabia committed 2026-11-14 13:49:22 +01:00
1 parent 33063afbdf
commit 2bc52a314d
28 files changed
+8633 -45

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
export interface GeoPoint {
lat: number
lon: number
}
export interface ProjectedPoint {
x: number
y: number
}
export function createProjection(
points: GeoPoint[],
width = 1200,
height = 800,
padding = 80,
): (point: GeoPoint) => ProjectedPoint {
const lats = points.map((point) => point.lat)
const lons = points.map((point) => point.lon)
const minLat = Math.min(...lats)
const maxLat = Math.max(...lats)
const minLon = Math.min(...lons)
const maxLon = Math.max(...lons)
const spanLat = Math.max(maxLat - minLat, 0.0001)
const spanLon = Math.max(maxLon - minLon, 0.0001)
const innerW = width - padding * 2
const innerH = height - padding * 2
return (point: GeoPoint) => ({
x: padding + ((point.lon - minLon) / spanLon) * innerW,
y: padding + ((maxLat - point.lat) / spanLat) * innerH,
})
}
export function pathFromCoordinates(
coordinates: Array<[number, number]>,
project: (point: GeoPoint) => ProjectedPoint,
): string {
return coordinates
.map(([lon, lat], index) => {
const point = project({ lat, lon })
return `${index === 0 ? 'M' : 'L'} ${point.x.toFixed(1)} ${point.y.toFixed(1)}`
})
.join(' ')
}
+51
View File
@@ -0,0 +1,51 @@
import type { CoolRouteValues } from '#shared/cool'
export function coolValue(value: number | null | undefined, suffix = ''): string {
if (value === null || value === undefined || Number.isNaN(value)) return 'TBD'
return `${value}${suffix}`
}
export function coolShade(value: number | null | undefined): string {
if (value === null || value === undefined) return 'TBD'
return `${value.toFixed(1)}%`
}
export function coolDistance(value: number | null | undefined): string {
if (value === null || value === undefined) return 'TBD'
if (value >= 1000) return `${(value / 1000).toFixed(2)} km`
return `${Math.floor(value)} m`
}
export function coolMinutes(value: number | null | undefined): string {
if (value === null || value === undefined) return 'TBD'
return `${value.toFixed(1)} min`
}
export function coolYesNo(value: boolean | null | undefined): string {
if (value === null || value === undefined) return 'TBD'
return value ? 'Yes' : 'No'
}
export function coolStops(value: number | null | undefined): string {
if (value === null || value === undefined) return 'TBD'
return String(value)
}
export function coolValues(values: CoolRouteValues | null | undefined): CoolRouteValues {
return (
values ?? {
shadePct: null,
directSunMin: null,
distanceM: null,
durationMin: null,
stepFree: null,
waterStops: null,
benchStops: null,
}
)
}
export function coolTallyPct(count: number, total: number): number {
if (!total) return 0
return Math.round((count / total) * 100)
}