2024-02-06 22:58:49 +01:00
|
|
|
import slugg from 'slugg';
|
2017-12-16 01:23:11 +01:00
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
const parseLine = (ctx, p) => {
|
|
|
|
const profile = ctx.profile;
|
2019-10-20 00:19:11 +02:00
|
|
|
const res = {
|
|
|
|
type: 'line',
|
2024-12-07 22:46:04 +00:00
|
|
|
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,
|
2024-02-06 22:58:49 +01:00
|
|
|
public: true,
|
|
|
|
};
|
2018-03-16 17:00:06 +01:00
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
// TODO res.adminCode
|
2024-12-07 22:46:04 +00:00
|
|
|
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category;
|
|
|
|
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type)
|
2024-12-07 16:16:31 +00:00
|
|
|
res.mode = foundProduct?.mode;
|
|
|
|
res.product = foundProduct?.id;
|
2020-03-03 18:06:46 +01:00
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
res.operator = profile.parseOperator(ctx, p.verkehrsmittel?.zugattribute || p.zugattribute);
|
2024-02-06 22:58:49 +01:00
|
|
|
return res;
|
|
|
|
};
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
parseLine,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|