16
16
import org .slf4j .Logger ;
17
17
import org .slf4j .LoggerFactory ;
18
18
import static com .conveyal .r5 .streets .StreetRouter .State .RoutingVariable ;
19
+ import static com .conveyal .r5 .transit .TransitLayer .WALK_DISTANCE_LIMIT_METERS ;
19
20
20
21
import java .io .Serializable ;
21
22
import java .util .ArrayList ;
@@ -57,6 +58,12 @@ public class LinkedPointSet implements Serializable {
57
58
static final int BICYCLE_DISTANCE_LINKING_LIMIT_METERS = 2000 ;
58
59
59
60
static final int CAR_TIME_LINKING_LIMIT_SECONDS = 20 * 60 ;
61
+ /**
62
+ * Limit to use when building linkageCostTables, re-calculated for different streetModes as needed, using the
63
+ * constants specified above. The value should be larger than any per-leg street mode limits that can be requested
64
+ * in the UI.
65
+ */
66
+ int linkingDistanceLimitMeters = WALK_DISTANCE_LIMIT_METERS ;
60
67
61
68
// Fair to assume that people walk from nearest OSM way to their ultimate destination? Should we just use the
62
69
// walk speed from the analysis request?
@@ -121,7 +128,7 @@ public LinkedPointSet (PointSet pointSet, StreetLayer streetLayer, StreetMode st
121
128
122
129
// The regions within which we want to link points to edges, then connect transit stops to points.
123
130
// Null means relink and rebuild everything, but this will be constrained below if a base linkage was supplied.
124
- Geometry treeRebuildZone = null ;
131
+ Geometry linkageCostRebuildZone = null ;
125
132
126
133
if (baseLinkage != null && (
127
134
baseLinkage .pointSet != pointSet ||
@@ -161,7 +168,18 @@ public LinkedPointSet (PointSet pointSet, StreetLayer streetLayer, StreetMode st
161
168
// transit stops, we still need to re-link points and rebuild stop trees (both the trees to the vertices
162
169
// and the trees to the points, because some existing stop-to-vertex trees might not include new splitter
163
170
// vertices).
164
- treeRebuildZone = streetLayer .scenarioEdgesBoundingGeometry (TransitLayer .WALK_DISTANCE_LIMIT_METERS );
171
+
172
+ if (streetMode != StreetMode .WALK ) {
173
+ // limit already set for WALK.
174
+ } else if (streetMode == StreetMode .BICYCLE ) {
175
+ linkingDistanceLimitMeters = BICYCLE_DISTANCE_LINKING_LIMIT_METERS ;
176
+ } else if (streetMode == StreetMode .CAR ) {
177
+ linkingDistanceLimitMeters = CAR_TIME_LINKING_LIMIT_SECONDS * MAX_CAR_SPEED_METERS_PER_SECOND ;
178
+ } else {
179
+ throw new UnsupportedOperationException ("Unrecognized streetMode" );
180
+ }
181
+
182
+ linkageCostRebuildZone = streetLayer .scenarioEdgesBoundingGeometry (linkingDistanceLimitMeters );
165
183
}
166
184
167
185
// If dealing with a scenario, pad out the stop trees list from the base linkage to match the new stop count.
@@ -174,7 +192,7 @@ public LinkedPointSet (PointSet pointSet, StreetLayer streetLayer, StreetMode st
174
192
175
193
// Second, make a table of linkage costs (distance or time) from each transit stop to the points in this
176
194
// PointSet.
177
- this .makeStopToPointLinkageCostTables (treeRebuildZone );
195
+ this .makeStopToPointLinkageCostTables (linkageCostRebuildZone );
178
196
179
197
}
180
198
0 commit comments