From 21879f9e5d4af5921926fa4f567af070089f3925 Mon Sep 17 00:00:00 2001 From: Arne Seime Date: Thu, 1 Sep 2016 16:45:37 +0200 Subject: [PATCH 01/10] When creating backStreet AreaEdge, wheelchairAccessible is set twice on 'street' instead of on both 'steet' and 'backStreet' --- .../graph_builder/module/osm/WalkableAreaBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java index 407d2d3f607..b2691255108 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java @@ -454,7 +454,7 @@ private void createSegments(OSMNode fromNode, OSMNode toNode, IntersectionVertex } if (areaEntity.isTagFalse("wheelchair")) { - street.setWheelchairAccessible(false); + backStreet.setWheelchairAccessible(false); } backStreet.setStreetClass(cls); From c7d06a5ae405fae36157e5ba90faeab7ba5a580b Mon Sep 17 00:00:00 2001 From: Vivek <3vivekb@gmail.com> Date: Fri, 23 Sep 2016 17:34:28 -0700 Subject: [PATCH 02/10] Web Link Typo --- docs/Deployments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Deployments.md b/docs/Deployments.md index 991a9415510..ecd5a120a8a 100644 --- a/docs/Deployments.md +++ b/docs/Deployments.md @@ -5,7 +5,7 @@ Following are known deployments of OTP in an agency-sponsored production capacity. * **New York State** Department of Transportation's 511 [transit trip planner](http://511ny.org/tripplanner/default.aspx) provides itineraries for public transit systems throughout the state in a single unified OTP instance. -* **Arlington, Virginia**'s [commute planning site](http://www.carfreea2z.com/) for the Washington, DC metropolitan area depends on OpenTripPlanner to weigh the costs and benefits of various travel options, making use of profile routing. +* **Arlington, Virginia**'s [commute planning site](http://www.carfreeatoz.com/) for the Washington, DC metropolitan area depends on OpenTripPlanner to weigh the costs and benefits of various travel options, making use of profile routing. * **Portland, Oregon, USA** TriMet [Regional Trip Planner](http://ride.trimet.org), the agency originally behind OpenTripPlanner. * The **Helsinki** Regional Transport Authority (HSL) [trip planner](https://digitransit.fi/en/) based on OpenTripPlanner is in public beta as of spring 2016. Source code for their new UI is [available on Github](https://github.com/HSLdevcom/digitransit-ui). * [**Valencia, Spain**](http://www.emtvalencia.es/geoportal/?lang=en_otp) from the Municipal Transport Company of Valencia S.A.U. From 805920fd21fea7d145506a2004c463ce4b721b92 Mon Sep 17 00:00:00 2001 From: David Emory Date: Wed, 16 Nov 2016 18:33:44 -0500 Subject: [PATCH 03/10] Add disableAlertFiltering API flag. Addresses #2351 --- .../api/common/RoutingResource.java | 6 ++++++ .../api/resource/GraphPathToTripPlanConverter.java | 14 +++++++------- .../org/opentripplanner/profile/StreetSegment.java | 2 +- .../routing/core/RoutingRequest.java | 6 +++++- .../resource/GraphPathToTripPlanConverterTest.java | 12 ++++++------ 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/opentripplanner/api/common/RoutingResource.java b/src/main/java/org/opentripplanner/api/common/RoutingResource.java index c20a8056eb1..3b71da50ad6 100644 --- a/src/main/java/org/opentripplanner/api/common/RoutingResource.java +++ b/src/main/java/org/opentripplanner/api/common/RoutingResource.java @@ -350,6 +350,9 @@ public abstract class RoutingResource { @QueryParam("maxHours") private Double maxHours; + @QueryParam("disableAlertFiltering") + private Boolean disableAlertFiltering; + /* * somewhat ugly bug fix: the graphService is only needed here for fetching per-graph time zones. * this should ideally be done when setting the routing context, but at present departure/ @@ -573,6 +576,9 @@ protected RoutingRequest buildRequest() throws ParameterException { if (maxHours != null) request.maxHours = maxHours; + if (disableAlertFiltering != null) + request.disableAlertFiltering = disableAlertFiltering; + //getLocale function returns defaultLocale if locale is null request.locale = ResourceBundleSingleton.INSTANCE.getLocale(locale); return request; diff --git a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java index 3f61638ed99..7d0236641a9 100644 --- a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java +++ b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java @@ -82,7 +82,7 @@ public static TripPlan generatePlan(List paths, RoutingRequest reques TripPlan plan = new TripPlan(from, to, request.getDateTime()); for (GraphPath path : paths) { - Itinerary itinerary = generateItinerary(path, request.showIntermediateStops, requestedLocale); + Itinerary itinerary = generateItinerary(path, request.showIntermediateStops, request.disableAlertFiltering, requestedLocale); itinerary = adjustItinerary(request, itinerary); plan.addItinerary(itinerary); } @@ -129,7 +129,7 @@ private static Itinerary adjustItinerary(RoutingRequest request, Itinerary itine * @param showIntermediateStops Whether to include intermediate stops in the itinerary or not * @return The generated itinerary */ - public static Itinerary generateItinerary(GraphPath path, boolean showIntermediateStops, Locale requestedLocale) { + public static Itinerary generateItinerary(GraphPath path, boolean showIntermediateStops, boolean disableAlertFiltering, Locale requestedLocale) { Itinerary itinerary = new Itinerary(); State[] states = new State[path.states.size()]; @@ -150,7 +150,7 @@ public static Itinerary generateItinerary(GraphPath path, boolean showIntermedia } for (State[] legStates : legsStates) { - itinerary.addLeg(generateLeg(graph, legStates, showIntermediateStops, requestedLocale)); + itinerary.addLeg(generateLeg(graph, legStates, showIntermediateStops, disableAlertFiltering, requestedLocale)); } addWalkSteps(graph, itinerary.legs, legsStates, requestedLocale); @@ -287,7 +287,7 @@ private static State[][] sliceStates(State[] states) { * @param showIntermediateStops Whether to include intermediate stops in the leg or not * @return The generated leg */ - private static Leg generateLeg(Graph graph, State[] states, boolean showIntermediateStops, Locale requestedLocale) { + private static Leg generateLeg(Graph graph, State[] states, boolean showIntermediateStops, boolean disableAlertFiltering, Locale requestedLocale) { Leg leg = new Leg(); Edge[] edges = new Edge[states.length - 1]; @@ -320,7 +320,7 @@ private static Leg generateLeg(Graph graph, State[] states, boolean showIntermed leg.rentedBike = states[0].isBikeRenting() && states[states.length - 1].isBikeRenting(); - addModeAndAlerts(graph, leg, states, requestedLocale); + addModeAndAlerts(graph, leg, states, disableAlertFiltering, requestedLocale); if (leg.isTransitLeg()) addRealTimeData(leg, states); return leg; @@ -517,7 +517,7 @@ private static void calculateElevations(Itinerary itinerary, Edge[] edges) { * @param leg The leg to add the mode and alerts to * @param states The states that go with the leg */ - private static void addModeAndAlerts(Graph graph, Leg leg, State[] states, Locale requestedLocale) { + private static void addModeAndAlerts(Graph graph, Leg leg, State[] states, boolean disableAlertFiltering, Locale requestedLocale) { for (State state : states) { TraverseMode mode = state.getBackMode(); Set alerts = graph.streetNotesService.getNotes(state); @@ -534,7 +534,7 @@ private static void addModeAndAlerts(Graph graph, Leg leg, State[] states, Local } for (AlertPatch alertPatch : graph.getAlertPatches(edge)) { - if (alertPatch.displayDuring(state)) { + if (disableAlertFiltering || alertPatch.displayDuring(state)) { if (alertPatch.hasTrip()) { // If the alert patch contains a trip and that trip match this leg only add the alert for // this leg. diff --git a/src/main/java/org/opentripplanner/profile/StreetSegment.java b/src/main/java/org/opentripplanner/profile/StreetSegment.java index a6ffcd56b48..5181a3cbd66 100644 --- a/src/main/java/org/opentripplanner/profile/StreetSegment.java +++ b/src/main/java/org/opentripplanner/profile/StreetSegment.java @@ -54,7 +54,7 @@ public StreetSegment (State state) { } //TODO: localize try { - Itinerary itin = GraphPathToTripPlanConverter.generateItinerary(path, false, new Locale("en")); + Itinerary itin = GraphPathToTripPlanConverter.generateItinerary(path, false, true, new Locale("en")); for (Leg leg : itin.legs) { // populate the streetEdges array for (WalkStep walkStep : leg.walkSteps) { diff --git a/src/main/java/org/opentripplanner/routing/core/RoutingRequest.java b/src/main/java/org/opentripplanner/routing/core/RoutingRequest.java index b6413799cf1..2d91a4105e1 100644 --- a/src/main/java/org/opentripplanner/routing/core/RoutingRequest.java +++ b/src/main/java/org/opentripplanner/routing/core/RoutingRequest.java @@ -427,6 +427,9 @@ public class RoutingRequest implements Cloneable, Serializable { /** Accept only paths that use transit (no street-only paths). */ public boolean onlyTransitTrips = false; + /** Option to disable the default filtering of GTFS-RT alerts by time. */ + public boolean disableAlertFiltering = false; + /** Saves split edge which can be split on origin/destination search * * This is used so that TrivialPathException is thrown if origin and destination search would split the same edge @@ -945,7 +948,8 @@ public boolean equals(Object o) { && ignoreRealtimeUpdates == other.ignoreRealtimeUpdates && disableRemainingWeightHeuristic == other.disableRemainingWeightHeuristic && Objects.equal(startingTransitTripId, other.startingTransitTripId) - && useTraffic == other.useTraffic; + && useTraffic == other.useTraffic + && disableAlertFiltering == other.disableAlertFiltering; } /** diff --git a/src/test/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverterTest.java b/src/test/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverterTest.java index ee4584378a6..7cf80bef772 100644 --- a/src/test/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverterTest.java +++ b/src/test/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverterTest.java @@ -128,9 +128,9 @@ public class GraphPathToTripPlanConverterTest { public void testGenerateItinerary() { GraphPath[] graphPaths = buildPaths(); - compare(GraphPathToTripPlanConverter.generateItinerary(graphPaths[0], true, locale), Type.FORWARD); - compare(GraphPathToTripPlanConverter.generateItinerary(graphPaths[1], true, locale), Type.BACKWARD); - compare(GraphPathToTripPlanConverter.generateItinerary(graphPaths[2], true, locale), Type.ONBOARD); + compare(GraphPathToTripPlanConverter.generateItinerary(graphPaths[0], true, false, locale), Type.FORWARD); + compare(GraphPathToTripPlanConverter.generateItinerary(graphPaths[1], true, false, locale), Type.BACKWARD); + compare(GraphPathToTripPlanConverter.generateItinerary(graphPaths[2], true, false, locale), Type.ONBOARD); } /** @@ -142,7 +142,7 @@ public void testEndWithLegSwitch() { // Reuse testGenerateItinerary()'s graph path, but shorten it GraphPath graphPath = new GraphPath(buildPaths()[0].states.get(3), false); - Itinerary itinerary = GraphPathToTripPlanConverter.generateItinerary(graphPath, false, locale); + Itinerary itinerary = GraphPathToTripPlanConverter.generateItinerary(graphPath, false, false, locale); assertEquals(1, itinerary.legs.size()); assertEquals("WALK", itinerary.legs.get(0).mode); @@ -161,7 +161,7 @@ public void testEmptyGraphPath() { GraphPath graphPath = new GraphPath(new State(options), false); - GraphPathToTripPlanConverter.generateItinerary(graphPath, false, locale); + GraphPathToTripPlanConverter.generateItinerary(graphPath, false, false, locale); } /** @@ -185,7 +185,7 @@ public void testLegSwitchOnlyGraphPath() { GraphPath graphPath = new GraphPath(arrive.traverse(intermediate), false); - GraphPathToTripPlanConverter.generateItinerary(graphPath, false, locale); + GraphPathToTripPlanConverter.generateItinerary(graphPath, false, false, locale); } /** From 34a24d183324e01f7e428d53924226bc56b3988b Mon Sep 17 00:00:00 2001 From: Landon Reed Date: Tue, 29 Nov 2016 11:10:51 -0500 Subject: [PATCH 04/10] add log for negative edge length and set to 1mm --- .../routing/edgetype/StreetEdge.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java b/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java index 8c9ae0dc3f2..5acc13aa952 100644 --- a/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java +++ b/src/main/java/org/opentripplanner/routing/edgetype/StreetEdge.java @@ -808,6 +808,10 @@ public P2 split(SplitterVertex v, boolean destructive) { e1 = new StreetEdge((StreetVertex) fromv, v, geoms.first, name, 0, permission, this.isBack()); e2 = new StreetEdge(v, (StreetVertex) tov, geoms.second, name, 0, permission, this.isBack()); + // copy the wayId to the split edges, so we can trace them back to their parent if need be + e1.wayId = this.wayId; + e2.wayId = this.wayId; + // figure the lengths, ensuring that they sum to the length of this edge e1.calculateLengthFromGeometry(); e2.calculateLengthFromGeometry(); @@ -829,6 +833,16 @@ public P2 split(SplitterVertex v, boolean destructive) { e1.length_mm = length_mm - e2.length_mm; } + // TODO: better handle this temporary fix to handle bad edge distance calculation + if (e1.length_mm < 0) { + LOG.error("Edge 1 ({}) split at vertex at {},{} has length {} mm. Setting to 1 mm.", e1.wayId, v.getLat(), v.getLon(), e1.length_mm); + e1.length_mm = 1; + } + if (e2.length_mm < 0) { + LOG.error("Edge 2 ({}) split at vertex at {},{} has length {} mm. Setting to 1 mm.", e2.wayId, v.getLat(), v.getLon(), e2.length_mm); + e2.length_mm = 1; + } + if (e1.length_mm < 0 || e2.length_mm < 0) { e1.tov.removeIncoming(e1); e1.fromv.removeOutgoing(e1); From daf1975936cbf6e97b84681e06669a9e2545f3b4 Mon Sep 17 00:00:00 2001 From: David Emory Date: Tue, 29 Nov 2016 17:55:22 -0500 Subject: [PATCH 05/10] Include turn-by-turn walking directions for transfer legs. See #1707 --- .../resource/GraphPathToTripPlanConverter.java | 14 ++++++++++++++ .../module/DirectTransferGenerator.java | 2 +- .../graph_builder/module/NearbyStopFinder.java | 4 ++++ .../routing/edgetype/SimpleTransfer.java | 16 +++++++++++++--- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java index 7d0236641a9..b5fcf5542d0 100644 --- a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java +++ b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java @@ -726,6 +726,20 @@ public static List generateWalkSteps(Graph graph, State[] states, Walk State onBikeRentalState = null, offBikeRentalState = null; + // Check if this leg is a SimpleTransfer; if so, rebuild state array based on stored transfer edges + if (states.length == 2 && states[1].getBackEdge() instanceof SimpleTransfer) { + SimpleTransfer transferEdge = ((SimpleTransfer) states[1].getBackEdge()); + List transferEdges = transferEdge.getEdges(); + State s = new State(transferEdges.get(0).getFromVertex(), states[0].getOptions()); + ArrayList transferStates = new ArrayList<>(); + transferStates.add(s); + for (Edge e : transferEdges) { + s = e.traverse(s); + transferStates.add(s); + } + states = transferStates.toArray(new State[0]); + } + for (int i = 0; i < states.length - 1; i++) { State backState = states[i]; State forwardState = states[i + 1]; diff --git a/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java b/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java index 28cc41da0a2..086e8f132a3 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java @@ -97,7 +97,7 @@ public void buildGraph(Graph graph, HashMap, Object> extra) { for (NearbyStopFinder.StopAtDistance sd : nearbyStopFinder.findNearbyStopsConsideringPatterns(ts0)) { /* Skip the origin stop, loop transfers are not needed. */ if (sd.tstop == ts0 || pathwayDestinations.contains(sd.tstop)) continue; - new SimpleTransfer(ts0, sd.tstop, sd.dist, sd.geom); + new SimpleTransfer(ts0, sd.tstop, sd.dist, sd.geom, sd.edges); n += 1; } LOG.debug("Linked stop {} to {} nearby stops on other patterns.", ts0.getStop(), n); diff --git a/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java b/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java index 4b80512ff02..5ccec59b91e 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java @@ -176,6 +176,7 @@ public static class StopAtDistance implements Comparable { public TransitStop tstop; public double dist; public LineString geom; + public List edges; public StopAtDistance(TransitStop tstop, double dist) { this.tstop = tstop; @@ -203,6 +204,7 @@ public static StopAtDistance stopAtDistanceForState (State state) { double distance = 0.0; GraphPath graphPath = new GraphPath(state, false); CoordinateArrayListSequence coordinates = new CoordinateArrayListSequence(); + List edges = new ArrayList<>(); for (Edge edge : graphPath.edges) { if (edge instanceof StreetEdge) { LineString geometry = edge.getGeometry(); @@ -214,6 +216,7 @@ public static StopAtDistance stopAtDistanceForState (State state) { } } distance += edge.getDistance(); + edges.add(edge); } } if (coordinates.size() < 2) { // Otherwise the walk step generator breaks. @@ -225,6 +228,7 @@ public static StopAtDistance stopAtDistanceForState (State state) { } StopAtDistance sd = new StopAtDistance((TransitStop) state.getVertex(), distance); sd.geom = geometryFactory.createLineString(new PackedCoordinateSequence.Double(coordinates.toCoordinateArray())); + sd.edges = edges; return sd; } diff --git a/src/main/java/org/opentripplanner/routing/edgetype/SimpleTransfer.java b/src/main/java/org/opentripplanner/routing/edgetype/SimpleTransfer.java index d0d031dd440..9a9c9a4c727 100644 --- a/src/main/java/org/opentripplanner/routing/edgetype/SimpleTransfer.java +++ b/src/main/java/org/opentripplanner/routing/edgetype/SimpleTransfer.java @@ -21,6 +21,8 @@ the License, or (at your option) any later version. import org.opentripplanner.routing.vertextype.TransitStop; import com.vividsolutions.jts.geom.LineString; + +import java.util.List; import java.util.Locale; /** @@ -34,11 +36,17 @@ public class SimpleTransfer extends Edge { private double distance; private LineString geometry; + private List edges; - public SimpleTransfer(TransitStop from, TransitStop to, double distance, LineString geometry) { + public SimpleTransfer(TransitStop from, TransitStop to, double distance, LineString geometry, List edges) { super(from, to); this.distance = distance; this.geometry = geometry; + this.edges = edges; + } + + public SimpleTransfer(TransitStop from, TransitStop to, double distance, LineString geometry) { + this(from, to, distance, geometry, null); } @Override @@ -89,11 +97,13 @@ public double getDistance(){ } - @Override - public LineString getGeometry(){ + @Override + public LineString getGeometry(){ return this.geometry; } + public List getEdges() { return this.edges; } + @Override public String toString() { return "SimpleTransfer " + getName(); From ea7c91aa4f938dd377bc1c4783902b9bb6574403 Mon Sep 17 00:00:00 2001 From: David Emory Date: Thu, 1 Dec 2016 12:20:07 -0500 Subject: [PATCH 06/10] Fix testGenerateItinerary failure --- .../api/resource/GraphPathToTripPlanConverter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java index b5fcf5542d0..d0093dc0290 100644 --- a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java +++ b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java @@ -730,14 +730,16 @@ public static List generateWalkSteps(Graph graph, State[] states, Walk if (states.length == 2 && states[1].getBackEdge() instanceof SimpleTransfer) { SimpleTransfer transferEdge = ((SimpleTransfer) states[1].getBackEdge()); List transferEdges = transferEdge.getEdges(); - State s = new State(transferEdges.get(0).getFromVertex(), states[0].getOptions()); - ArrayList transferStates = new ArrayList<>(); - transferStates.add(s); - for (Edge e : transferEdges) { - s = e.traverse(s); + if (transferEdges != null) { + State s = new State(transferEdges.get(0).getFromVertex(), states[0].getOptions()); + ArrayList transferStates = new ArrayList<>(); transferStates.add(s); + for (Edge e : transferEdges) { + s = e.traverse(s); + transferStates.add(s); + } + states = transferStates.toArray(new State[transferStates.size()]); } - states = transferStates.toArray(new State[0]); } for (int i = 0; i < states.length - 1; i++) { From e15f23da576d5ea03ce23a74add23e82e12a946e Mon Sep 17 00:00:00 2001 From: David Emory Date: Tue, 6 Dec 2016 16:21:36 -0500 Subject: [PATCH 07/10] Include Agency/Route branding in response --- pom.xml | 2 +- .../java/org/opentripplanner/api/model/Leg.java | 15 +++++++++++++-- .../resource/GraphPathToTripPlanConverter.java | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2e8febb15b8..aa3c6ecd259 100644 --- a/pom.xml +++ b/pom.xml @@ -573,7 +573,7 @@ org.onebusaway onebusaway-gtfs - 1.3.5-conveyal-SNAPSHOT + 1.3.5-conveyal-SNAPSHOT-2 diff --git a/src/main/java/org/opentripplanner/api/model/Leg.java b/src/main/java/org/opentripplanner/api/model/Leg.java index 7e35c94ae2f..2bde516d23e 100644 --- a/src/main/java/org/opentripplanner/api/model/Leg.java +++ b/src/main/java/org/opentripplanner/api/model/Leg.java @@ -109,6 +109,10 @@ public class Leg { @JsonSerialize public String agencyUrl; + @XmlAttribute + @JsonSerialize + public String agencyBrandingUrl; + @XmlAttribute @JsonSerialize public int agencyTimeZoneOffset; @@ -193,8 +197,15 @@ public class Leg { @XmlAttribute @JsonSerialize public String serviceDate = null; - - /** + + /** + * For transit leg, the route's branding URL (if one exists). For non-transit legs, null. + */ + @XmlAttribute + @JsonSerialize + public String routeBrandingUrl = null; + + /** * The Place where the leg originates. */ public Place from = null; diff --git a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java index d0093dc0290..e2eb4ae916c 100644 --- a/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java +++ b/src/main/java/org/opentripplanner/api/resource/GraphPathToTripPlanConverter.java @@ -567,6 +567,7 @@ private static void addTripFields(Leg leg, State[] states, Locale requestedLocal leg.agencyId = agency.getId(); leg.agencyName = agency.getName(); leg.agencyUrl = agency.getUrl(); + leg.agencyBrandingUrl = agency.getBrandingUrl(); leg.headsign = states[1].getBackDirection(); leg.route = states[states.length - 1].getBackEdge().getName(requestedLocale); leg.routeColor = route.getColor(); @@ -575,6 +576,7 @@ private static void addTripFields(Leg leg, State[] states, Locale requestedLocal leg.routeShortName = route.getShortName(); leg.routeTextColor = route.getTextColor(); leg.routeType = route.getType(); + leg.routeBrandingUrl = route.getBrandingUrl(); leg.tripId = trip.getId(); leg.tripShortName = trip.getTripShortName(); leg.tripBlockId = trip.getBlockId(); From 0dc1063ea6717a2ddc37d039818581062d350554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Barslett?= Date: Fri, 4 Nov 2016 15:10:20 +0100 Subject: [PATCH 08/10] PruneFloatingIslands with build parameters --- .../graph_builder/GraphBuilder.java | 5 ++++- .../graph_builder/module/PruneFloatingIslands.java | 10 ++++++++-- .../standalone/GraphBuilderParameters.java | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java index bec946cf500..9a74f866b3d 100644 --- a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java +++ b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java @@ -245,7 +245,10 @@ public static GraphBuilder forDirectory(CommandLineParameters params, File dir) osmModule.staticBikeParkAndRide = builderParams.staticBikeParkAndRide; osmModule.staticParkAndRide = builderParams.staticParkAndRide; graphBuilder.addModule(osmModule); - graphBuilder.addModule(new PruneFloatingIslands()); + PruneFloatingIslands pruneFloatingIslands = new PruneFloatingIslands(); + pruneFloatingIslands.setislandWithoutStopsMaxSize(builderParams.islandWithoutStopsMaxSize); + pruneFloatingIslands.setIslandWithStopsMaxSize(builderParams.islandWithStopsMaxSize); + graphBuilder.addModule(pruneFloatingIslands); } if ( hasGTFS ) { List gtfsBundles = Lists.newArrayList(); diff --git a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java index 3d0cb6c0a09..7bdf82e07a0 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java @@ -38,13 +38,13 @@ public class PruneFloatingIslands implements GraphBuilderModule { * this field indicate the maximum size for island without stops * island under this size will be pruned. */ - private int islandWithoutStopsMaxSize = 40; + private int islandWithoutStopsMaxSize; /** * this field indicate the maximum size for island with stops * island under this size will be pruned. */ - private int islandWithStopsMaxSize = 5; + private int islandWithStopsMaxSize; /** * The name for output file for this process. The file will store information about the islands @@ -87,5 +87,11 @@ public void buildGraph(Graph graph, HashMap, Object> extra) { public void checkInputs() { //no inputs } + public void setislandWithoutStopsMaxSize(int islandWithoutStopsMaxSize) { + this.islandWithoutStopsMaxSize = islandWithoutStopsMaxSize; + } + public void setIslandWithStopsMaxSize(int islandWithStopsMaxSize) { + this.islandWithStopsMaxSize = islandWithStopsMaxSize; + } } \ No newline at end of file diff --git a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java index f598869ba2f..d3812ea49ae 100644 --- a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java +++ b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java @@ -116,6 +116,18 @@ public class GraphBuilderParameters { * Maximal distance between stops in meters that will connect consecutive trips that are made with same vehicle */ public int maxInterlineDistance = 200; + + /** + * this field indicate the maximum size for island without stops + * island under this size will be pruned. + */ + public final int islandWithoutStopsMaxSize; + + /** + * this field indicate the maximum size for island with stops + * island under this size will be pruned. + */ + public final int islandWithStopsMaxSize; /** * Set all parameters from the given Jackson JSON tree, applying defaults. @@ -144,6 +156,8 @@ public GraphBuilderParameters(JsonNode config) { staticBikeParkAndRide = config.path("staticBikeParkAndRide").asBoolean(false); maxHtmlAnnotationsPerFile = config.path("maxHtmlAnnotationsPerFile").asInt(1000); maxInterlineDistance = config.path("maxInterlineDistance").asInt(200); + islandWithoutStopsMaxSize = config.path("islandWithoutStopsMaxSize").asInt(40); + islandWithStopsMaxSize = config.path("islandWithStopsMaxSize").asInt(5); } } From 1ee95adadc905bf9b9670a369b769cb7d25c52b6 Mon Sep 17 00:00:00 2001 From: David Emory Date: Thu, 8 Dec 2016 13:40:31 -0500 Subject: [PATCH 09/10] Do not filter edges when including them in SimpleTransfer --- .../opentripplanner/graph_builder/module/NearbyStopFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java b/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java index 5ccec59b91e..97abd75f537 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java @@ -216,8 +216,8 @@ public static StopAtDistance stopAtDistanceForState (State state) { } } distance += edge.getDistance(); - edges.add(edge); } + edges.add(edge); } if (coordinates.size() < 2) { // Otherwise the walk step generator breaks. ArrayList coordinateList = new ArrayList(2); From 03cb80e0c969192fd5f1e6a9065c3aab344c34ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Barslett?= Date: Fri, 16 Dec 2016 10:33:58 +0100 Subject: [PATCH 10/10] Found more intuitive parameter names, fixed typos --- .../graph_builder/GraphBuilder.java | 4 ++-- .../module/PruneFloatingIslands.java | 16 ++++++++-------- .../standalone/GraphBuilderParameters.java | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java index 9a74f866b3d..ef0b384225c 100644 --- a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java +++ b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java @@ -246,8 +246,8 @@ public static GraphBuilder forDirectory(CommandLineParameters params, File dir) osmModule.staticParkAndRide = builderParams.staticParkAndRide; graphBuilder.addModule(osmModule); PruneFloatingIslands pruneFloatingIslands = new PruneFloatingIslands(); - pruneFloatingIslands.setislandWithoutStopsMaxSize(builderParams.islandWithoutStopsMaxSize); - pruneFloatingIslands.setIslandWithStopsMaxSize(builderParams.islandWithStopsMaxSize); + pruneFloatingIslands.setPruningThresholdIslandWithoutStops(builderParams.pruningThresholdIslandWithoutStops); + pruneFloatingIslands.setPruningThresholdIslandWithStops(builderParams.pruningThresholdIslandWithStops); graphBuilder.addModule(pruneFloatingIslands); } if ( hasGTFS ) { diff --git a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java index 7bdf82e07a0..0fa3042ffa6 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java @@ -38,13 +38,13 @@ public class PruneFloatingIslands implements GraphBuilderModule { * this field indicate the maximum size for island without stops * island under this size will be pruned. */ - private int islandWithoutStopsMaxSize; + private int pruningThresholdIslandWithoutStops; /** * this field indicate the maximum size for island with stops * island under this size will be pruned. */ - private int islandWithStopsMaxSize; + private int pruningThresholdIslandWithStops; /** * The name for output file for this process. The file will store information about the islands @@ -72,8 +72,8 @@ public List getPrerequisites() { public void buildGraph(Graph graph, HashMap, Object> extra) { LOG.info("Pruning isolated islands in street network"); - StreetUtils.pruneFloatingIslands(graph, islandWithoutStopsMaxSize, - islandWithStopsMaxSize, islandLogFile); + StreetUtils.pruneFloatingIslands(graph, pruningThresholdIslandWithoutStops, + pruningThresholdIslandWithStops, islandLogFile); if (transitToStreetNetwork == null) { LOG.debug("TransitToStreetNetworkGraphBuilder was not provided to PruneFloatingIslands. Not attempting to reconnect stops."); } else { @@ -87,11 +87,11 @@ public void buildGraph(Graph graph, HashMap, Object> extra) { public void checkInputs() { //no inputs } - public void setislandWithoutStopsMaxSize(int islandWithoutStopsMaxSize) { - this.islandWithoutStopsMaxSize = islandWithoutStopsMaxSize; + public void setPruningThresholdIslandWithoutStops(int pruningThresholdIslandWithoutStops) { + this.pruningThresholdIslandWithoutStops = pruningThresholdIslandWithoutStops; } - public void setIslandWithStopsMaxSize(int islandWithStopsMaxSize) { - this.islandWithStopsMaxSize = islandWithStopsMaxSize; + public void setPruningThresholdIslandWithStops(int pruningThresholdIslandWithStops) { + this.pruningThresholdIslandWithStops = pruningThresholdIslandWithStops; } } \ No newline at end of file diff --git a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java index d3812ea49ae..94c491f800b 100644 --- a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java +++ b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java @@ -118,16 +118,16 @@ public class GraphBuilderParameters { public int maxInterlineDistance = 200; /** - * this field indicate the maximum size for island without stops - * island under this size will be pruned. + * This field indicates the pruning threshold for islands without stops. + * Any such island under this size will be pruned. */ - public final int islandWithoutStopsMaxSize; + public final int pruningThresholdIslandWithoutStops; /** - * this field indicate the maximum size for island with stops - * island under this size will be pruned. + * This field indicates the pruning threshold for islands with stops. + * Any such island under this size will be pruned. */ - public final int islandWithStopsMaxSize; + public final int pruningThresholdIslandWithStops; /** * Set all parameters from the given Jackson JSON tree, applying defaults. @@ -156,8 +156,8 @@ public GraphBuilderParameters(JsonNode config) { staticBikeParkAndRide = config.path("staticBikeParkAndRide").asBoolean(false); maxHtmlAnnotationsPerFile = config.path("maxHtmlAnnotationsPerFile").asInt(1000); maxInterlineDistance = config.path("maxInterlineDistance").asInt(200); - islandWithoutStopsMaxSize = config.path("islandWithoutStopsMaxSize").asInt(40); - islandWithStopsMaxSize = config.path("islandWithStopsMaxSize").asInt(5); + pruningThresholdIslandWithoutStops = config.path("islandWithoutStopsMaxSize").asInt(40); + pruningThresholdIslandWithStops = config.path("islandWithStopsMaxSize").asInt(5); } }