@Override public double getElevation(int nodeId) { if (isVirtualNode(nodeId)) return virtualNodes.getElevation(nodeId - mainNodes); return mainNodeAccess.getElevation(nodeId); }
assertEquals(0, na.getElevation(0), PRECISION); assertEquals(0, na.getElevation(1), PRECISION); assertEquals(10, na.getElevation(2), PRECISION); assertEquals(20, na.getElevation(3), PRECISION); assertEquals(0, na.getElevation(4), PRECISION);
assertEquals(10, na.getElevation(0), PRECISION); assertEquals(10, na.getElevation(1), PRECISION); assertEquals(10, na.getElevation(2), PRECISION); assertEquals(20, na.getElevation(3), PRECISION); assertEquals(20, na.getElevation(4), PRECISION);
assertEquals(0, na.getElevation(0), PRECISION); assertEquals(10, na.getElevation(1), PRECISION); assertEquals(20, na.getElevation(2), PRECISION); assertEquals(30, na.getElevation(3), PRECISION); assertEquals(40, na.getElevation(4), PRECISION);
/** * @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; }
assertEquals(0, na.getElevation(0), PRECISION); assertEquals(10, na.getElevation(1), PRECISION); assertEquals(20, na.getElevation(2), PRECISION); assertEquals(30, na.getElevation(3), PRECISION); assertEquals(40, na.getElevation(4), PRECISION); assertEquals(20, na.getElevation(5), PRECISION); assertEquals(30, na.getElevation(6), PRECISION); assertEquals(40, na.getElevation(7), PRECISION);
assertEquals(0, na.getElevation(0), PRECISION); assertEquals(10, na.getElevation(1), PRECISION); assertEquals(20, na.getElevation(2), PRECISION); assertEquals(30, na.getElevation(3), PRECISION); assertEquals(40, na.getElevation(4), PRECISION); assertEquals(40, na.getElevation(5), PRECISION); assertEquals(30, na.getElevation(6), PRECISION); assertEquals(20, na.getElevation(7), PRECISION); assertEquals(10, na.getElevation(8), PRECISION); assertEquals(0, na.getElevation(9), PRECISION);
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; }
assertEquals(0, na.getElevation(0), PRECISION); assertEquals(10, na.getElevation(1), PRECISION); assertEquals(20, na.getElevation(2), PRECISION); assertEquals(30, na.getElevation(3), PRECISION); assertEquals(40, na.getElevation(4), PRECISION); assertEquals(40, na.getElevation(5), PRECISION); assertEquals(30, na.getElevation(6), PRECISION); assertEquals(20, na.getElevation(7), PRECISION); assertEquals(10, na.getElevation(8), PRECISION); assertEquals(0, na.getElevation(9), PRECISION);
@Override public double getElevation( int nodeId ) { if (isVirtualNode(nodeId)) return virtualNodes.getElevation(nodeId - mainNodes); return mainNodeAccess.getElevation(nodeId); }
@Override public double getElevation(int nodeId) { if (isVirtualNode(nodeId)) return virtualNodes.getElevation(nodeId - mainNodes); return mainNodeAccess.getElevation(nodeId); }
@Override public double getElevation(int nodeId) { if (isVirtualNode(nodeId)) return virtualNodes.getElevation(nodeId - mainNodes); return mainNodeAccess.getElevation(nodeId); }
@Override public void setTo(int toNode) { toLat = nodeAccess.getLatitude(toNode); toLon = nodeAccess.getLongitude(toNode); if (this.weighting.needsElevation()) { toElevation = nodeAccess.getElevation(toNode); } }
@Override public double approximate(int fromNode) { double fromLat = nodeAccess.getLatitude(fromNode); double fromLon = nodeAccess.getLongitude(fromNode); double dist2goal = distanceCalc.calcDist(toLat, toLon, fromLat, fromLon); double weight2goal; if (this.weighting.needsElevation()) { GHPoint3D toPoint = new GHPoint3D(toLat, toLon, toElevation); GHPoint3D fromPoint = new GHPoint3D(fromLat, fromLon, nodeAccess.getElevation(fromNode)); weight2goal = this.weighting.getMinWeight(fromPoint, toPoint); } else { weight2goal = this.weighting.getMinWeight(dist2goal); } return weight2goal * epsilon; }
/** * @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; }