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;
}
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) {
}
}
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));
}
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));
}
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());
}
Aggregations