Permalink
Browse files

Merge branch 'master' into linbin

Conflicts:
	opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/TableTripPattern.java
	opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/factory/GTFSPatternHopFactory.java

Master just had one small getter method changed; the conflict looked
worse than it was because a large block of code had been moved into a
nested class in linbin branch.
  • Loading branch information...
2 parents f1d1703 + 7b67bf6 commit 82e2cd459abd3bc6403fdee45cb4ba7c072c2034 @abyrd abyrd committed Aug 16, 2012
Showing with 550 additions and 444 deletions.
  1. +1 −1 opentripplanner-analyst-client/src/main/webapp/index.html
  2. +11 −1 opentripplanner-api-webapp/src/main/java/org/opentripplanner/api/common/RoutingResource.java
  3. +4 −0 opentripplanner-api-webapp/src/main/java/org/opentripplanner/api/ws/GraphMetadata.java
  4. +23 −10 ...ilder/src/main/java/org/opentripplanner/graph_builder/impl/transit_index/TransitIndexBuilder.java
  5. +11 −10 opentripplanner-gui/src/main/java/org/opentripplanner/gui/ShowGraph.java
  6. +5 −6 opentripplanner-gui/src/main/java/org/opentripplanner/gui/VizGui.java
  7. +15 −1 opentripplanner-routing/src/main/java/org/opentripplanner/common/MavenVersion.java
  8. +4 −3 ...ipplanner-routing/src/main/java/org/opentripplanner/routing/algorithm/strategies/WeightTable.java
  9. +10 −3 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/RoutingRequest.java
  10. +218 −3 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/State.java
  11. +6 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/StateData.java
  12. +9 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/StateEditor.java
  13. +2 −1 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/FrequencyBoard.java
  14. +0 −254 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternAlight.java
  15. +1 −1 ...tripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternInterlineDwell.java
  16. +4 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/TableTripPattern.java
  17. +173 −36 .../src/main/java/org/opentripplanner/routing/edgetype/{PatternBoard.java → TransitBoardAlight.java}
  18. +3 −4 ...ner-routing/src/main/java/org/opentripplanner/routing/edgetype/factory/GTFSPatternHopFactory.java
  19. +8 −8 ...ipplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/factory/LocalStopFinder.java
  20. +1 −2 opentripplanner-routing/src/main/java/org/opentripplanner/routing/impl/NycFareServiceImpl.java
  21. +2 −77 opentripplanner-routing/src/main/java/org/opentripplanner/routing/spt/GraphPath.java
  22. +4 −4 ...nner-routing/src/main/java/org/opentripplanner/routing/transit_index/TransitIndexServiceImpl.java
  23. +7 −5 ...tripplanner-routing/src/test/java/org/opentripplanner/routing/edgetype/loader/TestHopFactory.java
  24. +16 −7 ...nner-routing/src/test/java/org/opentripplanner/routing/edgetype/loader/TestPatternHopFactory.java
  25. +3 −2 opentripplanner-routing/src/test/java/org/opentripplanner/routing/patches/TestPatch.java
  26. +7 −3 opentripplanner-updater/src/main/java/org/opentripplanner/updater/stoptime/StoptimeUpdater.java
  27. +2 −2 opentripplanner-webapp/src/main/webapp/js/otp/locale/Portuguese.js
