/** * See 'lookup' for further variables that are initialized */ private QueryGraph(Graph graph, QueryGraph superQueryGraph) { mainGraph = graph; baseGraph = this; wrappedExtension = superQueryGraph.wrappedExtension; mainNodeAccess = graph.getNodeAccess(); mainNodes = superQueryGraph.mainNodes; mainEdges = superQueryGraph.mainEdges; }
public DebugDijkstraBidirection(Graph graph, Weighting type, TraversalMode tMode, GraphicsWrapper mg) { super(graph, type, tMode); this.mg = mg; na = graph.getNodeAccess(); }
public DebugAStar(Graph graph, Weighting type, TraversalMode tMode, GraphicsWrapper mg) { super(graph, type, tMode); this.mg = mg; na = graph.getNodeAccess(); }
public Location2IDFullWithEdgesIndex(Graph g) { this.graph = g; this.nodeAccess = g.getNodeAccess(); }
public GraphicsWrapper(Graph g) { this.na = g.getNodeAccess(); BBox b = g.getBounds(); scaleX = scaleY = 0.002 * (b.maxLat - b.minLat); offsetY = b.maxLat - 90; offsetX = -b.minLon; }
@Override public void init(Graph graph, Directory dir) { if (turnCostsCount > 0) throw new AssertionError("The turn cost storage must be initialized only once."); this.nodeAccess = graph.getNodeAccess(); this.turnCosts = dir.find("turn_costs"); }
public Location2IDQuadtree(Graph g, Directory dir) { this.graph = g; this.nodeAccess = g.getNodeAccess(); index = dir.find("loc2id_index"); setResolution(100 * 100); }
public Path(Graph graph, Weighting weighting) { this.weight = Double.MAX_VALUE; this.graph = graph; this.nodeAccess = graph.getNodeAccess(); this.weighting = weighting; this.encoder = weighting.getFlagEncoder(); this.edgeIds = new GHIntArrayList(); }
/** * @param g the graph for which this index should do the lookup based on latitude,longitude. */ public LocationIndexTree(Graph g, Directory dir) { if (g instanceof CHGraph) throw new IllegalArgumentException("Use base graph for LocationIndexTree instead of CHGraph"); MAGIC_INT = Integer.MAX_VALUE / 22316; this.graph = g; this.nodeAccess = g.getNodeAccess(); dataAccess = dir.find("location_index", DAType.getPreferredInt(dir.getDefaultType())); }
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; }
public static int getIdOf(Graph g, double latitude, double longitude) { int s = g.getNodes(); NodeAccess na = g.getNodeAccess(); for (int i = 0; i < s; i++) { if (Math.abs(na.getLatitude(i) - latitude) < 1e-4 && Math.abs(na.getLongitude(i) - longitude) < 1e-4) { return i; } } throw new IllegalArgumentException("did not find node with location " + (float) latitude + "," + (float) longitude); }
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 OSMReader(GraphHopperStorage ghStorage) { this.ghStorage = ghStorage; this.graph = ghStorage; this.nodeAccess = graph.getNodeAccess(); this.encodingManager = ghStorage.getEncodingManager(); osmNodeIdToInternalNodeMap = new GHLongIntBTree(200); osmNodeIdToNodeFlagsMap = new GHLongLongHashMap(200, .5f); osmWayIdToRouteWeightMap = new GHLongLongHashMap(200, .5f); pillarInfo = new PillarInfo(nodeAccess.is3D(), ghStorage.getDirectory()); }
private String getCoords(EdgeIteratorState edge, Graph graph) { NodeAccess na = graph.getNodeAccess(); int base = edge.getBaseNode(); int adj = edge.getAdjNode(); return base + "->" + adj + " (" + edge.getEdge() + "); " + na.getLat(base) + "," + na.getLon(base) + " -> " + na.getLat(adj) + "," + na.getLon(adj); }
@Test public void testNoErrorOnEdgeCase_lastIndex() { final EncodingManager encodingManager = new EncodingManager("car"); int locs = 10000; Graph g = AbstractLocationIndexTester.this.createGHStorage(new MMapDirectory(location), encodingManager, false); NodeAccess na = g.getNodeAccess(); Random rand = new Random(12); for (int i = 0; i < locs; i++) { na.setNode(i, (float) rand.nextDouble() * 10 + 10, (float) rand.nextDouble() * 10 + 10); } idx = createIndex(g, 200); Helper.close((Closeable) g); }
private void initHorseshoeGraph(Graph g) { // setup graph // ____ // | | // | | // 0 1 NodeAccess na = g.getNodeAccess(); na.setNode(0, 0, 0); na.setNode(1, 0, 2); g.edge(0, 1, 10, true).setWayGeometry(Helper.createPointList(2, 0, 2, 2)); }
public static String getNodeInfo(Graph g, int nodeId, EdgeFilter filter) { EdgeIterator iter = g.createEdgeExplorer(filter).setBaseNode(nodeId); NodeAccess na = g.getNodeAccess(); String str = nodeId + ":" + na.getLatitude(nodeId) + "," + na.getLongitude(nodeId) + "\n"; while (iter.next()) { str += " ->" + iter.getAdjNode() + " (" + iter.getDistance() + ") pillars:" + iter.fetchWayGeometry(0).getSize() + ", edgeId:" + iter.getEdge() + "\t" + BitUtil.BIG.toBitString(iter.getFlags(), 8) + "\n"; } return str; }
public static void updateDistancesFor(Graph g, int node, double lat, double lon) { NodeAccess na = g.getNodeAccess(); na.setNode(node, lat, lon); EdgeIterator iter = g.createEdgeExplorer().setBaseNode(node); while (iter.next()) { iter.setDistance(iter.fetchWayGeometry(3).calcDistance(distCalc)); // System.out.println(node + "->" + adj + ": " + iter.getDistance()); } }
@Test public void testSortDirected() { Graph g = createGraph(); NodeAccess na = g.getNodeAccess(); na.setNode(0, 0, 1); na.setNode(1, 2.5, 2); na.setNode(2, 3.5, 3); g.edge(0, 1, 1.1, false); g.edge(2, 1, 1.1, false); GHUtility.sortDFS(g, createGraph()); }
@Test public void testSort2() { Graph g = initUnsorted(createGraph()); Graph newG = GHUtility.sortDFS(g, createGraph()); assertEquals(g.getNodes(), newG.getNodes()); NodeAccess na = newG.getNodeAccess(); assertEquals(0, na.getLatitude(0), 1e-4); // 0 assertEquals(2.5, na.getLatitude(1), 1e-4); // 1 assertEquals(4.5, na.getLatitude(2), 1e-4); // 2 assertEquals(4.6, na.getLatitude(3), 1e-4); // 8 }