@@ -114,6 +114,7 @@ public static FeedMetadata from(GtfsFeedContainer feedContainer, ImmutableSet<St
114
114
(GtfsTableContainer <GtfsCalendarDate , ?>)
115
115
feedContainer .getTableForFilename (GtfsCalendarDate .FILENAME ).get ());
116
116
}
117
+
117
118
feedMetadata .loadSpecFeatures (feedContainer );
118
119
return feedMetadata ;
119
120
}
@@ -195,25 +196,41 @@ private void loadDeviatedFixedRouteFeature(GtfsFeedContainer feedContainer) {
195
196
}
196
197
197
198
private boolean hasAtLeastOneTripWithAllFields (GtfsFeedContainer feedContainer ) {
198
- var optionalStopTimeTable = feedContainer .getTableForFilename (GtfsStopTime .FILENAME );
199
- if (optionalStopTimeTable .isPresent ()) {
200
- for (GtfsEntity entity : optionalStopTimeTable .get ().getEntities ()) {
201
- if (entity instanceof GtfsStopTime ) {
202
- GtfsStopTime stopTime = (GtfsStopTime ) entity ;
203
- return stopTime .hasTripId ()
204
- && stopTime .tripId () != null
205
- && stopTime .hasLocationId ()
206
- && stopTime .locationId () != null
207
- && stopTime .hasStopId ()
208
- && stopTime .stopId () != null
209
- && stopTime .hasArrivalTime ()
210
- && stopTime .arrivalTime () != null
211
- && stopTime .hasDepartureTime ()
212
- && stopTime .departureTime () != null ;
213
- }
214
- }
215
- }
216
- return false ;
199
+ return feedContainer
200
+ .getTableForFilename (GtfsStopTime .FILENAME )
201
+ .map (table -> (GtfsStopTimeTableContainer ) table )
202
+ .map (GtfsStopTimeTableContainer ::byTripIdMap )
203
+ .map (
204
+ byTripIdMap ->
205
+ byTripIdMap .asMap ().values ().stream ()
206
+ .anyMatch (
207
+ gtfsStopTimes -> {
208
+ boolean hasTripId = false ,
209
+ hasLocationId = false ,
210
+ hasStopId = false ,
211
+ hasArrivalTime = false ,
212
+ hasDepartureTime = false ;
213
+
214
+ for (GtfsStopTime stopTime : gtfsStopTimes ) {
215
+ hasTripId |= stopTime .hasTripId ();
216
+ hasLocationId |= stopTime .hasLocationId ();
217
+ hasStopId |= stopTime .hasStopId ();
218
+ hasArrivalTime |= stopTime .hasArrivalTime ();
219
+ hasDepartureTime |= stopTime .hasDepartureTime ();
220
+
221
+ // Early return if all fields are found for this trip
222
+ if (hasTripId
223
+ && hasLocationId
224
+ && hasStopId
225
+ && hasArrivalTime
226
+ && hasDepartureTime ) {
227
+ return true ;
228
+ }
229
+ }
230
+ // Continue checking other trips
231
+ return false ;
232
+ }))
233
+ .orElse (false );
217
234
}
218
235
219
236
private void loadZoneBasedDemandResponsiveTransitFeature (GtfsFeedContainer feedContainer ) {
@@ -228,11 +245,7 @@ private boolean hasAtLeastOneTripWithOnlyLocationId(GtfsFeedContainer feedContai
228
245
for (GtfsEntity entity : optionalStopTimeTable .get ().getEntities ()) {
229
246
if (entity instanceof GtfsStopTime ) {
230
247
GtfsStopTime stopTime = (GtfsStopTime ) entity ;
231
- if (stopTime .hasTripId ()
232
- && stopTime .tripId () != null
233
- && stopTime .hasLocationId ()
234
- && stopTime .locationId () != null
235
- && (!stopTime .hasStopId () || stopTime .stopId () == null )) {
248
+ if (stopTime .hasTripId () && stopTime .hasLocationId () && (!stopTime .hasStopId ())) {
236
249
return true ;
237
250
}
238
251
}
0 commit comments