minotor 7.0.2 → 9.0.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 (60) hide show
  1. package/.cspell.json +11 -1
  2. package/CHANGELOG.md +8 -3
  3. package/README.md +26 -24
  4. package/dist/cli.mjs +1786 -791
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/gtfs/transfers.d.ts +29 -5
  7. package/dist/gtfs/trips.d.ts +10 -5
  8. package/dist/parser.cjs.js +972 -525
  9. package/dist/parser.cjs.js.map +1 -1
  10. package/dist/parser.esm.js +972 -525
  11. package/dist/parser.esm.js.map +1 -1
  12. package/dist/router.cjs.js +1 -1
  13. package/dist/router.cjs.js.map +1 -1
  14. package/dist/router.d.ts +2 -2
  15. package/dist/router.esm.js +1 -1
  16. package/dist/router.esm.js.map +1 -1
  17. package/dist/router.umd.js +1 -1
  18. package/dist/router.umd.js.map +1 -1
  19. package/dist/routing/__tests__/plotter.test.d.ts +1 -0
  20. package/dist/routing/plotter.d.ts +42 -3
  21. package/dist/routing/result.d.ts +23 -7
  22. package/dist/routing/route.d.ts +2 -0
  23. package/dist/routing/router.d.ts +78 -19
  24. package/dist/timetable/__tests__/tripBoardingId.test.d.ts +1 -0
  25. package/dist/timetable/io.d.ts +4 -2
  26. package/dist/timetable/proto/timetable.d.ts +15 -1
  27. package/dist/timetable/route.d.ts +48 -23
  28. package/dist/timetable/timetable.d.ts +24 -7
  29. package/dist/timetable/tripBoardingId.d.ts +34 -0
  30. package/package.json +1 -1
  31. package/src/__e2e__/router.test.ts +114 -105
  32. package/src/__e2e__/timetable/stops.bin +2 -2
  33. package/src/__e2e__/timetable/timetable.bin +2 -2
  34. package/src/cli/repl.ts +245 -1
  35. package/src/gtfs/__tests__/parser.test.ts +19 -4
  36. package/src/gtfs/__tests__/transfers.test.ts +773 -37
  37. package/src/gtfs/__tests__/trips.test.ts +308 -27
  38. package/src/gtfs/parser.ts +36 -6
  39. package/src/gtfs/transfers.ts +193 -19
  40. package/src/gtfs/trips.ts +58 -21
  41. package/src/router.ts +2 -2
  42. package/src/routing/__tests__/plotter.test.ts +230 -0
  43. package/src/routing/__tests__/result.test.ts +486 -125
  44. package/src/routing/__tests__/route.test.ts +7 -3
  45. package/src/routing/__tests__/router.test.ts +380 -172
  46. package/src/routing/plotter.ts +279 -48
  47. package/src/routing/result.ts +114 -34
  48. package/src/routing/route.ts +0 -3
  49. package/src/routing/router.ts +344 -211
  50. package/src/timetable/__tests__/io.test.ts +34 -1
  51. package/src/timetable/__tests__/route.test.ts +74 -81
  52. package/src/timetable/__tests__/timetable.test.ts +232 -61
  53. package/src/timetable/__tests__/tripBoardingId.test.ts +57 -0
  54. package/src/timetable/io.ts +72 -10
  55. package/src/timetable/proto/timetable.proto +16 -2
  56. package/src/timetable/proto/timetable.ts +256 -22
  57. package/src/timetable/route.ts +174 -58
  58. package/src/timetable/timetable.ts +66 -16
  59. package/src/timetable/tripBoardingId.ts +94 -0
  60. package/tsconfig.json +2 -2
@@ -1,14 +1,20 @@
1
1
  import { SourceStopId, StopId } from '../stops/stops.js';
2
- import { ServiceRouteId, Transfer } from '../timetable/timetable.js';
2
+ import { ServiceRouteId, Timetable, Transfer, TripContinuations } from '../timetable/timetable.js';
3
3
  import { GtfsStopsMap } from './stops.js';
4
- import { TripId } from './trips.js';
4
+ import { GtfsTripId, TripsMapping } from './trips.js';
5
5
  export type GtfsTransferType = 0 | 1 | 2 | 3 | 4 | 5;
6
6
  export type TransfersMap = Map<StopId, Transfer[]>;
