minotor 1.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 (131) hide show
  1. package/.cspell.json +43 -0
  2. package/.czrc +3 -0
  3. package/.editorconfig +10 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
  5. package/.github/ISSUE_TEMPLATE/config.yml +5 -0
  6. package/.github/ISSUE_TEMPLATE/feature_request.md +29 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +4 -0
  8. package/.github/workflows/minotor.yml +85 -0
  9. package/.prettierrc +7 -0
  10. package/.releaserc.json +27 -0
  11. package/CHANGELOG.md +6 -0
  12. package/LICENSE +21 -0
  13. package/README.md +166 -0
  14. package/dist/bundle.cjs.js +16507 -0
  15. package/dist/bundle.cjs.js.map +1 -0
  16. package/dist/bundle.esm.js +16496 -0
  17. package/dist/bundle.esm.js.map +1 -0
  18. package/dist/bundle.umd.js +2 -0
  19. package/dist/bundle.umd.js.map +1 -0
  20. package/dist/cli/__tests__/minotor.test.d.ts +1 -0
  21. package/dist/cli/minotor.d.ts +5 -0
  22. package/dist/cli/repl.d.ts +1 -0
  23. package/dist/cli/utils.d.ts +3 -0
  24. package/dist/cli.mjs +20504 -0
  25. package/dist/cli.mjs.map +1 -0
  26. package/dist/gtfs/__tests__/parser.test.d.ts +1 -0
  27. package/dist/gtfs/__tests__/routes.test.d.ts +1 -0
  28. package/dist/gtfs/__tests__/services.test.d.ts +1 -0
  29. package/dist/gtfs/__tests__/stops.test.d.ts +1 -0
  30. package/dist/gtfs/__tests__/time.test.d.ts +1 -0
  31. package/dist/gtfs/__tests__/transfers.test.d.ts +1 -0
  32. package/dist/gtfs/__tests__/trips.test.d.ts +1 -0
  33. package/dist/gtfs/__tests__/utils.test.d.ts +1 -0
  34. package/dist/gtfs/parser.d.ts +34 -0
  35. package/dist/gtfs/profiles/__tests__/ch.test.d.ts +1 -0
  36. package/dist/gtfs/profiles/ch.d.ts +2 -0
  37. package/dist/gtfs/profiles/standard.d.ts +2 -0
  38. package/dist/gtfs/routes.d.ts +11 -0
  39. package/dist/gtfs/services.d.ts +19 -0
  40. package/dist/gtfs/stops.d.ts +20 -0
  41. package/dist/gtfs/time.d.ts +17 -0
  42. package/dist/gtfs/transfers.d.ts +22 -0
  43. package/dist/gtfs/trips.d.ts +26 -0
  44. package/dist/gtfs/utils.d.ts +21 -0
  45. package/dist/index.d.ts +11 -0
  46. package/dist/routing/__tests__/router.test.d.ts +1 -0
  47. package/dist/routing/plotter.d.ts +11 -0
  48. package/dist/routing/query.d.ts +35 -0
  49. package/dist/routing/result.d.ts +28 -0
  50. package/dist/routing/route.d.ts +25 -0
  51. package/dist/routing/router.d.ts +33 -0
  52. package/dist/stops/__tests__/io.test.d.ts +1 -0
  53. package/dist/stops/__tests__/stopFinder.test.d.ts +1 -0
  54. package/dist/stops/i18n.d.ts +10 -0
  55. package/dist/stops/io.d.ts +4 -0
  56. package/dist/stops/proto/stops.d.ts +53 -0
  57. package/dist/stops/stops.d.ts +16 -0
  58. package/dist/stops/stopsIndex.d.ts +52 -0
  59. package/dist/timetable/__tests__/io.test.d.ts +1 -0
  60. package/dist/timetable/__tests__/timetable.test.d.ts +1 -0
  61. package/dist/timetable/duration.d.ts +51 -0
  62. package/dist/timetable/io.d.ts +8 -0
  63. package/dist/timetable/proto/timetable.d.ts +122 -0
  64. package/dist/timetable/time.d.ts +98 -0
  65. package/dist/timetable/timetable.d.ts +82 -0
  66. package/dist/umdIndex.d.ts +9 -0
  67. package/eslint.config.mjs +52 -0
  68. package/package.json +109 -0
  69. package/rollup.config.js +44 -0
  70. package/src/cli/__tests__/minotor.test.ts +23 -0
  71. package/src/cli/minotor.ts +112 -0
  72. package/src/cli/repl.ts +200 -0
  73. package/src/cli/utils.ts +36 -0
  74. package/src/gtfs/__tests__/parser.test.ts +591 -0
  75. package/src/gtfs/__tests__/resources/sample-feed/agency.txt +2 -0
  76. package/src/gtfs/__tests__/resources/sample-feed/calendar.txt +3 -0
  77. package/src/gtfs/__tests__/resources/sample-feed/calendar_dates.txt +2 -0
  78. package/src/gtfs/__tests__/resources/sample-feed/fare_attributes.txt +3 -0
  79. package/src/gtfs/__tests__/resources/sample-feed/fare_rules.txt +5 -0
  80. package/src/gtfs/__tests__/resources/sample-feed/frequencies.txt +12 -0
  81. package/src/gtfs/__tests__/resources/sample-feed/routes.txt +6 -0
  82. package/src/gtfs/__tests__/resources/sample-feed/sample-feed.zip +0 -0
  83. package/src/gtfs/__tests__/resources/sample-feed/shapes.txt +1 -0
  84. package/src/gtfs/__tests__/resources/sample-feed/stop_times.txt +34 -0
  85. package/src/gtfs/__tests__/resources/sample-feed/stops.txt +10 -0
  86. package/src/gtfs/__tests__/resources/sample-feed/trips.txt +13 -0
  87. package/src/gtfs/__tests__/resources/sample-feed.zip +0 -0
  88. package/src/gtfs/__tests__/routes.test.ts +63 -0
  89. package/src/gtfs/__tests__/services.test.ts +209 -0
  90. package/src/gtfs/__tests__/stops.test.ts +177 -0
  91. package/src/gtfs/__tests__/time.test.ts +27 -0
  92. package/src/gtfs/__tests__/transfers.test.ts +117 -0
  93. package/src/gtfs/__tests__/trips.test.ts +463 -0
  94. package/src/gtfs/__tests__/utils.test.ts +13 -0
  95. package/src/gtfs/parser.ts +154 -0
  96. package/src/gtfs/profiles/__tests__/ch.test.ts +43 -0
  97. package/src/gtfs/profiles/ch.ts +70 -0
  98. package/src/gtfs/profiles/standard.ts +39 -0
  99. package/src/gtfs/routes.ts +48 -0
  100. package/src/gtfs/services.ts +98 -0
  101. package/src/gtfs/stops.ts +112 -0
  102. package/src/gtfs/time.ts +33 -0
  103. package/src/gtfs/transfers.ts +102 -0
  104. package/src/gtfs/trips.ts +228 -0
  105. package/src/gtfs/utils.ts +42 -0
  106. package/src/index.ts +28 -0
  107. package/src/routing/__tests__/router.test.ts +760 -0
  108. package/src/routing/plotter.ts +70 -0
  109. package/src/routing/query.ts +74 -0
  110. package/src/routing/result.ts +108 -0
  111. package/src/routing/route.ts +94 -0
  112. package/src/routing/router.ts +262 -0
  113. package/src/stops/__tests__/io.test.ts +43 -0
  114. package/src/stops/__tests__/stopFinder.test.ts +185 -0
  115. package/src/stops/i18n.ts +40 -0
  116. package/src/stops/io.ts +94 -0
  117. package/src/stops/proto/stops.proto +26 -0
  118. package/src/stops/proto/stops.ts +445 -0
  119. package/src/stops/stops.ts +24 -0
  120. package/src/stops/stopsIndex.ts +151 -0
  121. package/src/timetable/__tests__/io.test.ts +175 -0
  122. package/src/timetable/__tests__/timetable.test.ts +180 -0
  123. package/src/timetable/duration.ts +85 -0
  124. package/src/timetable/io.ts +265 -0
  125. package/src/timetable/proto/timetable.proto +76 -0
  126. package/src/timetable/proto/timetable.ts +1304 -0
  127. package/src/timetable/time.ts +192 -0
  128. package/src/timetable/timetable.ts +286 -0
  129. package/src/umdIndex.ts +14 -0
  130. package/tsconfig.build.json +4 -0
  131. package/tsconfig.json +21 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { Platform } from '../stops/stops.js';
