Repository navigation
destination support for car that doesn't modify the speed - #1752
Conversation
| public class CarFlagEncoder extends AbstractFlagEncoder { | ||
| protected final Map<String, Integer> trackTypeSpeedMap = new HashMap<>(); | ||
| protected final Set<String> badSurfaceSpeedMap = new HashSet<>(); | ||
| protected final Set<String> avoidAccessAtAllCosts = new HashSet<>(); |
There was a problem hiding this comment.
Why is this called avoidAccessAtAllCosts ? If we avoid access to roads with destination tag at all costs why do we not just add them to restrictedValues ? Well of course thats not what we want, because a start/target point can be located at a road with destination tag ?
There was a problem hiding this comment.
It is meant as "avoid access" but if necessary like for start and end locations the access should be allowed.
I would not want to use restrictedValues as e.g. there is no, restricted or private as value that should be excluded.
because a start/target point can be located at a road with destination tag ?
Yes
There was a problem hiding this comment.
ok but I still do not understand why it is called avoidAccessAtAllCosts because we do not want to 'avoid access at all costs'. We want to 'apply penalty so normally we do not pass these roads unless its required to arrive at the destination (or start)'.
There was a problem hiding this comment.
Sorry, I do not understand the difference why avoiding a road isn't the same as adding a penalty to it. If a road is only accessible for people living there then I want to avoid the access of that road under all circumstances for the general path finding.
There was a problem hiding this comment.
Hm for me 'avoiding something at all costs' sounds like I will not do it under any circumstances and 'applying a penalty' is more like I rather do not do it unless its really needed and I accept some penalty for doing it :)
If a road is only accessible for people living there then I want to avoid the access of that road under all circumstances for the general path finding.
Yes and no :) I want to avoid that road under all circumstances when I am only passing through, but I still use it if I need to use it to arrive at the destination. And even for passing through I do not avoid it under all circumstances, because the penalty is not infinite, i.e. if the required detour is too large I still use it.
But maybe this is just me..
| } | ||
|
|
||
| @Override | ||
| public boolean supports(Class<?> feature) { |
There was a problem hiding this comment.
This means we are using PriorityWeighting instead of FastestWeighting in GraphHopper#createWeighting, right ? But does that not change all the weights that are calculated, because PriorityWeighting uses weight/(0.5+priority) to calculate the weight and priority is not 0.5 by default, not even for PriorityCode.UNCHANGED ? Also this changes the min weight to minWeight/7.5 which means the weight estimation is a lot worse for A* (just to handle the rare case of destination tags).
Currently the javadocs for PriorityWeighting say its specifically for motor bikes ? Thats not the case anymore ?
There was a problem hiding this comment.
But does that not change all the weights that are calculated
What do you mean here? The weight should not be used or stored somewhere.
Also this changes the min weight to minWeight/7.5 which means the weight estimation is a lot worse
Hmmh, yes. Do you think changing it to e.g. weight*14/(7+priority) would help?
Currently the javadocs for PriorityWeighting say its specifically for motor bikes ? Thats not the case anymore ?
Ah, yes. This needs a change.
There was a problem hiding this comment.
What do you mean here? The weight should not be used or stored somewhere.
Yes, I guess you are right the weight has no 'real' meaning, but then again I think we use it for many tests to check for correctness (but really we do not, because we hardly use PriorityWeighting in tests, but I do not think this is a good thing). For the present feature all we want is penalizing roads with access=destination tags such that they are only used when the start/destination lies in such an area, but we do not pass these areas. I don't think this justifies changing all weights. I think there should be a 'neutral' priority for all the roads we do not want to change the weight of. PriorityCode.UNCHANGED sounds like its neutral but its not. Or actually I wonder why this is even about priorities and we are not simply using a penalty factor (see below).
Do you think changing it to e.g. weight*14/(7+priority)
Ok lets say our weight estimation without priority is minWeight and with priority a route weight can increase by a factor of x, then we do not have to adjust the weight estimation at all. I think thats what you mean here (because for the 'fastest' priority=7 your formula leaves the (min)weight unchanged) ? To be honest I do not know why we should use the formula from PriorityWeighting here at all. All we want is to increase the weight of access=destination roads. So why are we not just talking about this factor ? As long as it is >=1 we do not need to adjust the weight estimation and depending on its size we get an idea how much of a detour we want to tolerate to enforce not driving through access=destination roads.
There was a problem hiding this comment.
Another problem I see with PriorityWeighting is that it extends FastestWeighting, but do we not want to account for access=destination when we use the ShortFastestWeighting for example ?
There was a problem hiding this comment.
Let's assume we have a configurable Weighting like proposed in #193 then we could easily introduce this "destination factor" and also account for "shortest"-related weightings.
I wanted to introduce this fix before the mechanism for such a configurable Weighting is established because the situation is a bit ugly right now due to the changed speed for those values (still without it it would be worse IMO) and the configurable Weighting might still take a bit more time.
But we can also wait with this if you think this would be cleaner and obviously it would avoid changing the weight definition twice.
To be honest I do not know why we should use the formula from PriorityWeighting here at all ... So why are we not just talking about this factor ?
This would require yet another Weighting before introducing "configurable Weighting". Another option would be to introduce a roadAccessFactor in FastestWeighting if the RoadAccess EncodedValue is stored (but this would be also a bit unclean IMO).
There was a problem hiding this comment.
Ok, sure if this is only like a first step towards the final solution with configurable Weighting this is probably fine.
This would require yet another Weighting before introducing "configurable Weighting".
I would find all this easier to understand if there was something like DestinationSupportingFastestWeighting that just applies a penalty factor in case of access=destination instead of using PriorityWeighting with the weight/(0.5+priority) formula that does not make so much sense to me for this use case.
Another option would be to introduce a roadAccessFactor in FastestWeighting if the RoadAccess EncodedValue is stored (but this would be also a bit unclean IMO).
Why would this be unclean, is this not exactly what we want ? We want fastest weighting to support the access=destination tag (thats why you made GraphHopper#createWeighting return PriorityWeighting in case of "fastest"). Previously it did this by adjusting the speed and now it should do this by applying the penalty factor.
There was a problem hiding this comment.
Ok, sure if this is only like a first step towards the final solution with configurable Weighting this is probably fine.
Hmmh, it is not really a first step. More a last step of the old procedure :) before we introduce the new thing.
Why would this be unclean, is this not exactly what we want ?
Yes, if it goes into a separate Weighting class it wouldn't be unclean.
Will now think about this feature more and if we really should do this hassle before changing it again with the configurable Weighting.
karussell
left a comment
There was a problem hiding this comment.
Thanks for the review!
| public class CarFlagEncoder extends AbstractFlagEncoder { | ||
| protected final Map<String, Integer> trackTypeSpeedMap = new HashMap<>(); | ||
| protected final Set<String> badSurfaceSpeedMap = new HashSet<>(); | ||
| protected final Set<String> avoidAccessAtAllCosts = new HashSet<>(); |
There was a problem hiding this comment.
It is meant as "avoid access" but if necessary like for start and end locations the access should be allowed.
I would not want to use restrictedValues as e.g. there is no, restricted or private as value that should be excluded.
because a start/target point can be located at a road with destination tag ?
Yes
| } | ||
|
|
||
| @Override | ||
| public boolean supports(Class<?> feature) { |
There was a problem hiding this comment.
But does that not change all the weights that are calculated
What do you mean here? The weight should not be used or stored somewhere.
Also this changes the min weight to minWeight/7.5 which means the weight estimation is a lot worse
Hmmh, yes. Do you think changing it to e.g. weight*14/(7+priority) would help?
Currently the javadocs for PriorityWeighting say its specifically for motor bikes ? Thats not the case anymore ?
Ah, yes. This needs a change.
c3b56d0 to
5d2d469
Compare
|
Ok, moved it to FastestWeighting and so also ShortFastestWeighting can handle it. Also the factor is configurable and we do not use more bits as we reuse the road_access EncodedValue like it would be the case in the future for a configurable Weighting. I think this makes more sense :) ? There is also an integration test showing that it works: GraphHopperIT.testNorthBayreuthDestination |
| maxSpeed = encoder.getMaxSpeed() / SPEED_CONV; | ||
|
|
||
| if (encoder.hasEncodedValue(RoadAccess.KEY)) { | ||
| // ensure that we do not need to change getMinWeight, i.e. road_access_delay is actual a penalty |
There was a problem hiding this comment.
road_access_delay ? You probably mean roadAccessPenalty in the comment. And the import thing is its >=1 (which you enforce already).
There was a problem hiding this comment.
Maybe add a comment on the roadAccessPenalty about what it is supposed to do.
There was a problem hiding this comment.
road_access_delay
ups, this was the name before ;) .. will correct it
Maybe add a comment on the roadAccessPenalty about what it is supposed to do
Will do
|
IMO moving such a thing, like not allowing access because it is a destination, to weighting, is not a good approach. For example it is not considered in |
fixes #733
Basically it moves the priorityEncoder to the CarFlagEncoder and fills it with bad priority if e.g.
vehicleormotor_vehicletag isdestination