stopovers(station, [opt])

August 29, 2018 · View on GitHub

Stopovers (departures and arrivals) at a given station (or optionally other location).

Input parameters

station

FPTF@1 station object or id. Modules might optionally also accept other FPTF object types like location or stop, however only stopovers at stations will be supported by every module.

opt = {}

Required options are supported by every module. For non-required options, the main FPTI principle still applies: If a certain feature/option is available, it must be provided as described below.

Note that modules might provide additional options as long as they don't use reserved option attributes.

AttributeDescriptionRequiredValue typeDefault
whenStopover date, synonym to departureAfterDatenew Date()
resultsMax. number of results returnedNumbernull
intervalResults for how many minutes after whenNumbernull
departureAfterList stopovers with a departure after this date, mutually exclusive with arrivalBeforeDatenew Date()
arrivalBeforeList stopovers with an arrival before this date, mutually exclusive with departureAfterDatenull
direction Only show departures heading to this stationstation object or idnull

*Or other FPTF types, if the module supports it..

features

The features object would look like this for a module which only supports the required options:

{
    when: 'Stopover date, synonym to `departureAfter`',
    results: 'Max. number of results returned',
    interval: 'Results for how many minutes after `when`',
    departureAfter: 'List stopovers with a departure after this date'
    // additionalOption: 'description of this option'
}

Output

Returns a Promise that resolves in an Array of stopover FPTF@1 objects.

Example

const module = require('fpti-module')

const station = {
    type: 'station',
    id: '123456'
}
const otherStation = '234567' // station id

const stopovers = module.stopovers(station)
const stopoversWithOptions = module.stopovers(otherStation, {
    when: new Date('2019-03-01T12:00+01:00'),
    interval: 6*60, // 6 hours
    direction: {type: 'station', id: '345678'}
})

stopovers.then(data => {
    // data is an array of FPTF stopover objects
    console.log(data)
})

console.log(module.stopovers.features) // all options