use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class GenericWeightingTest method testDisabledRoadAttributes.
@Test
public void testDisabledRoadAttributes() {
DataFlagEncoder simpleEncoder = new DataFlagEncoder();
EncodingManager simpleEncodingManager = new EncodingManager(simpleEncoder);
Graph simpleGraph = new GraphBuilder(simpleEncodingManager).create();
ReaderWay way = new ReaderWay(27l);
way.setTag("highway", "primary");
way.setTag("maxspeed", "10");
way.setTag("maxheight", "4.4");
// 0-1
simpleGraph.edge(0, 1, 1, true);
AbstractRoutingAlgorithmTester.updateDistancesFor(simpleGraph, 0, 0.00, 0.00);
AbstractRoutingAlgorithmTester.updateDistancesFor(simpleGraph, 1, 0.01, 0.01);
simpleGraph.getEdgeIteratorState(0, 1).setFlags(simpleEncoder.handleWayTags(way, 1, 0));
Weighting instance = new GenericWeighting(simpleEncoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 5.0));
EdgeIteratorState edge = simpleGraph.getEdgeIteratorState(0, 1);
assertEquals(edgeWeight, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testAvoidTunnel.
@Test
@Override
public void testAvoidTunnel() {
// tunnel is not that bad for racing bike
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "residential");
osmWay.setTag("tunnel", "yes");
assertPriority(UNCHANGED.getValue(), osmWay);
osmWay.setTag("highway", "secondary");
osmWay.setTag("tunnel", "yes");
assertPriority(UNCHANGED.getValue(), osmWay);
osmWay.setTag("bicycle", "designated");
assertPriority(PREFER.getValue(), osmWay);
}
use of com.graphhopper.reader.ReaderWay 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.reader.ReaderWay in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testSmoothness.
@Test
public void testSmoothness() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "residential");
assertEquals(16, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "excellent");
assertEquals(20, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "bad");
assertEquals(12, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "impassable");
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "unknown");
assertEquals(12, getSpeedFromFlags(way), 0.01);
way.clearTags();
way.setTag("highway", "residential");
way.setTag("surface", "ground");
assertEquals(2, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "bad");
assertEquals(2, getSpeedFromFlags(way), 0.01);
way.clearTags();
way.setTag("highway", "track");
way.setTag("tracktype", "grade5");
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "bad");
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 0.01);
way.setTag("smoothness", "impassable");
assertEquals(PUSHING_SECTION_SPEED, getSpeedFromFlags(way), 0.01);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testService.
@Test
@Override
public void testService() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "service");
assertEquals(12, encoder.getSpeed(way));
assertPriority(UNCHANGED.getValue(), way);
way.setTag("service", "parking_aisle");
assertEquals(6, encoder.getSpeed(way));
assertPriority(SLIGHT_AVOID.getValue(), way);
}
Aggregations