corequery-gtfs 0.10.4 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/conversion/service-converter.d.ts +7 -3
  2. package/dist/conversion/service-converter.js +60 -98
  3. package/dist/conversion/service-converter.js.map +1 -1
  4. package/dist/data/gtfs-feed.d.ts +3 -4
  5. package/dist/data/gtfs-feed.js.map +1 -1
  6. package/dist/data/gtfs-realtime-data.d.ts +6 -7
  7. package/dist/data/gtfs-realtime-data.js +7 -11
  8. package/dist/data/gtfs-realtime-data.js.map +1 -1
  9. package/dist/data/gtfs-schedule-data.d.ts +1 -1
  10. package/dist/data/trip/added/gtfs-added-trip-originating-movement.d.ts +24 -0
  11. package/dist/data/trip/added/gtfs-added-trip-originating-movement.js +40 -0
  12. package/dist/data/trip/added/gtfs-added-trip-originating-movement.js.map +1 -0
  13. package/dist/data/trip/added/gtfs-added-trip-passing-movement.d.ts +14 -0
  14. package/dist/data/trip/added/gtfs-added-trip-passing-movement.js +24 -0
  15. package/dist/data/trip/added/gtfs-added-trip-passing-movement.js.map +1 -0
  16. package/dist/data/trip/added/gtfs-added-trip-regular-movement.d.ts +30 -0
  17. package/dist/data/trip/added/gtfs-added-trip-regular-movement.js +51 -0
  18. package/dist/data/trip/added/gtfs-added-trip-regular-movement.js.map +1 -0
  19. package/dist/data/trip/added/gtfs-added-trip-terminating-movement.d.ts +24 -0
  20. package/dist/data/trip/added/gtfs-added-trip-terminating-movement.js +40 -0
  21. package/dist/data/trip/added/gtfs-added-trip-terminating-movement.js.map +1 -0
  22. package/dist/data/trip/added/gtfs-added-trip.d.ts +26 -0
  23. package/dist/data/trip/added/gtfs-added-trip.js +52 -0
  24. package/dist/data/trip/added/gtfs-added-trip.js.map +1 -0
  25. package/dist/data/trip/added/types.d.ts +20 -0
  26. package/dist/data/trip/added/types.js +2 -0
  27. package/dist/data/trip/added/types.js.map +1 -0
  28. package/dist/data/trip/replaced/gtfs-replaced-trip-originating-movement.d.ts +24 -0
  29. package/dist/data/trip/replaced/gtfs-replaced-trip-originating-movement.js +40 -0
  30. package/dist/data/trip/replaced/gtfs-replaced-trip-originating-movement.js.map +1 -0
  31. package/dist/data/trip/replaced/gtfs-replaced-trip-passing-movement.d.ts +14 -0
  32. package/dist/data/trip/replaced/gtfs-replaced-trip-passing-movement.js +24 -0
  33. package/dist/data/trip/replaced/gtfs-replaced-trip-passing-movement.js.map +1 -0
  34. package/dist/data/trip/replaced/gtfs-replaced-trip-regular-movement.d.ts +30 -0
  35. package/dist/data/trip/replaced/gtfs-replaced-trip-regular-movement.js +51 -0
  36. package/dist/data/trip/replaced/gtfs-replaced-trip-regular-movement.js.map +1 -0
  37. package/dist/data/trip/replaced/gtfs-replaced-trip-terminating-movement.d.ts +24 -0
  38. package/dist/data/trip/replaced/gtfs-replaced-trip-terminating-movement.js +40 -0
  39. package/dist/data/trip/replaced/gtfs-replaced-trip-terminating-movement.js.map +1 -0
  40. package/dist/data/trip/replaced/gtfs-replaced-trip.d.ts +28 -0
  41. package/dist/data/trip/replaced/gtfs-replaced-trip.js +70 -0
  42. package/dist/data/trip/replaced/gtfs-replaced-trip.js.map +1 -0
  43. package/dist/data/trip/replaced/types.d.ts +20 -0
  44. package/dist/data/trip/replaced/types.js +2 -0
  45. package/dist/data/trip/replaced/types.js.map +1 -0
  46. package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.d.ts +29 -0
  47. package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.js +74 -0
  48. package/dist/data/trip/scheduled/gtfs-scheduled-trip-originating-movement.js.map +1 -0
  49. package/dist/data/trip/scheduled/gtfs-scheduled-trip-passing-movement.d.ts +17 -0
  50. package/dist/data/trip/scheduled/gtfs-scheduled-trip-passing-movement.js +35 -0
  51. package/dist/data/trip/scheduled/gtfs-scheduled-trip-passing-movement.js.map +1 -0
  52. package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.d.ts +35 -0
  53. package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js +98 -0
  54. package/dist/data/trip/scheduled/gtfs-scheduled-trip-regular-movement.js.map +1 -0
  55. package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.d.ts +29 -0
  56. package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js +74 -0
  57. package/dist/data/trip/scheduled/gtfs-scheduled-trip-terminating-movement.js.map +1 -0
  58. package/dist/data/{gtfs-scheduled-trip.d.ts → trip/scheduled/gtfs-scheduled-trip.d.ts} +6 -4
  59. package/dist/data/{gtfs-scheduled-trip.js → trip/scheduled/gtfs-scheduled-trip.js} +3 -2
  60. package/dist/data/trip/scheduled/gtfs-scheduled-trip.js.map +1 -0
  61. package/dist/data/trip/scheduled/types.d.ts +33 -0
  62. package/dist/data/trip/scheduled/types.js +2 -0
  63. package/dist/data/trip/scheduled/types.js.map +1 -0
  64. package/dist/data/trip/types.d.ts +14 -0
  65. package/dist/data/trip/types.js +2 -0
  66. package/dist/data/trip/types.js.map +1 -0
  67. package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.d.ts +36 -0
  68. package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.js +82 -0
  69. package/dist/data/trip/updated/gtfs-updated-trip-originating-movement.js.map +1 -0
  70. package/dist/data/trip/updated/gtfs-updated-trip-passing-movement.d.ts +15 -0
  71. package/dist/data/trip/updated/gtfs-updated-trip-passing-movement.js +27 -0
  72. package/dist/data/trip/updated/gtfs-updated-trip-passing-movement.js.map +1 -0
  73. package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.d.ts +48 -0
  74. package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.js +129 -0
  75. package/dist/data/trip/updated/gtfs-updated-trip-regular-movement.js.map +1 -0
  76. package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.d.ts +36 -0
  77. package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.js +82 -0
  78. package/dist/data/trip/updated/gtfs-updated-trip-terminating-movement.js.map +1 -0
  79. package/dist/data/{gtfs-updated-trip.d.ts → trip/updated/gtfs-updated-trip.d.ts} +5 -3
  80. package/dist/data/{gtfs-updated-trip.js → trip/updated/gtfs-updated-trip.js} +0 -18
  81. package/dist/data/trip/updated/gtfs-updated-trip.js.map +1 -0
  82. package/dist/data/trip/updated/types.d.ts +24 -0
  83. package/dist/data/trip/updated/types.js +2 -0
  84. package/dist/data/trip/updated/types.js.map +1 -0
  85. package/dist/departures/gtfs-scheduled-movements-index.d.ts +2 -2
  86. package/dist/departures/iterator/departures-iterator.d.ts +3 -5
  87. package/dist/departures/iterator/departures-iterator.js.map +1 -1
  88. package/dist/departures/iterator/scheduled-departures-block-iterator.js +2 -2
  89. package/dist/departures/iterator/scheduled-departures-block-iterator.js.map +1 -1
  90. package/dist/departures/realtime-departures-block.d.ts +3 -4
  91. package/dist/departures/realtime-departures-block.js.map +1 -1
  92. package/dist/gtfs-service-source.js +12 -2
  93. package/dist/gtfs-service-source.js.map +1 -1
  94. package/dist/parser/gtfs-feed-parser.js +3 -0
  95. package/dist/parser/gtfs-feed-parser.js.map +1 -1
  96. package/dist/parser/gtfs-route-matcher.d.ts +31 -0
  97. package/dist/parser/gtfs-route-matcher.js +114 -0
  98. package/dist/parser/gtfs-route-matcher.js.map +1 -0
  99. package/dist/parser/realtime/gtfs-added-trip-update-parser.d.ts +49 -0
  100. package/dist/parser/realtime/gtfs-added-trip-update-parser.js +207 -0
  101. package/dist/parser/realtime/gtfs-added-trip-update-parser.js.map +1 -0
  102. package/dist/parser/realtime/gtfs-cancelled-trip-update-parser.d.ts +16 -0
  103. package/dist/parser/realtime/gtfs-cancelled-trip-update-parser.js +24 -0
  104. package/dist/parser/realtime/gtfs-cancelled-trip-update-parser.js.map +1 -0
  105. package/dist/parser/realtime/gtfs-realtime-data-parser.d.ts +6 -0
  106. package/dist/parser/realtime/gtfs-realtime-data-parser.js +16 -12
  107. package/dist/parser/realtime/gtfs-realtime-data-parser.js.map +1 -1
  108. package/dist/parser/realtime/{gtfs-trip-update-trip-identifier.d.ts → gtfs-scheduled-trip-identifier.d.ts} +6 -6
  109. package/dist/parser/realtime/{gtfs-trip-update-trip-identifier.js → gtfs-scheduled-trip-identifier.js} +2 -2
  110. package/dist/parser/realtime/gtfs-scheduled-trip-identifier.js.map +1 -0
  111. package/dist/parser/realtime/gtfs-trip-movements-interpolator.d.ts +7 -0
  112. package/dist/parser/realtime/gtfs-trip-movements-interpolator.js +183 -0
  113. package/dist/parser/realtime/gtfs-trip-movements-interpolator.js.map +1 -0
  114. package/dist/parser/realtime/gtfs-trip-update-parser-common-error-types.d.ts +25 -0
  115. package/dist/parser/realtime/gtfs-trip-update-parser-common-error-types.js +37 -0
  116. package/dist/parser/realtime/gtfs-trip-update-parser-common-error-types.js.map +1 -0
  117. package/dist/parser/realtime/gtfs-trip-update-parser.d.ts +15 -81
  118. package/dist/parser/realtime/gtfs-trip-update-parser.js +30 -272
  119. package/dist/parser/realtime/gtfs-trip-update-parser.js.map +1 -1
  120. package/dist/parser/realtime/gtfs-updated-trip-update-parser.d.ts +76 -0
  121. package/dist/parser/realtime/gtfs-updated-trip-update-parser.js +264 -0
  122. package/dist/parser/realtime/gtfs-updated-trip-update-parser.js.map +1 -0
  123. package/dist/parser/schedule/gtfs-transfer-parser.d.ts +1 -1
  124. package/dist/parser/schedule/gtfs-transfer-parser.js +1 -1
  125. package/dist/parser/schedule/gtfs-transfer-parser.js.map +1 -1
  126. package/dist/parser/schedule/gtfs-trip-parser.d.ts +24 -8
  127. package/dist/parser/schedule/gtfs-trip-parser.js +120 -51
  128. package/dist/parser/schedule/gtfs-trip-parser.js.map +1 -1
  129. package/package.json +1 -1
  130. package/dist/data/gtfs-scheduled-trip-movements.d.ts +0 -118
  131. package/dist/data/gtfs-scheduled-trip-movements.js +0 -233
  132. package/dist/data/gtfs-scheduled-trip-movements.js.map +0 -1
  133. package/dist/data/gtfs-scheduled-trip.js.map +0 -1
  134. package/dist/data/gtfs-updated-trip-movements.d.ts +0 -124
  135. package/dist/data/gtfs-updated-trip-movements.js +0 -150
  136. package/dist/data/gtfs-updated-trip-movements.js.map +0 -1
  137. package/dist/data/gtfs-updated-trip.js.map +0 -1
  138. package/dist/data/utils.d.ts +0 -3
  139. package/dist/data/utils.js +0 -2
  140. package/dist/data/utils.js.map +0 -1
  141. package/dist/parser/realtime/gtfs-trip-update-trip-identifier.js.map +0 -1
  142. package/dist/parser/schedule/gtfs-route-matcher.d.ts +0 -53
  143. package/dist/parser/schedule/gtfs-route-matcher.js +0 -197
  144. package/dist/parser/schedule/gtfs-route-matcher.js.map +0 -1
