- New Schaad.OpenData.Weather project: MeteoSwissClient reads the
10-minute CSV of the five SwissMetNet stations in Thurgau every 10
minutes (station list once a day) and backfills the last 7 days from
the yearly file when the cache has less than 6 days
- History kept as JSON per day (60 days); a failing station does not
stop the others
- API: /api/weather/meta, /stations (current values, 1 h/24 h rain,
24 h min/max, strongest gust), /stations/{abbr}/history
- Combined map: "Wetter (live)" layer with station badges (temperature,
24 h rain or wind), wind arrows, rain marker, station panel with
hourly 7-day chart, overview and municipality context entries
- Docs: docs/datasets/wetter.md, overview in docs/datasets.md,
CLAUDE.md; Docker and appsettings wiring
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>
30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Schaad.OpenData.Weather.Source;
|
|
using Schaad.OpenData.Weather.Storage;
|
|
|
|
namespace Schaad.OpenData.Weather;
|
|
|
|
public static class WeatherServiceCollectionExtensions
|
|
{
|
|
private const string UserAgent = "OpenDataVisualizer/1.0";
|
|
|
|
public static IServiceCollection AddWeather(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.Configure<WeatherOptions>(configuration.GetSection(WeatherOptions.SectionName));
|
|
services.TryAddSingleton(TimeProvider.System);
|
|
services.AddSingleton<WeatherDataStore>();
|
|
services.AddSingleton<WeatherCacheStorage>();
|
|
services.AddSingleton<WeatherRefresher>();
|
|
services.AddHostedService<WeatherRefreshService>();
|
|
|
|
services.AddHttpClient<MeteoSwissClient>(client =>
|
|
{
|
|
client.Timeout = TimeSpan.FromMinutes(2);
|
|
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
|
});
|
|
|
|
return services;
|
|
}
|
|
}
|