- 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:
1 parent
33063afbdf
commit
2bc52a314d
28 files changed
+8633
-45
No files matched your search
+260
@@ -0,0 +1,260 @@
|
||||
export const COOL_ROUTE_IDS = ['shortest', 'shaded', 'accessible'] as const
|
||||
export type CoolRouteId = (typeof COOL_ROUTE_IDS)[number]
|
||||
|
||||
export const COOL_TIMES = ['10:00', '12:00', '14:00', '16:00'] as const
|
||||
export type CoolTime = (typeof COOL_TIMES)[number]
|
||||
|
||||
export const COOL_ROUNDS = ['preselection', 'final'] as const
|
||||
export type CoolRound = (typeof COOL_ROUNDS)[number]
|
||||
|
||||
export const COOL_SCENES = ['ruth', 'places', 'routes', 'vote', 'locked', 'coda'] as const
|
||||
export type CoolScene = (typeof COOL_SCENES)[number]
|
||||
|
||||
export const COOL_ROUTE_LABELS: Record<CoolRouteId, string> = {
|
||||
shortest: 'Shortest',
|
||||
shaded: 'Shaded',
|
||||
accessible: 'Accessible',
|
||||
}
|
||||
|
||||
export const COOL_ROUTE_DESCRIPTIONS: Record<CoolRouteId, string> = {
|
||||
shortest: 'Direct via Fleiner Straße.',
|
||||
shaded: 'Via the shaded passage and Kiliansplatz.',
|
||||
accessible: 'Step-free, with water and benches.',
|
||||
}
|
||||
|
||||
export const COOL_MODEL_LABEL = 'Accessible for Ruth'
|
||||
export const COOL_COMPOSITE_LABEL = 'Composite persona — illustrative, not a real person'
|
||||
export const COOL_CLOSING_LINE =
|
||||
'The pulse is not the people. But the city still has to protect them.'
|
||||
|
||||
export interface CoolRouteValues {
|
||||
shadePct: number
|
||||
directSunMin: number
|
||||
distanceM: number
|
||||
durationMin: number
|
||||
stepFree: boolean
|
||||
waterStops: number
|
||||
benchStops: number
|
||||
rampInclinePct: number | null
|
||||
}
|
||||
|
||||
export interface CoolRouteOption {
|
||||
id: CoolRouteId
|
||||
label: string
|
||||
longName: string
|
||||
description: string
|
||||
fullDescription: string
|
||||
values: Record<string, CoolRouteValues>
|
||||
ramp: { incline: string; location: string; wheelchair: string | null } | null
|
||||
accessibilityNotes: string[]
|
||||
geometry: Array<[number, number]>
|
||||
}
|
||||
|
||||
export interface CoolPoint {
|
||||
name: string
|
||||
lat: number
|
||||
lon: number
|
||||
wheelchair?: string | null
|
||||
nearRoutesM?: Record<string, number>
|
||||
}
|
||||
|
||||
export interface CoolRouteBundle {
|
||||
status: 'ready' | 'pending'
|
||||
generatedAt: string
|
||||
hotDay: {
|
||||
date: string
|
||||
temperature_max_c: number
|
||||
temperature_min_c: number
|
||||
precipitation_mm: number
|
||||
sunshine_hours: number
|
||||
source: string
|
||||
} | null
|
||||
label: string
|
||||
shadeLabel: string
|
||||
origin: { name: string; note?: string; lat?: number; lon?: number }
|
||||
destination: { name: string; note?: string; lat?: number; lon?: number }
|
||||
times: CoolTime[]
|
||||
routes: CoolRouteOption[]
|
||||
recommendationByTime: Record<string, CoolRouteId>
|
||||
modelLabel: string
|
||||
water: CoolPoint[]
|
||||
meta: {
|
||||
city: string
|
||||
shadeLabel: string
|
||||
method: string
|
||||
solarPositions: Record<string, { altitude_deg: number; azimuth_deg: number }>
|
||||
dataGaps: string[]
|
||||
walkingSpeedMps: number
|
||||
} | null
|
||||
}
|
||||
|
||||
export interface CoolDemoState {
|
||||
round: CoolRound
|
||||
time: CoolTime
|
||||
selectedRoute: CoolRouteId
|
||||
scene: CoolScene
|
||||
voteOpen: boolean
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface CoolVoteCounts {
|
||||
shortest: number
|
||||
shaded: number
|
||||
accessible: number
|
||||
}
|
||||
|
||||
export interface CoolVoteTally {
|
||||
round: CoolRound
|
||||
counts: CoolVoteCounts
|
||||
total: number
|
||||
updatedAt: string | null
|
||||
}
|
||||
|
||||
export interface CoolVoteResponse {
|
||||
yourRoute: CoolRouteId
|
||||
duplicate: boolean
|
||||
tally: CoolVoteTally
|
||||
}
|
||||
|
||||
export interface CoolCityCatchment {
|
||||
rank: number
|
||||
sensor_id: string
|
||||
sensor_name: string
|
||||
center: { lat: number; lon: number }
|
||||
radius_m: number
|
||||
geometry: { type: string; coordinates: number[][][] }
|
||||
inputs: {
|
||||
footfall: { mean: number; p95: number }
|
||||
shade: {
|
||||
building_footprint_share_of_land: number
|
||||
tree_canopy_share_of_land_proxy: number
|
||||
water_share_of_catchment: number
|
||||
building_polygons: number
|
||||
mapped_tree_points: number
|
||||
}
|
||||
access: {
|
||||
nearest_public_drinking_water_m: number
|
||||
nearest_bench_m: number
|
||||
nearest_public_toilet_m: number
|
||||
nearest_step_free_anchor_m: number
|
||||
within_300m: Record<string, number>
|
||||
}
|
||||
vulnerability: {
|
||||
district: string
|
||||
age_65plus_share: number
|
||||
age_65plus_count: number
|
||||
district_population: number
|
||||
reference_date: string
|
||||
}
|
||||
}
|
||||
normalized_inputs: Record<string, number>
|
||||
scores: {
|
||||
footfall: number
|
||||
shade_deficit: number
|
||||
access_deficit: number
|
||||
vulnerability: number
|
||||
gap_index: number
|
||||
}
|
||||
nearest_cool_place: { name: string; category: string; distance_m: number } | null
|
||||
reason: string
|
||||
max_overlap_with: { sensor_id: string; distance_m: number; overlap_fraction: number } | null
|
||||
}
|
||||
|
||||
export interface CoolCityPlace {
|
||||
name: string
|
||||
category: string
|
||||
lat: number
|
||||
lon: number
|
||||
distance_to_cluster_center_m: number
|
||||
within_1km?: boolean
|
||||
}
|
||||
|
||||
export interface CoolCityBundle {
|
||||
meta: {
|
||||
city: string
|
||||
generated: string
|
||||
sensor_source: string
|
||||
sensor_data_version: string
|
||||
sensor_model_version: string
|
||||
catchment_radius_m: number
|
||||
catchment_area_m2: number
|
||||
method: string
|
||||
weights: Record<string, number>
|
||||
weights_note: string
|
||||
ranking_note: string
|
||||
subweights: Record<string, unknown>
|
||||
assumptions: string[]
|
||||
sources: Array<{ name: string; url: string; retrieved: string; license: string }>
|
||||
self_check?: Record<string, unknown>
|
||||
sensitivity?: Record<string, unknown>
|
||||
data_gaps?: string[]
|
||||
layer_counts?: Record<string, number>
|
||||
}
|
||||
catchments: CoolCityCatchment[]
|
||||
official_cool_places: CoolCityPlace[]
|
||||
}
|
||||
|
||||
export function isCoolRouteId(value: unknown): value is CoolRouteId {
|
||||
return typeof value === 'string' && (COOL_ROUTE_IDS as readonly string[]).includes(value)
|
||||
}
|
||||
|
||||
export function isCoolTime(value: unknown): value is CoolTime {
|
||||
return typeof value === 'string' && (COOL_TIMES as readonly string[]).includes(value)
|
||||
}
|
||||
|
||||
export function isCoolRound(value: unknown): value is CoolRound {
|
||||
return typeof value === 'string' && (COOL_ROUNDS as readonly string[]).includes(value)
|
||||
}
|
||||
|
||||
export function isCoolScene(value: unknown): value is CoolScene {
|
||||
return typeof value === 'string' && (COOL_SCENES as readonly string[]).includes(value)
|
||||
}
|
||||
|
||||
export function defaultCoolState(round: CoolRound = 'preselection'): CoolDemoState {
|
||||
return {
|
||||
round,
|
||||
time: '10:00',
|
||||
selectedRoute: 'shortest',
|
||||
scene: 'ruth',
|
||||
voteOpen: false,
|
||||
updatedAt: '',
|
||||
}
|
||||
}
|
||||
|
||||
export function emptyCoolTally(round: CoolRound = 'preselection'): CoolVoteTally {
|
||||
return {
|
||||
round,
|
||||
counts: { shortest: 0, shaded: 0, accessible: 0 },
|
||||
total: 0,
|
||||
updatedAt: null,
|
||||
}
|
||||
}
|
||||
|
||||
/** Runtime fallback only; the shipped route.json has the real modelled values. */
|
||||
export function pendingCoolRouteBundle(): CoolRouteBundle {
|
||||
return {
|
||||
status: 'pending',
|
||||
generatedAt: '',
|
||||
hotDay: null,
|
||||
label: 'Route/shade bundle pending. No estimates shown.',
|
||||
shadeLabel: 'modeled shade, not measured',
|
||||
origin: { name: 'Stadtgalerie' },
|
||||
destination: { name: 'Marktplatz' },
|
||||
times: [...COOL_TIMES],
|
||||
routes: COOL_ROUTE_IDS.map((id) => ({
|
||||
id,
|
||||
label: COOL_ROUTE_LABELS[id],
|
||||
longName: COOL_ROUTE_LABELS[id],
|
||||
description: COOL_ROUTE_DESCRIPTIONS[id],
|
||||
fullDescription: '',
|
||||
values: {},
|
||||
ramp: null,
|
||||
accessibilityNotes: [],
|
||||
geometry: [],
|
||||
})),
|
||||
recommendationByTime: {},
|
||||
modelLabel: COOL_MODEL_LABEL,
|
||||
water: [],
|
||||
meta: null,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user