Search in sources :

Example 1 with DataFlagEncoder

use of com.graphhopper.routing.util.DataFlagEncoder in project graphhopper by graphhopper.

the class AbstractEdgeElevationInterpolatorTest method setUp.

@SuppressWarnings("resource")
@Before
public void setUp() {
    dataFlagEncoder = new DataFlagEncoder();
    graph = new GraphHopperStorage(new RAMDirectory(), new EncodingManager(Arrays.asList(dataFlagEncoder, new FootFlagEncoder()), 8), true, new GraphExtension.NoOpExtension()).create(100);
    edgeElevationInterpolator = createEdgeElevationInterpolator();
    interpolatableWay = createInterpolatableWay();
    normalWay = new ReaderWay(0);
    normalWay.setTag("highway", "primary");
}
Also used : DataFlagEncoder(com.graphhopper.routing.util.DataFlagEncoder) EncodingManager(com.graphhopper.routing.util.EncodingManager) ReaderWay(com.graphhopper.reader.ReaderWay) FootFlagEncoder(com.graphhopper.routing.util.FootFlagEncoder) RAMDirectory(com.graphhopper.storage.RAMDirectory) GraphHopperStorage(com.graphhopper.storage.GraphHopperStorage) GraphExtension(com.graphhopper.storage.GraphExtension) Before(org.junit.Before)

Example 2 with DataFlagEncoder

use of com.graphhopper.routing.util.DataFlagEncoder in project graphhopper by graphhopper.

the class GraphHopperStorageForDataFlagEncoderTest method testStorageProperties.

@Test
public void testStorageProperties() {
    graph = new GraphBuilder(encodingManager).setStore(true).setLocation(defaultGraphLoc).create();
    // 0-1
    ReaderWay way_0_1 = new ReaderWay(27l);
    way_0_1.setTag("highway", "primary");
    way_0_1.setTag("maxheight", "4.4");
    graph.edge(0, 1, 1, true);
    AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 0, 0.00, 0.00);
    AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 1, 0.01, 0.01);
    graph.getEdgeIteratorState(0, 1).setFlags(encoder.handleWayTags(way_0_1, 1, 0));
    // 1-2
    ReaderWay way_1_2 = new ReaderWay(28l);
    way_1_2.setTag("highway", "primary");
    way_1_2.setTag("maxweight", "45");
    graph.edge(1, 2, 1, true);
    AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 2, 0.02, 0.02);
    graph.getEdgeIteratorState(1, 2).setFlags(encoder.handleWayTags(way_1_2, 1, 0));
    // 2-0
    ReaderWay way_2_0 = new ReaderWay(29l);
    way_2_0.setTag("highway", "primary");
    way_2_0.setTag("maxwidth", "5");
    graph.edge(2, 0, 1, true);
    graph.getEdgeIteratorState(2, 0).setFlags(encoder.handleWayTags(way_2_0, 1, 0));
    graph.flush();
    graph.close();
    GraphHopper hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setCHEnabled(false).importOrLoad();
    EncodingManager em = hopper.getEncodingManager();
    assertNotNull(em);
    assertEquals(1, em.fetchEdgeEncoders().size());
    FlagEncoder flagEncoder = em.fetchEdgeEncoders().get(0);
    assertTrue(flagEncoder instanceof DataFlagEncoder);
    DataFlagEncoder dataFlagEncoder = (DataFlagEncoder) flagEncoder;
    assertTrue(dataFlagEncoder.isStoreHeight());
    assertTrue(dataFlagEncoder.isStoreWeight());
    assertFalse(dataFlagEncoder.isStoreWidth());
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) DataFlagEncoder(com.graphhopper.routing.util.DataFlagEncoder) DataFlagEncoder(com.graphhopper.routing.util.DataFlagEncoder) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) ReaderWay(com.graphhopper.reader.ReaderWay) GraphHopper(com.graphhopper.GraphHopper) Test(org.junit.Test)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)2 DataFlagEncoder (com.graphhopper.routing.util.DataFlagEncoder)2 EncodingManager (com.graphhopper.routing.util.EncodingManager)2 GraphHopper (com.graphhopper.GraphHopper)1 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)1 FootFlagEncoder (com.graphhopper.routing.util.FootFlagEncoder)1 GraphExtension (com.graphhopper.storage.GraphExtension)1 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)1 RAMDirectory (com.graphhopper.storage.RAMDirectory)1 Before (org.junit.Before)1 Test (org.junit.Test)1