corequery-gtfs 0.1.0 → 0.1.2
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/README.md +1 -1
- package/dist/config/gtfs-config.d.ts +10 -0
- package/dist/config/gtfs-config.js +2 -0
- package/dist/config/gtfs-config.js.map +1 -0
- package/dist/config/ids.d.ts +13 -0
- package/dist/config/ids.js +2 -0
- package/dist/config/ids.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/routes.d.ts +16 -0
- package/dist/config/routes.js +2 -0
- package/dist/config/routes.js.map +1 -0
- package/dist/config/timezone-data.d.ts +5 -0
- package/dist/config/timezone-data.js +2 -0
- package/dist/config/timezone-data.js.map +1 -0
- package/dist/corequery-types.d.ts +2 -0
- package/dist/corequery-types.js +3 -0
- package/dist/corequery-types.js.map +1 -0
- package/dist/data/bounded-instant-range.d.ts +10 -0
- package/dist/data/bounded-instant-range.js +30 -0
- package/dist/data/bounded-instant-range.js.map +1 -0
- package/dist/data/gtfs-calendar.d.ts +38 -0
- package/dist/data/gtfs-calendar.js +116 -0
- package/dist/data/gtfs-calendar.js.map +1 -0
- package/dist/data/gtfs-feed.d.ts +16 -0
- package/dist/data/gtfs-feed.js +33 -0
- package/dist/data/gtfs-feed.js.map +1 -0
- package/dist/data/gtfs-realtime-data.d.ts +9 -0
- package/dist/data/gtfs-realtime-data.js +20 -0
- package/dist/data/gtfs-realtime-data.js.map +1 -0
- package/dist/data/gtfs-schedule-data.d.ts +13 -0
- package/dist/data/gtfs-schedule-data.js +40 -0
- package/dist/data/gtfs-schedule-data.js.map +1 -0
- package/dist/data/gtfs-scheduled-trip-movements.d.ts +118 -0
- package/dist/data/gtfs-scheduled-trip-movements.js +233 -0
- package/dist/data/gtfs-scheduled-trip-movements.js.map +1 -0
- package/dist/data/gtfs-scheduled-trip.d.ts +41 -0
- package/dist/data/gtfs-scheduled-trip.js +100 -0
- package/dist/data/gtfs-scheduled-trip.js.map +1 -0
- package/dist/data/gtfs-stop-time.d.ts +38 -0
- package/dist/data/gtfs-stop-time.js +105 -0
- package/dist/data/gtfs-stop-time.js.map +1 -0
- package/dist/data/gtfs-updated-trip-movements.d.ts +124 -0
- package/dist/data/gtfs-updated-trip-movements.js +150 -0
- package/dist/data/gtfs-updated-trip-movements.js.map +1 -0
- package/dist/data/gtfs-updated-trip.d.ts +21 -0
- package/dist/data/gtfs-updated-trip.js +55 -0
- package/dist/data/gtfs-updated-trip.js.map +1 -0
- package/dist/data/ids/index.d.ts +2 -0
- package/dist/data/ids/index.js +3 -0
- package/dist/data/ids/index.js.map +1 -0
- package/dist/data/ids/line-gtfs-id-collection.d.ts +16 -0
- package/dist/data/ids/line-gtfs-id-collection.js +47 -0
- package/dist/data/ids/line-gtfs-id-collection.js.map +1 -0
- package/dist/data/ids/line-gtfs-id-mapping.d.ts +17 -0
- package/dist/data/ids/line-gtfs-id-mapping.js +50 -0
- package/dist/data/ids/line-gtfs-id-mapping.js.map +1 -0
- package/dist/data/ids/line-gtfs-id-metadata.d.ts +17 -0
- package/dist/data/ids/line-gtfs-id-metadata.js +2 -0
- package/dist/data/ids/line-gtfs-id-metadata.js.map +1 -0
- package/dist/data/ids/stop-gtfs-id-collection.d.ts +14 -0
- package/dist/data/ids/stop-gtfs-id-collection.js +55 -0
- package/dist/data/ids/stop-gtfs-id-collection.js.map +1 -0
- package/dist/data/ids/stop-gtfs-id-mapping.d.ts +17 -0
- package/dist/data/ids/stop-gtfs-id-mapping.js +50 -0
- package/dist/data/ids/stop-gtfs-id-mapping.js.map +1 -0
- package/dist/data/ids/stop-gtfs-id-metadata.d.ts +23 -0
- package/dist/data/ids/stop-gtfs-id-metadata.js +2 -0
- package/dist/data/ids/stop-gtfs-id-metadata.js.map +1 -0
- package/dist/data/index.d.ts +3 -0
- package/dist/data/index.js +4 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/plain-date-range.d.ts +11 -0
- package/dist/data/plain-date-range.js +36 -0
- package/dist/data/plain-date-range.js.map +1 -0
- package/dist/data/raw/realtime-data-json.d.ts +26 -0
- package/dist/data/raw/realtime-data-json.js +2 -0
- package/dist/data/raw/realtime-data-json.js.map +1 -0
- package/dist/data/raw/schedule-csvs.d.ts +69 -0
- package/dist/data/raw/schedule-csvs.js +2 -0
- package/dist/data/raw/schedule-csvs.js.map +1 -0
- package/dist/data/route/bonus-lines-mapping.d.ts +17 -0
- package/dist/data/route/bonus-lines-mapping.js +29 -0
- package/dist/data/route/bonus-lines-mapping.js.map +1 -0
- package/dist/data/route/index.d.ts +1 -0
- package/dist/data/route/index.js +2 -0
- package/dist/data/route/index.js.map +1 -0
- package/dist/data/route/line-routes-mapping.d.ts +8 -0
- package/dist/data/route/line-routes-mapping.js +20 -0
- package/dist/data/route/line-routes-mapping.js.map +1 -0
- package/dist/data/route/route-stop.d.ts +12 -0
- package/dist/data/route/route-stop.js +18 -0
- package/dist/data/route/route-stop.js.map +1 -0
- package/dist/data/route/route.d.ts +19 -0
- package/dist/data/route/route.js +43 -0
- package/dist/data/route/route.js.map +1 -0
- package/dist/data/utils.d.ts +3 -0
- package/dist/data/utils.js +2 -0
- package/dist/data/utils.js.map +1 -0
- package/dist/departures/departures-block-iterator.d.ts +18 -0
- package/dist/departures/departures-block-iterator.js +70 -0
- package/dist/departures/departures-block-iterator.js.map +1 -0
- package/dist/departures/departures-block.d.ts +19 -0
- package/dist/departures/departures-block.js +13 -0
- package/dist/departures/departures-block.js.map +1 -0
- package/dist/departures/departures-iterator.d.ts +16 -0
- package/dist/departures/departures-iterator.js +15 -0
- package/dist/departures/departures-iterator.js.map +1 -0
- package/dist/departures/gtfs-scheduled-movements-index.d.ts +18 -0
- package/dist/departures/gtfs-scheduled-movements-index.js +66 -0
- package/dist/departures/gtfs-scheduled-movements-index.js.map +1 -0
- package/dist/departures/index.d.ts +1 -0
- package/dist/departures/index.js +2 -0
- package/dist/departures/index.js.map +1 -0
- package/dist/departures/multifeed-departures-iterator.d.ts +20 -0
- package/dist/departures/multifeed-departures-iterator.js +52 -0
- package/dist/departures/multifeed-departures-iterator.js.map +1 -0
- package/dist/departures/realtime-departures-block-iterator.d.ts +12 -0
- package/dist/departures/realtime-departures-block-iterator.js +38 -0
- package/dist/departures/realtime-departures-block-iterator.js.map +1 -0
- package/dist/departures/realtime-departures-block.d.ts +16 -0
- package/dist/departures/realtime-departures-block.js +43 -0
- package/dist/departures/realtime-departures-block.js.map +1 -0
- package/dist/departures/scheduled-departures-block-iterator.d.ts +12 -0
- package/dist/departures/scheduled-departures-block-iterator.js +55 -0
- package/dist/departures/scheduled-departures-block-iterator.js.map +1 -0
- package/dist/departures/scheduled-departures-block.d.ts +18 -0
- package/dist/departures/scheduled-departures-block.js +54 -0
- package/dist/departures/scheduled-departures-block.js.map +1 -0
- package/dist/departures/scheduled-departures-blocks-builder.d.ts +20 -0
- package/dist/departures/scheduled-departures-blocks-builder.js +222 -0
- package/dist/departures/scheduled-departures-blocks-builder.js.map +1 -0
- package/dist/departures/scheduled-departures-iterator.d.ts +30 -0
- package/dist/departures/scheduled-departures-iterator.js +204 -0
- package/dist/departures/scheduled-departures-iterator.js.map +1 -0
- package/dist/departures/zipper-departures-iterator.d.ts +18 -0
- package/dist/departures/zipper-departures-iterator.js +68 -0
- package/dist/departures/zipper-departures-iterator.js.map +1 -0
- package/dist/gtfs-system.d.ts +31 -0
- package/dist/gtfs-system.js +86 -0
- package/dist/gtfs-system.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/gtfs-feed-parser.d.ts +18 -0
- package/dist/parser/gtfs-feed-parser.js +23 -0
- package/dist/parser/gtfs-feed-parser.js.map +1 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +3 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/realtime/gtfs-realtime-data-parser.d.ts +11 -0
- package/dist/parser/realtime/gtfs-realtime-data-parser.js +19 -0
- package/dist/parser/realtime/gtfs-realtime-data-parser.js.map +1 -0
- package/dist/parser/realtime/gtfs-trip-update-parser.d.ts +99 -0
- package/dist/parser/realtime/gtfs-trip-update-parser.js +335 -0
- package/dist/parser/realtime/gtfs-trip-update-parser.js.map +1 -0
- package/dist/parser/realtime/gtfs-trip-update-trip-identifier.d.ts +35 -0
- package/dist/parser/realtime/gtfs-trip-update-trip-identifier.js +95 -0
- package/dist/parser/realtime/gtfs-trip-update-trip-identifier.js.map +1 -0
- package/dist/parser/realtime/index.d.ts +3 -0
- package/dist/parser/realtime/index.js +2 -0
- package/dist/parser/realtime/index.js.map +1 -0
- package/dist/parser/schedule/gtfs-calendar-parser.d.ts +28 -0
- package/dist/parser/schedule/gtfs-calendar-parser.js +113 -0
- package/dist/parser/schedule/gtfs-calendar-parser.js.map +1 -0
- package/dist/parser/schedule/gtfs-route-matcher.d.ts +48 -0
- package/dist/parser/schedule/gtfs-route-matcher.js +199 -0
- package/dist/parser/schedule/gtfs-route-matcher.js.map +1 -0
- package/dist/parser/schedule/gtfs-schedule-parser.d.ts +15 -0
- package/dist/parser/schedule/gtfs-schedule-parser.js +19 -0
- package/dist/parser/schedule/gtfs-schedule-parser.js.map +1 -0
- package/dist/parser/schedule/gtfs-stop-time-normaliser.d.ts +47 -0
- package/dist/parser/schedule/gtfs-stop-time-normaliser.js +119 -0
- package/dist/parser/schedule/gtfs-stop-time-normaliser.js.map +1 -0
- package/dist/parser/schedule/gtfs-transfer-connector.d.ts +52 -0
- package/dist/parser/schedule/gtfs-transfer-connector.js +168 -0
- package/dist/parser/schedule/gtfs-transfer-connector.js.map +1 -0
- package/dist/parser/schedule/gtfs-trip-parser.d.ts +45 -0
- package/dist/parser/schedule/gtfs-trip-parser.js +169 -0
- package/dist/parser/schedule/gtfs-trip-parser.js.map +1 -0
- package/dist/parser/schedule/index.d.ts +6 -0
- package/dist/parser/schedule/index.js +2 -0
- package/dist/parser/schedule/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
2
|
+
const TRANSFER_TYPE_IN_SEAT_TRANSFER = 4;
|
|
3
|
+
export class GtfsTransferConnector {
|
|
4
|
+
_onError;
|
|
5
|
+
constructor(_onError) {
|
|
6
|
+
this._onError = _onError;
|
|
7
|
+
}
|
|
8
|
+
connect(trips, transfers) {
|
|
9
|
+
const tripMap = new Map(trips.map((trip) => [trip.gtfsTripId, trip]));
|
|
10
|
+
for (const transfer of transfers) {
|
|
11
|
+
const fromTrip = tripMap.get(transfer.from_trip_id);
|
|
12
|
+
const toTrip = tripMap.get(transfer.to_trip_id);
|
|
13
|
+
// TrainQuery only cares about "in-seat" transfers, because we're only
|
|
14
|
+
// parsing these transfers to form trips into multiple "legs" of a
|
|
15
|
+
// service, a.k.a. what I used to call continuations.
|
|
16
|
+
//
|
|
17
|
+
// We should ignore them, but it's not really an error. I'm just reporting
|
|
18
|
+
// them because right now PTV only publishes in-seat transfers, and I'm
|
|
19
|
+
// curious to see if that changes one day (e.g. with V/Line's guaranteed
|
|
20
|
+
// coach connections, or coupling of trains at Ballarat).
|
|
21
|
+
if (transfer.transfer_type !== TRANSFER_TYPE_IN_SEAT_TRANSFER) {
|
|
22
|
+
this._onError(new TransferIsNotInSeatTransferError(transfer));
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (fromTrip == null) {
|
|
26
|
+
const Err = TransferReferencesNonExistentTrip;
|
|
27
|
+
this._onError(new Err(transfer, "from_trip_id"));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (toTrip == null) {
|
|
31
|
+
const Err = TransferReferencesNonExistentTrip;
|
|
32
|
+
this._onError(new Err(transfer, "to_trip_id"));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (transfer.from_stop_id !== transfer.to_stop_id) {
|
|
36
|
+
this._onError(new TransferIsNotSameStopAndPositionError(transfer));
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// As alluded to above, I suspect one day V/Line might make things
|
|
40
|
+
// difficult if they start (accurately, to be fair) considering their
|
|
41
|
+
// Maryborough shuttles as "in-seat" transfers because the trains couple
|
|
42
|
+
// at Ballarat. No idea how we'd even want to _display_ those, let alone
|
|
43
|
+
// model it!
|
|
44
|
+
if (fromTrip.termination.gtfsIdMetadata.id !== transfer.from_stop_id) {
|
|
45
|
+
this._onError(new TransferIsNotFromTerminusError(transfer, fromTrip));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (toTrip.origination.gtfsIdMetadata.id !== transfer.to_stop_id) {
|
|
49
|
+
this._onError(new TransferIsNotToOriginError(transfer, toTrip));
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (fromTrip.nextTrip != null) {
|
|
53
|
+
const Err = TransferReferencesTripAlreadyConnectedError;
|
|
54
|
+
this._onError(new Err(transfer, fromTrip));
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (toTrip.previousTrip != null) {
|
|
58
|
+
const Err = TransferReferencesTripAlreadyConnectedError;
|
|
59
|
+
this._onError(new Err(transfer, toTrip));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// TODO: I'm gonna let this one slide, so long as we remember to:
|
|
63
|
+
// - When filtering out arrivals for trips which ultimately continue, make
|
|
64
|
+
// sure to check the next trip runs on that service day. ✅
|
|
65
|
+
// - When building the services for corequery (either through the
|
|
66
|
+
// departures algorithm, or lookup by ID), only add the extra leg if the
|
|
67
|
+
// next trip runs on that service day.
|
|
68
|
+
if (fromTrip.calendar.gtfsCalendarId !== toTrip.calendar.gtfsCalendarId) {
|
|
69
|
+
this._onError(new TransferCrossesCalendarsError(transfer));
|
|
70
|
+
}
|
|
71
|
+
// I'm assuming transfers would only be made by trips running on the same
|
|
72
|
+
// service day, not just "the next instance of this trip". If it were the
|
|
73
|
+
// latter you could have a trip terminating at 24:30 connecting to a trip
|
|
74
|
+
// originating at 00:32.
|
|
75
|
+
//
|
|
76
|
+
// (If that WERE to happen, it might be acceptable to just not connect
|
|
77
|
+
// them (as we're doing now) as it'd surely only be a couple weird
|
|
78
|
+
// overnight trips. Otherwise, would it be practical to shift the next
|
|
79
|
+
// trip into the same service day retroactively by rewriting its departure
|
|
80
|
+
// and arrival times and shifting its calendar by one day? Or would it be
|
|
81
|
+
// less destructive to have some transfer metadata to say the next trip is
|
|
82
|
+
// +1 day from this one.)
|
|
83
|
+
const fromArrivalTime = fromTrip.termination.arrivalTime;
|
|
84
|
+
const toDepartureTime = toTrip.origination.departureTime;
|
|
85
|
+
if (fromArrivalTime.isAfter(toDepartureTime)) {
|
|
86
|
+
this._onError(new TransferRequiresTimeTravelError(transfer));
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const [newFrom, newTo] = GtfsScheduledTrip.connectAsTransfer(fromTrip, toTrip);
|
|
90
|
+
tripMap.set(fromTrip.gtfsTripId, newFrom);
|
|
91
|
+
tripMap.set(toTrip.gtfsTripId, newTo);
|
|
92
|
+
}
|
|
93
|
+
return Array.from(tripMap.values());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export class TransferReferencesNonExistentTrip extends Error {
|
|
97
|
+
transfer;
|
|
98
|
+
field;
|
|
99
|
+
type = "transfer-references-non-existent-trip";
|
|
100
|
+
constructor(transfer, field) {
|
|
101
|
+
super();
|
|
102
|
+
this.transfer = transfer;
|
|
103
|
+
this.field = field;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export class TransferIsNotFromTerminusError extends Error {
|
|
107
|
+
transfer;
|
|
108
|
+
fromTrip;
|
|
109
|
+
type = "transfer-is-not-from-terminus";
|
|
110
|
+
constructor(transfer, fromTrip) {
|
|
111
|
+
super();
|
|
112
|
+
this.transfer = transfer;
|
|
113
|
+
this.fromTrip = fromTrip;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export class TransferIsNotToOriginError extends Error {
|
|
117
|
+
transfer;
|
|
118
|
+
toTrip;
|
|
119
|
+
type = "transfer-is-not-to-origin";
|
|
120
|
+
constructor(transfer, toTrip) {
|
|
121
|
+
super();
|
|
122
|
+
this.transfer = transfer;
|
|
123
|
+
this.toTrip = toTrip;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export class TransferReferencesTripAlreadyConnectedError extends Error {
|
|
127
|
+
transfer;
|
|
128
|
+
tripWithExistingConnection;
|
|
129
|
+
type = "transfer-references-trip-already-connected";
|
|
130
|
+
constructor(transfer, tripWithExistingConnection) {
|
|
131
|
+
super();
|
|
132
|
+
this.transfer = transfer;
|
|
133
|
+
this.tripWithExistingConnection = tripWithExistingConnection;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export class TransferIsNotInSeatTransferError extends Error {
|
|
137
|
+
transfer;
|
|
138
|
+
type = "transfer-is-not-in-seat-transfer";
|
|
139
|
+
constructor(transfer) {
|
|
140
|
+
super();
|
|
141
|
+
this.transfer = transfer;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export class TransferIsNotSameStopAndPositionError extends Error {
|
|
145
|
+
transfer;
|
|
146
|
+
type = "transfer-is-not-same-stop-and-position";
|
|
147
|
+
constructor(transfer) {
|
|
148
|
+
super();
|
|
149
|
+
this.transfer = transfer;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export class TransferCrossesCalendarsError extends Error {
|
|
153
|
+
transfer;
|
|
154
|
+
type = "transfer-crosses-calendars";
|
|
155
|
+
constructor(transfer) {
|
|
156
|
+
super();
|
|
157
|
+
this.transfer = transfer;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export class TransferRequiresTimeTravelError extends Error {
|
|
161
|
+
transfer;
|
|
162
|
+
type = "transfer-requires-time-travel";
|
|
163
|
+
constructor(transfer) {
|
|
164
|
+
super();
|
|
165
|
+
this.transfer = transfer;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=gtfs-transfer-connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtfs-transfer-connector.js","sourceRoot":"","sources":["../../../src/parser/schedule/gtfs-transfer-connector.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAEzC,MAAM,OAAO,qBAAqB;IAEb;IADnB,YACmB,QAAsD;QAAtD,aAAQ,GAAR,QAAQ,CAA8C;IACtE,CAAC;IAEJ,OAAO,CACL,KAAmC,EACnC,SAAuB;QAEvB,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAC7C,CAAC;QAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACpD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAEhD,sEAAsE;YACtE,kEAAkE;YAClE,qDAAqD;YACrD,EAAE;YACF,0EAA0E;YAC1E,uEAAuE;YACvE,wEAAwE;YACxE,yDAAyD;YACzD,IAAI,QAAQ,CAAC,aAAa,KAAK,8BAA8B,EAAE,CAAC;gBAC9D,IAAI,CAAC,QAAQ,CAAC,IAAI,gCAAgC,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC9D,SAAS;YACX,CAAC;YAED,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;gBACrB,MAAM,GAAG,GAAG,iCAAiC,CAAC;gBAC9C,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;gBACjD,SAAS;YACX,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AyB;QAC5C,KAAK,EAAE,CAAC;QADW,aAAQ,GAAR,QAAQ,CAAiB;IAE9C,CAAC;CACF;AAED,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IAEnC;IADZ,IAAI,GAAG,+BAA+B,CAAC;IAChD,YAAqB,QAAyB;QAC5C,KAAK,EAAE,CAAC;QADW,aAAQ,GAAR,QAAQ,CAAiB;IAE9C,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { LineGtfsIdMapping } from "../../data/ids/line-gtfs-id-mapping.js";
|
|
2
|
+
import type { StopGtfsIdMapping } from "../../data/ids/stop-gtfs-id-mapping.js";
|
|
3
|
+
import type { StopTimesCsv, StopTimesCsvRow, TransfersCsv, TripsCsv, TripsCsvRow } from "../../data/raw/schedule-csvs.js";
|
|
4
|
+
import type { GtfsCalendar } from "../../data/gtfs-calendar.js";
|
|
5
|
+
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
6
|
+
import { type GtfsStopTimeNormalisationError } from "./gtfs-stop-time-normaliser.js";
|
|
7
|
+
import { type GtfsRouteMatchingError } from "./gtfs-route-matcher.js";
|
|
8
|
+
import { type GtfsTransferConnectionError } from "./gtfs-transfer-connector.js";
|
|
9
|
+
import type { LineRoutesMapping } from "../../data/route/line-routes-mapping.js";
|
|
10
|
+
import type { BonusLinesMapping } from "../../data/route/bonus-lines-mapping.js";
|
|
11
|
+
export declare class GtfsTripParser {
|
|
12
|
+
private readonly _lineRoutesMapping;
|
|
13
|
+
private readonly _bonusLinesMapping;
|
|
14
|
+
private readonly _onError;
|
|
15
|
+
private readonly _stopTimeNormaliser;
|
|
16
|
+
private readonly _primaryRouteMatcher;
|
|
17
|
+
private readonly _bonusRouteMatcher;
|
|
18
|
+
private readonly _transferConnector;
|
|
19
|
+
constructor(_lineRoutesMapping: LineRoutesMapping, _bonusLinesMapping: BonusLinesMapping, _onError: (error: GtfsTripParsingError) => void);
|
|
20
|
+
parse(trips: TripsCsv, stopTimes: StopTimesCsv, transfers: TransfersCsv, calendars: readonly GtfsCalendar[], lineGtfsIdMapping: LineGtfsIdMapping, stopGtfsIdMapping: StopGtfsIdMapping): readonly GtfsScheduledTrip[];
|
|
21
|
+
private _organiseStopTimesIntoTrips;
|
|
22
|
+
private _applyBonusLines;
|
|
23
|
+
private _buildCalendarMap;
|
|
24
|
+
}
|
|
25
|
+
export type GtfsTripParsingError = StopTimeReferencesNonExistentTripError | DuplicateTripIdError | TripReferencesNonExistentCalendarError | TripReferencesUnmappedRouteIdError | GtfsStopTimeNormalisationError | GtfsRouteMatchingError | GtfsTransferConnectionError;
|
|
26
|
+
export declare class StopTimeReferencesNonExistentTripError extends Error {
|
|
27
|
+
readonly stopTime: StopTimesCsvRow;
|
|
28
|
+
readonly type = "stop-time-references-non-existent-trip";
|
|
29
|
+
constructor(stopTime: StopTimesCsvRow);
|
|
30
|
+
}
|
|
31
|
+
export declare class DuplicateTripIdError extends Error {
|
|
32
|
+
readonly subsequentRowWithDuplicateId: TripsCsvRow;
|
|
33
|
+
readonly type = "duplicate-trip-id";
|
|
34
|
+
constructor(subsequentRowWithDuplicateId: TripsCsvRow);
|
|
35
|
+
}
|
|
36
|
+
export declare class TripReferencesNonExistentCalendarError extends Error {
|
|
37
|
+
readonly trip: TripsCsvRow;
|
|
38
|
+
readonly type = "trip-references-non-existent-calendar";
|
|
39
|
+
constructor(trip: TripsCsvRow);
|
|
40
|
+
}
|
|
41
|
+
export declare class TripReferencesUnmappedRouteIdError extends Error {
|
|
42
|
+
readonly trip: TripsCsvRow;
|
|
43
|
+
readonly type = "trip-references-unmapped-route-id";
|
|
44
|
+
constructor(trip: TripsCsvRow);
|
|
45
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { GtfsScheduledTrip } from "../../data/gtfs-scheduled-trip.js";
|
|
2
|
+
import { GtfsStopTimeNormaliser, } from "./gtfs-stop-time-normaliser.js";
|
|
3
|
+
import { GtfsRouteMatcher, } from "./gtfs-route-matcher.js";
|
|
4
|
+
import { GtfsTransferConnector, } from "./gtfs-transfer-connector.js";
|
|
5
|
+
export class GtfsTripParser {
|
|
6
|
+
_lineRoutesMapping;
|
|
7
|
+
_bonusLinesMapping;
|
|
8
|
+
_onError;
|
|
9
|
+
_stopTimeNormaliser;
|
|
10
|
+
_primaryRouteMatcher;
|
|
11
|
+
_bonusRouteMatcher;
|
|
12
|
+
_transferConnector;
|
|
13
|
+
constructor(
|
|
14
|
+
// Unlike csvs, lineGtfsIdMapping, and stopGtfsIdMapping, these are not
|
|
15
|
+
// subfeed-dependent, so I'm opting to make them constructor args.
|
|
16
|
+
_lineRoutesMapping, _bonusLinesMapping, _onError) {
|
|
17
|
+
this._lineRoutesMapping = _lineRoutesMapping;
|
|
18
|
+
this._bonusLinesMapping = _bonusLinesMapping;
|
|
19
|
+
this._onError = _onError;
|
|
20
|
+
this._stopTimeNormaliser = new GtfsStopTimeNormaliser(this._onError);
|
|
21
|
+
this._primaryRouteMatcher = new GtfsRouteMatcher(this._onError);
|
|
22
|
+
this._transferConnector = new GtfsTransferConnector(this._onError);
|
|
23
|
+
// We don't care if a bonus route doesn't match. Most of the time, it won't!
|
|
24
|
+
this._bonusRouteMatcher = new GtfsRouteMatcher(() => { });
|
|
25
|
+
}
|
|
26
|
+
parse(trips, stopTimes, transfers, calendars, lineGtfsIdMapping, stopGtfsIdMapping) {
|
|
27
|
+
const calendarMap = this._buildCalendarMap(calendars);
|
|
28
|
+
const rowsByTrip = this._organiseStopTimesIntoTrips(trips, stopTimes);
|
|
29
|
+
const unconnectedTrips = [];
|
|
30
|
+
for (const { trip, stopTimes } of rowsByTrip) {
|
|
31
|
+
const calendar = calendarMap.get(trip.service_id);
|
|
32
|
+
if (calendar == null) {
|
|
33
|
+
this._onError(new TripReferencesNonExistentCalendarError(trip));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const lineIdMatch = lineGtfsIdMapping.tryResolve(trip.route_id);
|
|
37
|
+
if (lineIdMatch == null) {
|
|
38
|
+
this._onError(new TripReferencesUnmappedRouteIdError(trip));
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (lineIdMatch.type === "replacement-bus")
|
|
42
|
+
continue;
|
|
43
|
+
const normalizedStopTimes = this._stopTimeNormaliser.normalise(stopTimes);
|
|
44
|
+
// Stop time normaliser reports its own errors.
|
|
45
|
+
if (normalizedStopTimes == null)
|
|
46
|
+
continue;
|
|
47
|
+
const routesForLine = this._lineRoutesMapping.forLine(lineIdMatch.lineId);
|
|
48
|
+
const routeMatchResult = this._primaryRouteMatcher.match(normalizedStopTimes, routesForLine, stopGtfsIdMapping);
|
|
49
|
+
// Route matcher reports its own errors.
|
|
50
|
+
if (routeMatchResult == null)
|
|
51
|
+
continue;
|
|
52
|
+
const { lineIds, serviceTags } = this._applyBonusLines(lineIdMatch.lineId, routeMatchResult.serviceTags, normalizedStopTimes, stopGtfsIdMapping);
|
|
53
|
+
unconnectedTrips.push(new GtfsScheduledTrip({
|
|
54
|
+
gtfsTripId: trip.trip_id,
|
|
55
|
+
gtfsRouteId: trip.route_id,
|
|
56
|
+
calendar,
|
|
57
|
+
movements: routeMatchResult.movements,
|
|
58
|
+
lineIds,
|
|
59
|
+
color: routeMatchResult.color,
|
|
60
|
+
serviceTags,
|
|
61
|
+
previousTrip: null,
|
|
62
|
+
nextTrip: null,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
return this._transferConnector.connect(unconnectedTrips, transfers);
|
|
66
|
+
}
|
|
67
|
+
_organiseStopTimesIntoTrips(trips, stopTimes) {
|
|
68
|
+
const result = new Map();
|
|
69
|
+
// Step 1: Build a map from everything in trips.txt.
|
|
70
|
+
for (const trip of trips) {
|
|
71
|
+
if (result.has(trip.trip_id)) {
|
|
72
|
+
// We only keep the first trip we see for a given trip_id, I guess.
|
|
73
|
+
this._onError(new DuplicateTripIdError(trip));
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
result.set(trip.trip_id, { trip, stopTimes: [] });
|
|
77
|
+
}
|
|
78
|
+
// Step 2: Iterate through stop_times.txt and add each row to the
|
|
79
|
+
// appropriate trip.
|
|
80
|
+
for (const stopTime of stopTimes) {
|
|
81
|
+
const trip = result.get(stopTime.trip_id);
|
|
82
|
+
if (trip == null) {
|
|
83
|
+
// It's likely if something's missing from trips.txt that multiple
|
|
84
|
+
// stop_times.txt rows will reference it. However, I consider it out of
|
|
85
|
+
// scope for the parser to group those errors. Something which listens
|
|
86
|
+
// for the errors (i.e. to build some report) is responsible for that.
|
|
87
|
+
this._onError(new StopTimeReferencesNonExistentTripError(stopTime));
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
trip.stopTimes.push(stopTime);
|
|
91
|
+
}
|
|
92
|
+
// Step 3: Convert to an array. Do NOT sort by stop_sequence, as the stop
|
|
93
|
+
// time normaliser is interested in the original order of the rows in
|
|
94
|
+
// stop_times.txt for some special case handling (i.e. PTV has published
|
|
95
|
+
// invalid data, but we can still interpret it).
|
|
96
|
+
return Array.from(result.values()).map((group) => ({
|
|
97
|
+
...group,
|
|
98
|
+
stopTimes: group.stopTimes,
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
_applyBonusLines(mainRouteLineId, mainRouteServiceTags, normalizedStopTimes, stopGtfsIdMapping) {
|
|
102
|
+
const bonusLines = this._bonusLinesMapping.forLine(mainRouteLineId);
|
|
103
|
+
if (bonusLines == null) {
|
|
104
|
+
return { lineIds: [mainRouteLineId], serviceTags: mainRouteServiceTags };
|
|
105
|
+
}
|
|
106
|
+
// Go through all bonus lines, and collect the line IDs and service tags
|
|
107
|
+
// for any routes that match.
|
|
108
|
+
const lineIds = new Set();
|
|
109
|
+
const serviceTags = new Set();
|
|
110
|
+
for (const bonusLine of bonusLines.lines) {
|
|
111
|
+
const matchResult = this._bonusRouteMatcher.match(normalizedStopTimes, this._lineRoutesMapping.forLine(bonusLine), stopGtfsIdMapping);
|
|
112
|
+
if (matchResult != null) {
|
|
113
|
+
lineIds.add(bonusLine);
|
|
114
|
+
for (const serviceTag of matchResult.serviceTags) {
|
|
115
|
+
serviceTags.add(serviceTag);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// If in "replace" mode, we throw away the main route's line ID and tags if
|
|
120
|
+
// anything else matches. Otherwise they're added on.
|
|
121
|
+
const shouldReplace = lineIds.size > 0 && bonusLines.mode === "replace";
|
|
122
|
+
if (!shouldReplace) {
|
|
123
|
+
lineIds.add(mainRouteLineId);
|
|
124
|
+
for (const serviceTag of mainRouteServiceTags) {
|
|
125
|
+
serviceTags.add(serviceTag);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
lineIds: Array.from(lineIds),
|
|
130
|
+
serviceTags: Array.from(serviceTags),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
_buildCalendarMap(calendars) {
|
|
134
|
+
return new Map(calendars.map((c) => [c.gtfsCalendarId, c]));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export class StopTimeReferencesNonExistentTripError extends Error {
|
|
138
|
+
stopTime;
|
|
139
|
+
type = "stop-time-references-non-existent-trip";
|
|
140
|
+
constructor(stopTime) {
|
|
141
|
+
super();
|
|
142
|
+
this.stopTime = stopTime;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export class DuplicateTripIdError extends Error {
|
|
146
|
+
subsequentRowWithDuplicateId;
|
|
147
|
+
type = "duplicate-trip-id";
|
|
148
|
+
constructor(subsequentRowWithDuplicateId) {
|
|
149
|
+
super();
|
|
150
|
+
this.subsequentRowWithDuplicateId = subsequentRowWithDuplicateId;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export class TripReferencesNonExistentCalendarError extends Error {
|
|
154
|
+
trip;
|
|
155
|
+
type = "trip-references-non-existent-calendar";
|
|
156
|
+
constructor(trip) {
|
|
157
|
+
super();
|
|
158
|
+
this.trip = trip;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export class TripReferencesUnmappedRouteIdError extends Error {
|
|
162
|
+
trip;
|
|
163
|
+
type = "trip-references-unmapped-route-id";
|
|
164
|
+
constructor(trip) {
|
|
165
|
+
super();
|
|
166
|
+
this.trip = trip;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=gtfs-trip-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtfs-trip-parser.js","sourceRoot":"","sources":["../../../src/parser/schedule/gtfs-trip-parser.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,sBAAsB,GAEvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAItC,MAAM,OAAO,cAAc;IASN;IACA;IAEA;IAXF,mBAAmB,CAAyB;IAC5C,oBAAoB,CAAmB;IACvC,kBAAkB,CAAmB;IACrC,kBAAkB,CAAwB;IAE3D;IACE,uEAAuE;IACvE,kEAAkE;IACjD,kBAAqC,EACrC,kBAAqC,EAErC,QAA+C;QAH/C,uBAAkB,GAAlB,kBAAkB,CAAmB;QACrC,uBAAkB,GAAlB,kBAAkB,CAAmB;QAErC,aAAQ,GAAR,QAAQ,CAAuC;QAEhE,IAAI,CAAC,mBAAmB,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,oBAAoB,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,kBAAkB,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEnE,4EAA4E;QAC5E,IAAI,CAAC,kBAAkB,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,GAAE,C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,CAAa;IAE9D,CAAC;CACF;AAED,MAAM,OAAO,sCAAuC,SAAQ,KAAK;IAE1C;IADZ,IAAI,GAAG,uCAAuC,CAAC;IACxD,YAAqB,IAAiB;QACpC,KAAK,EAAE,CAAC;QADW,SAAI,GAAJ,IAAI,CAAa;IAEtC,CAAC;CACF;AAED,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAEtC;IADZ,IAAI,GAAG,mCAAmC,CAAC;IACpD,YAAqB,IAAiB;QACpC,KAAK,EAAE,CAAC;QADW,SAAI,GAAJ,IAAI,CAAa;IAEtC,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { GtfsCalendarParsingError, DuplicateCalendarIdError, UnexpectedCalendarDateExceptionTypeError, InvalidCalendarDateRangeError, MultipleExceptionsForSameDateError, } from "./gtfs-calendar-parser.js";
|
|
2
|
+
export type { GtfsRouteMatchingError, NoMatchingRouteError, StopTimeReferencesUnmappedStopIdError, UnexpectedPickupTypeError, UnexpectedDropOffTypeError, } from "./gtfs-route-matcher.js";
|
|
3
|
+
export type { GtfsScheduleParsingError } from "./gtfs-schedule-parser.js";
|
|
4
|
+
export type { GtfsStopTimeNormalisationError, InvalidStopSequenceError, MultipleStopSequencesError, } from "./gtfs-stop-time-normaliser.js";
|
|
5
|
+
export type { GtfsTransferConnectionError, TransferReferencesNonExistentTrip, TransferIsNotFromTerminusError, TransferIsNotToOriginError, TransferReferencesTripAlreadyConnectedError, TransferIsNotInSeatTransferError, TransferIsNotSameStopAndPositionError, TransferCrossesCalendarsError, TransferRequiresTimeTravelError, } from "./gtfs-transfer-connector.js";
|
|
6
|
+
export type { GtfsTripParsingError, StopTimeReferencesNonExistentTripError, DuplicateTripIdError, TripReferencesNonExistentCalendarError, TripReferencesUnmappedRouteIdError, } from "./gtfs-trip-parser.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/parser/schedule/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corequery-gtfs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
|
-
"exports": "./dist/
|
|
9
|
-
"types": "./dist/
|
|
8
|
+
"exports": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
12
12
|
"test": "vitest --run",
|