nigig-org/crates/apps/valhalla
2026-07-28 17:50:06 +00:00
..
src feat(valhalla): implement phase 3 valhalla-elevation skadi dem tile sampler, height endpoint, and isochrone service 2026-07-28 17:05:56 +00:00
valhalla-builder test(valhalla): expand unit test suite to 66 passing tests across core, cost, narrative, and builder crates 2026-07-28 17:21:55 +00:00
valhalla-core feat(valhalla): implement phase B 2d line segment intersection, ellipse containment, and oriented bounding box obb2 overlap math 2026-07-28 17:50:06 +00:00
valhalla-cost test(valhalla): expand unit test suite to 66 passing tests across core, cost, narrative, and builder crates 2026-07-28 17:21:55 +00:00
valhalla-diff test(valhalla): expand end-to-end integration tests for compiled graph tile routing, matrix calculation, and map matching 2026-07-28 17:30:35 +00:00
valhalla-elevation feat(valhalla): implement phase 3 valhalla-elevation skadi dem tile sampler, height endpoint, and isochrone service 2026-07-28 17:05:56 +00:00
valhalla-makepad feat(valhalla): implement phase 4 makepad ui integration and relocate valhalla suite under crates/apps/valhalla 2026-07-27 16:09:08 +00:00
valhalla-match feat(valhalla): implement phase 2 isochrone reachability polygon generator, alternate route finder, and gps heading emission penalty 2026-07-28 17:01:12 +00:00
valhalla-narrative feat(valhalla): implement phase A signinfo, landmark attacher, and maneuver guidance sign integration 2026-07-28 17:43:46 +00:00
valhalla-path test(valhalla): expand end-to-end integration tests for compiled graph tile routing, matrix calculation, and map matching 2026-07-28 17:30:35 +00:00
valhalla-search feat(valhalla): implement phase 4 makepad ui integration and relocate valhalla suite under crates/apps/valhalla 2026-07-27 16:09:08 +00:00
valhalla-service test(valhalla): expand end-to-end integration tests for compiled graph tile routing, matrix calculation, and map matching 2026-07-28 17:30:35 +00:00
Cargo.toml feat(valhalla): implement phase 3 valhalla-elevation skadi dem tile sampler, height endpoint, and isochrone service 2026-07-28 17:05:56 +00:00
README.md docs(valhalla): add native makepad integration guide and architecture documentation 2026-07-28 16:25:29 +00:00

Valhalla Pure Rust Routing Engine (valhalla-rs)

Native Makepad Integration Guide & Architecture Overview

valhalla-rs is a Pure Rust port and architectural rewrite of the Valhalla Routing Engine, designed specifically for cross-platform Makepad UI Framework applications (nigig-rider, nigig-delivery, nigig-tow, nigig-mobility).


1. Crate Architecture

The suite is organized into modular pure Rust crates under crates/apps/valhalla/:

crates/apps/valhalla/
├── valhalla              # Top-level unified facade crate
├── valhalla-core         # Midgard geometry & Baldr GraphTile binary bitfield reader
├── valhalla-cost         # Auto, Bicycle, Pedestrian, Truck, & Transit costing profiles
├── valhalla-path         # DoubleBucketQueue, A*, Bidi A*, Matrix, & MultiModal A*
├── valhalla-search       # Location snapping & candidate edge locator (Loki)
├── valhalla-match        # HMM Viterbi trajectory map matcher (Meili)
├── valhalla-narrative    # Maneuver builder, NarrativeDictionary, & VerbalTextFormatter
├── valhalla-service      # Tyr ValhallaActor service API
├── valhalla-makepad      # Makepad UI overlay & DriverGuidanceController
├── valhalla-builder      # OSM PBF tag parser, PbfReader, TileGenerator & shortcuts
└── valhalla-diff         # Golden differential parity test harness

2. Quickstart & Integration Usage

2.1 Basic Route Query (ValhallaActor)

use valhalla::{ValhallaActor, PointLL};

// Initialize actor with loaded GraphTiles
let actor = ValhallaActor::new(tile_buffers);

let origin = PointLL::new(36.8219, -1.2921);      // Nairobi CBD
let destination = PointLL::new(36.8050, -1.2650); // Westlands

// Calculate route response
let response = actor.route(origin, destination, "auto");

if response.status == 200 {
    println!("Total Distance: {} meters", response.directions.total_distance_meters);
    println!("Total Time: {} seconds", response.directions.total_time_secs);

    for maneuver in &response.directions.maneuvers {
        println!("Instruction: {}", maneuver.instruction);
    }
}

2.2 Live Driver Navigation & Off-Route Auto-Rerouting (DriverGuidanceController)

use valhalla::{DriverGuidanceController, ValhallaActor, PointLL, GuidanceEvent};

let actor = ValhallaActor::new(tile_buffers);
let mut controller = DriverGuidanceController::new(actor);

// Set calculated route
controller.set_active_route(route_response);

// On GPS location update from robius-location
let gps_coord = PointLL::new(36.8220, -1.2915);
let events = controller.on_location_update(gps_coord, "auto");

for event in events {
    match event {
        GuidanceEvent::UpdatedHud(hud_data) => {
            println!("HUD Step: {}", hud_data.current_instruction);
            println!("Distance to turn: {}m", hud_data.distance_to_next_maneuver_meters);
        }
        GuidanceEvent::Rerouted(new_route) => {
            println!("Off-route detected! Auto-rerouted along new path.");
        }
        GuidanceEvent::ArrivedAtDestination => {
            println!("Arrived at destination!");
        }
    }
}

// Generate GPU stroke overlay for nigig-map
let overlay = controller.get_route_overlay();

3. Testing & CI Verification

Run the isolated test harness across all 10 Valhalla subcrates:

TEST_TARGET=valhalla ./tools/test-rust-clean.sh

All 45 unit and integration parity tests must pass cleanly under rustfmt and clippy.