minotor 3.0.0 → 3.0.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/.cspell.json +14 -1
- package/.gitattributes +3 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +3 -0
- package/.github/workflows/minotor.yml +17 -1
- package/CHANGELOG.md +3 -9
- package/README.md +47 -17
- package/dist/__e2e__/router.test.d.ts +1 -0
- package/dist/cli/perf.d.ts +28 -0
- package/dist/cli/utils.d.ts +6 -2
- package/dist/cli.mjs +1967 -823
- package/dist/cli.mjs.map +1 -1
- package/dist/gtfs/trips.d.ts +1 -0
- package/dist/gtfs/utils.d.ts +1 -1
- package/dist/parser.cjs.js +1030 -627
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.d.ts +4 -2
- package/dist/parser.esm.js +1030 -627
- package/dist/parser.esm.js.map +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +10 -5
- package/dist/router.esm.js +1 -1
- package/dist/router.esm.js.map +1 -1
- package/dist/router.umd.js +1 -1
- package/dist/router.umd.js.map +1 -1
- package/dist/routing/__tests__/result.test.d.ts +1 -0
- package/dist/routing/query.d.ts +27 -6
- package/dist/routing/result.d.ts +1 -1
- package/dist/routing/route.d.ts +47 -2
- package/dist/routing/router.d.ts +15 -1
- package/dist/stops/stopsIndex.d.ts +3 -3
- package/dist/timetable/__tests__/route.test.d.ts +1 -0
- package/dist/timetable/__tests__/time.test.d.ts +1 -0
- package/dist/timetable/io.d.ts +7 -1
- package/dist/timetable/proto/timetable.d.ts +1 -1
- package/dist/timetable/route.d.ts +155 -0
- package/dist/timetable/time.d.ts +21 -0
- package/dist/timetable/timetable.d.ts +41 -61
- package/package.json +36 -35
- package/src/__e2e__/benchmark.json +22 -0
- package/src/__e2e__/router.test.ts +209 -0
- package/src/__e2e__/timetable/stops.bin +3 -0
- package/src/__e2e__/timetable/timetable.bin +3 -0
- package/src/cli/minotor.ts +51 -1
- package/src/cli/perf.ts +136 -0
- package/src/cli/repl.ts +26 -13
- package/src/cli/utils.ts +6 -28
- package/src/gtfs/__tests__/parser.test.ts +12 -15
- package/src/gtfs/__tests__/services.test.ts +1 -0
- package/src/gtfs/__tests__/transfers.test.ts +0 -1
- package/src/gtfs/__tests__/trips.test.ts +67 -74
- package/src/gtfs/profiles/ch.ts +1 -1
- package/src/gtfs/routes.ts +4 -4
- package/src/gtfs/services.ts +15 -2
- package/src/gtfs/stops.ts +7 -3
- package/src/gtfs/transfers.ts +6 -3
- package/src/gtfs/trips.ts +33 -16
- package/src/gtfs/utils.ts +13 -2
- package/src/parser.ts +4 -2
- package/src/router.ts +17 -11
- package/src/routing/__tests__/result.test.ts +392 -0
- package/src/routing/__tests__/router.test.ts +94 -137
- package/src/routing/query.ts +28 -7
- package/src/routing/result.ts +10 -5
- package/src/routing/route.ts +95 -9
- package/src/routing/router.ts +82 -66
- package/src/stops/__tests__/io.test.ts +1 -1
- package/src/stops/__tests__/stopFinder.test.ts +1 -1
- package/src/stops/proto/stops.ts +4 -4
- package/src/stops/stopsIndex.ts +3 -3
- package/src/timetable/__tests__/io.test.ts +16 -23
- package/src/timetable/__tests__/route.test.ts +317 -0
- package/src/timetable/__tests__/time.test.ts +494 -0
- package/src/timetable/__tests__/timetable.test.ts +64 -75
- package/src/timetable/io.ts +32 -26
- package/src/timetable/proto/timetable.proto +1 -1
- package/src/timetable/proto/timetable.ts +13 -13
- package/src/timetable/route.ts +347 -0
- package/src/timetable/time.ts +40 -8
- package/src/timetable/timetable.ts +74 -165
- package/tsconfig.build.json +1 -1
package/.cspell.json
CHANGED
|
@@ -28,7 +28,20 @@
|
|
|
28
28
|
"Davos",
|
|
29
29
|
"moleson",
|
|
30
30
|
"Klosters",
|
|
31
|
-
"Engadin"
|
|
31
|
+
"Engadin",
|
|
32
|
+
"isochrone",
|
|
33
|
+
"Delling",
|
|
34
|
+
"Moléson",
|
|
35
|
+
"Bulle",
|
|
36
|
+
"Gruyères",
|
|
37
|
+
"gare",
|
|
38
|
+
"funi",
|
|
39
|
+
"Francey",
|
|
40
|
+
"téléphérique",
|
|
41
|
+
"Moritz",
|
|
42
|
+
"Haut",
|
|
43
|
+
"Rhin",
|
|
44
|
+
"Olten"
|
|
32
45
|
],
|
|
33
46
|
"flagWords": [],
|
|
34
47
|
"ignorePaths": [
|
package/.gitattributes
ADDED
|
@@ -2,3 +2,6 @@ Fixes # (issue)
|
|
|
2
2
|
|
|
3
3
|
Please provide a concise description of your changes, and the motivation for making them.
|
|
4
4
|
If relevant, include links to related issues or pull requests.
|
|
5
|
+
|
|
6
|
+
- [ ] If the timetable or stops format changed, I re-generated `src/__e2e__/timetable/stops.bin` and `src/__e2e__/timetable/timetable.bin` based on the latest Swiss GTFS for the next Monday (and adjusted e2e tests results accordingly if needed).
|
|
7
|
+
- [ ] I ran the performance tests and confirmed that no regression was introduced.
|
|
@@ -67,9 +67,25 @@ jobs:
|
|
|
67
67
|
- name: ⚡ Tests
|
|
68
68
|
run: npm run test:coverage
|
|
69
69
|
|
|
70
|
+
e2e:
|
|
71
|
+
name: 🏁 End-to-end tests
|
|
72
|
+
runs-on: ubuntu-latest
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v3
|
|
75
|
+
with:
|
|
76
|
+
lfs: true
|
|
77
|
+
- name: Checkout LFS objects
|
|
78
|
+
run: git lfs pull
|
|
79
|
+
- uses: actions/setup-node@v3
|
|
80
|
+
with:
|
|
81
|
+
node-version: '21.1.0'
|
|
82
|
+
- uses: bahmutov/npm-install@v1
|
|
83
|
+
- name: 🏁 End-to-end tests
|
|
84
|
+
run: npm run e2e
|
|
85
|
+
|
|
70
86
|
build-and-release:
|
|
71
87
|
name: 🚀 Build & release
|
|
72
|
-
needs: [format, lint, audit, spell, type, test]
|
|
88
|
+
needs: [format, lint, audit, spell, type, test, e2e]
|
|
73
89
|
runs-on: ubuntu-latest
|
|
74
90
|
steps:
|
|
75
91
|
- uses: actions/checkout@v3
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
## [3.0.2](https://github.com/aubryio/minotor/compare/v3.0.1...v3.0.2) (2025-09-05)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### BREAKING CHANGES
|
|
10
|
-
|
|
11
|
-
* - timetable serialization format upgraded to 0.0.3. Cannot read nor produce older
|
|
12
|
-
versions anymore.
|
|
6
|
+
* make csv-parser cast sequence numbers as numbers ([#21](https://github.com/aubryio/minotor/issues/21)) ([8bf70c2](https://github.com/aubryio/minotor/commit/8bf70c26a4ccec6e32b849b608bd399fe53382db))
|
package/README.md
CHANGED
|
@@ -13,13 +13,23 @@ Privacy-conscious applications where the user does not want to share their locat
|
|
|
13
13
|
The transit router and the stops index of **minotor** can run in the browser, on react-native or in a Node.js environment.
|
|
14
14
|
Transit data (GTFS) parsing runs on Node.js, and the resulting data is serialized as a protobuf binary that can be loaded from the router.
|
|
15
15
|
|
|
16
|
+
Minotor routing algorithm is mostly based on RAPTOR. See [Round-Based Public Transit Routing, D. Delling et al. 2012](https://www.microsoft.com/en-us/research/wp-content/uploads/2012/01/raptor_alenex.pdf).
|
|
17
|
+
|
|
16
18
|
## Examples
|
|
17
19
|
|
|
18
20
|
### In-browser transit router
|
|
19
21
|
|
|
20
22
|
An example client-side transit router running in the browser with a web worker.
|
|
21
23
|
|
|
22
|
-
[Demo](https://www.minotor.dev/#
|
|
24
|
+
[Demo](https://www.minotor.dev/#router) | [Code](https://github.com/aubryio/minotor.dev/tree/main/app/examples/planner)
|
|
25
|
+
|
|
26
|
+
### Isochrone maps
|
|
27
|
+
|
|
28
|
+
An example implementation of dynamic isochrone maps using minotor in the browser.
|
|
29
|
+
|
|
30
|
+
[Demo](https://www.minotor.dev/#isochrones) | [Code](https://github.com/aubryio/minotor.dev/tree/main/app/examples/isochrones)
|
|
31
|
+
|
|
32
|
+
A more complete isochrone map showcase can be found on [isochrone.ch](https://isochrone.ch).
|
|
23
33
|
|
|
24
34
|
## Features
|
|
25
35
|
|
|
@@ -32,7 +42,7 @@ An example client-side transit router running in the browser with a web worker.
|
|
|
32
42
|
|
|
33
43
|
| Feed | Parsing time | Timetable Size for a Day (Compressed) |
|
|
34
44
|
| ------------------------------------------------------------------------------------------ | ------------ | ------------------------------------- |
|
|
35
|
-
| [Swiss GTFS feed](https://data.opentransportdata.swiss/en/dataset/timetable-2025-gtfs2020) | ~2 minutes |
|
|
45
|
+
| [Swiss GTFS feed](https://data.opentransportdata.swiss/en/dataset/timetable-2025-gtfs2020) | ~2 minutes | 20 MB (5MB) |
|
|
36
46
|
|
|
37
47
|
## Get started
|
|
38
48
|
|
|
@@ -51,8 +61,9 @@ const parser = new GtfsParser('gtfs-feed.zip', chGtfsProfile);
|
|
|
51
61
|
const { timetable, stopsIndex } = await parser.parse(new Date());
|
|
52
62
|
```
|
|
53
63
|
|
|
54
|
-
Note that
|
|
55
|
-
|
|
64
|
+
Note that times are only represented at the minute level so they can fit on 16 bits.
|
|
65
|
+
|
|
66
|
+
This operation can take a few minutes for large GTFS feeds.
|
|
56
67
|
|
|
57
68
|
#### Stop Search (Browser or Node.js)
|
|
58
69
|
|
|
@@ -63,7 +74,7 @@ const destinations = stopsIndex.findStopsByName('Moles'); // Partial name search
|
|
|
63
74
|
|
|
64
75
|
Query stops by ID:
|
|
65
76
|
|
|
66
|
-
`const stopFromId = stopsIndex.
|
|
77
|
+
`const stopFromId = stopsIndex.findStopBySourceId('8592374:0:A');`
|
|
67
78
|
|
|
68
79
|
Or by location:
|
|
69
80
|
|
|
@@ -117,11 +128,21 @@ Query routes (`minotor> .route -h for more options`):
|
|
|
117
128
|
|
|
118
129
|
## Development
|
|
119
130
|
|
|
131
|
+
### Requirements
|
|
132
|
+
|
|
133
|
+
Make sure you have a working [node](https://nodejs.org) environment.
|
|
134
|
+
|
|
135
|
+
`protoc` also needs to be available on the build system.
|
|
136
|
+
|
|
137
|
+
Ubuntu: `sudo apt install -y protobuf-compiler` |
|
|
138
|
+
Fedora: `sudo dnf install -y protobuf-compiler` |
|
|
139
|
+
MacOS: `brew install protobuf`
|
|
140
|
+
|
|
120
141
|
### Debugging
|
|
121
142
|
|
|
122
143
|
It is possible to plot the router graph to debug the algorithm:
|
|
123
144
|
|
|
124
|
-
`minotor repl`
|
|
145
|
+
Using the npm script `repl`, or `minotor repl` if the project is installed globally.
|
|
125
146
|
|
|
126
147
|
`minotor> .plot from <stationId> to <stationId> at <HH:mm> [with <N> transfers] [to <graph.dot>]`
|
|
127
148
|
|
|
@@ -129,15 +150,20 @@ It is possible to plot the router graph to debug the algorithm:
|
|
|
129
150
|
|
|
130
151
|
### Build
|
|
131
152
|
|
|
132
|
-
Make sure you have a working node setup as well as a protobuf compiler.
|
|
133
|
-
|
|
134
153
|
- `build`: builds the project in the `dist/` directory
|
|
135
154
|
- `clean`: removes the `dist/` directory
|
|
136
155
|
|
|
137
|
-
### Tests
|
|
156
|
+
### Unit Tests
|
|
157
|
+
|
|
158
|
+
- `test`: runs unit tests
|
|
159
|
+
- `test:coverage`: runs unit test runner with coverage reports
|
|
138
160
|
|
|
139
|
-
-
|
|
140
|
-
|
|
161
|
+
### End-to-End Tests
|
|
162
|
+
|
|
163
|
+
- `e2e`: runs end-to-end tests, using a real data from a day in the Swiss GTFS dataset
|
|
164
|
+
- `perf`: runs a basic performance test, using a real data from a day in the Swiss GTFS dataset
|
|
165
|
+
|
|
166
|
+
Note that performance tests are not included in the CI pipeline and must be run manually.
|
|
141
167
|
|
|
142
168
|
### Formatting & linting
|
|
143
169
|
|
|
@@ -153,15 +179,19 @@ Releases are automatically published to npm when merging to the `main` or `beta`
|
|
|
153
179
|
|
|
154
180
|
## Roadmap
|
|
155
181
|
|
|
156
|
-
The project is under active development. Here are some of the features that are planned
|
|
182
|
+
The project is under active development. Here are some of the features that are planned (ordered by priority).
|
|
183
|
+
Contact [the author](https://aubry.io/) for feature requests.
|
|
157
184
|
|
|
158
|
-
-
|
|
185
|
+
- Route/Trip-based transfer support
|
|
186
|
+
- Arrive-by support
|
|
159
187
|
- Range queries
|
|
160
188
|
- Transfer preferences
|
|
189
|
+
- Route/Trip metadata support
|
|
190
|
+
- Routing filters based on metadata e.g. bicycle support, wheelchair access
|
|
191
|
+
- More routing options (slower/faster transfers, etc.)
|
|
192
|
+
- Improved stop search (sort by stop importance)
|
|
193
|
+
- Real-time timetable support (tripId/routeId mapping)
|
|
161
194
|
- Support for exporting a calendar range as opposed to a single day
|
|
162
195
|
- Support for GTFS `frequencies.txt`
|
|
163
|
-
-
|
|
196
|
+
- Load multiple GTFS archives at once
|
|
164
197
|
- NeTEx support
|
|
165
|
-
- Higher level timetable API for cleaner router code
|
|
166
|
-
- RT-GTFS Support (adding tripId support)
|
|
167
|
-
- More extensive testing
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Query, Router, StopsIndex } from '../router.js';
|
|
2
|
+
type PerformanceResult = {
|
|
3
|
+
task: Query;
|
|
4
|
+
meanTimeMs: number;
|
|
5
|
+
meanMemoryMb: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param filePath
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const loadQueriesFromJson: (filePath: string) => Query[];
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param router
|
|
16
|
+
* @param stopsIndex
|
|
17
|
+
* @param tasks
|
|
18
|
+
* @param iterations
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const testRouterPerformance: (router: Router, stopsIndex: StopsIndex, tasks: Query[], iterations: number) => PerformanceResult[];
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param results
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare const prettyPrintPerformanceResults: (results: PerformanceResult[]) => void;
|
|
28
|
+
export {};
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { Result
|
|
2
|
-
|
|
1
|
+
import { Result } from '../router.js';
|
|
2
|
+
/**
|
|
3
|
+
* Plots the graph of the result to a dot file.
|
|
4
|
+
* @param result - The result object to plot.
|
|
5
|
+
* @param filePath - The path where the dot file will be saved.
|
|
6
|
+
*/
|
|
3
7
|
export declare const plotGraphToDotFile: (result: Result, filePath: string) => void;
|