Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

hafas-find-trip

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hafas-find-trip

Provide location and bearing, get the vehicle you're most likely in.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

hafas-find-trip

Provide location and bearing, get the public transport vehicle you're most likely in.

Location and bearing are expected to be inaccurate because they come from a mobile device. Also, The vehicle movements from the underlying radar() API are often not the actual position, but the estimated position, based on their current delays and their track. To compensate for this, hafas-find-trip

  • filters by product if you provide one,
  • checks if the location is close to where vehicles have recently been or will soon be,
  • takes the bearing of each vehicle into account.

npm version ISC-licensed chat with me on Gitter support me on Patreon

Installation

npm install hafas-find-trip

Usage

If possible, provide location, bearing and product. An example from Berlin:

const query = {
	// U6 tunnel, northbound
	latitude: 52.496633,
	longitude: 13.390944,
	bearing: 16, // degrees, 0 is north
	product: 'subway'
}

If you don't provide the product, hafas-find-trip will instead apply its heuristic to all vehicles nearby. If you don't provide a bearing, it will estimate purely on the distance to the track of each vehicle.

const findTrip = require('hafas-find-trip')
const hafas = require('vbb-hafas')

findTrip(hafas, query)
.then((vehicle) => {
	console.log(vehicle.line.name, vehicle.direction, location)
})
.catch((err) => {
	console.error(err)
	process.exitCode = 1
})

Contributing

If you have a question or have difficulties using hafas-find-trip, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Keywords

hafas

FAQs

Package last updated on 17 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts