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
|
@@ -1,106 +1,31 @@
|
|
|
1
1
|
import type { GtfsScheduleData } from "../../data/gtfs-schedule-data.js";
|
|
2
|
-
import type {
|
|
3
|
-
import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
|
|
4
|
-
import type { StopTimeUpdateJson, TripUpdateJson, UpdatedTimeJson } from "../../data/raw/realtime-data-json.js";
|
|
5
|
-
import { type GtfsTripUpdateTripIdentificationError } from "./gtfs-trip-update-trip-identifier.js";
|
|
2
|
+
import type { TripUpdateJson } from "../../data/raw/realtime-data-json.js";
|
|
6
3
|
import type { StopGtfsIdMapping } from "../../data/ids/stop-gtfs-id-mapping.js";
|
|
7
|
-
import type
|
|
4
|
+
import { type GtfsAddedTripUpdateParsingError } from "./gtfs-added-trip-update-parser.js";
|
|
5
|
+
import { type GtfsCancelledTripUpdateParsingError } from "./gtfs-cancelled-trip-update-parser.js";
|
|
6
|
+
import { type GtfsUpdatedTripUpdateParsingError } from "./gtfs-updated-trip-update-parser.js";
|
|
7
|
+
import type { LineRoutesMapping } from "../../data/route/line-routes-mapping.js";
|
|
8
|
+
import type { BonusLinesMapping } from "../../data/route/bonus-lines-mapping.js";
|
|
9
|
+
import type { LineGtfsIdMapping } from "../../data/ids/line-gtfs-id-mapping.js";
|
|
8
10
|
export type GtfsTripUpdateParserFields = {
|
|
9
11
|
readonly timezone: string;
|
|
10
12
|
readonly stopGtfsIdMapping: StopGtfsIdMapping;
|
|
13
|
+
readonly lineGtfsIdMapping: LineGtfsIdMapping;
|
|
14
|
+
readonly lineRoutesMapping: LineRoutesMapping;
|
|
15
|
+
readonly bonusLinesMapping: BonusLinesMapping;
|
|
11
16
|
readonly onError: (error: GtfsTripUpdateParsingError) => void;
|
|
12
17
|
};
|
|
13
18
|
export declare class GtfsTripUpdateParser {
|
|
14
|
-
private readonly _timezone;
|
|
15
|
-
private readonly _stopGtfsIdMapping;
|
|
16
19
|
private readonly _onError;
|
|
17
|
-
private readonly
|
|
18
|
-
private readonly
|
|
20
|
+
private readonly _updatedTripParser;
|
|
21
|
+
private readonly _cancelledTripParser;
|
|
22
|
+
private readonly _addedTripParser;
|
|
19
23
|
constructor(fields: GtfsTripUpdateParserFields);
|
|
20
|
-
parse(tripUpdate: TripUpdateJson, scheduleData: GtfsScheduleData): GtfsUpdatedTrip | null;
|
|
21
|
-
private _parseForScheduledTrip;
|
|
22
|
-
private _parseForCancelledTrip;
|
|
23
|
-
private _parseUpdatedTime;
|
|
24
|
+
parse(tripUpdate: TripUpdateJson, scheduleData: GtfsScheduleData): import("../../data/trip/added/gtfs-added-trip.js").GtfsAddedTrip | import("../../data/trip/replaced/gtfs-replaced-trip.js").GtfsReplacedTrip | import("../../data/trip/updated/gtfs-updated-trip.js").GtfsUpdatedTrip | null;
|
|
24
25
|
}
|
|
25
|
-
export type GtfsTripUpdateParsingError = UnsupportedTripUpdateScheduleRelationshipError |
|
|
26
|
+
export type GtfsTripUpdateParsingError = UnsupportedTripUpdateScheduleRelationshipError | GtfsUpdatedTripUpdateParsingError | GtfsCancelledTripUpdateParsingError | GtfsAddedTripUpdateParsingError;
|
|
26
27
|
export declare class UnsupportedTripUpdateScheduleRelationshipError {
|
|
27
28
|
readonly tripUpdate: TripUpdateJson;
|
|
28
29
|
readonly type = "unsupported-trip-update-schedule-relationship";
|
|
29
30
|
constructor(tripUpdate: TripUpdateJson);
|
|
30
31
|
}
|
|
31
|
-
export declare class NoStopTimeUpdateFieldGivenError {
|
|
32
|
-
readonly tripUpdate: TripUpdateJson;
|
|
33
|
-
readonly type = "no-stop-time-update-field-given";
|
|
34
|
-
constructor(tripUpdate: TripUpdateJson);
|
|
35
|
-
}
|
|
36
|
-
export declare class UnsupportedStopTimeUpdateEntryScheduleRelationshipError {
|
|
37
|
-
readonly tripUpdate: TripUpdateJson;
|
|
38
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
39
|
-
readonly type = "unsupported-stop-time-update-entry-schedule-relationship";
|
|
40
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson);
|
|
41
|
-
}
|
|
42
|
-
export declare class NecessaryFieldNotInStopTimeUpdateEntryError {
|
|
43
|
-
readonly tripUpdate: TripUpdateJson;
|
|
44
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
45
|
-
readonly field: "stopSequence" | "stopId";
|
|
46
|
-
readonly type = "necessary-field-not-in-stop-time-update-entry";
|
|
47
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, field: "stopSequence" | "stopId");
|
|
48
|
-
}
|
|
49
|
-
export declare class StopTimeUpdateEntryReferencesNonExistentStopSequenceError {
|
|
50
|
-
readonly tripUpdate: TripUpdateJson;
|
|
51
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
52
|
-
readonly matchedTrip: GtfsScheduledTrip;
|
|
53
|
-
readonly type = "stop-time-update-entry-references-non-existent-stop-sequence";
|
|
54
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip);
|
|
55
|
-
}
|
|
56
|
-
export declare class MultipleStopTimeUpdateEntriesForSameMovementIndexError {
|
|
57
|
-
readonly tripUpdate: TripUpdateJson;
|
|
58
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
59
|
-
readonly matchedTrip: GtfsScheduledTrip;
|
|
60
|
-
readonly matchedMovementIndex: number;
|
|
61
|
-
readonly type = "multiple-stop-time-update-entries-for-same-movement-index";
|
|
62
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip, matchedMovementIndex: number);
|
|
63
|
-
}
|
|
64
|
-
export declare class StopTimeUpdateEntryReferencesUnmappedStopIdError {
|
|
65
|
-
readonly tripUpdate: TripUpdateJson;
|
|
66
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
67
|
-
readonly type = "stop-time-update-entry-references-unmapped-stop-id";
|
|
68
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson);
|
|
69
|
-
}
|
|
70
|
-
export declare class StopTimeUpdateEntryChangesStopError {
|
|
71
|
-
readonly tripUpdate: TripUpdateJson;
|
|
72
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
73
|
-
readonly matchedTrip: GtfsScheduledTrip;
|
|
74
|
-
readonly matchedMovementIndex: number;
|
|
75
|
-
readonly type = "stop-time-update-entry-changes-stop";
|
|
76
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip, matchedMovementIndex: number);
|
|
77
|
-
}
|
|
78
|
-
export declare class NeitherTimeNorDelayGivenError {
|
|
79
|
-
readonly tripUpdate: TripUpdateJson;
|
|
80
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
81
|
-
readonly updatedTime: UpdatedTimeJson;
|
|
82
|
-
readonly type = "neither-time-nor-delay-given";
|
|
83
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, updatedTime: UpdatedTimeJson);
|
|
84
|
-
}
|
|
85
|
-
export declare class TimeAndDelayDisagreeWithEachOtherError {
|
|
86
|
-
readonly tripUpdate: TripUpdateJson;
|
|
87
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
88
|
-
readonly updatedTime: UpdatedTimeJson;
|
|
89
|
-
readonly parsedFromTime: Temporal.Instant;
|
|
90
|
-
readonly parsedFromDelay: Temporal.Instant;
|
|
91
|
-
readonly type = "time-and-delay-disagree-with-each-other";
|
|
92
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, updatedTime: UpdatedTimeJson, parsedFromTime: Temporal.Instant, parsedFromDelay: Temporal.Instant);
|
|
93
|
-
}
|
|
94
|
-
export declare class NeitherArrivalNorDepartureGivenError {
|
|
95
|
-
readonly tripUpdate: TripUpdateJson;
|
|
96
|
-
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
97
|
-
readonly type = "neither-arrival-nor-departure-given";
|
|
98
|
-
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson);
|
|
99
|
-
}
|
|
100
|
-
declare class KnownDepartureTimesEntailTimeTravel {
|
|
101
|
-
readonly tripUpdate: TripUpdateJson;
|
|
102
|
-
readonly movements: readonly GtfsUpdatedTripMovement[];
|
|
103
|
-
readonly type = "known-departure-times-entail-time-travel";
|
|
104
|
-
constructor(tripUpdate: TripUpdateJson, movements: readonly GtfsUpdatedTripMovement[]);
|
|
105
|
-
}
|
|
106
|
-
export {};
|
|
@@ -1,197 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { GtfsTripMovementsInterpolator } from "./gtfs-trip-movements-interpolator.js";
|
|
1
|
+
import { GtfsAddedTripUpdateParser, } from "./gtfs-added-trip-update-parser.js";
|
|
2
|
+
import { GtfsCancelledTripUpdateParser, } from "./gtfs-cancelled-trip-update-parser.js";
|
|
3
|
+
import { GtfsUpdatedTripUpdateParser, } from "./gtfs-updated-trip-update-parser.js";
|
|
5
4
|
const TRIP_UPDATE_SCHEDULE_RELATIONSHIP_SCHEDULED = "SCHEDULED";
|
|
6
5
|
const TRIP_UPDATE_SCHEDULE_RELATIONSHIP_CANCELLED = "CANCELED";
|
|
7
|
-
const
|
|
6
|
+
const TRIP_UPDATE_SCHEDULE_RELATIONSHIP_ADDED = "ADDED";
|
|
7
|
+
const TRIP_UPDATE_SCHEDULE_RELATIONSHIP_NEW = "NEW";
|
|
8
8
|
export class GtfsTripUpdateParser {
|
|
9
|
-
_timezone;
|
|
10
|
-
_stopGtfsIdMapping;
|
|
11
9
|
_onError;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
_updatedTripParser;
|
|
11
|
+
_cancelledTripParser;
|
|
12
|
+
_addedTripParser;
|
|
14
13
|
constructor(fields) {
|
|
15
|
-
this._timezone = fields.timezone;
|
|
16
|
-
this._stopGtfsIdMapping = fields.stopGtfsIdMapping;
|
|
17
14
|
this._onError = fields.onError;
|
|
18
|
-
this.
|
|
15
|
+
this._updatedTripParser = new GtfsUpdatedTripUpdateParser({
|
|
16
|
+
timezone: fields.timezone,
|
|
17
|
+
stopGtfsIdMapping: fields.stopGtfsIdMapping,
|
|
18
|
+
lineGtfsIdMapping: fields.lineGtfsIdMapping,
|
|
19
|
+
lineRoutesMapping: fields.lineRoutesMapping,
|
|
20
|
+
bonusLinesMapping: fields.bonusLinesMapping,
|
|
21
|
+
onError: this._onError,
|
|
22
|
+
});
|
|
23
|
+
this._cancelledTripParser = new GtfsCancelledTripUpdateParser({
|
|
24
|
+
timezone: fields.timezone,
|
|
25
|
+
onError: this._onError,
|
|
26
|
+
});
|
|
27
|
+
this._addedTripParser = new GtfsAddedTripUpdateParser({
|
|
28
|
+
stopGtfsIdMapping: fields.stopGtfsIdMapping,
|
|
29
|
+
lineGtfsIdMapping: fields.lineGtfsIdMapping,
|
|
30
|
+
lineRoutesMapping: fields.lineRoutesMapping,
|
|
31
|
+
bonusLinesMapping: fields.bonusLinesMapping,
|
|
19
32
|
onError: this._onError,
|
|
20
33
|
});
|
|
21
|
-
this._movementsInterpolator = new GtfsTripMovementsInterpolator();
|
|
22
34
|
}
|
|
23
35
|
parse(tripUpdate, scheduleData) {
|
|
24
36
|
const sr = tripUpdate.trip.scheduleRelationship;
|
|
25
37
|
if (sr === TRIP_UPDATE_SCHEDULE_RELATIONSHIP_SCHEDULED) {
|
|
26
|
-
return this.
|
|
38
|
+
return this._updatedTripParser.parse(tripUpdate, scheduleData);
|
|
27
39
|
}
|
|
28
40
|
else if (sr === TRIP_UPDATE_SCHEDULE_RELATIONSHIP_CANCELLED) {
|
|
29
|
-
return this.
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
this._onError(new UnsupportedTripUpdateScheduleRelationshipError(tripUpdate));
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
_parseForScheduledTrip(tripUpdate, scheduleData) {
|
|
37
|
-
const result = this._tripIdentifier.identify(tripUpdate.trip, scheduleData);
|
|
38
|
-
if (result == null)
|
|
39
|
-
return null;
|
|
40
|
-
const { trip, serviceDay } = result;
|
|
41
|
-
if (tripUpdate.stopTimeUpdate == null) {
|
|
42
|
-
this._onError(new NoStopTimeUpdateFieldGivenError(tripUpdate));
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const updatedMovementsByIndex = new Map();
|
|
46
|
-
for (const entry of tripUpdate.stopTimeUpdate) {
|
|
47
|
-
// This `scheduleRelationship` field is probably how altered routes work.
|
|
48
|
-
const sr = entry.scheduleRelationship;
|
|
49
|
-
if (sr !== STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED) {
|
|
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 (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
|
-
const Err = MultipleStopTimeUpdateEntriesForSameMovementIndexError;
|
|
88
|
-
this._onError(new Err(tripUpdate, entry, trip, movementIndex));
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
// Look up the stop GTFS ID given in the stop time update entry, and check
|
|
92
|
-
// whether it still maps to the same (CoreQuery) stop. In this way, we
|
|
93
|
-
// allow the platform/position ID to change, not the overall stop/station.
|
|
94
|
-
const gtfsIdMetadata = this._stopGtfsIdMapping.tryResolve(entry.stopId);
|
|
95
|
-
if (gtfsIdMetadata == null) {
|
|
96
|
-
const Err = StopTimeUpdateEntryReferencesUnmappedStopIdError;
|
|
97
|
-
this._onError(new Err(tripUpdate, entry));
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
if (gtfsIdMetadata.stopId !== scheduledMovement.gtfsIdMetadata.stopId) {
|
|
101
|
-
const Err = StopTimeUpdateEntryChangesStopError;
|
|
102
|
-
this._onError(new Err(tripUpdate, entry, trip, movementIndex));
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
const updatedPositionId = gtfsIdMetadata.type === "positional" ? gtfsIdMetadata.positionId : null;
|
|
106
|
-
// Parse the updated times from the `arrivalTime` and `departureTime`
|
|
107
|
-
// fields.
|
|
108
|
-
const realtimeArrivalTime = "arrivalTime" in scheduledMovement
|
|
109
|
-
? this._parseUpdatedTime(entry.arrival ?? null, scheduledMovement.arrivalTime, serviceDay, tripUpdate, entry)
|
|
110
|
-
: null;
|
|
111
|
-
const realtimeDepartureTime = "departureTime" in scheduledMovement
|
|
112
|
-
? this._parseUpdatedTime(entry.departure ?? null, scheduledMovement.departureTime, serviceDay, tripUpdate, entry)
|
|
113
|
-
: null;
|
|
114
|
-
updatedMovementsByIndex.set(movementIndex, scheduledMovement.asUpdatedTripMovement({
|
|
115
|
-
arrivalTime: realtimeArrivalTime,
|
|
116
|
-
departureTime: realtimeDepartureTime,
|
|
117
|
-
updatedPositionId,
|
|
118
|
-
updatedGtfsIdMetadata: gtfsIdMetadata,
|
|
119
|
-
serviceDay,
|
|
120
|
-
timezone: this._timezone,
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
const rawMovements = trip.movements.map((m, i) => {
|
|
124
|
-
return (updatedMovementsByIndex.get(i) ??
|
|
125
|
-
m.asHollowUpdatedTripMovement(serviceDay, this._timezone));
|
|
126
|
-
});
|
|
127
|
-
const interpolated = this._movementsInterpolator.interpolate(rawMovements);
|
|
128
|
-
if (interpolated == null) {
|
|
129
|
-
// TODO: This keeps happening in the PTV feed. In all the cases I've seen
|
|
130
|
-
// so far, the arrival times are one minute later than the departure times
|
|
131
|
-
// (for whatever reason). I think I should apply a patch for it, rather
|
|
132
|
-
// than "fixing" it in corequery-gtfs.
|
|
133
|
-
//
|
|
134
|
-
// TODO: Add a test for this.
|
|
135
|
-
const Err = KnownDepartureTimesEntailTimeTravel;
|
|
136
|
-
this._onError(new Err(tripUpdate, rawMovements));
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return new GtfsUpdatedTrip({
|
|
140
|
-
scheduledTrip: trip,
|
|
141
|
-
serviceDay,
|
|
142
|
-
movements: interpolated,
|
|
143
|
-
isCancelled: false,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
_parseForCancelledTrip(tripUpdate, scheduleData) {
|
|
147
|
-
const result = this._tripIdentifier.identify(tripUpdate.trip, scheduleData);
|
|
148
|
-
if (result == null)
|
|
149
|
-
return null;
|
|
150
|
-
const { trip, serviceDay } = result;
|
|
151
|
-
return GtfsUpdatedTrip.unmodified(trip, serviceDay, this._timezone).with({
|
|
152
|
-
isCancelled: true,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
_parseUpdatedTime(updatedTime, scheduledTime, serviceDay, tripUpdate, stopTimeUpdateEntry) {
|
|
156
|
-
if (updatedTime == null) {
|
|
157
|
-
return null;
|
|
41
|
+
return this._cancelledTripParser.parse(tripUpdate, scheduleData);
|
|
158
42
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.add({ seconds: delay })
|
|
165
|
-
: null;
|
|
166
|
-
// Most/all trips in PTV's realtime feed have both time and delay. If using
|
|
167
|
-
// both of those methods gives us different results, then I've probably
|
|
168
|
-
// messed something up (e.g. maybe my service day assumption in the trip
|
|
169
|
-
// identifier is wrong)... or PTV has.
|
|
170
|
-
//
|
|
171
|
-
// We'll press on (this check is only meant for reporting/my interest), but
|
|
172
|
-
// the something's probably gonna be very broken for this trip!
|
|
173
|
-
if (fromTime != null && fromDelay != null && !fromTime.equals(fromDelay)) {
|
|
174
|
-
this._onError(new TimeAndDelayDisagreeWithEachOtherError(tripUpdate, stopTimeUpdateEntry, updatedTime, fromTime, fromDelay));
|
|
175
|
-
}
|
|
176
|
-
// I don't think it really matters which of `delay` or `time` we preference,
|
|
177
|
-
// since they're either identical, or we've (probably) messed up the service
|
|
178
|
-
// day, in which case we're either applying the right time to the wrong
|
|
179
|
-
// service (`time`), or the we've calculated the time assuming the wrong
|
|
180
|
-
// service day (`delay`).
|
|
181
|
-
//
|
|
182
|
-
// It'll probably be clearer to me trying to debug this if we apply this
|
|
183
|
-
// realtime update to yesterday/tomorrow's service and it makes it look like
|
|
184
|
-
// there's two departures of the same service happening at/near to the same
|
|
185
|
-
// time, so I'll pick `time`.
|
|
186
|
-
if (fromTime != null) {
|
|
187
|
-
return fromTime;
|
|
188
|
-
}
|
|
189
|
-
else if (fromDelay != null) {
|
|
190
|
-
return fromDelay;
|
|
43
|
+
else if (
|
|
44
|
+
// ADDED is deprecated in favour of NEW, but PTV still uses ADDED.
|
|
45
|
+
sr === TRIP_UPDATE_SCHEDULE_RELATIONSHIP_ADDED ||
|
|
46
|
+
sr === TRIP_UPDATE_SCHEDULE_RELATIONSHIP_NEW) {
|
|
47
|
+
return this._addedTripParser.parse(tripUpdate, scheduleData);
|
|
191
48
|
}
|
|
192
49
|
else {
|
|
193
|
-
|
|
194
|
-
this._onError(new Err(tripUpdate, stopTimeUpdateEntry, updatedTime));
|
|
50
|
+
this._onError(new UnsupportedTripUpdateScheduleRelationshipError(tripUpdate));
|
|
195
51
|
return null;
|
|
196
52
|
}
|
|
197
53
|
}
|
|
@@ -203,123 +59,4 @@ export class UnsupportedTripUpdateScheduleRelationshipError {
|
|
|
203
59
|
this.tripUpdate = tripUpdate;
|
|
204
60
|
}
|
|
205
61
|
}
|
|
206
|
-
export class NoStopTimeUpdateFieldGivenError {
|
|
207
|
-
tripUpdate;
|
|
208
|
-
type = "no-stop-time-update-field-given";
|
|
209
|
-
constructor(tripUpdate) {
|
|
210
|
-
this.tripUpdate = tripUpdate;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
export class UnsupportedStopTimeUpdateEntryScheduleRelationshipError {
|
|
214
|
-
tripUpdate;
|
|
215
|
-
stopTimeUpdateEntry;
|
|
216
|
-
type = "unsupported-stop-time-update-entry-schedule-relationship";
|
|
217
|
-
constructor(tripUpdate, stopTimeUpdateEntry) {
|
|
218
|
-
this.tripUpdate = tripUpdate;
|
|
219
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
export class NecessaryFieldNotInStopTimeUpdateEntryError {
|
|
223
|
-
tripUpdate;
|
|
224
|
-
stopTimeUpdateEntry;
|
|
225
|
-
field;
|
|
226
|
-
type = "necessary-field-not-in-stop-time-update-entry";
|
|
227
|
-
constructor(tripUpdate, stopTimeUpdateEntry, field) {
|
|
228
|
-
this.tripUpdate = tripUpdate;
|
|
229
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
230
|
-
this.field = field;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
export class StopTimeUpdateEntryReferencesNonExistentStopSequenceError {
|
|
234
|
-
tripUpdate;
|
|
235
|
-
stopTimeUpdateEntry;
|
|
236
|
-
matchedTrip;
|
|
237
|
-
type = "stop-time-update-entry-references-non-existent-stop-sequence";
|
|
238
|
-
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip) {
|
|
239
|
-
this.tripUpdate = tripUpdate;
|
|
240
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
241
|
-
this.matchedTrip = matchedTrip;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
export class MultipleStopTimeUpdateEntriesForSameMovementIndexError {
|
|
245
|
-
tripUpdate;
|
|
246
|
-
stopTimeUpdateEntry;
|
|
247
|
-
matchedTrip;
|
|
248
|
-
matchedMovementIndex;
|
|
249
|
-
type = "multiple-stop-time-update-entries-for-same-movement-index";
|
|
250
|
-
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip, matchedMovementIndex) {
|
|
251
|
-
this.tripUpdate = tripUpdate;
|
|
252
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
253
|
-
this.matchedTrip = matchedTrip;
|
|
254
|
-
this.matchedMovementIndex = matchedMovementIndex;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
export class StopTimeUpdateEntryReferencesUnmappedStopIdError {
|
|
258
|
-
tripUpdate;
|
|
259
|
-
stopTimeUpdateEntry;
|
|
260
|
-
type = "stop-time-update-entry-references-unmapped-stop-id";
|
|
261
|
-
constructor(tripUpdate, stopTimeUpdateEntry) {
|
|
262
|
-
this.tripUpdate = tripUpdate;
|
|
263
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
// i.e. It doesn't just change the position/platform (which we're fine with),
|
|
267
|
-
// but the entire stop.
|
|
268
|
-
export class StopTimeUpdateEntryChangesStopError {
|
|
269
|
-
tripUpdate;
|
|
270
|
-
stopTimeUpdateEntry;
|
|
271
|
-
matchedTrip;
|
|
272
|
-
matchedMovementIndex;
|
|
273
|
-
type = "stop-time-update-entry-changes-stop";
|
|
274
|
-
constructor(tripUpdate, stopTimeUpdateEntry, matchedTrip, matchedMovementIndex) {
|
|
275
|
-
this.tripUpdate = tripUpdate;
|
|
276
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
277
|
-
this.matchedTrip = matchedTrip;
|
|
278
|
-
this.matchedMovementIndex = matchedMovementIndex;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
export class NeitherTimeNorDelayGivenError {
|
|
282
|
-
tripUpdate;
|
|
283
|
-
stopTimeUpdateEntry;
|
|
284
|
-
updatedTime;
|
|
285
|
-
type = "neither-time-nor-delay-given";
|
|
286
|
-
constructor(tripUpdate, stopTimeUpdateEntry, updatedTime) {
|
|
287
|
-
this.tripUpdate = tripUpdate;
|
|
288
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
289
|
-
this.updatedTime = updatedTime;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
export class TimeAndDelayDisagreeWithEachOtherError {
|
|
293
|
-
tripUpdate;
|
|
294
|
-
stopTimeUpdateEntry;
|
|
295
|
-
updatedTime;
|
|
296
|
-
parsedFromTime;
|
|
297
|
-
parsedFromDelay;
|
|
298
|
-
type = "time-and-delay-disagree-with-each-other";
|
|
299
|
-
constructor(tripUpdate, stopTimeUpdateEntry, updatedTime, parsedFromTime, parsedFromDelay) {
|
|
300
|
-
this.tripUpdate = tripUpdate;
|
|
301
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
302
|
-
this.updatedTime = updatedTime;
|
|
303
|
-
this.parsedFromTime = parsedFromTime;
|
|
304
|
-
this.parsedFromDelay = parsedFromDelay;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
export class NeitherArrivalNorDepartureGivenError {
|
|
308
|
-
tripUpdate;
|
|
309
|
-
stopTimeUpdateEntry;
|
|
310
|
-
type = "neither-arrival-nor-departure-given";
|
|
311
|
-
constructor(tripUpdate, stopTimeUpdateEntry) {
|
|
312
|
-
this.tripUpdate = tripUpdate;
|
|
313
|
-
this.stopTimeUpdateEntry = stopTimeUpdateEntry;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
class KnownDepartureTimesEntailTimeTravel {
|
|
317
|
-
tripUpdate;
|
|
318
|
-
movements;
|
|
319
|
-
type = "known-departure-times-entail-time-travel";
|
|
320
|
-
constructor(tripUpdate, movements) {
|
|
321
|
-
this.tripUpdate = tripUpdate;
|
|
322
|
-
this.movements = movements;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
62
|
//# sourceMappingURL=gtfs-trip-update-parser.js.map
|
|
@@ -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,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;QAE/B,IAAI,CAAC,kBAAkB,GAAG,IAAI,2BAA2B,CAAC;YACxD,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,oBAAoB,GAAG,IAAI,6BAA6B,CAAC;YAC5D,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,GAAG,IAAI,yBAAyB,CAAC;YACpD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAA0B,EAAE,YAA8B;QAC9D,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,oBAAoB,CAAC;QAEhD,IAAI,EAAE,KAAK,2CAA2C,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACjE,CAAC;aAAM,IAAI,EAAE,KAAK,2CAA2C,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACnE,CAAC;aAAM;QACL,kEAAkE;QAClE,EAAE,KAAK,uCAAuC;YAC9C,EAAE,KAAK,qCAAqC,EAC5C,CAAC;YACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,IAAI,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,93 @@
|
|
|
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 type { LineGtfsIdMapping } from "../../data/ids/line-gtfs-id-mapping.js";
|
|
6
|
+
import type { LineRoutesMapping } from "../../data/route/line-routes-mapping.js";
|
|
7
|
+
import type { BonusLinesMapping } from "../../data/route/bonus-lines-mapping.js";
|
|
8
|
+
import { GtfsReplacedTrip } from "../../data/trip/replaced/gtfs-replaced-trip.js";
|
|
9
|
+
import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
|
|
10
|
+
import type { GtfsUpdatedTripMovement } from "../../data/trip/updated/types.js";
|
|
11
|
+
import { type GtfsRouteMatchingError } from "../gtfs-route-matcher.js";
|
|
12
|
+
import { type GtfsScheduledTripIdentificationError } from "./gtfs-scheduled-trip-identifier.js";
|
|
13
|
+
import { NecessaryFieldNotInStopTimeUpdateEntryError, NoStopTimeUpdateFieldGivenError, StopTimeUpdateEntryReferencesUnmappedStopIdError, UnsupportedStopTimeUpdateEntryScheduleRelationshipError } from "./gtfs-trip-update-parser-common-error-types.js";
|
|
14
|
+
export type GtfsUpdatedTripUpdateParserFields = {
|
|
15
|
+
readonly timezone: string;
|
|
16
|
+
readonly stopGtfsIdMapping: StopGtfsIdMapping;
|
|
17
|
+
readonly lineGtfsIdMapping: LineGtfsIdMapping;
|
|
18
|
+
readonly lineRoutesMapping: LineRoutesMapping;
|
|
19
|
+
readonly bonusLinesMapping: BonusLinesMapping;
|
|
20
|
+
readonly onError: (error: GtfsUpdatedTripUpdateParsingError) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare class GtfsUpdatedTripUpdateParser {
|
|
23
|
+
private readonly _timezone;
|
|
24
|
+
private readonly _stopGtfsIdMapping;
|
|
25
|
+
private readonly _onError;
|
|
26
|
+
private readonly _tripIdentifier;
|
|
27
|
+
private readonly _movementsInterpolator;
|
|
28
|
+
private readonly _lineGtfsIdMapping;
|
|
29
|
+
private readonly _routeMatcher;
|
|
30
|
+
constructor(fields: GtfsUpdatedTripUpdateParserFields);
|
|
31
|
+
parse(tripUpdate: TripUpdateJson, scheduleData: GtfsScheduleData): GtfsUpdatedTrip | GtfsReplacedTrip | null;
|
|
32
|
+
private _buildReplacedTrip;
|
|
33
|
+
private _parseUpdatedTime;
|
|
34
|
+
}
|
|
35
|
+
export type GtfsUpdatedTripUpdateParsingError = GtfsScheduledTripIdentificationError | GtfsRouteMatchingError | NoStopTimeUpdateFieldGivenError | UnsupportedStopTimeUpdateEntryScheduleRelationshipError | NecessaryFieldNotInStopTimeUpdateEntryError | StopTimeUpdateEntryReferencesNonExistentStopSequenceError | MultipleStopTimeUpdateEntriesForSameMovementIndexError | StopTimeUpdateEntryReferencesUnmappedStopIdError | StopTimeUpdateEntryChangesStopError | NeitherTimeNorDelayGivenError | TimeAndDelayDisagreeWithEachOtherError | NeitherArrivalNorDepartureGivenError | KnownDepartureTimesEntailTimeTravelError | TooFewSurvivingServicingMovementsError;
|
|
36
|
+
export declare class StopTimeUpdateEntryReferencesNonExistentStopSequenceError {
|
|
37
|
+
readonly tripUpdate: TripUpdateJson;
|
|
38
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
39
|
+
readonly matchedTrip: GtfsScheduledTrip;
|
|
40
|
+
readonly type = "stop-time-update-entry-references-non-existent-stop-sequence";
|
|
41
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip);
|
|
42
|
+
}
|
|
43
|
+
export declare class MultipleStopTimeUpdateEntriesForSameMovementIndexError {
|
|
44
|
+
readonly tripUpdate: TripUpdateJson;
|
|
45
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
46
|
+
readonly matchedTrip: GtfsScheduledTrip;
|
|
47
|
+
readonly matchedMovementIndex: number;
|
|
48
|
+
readonly type = "multiple-stop-time-update-entries-for-same-movement-index";
|
|
49
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip, matchedMovementIndex: number);
|
|
50
|
+
}
|
|
51
|
+
export declare class StopTimeUpdateEntryChangesStopError {
|
|
52
|
+
readonly tripUpdate: TripUpdateJson;
|
|
53
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
54
|
+
readonly matchedTrip: GtfsScheduledTrip;
|
|
55
|
+
readonly matchedMovementIndex: number;
|
|
56
|
+
readonly type = "stop-time-update-entry-changes-stop";
|
|
57
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, matchedTrip: GtfsScheduledTrip, matchedMovementIndex: number);
|
|
58
|
+
}
|
|
59
|
+
export declare class NeitherTimeNorDelayGivenError {
|
|
60
|
+
readonly tripUpdate: TripUpdateJson;
|
|
61
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
62
|
+
readonly updatedTime: UpdatedTimeJson;
|
|
63
|
+
readonly type = "neither-time-nor-delay-given";
|
|
64
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, updatedTime: UpdatedTimeJson);
|
|
65
|
+
}
|
|
66
|
+
export declare class TimeAndDelayDisagreeWithEachOtherError {
|
|
67
|
+
readonly tripUpdate: TripUpdateJson;
|
|
68
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
69
|
+
readonly updatedTime: UpdatedTimeJson;
|
|
70
|
+
readonly parsedFromTime: Temporal.Instant;
|
|
71
|
+
readonly parsedFromDelay: Temporal.Instant;
|
|
72
|
+
readonly type = "time-and-delay-disagree-with-each-other";
|
|
73
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson, updatedTime: UpdatedTimeJson, parsedFromTime: Temporal.Instant, parsedFromDelay: Temporal.Instant);
|
|
74
|
+
}
|
|
75
|
+
export declare class NeitherArrivalNorDepartureGivenError {
|
|
76
|
+
readonly tripUpdate: TripUpdateJson;
|
|
77
|
+
readonly stopTimeUpdateEntry: StopTimeUpdateJson;
|
|
78
|
+
readonly type = "neither-arrival-nor-departure-given";
|
|
79
|
+
constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson);
|
|
80
|
+
}
|
|
81
|
+
declare class KnownDepartureTimesEntailTimeTravelError {
|
|
82
|
+
readonly tripUpdate: TripUpdateJson;
|
|
83
|
+
readonly movements: readonly GtfsUpdatedTripMovement[];
|
|
84
|
+
readonly type = "known-departure-times-entail-time-travel";
|
|
85
|
+
constructor(tripUpdate: TripUpdateJson, movements: readonly GtfsUpdatedTripMovement[]);
|
|
86
|
+
}
|
|
87
|
+
declare class TooFewSurvivingServicingMovementsError {
|
|
88
|
+
readonly tripUpdate: TripUpdateJson;
|
|
89
|
+
readonly survivingMovements: GtfsUpdatedTripMovement[];
|
|
90
|
+
readonly type = "too-few-surviving-servicing-movements";
|
|
91
|
+
constructor(tripUpdate: TripUpdateJson, survivingMovements: GtfsUpdatedTripMovement[]);
|
|
92
|
+
}
|
|
93
|
+
export {};
|