corequery-gtfs 0.11.0 → 0.13.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 +5 -1
- package/dist/conversion/service-converter.js +50 -2
- 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/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.js +1 -1
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.js.map +1 -1
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js +1 -1
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js.map +1 -1
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js +1 -1
- package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js.map +1 -1
- 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 +2 -0
- package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.js +10 -0
- package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.js.map +1 -1
- package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.d.ts +6 -0
- package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.js +33 -0
- package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.js.map +1 -1
- package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.d.ts +2 -0
- package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.js +10 -0
- package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.js.map +1 -1
- package/dist/data/trip/updated/gtfs-updated-trip.js +0 -18
- package/dist/data/trip/updated/gtfs-updated-trip.js.map +1 -1
- 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 +10 -0
- 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} +5 -5
- 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.js +18 -0
- package/dist/parser/realtime/gtfs-trip-movements-interpolator.js.map +1 -1
- 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 -90
- package/dist/parser/realtime/gtfs-trip-update-parser.js +33 -296
- package/dist/parser/realtime/gtfs-trip-update-parser.js.map +1 -1
- package/dist/parser/realtime/gtfs-updated-trip-update-parser.d.ts +93 -0
- package/dist/parser/realtime/gtfs-updated-trip-update-parser.js +365 -0
- package/dist/parser/realtime/gtfs-updated-trip-update-parser.js.map +1 -0
- package/dist/parser/schedule/gtfs-trip-parser.d.ts +23 -7
- package/dist/parser/schedule/gtfs-trip-parser.js +119 -50
- package/dist/parser/schedule/gtfs-trip-parser.js.map +1 -1
- package/package.json +1 -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 -200
- package/dist/parser/schedule/gtfs-route-matcher.js.map +0 -1
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { itsOk } from "@dan-schel/js-utils";
|
|
2
|
+
import { GtfsReplacedTrip } from "../../data/trip/replaced/gtfs-replaced-trip.js";
|
|
3
|
+
import { GtfsReplacedTripPassingMovement } from "../../data/trip/replaced/gtfs-replaced-trip-passing-movement.js";
|
|
4
|
+
import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
|
|
5
|
+
import { GtfsTripMovementsInterpolator } from "./gtfs-trip-movements-interpolator.js";
|
|
6
|
+
import { GtfsRouteMatcher, } from "../gtfs-route-matcher.js";
|
|
7
|
+
import { GtfsScheduledTripIdentifier, } from "./gtfs-scheduled-trip-identifier.js";
|
|
8
|
+
import { NecessaryFieldNotInStopTimeUpdateEntryError, NoStopTimeUpdateFieldGivenError, StopTimeUpdateEntryReferencesUnmappedStopIdError, UnsupportedStopTimeUpdateEntryScheduleRelationshipError, } from "./gtfs-trip-update-parser-common-error-types.js";
|
|
9
|
+
const STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED = "SCHEDULED";
|
|
10
|
+
const STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SKIPPED = "SKIPPED";
|
|
11
|
+
export class GtfsUpdatedTripUpdateParser {
|
|
12
|
+
_timezone;
|
|
13
|
+
_stopGtfsIdMapping;
|
|
14
|
+
_onError;
|
|
15
|
+
_tripIdentifier;
|
|
16
|
+
_movementsInterpolator;
|
|
17
|
+
_lineGtfsIdMapping;
|
|
18
|
+
_routeMatcher;
|
|
19
|
+
constructor(fields) {
|
|
20
|
+
this._timezone = fields.timezone;
|
|
21
|
+
this._stopGtfsIdMapping = fields.stopGtfsIdMapping;
|
|
22
|
+
this._onError = fields.onError;
|
|
23
|
+
this._lineGtfsIdMapping = fields.lineGtfsIdMapping;
|
|
24
|
+
this._tripIdentifier = new GtfsScheduledTripIdentifier({
|
|
25
|
+
onError: this._onError,
|
|
26
|
+
});
|
|
27
|
+
this._movementsInterpolator = new GtfsTripMovementsInterpolator();
|
|
28
|
+
this._routeMatcher = new GtfsRouteMatcher({
|
|
29
|
+
onError: this._onError,
|
|
30
|
+
lineRoutesMapping: fields.lineRoutesMapping,
|
|
31
|
+
bonusLinesMapping: fields.bonusLinesMapping,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
parse(tripUpdate, scheduleData) {
|
|
35
|
+
const result = this._tripIdentifier.identify(tripUpdate.trip, scheduleData);
|
|
36
|
+
if (result == null)
|
|
37
|
+
return null;
|
|
38
|
+
const { trip, serviceDay } = result;
|
|
39
|
+
if (tripUpdate.stopTimeUpdate == null) {
|
|
40
|
+
this._onError(new NoStopTimeUpdateFieldGivenError(tripUpdate));
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const updatedMovementsByIndex = new Map();
|
|
44
|
+
const skippedMovementIndexes = new Set();
|
|
45
|
+
for (const entry of tripUpdate.stopTimeUpdate) {
|
|
46
|
+
const sr = entry.scheduleRelationship;
|
|
47
|
+
const isSkipped = sr === STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SKIPPED;
|
|
48
|
+
if (sr !== STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED &&
|
|
49
|
+
!isSkipped) {
|
|
50
|
+
const Err = UnsupportedStopTimeUpdateEntryScheduleRelationshipError;
|
|
51
|
+
this._onError(new Err(tripUpdate, entry));
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
// Check the fields we're gonna rely on (that PTV seems to reliably give
|
|
55
|
+
// but are technically optional in the GTFS-RT spec) are actually present.
|
|
56
|
+
if (entry.stopSequence == null) {
|
|
57
|
+
const Err = NecessaryFieldNotInStopTimeUpdateEntryError;
|
|
58
|
+
this._onError(new Err(tripUpdate, entry, "stopSequence"));
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (entry.stopId == null) {
|
|
62
|
+
const Err = NecessaryFieldNotInStopTimeUpdateEntryError;
|
|
63
|
+
this._onError(new Err(tripUpdate, entry, "stopId"));
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (!isSkipped && entry.arrival == null && entry.departure == null) {
|
|
67
|
+
const Err = NeitherArrivalNorDepartureGivenError;
|
|
68
|
+
this._onError(new Err(tripUpdate, entry));
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
// Find the stop in the scheduled trip that this update is supposed to be
|
|
72
|
+
// for.
|
|
73
|
+
const movementIndex = trip.movements.findIndex((m) => m.isServicing && m.gtfsStopSequence === entry.stopSequence);
|
|
74
|
+
if (movementIndex === -1) {
|
|
75
|
+
const Err = StopTimeUpdateEntryReferencesNonExistentStopSequenceError;
|
|
76
|
+
this._onError(new Err(tripUpdate, entry, trip));
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
// Enforced by findIndex above.
|
|
80
|
+
const scheduledMovement = itsOk(trip.movements[movementIndex]);
|
|
81
|
+
if (!scheduledMovement.isServicing)
|
|
82
|
+
throw new Error();
|
|
83
|
+
// Check that we haven't already matched a stop time update entry to this
|
|
84
|
+
// movement index. (Would happen if `stopSequence` was the same value
|
|
85
|
+
// twice, I guess.)
|
|
86
|
+
if (updatedMovementsByIndex.has(movementIndex) ||
|
|
87
|
+
skippedMovementIndexes.has(movementIndex)) {
|
|
88
|
+
const Err = MultipleStopTimeUpdateEntriesForSameMovementIndexError;
|
|
89
|
+
this._onError(new Err(tripUpdate, entry, trip, movementIndex));
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
// Look up the stop GTFS ID given in the stop time update entry, and check
|
|
93
|
+
// whether it still maps to the same (CoreQuery) stop. In this way, we
|
|
94
|
+
// allow the platform/position ID to change, not the overall stop/station.
|
|
95
|
+
const gtfsIdMetadata = this._stopGtfsIdMapping.tryResolve(entry.stopId);
|
|
96
|
+
if (gtfsIdMetadata == null) {
|
|
97
|
+
const Err = StopTimeUpdateEntryReferencesUnmappedStopIdError;
|
|
98
|
+
this._onError(new Err(tripUpdate, entry));
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
if (gtfsIdMetadata.stopId !== scheduledMovement.gtfsIdMetadata.stopId) {
|
|
102
|
+
const Err = StopTimeUpdateEntryChangesStopError;
|
|
103
|
+
this._onError(new Err(tripUpdate, entry, trip, movementIndex));
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (isSkipped) {
|
|
107
|
+
skippedMovementIndexes.add(movementIndex);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const updatedPositionId = gtfsIdMetadata.type === "positional"
|
|
111
|
+
? gtfsIdMetadata.positionId
|
|
112
|
+
: null;
|
|
113
|
+
// Parse the updated times from the `arrivalTime` and `departureTime`
|
|
114
|
+
// fields.
|
|
115
|
+
const realtimeArrivalTime = "arrivalTime" in scheduledMovement
|
|
116
|
+
? this._parseUpdatedTime(entry.arrival ?? null, scheduledMovement.arrivalTime, serviceDay, tripUpdate, entry)
|
|
117
|
+
: null;
|
|
118
|
+
const realtimeDepartureTime = "departureTime" in scheduledMovement
|
|
119
|
+
? this._parseUpdatedTime(entry.departure ?? null, scheduledMovement.departureTime, serviceDay, tripUpdate, entry)
|
|
120
|
+
: null;
|
|
121
|
+
updatedMovementsByIndex.set(movementIndex, scheduledMovement.asUpdatedTripMovement({
|
|
122
|
+
arrivalTime: realtimeArrivalTime,
|
|
123
|
+
departureTime: realtimeDepartureTime,
|
|
124
|
+
updatedPositionId,
|
|
125
|
+
updatedGtfsIdMetadata: gtfsIdMetadata,
|
|
126
|
+
serviceDay,
|
|
127
|
+
timezone: this._timezone,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const rawMovements = trip.movements.map((m, i) => {
|
|
132
|
+
return (updatedMovementsByIndex.get(i) ??
|
|
133
|
+
m.asHollowUpdatedTripMovement(serviceDay, this._timezone));
|
|
134
|
+
});
|
|
135
|
+
const interpolated = this._movementsInterpolator.interpolate(rawMovements);
|
|
136
|
+
if (interpolated == null) {
|
|
137
|
+
// TODO: This keeps happening in the PTV feed. In all the cases I've seen
|
|
138
|
+
// so far, the arrival times are one minute later than the departure times
|
|
139
|
+
// (for whatever reason). I think I should apply a patch for it, rather
|
|
140
|
+
// than "fixing" it in corequery-gtfs.
|
|
141
|
+
//
|
|
142
|
+
// TODO: Add a test for this.
|
|
143
|
+
const Err = KnownDepartureTimesEntailTimeTravelError;
|
|
144
|
+
this._onError(new Err(tripUpdate, rawMovements));
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (skippedMovementIndexes.size === 0) {
|
|
148
|
+
return new GtfsUpdatedTrip({
|
|
149
|
+
scheduledTrip: trip,
|
|
150
|
+
serviceDay,
|
|
151
|
+
movements: interpolated,
|
|
152
|
+
isCancelled: false,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// TODO: Test this.
|
|
157
|
+
const survivingMovements = interpolated.filter((movement, index) => movement.isServicing && !skippedMovementIndexes.has(index));
|
|
158
|
+
if (survivingMovements.length < 2) {
|
|
159
|
+
this._onError(new TooFewSurvivingServicingMovementsError(tripUpdate, survivingMovements));
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
return this._buildReplacedTrip(trip, serviceDay, survivingMovements);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
_buildReplacedTrip(trip, serviceDay, survivingMovements) {
|
|
166
|
+
// After stripping out skipped movements, some movements may have changed
|
|
167
|
+
// type (and all of them need converting to replaced trip movements too)!
|
|
168
|
+
const movements = survivingMovements.map((movement, index) => {
|
|
169
|
+
if (index === 0) {
|
|
170
|
+
if (movement.type === "originating") {
|
|
171
|
+
return movement.asReplacedTripOriginatingMovement();
|
|
172
|
+
}
|
|
173
|
+
else if (movement.type === "regular") {
|
|
174
|
+
return movement.asReplacedTripOriginatingMovement();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// The first surviving servicing movement cannot be terminating when
|
|
178
|
+
// there are at least two surviving movements.
|
|
179
|
+
throw new Error();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (index === survivingMovements.length - 1) {
|
|
183
|
+
if (movement.type === "regular") {
|
|
184
|
+
return movement.asReplacedTripTerminatingMovement();
|
|
185
|
+
}
|
|
186
|
+
else if (movement.type === "terminating") {
|
|
187
|
+
return movement.asReplacedTripTerminatingMovement();
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// The last surviving servicing movement cannot be originating when
|
|
191
|
+
// there are at least two surviving movements.
|
|
192
|
+
throw new Error();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
if (movement.type === "regular") {
|
|
197
|
+
return movement.asReplacedTripRegularMovement();
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// You won't get an originating or terminating movement to leave the first
|
|
201
|
+
// or last index by removing stops, so therefore if we're not in the first
|
|
202
|
+
// or last index, it must be a regular movement.
|
|
203
|
+
throw new Error();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const lineMetadata = this._lineGtfsIdMapping.tryResolve(trip.gtfsRouteId);
|
|
208
|
+
if (lineMetadata == null || lineMetadata.type === "ignored") {
|
|
209
|
+
// We're grabbing the GTFS route ID from the scheduled trip, so it should
|
|
210
|
+
// be impossible that it's invalid or ignored, otherwise the scheduled
|
|
211
|
+
// trip wouldn't exist!
|
|
212
|
+
throw new Error();
|
|
213
|
+
}
|
|
214
|
+
const routeMatch = this._routeMatcher.match(lineMetadata.lineId, movements, (stopId) => new GtfsReplacedTripPassingMovement({ stopId }));
|
|
215
|
+
if (routeMatch == null)
|
|
216
|
+
return null;
|
|
217
|
+
return new GtfsReplacedTrip({
|
|
218
|
+
scheduledTrip: trip,
|
|
219
|
+
serviceDay,
|
|
220
|
+
movements: routeMatch.movements,
|
|
221
|
+
lineIds: routeMatch.lineIds,
|
|
222
|
+
serviceTags: routeMatch.serviceTags,
|
|
223
|
+
color: routeMatch.color,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
_parseUpdatedTime(updatedTime, scheduledTime, serviceDay, tripUpdate, stopTimeUpdateEntry) {
|
|
227
|
+
if (updatedTime == null) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const { time, delay } = updatedTime;
|
|
231
|
+
const fromTime = time != null ? Temporal.Instant.fromEpochMilliseconds(time * 1000) : null;
|
|
232
|
+
const fromDelay = delay != null
|
|
233
|
+
? scheduledTime
|
|
234
|
+
.toInstant(serviceDay, this._timezone)
|
|
235
|
+
.add({ seconds: delay })
|
|
236
|
+
: null;
|
|
237
|
+
// Most/all trips in PTV's realtime feed have both time and delay. If using
|
|
238
|
+
// both of those methods gives us different results, then I've probably
|
|
239
|
+
// messed something up (e.g. maybe my service day assumption in the trip
|
|
240
|
+
// identifier is wrong)... or PTV has.
|
|
241
|
+
//
|
|
242
|
+
// We'll press on (this check is only meant for reporting/my interest), but
|
|
243
|
+
// the something's probably gonna be very broken for this trip!
|
|
244
|
+
if (fromTime != null && fromDelay != null && !fromTime.equals(fromDelay)) {
|
|
245
|
+
this._onError(new TimeAndDelayDisagreeWithEachOtherError(tripUpdate, stopTimeUpdateEntry, updatedTime, fromTime, fromDelay));
|
|
246
|
+
}
|
|
247
|
+
// I don't think it really matters which of `delay` or `time` we preference,
|
|
248
|
+
// since they're either identical, or we've (probably) messed up the service
|
|
249
|
+
// day, in which case we're either applying the right time to the wrong
|
|
250
|
+
// service (`time`), or the we've calculated the time assuming the wrong
|
|
251
|
+
// service day (`delay`).
|
|
252
|
+
//
|
|
253
|
+
// It'll probably be clearer to me trying to debug this if we apply this
|
|
254
|
+
// realtime update to yesterday/tomorrow's service and it makes it look like
|
|
255
|
+
// there's two departures of the same service happening at/near to the same
|
|
256
|
+
// time, so I'll pick `time`.
|
|
257
|
+
//
|
|
258
|
+
// This also aligns with the GTFS-RT spec, which says `time` takes
|
|
259
|
+
// precedence.
|
|
260
|
+
if (fromTime != null) {
|
|
261
|
+
return fromTime;
|
|
262
|
+
}
|
|
263
|
+
else if (fromDelay != null) {
|
|
264
|
+
return fromDelay;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
const Err = NeitherTimeNorDelayGivenError;
|
|
268
|
+
this._onError(new Err(tripUpdate, stopTimeUpdateEntry, updatedTime));
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
export class StopTimeUpdateEntryReferencesNonExistentStopSequenceError {
|
|
274
|
+
tripUpdate;
|
|
275
|
+
stopTimeUpdateEntry;
|
|
276
|
+
matchedTrip;
|
|
277
|
+
type = "stop-time-update-entry-references-non-existent-stop-sequence";
|
|
278
|
+
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip) {
|
|
279
|
+
this.tripUpdate = tripUpdate;
|
|
280
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
281
|
+
this.matchedTrip = matchedTrip;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
export class MultipleStopTimeUpdateEntriesForSameMovementIndexError {
|
|
285
|
+
tripUpdate;
|
|
286
|
+
stopTimeUpdateEntry;
|
|
287
|
+
matchedTrip;
|
|
288
|
+
matchedMovementIndex;
|
|
289
|
+
type = "multiple-stop-time-update-entries-for-same-movement-index";
|
|
290
|
+
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip, matchedMovementIndex) {
|
|
291
|
+
this.tripUpdate = tripUpdate;
|
|
292
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
293
|
+
this.matchedTrip = matchedTrip;
|
|
294
|
+
this.matchedMovementIndex = matchedMovementIndex;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// i.e. It doesn't just change the position/platform (which we're fine with),
|
|
298
|
+
// but the entire stop.
|
|
299
|
+
export class StopTimeUpdateEntryChangesStopError {
|
|
300
|
+
tripUpdate;
|
|
301
|
+
stopTimeUpdateEntry;
|
|
302
|
+
matchedTrip;
|
|
303
|
+
matchedMovementIndex;
|
|
304
|
+
type = "stop-time-update-entry-changes-stop";
|
|
305
|
+
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip, matchedMovementIndex) {
|
|
306
|
+
this.tripUpdate = tripUpdate;
|
|
307
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
308
|
+
this.matchedTrip = matchedTrip;
|
|
309
|
+
this.matchedMovementIndex = matchedMovementIndex;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
export class NeitherTimeNorDelayGivenError {
|
|
313
|
+
tripUpdate;
|
|
314
|
+
stopTimeUpdateEntry;
|
|
315
|
+
updatedTime;
|
|
316
|
+
type = "neither-time-nor-delay-given";
|
|
317
|
+
constructor(tripUpdate, stopTimeUpdateEntry, updatedTime) {
|
|
318
|
+
this.tripUpdate = tripUpdate;
|
|
319
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
320
|
+
this.updatedTime = updatedTime;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
export class TimeAndDelayDisagreeWithEachOtherError {
|
|
324
|
+
tripUpdate;
|
|
325
|
+
stopTimeUpdateEntry;
|
|
326
|
+
updatedTime;
|
|
327
|
+
parsedFromTime;
|
|
328
|
+
parsedFromDelay;
|
|
329
|
+
type = "time-and-delay-disagree-with-each-other";
|
|
330
|
+
constructor(tripUpdate, stopTimeUpdateEntry, updatedTime, parsedFromTime, parsedFromDelay) {
|
|
331
|
+
this.tripUpdate = tripUpdate;
|
|
332
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
333
|
+
this.updatedTime = updatedTime;
|
|
334
|
+
this.parsedFromTime = parsedFromTime;
|
|
335
|
+
this.parsedFromDelay = parsedFromDelay;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export class NeitherArrivalNorDepartureGivenError {
|
|
339
|
+
tripUpdate;
|
|
340
|
+
stopTimeUpdateEntry;
|
|
341
|
+
type = "neither-arrival-nor-departure-given";
|
|
342
|
+
constructor(tripUpdate, stopTimeUpdateEntry) {
|
|
343
|
+
this.tripUpdate = tripUpdate;
|
|
344
|
+
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
class KnownDepartureTimesEntailTimeTravelError {
|
|
348
|
+
tripUpdate;
|
|
349
|
+
movements;
|
|
350
|
+
type = "known-departure-times-entail-time-travel";
|
|
351
|
+
constructor(tripUpdate, movements) {
|
|
352
|
+
this.tripUpdate = tripUpdate;
|
|
353
|
+
this.movements = movements;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
class TooFewSurvivingServicingMovementsError {
|
|
357
|
+
tripUpdate;
|
|
358
|
+
survivingMovements;
|
|
359
|
+
type = "too-few-surviving-servicing-movements";
|
|
360
|
+
constructor(tripUpdate, survivingMovements) {
|
|
361
|
+
this.tripUpdate = tripUpdate;
|
|
362
|
+
this.survivingMovements = survivingMovements;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# 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;AAa5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,iEAAiE,CAAC;AAElH,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAE/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACL,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAClC,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;AAC3E,MAAM,oDAAoD,GAAG,SAAS,CAAC;AAWvE,MAA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AoB;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;AAED,MAAM,sCAAsC;IAG/B;IACA;IAHF,IAAI,GAAG,uCAAuC,CAAC;IACxD,YACW,UAA0B,EAC1B,kBAA6C;QAD7C,eAAU,GAAV,UAAU,CAAgB;QAC1B,uBAAkB,GAAlB,kBAAkB,CAA2B;IACrD,CAAC;CACL"}
|
|
@@ -4,7 +4,7 @@ import type { StopTimesCsv, StopTimesCsvRow, TransfersCsv, TripsCsv, TripsCsvRow
|
|
|
4
4
|
import type { GtfsCalendar } from "../../data/gtfs-calendar.js";
|
|
5
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
|
+
}
|