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