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(url: string): Promise { 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('/api/vehicles/meta'); export const fetchVehicleYears = () => getJson('/api/vehicles/years'); export const fetchMunicipalityShapes = () => getJson('/api/vehicles/municipalities');