db-vendo-client/p/vbb/parse-loc-dhid.js

19 lines
483 B
JavaScript
Raw Permalink Normal View History

2022-03-07 01:34:33 +01:00
'use strict'
const dhidPrefix = 'A×'
const parseAndAddLocationDHID = (loc, l) => {
if (!Array.isArray(l.gidL)) return;
const dhidGid = l.gidL.find(gid => gid.slice(0, dhidPrefix.length) === dhidPrefix)
if (!dhidGid) return;
const dhid = dhidGid.slice(dhidPrefix.length)
// It seems that the DHID of the parent station is being used, not of the stop.
// if (!loc.ids) loc.ids = {}
// loc.ids.dhid = dhid
loc.stationDHID = dhid
}
module.exports = parseAndAddLocationDHID