@@ -123,7 +123,7 @@
</span>
<input type="button" value="Download Image" onclick="downloadTool()" class="fullWidth" />
</form>
- -->
+ -->
</div>
<div id="map"> </div>
<script type="text/javascript" src="js/otp/client.js"></script>
@@ -139,7 +139,14 @@
*/
@DefaultValue("0") @QueryParam("clampInitialWait")
protected List<Long> clampInitialWait;
-
+
+ /**
+ * If true, this trip will be reverse-optimized on the fly. Otherwise, reverse-optimization
+ * will occur once a trip has been chosen (in Analyst, it will not be done at all).
+ */
+ @QueryParam("reverseOptimizeOnTheFly")
+ protected List<Boolean> reverseOptimizeOnTheFly;
+
@DefaultValue("-1") @QueryParam("boardSlack")
private List<Integer> boardSlack;
@@ -290,6 +297,9 @@ protected RoutingRequest buildRequest(int n) throws ParameterException {
request.setClampInitialWait(get(clampInitialWait, n, request.getClampInitialWait()));
+ request.setReverseOptimizeOnTheFly(get(reverseOptimizeOnTheFly, n,
+ request.isReverseOptimizeOnTheFly()));
+
return request;
}
@@ -18,6 +18,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.opentripplanner.common.MavenVersion;
import org.opentripplanner.routing.core.TraverseMode;
import org.opentripplanner.routing.edgetype.PatternHop;
import org.opentripplanner.routing.graph.Edge;
@@ -40,6 +41,9 @@
private double centerLongitude;
+ @XmlElement
+ private MavenVersion serverVersion = MavenVersion.VERSION;
+
public GraphMetadata() {
// 0-arg constructor avoids com.sun.xml.bind.v2.runtime.IllegalAnnotationsException
}
@@ -41,8 +41,7 @@
import org.opentripplanner.routing.edgetype.Board;
import org.opentripplanner.routing.edgetype.Dwell;
import org.opentripplanner.routing.edgetype.Hop;
-import org.opentripplanner.routing.edgetype.PatternAlight;
-import org.opentripplanner.routing.edgetype.PatternBoard;
+import org.opentripplanner.routing.edgetype.TransitBoardAlight;
import org.opentripplanner.routing.edgetype.PatternDwell;
import org.opentripplanner.routing.edgetype.PatternHop;
import org.opentripplanner.routing.edgetype.PreAlightEdge;
@@ -324,6 +323,8 @@ private void addAgencies(TransitIndexServiceImpl service) {
}
private void createRouteVariants(Graph graph) {
+ TransitBoardAlight tba;
+
for (TransitVertex gv : IterableLibrary.filter(graph.getVertices(), TransitVertex.class)) {
boolean start = false;
boolean noStart = false;
@@ -341,10 +342,14 @@ private void createRouteVariants(Graph graph) {
|| e instanceof Dwell) {
noStart = true;
}
- if (e instanceof PatternBoard) {
- pattern = ((PatternBoard) e).getPattern();
- trip = pattern.getExemplar();
- start = true;
+ if (e instanceof TransitBoardAlight) {
+ tba = (TransitBoardAlight) e;
+
+ if (tba.isBoarding()) {
+ pattern = tba.getPattern();
+ trip = pattern.getExemplar();
+ start = true;
+ }
}
if (e instanceof Board) {
trip = ((Board) e).getTrip();
@@ -382,7 +387,9 @@ private void createRouteVariants(Graph graph) {
RouteSegment segment = new RouteSegment(gv.getStopId());
segment.hopIn = prevHop;
for (Edge e : gv.getIncoming()) {
- if (e instanceof Board || e instanceof PatternBoard) {
+ if (e instanceof Board ||
+ (e instanceof TransitBoardAlight &&
+ ((TransitBoardAlight) e).isBoarding())) {
segment.board = e;
}
}
@@ -396,7 +403,9 @@ private void createRouteVariants(Graph graph) {
if (e instanceof PatternDwell || e instanceof Dwell) {
segment.dwell = e;
for (Edge e2 : e.getToVertex().getIncoming()) {
- if (e2 instanceof Board || e2 instanceof PatternBoard) {
+ if (e2 instanceof Board ||
+ (e2 instanceof TransitBoardAlight &&
+ ((TransitBoardAlight) e2).isBoarding())) {
segment.board = e2;
}
}
@@ -405,12 +414,16 @@ private void createRouteVariants(Graph graph) {
segment.hopOut = e2;
gv = (TransitVertex) e2.getToVertex();
}
- if (e2 instanceof PatternAlight || e2 instanceof Alight) {
+ if ((e2 instanceof TransitBoardAlight &&
+ !((TransitBoardAlight) e2).isBoarding())
+ || e2 instanceof Alight) {
segment.alight = e2;
}
}
}
- if (e instanceof PatternAlight || e instanceof Alight) {
+ if ((e instanceof TransitBoardAlight &&
+ !((TransitBoardAlight) e).isBoarding())
+ || e instanceof Alight) {
segment.alight = e;
}
}
@@ -40,8 +40,7 @@
import org.opentripplanner.routing.vertextype.TurnVertex;
import org.opentripplanner.routing.edgetype.DelegatingEdgeNarrative;
import org.opentripplanner.routing.graph.Edge;
-import org.opentripplanner.routing.edgetype.PatternAlight;
-import org.opentripplanner.routing.edgetype.PatternBoard;
+import org.opentripplanner.routing.edgetype.TransitBoardAlight;
import org.opentripplanner.routing.edgetype.StreetTransitLink;
import org.opentripplanner.routing.edgetype.StreetTraversalPermission;
import org.opentripplanner.routing.edgetype.StreetEdge;
@@ -364,14 +363,16 @@ private void drawGraphPath(GraphPath gp) {
// mark key vertices
lastLabelY = -999;
labelState(gp.states.getFirst(), "begin");
- for (State s : gp.states) {
- Edge e = s.getBackEdge();
- if (e instanceof PatternBoard) {
- labelState(s, "board");
- } else if (e instanceof PatternAlight) {
- labelState(s, "alight");
- }
- }
+ for (State s : gp.states) {
+ Edge e = s.getBackEdge();
+ if (e instanceof TransitBoardAlight) {
+ if (((TransitBoardAlight) e).isBoarding()) {
+ labelState(s, "board");
+ } else {
+ labelState(s, "alight");
+ }
+ }
+ }
labelState(gp.states.getLast(), "end");
if (VIDEO) {
@@ -66,8 +66,7 @@
import org.opentripplanner.routing.core.RoutingRequest;
import org.opentripplanner.routing.core.GraphBuilderAnnotation;
import org.opentripplanner.routing.edgetype.EdgeWithElevation;
-import org.opentripplanner.routing.edgetype.PatternAlight;
-import org.opentripplanner.routing.edgetype.PatternBoard;
+import org.opentripplanner.routing.edgetype.TransitBoardAlight;
import org.opentripplanner.routing.edgetype.PlainStreetEdge;
import org.opentripplanner.routing.edgetype.TableTripPattern;
import org.opentripplanner.routing.edgetype.TurnEdge;
@@ -488,12 +487,12 @@ public void valueChanged(ListSelectionEvent e) {
// figure out the pattern, if any
TableTripPattern pattern = null;
int stopIndex = 0;
- if (selected instanceof PatternBoard) {
- PatternBoard boardEdge = (PatternBoard) selected;
+ if (selected instanceof TransitBoardAlight && ((TransitBoardAlight) selected).isBoarding()) {
+ TransitBoardAlight boardEdge = (TransitBoardAlight) selected;
pattern = boardEdge.getPattern();
stopIndex = boardEdge.getStopIndex();
- } else if (selected instanceof PatternAlight) {
- PatternAlight alightEdge = (PatternAlight) selected;
+ } else if (selected instanceof TransitBoardAlight && !((TransitBoardAlight) selected).isBoarding()) {
+ TransitBoardAlight alightEdge = (TransitBoardAlight) selected;
pattern = alightEdge.getPattern();
stopIndex = alightEdge.getStopIndex();
} else {
@@ -32,10 +32,24 @@ private static MavenVersion fromProperties() {
return version;
} catch (Exception e) {
LOG.error("Error reading version from properties file: {}", e.getMessage());
- return new MavenVersion("0.0.0-ParseFailure", "0");
+ return new MavenVersion();
}
}
+ private MavenVersion () {
+ // JAXB Marshalling requires classes to have a 0-arg constructor and mutable fields.
+ // otherwise it throws a com.sun.xml.bind.v2.runtime.IllegalAnnotationsException.
+ // It is protecting you against yourself, since you might someday want to
+ // unmarshal that same object in Java.
+ // The 'proper' way of handling this is to make a mutable equivalent of your class,
+ // plus another adapter class that converts between the mutable and immutable
+ // versions. It would be absurd to produce so much boilerplate and verbosity in this
+ // situation, so I am providing a 0-arg constructor with a totally different role:
+ // generating a default version when OTP encounters a problem parsing the
+ // maven-version.properties file.
+ this("0.0.0-ParseFailure", "0");
+ }
+
public MavenVersion (String v, String c) {
version = v;
String [] fields = v.split("\\-");
@@ -32,7 +32,7 @@
import org.opentripplanner.routing.core.TraverseMode;
import org.opentripplanner.routing.core.RoutingRequest;
import org.opentripplanner.routing.edgetype.FreeEdge;
-import org.opentripplanner.routing.edgetype.PatternBoard;
+import org.opentripplanner.routing.edgetype.TransitBoardAlight;
import org.opentripplanner.routing.edgetype.PreBoardEdge;
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.graph.Graph;
@@ -249,8 +249,9 @@ public Void call() throws Exception {
while (!q.isEmpty()) {
Vertex u = q.poll();
for (Edge e : u.getOutgoing()) {
- if (e instanceof PatternBoard) {
- Vertex v = ((PatternBoard) e).getToVertex();
+ if (e instanceof TransitBoardAlight &&
+ ((TransitBoardAlight) e).isBoarding()) {
+ Vertex v = ((TransitBoardAlight) e).getToVertex();
// give onboard vertices same index as their
// corresponding station
stopIndices.put(v, oi);
@@ -242,6 +242,12 @@
public long clampInitialWait;
/**
+ * When true, reverse optimize this search on the fly whenever needed, rather than
+ * reverse-optimizing the entire path when it's done.
+ */
+ public boolean reverseOptimizeOnTheFly = false;
+
+ /**
* The routing context used to actually carry out this search. It is important to build States
* from TraverseOptions rather than RoutingContexts, and just keep a reference to the context
* in the TraverseOptions, rather than using RoutingContexts for everything because in some
@@ -261,7 +267,6 @@
/** A transit stop that this trip must start from */
private AgencyAndId startingTransitStopId;
-
/* CONSTRUCTORS */
/** Constructor for options; modes defaults to walk and transit */
@@ -681,7 +686,8 @@ public boolean equals(Object o) {
&& bikeRentalDropoffCost == other.bikeRentalDropoffCost
&& useBikeRentalAvailabilityInformation == other.useBikeRentalAvailabilityInformation
&& extensions.equals(other.extensions)
- && clampInitialWait == other.clampInitialWait;
+ && clampInitialWait == other.clampInitialWait
+ && reverseOptimizeOnTheFly == other.reverseOptimizeOnTheFly;
}
/** Equality and hashCode should not consider the routing context, to allow SPT caching. */
@@ -702,7 +708,8 @@ public int hashCode() {
+ new Double(triangleSlopeFactor).hashCode() * 136372361
+ new Double(triangleTimeFactor).hashCode() * 790052899
+ new Double(stairsReluctance).hashCode() * 315595321
- + new Long(clampInitialWait).hashCode() * 209477;
+ + new Long(clampInitialWait).hashCode() * 209477
+ + new Boolean(reverseOptimizeOnTheFly).hashCode() * 95112799;
if (batch) {
hashCode *= -1;
hashCode += to.hashCode() * 1327144003;
Oops, something went wrong.

0 comments on commit 82e2cd4

Please sign in to comment.