raptor-journey-planner
Version:
Implementation of the Round bAsed Public Transit Optimized Router (Raptor) journey planning algorithm.
44 lines (43 loc) • 1.37 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScanResults = void 0;
class ScanResults {
bestArrivals;
kArrivals;
kConnections;
k = 0;
constructor(bestArrivals, kArrivals, kConnections) {
this.bestArrivals = bestArrivals;
this.kArrivals = kArrivals;
this.kConnections = kConnections;
}
addRound() {
this.kArrivals[++this.k] = {};
}
previousArrival(stopPi) {
return this.kArrivals[this.k - 1][stopPi];
}
setTrip(trip, startIndex, endIndex, interchange) {
const time = trip.stopTimes[endIndex].arrivalTime + interchange;
const stopPi = trip.stopTimes[endIndex].stop;
this.kArrivals[this.k][stopPi] = time;
this.bestArrivals[stopPi] = time;
this.kConnections[stopPi][this.k] = [trip, startIndex, endIndex];
}
setTransfer(transfer, time) {
const stopPi = transfer.destination;
this.kArrivals[this.k][stopPi] = time;
this.bestArrivals[stopPi] = time;
this.kConnections[stopPi][this.k] = transfer;
}
bestArrival(stopPi) {
return this.bestArrivals[stopPi];
}
getMarkedStops() {
return Object.keys(this.kArrivals[this.k]);
}
finalize() {
return [this.kConnections, this.bestArrivals];
}
}
exports.ScanResults = ScanResults;