mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
switch to regio-guide ris for boards
This commit is contained in:
parent
f8a79834b3
commit
c663a35711
6 changed files with 35 additions and 15 deletions
|
@ -1,6 +1,25 @@
|
||||||
const formatStationBoardReq = (ctx, station, type) => {
|
const formatStationBoardReq = (ctx, station, type) => {
|
||||||
const {profile, opt} = ctx;
|
const {profile, opt} = ctx;
|
||||||
|
|
||||||
|
return {
|
||||||
|
endpoint: profile.boardEndpoint,
|
||||||
|
path: (type == 'departures' ? 'departure' : 'arrival') + '/' + station,
|
||||||
|
query: {
|
||||||
|
// TODO direction, fields below
|
||||||
|
modeOfTransport: profile.formatProductsFilter(ctx, opt.products || {}, 'ris'),
|
||||||
|
timeStart: profile.formatTime(profile, opt.when, true),
|
||||||
|
timeEnd: profile.formatTime(profile, opt.when.getTime() + opt.duration * 60 * 1000, true),
|
||||||
|
expandTimeFrame: 'TIME_END', // TODO impact?
|
||||||
|
},
|
||||||
|
method: 'get',
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO separate RIS::Boards profile?
|
||||||
|
const formatRisStationBoardReq = (ctx, station, type) => {
|
||||||
|
const {profile, opt} = ctx;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
endpoint: profile.boardEndpoint,
|
endpoint: profile.boardEndpoint,
|
||||||
path: type + '/' + station,
|
path: type + '/' + station,
|
||||||
|
@ -23,6 +42,7 @@ const formatStationBoardReq = (ctx, station, type) => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
export {
|
export {
|
||||||
formatStationBoardReq,
|
formatStationBoardReq,
|
||||||
|
|
2
index.js
2
index.js
|
@ -89,7 +89,7 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
const {res, common} = await profile.request({profile, opt}, userAgent, req);
|
const {res, common} = await profile.request({profile, opt}, userAgent, req);
|
||||||
|
|
||||||
const ctx = {profile, opt, common, res};
|
const ctx = {profile, opt, common, res};
|
||||||
const results = res[resultsField].map(res => parse(ctx, res)); // todo sort?
|
const results = (res[resultsField] || res.items).map(res => parse(ctx, res)); // todo sort?
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[resultsField]: results,
|
[resultsField]: results,
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
"journeysEndpoint": "https://int.bahn.de/web/api/angebote/fahrplan",
|
"journeysEndpoint": "https://int.bahn.de/web/api/angebote/fahrplan",
|
||||||
"locationsEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte",
|
"locationsEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte",
|
||||||
"nearbyEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte/nearby",
|
"nearbyEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte/nearby",
|
||||||
"boardEndpoint": "https://apis.deutschebahn.com/db/apis/ris-boards/v1/public/",
|
"boardEndpoint": "https://regio-guide.de/@prd/zupo-travel-information/api/public/ri/board/",
|
||||||
"defaultLanguage": "en"
|
"defaultLanguage": "en"
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,15 @@ const createParseArrOrDep = (prefix) => {
|
||||||
const res = {
|
const res = {
|
||||||
tripId: d.journeyID,
|
tripId: d.journeyID,
|
||||||
stop: profile.parseLocation(ctx, d.station),
|
stop: profile.parseLocation(ctx, d.station),
|
||||||
...profile.parseWhen(ctx, null, d.timeSchedule, d.time, d.canceled),
|
...profile.parseWhen(ctx, null, d.timeSchedule ? d.timeSchedule : d.time, d.timePredicted ? d.timePredicted : d.time, d.canceled),
|
||||||
...profile.parsePlatform(ctx, d.platformSchedule, d.platform, d.canceled),
|
...profile.parsePlatform(ctx, d.platformSchedule ? d.platformSchedule : d.platform, d.platformPredicted ? d.platformPredicted : d.platform, d.canceled),
|
||||||
// prognosisType: TODO
|
// prognosisType: TODO
|
||||||
direction: d.transport?.direction?.stopPlaces?.length > 0 && profile.parseStationName(ctx, d.transport?.direction?.stopPlaces[0].name) || null,
|
direction: d.transport?.direction?.stopPlaces?.length > 0 && profile.parseStationName(ctx, d.transport?.direction?.stopPlaces[0].name) || profile.parseStationName(ctx, d.destination?.name) || null,
|
||||||
provenance: profile.parseStationName(ctx, d.transport?.origin?.name) || null,
|
provenance: profile.parseStationName(ctx, d.transport?.origin?.name) || profile.parseStationName(ctx, d.origin?.name) || null,
|
||||||
line: profile.parseLine(ctx, d) || null,
|
line: profile.parseLine(ctx, d) || null,
|
||||||
remarks: [],
|
remarks: [],
|
||||||
origin: profile.parseLocation(ctx, d.transport?.origin) || null,
|
origin: profile.parseLocation(ctx, d.transport?.origin || d.origin) || null,
|
||||||
destination: profile.parseLocation(ctx, d.transport?.destination) || null,
|
destination: profile.parseLocation(ctx, d.transport?.destination || d.destination) || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO pos
|
// TODO pos
|
||||||
|
|
|
@ -4,15 +4,15 @@ const parseLine = (ctx, p) => {
|
||||||
const profile = ctx.profile;
|
const profile = ctx.profile;
|
||||||
const res = {
|
const res = {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: slugg(p.verkehrsmittel?.langText || p.transport?.journeyDescription), // TODO terrible
|
id: slugg(p.verkehrsmittel?.langText || p.transport?.journeyDescription || p.train?.no), // TODO terrible
|
||||||
fahrtNr: p.verkehrsmittel?.nummer || p.transport?.number,
|
fahrtNr: p.verkehrsmittel?.nummer || p.transport?.number || p.train?.no,
|
||||||
name: p.verkehrsmittel?.name || p.zugName || p.transport?.journeyDescription,
|
name: p.verkehrsmittel?.name || p.zugName || p.transport?.journeyDescription || p.train && p.train.category + ' ' + p.train.lineName,
|
||||||
public: true,
|
public: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO res.adminCode
|
// TODO res.adminCode
|
||||||
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category;
|
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category || p.train?.category;
|
||||||
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type);
|
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type || pp.ris == p.train?.type);
|
||||||
res.mode = foundProduct?.mode;
|
res.mode = foundProduct?.mode;
|
||||||
res.product = foundProduct?.id;
|
res.product = foundProduct?.id;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ const parseLocation = (ctx, l) => {
|
||||||
const lid = parse(l.id, {delimiter: '@'});
|
const lid = parse(l.id, {delimiter: '@'});
|
||||||
const res = {
|
const res = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: (l.extId || lid.L || l.evaNumber || '').replace(leadingZeros, '') || null,
|
id: (l.extId || lid.L || l.evaNumber || l.evaNo || '').replace(leadingZeros, '') || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (l.lat && l.lon) {
|
if (l.lat && l.lon) {
|
||||||
|
@ -27,7 +27,7 @@ const parseLocation = (ctx, l) => {
|
||||||
res.longitude = lid.X / 1000000;
|
res.longitude = lid.X / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l.type === STATION || l.extId || l.evaNumber) {
|
if (l.type === STATION || l.extId || l.evaNumber || l.evaNo) {
|
||||||
const stop = {
|
const stop = {
|
||||||
type: 'stop', // TODO station
|
type: 'stop', // TODO station
|
||||||
id: res.id,
|
id: res.id,
|
||||||
|
|
Loading…
Add table
Reference in a new issue