use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testPier.
@Test
public void testPier() {
ReaderWay way = new ReaderWay(1);
way.setTag("man_made", "pier");
IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertFalse(flags.isEmpty());
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class MountainBikeFlagEncoderTest method testGetSpeed.
@Test
public void testGetSpeed() {
IntsRef intsRef = GHUtility.setSpeed(10, 0, encoder, encodingManager.createEdgeFlags());
assertEquals(10, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "primary");
assertEquals(18, encoder.getSpeed(way));
assertPriority(AVOID.getValue(), way);
way.setTag("highway", "residential");
assertEquals(16, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
// Test pushing section speeds
way.setTag("highway", "footway");
assertEquals(4, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.setTag("highway", "track");
assertEquals(18, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("highway", "steps");
assertEquals(4, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
// test speed for allowed pushing section types
way.setTag("highway", "track");
way.setTag("bicycle", "yes");
assertEquals(18, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("highway", "track");
way.setTag("bicycle", "yes");
way.setTag("tracktype", "grade3");
assertPriority(VERY_NICE.getValue(), way);
way.setTag("surface", "paved");
assertEquals(18, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
way.clearTags();
way.setTag("highway", "path");
way.setTag("surface", "ground");
assertEquals(16, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testGetSpeed.
@Test
public void testGetSpeed() {
IntsRef intsRef = GHUtility.setSpeed(10, 0, encoder, encodingManager.createEdgeFlags());
assertEquals(10, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("tracktype", "grade3");
// use pushing section
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 1e-1);
// Even if it is part of a cycle way
way.setTag("bicycle", "yes");
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 1e-1);
way.clearTags();
way.setTag("highway", "steps");
assertEquals(2, getSpeedFromFlags(way), 1e-1);
way.clearTags();
way.setTag("highway", "primary");
assertEquals(20, getSpeedFromFlags(way), 1e-1);
way.clearTags();
way.setTag("highway", "primary");
way.setTag("surface", "paved");
assertEquals(20, getSpeedFromFlags(way), 1e-1);
way.clearTags();
way.setTag("highway", "primary");
way.setTag("surface", "unknownpavement");
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 1e-1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method assertPriority.
private void assertPriority(EncodingManager encodingManager, int expectedPrio, ReaderWay way) {
IntsRef edgeFlags = encodingManager.handleWayTags(way, encodingManager.createRelationFlags());
FlagEncoder encoder = encodingManager.fetchEdgeEncoders().iterator().next();
DecimalEncodedValue enc = encodingManager.getDecimalEncodedValue(EncodingManager.getKey(encoder.toString(), "priority"));
assertEquals(PriorityCode.getValue(expectedPrio), enc.getDecimal(false, edgeFlags), 0.01);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testHandleWayTagsInfluencedByRelation.
@Test
public void testHandleWayTagsInfluencedByRelation() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "track");
assertEquals(PUSHING_SECTION_SPEED / 2, getSpeedFromFlags(osmWay), 1e-1);
// relation code is PREFER
ReaderRelation osmRel = new ReaderRelation(1);
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "lcn");
IntsRef flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// relation code is OUTSTANDING NICE but as unpaved, the speed is still PUSHING_SECTION_SPEED/2
osmRel.setTag("network", "icn");
flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// Now we assume bicycle=yes, anyhow still unpaved
osmWay.setTag("bicycle", "yes");
flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// Now we assume bicycle=yes, and paved
osmWay.setTag("tracktype", "grade1");
flags = assertPriority(PREFER.getValue(), osmWay, osmRel);
assertEquals(20, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// Now we assume bicycle=yes, and unpaved as part of a cycle relation
osmWay.setTag("tracktype", "grade2");
osmWay.setTag("bicycle", "yes");
flags = assertPriority(AVOID_MORE.getValue(), osmWay, osmRel);
assertEquals(10, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// Now we assume bicycle=yes, and unpaved not part of a cycle relation
osmWay.clearTags();
osmWay.setTag("highway", "track");
osmWay.setTag("tracktype", "grade3");
flags = assertPriority(AVOID_MORE.getValue(), osmWay);
assertEquals(PUSHING_SECTION_SPEED, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// Now we assume bicycle=yes, and tracktype = null
osmWay.clearTags();
osmWay.setTag("highway", "track");
flags = assertPriority(AVOID_MORE.getValue(), osmWay);
assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
}
Aggregations