Giter VIP home page Giter VIP logo

hafas-find-trips's Introduction

hafas-find-trips

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

Location and bearing/heading 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-trips

  • 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/heading of each vehicle into account.

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

Installation

npm install hafas-find-trips

Usage

Provide a track of user locations from the last ~10 seconds as GeoJSON LineString. If possible, provide a product in addition.

const findTrips = require('hafas-find-trips')
const createHafas = require('vbb-hafas')

const hafas = createHafas('my-awesome-program')

findTrips(hafas, {
	recording: {
		type: 'Feature',
		properties: {},
		geometry: { // GeoJSON LineString
			type: 'LineString',
			coordinates: [ /* … */ ]
		}
	},
	product: 'subway' // optional
})
.then((matches) => {
	for (let match of matches) {
		const m = match.movement
		console.log(match.score, m.line.name, m.direction, m.location)
	}
})
.catch((err) => {
	console.error(err)
	process.exitCode = 1
})

If you don't provide the product, it will instead apply its heuristic to all vehicles nearby.

Contributing

If you have a question or have difficulties using hafas-find-trips, 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.

hafas-find-trips's People

Contributors

derhuerst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hafas-find-trips's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.