valhalla_routing
DuckDB-Erweiterung für Routing und Fahrzeitberechnungen mit der Valhalla-Routing-Engine
Maintainer: onnimonni
Installation und Laden
INSTALL valhalla_routing FROM community;LOAD valhalla_routing;Beispiel
-- Load extensionsINSTALL httpfs; LOAD httpfs;INSTALL spatial; LOAD spatial;LOAD valhalla_routing;
-- Download and build tiles (Pure SQL!)SELECT valhalla_build_tiles( 'https://download.geofabrik.de/europe/monaco-latest.osm.pbf', './monaco_tiles');
-- Load tilesSET valhalla_tiles = './monaco_tiles';
-- Calculate routeSELECT round(r.distance_km, 1) as km, round(r.duration_minutes, 1) as minutes, ST_NPoints(r.geometry) as waypointsFROM ( SELECT valhalla_route( ST_Point(7.4275, 43.7397), -- Casino Monte-Carlo ST_Point(7.4254, 43.7308), -- Oceanographic Museum 'auto' ) as r);Über valhalla_routing
DuckDB Valhalla Routing Extension
Punkt-zu-Punkt-Routing mit Distanz, Dauer und Geometrie über die Valhalla-Routing-Engine.
Wichtige Funktionen (v0.2.0)
- Reiner SQL-Arbeitsablauf: Kacheln vollständig aus SQL herunterladen und bauen mit
valhalla_build_tiles() - Kluge Konfiguration: Routing-Daten mit
SET valhalla_tiles = './path'laden - Flexible Eingabe: akzeptiert WKT-Zeichenketten, WKB-Blobs oder GEOMETRY-Typen
- GEOMETRY-Ausgabe: liefert echte GEOMETRY-Typen (über Makro) oder WKB-Blobs
- Mehrere Verkehrsmodi: unterstützt auto, bicycle, pedestrian, truck, bus, taxi, motor_scooter
- Matrixabfragen: N×M-Fahrzeitmatrizen berechnen
- Räumliche Integration: arbeitet nahtlos mit der DuckDB-Spatial-Erweiterung
Funktionen
Kachelverwaltung (NEU in v0.2.0):
valhalla_build_tiles(pbf_url, output_dir)- PBF herunterladen und Routing-Kacheln bauenSET valhalla_tiles = 'path'- Kacheln laden (erkennt valhalla.json automatisch)
Routing:
valhalla_route(from, to, costing)- gibt den Typ GEOMETRY zurück (empfohlen)valhalla_route_wkb(from, to, costing)- gibt WKB BLOB zurücktravel_time_matrix(lats1, lons1, lats2, lons2, costing)- Distanz-/Dauermatrixtravel_time_locate(lat, lon, costing)- Koordinaten auf das Straßennetz einrastentravel_time_request(action, json)- rohe Valhalla-JSON-API
Schnellstart (100 % reines SQL)
-- Build tiles from HTTP URLSELECT valhalla_build_tiles( 'https://download.geofabrik.de/europe/monaco-latest.osm.pbf', './tiles');
-- Load and routeSET valhalla_tiles = './tiles';SELECT valhalla_route(ST_Point(7.42, 43.73), ST_Point(7.43, 43.74), 'auto');Dokumentation
- README.md - Schnellstart und API-Referenz
- ITALY.md - vollständiger Leitfaden zum Italien-Datensatz
- examples/ - einsatzbereite Beispiele
Datensätze
Getestet mit:
- Italien (2,4 GB Kacheln): Rom, Mailand, Venedig, Florenz
- Estland: Beispiele Tallinn–Tartu
- Monaco: Testdaten
OSM-Extrakte von Geofabrik herunterladen
Hinzugefügte Funktionen
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| travel_time | scalar | NULL | NULL | |
| travel_time_is_loaded | scalar | NULL | NULL | |
| travel_time_load_config | scalar | NULL | NULL | |
| travel_time_locate | scalar | NULL | NULL | |
| travel_time_matrix | table | NULL | NULL | |
| travel_time_request | scalar | NULL | NULL | |
| valhalla_build_tiles | scalar | NULL | NULL | |
| valhalla_route_wkb | scalar | NULL | NULL |
Überladene Funktionen
Diese Erweiterung fügt keine Funktionsüberladungen hinzu.
Hinzugefügte Typen
Diese Erweiterung fügt keine Typen hinzu.
Hinzugefügte Einstellungen
| name | description | input_type | scope | aliases |
|---|---|---|---|---|
| valhalla_tiles | Path to Valhalla tiles directory or config file | VARCHAR | GLOBAL | [] |