Search in sources :

Example 1 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class PathTest method generatePathDetailsGraph.

private Graph generatePathDetailsGraph() {
    final Graph graph = new GraphBuilder(carManager).create();
    final NodeAccess na = graph.getNodeAccess();
    na.setNode(1, 52.514, 13.348);
    na.setNode(2, 52.514, 13.349);
    na.setNode(3, 52.514, 13.350);
    na.setNode(4, 52.515, 13.349);
    na.setNode(5, 52.516, 13.3452);
    na.setNode(6, 52.516, 13.344);
    ReaderWay w = new ReaderWay(1);
    w.setTag("highway", "tertiary");
    w.setTag("maxspeed", "50");
    EdgeIteratorState tmpEdge;
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(5)).setName("1-2");
    assertNotEquals(EncodingManager.Access.CAN_SKIP, ((AbstractFlagEncoder) encoder).getAccess(w));
    IntsRef relFlags = carManager.createRelationFlags();
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(4, 5).setDistance(5)).setName("4-5");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    w.setTag("maxspeed", "100");
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(2, 3).setDistance(5)).setName("2-3");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    w.setTag("maxspeed", "10");
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(3, 4).setDistance(10)).setName("3-4");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(5, 6).setDistance(0.01)).setName("3-4");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    return graph;
}
Also used : NodeAccess(com.graphhopper.storage.NodeAccess) Graph(com.graphhopper.storage.Graph) GraphBuilder(com.graphhopper.storage.GraphBuilder) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef)

Example 2 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class IntEncodedValueImplTest method testInvalidReverseAccess.

@Test
public void testInvalidReverseAccess() {
    IntEncodedValue prop = new IntEncodedValueImpl("test", 10, false);
    prop.init(new EncodedValue.InitializerConfig());
    try {
        prop.setInt(true, new IntsRef(1), -1);
        fail();
    } catch (Exception ex) {
    }
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 3 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class IntEncodedValueImplTest method padding.

@Test
public void padding() {
    IntEncodedValue prop = new IntEncodedValueImpl("test", 30, true);
    prop.init(new EncodedValue.InitializerConfig());
    IntsRef ref = new IntsRef(2);
    prop.setInt(false, ref, 10);
    prop.setInt(true, ref, 20);
    assertEquals(10, prop.getInt(false, ref));
    assertEquals(20, prop.getInt(true, ref));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 4 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class IntEncodedValueImplTest method multiIntsUsage.

@Test
public void multiIntsUsage() {
    IntEncodedValue prop = new IntEncodedValueImpl("test", 31, true);
    prop.init(new EncodedValue.InitializerConfig());
    IntsRef ref = new IntsRef(2);
    prop.setInt(false, ref, 10);
    prop.setInt(true, ref, 20);
    assertEquals(10, prop.getInt(false, ref));
    assertEquals(20, prop.getInt(true, ref));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 5 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class IntEncodedValueImplTest method testSignedInt2.

@Test
public void testSignedInt2() {
    IntEncodedValue prop = new IntEncodedValueImpl("test", 31, false);
    EncodedValue.InitializerConfig config = new EncodedValue.InitializerConfig();
    prop.init(config);
    IntsRef ref = new IntsRef(1);
    prop.setInt(false, ref, Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, prop.getInt(false, ref));
    Exception exception = assertThrows(IllegalArgumentException.class, () -> {
        prop.setInt(false, ref, -5);
    });
    assertTrue(exception.getMessage().contains("test value too small for encoding"), exception.getMessage());
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Aggregations

IntsRef (com.graphhopper.storage.IntsRef)108 Test (org.junit.jupiter.api.Test)96 ReaderWay (com.graphhopper.reader.ReaderWay)67 ReaderRelation (com.graphhopper.reader.ReaderRelation)7 GraphBuilder (com.graphhopper.storage.GraphBuilder)7 EncodingManager (com.graphhopper.routing.util.EncodingManager)5 Graph (com.graphhopper.storage.Graph)5 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)4 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)4 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)3 NodeAccess (com.graphhopper.storage.NodeAccess)3 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)2 RoadEnvironment (com.graphhopper.routing.ev.RoadEnvironment)2 VirtualEdgeIteratorState (com.graphhopper.routing.querygraph.VirtualEdgeIteratorState)2 TransportationMode (com.graphhopper.routing.util.TransportationMode)2 CountryRule (com.graphhopper.routing.util.countryrules.CountryRule)2 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)2 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)2 PMap (com.graphhopper.util.PMap)2 PointList (com.graphhopper.util.PointList)2