2
+ import { StopsIndex } from '../stops/stopsIndex.js';
3
+ import { RouteType, Timetable } from '../timetable/timetable.js';
4
+ import { StopEntry } from './stops.js';
5
+ import { Maybe } from './utils.js';
6
+ export type GtfsProfile = {
7
+ routeTypeParser: (routeType: number) => Maybe<RouteType>;
8
+ platformParser?: (stopEntry: StopEntry) => Maybe<Platform>;
9
+ };
10
+ export declare class GtfsParser {
11
+ private path;
12
+ private profile;
13
+ constructor(path: string, profile?: GtfsProfile);
14
+ /**
15
+ * Parses a GTFS feed to extract all the data relevant to a given day in a transit-planner friendly format.
16
+ *
17
+ * @param date The active date.
18
+ * @param gtfsPath A path to the zipped GTFS feed.
19
+ * @param gtfsProfile The GTFS profile configuration.
20
+ * @returns An object containing the timetable and stops map.
21
+ */
22
+ parse(date: Date): Promise<{
23
+ timetable: Timetable;
24
+ stopsIndex: StopsIndex;
25
+ }>;
26
+ /**
27
+ * Parses a GTFS feed to extract all stops.
28
+ *
29
+ * @param gtfsPath A path the zipped GTFS feed.
30
+ * @param gtfsProfile The GTFS profile configuration.
31
+ * @returns An object containing the timetable and stops map.
32
+ */
33
+ parseStops(): Promise<StopsIndex>;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { GtfsProfile } from '../parser.js';
2
+ export declare const chGtfsProfile: GtfsProfile;
@@ -0,0 +1,2 @@
1
+ import { GtfsProfile } from '../parser.js';
2
+ export declare const standardProfile: GtfsProfile;
@@ -0,0 +1,11 @@
1
+ import { ServiceRoutesMap } from '../timetable/timetable.js';
2
+ import { GtfsProfile } from './parser.js';
3
+ export type GtfsRouteType = number;
4
+ /**
5
+ * Parses a GTFS routes.txt file and returns a map of all the valid routes.
6
+ *
7
+ * @param routesStream A readable stream for the GTFS routes.txt file.
8
+ * @param profile A configuration object defining the specificities of the GTFS feed.
9
+ * @returns A map of all the valid routes.
10
+ */
11
+ export declare const parseRoutes: (routesStream: NodeJS.ReadableStream, profile?: GtfsProfile) => Promise<ServiceRoutesMap>;
@@ -0,0 +1,19 @@
1
+ import { DateTime } from 'luxon';
2
+ export type ServiceId = string;
3
+ export type ServiceIds = Set<ServiceId>;
4
+ /**
5
+ * Parses a GTFS calendar.txt file and finds the service_ids of a given date.
6
+ *
7
+ * @param serviceIds A map of the active service ids (will be populated with active service_ids).
8
+ * @param date The active date.
9
+ * @param calendarStream A readable stream for the GTFS calendar.txt file.
10
+ */
11
+ export declare const parseCalendar: (calendarStream: NodeJS.ReadableStream, serviceIds: ServiceIds, date: DateTime) => Promise<void>;
12
+ /**
13
+ * Parses a gtfs calendar_dates.txt file and finds the service ids valid at a given date.
14
+ *
15
+ * @param serviceIds A map of the active service ids (will be populated and filtered).
16
+ * @param date The active date, in the format "YYYYMMDD".
17
+ * @param calendarDatesStream A readable stream for the GTFS calendar_dates.txt file.
18
+ */
19
+ export declare const parseCalendarDates: (calendarDatesStream: NodeJS.ReadableStream, serviceIds: ServiceIds, date: DateTime) => Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { Latitude, Longitude, Platform, StopId, StopsMap } from '../stops/stops.js';
2
+ import { Maybe } from './utils.js';
3
+ export type StopIds = Set<StopId>;
4
+ export type GtfsLocationType = 0 | 1 | 2 | 3 | 4;
5
+ export type StopEntry = {
6
+ stop_id: StopId;
7
+ stop_name: string;
8
+ stop_lat?: Latitude;
9
+ stop_lon?: Longitude;
10
+ location_type?: GtfsLocationType;
11
+ parent_station?: StopId;
12
+ platform_code?: Platform;
13
+ };
14
+ /**
15
+ * Parses the stops.txt file from a GTFS feed.
16
+ *
17
+ * @param stopsStream The readable stream containing the stops data.
18
+ * @return A mapping of stop IDs to corresponding stop details.
19
+ */
20
+ export declare const parseStops: (stopsStream: NodeJS.ReadableStream, platformParser?: (stopEntry: StopEntry) => Maybe<Platform>, validStops?: StopIds) => Promise<StopsMap>;
@@ -0,0 +1,17 @@
1
+ import { DateTime } from 'luxon';
2
+ import { Time } from '../timetable/time.js';
3
+ export type GtfsDate = number;
4
+ export type GtfsTime = string;
5
+ export declare const toGtfsDate: (date: DateTime) => GtfsDate;
6
+ /**
7
+ * Converts a time string in the format 'HH:mm:ss' to a Time object
8
+ * (number of seconds since midnight).
9
+ *
10
+ * This method splits the input time string into hours, minutes, and seconds,
11
+ * and then calculates the total number of seconds.
12
+ *
13
+ * @param time - A string representing the time in 'HH:mm:ss' format.
14
+ * @returns The GTFS time as the number of seconds since midnight.
15
+ * @throws An error if the input time string is not in the correct format.
16
+ */
17
+ export declare const toTime: (time: GtfsTime) => Time;
@@ -0,0 +1,22 @@
1
+ import { StopId } from '../stops/stops.js';
2
+ import { ServiceRouteId, Transfer } from '../timetable/timetable.js';
3
+ import { TripId } from './trips.js';
4
+ export type GtfsTransferType = 0 | 1 | 2 | 3 | 4 | 5;
5
+ export type TransfersMap = Map<StopId, Transfer[]>;
6
+ export type TransferEntry = {
7
+ from_stop_id?: StopId;
8
+ to_stop_id?: StopId;
9
+ from_trip_id?: TripId;
10
+ to_trip_id?: TripId;
11
+ from_route_id?: ServiceRouteId;
12
+ to_route_id?: ServiceRouteId;
13
+ transfer_type: GtfsTransferType;
14
+ min_transfer_time?: number;
15
+ };
16
+ /**
17
+ * Parses the transfers.txt file from a GTFS feed.
18
+ *
19
+ * @param stopsStream The readable stream containing the stops data.
20
+ * @return A mapping of stop IDs to corresponding stop details.
21
+ */
22
+ export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream) => Promise<TransfersMap>;
@@ -0,0 +1,26 @@
1
+ import { RoutesAdjacency, ServiceRouteId, ServiceRoutesMap, StopsAdjacency } from '../timetable/timetable.js';
2
+ import { ServiceIds } from './services.js';
3
+ import { StopIds } from './stops.js';
4
+ import { TransfersMap } from './transfers.js';
5
+ export type TripId = string;
6
+ export type TripIdsMap = Map<TripId, ServiceRouteId>;
7
+ export type GtfsPickupDropOffType = '' | 0 | 1 | 2 | 3;
8
+ /**
9
+ * Parses the trips.txt file from a GTFS feed
10
+ *
11
+ * @param tripsStream The readable stream containing the trips data.
12
+ * @param serviceIds A mapping of service IDs to corresponding route IDs.
13
+ * @param routeIds A mapping of route IDs to route details.
14
+ * @returns A mapping of trip IDs to corresponding route IDs.
15
+ */
16
+ export declare const parseTrips: (tripsStream: NodeJS.ReadableStream, serviceIds: ServiceIds, routeIds: ServiceRoutesMap) => Promise<TripIdsMap>;
17
+ export declare const buildStopsAdjacencyStructure: (validStops: StopIds, routes: RoutesAdjacency, transfersMap: TransfersMap) => StopsAdjacency;
18
+ /**
19
+ * Parses the stop_times.txt data from a GTFS feed.
20
+ *
21
+ * @param stopTimesStream The readable stream containing the stop times data.
22
+ * @param validTripIds A map of valid trip IDs to corresponding route IDs.
23
+ * @param validStopIds A map of valid stop IDs.
24
+ * @returns A mapping of route IDs to route details. The routes return corresponds to the set of trips from GTFS that share the same stop list.
25
+ */
26
+ export declare const parseStopTimes: (stopTimesStream: NodeJS.ReadableStream, validTripIds: TripIdsMap, validStopIds: StopIds) => Promise<RoutesAdjacency>;
@@ -0,0 +1,21 @@
1
+ import { Parser } from 'csv-parse';
2
+ export type Maybe<T> = T | undefined;
3
+ /**
4
+ * Generates a simple hash from a string.
5
+ *
6
+ * This function computes a hash for a given string by iterating over each
7
+ * character and applying bitwise operations to accumulate a hash value.
8
+ * The final hash is then converted to a base-36 string and padded to
9
+ * ensure a minimum length of 6 characters.
10
+ *
11
+ * @param str - The input string to hash.
12
+ * @returns A hashed string representation of the input.
13
+ */
14
+ export declare const hash: (str: string) => string;
15
+ /**
16
+ * Parses a CSV stream with a sensible configuration for GTFS feeds.
17
+ *
18
+ * @param stream The CSV stream.
19
+ * @returns A parser from the csv-parse library.
20
+ */
21
+ export declare const parseCsv: (stream: NodeJS.ReadableStream) => Parser;
@@ -0,0 +1,11 @@
1
+ import { GtfsParser, GtfsProfile } from './gtfs/parser.js';
2
+ import { chGtfsProfile } from './gtfs/profiles/ch.js';
3
+ import { Plotter } from './routing/plotter.js';
4
+ import { Query } from './routing/query.js';
5
+ import { Result } from './routing/result.js';
6
+ import { Route } from './routing/route.js';
7
+ import { Router } from './routing/router.js';
8
+ import { StopsIndex } from './stops/stopsIndex.js';
9
+ import { Time } from './timetable/time.js';
10
+ import { Timetable } from './timetable/timetable.js';
11
+ export { chGtfsProfile, GtfsParser, GtfsProfile, Plotter, Query, Result, Route, Router, StopsIndex, Time, Timetable, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Result } from './result.js';
2
+ export declare class Plotter {
3
+ private result;
4
+ constructor(result: Result);
5
+ /**
6
+ * Plots the path three as a DOT for debugging purposes.
7
+ *
8
+ * @returns A string representing the DOT graph of the path tree.
9
+ */
10
+ plotDotGraph(): string;
11
+ }
@@ -0,0 +1,35 @@
1
+ import { StopId } from '../stops/stops.js';
2
+ import { Duration } from '../timetable/duration.js';
3
+ import { Time } from '../timetable/time.js';
4
+ import { RouteType } from '../timetable/timetable.js';
5
+ export declare class Query {
6
+ from: StopId;
7
+ to: StopId[];
8
+ departureTime: Time;
9
+ lastDepartureTime?: Time;
10
+ options: {
11
+ maxTransfers: number;
12
+ minTransferTime: Duration;
13
+ transportModes: RouteType[];
14
+ };
15
+ constructor(builder: typeof Query.Builder.prototype);
16
+ static Builder: {
17
+ new (): {
18
+ fromValue: StopId;
19
+ toValue: StopId[];
20
+ departureTimeValue: Time;
21
+ optionsValue: {
22
+ maxTransfers: number;
23
+ minTransferTime: Duration;
24
+ transportModes: RouteType[];
25
+ };
26
+ from(from: StopId): /*elided*/ any;
27
+ to(to: StopId | StopId[]): /*elided*/ any;
28
+ departureTime(departureTime: Time): /*elided*/ any;
29
+ maxTransfers(maxTransfers: number): /*elided*/ any;
30
+ minTransferTime(minTransferTime: Duration): /*elided*/ any;
31
+ transportModes(transportModes: RouteType[]): /*elided*/ any;
32
+ build(): Query;
33
+ };
34
+ };
35
+ }
@@ -0,0 +1,28 @@
1
+ import { StopId } from '../stops/stops.js';
2
+ import { StopsIndex } from '../umdIndex.js';
3
+ import { Query } from './query.js';
4
+ import { Route } from './route.js';
5
+ import { ReachingTime, TripLeg } from './router.js';
6
+ export declare class Result {
7
+ private readonly query;
8
+ private readonly earliestArrivals;
9
+ readonly earliestArrivalsPerRound: Map<StopId, TripLeg>[];
10
+ private readonly stopsIndex;
11
+ constructor(query: Query, earliestArrivals: Map<StopId, ReachingTime>, earliestArrivalsPerRound: Map<StopId, TripLeg>[], stopsIndex: StopsIndex);
12
+ /**
13
+ * Reconstructs the best route to a stop.
14
+ * (to any stop reachable in less time / transfers than the destination(s) of the query)
15
+ *
16
+ * @param to The destination stop. Defaults to the destination of the original query.
17
+ * @returns a route to the destination stop if it exists.
18
+ */
19
+ bestRoute(to?: StopId | StopId[]): Route | undefined;
20
+ /**
21
+ * Returns the arrival time at any stop reachable in less time / transfers than the destination(s) of the query)
22
+ *
23
+ * @param stop The target stop for which to return the arrival time.
24
+ * @param maxTransfers The optional maximum number of transfers allowed.
25
+ * @returns The arrival time if the target stop is reachable, otherwise undefined.
26
+ */
27
+ arrivalAt(stop: StopId, maxTransfers?: number): ReachingTime | undefined;
28
+ }
@@ -0,0 +1,25 @@
1
+ import { Stop } from '../stops/stops.js';
2
+ import { Duration } from '../timetable/duration.js';
3
+ import { Time } from '../timetable/time.js';
4
+ import { ServiceRoute } from '../timetable/timetable.js';
5
+ export type BaseLeg = {
6
+ from: Stop;
7
+ to: Stop;
8
+ };
9
+ export type Transfer = BaseLeg & {
10
+ minTransferTime?: Duration;
11
+ };
12
+ export type VehicleLeg = BaseLeg & {
13
+ route: ServiceRoute;
14
+ departureTime: Time;
15
+ arrivalTime: Time;
16
+ };
17
+ export type Leg = Transfer | VehicleLeg;
18
+ export declare class Route {
19
+ legs: Leg[];
20
+ constructor(legs: Leg[]);
21
+ departureTime(): Time;
22
+ arrivalTime(): Time;
23
+ totalDuration(): Duration;
24
+ print(): string;
25
+ }
@@ -0,0 +1,33 @@
1
+ import { StopId } from '../stops/stops.js';
2
+ import { Time } from '../timetable/time.js';
3
+ import { Timetable } from '../timetable/timetable.js';
4
+ import { StopsIndex } from '../umdIndex.js';
5
+ import { Query } from './query.js';
6
+ import { Result } from './result.js';
7
+ import { Leg } from './route.js';
8
+ export type TripLeg = ReachingTime & {
9
+ leg?: Leg;
10
+ };
11
+ export type ReachingTime = {
12
+ time: Time;
13
+ legNumber: number;
14
+ origin: StopId;
15
+ };
16
+ export declare class Router {
17
+ private readonly timetable;
18
+ private readonly stopsIndex;
19
+ constructor(timetable: Timetable, stopsIndex: StopsIndex);
20
+ /**
21
+ * Evaluates possible transfers for a given query on a transport
22
+ * network, updating the earliest arrivals at various stops and marking new
23
+ * stops that can be reached through these transfers.
24
+ */
25
+ private considerTransfers;
26
+ /**
27
+ * The main Raptor algorithm implementation.
28
+ *
29
+ * @param query The query containing the main parameters for the routing.
30
+ * @returns A result object containing data structures allowing to reconstruct routes and .
31
+ */
32
+ route(query: Query): Result;
33
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Generates a list of accent variants for a given term.
3
+ *
4
+ * This function takes a term and generates a list of alternative spellings
5
+ * by replacing characters with their accented variants and vice versa.
6
+ *
7
+ * @param term - The input term for which to generate accent variants.
8
+ * @returns An array of strings containing the original term and its accent variants.
9
+ */
10
+ export declare const generateAccentVariants: (term: string) => string[];
@@ -0,0 +1,4 @@
1
+ import { StopsMap as ProtoStopsMap } from './proto/stops.js';
2
+ import { StopsMap } from './stops.js';
3
+ export declare const serializeStopsMap: (stopsMap: StopsMap) => ProtoStopsMap;
4
+ export declare const deserializeStopsMap: (protoStopsMap: ProtoStopsMap) => StopsMap;
@@ -0,0 +1,53 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ export declare const protobufPackage = "minotor.stops";
3
+ export declare enum LocationType {
4
+ SIMPLE_STOP_OR_PLATFORM = 0,
5
+ STATION = 1,
6
+ ENTRANCE_EXIT = 2,
7
+ GENERIC_NODE = 3,
8
+ BOARDING_AREA = 4,
9
+ UNRECOGNIZED = -1
10
+ }
11
+ export declare function locationTypeFromJSON(object: any): LocationType;
12
+ export declare function locationTypeToJSON(object: LocationType): string;
13
+ export interface Stop {
14
+ name: string;
15
+ lat?: number | undefined;
16
+ lon?: number | undefined;
17
+ children: string[];
18
+ parent?: string | undefined;
19
+ locationType: LocationType;
20
+ platform?: string | undefined;
21
+ }
22
+ export interface StopsMap {
23
+ version: string;
24
+ stops: {
25
+ [key: string]: Stop;
26
+ };
27
+ }
28
+ export interface StopsMap_StopsEntry {
29
+ key: string;
30
+ value: Stop | undefined;
31
+ }
32
+ export declare const Stop: MessageFns<Stop>;
33
+ export declare const StopsMap: MessageFns<StopsMap>;
34
+ export declare const StopsMap_StopsEntry: MessageFns<StopsMap_StopsEntry>;
35
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
36
+ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
37
+ [K in keyof T]?: DeepPartial<T[K]>;
38
+ } : Partial<T>;
39
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
40
+ export type Exact<P, I extends P> = P extends Builtin ? P : P & {
41
+ [K in keyof P]: Exact<P[K], I[K]>;
42
+ } & {
43
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
44
+ };
45
+ export interface MessageFns<T> {
46
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
47
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
48
+ fromJSON(object: any): T;
49
+ toJSON(message: T): unknown;
50
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
51
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
52
+ }
53
+ export {};
@@ -0,0 +1,16 @@
1
+ export type StopId = string;
2
+ export type Platform = string;
3
+ export type Latitude = number;
4
+ export type Longitude = number;
5
+ export type LocationType = 'SIMPLE_STOP_OR_PLATFORM' | 'STATION' | 'ENTRANCE_EXIT' | 'GENERIC_NODE' | 'BOARDING_AREA';
6
+ export type Stop = {
7
+ id: StopId;
8
+ name: string;
9
+ lat?: Latitude;
10
+ lon?: Longitude;
11
+ children: StopId[];
12
+ parent?: StopId;
13
+ locationType: LocationType;
14
+ platform?: Platform;
15
+ };
16
+ export type StopsMap = Map<StopId, Stop>;
@@ -0,0 +1,52 @@
1
+ import { Stop, StopId, StopsMap } from './stops.js';
2
+ /**
3
+ * The StopMap class provides functionality to search for public transport stops
4
+ * by name or geographic location. It leverages text search and geospatial indexing
5
+ * to efficiently find stops based on user queries.
6
+ */
7
+ export declare class StopsIndex {
8
+ private readonly stopsMap;
9
+ private readonly textIndex;
10
+ private readonly geoIndex;
11
+ private readonly stopPoints;
12
+ constructor(stopsMap: StopsMap);
13
+ /**
14
+ * Deserializes a binary representation of the stops.
15
+ *
16
+ * @param {Uint8Array} data - The binary data to deserialize.
17
+ * @returns {StopsMap} - The deserialized StopFinder.
18
+ */
19
+ static fromData(data: Uint8Array): StopsIndex;
20
+ /**
21
+ * Serializes the stops into a binary protobuf.
22
+ *
23
+ * @returns {Uint8Array} - The serialized binary data.
24
+ */
25
+ serialize(): Uint8Array;
26
+ /**
27
+ * Finds stops by their name using a text search.
28
+ *
29
+ * @param query - The name or partial name of the stop to search for.
30
+ * @param maxResults - The maximum number of results to return (default is 5).
31
+ * @returns An array of Stop objects that match the search query.
32
+ */
33
+ findStopsByName(query: string, maxResults?: number): Stop[];
34
+ /**
35
+ * Finds stops by their geographic location using latitude and longitude.
36
+ *
37
+ * @param lat - The latitude of the location to search near.
38
+ * @param lon - The longitude of the location to search near.
39
+ * @param maxResults - The maximum number of results to return (default is 10).
40
+ * @param radius - The search radius in kilometers (default is 0.5).
41
+ * @returns An array of Stop objects that are closest to the specified location.
42
+ */
43
+ findStopsByLocation(lat: number, lon: number, maxResults?: number, radius?: number): Stop[];
44
+ /**
45
+ * Finds a stop by its ID.
46
+ *
47
+ * @param id - The ID of the stop to search for.
48
+ * @returns The Stop object that matches the specified ID, or undefined if not found.
49
+ */
50
+ findStopById(id: StopId): Stop | undefined;
51
+ equivalentStops(id: StopId): StopId[];
52
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ export declare class Duration {
2
+ private totalSeconds;
3
+ private constructor();
4
+ /**
5
+ * Creates a Duration instance from a given number of seconds.
6
+ *
7
+ * @param seconds - The number of seconds for the duration.
8
+ * @returns A Duration instance representing the specified duration.
9
+ */
10
+ static fromSeconds(seconds: number): Duration;
11
+ /**
12
+ * Creates a Duration instance from a given number of minutes.
13
+ *
14
+ * @param minutes - The number of minutes for the duration.
15
+ * @returns A Duration instance representing the specified duration.
16
+ */
17
+ static fromMinutes(minutes: number): Duration;
18
+ /**
19
+ * Gets a Duration instance representing zero duration (0 hours, 0 minutes, 0 seconds).
20
+ *
21
+ * @returns A Duration instance representing zero duration.
22
+ */
23
+ static zero(): Duration;
24
+ /**
25
+ * Converts the duration instance to a string in "HH:MM:SS" format.
26
+ *
27
+ * @returns A string representing the duration.
28
+ */
29
+ toString(): string;
30
+ /**
31
+ * Gets the duration as the number of seconds.
32
+ *
33
+ * @returns The duration in seconds.
34
+ */
35
+ toSeconds(): number;
36
+ /**
37
+ * Adds another Duration to this instance and returns the result as a new Duration.
38
+ *
39
+ * @param other - The other Duration to add.
40
+ * @returns A new Duration instance representing the sum.
41
+ */
42
+ add(other: Duration): Duration;
43
+ /**
44
+ * Subtracts another Duration from this instance and returns the result as a new Duration.
45
+ * If the result would be negative, it returns a Duration of 0 seconds.
46
+ *
47
+ * @param other - The other Duration to subtract.
48
+ * @returns A new Duration instance representing the difference.
49
+ */
50
+ subtract(other: Duration): Duration;
51
+ }
@@ -0,0 +1,8 @@
1
+ import { RoutesAdjacency as ProtoRoutesAdjacency, ServiceRoutesMap as ProtoServiceRoutesMap, StopsAdjacency as ProtoStopsAdjacency } from './proto/timetable.js';
2
+ import { RoutesAdjacency, ServiceRoutesMap, StopsAdjacency } from './timetable.js';
3
+ export declare const serializeStopsAdjacency: (stopsAdjacency: StopsAdjacency) => ProtoStopsAdjacency;
4
+ export declare const serializeRoutesAdjacency: (routesAdjacency: RoutesAdjacency) => ProtoRoutesAdjacency;
5
+ export declare const serializeServiceRoutesMap: (serviceRoutesMap: ServiceRoutesMap) => ProtoServiceRoutesMap;
6
+ export declare const deserializeStopsAdjacency: (protoStopsAdjacency: ProtoStopsAdjacency) => StopsAdjacency;
7
+ export declare const deserializeRoutesAdjacency: (protoRoutesAdjacency: ProtoRoutesAdjacency) => RoutesAdjacency;
8
+ export declare const deserializeServiceRoutesMap: (protoServiceRoutesMap: ProtoServiceRoutesMap) => ServiceRoutesMap;