Osrm-backend: Distance Table

Created on 18 Feb 2019  路  4Comments  路  Source: Project-OSRM/osrm-backend

I need a matrix/table of distances between coords to pass to a VRP Solver.
This is the format: std::vector> .
I know OSRM does provide such a table, but it returns a JSON object, I don't need this, since I want to feed the table right into the Solver ( same .exe ).
How can I do this ? Without converting back & forth to JSON

Most helpful comment

Is this feature (exposing raw data) planned for the future?

I use osrm-backend with a homemade Scala/JNI wrapper and avoid the passage through JSON would be very nice.

All 4 comments

@Eichenherz Without modifying OSRM's code, you can't.

Internally, OSRM stores a flat std::vector before serializing to JSON - the data is there in an efficient format, it's just not exposed in the primary OSRM API (either via Node, HTTP or C++).

I've been considering how we could expose more compact representations, but there has been no work done so far. Unless you're willing to modify OSRM C++ code, there is no way to get the data in non-JSON format currently.

If there's no other way, then I'll modify the code. Where should I look exactly ?

Here: https://github.com/Project-OSRM/osrm-backend/blob/master/src/engine/plugins/table.cpp#L157

On this line, the result_tables_pair vector is fully populated with results. The .MakeResponse function converts that and packs it into the result object in JSON form.

The easiest thing to do would be to dive into .MakeResponse and have it serialize out a Buffer or some other flat structure. Check the tile.cpp plugin for an example of how to return binary data.

Is this feature (exposing raw data) planned for the future?

I use osrm-backend with a homemade Scala/JNI wrapper and avoid the passage through JSON would be very nice.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koussaimb picture koussaimb  路  4Comments

ryanbishop12 picture ryanbishop12  路  4Comments

brunosan picture brunosan  路  5Comments

ardanika picture ardanika  路  3Comments

Bardo-Konrad picture Bardo-Konrad  路  3Comments