Search in sources :

Example 6 with ReaderNode

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

the class CarFlagEncoderTest method testBarrierAccess.

@Test
public void testBarrierAccess() {
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("access", "yes");
    // no barrier!
    assertFalse(encoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("bicycle", "yes");
    // no barrier!
    assertFalse(encoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("access", "yes");
    node.setTag("bicycle", "yes");
    // should this be a barrier for motorcars too?
    // assertTrue(encoder.handleNodeTags(node) == true);
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("access", "no");
    node.setTag("motorcar", "yes");
    // no barrier!
    assertFalse(encoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "bollard");
    // barrier!
    assertTrue(encoder.isBarrier(node));
    CarFlagEncoder tmpEncoder = new CarFlagEncoder();
    EncodingManager.create(tmpEncoder);
    // Test if cattle_grid is not blocking
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "cattle_grid");
    assertFalse(tmpEncoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) Test(org.junit.jupiter.api.Test)

Example 7 with ReaderNode

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

the class CarFlagEncoderTest method testFordAccess.

@Test
public void testFordAccess() {
    ReaderNode node = new ReaderNode(0, 0.0, 0.0);
    node.setTag("ford", "yes");
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "unclassified");
    way.setTag("ford", "yes");
    // Node and way are initially blocking
    assertTrue(encoder.isBlockFords());
    assertTrue(encoder.getAccess(way).canSkip());
    assertTrue(encoder.isBarrier(node));
    CarFlagEncoder tmpEncoder = new CarFlagEncoder(new PMap("block_fords=false"));
    EncodingManager.create(tmpEncoder);
    assertTrue(tmpEncoder.getAccess(way).isWay());
    assertFalse(tmpEncoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) PMap(com.graphhopper.util.PMap) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 8 with ReaderNode

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

the class FootFlagEncoderTest method testChainBarrier.

@Test
public void testChainBarrier() {
    // by default allow access through the gate for bike & foot!
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "chain");
    assertFalse(footEncoder.isBarrier(node));
    node.setTag("foot", "no");
    assertTrue(footEncoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) Test(org.junit.jupiter.api.Test)

Example 9 with ReaderNode

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

the class FootFlagEncoderTest method testFord.

@Test
public void testFord() {
    // by default do not block access due to fords!
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("ford", "no");
    assertFalse(footEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("ford", "yes");
    // no barrier!
    assertFalse(footEncoder.isBarrier(node));
    // barrier!
    node.setTag("foot", "no");
    assertTrue(footEncoder.isBarrier(node));
    FootFlagEncoder tmpEncoder = new FootFlagEncoder(new PMap("block_fords=true"));
    EncodingManager.create(tmpEncoder);
    node = new ReaderNode(1, -1, -1);
    node.setTag("ford", "no");
    assertFalse(tmpEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("ford", "yes");
    assertTrue(tmpEncoder.isBarrier(node));
}
Also used : ReaderNode(com.graphhopper.reader.ReaderNode) Test(org.junit.jupiter.api.Test)

Example 10 with ReaderNode

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

the class WheelchairFlagEncoderTest method testBarrierAccess.

@Test
public void testBarrierAccess() {
    // by default allow access through the gate for bike & foot!
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "gate");
    // no barrier!
    assertFalse(wheelchairEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "gate");
    node.setTag("access", "yes");
    // no barrier!
    assertFalse(wheelchairEncoder.isBarrier(node));
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "gate");
    node.setTag("access", "no");
    // barrier!
    assertTrue(wheelchairEncoder.isBarrier(node));
    node.setTag("bicycle", "yes");
    // no barrier!?
    // assertTrue(wheelchairEncoder.handleNodeTags(node) == false);
    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "gate");
    node.setTag("access", "no");
    node.setTag("foot", "yes");
    // no barrier!
    assertFalse(wheelchairEncoder.isBarrier(node));
    node.setTag("locked", "yes");
    // barrier!
    assertTrue(wheelchairEncoder.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