use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testDoNotRejectEdgeIfFirstNodeIsMissing_issue2221.
@Test
public void testDoNotRejectEdgeIfFirstNodeIsMissing_issue2221() {
GraphHopper hopper = new GraphHopperFacade("test-osm9.xml").importOrLoad();
GraphHopperStorage graph = hopper.getGraphHopperStorage();
assertEquals(2, graph.getNodes());
assertEquals(1, graph.getEdges());
AllEdgesIterator iter = graph.getAllEdges();
iter.next();
assertEquals(0, iter.getBaseNode());
assertEquals(1, iter.getAdjNode());
assertEquals(51.21, graph.getNodeAccess().getLat(0), 1.e-3);
assertEquals(9.41, graph.getNodeAccess().getLon(0), 1.e-3);
assertEquals(51.22, graph.getNodeAccess().getLat(1), 1.e-3);
assertEquals(9.42, graph.getNodeAccess().getLon(1), 1.e-3);
assertEquals(DistanceCalcEarth.DIST_EARTH.calcDistance(iter.fetchWayGeometry(FetchMode.ALL)), iter.getDistance(), 1.e-3);
assertEquals(1312.1, iter.getDistance(), 1.e-1);
assertEquals(1312.1, DistanceCalcEarth.DIST_EARTH.calcDistance(iter.fetchWayGeometry(FetchMode.ALL)), 1.e-1);
assertFalse(iter.next());
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testPreferredLanguage.
@Test
public void testPreferredLanguage() {
GraphHopper hopper = new GraphHopperFacade(file1, false, "de").importOrLoad();
GraphHopperStorage graph = hopper.getGraphHopperStorage();
int n20 = AbstractGraphStorageTester.getIdOf(graph, 52);
EdgeIterator iter = carOutExplorer.setBaseNode(n20);
assertTrue(iter.next());
assertEquals("straße 123, B 122", iter.getName());
hopper = new GraphHopperFacade(file1, false, "el").importOrLoad();
graph = hopper.getGraphHopperStorage();
n20 = AbstractGraphStorageTester.getIdOf(graph, 52);
iter = carOutExplorer.setBaseNode(n20);
assertTrue(iter.next());
assertTrue(iter.next());
assertEquals("διαδρομή 666", iter.getName());
}
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.getLon(findID(hopper.getLocationIndex(), 49, 10)), 1e-3);
assertEquals(51.249, na.getLat(findID(hopper.getLocationIndex(), 51.2492152, 9.4317166)), 1e-3);
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testWayReferencesNotExistingAdjNode_issue19.
@Test
public void testWayReferencesNotExistingAdjNode_issue19() {
GraphHopper hopper = new GraphHopperFacade(file4).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
assertEquals(2, graph.getNodes());
// the missing node is ignored, but the separated nodes are still connected
assertEquals(1, graph.getEdges());
int n10 = AbstractGraphStorageTester.getIdOf(graph, 51.2492152);
int n30 = AbstractGraphStorageTester.getIdOf(graph, 51.2);
assertEquals(GHUtility.asSet(n30), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n10)));
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testBarrierBetweenWays.
@Test
public void testBarrierBetweenWays() {
GraphHopper hopper = new GraphHopperFacade("test-barriers2.xml").setMinNetworkSize(0).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
// there are seven ways, but there should also be six barrier edges
// we first split the loop way into two parts, and then we split the barrier node => 3 edges total
assertEquals(7 + 6, graph.getEdges());
int loops = 0;
AllEdgesIterator iter = graph.getAllEdges();
while (iter.next()) {
// there are 'loop' edges, but only between different nodes
assertNotEquals(iter.getBaseNode(), iter.getAdjNode());
if (graph.getNodeAccess().getLat(iter.getBaseNode()) == graph.getNodeAccess().getLat(iter.getAdjNode()))
loops++;
}
assertEquals(5, loops);
}
Aggregations