OpenDataVisualizer/Schaad.OpenData.Tests/TestData.cs
Claudio Schaad 7b65926aa2 Add Thurgau traffic visualizer and start page (#1)
- Thurgau hourly traffic counts (data.tg.ch) refreshed every 6 h into a per-day JSON cache
- Road geometry per station direction from swisstopo swissTLM3D; roundabout arms run outward from the roundabout centre
- Leaflet map with animated vehicles by class, time controls and base map switcher (grey, colour, aerial)
- Station panel with per-class counts and Chart.js charts
- Start page with map tiles; traffic map at /verkehr/thurgau
- Dockerfile and docker-compose, xUnit tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
2026-11-06 20:17:26 +00:00

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 },
};
}