mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
bugfixes 🐛, even more todos
This commit is contained in:
parent
3811b4553c
commit
608a91989f
9 changed files with 14 additions and 11 deletions
|
@ -73,6 +73,8 @@ const parseLine = (profile, l) => {
|
|||
const createParseJourney = (profile, stations, lines, remarks) => {
|
||||
const parseJourney = _createParseJourney(profile, stations, lines, remarks)
|
||||
|
||||
// todo: j.sotRating, j.conSubscr, j.isSotCon, j.showARSLink, k.sotCtxt
|
||||
// todo: j.conSubscr, j.showARSLink, j.useableTime
|
||||
const parseJourneyWithPrice = (j) => {
|
||||
const res = parseJourney(j)
|
||||
|
||||
|
|
|
@ -50,10 +50,8 @@ const parseLine = (profile, l) => {
|
|||
const parseLocation = (profile, l) => {
|
||||
const res = _parseLocation(profile, l)
|
||||
|
||||
// todo: shorten has been made for stations, not any type of location
|
||||
res.name = shorten(res.name)
|
||||
|
||||
if (res.type === 'station') {
|
||||
res.name = shorten(res.name)
|
||||
res.id = to12Digit(res.id)
|
||||
// todo: https://github.com/derhuerst/vbb-hafas/blob/1c64bfe42422e2648b21016d233c808460250308/lib/parse.js#L67-L75
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ const parseDateTime = (profile, date, time) => {
|
|||
|
||||
const offset = time.length > 6 ? parseInt(time.slice(0, -6)) : 0
|
||||
|
||||
console.error(pDate, pTime, offset)
|
||||
const dt = DateTime.fromISO(pDate.join('-') + 'T' + pTime.join(':'), {
|
||||
locale: profile.locale,
|
||||
zone: profile.timezone
|
||||
|
|
|
@ -17,13 +17,14 @@ const parseLocation = (profile, l) => {
|
|||
const station = {
|
||||
type: 'station',
|
||||
id: l.extId,
|
||||
name: l.name,
|
||||
location: res
|
||||
}
|
||||
if ('pCls' in l) station.products = profile.parseProducts(l.pCls)
|
||||
return station
|
||||
}
|
||||
|
||||
if (type === POI) res.id = l.extId
|
||||
if (l.type === POI) res.id = l.extId
|
||||
else if (l.type === ADDRESS) res.address = l.name
|
||||
else res.name = l.name
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ const createParseMovement = (profile, locations, lines, remarks) => {
|
|||
|
||||
return {
|
||||
station: locations[s.locX],
|
||||
departure: dep ? dep.format() : null,
|
||||
arrival: arr ? arr.format() : null
|
||||
departure: dep ? dep.toISO() : null,
|
||||
arrival: arr ? arr.toISO() : null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ const createParseStopover = (profile, stations, lines, remarks, connection) => {
|
|||
}
|
||||
if (st.aTimeR || st.aTimeS) {
|
||||
const arr = profile.parseDateTime(profile, connection.date, st.aTimeR || st.aTimeS)
|
||||
res.arrival = arr.format()
|
||||
res.arrival = arr.toISO()
|
||||
}
|
||||
if (st.dTimeR || st.dTimeS) {
|
||||
const dep = profile.parseDateTime(profile, connection.date, st.dTimeR || st.dTimeS)
|
||||
res.departure = dep.format()
|
||||
res.departure = dep.toISO()
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ const assertIsJungfernheide = (t, s) => {
|
|||
t.ok(isRoughlyEqual(s.location.longitude, 13.299424, .0005))
|
||||
}
|
||||
|
||||
// todo: this doesnt seem to work
|
||||
// todo: DRY with assertValidStationProducts
|
||||
const assertValidProducts = (t, p) => {
|
||||
for (let k of Object.keys(modes)) {
|
||||
t.ok('boolean', typeof modes[k], 'mode ' + k + ' must be a boolean')
|
||||
|
@ -169,7 +171,7 @@ test('Berlin Jungfernheide to Torfstraße 17', co.wrap(function* (t) {
|
|||
|
||||
const d = part.destination
|
||||
assertValidAddress(t, d)
|
||||
t.equal(d.name, 'Torfstraße 17')
|
||||
t.equal(d.address, 'Torfstraße 17')
|
||||
t.ok(isRoughlyEqual(.0001, d.latitude, 52.5416823))
|
||||
t.ok(isRoughlyEqual(.0001, d.longitude, 13.3491223))
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ const assertValidLocation = (t, l, coordsOptional = false) => {
|
|||
}
|
||||
}
|
||||
|
||||
// todo: https://github.com/public-transport/friendly-public-transport-format/tree/babf2b82947ab0e655a4a0e1cbee6b5519af9172/spec#modes
|
||||
const isValidMode = (m) => {
|
||||
return m === 'walking' ||
|
||||
m === 'train' ||
|
||||
|
|
|
@ -203,7 +203,7 @@ test('journeys – station to address', co.wrap(function* (t) {
|
|||
|
||||
const dest = part.destination
|
||||
assertValidAddress(t, dest)
|
||||
t.strictEqual(dest.name, 'Torfstr. 17')
|
||||
t.strictEqual(dest.address, 'Torfstraße 17')
|
||||
t.ok(isRoughlyEqual(.0001, dest.latitude, 52.5416823))
|
||||
t.ok(isRoughlyEqual(.0001, dest.longitude, 13.3491223))
|
||||
assertValidWhen(t, part.arrival)
|
||||
|
|
Loading…
Add table
Reference in a new issue