Simulated navigation
How the app calculates and plays outbound and return routes, identifies test points, and cancels execution.
The Simulate route section on the Tracking screen plays a street route in approximately 60 seconds per leg. It uses the phone's identity and the same native queue as tracking. Points receive provider:test; the simulation does not change the system GPS.
Outbound and return legs
| Action | Origin | Destination |
|---|---|---|
| Go to destination · 1 min | A fresh reading of the current system position | The fixed destination defined in SIMULATION_DESTINATION |
| Return to actual location · 1 min | The latest simulated position persisted in this session | Another reading of the current system position |
The destination is configured in code and can be viewed in the app through View destination in Google Maps. This public documentation omits its address and coordinates.
The return leg does not automatically reuse the outbound GPS reading. If the device has moved, the return destination follows the position read at that moment. It is also possible to return from an interrupted outbound leg, provided the queue has accepted at least one simulated position. Without that starting point, the return control remains unavailable. The simulated position stays in memory during this screen session; there is no automatic leg resumption after restarting the app.
Preparation and route calculation
Continuous native collection does not need to be started to run a simulation. Enrollment must be complete, location access while using the app must be granted, GPS must be available, and route lookup requires internet access.
The app requests a fresh position with high accuracy through expo-location. Permission and GPS waits have 20-second limits. A position older than 20 seconds, a future timestamp beyond the five-second tolerance, or invalid coordinates are rejected. The position previously displayed under Latest sample is not used as a substitute for a fresh reading.
The HTTPS query uses the public OSRM service with the driving profile and full GeoJSON geometry. The client spaces query starts at least one second apart and ends route preparation after 20 seconds. The returned route must be a valid LineString with between two and 100,000 vertices. The app does not invent a straight line when the service cannot find a route.
OSRM snaps endpoints to available streets. The app accepts connectors up to 250 meters to preserve the exact endpoints; larger distances are rejected. The origin and destination are sent to the external routing service. No tracking token is sent in this query, and network errors are replaced with messages that do not reveal the URL containing coordinates.
One-minute playback
The playback clock starts after the GPS reading and route have been obtained. The total time from tapping the button can therefore exceed one minute. The original duration estimated by the service is neither the animation duration nor a real journey forecast.
The plan sums segment distances and interpolates the point corresponding to progress. This distributes movement by distance and preserves turns and endpoints. Playback targets one sample every 500 ms, including the start and end: under ideal conditions, one leg generates 121 points.
Each point receives a capture timestamp, synthetic accuracy of five meters, and provider:test. The next write only starts after the previous one finishes. If the native bridge is delayed, progress advances to the current time; there is no burst of overdue points, and the count may be lower than 121. Leg completed means that points have been handed to the queue, not that all have already received a server ACK.
Keeping the screen open, cancellation, and real collection
Execution keeps the screen awake with expo-keep-awake. The user must remain on the screen and in the foreground. Leaving it or sending the app to the background cancels preparation or playback. Returning to the screen does not resume the leg automatically.
| Action | Effect |
|---|---|
| Stop simulation | Cancels new synthetic points; native collection remains as it was. |
| Stop tracking | Cancels the simulation and ends the local native capture session. |
| Leave the screen or go to Home | Cancels the synthetic leg; the native collector follows its own lifecycle. |
| Retry leg | Starts another preparation attempt after an error. |
A point already handed to the bridge may finish writing during cancellation. The app waits for that completion before allowing another leg. Canceling does not remove points from SQLite or the server; queue and synchronization still apply to those events.
Viewing and interpreting results
On the dashboard, enable Show simulations to include orange markers. The native marker remains separate. The browser's WebSocket connection describes communication between the dashboard and server, not the phone's current connectivity.
| Point origin | provider | Evidence produced |
|---|---|---|
| Route or synthetic sample in the app | test | Geometry, bridge, native queue, and transport. |
| GPS changed through emulator/simulator commands | native | System location callback in a simulated environment. |
| GPS from a physical phone | native | Physical capture, to be evaluated in the field test. |
The public routing server is an external dependency: unavailability, a position far from a road, or an invalid route prevents the leg from starting. Simulation does not demonstrate battery life, continuous background capture, reboot behavior, or physical reliability. Historical results and gaps are covered in tests and field testing.
Repository sources
geo-demo/src/features/tracking/route-simulation.ts.geo-demo/src/features/tracking/current-system-location.ts.geo-demo/src/features/tracking/route-simulation-runner.tsanduse-route-simulation.ts.geo-demo/src/features/tracking/components/route-simulation-panel.tsx.docs/navigation-simulation.md.