Hi,
In my application, I use custom FlagEncoder and Weighting. In particular, my encoding manager has three encoders: DataFlagEncoder, CustomFlagEncoder, and CarFlagEncoder. For actual route calculation, I use CustomWeighting & FastestWeighting. CustomWeighting is a wrapper of BlockAreaWeighting, GenericWeighting & FastestWeighting to define per-request constraints like height, blocked areas and something else.
Currently, I am having issues in enabling LM when importing graph. I tried the following and they didnât work.
-
Add properties:
setProperty(âprepare.lm.weightingsâ, âfastestâ);
setProperty(âch.disableâ, âtrueâ);
Nothing happened. Graph was still created with CH. -
Programmatically enable LM & weighting string
hopper.setCHEnabled(false);
hopper.getLMFactoryDecorator().setEnabled(true);
hopper.getLMFactoryDecorator().setWeightingsAsStrings(Arrays.asList(âgenericâ, âcustomâ, âfastestâ));
GH tried to create weighting for every combination of weighting string in the provided list & encoder in the encodingManager as in initLMAlgoFactoryDecorator(). And I got null weighting as it resorted to default createWeighting() in GraphHopper.java for some combination. I know I can change my createWeighting() method in my subclass of GraphHopper.java but it should be the same approach as #3 below.
- Invoke createWeighting() for the combinations of weighting, encoder I need and add weighting to hopper.getLMFactoryDecorator().getWeightings() before importing graph.
GH ran successfully to generate initial graph and failed at postProcessing() (stacktrace below)
java.lang.IllegalStateException: maximumWeight cannot be null. Default should be just negative. Couldn't find generic in {}
at com.graphhopper.routing.lm.LMAlgoFactoryDecorator.createPreparations(LMAlgoFactoryDecorator.java:333)
at com.graphhopper.GraphHopper.postProcessing(GraphHopper.java:850)
at com.graphhopper.GraphHopper.process(GraphHopper.java:650)
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:619)
at au.net.transtech.geo.GeoEngine.importGraph(GeoEngine.java:149)
at au.net.transtech.geo.GeoEngineTest.setUp(GeoEngineTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Can you please advise the correct way to enable LM?