Files
laadpalenviewer/webapp/types/charging.ts
T
robbertjanssen85andClaude Opus 4.8 22e54a57a5 Add current €/kWh prices per charger across the stack
NDW already publishes OCPI tariffs (embedded per connector); resolve the
cheapest currently-applicable ENERGY price and surface it everywhere:

- pipeline: tariff.ts resolveConnectorPrice() matches connector power +
  build-time (Europe/Amsterdam) against each element's restrictions, with
  a €0.05–5.0 sanity band. Baked onto EnrichedConnector.priceKwh and the
  location headline LightLocation.priceKwh (min across connectors) ->
  crop-out/national point properties. Preserved through freight merge.
- webapp: detail panel shows the resolved price (falls back to parsing the
  raw tariff); new "Kleur op prijs" filter colors points by €/kWh ramp with
  legend + hover price.
- analysis: chargers.py reads priceKwh from crop-outs -> price_kwh_median/
  _mean/_n + price_pct percentile -> "Prijs" choropleth metric + scorecard.
- regenerated data: ~40k locations priced (median ≈€0.39); all 342 gemeenten
  get a median price.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 21:24:18 +02:00

142 lines
3.3 KiB
TypeScript

// Types mirroring the static data files produced by data-pipeline.
export type ChargeLayer = "passenger" | "freight";
export type AggregateStatus = "AVAILABLE" | "CHARGING" | "UNAVAILABLE" | "UNKNOWN";
export interface Municipality {
name: string;
slug: string;
province: string;
population: number;
code: string | null;
passengerCount: number;
freightCount: number;
}
export interface ChargeProperties {
type: "charge";
layer: ChargeLayer;
locationId: string;
name: string;
address: string;
city: string;
operatorName: string;
maxPowerKw: number;
isMegawatt: boolean;
status: AggregateStatus;
source: string; // 'ndw' | 'curated' | 'eafo' | 'ocm'
priceKwh?: number; // cheapest currently-applicable €/kWh at this location
}
export interface BoundaryProperties {
type: "boundary";
gemeente: string;
code: string;
}
export type FeatureProperties = ChargeProperties | BoundaryProperties;
export interface ChargeFeature {
type: "Feature";
geometry: { type: "Point"; coordinates: [number, number] };
properties: ChargeProperties;
}
export interface BoundaryFeature {
type: "Feature";
geometry: { type: "Polygon" | "MultiPolygon"; coordinates: unknown };
properties: BoundaryProperties;
}
export type AnyFeature = ChargeFeature | BoundaryFeature;
export interface CropoutData {
type: "FeatureCollection";
metadata: {
gemeente?: string;
slug?: string;
code?: string;
generated_at: string;
total_passenger?: number;
total_freight?: number;
layer?: ChargeLayer;
total?: number;
bounds?: [number, number, number, number];
operators?: string[];
};
features: AnyFeature[];
}
// "With details" payload (per-gemeente bundle: locationId -> EnrichedLocation).
export interface EnrichedConnector {
id: string;
standard: string;
format: string;
power_type: string;
max_voltage?: number;
max_amperage?: number;
max_electric_power?: number;
tariff_ids?: string[];
tariffs: EnrichedTariff[];
priceKwh?: number; // resolved current €/kWh ENERGY price
priceVat?: number; // VAT %, informational
last_updated: string;
}
export interface EnrichedTariff {
id: string;
currency: string;
elements: Array<{
price_components?: Array<{ type: string; price: number; vat?: number; step_size?: number }>;
}>;
}
export interface EnrichedEVSE {
uid: string;
evse_id: string;
status: string;
capabilities?: string[];
physical_reference?: string;
connectors: EnrichedConnector[];
last_updated: string;
}
export interface EnrichedLocation {
locationId: string;
ocpiId: string;
name: string;
address: string;
city: string;
postalCode?: string;
country: string;
latitude: number;
longitude: number;
parkingType?: string;
operatorName: string;
operatorWebsite?: string;
ownerName?: string;
twentyFourSeven: boolean;
lastUpdated: string;
layer: ChargeLayer;
maxPowerKw: number;
evses: EnrichedEVSE[];
}
export type DetailBundle = Record<string, EnrichedLocation>;
export interface Filters {
showPassenger: boolean;
showFreight: boolean;
showBoundary: boolean;
minPowerKw: number;
colorByPrice: boolean; // color charge points by €/kWh instead of status
}
export const DEFAULT_FILTERS: Filters = {
showPassenger: true,
showFreight: true,
showBoundary: true,
minPowerKw: 0,
colorByPrice: false,
};