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
Request fails when not setting the weighting and/or the vehicle with CH and finite u-turn costs #1788
If we specify something like prepare.ch.weightings=fastest|u_turn_costs=40 in the configuration and then do not specify a weighting in GHRequest, GH tries to determine the weighting by looking at the CHProfile(s). This leads to:
java.lang.IllegalArgumentException: Cannot find CH profile for weighting map {edge_based=true, weighting=fastest|u_turn_costs=40, vehicle=car} in entries: [fastest|car|edge_based=true|u_turn_costs=40.
changed the title [-]Request fails when not setting the weighting with CH and finite u-turn costs[/-][+]Request fails when not setting the weighting and/or the vehicle with CH and finite u-turn costs[/+]on Nov 12, 2019
This is very ugly. We already have this complex logic to determine the CHProfile when edge_based=true/false or u_turn_costs is not given on the request. Handling the case(s) where also the vehicle and/or the weighting is missing makes this even worse.
This is bad: If the weighting has not been specified on the request (HintsMap) we just take the one of the first of the CH profiles. In case we use multiple weightings we basically pick one at random which makes no sense. When u_turn_costs=40 is included it leads to the error, because we kind of compare a 'CH profile definition' (prepare.ch.weightings=fastest|u_turn_costs=40) with a 'weighting name' (fastest). For the vehicle we do not even set anything, so it remains an empty string when its not given in the request. (Update: no the vehicle is set to "car" by default if missing sigh)
I think the easiest solution (for us of course) would be to just throw an error if CH is requested but the vehicle and weighting is not given, so we force the client to pass this information with the request.
The next best thing we can do is check whether or not the CHProfiles use multiple weightings/vehicles. If not we use the single one there is, if yes we throw an error.
In the mid/long run I think every CHProfile should just have a name/id and to use it this name/id has to be passed along with the request, #1708.
(Update: no the vehicle is set to "car" by default if missing sigh)
I think it uses the first flag encoder if missing. I.e. if no car is given it should still work.
In case we use multiple weightings we basically pick one at random which makes no sense
Oh, really random?
I think the easiest solution (for us of course) would be to just throw an error if CH is requested but the vehicle and weighting is not given, so we force the client to pass this information with the request
Hmmh, yeah. This would break backward compatibility as currently the minimal request needs just two points. Couldn't it pick the first CHProfile as default settings for vehicle+weighting and the order is defined as
IMO it makes sense to not specify these parameters, because if you just have one vehicle and one weighting defined you would not expect to be forced to specify them in the request.
thrownewIllegalStateException("No encoding manager specified or loaded");
returnencodingManager.fetchEdgeEncoders().get(0);
}
Oh, really random?
Well not 'random' but it depends on the order the profile string are in this list (so in a sense its random, I mean its deterministic, but there is no 'real' reason to choose one over the other)
Activity
[-]Request fails when not setting the weighting with CH and finite u-turn costs[/-][+]Request fails when not setting the weighting and/or the vehicle with CH and finite u-turn costs[/+]easbar commentedon Nov 12, 2019
This is very ugly. We already have this complex logic to determine the
CHProfilewhenedge_based=true/falseoru_turn_costsis not given on the request. Handling the case(s) where also the vehicle and/or the weighting is missing makes this even worse.The problematic code is here:
graphhopper/core/src/main/java/com/graphhopper/routing/ch/CHAlgoFactoryDecorator.java
Lines 249 to 250 in c0e129c
This is bad: If the weighting has not been specified on the request (
HintsMap) we just take the one of the first of the CH profiles. In case we use multiple weightings we basically pick one at random which makes no sense. Whenu_turn_costs=40is included it leads to the error, because we kind of compare a 'CH profile definition' (prepare.ch.weightings=fastest|u_turn_costs=40) with a 'weighting name' (fastest). For the vehicle we do not even set anything, so it remains an empty string when its not given in the request. (Update: no the vehicle is set to "car" by default if missing sigh)I think the easiest solution (for us of course) would be to just throw an error if CH is requested but the vehicle and weighting is not given, so we force the client to pass this information with the request.
The next best thing we can do is check whether or not the
CHProfilesuse multiple weightings/vehicles. If not we use the single one there is, if yes we throw an error.In the mid/long run I think every
CHProfileshould just have a name/id and to use it this name/id has to be passed along with the request, #1708.karussell commentedon Nov 12, 2019
I think it uses the first flag encoder if missing. I.e. if no car is given it should still work.
Oh, really random?
Hmmh, yeah. This would break backward compatibility as currently the minimal request needs just two points. Couldn't it pick the first CHProfile as default settings for vehicle+weighting and the order is defined as
IMO it makes sense to not specify these parameters, because if you just have one vehicle and one weighting defined you would not expect to be forced to specify them in the request.
easbar commentedon Nov 12, 2019
Yes if vehicle is missing on the request its set to the first encoder here (somewhat random):
graphhopper/core/src/main/java/com/graphhopper/GraphHopper.java
Lines 986 to 990 in c0e129c
graphhopper/core/src/main/java/com/graphhopper/GraphHopper.java
Lines 153 to 158 in c0e129c
Well not 'random' but it depends on the order the profile string are in this list (so in a sense its random, I mean its deterministic, but there is no 'real' reason to choose one over the other)
graphhopper/core/src/main/java/com/graphhopper/routing/ch/CHAlgoFactoryDecorator.java
Lines 232 to 234 in c0e129c
Yeah I am working on this. Its doable, and with some cleanup its maybe not that bad...