Search in sources :

Example 16 with IntsRef

use of com.graphhopper.storage.IntsRef 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 17 with IntsRef

use of com.graphhopper.storage.IntsRef 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 18 with IntsRef

use of com.graphhopper.storage.IntsRef 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 19 with IntsRef

use of com.graphhopper.storage.IntsRef 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 20 with IntsRef

use of com.graphhopper.storage.IntsRef 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

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