Custom weighting for Landmark algorithm

Can I use custom weighting along with the landmark algorithm?

Yes. Why not just try it :smiley: ?

I did not get any documentation on how to actually use it with apart from this
Which says to enable prepare.lm.weightings=fastest
I was confused if this is the fastest weighting which we use for normal Car Fastest routes. And hence the question.

Edit: Where do I use it. In the GHRequest or the hopper object?

Yes, if you have a custom weighting you can use it in the configuration or (also directly in Java).

See the very recently merged docs enhancements from @boldtrn

Edit: Where do I use it. In the GHRequest or the hopper object?

Overwrite the standard GraphHopper object as described in the linked docs, then you can use it in the config or hopper object. And additionally you can change the weighting per request in the GHRequest object too.

Thanks a ton for the clarification :slight_smile:

@karussell @boldtrn I managed to enable LM mode via config. I just couldn’t​ do it via Java API. How can it be done in Java? Through the request hints?

What do you mean? Enable it on a per-request base? If you don’t use CH, it is used per default, if not add ch.disable=true to the request hints.

If you are talking about enabling it initially, you can add it the the params, similar to how you add it to the properties file.


Do you mean the following line would automatically enable LM mode?


No, I was talking about the hints in the Request on a per request base.

The init happens in GraphHopper#init(), you should be able to find the usage of the properties there. Setting them should be straight forwards. You have to init LM before using it.

Done. The custom weighting doesn’t really come into effect when using LM. Maybe I should increase the number of Landmarks? If yes, how would I do that via Java API?

Tried setting parameters.landmark.active_count to 32. But got an illegal argument exception.

Edit: got it… lemme see if increasing the Landmark would help

Please see also this recent discussion: