use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testPriority_avoidanceOfHighMaxSpeed.
@Test
public void testPriority_avoidanceOfHighMaxSpeed() {
// here we test the priority that would be calculated if the way was accessible (even when it is not)
// therefore we need a modified encoder that always yields access=WAY
BikeCommonFlagEncoder encoder = new RacingBikeFlagEncoder(new PMap("block_fords=true")) {
@Override
public EncodingManager.Access getAccess(ReaderWay way) {
return WAY;
}
};
EncodingManager encodingManager = EncodingManager.create(encoder);
DecimalEncodedValue avgSpeedEnc = encoder.getAverageSpeedEnc();
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "tertiary");
osmWay.setTag("maxspeed", "50");
IntsRef intsRef = encodingManager.createEdgeFlags();
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, PREFER.getValue(), osmWay);
osmWay.setTag("maxspeed", "60");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, PREFER.getValue(), osmWay);
osmWay.setTag("maxspeed", "80");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, PREFER.getValue(), osmWay);
osmWay.setTag("maxspeed", "90");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, UNCHANGED.getValue(), osmWay);
osmWay.setTag("maxspeed", "120");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, UNCHANGED.getValue(), osmWay);
osmWay.setTag("highway", "motorway");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID.getValue(), osmWay);
osmWay.setTag("tunnel", "yes");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "motorway");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("maxspeed", "80");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "motorway");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("maxspeed", "120");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "notdefined");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("maxspeed", "120");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "notdefined");
osmWay.setTag("maxspeed", "50");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, UNCHANGED.getValue(), osmWay);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class WheelchairFlagEncoderTest method testPier.
@Test
public void testPier() {
ReaderWay way = new ReaderWay(1);
way.setTag("man_made", "pier");
IntsRef flags = wheelchairEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertFalse(flags.isEmpty());
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class WheelchairFlagEncoderTest method testSurfaces.
@Test
public void testSurfaces() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "footway");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("surface", "cobblestone");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("surface", "sand");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("surface", "gravel");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("surface", "asphalt");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "service");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("surface", "sand");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("sidewalk", "left");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("sidewalk:left:surface", "cobblestone");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class WheelchairFlagEncoderTest method testAccess.
@Test
public void testAccess() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "motorway");
way.setTag("sidewalk", "yes");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("sidewalk", "left");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("sidewalk", "none");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("sidewalk", "left");
way.setTag("access", "private");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "pedestrian");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("highway", "footway");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("highway", "platform");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("highway", "motorway");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("bicycle", "official");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("foot", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("foot", "official");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "service");
way.setTag("access", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("foot", "yes");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "service");
way.setTag("vehicle", "no");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("foot", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("motorroad", "yes");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "cycleway");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("foot", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("access", "yes");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "service");
way.setTag("foot", "yes");
way.setTag("access", "no");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "track");
way.setTag("ford", "yes");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("route", "ferry");
assertTrue(wheelchairEncoder.getAccess(way).isFerry());
way.setTag("foot", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
// #1562, test if ferry route with foot
way.clearTags();
way.setTag("route", "ferry");
way.setTag("foot", "yes");
assertTrue(wheelchairEncoder.getAccess(way).isFerry());
way.setTag("foot", "designated");
assertTrue(wheelchairEncoder.getAccess(way).isFerry());
way.setTag("foot", "official");
assertTrue(wheelchairEncoder.getAccess(way).isFerry());
way.setTag("foot", "permissive");
assertTrue(wheelchairEncoder.getAccess(way).isFerry());
way.setTag("foot", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("foot", "designated");
way.setTag("access", "private");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
DateFormat simpleDateFormat = Helper.createFormatter("yyyy MMM dd");
way.clearTags();
way.setTag("highway", "footway");
way.setTag("access:conditional", "no @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "footway");
way.setTag("access", "no");
way.setTag("access:conditional", "yes @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "steps");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
// allow paths as they are used as generic path
way.setTag("highway", "path");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "track");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("sac_scale", "hiking");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "footway");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("incline", "up");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("incline", "3%");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("incline", "9.1%");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("incline", "1°");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("incline", "5°");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("incline", "-4%");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("incline", "-9%");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("incline", "-3°");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("incline", "-6.5°");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.clearTags();
way.setTag("highway", "footway");
way.setTag("wheelchair", "no");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("wheelchair", "limited");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.clearTags();
way.setTag("highway", "footway");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("kerb", "lowered");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("kerb", "raised");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("kerb", "2cm");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
way.setTag("kerb", "4cm");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("kerb", "20mm");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
// highway tag required
way.clearTags();
way.setTag("wheelchair", "yes");
assertTrue(wheelchairEncoder.getAccess(way).canSkip());
way.setTag("highway", "footway");
assertTrue(wheelchairEncoder.getAccess(way).isWay());
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class WheelchairFlagEncoderTest method testPriority.
@Test
public void testPriority() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "cycleway");
assertEquals(PriorityCode.UNCHANGED.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("highway", "primary");
assertEquals(PriorityCode.AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("highway", "secondary");
assertEquals(PriorityCode.AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("highway", "track");
way.setTag("bicycle", "official");
assertEquals(PriorityCode.SLIGHT_AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("highway", "track");
way.setTag("bicycle", "designated");
assertEquals(PriorityCode.SLIGHT_AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("highway", "cycleway");
way.setTag("bicycle", "designated");
way.setTag("foot", "designated");
assertEquals(PriorityCode.PREFER.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "primary");
way.setTag("sidewalk", "yes");
assertEquals(PriorityCode.UNCHANGED.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "cycleway");
way.setTag("sidewalk", "no");
assertEquals(PriorityCode.UNCHANGED.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "road");
way.setTag("bicycle", "official");
way.setTag("sidewalk", "no");
assertEquals(PriorityCode.SLIGHT_AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "trunk");
way.setTag("sidewalk", "no");
assertEquals(PriorityCode.AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("sidewalk", "none");
assertEquals(PriorityCode.AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "residential");
way.setTag("sidewalk", "yes");
assertEquals(PriorityCode.PREFER.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "footway");
assertEquals(PriorityCode.PREFER.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("wheelchair", "designated");
assertEquals(PriorityCode.VERY_NICE.getValue(), wheelchairEncoder.handlePriority(way, null));
way.clearTags();
way.setTag("highway", "footway");
assertEquals(PriorityCode.PREFER.getValue(), wheelchairEncoder.handlePriority(way, null));
way.setTag("wheelchair", "limited");
assertEquals(PriorityCode.AVOID.getValue(), wheelchairEncoder.handlePriority(way, null));
}
Aggregations