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));
}
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);
}
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());
}
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);
}
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));
}
Aggregations