Search in sources :

Example 86 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class FootFlagEncoderTest method testPier.

@Test
public void testPier() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("man_made", "pier");
    IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertFalse(flags.isEmpty());
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 87 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class MountainBikeFlagEncoderTest method testGetSpeed.

@Test
public void testGetSpeed() {
    IntsRef intsRef = GHUtility.setSpeed(10, 0, encoder, encodingManager.createEdgeFlags());
    assertEquals(10, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "primary");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(AVOID.getValue(), way);
    way.setTag("highway", "residential");
    assertEquals(16, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    // Test pushing section speeds
    way.setTag("highway", "footway");
    assertEquals(4, encoder.getSpeed(way));
    assertPriority(SLIGHT_AVOID.getValue(), way);
    way.setTag("highway", "track");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("highway", "steps");
    assertEquals(4, encoder.getSpeed(way));
    assertPriority(SLIGHT_AVOID.getValue(), way);
    way.clearTags();
    // test speed for allowed pushing section types
    way.setTag("highway", "track");
    way.setTag("bicycle", "yes");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("highway", "track");
    way.setTag("bicycle", "yes");
    way.setTag("tracktype", "grade3");
    assertPriority(VERY_NICE.getValue(), way);
    way.setTag("surface", "paved");
    assertEquals(18, encoder.getSpeed(way));
    assertPriority(VERY_NICE.getValue(), way);
    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("surface", "ground");
    assertEquals(16, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 88 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class RacingBikeFlagEncoderTest method testGetSpeed.

@Test
public void testGetSpeed() {
    IntsRef intsRef = GHUtility.setSpeed(10, 0, encoder, encodingManager.createEdgeFlags());
    assertEquals(10, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("tracktype", "grade3");
    // use pushing section
    assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 1e-1);
    // Even if it is part of a cycle way
    way.setTag("bicycle", "yes");
    assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 1e-1);
    way.clearTags();
    way.setTag("highway", "steps");
    assertEquals(2, getSpeedFromFlags(way), 1e-1);
    way.clearTags();
    way.setTag("highway", "primary");
    assertEquals(20, getSpeedFromFlags(way), 1e-1);
    way.clearTags();
    way.setTag("highway", "primary");
    way.setTag("surface", "paved");
    assertEquals(20, getSpeedFromFlags(way), 1e-1);
    way.clearTags();
    way.setTag("highway", "primary");
    way.setTag("surface", "unknownpavement");
    assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 1e-1);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 89 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class RacingBikeFlagEncoderTest method assertPriority.

private void assertPriority(EncodingManager encodingManager, int expectedPrio, ReaderWay way) {
    IntsRef edgeFlags = encodingManager.handleWayTags(way, encodingManager.createRelationFlags());
    FlagEncoder encoder = encodingManager.fetchEdgeEncoders().iterator().next();
    DecimalEncodedValue enc = encodingManager.getDecimalEncodedValue(EncodingManager.getKey(encoder.toString(), "priority"));
    assertEquals(PriorityCode.getValue(expectedPrio), enc.getDecimal(false, edgeFlags), 0.01);
}
Also used : DecimalEncodedValue(com.graphhopper.routing.ev.DecimalEncodedValue) IntsRef(com.graphhopper.storage.IntsRef)

Example 90 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class RacingBikeFlagEncoderTest method testHandleWayTagsInfluencedByRelation.

@Test
public void testHandleWayTagsInfluencedByRelation() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "track");
    assertEquals(PUSHING_SECTION_SPEED / 2, getSpeedFromFlags(osmWay), 1e-1);
    // relation code is PREFER
    ReaderRelation osmRel = new ReaderRelation(1);
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "lcn");
    IntsRef flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
    assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // relation code is OUTSTANDING NICE but as unpaved, the speed is still PUSHING_SECTION_SPEED/2
    osmRel.setTag("network", "icn");
    flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
    assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // Now we assume bicycle=yes, anyhow still unpaved
    osmWay.setTag("bicycle", "yes");
    flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
    assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // Now we assume bicycle=yes, and paved
    osmWay.setTag("tracktype", "grade1");
    flags = assertPriority(PREFER.getValue(), osmWay, osmRel);
    assertEquals(20, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // Now we assume bicycle=yes, and unpaved as part of a cycle relation
    osmWay.setTag("tracktype", "grade2");
    osmWay.setTag("bicycle", "yes");
    flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
    assertEquals(10, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // Now we assume bicycle=yes, and unpaved not part of a cycle relation
    osmWay.clearTags();
    osmWay.setTag("highway", "track");
    osmWay.setTag("tracktype", "grade3");
    flags = assertPriority(AVOID_MORE.getValue(), osmWay);
    assertEquals(PUSHING_SECTION_SPEED, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // Now we assume bicycle=yes, and tracktype = null
    osmWay.clearTags();
    osmWay.setTag("highway", "track");
    flags = assertPriority(AVOID_MORE.getValue(), osmWay);
    assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) ReaderRelation(com.graphhopper.reader.ReaderRelation) Test(org.junit.jupiter.api.Test)

Aggregations

IntsRef (com.graphhopper.storage.IntsRef)108 Test (org.junit.jupiter.api.Test)96 ReaderWay (com.graphhopper.reader.ReaderWay)67 ReaderRelation (com.graphhopper.reader.ReaderRelation)7 GraphBuilder (com.graphhopper.storage.GraphBuilder)7 EncodingManager (com.graphhopper.routing.util.EncodingManager)5 Graph (com.graphhopper.storage.Graph)5 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)4 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)4 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)3 NodeAccess (com.graphhopper.storage.NodeAccess)3 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)2 RoadEnvironment (com.graphhopper.routing.ev.RoadEnvironment)2 VirtualEdgeIteratorState (com.graphhopper.routing.querygraph.VirtualEdgeIteratorState)2 TransportationMode (com.graphhopper.routing.util.TransportationMode)2 CountryRule (com.graphhopper.routing.util.countryrules.CountryRule)2 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)2 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)2 PMap (com.graphhopper.util.PMap)2 PointList (com.graphhopper.util.PointList)2