Skip to content

On-device routing — explore offline surveillance-aware routing engines #119

@dougborg

Description

@dougborg

Problem

Remote routing requires internet connectivity and adds latency. DeFlock already supports offline map areas — offline routing would complete the offline experience and remove server dependency.

Goal

Investigate routing engines that could run on-device in DeFlock with camera avoidance support and downloadable regional data.

Research So Far — CoMaps/Organic Maps Engine

One option explored is the CoMaps routing engine (Apache 2.0, C++, fork of Organic Maps/MAPS.ME):

  • Custom bidirectional A* algorithm in C++
  • On-device routing with pre-downloaded .mwm regional data
  • Existing penalty system (7 types × 4 vehicle classes) with extensible architecture
  • EdgeEstimator::CalcSegmentWeight() is the key injection point for camera avoidance penalties
  • Road avoidance already exists (tolls, unpaved, motorways, ferries) via bitmask system
  • Geographic avoidance zones are architecturally feasible: extend EdgeEstimator, inject camera database, query proximity during weight calculation
  • No existing Flutter bindings — would need platform channels (C++ via JNI on Android, Swift bridge on iOS) or a Dart rewrite

Other Directions to Explore

  • Valhalla (C++, MIT license) — supports custom costing profiles, more feature-rich avoidance
  • OSRM (C++, BSD license) — proven offline routing, simpler model
  • Pure Dart implementation — rewrite A* routing in Dart, no FFI needed, simpler integration but needs custom map data preprocessing
  • GraphHopper Mobile — Java-based, Android-native, may have iOS limitations
  • flutter_osm_plugin — existing Flutter package with offline routing support

Key Design Decisions Needed

  • C++ via FFI vs. pure Dart rewrite
  • Map data format (MWM? Custom binary? OSM PBF preprocessing?)
  • Downloaded regions model (user picks state/metro area, ~100–500 MB per region)
  • How to inject camera locations into the routing graph (preprocessing vs. runtime penalty)
  • How to keep camera data fresh for offline use

Relationship to Remote Routing

This is exploratory — the short-term remote routing (#118) addresses the immediate need while this investigation proceeds.

Category

Routing · Research · Enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routingNavigation and routingenhancementNew feature or requestneeds-researchRequires investigation before implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions