Feeding Matrix API's response to jsprit

Hi,

How do I feed my matrix api’s response data (distance and time) into Jsprit. ?

Thanks,
Karthi.

Hi Kardee,
I think you are looking for this.

You can feed distance and time by:
VehicleRoutingTransportCostsMatrix.Builder costMatrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);

costMatrixBuilder.addTransportDistance(“idFrom”, “idTo”, distance);

costMatrixBuilder.addTransportTime(“idFrom”, “idTo”, duration);

I hope this helps.

Kind regards.

1 Like

FastVehicleRoutingTransportCostsMatrix might be the faster option. There is also a simple method allowing you to add time and distance at the same time.

Regarding this, what is the fastest way to calculate the distance between two points?
eg. of 5 points, I have to add the following;
0, 1, x
0, 2, x
0, 3, x
etc

This can be done via graphhopper iteratively but is slow.