corequery-gtfs 0.10.4 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conversion/service-converter.d.ts +7 -3
- package/dist/conversion/service-converter.js +60 -98
- package/dist/conversion/service-converter.js.map +1 -1
- package/dist/data/gtfs-feed.d.ts +3 -4
- package/dist/data/gtfs-feed.js.map +1 -1
- package/dist/data/gtfs-realtime-data.d.ts +6 -7
- package/dist/data/gtfs-realtime-data.js +7 -11
- package/dist/data/gtfs-realtime-data.js.map +1 -1
- package/dist/data/gtfs-schedule-data.d.ts +1 -1
- package/dist/data/trip/added/gtfs-added-trip-originating-movement.d.ts +24 -0
- package/dist/data/trip/added/gtfs-added-trip-originating-movement.js +40 -0
- package/dist/data/trip/added/gtfs-added-trip-originating-movement.js.map +1 -0
- package/dist/data/trip/added/gtfs-added-trip-passing-movement.d.ts +14 -0
- package/dist/data/trip/added/gtfs-added-trip-passing-movement.js +24 -0
- package/dist/data/trip/added/gtfs-added-trip-passing-movement.js.map +1 -0
- package/dist/data/trip/added/gtfs-added-trip-regular-movement.d.ts +30 -0
- package/dist/data/trip/added/gtfs-added-trip-regular-movement.js +51 -0
- package/dist/data/trip/added/gtfs-added-trip-regular-movement.js.map +1 -0
- package/dist/data/trip/added/gtfs-added-trip-terminating-movement.d.ts +24 -0
- package/dist/data/trip/added/gtfs-added-trip-terminating-movement.js +40 -0
- package/dist/data/trip/added/gtfs-added-trip-terminating-movement.js.map +1 -0
- package/dist/data/trip/added/gtfs-added-trip.d.ts +26 -0
- package/dist/data/trip/added/gtfs-added-trip.js +52 -0
- package/dist/data/trip/added/gtfs-added-trip.js.map +1 -0
- package/dist/data/trip/added/types.d.ts +20 -0
- package/dist/data/trip/added/types.js +2 -0
- package/dist/data/trip/added/types.js.map +1 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-originating-movement.d.ts +24 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-originating-movement.js +40 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-originating-movement.js.map +1 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-passing-movement.d.ts +14 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-passing-movement.js +24 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-passing-movement.js.map +1 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-regular-movement.d.ts +30 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-regular-movement.js +51 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-regular-movement.js.map +1 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-terminating-movement.d.ts +24 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-terminating-movement.js +40 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip-terminating-movement.js.map +1 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip.d.ts +28 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip.js +70 -0
- package/dist/data/trip/replaced/gtfs-replaced-trip.js.map +1 -0
- package/dist/data/trip/replaced/types.d.ts +20 -0
- package/dist/data/trip/replaced/types.js +2 -0
- package/dist/data/trip/replaced/types.js.map +1 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.d.ts +29 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.js +74 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.js.map +1 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-passing-movement.d.ts +17 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-passing-movement.js +35 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-passing-movement.js.map +1 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.d.ts +35 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js +98 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js.map +1 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.d.ts +29 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js +74 -0
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js.map +1 -0
- package/dist/data/{gtfs-scheduled-trip.d.ts → trip/scheduled/gtfs-scheduled-trip.d.ts} +6 -4
- package/dist/data/{gtfs-scheduled-trip.js → trip/scheduled/gtfs-scheduled-trip.js} +3 -2
- package/dist/data/trip/scheduled/gtfs-scheduled-trip.js.map +1 -0
- package/dist/data/trip/scheduled/types.d.ts +33 -0
- package/dist/data/trip/scheduled/types.js +2 -0
- package/dist/data/trip/scheduled/types.js.map +1 -0
- package/dist/data/trip/types.d.ts +14 -0
- package/dist/data/trip/types.js +2 -0
- package/dist/data/trip/types.js.map +1 -0
- package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.d.ts +36 -0
- package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.js +82 -0
- package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.js.map +1 -0
- package/dist/data/trip/updated/gtfs-updated-trip-passing-movement.d.ts +15 -0
- package/dist/data/trip/updated/gtfs-updated-trip-passing-movement.js +27 -0
- package/dist/data/trip/updated/gtfs-updated-trip-passing-movement.js.map +1 -0
- package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.d.ts +48 -0
- package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.js +129 -0
- package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.js.map +1 -0
- package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.d.ts +36 -0
- package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.js +82 -0
- package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.js.map +1 -0
- package/dist/data/{gtfs-updated-trip.d.ts → trip/updated/gtfs-updated-trip.d.ts} +5 -3
- package/dist/data/{gtfs-updated-trip.js → trip/updated/gtfs-updated-trip.js} +0 -18
- package/dist/data/trip/updated/gtfs-updated-trip.js.map +1 -0
- package/dist/data/trip/updated/types.d.ts +24 -0
- package/dist/data/trip/updated/types.js +2 -0
- package/dist/data/trip/updated/types.js.map +1 -0
- package/dist/departures/gtfs-scheduled-movements-index.d.ts +2 -2
- package/dist/departures/iterator/departures-iterator.d.ts +3 -5
- package/dist/departures/iterator/departures-iterator.js.map +1 -1
- package/dist/departures/iterator/scheduled-departures-block-iterator.js +2 -2
- package/dist/departures/iterator/scheduled-departures-block-iterator.js.map +1 -1
- package/dist/departures/realtime-departures-block.d.ts +3 -4
- package/dist/departures/realtime-departures-block.js.map +1 -1
- package/dist/gtfs-service-source.js +12 -2
- package/dist/gtfs-service-source.js.map +1 -1
- package/dist/parser/gtfs-feed-parser.js +3 -0
- package/dist/parser/gtfs-feed-parser.js.map +1 -1
- package/dist/parser/gtfs-route-matcher.d.ts +31 -0
- package/dist/parser/gtfs-route-matcher.js +114 -0
- package/dist/parser/gtfs-route-matcher.js.map +1 -0
- package/dist/parser/realtime/gtfs-added-trip-update-parser.d.ts +49 -0
- package/dist/parser/realtime/gtfs-added-trip-update-parser.js +207 -0
- package/dist/parser/realtime/gtfs-added-trip-update-parser.js.map +1 -0
- package/dist/parser/realtime/gtfs-cancelled-trip-update-parser.d.ts +16 -0
- package/dist/parser/realtime/gtfs-cancelled-trip-update-parser.js +24 -0
- package/dist/parser/realtime/gtfs-cancelled-trip-update-parser.js.map +1 -0
- package/dist/parser/realtime/gtfs-realtime-data-parser.d.ts +6 -0
- package/dist/parser/realtime/gtfs-realtime-data-parser.js +16 -12
- package/dist/parser/realtime/gtfs-realtime-data-parser.js.map +1 -1
- package/dist/parser/realtime/{gtfs-trip-update-trip-identifier.d.ts → gtfs-scheduled-trip-identifier.d.ts} +6 -6
- package/dist/parser/realtime/{gtfs-trip-update-trip-identifier.js → gtfs-scheduled-trip-identifier.js} +2 -2
- package/dist/parser/realtime/gtfs-scheduled-trip-identifier.js.map +1 -0
- package/dist/parser/realtime/gtfs-trip-movements-interpolator.d.ts +7 -0
- package/dist/parser/realtime/gtfs-trip-movements-interpolator.js +183 -0
- package/dist/parser/realtime/gtfs-trip-movements-interpolator.js.map +1 -0
- package/dist/parser/realtime/gtfs-trip-update-parser-common-error-types.d.ts +25 -0
- package/dist/parser/realtime/gtfs-trip-update-parser-common-error-types.js +37 -0
- package/dist/parser/realtime/gtfs-trip-update-parser-common-error-types.js.map +1 -0
- package/dist/parser/realtime/gtfs-trip-update-parser.d.ts +15 -81
- package/dist/parser/realtime/gtfs-trip-update-parser.js +30 -272
- package/dist/parser/realtime/gtfs-trip-update-parser.js.map +1 -1
- package/dist/parser/realtime/gtfs-updated-trip-update-parser.d.ts +76 -0
- package/dist/parser/realtime/gtfs-updated-trip-update-parser.js +264 -0
- package/dist/parser/realtime/gtfs-updated-trip-update-parser.js.map +1 -0
- package/dist/parser/schedule/gtfs-transfer-parser.d.ts +1 -1
- package/dist/parser/schedule/gtfs-transfer-parser.js +1 -1
- package/dist/parser/schedule/gtfs-transfer-parser.js.map +1 -1
- package/dist/parser/schedule/gtfs-trip-parser.d.ts +24 -8
- package/dist/parser/schedule/gtfs-trip-parser.js +120 -51
- package/dist/parser/schedule/gtfs-trip-parser.js.map +1 -1
- package/package.json +1 -1
- package/dist/data/gtfs-scheduled-trip-movements.d.ts +0 -118
- package/dist/data/gtfs-scheduled-trip-movements.js +0 -233
- package/dist/data/gtfs-scheduled-trip-movements.js.map +0 -1
- package/dist/data/gtfs-scheduled-trip.js.map +0 -1
- package/dist/data/gtfs-updated-trip-movements.d.ts +0 -124
- package/dist/data/gtfs-updated-trip-movements.js +0 -150
- package/dist/data/gtfs-updated-trip-movements.js.map +0 -1
- package/dist/data/gtfs-updated-trip.js.map +0 -1
- package/dist/data/utils.d.ts +0 -3
- package/dist/data/utils.js +0 -2
- package/dist/data/utils.js.map +0 -1
- package/dist/parser/realtime/gtfs-trip-update-trip-identifier.js.map +0 -1
- package/dist/parser/schedule/gtfs-route-matcher.d.ts +0 -53
- package/dist/parser/schedule/gtfs-route-matcher.js +0 -197
- package/dist/parser/schedule/gtfs-route-matcher.js.map +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { itsOk } from "@dan-schel/js-utils";
|
|
2
|
+
import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
|
|
3
|
+
import { GtfsTripMovementsInterpolator } from "./gtfs-trip-movements-interpolator.js";
|
|
4
|
+
import { GtfsScheduledTripIdentifier, } from "./gtfs-scheduled-trip-identifier.js";
|
|
5
|
+
import { NecessaryFieldNotInStopTimeUpdateEntryError, NoStopTimeUpdateFieldGivenError, StopTimeUpdateEntryReferencesUnmappedStopIdError, UnsupportedStopTimeUpdateEntryScheduleRelationshipError, } from "./gtfs-trip-update-parser-common-error-types.js";
|
|
6
|
+
const STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED = "SCHEDULED";
|
|
7
|
+
export class GtfsUpdatedTripUpdateParser {
|
|
8
|
+
_timezone;
|
|
9
|
+
_stopGtfsIdMapping;
|
|
10
|
+
_onError;
|
|
11
|
+
_tripIdentifier;
|
|
12
|
+
_movementsInterpolator;
|
|
13
|
+
constructor(fields) {
|
|
14
|
+
this._timezone = fields.timezone;
|
|
15
|
+
this._stopGtfsIdMapping = fields.stopGtfsIdMapping;
|
|
16
|
+
this._onError = fields.onError;
|
|
17
|
+
this._tripIdentifier = new GtfsScheduledTripIdentifier({
|
|
18
|
+
onError: this._onError,
|
|
19
|
+
});
|
|
20
|
+
this._movementsInterpolator = new GtfsTripMovementsInterpolator();
|
|
21
|
+
}
|
|
22
|
+
parse(tripUpdate, scheduleData) {
|
|
23
|
+
const result = this._tripIdentifier.identify(tripUpdate.trip, scheduleData);
|
|
24
|
+
if (result == null)
|
|
25
|
+
return null;
|
|
26
|
+
const { trip, serviceDay } = result;
|
|
27
|
+
if (tripUpdate.stopTimeUpdate == null) {
|
|
28
|
+
this._onError(new NoStopTimeUpdateFieldGivenError(tripUpdate));
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const updatedMovementsByIndex = new Map();
|
|
32
|
+
for (const entry of tripUpdate.stopTimeUpdate) {
|
|
33
|
+
// TODO: If the schedule relationship is `SKIPPED`, then build a
|
|
34
|
+
// GtfsReplacedTrip instead, and ensure the new list of movements is put
|
|
35
|
+
// through the GtfsRouteMatcher so that if bonus lines which previously
|
|
36
|
+
// didn't match now do, the trip gets them. (Consider how an East Pakenham
|
|
37
|
+
// bound train now terminating early at Dandenong would now be eligible to
|
|
38
|
+
// be considered a Cranbourne line service.)
|
|
39
|
+
const sr = entry.scheduleRelationship;
|
|
40
|
+
if (sr !== STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED) {
|
|
41
|
+
const Err = UnsupportedStopTimeUpdateEntryScheduleRelationshipError;
|
|
42
|
+
this._onError(new Err(tripUpdate, entry));
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
// Check the fields we're gonna rely on (that PTV seems to reliably give
|
|
46
|
+
// but are technically optional in the GTFS-RT spec) are actually present.
|
|
47
|
+
if (entry.stopSequence == null) {
|
|
48
|
+
const Err = NecessaryFieldNotInStopTimeUpdateEntryError;
|
|
49
|
+
this._onError(new Err(tripUpdate, entry, "stopSequence"));
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (entry.stopId == null) {
|
|
53
|
+
const Err = NecessaryFieldNotInStopTimeUpdateEntryError;
|
|
54
|
+
this._onError(new Err(tripUpdate, entry, "stopId"));
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (entry.arrival == null && entry.departure == null) {
|
|
58
|
+
const Err = NeitherArrivalNorDepartureGivenError;
|
|
59
|
+
this._onError(new Err(tripUpdate, entry));
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
// Find the stop in the scheduled trip that this update is supposed to be
|
|
63
|
+
// for.
|
|
64
|
+
const movementIndex = trip.movements.findIndex((m) => m.isServicing && m.gtfsStopSequence === entry.stopSequence);
|
|
65
|
+
if (movementIndex === -1) {
|
|
66
|
+
const Err = StopTimeUpdateEntryReferencesNonExistentStopSequenceError;
|
|
67
|
+
this._onError(new Err(tripUpdate, entry, trip));
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// Enforced by findIndex above.
|
|
71
|
+
const scheduledMovement = itsOk(trip.movements[movementIndex]);
|
|
72
|
+
if (!scheduledMovement.isServicing)
|
|
73
|
+
throw new Error();
|
|
74
|
+
// Check that we haven't already matched a stop time update entry to this
|
|
75
|
+
// movement index. (Would happen if `stopSequence` was the same value
|
|
76
|
+
// twice, I guess.)
|
|
77
|
+
if (updatedMovementsByIndex.has(movementIndex)) {
|
|
78
|
+
const Err = MultipleStopTimeUpdateEntriesForSameMovementIndexError;
|
|
79
|
+
this._onError(new Err(tripUpdate, entry, trip, movementIndex));
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
// Look up the stop GTFS ID given in the stop time update entry, and check
|
|
83
|
+
// whether it still maps to the same (CoreQuery) stop. In this way, we
|
|
84
|
+
// allow the platform/position ID to change, not the overall stop/station.
|
|
85
|
+
const gtfsIdMetadata = this._stopGtfsIdMapping.tryResolve(entry.stopId);
|
|
86
|
+
if (gtfsIdMetadata == null) {
|
|
87
|
+
const Err = StopTimeUpdateEntryReferencesUnmappedStopIdError;
|
|
88
|
+
this._onError(new Err(tripUpdate, entry));
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
if (gtfsIdMetadata.stopId !== scheduledMovement.gtfsIdMetadata.stopId) {
|
|
92
|
+
const Err = StopTimeUpdateEntryChangesStopError;
|
|
93
|
+
this._onError(new Err(tripUpdate, entry, trip, movementIndex));
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const updatedPositionId = gtfsIdMetadata.type === "positional" ? gtfsIdMetadata.positionId : null;
|
|
97
|
+
// Parse the updated times from the `arrivalTime` and `departureTime`
|
|
98
|
+
// fields.
|
|
99
|
+
const realtimeArrivalTime = "arrivalTime" in scheduledMovement
|
|
100
|
+
? this._parseUpdatedTime(entry.arrival ?? null, scheduledMovement.arrivalTime, serviceDay, tripUpdate, entry)
|
|
101
|
+
: null;
|
|
102
|
+
const realtimeDepartureTime = "departureTime" in scheduledMovement
|
|
103
|
+
? this._parseUpdatedTime(entry.departure ?? null, scheduledMovement.departureTime, serviceDay, tripUpdate, entry)
|
|
104
|
+
: null;
|
|
105
|
+
updatedMovementsByIndex.set(movementIndex, scheduledMovement.asUpdatedTripMovement({
|
|
106
|
+
arrivalTime: realtimeArrivalTime,
|
|
107
|
+
departureTime: realtimeDepartureTime,
|
|
108
|
+
updatedPositionId,
|
|
109
|
+
updatedGtfsIdMetadata: gtfsIdMetadata,
|
|
110
|
+
serviceDay,
|
|
111
|
+
timezone: this._timezone,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
const rawMovements = trip.movements.map((m, i) => {
|
|
115
|
+
return (updatedMovementsByIndex.get(i) ??
|
|
116
|
+
m.asHollowUpdatedTripMovement(serviceDay, this._timezone));
|
|
117
|
+
});
|
|
118
|
+
const interpolated = this._movementsInterpolator.interpolate(rawMovements);
|
|
119
|
+
if (interpolated == null) {
|
|
120
|
+
// TODO: This keeps happening in the PTV feed. In all the cases I've seen
|
|
121
|
+
// so far, the arrival times are one minute later than the departure times
|
|
122
|
+
// (for whatever reason). I think I should apply a patch for it, rather
|
|
123
|
+
// than "fixing" it in corequery-gtfs.
|
|
124
|
+
//
|
|
125
|
+
// TODO: Add a test for this.
|
|
126
|
+
const Err = KnownDepartureTimesEntailTimeTravelError;
|
|
127
|
+
this._onError(new Err(tripUpdate, rawMovements));
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return new GtfsUpdatedTrip({
|
|
131
|
+
scheduledTrip: trip,
|
|
132
|
+
serviceDay,
|
|
133
|
+
movements: interpolated,
|
|
134
|
+
isCancelled: false,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
_parseUpdatedTime(updatedTime, scheduledTime, serviceDay, tripUpdate, stopTimeUpdateEntry) {
|
|
138
|
+
if (updatedTime == null) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const { time, delay } = updatedTime;
|
|
142
|
+
const fromTime = time != null ? Temporal.Instant.fromEpochMilliseconds(time * 1000) : null;
|
|
143
|
+
const fromDelay = delay != null
|
|
144
|
+
? scheduledTime
|
|
145
|
+
.toInstant(serviceDay, this._timezone)
|
|
146
|
+
.add({ seconds: delay })
|
|
147
|
+
: null;
|
|
148
|
+
// Most/all trips in PTV's realtime feed have both time and delay. If using
|
|
149
|
+
// both of those methods gives us different results, then I've probably
|
|
150
|
+
// messed something up (e.g. maybe my service day assumption in the trip
|
|
151
|
+
// identifier is wrong)... or PTV has.
|
|
152
|
+
//
|
|
153
|
+
// We'll press on (this check is only meant for reporting/my interest), but
|
|
154
|
+
// the something's probably gonna be very broken for this trip!
|
|
155
|
+
if (fromTime != null && fromDelay != null && !fromTime.equals(fromDelay)) {
|
|
156
|
+
this._onError(new TimeAndDelayDisagreeWithEachOtherError(tripUpdate, stopTimeUpdateEntry, updatedTime, fromTime, fromDelay));
|
|
157
|
+
}
|
|
158
|
+
// I don't think it really matters which of `delay` or `time` we preference,
|
|
159
|
+
// since they're either identical, or we've (probably) messed up the service
|
|
160
|
+
// day, in which case we're either applying the right time to the wrong
|
|
161
|
+
// service (`time`), or the we've calculated the time assuming the wrong
|
|
162
|
+
// service day (`delay`).
|
|
163
|
+
//
|
|
164
|
+
// It'll probably be clearer to me trying to debug this if we apply this
|
|
165
|
+
// realtime update to yesterday/tomorrow's service and it makes it look like
|
|
166
|
+
// there's two departures of the same service happening at/near to the same
|
|
167
|
+
// time, so I'll pick `time`.
|
|
168
|
+
if (fromTime != null) {
|
|
169
|
+
return fromTime;
|
|
170
|
+
}
|
|
171
|
+
else if (fromDelay != null) {
|
|
172
|
+
return fromDelay;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const Err = NeitherTimeNorDelayGivenError;
|
|
176
|
+
this._onError(new Err(tripUpdate, stopTimeUpdateEntry, updatedTime));
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export class StopTimeUpdateEntryReferencesNonExistentStopSequenceError {
|
|
182
|
+
tripUpdate;
|
|
183
|
+
stopTimeUpdateEntry;
|
|
184
|
+
matchedTrip;
|
|
185
|
+
type = "stop-time-update-entry-references-non-existent-stop-sequence";
|
|
186
|
+
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip) {
|
|
187
|
+
this.tripUpdate = tripUpdate;
|
|
188
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
189
|
+
this.matchedTrip = matchedTrip;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export class MultipleStopTimeUpdateEntriesForSameMovementIndexError {
|
|
193
|
+
tripUpdate;
|
|
194
|
+
stopTimeUpdateEntry;
|
|
195
|
+
matchedTrip;
|
|
196
|
+
matchedMovementIndex;
|
|
197
|
+
type = "multiple-stop-time-update-entries-for-same-movement-index";
|
|
198
|
+
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip, matchedMovementIndex) {
|
|
199
|
+
this.tripUpdate = tripUpdate;
|
|
200
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
201
|
+
this.matchedTrip = matchedTrip;
|
|
202
|
+
this.matchedMovementIndex = matchedMovementIndex;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// i.e. It doesn't just change the position/platform (which we're fine with),
|
|
206
|
+
// but the entire stop.
|
|
207
|
+
export class StopTimeUpdateEntryChangesStopError {
|
|
208
|
+
tripUpdate;
|
|
209
|
+
stopTimeUpdateEntry;
|
|
210
|
+
matchedTrip;
|
|
211
|
+
matchedMovementIndex;
|
|
212
|
+
type = "stop-time-update-entry-changes-stop";
|
|
213
|
+
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip, matchedMovementIndex) {
|
|
214
|
+
this.tripUpdate = tripUpdate;
|
|
215
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
216
|
+
this.matchedTrip = matchedTrip;
|
|
217
|
+
this.matchedMovementIndex = matchedMovementIndex;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export class NeitherTimeNorDelayGivenError {
|
|
221
|
+
tripUpdate;
|
|
222
|
+
stopTimeUpdateEntry;
|
|
223
|
+
updatedTime;
|
|
224
|
+
type = "neither-time-nor-delay-given";
|
|
225
|
+
constructor(tripUpdate, stopTimeUpdateEntry, updatedTime) {
|
|
226
|
+
this.tripUpdate = tripUpdate;
|
|
227
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
228
|
+
this.updatedTime = updatedTime;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export class TimeAndDelayDisagreeWithEachOtherError {
|
|
232
|
+
tripUpdate;
|
|
233
|
+
stopTimeUpdateEntry;
|
|
234
|
+
updatedTime;
|
|
235
|
+
parsedFromTime;
|
|
236
|
+
parsedFromDelay;
|
|
237
|
+
type = "time-and-delay-disagree-with-each-other";
|
|
238
|
+
constructor(tripUpdate, stopTimeUpdateEntry, updatedTime, parsedFromTime, parsedFromDelay) {
|
|
239
|
+
this.tripUpdate = tripUpdate;
|
|
240
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
241
|
+
this.updatedTime = updatedTime;
|
|
242
|
+
this.parsedFromTime = parsedFromTime;
|
|
243
|
+
this.parsedFromDelay = parsedFromDelay;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
export class NeitherArrivalNorDepartureGivenError {
|
|
247
|
+
tripUpdate;
|
|
248
|
+
stopTimeUpdateEntry;
|
|
249
|
+
type = "neither-arrival-nor-departure-given";
|
|
250
|
+
constructor(tripUpdate, stopTimeUpdateEntry) {
|
|
251
|
+
this.tripUpdate = tripUpdate;
|
|
252
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
class KnownDepartureTimesEntailTimeTravelError {
|
|
256
|
+
tripUpdate;
|
|
257
|
+
movements;
|
|
258
|
+
type = "known-departure-times-entail-time-travel";
|
|
259
|
+
constructor(tripUpdate, movements) {
|
|
260
|
+
this.tripUpdate = tripUpdate;
|
|
261
|
+
this.movements = movements;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=gtfs-updated-trip-update-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtfs-updated-trip-update-parser.js","sourceRoot":"","sources":["../../../src/parser/realtime/gtfs-updated-trip-update-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAU5C,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAE/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACL,2BAA2B,GAE5B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,2CAA2C,EAC3C,+BAA+B,EAC/B,gDAAgD,EAChD,uDAAuD,GACxD,MAAM,iDAAiD,CAAC;AAEzD,MAAM,sDAAsD,GAAG,WAAW,CAAC;AAQ3E,MAAM,OAAO,2BAA2B;IACrB,SAAS,CAAS;IAClB,kBAAkB,CAAoB;IACtC,QAAQ,CAAqD;IAE7D,eAAe,CAA8B;IAC7C,sBAAsB,CAAgC;IAEvE,YAAY,MAAyC;QACnD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;QAE/B,IAAI,CAAC,eAAe,GAAG,IAAI,2BAA2B,CAAC;YACrD,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,sBAAsB,GA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F,IAAI,GAAG,yCAAyC,CAAC;IAC1D,YACW,UAA0B,EAC1B,mBAAuC,EACvC,WAA4B,EAC5B,cAAgC,EAChC,eAAiC;QAJjC,eAAU,GAAV,UAAU,CAAgB;QAC1B,wBAAmB,GAAnB,mBAAmB,CAAoB;QACvC,gBAAW,GAAX,WAAW,CAAiB;QAC5B,mBAAc,GAAd,cAAc,CAAkB;QAChC,oBAAe,GAAf,eAAe,CAAkB;IACzC,CAAC;CACL;AAED,MAAM,OAAO,oCAAoC;IAGpC;IACA;IAHF,IAAI,GAAG,qCAAqC,CAAC;IACtD,YACW,UAA0B,EAC1B,mBAAuC;QADvC,eAAU,GAAV,UAAU,CAAgB;QAC1B,wBAAmB,GAAnB,mBAAmB,CAAoB;IAC/C,CAAC;CACL;AAED,MAAM,wCAAwC;IAGjC;IACA;IAHF,IAAI,GAAG,0CAA0C,CAAC;IAC3D,YACW,UAA0B,EAC1B,SAA6C;QAD7C,eAAU,GAAV,UAAU,CAAgB;QAC1B,cAAS,GAAT,SAAS,CAAoC;IACrD,CAAC;CACL"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TransfersCsv, TransfersCsvRow } from "../../data/raw/schedule-csvs.js";
|
|
2
|
-
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
2
|
+
import { GtfsScheduledTrip } from "../../data/trip/scheduled/gtfs-scheduled-trip.js";
|
|
3
3
|
import { type GtfsTransfer } from "../../data/gtfs-transfer.js";
|
|
4
4
|
export type GtfsTransferParserFields = {
|
|
5
5
|
readonly onError: (error: GtfsTransferParsingError) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
1
|
+
import { GtfsScheduledTrip } from "../../data/trip/scheduled/gtfs-scheduled-trip.js";
|
|
2
2
|
import { GtfsEntireVehicleFormsServiceTransfer, } from "../../data/gtfs-transfer.js";
|
|
3
3
|
import { MutableGtfsTransferMapping } from "../../data/gtfs-transfer-mapping.js";
|
|
4
4
|
const TRANSFER_TYPE_IN_SEAT_TRANSFER = 4;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtfs-transfer-parser.js","sourceRoot":"","sources":["../../../src/parser/schedule/gtfs-transfer-parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"gtfs-transfer-parser.js","sourceRoot":"","sources":["../../../src/parser/schedule/gtfs-transfer-parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AACrF,OAAO,EACL,qCAAqC,GAEtC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEjF,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAMzC,MAAM,OAAO,kBAAkB;IACZ,QAAQ,CAA4C;IAErE,YAAY,MAAgC;QAC1C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,KAAK,CACH,KAAmC,EACnC,SAAuB;QAEvB,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAC7C,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAe,CAAC,CAAC,EAAE,EAAE,CAChE,CAAC,CAAC,kBAAkB,EAAE,CACvB,CAAC;QAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACpD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAEhD,wEAAwE;YACxE,qEAAqE;Y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,QAAyB,EACzB,MAAyB;QADzB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,WAAM,GAAN,MAAM,CAAmB;IACjC,CAAC;CACL;AAED,MAAM,OAAO,2CAA2C;IAG3C;IACA;IAHF,IAAI,GAAG,4CAA4C,CAAC;IAC7D,YACW,QAAyB,EACzB,0BAA6C;QAD7C,aAAQ,GAAR,QAAQ,CAAiB;QACzB,+BAA0B,GAA1B,0BAA0B,CAAmB;IACrD,CAAC;CACL;AAED,MAAM,OAAO,gCAAgC;IAEtB;IADZ,IAAI,GAAG,kCAAkC,CAAC;IACnD,YAAqB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;IAAG,CAAC;CACnD;AAED,MAAM,OAAO,qCAAqC;IAE3B;IADZ,IAAI,GAAG,wCAAwC,CAAC;IACzD,YAAqB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;IAAG,CAAC;CACnD;AAED,MAAM,OAAO,6BAA6B;IAEnB;IADZ,IAAI,GAAG,4BAA4B,CAAC;IAC7C,YAAqB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;IAAG,CAAC;CACnD;AAED,MAAM,OAAO,+BAA+B;IAErB;IADZ,IAAI,GAAG,+BAA+B,CAAC;IAChD,YAAqB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;IAAG,CAAC;CACnD"}
|
|
@@ -2,9 +2,9 @@ import type { LineGtfsIdMapping } from "../../data/ids/line-gtfs-id-mapping.js";
|
|
|
2
2
|
import type { StopGtfsIdMapping } from "../../data/ids/stop-gtfs-id-mapping.js";
|
|
3
3
|
import type { StopTimesCsv, StopTimesCsvRow, TransfersCsv, TripsCsv, TripsCsvRow } from "../../data/raw/schedule-csvs.js";
|
|
4
4
|
import type { GtfsCalendar } from "../../data/gtfs-calendar.js";
|
|
5
|
-
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
5
|
+
import { GtfsScheduledTrip } from "../../data/trip/scheduled/gtfs-scheduled-trip.js";
|
|
6
6
|
import { type GtfsStopTimeNormalisationError } from "./gtfs-stop-time-normaliser.js";
|
|
7
|
-
import { type GtfsRouteMatchingError } from "
|
|
7
|
+
import { type GtfsRouteMatchingError } from "../gtfs-route-matcher.js";
|
|
8
8
|
import { type GtfsTransferParsingError } from "./gtfs-transfer-parser.js";
|
|
9
9
|
import type { LineRoutesMapping } from "../../data/route/line-routes-mapping.js";
|
|
10
10
|
import type { BonusLinesMapping } from "../../data/route/bonus-lines-mapping.js";
|
|
@@ -17,12 +17,11 @@ export type GtfsTripParserFields = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare class GtfsTripParser {
|
|
19
19
|
private readonly _lineRoutesMapping;
|
|
20
|
-
private readonly _bonusLinesMapping;
|
|
21
20
|
private readonly _lineGtfsIdMapping;
|
|
21
|
+
private readonly _stopGtfsIdMapping;
|
|
22
22
|
private readonly _onError;
|
|
23
23
|
private readonly _stopTimeNormaliser;
|
|
24
|
-
private readonly
|
|
25
|
-
private readonly _bonusRouteMatcher;
|
|
24
|
+
private readonly _routeMatcher;
|
|
26
25
|
private readonly _transferParser;
|
|
27
26
|
constructor(fields: GtfsTripParserFields);
|
|
28
27
|
parse(trips: TripsCsv, stopTimes: StopTimesCsv, transfers: TransfersCsv, calendars: readonly GtfsCalendar[]): {
|
|
@@ -30,11 +29,13 @@ export declare class GtfsTripParser {
|
|
|
30
29
|
parsedTransfers: readonly import("../../data/gtfs-transfer.js").GtfsEntireVehicleFormsServiceTransfer[];
|
|
31
30
|
ignoredTripIds: string[];
|
|
32
31
|
};
|
|
33
|
-
private _organiseStopTimesIntoTrips;
|
|
34
|
-
private _applyBonusLines;
|
|
35
32
|
private _buildCalendarMap;
|
|
33
|
+
private _organiseStopTimesIntoTrips;
|
|
34
|
+
private _convertToServicingMovements;
|
|
35
|
+
private _doesPickUp;
|
|
36
|
+
private _doesDropOff;
|
|
36
37
|
}
|
|
37
|
-
export type GtfsTripParsingError = StopTimeReferencesNonExistentTripError | DuplicateTripIdError | TripReferencesNonExistentCalendarError | TripReferencesUnmappedRouteIdError | GtfsStopTimeNormalisationError | GtfsRouteMatchingError | GtfsTransferParsingError;
|
|
38
|
+
export type GtfsTripParsingError = StopTimeReferencesNonExistentTripError | DuplicateTripIdError | TripReferencesNonExistentCalendarError | TripReferencesUnmappedRouteIdError | GtfsStopTimeNormalisationError | GtfsRouteMatchingError | GtfsTransferParsingError | StopTimeReferencesUnmappedStopIdError | UnexpectedPickupTypeError | UnexpectedDropOffTypeError;
|
|
38
39
|
export declare class StopTimeReferencesNonExistentTripError {
|
|
39
40
|
readonly stopTime: StopTimesCsvRow;
|
|
40
41
|
readonly type = "stop-time-references-non-existent-trip";
|
|
@@ -55,3 +56,18 @@ export declare class TripReferencesUnmappedRouteIdError {
|
|
|
55
56
|
readonly type = "trip-references-unmapped-route-id";
|
|
56
57
|
constructor(trip: TripsCsvRow);
|
|
57
58
|
}
|
|
59
|
+
export declare class StopTimeReferencesUnmappedStopIdError {
|
|
60
|
+
readonly stopTime: StopTimesCsvRow;
|
|
61
|
+
readonly type = "stop-time-references-unmapped-stop-id";
|
|
62
|
+
constructor(stopTime: StopTimesCsvRow);
|
|
63
|
+
}
|
|
64
|
+
export declare class UnexpectedPickupTypeError {
|
|
65
|
+
readonly stopTime: StopTimesCsvRow;
|
|
66
|
+
readonly type = "unexpected-pickup-type";
|
|
67
|
+
constructor(stopTime: StopTimesCsvRow);
|
|
68
|
+
}
|
|
69
|
+
export declare class UnexpectedDropOffTypeError {
|
|
70
|
+
readonly stopTime: StopTimesCsvRow;
|
|
71
|
+
readonly type = "unexpected-drop-off-type";
|
|
72
|
+
constructor(stopTime: StopTimesCsvRow);
|
|
73
|
+
}
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
1
|
+
import { GtfsScheduledTrip } from "../../data/trip/scheduled/gtfs-scheduled-trip.js";
|
|
2
2
|
import { GtfsStopTimeNormaliser, } from "./gtfs-stop-time-normaliser.js";
|
|
3
|
-
import { GtfsRouteMatcher, } from "
|
|
3
|
+
import { GtfsRouteMatcher, } from "../gtfs-route-matcher.js";
|
|
4
4
|
import { GtfsTransferParser, } from "./gtfs-transfer-parser.js";
|
|
5
|
+
import { itsOk } from "@dan-schel/js-utils";
|
|
6
|
+
import { GtfsScheduledTripOriginatingMovement } from "../../data/trip/scheduled/gtfs-scheduled-trip-originating-movement.js";
|
|
7
|
+
import { GtfsScheduledTripTerminatingMovement } from "../../data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js";
|
|
8
|
+
import { GtfsScheduledTripRegularMovement } from "../../data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js";
|
|
9
|
+
import { GtfsScheduledTripPassingMovement } from "../../data/trip/scheduled/gtfs-scheduled-trip-passing-movement.js";
|
|
10
|
+
const STOP_TIME_PICKUP_TYPE_REGULAR = 0;
|
|
11
|
+
const STOP_TIME_PICKUP_TYPE_NO_PICKUP = 1;
|
|
12
|
+
const STOP_TIME_DROP_OFF_TYPE_REGULAR = 0;
|
|
13
|
+
const STOP_TIME_DROP_OFF_TYPE_NO_DROP_OFF = 1;
|
|
5
14
|
export class GtfsTripParser {
|
|
6
15
|
_lineRoutesMapping;
|
|
7
|
-
_bonusLinesMapping;
|
|
8
16
|
_lineGtfsIdMapping;
|
|
17
|
+
_stopGtfsIdMapping;
|
|
9
18
|
_onError;
|
|
10
19
|
_stopTimeNormaliser;
|
|
11
|
-
|
|
12
|
-
_bonusRouteMatcher;
|
|
20
|
+
_routeMatcher;
|
|
13
21
|
_transferParser;
|
|
14
22
|
constructor(fields) {
|
|
15
23
|
this._lineRoutesMapping = fields.lineRoutesMapping;
|
|
16
|
-
this._bonusLinesMapping = fields.bonusLinesMapping;
|
|
17
24
|
this._lineGtfsIdMapping = fields.lineGtfsIdMapping;
|
|
25
|
+
this._stopGtfsIdMapping = fields.stopGtfsIdMapping;
|
|
18
26
|
this._onError = fields.onError;
|
|
19
27
|
this._stopTimeNormaliser = new GtfsStopTimeNormaliser({
|
|
20
28
|
onError: this._onError,
|
|
21
29
|
});
|
|
22
|
-
this.
|
|
30
|
+
this._routeMatcher = new GtfsRouteMatcher({
|
|
23
31
|
onError: this._onError,
|
|
24
|
-
|
|
32
|
+
lineRoutesMapping: fields.lineRoutesMapping,
|
|
33
|
+
bonusLinesMapping: fields.bonusLinesMapping,
|
|
25
34
|
});
|
|
26
35
|
this._transferParser = new GtfsTransferParser({
|
|
27
36
|
onError: this._onError,
|
|
28
37
|
});
|
|
29
|
-
// We don't care if a bonus route doesn't match. Most of the time, it won't!
|
|
30
|
-
this._bonusRouteMatcher = new GtfsRouteMatcher({
|
|
31
|
-
onError: () => { },
|
|
32
|
-
stopGtfsIdMapping: fields.stopGtfsIdMapping,
|
|
33
|
-
});
|
|
34
38
|
}
|
|
35
39
|
parse(trips, stopTimes, transfers, calendars) {
|
|
36
40
|
const calendarMap = this._buildCalendarMap(calendars);
|
|
@@ -56,25 +60,29 @@ export class GtfsTripParser {
|
|
|
56
60
|
// Stop time normaliser reports its own errors.
|
|
57
61
|
if (normalizedStopTimes == null)
|
|
58
62
|
continue;
|
|
59
|
-
const
|
|
60
|
-
|
|
63
|
+
const servicingMovements = this._convertToServicingMovements(normalizedStopTimes);
|
|
64
|
+
if (servicingMovements == null)
|
|
65
|
+
continue;
|
|
66
|
+
const routeMatch = this._routeMatcher.match(lineIdMatch.lineId, servicingMovements, (stopId) => new GtfsScheduledTripPassingMovement({ stopId }));
|
|
61
67
|
// Route matcher reports its own errors.
|
|
62
|
-
if (
|
|
68
|
+
if (routeMatch == null)
|
|
63
69
|
continue;
|
|
64
|
-
const { lineIds, serviceTags } = this._applyBonusLines(lineIdMatch.lineId, routeMatchResult.serviceTags, normalizedStopTimes);
|
|
65
70
|
parsedTrips.push(new GtfsScheduledTrip({
|
|
66
71
|
gtfsTripId: trip.trip_id,
|
|
67
72
|
gtfsRouteId: trip.route_id,
|
|
68
73
|
calendar,
|
|
69
|
-
movements:
|
|
70
|
-
lineIds,
|
|
71
|
-
color:
|
|
72
|
-
serviceTags,
|
|
74
|
+
movements: routeMatch.movements,
|
|
75
|
+
lineIds: routeMatch.lineIds,
|
|
76
|
+
color: routeMatch.color,
|
|
77
|
+
serviceTags: routeMatch.serviceTags,
|
|
73
78
|
}));
|
|
74
79
|
}
|
|
75
80
|
const parsedTransfers = this._transferParser.parse(parsedTrips, transfers);
|
|
76
81
|
return { parsedTrips, parsedTransfers, ignoredTripIds };
|
|
77
82
|
}
|
|
83
|
+
_buildCalendarMap(calendars) {
|
|
84
|
+
return new Map(calendars.map((c) => [c.gtfsCalendarId, c]));
|
|
85
|
+
}
|
|
78
86
|
_organiseStopTimesIntoTrips(trips, stopTimes) {
|
|
79
87
|
const result = new Map();
|
|
80
88
|
// Step 1: Build a map from everything in trips.txt.
|
|
@@ -109,40 +117,80 @@ export class GtfsTripParser {
|
|
|
109
117
|
stopTimes: group.stopTimes,
|
|
110
118
|
}));
|
|
111
119
|
}
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const serviceTags = new Set();
|
|
121
|
-
for (const bonusLine of bonusLines.lines) {
|
|
122
|
-
const matchResult = this._bonusRouteMatcher.match(normalizedStopTimes, this._lineRoutesMapping.forLine(bonusLine));
|
|
123
|
-
if (matchResult != null) {
|
|
124
|
-
lineIds.add(bonusLine);
|
|
125
|
-
for (const serviceTag of matchResult.serviceTags) {
|
|
126
|
-
serviceTags.add(serviceTag);
|
|
127
|
-
}
|
|
120
|
+
_convertToServicingMovements(stopTimes) {
|
|
121
|
+
const result = [];
|
|
122
|
+
for (let i = 0; i < stopTimes.length; i++) {
|
|
123
|
+
const stopTime = itsOk(stopTimes[i]);
|
|
124
|
+
const gtfsIdMetadata = this._stopGtfsIdMapping.tryResolve(stopTime.stop_id);
|
|
125
|
+
if (gtfsIdMetadata == null) {
|
|
126
|
+
this._onError(new StopTimeReferencesUnmappedStopIdError(stopTime));
|
|
127
|
+
return null;
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
const positionId = gtfsIdMetadata.type === "positional" ? gtfsIdMetadata.positionId : null;
|
|
130
|
+
const picksUp = this._doesPickUp(stopTime);
|
|
131
|
+
const dropsOff = this._doesDropOff(stopTime);
|
|
132
|
+
if (i === 0) {
|
|
133
|
+
result.push(new GtfsScheduledTripOriginatingMovement({
|
|
134
|
+
stopId: gtfsIdMetadata.stopId,
|
|
135
|
+
positionId,
|
|
136
|
+
departureTime: stopTime.departure_time,
|
|
137
|
+
gtfsIdMetadata,
|
|
138
|
+
gtfsStopSequence: stopTime.stop_sequence,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
else if (i === stopTimes.length - 1) {
|
|
142
|
+
result.push(new GtfsScheduledTripTerminatingMovement({
|
|
143
|
+
stopId: gtfsIdMetadata.stopId,
|
|
144
|
+
positionId,
|
|
145
|
+
arrivalTime: stopTime.arrival_time,
|
|
146
|
+
gtfsIdMetadata,
|
|
147
|
+
gtfsStopSequence: stopTime.stop_sequence,
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
result.push(new GtfsScheduledTripRegularMovement({
|
|
152
|
+
stopId: gtfsIdMetadata.stopId,
|
|
153
|
+
positionId,
|
|
154
|
+
arrivalTime: stopTime.arrival_time,
|
|
155
|
+
departureTime: stopTime.departure_time,
|
|
156
|
+
picksUp,
|
|
157
|
+
dropsOff,
|
|
158
|
+
gtfsIdMetadata,
|
|
159
|
+
gtfsStopSequence: stopTime.stop_sequence,
|
|
160
|
+
}));
|
|
137
161
|
}
|
|
138
162
|
}
|
|
139
|
-
return
|
|
140
|
-
lineIds: Array.from(lineIds),
|
|
141
|
-
serviceTags: Array.from(serviceTags),
|
|
142
|
-
};
|
|
163
|
+
return result;
|
|
143
164
|
}
|
|
144
|
-
|
|
145
|
-
|
|
165
|
+
_doesPickUp(stopTime) {
|
|
166
|
+
if (stopTime.pickup_type === STOP_TIME_PICKUP_TYPE_REGULAR) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
else if (stopTime.pickup_type === STOP_TIME_PICKUP_TYPE_NO_PICKUP) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this._onError(new UnexpectedPickupTypeError(stopTime));
|
|
174
|
+
// If pickup_type is unexpected, let's just treat it like a normal stop. I
|
|
175
|
+
// don't think we need to exclude the whole trip for something as minor as
|
|
176
|
+
// mislabelling pick up only stops.
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
_doesDropOff(stopTime) {
|
|
181
|
+
if (stopTime.drop_off_type === STOP_TIME_DROP_OFF_TYPE_REGULAR) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
else if (stopTime.drop_off_type === STOP_TIME_DROP_OFF_TYPE_NO_DROP_OFF) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this._onError(new UnexpectedDropOffTypeError(stopTime));
|
|
189
|
+
// If drop_off_type is unexpected, let's just treat it like a normal stop.
|
|
190
|
+
// I don't think we need to exclude the whole trip for something as minor
|
|
191
|
+
// as mislabelling drop off only stops.
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
146
194
|
}
|
|
147
195
|
}
|
|
148
196
|
export class StopTimeReferencesNonExistentTripError {
|
|
@@ -173,4 +221,25 @@ export class TripReferencesUnmappedRouteIdError {
|
|
|
173
221
|
this.trip = trip;
|
|
174
222
|
}
|
|
175
223
|
}
|
|
224
|
+
export class StopTimeReferencesUnmappedStopIdError {
|
|
225
|
+
stopTime;
|
|
226
|
+
type = "stop-time-references-unmapped-stop-id";
|
|
227
|
+
constructor(stopTime) {
|
|
228
|
+
this.stopTime = stopTime;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export class UnexpectedPickupTypeError {
|
|
232
|
+
stopTime;
|
|
233
|
+
type = "unexpected-pickup-type";
|
|
234
|
+
constructor(stopTime) {
|
|
235
|
+
this.stopTime = stopTime;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
export class UnexpectedDropOffTypeError {
|
|
239
|
+
stopTime;
|
|
240
|
+
type = "unexpected-drop-off-type";
|
|
241
|
+
constructor(stopTime) {
|
|
242
|
+
this.stopTime = stopTime;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
176
245
|
//# sourceMappingURL=gtfs-trip-parser.js.map
|