use of com.graphhopper.util.EdgeExplorer in project graphhopper by graphhopper.
the class OSMTurnRelationParser method addRelationToTCStorage.
/**
* Add the specified relation to the TurnCostStorage
*/
void addRelationToTCStorage(OSMTurnRelation osmTurnRelation, ExternalInternalMap map, Graph graph) {
TurnCostStorage tcs = graph.getTurnCostStorage();
int viaNode = map.getInternalNodeIdOfOsmNode(osmTurnRelation.getViaOsmNodeId());
EdgeExplorer edgeOutExplorer = getOutExplorer(graph), edgeInExplorer = getInExplorer(graph);
try {
int edgeIdFrom = EdgeIterator.NO_EDGE;
// get all incoming edges and receive the edge which is defined by fromOsm
EdgeIterator iter = edgeInExplorer.setBaseNode(viaNode);
while (iter.next()) {
if (map.getOsmIdOfInternalEdge(iter.getEdge()) == osmTurnRelation.getOsmIdFrom()) {
edgeIdFrom = iter.getEdge();
break;
}
}
if (!EdgeIterator.Edge.isValid(edgeIdFrom))
return;
// get all outgoing edges of the via node
iter = edgeOutExplorer.setBaseNode(viaNode);
// for TYPE_NOT_* we add ONE restriction (from, via, to)
while (iter.next()) {
int edgeId = iter.getEdge();
long wayId = map.getOsmIdOfInternalEdge(edgeId);
if (edgeId != edgeIdFrom && osmTurnRelation.getRestriction() == OSMTurnRelation.Type.ONLY && wayId != osmTurnRelation.getOsmIdTo() || osmTurnRelation.getRestriction() == OSMTurnRelation.Type.NOT && wayId == osmTurnRelation.getOsmIdTo() && wayId >= 0) {
tcs.set(turnCostEnc, edgeIdFrom, viaNode, iter.getEdge(), Double.POSITIVE_INFINITY);
if (osmTurnRelation.getRestriction() == OSMTurnRelation.Type.NOT)
break;
}
}
} catch (Exception e) {
throw new IllegalStateException("Could not built turn table entry for relation of node with osmId:" + osmTurnRelation.getViaOsmNodeId(), e);
}
}
use of com.graphhopper.util.EdgeExplorer in project graphhopper by graphhopper.
the class EdgeBasedTarjanSCC method findComponentForEdgeKey.
private void findComponentForEdgeKey(int p, int adjNode) {
setupNextEdgeKey(p);
// we have to create a new explorer on each iteration because of the nested edge iterations
final int edge = getEdgeFromKey(p);
EdgeExplorer explorer = graph.createEdgeExplorer();
EdgeIterator iter = explorer.setBaseNode(adjNode);
while (iter.next()) {
if (!edgeTransitionFilter.accept(edge, iter))
continue;
int q = createEdgeKey(iter, false);
handleNeighbor(p, q, iter.getAdjNode());
// both ways
if (iter.getBaseNode() == iter.getAdjNode())
handleNeighbor(p, q + 1, iter.getAdjNode());
}
buildComponent(p);
}
Aggregations