minotor 12.0.0 → 13.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.
- package/CHANGELOG.md +4 -4
- package/README.md +7 -4
- package/dist/cli/perf.d.ts +19 -9
- package/dist/cli.mjs +289 -206
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +37 -19
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +37 -19
- 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 +2 -1
- 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/rangeResult.d.ts +34 -25
- package/dist/routing/result.d.ts +28 -9
- package/dist/routing/resultInternals.d.ts +4 -0
- package/dist/routing/routingResult.d.ts +29 -0
- package/dist/routing/state.d.ts +2 -2
- package/dist/stops/stopsIndex.d.ts +1 -1
- package/dist/timetable/route.d.ts +2 -0
- package/package.json +2 -2
- package/src/cli/minotor.ts +20 -3
- package/src/cli/perf.ts +98 -111
- package/src/cli/repl.ts +1 -1
- package/src/router.ts +3 -0
- package/src/routing/__tests__/plotter.test.ts +0 -11
- package/src/routing/__tests__/rangeResult.test.ts +1470 -46
- package/src/routing/__tests__/rangeRouter.test.ts +14 -8
- package/src/routing/__tests__/result.test.ts +375 -76
- package/src/routing/__tests__/state.test.ts +29 -0
- package/src/routing/plainRouter.ts +1 -6
- package/src/routing/plotter.ts +6 -5
- package/src/routing/rangeResult.ts +67 -52
- package/src/routing/rangeRouter.ts +3 -8
- package/src/routing/result.ts +95 -36
- package/src/routing/resultInternals.ts +5 -0
- package/src/routing/routingResult.ts +34 -0
- package/src/routing/state.ts +11 -3
- package/src/stops/__tests__/stopFinder.test.ts +13 -0
- package/src/stops/stopsIndex.ts +13 -19
- package/src/timetable/__tests__/io.test.ts +27 -0
- package/src/timetable/__tests__/route.test.ts +30 -0
- package/src/timetable/io.ts +15 -1
- package/src/timetable/route.ts +19 -5
- package/src/timetable/timetable.ts +1 -1
package/dist/parser.esm.js
CHANGED
|
@@ -12106,7 +12106,7 @@ class StopsIndex {
|
|
|
12106
12106
|
this.stops = stops;
|
|
12107
12107
|
this.sourceStopsMap = new Map();
|
|
12108
12108
|
const stopsSet = new Map();
|
|
12109
|
-
this.
|
|
12109
|
+
this.geoStopIds = [];
|
|
12110
12110
|
for (let id = 0; id < stops.length; id++) {
|
|
12111
12111
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12112
12112
|
const stop = stops[id];
|
|
@@ -12122,11 +12122,7 @@ class StopsIndex {
|
|
|
12122
12122
|
});
|
|
12123
12123
|
}
|
|
12124
12124
|
if (stop.lat && stop.lon) {
|
|
12125
|
-
this.
|
|
12126
|
-
id: id,
|
|
12127
|
-
lat: stop.lat,
|
|
12128
|
-
lon: stop.lon,
|
|
12129
|
-
});
|
|
12125
|
+
this.geoStopIds.push(id);
|
|
12130
12126
|
}
|
|
12131
12127
|
}
|
|
12132
12128
|
this.textIndex = H({
|
|
@@ -12137,11 +12133,12 @@ class StopsIndex {
|
|
|
12137
12133
|
});
|
|
12138
12134
|
const stopsArray = Array.from(stopsSet.values());
|
|
12139
12135
|
S(this.textIndex, stopsArray);
|
|
12140
|
-
this.geoIndex = new KDBush(this.
|
|
12141
|
-
for (let i = 0; i < this.
|
|
12136
|
+
this.geoIndex = new KDBush(this.geoStopIds.length);
|
|
12137
|
+
for (let i = 0; i < this.geoStopIds.length; i++) {
|
|
12142
12138
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12143
|
-
const
|
|
12144
|
-
|
|
12139
|
+
const stop = this.stops[this.geoStopIds[i]];
|
|
12140
|
+
// Coordinates were checked when collecting geoStopIds.
|
|
12141
|
+
this.geoIndex.add(stop.lon, stop.lat);
|
|
12145
12142
|
}
|
|
12146
12143
|
this.geoIndex.finish();
|
|
12147
12144
|
}
|
|
@@ -12183,8 +12180,9 @@ class StopsIndex {
|
|
|
12183
12180
|
* @returns An array of Stop objects that match the search query.
|
|
12184
12181
|
*/
|
|
12185
12182
|
findStopsByName(query, maxResults = 5) {
|
|
12186
|
-
|
|
12187
|
-
|
|
12183
|
+
return R(this.textIndex, query)
|
|
12184
|
+
.slice(0, maxResults)
|
|
12185
|
+
.map((result) => this.stops[result.id]);
|
|
12188
12186
|
}
|
|
12189
12187
|
/**
|
|
12190
12188
|
* Finds stops by their geographic location using latitude and longitude.
|
|
@@ -12197,8 +12195,8 @@ class StopsIndex {
|
|
|
12197
12195
|
*/
|
|
12198
12196
|
findStopsByLocation(lat, lon, maxResults = 5, radius = 0.5) {
|
|
12199
12197
|
const nearestStops = around(this.geoIndex, lon, lat, maxResults, radius).map((id) => {
|
|
12200
|
-
const
|
|
12201
|
-
return this.stops[
|
|
12198
|
+
const stopId = this.geoStopIds[id];
|
|
12199
|
+
return this.stops[stopId];
|
|
12202
12200
|
});
|
|
12203
12201
|
return nearestStops;
|
|
12204
12202
|
}
|
|
@@ -13244,11 +13242,14 @@ class Route {
|
|
|
13244
13242
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13245
13243
|
const stopId = stops[i];
|
|
13246
13244
|
const existingIndices = this.stopIndices.get(stopId);
|
|
13247
|
-
if (existingIndices) {
|
|
13248
|
-
|
|
13245
|
+
if (existingIndices === undefined) {
|
|
13246
|
+
this.stopIndices.set(stopId, i);
|
|
13247
|
+
}
|
|
13248
|
+
else if (typeof existingIndices === 'number') {
|
|
13249
|
+
this.stopIndices.set(stopId, [existingIndices, i]);
|
|
13249
13250
|
}
|
|
13250
13251
|
else {
|
|
13251
|
-
|
|
13252
|
+
existingIndices.push(i);
|
|
13252
13253
|
}
|
|
13253
13254
|
}
|
|
13254
13255
|
}
|
|
@@ -13529,8 +13530,19 @@ class Route {
|
|
|
13529
13530
|
if (stopIndex === undefined) {
|
|
13530
13531
|
return [];
|
|
13531
13532
|
}
|
|
13533
|
+
if (typeof stopIndex === 'number') {
|
|
13534
|
+
// Preserve stable, mutable array results for callers that request all indices.
|
|
13535
|
+
const indices = [stopIndex];
|
|
13536
|
+
this.stopIndices.set(stopId, indices);
|
|
13537
|
+
return indices;
|
|
13538
|
+
}
|
|
13532
13539
|
return stopIndex;
|
|
13533
13540
|
}
|
|
13541
|
+
/** Returns the first occurrence without allocating an array. */
|
|
13542
|
+
firstStopRouteIndex(stopId) {
|
|
13543
|
+
const indices = this.stopIndices.get(stopId);
|
|
13544
|
+
return typeof indices === 'number' ? indices : indices === null || indices === void 0 ? void 0 : indices[0];
|
|
13545
|
+
}
|
|
13534
13546
|
/**
|
|
13535
13547
|
* Retrieves the id of a stop at a given index in a route.
|
|
13536
13548
|
* @param stopRouteIndex The route index of the stop.
|
|
@@ -13715,11 +13727,17 @@ const deserializeStopsAdjacency = (protoStopsAdjacency) => {
|
|
|
13715
13727
|
};
|
|
13716
13728
|
const deserializeRoutesAdjacency = (protoRoutesAdjacency) => {
|
|
13717
13729
|
const routesAdjacency = [];
|
|
13730
|
+
// Own the compact payload so small protobuf views do not retain the input file.
|
|
13731
|
+
const pickupDropOffStorage = new Uint8Array(protoRoutesAdjacency.reduce((size, route) => size + route.pickupDropOffTypes.byteLength, 0));
|
|
13732
|
+
let pickupOffset = 0;
|
|
13718
13733
|
for (let i = 0; i < protoRoutesAdjacency.length; i++) {
|
|
13719
13734
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13720
13735
|
const value = protoRoutesAdjacency[i];
|
|
13721
13736
|
const stops = bytesToUint32Array(value.stops);
|
|
13722
|
-
|
|
13737
|
+
pickupDropOffStorage.set(value.pickupDropOffTypes, pickupOffset);
|
|
13738
|
+
const pickupDropOffTypes = pickupDropOffStorage.subarray(pickupOffset, pickupOffset + value.pickupDropOffTypes.byteLength);
|
|
13739
|
+
pickupOffset += value.pickupDropOffTypes.byteLength;
|
|
13740
|
+
routesAdjacency.push(new Route(i, bytesToUint16Array(value.stopTimes), pickupDropOffTypes, stops, value.serviceRouteId));
|
|
13723
13741
|
}
|
|
13724
13742
|
return routesAdjacency;
|
|
13725
13743
|
};
|
|
@@ -14041,7 +14059,7 @@ class Timetable {
|
|
|
14041
14059
|
if (!serviceRoute || !transportModes.has(serviceRoute.type))
|
|
14042
14060
|
continue;
|
|
14043
14061
|
}
|
|
14044
|
-
const originStopIndex = route.
|
|
14062
|
+
const originStopIndex = route.firstStopRouteIndex(originStop);
|
|
14045
14063
|
const existingHopOnStopIndex = reachableRoutes.get(route);
|
|
14046
14064
|
if (existingHopOnStopIndex !== undefined) {
|
|
14047
14065
|
if (originStopIndex < existingHopOnStopIndex) {
|