You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Isochrone issue with distance_limit compared to actual route when not using ShortestWeighting #1979
I just saw an issue with the Isochrone calculation. When I pass a time_limit, the resulting isoline surrounds more or less exactly the area that I can reach within the given time. When I pass a distance_limit, the resulting isoline seems to differ significantly from the give distance.
Here is one example with 10km, but this seems to be the case for every example I have checked so far: /isochrone?point=48.692958,9.461932&distance_limit=10000&vehicle=car
The resulting polygon looks like this:
If I pick any point at random at the border of the polygon, for example this one. The resulting route is < 7km. I would have expected the resulting route to be close to the requested 10km.
changed the title [-]Isochrone issue with distance_limit compared to actual route[/-][+]Isochrone issue with distance_limit compared to actual route when not using ShortestWeighting[/+]on Mar 31, 2020
Ah, I found the issue, sorry for the trouble. The issue was in this case that I used the incorrect weighting. If you use the FastestWeight the above result is generated. If you use the ShortestWeight, the results seem correct.
Ok, so I think I found the underlying issue here as well. In Isochrone#searchInternal() we use the check nEdge.weight > tmpWeight, shouldn't we use the limit criteria instead?
So for distance, we should probably check: nEdge.distance > tmpDistance, I tried this locally, and the results for weighting=fastest, look a lot more reasonable (still a bit different than using weighting=shortest).
When I also change the compareTo method of the IsoLabel ot use distance, the results look pretty identical.
Using the FastestWeighting and the distance_limit is indeed a bit "strange" but several user seems to want this so we provide it :)
Still I do not think that we should change the check (but I might be wrong), because the "shortest path tree" should be created according to the weighting not according to the limit, i.e. it should use the FastestWeighting and not the distance. And only changing the check does not seem to be correct, i.e. we would also need to change the queue sorting property, which basically means that we switch to ShortestWeighting.
To your issue. Could it be that we traverse too few entries beyond we reach the limit in this case, resulting in the weak isochrone? I.e. what happens when you increase the finishLimit to e.g.
Using the FastestWeighting and the distance_limit is indeed a bit "strange" but several user seems to want this so we provide it :)
But how about any other Weighting, like some custom weighting? If this issue exists with the FastestWeighting, it probably exists for arbitrary weightings as well. Like a fuel consumption weighting or a toll cost weighting. What would be the meaning of the distance_limit with the FastetWeighting? The more I think about it, it makes sense that the results are "unexpected".
So I am thinking that probably the correct way of doing this would be to only allow a weight_limit and requiring to set the correct Weighting. So FastestWeigthing will limit based on the time, as this is the result of the weighting method, ShortestWeighting based on distance, and some toll cost weighting based on cost.
We could automate this for distance_limit and time_limit by enforcing the shortest and fastest weighting, for weight_limit, we would use the given Weighting (when we add a weight_limit parameter :)).
And only changing the check does not seem to be correct, i.e. we would also need to change the queue sorting property, which basically means that we switch to ShortestWeighting.
Yes exactly. Essentially, when you change all the things I mention above, you essentially are creating a ShortestWeighting. I changed the limit criteria and the ordering of the queue by changing:
When I also change the compareTo method of the IsoLabel ot use distance, the results look pretty identical.
But how about any other Weighting, like some custom weighting?
The recommended way is to use the time_limit parameter and make sure the calcWeight method returns a time unit :).
Things get a bit complicated when something like fuel or energy consumption are dependent on the distance and so the distance_limit makes some sense for "fastest" too.
and some toll cost weighting based on cost
I think that even toll costs can be converted into a time unit, i.e. it defines how you trade money for potential detours.
@karussell Hmmm. I think we should either know precisely what we mean when the objective function (the weighting) is different from the z-function (for which we compute the isoline), or we shouldn't offer it. Robin is right, those two functions can be arbitrarily different, and we (the isochrone service) have to be able to give a consistent answer. I think there is one, but this is not it. We probably have to track all leaves of the SPT and terminate only when all of them are > limit, because, as you say, the queue is sorted by something else.
I changed half of this anyway an hour ago. There was at least one more problem in there: It would return points that weren't even pulled out of the queue yet. (Also in SPTResource.)
I tried to understand your fix and was wondering about the two queues. Having two queues is actually a really good idea. I first thought that always ordering by weight and simply enforcing that weighting matches the limit would be enough, but there are valid cases, where you actually want them to be different.
Activity
[-]Isochrone distance_limit[/-][+]Isochrone issue with distance_limit compared to actual route[/+][-]Isochrone issue with distance_limit compared to actual route[/-][+]Isochrone issue with distance_limit compared to actual route when not using ShortestWeighting[/+]boldtrn commentedon Mar 31, 2020
Ah, I found the issue, sorry for the trouble. The issue was in this case that I used the incorrect weighting. If you use the FastestWeight the above result is generated. If you use the ShortestWeight, the results seem correct.
In this case the polygon looks like this:

