use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class EncodingManagerTest method testCompatibilityBug.
@Test
public void testCompatibilityBug() {
EncodingManager manager2 = EncodingManager.create(new DefaultFlagEncoderFactory(), "bike2");
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "footway");
osmWay.setTag("name", "test");
BikeFlagEncoder singleBikeEnc = (BikeFlagEncoder) manager2.getEncoder("bike2");
IntsRef flags = manager2.handleWayTags(osmWay, manager2.createRelationFlags());
double singleSpeed = singleBikeEnc.avgSpeedEnc.getDecimal(false, flags);
assertEquals(4, singleSpeed, 1e-3);
assertEquals(singleSpeed, singleBikeEnc.avgSpeedEnc.getDecimal(true, flags), 1e-3);
EncodingManager manager = EncodingManager.create(new DefaultFlagEncoderFactory(), "bike2,bike,foot");
FootFlagEncoder foot = (FootFlagEncoder) manager.getEncoder("foot");
BikeFlagEncoder bike = (BikeFlagEncoder) manager.getEncoder("bike2");
flags = manager.handleWayTags(osmWay, manager.createRelationFlags());
assertEquals(singleSpeed, bike.avgSpeedEnc.getDecimal(false, flags), 1e-2);
assertEquals(singleSpeed, bike.avgSpeedEnc.getDecimal(true, flags), 1e-2);
assertEquals(5, foot.avgSpeedEnc.getDecimal(false, flags), 1e-2);
assertEquals(5, foot.avgSpeedEnc.getDecimal(true, flags), 1e-2);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class RoadsFlagEncoderTest method testAccess.
@Test
public void testAccess() {
ReaderWay way = new ReaderWay(1);
assertTrue(roadsEncoder.getAccess(way).canSkip());
way.setTag("highway", "motorway");
assertTrue(roadsEncoder.getAccess(way).isWay());
way.setTag("highway", "footway");
assertTrue(roadsEncoder.getAccess(way).isWay());
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class RoadsFlagEncoderTest method testSpeed.
@Test
public void testSpeed() {
ReaderWay way = new ReaderWay(1);
IntsRef flags = roadsEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(roadsEncoder.getAverageSpeedEnc().getDecimal(false, flags) > 200);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class BikeFlagEncoderTest method testSpeedAndPriority.
@Test
public void testSpeedAndPriority() {
IntsRef intsRef = encodingManager.createEdgeFlags();
encoder.setSpeed(false, intsRef, 10);
encoder.getAccessEnc().setBool(false, intsRef, true);
encoder.getAccessEnc().setBool(true, intsRef, true);
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("scenic", "yes");
assertEquals(18, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
// Pushing section: this is fine as we obey the law!
way.clearTags();
way.setTag("highway", "footway");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
// Use pushing section irrespective of the pavement
way.setTag("surface", "paved");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "path");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "secondary");
way.setTag("bicycle", "dismount");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "footway");
way.setTag("bicycle", "yes");
assertEquals(10, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "no");
assertEquals(10, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(18, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.clearTags();
way.setTag("highway", "footway");
way.setTag("surface", "paved");
way.setTag("bicycle", "yes");
assertEquals(10, encoder.getSpeed(way));
way.setTag("surface", "cobblestone");
assertEquals(8, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
way.setTag("surface", "paved");
assertEquals(18, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.clearTags();
way.setTag("highway", "platform");
way.setTag("surface", "paved");
way.setTag("bicycle", "yes");
assertEquals(10, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(18, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.clearTags();
way.setTag("highway", "cycleway");
assertEquals(18, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
int cyclewaySpeed = encoder.getSpeed(way);
way.setTag("foot", "yes");
way.setTag("segregated", "yes");
assertPriority(VERY_NICE.getValue(), way);
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
way.setTag("segregated", "no");
assertPriority(PREFER.getValue(), way);
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
// Make sure that "highway=cycleway" and "highway=path" with "bicycle=designated" give the same result
way.clearTags();
way.setTag("highway", "path");
way.setTag("bicycle", "designated");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
// Assume foot=no for designated in absence of a foot tag
assertPriority(VERY_NICE.getValue(), way);
way.setTag("foot", "yes");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("foot", "no");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
way.setTag("segregated", "no");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
way.setTag("bicycle", "yes");
assertEquals(10, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("surface", "unpaved");
assertEquals(14, encoder.getSpeed(way));
way.setTag("surface", "paved");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "path");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
// use pushing section
way.clearTags();
way.setTag("highway", "path");
way.setTag("surface", "paved");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "path");
way.setTag("surface", "ground");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "platform");
way.setTag("surface", "paved");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "footway");
way.setTag("surface", "paved");
way.setTag("bicycle", "designated");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
way.clearTags();
way.setTag("highway", "platform");
way.setTag("surface", "paved");
way.setTag("bicycle", "designated");
assertEquals(cyclewaySpeed, encoder.getSpeed(way));
assertPriority(VERY_NICE.getValue(), way);
way.clearTags();
way.setTag("highway", "track");
assertEquals(12, encoder.getSpeed(way));
assertPriority(UNCHANGED.getValue(), way);
way.setTag("tracktype", "grade1");
assertEquals(18, encoder.getSpeed(way));
assertPriority(UNCHANGED.getValue(), way);
way.setTag("highway", "track");
way.setTag("tracktype", "grade2");
assertEquals(12, encoder.getSpeed(way));
assertPriority(UNCHANGED.getValue(), way);
// test speed for allowed get off the bike types
way.setTag("highway", "track");
way.setTag("bicycle", "yes");
assertEquals(12, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "steps");
assertEquals(2, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "residential");
way.setTag("bicycle", "use_sidepath");
assertEquals(18, encoder.getSpeed(way));
assertPriority(REACH_DESTINATION.getValue(), way);
way.clearTags();
way.setTag("highway", "steps");
way.setTag("surface", "wood");
assertEquals(PUSHING_SECTION_SPEED / 2, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.setTag("maxspeed", "20");
assertEquals(PUSHING_SECTION_SPEED / 2, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "track");
way.setTag("surface", "paved");
assertEquals(18, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "path");
way.setTag("surface", "ground");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
way.clearTags();
way.setTag("highway", "track");
way.setTag("bicycle", "yes");
way.setTag("surface", "fine_gravel");
assertEquals(18, encoder.getSpeed(way));
way.setTag("surface", "unknown_surface");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "primary");
way.setTag("surface", "fine_gravel");
assertEquals(18, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "track");
way.setTag("surface", "gravel");
way.setTag("tracktype", "grade2");
assertEquals(12, encoder.getSpeed(way));
assertPriority(UNCHANGED.getValue(), way);
way.clearTags();
way.setTag("highway", "primary");
way.setTag("surface", "paved");
assertEquals(18, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "primary");
assertEquals(18, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "residential");
way.setTag("surface", "asphalt");
assertEquals(18, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "motorway");
way.setTag("bicycle", "yes");
assertEquals(18, encoder.getSpeed(way));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class BikeFlagEncoderTest method testSacScale.
@Test
@Override
public void testSacScale() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "path");
way.setTag("sac_scale", "hiking");
assertTrue(encoder.getAccess(way).isWay());
way.setTag("highway", "path");
way.setTag("sac_scale", "mountain_hiking");
assertTrue(encoder.getAccess(way).canSkip());
way.setTag("highway", "cycleway");
way.setTag("sac_scale", "hiking");
assertTrue(encoder.getAccess(way).isWay());
way.setTag("highway", "cycleway");
way.setTag("sac_scale", "mountain_hiking");
// disallow questionable combination as too dangerous
assertTrue(encoder.getAccess(way).canSkip());
}
Aggregations