From d115ad194f72e7ef3055d828f3e2200e9c5d1c27 Mon Sep 17 00:00:00 2001 From: TeemuP Date: Tue, 18 Dec 2018 16:04:43 +0200 Subject: [PATCH 1/2] Fix thru-traffic edges handling --- .../routing/edgetype/StreetEdge.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java b/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java index 5d3c6a12d1a..0975b225629 100644 --- a/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java +++ b/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java @@ -408,14 +408,11 @@ private StateEditor doTraverse(State s0, RoutingRequest options, TraverseMode tr } // If we transitioned into a no-through-traffic area at some point, check if we are exiting it. if (s1.hasEnteredNoThroughTrafficArea()) { - // Only Edges are marked as no-thru, but really we need to avoid creating dominant, pruned states - // on thru _Vertices_. This could certainly be improved somehow. - for (StreetEdge se : Iterables.filter(s1.getVertex().getOutgoing(), StreetEdge.class)) { - if (!se.isNoThruTraffic()) { - // This vertex has at least one through-traffic edge. We can't dominate it with a no-thru state. - return null; - } - } + boolean allEdgesThruTraffic = s1.getVertex().getOutgoing().stream() + .filter(se -> se instanceof StreetEdge) + .allMatch(se -> !((StreetEdge) se).isNoThruTraffic()); + + if (allEdgesThruTraffic) return null; } } From 3d8ea1e0a985a6cfc54b7ec02a286094ca88c200 Mon Sep 17 00:00:00 2001 From: TeemuP Date: Wed, 19 Dec 2018 19:28:40 +0200 Subject: [PATCH 2/2] Ignore NTT when reverse optimizing, use upstream NTT check --- .../routing/edgetype/StreetEdge.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java b/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java index 0975b225629..f48f412dcf8 100644 --- a/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java +++ b/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java @@ -401,18 +401,24 @@ private StateEditor doTraverse(State s0, RoutingRequest options, TraverseMode tr s1.setBackWalkingBike(walkingBike); /* Handle no through traffic areas. */ - if (this.isNoThruTraffic()) { - // Record transition into no-through-traffic area. - if (backEdge instanceof StreetEdge && !((StreetEdge)backEdge).isNoThruTraffic()) { - s1.setEnteredNoThroughTrafficArea(); - } - // If we transitioned into a no-through-traffic area at some point, check if we are exiting it. - if (s1.hasEnteredNoThroughTrafficArea()) { - boolean allEdgesThruTraffic = s1.getVertex().getOutgoing().stream() - .filter(se -> se instanceof StreetEdge) - .allMatch(se -> !((StreetEdge) se).isNoThruTraffic()); - - if (allEdgesThruTraffic) return null; + if (!s0.getReverseOptimizing()) { + if (this.isNoThruTraffic()) { + // Record transition into no-through-traffic area. + if (backEdge instanceof StreetEdge && !((StreetEdge) backEdge).isNoThruTraffic()) { + s1.setEnteredNoThroughTrafficArea(); + } + // If we transitioned into a no-through-traffic area at some point, check if we are exiting it. + if (s1.hasEnteredNoThroughTrafficArea()) { + // Only Edges are marked as no-thru, but really we need to avoid creating dominant, pruned states + // on thru _Vertices_. This could certainly be improved somehow. + for (StreetEdge se : Iterables.filter(s1.getVertex().getOutgoing(), StreetEdge.class)) { + if (!se.isNoThruTraffic()) { + + // This vertex has at least one through-traffic edge. We can't dominate it with a no-thru state. + return null; + } + } + } } } @@ -613,7 +619,7 @@ private void writeObject(ObjectOutputStream out) throws IOException { public String toString() { return "StreetEdge(" + getId() + ", " + name + ", " + fromv + " -> " + tov + " length=" + this.getDistance() + " carSpeed=" + this.getCarSpeed() - + " permission=" + this.getPermission() + " ref=" + this.getRef() + ")"; + + " permission=" + this.getPermission() + " ref=" + this.getRef() + " NTT=" + this.isNoThruTraffic() + ")"; } @Override