diff --git a/core/src/main/java/com/graphhopper/routing/weighting/custom/FindMinMax.java b/core/src/main/java/com/graphhopper/routing/weighting/custom/FindMinMax.java index 97b2156d577..9aa5a1c8eed 100644 --- a/core/src/main/java/com/graphhopper/routing/weighting/custom/FindMinMax.java +++ b/core/src/main/java/com/graphhopper/routing/weighting/custom/FindMinMax.java @@ -23,11 +23,12 @@ public class FindMinMax { public static void checkLMConstraints(CustomModel baseModel, CustomModel queryModel, EncodedValueLookup lookup) { if (queryModel.isInternal()) throw new IllegalArgumentException("CustomModel of query cannot be internal"); - double qmDI = queryModel.getDistanceInfluence() == null ? 0 : queryModel.getDistanceInfluence(); - double bmDI = baseModel.getDistanceInfluence() == null ? 0 : baseModel.getDistanceInfluence(); - if (qmDI < bmDI) - throw new IllegalArgumentException("CustomModel in query can only use " + - "distance_influence bigger or equal to " + bmDI + ", but was: " + qmDI); + if (queryModel.getDistanceInfluence() != null) { + double bmDI = baseModel.getDistanceInfluence() == null ? 0 : baseModel.getDistanceInfluence(); + if (queryModel.getDistanceInfluence() < bmDI) + throw new IllegalArgumentException("CustomModel in query can only use distance_influence bigger or equal to " + + bmDI + ", but was: " + queryModel.getDistanceInfluence()); + } checkMultiplyValue(queryModel.getPriority(), lookup); checkMultiplyValue(queryModel.getSpeed(), lookup); diff --git a/web/src/test/java/com/graphhopper/application/resources/RouteResourceCustomModelLMTest.java b/web/src/test/java/com/graphhopper/application/resources/RouteResourceCustomModelLMTest.java index 988018f6096..32421e7cb42 100644 --- a/web/src/test/java/com/graphhopper/application/resources/RouteResourceCustomModelLMTest.java +++ b/web/src/test/java/com/graphhopper/application/resources/RouteResourceCustomModelLMTest.java @@ -59,8 +59,7 @@ private static GraphHopperServerConfiguration createConfig() { putObject("import.osm.ignored_highways", ""). putObject("graph.encoded_values", "surface"). setProfiles(Arrays.asList( - // give strange profile names to ensure that we do not mix vehicle and profile: - new CustomProfile("car_custom").setCustomModel(new CustomModel()).setVehicle("car"), + new CustomProfile("car_custom").setCustomModel(new CustomModel().setDistanceInfluence(15d)).setVehicle("car"), new Profile("foot_profile").setVehicle("foot").setWeighting("fastest"), new CustomProfile("foot_custom").setCustomModel(new CustomModel()).setVehicle("foot"))). setLMProfiles(Arrays.asList(new LMProfile("car_custom"), new LMProfile("foot_custom")));