Search in sources :

Example 11 with ReaderNode

use of com.graphhopper.reader.ReaderNode in project graphhopper by graphhopper.

the class WheelchairFlagEncoderTest method testBlockByDefault.

@Test
public void testBlockByDefault() {
    WheelchairFlagEncoder tmpWheelchairEncoder = new WheelchairFlagEncoder();
    EncodingManager.create(tmpWheelchairEncoder);
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "gate");
    // passByDefaultBarriers are no barrier by default
    assertFalse(tmpWheelchairEncoder.isBarrier(node));
    node.setTag("access", "no");
    assertTrue(tmpWheelchairEncoder.isBarrier(node));
    // these barriers block
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "fence");
    assertTrue(tmpWheelchairEncoder.isBarrier(node));
    node.setTag("barrier", "wall");
    assertTrue(tmpWheelchairEncoder.isBarrier(node));
    node.setTag("barrier", "handrail");
    assertTrue(tmpWheelchairEncoder.isBarrier(node));
    node.setTag("barrier", "turnstile");
    assertTrue(tmpWheelchairEncoder.isBarrier(node));
    // Explictly allowed access is allowed
    node.setTag("barrier", "fence");
    node.setTag("access", "yes");
    assertFalse(tmpWheelchairEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "gate");
    node.setTag("access", "yes");
    assertFalse(tmpWheelchairEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "kerb");
    assertFalse(tmpWheelchairEncoder.isBarrier(node));
    node.setTag("wheelchair", "yes");
    assertFalse(tmpWheelchairEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "fence");
    assertTrue(tmpWheelchairEncoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) Test(org.junit.jupiter.api.Test)

Example 12 with ReaderNode

use of com.graphhopper.reader.ReaderNode in project graphhopper by graphhopper.

the class OSMReaderTest method testReadEleFromCustomOSM.

@Test
public void testReadEleFromCustomOSM() {
    GraphHopper hopper = new GraphHopperFacade("custom-osm-ele.xml") {

        @Override
        protected DataReader createReader(GraphHopperStorage tmpGraph) {
            return initDataReader(new OSMReader(tmpGraph) {

                @Override
                protected double getElevation(ReaderNode node) {
                    return node.getEle();
                }
            });
        }
    }.setElevation(true).importOrLoad();
    Graph graph = hopper.getGraphHopperStorage();
    int n20 = AbstractGraphStorageTester.getIdOf(graph, 52);
    int n50 = AbstractGraphStorageTester.getIdOf(graph, 49);
    EdgeIteratorState edge = GHUtility.getEdge(graph, n20, n50);
    assertEquals(Helper.createPointList3D(52, 9, -10, 51.25, 9.43, 100, 49, 10, -30), edge.fetchWayGeometry(3));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) GraphHopper(com.graphhopper.GraphHopper) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Example 13 with ReaderNode

use of com.graphhopper.reader.ReaderNode in project graphhopper by graphhopper.

the class EncodingManager method handleNodeTags.

/**
 * Updates the given edge flags based on node tags
 */
public IntsRef handleNodeTags(Map<String, Object> nodeTags, IntsRef edgeFlags) {
    for (AbstractFlagEncoder encoder : edgeEncoders) {
        // for now we just create a dummy reader node, because our encoders do not make use of the coordinates anyway
        ReaderNode readerNode = new ReaderNode(0, 0, 0, nodeTags);
        // block access for all encoders that treat this node as a barrier
        if (encoder.isBarrier(readerNode)) {
            BooleanEncodedValue accessEnc = encoder.getAccessEnc();
            accessEnc.setBool(false, edgeFlags, false);
            accessEnc.setBool(true, edgeFlags, false);
        }
    }
    return edgeFlags;
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode)

Example 14 with ReaderNode

use of com.graphhopper.reader.ReaderNode in project graphhopper by graphhopper.

the class BikeFlagEncoderTest method testBarrierAccess.

// Issue 407 : Always block kissing_gate execpt for mountainbikes
@Test
@Override
public void testBarrierAccess() {
    // kissing_gate without bicycle tag
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "kissing_gate");
    // barrier!
    assertTrue(encoder.isBarrier(node));
    // kissing_gate with bicycle tag
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "kissing_gate");
    node.setTag("bicycle", "yes");
    // no barrier!
    assertFalse(encoder.isBarrier(node));
    // Test if cattle_grid is non blocking
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "cattle_grid");
    assertFalse(encoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) Test(org.junit.jupiter.api.Test)

Example 15 with ReaderNode

use of com.graphhopper.reader.ReaderNode in project graphhopper by graphhopper.

the class AbstractBikeFlagEncoderTester method testBarrierAccessFord.

@Test
public void testBarrierAccessFord() {
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("ford", "yes");
    // barrier!
    assertTrue(encoder.isBarrier(node));
    node.setTag("bicycle", "yes");
    // no barrier!
    assertFalse(encoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) Test(org.junit.jupiter.api.Test)

Aggregations

ReaderNode (com.graphhopper.reader.ReaderNode)20 Test (org.junit.jupiter.api.Test)13 GHPoint (com.graphhopper.util.shapes.GHPoint)3 Test (org.junit.Test)3 GraphHopper (com.graphhopper.GraphHopper)2 ReaderWay (com.graphhopper.reader.ReaderWay)2 LongIndexedContainer (com.carrotsearch.hppc.LongIndexedContainer)1 PMap (com.graphhopper.util.PMap)1 Osmformat (org.openstreetmap.osmosis.osmbinary.Osmformat)1