@@ -50,14 +50,17 @@ public class SelectLink extends Modification {
50
50
51
51
private int nPatternsWithoutShapes = 0 ;
52
52
53
+ private int nPatternsWithoutGtfs = 0 ;
54
+
53
55
@ Override
54
56
public boolean resolve (TransportNetwork network ) {
55
57
// Convert the incoming description of the selected link area to a Geometry for computing intersections.
56
58
boxPolygon = polygonForEnvelope (envelopeForCircle (lon , lat , radiusMeters ));
57
59
// Iterate over all TripPatterns in the TransitLayer and ensure that we can associate a feed with each one.
58
60
// These feeds must have been previously supplied with the injectGtfs() method. The feed IDs recorded in the
59
61
// TripPatterns are not bundle-scoped. Check that a feed with a correctly de-scoped ID was supplied for every
60
- // TripPattern in this TransitLayer.
62
+ // TripPattern in this TransitLayer. Note that this only applies to patterns in the base network - other
63
+ // modifications in the scenario such as add-trips can create new patterns that don't reference any GTFS.
61
64
for (TripPattern tripPattern : network .transitLayer .tripPatterns ) {
62
65
String feedId = feedIdForTripPattern (tripPattern );
63
66
if (isNullOrEmpty (feedId )) {
@@ -80,15 +83,23 @@ public boolean apply(TransportNetwork network) {
80
83
81
84
// During raptor search, paths are recorded in terms of pattern and stop index numbers rather than
82
85
// TripPattern and Stop instance references, so iterate over the numbers.
83
- for (int patternIndex = 0 ; patternIndex < network .transitLayer .tripPatterns .size (); patternIndex ++) {
84
- TripPattern tripPattern = network .transitLayer .tripPatterns .get (patternIndex );
86
+ final List <TripPattern > patterns = network .transitLayer .tripPatterns ;
87
+ for (int patternIndex = 0 ; patternIndex < patterns .size (); patternIndex ++) {
88
+ TripPattern tripPattern = patterns .get (patternIndex );
85
89
// Make a sacrificial protective copy to avoid interfering with other requests using this network.
86
90
// We're going to add shape data to this TripPattern then throw it away immediately afterward.
87
91
// Be careful not to use a reference to this clone as a key in any Maps, it will not match TransitLayer.
88
92
tripPattern = tripPattern .clone ();
89
93
String feedId = feedIdForTripPattern (tripPattern );
90
94
GTFSFeed feed = feedForUnscopedId .get (feedId );
91
- TransitLayer .addShapeToTripPattern (feed , tripPattern );
95
+ if (feed == null ) {
96
+ // We could not find any feed ID on this pattern, or the apparent feed ID does not match any known feed.
97
+ // Since feeds for all patterns were all verified in apply(), this means the pattern must have been
98
+ // added by another modification in the scenario.
99
+ nPatternsWithoutGtfs += 1 ;
100
+ } else {
101
+ TransitLayer .addShapeToTripPattern (feed , tripPattern );
102
+ }
92
103
if (tripPattern .shape == null ) {
93
104
nPatternsWithoutShapes += 1 ;
94
105
}
@@ -105,9 +116,14 @@ public boolean apply(TransportNetwork network) {
105
116
hopsInTripPattern .put (patternIndex , intersectedHops .toArray ());
106
117
}
107
118
}
119
+ if (nPatternsWithoutGtfs > 0 ) {
120
+ addInfo ("Of %d patterns, %d did not reference any GTFS (apparently generated by scenario)." .formatted (
121
+ patterns .size (), nPatternsWithoutGtfs
122
+ ));
123
+ }
108
124
if (nPatternsWithoutShapes > 0 ) {
109
- addInfo ( "Out of %d patterns, %d had no shapes and used straight lines." .formatted (
110
- network . transitLayer . tripPatterns .size (), nPatternsWithoutShapes
125
+ addInfo ("Of %d patterns, %d had no shapes and used straight lines." .formatted (
126
+ patterns .size (), nPatternsWithoutShapes
111
127
));
112
128
}
113
129
// After finding all links (TripPattern hops) in the SelectedLink area, release the GTFSFeeds which don't really
0 commit comments