OpenDataVisualizer/Schaad.OpenData.Vehicles/VehicleServiceCollectionExtensions.cs
Claudio Schaad 81c3661687 Add Thurgau vehicle stock map
Choropleth of the 80 Thurgau municipalities from the road vehicle stock
dataset (djs-stv-17): vehicles per 1000 inhabitants by vehicle group or
share of a car brand among passenger cars, with year controls and a
municipality panel. Population comes from sk-stat-56, outlines from
swisstopo swissBOUNDARIES3D.

Also fixes the broken ENV line in the Dockerfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 22:41:47 +01: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;
}
}