Choropleth of the 80 Thurgau municipalities from the road vehicle stock dataset (djs-stv-17): vehicles per 1000 inhabitants by vehicle group or share of a car brand among passenger cars, with year controls and a municipality panel. Population comes from sk-stat-56, outlines from swisstopo swissBOUNDARIES3D. Also fixes the broken ENV line in the Dockerfile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
export interface VehicleYearInfo {
|
|
year: number;
|
|
referenceDate: string;
|
|
count: number;
|
|
population: number;
|
|
}
|
|
|
|
export interface VehicleType {
|
|
name: string;
|
|
group: string;
|
|
}
|
|
|
|
export interface VehicleMeta {
|
|
title: string;
|
|
publisher: string;
|
|
sourceUrl: string;
|
|
license: string;
|
|
populationSourceUrl: string;
|
|
years: VehicleYearInfo[];
|
|
groups: string[];
|
|
types: VehicleType[];
|
|
brands: string[];
|
|
lastRefresh: string | null;
|
|
}
|
|
|
|
export interface AreaSummary {
|
|
id: string;
|
|
name: string;
|
|
district: string | null;
|
|
population: number;
|
|
count: number;
|
|
groups: number[];
|
|
types: number[];
|
|
brands: number[];
|
|
}
|
|
|
|
export interface VehicleYearView {
|
|
year: number;
|
|
referenceDate: string;
|
|
canton: AreaSummary;
|
|
municipalities: AreaSummary[];
|
|
}
|
|
|
|
export interface MunicipalityShape {
|
|
id: string;
|
|
name: string;
|
|
district: string;
|
|
polygons: number[][][][];
|
|
}
|
|
|
|
async function getJson<T>(url: string): Promise<T> {
|
|
const response = await fetch(url);
|
|
if (!response.ok) {
|
|
throw new Error(`${response.status} ${response.statusText}`);
|
|
}
|
|
return (await response.json()) as T;
|
|
}
|
|
|
|
export const fetchVehicleMeta = () => getJson<VehicleMeta>('/api/vehicles/meta');
|
|
|
|
export const fetchVehicleYears = () => getJson<VehicleYearView[]>('/api/vehicles/years');
|
|
|
|
export const fetchMunicipalityShapes = () =>
|
|
getJson<MunicipalityShape[]>('/api/vehicles/municipalities');
|