Skip to content
Implementation of the Route Based Public Transit Algorithm (Raptor)
Branch: master
Clone or download
Latest commit 86cfb36 Jun 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test update perf test May 11, 2019
.gitignore initial commit Oct 15, 2018
.npmignore initial commit Oct 15, 2018
.travis.yml update travis node version Apr 15, 2019
README.md fix readme examples (#2) May 11, 2019
logo.png update readme Dec 21, 2018
package-lock.json update deps, sort stop times Jun 5, 2019
package.json revert Jun 5, 2019
tsconfig.json Fixed a bug where journeys with fewer changes were not found in range… Apr 15, 2019
tslint.json added integration test, fixed issue with fixed legs Oct 23, 2018

README.md

Raptor

Raptor Journey Planner

Travis npm David

A near direct implementation of the Round bAsed Public Transit Optimized Router (Raptor) journey planning algorithm as described in the paper.

It does not contain the multi-threading or multi-criteria (mcRaptor) variants but does contain the range query (rRaptor) algorithm.

Additional features not in the paper implementation:

  • Calendars are checked to ensure services are running on the specified day
  • Multi-day journeys
  • The origin and destination may be a set of stops
  • Interchange time at each station is applied
  • Pickup / set down marker of stop times are obeyed
  • Multi-criteria journey filtering
  • Taking a footpath counts towards the number of changes (journey legs)

Usage

It will work with any well formed GTFS data set.

Node +11 is required for all examples.

npm install --save raptor-journey-planner

Depart After Query

Find the first results that depart after a specific time

const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, DepartAfterQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS("gtfs.zip");
const raptor = RaptorAlgorithmFactory.create(trips, transfers, interchange, calendars);
const resultsFactory = new JourneyFactory();
const query = new DepartAfterQuery(raptor, resultsFactory);
const journeys = query.plan("NRW", "STA", new Date(), 9 * 60 * 60);

Group Station Depart After Query

Find results from multiple origin and destinations

const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, GroupStationDepartAfterQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS("gtfs.zip");
const raptor = RaptorAlgorithmFactory.create(trips, transfers, interchange, calendars);
const resultsFactory = new JourneyFactory();
const query = new GroupStationDepartAfterQuery(raptor, resultsFactory);
const journeys = query.plan(["NRW"], ["LST", "EUS"], new Date(), 9 * 60 * 60);

Range Query

Find results departing between a time range

const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, RangeQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS("gtfs.zip");
const raptor = RaptorAlgorithmFactory.create(trips, transfers, interchange, calendars);
const resultsFactory = new JourneyFactory();
const query = new RangeQuery(raptor, resultsFactory);
const journeys = query.plan("NRW", "LST", new Date(), 9 * 60 * 60, 11 * 60 * 60);

Transfer Pattern Query

Finds transfer patterns for a stop on a given date

const {loadGTFS, StringResults, RaptorAlgorithmFactory, TransferPatternQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS("gtfs.zip");
const raptor = RaptorAlgorithmFactory.create(trips, transfers, interchange, calendars);
const resultsFactory = () => new StringResults();
const query = new TransferPatternQuery(raptor, resultsFactory);
const journeys = query.plan("NRW", new Date());

Filters

By default the multi-criteria filter will keep journeys as long as there are no subsequent journeys that arrive sooner and have the same or less changes.

const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, RangeQuery, MultipleCriteriaFilter} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS("gtfs.zip");
const raptor = RaptorAlgorithmFactory.create(trips, transfers, interchange, calendars);
const resultsFactory = new JourneyFactory();
const filter = new MultipleCriteriaFilter();
const maxSearchDays = 3;
const query = new RangeQuery(raptor, resultsFactory, maxSearchDays, [filter]);
const journeys = query.plan("NRW", "LST", new Date(), 9 * 60 * 60, 11 * 60 * 60);

Contributing

Issues and PRs are very welcome. To get the project set up run:

git clone git@github.com:planarnetwork/raptor
npm install --dev
npm test

If you would like to send a pull request please write your contribution in TypeScript and if possible, add a test.

License

This software is licensed under GNU GPLv3.

You can’t perform that action at this time.