Search in sources :

Example 41 with ReaderWay

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

the class BikeFlagEncoderTest method testMaxSpeed.

@Test
public void testMaxSpeed() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("maxspeed", "10");
    IntsRef edgeFlags = encodingManager.handleWayTags(way, encodingManager.createRelationFlags());
    assertEquals(10, avgSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    assertPriority(PREFER.getValue(), way);
    way = new ReaderWay(1);
    way.setTag("highway", "tertiary");
    way.setTag("maxspeed", "90");
    edgeFlags = encodingManager.createEdgeFlags();
    encoder.setSpeed(false, edgeFlags, encoder.applyMaxSpeed(way, 20));
    assertEquals(20, avgSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    assertPriority(UNCHANGED.getValue(), way);
    way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("maxspeed", "90");
    edgeFlags = encodingManager.createEdgeFlags();
    encoder.setSpeed(false, edgeFlags, encoder.applyMaxSpeed(way, 20));
    assertEquals(20, avgSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    assertPriority(UNCHANGED.getValue(), way);
    way = new ReaderWay(1);
    way.setTag("highway", "residential");
    way.setTag("maxspeed", "15");
    edgeFlags = encodingManager.createEdgeFlags();
    encoder.setSpeed(false, edgeFlags, encoder.applyMaxSpeed(way, 15));
    assertEquals(15, avgSpeedEnc.getDecimal(false, edgeFlags), 1.0);
    edgeFlags = encodingManager.handleWayTags(way, encodingManager.createRelationFlags());
    assertEquals(15, avgSpeedEnc.getDecimal(false, edgeFlags), 1.0);
    assertPriority(PREFER.getValue(), way);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 42 with ReaderWay

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

the class BikeFlagEncoderTest method testCalcPriority.

@Test
public void testCalcPriority() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "tertiary");
    ReaderRelation osmRel = new ReaderRelation(1);
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "icn");
    IntsRef relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
    IntsRef flags = encodingManager.handleWayTags(osmWay, relFlags);
    assertEquals(PriorityCode.getValue(BEST.getValue()), priorityEnc.getDecimal(false, flags), .1);
    // for some highways the priority is UNCHANGED
    osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "track");
    flags = encodingManager.handleWayTags(osmWay, encodingManager.createRelationFlags());
    assertEquals(PriorityCode.getValue(UNCHANGED.getValue()), priorityEnc.getDecimal(false, flags), .1);
    // for unknown highways we should probably keep the priority unchanged, but currently it does not matter
    // because the access will be false anyway
    osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "whatever");
    flags = encodingManager.handleWayTags(osmWay, encodingManager.createRelationFlags());
    assertEquals(EXCLUDE.getValue(), priorityEnc.getDecimal(false, flags), .1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) ReaderRelation(com.graphhopper.reader.ReaderRelation) Test(org.junit.jupiter.api.Test)

Example 43 with ReaderWay

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

the class BikeFlagEncoderTest method testHandleWayTagsInfluencedByRelation.

@Test
public void testHandleWayTagsInfluencedByRelation() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "road");
    // unchanged
    IntsRef flags = assertPriority(UNCHANGED.getValue(), osmWay);
    assertEquals(12, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // relation code is
    ReaderRelation osmRel = new ReaderRelation(1);
    osmRel.setTag("route", "bicycle");
    flags = assertPriority(PREFER.getValue(), osmWay, osmRel);
    assertEquals(12, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    osmRel.setTag("network", "lcn");
    flags = assertPriority(PREFER.getValue(), osmWay, osmRel);
    assertEquals(12, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // relation code is NICE
    osmRel.setTag("network", "rcn");
    assertPriority(VERY_NICE.getValue(), osmWay, osmRel);
    // relation code is BEST
    osmRel.setTag("network", "ncn");
    assertPriority(BEST.getValue(), osmWay, osmRel);
    // PREFER relation, but tertiary road => no get off the bike but road wayTypeCode and faster
    osmWay.clearTags();
    osmWay.setTag("highway", "tertiary");
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "lcn");
    assertPriority(PREFER.getValue(), osmWay, osmRel);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) ReaderRelation(com.graphhopper.reader.ReaderRelation) Test(org.junit.jupiter.api.Test)

Example 44 with ReaderWay

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

the class CarFlagEncoderTest method testRoundabout.

@Test
public void testRoundabout() {
    IntsRef edgeFlags = em.createEdgeFlags();
    accessEnc.setBool(false, edgeFlags, true);
    accessEnc.setBool(true, edgeFlags, true);
    roundaboutEnc.setBool(false, edgeFlags, true);
    assertTrue(roundaboutEnc.getBool(false, edgeFlags));
    assertTrue(accessEnc.getBool(false, edgeFlags));
    assertTrue(accessEnc.getBool(true, edgeFlags));
    roundaboutEnc.setBool(false, edgeFlags, false);
    assertFalse(roundaboutEnc.getBool(false, edgeFlags));
    assertTrue(accessEnc.getBool(false, edgeFlags));
    assertTrue(accessEnc.getBool(true, edgeFlags));
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertTrue(accessEnc.getBool(false, edgeFlags));
    assertTrue(accessEnc.getBool(true, edgeFlags));
    assertFalse(roundaboutEnc.getBool(false, edgeFlags));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 45 with ReaderWay

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

the class CarFlagEncoderTest method testCombination.

@Test
public void testCombination() {
    ReaderWay way = new ReaderWay(123);
    way.setTag("highway", "cycleway");
    way.setTag("sac_scale", "hiking");
    assertEquals(EncodingManager.Access.CAN_SKIP, encoder.getAccess(way));
    assertNotEquals(EncodingManager.Access.CAN_SKIP, ((AbstractFlagEncoder) em.getEncoder("bike")).getAccess(way));
    IntsRef edgeFlags = em.handleWayTags(way, em.createRelationFlags());
    assertFalse(accessEnc.getBool(true, edgeFlags));
    assertFalse(accessEnc.getBool(false, edgeFlags));
    BooleanEncodedValue bikeAccessEnc = em.getEncoder("bike").getAccessEnc();
    assertTrue(bikeAccessEnc.getBool(true, edgeFlags));
    assertTrue(bikeAccessEnc.getBool(false, edgeFlags));
}
Also used : BooleanEncodedValue(com.graphhopper.routing.ev.BooleanEncodedValue) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.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