use of com.graphhopper.util.ConfigMap in project graphhopper by graphhopper.
the class GraphEdgeIdFinderTest method testParseStringHints.
@Test
public void testParseStringHints() {
FlagEncoder encoder = new CarFlagEncoder();
EncodingManager em = new EncodingManager(encoder);
GraphHopperStorage graph = new GraphBuilder(em).create();
// 0-1-2
// | |
// 3-4
graph.edge(0, 1, 1, true);
graph.edge(1, 2, 1, true);
graph.edge(3, 4, 1, true);
graph.edge(0, 3, 1, true);
graph.edge(1, 4, 1, true);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 0, 0.01, 0.00);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 1, 0.01, 0.01);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 2, 0.01, 0.02);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 3, 0.00, 0.00);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 4, 0.00, 0.01);
LocationIndex locationIndex = new LocationIndexTree(graph, new RAMDirectory()).prepareIndex();
HintsMap hints = new HintsMap();
hints.put(Parameters.Routing.BLOCK_AREA, "0.01,0.005,1");
ConfigMap cMap = new ConfigMap();
GraphEdgeIdFinder graphFinder = new GraphEdgeIdFinder(graph, locationIndex);
ConfigMap result = graphFinder.parseStringHints(cMap, hints, new DefaultEdgeFilter(encoder));
GHIntHashSet blockedEdges = new GHIntHashSet();
blockedEdges.add(0);
assertEquals(blockedEdges, result.get(BLOCKED_EDGES, new GHIntHashSet()));
List<Shape> blockedShapes = new ArrayList<>();
assertEquals(blockedShapes, result.get(BLOCKED_SHAPES, new ArrayList<>()));
// big area converts into shapes
hints.put(Parameters.Routing.BLOCK_AREA, "0,0,1000");
result = graphFinder.parseStringHints(cMap, hints, new DefaultEdgeFilter(encoder));
blockedEdges.clear();
assertEquals(blockedEdges, result.get(BLOCKED_EDGES, new GHIntHashSet()));
blockedShapes.add(new Circle(0, 0, 1000));
assertEquals(blockedShapes, result.get(BLOCKED_SHAPES, new ArrayList<>()));
}
Aggregations