boldtrn commentedon Mar 31, 2020
Ok, so I think I found the underlying issue here as well. In
Isochrone#searchInternal()we use the checknEdge.weight > tmpWeight, shouldn't we use the limit criteria instead?So for distance, we should probably check:
nEdge.distance > tmpDistance, I tried this locally, and the results for weighting=fastest, look a lot more reasonable (still a bit different than using weighting=shortest).When I also change the compareTo method of the IsoLabel ot use distance, the results look pretty identical.
boldtrn commentedon Mar 31, 2020
So WDYT, should we change this? I could provide a PR to add the above mentioned changes in a more flexible way based on the finish criteria.
karussell commentedon Apr 6, 2020
Using the FastestWeighting and the distance_limit is indeed a bit "strange" but several user seems to want this so we provide it :)
Still I do not think that we should change the check (but I might be wrong), because the "shortest path tree" should be created according to the weighting not according to the limit, i.e. it should use the FastestWeighting and not the distance. And only changing the check does not seem to be correct, i.e. we would also need to change the queue sorting property, which basically means that we switch to ShortestWeighting.
To your issue. Could it be that we traverse too few entries beyond we reach the limit in this case, resulting in the weak isochrone? I.e. what happens when you increase the finishLimit to e.g.
in setTimeLimit?
boldtrn commentedon Apr 6, 2020
But how about any other Weighting, like some custom weighting? If this issue exists with the FastestWeighting, it probably exists for arbitrary weightings as well. Like a fuel consumption weighting or a toll cost weighting. What would be the meaning of the distance_limit with the FastetWeighting? The more I think about it, it makes sense that the results are "unexpected".
So I am thinking that probably the correct way of doing this would be to only allow a weight_limit and requiring to set the correct Weighting. So FastestWeigthing will limit based on the time, as this is the result of the weighting method, ShortestWeighting based on distance, and some toll cost weighting based on cost.
We could automate this for distance_limit and time_limit by enforcing the shortest and fastest weighting, for weight_limit, we would use the given Weighting (when we add a weight_limit parameter :)).
Yes exactly. Essentially, when you change all the things I mention above, you essentially are creating a ShortestWeighting. I changed the limit criteria and the ordering of the queue by changing:
karussell commentedon Apr 6, 2020
The recommended way is to use the time_limit parameter and make sure the calcWeight method returns a time unit :).
Things get a bit complicated when something like fuel or energy consumption are dependent on the distance and so the distance_limit makes some sense for "fastest" too.
I think that even toll costs can be converted into a time unit, i.e. it defines how you trade money for potential detours.
michaz commentedon Apr 7, 2020
@boldtrn You're right, and this is wrong.
@karussell Hmmm. I think we should either know precisely what we mean when the objective function (the weighting) is different from the z-function (for which we compute the isoline), or we shouldn't offer it. Robin is right, those two functions can be arbitrarily different, and we (the isochrone service) have to be able to give a consistent answer. I think there is one, but this is not it. We probably have to track all leaves of the SPT and terminate only when all of them are
> limit, because, as you say, the queue is sorted by something else.I changed half of this anyway an hour ago. There was at least one more problem in there: It would return points that weren't even pulled out of the queue yet. (Also in
SPTResource.)I'll have a look..
boldtrn commentedon Apr 14, 2020
Thanks a lot for fixing this @michaz.
I tried to understand your fix and was wondering about the two queues. Having two queues is actually a really good idea. I first thought that always ordering by weight and simply enforcing that weighting matches the limit would be enough, but there are valid cases, where you actually want them to be different.