Search in sources :

Example 31 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class AbstractBikeFlagEncoderTester method testTramStations.

@Test
public void testTramStations() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "rail");
    assertTrue(encoder.getAccess(way).isWay());
    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "station");
    assertTrue(encoder.getAccess(way).isWay());
    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "station");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("bicycle", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way = new ReaderWay(1);
    way.setTag("railway", "platform");
    IntsRef flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertNotEquals(true, flags.isEmpty());
    way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("railway", "platform");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertNotEquals(true, flags.isEmpty());
    way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("railway", "platform");
    way.setTag("bicycle", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(true, flags.isEmpty());
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 32 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class Bike2WeightFlagEncoderTest method testApplyWayTags.

@Test
public void testApplyWayTags() {
    Graph graph = initExampleGraph();
    EdgeIteratorState edge = GHUtility.getEdge(graph, 0, 1);
    ReaderWay way = new ReaderWay(1);
    encoder.applyWayTags(way, edge);
    IntsRef flags = edge.getFlags();
    // decrease speed
    assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // increase speed but use maximum speed (calculated was 24)
    assertEquals(18, avgSpeedEnc.getDecimal(true, flags), 1e-1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 33 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class Bike2WeightFlagEncoderTest method testRoutingFailsWithInvalidGraph_issue665.

@Test
public void testRoutingFailsWithInvalidGraph_issue665() {
    GraphHopperStorage graph = new GraphBuilder(encodingManager).set3D(true).create();
    ReaderWay way = new ReaderWay(0);
    way.setTag("route", "ferry");
    assertNotEquals(EncodingManager.Access.CAN_SKIP, encoder.getAccess(way));
    IntsRef wayFlags = encodingManager.handleWayTags(way, encodingManager.createRelationFlags());
    graph.edge(0, 1).setDistance(247).setFlags(wayFlags);
    assertTrue(isGraphValid(graph, encoder));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 34 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class DecimalEncodedValueTest method testMaxValue.

@Test
public void testMaxValue() {
    CarFlagEncoder carEncoder = new CarFlagEncoder(10, 0.5, 0);
    EncodingManager em = EncodingManager.create(carEncoder);
    DecimalEncodedValue carAverageSpeedEnc = em.getDecimalEncodedValue(EncodingManager.getKey(carEncoder, "average_speed"));
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway_link");
    way.setTag("maxspeed", "70 mph");
    IntsRef flags = carEncoder.handleWayTags(em.createEdgeFlags(), way);
    assertEquals(101.5, carAverageSpeedEnc.getDecimal(true, flags), 1e-1);
    DecimalEncodedValue instance1 = new DecimalEncodedValueImpl("test1", 8, 0.5, false);
    instance1.init(new EncodedValue.InitializerConfig());
    flags = em.createEdgeFlags();
    instance1.setDecimal(false, flags, 100d);
    assertEquals(100, instance1.getDecimal(false, flags), 1e-1);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Test(org.junit.jupiter.api.Test)

Example 35 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class EncodingManagerTest method testSharedEncodedValues.

@Test
public void testSharedEncodedValues() {
    EncodingManager manager = EncodingManager.create("car,foot,bike,motorcycle,mtb");
    for (FlagEncoder tmp : manager.fetchEdgeEncoders()) {
        AbstractFlagEncoder encoder = (AbstractFlagEncoder) tmp;
        BooleanEncodedValue accessEnc = encoder.getAccessEnc();
        BooleanEncodedValue roundaboutEnc = manager.getBooleanEncodedValue(Roundabout.KEY);
        ReaderWay way = new ReaderWay(1);
        way.setTag("highway", "primary");
        way.setTag("junction", "roundabout");
        IntsRef edgeFlags = manager.handleWayTags(way, manager.createRelationFlags());
        assertTrue(accessEnc.getBool(false, edgeFlags));
        if (!encoder.getName().equals("foot"))
            assertFalse(accessEnc.getBool(true, edgeFlags), encoder.getName());
        assertTrue(roundaboutEnc.getBool(false, edgeFlags), encoder.getName());
        way.clearTags();
        way.setTag("highway", "tertiary");
        way.setTag("junction", "circular");
        edgeFlags = manager.handleWayTags(way, manager.createRelationFlags());
        assertTrue(accessEnc.getBool(false, edgeFlags));
        if (!encoder.getName().equals("foot"))
            assertFalse(accessEnc.getBool(true, edgeFlags), encoder.getName());
        assertTrue(roundaboutEnc.getBool(false, edgeFlags), encoder.getName());
    }
}
Also used : BooleanEncodedValue(com.graphhopper.routing.ev.BooleanEncodedValue) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) 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