Skip to content

Commit 8135306

Browse files
author
Peter
committed
moving writing method again up to Graph; introduce pillarNodes methods; new RawEdgeIterator to show the difference between getAllEdges and the other edges methods
1 parent 9fcbfde commit 8135306

20 files changed

+329
-308
lines changed

src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import com.graphhopper.storage.LevelGraph;
3232
import com.graphhopper.util.EdgeIterator;
3333
import com.graphhopper.util.EdgeSkipIterator;
34-
import com.graphhopper.util.EdgeWriteIterator;
3534
import com.graphhopper.util.GraphUtility;
3635
import com.graphhopper.util.Helper;
3736
import com.graphhopper.util.NumHelper;
37+
import com.graphhopper.util.RawEdgeIterator;
3838
import com.graphhopper.util.StopWatch;
3939
import gnu.trove.list.array.TIntArrayList;
4040
import java.util.ArrayList;
@@ -107,7 +107,7 @@ boolean prepareEdges() {
107107
// in CH the flags will be ignored (calculating the new flags for the shortcuts is impossible)
108108
// also several shortcuts would be necessary with the different modes (e.g. fastest and shortest)
109109
// so calculate the weight and store this as distance, then use only distance instead of getWeight
110-
EdgeWriteIterator iter = g.getAllEdges();
110+
RawEdgeIterator iter = g.getAllEdges();
111111
int c = 0;
112112
while (iter.next()) {
113113
c++;
@@ -289,7 +289,7 @@ Collection<Shortcut> findShortcuts(int v) {
289289
// we can use distance instead of weight, see prepareEdges where distance is overwritten by weight!
290290
List<NodeCH> goalNodes = new ArrayList<NodeCH>();
291291
shortcuts.clear();
292-
EdgeWriteIterator iter1 = g.getIncoming(v);
292+
EdgeIterator iter1 = g.getIncoming(v);
293293
// TODO PERFORMANCE collect outgoing nodes (goalnodes) only once and just skip u
294294
while (iter1.next()) {
295295
int u = iter1.node();
@@ -301,7 +301,7 @@ Collection<Shortcut> findShortcuts(int v) {
301301

302302
// one-to-many shortest path
303303
goalNodes.clear();
304-
EdgeWriteIterator iter2 = g.getOutgoing(v);
304+
EdgeIterator iter2 = g.getOutgoing(v);
305305
double maxWeight = 0;
306306
while (iter2.next()) {
307307
int w = iter2.node();

src/main/java/com/graphhopper/routing/util/EdgeLevelFilter.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import com.graphhopper.storage.LevelGraph;
1919
import com.graphhopper.util.EdgeIterator;
20+
import gnu.trove.TIntCollection;
21+
import gnu.trove.iterator.TIntIterator;
2022

2123
/**
2224
* Only certain nodes are accepted and therefor the others are filtered out.
@@ -73,4 +75,20 @@ public boolean accept() {
7375
@Override public boolean isEmpty() {
7476
return false;
7577
}
78+
79+
@Override public TIntIterator pillarNodes() {
80+
return edgeIter.pillarNodes();
81+
}
82+
83+
@Override public void pillarNodes(TIntCollection pillarNodes) {
84+
edgeIter.pillarNodes(pillarNodes);
85+
}
86+
87+
@Override public void distance(double dist) {
88+
edgeIter.distance(dist);
89+
}
90+
91+
@Override public void flags(int flags) {
92+
edgeIter.flags(flags);
93+
}
7694
}

src/main/java/com/graphhopper/storage/Graph.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package com.graphhopper.storage;
1717

1818
import com.graphhopper.util.EdgeIterator;
19+
import com.graphhopper.util.RawEdgeIterator;
1920
import com.graphhopper.util.shapes.BBox;
20-
import gnu.trove.list.TIntList;
2121

2222
/**
2323
* An interface to represent a (geo) graph - suited for efficient storage as it can be requested via
@@ -56,14 +56,11 @@ public interface Graph {
5656
* @param b the index of the ending (tower) node of the edge
5757
* @param distance necessary if no setNode is called - e.g. if the graph is not a geo-graph
5858
* @param flags see EdgeFlags - involves velocity and direction
59-
* @param nodesOnPath list of nodes between a and b but inclusive the tower nodes a and b. The nodes
60-
* between a and b would otherwise have no connection - so called pillar nodes.
59+
* @return the created edge
6160
*/
62-
void edge(int a, int b, double distance, int flags, TIntList nodesOnPath);
63-
64-
void edge(int a, int b, double distance, int flags);
61+
EdgeIterator edge(int a, int b, double distance, int flags);
6562

66-
void edge(int a, int b, double distance, boolean bothDirections);
63+
EdgeIterator edge(int a, int b, double distance, boolean bothDirections);
6764

6865
/**
6966
* @return an edge iterator over one element where the method next() has no meaning and will
@@ -73,7 +70,10 @@ public interface Graph {
7370
*/
7471
EdgeIterator getEdgeProps(int edgeId, int endNode);
7572

76-
EdgeIterator getAllEdges();
73+
/**
74+
* @return all edges in this graph
75+
*/
76+
RawEdgeIterator getAllEdges();
7777

7878
/**
7979
* Returns an iterator which makes it possible to traverse all edges of the specified node
@@ -82,8 +82,6 @@ public interface Graph {
8282
*/
8383
EdgeIterator getEdges(int index);
8484

85-
EdgeIterator getEdges(int index, EdgeFilter filter);
86-
8785
EdgeIterator getIncoming(int index);
8886

8987
EdgeIterator getOutgoing(int index);

0 commit comments

Comments
 (0)