use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testSort.
@Test
public void testSort() {
GraphHopper hopper = new GraphHopperFacade(file1).setSortGraph(true).importOrLoad();
NodeAccess na = hopper.getGraphHopperStorage().getNodeAccess();
assertEquals(10, na.getLongitude(findID(hopper.getLocationIndex(), 49, 10)), 1e-3);
assertEquals(51.249, na.getLatitude(findID(hopper.getLocationIndex(), 51.2492152, 9.4317166)), 1e-3);
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testCrossBoundary_issue667.
@Test
public void testCrossBoundary_issue667() {
GraphHopper hopper = new GraphHopperFacade("test-osm-waterway.xml").importOrLoad();
QueryResult qr = hopper.getLocationIndex().findClosest(0.1, 179.5, EdgeFilter.ALL_EDGES);
assertTrue(qr.isValid());
assertEquals(0.1, qr.getSnappedPoint().lat, 0.1);
assertEquals(179.5, qr.getSnappedPoint().lon, 0.1);
assertEquals(11, qr.getClosestEdge().getDistance() / 1000, 1);
qr = hopper.getLocationIndex().findClosest(0.1, -179.6, EdgeFilter.ALL_EDGES);
assertTrue(qr.isValid());
assertEquals(0.1, qr.getSnappedPoint().lat, 0.1);
assertEquals(-179.6, qr.getSnappedPoint().lon, 0.1);
assertEquals(56, qr.getClosestEdge().getDistance() / 1000, 1);
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testNegativeIds.
@Test
public void testNegativeIds() {
GraphHopper hopper = new GraphHopperFacade(fileNegIds).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
assertEquals(4, graph.getNodes());
int n20 = AbstractGraphStorageTester.getIdOf(graph, 52);
int n10 = AbstractGraphStorageTester.getIdOf(graph, 51.2492152);
int n30 = AbstractGraphStorageTester.getIdOf(graph, 51.2);
assertEquals(GHUtility.asSet(n20), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n10)));
assertEquals(3, GHUtility.count(carOutExplorer.setBaseNode(n20)));
assertEquals(GHUtility.asSet(n20), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n30)));
EdgeIterator iter = carOutExplorer.setBaseNode(n20);
assertTrue(iter.next());
assertTrue(iter.next());
assertEquals(n30, iter.getAdjNode());
assertEquals(93147, iter.getDistance(), 1);
assertTrue(iter.next());
assertEquals(n10, iter.getAdjNode());
assertEquals(88643, iter.getDistance(), 1);
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testReadEleFromCustomOSM.
@Test
public void testReadEleFromCustomOSM() {
GraphHopper hopper = new GraphHopperFacade("custom-osm-ele.xml") {
@Override
protected DataReader createReader(GraphHopperStorage tmpGraph) {
return initDataReader(new OSMReader(tmpGraph) {
@Override
protected double getElevation(ReaderNode node) {
return node.getEle();
}
});
}
}.setElevation(true).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
int n20 = AbstractGraphStorageTester.getIdOf(graph, 52);
int n50 = AbstractGraphStorageTester.getIdOf(graph, 49);
EdgeIteratorState edge = GHUtility.getEdge(graph, n20, n50);
assertEquals(Helper.createPointList3D(52, 9, -10, 51.25, 9.43, 100, 49, 10, -30), edge.fetchWayGeometry(3));
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testFoot.
@Test
public void testFoot() {
GraphHopper hopper = new GraphHopperFacade(file3).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
int n10 = AbstractGraphStorageTester.getIdOf(graph, 11.1);
int n20 = AbstractGraphStorageTester.getIdOf(graph, 12);
int n30 = AbstractGraphStorageTester.getIdOf(graph, 11.2);
int n40 = AbstractGraphStorageTester.getIdOf(graph, 11.3);
int n50 = AbstractGraphStorageTester.getIdOf(graph, 10);
assertEquals(GHUtility.asSet(n20, n40), GHUtility.getNeighbors(carAllExplorer.setBaseNode(n10)));
assertEquals(GHUtility.asSet(), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n30)));
assertEquals(GHUtility.asSet(n10, n30, n40), GHUtility.getNeighbors(carAllExplorer.setBaseNode(n20)));
assertEquals(GHUtility.asSet(n30, n40), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n20)));
EdgeExplorer footOutExplorer = graph.createEdgeExplorer(new DefaultEdgeFilter(footEncoder, false, true));
assertEquals(GHUtility.asSet(n20, n50), GHUtility.getNeighbors(footOutExplorer.setBaseNode(n10)));
assertEquals(GHUtility.asSet(n20, n50), GHUtility.getNeighbors(footOutExplorer.setBaseNode(n30)));
assertEquals(GHUtility.asSet(n10, n30), GHUtility.getNeighbors(footOutExplorer.setBaseNode(n20)));
}
Aggregations