7.2 KiB
7.2 KiB
Valhalla Pure Rust Engine, nigig-map, and nigig-rider Integration Plan
End-to-End Architectural Specification & Implementation Roadmap
Date: July 28, 2026
Target Application: nigig-rider (Riding App) & nigig-map (Map Renderer)
Routing Engine: valhalla (crates/apps/valhalla/*)
GPS Tracking: robius-location
1. Executive Summary & Integration Architecture
With the completion of the Pure Rust Valhalla Routing Engine (valhalla-rs), this plan specifies the exact technical architecture to connect the routing engine with the Makepad Map Renderer (nigig-map) and the Rider Riding Application (nigig-rider).
┌────────────────────────────────────────────────────────────────────────┐
│ nigig-rider App │
│ │
│ 1. `RiderBookPage` (Search / Pin Drop) │
│ 2. `RiderTrackPage` (Live Navigation HUD & Driver Tracking) │
└───────────────────┬────────────────────────────────┬───────────────────┘
│ │
▼ ▼
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ valhalla::ValhallaActor │ │ valhalla::DriverGuidance │
│ (A* Route & Matrix Engine) │ │ Controller (HMM GPS Snapper) │
└──────────────┬───────────────┘ └──────────────┬───────────────┘
│ │
└────────────────┬───────────────┘
│
▼
┌─────────────────────────────────┐
│ nigig-map Map Renderer │
│ │
│ • RouteRenderPass (StrokePass) │
│ • Waypoint Marker Pass │
└─────────────────────────────────┘
2. Key Technical Integration Points
2.1 Route Overlay Pass in nigig-map (RouteRenderPass)
nigig-map uses a modular RenderGraph pipeline with explicit pass ordering:
PassType::Background(z=0)PassType::Fill(z=100)PassType::Stroke(z=200)PassType::Poi(z=300)PassType::Label(z=400)PassType::Selection(z=500)
Action: Add a custom RouteRenderPass (z=250, between road stroke and POI) implementing RenderPass in crates/apps/map/src/render_graph.rs:
- Reads route shape points (
Vec<PointLL>) fromvalhalla::ui::RouteOverlay. - Converts geographic coordinates (
PointLL) to Mercator screen space usinglon_lat_to_normalized(lng, lat) * world_size + map_offset. - Tessellates route polylines into GPU stroke vertices with navigation-blue casing (
#3b82f6) and 6px stroke width.
2.2 RiderBookPage Integration (crates/apps/nigig-rider/src/rider_frame/pages/book.rs)
- On destination search or location row tap:
- Retrieve origin coordinate (current GPS position or map center:
36.8219, -1.2921). - Issue route request:
actor.route(origin, destination, "auto"). - Extract
RouteResponsepolyline shape and pass toNigigMapView::set_route_overlay(). - Display ETA summary card (total distance in km, travel duration in minutes).
- Retrieve origin coordinate (current GPS position or map center:
2.3 RiderTrackPage Integration (crates/apps/nigig-rider/src/rider_frame/pages/track.rs)
- On live GPS updates from
robius-location:- Feed location to
DriverGuidanceController::on_location_update(coord, "auto"). - Update
NavigationHudDataUI card (current turn maneuver instruction, distance to turn, next turn arrow). - On
GuidanceEvent::Rerouted(new_route)(>25\text{m}off-route threshold): update map route overlay line and recalculate ETA automatically.
- Feed location to
3. Step-by-Step Execution Roadmap
┌────────────────────────────────────────────────────────────────────────┐
│ 5-STEP IMPLEMENTATION ROADMAP │
│ │
│ STEP 1: Add `RouteRenderPass` to `nigig-map` RenderGraph │
│ STEP 2: Add `set_route_overlay()` API to `NigigMapView` │
│ STEP 3: Wire `ValhallaActor` into `RiderBookPage` (`book.rs`) │
│ STEP 4: Wire Guidance HUD & `robius-location` into `track.rs` │
│ STEP 5: Validate via `tools/test-rust-clean.sh` & Push to Gitdab │
└────────────────────────────────────────────────────────────────────────┘
Step 1: Add RouteRenderPass to nigig-map
- File:
crates/apps/map/src/render_graph.rs - Add
PassType::Route(z=250) and implementRenderPassforRoutePassrendering polyline strokes over road networks.
Step 2: Add set_route_overlay() API to NigigMapView
- File:
crates/apps/map/src/view.rs - Add
pub fn set_route_overlay(&mut self, cx: &mut Cx, overlay: Option<valhalla::ui::RouteOverlay>)to update active route overlays and triggerredraw(cx).
Step 3: Wire ValhallaActor into RiderBookPage
- File:
crates/apps/nigig-rider/src/rider_frame/pages/book.rs - Instantiate
ValhallaActoron page load, attach destination tap handler, and render ETA card on route completion.
Step 4: Wire Guidance HUD into RiderTrackPage
- File:
crates/apps/nigig-rider/src/rider_frame/pages/track.rs - Instantiate
DriverGuidanceController, bind location stream, and update navigation HUD cards.
Step 5: Verification & Testing
- Test using
TEST_TARGET=valhallaandcargo check -p nigig-riderto ensure clean compilation.
4. Expected User Experience Outcome
When complete:
- Interactive Route Planning: Tapping any location in
nigig-riderinstantly renders a smooth blue route overlay line along the road network onNigigMapView. - Turn-by-Turn Guidance HUD: Displays upcoming maneuvers ("Turn right onto Uhuru Highway in 200m").
- Live GPS Tracking & Auto-Rerouting: Snaps driver location to road network and automatically recalculates routes if the driver takes a wrong turn (
>25\text{m}deviation).