Search in sources :

Example 86 with ReaderWay

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

the class DataFlagEncoderTest method testHighway.

@Test
public void testHighway() {
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("surface", "sand");
    osmWay.setTag("tunnel", "yes");
    long flags = encoder.handleWayTags(osmWay, 1, 0);
    EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals("primary", encoder.getHighwayAsString(edge));
    assertEquals("sand", encoder.getSurfaceAsString(edge));
    assertEquals("tunnel", encoder.getTransportModeAsString(edge));
    assertTrue(encoder.isForward(edge, motorVehicleInt));
    assertTrue(encoder.isBackward(edge, motorVehicleInt));
    osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("oneway", "yes");
    flags = encoder.handleWayTags(osmWay, 1, 0);
    edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertTrue(encoder.isForward(edge, motorVehicleInt));
    assertFalse(encoder.isBackward(edge, motorVehicleInt));
    osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "unknownX");
    flags = encoder.handleWayTags(osmWay, 1, 0);
    edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals("_default", encoder.getHighwayAsString(edge));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 87 with ReaderWay

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

the class DataFlagEncoderTest method testTunnel.

@Test
public void testTunnel() {
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("tunnel", "yes");
    long flags = encoder.handleWayTags(osmWay, 1, 0);
    EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals("primary", encoder.getHighwayAsString(edge));
    assertEquals("tunnel", encoder.getTransportModeAsString(edge));
    assertTrue(encoder.isTransportModeTunnel(edge));
    assertFalse(encoder.isTransportModeBridge(edge));
    osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("tunnel", "yes");
    osmWay.setTag("bridge", "yes");
    flags = encoder.handleWayTags(osmWay, 1, 0);
    edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals("bridge", encoder.getTransportModeAsString(edge));
    assertFalse(encoder.isTransportModeTunnel(edge));
    assertTrue(encoder.isTransportModeBridge(edge));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 88 with ReaderWay

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

the class DataFlagEncoderTest method testLargeMaxspeed.

@Test
public void testLargeMaxspeed() {
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("maxspeed", "145");
    long flags = encoder.handleWayTags(osmWay, 1, 0);
    EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
    assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
    osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("maxspeed", "1000");
    flags = encoder.handleWayTags(osmWay, 1, 0);
    edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
    assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 89 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testHandleCommonWayTags.

@Test
public void testHandleCommonWayTags() {
    ReaderWay way = new ReaderWay(1);
    String wayType;
    way.setTag("highway", "steps");
    wayType = getWayTypeFromFlags(way);
    assertEquals("get off the bike", wayType);
    way.setTag("highway", "footway");
    wayType = getWayTypeFromFlags(way);
    assertEquals("get off the bike", wayType);
    way.setTag("highway", "footway");
    way.setTag("surface", "pebblestone");
    wayType = getWayTypeFromFlags(way);
    assertEquals("get off the bike", wayType);
    way.setTag("highway", "residential");
    wayType = getWayTypeFromFlags(way);
    assertEquals("", wayType);
    assertPriority(PREFER.getValue(), way);
    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("bicycle", "yes");
    wayType = getWayTypeFromFlags(way);
    assertEquals("", wayType);
    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("bicycle", "designated");
    wayType = getWayTypeFromFlags(way);
    assertEquals("", wayType);
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("bicycle", "designated");
    wayType = getWayTypeFromFlags(way);
    assertEquals("cycleway, unpaved", wayType);
    way.clearTags();
    way.setTag("highway", "cycleway");
    wayType = getWayTypeFromFlags(way);
    assertEquals("cycleway", wayType);
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("surface", "grass");
    wayType = getWayTypeFromFlags(way);
    assertEquals("cycleway, unpaved", wayType);
    way.setTag("surface", "asphalt");
    wayType = getWayTypeFromFlags(way);
    assertEquals("cycleway", wayType);
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("highway", "footway");
    way.setTag("bicycle", "yes");
    way.setTag("surface", "grass");
    wayType = getWayTypeFromFlags(way);
    assertEquals("small way, unpaved", wayType);
    way.setTag("bicycle", "designated");
    wayType = getWayTypeFromFlags(way);
    assertEquals("cycleway, unpaved", wayType);
    way.clearTags();
    way.setTag("highway", "footway");
    way.setTag("bicycle", "yes");
    way.setTag("surface", "grass");
    wayType = getWayTypeFromFlags(way);
    assertEquals("small way, unpaved", wayType);
    way.clearTags();
    way.setTag("railway", "platform");
    wayType = getWayTypeFromFlags(way);
    assertEquals("get off the bike", wayType);
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("railway", "platform");
    wayType = getWayTypeFromFlags(way);
    assertEquals("get off the bike, unpaved", wayType);
    way.clearTags();
    way.setTag("highway", "secondary");
    way.setTag("bicycle", "dismount");
    wayType = getWayTypeFromFlags(way);
    assertEquals("get off the bike", wayType);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 90 with ReaderWay

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

the class BikeFlagEncoderTest method testGetSpeed.

@Test
public void testGetSpeed() {
    long result = encoder.setProperties(10, true, true);
    assertEquals(10, encoder.getSpeed(result), 1e-1);
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "primary");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(REACH_DEST.getValue(), way);
    way.setTag("scenic", "yes");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    // Pushing section: this is fine as we obey the law!
    way.clearTags();
    way.setTag("highway", "footway");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    // Use pushing section irrespective of the pavement
    way.setTag("surface", "paved");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "secondary");
    way.setTag("bicycle", "dismount");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(REACH_DEST.getValue(), way);
    way.clearTags();
    way.setTag("highway", "footway");
    way.setTag("bicycle", "yes");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("segregated", "no");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("segregated", "yes");
    assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.clearTags();
    way.setTag("highway", "footway");
    way.setTag("surface", "paved");
    way.setTag("bicycle", "yes");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("segregated", "yes");
    assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.clearTags();
    way.setTag("highway", "cycleway");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(VERY_NICE.getValue(), way);
    int cyclewaySpeed = encoder.getSpeed(way);
    way.setTag("foot", "yes");
    way.setTag("segregated", "yes");
    assertPriority(VERY_NICE.getValue(), way);
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    way.setTag("segregated", "no");
    assertPriority(PREFER.getValue(), way);
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    // Make sure that "highway=cycleway" and "highway=path" with "bicycle=designated" give the same result
    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("bicycle", "designated");
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    // Assume foot=no for designated in absence of a foot tag
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("foot", "yes");
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("foot", "no");
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("segregated", "yes");
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("segregated", "no");
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("bicycle", "yes");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("segregated", "yes");
    assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("surface", "unpaved");
    assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
    way.setTag("surface", "paved");
    assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "path");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    // use pushing section
    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("surface", "paved");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("surface", "ground");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "footway");
    way.setTag("surface", "paved");
    way.setTag("bicycle", "designated");
    assertEquals(cyclewaySpeed, encoder.getSpeed(way));
    assertPriority(VERY_NICE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "track");
    assertEquals(12, encoder.getSpeed(way));
    assertPriority(UNCHANGED.getValue(), way);
    way.setTag("tracktype", "grade1");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(UNCHANGED.getValue(), way);
    way.setTag("highway", "track");
    way.setTag("tracktype", "grade2");
    assertEquals(12, encoder.getSpeed(way));
    assertPriority(UNCHANGED.getValue(), way);
    // test speed for allowed get off the bike types
    way.setTag("highway", "track");
    way.setTag("bicycle", "yes");
    assertEquals(12, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "steps");
    assertEquals(2, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "steps");
    way.setTag("surface", "wood");
    assertEquals(PUSHING_SECTION_SPEED / 2, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.setTag("maxspeed", "20");
    assertEquals(PUSHING_SECTION_SPEED / 2, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("surface", "paved");
    assertEquals(18, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("surface", "ground");
    assertEquals(4, encoder.getSpeed(way));
    assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("bicycle", "yes");
    way.setTag("surface", "fine_gravel");
    assertEquals(18, encoder.getSpeed(way));
    way.setTag("surface", "unknown_surface");
    assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "primary");
    way.setTag("surface", "fine_gravel");
    assertEquals(18, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("surface", "gravel");
    way.setTag("tracktype", "grade2");
    assertEquals(12, encoder.getSpeed(way));
    assertPriority(UNCHANGED.getValue(), way);
    way.clearTags();
    way.setTag("highway", "primary");
    way.setTag("surface", "paved");
    assertEquals(18, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "primary");
    assertEquals(18, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("surface", "asphalt");
    assertEquals(18, encoder.getSpeed(way));
    way.clearTags();
    way.setTag("highway", "motorway");
    way.setTag("bicycle", "yes");
    assertEquals(18, encoder.getSpeed(way));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)157 Test (org.junit.jupiter.api.Test)119 IntsRef (com.graphhopper.storage.IntsRef)67 Test (org.junit.Test)24 EncodingManager (com.graphhopper.routing.util.EncodingManager)9 GraphBuilder (com.graphhopper.storage.GraphBuilder)9 ReaderRelation (com.graphhopper.reader.ReaderRelation)8 ConditionalTagInspector (com.graphhopper.reader.ConditionalTagInspector)7 Graph (com.graphhopper.storage.Graph)7 DateFormat (java.text.DateFormat)6 Date (java.util.Date)6 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)5 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)5 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)4 PMap (com.graphhopper.util.PMap)4 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)3 DataFlagEncoder (com.graphhopper.routing.util.DataFlagEncoder)3 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 LongIndexedContainer (com.carrotsearch.hppc.LongIndexedContainer)2