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>
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using Schaad.OpenData.Traffic.Models;
|
|
using Schaad.OpenData.Traffic.Source;
|
|
|
|
namespace Schaad.OpenData.Tests;
|
|
|
|
internal static class TestData
|
|
{
|
|
public static readonly GeoPoint Origin = new(47.5, 9.0);
|
|
|
|
public static GeoPoint Meters(double east, double north) => new(
|
|
Origin.Lat + north / 111_320,
|
|
Origin.Lon + east / (111_320 * Math.Cos(Origin.Lat * Math.PI / 180)));
|
|
|
|
public static VehicleCounts Cars(int cars, int trucks = 0) => new(0, 0, cars, 0, 0, 0, 0, trucks, 0, 0);
|
|
|
|
public static HourlyCount Count(int station, string direction, DateOnly date, int hour, int cars, int trucks = 0) =>
|
|
new(station, direction, date, hour, Cars(cars, trucks));
|
|
|
|
public static Station Station(int code, params string[] directions) =>
|
|
new(code, $"Station {code}", "Gemeinde", "Strasse", "H1", Origin, directions);
|
|
|
|
public static ThurgauTrafficRecord Record(
|
|
int code = 49,
|
|
string direction = "nach Diessenhofen",
|
|
string date = "2026-10-27",
|
|
int hour = 13,
|
|
int? cars = 220,
|
|
ThurgauCoordinates? coordinates = null) => new()
|
|
{
|
|
Code = code,
|
|
Name = "WAGENHAUSEN Wagenhausen - Diessenhofen",
|
|
Municipality = "Wagenhausen",
|
|
Address = "Hauptstrasse",
|
|
Road = "H13",
|
|
Direction = direction,
|
|
Date = date,
|
|
Hour = hour,
|
|
Bus = 1,
|
|
Motorcycle = 12,
|
|
Car = cars,
|
|
Truck = 6,
|
|
SemiTrailerTruck = 5,
|
|
Coordinates = coordinates ?? new ThurgauCoordinates { Lat = 47.66, Lon = 8.84 },
|
|
};
|
|
}
|