mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parseLocation: L param as fallback ID
This commit is contained in:
parent
9c449958c4
commit
4a79b91680
3 changed files with 9 additions and 4 deletions
|
@ -6,7 +6,7 @@ const DEBUG = process.env.DEBUG === 'hafas-client'
|
||||||
const {join} = require('path')
|
const {join} = require('path')
|
||||||
const createHash = require('create-hash')
|
const createHash = require('create-hash')
|
||||||
const captureStackTrace = DEV ? require('capture-stack-trace') : () => {}
|
const captureStackTrace = DEV ? require('capture-stack-trace') : () => {}
|
||||||
const {stringify} = require('query-string')
|
const {stringify} = require('qs')
|
||||||
const Promise = require('pinkie-promise')
|
const Promise = require('pinkie-promise')
|
||||||
const {fetch} = require('fetch-ponyfill')({Promise})
|
const {fetch} = require('fetch-ponyfill')({Promise})
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"p-retry": "^2.0.0",
|
"p-retry": "^2.0.0",
|
||||||
"p-throttle": "^2.1.0",
|
"p-throttle": "^2.1.0",
|
||||||
"pinkie-promise": "^2.0.1",
|
"pinkie-promise": "^2.0.1",
|
||||||
"query-string": "^6.0.0",
|
"qs": "^6.6.0",
|
||||||
"slugg": "^1.2.0",
|
"slugg": "^1.2.0",
|
||||||
"vbb-parse-line": "^0.3.1",
|
"vbb-parse-line": "^0.3.1",
|
||||||
"vbb-parse-ticket": "^0.2.1",
|
"vbb-parse-ticket": "^0.2.1",
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const {parse} = require('qs')
|
||||||
|
|
||||||
const POI = 'P'
|
const POI = 'P'
|
||||||
const STATION = 'S'
|
const STATION = 'S'
|
||||||
const ADDRESS = 'A'
|
const ADDRESS = 'A'
|
||||||
|
@ -14,10 +16,13 @@ const parseLocation = (profile, opt, {lines}, l) => {
|
||||||
res.longitude = l.crd.x / 1000000
|
res.longitude = l.crd.x / 1000000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lid = parse(l.lid, {delimiter: '@'})
|
||||||
|
const id = (l.extId || lid.L || '').replace(leadingZeros, '') || null
|
||||||
|
|
||||||
if (l.type === STATION) {
|
if (l.type === STATION) {
|
||||||
const stop = {
|
const stop = {
|
||||||
type: l.isMainMast ? 'station' : 'stop',
|
type: l.isMainMast ? 'station' : 'stop',
|
||||||
id: (l.extId || '').replace(leadingZeros, ''),
|
id,
|
||||||
name: l.name ? profile.parseStationName(l.name) : null,
|
name: l.name ? profile.parseStationName(l.name) : null,
|
||||||
location: 'number' === typeof res.latitude ? res : null
|
location: 'number' === typeof res.latitude ? res : null
|
||||||
}
|
}
|
||||||
|
@ -41,7 +46,7 @@ const parseLocation = (profile, opt, {lines}, l) => {
|
||||||
|
|
||||||
if (l.type === ADDRESS) res.address = l.name
|
if (l.type === ADDRESS) res.address = l.name
|
||||||
else res.name = l.name
|
else res.name = l.name
|
||||||
if (l.type === POI) res.id = l.extId && l.extId.replace(leadingZeros, '') || null
|
if (l.type === POI) res.id = id
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue