Search in sources :

Example 6 with CarFlagEncoder

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);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Before(org.junit.Before)

Example 7 with CarFlagEncoder

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);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) ShortestWeighting(com.graphhopper.routing.weighting.ShortestWeighting) RAMDirectory(com.graphhopper.storage.RAMDirectory) GraphHopperStorage(com.graphhopper.storage.GraphHopperStorage) Test(org.junit.Test)

Example 8 with CarFlagEncoder

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);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Before(org.junit.Before)

Example 9 with CarFlagEncoder

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);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) GraphBuilder(com.graphhopper.storage.GraphBuilder) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Before(org.junit.Before)

Example 10 with CarFlagEncoder

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);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) Circle(com.graphhopper.util.shapes.Circle) GHIntHashSet(com.graphhopper.coll.GHIntHashSet) Shape(com.graphhopper.util.shapes.Shape) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) ArrayList(java.util.ArrayList) LocationIndex(com.graphhopper.storage.index.LocationIndex) DefaultEdgeFilter(com.graphhopper.routing.util.DefaultEdgeFilter) LocationIndexTree(com.graphhopper.storage.index.LocationIndexTree) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Test(org.junit.Test)

Aggregations

CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)14 EncodingManager (com.graphhopper.routing.util.EncodingManager)14 Test (org.junit.Test)9 BikeFlagEncoder (com.graphhopper.routing.util.BikeFlagEncoder)4 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)4 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)4 Before (org.junit.Before)4 ShortestWeighting (com.graphhopper.routing.weighting.ShortestWeighting)3 GraphBuilder (com.graphhopper.storage.GraphBuilder)3 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)3 DefaultEdgeFilter (com.graphhopper.routing.util.DefaultEdgeFilter)2 Weighting (com.graphhopper.routing.weighting.Weighting)2 File (java.io.File)2 GraphHopper (com.graphhopper.GraphHopper)1 GHIntHashSet (com.graphhopper.coll.GHIntHashSet)1 ReaderWay (com.graphhopper.reader.ReaderWay)1 EdgeBasedRoutingAlgorithmTest (com.graphhopper.routing.EdgeBasedRoutingAlgorithmTest)1 EdgeFilter (com.graphhopper.routing.util.EdgeFilter)1 CHGraph (com.graphhopper.storage.CHGraph)1 RAMDirectory (com.graphhopper.storage.RAMDirectory)1