7
+ export type GtfsTripContinuation = {
8
+ fromStop: StopId;
9
+ fromTrip: GtfsTripId;
10
+ toStop: StopId;
11
+ toTrip: GtfsTripId;
12
+ };
7
13
  export type TransferEntry = {
8
14
  from_stop_id?: SourceStopId;
9
15
  to_stop_id?: SourceStopId;
10
- from_trip_id?: TripId;
11
- to_trip_id?: TripId;
16
+ from_trip_id?: GtfsTripId;
17
+ to_trip_id?: GtfsTripId;
12
18
  from_route_id?: ServiceRouteId;
13
19
  to_route_id?: ServiceRouteId;
14
20
  transfer_type: GtfsTransferType;
@@ -20,4 +26,22 @@ export type TransferEntry = {
20
26
  * @param stopsStream The readable stream containing the stops data.
21
27
  * @return A mapping of stop IDs to corresponding stop details.
22
28
  */
23
- export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap) => Promise<TransfersMap>;
29
+ export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap) => Promise<{
30
+ transfers: TransfersMap;
31
+ tripContinuations: GtfsTripContinuation[];
32
+ }>;
33
+ /**
34
+ * Builds trip continuations map from GTFS trip continuation data.
35
+ *
36
+ * This function processes GTFS in-seat transfer data and creates a mapping
37
+ * from trip boarding IDs to continuation boarding information. It disambiguates
38
+ * stop indices when routes have multiple stops with the same ID by finding
39
+ * the most coherent transfer timing.
40
+ *
41
+ * @param tripsMapping Mapping from GTFS trip IDs to internal trip representations
42
+ * @param tripContinuations Array of GTFS trip continuation data from transfers.txt
43
+ * @param timetable The timetable containing route and timing information
44
+ * @param activeStopIds Set of stop IDs that are active/enabled in the system
45
+ * @returns A map from trip boarding IDs to arrays of continuation boarding options
46
+ */
47
+ export declare const buildTripContinuations: (tripsMapping: TripsMapping, tripContinuations: GtfsTripContinuation[], timetable: Timetable, activeStopIds: Set<StopId>) => TripContinuations;
@@ -1,12 +1,16 @@
1
1
  import { StopId } from '../stops/stops.js';
2
- import { Route } from '../timetable/route.js';
2
+ import { Route, RouteId, TripRouteIndex } from '../timetable/route.js';
3
3
  import { ServiceRoute, ServiceRouteId, StopAdjacency } from '../timetable/timetable.js';
4
4
  import { GtfsRouteId, GtfsRoutesMap } from './routes.js';
5
5
  import { ServiceIds } from './services.js';
6
6
  import { GtfsStopsMap } from './stops.js';
7
7
  import { TransfersMap } from './transfers.js';
8
- export type TripId = string;
9
- export type TripIdsMap = Map<TripId, GtfsRouteId>;
8
+ export type GtfsTripId = string;
9
+ export type GtfsTripIdsMap = Map<GtfsTripId, GtfsRouteId>;
10
+ export type TripsMapping = Map<GtfsTripId, {
11
+ routeId: RouteId;
12
+ tripRouteIndex: TripRouteIndex;
13
+ }>;
10
14
  export type GtfsPickupDropOffType = '' | '0' | '1' | '2' | '3';
11
15
  export type SerializedPickUpDropOffType = 0 | 1 | 2 | 3;
12
16
  /**
@@ -22,7 +26,7 @@ export declare const encodePickUpDropOffTypes: (pickUpTypes: SerializedPickUpDro
22
26
  * @param serviceRoutes A mapping of route IDs to route details.
23
27
  * @returns A mapping of trip IDs to corresponding route IDs.
24
28
  */
25
- export declare const parseTrips: (tripsStream: NodeJS.ReadableStream, serviceIds: ServiceIds, validGtfsRoutes: GtfsRoutesMap) => Promise<TripIdsMap>;
29
+ export declare const parseTrips: (tripsStream: NodeJS.ReadableStream, serviceIds: ServiceIds, validGtfsRoutes: GtfsRoutesMap) => Promise<GtfsTripIdsMap>;
26
30
  export declare const buildStopsAdjacencyStructure: (serviceRoutes: ServiceRoute[], routes: Route[], transfersMap: TransfersMap, nbStops: number, activeStops: Set<StopId>) => StopAdjacency[];
27
31
  /**
28
32
  * Parses the stop_times.txt data from a GTFS feed.
@@ -33,7 +37,8 @@ export declare const buildStopsAdjacencyStructure: (serviceRoutes: ServiceRoute[
33
37
  * @param activeStopIds A set of valid stop IDs.
34
38
  * @returns A mapping of route IDs to route details. The routes returned correspond to the set of trips from GTFS that share the same stop list.
35
39
  */
36
- export declare const parseStopTimes: (stopTimesStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap, activeTripIds: TripIdsMap, activeStopIds: Set<StopId>) => Promise<{
40
+ export declare const parseStopTimes: (stopTimesStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap, activeTripIds: GtfsTripIdsMap, activeStopIds: Set<StopId>) => Promise<{
37
41
  routes: Route[];
38
42
  serviceRoutesMap: Map<GtfsRouteId, ServiceRouteId>;
43
+ tripsMapping: TripsMapping;
39
44
  }>;