@@ -0,0 +1,114 @@
1
+ export class GtfsRouteMatcher {
2
+ _onError;
3
+ _lineRoutesMapping;
4
+ _bonusLinesMapping;
5
+ constructor(fields) {
6
+ this._lineRoutesMapping = fields.lineRoutesMapping;
7
+ this._bonusLinesMapping = fields.bonusLinesMapping;
8
+ this._onError = fields.onError;
9
+ }
10
+ match(lineId, servicingMovements, buildPassingMovement) {
11
+ const stopIds = servicingMovements.map((m) => m.stopId);
12
+ const primaryRoute = this._getBestMatchForLine(lineId, stopIds);
13
+ if (primaryRoute == null) {
14
+ this._onError(new NoMatchingRouteError(stopIds));
15
+ return null;
16
+ }
17
+ const fullMovements = this._addPassingMovementsFromRoute(servicingMovements, primaryRoute, buildPassingMovement);
18
+ const fullMovementsStopIds = fullMovements.map((m) => m.stopId);
19
+ const { lineIds, serviceTags } = this._applyBonusLines(lineId, primaryRoute.serviceTags, fullMovementsStopIds);
20
+ return {
21
+ movements: fullMovements,
22
+ lineIds,
23
+ color: primaryRoute.color,
24
+ serviceTags,
25
+ };
26
+ }
27
+ _getBestMatchForLine(lineId, stopIds) {
28
+ const routesForLine = this._lineRoutesMapping.forLine(lineId);
29
+ return routesForLine
30
+ .filter((r) => r.matchesStoppingOrder(stopIds))
31
+ .reduce((prev, me) => (prev == null || me.isShorterThan(prev) ? me : prev), null);
32
+ }
33
+ _applyBonusLines(primaryLineId, primaryServiceTags, stopIds) {
34
+ const bonusLines = this._bonusLinesMapping.forLine(primaryLineId);
35
+ if (bonusLines == null) {
36
+ return { lineIds: [primaryLineId], serviceTags: primaryServiceTags };
37
+ }
38
+ // Go through all bonus lines, and collect the line IDs and service tags
39
+ // for any routes that match.
40
+ const lineIds = new Set();
41
+ const serviceTags = new Set();
42
+ for (const bonusLine of bonusLines.lines) {
43
+ const route = this._getBestMatchForLine(bonusLine, stopIds);
44
+ if (route != null) {
45
+ lineIds.add(bonusLine);
46
+ for (const serviceTag of route.serviceTags) {
47
+ serviceTags.add(serviceTag);
48
+ }
49
+ }
50
+ }
51
+ // If in "replace" mode, we throw away the main route's line ID and tags if
52
+ // anything else matches. Otherwise they're added on.
53
+ const shouldReplace = lineIds.size > 0 && bonusLines.mode === "replace";
54
+ if (!shouldReplace) {
55
+ lineIds.add(primaryLineId);
56
+ for (const serviceTag of primaryServiceTags) {
57
+ serviceTags.add(serviceTag);
58
+ }
59
+ }
60
+ return {
61
+ lineIds: Array.from(lineIds),
62
+ serviceTags: Array.from(serviceTags),
63
+ };
64
+ }
65
+ _addPassingMovementsFromRoute(servicingMovements, matchingRoute, buildPassingMovement) {
66
+ const result = [];
67
+ let nextServicingMovementIndex = 0;
68
+ // Broadly: Iterate through the route's stops, and step through the trip
69
+ // movements simultaneously when they match. Add all route stops between
70
+ // first and last trip movements as servicing movements where found or
71
+ // passing movements otherwise.
72
+ for (const routeStop of matchingRoute.stops) {
73
+ const nextServicingMovement = servicingMovements[nextServicingMovementIndex];
74
+ // If there's no next servicing movement, then the index must be off the
75
+ // end of the array, so we're done (the service has terminated).
76
+ if (nextServicingMovement == null)
77
+ break;
78
+ if (routeStop.stopId === nextServicingMovement.stopId) {
79
+ // When the next movement from the trip matches the one in the route
80
+ // we're up to, add the servicing movement.
81
+ result.push(nextServicingMovement);
82
+ nextServicingMovementIndex++;
83
+ }
84
+ else if (nextServicingMovementIndex > 0 &&
85
+ !routeStop.collapseInStoppingPatterns) {
86
+ // Otherwise the stop from the route is an `type: "passing"` movement.
87
+ // `nextServicingMovementIndex > 0` stops us adding passing movements
88
+ // from the route before the service originates.
89
+ //
90
+ // For now, I'm skipping adding `collapseInStoppingPatterns` stops as
91
+ // passing movements. This flag means we don't want this stop to show up
92
+ // in stopping patterns normally, unless it's servicing (e.g. East
93
+ // Pakenham on the Gippsland line is one of these). I'm assuming there's
94
+ // nothing downstream that'll need to consider these collapsed stops.
95
+ //
96
+ // (If I need to reconsider this decision for some reason, maybe instead
97
+ // of adding those stops back in to this array with some sort of flag, I
98
+ // could consider adding the matched route itself as metadata to the
99
+ // trip? Probably having the index of the route stop in this array will
100
+ // be useful to reconcile the two.)
101
+ result.push(buildPassingMovement(routeStop.stopId));
102
+ }
103
+ }
104
+ return result;
105
+ }
106
+ }
107
+ export class NoMatchingRouteError {
108
+ stopIds;
109
+ type = "no-matching-route";
110
+ constructor(stopIds) {
111
+ this.stopIds = stopIds;
112
+ }
113
+ }
114
+ //# sourceMappingURL=gtfs-route-matcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtfs-route-matcher.js","sourceRoot":"","sources":["../../src/parser/gtfs-route-matcher.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,gBAAgB;IACV,QAAQ,CAA0C;IAElD,kBAAkB,CAAoB;IACtC,kBAAkB,CAAoB;IAEvD,YAAY,MAA8B;QACxC,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,KAAK,CACH,MAAc,EACd,kBAAgC,EAChC,oBAA2C;QAE3C,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACxD,MAAM,YAAY,GAAG,I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AC;QAEvB,IAAI,0BAA0B,GAAG,CAAC,CAAC;QAEnC,wEAAwE;QACxE,wEAAwE;QACxE,sEAAsE;QACtE,+BAA+B;QAC/B,KAAK,MAAM,SAAS,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;YAC5C,MAAM,qBAAqB,GACzB,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;YAEjD,wEAAwE;YACxE,gEAAgE;YAChE,IAAI,qBAAqB,IAAI,IAAI;gBAAE,MAAM;YAEzC,IAAI,SAAS,CAAC,MAAM,KAAK,qBAAqB,CAAC,MAAM,EAAE,CAAC;gBACtD,oEAAoE;gBACpE,2CAA2C;gBAC3C,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;gBACnC,0BAA0B,EAAE,CAAC;YAC/B,CAAC;iBAAM,IACL,0BAA0B,GAAG,CAAC;gBAC9B,CAAC,SAAS,CAAC,0BAA0B,EACrC,CAAC;gBACD,sEAAsE;gBACtE,qEAAqE;gBACrE,gDAAgD;gBAChD,EAAE;gBACF,qEAAqE;gBACrE,wEAAwE;gBACxE,kEAAkE;gBAClE,wEAAwE;gBACxE,qEAAqE;gBACrE,EAAE;gBACF,wEAAwE;gBACxE,wEAAwE;gBACxE,oEAAoE;gBACpE,uEAAuE;gBACvE,mCAAmC;gBACnC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAID,MAAM,OAAO,oBAAoB;IAEV;IADZ,IAAI,GAAG,mBAAmB,CAAC;IACpC,YAAqB,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;CACpD"}
@@ -0,0 +1,49 @@
1
+ import type { StopGtfsIdMapping } from "../../data/ids/stop-gtfs-id-mapping.js";
2
+ import type { StopTimeUpdateJson, TripUpdateJson } from "../../data/raw/realtime-data-json.js";
3
+ import type { GtfsScheduleData } from "../../data/gtfs-schedule-data.js";
4
+ import { GtfsAddedTrip } from "../../data/trip/added/gtfs-added-trip.js";
5
+ import { NecessaryFieldNotInStopTimeUpdateEntryError, NoStopTimeUpdateFieldGivenError, StopTimeUpdateEntryReferencesUnmappedStopIdError, UnsupportedStopTimeUpdateEntryScheduleRelationshipError } from "./gtfs-trip-update-parser-common-error-types.js";
6
+ import { type GtfsRouteMatchingError } from "../gtfs-route-matcher.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";
10
+ export type GtfsAddedTripUpdateParserFields = {
11
+ readonly stopGtfsIdMapping: StopGtfsIdMapping;
12
+ readonly lineGtfsIdMapping: LineGtfsIdMapping;
13
+ readonly lineRoutesMapping: LineRoutesMapping;
14
+ readonly bonusLinesMapping: BonusLinesMapping;
15
+ readonly onError: (error: GtfsAddedTripUpdateParsingError) => void;
16
+ };
17
+ export declare class GtfsAddedTripUpdateParser {
18
+ private readonly _onError;
19
+ private readonly _stopGtfsIdMapping;
20
+ private readonly _lineGtfsIdMapping;
21
+ private readonly _routeMatcher;
22
+ constructor(fields: GtfsAddedTripUpdateParserFields);
23
+ parse(tripUpdate: TripUpdateJson, scheduleData: GtfsScheduleData): GtfsAddedTrip | null;
24
+ }
25
+ export type GtfsAddedTripUpdateParsingError = NecessaryFieldNotSuppliedForAddedTripError | AddedTripIdDuplicatesScheduledTripIdError | NoStopTimeUpdateFieldGivenError | UnsupportedStopTimeUpdateEntryScheduleRelationshipError | NecessaryFieldNotInStopTimeUpdateEntryError | StopTimeUpdateEntryReferencesUnmappedStopIdError | AddedTripStopTimeUpdateMissingTimeError | AddedTripReferencesUnmappedRouteIdError | GtfsRouteMatchingError;
26
+ export declare class NecessaryFieldNotSuppliedForAddedTripError {
27
+ readonly tripUpdate: TripUpdateJson;
28
+ readonly field: "tripId" | "routeId" | "startDate";
29
+ readonly type = "necessary-field-not-supplied-for-added-trip";
30
+ constructor(tripUpdate: TripUpdateJson, field: "tripId" | "routeId" | "startDate");
31
+ }
32
+ export declare class AddedTripIdDuplicatesScheduledTripIdError {
33
+ readonly tripUpdate: TripUpdateJson;
34
+ readonly tripId: string;
35
+ readonly type = "added-trip-id-duplicates-scheduled-trip-id";
36
+ constructor(tripUpdate: TripUpdateJson, tripId: string);
37
+ }
38
+ export declare class AddedTripStopTimeUpdateMissingTimeError {
39
+ readonly tripUpdate: TripUpdateJson;
40
+ readonly stopTimeUpdateEntry: StopTimeUpdateJson;
41
+ readonly type = "added-trip-stop-time-update-missing-time";
42
+ constructor(tripUpdate: TripUpdateJson, stopTimeUpdateEntry: StopTimeUpdateJson);
43
+ }
44
+ export declare class AddedTripReferencesUnmappedRouteIdError {
45
+ readonly tripUpdate: TripUpdateJson;
46
+ readonly gtfsRouteId: string;
47
+ readonly type = "trip-references-unmapped-route-id";
48
+ constructor(tripUpdate: TripUpdateJson, gtfsRouteId: string);
49
+ }
@@ -0,0 +1,207 @@
1
+ import { itsOk } from "@dan-schel/js-utils";
2
+ import { GtfsAddedTripOriginatingMovement } from "../../data/trip/added/gtfs-added-trip-originating-movement.js";
3
+ import { GtfsAddedTripRegularMovement } from "../../data/trip/added/gtfs-added-trip-regular-movement.js";
4
+ import { GtfsAddedTripTerminatingMovement } from "../../data/trip/added/gtfs-added-trip-terminating-movement.js";
5
+ import { GtfsAddedTrip } from "../../data/trip/added/gtfs-added-trip.js";
6
+ import { NecessaryFieldNotInStopTimeUpdateEntryError, NoStopTimeUpdateFieldGivenError, StopTimeUpdateEntryReferencesUnmappedStopIdError, UnsupportedStopTimeUpdateEntryScheduleRelationshipError, } from "./gtfs-trip-update-parser-common-error-types.js";
7
+ import { GtfsRouteMatcher, } from "../gtfs-route-matcher.js";
8
+ import { GtfsAddedTripPassingMovement } from "../../data/trip/added/gtfs-added-trip-passing-movement.js";
9
+ const STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED = "SCHEDULED";
10
+ export class GtfsAddedTripUpdateParser {
11
+ _onError;
12
+ _stopGtfsIdMapping;
13
+ _lineGtfsIdMapping;
14
+ _routeMatcher;
15
+ constructor(fields) {
16
+ this._onError = fields.onError;
17
+ this._stopGtfsIdMapping = fields.stopGtfsIdMapping;
18
+ this._lineGtfsIdMapping = fields.lineGtfsIdMapping;
19
+ this._routeMatcher = new GtfsRouteMatcher({
20
+ onError: fields.onError,
21
+ lineRoutesMapping: fields.lineRoutesMapping,
22
+ bonusLinesMapping: fields.bonusLinesMapping,
23
+ });
24
+ }
25
+ parse(tripUpdate, scheduleData) {
26
+ // TODO: Test this.
27
+ const gtfsTripId = tripUpdate.trip.tripId;
28
+ if (gtfsTripId == null) {
29
+ const Err = NecessaryFieldNotSuppliedForAddedTripError;
30
+ this._onError(new Err(tripUpdate, "tripId"));
31
+ return null;
32
+ }
33
+ const gtfsRouteId = tripUpdate.trip.routeId;
34
+ if (gtfsRouteId == null) {
35
+ const Err = NecessaryFieldNotSuppliedForAddedTripError;
36
+ this._onError(new Err(tripUpdate, "routeId"));
37
+ return null;
38
+ }
39
+ const lineGtfsIdMetadata = this._lineGtfsIdMapping.tryResolve(gtfsRouteId);
40
+ if (lineGtfsIdMetadata == null) {
41
+ const Err = AddedTripReferencesUnmappedRouteIdError;
42
+ this._onError(new Err(tripUpdate, gtfsRouteId));
43
+ return null;
44
+ }
45
+ const serviceDay = tripUpdate.trip.startDate;
46
+ if (serviceDay == null) {
47
+ const Err = NecessaryFieldNotSuppliedForAddedTripError;
48
+ this._onError(new Err(tripUpdate, "startDate"));
49
+ return null;
50
+ }
51
+ if (scheduleData.getTrip(gtfsTripId) != null) {
52
+ const Err = AddedTripIdDuplicatesScheduledTripIdError;
53
+ this._onError(new Err(tripUpdate, gtfsTripId));
54
+ return null;
55
+ }
56
+ if (tripUpdate.stopTimeUpdate == null) {
57
+ this._onError(new NoStopTimeUpdateFieldGivenError(tripUpdate));
58
+ return null;
59
+ }
60
+ // TODO: Report non-sequential stop sequences, like we do for scheduled
61
+ // trips?
62
+ const sortedEntries = [...tripUpdate.stopTimeUpdate].sort((a, b) => (a.stopSequence ?? 0) - (b.stopSequence ?? 0));
63
+ const servicingMovements = [];
64
+ for (let i = 0; i < sortedEntries.length; i++) {
65
+ const entry = itsOk(sortedEntries[i]);
66
+ // "ADDED" trips seem to always have "SCHEDULED" stop time updates, even
67
+ // though that kinda makes no sense. I guess it's as opposed to "SKIPPED".
68
+ const sr = entry.scheduleRelationship;
69
+ if (sr !== STOP_TIME_UPDATE_ENTRY_SCHEDULE_RELATIONSHIP_SCHEDULED) {
70
+ const Err = UnsupportedStopTimeUpdateEntryScheduleRelationshipError;
71
+ this._onError(new Err(tripUpdate, entry));
72
+ return null;
73
+ }
74
+ if (entry.stopSequence == null) {
75
+ const Err = NecessaryFieldNotInStopTimeUpdateEntryError;
76
+ this._onError(new Err(tripUpdate, entry, "stopSequence"));
77
+ return null;
78
+ }
79
+ if (entry.stopId == null) {
80
+ const Err = NecessaryFieldNotInStopTimeUpdateEntryError;
81
+ this._onError(new Err(tripUpdate, entry, "stopId"));
82
+ return null;
83
+ }
84
+ const gtfsIdMetadata = this._stopGtfsIdMapping.tryResolve(entry.stopId);
85
+ if (gtfsIdMetadata == null) {
86
+ const Err = StopTimeUpdateEntryReferencesUnmappedStopIdError;
87
+ this._onError(new Err(tripUpdate, entry));
88
+ return null;
89
+ }
90
+ const stopId = gtfsIdMetadata.stopId;
91
+ const positionId = gtfsIdMetadata.type === "positional" ? gtfsIdMetadata.positionId : null;
92
+ // TODO: PTV still seems to provide delay values for "ADDED" trips, from
93
+ // which we could infer scheduled times for these added trips. The added
94
+ // trip movement classes don't currently support scheduled vs realtime
95
+ // times because I assumed GTFS-RT wouldn't supply scheduled times for
96
+ // added trips, but it looks like that's wrong!
97
+ if (i === 0) {
98
+ const departureTimestamp = entry.departure?.time;
99
+ if (departureTimestamp == null) {
100
+ const Err = AddedTripStopTimeUpdateMissingTimeError;
101
+ this._onError(new Err(tripUpdate, entry));
102
+ return null;
103
+ }
104
+ const departureTime = Temporal.Instant.fromEpochMilliseconds(departureTimestamp * 1000);
105
+ servicingMovements.push(new GtfsAddedTripOriginatingMovement({
106
+ stopId,
107
+ positionId,
108
+ departureTime,
109
+ gtfsIdMetadata,
110
+ gtfsStopSequence: entry.stopSequence,
111
+ }));
112
+ }
113
+ else if (i === sortedEntries.length - 1) {
114
+ const arrivalTimestamp = entry.arrival?.time;
115
+ if (arrivalTimestamp == null) {
116
+ const Err = AddedTripStopTimeUpdateMissingTimeError;
117
+ this._onError(new Err(tripUpdate, entry));
118
+ return null;
119
+ }
120
+ const arrivalTime = Temporal.Instant.fromEpochMilliseconds(arrivalTimestamp * 1000);
121
+ servicingMovements.push(new GtfsAddedTripTerminatingMovement({
122
+ stopId,
123
+ positionId,
124
+ arrivalTime,
125
+ gtfsIdMetadata,
126
+ gtfsStopSequence: entry.stopSequence,
127
+ }));
128
+ }
129
+ else {
130
+ const departureTimestamp = entry.departure?.time;
131
+ const arrivalTimestamp = (entry.arrival ?? entry.departure)?.time;
132
+ if (arrivalTimestamp == null || departureTimestamp == null) {
133
+ const Err = AddedTripStopTimeUpdateMissingTimeError;
134
+ this._onError(new Err(tripUpdate, entry));
135
+ return null;
136
+ }
137
+ const arrivalTime = Temporal.Instant.fromEpochMilliseconds(arrivalTimestamp * 1000);
138
+ const departureTime = Temporal.Instant.fromEpochMilliseconds(departureTimestamp * 1000);
139
+ servicingMovements.push(new GtfsAddedTripRegularMovement({
140
+ stopId,
141
+ positionId,
142
+ arrivalTime,
143
+ departureTime,
144
+ gtfsIdMetadata,
145
+ gtfsStopSequence: entry.stopSequence,
146
+ // TODO: These can be set via `stop_time_properties` (experimental
147
+ // field), but I'm not sure if V/Line actually does. If not, we
148
+ // might need to handle it manually. This could involve adding
149
+ // metadata to stops on each route, to say whether they're set down
150
+ // only/pick up only by default (similar to how TrainQuery v3 did
151
+ // it).
152
+ picksUp: true,
153
+ dropsOff: true,
154
+ }));
155
+ }
156
+ }
157
+ const routeMatch = this._routeMatcher.match(lineGtfsIdMetadata.lineId, servicingMovements, (stopId) => new GtfsAddedTripPassingMovement({ stopId }));
158
+ // Route matcher reports its own errors.
159
+ if (routeMatch == null)
160
+ return null;
161
+ return new GtfsAddedTrip({
162
+ gtfsTripId,
163
+ serviceDay,
164
+ movements: routeMatch.movements,
165
+ lineIds: routeMatch.lineIds,
166
+ serviceTags: routeMatch.serviceTags,
167
+ color: routeMatch.color,
168
+ });
169
+ }
170
+ }
171
+ export class NecessaryFieldNotSuppliedForAddedTripError {
172
+ tripUpdate;
173
+ field;
174
+ type = "necessary-field-not-supplied-for-added-trip";
175
+ constructor(tripUpdate, field) {
176
+ this.tripUpdate = tripUpdate;
177
+ this.field = field;
178
+ }
179
+ }
180
+ export class AddedTripIdDuplicatesScheduledTripIdError {
181
+ tripUpdate;
182
+ tripId;
183
+ type = "added-trip-id-duplicates-scheduled-trip-id";
184
+ constructor(tripUpdate, tripId) {
185
+ this.tripUpdate = tripUpdate;
186
+ this.tripId = tripId;
187
+ }
188
+ }
189
+ export class AddedTripStopTimeUpdateMissingTimeError {
190
+ tripUpdate;
191
+ stopTimeUpdateEntry;
192
+ type = "added-trip-stop-time-update-missing-time";
193
+ constructor(tripUpdate, stopTimeUpdateEntry) {
194
+ this.tripUpdate = tripUpdate;
195
+ this.stopTimeUpdateEntry = stopTimeUpdateEntry;
196
+ }
197
+ }
198
+ export class AddedTripReferencesUnmappedRouteIdError {
199
+ tripUpdate;
200
+ gtfsRouteId;
201
+ type = "trip-references-unmapped-route-id";
202
+ constructor(tripUpdate, gtfsRouteId) {
203
+ this.tripUpdate = tripUpdate;
204
+ this.gtfsRouteId = gtfsRouteId;
205
+ }
206
+ }
207
+ //# sourceMappingURL=gtfs-added-trip-update-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtfs-added-trip-update-parser.js","sourceRoot":"","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C;IAGvC;IACA;IAHF,IAAI,GAAG,0CAA0C,CAAC;IAC3D,YACW,UAA0B,EAC1B,mBAAuC;QADvC,eAAU,GAAV,UAAU,CAAgB;QAC1B,wBAAmB,GAAnB,mBAAmB,CAAoB;IAC/C,CAAC;CACL;AAED,MAAM,OAAO,uCAAuC;IAGvC;IACA;IAHF,IAAI,GAAG,mCAAmC,CAAC;IACpD,YACW,UAA0B,EAC1B,WAAmB;QADnB,eAAU,GAAV,UAAU,CAAgB;QAC1B,gBAAW,GAAX,WAAW,CAAQ;IAC3B,CAAC;CACL"}
@@ -0,0 +1,16 @@
1
+ import type { GtfsScheduleData } from "../../data/gtfs-schedule-data.js";
2
+ import type { TripUpdateJson } from "../../data/raw/realtime-data-json.js";
3
+ import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
4
+ import { type GtfsScheduledTripIdentificationError } from "./gtfs-scheduled-trip-identifier.js";
5
+ export type GtfsCancelledTripUpdateParserFields = {
6
+ readonly timezone: string;
7
+ readonly onError: (error: GtfsCancelledTripUpdateParsingError) => void;
8
+ };
9
+ export declare class GtfsCancelledTripUpdateParser {
10
+ private readonly _timezone;
11
+ private readonly _onError;
12
+ private readonly _tripIdentifier;
13
+ constructor(fields: GtfsCancelledTripUpdateParserFields);
14
+ parse(tripUpdate: TripUpdateJson, scheduleData: GtfsScheduleData): GtfsUpdatedTrip | null;
15
+ }
16
+ export type GtfsCancelledTripUpdateParsingError = GtfsScheduledTripIdentificationError;
@@ -0,0 +1,24 @@
1
+ import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
2
+ import { GtfsScheduledTripIdentifier, } from "./gtfs-scheduled-trip-identifier.js";
3
+ export class GtfsCancelledTripUpdateParser {
4
+ _timezone;
5
+ _onError;
6
+ _tripIdentifier;
7
+ constructor(fields) {
8
+ this._timezone = fields.timezone;
9
+ this._onError = fields.onError;
10
+ this._tripIdentifier = new GtfsScheduledTripIdentifier({
11
+ onError: this._onError,
12
+ });
13
+ }
14
+ parse(tripUpdate, scheduleData) {
15
+ const result = this._tripIdentifier.identify(tripUpdate.trip, scheduleData);
16
+ if (result == null)
17
+ return null;
18
+ const { trip, serviceDay } = result;
19
+ return GtfsUpdatedTrip.unmodified(trip, serviceDay, this._timezone).with({
20
+ isCancelled: true,
21
+ });
22
+ }
23
+ }
24
+ //# sourceMappingURL=gtfs-cancelled-trip-update-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtfs-cancelled-trip-update-parser.js","sourceRoot":"","sources":["../../../src/parser/realtime/gtfs-cancelled-trip-update-parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EACL,2BAA2B,GAE5B,MAAM,qCAAqC,CAAC;AAO7C,MAAM,OAAO,6BAA6B;IACvB,SAAS,CAAS;IAClB,QAAQ,CAEf;IAEO,eAAe,CAA8B;IAE9D,YAAY,MAA2C;QACrD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;QAE/B,IAAI,CAAC,eAAe,GAAG,IAAI,2BAA2B,CAAC;YACrD,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CACH,UAA0B,EAC1B,YAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5E,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAEpC,OAAO,eAAe,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;YACvE,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -3,9 +3,15 @@ import type { GtfsScheduleData } from "../../data/gtfs-schedule-data.js";
3
3
  import type { StopGtfsIdMapping } from "../../data/ids/stop-gtfs-id-mapping.js";
