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.cjs.js
CHANGED
|
@@ -12108,7 +12108,7 @@ class StopsIndex {
|
|
|
12108
12108
|
this.stops = stops;
|
|
12109
12109
|
this.sourceStopsMap = new Map();
|
|
12110
12110
|
const stopsSet = new Map();
|
|
12111
|
-
this.
|
|
12111
|
+
this.geoStopIds = [];
|
|
12112
12112
|
for (let id = 0; id < stops.length; id++) {
|
|
12113
12113
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12114
12114
|
const stop = stops[id];
|
|
@@ -12124,11 +12124,7 @@ class StopsIndex {
|
|
|
12124
12124
|
});
|
|
12125
12125
|
}
|
|
12126
12126
|
if (stop.lat && stop.lon) {
|
|
12127
|
-
this.
|
|
12128
|
-
id: id,
|
|
12129
|
-
lat: stop.lat,
|
|
12130
|
-
lon: stop.lon,
|
|
12131
|
-
});
|
|
12127
|
+
this.geoStopIds.push(id);
|
|
12132
12128
|
}
|
|
12133
12129
|
}
|
|
12134
12130
|
this.textIndex = H({
|
|
@@ -12139,11 +12135,12 @@ class StopsIndex {
|
|
|
12139
12135
|
});
|
|
12140
12136
|
const stopsArray = Array.from(stopsSet.values());
|
|
12141
12137
|
S(this.textIndex, stopsArray);
|
|
12142
|
-
this.geoIndex = new KDBush(this.
|
|
12143
|
-
for (let i = 0; i < this.
|
|
12138
|
+
this.geoIndex = new KDBush(this.geoStopIds.length);
|
|
12139
|
+
for (let i = 0; i < this.geoStopIds.length; i++) {
|
|
12144
12140
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12145
|
-
const
|
|
12146
|
-
|
|
12141
|
+
const stop = this.stops[this.geoStopIds[i]];
|
|
12142
|
+
// Coordinates were checked when collecting geoStopIds.
|
|
12143
|
+
this.geoIndex.add(stop.lon, stop.lat);
|
|
12147
12144
|
}
|
|
12148
12145
|
this.geoIndex.finish();
|
|
12149
12146
|
}
|
|
@@ -12185,8 +12182,9 @@ class StopsIndex {
|
|
|
12185
12182
|
* @returns An array of Stop objects that match the search query.
|
|
12186
12183
|
*/
|
|
12187
12184
|
findStopsByName(query, maxResults = 5) {
|
|
12188
|
-
|
|
12189
|
-
|
|
12185
|
+
return R(this.textIndex, query)
|
|
12186
|
+
.slice(0, maxResults)
|
|
12187
|
+
.map((result) => this.stops[result.id]);
|
|
12190
12188
|
}
|
|
12191
12189
|
/**
|
|
12192
12190
|
* Finds stops by their geographic location using latitude and longitude.
|
|
@@ -12199,8 +12197,8 @@ class StopsIndex {
|
|
|
12199
12197
|
*/
|
|
12200
12198
|
findStopsByLocation(lat, lon, maxResults = 5, radius = 0.5) {
|
|
12201
12199
|
const nearestStops = around(this.geoIndex, lon, lat, maxResults, radius).map((id) => {
|
|
12202
|
-
const
|
|
12203
|
-
return this.stops[
|
|
12200
|
+
const stopId = this.geoStopIds[id];
|
|
12201
|
+
return this.stops[stopId];
|
|
12204
12202
|
});
|
|
12205
12203
|
return nearestStops;
|
|
12206
12204
|
}
|
|
@@ -13246,11 +13244,14 @@ class Route {
|
|
|
13246
13244
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13247
13245
|
const stopId = stops[i];
|
|
13248
13246
|
const existingIndices = this.stopIndices.get(stopId);
|
|
13249
|
-
if (existingIndices) {
|
|
13250
|
-
|
|
13247
|
+
if (existingIndices === undefined) {
|
|
13248
|
+
this.stopIndices.set(stopId, i);
|
|
13249
|
+
}
|
|
13250
|
+
else if (typeof existingIndices === 'number') {
|
|
13251
|
+
this.stopIndices.set(stopId, [existingIndices, i]);
|
|
13251
13252
|
}
|
|
13252
13253
|
else {
|
|
13253
|
-
|
|
13254
|
+
existingIndices.push(i);
|
|
13254
13255
|
}
|
|
13255
13256
|
}
|
|
13256
13257
|
}
|
|
@@ -13531,8 +13532,19 @@ class Route {
|
|
|
13531
13532
|
if (stopIndex === undefined) {
|
|
13532
13533
|
return [];
|
|
13533
13534
|
}
|
|
13535
|
+
if (typeof stopIndex === 'number') {
|
|
13536
|
+
// Preserve stable, mutable array results for callers that request all indices.
|
|
13537
|
+
const indices = [stopIndex];
|
|
13538
|
+
this.stopIndices.set(stopId, indices);
|
|
13539
|
+
return indices;
|
|
13540
|
+
}
|
|
13534
13541
|
return stopIndex;
|
|
13535
13542
|
}
|
|
13543
|
+
/** Returns the first occurrence without allocating an array. */
|
|
13544
|
+
firstStopRouteIndex(stopId) {
|
|
13545
|
+
const indices = this.stopIndices.get(stopId);
|
|
13546
|
+
return typeof indices === 'number' ? indices : indices === null || indices === void 0 ? void 0 : indices[0];
|
|
13547
|
+
}
|
|
13536
13548
|
/**
|
|
13537
13549
|
* Retrieves the id of a stop at a given index in a route.
|
|
13538
13550
|
* @param stopRouteIndex The route index of the stop.
|
|
@@ -13717,11 +13729,17 @@ const deserializeStopsAdjacency = (protoStopsAdjacency) => {
|
|
|
13717
13729
|
};
|
|
13718
13730
|
const deserializeRoutesAdjacency = (protoRoutesAdjacency) => {
|
|
13719
13731
|
const routesAdjacency = [];
|
|
13732
|
+
// Own the compact payload so small protobuf views do not retain the input file.
|
|
13733
|
+
const pickupDropOffStorage = new Uint8Array(protoRoutesAdjacency.reduce((size, route) => size + route.pickupDropOffTypes.byteLength, 0));
|
|
13734
|
+
let pickupOffset = 0;
|
|
13720
13735
|
for (let i = 0; i < protoRoutesAdjacency.length; i++) {
|
|
13721
13736
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13722
13737
|
const value = protoRoutesAdjacency[i];
|
|
13723
13738
|
const stops = bytesToUint32Array(value.stops);
|
|
13724
|
-
|
|
13739
|
+
pickupDropOffStorage.set(value.pickupDropOffTypes, pickupOffset);
|
|
13740
|
+
const pickupDropOffTypes = pickupDropOffStorage.subarray(pickupOffset, pickupOffset + value.pickupDropOffTypes.byteLength);
|
|
13741
|
+
pickupOffset += value.pickupDropOffTypes.byteLength;
|
|
13742
|
+
routesAdjacency.push(new Route(i, bytesToUint16Array(value.stopTimes), pickupDropOffTypes, stops, value.serviceRouteId));
|
|
13725
13743
|
}
|
|
13726
13744
|
return routesAdjacency;
|
|
13727
13745
|
};
|
|
@@ -14043,7 +14061,7 @@ class Timetable {
|
|
|
14043
14061
|
if (!serviceRoute || !transportModes.has(serviceRoute.type))
|
|
14044
14062
|
continue;
|
|
14045
14063
|
}
|
|
14046
|
-
const originStopIndex = route.
|
|
14064
|
+
const originStopIndex = route.firstStopRouteIndex(originStop);
|
|
14047
14065
|
const existingHopOnStopIndex = reachableRoutes.get(route);
|
|
14048
14066
|
if (existingHopOnStopIndex !== undefined) {
|
|
14049
14067
|
if (originStopIndex < existingHopOnStopIndex) {
|