Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async extractJourneys(
profilesByStop: IProfilesByStop,
query: IResolvedQuery,
): Promise> {
const filteredProfilesByStop: IProfilesByStop = ProfileUtil.filterInfinity(profilesByStop);
const departureLocation: ILocation = query.from[0];
const arrivalLocation: ILocation = query.to[0];
const paths: IPath[] = [];
const departureLocationProfiles: IProfile[] = filteredProfilesByStop[departureLocation.id];
// Can't find departure stop;
if (!departureLocationProfiles) {
return new ArrayIterator(paths);
}
for (const profile of departureLocationProfiles) {
for (let amountOfTransfers = 0; amountOfTransfers < profile.transferProfiles.length; amountOfTransfers++) {
const transferProfile: ITransferProfile = profile.transferProfiles[amountOfTransfers];
if (this.checkBestArrivalTime(transferProfile, departureLocation, arrivalLocation)) {
try {
paths.push(await this.extractJourney(
departureLocation,
arrivalLocation,
transferProfile,
amountOfTransfers,
filteredProfilesByStop,
));
filteredProfilesByStop,
));
this.setBestArrivalTime(
departureLocation,
arrivalLocation,
transferProfile.arrivalTime,
);
} catch (e) {
console.warn(e);
}
}
}
}
return new ArrayIterator(paths.reverse());
}
this.setBestArrivalTime(
departureLocation,
arrivalLocation,
transferProfile.arrivalTime,
);
} catch (e) {
if (this.eventBus) {
this.eventBus.emit(EventType.Warning, (e));
}
}
}
}
}
return new ArrayIterator(paths.reverse());
}
_createTransformer (bindings: Bindings): AsyncIterator {
return new ArrayIterator(compact(this._templates.map(t => bindings.bound(t))))
}
}
_createTransformer (bindings) {
return new ArrayIterator(compact(this._templates.map(t => applyBindings(t, bindings))))
}
}
for (const to of toLocations) {
const newPath = await this.getPathBetweenLocations(
from,
to,
profile,
);
if (newPath) {
paths.push(newPath);
}
}
}
}
return new ArrayIterator(paths);
}
const queryState: IQueryState = {
query,
profilesByStop: {},
earliestArrivalByTrip: {},
durationToTargetByStop: {},
gtfsTripByConnection: {},
initialReachableStops: [],
footpathQueue,
connectionsIterator: mergedIterator,
};
const hasInitialReachableStops: boolean = await this.initDurationToTargetByStop(queryState);
const hasFinalReachableStops: boolean = await this.initInitialReachableStops(queryState);
if (!hasInitialReachableStops || !hasFinalReachableStops) {
return Promise.resolve(new ArrayIterator([]));
}
const self = this;
return new Promise((resolve, reject) => {
let isDone: boolean = false;
const done = () => {
if (!isDone) {
queryState.connectionsIterator.close();
self.journeyExtractor.extractJourneys(queryState.profilesByStop, queryState.query)
.then((resultIterator) => {
resolve(resultIterator);
});
public _createTransformer(bindings: Bindings): AsyncIterator {
return new ArrayIterator(BindingsToQuadsIterator.bindTemplate(
bindings, this.template, this.blankNodeCounter++));
}
for (const to of toLocations) {
const newPath = await this.getPathBetweenLocations(
from,
to,
profile,
);
if (newPath) {
paths.push(newPath);
}
}
}
}
return new ArrayIterator(paths);
}
const parsePageConnections = (page: IHydraPage) => {
const connectionsParser = new ConnectionsPageParser(page.documentIri, page.triples);
const connections = connectionsParser.getConnections(travelMode);
if (options.backward) {
connections.reverse();
}
return new ArrayIterator(connections);
};