Skip to content

Commit 96f8798

Browse files
committed
for now avoid exception if unknown FlagEncoder name
1 parent b600ddb commit 96f8798

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

core/src/main/java/com/graphhopper/routing/util/parsers/OSMTurnRelationParser.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
import com.graphhopper.util.EdgeExplorer;
2727
import com.graphhopper.util.EdgeIterator;
2828

29-
import java.util.*;
29+
import java.util.Arrays;
30+
import java.util.Collection;
31+
import java.util.Collections;
32+
import java.util.List;
3033

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

@@ -63,8 +66,8 @@ else if (name.contains("truck"))
6366
else if (name.contains("bike") || name.contains("bicycle"))
6467
this.restrictions = Arrays.asList("bicycle", "vehicle", "access");
6568
else
66-
throw new IllegalArgumentException("restrictions collection must be specified for parser " + name
67-
+ ", e.g. [\"motorcar\", \"motor_vehicle\", \"vehicle\", \"access\"]");
69+
// assume default is some motor_vehicle, exception is too strict
70+
this.restrictions = Arrays.asList("motor_vehicle", "vehicle", "access");
6871
} else {
6972
this.restrictions = restrictions;
7073
}
@@ -107,7 +110,7 @@ EdgeExplorer getOutExplorer(Graph graph) {
107110
* @return a collection of turn cost entries which can be used for testing
108111
*/
109112
void addRelationToTCStorage(OSMTurnRelation osmTurnRelation, IntsRef turnCostFlags,
110-
ExternalInternalMap map, Graph graph) {
113+
ExternalInternalMap map, Graph graph) {
111114
TurnCostStorage tcs = graph.getTurnCostStorage();
112115
int viaNode = map.getInternalNodeIdOfOsmNode(osmTurnRelation.getViaOsmNodeId());
113116
EdgeExplorer edgeOutExplorer = getOutExplorer(graph), edgeInExplorer = getInExplorer(graph);

core/src/test/java/com/graphhopper/routing/util/parsers/OSMTurnRelationParserTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ public long getOsmIdOfInternalEdge(int edgeId) {
6666
parser.addRelationToTCStorage(instance, tcFlags, map, ghStorage);
6767
assertTrue(Double.isInfinite(tcs.get(tce, tcFlags, 4, 3, 3)));
6868
}
69+
70+
@Test
71+
public void unknownShouldBehaveLikeMotorVehicle() {
72+
OSMTurnRelationParser parser = new OSMTurnRelationParser("fatcarsomething", 1);
73+
OSMTurnRelation turnRelation = new OSMTurnRelation(4, 3, 3, OSMTurnRelation.Type.NOT);
74+
turnRelation.setVehicleTypeRestricted("space");
75+
parser.handleTurnRelationTags(TurnCost.createFlags(), turnRelation, null, null);
76+
}
6977
}

0 commit comments

Comments
 (0)