use of com.graphhopper.routing.util.CarFlagEncoder in project graphhopper by graphhopper.
the class PathSimplificationTest method setUp.
@Before
public void setUp() {
carEncoder = new CarFlagEncoder();
carManager = new EncodingManager(carEncoder);
}
use of com.graphhopper.routing.util.CarFlagEncoder in project graphhopper by graphhopper.
the class LMAlgoFactoryDecoratorTest method addWeighting.
@Test
public void addWeighting() {
LMAlgoFactoryDecorator dec = new LMAlgoFactoryDecorator().setEnabled(true);
dec.addWeighting("fastest");
assertEquals(Arrays.asList("fastest"), dec.getWeightingsAsStrings());
// special parameters like the maximum weight
dec = new LMAlgoFactoryDecorator().setEnabled(true);
dec.addWeighting("fastest|maximum=65000");
dec.addWeighting("shortest|maximum=20000");
assertEquals(Arrays.asList("fastest", "shortest"), dec.getWeightingsAsStrings());
FlagEncoder car = new CarFlagEncoder();
EncodingManager em = new EncodingManager(car);
dec.addWeighting(new FastestWeighting(car)).addWeighting(new ShortestWeighting(car));
dec.createPreparations(new GraphHopperStorage(new RAMDirectory(), em, false, new GraphExtension.NoOpExtension()), null);
assertEquals(1, dec.getPreparations().get(0).getLandmarkStorage().getFactor(), .1);
assertEquals(0.3, dec.getPreparations().get(1).getLandmarkStorage().getFactor(), .1);
}
use of com.graphhopper.routing.util.CarFlagEncoder in project graphhopper by graphhopper.
the class LandmarkStorageTest method setUp.
@Before
public void setUp() {
encoder = new CarFlagEncoder();
ghStorage = new GraphHopperStorage(new RAMDirectory(), new EncodingManager(encoder), false, new GraphExtension.NoOpExtension());
ghStorage.create(1000);
}
use of com.graphhopper.routing.util.CarFlagEncoder in project graphhopper by graphhopper.
the class BlockAreaWeightingTest method setUp.
@Before
public void setUp() {
encoder = new CarFlagEncoder();
em = new EncodingManager(Arrays.asList(encoder), 8);
graph = new GraphBuilder(em).create();
// 0-1
graph.edge(0, 1, 1, true);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 0, 0.00, 0.00);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 1, 0.01, 0.01);
}
use of com.graphhopper.routing.util.CarFlagEncoder 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();
GraphEdgeIdFinder graphFinder = new GraphEdgeIdFinder(graph, locationIndex);
GraphEdgeIdFinder.BlockArea blockArea = graphFinder.parseBlockArea("0.01,0.005,1", new DefaultEdgeFilter(encoder), 1000 * 1000);
GHIntHashSet blockedEdges = new GHIntHashSet();
blockedEdges.add(0);
assertEquals(blockedEdges, blockArea.blockedEdges);
List<Shape> blockedShapes = new ArrayList<>();
assertEquals(blockedShapes, blockArea.blockedShapes);
// big area converts into shapes
graphFinder = new GraphEdgeIdFinder(graph, locationIndex);
blockArea = graphFinder.parseBlockArea("0,0,1000", new DefaultEdgeFilter(encoder), 1000 * 1000);
blockedEdges.clear();
assertEquals(blockedEdges, blockArea.blockedEdges);
blockedShapes.add(new Circle(0, 0, 1000));
assertEquals(blockedShapes, blockArea.blockedShapes);
}
Aggregations