| Forum | GitHub | Maps | Blog

Feeding Matrix API's response to jsprit



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



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.


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