diff --git a/parse/line.js b/parse/line.js index cefc0f2a..a64d119a 100644 --- a/parse/line.js +++ b/parse/line.js @@ -25,6 +25,13 @@ const parseLine = ({profile}, p) => { res.adminCode = p.prodCtx.admin.replace(/-+$/, '') } + if (p.prodCtx && 'string' === typeof p.prodCtx.catOut) { + const productName = p.prodCtx.catOut.trim(); + if (productName != "") { + res.productName = productName; + } + } + if ('cls' in p) { // todo: use profile.products.find() for this const byBitmask = [] diff --git a/test/fixtures/bvg-journey.js b/test/fixtures/bvg-journey.js index 990aa0c2..2a7e777b 100644 --- a/test/fixtures/bvg-journey.js +++ b/test/fixtures/bvg-journey.js @@ -696,6 +696,7 @@ module.exports = { name: 'S2', public: true, adminCode: 'DBS', + productName: 'S', mode: 'train', product: 'suburban', operator: { diff --git a/test/fixtures/db-arrivals.js b/test/fixtures/db-arrivals.js index 76eb6ea2..61f9a9bc 100644 --- a/test/fixtures/db-arrivals.js +++ b/test/fixtures/db-arrivals.js @@ -256,6 +256,7 @@ module.exports = [ name: 'U 7', public: true, adminCode: 'vbbBVU', + productName: 'U', mode: 'train', product: 'subway', operator: { type: 'operator', id: 'nahreisezug', name: 'Nahreisezug' } diff --git a/test/fixtures/db-journey-2.js b/test/fixtures/db-journey-2.js index c936d0b1..1fb2c1d1 100644 --- a/test/fixtures/db-journey-2.js +++ b/test/fixtures/db-journey-2.js @@ -65,6 +65,7 @@ module.exports = { name: 'S 7', public: true, adminCode: '800725', + productName: 'S', mode: 'train', product: 'suburban', operator: { @@ -365,6 +366,7 @@ module.exports = { name: 'U 3', public: true, adminCode: 'swm001', + productName: 'U', mode: 'train', product: 'subway' }, diff --git a/test/fixtures/db-journey-polyline.js b/test/fixtures/db-journey-polyline.js index 36b0618f..20b655fe 100644 --- a/test/fixtures/db-journey-polyline.js +++ b/test/fixtures/db-journey-polyline.js @@ -3952,6 +3952,7 @@ module.exports = { 'name': 'ICE 696', 'public': true, 'adminCode': '80____', + 'productName': 'ICE', 'mode': 'train', 'product': 'nationalExpress', 'operator': { diff --git a/test/fixtures/db-journey.js b/test/fixtures/db-journey.js index a1223602..c6621c62 100644 --- a/test/fixtures/db-journey.js +++ b/test/fixtures/db-journey.js @@ -169,6 +169,7 @@ module.exports = { name: 'ICE 523', public: true, adminCode: '80____', + productName: 'ICE', mode: 'train', product: 'nationalExpress', operator: { diff --git a/test/fixtures/oebb-trip.js b/test/fixtures/oebb-trip.js index ef86dbac..863f170b 100644 --- a/test/fixtures/oebb-trip.js +++ b/test/fixtures/oebb-trip.js @@ -114,6 +114,7 @@ module.exports = { name: 'RJ 742', public: true, adminCode: '81____', + productName: 'RJ', mode: 'train', product: 'nationalExpress', operator: {type: 'operator', id: 'nahreisezug', name: 'Nahreisezug'} diff --git a/test/fixtures/rejseplanen-trip.js b/test/fixtures/rejseplanen-trip.js index d732d0a9..02deafe5 100644 --- a/test/fixtures/rejseplanen-trip.js +++ b/test/fixtures/rejseplanen-trip.js @@ -55,6 +55,7 @@ module.exports = { name: 'Replacement bus RØD', public: true, adminCode: '000001', + productName: 'Togbus', mode: 'train', product: 'o', operator: {type: 'operator', id: 'dsb', name: 'DSB'}, diff --git a/test/fixtures/rsag-journey.js b/test/fixtures/rsag-journey.js index 760e8193..82219d96 100644 --- a/test/fixtures/rsag-journey.js +++ b/test/fixtures/rsag-journey.js @@ -13,6 +13,7 @@ module.exports = { name: 'S2', public: true, adminCode: '800156', + productName: 'S', mode: 'train', product: 's-bahn', operator: { diff --git a/test/fixtures/sbb-journeys.js b/test/fixtures/sbb-journeys.js index 8abdbaa2..b6b17fa9 100644 --- a/test/fixtures/sbb-journeys.js +++ b/test/fixtures/sbb-journeys.js @@ -140,6 +140,7 @@ module.exports = [{ name: 'IC 51', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -172,6 +173,7 @@ module.exports = [{ name: 'IC 5', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -204,6 +206,7 @@ module.exports = [{ name: 'S 5', public: true, adminCode: '000011', + productName: 'S', mode: 'train', product: 'suburban-train', operator: { @@ -244,6 +247,7 @@ module.exports = [{ name: 'IC 6', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -267,6 +271,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -288,6 +293,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -309,6 +315,7 @@ module.exports = [{ name: 'EC 57', public: true, adminCode: '000011', + productName: 'EC', mode: 'train', product: 'international-train', operator: { @@ -330,6 +337,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -361,6 +369,7 @@ module.exports = [{ name: 'IC 1', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -401,6 +410,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -424,6 +434,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -445,6 +456,7 @@ module.exports = [{ name: 'EC 57', public: true, adminCode: '000011', + productName: 'EC', mode: 'train', product: 'international-train', operator: { @@ -466,6 +478,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -487,6 +500,7 @@ module.exports = [{ name: 'IC 61', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -518,6 +532,7 @@ module.exports = [{ name: 'IR 15', public: true, adminCode: '000011', + productName: 'IR', mode: 'train', product: 'interregional-train', operator: { @@ -558,6 +573,7 @@ module.exports = [{ name: 'IC 51', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -590,6 +606,7 @@ module.exports = [{ name: 'IC 5', public: true, adminCode: '000011', + productName: 'IC', mode: 'train', product: 'international-train', operator: { @@ -622,6 +639,7 @@ module.exports = [{ name: 'S 5', public: true, adminCode: '000011', + productName: 'S', mode: 'train', product: 'suburban-train', operator: { diff --git a/test/fixtures/vbb-departures.js b/test/fixtures/vbb-departures.js index af9b5c51..a46b0376 100644 --- a/test/fixtures/vbb-departures.js +++ b/test/fixtures/vbb-departures.js @@ -193,6 +193,7 @@ module.exports = [ name: 'U8', public: true, adminCode: 'BVU', + productName: 'U', mode: 'train', product: 'subway', operator: { @@ -858,6 +859,7 @@ module.exports = [ name: 'U8', public: true, adminCode: 'BVU', + productName: 'U', mode: 'train', product: 'subway', operator: { @@ -1618,6 +1620,7 @@ module.exports = [ name: 'S9', public: true, adminCode: 'DBS', + productName: 'S', mode: 'train', product: 'suburban', operator: { diff --git a/test/fixtures/vbb-journeys.js b/test/fixtures/vbb-journeys.js index 2fecb41b..f61767de 100644 --- a/test/fixtures/vbb-journeys.js +++ b/test/fixtures/vbb-journeys.js @@ -58,6 +58,7 @@ module.exports = [{ name: 'U9', public: true, adminCode: 'BVU', + productName: 'U', mode: 'train', product: 'subway', operator: { @@ -133,6 +134,7 @@ module.exports = [{ name: 'S41', public: true, adminCode: 'DBS', + productName: 'S', mode: 'train', product: 'suburban', operator: { @@ -208,6 +210,7 @@ module.exports = [{ name: 'ICE 1710', public: true, adminCode: 'N80', + productName: 'ICE', mode: 'train', product: 'express', operator: {type: 'operator', id: 'db-regio-ag', name: 'DB Regio AG'}, @@ -232,6 +235,7 @@ module.exports = [{ name: 'IC 2457', public: true, adminCode: 'N80', + productName: 'IC', mode: 'train', product: 'express', operator: { @@ -258,6 +262,7 @@ module.exports = [{ name: 'IC 2055', public: true, adminCode: 'N80', + productName: 'IC', mode: 'train', product: 'express', operator: { @@ -347,6 +352,7 @@ module.exports = [{ name: 'U9', public: true, adminCode: 'BVU', + productName: 'U', mode: 'train', product: 'subway', operator: { @@ -422,6 +428,7 @@ module.exports = [{ name: 'S41', public: true, adminCode: 'DBS', + productName: 'S', mode: 'train', product: 'suburban', operator: { @@ -498,6 +505,7 @@ module.exports = [{ name: 'RE3', public: true, adminCode: '800158', + productName: 'RE', mode: 'train', product: 'regional', operator: {type: 'operator', id: 'db-regio-ag', name: 'DB Regio AG'}, @@ -522,6 +530,7 @@ module.exports = [{ name: 'RE66', public: true, adminCode: '800151', + productName: 'RE', mode: 'train', product: 'regional', operator: { @@ -548,6 +557,7 @@ module.exports = [{ name: 'RE3', public: true, adminCode: '800158', + productName: 'RE', mode: 'train', product: 'regional', operator: { @@ -574,6 +584,7 @@ module.exports = [{ name: 'RE3', public: true, adminCode: '800158', + productName: 'RE', mode: 'train', product: 'regional', operator: { @@ -600,6 +611,7 @@ module.exports = [{ name: 'RE3', public: true, adminCode: '800158', + productName: 'RE', mode: 'train', product: 'regional', operator: { @@ -626,6 +638,7 @@ module.exports = [{ name: 'RE66', public: true, adminCode: '800151', + productName: 'RE', mode: 'train', product: 'regional', operator: { diff --git a/test/fixtures/vsn-departures.js b/test/fixtures/vsn-departures.js index 98c93b6b..a2c0e9d9 100644 --- a/test/fixtures/vsn-departures.js +++ b/test/fixtures/vsn-departures.js @@ -63,6 +63,7 @@ module.exports = { name: 'IC 2315', public: true, adminCode: '80____', + productName: 'IC', mode: 'train', product: 'national', operator: { diff --git a/test/mobiliteit-lu-line.js b/test/mobiliteit-lu-line.js index af78376d..f93b297c 100644 --- a/test/mobiliteit-lu-line.js +++ b/test/mobiliteit-lu-line.js @@ -44,6 +44,7 @@ tap.test('parses a line correctly (mobiliteit.lu)', (t) => { name: 'IC 108', public: true, adminCode: 'C88', + productName: 'IC', mode: 'train', product: 'national-train', })