Snap to Roads

Track-trace2 3 years ago

Has anyone been working on or implemented Snap to Roads in traccar server ?

The idear seems interesting if it can be used for showing a "better" route in traccar.

I found some links, might be interesting to run your own server for it.

https://github.com/Project-OSRM

https://github.com/valhalla/valhalla

Anyone has idears about it or some tutorials if you have used it with traccar server ?

Track-trace2 3 years ago

Or some info from Google Developers

https://developers.google.com/maps/documentation/roads/snap

I could not post more then two links in the topic above. Btw i read some old topics here about it, but not really found a project.

Tracker 3 years ago

Hello, I had never heard of it and I haven't used it either, it would be good to look at the documentation as soon as possible

Track-trace 3 years ago

Actually in the past it was already implemented in a fork of traccar support for the new version of the OSRM API (v5) used for the “Snap-to-roads” functionality.

Tracker 3 years ago

I will deepen my view on this matter. Thanks

Urdanegui Castillo 2 years ago

Have any colleagues managed to implement OSRM in Traccar and achieve a significant improvement in reporting?

Byhturk 2 years ago

I'm looking forward to your answers on this subject. Since the devices can sometimes be positioned in this way, they also have the ability to load according to angle, but deviations may occur in this way.
route slip example

Angelo Zuottolo 8 months ago

I am using a clean installation of Traccar Server v6.8 on Ubuntu. I am trying to use the 'Show Route' feature in the reports to display the route on the road, instead of a straight line between points.
I have enabled the geocoder with geocoder.type = nominatim and I have set <entry key='web.lilius'>true</entry> in my config file.
When I generate a report and enable the 'Show Route' option, I can see the checkbox, but it does not draw the calculated route on the map (the "blue line"). The log files show no errors.
The main documentation for the config file does not list the old routing.* parameters anymore.
What is the official, documented way to configure a routing provider (like GraphHopper or OSRM) to make the 'Show Route' feature work in the latest versions?
Thank you.

Anton Tananaev 8 months ago

The web.lilius does not exist. You should probably check the official documentation first.

Angelo Zuottolo 8 months ago

I checked the documentation and there is no SnapToRoad functionality, but i read on other Topics that this is somehow achievable

WrA 6 days ago

has been tested and can be implemented using one of the following approaches:

  • Self-hosted OSRM backend (Docker) with specific regional data (requires sufficient capacity)
  • forward.url --> Post the location received by the Traccar backend (can be Node-RED or another suitable solution)
  • Payload message processing on the receiving machine (DB, JSON, MQTT, and others)
  • Data visualization and retrieval methods from the DB (route/match) can be selected as needed, for example using Node.js
  • If possible, create a custom Traccar-Web as an additional feature within it
Track-trace 6 days ago

You have a working example or links / tutorial for a working setup?

WrA 5 days ago

At the moment, I haven’t created any specific documentation yet, and there’s quite a lot involved in the process.
Maybe in the future I’ll try to push it to Git.
My apologies.
As an example, here are the results from the OSRM routing engine backend stored in a database, with a Node.js UI serving as the viewer.
I hope this provides a simple illustration
Produced by route controller function
which is generated by the route controller function based on device data in the database, and processed into an OSRM-backend URL

// GET /api/routes/device/:deviceId
router.get('/device/:deviceId', routeController.getDeviceRoute);
// GET /api/routes/device/:deviceId/time-range
router.get('/device/:deviceId/time-range', routeController.getDeviceTimeRange);
// GET /api/routes/device/:deviceId/match (map matching)
router.post('/device/:deviceId/match', routeController.matchRoute);

osrm-engine.jpg

Track-trace 4 days ago

Ok, so acctually you only get the positions from traccar server, there's no implementation in traccar server itself right ?

WrA 4 days ago

Yes, you're right; that's how it works in the object above.
Using the middleware method could be the safest approach in practice.
Traccar itself hasn't implemented it in its source code yet. I haven't found that yet
So in that case, Traccar functions as a tracking server with various internal processes and provides routing using the Haversine algorithm (fast).
The custom “snap to road” visual (slower) is processed separately via GeoJSON outside the tracking server (Traccar) using the available forwarding feature.

Note: There is a difference in coordinate order usage:
Traccar --> Latitude, Longitude (lat, lon) (GPS/NMEA & Human conventions)
OSRM --> Longitude, Latitude (lon, lat) (GIS/GeoJSON/OSM standards)

Even if implemented / integrated directly into the backend as a custom feature, the OSRM engine would likely remain a separate component outside of the Traccar tracking system itself
OSRM as an independent service system

Possibility of native code implementation, with the following (as an opinion):

src/main/java/org/traccar/
--> reports/RouteReportProvider.java (addition of custom imports & routing logic)
--> api/ReportResource.java (addition of custom imports & routing logic:)
--> routing/OsrmClient.java (new class & constructor)
--> config/Keys.java (addition of routing config key)

e.g. :

/**
 * Routing engine type: none, osrm, graphhopper, valhalla
 * Default: none (disabled)
 */
public static final ConfigKey<String> ROUTING_TYPE = new StringConfigKey(
    “routing.type”,
    List.of(KeyType.CONFIG),
    “none”);

/**
 * Base URL for routing engine API endpoint
 * Example: http://localhost:5000
 */
public static final ConfigKey<String> ROUTING_URL = new StringConfigKey(
    “routing.url”,
    List.of(KeyType.CONFIG),
    “http://localhost:5000”);

and so on, in accordance with the OSRM-Engine platform architecture
In short, that’s just as opinion