Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support reduced fare passengers, parse "Kleinkindabteil" remarks #235

Open
tordans opened this issue Jul 3, 2021 · 1 comment
Open

support reduced fare passengers, parse "Kleinkindabteil" remarks #235

tordans opened this issue Jul 3, 2021 · 1 comment

Comments

@tordans
Copy link

tordans commented Jul 3, 2021

Is there a way to solve this user story?

I want to journey from LocA to LocB with 2 adults + 1 child "0-5 years" on some day between Date1 and Date2 and pick the train wich the least "Auslastung" and a reservation for a "Kleinkindabteil/-bereich" (not "Familienbereich") is available.

Thanks for hints.

@derhuerst
Copy link
Member

Is there a way to solve this user story?

Whever is displayed in the DB Navigator app could also be parsed by hafas-client. Not every is parsed as of right now, though.

I want to journey from LocA to LocB with 2 adults + 1 child "0-5 years"

AFAIR currently hafas-client's DB profile doesn't support children yet:

hafas-client/p/db/index.js

Lines 154 to 170 in cec4f4d

const transformJourneysQuery = ({opt}, query) => {
const filters = query.jnyFltrL
if (opt.bike) filters.push(bike)
query.trfReq = {
jnyCl: opt.firstClass === true ? 1 : 2,
tvlrProf: [{
type: 'E',
redtnCard: opt.loyaltyCard
? formatLoyaltyCard(opt.loyaltyCard)
: null
}],
cType: 'PK'
}
return query
}

But I expect support for this to be very easy to add.

on some day between Date1 and Date2

You would have to iterate a) through all dates, and b) through all results for the day (using res.laterRef as documented).

and pick the train wich the least "Auslastung"

hafas-client's DB profile parses the occupancy level (or load factor) is provided:

hafas-client/p/db/index.js

Lines 217 to 224 in cec4f4d

const parseJourneyLegWithLoadFactor = ({parsed, res, opt}, raw) => {
const tcocX = raw.jny && raw.jny.dTrnCmpSX && raw.jny.dTrnCmpSX.tcocX
if (Array.isArray(tcocX) && Array.isArray(res.common.tcocL)) {
const load = parseLoadFactor(opt, res.common.tcocL, tcocX)
if (load) parsed.loadFactor = load
}
return parsed
}

and a reservation for a "Kleinkindabteil/-bereich" (not "Familienbereich") is available.

hafas-client parses all regular (as in not special ones, e.g. a reference to a stop's ID within another API) remarks. I'd have to check though if and how it actually parses the Kleinkindabteil" remark.

This is what (a simplified version of) a raw response including a "Kleinkindabteil" remark looks like:
{
	"common": {
		"locL": [
						{
				"lid": "A=1@O=Salzburg Hbf@X=13045559@Y=47812824@U=81@L=8100002@",
				"type": "S",
				"name": "Salzburg Hbf",
				"extId": "8100002",
				"crd": {
					"x": 13045604,
					"y": 47812851,
					"floor": 0
				},
				"pCls": 6271
			},
			{
				"lid": "A=1@O=Erfurt Hbf@X=11038502@Y=50972550@U=81@L=8010101@",
				"type": "S",
				"name": "Erfurt Hbf",
				"extId": "8010101",
				"crd": {
					"x": 11038502,
					"y": 50972550,
					"floor": 0
				},
				"pCls": 23
			}
		],
		"prodL": [
			{
				"name": "EC 218",
				"number": "218",
				"cls": 4,
				"oprX": 0,
				"prodCtx": {
					"name": "EC 218  ",
					"num": "218",
					"matchId": "218",
					"catOut": "EC      ",
					"catOutS": "EC",
					"catOutL": "EuroCity",
					"catIn": "EC",
					"catCode": "2",
					"admin": "81____"
				}
			}
		],
		"opL": [
			{
				"name": "Salzburg AG - O-Bus",
				"url": "www.obus.at"
			}
		],
		"remL": [
			{
				"type": "A",
				"code": "KK",
				"prio": 610,
				"icoX": 19,
				"txtN": "Kleinkindabteil"
			}
		]
	},
	"type": "DEP",
	"jnyL": [
		{
			"jid": "2|#VN#1#ST#1619093960#PI#0#ZI#453536#TA#0#DA#30521#1S#8100173#1T#545#LS#8010101#LT#1900#PU#81#RT#1#CA#EC#ZE#218#ZB#EC 218  #PC#2#FR#8100173#FT#545#TO#8010101#TT#1900#",
			"prodX": 0,
			"dirTxt": "Erfurt Hbf",
			"status": "P",
			"stbStop": {
				"locX": 5,
				"idx": 19,
				"dPltfS": {
					"type": "PL",
					"txt": "1"
				},
				"dTimeS": "100000",
				"type": "N"
			},
			"msgL": [
				{
					"type": "REM",
					"remX": 10,
					"fLocX": 5,
					"tLocX": 6
				}
			]
		}
	]
}

@derhuerst derhuerst changed the title Filter by reservation of "Kleinkindabteil/-bereich" support reduced fare passengers, parse "Kleinkindabteil" remarks Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants