nigig-org/crates/nigig-pay-domain
User 0718743e19
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
nigig-map / test (push) Has been cancelled
Payment domain, storage, platform and UI / isolated-payment-tests (push) Has been cancelled
Payment domain, storage, platform and UI / payment-ui-tests (push) Has been cancelled
feat(map): implement Phase 2 route overlay system with markers and position puck
Complete overlay rendering system ported from Makepad upstream:

## New Features
- **Route Overlay Rendering**: Route polyline with casing (9px) and fill (5.5px)
  - Traveled portion dimming (alpha 0.30) for navigation progress
  - Additive glow effect (route_glow) for visual enhancement
  - Destination dot at route end
  - Screen-space rendering with viewport clipping

- **Drop Markers**: Professional pin-shaped markers with:
  - Soft ground shadow (ellipse)
  - Triangular tail + circular head pin shape
  - White pip in center
  - 16px tap detection radius for interaction
  - Custom color support per marker

- **Position Puck**: Current location indicator with:
  - Accuracy circle (scales with zoom, 10-28% alpha)
  - Heading wedge (20px tip, shows direction)
  - White ring + blue dot (9px/6.2px)
  - Automatic viewport clipping (60px margin)

## Implementation Details
- **OverlayCamera**: Screen-space transformation system
  - norm_to_screen() converts normalized coords to screen pixels
  - Supports rotation and 2.5D tilt (for future phases)
  - Meters-per-pixel calculation for accuracy circle scaling

- **Integration**: Seamlessly integrated into NigigMapView
  - Added draw_overlay: DrawVector field to widget
  - Added overlay_state: MapOverlayState field
  - Rendering happens after tile passes, before status text
  - Zero overhead when no overlays are active (is_empty() check)

- **Helper Functions**:
  - draw_route(): Multi-pass route rendering with travel dimming
  - draw_marker(): Pin-shaped marker with shadow and highlight
  - draw_puck(): Location indicator with accuracy and heading
  - marker_at(): Hit testing for tap interaction

- **Viewport Enhancement**: Added meters_per_pixel() method
  - Calculates real-world scale for accuracy circle sizing
  - Accounts for latitude-based distortion
  - Used by position puck for realistic accuracy visualization

## Technical Architecture
- Immediate-mode rendering using DrawVector
- Per-frame geometry rebuild (route scale: few hundred points)
- Viewport clipping with margin (24px for routes, 30px for markers)
- Decimation for performance (1.5px threshold on zoom-out)
- Additive blending for glow effects (no HDR required)

## Files Changed
- crates/apps/map/src/overlay.rs (NEW, 379 lines)
- crates/apps/map/src/lib.rs (module registration)
- crates/apps/map/src/view.rs (widget integration, 15 lines added)
- crates/apps/map/src/viewport.rs (meters_per_pixel method, 18 lines)

## API Usage

## Performance
- Zero cost when no overlays (early return on is_empty())
- Efficient viewport clipping reduces overdraw
- Route decimation prevents excessive geometry at low zoom
- All rendering uses GPU-accelerated DrawVector

## Compatibility
- Backward compatible: existing map functionality unchanged
- Overlay state persists across frames (no per-frame allocation)
- Integrates with existing theme system (route colors from theme)
- Supports future 2.5D camera and heading-up rotation

## Testing Recommendations
1. Verify routes render with casing/fill at all zoom levels
2. Test traveled portion dimming updates correctly
3. Verify markers appear at correct screen positions
4. Test position puck accuracy circle scales with zoom
5. Verify heading wedge rotates correctly
6. Test viewport clipping at screen edges

Refs: Phase 2 from MAKEPAD_DEV_BRANCH_GAP_ANALYSIS.md
Built on: Phase 1 (POI icon system, commit ae23d36)
2026-08-01 05:27:00 +00:00
..
benches feat(pay): complete the partially-done review phases 2026-07-27 15:07:28 +00:00
src feat(map): implement Phase 2 route overlay system with markers and position puck 2026-08-01 05:27:00 +00:00
Cargo.lock feat(pay): complete the partially-done review phases 2026-07-27 15:07:28 +00:00
Cargo.toml feat(pay): complete Phase 1 and fix M-Pesa store defects B1/B4 2026-07-27 15:23:20 +00:00