public static void printGraphForUnitTest(Graph g, FlagEncoder encoder, BBox bBox) { NodeAccess na = g.getNodeAccess(); for (int node = 0; node < g.getNodes(); ++node) { if (bBox.contains(na.getLat(node), na.getLon(node))) { System.out.printf(Locale.ROOT, "na.setNode(%d, %f, %f);\n", node, na.getLat(node), na.getLon(node)); } } AllEdgesIterator iter = g.getAllEdges(); while (iter.next()) { if (bBox.contains(na.getLat(iter.getBaseNode()), na.getLon(iter.getBaseNode())) && bBox.contains(na.getLat(iter.getAdjNode()), na.getLon(iter.getAdjNode()))) { printUnitTestEdge(encoder, iter); } } }
continue; int nodeIndex = edge.getBaseNode(); double lat = na.getLatitude(nodeIndex); double lon = na.getLongitude(nodeIndex);
/** * This method makes edges crossing the specified border inaccessible to split a bigger area into smaller subnetworks. * This is important for the world wide use case to limit the maximum distance and also to detect unreasonable routes faster. */ protected IntHashSet findBorderEdgeIds(SpatialRuleLookup ruleLookup) { AllEdgesIterator allEdgesIterator = graph.getAllEdges(); NodeAccess nodeAccess = graph.getNodeAccess(); IntHashSet inaccessible = new IntHashSet(); while (allEdgesIterator.next()) { int adjNode = allEdgesIterator.getAdjNode(); SpatialRule ruleAdj = ruleLookup.lookupRule(nodeAccess.getLatitude(adjNode), nodeAccess.getLongitude(adjNode)); int baseNode = allEdgesIterator.getBaseNode(); SpatialRule ruleBase = ruleLookup.lookupRule(nodeAccess.getLatitude(baseNode), nodeAccess.getLongitude(baseNode)); if (ruleAdj != ruleBase) { inaccessible.add(allEdgesIterator.getEdge()); } } return inaccessible; }
node = iter.getBaseNode(); } else { node = iter.getAdjNode();
/** * @return the specified toGraph which is now filled with data from fromGraph */ // TODO very similar to createSortedGraph -> use a 'int map(int)' interface public static Graph copyTo(Graph fromGraph, Graph toGraph) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int adj = eIter.getAdjNode(); eIter.copyPropertiesTo(toGraph.edge(base, adj)); } NodeAccess fna = fromGraph.getNodeAccess(); NodeAccess tna = toGraph.getNodeAccess(); int nodes = fromGraph.getNodes(); for (int node = 0; node < nodes; node++) { if (tna.is3D()) tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node), fna.getElevation(node)); else tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node)); } return toGraph; }
static Graph createSortedGraph(Graph fromGraph, Graph toSortedGraph, final IntIndexedContainer oldToNewNodeList) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int newBaseIndex = oldToNewNodeList.get(base); int adj = eIter.getAdjNode(); int newAdjIndex = oldToNewNodeList.get(adj); // ignore empty entries if (newBaseIndex < 0 || newAdjIndex < 0) continue; eIter.copyPropertiesTo(toSortedGraph.edge(newBaseIndex, newAdjIndex)); } int nodes = fromGraph.getNodes(); NodeAccess na = fromGraph.getNodeAccess(); NodeAccess sna = toSortedGraph.getNodeAccess(); for (int old = 0; old < nodes; old++) { int newIndex = oldToNewNodeList.get(old); if (sna.is3D()) sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old), na.getElevation(old)); else sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old)); } return toSortedGraph; }
node = iter.getBaseNode(); } else { node = iter.getAdjNode();
assertEquals(iter.getBaseNode(), eState2.getAdjNode()); assertFalse(iter.next());
public static void printGraphForUnitTest(Graph g, FlagEncoder encoder, BBox bBox) { NodeAccess na = g.getNodeAccess(); for (int node = 0; node < g.getNodes(); ++node) { if (bBox.contains(na.getLat(node), na.getLon(node))) { System.out.printf(Locale.ROOT, "na.setNode(%d, %f, %f);\n", node, na.getLat(node), na.getLon(node)); } } AllEdgesIterator iter = g.getAllEdges(); while (iter.next()) { if (bBox.contains(na.getLat(iter.getBaseNode()), na.getLon(iter.getBaseNode())) && bBox.contains(na.getLat(iter.getAdjNode()), na.getLon(iter.getAdjNode()))) { printUnitTestEdge(encoder, iter); } } }
/** * This method makes edges crossing the specified border inaccessible to split a bigger area into smaller subnetworks. * This is important for the world wide use case to limit the maximum distance and also to detect unreasonable routes faster. */ protected IntHashSet findBorderEdgeIds(SpatialRuleLookup ruleLookup) { AllEdgesIterator allEdgesIterator = graph.getAllEdges(); NodeAccess nodeAccess = graph.getNodeAccess(); IntHashSet inaccessible = new IntHashSet(); while (allEdgesIterator.next()) { int adjNode = allEdgesIterator.getAdjNode(); SpatialRule ruleAdj = ruleLookup.lookupRule(nodeAccess.getLatitude(adjNode), nodeAccess.getLongitude(adjNode)); int baseNode = allEdgesIterator.getBaseNode(); SpatialRule ruleBase = ruleLookup.lookupRule(nodeAccess.getLatitude(baseNode), nodeAccess.getLongitude(baseNode)); if (ruleAdj != ruleBase) inaccessible.add(allEdgesIterator.getEdge()); } return inaccessible; }
/** * This method makes edges crossing the specified border inaccessible to split a bigger area into smaller subnetworks. * This is important for the world wide use case to limit the maximum distance and also to detect unreasonable routes faster. */ protected IntHashSet findBorderEdgeIds(SpatialRuleLookup ruleLookup) { AllEdgesIterator allEdgesIterator = graph.getAllEdges(); NodeAccess nodeAccess = graph.getNodeAccess(); IntHashSet inaccessible = new IntHashSet(); while (allEdgesIterator.next()) { int adjNode = allEdgesIterator.getAdjNode(); SpatialRule ruleAdj = ruleLookup.lookupRule(nodeAccess.getLatitude(adjNode), nodeAccess.getLongitude(adjNode)); int baseNode = allEdgesIterator.getBaseNode(); SpatialRule ruleBase = ruleLookup.lookupRule(nodeAccess.getLatitude(baseNode), nodeAccess.getLongitude(baseNode)); if (ruleAdj != ruleBase) { inaccessible.add(allEdgesIterator.getEdge()); } } return inaccessible; }
node = iter.getBaseNode(); } else { node = iter.getAdjNode();
node = iter.getBaseNode(); } else { node = iter.getAdjNode();
node = iter.getBaseNode(); } else
/** * @return the specified toGraph which is now filled with data from fromGraph */ // TODO very similar to createSortedGraph -> use a 'int map(int)' interface public static Graph copyTo(Graph fromGraph, Graph toGraph) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int adj = eIter.getAdjNode(); eIter.copyPropertiesTo(toGraph.edge(base, adj)); } NodeAccess fna = fromGraph.getNodeAccess(); NodeAccess tna = toGraph.getNodeAccess(); int nodes = fromGraph.getNodes(); for (int node = 0; node < nodes; node++) { if (tna.is3D()) tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node), fna.getElevation(node)); else tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node)); } return toGraph; }
/** * @return the specified toGraph which is now filled with data from fromGraph */ // TODO very similar to createSortedGraph -> use a 'int map(int)' interface public static Graph copyTo(Graph fromGraph, Graph toGraph) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int adj = eIter.getAdjNode(); eIter.copyPropertiesTo(toGraph.edge(base, adj)); } NodeAccess fna = fromGraph.getNodeAccess(); NodeAccess tna = toGraph.getNodeAccess(); int nodes = fromGraph.getNodes(); for (int node = 0; node < nodes; node++) { if (tna.is3D()) tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node), fna.getElevation(node)); else tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node)); } return toGraph; }
/** * @return the specified toGraph which is now filled with data from fromGraph */ // TODO very similar to createSortedGraph -> use a 'int map(int)' interface public static Graph copyTo( Graph fromGraph, Graph toGraph ) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int adj = eIter.getAdjNode(); eIter.copyPropertiesTo(toGraph.edge(base, adj)); } NodeAccess fna = fromGraph.getNodeAccess(); NodeAccess tna = toGraph.getNodeAccess(); int nodes = fromGraph.getNodes(); for (int node = 0; node < nodes; node++) { if (tna.is3D()) tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node), fna.getElevation(node)); else tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node)); } return toGraph; }
static Graph createSortedGraph(Graph fromGraph, Graph toSortedGraph, final IntIndexedContainer oldToNewNodeList) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int newBaseIndex = oldToNewNodeList.get(base); int adj = eIter.getAdjNode(); int newAdjIndex = oldToNewNodeList.get(adj); // ignore empty entries if (newBaseIndex < 0 || newAdjIndex < 0) continue; eIter.copyPropertiesTo(toSortedGraph.edge(newBaseIndex, newAdjIndex)); } int nodes = fromGraph.getNodes(); NodeAccess na = fromGraph.getNodeAccess(); NodeAccess sna = toSortedGraph.getNodeAccess(); for (int old = 0; old < nodes; old++) { int newIndex = oldToNewNodeList.get(old); if (sna.is3D()) sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old), na.getElevation(old)); else sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old)); } return toSortedGraph; }
static Graph createSortedGraph(Graph fromGraph, Graph toSortedGraph, final IntIndexedContainer oldToNewNodeList) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int newBaseIndex = oldToNewNodeList.get(base); int adj = eIter.getAdjNode(); int newAdjIndex = oldToNewNodeList.get(adj); // ignore empty entries if (newBaseIndex < 0 || newAdjIndex < 0) continue; eIter.copyPropertiesTo(toSortedGraph.edge(newBaseIndex, newAdjIndex)); } int nodes = fromGraph.getNodes(); NodeAccess na = fromGraph.getNodeAccess(); NodeAccess sna = toSortedGraph.getNodeAccess(); for (int old = 0; old < nodes; old++) { int newIndex = oldToNewNodeList.get(old); if (sna.is3D()) sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old), na.getElevation(old)); else sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old)); } return toSortedGraph; }
static Graph createSortedGraph( Graph fromGraph, Graph toSortedGraph, final TIntList oldToNewNodeList ) { AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int newBaseIndex = oldToNewNodeList.get(base); int adj = eIter.getAdjNode(); int newAdjIndex = oldToNewNodeList.get(adj); // ignore empty entries if (newBaseIndex < 0 || newAdjIndex < 0) continue; eIter.copyPropertiesTo(toSortedGraph.edge(newBaseIndex, newAdjIndex)); } int nodes = fromGraph.getNodes(); NodeAccess na = fromGraph.getNodeAccess(); NodeAccess sna = toSortedGraph.getNodeAccess(); for (int old = 0; old < nodes; old++) { int newIndex = oldToNewNodeList.get(old); if (sna.is3D()) sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old), na.getElevation(old)); else sna.setNode(newIndex, na.getLatitude(old), na.getLongitude(old)); } return toSortedGraph; }