OpenDataVisualizer/Schaad.OpenData.Vehicles/VehicleServiceCollectionExtensions.cs
Claudio Schaad 688775e742 Add Thurgau vehicle stock map (#3)
Choropleth of the 80 Thurgau municipalities from the road vehicle stock dataset (djs-stv-17), with population from sk-stat-56 and outlines from swisstopo. Also fixes the broken ENV line in the Dockerfile.

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 21:43:23 +00:00

35 lines
1.3 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Schaad.OpenData.Vehicles.Source;
using Schaad.OpenData.Vehicles.Storage;
namespace Schaad.OpenData.Vehicles;
public static class VehicleServiceCollectionExtensions
{
private const string UserAgent = "OpenDataVisualizer/1.0";
public static IServiceCollection AddVehicles(this IServiceCollection services, IConfiguration configuration)
{
services.Configure<VehicleOptions>(configuration.GetSection(VehicleOptions.SectionName));
services.TryAddSingleton(TimeProvider.System);
services.AddSingleton<VehicleDataStore>();
services.AddSingleton<VehicleCacheStorage>();
services.AddSingleton<VehicleRefresher>();
services.AddHostedService<VehicleRefreshService>();
services.AddHttpClient<ThurgauVehicleClient>(client =>
{
client.Timeout = TimeSpan.FromMinutes(2);
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
});
services.AddHttpClient<MunicipalityBoundaryClient>(client =>
{
client.Timeout = TimeSpan.FromSeconds(30);
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
});
return services;
}
}