Skip to content

Commit 890ba82

Browse files
authored
Remove edgeHasNoAccess from Weighting interface (graphhopper#2872)
1 parent e685c4f commit 890ba82

File tree

7 files changed

+3
-29
lines changed

7 files changed

+3
-29
lines changed

core/src/main/java/com/graphhopper/routing/weighting/AbstractAdjustedWeighting.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public double getMinWeight(double distance) {
3838
return superWeighting.getMinWeight(distance);
3939
}
4040

41-
@Override
42-
public boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse) {
43-
return superWeighting.edgeHasNoAccess(edgeState, reverse);
44-
}
45-
4641
@Override
4742
public double calcEdgeWeight(EdgeIteratorState edgeState, boolean reverse) {
4843
return superWeighting.calcEdgeWeight(edgeState, reverse);

core/src/main/java/com/graphhopper/routing/weighting/AbstractWeighting.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ protected AbstractWeighting(BooleanEncodedValue accessEnc, DecimalEncodedValue s
4040
this.turnCostProvider = turnCostProvider;
4141
}
4242

43-
@Override
44-
public boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse) {
43+
protected boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse) {
4544
if (edgeState.getBaseNode() == edgeState.getAdjNode())
4645
throw new IllegalStateException("Unexpected loop-edge at node: " + edgeState.getBaseNode());
4746
return reverse ? !edgeState.getReverse(accessEnc) : !edgeState.get(accessEnc);

core/src/main/java/com/graphhopper/routing/weighting/QueryGraphWeighting.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public double getMinWeight(double distance) {
4646
return weighting.getMinWeight(distance);
4747
}
4848

49-
@Override
50-
public boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse) {
51-
return weighting.edgeHasNoAccess(edgeState, reverse);
52-
}
53-
5449
@Override
5550
public double calcEdgeWeight(EdgeIteratorState edgeState, boolean reverse) {
5651
return weighting.calcEdgeWeight(edgeState, reverse);

core/src/main/java/com/graphhopper/routing/weighting/SpeedWeighting.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public double getMinWeight(double distance) {
4646
return distance / speedEnc.getMaxStorableDecimal();
4747
}
4848

49-
@Override
50-
public boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse) {
51-
return false;
52-
}
53-
5449
@Override
5550
public double calcEdgeWeight(EdgeIteratorState edgeState, boolean reverse) {
5651
double speed = reverse ? edgeState.getReverse(speedEnc) : edgeState.get(speedEnc);

core/src/main/java/com/graphhopper/routing/weighting/Weighting.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ public interface Weighting {
3636
*/
3737
double getMinWeight(double distance);
3838

39-
/**
40-
* @return true if the edge is not accessible in the given direction. Note that when false is returned it does
41-
* **not** mean the weight is finite! But when true is returned the weight must be infinite as well.
42-
*/
43-
boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse);
44-
4539
/**
4640
* This method calculates the weight of a given {@link EdgeIteratorState}. E.g. a high value indicates that the edge
4741
* should be avoided during shortest path search. Make sure that this method is very fast and optimized as this is

core/src/test/java/com/graphhopper/routing/RoutingAlgorithmTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,9 @@ public double getMinWeight(double distance) {
931931
return 0.8 * distance;
932932
}
933933

934-
public boolean edgeHasNoAccess(EdgeIteratorState edgeState, boolean reverse) {
935-
return tmpW.edgeHasNoAccess(edgeState, reverse);
936-
}
937-
938934
@Override
939935
public double calcEdgeWeight(EdgeIteratorState edgeState, boolean reverse) {
940-
if (edgeHasNoAccess(edgeState, reverse))
936+
if (Double.isInfinite(tmpW.calcEdgeWeight(edgeState, reverse)))
941937
return Double.POSITIVE_INFINITY;
942938
int adj = edgeState.getAdjNode();
943939
int base = edgeState.getBaseNode();

reader-gtfs/src/main/java/com/graphhopper/gtfs/GraphExplorer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private Iterable<MultiModalEdge> streetEdgeStream(int streetNode) {
160160
@Override
161161
public boolean tryAdvance(Consumer<? super MultiModalEdge> action) {
162162
while (e.next()) {
163-
if (!accessEgressWeighting.edgeHasNoAccess(e, reverse)) {
163+
if (Double.isFinite(accessEgressWeighting.calcEdgeWeight(e, reverse))) {
164164
action.accept(new MultiModalEdge(e.getEdge(), e.getBaseNode(), e.getAdjNode(), (long) (accessEgressWeighting.calcEdgeMillis(e.detach(false), reverse) * (5.0 / walkSpeedKmH)), e.getDistance()));
165165
return true;
166166
}

0 commit comments

Comments
 (0)