OpenDataVisualizer/Schaad.OpenData.Traffic/Geometry/LocalProjection.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

19 lines
689 B
C#

using System.Numerics;
using Schaad.OpenData.Traffic.Models;
namespace Schaad.OpenData.Traffic.Geometry;
internal readonly struct LocalProjection(GeoPoint origin)
{
private const double MetersPerDegreeLat = 111_320;
private double MetersPerDegreeLon => MetersPerDegreeLat * Math.Cos(origin.Lat * Math.PI / 180);
public Vector2 ToLocal(GeoPoint point) => new(
(float)((point.Lon - origin.Lon) * MetersPerDegreeLon),
(float)((point.Lat - origin.Lat) * MetersPerDegreeLat));
public GeoPoint ToGeo(Vector2 point) => new(
Math.Round(origin.Lat + point.Y / MetersPerDegreeLat, 7),
Math.Round(origin.Lon + point.X / MetersPerDegreeLon, 7));
}