corequery-gtfs 0.11.0 → 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 +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.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-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 +30 -296
- 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-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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtfs-trip-update-parser.js","sourceRoot":"","sources":["../../../src/parser/realtime/gtfs-trip-update-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gtfs-trip-update-parser.js","sourceRoot":"","sources":["../../../src/parser/realtime/gtfs-trip-update-parser.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,6BAA6B,GAE9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,2BAA2B,GAE5B,MAAM,sCAAsC,CAAC;AAK9C,MAAM,2CAA2C,GAAG,WAAW,CAAC;AAChE,MAAM,2CAA2C,GAAG,UAAU,CAAC;AAC/D,MAAM,uCAAuC,GAAG,OAAO,CAAC;AACxD,MAAM,qCAAqC,GAAG,KAAK,CAAC;AAWpD,MAAM,OAAO,oBAAoB;IACd,QAAQ,CAA8C;IAEtD,kBAAkB,CAA8B;IAChD,oBAAoB,CAAgC;IACpD,gBAAgB,CAA4B;IAE7D,YAAY,MAAkC;QAC5C,IAAI,CAAC,QAA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AAI,CAAC,QAAQ,CACX,IAAI,8CAA8C,CAAC,UAAU,CAAC,CAC/D,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAQD,MAAM,OAAO,8CAA8C;IAGpC;IAFZ,IAAI,GAAG,+CAA+C,CAAC;IAEhE,YAAqB,UAA0B;QAA1B,eAAU,GAAV,UAAU,CAAgB;IAAG,CAAC;CACpD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { StopGtfsIdMapping } from "../../data/ids/stop-gtfs-id-mapping.js";
|
|
2
|
+
import type { StopTimeUpdateJson, TripUpdateJson, UpdatedTimeJson } from "../../data/raw/realtime-data-json.js";
|
|
3
|
+
import type { GtfsScheduleData } from "../../data/gtfs-schedule-data.js";
|
|
4
|
+
import type { GtfsScheduledTrip } from "../../data/trip/scheduled/gtfs-scheduled-trip.js";
|
|
5
|
+
import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
|
|
6
|
+
import type { GtfsUpdatedTripMovement } from "../../data/trip/updated/types.js";
|
|
7
|
+
import { type GtfsScheduledTripIdentificationError } from "./gtfs-scheduled-trip-identifier.js";
|
|
8
|
+
import { NecessaryFieldNotInStopTimeUpdateEntryError, NoStopTimeUpdateFieldGivenError, StopTimeUpdateEntryReferencesUnmappedStopIdError, UnsupportedStopTimeUpdateEntryScheduleRelationshipError } from "./gtfs-trip-update-parser-common-error-types.js";
|
|
9
|
+
export type GtfsUpdatedTripUpdateParserFields = {
|
|
10
|
+
readonly timezone: string;
|
|
11
|
+
readonly stopGtfsIdMapping: StopGtfsIdMapping;
|
|
12
|
+
readonly onError: (error: GtfsUpdatedTripUpdateParsingError) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare class GtfsUpdatedTripUpdateParser {
|
|
15
|
+
private readonly _timezone;
|
|
16
|
+
private readonly _stopGtfsIdMapping;
|
|
17
|
+
private readonly _onError;
|
|
18
|
+
private readonly _tripIdentifier;
|
|
19
|
+
private readonly _movementsInterpolator;
|
|
20
|
+
constructor(fields: GtfsUpdatedTripUpdateParserFields);
|
|
21
|
+
parse(tripUpdate: TripUpdateJson, scheduleData: GtfsScheduleData): GtfsUpdatedTrip | null;
|
|
22
|
+
private _parseUpdatedTime;
|
|
23
|
+
}
|
|
24
|
+
export type GtfsUpdatedTripUpdateParsingError = GtfsScheduledTripIdentificationError | NoStopTimeUpdateFieldGivenError | UnsupportedStopTimeUpdateEntryScheduleRelationshipError | NecessaryFieldNotInStopTimeUpdateEntryError | StopTimeUpdateEntryReferencesNonExistentStopSequenceError | MultipleStopTimeUpdateEntriesForSameMovementIndexError | StopTimeUpdateEntryReferencesUnmappedStopIdError | StopTimeUpdateEntryChangesStopError | NeitherTimeNorDelayGivenError | TimeAndDelayDisagreeWithEachOtherError | NeitherArrivalNorDepartureGivenError | KnownDepartureTimesEntailTimeTravelError;
|
|
25
|
+
export declare class StopTimeUpdateEntryReferencesNonExistentStopSequenceError {
|
|
26
|
+
readonly tripUpdate: TripUpdateJson;
|
|
27
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
28
|
+
readonly matchedTrip: GtfsScheduledTrip;
|
|
29
|
+
readonly type = "stop-time-update-entry-references-non-existent-stop-sequence";
|
|
30
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip);
|
|
31
|
+
}
|
|
32
|
+
export declare class MultipleStopTimeUpdateEntriesForSameMovementIndexError {
|
|
33
|
+
readonly tripUpdate: TripUpdateJson;
|
|
34
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
35
|
+
readonly matchedTrip: GtfsScheduledTrip;
|
|
36
|
+
readonly matchedMovementIndex: number;
|
|
37
|
+
readonly type = "multiple-stop-time-update-entries-for-same-movement-index";
|
|
38
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip, matchedMovementIndex: number);
|
|
39
|
+
}
|
|
40
|
+
export declare class StopTimeUpdateEntryChangesStopError {
|
|
41
|
+
readonly tripUpdate: TripUpdateJson;
|
|
42
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
43
|
+
readonly matchedTrip: GtfsScheduledTrip;
|
|
44
|
+
readonly matchedMovementIndex: number;
|
|
45
|
+
readonly type = "stop-time-update-entry-changes-stop";
|
|
46
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip, matchedMovementIndex: number);
|
|
47
|
+
}
|
|
48
|
+
export declare class NeitherTimeNorDelayGivenError {
|
|
49
|
+
readonly tripUpdate: TripUpdateJson;
|
|
50
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
51
|
+
readonly updatedTime: UpdatedTimeJson;
|
|
52
|
+
readonly type = "neither-time-nor-delay-given";
|
|
53
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, updatedTime: UpdatedTimeJson);
|
|
54
|
+
}
|
|
55
|
+
export declare class TimeAndDelayDisagreeWithEachOtherError {
|
|
56
|
+
readonly tripUpdate: TripUpdateJson;
|
|
57
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
58
|
+
readonly updatedTime: UpdatedTimeJson;
|
|
59
|
+
readonly parsedFromTime: Temporal.Instant;
|
|
60
|
+
readonly parsedFromDelay: Temporal.Instant;
|
|
61
|
+
readonly type = "time-and-delay-disagree-with-each-other";
|
|
62
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, updatedTime: UpdatedTimeJson, parsedFromTime: Temporal.Instant, parsedFromDelay: Temporal.Instant);
|
|
63
|
+
}
|
|
64
|
+
export declare class NeitherArrivalNorDepartureGivenError {
|
|
65
|
+
readonly tripUpdate: TripUpdateJson;
|
|
66
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
67
|
+
readonly type = "neither-arrival-nor-departure-given";
|
|
68
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson);
|
|
69
|
+
}
|
|
70
|
+
declare class KnownDepartureTimesEntailTimeTravelError {
|
|
71
|
+
readonly tripUpdate: TripUpdateJson;
|
|
72
|
+
readonly movements: readonly GtfsUpdatedTripMovement[];
|
|
73
|
+
readonly type = "known-departure-times-entail-time-travel";
|
|
74
|
+
constructor(tripUpdate: TripUpdateJson, movements: readonly GtfsUpdatedTripMovement[]);
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
@@ -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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AQ;IACpC,CAAC;CACL;AAED,MAAM,OAAO,6BAA6B;IAG7B;IACA;IACA;IAJF,IAAI,GAAG,8BAA8B,CAAC;IAC/C,YACW,UAA0B,EAC1B,mBAAuC,EACvC,WAA4B;QAF5B,eAAU,GAAV,UAAU,CAAgB;QAC1B,wBAAmB,GAAnB,mBAAmB,CAAoB;QACvC,gBAAW,GAAX,WAAW,CAAiB;IACpC,CAAC;CACL;AAED,MAAM,OAAO,sCAAsC;IAGtC;IACA;IACA;IACA;IACA;IANF,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"}
|
|
@@ -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
|
+
}
|