4
4
  import type { RealtimeDataJson } from "../../data/raw/realtime-data-json.js";
5
5
  import { type GtfsTripUpdateParsingError } from "./gtfs-trip-update-parser.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 type { LineGtfsIdMapping } from "../../data/ids/line-gtfs-id-mapping.js";
6
9
  export type GtfsRealtimeDataParserFields = {
7
10
  readonly timezone: string;
8
11
  readonly stopGtfsIdMapping: StopGtfsIdMapping;
12
+ readonly lineGtfsIdMapping: LineGtfsIdMapping;
13
+ readonly lineRoutesMapping: LineRoutesMapping;
14
+ readonly bonusLinesMapping: BonusLinesMapping;
9
15
  readonly onError: (error: GtfsRealtimeDataParsingError) => void;
10
16
  };
11
17
  export declare class GtfsRealtimeDataParser {
@@ -1,6 +1,7 @@
1
1
  import { GtfsRealtimeData } from "../../data/gtfs-realtime-data.js";
2
2
  import { GtfsBrokenTransfer } from "../../data/gtfs-realtime-transfer.js";
3
3
  import { MutableGtfsTransferMapping } from "../../data/gtfs-transfer-mapping.js";
4
+ import { GtfsUpdatedTrip } from "../../data/trip/updated/gtfs-updated-trip.js";
4
5
  import { GtfsTripUpdateParser, } from "./gtfs-trip-update-parser.js";
5
6
  export class GtfsRealtimeDataParser {
6
7
  _tripUpdateParser;
@@ -8,32 +9,35 @@ export class GtfsRealtimeDataParser {
8
9
  this._tripUpdateParser = new GtfsTripUpdateParser({
9
10
  timezone: fields.timezone,
10
11
  stopGtfsIdMapping: fields.stopGtfsIdMapping,
12
+ lineGtfsIdMapping: fields.lineGtfsIdMapping,
13
+ lineRoutesMapping: fields.lineRoutesMapping,
14
+ bonusLinesMapping: fields.bonusLinesMapping,
11
15
  onError: fields.onError,
12
16
  });
13
17
  }
14
18
  parse(realtimeData, scheduleData) {
15
- const updatedTrips = this._parseTripUpdates(realtimeData, scheduleData);
16
- const brokenTransfers = this._breakTransfers(updatedTrips, scheduleData);
17
- return new GtfsRealtimeData(updatedTrips, brokenTransfers, []);
19
+ const realtimeTrips = this._parseTripUpdates(realtimeData, scheduleData);
20
+ const brokenTransfers = this._breakTransfers(realtimeTrips, scheduleData);
21
+ return new GtfsRealtimeData(realtimeTrips, brokenTransfers, []);
18
22
  }
19
23
  _parseTripUpdates(realtimeData, scheduleData) {
20
- const updatedTrips = [];
24
+ const realtimeTrips = [];
21
25
  for (const tripUpdates of realtimeData.tripUpdates) {
22
26
  const result = this._tripUpdateParser.parse(tripUpdates, scheduleData);
23
27
  if (result != null) {
24
- updatedTrips.push(result);
28
+ realtimeTrips.push(result);
25
29
  }
26
30
  }
27
- return updatedTrips;
31
+ return realtimeTrips;
28
32
  }
29
- _breakTransfers(updatedTrips, scheduleData) {
33
+ _breakTransfers(realtimeTrips, scheduleData) {
30
34
  const brokenTransfers = new MutableGtfsTransferMapping((x) => x.transfer.getInvolvedTripIds());
31
- for (const updatedTrip of updatedTrips) {
32
- if (updatedTrip.isCancelled) {
33
- const transfers = scheduleData.getTransfersForTrip(updatedTrip.gtfsTripId);
35
+ for (const trip of realtimeTrips) {
36
+ if (trip instanceof GtfsUpdatedTrip && trip.isCancelled) {
37
+ const transfers = scheduleData.getTransfersForTrip(trip.gtfsTripId);
34
38
  for (const transfer of transfers) {
35
- const brokenTransfer = new GtfsBrokenTransfer(transfer, updatedTrip.serviceDay);
36
- const existing = brokenTransfers.forTripId(updatedTrip.gtfsTripId);
39
+ const brokenTransfer = new GtfsBrokenTransfer(transfer, trip.serviceDay);
40
+ const existing = brokenTransfers.forTripId(trip.gtfsTripId);
37
41
  if (!existing.some((x) => x.equals(brokenTransfer))) {
38
42
  brokenTransfers.push(brokenTransfer);
39
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gtfs-realtime-data-parser.js","sourceRoot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CAAC;YACjC,IAAI,IAAI,YAAY,eAAe,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACxD,MAAM,SAAS,GAAG,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAEpE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;oBACjC,MAAM,cAAc,GAAG,IAAI,kBAAkB,CAC3C,QAAQ,EACR,IAAI,CAAC,UAAU,CAChB,CAAC;oBACF,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBAC5D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;wBACpD,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;CACF"}
@@ -1,18 +1,18 @@
1
1
  import type { GtfsScheduleData } from "../../data/gtfs-schedule-data.js";
2
- import type { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
2
+ import type { GtfsScheduledTrip } from "../../data/trip/scheduled/gtfs-scheduled-trip.js";
3
3
  import type { TripDescriptorJson } from "../../data/raw/realtime-data-json.js";
4
- export type GtfsTripUpdateTripIdentifierFields = {
5
- readonly onError: (error: GtfsTripUpdateTripIdentificationError) => void;
4
+ export type GtfsScheduledTripIdentifierFields = {
5
+ readonly onError: (error: GtfsScheduledTripIdentificationError) => void;
6
6
  };
7
- export declare class GtfsTripUpdateTripIdentifier {
7
+ export declare class GtfsScheduledTripIdentifier {
8
8
  private readonly _onError;
9
- constructor(fields: GtfsTripUpdateTripIdentifierFields);
9
+ constructor(fields: GtfsScheduledTripIdentifierFields);
10
10
  identify(tripDescriptor: TripDescriptorJson, scheduleData: GtfsScheduleData): {
11
11
  trip: GtfsScheduledTrip;
12
12
  serviceDay: Temporal.PlainDate;
13
13
  } | null;
14
14
  }
15
- export type GtfsTripUpdateTripIdentificationError = NecessaryFieldNotInTripDescriptorError | TripDescriptorReferencesNonExistentTripIdError | TripDoesNotOccurOnStartDateError | TripDescriptorStartTimeDoesNotMatchTripOriginStopTimeError;
15
+ export type GtfsScheduledTripIdentificationError = NecessaryFieldNotInTripDescriptorError | TripDescriptorReferencesNonExistentTripIdError | TripDoesNotOccurOnStartDateError | TripDescriptorStartTimeDoesNotMatchTripOriginStopTimeError;
16
16
  export declare class NecessaryFieldNotInTripDescriptorError {
17
17
  readonly tripDescriptor: TripDescriptorJson;
18
18
  readonly field: "tripId" | "startDate";
@@ -1,4 +1,4 @@
1
- export class GtfsTripUpdateTripIdentifier {
1
+ export class GtfsScheduledTripIdentifier {
2
2
  _onError;
3
3
  constructor(fields) {
4
4
  this._onError = fields.onError;
@@ -90,4 +90,4 @@ export class TripDescriptorStartTimeDoesNotMatchTripOriginStopTimeError {
90
90
  this.trip = trip;
91
91
  }
92
92
  }
93
- //# sourceMappingURL=gtfs-trip-update-trip-identifier.js.map
93
+ //# sourceMappingURL=gtfs-scheduled-trip-identifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtfs-scheduled-trip-identifier.js","sourceRoot":"","sources":["../../../src/parser/realtime/gtfs-scheduled-trip-identifier.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,2BAA2B;IACrB,QAAQ,CAEf;IAEV,YAAY,MAAyC;QACnD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,QAAQ,CAAC,cAAkC,EAAE,YAA8B;QACzE,2EAA2E;QAC3E,wEAAwE;QACxE,yEAAyE;QACzE,sBAAsB;QACtB,IAAI,cAAc,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;YAClC,MAAM,GAAG,GAAG,sCAAsC,CAAC;YACnD,IAAI,CAAC,QAAQ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,CAAC;YACD,MAAM,GAAG,GAAG,0DAA0D,CAAC;YACvE,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,SAAS,EAAE,CAAC;IACxD,CAAC;CACF;AAQD,6EAA6E;AAC7E,gFAAgF;AAChF,uCAAuC;AACvC,MAAM,OAAO,sCAAsC;IAGtC;IACA;IAHF,IAAI,GAAG,wCAAwC,CAAC;IACzD,YACW,cAAkC,EAClC,KAA6B;QAD7B,mBAAc,GAAd,cAAc,CAAoB;QAClC,UAAK,GAAL,KAAK,CAAwB;IACrC,CAAC;CACL;AAED,MAAM,OAAO,8CAA8C;IAEpC;IADZ,IAAI,GAAG,iDAAiD,CAAC;IAClE,YAAqB,cAAkC;QAAlC,mBAAc,GAAd,cAAc,CAAoB;IAAG,CAAC;CAC5D;AAED,MAAM,OAAO,gCAAgC;IAGhC;IACA;IAHF,IAAI,GAAG,mCAAmC,CAAC;IACpD,YACW,cAAkC,EAClC,IAAuB;QADvB,mBAAc,GAAd,cAAc,CAAoB;QAClC,SAAI,GAAJ,IAAI,CAAmB;IAC/B,CAAC;CACL;AAED,MAAM,OAAO,0DAA0D;IAI1D;IACA;IAJF,IAAI,GACX,iEAAiE,CAAC;IACpE,YACW,cAAkC,EAClC,IAAuB;QADvB,mBAAc,GAAd,cAAc,CAAoB;QAClC,SAAI,GAAJ,IAAI,CAAmB;IAC/B,CAAC;CACL"}
@@ -0,0 +1,7 @@
1
+ import type { GtfsUpdatedTripMovement } from "../../data/trip/updated/types.js";
2
+ export declare class GtfsTripMovementsInterpolator {
3
+ interpolate(movements: readonly GtfsUpdatedTripMovement[]): readonly GtfsUpdatedTripMovement[] | null;
4
+ private _interpolateDelayValues;
5
+ private _applyDelays;
6
+ private _eliminateTimeTravel;
7
+ }