-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/main/java/com/conveyal/r5/analyst/cluster/SelectedLink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.conveyal.r5.analyst.cluster; | ||
|
||
import com.conveyal.r5.transit.TransitLayer; | ||
import com.conveyal.r5.transit.TransportNetworkCache; | ||
import com.conveyal.r5.transit.TripPattern; | ||
import org.locationtech.jts.geom.Envelope; | ||
import org.locationtech.jts.geom.LineString; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* For Selected Link Analysis. | ||
* | ||
* Simplifications: | ||
* Assumes all trips on the same pattern have the same geometry. | ||
* | ||
* TripPattern.getHopGeometries usually returns straight lines because TripPattern.shape is null (it is hard-wired to | ||
* not save shapes in TransitLayers). However, the GTFS MapDBs should have the shapes for each trip. This is how we | ||
* show them in GtfsController making VectorMapTiles. In fact we already have spatial index capabilities: | ||
* gtfsCache.patternShapes.queryEnvelope(bundleScopedFeedId, tile.envelope) | ||
* See L206-209 of GtfsController. However this does not retain enough information about the segments between stops | ||
* in the patterns, and uses a lot of space for all those geometries. | ||
* | ||
* We'll need to turn on shape storage in the TripPatterns, or otherwise iterate through all of them in a streaming | ||
* fashion to record every one that passes through the bounding box. | ||
* | ||
* Do the workers have access to the GTFS files or not? | ||
* WorkerComponents has a TransportNetworkCache which is injected into the AnalysisWorker constructor. This is the only | ||
* path to access a GtfsCache which is private, so we need a method on TransportNetworkCache. | ||
*/ | ||
public class SelectedLink { | ||
|
||
public SelectedLink (TransportNetworkCache transportNetworkCache, SelectionBox box) { | ||
for (TripPattern pattern : transit.tripPatterns) { | ||
for (LineString hopGeoms : pattern.getHopGeometries(transit)) { | ||
|
||
} | ||
} | ||
} | ||
|
||
public SelectedLink (SelectionBox box, TransitLayer transit) { | ||
for (TripPattern pattern : transit.tripPatterns) { | ||
for (LineString hopGeoms : pattern.getHopGeometries(transit)) { | ||
|
||
} | ||
} | ||
} | ||
|
||
/** | ||
* An alternate way of specifying a bounding box where there is a central point of interest and a margin of error | ||
* around it. Some points at the corners of the bounding box are farther away than the radius (which is the radius | ||
* of a circle inscribed in the bounding box). | ||
*/ | ||
public static class SelectionBox { | ||
double lon; | ||
double lat; | ||
double radiusMeters; | ||
public Envelope toEnvelope () { | ||
Envelope env = new Envelope(); | ||
env.expandToInclude(lon, lat); | ||
env.expandBy(radiusMeters); // FIXME convert to lon and lat degrees | ||
} | ||
} | ||
|
||
/** | ||
* Uniquely identifies a segment between two subsequent stops on a TripPattern. | ||
* This allows us to record in advance which segments pass through the link selection box. | ||
*/ | ||
public static class TripPatternSegment { | ||
TripPattern tripPattern; | ||
int tripPatternIndex; // The integer ID of this tripPattern as a Raptor "route" in R5 routing. | ||
int fromStopIndex; // Not the GTFS stop sequence number, the internal R5 index within the pattern. | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters