mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59: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 {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 {
|
||||
endpoint: profile.boardEndpoint,
|
||||
path: type + '/' + station,
|
||||
|
@ -23,6 +42,7 @@ const formatStationBoardReq = (ctx, station, type) => {
|
|||
},
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
export {
|
||||
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 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 {
|
||||
[resultsField]: results,
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
"journeysEndpoint": "https://int.bahn.de/web/api/angebote/fahrplan",
|
||||
"locationsEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte",
|
||||
"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"
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ const createParseArrOrDep = (prefix) => {
|
|||
const res = {
|
||||
tripId: d.journeyID,
|
||||
stop: profile.parseLocation(ctx, d.station),
|
||||
...profile.parseWhen(ctx, null, d.timeSchedule, d.time, d.canceled),
|
||||
...profile.parsePlatform(ctx, d.platformSchedule, d.platform, 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.platformSchedule : d.platform, d.platformPredicted ? d.platformPredicted : d.platform, d.canceled),
|
||||
// prognosisType: TODO
|
||||
direction: d.transport?.direction?.stopPlaces?.length > 0 && profile.parseStationName(ctx, d.transport?.direction?.stopPlaces[0].name) || null,
|
||||
provenance: profile.parseStationName(ctx, d.transport?.origin?.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) || profile.parseStationName(ctx, d.origin?.name) || null,
|
||||
line: profile.parseLine(ctx, d) || null,
|
||||
remarks: [],
|
||||
origin: profile.parseLocation(ctx, d.transport?.origin) || null,
|
||||
destination: profile.parseLocation(ctx, d.transport?.destination) || null,
|
||||
origin: profile.parseLocation(ctx, d.transport?.origin || d.origin) || null,
|
||||
destination: profile.parseLocation(ctx, d.transport?.destination || d.destination) || null,
|
||||
};
|
||||
|
||||
// TODO pos
|
||||
|
|
|
@ -4,15 +4,15 @@ const parseLine = (ctx, p) => {
|
|||
const profile = ctx.profile;
|
||||
const res = {
|
||||
type: 'line',
|
||||
id: slugg(p.verkehrsmittel?.langText || p.transport?.journeyDescription), // TODO terrible
|
||||
fahrtNr: p.verkehrsmittel?.nummer || p.transport?.number,
|
||||
name: p.verkehrsmittel?.name || p.zugName || p.transport?.journeyDescription,
|
||||
id: slugg(p.verkehrsmittel?.langText || p.transport?.journeyDescription || p.train?.no), // TODO terrible
|
||||
fahrtNr: p.verkehrsmittel?.nummer || p.transport?.number || p.train?.no,
|
||||
name: p.verkehrsmittel?.name || p.zugName || p.transport?.journeyDescription || p.train && p.train.category + ' ' + p.train.lineName,
|
||||
public: true,
|
||||
};
|
||||
|
||||
// TODO res.adminCode
|
||||
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category;
|
||||
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type);
|
||||
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 || pp.ris == p.train?.type);
|
||||
res.mode = foundProduct?.mode;
|
||||
res.product = foundProduct?.id;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ const parseLocation = (ctx, l) => {
|
|||
const lid = parse(l.id, {delimiter: '@'});
|
||||
const res = {
|
||||
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) {
|
||||
|
@ -27,7 +27,7 @@ const parseLocation = (ctx, l) => {
|
|||
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 = {
|
||||
type: 'stop', // TODO station
|
||||
id: res.id,
|
||||
|
|
Loading…
Add table
Reference in a new issue