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
156 lines
4.0 KiB
Vue
156 lines
4.0 KiB
Vue
<script setup lang="ts">
|
|
import type { CoolCityCatchment, CoolCityPlace } from '#shared/cool'
|
|
import { createProjection, pathFromCoordinates } from '~/utils/cool-map'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
places: CoolCityPlace[]
|
|
catchments?: CoolCityCatchment[]
|
|
selectedRank?: number | null
|
|
showCatchments?: boolean
|
|
stage?: boolean
|
|
}>(),
|
|
{ catchments: () => [], selectedRank: null, showCatchments: false, stage: false },
|
|
)
|
|
|
|
const allPoints = computed(() => {
|
|
const placePoints = props.places.map((place) => ({ lat: place.lat, lon: place.lon }))
|
|
const centers = props.catchments.map((catchment) => catchment.center)
|
|
return [...placePoints, ...centers]
|
|
})
|
|
|
|
const project = computed(() => createProjection(allPoints.value, 1200, 800, 90))
|
|
const dots = computed(() =>
|
|
props.places.map((place) => ({
|
|
...place,
|
|
position: project.value({ lat: place.lat, lon: place.lon }),
|
|
})),
|
|
)
|
|
const rings = computed(() =>
|
|
props.catchments.map((catchment) => {
|
|
const ring = catchment.geometry.coordinates?.[0] ?? []
|
|
const path = ring.length
|
|
? pathFromCoordinates(
|
|
ring.map(([lon, lat]) => [lon, lat] as [number, number]),
|
|
project.value,
|
|
)
|
|
: ''
|
|
return {
|
|
...catchment,
|
|
path,
|
|
centerPoint: project.value(catchment.center),
|
|
selected: props.selectedRank === catchment.rank,
|
|
}
|
|
}),
|
|
)
|
|
</script>
|
|
|
|
<template>
|
|
<figure class="cc-placesmap" :class="{ 'cc-placesmap--stage': props.stage }">
|
|
<svg
|
|
class="cc-placesmap__canvas"
|
|
viewBox="0 0 1200 800"
|
|
preserveAspectRatio="xMidYMid meet"
|
|
role="img"
|
|
:aria-label="`Map of ${places.length} cool places near the eight Heilbronn sensor catchments.`"
|
|
>
|
|
<defs>
|
|
<pattern id="cc-places-grid" width="44" height="44" patternUnits="userSpaceOnUse">
|
|
<circle cx="1" cy="1" r="1" fill="currentColor" />
|
|
</pattern>
|
|
</defs>
|
|
<rect class="cc-placesmap__ground" x="0" y="0" width="1200" height="800" />
|
|
<rect class="cc-placesmap__grid" x="0" y="0" width="1200" height="800" fill="url(#cc-places-grid)" />
|
|
|
|
<g v-if="props.showCatchments">
|
|
<path
|
|
v-for="ring in rings"
|
|
:key="ring.sensor_id"
|
|
class="cc-placesmap__ring"
|
|
:class="{ 'is-selected': ring.selected }"
|
|
:d="ring.path"
|
|
/>
|
|
<g v-for="ring in rings" :key="`${ring.sensor_id}-label`" class="cc-placesmap__rank">
|
|
<text :x="ring.centerPoint.x" :y="ring.centerPoint.y + 6" text-anchor="middle">{{ ring.rank }}</text>
|
|
</g>
|
|
</g>
|
|
|
|
<g class="cc-placesmap__dots">
|
|
<circle
|
|
v-for="dot in dots"
|
|
:key="`${dot.name}-${dot.lat}-${dot.lon}`"
|
|
:cx="dot.position.x"
|
|
:cy="dot.position.y"
|
|
:r="props.stage ? 9 : 6"
|
|
/>
|
|
</g>
|
|
</svg>
|
|
|
|
<p class="cc-placesmap__stamp">Relative map · OSM cool places · no heatmap</p>
|
|
</figure>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.cc-placesmap {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
min-height: 24rem;
|
|
margin: 0;
|
|
overflow: hidden;
|
|
color: var(--cc-line);
|
|
}
|
|
|
|
.cc-placesmap__canvas {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.cc-placesmap__ground {
|
|
fill: var(--cc-ground, #f6f3ee);
|
|
}
|
|
|
|
.cc-placesmap__grid {
|
|
color: var(--cc-line, rgba(18, 18, 18, 0.12));
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.cc-placesmap__ring {
|
|
fill: color-mix(in srgb, var(--cc-shade) 8%, transparent);
|
|
stroke: var(--cc-line);
|
|
stroke-width: 1.5;
|
|
}
|
|
|
|
.cc-placesmap__ring.is-selected {
|
|
fill: color-mix(in srgb, var(--cc-heat) 14%, transparent);
|
|
stroke: var(--cc-heat);
|
|
stroke-width: 3;
|
|
}
|
|
|
|
.cc-placesmap__rank text {
|
|
fill: var(--cc-muted);
|
|
font-size: 17px;
|
|
font-weight: 750;
|
|
}
|
|
|
|
.cc-placesmap__dots circle {
|
|
fill: var(--cc-shade);
|
|
stroke: var(--cc-ground, #f6f3ee);
|
|
stroke-width: 2;
|
|
}
|
|
|
|
.cc-placesmap__stamp {
|
|
position: absolute;
|
|
right: 1rem;
|
|
bottom: 0.8rem;
|
|
margin: 0;
|
|
color: var(--cc-muted);
|
|
font-family: var(--cc-font);
|
|
font-size: 0.62rem;
|
|
letter-spacing: 0.03em;
|
|
}
|
|
|
|
|
|
</style>
|