mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
parse admincode, operator where available
This commit is contained in:
parent
615c36650e
commit
126077582b
7 changed files with 76 additions and 12 deletions
|
@ -11,13 +11,16 @@ const parseLine = (ctx, p) => {
|
||||||
public: true,
|
public: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO res.adminCode
|
const adminCode = p.administrationId || p.administration?.id || p.administration?.administrationID;
|
||||||
|
if (adminCode) {
|
||||||
|
res.adminCode = adminCode;
|
||||||
|
}
|
||||||
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category || p.train?.category || p.kurztext;
|
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category || p.train?.category || p.kurztext;
|
||||||
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type || pp.ris == p.train?.type || pp.ris_alt == p.train?.type || pp.dbnav_short == p.produktGattung);
|
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type || pp.ris == p.train?.type || pp.ris_alt == p.train?.type || pp.dbnav_short == p.produktGattung);
|
||||||
res.mode = foundProduct?.mode;
|
res.mode = foundProduct?.mode;
|
||||||
res.product = foundProduct?.id;
|
res.product = foundProduct?.id;
|
||||||
|
|
||||||
res.operator = profile.parseOperator(ctx, p.verkehrsmittel?.zugattribute || p.zugattribute || p.attributNotizen); // TODO regio-guide op
|
res.operator = profile.parseOperator(ctx, p.verkehrsmittel?.zugattribute || p.zugattribute || p.attributNotizen || p.administration);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,13 @@ const parseOperator = (ctx, zugattrib) => {
|
||||||
if (!zugattrib) {
|
if (!zugattrib) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (zugattrib.operatorName) {
|
||||||
|
return {
|
||||||
|
type: 'operator',
|
||||||
|
id: zugattrib.operatorCode,
|
||||||
|
name: zugattrib.operatorName,
|
||||||
|
};
|
||||||
|
}
|
||||||
const bef = zugattrib.find(z => z.key == 'BEF' || z.key == 'OP');
|
const bef = zugattrib.find(z => z.key == 'BEF' || z.key == 'OP');
|
||||||
if (!bef) {
|
if (!bef) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -32,6 +32,7 @@ Depending on the configured profile, db-vendo-client will use multiple different
|
||||||
| polylines | only for `trip()` | only for `refreshJourney()/trip()`, mutually exclusive with tickets |
|
| polylines | only for `trip()` | only for `refreshJourney()/trip()`, mutually exclusive with tickets |
|
||||||
| trip ids used | HAFAS trip ids for journeys, RIS trip ids for boards (static on train splits?) | HAFAS trip ids |
|
| trip ids used | HAFAS trip ids for journeys, RIS trip ids for boards (static on train splits?) | HAFAS trip ids |
|
||||||
| line.id/fahrtNr used | unreliable/route id for journeys, actual fahrtNr for boards | unreliable/route id |
|
| line.id/fahrtNr used | unreliable/route id for journeys, actual fahrtNr for boards | unreliable/route id |
|
||||||
|
| adminCode/operator | adminCode only for boards | only for `journeys()` |
|
||||||
| `stop()` | ❌ | ✅ |
|
| `stop()` | ❌ | ✅ |
|
||||||
| assumed backend API stability | less stable | more stable |
|
| assumed backend API stability | less stable | more stable |
|
||||||
|
|
||||||
|
|
49
test/fixtures/db-arrivals.js
vendored
49
test/fixtures/db-arrivals.js
vendored
|
@ -22,7 +22,12 @@ const dbArrivals = [
|
||||||
productName: 'S',
|
productName: 'S',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'suburban',
|
product: 'suburban',
|
||||||
operator: null,
|
adminCode: '08',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'S',
|
||||||
|
name: 'DB Regio, S-Bahn Berlin',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
@ -62,7 +67,12 @@ const dbArrivals = [
|
||||||
productName: 'U',
|
productName: 'U',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'subway',
|
product: 'subway',
|
||||||
operator: null,
|
adminCode: 'vbbBVU',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'DPN',
|
||||||
|
name: 'Nahreisezug',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
@ -108,7 +118,12 @@ const dbArrivals = [
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
mode: 'bus',
|
mode: 'bus',
|
||||||
product: 'bus',
|
product: 'bus',
|
||||||
operator: null,
|
adminCode: 'vbbBVB',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'DPN',
|
||||||
|
name: 'Nahreisezug',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
@ -154,7 +169,12 @@ const dbArrivals = [
|
||||||
productName: 'S',
|
productName: 'S',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'suburban',
|
product: 'suburban',
|
||||||
operator: null,
|
adminCode: '08',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'S',
|
||||||
|
name: 'DB Regio, S-Bahn Berlin',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
@ -194,7 +214,12 @@ const dbArrivals = [
|
||||||
productName: 'U',
|
productName: 'U',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'subway',
|
product: 'subway',
|
||||||
operator: null,
|
adminCode: 'vbbBVU',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'DPN',
|
||||||
|
name: 'Nahreisezug',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
@ -240,7 +265,12 @@ const dbArrivals = [
|
||||||
productName: 'S',
|
productName: 'S',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'suburban',
|
product: 'suburban',
|
||||||
operator: null,
|
adminCode: '08',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'S',
|
||||||
|
name: 'DB Regio, S-Bahn Berlin',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
@ -280,7 +310,12 @@ const dbArrivals = [
|
||||||
productName: 'U',
|
productName: 'U',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'subway',
|
product: 'subway',
|
||||||
operator: null,
|
adminCode: 'vbbBVU',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'DPN',
|
||||||
|
name: 'Nahreisezug',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [
|
remarks: [
|
||||||
{
|
{
|
||||||
|
|
21
test/fixtures/db-departures-regio-guide.js
vendored
21
test/fixtures/db-departures-regio-guide.js
vendored
|
@ -22,7 +22,12 @@ const dbDepartures = [
|
||||||
productName: 'RE',
|
productName: 'RE',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'regional',
|
product: 'regional',
|
||||||
operator: null,
|
adminCode: 'GARE',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'RE',
|
||||||
|
name: 'Arverio Baden-Württemberg (RE)',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [],
|
remarks: [],
|
||||||
origin: null,
|
origin: null,
|
||||||
|
@ -55,7 +60,12 @@ const dbDepartures = [
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
mode: 'bus',
|
mode: 'bus',
|
||||||
product: 'bus',
|
product: 'bus',
|
||||||
operator: null,
|
adminCode: 'vgn063',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'DPN',
|
||||||
|
name: 'Nahreisezug',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [],
|
remarks: [],
|
||||||
origin: null,
|
origin: null,
|
||||||
|
@ -88,7 +98,12 @@ const dbDepartures = [
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
mode: 'bus',
|
mode: 'bus',
|
||||||
product: 'bus',
|
product: 'bus',
|
||||||
operator: null,
|
adminCode: 'vgn063',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 'DPN',
|
||||||
|
name: 'Nahreisezug',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
remarks: [],
|
remarks: [],
|
||||||
origin: null,
|
origin: null,
|
||||||
|
|
2
test/fixtures/dbnav-refresh-journey.js
vendored
2
test/fixtures/dbnav-refresh-journey.js
vendored
|
@ -41,6 +41,7 @@ const dbNavJourney = {
|
||||||
productName: 'RB',
|
productName: 'RB',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'regional',
|
product: 'regional',
|
||||||
|
adminCode: 'V6RB__',
|
||||||
operator: {
|
operator: {
|
||||||
type: 'operator',
|
type: 'operator',
|
||||||
id: 'vlexx',
|
id: 'vlexx',
|
||||||
|
@ -151,6 +152,7 @@ const dbNavJourney = {
|
||||||
productName: 'IC',
|
productName: 'IC',
|
||||||
mode: 'train',
|
mode: 'train',
|
||||||
product: 'national',
|
product: 'national',
|
||||||
|
adminCode: '80____',
|
||||||
operator: {
|
operator: {
|
||||||
type: 'operator',
|
type: 'operator',
|
||||||
id: 'db-fernverkehr-ag',
|
id: 'db-fernverkehr-ag',
|
||||||
|
|
|
@ -184,6 +184,7 @@ tap.test('parses regio guide ruf correctly', (t) => {
|
||||||
product: 'taxi',
|
product: 'taxi',
|
||||||
productName: 'RUF',
|
productName: 'RUF',
|
||||||
mode: 'taxi',
|
mode: 'taxi',
|
||||||
|
adminCode: 'vrn062',
|
||||||
operator: null,
|
operator: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue