Skip to content

Commit

Permalink
move custom_model.internal check a bit higher
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Sep 5, 2024
1 parent f19175c commit 3610786
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 7 additions & 1 deletion core/src/main/java/com/graphhopper/routing/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@

import java.util.*;

import static com.graphhopper.util.TurnCostsConfig.INFINITE_U_TURN_COSTS;
import static com.graphhopper.util.DistanceCalcEarth.DIST_EARTH;
import static com.graphhopper.util.Parameters.Algorithms.ALT_ROUTE;
import static com.graphhopper.util.Parameters.Algorithms.ROUND_TRIP;
import static com.graphhopper.util.Parameters.Routing.*;
import static com.graphhopper.util.TurnCostsConfig.INFINITE_U_TURN_COSTS;

public class Router {
protected final BaseGraph graph;
Expand Down Expand Up @@ -103,6 +103,7 @@ public GHResponse route(GHRequest request) {
checkPointHints(request);
checkCurbsides(request);
checkNoBlockArea(request);
checkCustomModel(request);

Solver solver = createSolver(request);
solver.checkRequest();
Expand Down Expand Up @@ -180,6 +181,11 @@ private void checkNoBlockArea(GHRequest request) {
throw new IllegalArgumentException("The `block_area` parameter is no longer supported. Use a custom model with `areas` instead.");
}

private void checkCustomModel(GHRequest request) {
if (request.getCustomModel() != null && request.getCustomModel().isInternal())
throw new IllegalArgumentException("CustomModel of query cannot be internal");
}

protected Solver createSolver(GHRequest request) {
final boolean disableCH = getDisableCH(request.getHints());
final boolean disableLM = getDisableLM(request.getHints());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class FindMinMax {
* is based on baseModel).
*/
public static void checkLMConstraints(CustomModel baseModel, CustomModel queryModel, EncodedValueLookup lookup) {
if (queryModel.isInternal())
throw new IllegalArgumentException("CustomModel of query cannot be internal");
if (queryModel.getDistanceInfluence() != null) {
double bmDI = baseModel.getDistanceInfluence() == null ? 0 : baseModel.getDistanceInfluence();
if (queryModel.getDistanceInfluence() < bmDI)
Expand Down

0 comments on commit 3610786

Please sign in to comment.