Skip to content

Commit

Permalink
for now avoid exception if unknown FlagEncoder name
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Nov 28, 2019
1 parent b600ddb commit 96f8798
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import com.graphhopper.util.EdgeExplorer;
import com.graphhopper.util.EdgeIterator;

import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import static com.graphhopper.routing.util.EncodingManager.getKey;

Expand Down Expand Up @@ -63,8 +66,8 @@ else if (name.contains("truck"))
else if (name.contains("bike") || name.contains("bicycle"))
this.restrictions = Arrays.asList("bicycle", "vehicle", "access");
else
throw new IllegalArgumentException("restrictions collection must be specified for parser " + name
+ ", e.g. [\"motorcar\", \"motor_vehicle\", \"vehicle\", \"access\"]");
// assume default is some motor_vehicle, exception is too strict
this.restrictions = Arrays.asList("motor_vehicle", "vehicle", "access");
} else {
this.restrictions = restrictions;
}
Expand Down Expand Up @@ -107,7 +110,7 @@ EdgeExplorer getOutExplorer(Graph graph) {
* @return a collection of turn cost entries which can be used for testing
*/
void addRelationToTCStorage(OSMTurnRelation osmTurnRelation, IntsRef turnCostFlags,
ExternalInternalMap map, Graph graph) {
ExternalInternalMap map, Graph graph) {
TurnCostStorage tcs = graph.getTurnCostStorage();
int viaNode = map.getInternalNodeIdOfOsmNode(osmTurnRelation.getViaOsmNodeId());
EdgeExplorer edgeOutExplorer = getOutExplorer(graph), edgeInExplorer = getInExplorer(graph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,12 @@ public long getOsmIdOfInternalEdge(int edgeId) {
parser.addRelationToTCStorage(instance, tcFlags, map, ghStorage);
assertTrue(Double.isInfinite(tcs.get(tce, tcFlags, 4, 3, 3)));
}

@Test
public void unknownShouldBehaveLikeMotorVehicle() {
OSMTurnRelationParser parser = new OSMTurnRelationParser("fatcarsomething", 1);
OSMTurnRelation turnRelation = new OSMTurnRelation(4, 3, 3, OSMTurnRelation.Type.NOT);
turnRelation.setVehicleTypeRestricted("space");
parser.handleTurnRelationTags(TurnCost.createFlags(), turnRelation, null, null);
}
}

0 comments on commit 96f8798

Please sign in to comment.