mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
add BART profile
This commit is contained in:
parent
2ae6a9a4ea
commit
f47343df8f
4 changed files with 139 additions and 0 deletions
53
p/bart/example.js
Normal file
53
p/bart/example.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
'use strict'
|
||||
|
||||
const createClient = require('../..')
|
||||
const vosProfile = require('.')
|
||||
|
||||
const client = createClient(vosProfile, 'hafas-client-example')
|
||||
|
||||
const fremont = '100013296'
|
||||
const embarcadero = '100013295'
|
||||
|
||||
// client.journeys(fremont, embarcadero, {results: 1, stopovers: true})
|
||||
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
|
||||
// })
|
||||
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// return client.trip(leg.tripId, leg.line.name, {polyline: true})
|
||||
// })
|
||||
|
||||
// client.departures(fremont, {duration: 1})
|
||||
// client.arrivals(fremont, {duration: 10, linesOfStops: true})
|
||||
// client.radar({
|
||||
// north: 37.8735,
|
||||
// west: -122.5250,
|
||||
// south: 37.6884,
|
||||
// east: -122.2105,
|
||||
// }, {results: 10})
|
||||
|
||||
client.locations('embarcadero', {results: 3})
|
||||
// client.stop(fremont, {linesOfStops: true})
|
||||
// client.nearby({
|
||||
// type: 'location',
|
||||
// latitude: 38.554779,
|
||||
// longitude: -121.738798,
|
||||
// }, {distance: 500})
|
||||
// client.reachableFrom({
|
||||
// type: 'location',
|
||||
// id: '980557173',
|
||||
// address: '1000 Alice St, Davis, 95616',
|
||||
// latitude: 38.554779,
|
||||
// longitude: -121.738798,
|
||||
// }, {
|
||||
// maxDuration: 8,
|
||||
// })
|
||||
|
||||
.then((data) => {
|
||||
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||
})
|
||||
.catch(console.error)
|
72
p/bart/index.js
Normal file
72
p/bart/index.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
'use strict'
|
||||
|
||||
const products = [{
|
||||
id: 'bart',
|
||||
mode: 'train',
|
||||
bitmasks: [128],
|
||||
name: 'BART',
|
||||
short: 'BART',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'regional-train',
|
||||
mode: 'train',
|
||||
bitmasks: [8],
|
||||
name: 'regional trains (Caltrain, Capitol Corridor, ACE)',
|
||||
short: 'regional trains',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'bus',
|
||||
mode: 'bus',
|
||||
bitmasks: [32],
|
||||
name: 'Bus',
|
||||
short: 'Bus',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'ferry',
|
||||
mode: 'watercraft',
|
||||
bitmasks: [64],
|
||||
name: 'Ferry',
|
||||
short: 'Ferry',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'tram',
|
||||
mode: 'train',
|
||||
bitmasks: [256],
|
||||
name: 'Tram',
|
||||
short: 'Tram',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'cable-car',
|
||||
mode: 'train',
|
||||
bitmasks: [4],
|
||||
name: 'cable car',
|
||||
short: 'cable car',
|
||||
default: true,
|
||||
}]
|
||||
|
||||
const bartProfile = {
|
||||
locale: 'en-US',
|
||||
timezone: 'America/Los_Angeles',
|
||||
endpoint: 'https://planner.bart.gov/bin/mgate.exe',
|
||||
|
||||
auth: {
|
||||
type: 'AID',
|
||||
aid: 'kEwHkFUCIL500dym',
|
||||
},
|
||||
client: {
|
||||
id: 'BART',
|
||||
type: 'WEB',
|
||||
name: 'webapp',
|
||||
l: 'vs_webapp',
|
||||
},
|
||||
ver: '1.25',
|
||||
|
||||
products,
|
||||
|
||||
trip: true,
|
||||
radar: true,
|
||||
refreshJourney: false, // todo: depends on 8615b85 from #204
|
||||
reachableFrom: true,
|
||||
}
|
||||
|
||||
module.exports = bartProfile
|
13
p/bart/readme.md
Normal file
13
p/bart/readme.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# BART profile for `hafas-client`
|
||||
|
||||
[*Bay Area Rapid Transit (BART)*](https://en.wikipedia.org/wiki/Bay_Area_Rapid_Transit) is the rapid transit public transportation system serving the [San Francisco Bay Area](https://en.wikipedia.org/wiki/San_Francisco_Bay_Area). This profile adds *BART* support to `hafas-client`.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const createClient = require('hafas-client')
|
||||
const bartProfile = require('hafas-client/p/BART')
|
||||
|
||||
// create a client with BART profile
|
||||
const client = createClient(bartProfile, 'my-awesome-program')
|
||||
```
|
|
@ -214,6 +214,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
|||
[Berlin public transport (BVG)](https://en.wikipedia.org/wiki/Berliner_Verkehrsbetriebe) | [`bvg-hafas`](https://github.com/public-transport/bvg-hafas) | [docs](p/bvg/readme.md) | [example code](p/bvg/example.js) | [src](p/bvg/index.js)
|
||||
[Österreichische Bundesbahnen (ÖBB)](https://en.wikipedia.org/wiki/Austrian_Federal_Railways) | [`oebb-hafas`](https://github.com/juliuste/oebb-hafas) | [docs](p/oebb/readme.md) | [example code](p/oebb/example.js) | [src](p/oebb/index.js)
|
||||
[*Mobilitéitszentral* (Luxembourg)](https://www.mobiliteit.lu/) | - | [docs](p/mobiliteit-lu/readme.md) | [example code](p/mobiliteit-lu/example.js) | [src](p/mobiliteit-lu/index.js)
|
||||
[Bay Area Rapid Transit (BART)](https://en.wikipedia.org/wiki/Bay_Area_Rapid_Transit) | [docs](p/bart/readme.md) | [example code](p/bart/example.js) | [src](p/bart/index.js)
|
||||
[Nahverkehr Sachsen-Anhalt (NASA)](https://de.wikipedia.org/wiki/Nahverkehrsservice_Sachsen-Anhalt)/[INSA](https://insa.de) | [`insa-hafas`](https://github.com/public-transport/insa-hafas) | [docs](p/insa/readme.md) | [example code](p/insa/example.js) | [src](p/insa/index.js)
|
||||
[Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](https://de.wikipedia.org/wiki/Nahverkehrsverbund_Schleswig-Holstein) | [`nahsh-hafas`](https://github.com/juliuste/nahsh-hafas) | [docs](p/nahsh/readme.md) | [example code](p/nahsh/example.js) | [src](p/nahsh/index.js)
|
||||
[Rhein-Main-Verkehrsverbund (RMV)](https://en.wikipedia.org/wiki/Rhein-Main-Verkehrsverbund) | - | [docs](p/rmv/readme.md) | [example code](p/rmv/example.js) | [src](p/rmv/index.js)
|
||||
|
|
Loading…
Add table
Reference in a new issue