otp-travel-time-matrix icon indicating copy to clipboard operation
otp-travel-time-matrix copied to clipboard

extract distance information

Open rafapereirabr opened this issue 8 years ago • 2 comments

@laurentg and @mattwigway , do you know how to get the distance travelled by each mode?

There is command r.getWalkDistance() in the current python script that returns the distance walked for each trip. Following the same intuition, I have tried to get the distance travelled on other transport modes using these commands below. None of them worked :( Is there a way to get this information through the python script? As you know, this is quite important because some transport models focus on travelled distances instead of time.

r.getBicycleDistance() for bikes r.getCarDistance() for cars r.getTransitDistance() for multimodal transit trips

rafapereirabr avatar Jan 30 '17 11:01 rafapereirabr

There is no such methods in the OTP scripting API. To see the API you can check the various classes in the org.opentripplanner.scripting.api package (the class you refer to is called OtpsEvaluatedIndividual.

Number of boardings and walk distance are easy to evaluate as they are directly accessible in the state pointed to by the sampled point. As the break-down of distance traveled by mode is not directly stored in the state, they are a bit more complex to compute, but it's feasible. You just have to traverse the back states starting from the evaluated point and accumulate the result depending on the traversed states.

The only tricky part is maybe to interpolate the result, as in this implementation the sample point keep two vertices with two walk distances; but the path to the origin can be completely different according to which vertex is taken first. The easiest is to only take the result from the optimal vertex (shortest total time, total time being state @ vertex time + walk time from this vertex to the point).

laurentg avatar Jan 30 '17 12:01 laurentg

Thank you for the information @laurentg !

rafapereirabr avatar Jan 31 '17 14:01 rafapereirabr