ASP.NET Core 10 API and React client that visualize the canton of Thurgau's hourly traffic counts by vehicle class (data.tg.ch, CC0). - Background refresh from data.tg.ch every 6 h into a per-day JSON cache, so history grows beyond the source's two-week window - Road geometry per station direction from swisstopo swissTLM3D, oriented by geocoding the direction's target town; roundabout arms follow the road outward only - Leaflet map with canvas animation: dots drive along the road in both directions, density by hourly count, colour by vehicle class, right-hand traffic; play/pause, time slider and day selection - Station panel with per-class counts and Chart.js charts (hourly, weekday/weekend profile, daily totals, class mix) - swisstopo base map switcher (grey, colour, aerial) - Dockerfile and docker-compose with a data volume - xUnit tests for mapping, cache, geometry, geocoding and analysis Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
export type VehicleGroup = 'car' | 'motorcycle' | 'van' | 'truck' | 'bus';
|
|
|
|
export interface VehicleClassInfo {
|
|
label: string;
|
|
group: VehicleGroup;
|
|
}
|
|
|
|
export const VEHICLE_CLASSES: VehicleClassInfo[] = [
|
|
{ label: 'Bus/Car', group: 'bus' },
|
|
{ label: 'Motorrad', group: 'motorcycle' },
|
|
{ label: 'Personenwagen', group: 'car' },
|
|
{ label: 'PW mit Anhänger', group: 'car' },
|
|
{ label: 'Lieferwagen', group: 'van' },
|
|
{ label: 'Lieferwagen mit Anhänger', group: 'van' },
|
|
{ label: 'Lieferwagen mit Auflieger', group: 'van' },
|
|
{ label: 'Lastwagen', group: 'truck' },
|
|
{ label: 'Lastenzug', group: 'truck' },
|
|
{ label: 'Sattelzug', group: 'truck' },
|
|
];
|
|
|
|
export interface VehicleGroupStyle {
|
|
label: string;
|
|
color: string;
|
|
radius: number;
|
|
}
|
|
|
|
export const VEHICLE_GROUPS: Record<VehicleGroup, VehicleGroupStyle> = {
|
|
car: { label: 'Personenwagen', color: '#2563eb', radius: 2.6 },
|
|
motorcycle: { label: 'Motorräder', color: '#0d9488', radius: 2 },
|
|
van: { label: 'Lieferwagen', color: '#16a34a', radius: 3 },
|
|
truck: { label: 'Lastwagen', color: '#ea580c', radius: 4 },
|
|
bus: { label: 'Busse', color: '#9333ea', radius: 4 },
|
|
};
|
|
|
|
export const GROUP_ORDER: VehicleGroup[] = ['car', 'van', 'truck', 'bus', 'motorcycle'];
|
|
|
|
export const DIRECTION_COLORS = ['#2563eb', '#ea580c'];
|
|
|
|
export function sumCounts(counts: number[] | null | undefined): number {
|
|
return counts ? counts.reduce((sum, value) => sum + value, 0) : 0;
|
|
}
|