minotor 11.3.0 → 11.4.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.
@@ -1,5 +1,6 @@
1
1
  import { SourceStopId, StopId } from '../stops/stops.js';
2
2
  import { ServiceRouteId, Timetable, Transfer, TripTransfers as TripTransfers } from '../timetable/timetable.js';
3
+ import { ServiceId, ServiceIds } from './services.js';
3
4
  import { GtfsStopsMap } from './stops.js';
4
5
  import { GtfsTripId, TripsMapping } from './trips.js';
5
6
  export type GtfsTransferType = 0 | 1 | 2 | 3 | 4 | 5;
@@ -17,16 +18,19 @@ export type TransferEntry = {
17
18
  to_trip_id?: GtfsTripId;
18
19
  from_route_id?: ServiceRouteId;
19
20
  to_route_id?: ServiceRouteId;
21
+ service_id?: ServiceId;
20
22
  transfer_type: GtfsTransferType;
21
23
  min_transfer_time?: number;
22
24
  };
23
25
  /**
24
26
  * Parses the transfers.txt file from a GTFS feed.
25
27
  *
26
- * @param stopsStream The readable stream containing the stops data.
27
- * @return A mapping of stop IDs to corresponding stop details.
28
+ * @param transfersStream The readable stream containing the transfers data.
29
+ * @param stopsMap The parsed GTFS stops indexed by their source IDs.
30
+ * @param activeServiceIds The service IDs active for the requested date.
31
+ * @returns Parsed stop transfers, trip continuations, and guaranteed trip transfers.
28
32
  */
29
- export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap) => Promise<{
33
+ export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap, activeServiceIds: ServiceIds) => Promise<{
30
34
  transfers: TransfersMap;
31
35
  tripContinuations: GtfsTripTransfer[];
32
36
  guaranteedTripTransfers: GtfsTripTransfer[];
@@ -16021,10 +16021,12 @@ const processStopToStopTransfer = (transferEntry, fromStop, toStop, transfers) =
16021
16021
  /**
16022
16022
  * Parses the transfers.txt file from a GTFS feed.
16023
16023
  *
16024
- * @param stopsStream The readable stream containing the stops data.
16025
- * @return A mapping of stop IDs to corresponding stop details.
16024
+ * @param transfersStream The readable stream containing the transfers data.
16025
+ * @param stopsMap The parsed GTFS stops indexed by their source IDs.
16026
+ * @param activeServiceIds The service IDs active for the requested date.
16027
+ * @returns Parsed stop transfers, trip continuations, and guaranteed trip transfers.
16026
16028
  */
16027
- const parseTransfers = (transfersStream, stopsMap) => __awaiter(void 0, void 0, void 0, function* () {
16029
+ const parseTransfers = (transfersStream, stopsMap, activeServiceIds) => __awaiter(void 0, void 0, void 0, function* () {
16028
16030
  var _a, e_1, _b, _c;
16029
16031
  const transfers = new Map();
16030
16032
  const tripContinuations = [];
@@ -16038,6 +16040,10 @@ const parseTransfers = (transfersStream, stopsMap) => __awaiter(void 0, void 0,
16038
16040
  _d = false;
16039
16041
  const rawLine = _c;
16040
16042
  const transferEntry = rawLine;
16043
+ if (transferEntry.service_id &&
16044
+ !activeServiceIds.has(transferEntry.service_id)) {
16045
+ continue;
16046
+ }
16041
16047
  if (transferEntry.transfer_type === 3 ||
16042
16048
  transferEntry.transfer_type === 5) {
16043
16049
  continue;
@@ -16615,7 +16621,7 @@ class GtfsParser {
16615
16621
  log.info(`Parsing ${TRANSFERS_FILE}`);
16616
16622
  const transfersStart = performance.now();
16617
16623
  const transfersStream = yield zip.stream(TRANSFERS_FILE);
16618
- const { transfers: parsedTransfers, tripContinuations: parsedTripContinuations, guaranteedTripTransfers: parsedGuaranteedTripTransfers, } = yield parseTransfers(transfersStream, parsedStops);
16624
+ const { transfers: parsedTransfers, tripContinuations: parsedTripContinuations, guaranteedTripTransfers: parsedGuaranteedTripTransfers, } = yield parseTransfers(transfersStream, parsedStops, activeServiceIds);
16619
16625
  transfers = parsedTransfers;
16620
16626
  tripContinuationsList = parsedTripContinuations;
16621
16627
  guaranteedTripTransfersList = parsedGuaranteedTripTransfers;