Search in sources :

Example 26 with IntsRef

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

the class CarFlagEncoderTest method testOneway.

@Test
public void testOneway() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "primary");
    IntsRef flags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertTrue(accessEnc.getBool(false, flags));
    assertTrue(accessEnc.getBool(true, flags));
    way.setTag("oneway", "yes");
    flags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertTrue(accessEnc.getBool(false, flags));
    assertFalse(accessEnc.getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    flags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertTrue(accessEnc.getBool(false, flags));
    assertTrue(accessEnc.getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("vehicle:forward", "no");
    flags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertFalse(accessEnc.getBool(false, flags));
    assertTrue(accessEnc.getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("vehicle:backward", "no");
    flags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertTrue(accessEnc.getBool(false, flags));
    assertFalse(accessEnc.getBool(true, flags));
    way.clearTags();
    // This is no one way
    way.setTag("highway", "tertiary");
    way.setTag("vehicle:backward", "designated");
    flags = encoder.handleWayTags(em.createEdgeFlags(), way);
    assertTrue(accessEnc.getBool(false, flags));
    assertTrue(accessEnc.getBool(true, flags));
    way.clearTags();
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 27 with IntsRef

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

the class CarFlagEncoderTest method testMaxSpeed.

@Test
public void testMaxSpeed() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "trunk");
    way.setTag("maxspeed", "500");
    IntsRef relFlags = em.createRelationFlags();
    IntsRef edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(140, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    way = new ReaderWay(1);
    way.setTag("highway", "primary");
    way.setTag("maxspeed:backward", "10");
    way.setTag("maxspeed:forward", "20");
    edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(10, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    way = new ReaderWay(1);
    way.setTag("highway", "primary");
    way.setTag("maxspeed:forward", "20");
    edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(20, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    way = new ReaderWay(1);
    way.setTag("highway", "primary");
    way.setTag("maxspeed:backward", "20");
    edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(20, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    way.setTag("maxspeed", "none");
    edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(135, avSpeedEnc.getDecimal(false, edgeFlags), .1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 28 with IntsRef

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

the class FootFlagEncoderTest method testMixSpeedAndSafe.

@Test
public void testMixSpeedAndSafe() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(0, flags.ints[0]);
    way.setTag("sidewalk", "yes");
    flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(5, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
    way.clearTags();
    way.setTag("highway", "track");
    flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(5, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 29 with IntsRef

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

the class FootFlagEncoderTest method testFerrySpeed.

@Test
public void testFerrySpeed() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("route", "ferry");
    // a bit longer than an hour
    way.setTag("duration:seconds", "4000");
    assertEquals(30, footEncoder.ferrySpeedCalc.getSpeed(way), .1);
    IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(15, footAvgSpeedEnc.getDecimal(false, flags), .1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 30 with IntsRef

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

the class BooleanEncodedValueTest method testBitDirected.

@Test
public void testBitDirected() {
    EncodedValue.InitializerConfig config = new EncodedValue.InitializerConfig();
    BooleanEncodedValue bool = new SimpleBooleanEncodedValue("access", true);
    bool.init(config);
    IntsRef ref = new IntsRef(1);
    bool.setBool(false, ref, false);
    bool.setBool(true, ref, true);
    assertFalse(bool.getBool(false, ref));
    assertTrue(bool.getBool(true, ref));
}
Also used : 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