minotor 1.0.1 → 1.0.3

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.
@@ -0,0 +1 @@
1
+ proto/
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
- ## [1.0.1](https://github.com/aubryio/minotor/compare/v1.0.0...v1.0.1) (2025-02-03)
1
+ ## [1.0.3](https://github.com/aubryio/minotor/compare/v1.0.2...v1.0.3) (2025-02-09)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * trigger new version after fixing types export ([b14dccc](https://github.com/aubryio/minotor/commit/b14dccc37b607fb9e06814bed9bd9795e47e6f5c))
6
+ * split parser and router modules for better bundling ([#8](https://github.com/aubryio/minotor/issues/8)) ([6c89814](https://github.com/aubryio/minotor/commit/6c89814a336b3557458cd193b92bc8ffca4a79c1))
@@ -1,4 +1,4 @@
1
- import { GtfsProfile } from '../index.js';
1
+ import { GtfsProfile } from '../parser.js';
2
2
  export type GtfsVariant = string;
3
3
  export type Config = {
4
4
  [config: GtfsVariant]: GtfsProfile;
@@ -1,3 +1,3 @@
1
- import { Result, Route } from '../index.js';
1
+ import { Result, Route } from '../router.js';
2
2
  export declare const prettyPrintRoute: (route: Route) => void;
3
3
  export declare const plotGraphToDotFile: (result: Result, filePath: string) => void;
@@ -12134,7 +12134,7 @@ const StopTimes = {
12134
12134
  function createBaseRoute() {
12135
12135
  return { stopTimes: [], stops: [], serviceRouteId: "" };
12136
12136
  }
12137
- const Route$1 = {
12137
+ const Route = {
12138
12138
  encode(message, writer = new BinaryWriter()) {
12139
12139
  for (const v of message.stopTimes) {
12140
12140
  StopTimes.encode(v, writer.uint32(10).fork()).join();
@@ -12207,7 +12207,7 @@ const Route$1 = {
12207
12207
  return obj;
12208
12208
  },
12209
12209
  create(base) {
12210
- return Route$1.fromPartial(base !== null && base !== undefined ? base : {});
12210
+ return Route.fromPartial(base !== null && base !== undefined ? base : {});
12211
12211
  },
12212
12212
  fromPartial(object) {
12213
12213
  var _a, _b, _c;
@@ -12257,7 +12257,7 @@ const RoutesAdjacency = {
12257
12257
  return {
12258
12258
  routes: isObject(object.routes)
12259
12259
  ? Object.entries(object.routes).reduce((acc, [key, value]) => {
12260
- acc[key] = Route$1.fromJSON(value);
12260
+ acc[key] = Route.fromJSON(value);
12261
12261
  return acc;
12262
12262
  }, {})
12263
12263
  : {},
@@ -12270,7 +12270,7 @@ const RoutesAdjacency = {
12270
12270
  if (entries.length > 0) {
12271
12271
  obj.routes = {};
12272
12272
  entries.forEach(([k, v]) => {
12273
- obj.routes[k] = Route$1.toJSON(v);
12273
+ obj.routes[k] = Route.toJSON(v);
12274
12274
  });
12275
12275
  }
12276
12276
  }
@@ -12284,7 +12284,7 @@ const RoutesAdjacency = {
12284
12284
  const message = createBaseRoutesAdjacency();
12285
12285
  message.routes = Object.entries((_a = object.routes) !== null && _a !== undefined ? _a : {}).reduce((acc, [key, value]) => {
12286
12286
  if (value !== undefined) {
12287
- acc[key] = Route$1.fromPartial(value);
12287
+ acc[key] = Route.fromPartial(value);
12288
12288
  }
12289
12289
  return acc;
12290
12290
  }, {});
@@ -12300,7 +12300,7 @@ const RoutesAdjacency_RoutesEntry = {
12300
12300
  writer.uint32(10).string(message.key);
12301
12301
  }
12302
12302
  if (message.value !== undefined) {
12303
- Route$1.encode(message.value, writer.uint32(18).fork()).join();
12303
+ Route.encode(message.value, writer.uint32(18).fork()).join();
12304
12304
  }
12305
12305
  return writer;
12306
12306
  },
@@ -12322,7 +12322,7 @@ const RoutesAdjacency_RoutesEntry = {
12322
12322
  if (tag !== 18) {
12323
12323
  break;
12324
12324
  }
12325
- message.value = Route$1.decode(reader, reader.uint32());
12325
+ message.value = Route.decode(reader, reader.uint32());
12326
12326
  continue;
12327
12327
  }
12328
12328
  }
@@ -12336,7 +12336,7 @@ const RoutesAdjacency_RoutesEntry = {
12336
12336
  fromJSON(object) {
12337
12337
  return {
12338
12338
  key: isSet(object.key) ? globalThis.String(object.key) : "",
12339
- value: isSet(object.value) ? Route$1.fromJSON(object.value) : undefined,
12339
+ value: isSet(object.value) ? Route.fromJSON(object.value) : undefined,
12340
12340
  };
12341
12341
  },
12342
12342
  toJSON(message) {
@@ -12345,7 +12345,7 @@ const RoutesAdjacency_RoutesEntry = {
12345
12345
  obj.key = message.key;
12346
12346
  }
12347
12347
  if (message.value !== undefined) {
12348
- obj.value = Route$1.toJSON(message.value);
12348
+ obj.value = Route.toJSON(message.value);
12349
12349
  }
12350
12350
  return obj;
12351
12351
  },
@@ -12356,7 +12356,7 @@ const RoutesAdjacency_RoutesEntry = {
12356
12356
  var _a;
12357
12357
  const message = createBaseRoutesAdjacency_RoutesEntry();
12358
12358
  message.key = (_a = object.key) !== null && _a !== undefined ? _a : "";
12359
- message.value = (object.value !== undefined && object.value !== null) ? Route$1.fromPartial(object.value) : undefined;
12359
+ message.value = (object.value !== undefined && object.value !== null) ? Route.fromPartial(object.value) : undefined;
12360
12360
  return message;
12361
12361
  },
12362
12362
  };
@@ -16080,428 +16080,6 @@ const chGtfsProfile = {
16080
16080
  platformParser,
16081
16081
  };
16082
16082
 
16083
- class Plotter {
16084
- constructor(result) {
16085
- this.result = result;
16086
- }
16087
- /**
16088
- * Plots the path three as a DOT for debugging purposes.
16089
- *
16090
- * @returns A string representing the DOT graph of the path tree.
16091
- */
16092
- plotDotGraph() {
16093
- const earliestArrivalsPerRound = this.result.earliestArrivalsPerRound;
16094
- const dotParts = [
16095
- 'digraph PathTree {',
16096
- ' graph [overlap=false];',
16097
- ' node [shape=ellipse style=filled fillcolor=lightgrey];',
16098
- ];
16099
- earliestArrivalsPerRound.forEach((arrivalsInRound, round) => {
16100
- arrivalsInRound.forEach((tripLeg) => {
16101
- const { origin, leg } = tripLeg;
16102
- if (!leg)
16103
- return; // Skip if leg is undefined
16104
- const fromStop = this.result['stopsIndex'].findStopById(leg.from.id);
16105
- const toStop = this.result['stopsIndex'].findStopById(leg.to.id);
16106
- const originStop = this.result['stopsIndex'].findStopById(origin);
16107
- if (fromStop && toStop && originStop) {
16108
- const fromName = fromStop.platform
16109
- ? `${fromStop.name} (Pl. ${fromStop.platform})`
16110
- : fromStop.name;
16111
- const toName = toStop.platform
16112
- ? `${toStop.name} (Pl. ${toStop.platform})`
16113
- : toStop.name;
16114
- const originName = originStop.platform
16115
- ? `${originStop.name} (Pl. ${originStop.platform})`
16116
- : originStop.name;
16117
- const isVehicle = 'route' in leg;
16118
- const routeLabelContent = isVehicle
16119
- ? `${leg.route.name}\n${leg.departureTime.toString()} - ${leg.arrivalTime.toString()}`
16120
- : leg.minTransferTime
16121
- ? leg.minTransferTime.toString()
16122
- : '';
16123
- const intermediateNode = `IntermediateNode${fromStop.id}_${toStop.id}`;
16124
- const lineColor = isVehicle ? '' : ', color="red", fontcolor="red"';
16125
- const labelColor = isVehicle ? '' : ' fontcolor="red"';
16126
- dotParts.push(` "${fromName} (Origin: ${originName}) [R${round}]\n(${fromStop.id})" -> "${intermediateNode}" [shape=point${lineColor}];`);
16127
- dotParts.push(` "${intermediateNode}" [label="${routeLabelContent}" shape=rect style=filled fillcolor=white${labelColor} border=0];`);
16128
- dotParts.push(` "${intermediateNode}" -> "${toName} (Origin: ${originName}) [R${round}]\n(${toStop.id})" [${lineColor.replace(', ', '')}];`);
16129
- }
16130
- });
16131
- });
16132
- dotParts.push('}');
16133
- return dotParts.join('\n');
16134
- }
16135
- }
16136
-
16137
- class Query {
16138
- constructor(builder) {
16139
- this.from = builder.fromValue;
16140
- this.to = builder.toValue;
16141
- this.departureTime = builder.departureTimeValue;
16142
- this.options = builder.optionsValue;
16143
- }
16144
- }
16145
- Query.Builder = class {
16146
- constructor() {
16147
- // lastDepartureTimeValue?: Date;
16148
- // via: StopId[] = [];
16149
- this.optionsValue = {
16150
- maxTransfers: 5,
16151
- minTransferTime: Duration.fromSeconds(120),
16152
- transportModes: ALL_TRANSPORT_MODES,
16153
- };
16154
- }
16155
- from(from) {
16156
- this.fromValue = from;
16157
- return this;
16158
- }
16159
- to(to) {
16160
- this.toValue = Array.isArray(to) ? to : [to];
16161
- return this;
16162
- }
16163
- departureTime(departureTime) {
16164
- this.departureTimeValue = departureTime;
16165
- return this;
16166
- }
16167
- maxTransfers(maxTransfers) {
16168
- this.optionsValue.maxTransfers = maxTransfers;
16169
- return this;
16170
- }
16171
- minTransferTime(minTransferTime) {
16172
- this.optionsValue.minTransferTime = minTransferTime;
16173
- return this;
16174
- }
16175
- transportModes(transportModes) {
16176
- this.optionsValue.transportModes = transportModes;
16177
- return this;
16178
- }
16179
- build() {
16180
- return new Query(this);
16181
- }
16182
- };
16183
-
16184
- class Route {
16185
- constructor(legs) {
16186
- if (legs.length === 0) {
16187
- throw new Error('There must be at least one leg in a route');
16188
- }
16189
- this.legs = legs;
16190
- }
16191
- departureTime() {
16192
- const cumulativeTransferTime = Duration.zero();
16193
- for (let i = 0; i < this.legs.length; i++) {
16194
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16195
- const leg = this.legs[i];
16196
- if ('departureTime' in leg) {
16197
- return leg.departureTime.minus(cumulativeTransferTime);
16198
- }
16199
- if ('minTransferTime' in leg && leg.minTransferTime) {
16200
- cumulativeTransferTime.add(leg.minTransferTime);
16201
- }
16202
- }
16203
- throw new Error('No vehicle leg found in route');
16204
- }
16205
- arrivalTime() {
16206
- let lastVehicleArrivalTime = Time.origin();
16207
- const totalTransferTime = Duration.zero();
16208
- let vehicleLegFound = false;
16209
- for (let i = this.legs.length - 1; i >= 0; i--) {
16210
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16211
- const leg = this.legs[i];
16212
- if ('arrivalTime' in leg && !vehicleLegFound) {
16213
- lastVehicleArrivalTime = leg.arrivalTime;
16214
- vehicleLegFound = true;
16215
- }
16216
- else if ('minTransferTime' in leg &&
16217
- leg.minTransferTime &&
16218
- vehicleLegFound) {
16219
- totalTransferTime.add(leg.minTransferTime);
16220
- }
16221
- }
16222
- if (!vehicleLegFound) {
16223
- throw new Error('No vehicle leg found in route');
16224
- }
16225
- return lastVehicleArrivalTime.plus(totalTransferTime);
16226
- }
16227
- totalDuration() {
16228
- if (this.legs.length === 0)
16229
- return Duration.zero();
16230
- return this.arrivalTime().diff(this.departureTime());
16231
- }
16232
- print() {
16233
- return this.legs
16234
- .map((leg, index) => {
16235
- var _a, _b;
16236
- if ('route' in leg) {
16237
- return `Leg ${index + 1}: ${leg.from.name} to ${leg.to.name}
16238
- via route ${leg.route.type} ${leg.route.name},
16239
- departs at ${leg.departureTime.toString()}, arrives at ${leg.arrivalTime.toString()}`;
16240
- }
16241
- return `Leg ${index + 1}: Transfer from ${leg.from.name} to ${leg.to.name},
16242
- minimum transfer time: ${(_b = (_a = leg.minTransferTime) === null || _a === undefined ? undefined : _a.toString()) !== null && _b !== undefined ? _b : 'not specified'}`;
16243
- })
16244
- .join('\n');
16245
- }
16246
- }
16247
-
16248
- class Result {
16249
- constructor(query, earliestArrivals, earliestArrivalsPerRound, stopsIndex) {
16250
- this.query = query;
16251
- this.earliestArrivals = earliestArrivals;
16252
- this.earliestArrivalsPerRound = earliestArrivalsPerRound;
16253
- this.stopsIndex = stopsIndex;
16254
- }
16255
- /**
16256
- * Reconstructs the best route to a stop.
16257
- * (to any stop reachable in less time / transfers than the destination(s) of the query)
16258
- *
16259
- * @param to The destination stop. Defaults to the destination of the original query.
16260
- * @returns a route to the destination stop if it exists.
16261
- */
16262
- bestRoute(to) {
16263
- var _a, _b, _c;
16264
- const destinationList = Array.isArray(to) ? to : to ? [to] : this.query.to;
16265
- const destinations = destinationList.flatMap((destination) => this.stopsIndex.equivalentStops(destination));
16266
- let fastestDestination = undefined;
16267
- let fastestTime = undefined;
16268
- for (const destination of destinations) {
16269
- const arrivalTime = this.earliestArrivals.get(destination);
16270
- if (arrivalTime !== undefined) {
16271
- if (fastestTime === undefined ||
16272
- arrivalTime.time.toSeconds() < fastestTime.time.toSeconds()) {
16273
- fastestDestination = destination;
16274
- fastestTime = arrivalTime;
16275
- }
16276
- }
16277
- }
16278
- if (!fastestDestination || !fastestTime) {
16279
- return undefined;
16280
- }
16281
- const route = [];
16282
- let currentStop = fastestDestination;
16283
- let round = fastestTime.legNumber;
16284
- while (fastestTime.origin !== currentStop) {
16285
- const tripLeg = (_a = this.earliestArrivalsPerRound[round]) === null || _a === undefined ? undefined : _a.get(currentStop);
16286
- if (!(tripLeg === null || tripLeg === undefined ? undefined : tripLeg.leg)) {
16287
- throw new Error(`No leg found for a trip leg: start stop=${(_c = (_b = tripLeg === null || tripLeg === undefined ? undefined : tripLeg.leg) === null || _b === undefined ? undefined : _b.from.id) !== null && _c !== undefined ? _c : 'unknown'}, end stop=${currentStop}, round=${round}, origin=${fastestTime.origin}`);
16288
- }
16289
- route.unshift(tripLeg.leg);
16290
- currentStop = tripLeg.leg.from.id;
16291
- if ('route' in tripLeg.leg) {
16292
- round -= 1;
16293
- }
16294
- }
16295
- return new Route(route);
16296
- }
16297
- /**
16298
- * Returns the arrival time at any stop reachable in less time / transfers than the destination(s) of the query)
16299
- *
16300
- * @param stop The target stop for which to return the arrival time.
16301
- * @param maxTransfers The optional maximum number of transfers allowed.
16302
- * @returns The arrival time if the target stop is reachable, otherwise undefined.
16303
- */
16304
- arrivalAt(stop, maxTransfers) {
16305
- const equivalentStops = this.stopsIndex.equivalentStops(stop);
16306
- let earliestArrival = undefined;
16307
- const relevantArrivals = maxTransfers !== undefined
16308
- ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16309
- this.earliestArrivalsPerRound[maxTransfers - 1]
16310
- : this.earliestArrivals;
16311
- for (const equivalentStop of equivalentStops) {
16312
- const arrivalTime = relevantArrivals.get(equivalentStop);
16313
- if (arrivalTime !== undefined) {
16314
- if (earliestArrival === undefined ||
16315
- arrivalTime.time.toSeconds() < earliestArrival.time.toSeconds()) {
16316
- earliestArrival = arrivalTime;
16317
- }
16318
- }
16319
- }
16320
- return earliestArrival;
16321
- }
16322
- }
16323
-
16324
- const UNREACHED = Time.infinity();
16325
- class Router {
16326
- constructor(timetable, stopsIndex) {
16327
- this.timetable = timetable;
16328
- this.stopsIndex = stopsIndex;
16329
- }
16330
- /**
16331
- * Evaluates possible transfers for a given query on a transport
16332
- * network, updating the earliest arrivals at various stops and marking new
16333
- * stops that can be reached through these transfers.
16334
- */
16335
- considerTransfers(query, markedStops, arrivalsAtCurrentRound, earliestArrivals, round) {
16336
- var _a, _b, _c, _d;
16337
- const { options } = query;
16338
- const newlyMarkedStops = new Set();
16339
- for (const stop of markedStops) {
16340
- for (const transfer of this.timetable.getTransfers(stop)) {
16341
- let transferTime;
16342
- if (transfer.minTransferTime) {
16343
- transferTime = transfer.minTransferTime;
16344
- }
16345
- else if (transfer.type === 'IN_SEAT') {
16346
- transferTime = Duration.zero();
16347
- }
16348
- else {
16349
- transferTime = options.minTransferTime;
16350
- }
16351
- const arrivalAfterTransfer = arrivalsAtCurrentRound
16352
- .get(stop)
16353
- .time.plus(transferTime);
16354
- const originalArrival = (_b = (_a = arrivalsAtCurrentRound.get(transfer.destination)) === null || _a === undefined ? undefined : _a.time) !== null && _b !== undefined ? _b : UNREACHED;
16355
- if (arrivalAfterTransfer.toSeconds() < originalArrival.toSeconds()) {
16356
- const origin = (_d = (_c = arrivalsAtCurrentRound.get(stop)) === null || _c === undefined ? undefined : _c.origin) !== null && _d !== undefined ? _d : stop;
16357
- arrivalsAtCurrentRound.set(transfer.destination, {
16358
- time: arrivalAfterTransfer,
16359
- legNumber: round,
16360
- origin: origin,
16361
- leg: {
16362
- from: this.stopsIndex.findStopById(stop),
16363
- to: this.stopsIndex.findStopById(transfer.destination),
16364
- minTransferTime: transfer.minTransferTime,
16365
- },
16366
- });
16367
- earliestArrivals.set(transfer.destination, {
16368
- time: arrivalAfterTransfer,
16369
- legNumber: round,
16370
- origin: origin,
16371
- });
16372
- newlyMarkedStops.add(transfer.destination);
16373
- }
16374
- }
16375
- }
16376
- for (const newStop of newlyMarkedStops) {
16377
- markedStops.add(newStop);
16378
- }
16379
- }
16380
- /**
16381
- * The main Raptor algorithm implementation.
16382
- *
16383
- * @param query The query containing the main parameters for the routing.
16384
- * @returns A result object containing data structures allowing to reconstruct routes and .
16385
- */
16386
- route(query) {
16387
- var _a, _b, _c, _d, _e, _f, _g;
16388
- const { from, to, departureTime, options } = query;
16389
- // Consider children or siblings of the "from" stop as potential origins
16390
- const origins = this.stopsIndex.equivalentStops(from);
16391
- // Consider children or siblings of the "to" stop(s) as potential destinations
16392
- const destinations = to.flatMap((destination) => this.stopsIndex.equivalentStops(destination));
16393
- const earliestArrivals = new Map();
16394
- const earliestArrivalsWithoutAnyLeg = new Map();
16395
- const earliestArrivalsPerRound = [earliestArrivalsWithoutAnyLeg];
16396
- // Stops that have been improved at round k-1
16397
- const markedStops = new Set();
16398
- for (const originStop of origins) {
16399
- markedStops.add(originStop);
16400
- earliestArrivals.set(originStop, {
16401
- time: departureTime,
16402
- legNumber: 0,
16403
- origin: originStop,
16404
- });
16405
- earliestArrivalsWithoutAnyLeg.set(originStop, {
16406
- time: departureTime,
16407
- legNumber: 0,
16408
- origin: originStop,
16409
- });
16410
- }
16411
- // on the first round we need to first consider transfers to discover all possible route origins
16412
- this.considerTransfers(query, markedStops, earliestArrivalsWithoutAnyLeg, earliestArrivals, 0);
16413
- for (let round = 1; round <= options.maxTransfers + 1; round++) {
16414
- const arrivalsAtCurrentRound = new Map();
16415
- earliestArrivalsPerRound.push(arrivalsAtCurrentRound);
16416
- const arrivalsAtPreviousRound = earliestArrivalsPerRound[round - 1];
16417
- // Routes that contain at least one stop reached with at least round - 1 legs
16418
- // together with corresponding hop on stop index (earliest marked stop)
16419
- const reachableRoutes = this.timetable.findReachableRoutes(markedStops, options.transportModes);
16420
- markedStops.clear();
16421
- // for each route that can be reached with at least round - 1 trips
16422
- for (const [routeId, hopOnStop] of reachableRoutes.entries()) {
16423
- const route = this.timetable.getRoute(routeId);
16424
- let currentTrip = undefined;
16425
- const hopOnIndex = route.stopIndices.get(hopOnStop);
16426
- // for each stops in the route starting with the hop-on one
16427
- for (let i = hopOnIndex; i < route.stops.length; i++) {
16428
- const currentStop = route.stops[i];
16429
- const stopNumbers = route.stops.length;
16430
- if (currentTrip !== undefined) {
16431
- const currentStopTimes = route.stopTimes[currentTrip.trip * stopNumbers + i];
16432
- const earliestArrivalAtCurrentStop = (_b = (_a = earliestArrivals.get(currentStop)) === null || _a === undefined ? undefined : _a.time) !== null && _b !== undefined ? _b : UNREACHED;
16433
- let arrivalToImprove = earliestArrivalAtCurrentStop;
16434
- if (destinations.length > 0) {
16435
- const earliestArrivalsAtDestinations = [];
16436
- // if multiple destinations are specified, the target pruning
16437
- // should compare to the earliest arrival at any of them
16438
- for (const destinationStop of destinations) {
16439
- const earliestArrivalAtDestination = (_d = (_c = earliestArrivals.get(destinationStop)) === null || _c === undefined ? undefined : _c.time) !== null && _d !== undefined ? _d : UNREACHED;
16440
- earliestArrivalsAtDestinations.push(earliestArrivalAtDestination);
16441
- }
16442
- const earliestArrivalAtDestination = Time.min(...earliestArrivalsAtDestinations);
16443
- arrivalToImprove = Time.min(earliestArrivalAtCurrentStop, earliestArrivalAtDestination);
16444
- }
16445
- if (currentStopTimes.dropOffType !== 'NOT_AVAILABLE' &&
16446
- currentStopTimes.arrival.toSeconds() <
16447
- arrivalToImprove.toSeconds()) {
16448
- const bestHopOnStopIndex = route.stopIndices.get(currentTrip.bestHopOnStop);
16449
- const bestHopOnStopTimes = route.stopTimes[currentTrip.trip * stopNumbers + bestHopOnStopIndex];
16450
- arrivalsAtCurrentRound.set(currentStop, {
16451
- time: currentStopTimes.arrival,
16452
- legNumber: round,
16453
- origin: currentTrip.origin,
16454
- leg: {
16455
- from: this.stopsIndex.findStopById(currentTrip.bestHopOnStop),
16456
- to: this.stopsIndex.findStopById(currentStop),
16457
- departureTime: bestHopOnStopTimes.departure,
16458
- arrivalTime: currentStopTimes.arrival,
16459
- route: this.timetable.getServiceRoute(route.serviceRouteId),
16460
- },
16461
- });
16462
- earliestArrivals.set(currentStop, {
16463
- time: currentStopTimes.arrival,
16464
- legNumber: round,
16465
- origin: currentTrip.origin,
16466
- });
16467
- markedStops.add(currentStop);
16468
- }
16469
- }
16470
- // check if we can catch a previous trip at the current stop
16471
- // if there was no current trip, find the first one reachable
16472
- const earliestArrivalOnPreviousRound = (_e = arrivalsAtPreviousRound.get(currentStop)) === null || _e === undefined ? undefined : _e.time;
16473
- if (earliestArrivalOnPreviousRound !== undefined &&
16474
- (currentTrip === undefined ||
16475
- earliestArrivalOnPreviousRound.toSeconds() <=
16476
- route.stopTimes[currentTrip.trip * stopNumbers + i].departure.toSeconds())) {
16477
- const earliestTrip = this.timetable.findEarliestTrip(route, currentStop, currentTrip === null || currentTrip === undefined ? undefined : currentTrip.trip, earliestArrivalOnPreviousRound);
16478
- if (earliestTrip !== undefined) {
16479
- currentTrip = {
16480
- trip: earliestTrip,
16481
- // we need to keep track of the best hop-on stop to reconstruct the route at the end
16482
- bestHopOnStop: currentStop,
16483
- origin: (_g = (_f = arrivalsAtPreviousRound.get(currentStop)) === null || _f === undefined ? undefined : _f.origin) !== null && _g !== undefined ? _g : currentStop,
16484
- };
16485
- }
16486
- }
16487
- }
16488
- }
16489
- this.considerTransfers(query, markedStops, arrivalsAtCurrentRound, earliestArrivals, round);
16490
- if (markedStops.size === 0)
16491
- break;
16492
- }
16493
- return new Result(query, earliestArrivals, earliestArrivalsPerRound, this.stopsIndex);
16494
- }
16495
- }
16496
-
16497
16083
  exports.GtfsParser = GtfsParser;
16498
- exports.Plotter = Plotter;
16499
- exports.Query = Query;
16500
- exports.Result = Result;
16501
- exports.Route = Route;
16502
- exports.Router = Router;
16503
- exports.StopsIndex = StopsIndex;
16504
- exports.Time = Time;
16505
- exports.Timetable = Timetable;
16506
16084
  exports.chGtfsProfile = chGtfsProfile;
16507
- //# sourceMappingURL=bundle.cjs.js.map
16085
+ //# sourceMappingURL=parser.cjs.js.map