Initial commit: Laadpalenviewer

Static-generation EV charging map for the Netherlands with two layers
(passenger / logistics-freight), per-municipality crop-outs, and
gemeente + province boundaries from PDOK/CBS.

- data-pipeline/ (Node/TS): NDW OCPI download + classify (freight >=350kW /
  MCS / megawatt / Milence,WattHub) + external sources (curated, OCM, EAFO)
  + PDOK CBS boundaries -> static GeoJSON/JSON.
- webapp/ (Next.js 16 + React 19 + deck.gl + MapLibre): national view loads
  all points without details; selecting a gemeente eagerly loads its detail
  bundle (OCPI EVSE/connector/tariff + status) for instant marker clicks.
  Passenger colored by OCPI status (fleetsim-style), freight amber/megawatt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Robbert Janssen
2026-06-02 15:26:56 +02:00
co-authored by Claude Opus 4.8
commit ab9ed8abb8
733 changed files with 18413 additions and 0 deletions
+189
View File
@@ -0,0 +1,189 @@
"use client";
import { X, ExternalLink, Clock, Zap, MapPin, Building2, Truck } from "lucide-react";
import type { ChargeFeature, EnrichedLocation } from "@/types/charging";
import { formatConnectorStandard, formatPowerType, statusColorClass, statusLabel } from "@/lib/connectorLabels";
interface Props {
selected: ChargeFeature | null;
detail: EnrichedLocation | null;
loading: boolean;
onClose: () => void;
onJumpToGemeente?: () => void;
}
export default function LocationDetailPanel({ selected, detail, loading, onClose, onJumpToGemeente }: Props) {
if (!selected) return null;
const p = selected.properties;
const isFreight = p.layer === "freight";
return (
<div className="absolute top-4 right-14 w-96 max-w-[calc(100vw-5rem)] max-h-[calc(100%-2rem)] bg-white rounded-lg shadow-lg overflow-hidden flex flex-col z-10">
<div className="p-4 border-b bg-gray-50 flex-shrink-0">
<div className="flex justify-between items-start">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<span
className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs text-white ${
isFreight ? "bg-amber-500" : "bg-blue-500"
}`}
>
{isFreight ? <Truck className="h-3 w-3" /> : <Zap className="h-3 w-3" />}
{isFreight ? "Vracht" : "Personenauto"}
</span>
{p.isMegawatt && (
<span className="px-1.5 py-0.5 rounded text-xs text-white bg-orange-600">Megawatt</span>
)}
</div>
<h3 className="font-semibold text-lg truncate mt-1">{p.name}</h3>
{p.address && (
<div className="flex items-center gap-1 text-sm text-gray-600 mt-1">
<MapPin className="h-3 w-3 flex-shrink-0" />
<span className="truncate">
{p.address}
{p.city ? `, ${p.city}` : ""}
</span>
</div>
)}
</div>
<button onClick={onClose} className="p-1 hover:bg-gray-200 rounded ml-2 flex-shrink-0">
<X className="h-5 w-5" />
</button>
</div>
</div>
<div className="overflow-y-auto flex-1 p-4 space-y-4">
{/* Operator */}
<div className="space-y-2">
<h4 className="font-medium text-sm text-gray-700 flex items-center gap-2">
<Building2 className="h-4 w-4" />
Exploitant
</h4>
<div className="bg-gray-50 rounded p-3 text-sm">
<div className="font-medium">{p.operatorName || "Onbekend"}</div>
{detail?.operatorWebsite && (
<a
href={detail.operatorWebsite}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 hover:underline flex items-center gap-1 text-xs mt-1"
>
{detail.operatorWebsite}
<ExternalLink className="h-3 w-3" />
</a>
)}
<div className="text-xs text-gray-500 mt-1">Bron: {p.source.toUpperCase()}</div>
</div>
</div>
{loading && (
<div className="text-sm text-gray-500 italic flex items-center gap-2">
<span className="animate-spin h-4 w-4 border-2 border-gray-300 border-t-gray-600 rounded-full" />
Details laden…
</div>
)}
{!loading && detail && (
<>
{/* General */}
<div className="space-y-2">
<h4 className="font-medium text-sm text-gray-700 flex items-center gap-2">
<Clock className="h-4 w-4" />
Gegevens
</h4>
<div className="bg-gray-50 rounded p-3 text-sm space-y-1">
<Row label="24/7 toegang">
<span className={detail.twentyFourSeven ? "text-green-600" : "text-gray-500"}>
{detail.twentyFourSeven ? "Ja" : "Nee"}
</span>
</Row>
{detail.maxPowerKw > 0 && <Row label="Max. vermogen">{detail.maxPowerKw} kW</Row>}
{detail.parkingType && (
<Row label="Parkeren">{detail.parkingType.replace(/_/g, " ")}</Row>
)}
<Row label="OCPI ID">
<span className="font-mono text-xs">{detail.ocpiId}</span>
</Row>
<Row label="Bijgewerkt">
<span className="text-xs">{new Date(detail.lastUpdated).toLocaleString("nl-NL")}</span>
</Row>
</div>
</div>
{/* EVSEs */}
{detail.evses.length > 0 && (
<div className="space-y-2">
<h4 className="font-medium text-sm text-gray-700 flex items-center gap-2">
<Zap className="h-4 w-4" />
Laadpunten ({detail.evses.length})
</h4>
<div className="space-y-3">
{detail.evses.map((evse) => (
<div key={evse.uid} className="bg-gray-50 rounded p-3 text-sm">
<div className="flex items-center justify-between mb-2">
<span className="font-mono text-xs">{evse.evse_id}</span>
<span className={`px-2 py-0.5 rounded text-xs text-white ${statusColorClass(evse.status)}`}>
{statusLabel(evse.status)}
</span>
</div>
{evse.connectors.length > 0 && (
<div className="mt-1 pt-2 border-t border-gray-200 space-y-2">
{evse.connectors.map((c) => (
<div key={c.id} className="text-xs space-y-1">
<div className="flex justify-between">
<span className="font-medium">{formatConnectorStandard(c.standard)}</span>
<span className="text-gray-500">{c.format}</span>
</div>
<div className="flex justify-between text-gray-600">
<span>{formatPowerType(c.power_type)}</span>
{c.max_electric_power ? (
<span className="font-medium">{(c.max_electric_power / 1000).toFixed(1)} kW</span>
) : null}
</div>
{c.tariffs.length > 0 && c.tariffs[0].elements?.[0]?.price_components?.[0] && (
<div className="text-gray-500">
Tarief: {c.tariffs[0].elements[0].price_components[0].price}{" "}
{c.tariffs[0].currency} / {c.tariffs[0].elements[0].price_components[0].type.toLowerCase()}
</div>
)}
</div>
))}
</div>
)}
</div>
))}
</div>
</div>
)}
</>
)}
{!loading && !detail && (
<div className="text-sm text-gray-500 italic space-y-3">
<p>
Geen gedetailleerde informatie geladen voor deze locatie
{p.maxPowerKw > 0 ? ` (max. ${p.maxPowerKw} kW).` : "."}
</p>
{onJumpToGemeente && (
<button
onClick={onJumpToGemeente}
className="px-3 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition not-italic"
>
Ga naar deze gemeente voor details
</button>
)}
</div>
)}
</div>
</div>
);
}
function Row({ label, children }: { label: string; children: React.ReactNode }) {
return (
<div className="flex justify-between gap-2">
<span className="text-gray-600">{label}:</span>
<span className="text-right">{children}</span>
</div>
);
}