public boolean containsLatitude(Graph g, EdgeIterator iter, double latitude) { NodeAccess na = g.getNodeAccess(); while (iter.next()) { if (Math.abs(na.getLatitude(iter.getAdjNode()) - latitude) < 1e-4) return true; } return false; }
public static int getIdOf(Graph g, double latitude) { int s = g.getNodes(); NodeAccess na = g.getNodeAccess(); for (int i = 0; i < s; i++) { if (Math.abs(na.getLatitude(i) - latitude) < 1e-4) { return i; } } return -1; }
protected void checkGraph(Graph g) { NodeAccess na = g.getNodeAccess(); assertTrue(na.is3D()); assertTrue(g.getBounds().isValid()); assertEquals(new BBox(10, 20, 10, 12, 0, 1), g.getBounds()); assertEquals(10, na.getLatitude(0), 1e-2); assertEquals(10, na.getLongitude(0), 1e-2); EdgeExplorer explorer = g.createEdgeExplorer(carOutFilter); assertEquals(2, GHUtility.count(explorer.setBaseNode(0))); assertEquals(GHUtility.asSet(2, 1), GHUtility.getNeighbors(explorer.setBaseNode(0))); EdgeIterator iter = explorer.setBaseNode(0); assertTrue(iter.next()); assertEquals(Helper.createPointList3D(3.5, 4.5, 0, 5, 6, 0), iter.fetchWayGeometry(0)); assertTrue(iter.next()); assertEquals(Helper.createPointList3D(1.5, 1, 0, 2, 3, 0), iter.fetchWayGeometry(0)); assertEquals(Helper.createPointList3D(10, 10, 0, 1.5, 1, 0, 2, 3, 0), iter.fetchWayGeometry(1)); assertEquals(Helper.createPointList3D(1.5, 1, 0, 2, 3, 0, 11, 20, 1), iter.fetchWayGeometry(2)); assertEquals(11, na.getLatitude(1), 1e-2); assertEquals(20, na.getLongitude(1), 1e-2); assertEquals(2, GHUtility.count(explorer.setBaseNode(1))); assertEquals(GHUtility.asSet(2, 0), GHUtility.getNeighbors(explorer.setBaseNode(1))); assertEquals(12, na.getLatitude(2), 1e-2); assertEquals(12, na.getLongitude(2), 1e-2); assertEquals(1, GHUtility.count(explorer.setBaseNode(2))); assertEquals(GHUtility.asSet(0), GHUtility.getNeighbors(explorer.setBaseNode(2))); EdgeIteratorState eib = GHUtility.getEdge(g, 1, 2); assertEquals(Helper.createPointList3D(), eib.fetchWayGeometry(0)); assertEquals(Helper.createPointList3D(11, 20, 1), eib.fetchWayGeometry(1)); assertEquals(Helper.createPointList3D(12, 12, 0.4), eib.fetchWayGeometry(2)); assertEquals(GHUtility.asSet(0), GHUtility.getNeighbors(explorer.setBaseNode(2))); }
private void checkExampleGraph(Graph graph) { NodeAccess na = graph.getNodeAccess(); assertEquals(12f, na.getLatitude(0), 1e-6); assertEquals(23f, na.getLongitude(0), 1e-6); assertEquals(38.33f, na.getLatitude(1), 1e-6); assertEquals(135.3f, na.getLongitude(1), 1e-6); assertEquals(6, na.getLatitude(2), 1e-6); assertEquals(139, na.getLongitude(2), 1e-6); assertEquals(78, na.getLatitude(3), 1e-6); assertEquals(89, na.getLongitude(3), 1e-6); assertEquals(GHUtility.asSet(0), GHUtility.getNeighbors(carOutExplorer.setBaseNode((1)))); assertEquals( GHUtility.asSet(5, 4, 3, 2, 1), GHUtility.getNeighbors(carOutExplorer.setBaseNode(0))); try { assertEquals(0, count(carOutExplorer.setBaseNode(6))); // for now return empty iterator // assertFalse(true); } catch (Exception ex) { } }