npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

raptor-journey-planner

v2.2.3

Published

Implementation of the Round bAsed Public Transit Optimized Router (Raptor) journey planning algorithm.

Downloads

32

Readme

Raptor

Raptor Journey Planner

npm

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 +14 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 fs = require("fs");
const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, DepartAfterQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS(fs.createReadStream("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 fs = require("fs");
const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, GroupStationDepartAfterQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS(fs.createReadStream("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 fs = require("fs");
const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, RangeQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS(fs.createReadStream("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 fs = require("fs");
const {loadGTFS, StringResults, RaptorAlgorithmFactory, TransferPatternQuery} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS(fs.createReadStream("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 fs = require("fs");
const {loadGTFS, JourneyFactory, RaptorAlgorithmFactory, RangeQuery, MultipleCriteriaFilter} = require("raptor-journey-planner");

const [trips, transfers, interchange, calendars] = await loadGTFS(fs.createReadStream("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 [email protected]: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.