Search in sources :

Example 96 with ReaderWay

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);
}
Also used : DataFlagEncoder(com.graphhopper.routing.util.DataFlagEncoder) EncodingManager(com.graphhopper.routing.util.EncodingManager) HintsMap(com.graphhopper.routing.util.HintsMap) Graph(com.graphhopper.storage.Graph) EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) GraphBuilder(com.graphhopper.storage.GraphBuilder) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 97 with ReaderWay

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);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 98 with ReaderWay

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);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 99 with ReaderWay

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);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 100 with ReaderWay

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);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)157 Test (org.junit.jupiter.api.Test)119 IntsRef (com.graphhopper.storage.IntsRef)67 Test (org.junit.Test)24 EncodingManager (com.graphhopper.routing.util.EncodingManager)9 GraphBuilder (com.graphhopper.storage.GraphBuilder)9 ReaderRelation (com.graphhopper.reader.ReaderRelation)8 ConditionalTagInspector (com.graphhopper.reader.ConditionalTagInspector)7 Graph (com.graphhopper.storage.Graph)7 DateFormat (java.text.DateFormat)6 Date (java.util.Date)6 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)5 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)5 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)4 PMap (com.graphhopper.util.PMap)4 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)3 DataFlagEncoder (com.graphhopper.routing.util.DataFlagEncoder)3 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 LongIndexedContainer (com.carrotsearch.hppc.LongIndexedContainer)2