GraphHopper.com | Forum | GitHub | Maps | Blog

Correct way to enable landmark algorithm


#21

I am debugging why my fastest car with LM always visit much more nodes than your online version. Then I cam across the following example: Same request but one had 675 visited nodes, another had 13858 visited nodes.

First with 675 visits


Link: https://graphhopper.com/maps/?point=-37.81361%2C144.96306&point=-33.86882%2C151.2093&locale=en-US&vehicle=car&weighting=fastest&elevation=true&use_miles=false&layer=Omniscale

Second with 13858 visits


Link: https://graphhopper.com/maps/?point=-37.81361%2C144.96306&point=-33.86882%2C151.2093&locale=en-AU&vehicle=car&weighting=fastest&elevation=true&ch.disable=true&use_miles=false&layer=Omniscale

I reckon each request hit different server and you might not be able to reproduce this. Just wonder how could this happen?

FYI
Start: -37.81361,144.96306
End: -33.86882,151.2093

Edited: Looking at the request now, the only difference is the presence of “ch.disable=true”


#22

With CH you often visit less nodes compared to LM (ch.disable=true). If you disable landmarks too via lm.disable=true (not possible for our online service) you’ll see much more visited nodes (>X00 000)


#23

Ah, my bad. I was thinking too much about my use case (LM is enabled, CH is disabled). So I assumed that for both requests, LM was the default algorithm, hence the presence of “ch.disable=true” didn’t change anything. Thanks for the clarification Peter.


#24

I also stumbled now over the initial problem with “maximumWeight cannot be null”. The reason is that if you have two vehicle profiles and eg. one weighting then weightingsAsStrings.size is 1 and then 1*2=2 weightings will be created via GraphHopper.initLMAlgoFactoryDecorator. But LMAlgoFactoryDecorator.createPreparations cannot handle the second weighting as it had a different name than the first (e.g. fastest_car, fastest_truck).

This is ugly and a current possible workaround is:

class MyGraphHopper {
 @Override
 public void postProcessing() {
   for (Weighting w : getLMFactoryDecorator().getWeightings()) {
     if (!getLMFactoryDecorator().getWeightingsAsStrings().contains(w.toString()))
        getLMFactoryDecorator().addWeighting(w.toString());
   }
   super.postProcessing();
 }
}

Another solution should be to specify the weightings explicitly in the config with the maximumWeight but then fastest_truck is used for car which makes no sense. We have to improve this, likely related to: https://github.com/graphhopper/graphhopper/issues/493