use of com.graphhopper.storage.NodeAccess in project graphhopper by graphhopper.
the class AbstractEdgeElevationInterpolator method interpolateElevationsOfPillarNodes.
private void interpolateElevationsOfPillarNodes() {
final EdgeIterator edge = storage.getAllEdges();
final NodeAccess nodeAccess = storage.getNodeAccess();
while (edge.next()) {
if (isInterpolatableEdge(edge)) {
int firstNodeId = edge.getBaseNode();
int secondNodeId = edge.getAdjNode();
double lat0 = nodeAccess.getLat(firstNodeId);
double lon0 = nodeAccess.getLon(firstNodeId);
double ele0 = nodeAccess.getEle(firstNodeId);
double lat1 = nodeAccess.getLat(secondNodeId);
double lon1 = nodeAccess.getLon(secondNodeId);
double ele1 = nodeAccess.getEle(secondNodeId);
final PointList pointList = edge.fetchWayGeometry(0);
final int count = pointList.size();
for (int index = 0; index < count; index++) {
double lat = pointList.getLat(index);
double lon = pointList.getLon(index);
double ele = elevationInterpolator.calculateElevationBasedOnTwoPoints(lat, lon, lat0, lon0, ele0, lat1, lon1, ele1);
pointList.set(index, lat, lon, ele);
}
edge.setWayGeometry(pointList);
}
}
}
use of com.graphhopper.storage.NodeAccess in project graphhopper by graphhopper.
the class NodeElevationInterpolator method interpolateElevationsOfInnerNodesForOneOuterNode.
private void interpolateElevationsOfInnerNodesForOneOuterNode(int outerNodeId, int[] innerNodeIds) {
NodeAccess nodeAccess = storage.getNodeAccess();
double ele = nodeAccess.getEle(outerNodeId);
for (int innerNodeId : innerNodeIds) {
double lat = nodeAccess.getLat(innerNodeId);
double lon = nodeAccess.getLon(innerNodeId);
nodeAccess.setNode(innerNodeId, lat, lon, ele);
}
}
use of com.graphhopper.storage.NodeAccess in project graphhopper by graphhopper.
the class NodeElevationInterpolator method interpolateElevationsOfInnerNodesForTwoOuterNodes.
private void interpolateElevationsOfInnerNodesForTwoOuterNodes(int firstOuterNodeId, int secondOuterNodeId, int[] innerNodeIds) {
final NodeAccess nodeAccess = storage.getNodeAccess();
double lat0 = nodeAccess.getLat(firstOuterNodeId);
double lon0 = nodeAccess.getLon(firstOuterNodeId);
double ele0 = nodeAccess.getEle(firstOuterNodeId);
double lat1 = nodeAccess.getLat(secondOuterNodeId);
double lon1 = nodeAccess.getLon(secondOuterNodeId);
double ele1 = nodeAccess.getEle(secondOuterNodeId);
for (int innerNodeId : innerNodeIds) {
double lat = nodeAccess.getLat(innerNodeId);
double lon = nodeAccess.getLon(innerNodeId);
double ele = elevationInterpolator.calculateElevationBasedOnTwoPoints(lat, lon, lat0, lon0, ele0, lat1, lon1, ele1);
nodeAccess.setNode(innerNodeId, lat, lon, ele);
}
}
use of com.graphhopper.storage.NodeAccess in project graphhopper by graphhopper.
the class TunnelElevationInterpolatorTest method interpolatesElevationOfTunnelWithFourOuterNodes.
@Test
public void interpolatesElevationOfTunnelWithFourOuterNodes() {
// @formatter:off
/*
* Graph structure:
* 0-----1--T--2--T--3-----4
* |
* |
* T
* |
* |
* 5-----6--T--7--T--8-----9
*/
// @formatter:on
NodeAccess na = graph.getNodeAccess();
na.setNode(0, 0, 0, 0);
na.setNode(1, 10, 0, 10);
na.setNode(2, 20, 0, 1000);
na.setNode(3, 30, 0, 30);
na.setNode(4, 40, 0, 40);
na.setNode(5, 0, 10, 40);
na.setNode(6, 10, 10, 30);
na.setNode(7, 20, 10, 1000);
na.setNode(8, 30, 10, 10);
na.setNode(9, 40, 10, 0);
EdgeIteratorState edge01 = graph.edge(0, 1, 10, true);
EdgeIteratorState edge12 = graph.edge(1, 2, 10, true);
EdgeIteratorState edge23 = graph.edge(2, 3, 10, true);
EdgeIteratorState edge34 = graph.edge(3, 4, 10, true);
EdgeIteratorState edge56 = graph.edge(5, 6, 10, true);
EdgeIteratorState edge67 = graph.edge(6, 7, 10, true);
EdgeIteratorState edge78 = graph.edge(7, 8, 10, true);
EdgeIteratorState edge89 = graph.edge(8, 9, 10, true);
EdgeIteratorState edge27 = graph.edge(2, 7, 10, true);
edge01.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
edge12.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge23.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge34.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
edge56.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
edge67.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge78.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge89.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
edge27.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
final GHIntHashSet outerNodeIds = new GHIntHashSet();
final GHIntHashSet innerNodeIds = new GHIntHashSet();
gatherOuterAndInnerNodeIdsOfStructure(edge12, outerNodeIds, innerNodeIds);
assertEquals(GHIntHashSet.from(1, 3, 6, 8), outerNodeIds);
assertEquals(GHIntHashSet.from(2, 7), innerNodeIds);
edgeElevationInterpolator.execute();
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);
}
use of com.graphhopper.storage.NodeAccess in project graphhopper by graphhopper.
the class TunnelElevationInterpolatorTest method interpolatesElevationOfTunnelWithThreeOuterNodes.
@Test
public void interpolatesElevationOfTunnelWithThreeOuterNodes() {
// @formatter:off
/*
* Graph structure:
* 0-----1--T--2--T--3-----4
* |
* |
* T
* |
* |
* 5--T--6-----7
*/
// @formatter:on
NodeAccess na = graph.getNodeAccess();
na.setNode(0, 0, 0, 0);
na.setNode(1, 10, 0, 10);
na.setNode(2, 20, 0, 1000);
na.setNode(3, 30, 0, 30);
na.setNode(4, 40, 0, 40);
na.setNode(5, 20, 10, 1000);
na.setNode(6, 30, 10, 30);
na.setNode(7, 40, 10, 40);
EdgeIteratorState edge01 = graph.edge(0, 1, 10, true);
EdgeIteratorState edge12 = graph.edge(1, 2, 10, true);
EdgeIteratorState edge23 = graph.edge(2, 3, 10, true);
EdgeIteratorState edge34 = graph.edge(3, 4, 10, true);
EdgeIteratorState edge25 = graph.edge(2, 5, 10, true);
EdgeIteratorState edge56 = graph.edge(5, 6, 10, true);
EdgeIteratorState edge67 = graph.edge(6, 7, 10, true);
edge01.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
edge12.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge23.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge34.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
edge25.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge56.setFlags(dataFlagEncoder.handleWayTags(interpolatableWay, 1, 0));
edge67.setFlags(dataFlagEncoder.handleWayTags(normalWay, 1, 0));
final GHIntHashSet outerNodeIds = new GHIntHashSet();
final GHIntHashSet innerNodeIds = new GHIntHashSet();
gatherOuterAndInnerNodeIdsOfStructure(edge12, outerNodeIds, innerNodeIds);
assertEquals(GHIntHashSet.from(1, 3, 6), outerNodeIds);
assertEquals(GHIntHashSet.from(2, 5), innerNodeIds);
edgeElevationInterpolator.execute();
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);
}
Aggregations