Skip to content

If only edge based CH is prepared no error should be thrown #1637

Closed

Description

@karussell

When a route is done the 'edge_based' url parameter should not be required. Currently you get:

Caused by: java.lang.IllegalArgumentException: Cannot find CH RoutingAlgorithmFactory for weighting map {weighting=fastest, vehicle=car} in entries: [fastest|car|edge, faste .... The 'edge_based' url parameter is missing or does not fit the weightings. Its value was: 'false'
        at com.graphhopper.routing.ch.CHAlgoFactoryDecorator.getPreparation(CHAlgoFactoryDecorator.java:266)
        at com.graphhopper.routing.ch.CHAlgoFactoryDecorator.getDecoratedAlgorithmFactory(CHAlgoFactoryDecorator.java:246)
        at com.graphhopper.GraphHopper.getAlgorithmFactory(GraphHopper.java:760)

@easbar Yes, maybe we can:

  • always fall back to edge based if there really is only one edge-based CH and no node based CH (for any weighting)

  • add a config value that changes the default value of edge_based

Activity

  1. easbar commented on Jun 27, 2019

    @easbar
    Member

    GraphHopper already has a traversalMode field that is used as default for routing requests. I think this is also what it should be called: defaultTraversalMode, so this is what I will call it here. It can be set via setTraversalMode() and is automatically set by setEncodingManager() if the EncodingManager needs turn cost support.

    The default can be overwritten on a per-request basis by the edge_based parameter, but also by the traversal_mode parameter (traversal_mode is overwritten by edge_based):

    String tModeStr = hints.get("traversal_mode", traversalMode.toString());
    TraversalMode tMode = TraversalMode.fromString(tModeStr);
    if (hints.has(Routing.EDGE_BASED))
    tMode = hints.getBool(Routing.EDGE_BASED, false) ? TraversalMode.EDGE_BASED : TraversalMode.NODE_BASED;

    The traversal_mode parameter definitely seems redundant (at least after #1640). Can we remove it ? I did not find documentation for it either.

    To me it also seems a bit strange that the default traversalMode is edge-based as soon as encodingManager.needsTurnCostSupport() == true (so as soon as one encoder needs turn cost support).
    Would it not be much more obvious to check if the encoder that is selected by the vehicle parameter supports turn costs and if yes use edge-based routing (unless edge_based is given explicitly with the request) ? I mean here:

    FlagEncoder encoder = encodingManager.getEncoder(vehicle);

    For CH it is again different because the tMode variable in the first snippet above is ignored (it is not passed to the hints map here):

    RoutingAlgorithmFactory tmpAlgoFactory = getAlgorithmFactory(hints);

    Instead, at the moment the traversal mode for CH is solely chosen based on the edge_based request parameter (hence the error this issue was opened for). I think this is partly because if we want edge-based and node-based routing we cannot specify graph.flag_encoders=car,car|turn_costs=true, but instead we have to specify graph.flag_encoders=car|turn_costs=true and prepare.ch.edge_based: edge_and_node (because there can not be two flag encoders for car). So determining the traversal mode by FlagEncoder.supports(TurnWeighting.class) as we do for non-CH is not possible in this case.

    So regarding the previous suggestions:

    always fall back to edge based if there really is only one edge-based CH and no node based CH (for any weighting)

    this should work

    add a config value that changes the default value of edge_based

    considering the complexity that is already there (for such a 'simple' thing as choosing one of two traversal modes) I am a bit hesitant to add another way to do this. Or maybe we use this config value only for CH (routing.ch.edge_based_by_default=false) ?

  2. easbar commented on Jun 27, 2019

    @easbar
    Member

    Maybe the situation would be improved with #1023, #493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions