use of com.graphhopper.storage.Graph in project graphhopper by graphhopper.
the class AlternativeRouteTest method testDisconnectedAreas.
@Test
public void testDisconnectedAreas() {
Graph g = createTestGraph(true, em);
// one single disconnected node
updateDistancesFor(g, 20, 0.00, -0.01);
Weighting weighting = new FastestWeighting(carFE);
AlternativeBidirSearch altDijkstra = new AlternativeBidirSearch(g, weighting, traversalMode, 1);
Path path = altDijkstra.calcPath(1, 20);
assertFalse(path.isFound());
// make sure not the full graph is traversed!
assertEquals(3, altDijkstra.getVisitedNodes());
}
use of com.graphhopper.storage.Graph in project graphhopper by graphhopper.
the class PrinctonReaderTest method testRead.
@Test
public void testRead() {
Graph graph = new GraphBuilder(encodingManager).create();
new PrinctonReader(graph).setStream(PrinctonReader.class.getResourceAsStream("tinyEWD.txt")).read();
assertEquals(8, graph.getNodes());
EdgeExplorer explorer = graph.createEdgeExplorer(carOutEdges);
assertEquals(2, count(explorer.setBaseNode(0)));
assertEquals(3, count(explorer.setBaseNode(6)));
}
use of com.graphhopper.storage.Graph in project graphhopper by graphhopper.
the class LocationIndexTreeTest method testFindingWayGeometry.
@Test
public void testFindingWayGeometry() {
Graph g = createGHStorage(encodingManager);
NodeAccess na = g.getNodeAccess();
na.setNode(10, 51.2492152, 9.4317166);
na.setNode(20, 52, 9);
na.setNode(30, 51.2, 9.4);
na.setNode(50, 49, 10);
g.edge(20, 50, 1, true).setWayGeometry(Helper.createPointList(51.25, 9.43));
g.edge(10, 20, 1, true);
g.edge(20, 30, 1, true);
LocationIndex index = createIndex(g, 2000);
assertEquals(20, findID(index, 51.25, 9.43));
}
use of com.graphhopper.storage.Graph in project graphhopper by graphhopper.
the class LocationIndexTreeTest method testRMin.
@Test
public void testRMin() {
Graph graph = createTestGraph(encodingManager);
LocationIndexTree index = createIndex(graph, 50000);
//query: 0.05 | -0.3
DistanceCalc distCalc = new DistancePlaneProjection();
double rmin = index.calculateRMin(0.05, -0.3);
double check = distCalc.calcDist(0.05, Math.abs(graph.getNodeAccess().getLon(2)) - index.getDeltaLon(), -0.3, -0.3);
assertTrue((rmin - check) < 0.0001);
double rmin2 = index.calculateRMin(0.05, -0.3, 1);
double check2 = distCalc.calcDist(0.05, Math.abs(graph.getNodeAccess().getLat(0)), -0.3, -0.3);
assertTrue((rmin2 - check2) < 0.0001);
GHIntHashSet points = new GHIntHashSet();
assertEquals(Double.MAX_VALUE, index.calcMinDistance(0.05, -0.3, points), 1e-1);
points.add(0);
points.add(1);
assertEquals(54757.03, index.calcMinDistance(0.05, -0.3, points), 1e-1);
/*GraphVisualizer gv = new GraphVisualizer(graph, index.getDeltaLat(), index.getDeltaLon(), index.getCenter(0, 0).lat, index.getCenter(0, 0).lon);
try {
Thread.sleep(4000);
} catch(InterruptedException ie) {}*/
}
use of com.graphhopper.storage.Graph in project graphhopper by graphhopper.
the class LocationIndexTreeTest method testWayGeometry.
@Test
public void testWayGeometry() {
Graph g = createTestGraphWithWayGeometry();
LocationIndex index = createIndex(g, -1);
assertEquals(1, findID(index, 0, 0));
assertEquals(1, findID(index, 0, 0.1));
assertEquals(1, findID(index, 0.1, 0.1));
assertEquals(1, findID(index, -0.5, -0.5));
}
Aggregations