diff --git a/p/mobiliteit-lu/example.js b/p/mobiliteit-lu/example.js new file mode 100644 index 00000000..a70023d3 --- /dev/null +++ b/p/mobiliteit-lu/example.js @@ -0,0 +1,48 @@ +'use strict' + +const createClient = require('../..') +const mobiliteitProfile = require('.') + +const client = createClient(mobiliteitProfile, 'hafas-client example') + +const mersch = '160904001' +const bruxellesCentral = '300000079' + +// from Mersch to Bruxelles Central +client.journeys(mersch, bruxellesCentral, {results: 1}) +// .then(({journeys}) => { +// const leg = journeys[0].legs[0] +// return client.trip(leg.id, leg.line.name, {polyline: true}) +// }) + +// client.locations('mersch', {results: 3}) +// client.stop(mersch) +// client.nearby({ +// type: 'location', +// latitude: 49.7523, +// longitude: 6.1103 +// }, {distance: 500}) + +// client.departures(mersch, {duration: 5}) +// client.arrivals(mersch, {duration: 10, linesOfStops: true}) + +// client.radar({ +// north: 49.9, +// west: 6.11, +// south: 49.7, +// east: 6.13 +// }, {results: 10}) +// client.reachableFrom({ +// type: 'location', +// id: '990005227', +// address: 'Mersch, Rue Mies 1', +// latitude: 49.746044, longitude: 6.102228, +// }, { +// when: new Date('2020-10-10T10:00:00+02:00'), +// maxDuration: 30 +// }) + +.then(data => { + console.log(require('util').inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/mobiliteit-lu/index.js b/p/mobiliteit-lu/index.js new file mode 100644 index 00000000..28fcd7e3 --- /dev/null +++ b/p/mobiliteit-lu/index.js @@ -0,0 +1,33 @@ +'use strict' + +const products = require('./products') + +const transformReqBody = (ctx, body) => { + body.client = { + type: 'IPH', + id: 'HAFAS', + v: '4000200', + name: 'mobiliteit.luPROD', + os: 'iPhone OS 9.3.5', + } + body.ver = '1.15' + body.auth = {aid: 'Aqf9kNqJLjxFx6vv'} + body.lang = 'de' + + return body +} + +const mobiliteitLuProfile = { + locale: 'de-LU', + timezone: 'Europe/Luxembourg', + endpoint: 'https://travelplanner.mobiliteit.lu/hafas/mgate.exe', + transformReqBody, + + products: products, + + trip: true, + radar: true, + reachableFrom: true, +} + +module.exports = mobiliteitLuProfile; diff --git a/p/mobiliteit-lu/products.js b/p/mobiliteit-lu/products.js new file mode 100644 index 00000000..6fafc324 --- /dev/null +++ b/p/mobiliteit-lu/products.js @@ -0,0 +1,44 @@ +'use strict' + +module.exports = [ + { + id: 'express-train', + mode: 'train', + bitmasks: [1], + name: 'local train (TGV/ICE)', + short: 'TGV/ICE', + default: true + }, + { + id: 'national-train', + mode: 'train', + bitmasks: [6], + name: 'national train (IC/RE/IRE)', + short: 'IC/RE/IRE', + default: true + }, + { + id: 'local-train', + mode: 'train', + bitmasks: [8], + name: 'local train (RB/TER)', + short: 'RB/TER', + default: true + }, + { + id: 'bus', + mode: 'bus', + bitmasks: [32], + name: 'Bus', + short: 'Bus', + default: true + }, + { + id: 'tram', + mode: 'train', + bitmasks: [256], + name: 'Tram', + short: 'Tram', + default: true + } +] diff --git a/p/mobiliteit-lu/readme.md b/p/mobiliteit-lu/readme.md new file mode 100644 index 00000000..5b64f590 --- /dev/null +++ b/p/mobiliteit-lu/readme.md @@ -0,0 +1,18 @@ +# mobiliteit.lu profile for `hafas-client` + +[*mobiliteit.lu*](https://www.mobiliteit.lu) provides public transport data for Luxembourg. This profile adds *mobiliteit.lu*-specific customizations to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const mobiliteitProfile = require('hafas-client/p/mobiliteit-lu') + +// create a client with mobiliteit.lu profile +const client = createClient(mobiliteitProfile, 'my-awesome-program') +``` + + +## Customisations + +- parses *mobiliteit.lu*-specific products diff --git a/readme.md b/readme.md index 8cb18198..5a7f4ba8 100644 --- a/readme.md +++ b/readme.md @@ -212,6 +212,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [Berlin & Brandenburg public transport (VBB)](https://en.wikipedia.org/wiki/Verkehrsverbund_Berlin-Brandenburg) | [`vbb-hafas`](https://github.com/public-transport/vbb-hafas) | [docs](p/vbb/readme.md) | [example code](p/vbb/example.js) | [src](p/vbb/index.js) [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) [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)