use of com.graphhopper.routing.ch.CHAlgoFactoryDecorator in project graphhopper by graphhopper.
the class GraphHopperOSMTest method testGetWeightingForCH.
@Test
public void testGetWeightingForCH() {
TestEncoder truck = new TestEncoder("truck");
TestEncoder simpleTruck = new TestEncoder("simple_truck");
// use simple truck first
EncodingManager em = new EncodingManager(simpleTruck, truck);
CHAlgoFactoryDecorator decorator = new CHAlgoFactoryDecorator();
Weighting fwSimpleTruck = new FastestWeighting(simpleTruck);
Weighting fwTruck = new FastestWeighting(truck);
RAMDirectory ramDir = new RAMDirectory();
GraphHopperStorage storage = new GraphHopperStorage(Arrays.asList(fwSimpleTruck, fwTruck), ramDir, em, false, new GraphExtension.NoOpExtension());
decorator.addWeighting(fwSimpleTruck);
decorator.addWeighting(fwTruck);
decorator.addPreparation(new PrepareContractionHierarchies(ramDir, storage, storage.getGraph(CHGraph.class, fwSimpleTruck), fwSimpleTruck, TraversalMode.NODE_BASED));
decorator.addPreparation(new PrepareContractionHierarchies(ramDir, storage, storage.getGraph(CHGraph.class, fwTruck), fwTruck, TraversalMode.NODE_BASED));
HintsMap wMap = new HintsMap("fastest");
wMap.put("vehicle", "truck");
assertEquals("fastest|truck", ((PrepareContractionHierarchies) decorator.getDecoratedAlgorithmFactory(null, wMap)).getWeighting().toString());
wMap.put("vehicle", "simple_truck");
assertEquals("fastest|simple_truck", ((PrepareContractionHierarchies) decorator.getDecoratedAlgorithmFactory(null, wMap)).getWeighting().toString());
// make sure weighting cannot be mixed
decorator.addWeighting(fwTruck);
decorator.addWeighting(fwSimpleTruck);
try {
decorator.addPreparation(new PrepareContractionHierarchies(ramDir, storage, storage.getGraph(CHGraph.class, fwSimpleTruck), fwSimpleTruck, TraversalMode.NODE_BASED));
assertTrue(false);
} catch (Exception ex) {
}
}
Aggregations