parse CHKI legs with checkin: true

fixes #267
This commit is contained in:
Jannis R 2022-07-21 21:36:59 +02:00
parent 9f2dcecf19
commit 0a63698100
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 2050 additions and 1 deletions

View file

@ -90,7 +90,7 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg
res.polyline = profile.parsePolyline(ctx, pt.jny.poly)
}
if (pt.type === 'WALK' || pt.type === 'TRSF' || pt.type === 'DEVI') {
if (pt.type === 'WALK' || pt.type === 'TRSF' || pt.type === 'DEVI' || pt.type === 'CHKI') {
res.public = true
res.walking = true
res.distance = pt.gis && pt.gis.dist || null
@ -99,6 +99,7 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg
// todo: pt.resState, pt.resRecommendation
res.transfer = true
}
if (pt.type === 'CHKI') res.checkin = true
// https://gist.github.com/derhuerst/426d4b95aeae701843b1e9c23105b8d4#file-tripsearch-2018-12-05-http-L4207-L4229
if (opt.remarks && pt.gis && Array.isArray(pt.gis.msgL)) {

2019
test/fixtures/sncb-journey-with-chki.json vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
'use strict'
const tap = require('tap')
const createClient = require('..')
const rawProfile = require('../p/sncb')
const resWithChkiLeg = require('./fixtures/sncb-journey-with-chki.json')
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
const {profile} = client
const opt = {
stopovers: false,
tickets: false,
polylines: false,
subStops: false,
entrances: false,
remarks: true,
}
tap.test('parses a journey with a CHKI leg (#267)', (t) => {
const common = profile.parseCommon({profile, opt, res: resWithChkiLeg})
const ctx = {profile, opt, common, res: resWithChkiLeg}
const journey = profile.parseJourney(ctx, resWithChkiLeg.outConL[0])
const checkinLeg = journey.legs[0]
t.equal(checkinLeg.checkin, true, 'checkinLeg.checkin')
t.end()
})