Search in sources :

Example 81 with IntsRef

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

the class OSMTrackTypeParserTest method testUnkownValue.

@Test
public void testUnkownValue() {
    ReaderWay readerWay = new ReaderWay(1);
    IntsRef intsRef = em.createEdgeFlags();
    readerWay.setTag("tracktype", "unknownstuff");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.MISSING, ttEnc.getEnum(false, intsRef));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 82 with IntsRef

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

the class CarFlagEncoderTest method testDestinationTag.

@Test
public void testDestinationTag() {
    IntsRef relFlags = em.createRelationFlags();
    FastestWeighting weighting = new FastestWeighting(encoder);
    FastestWeighting bikeWeighting = new FastestWeighting(em.getEncoder("bike"));
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    assertNotEquals(EncodingManager.Access.CAN_SKIP, encoder.getAccess(way));
    IntsRef edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(60, weighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
    assertEquals(200, bikeWeighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
    // no change for bike!
    way.setTag("motor_vehicle", "destination");
    edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(600, weighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
    assertEquals(200, bikeWeighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("vehicle", "destination");
    edgeFlags = em.handleWayTags(way, relFlags);
    assertEquals(600, weighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
    assertEquals(200, bikeWeighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
}
Also used : FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 83 with IntsRef

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

the class CarFlagEncoderTest method testFerry.

@Test
public void testFerry() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("route", "shuttle_train");
    way.setTag("motorcar", "yes");
    way.setTag("bicycle", "no");
    // Provide the duration value in seconds:
    way.setTag("duration:seconds", Long.toString(35 * 60));
    way.setTag("estimated_distance", 50000);
    // accept
    assertTrue(encoder.getAccess(way).isFerry());
    // calculate speed from estimated_distance and duration
    assertEquals(61, encoder.ferrySpeedCalc.getSpeed(way), 1e-1);
    // Test for very short and slow 0.5km/h still realisitic ferry
    way = new ReaderWay(1);
    way.setTag("route", "ferry");
    way.setTag("motorcar", "yes");
    // Provide the duration of 12 minutes in seconds:
    way.setTag("duration:seconds", Long.toString(12 * 60));
    way.setTag("estimated_distance", 100);
    // accept
    assertTrue(encoder.getAccess(way).isFerry());
    // We can't store 0.5km/h, but we expect the lowest possible speed (5km/h)
    assertEquals(2.5, encoder.ferrySpeedCalc.getSpeed(way), 1e-1);
    IntsRef edgeFlags = em.createEdgeFlags();
    avSpeedEnc.setDecimal(false, edgeFlags, 2.5);
    assertEquals(5, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    // Test for an unrealisitic long duration
    way = new ReaderWay(1);
    way.setTag("route", "ferry");
    way.setTag("motorcar", "yes");
    // Provide the duration of 2 months in seconds:
    way.setTag("duration:seconds", Long.toString(87900 * 60));
    way.setTag("estimated_distance", 100);
    // accept
    assertTrue(encoder.getAccess(way).isFerry());
    // We have ignored the unrealisitc long duration and take the unknown speed
    assertEquals(2.5, encoder.ferrySpeedCalc.getSpeed(way), 1e-1);
    way.clearTags();
    way.setTag("route", "ferry");
    assertTrue(encoder.getAccess(way).isFerry());
    way.setTag("motorcar", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("route", "ferry");
    way.setTag("foot", "yes");
    assertTrue(encoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("route", "ferry");
    way.setTag("foot", "designated");
    way.setTag("motor_vehicle", "designated");
    assertTrue(encoder.getAccess(way).isFerry());
    way.clearTags();
    way.setTag("route", "ferry");
    way.setTag("access", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("vehicle", "yes");
    assertTrue(encoder.getAccess(way).isFerry());
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 84 with IntsRef

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

the class CarFlagEncoderTest method testSetSpeed.

@Test
public void testSetSpeed() {
    IntsRef edgeFlags = em.createEdgeFlags();
    avSpeedEnc.setDecimal(false, edgeFlags, 10);
    assertEquals(10, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 85 with IntsRef

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

the class FootFlagEncoderTest method testSteps.

@Test
public void testSteps() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "service");
    IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(FootFlagEncoder.MEAN_SPEED, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
    way.setTag("highway", "steps");
    flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(FootFlagEncoder.MEAN_SPEED > footAvgSpeedEnc.getDecimal(false, flags));
}
Also used : 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