use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class NameIndexTest method testFlush.
@Test
public void testFlush() {
String location = "./target/nameindex-store";
Helper.removeDir(new File(location));
NameIndex index = new NameIndex(new RAMDirectory(location, true).create()).create(1000);
long pointer = index.put("test");
index.flush();
index.close();
index = new NameIndex(new RAMDirectory(location, true));
assertTrue(index.loadExisting());
assertEquals("test", index.get(pointer));
// make sure bytePointer is correctly set after loadExisting
long newPointer = index.put("testing");
assertEquals(newPointer + ">" + pointer, pointer + "test".getBytes().length + 1, newPointer);
index.close();
Helper.removeDir(new File(location));
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class AlternativeRouteTest method createTestGraph.
public GraphHopperStorage createTestGraph(boolean fullGraph, EncodingManager tmpEM) {
GraphHopperStorage graph = new GraphHopperStorage(new RAMDirectory(), tmpEM, false, new GraphExtension.NoOpExtension());
graph.create(1000);
/* 9
_/\
1 2-3-4-10
\ / \
5--6-7---8
*/
graph.edge(1, 9, 1, true);
graph.edge(9, 2, 1, true);
if (fullGraph)
graph.edge(2, 3, 1, true);
graph.edge(3, 4, 1, true);
graph.edge(4, 10, 1, true);
graph.edge(5, 6, 1, true);
graph.edge(6, 7, 1, true);
graph.edge(7, 8, 1, true);
if (fullGraph)
graph.edge(1, 5, 2, true);
graph.edge(6, 3, 1, true);
graph.edge(4, 8, 1, true);
updateDistancesFor(graph, 5, 0.00, 0.05);
updateDistancesFor(graph, 6, 0.00, 0.10);
updateDistancesFor(graph, 7, 0.00, 0.15);
updateDistancesFor(graph, 8, 0.00, 0.25);
updateDistancesFor(graph, 1, 0.05, 0.00);
updateDistancesFor(graph, 9, 0.10, 0.05);
updateDistancesFor(graph, 2, 0.05, 0.10);
updateDistancesFor(graph, 3, 0.05, 0.15);
updateDistancesFor(graph, 4, 0.05, 0.25);
updateDistancesFor(graph, 10, 0.05, 0.30);
return graph;
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class SubnetworkStorageTest method testSimple.
@Test
public void testSimple() {
SubnetworkStorage storage = new SubnetworkStorage(new RAMDirectory(), "fastest");
storage.create(2000);
storage.setSubnetwork(1, 88);
assertEquals(88, storage.getSubnetwork(1));
assertEquals(0, storage.getSubnetwork(0));
storage.close();
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class RoundTripRoutingTemplateTest method testCalcRoundTrip.
@Test
public void testCalcRoundTrip() throws Exception {
Weighting weighting = new FastestWeighting(carFE);
Graph g = createTestGraph(true);
RoundTripRoutingTemplate rTripRouting = new RoundTripRoutingTemplate(new GHRequest(), new GHResponse(), null, 1);
LocationIndex locationIndex = new LocationIndexTree(g, new RAMDirectory()).prepareIndex();
QueryResult qr4 = locationIndex.findClosest(0.05, 0.25, EdgeFilter.ALL_EDGES);
assertEquals(4, qr4.getClosestNode());
QueryResult qr5 = locationIndex.findClosest(0.00, 0.05, EdgeFilter.ALL_EDGES);
assertEquals(5, qr5.getClosestNode());
QueryResult qr6 = locationIndex.findClosest(0.00, 0.10, EdgeFilter.ALL_EDGES);
assertEquals(6, qr6.getClosestNode());
QueryGraph qGraph = new QueryGraph(g);
qGraph.lookup(qr4, qr5);
rTripRouting.setQueryResults(Arrays.asList(qr5, qr4, qr5));
List<Path> paths = rTripRouting.calcPaths(qGraph, new RoutingAlgorithmFactorySimple(), new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode));
assertEquals(2, paths.size());
assertEquals(Helper.createTList(5, 6, 3, 4), paths.get(0).calcNodes());
assertEquals(Helper.createTList(4, 8, 7, 6, 5), paths.get(1).calcNodes());
qGraph = new QueryGraph(g);
qGraph.lookup(qr4, qr6);
rTripRouting.setQueryResults(Arrays.asList(qr6, qr4, qr6));
paths = rTripRouting.calcPaths(qGraph, new RoutingAlgorithmFactorySimple(), new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode));
assertEquals(2, paths.size());
assertEquals(Helper.createTList(6, 3, 4), paths.get(0).calcNodes());
assertEquals(Helper.createTList(4, 8, 7, 6), paths.get(1).calcNodes());
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class AbstractEdgeElevationInterpolatorTest method setUp.
@SuppressWarnings("resource")
@Before
public void setUp() {
dataFlagEncoder = new DataFlagEncoder();
graph = new GraphHopperStorage(new RAMDirectory(), new EncodingManager(Arrays.asList(dataFlagEncoder, new FootFlagEncoder()), 8), true, new GraphExtension.NoOpExtension()).create(100);
edgeElevationInterpolator = createEdgeElevationInterpolator();
interpolatableWay = createInterpolatableWay();
normalWay = new ReaderWay(0);
normalWay.setTag("highway", "primary");
}
Aggregations