Skip to content

Commit 55e28a8

Browse files
fix(MergeLineContext): Process GTFS+ timepoints table using logic og trips table.
1 parent b58e73b commit 55e28a8

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

src/main/java/com/conveyal/datatools/manager/jobs/feedmerge/MergeLineContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public static MergeLineContext create(MergeFeedsJob job, Table table, ZipOutputS
9595
case "stops":
9696
return new StopsMergeLineContext(job, table, out);
9797
case "trips":
98+
case "timepoints":
99+
// Use same merge logic to filter out trips in both tables.
98100
return new TripsMergeLineContext(job, table, out);
99101
default:
100102
return new MergeLineContext(job, table, out);

src/test/java/com/conveyal/datatools/manager/jobs/MergeFeedsJobTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.conveyal.datatools.DatatoolsTest;
44
import com.conveyal.datatools.UnitTest;
55
import com.conveyal.datatools.manager.auth.Auth0UserProfile;
6+
import com.conveyal.datatools.manager.gtfsplus.GtfsPlusValidation;
67
import com.conveyal.datatools.manager.jobs.feedmerge.MergeFeedsType;
78
import com.conveyal.datatools.manager.jobs.feedmerge.MergeStrategy;
89
import com.conveyal.datatools.manager.models.FeedSource;
@@ -421,7 +422,7 @@ void mergeMTCShouldHandleMatchingTripIdsWithSameSignature() throws SQLException
421422
* {@link MergeStrategy#CHECK_STOP_TIMES} strategy correctly and drop unused future service ids.
422423
*/
423424
@Test
424-
void mergeMTCShouldHandleMatchingTripIdsAndDropUnusedFutureCalendar() throws SQLException {
425+
void mergeMTCShouldHandleMatchingTripIdsAndDropUnusedFutureCalendar() throws Exception {
425426
Set<FeedVersion> versions = new HashSet<>();
426427
versions.add(fakeTransitBase);
427428
versions.add(fakeTransitSameSignatureTrips2);
@@ -458,13 +459,25 @@ void mergeMTCShouldHandleMatchingTripIdsAndDropUnusedFutureCalendar() throws SQL
458459
// The calendar_dates entry should be preserved, but remapped to a different id.
459460
assertRowCountInTable(mergedNamespace, "calendar_dates", 1);
460461

461-
// The GTFS+ calendar_attributes table should contain the same number of entries as the calendar table.
462+
// The GTFS+ calendar_attributes table should contain the same number of entries as the calendar table
463+
// (reported by MTC).
462464
assertEquals(
463465
3,
464466
mergeFeedsJob.mergeFeedsResult.linesPerTable.get("calendar_attributes").intValue(),
465467
"Merged calendar_dates table count should equal expected value."
466468
);
467469

470+
// The GTFS+ timepoints table should not contain any trip ids not in the trips table
471+
// (reported by MTC).
472+
GtfsPlusValidation validation = GtfsPlusValidation.validate(mergeFeedsJob.mergedVersion.id);
473+
assertEquals(
474+
0L,
475+
validation.issues.stream().filter(
476+
issue -> issue.tableId.equals("timepoints") && issue.fieldName.equals("trip_id")
477+
).count(),
478+
"There should not be trip_id issues in the GTFS+ timepoints table."
479+
);
480+
468481
assertNoUnusedServiceIds(mergedNamespace);
469482
assertNoRefIntegrityErrors(mergedNamespace);
470483
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_type,drop_off_type,shape_dist_traveled,timepoint
22
trip3,07:00:00,07:00:00,4u6g,1,,0,0,0.0000000,
33
trip3,07:01:00,07:01:00,johv,2,,0,0,341.4491961,
4-
only-calendar-trip1,07:00:00,07:00:00,4u6g,1,,0,0,0.0000000,
5-
only-calendar-trip1,07:01:00,07:01:00,johv,2,,0,0,341.4491961,
64
only-calendar-trip2,07:00:00,07:00:00,johv,1,,0,0,0.0000000,
75
only-calendar-trip2,07:01:00,07:01:00,4u6g,2,,0,0,341.4491961,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
trip_id,stop_id
2+
trip3,4u6g
3+
trip3,johv
4+
only-calendar-trip2,johv
5+
only-calendar-trip2,4u6g
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
trip_id,stop_id
2+
only-calendar-trip1,4u6g
3+
only-calendar-trip1,johv
4+
only-calendar-trip2,johv
5+
only-calendar-trip2,4u6g

0 commit comments

Comments
 (0)