Traccar inconsistency #21

Closed
opened 2026-02-08 07:26:42 -08:00 by kyle · 3 comments
Owner

Unsure why why there are so many gaps between the coverage. Missing many pings that are interfering with the map plotting.

Unsure why why there are so many gaps between the coverage. Missing many pings that are interfering with the map plotting.
Author
Owner

Investigated and fixed multiple causes of GPS gaps:

  1. Increased sync overlap buffer from 5s to 30s to catch late-arriving positions
  2. Added position history endpoint for route trail data
  3. Added route trail rendering - map now draws Polyline paths showing historical positions for each tracked driver
  4. Added sync logging to help diagnose future issues (logs positions returned vs inserted)

The map now shows both live position markers AND historical route trails, so gaps in coverage are visually clear and the routes connect properly.

Investigated and fixed multiple causes of GPS gaps: 1. **Increased sync overlap buffer** from 5s to 30s to catch late-arriving positions 2. **Added position history endpoint** for route trail data 3. **Added route trail rendering** - map now draws Polyline paths showing historical positions for each tracked driver 4. **Added sync logging** to help diagnose future issues (logs positions returned vs inserted) The map now shows both live position markers AND historical route trails, so gaps in coverage are visually clear and the routes connect properly.
kyle closed this issue 2026-02-08 07:43:32 -08:00
kyle reopened this issue 2026-02-08 07:53:27 -08:00
Author
Owner

Is there any way that you can take the data points and tie the positions to the most likely route so we can get accurate mileage? As the user is driving a car (and not flying) this route is impossible. image.png Are there client setting to ensure that the route/position is captured every 10 seconds?

Is there any way that you can take the data points and tie the positions to the most likely route so we can get accurate mileage? As the user is driving a car (and not flying) this route is impossible. <img width="987" alt="image.png" src="attachments/363a8265-16d7-4978-8e4a-55d73b07e5d0"> Are there client setting to ensure that the route/position is captured every 10 seconds?
1.3 MiB
Author
Owner

Fixed with OSRM road-snapping (commit 33fda57)

Root cause: GPS routes were drawn as straight-line polylines between GPS points, cutting through buildings and non-existent roads. Mileage was also inaccurate because Haversine distance measures "as the crow flies" between points.

Solution: OSRM Map Matching

  • New OsrmService calls the free OSRM Match API to snap GPS coordinates to actual road networks
  • Backend endpoint GET /gps/locations/:driverId/history?matched=true returns road-snapped geometry
  • Mileage now calculated from OSRM road distance (falls back to Haversine if OSRM unavailable)
  • Frontend shows solid blue polylines for matched routes, dashed for raw GPS fallback
  • Distance badges show road miles on the map

Files changed:

  • backend/src/gps/osrm.service.ts (NEW) - OSRM client with chunking, rate limiting
  • backend/src/gps/gps.service.ts - getMatchedRoute(), OSRM-based stats
  • backend/src/gps/gps.controller.ts - history endpoint with matched param
  • frontend/src/pages/GpsTracking.tsx - road-snapped polylines + distance badges
  • frontend/src/hooks/useGps.ts - matched route requests
**Fixed with OSRM road-snapping** (commit 33fda57) Root cause: GPS routes were drawn as straight-line polylines between GPS points, cutting through buildings and non-existent roads. Mileage was also inaccurate because Haversine distance measures "as the crow flies" between points. **Solution: OSRM Map Matching** - New `OsrmService` calls the free OSRM Match API to snap GPS coordinates to actual road networks - Backend endpoint `GET /gps/locations/:driverId/history?matched=true` returns road-snapped geometry - Mileage now calculated from OSRM road distance (falls back to Haversine if OSRM unavailable) - Frontend shows solid blue polylines for matched routes, dashed for raw GPS fallback - Distance badges show road miles on the map **Files changed:** - `backend/src/gps/osrm.service.ts` (NEW) - OSRM client with chunking, rate limiting - `backend/src/gps/gps.service.ts` - getMatchedRoute(), OSRM-based stats - `backend/src/gps/gps.controller.ts` - history endpoint with matched param - `frontend/src/pages/GpsTracking.tsx` - road-snapped polylines + distance badges - `frontend/src/hooks/useGps.ts` - matched route requests
kyle closed this issue 2026-02-08 08:06:03 -08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kyle/vip-coordinator#21