use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class DataFlagEncoderTest method testHighway.
@Test
public void testHighway() {
ReaderWay osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("surface", "sand");
osmWay.setTag("tunnel", "yes");
long flags = encoder.handleWayTags(osmWay, 1, 0);
EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertEquals("primary", encoder.getHighwayAsString(edge));
assertEquals("sand", encoder.getSurfaceAsString(edge));
assertEquals("tunnel", encoder.getTransportModeAsString(edge));
assertTrue(encoder.isForward(edge, motorVehicleInt));
assertTrue(encoder.isBackward(edge, motorVehicleInt));
osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("oneway", "yes");
flags = encoder.handleWayTags(osmWay, 1, 0);
edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertTrue(encoder.isForward(edge, motorVehicleInt));
assertFalse(encoder.isBackward(edge, motorVehicleInt));
osmWay = new ReaderWay(0);
osmWay.setTag("highway", "unknownX");
flags = encoder.handleWayTags(osmWay, 1, 0);
edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertEquals("_default", encoder.getHighwayAsString(edge));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class DataFlagEncoderTest method testTunnel.
@Test
public void testTunnel() {
ReaderWay osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("tunnel", "yes");
long flags = encoder.handleWayTags(osmWay, 1, 0);
EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertEquals("primary", encoder.getHighwayAsString(edge));
assertEquals("tunnel", encoder.getTransportModeAsString(edge));
assertTrue(encoder.isTransportModeTunnel(edge));
assertFalse(encoder.isTransportModeBridge(edge));
osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("bridge", "yes");
flags = encoder.handleWayTags(osmWay, 1, 0);
edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertEquals("bridge", encoder.getTransportModeAsString(edge));
assertFalse(encoder.isTransportModeTunnel(edge));
assertTrue(encoder.isTransportModeBridge(edge));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class DataFlagEncoderTest method testLargeMaxspeed.
@Test
public void testLargeMaxspeed() {
ReaderWay osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("maxspeed", "145");
long flags = encoder.handleWayTags(osmWay, 1, 0);
EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("maxspeed", "1000");
flags = encoder.handleWayTags(osmWay, 1, 0);
edge = GHUtility.createMockedEdgeIteratorState(0, flags);
assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
assertEquals(140, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class AbstractBikeFlagEncoderTester method testHandleCommonWayTags.
@Test
public void testHandleCommonWayTags() {
ReaderWay way = new ReaderWay(1);
String wayType;
way.setTag("highway", "steps");
wayType = getWayTypeFromFlags(way);
assertEquals("get off the bike", wayType);
way.setTag("highway", "footway");
wayType = getWayTypeFromFlags(way);
assertEquals("get off the bike", wayType);
way.setTag("highway", "footway");
way.setTag("surface", "pebblestone");
wayType = getWayTypeFromFlags(way);
assertEquals("get off the bike", wayType);
way.setTag("highway", "residential");
wayType = getWayTypeFromFlags(way);
assertEquals("", wayType);
assertPriority(PREFER.getValue(), way);
way.clearTags();
way.setTag("highway", "residential");
way.setTag("bicycle", "yes");
wayType = getWayTypeFromFlags(way);
assertEquals("", wayType);
way.clearTags();
way.setTag("highway", "residential");
way.setTag("bicycle", "designated");
wayType = getWayTypeFromFlags(way);
assertEquals("", wayType);
way.clearTags();
way.setTag("highway", "track");
way.setTag("bicycle", "designated");
wayType = getWayTypeFromFlags(way);
assertEquals("cycleway, unpaved", wayType);
way.clearTags();
way.setTag("highway", "cycleway");
wayType = getWayTypeFromFlags(way);
assertEquals("cycleway", wayType);
assertPriority(VERY_NICE.getValue(), way);
way.setTag("surface", "grass");
wayType = getWayTypeFromFlags(way);
assertEquals("cycleway, unpaved", wayType);
way.setTag("surface", "asphalt");
wayType = getWayTypeFromFlags(way);
assertEquals("cycleway", wayType);
assertPriority(VERY_NICE.getValue(), way);
way.setTag("highway", "footway");
way.setTag("bicycle", "yes");
way.setTag("surface", "grass");
wayType = getWayTypeFromFlags(way);
assertEquals("small way, unpaved", wayType);
way.setTag("bicycle", "designated");
wayType = getWayTypeFromFlags(way);
assertEquals("cycleway, unpaved", wayType);
way.clearTags();
way.setTag("highway", "footway");
way.setTag("bicycle", "yes");
way.setTag("surface", "grass");
wayType = getWayTypeFromFlags(way);
assertEquals("small way, unpaved", wayType);
way.clearTags();
way.setTag("railway", "platform");
wayType = getWayTypeFromFlags(way);
assertEquals("get off the bike", wayType);
way.clearTags();
way.setTag("highway", "track");
way.setTag("railway", "platform");
wayType = getWayTypeFromFlags(way);
assertEquals("get off the bike, unpaved", wayType);
way.clearTags();
way.setTag("highway", "secondary");
way.setTag("bicycle", "dismount");
wayType = getWayTypeFromFlags(way);
assertEquals("get off the bike", wayType);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class BikeFlagEncoderTest method testGetSpeed.
@Test
public void testGetSpeed() {
long result = encoder.setProperties(10, true, true);
assertEquals(10, encoder.getSpeed(result), 1e-1);
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "primary");
assertEquals(18, encoder.getSpeed(way));
assertPriority(REACH_DEST.getValue(), way);
way.setTag("scenic", "yes");
assertEquals(18, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.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(AVOID_IF_POSSIBLE.getValue(), way);
// Use pushing section irrespective of the pavement
way.setTag("surface", "paved");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
way.clearTags();
way.setTag("highway", "secondary");
way.setTag("bicycle", "dismount");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(REACH_DEST.getValue(), way);
way.clearTags();
way.setTag("highway", "footway");
way.setTag("bicycle", "yes");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "no");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.clearTags();
way.setTag("highway", "footway");
way.setTag("surface", "paved");
way.setTag("bicycle", "yes");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(PUSHING_SECTION_SPEED * 2, 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(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("segregated", "yes");
assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
assertPriority(PREFER.getValue(), way);
way.setTag("surface", "unpaved");
assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
way.setTag("surface", "paved");
assertEquals(PUSHING_SECTION_SPEED * 2, encoder.getSpeed(way));
way.clearTags();
way.setTag("highway", "path");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
// use pushing section
way.clearTags();
way.setTag("highway", "path");
way.setTag("surface", "paved");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
way.clearTags();
way.setTag("highway", "path");
way.setTag("surface", "ground");
assertEquals(PUSHING_SECTION_SPEED, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.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", "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(AVOID_IF_POSSIBLE.getValue(), way);
way.clearTags();
way.setTag("highway", "steps");
way.setTag("surface", "wood");
assertEquals(PUSHING_SECTION_SPEED / 2, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
way.setTag("maxspeed", "20");
assertEquals(PUSHING_SECTION_SPEED / 2, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.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(4, encoder.getSpeed(way));
assertPriority(AVOID_IF_POSSIBLE.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));
}
Aggregations