Selbstgehostete Geo-Dienste (OSRM + Nominatim auf Österreich-Extrakt),
Geokodierung beim Speichern und ETA-Sortierung der Suchtreffer mit
vollständigem Haversine-Luftlinie-Fallback.
- src/lib/geo/types.ts, config.ts: reine Typen + zentrale Konfiguration
(aus kanonischem env.ts; Defaults, kaputte URL wird weiterhin abgelehnt).
- haversine.ts: Luftlinie in Metern (rein). St. Pölten->Wien ~55 km verifiziert.
- nominatim.ts: kanonische, reine geocodeAddress(address) (countrycodes=at,
Timeout/Abort, status ok/not_found/error; KEIN geocodeBrigade-Zweitpfad).
- osrm.ts: etaTable via /table (sources=0, lng,lat), wirft bei Fehler.
- eintreffzeit.ts: orderByEintreffzeit (OSRM-first, kompletter Haversine-
Fallback bei Wurf, Kandidaten ohne Koordinaten ans Ende, stabile Sortierung;
OSRM-Funktion injizierbar fuer Tests).
- candidates.ts: searchHitsToGeoCandidates (Adapter, laedt brigades.lat/lng)
+ reine filterAndCapCandidates (Bounding-Box-Vorfilter 60 km, max 100).
- API: /api/geo/geocode (POST, auth-gated 401, Zod-Body, 404 bei not_found)
und /api/geo/health (GET, auth-gated; OSRM/Nominatim up/down) — beide
default-deny ueber apiAuth.
- Komponenten: standort-input.tsx (Client, Geolocation + Geocode-Fetch),
eta-badge.tsx (kennzeichnet Luftlinie-Fallback), optionale karte.tsx
via next/dynamic (ssr:false).
- Infra: docker-compose.geo.yml (internes Netz, Healthchecks), docker/osrm/
Dockerfile, scripts/prepare-osm-data.sh, infra/geo/{Makefile,README.md}.
WS4 legt KEINE Migration an (brigades-Geo-Spalten + brigades_latlng_idx
stammen aus WS2); drizzle-kit check bleibt sauber.
Offline verifiziert: tsc --noEmit (exit 0), next lint (0 Warnungen),
vitest run (54 passed / 7 skipped DB-roundtrip), next build (exit 0 mit
gesetzten env-Vars), drizzle-kit check ("Everything's fine").
Deferred (kein Postgres/Server im Sandbox): db:migrate, Live-OSRM/Nominatim,
Playwright-E2E.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.3 KiB
Bash
Executable File
40 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# OSRM-Preprocessing für den Österreich-Extrakt (extract -> partition -> customize).
|
|
# Erzeugt das .osrm-Set im OSRM-Daten-Volume, bevor `osrm-routed` startet.
|
|
#
|
|
# Verwendung:
|
|
# scripts/prepare-osm-data.sh
|
|
# (oder: make -C infra/geo data)
|
|
#
|
|
# Hinweis: Läuft NICHT in der CI/Sandbox — benötigt Docker, Netzugriff zum
|
|
# Geofabrik-Download und mehrere GB RAM/Disk. Dauer: mehrere Minuten bis Stunden.
|
|
set -euo pipefail
|
|
|
|
DATA_DIR="${OSRM_DATA_DIR:-./infra/geo/data}"
|
|
PBF_URL="${PBF_URL:-https://download.geofabrik.de/europe/austria-latest.osm.pbf}"
|
|
PBF_FILE="austria-latest.osm.pbf"
|
|
OSM_BASENAME="austria-latest"
|
|
OSRM_IMAGE="${OSRM_IMAGE:-ghcr.io/project-osrm/osrm-backend:latest}"
|
|
PROFILE="/opt/car.lua"
|
|
|
|
mkdir -p "${DATA_DIR}"
|
|
|
|
if [[ ! -f "${DATA_DIR}/${PBF_FILE}" ]]; then
|
|
echo "Lade OSM-Extrakt: ${PBF_URL}"
|
|
curl -fSL "${PBF_URL}" -o "${DATA_DIR}/${PBF_FILE}"
|
|
fi
|
|
|
|
run_osrm() {
|
|
docker run --rm -t -v "$(pwd)/${DATA_DIR}:/data" "${OSRM_IMAGE}" "$@"
|
|
}
|
|
|
|
echo "1/3 extract"
|
|
run_osrm osrm-extract -p "${PROFILE}" "/data/${PBF_FILE}"
|
|
echo "2/3 partition"
|
|
run_osrm osrm-partition "/data/${OSM_BASENAME}.osrm"
|
|
echo "3/3 customize"
|
|
run_osrm osrm-customize "/data/${OSM_BASENAME}.osrm"
|
|
|
|
echo "Fertig. .osrm-Set liegt in ${DATA_DIR}."
|
|
echo "Daten ins OSRM-Volume kopieren oder Volume auf ${DATA_DIR} mappen."
|