watson / mode-s-aircraft-store

A utility library for keeping track of active aircrafts and their position based on their Mode S messages
MIT License
10 stars 5 forks source link

mode-s-aircraft-store

A utility library for keeping track of active aircrafts and their position based on their Mode S messages as decoded by mode-s-decoder.

Mode S is an aviation transponder interrogation mode used by Secondary Surveillance Radar (SSR) and Automatic Dependent Surveillance-Broadcast (ADS-B) systems.

For an example of this module in use, see AirplaneJS.

Build status js-standard-style

Installation

npm install mode-s-aircraft-store --save

Usage

const AircraftStore = require('mode-s-aircraft-store')

const store = new AircraftStore({
  timeout: 120000 // remove airplane from store if we haven't seen it for 2 minutes
})

// Add a Mode S message to the store.
// `message` is a decoded Mode S message generated by the mode-s-decoder module.
store.addMessage(message)

store.getAircrafts().forEach(function (aircraft) {
  console.log('Aircraft:\n' +
    `  ID: ${aircraft.icao}\n` +
    `  Altitude: ${aircraft.altitude}\n` +
    `  Speed: ${aircraft.speed}\n` +
    `  Heading: ${aircraft.heading}\n` +
    `  Latitude: ${aircraft.lat}\n` +
    `  Longitude: ${aircraft.lng}\n`)
})

API

store = new AircraftStore([options])

Initialize an AircraftStore instance.

Arguments:

The following options are available:

store.addMessage(message)

Add a new message to the store.

The message must be a decoded Mode S message received in detect callback from the mode-s-decoder module.

aircrafts = store.getAircrafts()

Return an array of aircrafts currently in the store.

Each aircraft have the following properties:

License

MIT