mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parseCommon: resolve **.msgL[] before **.locX
This commit is contained in:
parent
6c4785b05b
commit
0f284e09b8
1 changed files with 19 additions and 16 deletions
|
@ -62,6 +62,25 @@ const parseCommonData = (_ctx) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolve .msgL[] references
|
||||||
|
// todo: `himMsgEdgeL[].msgRefL[]` look different, it seems they only reference
|
||||||
|
// `common.himL[]` items?
|
||||||
|
const parseRemarkRef = (ref) => {
|
||||||
|
if (ref.type === 'REM' && ref.hint) {
|
||||||
|
return omit(ref, ['type', 'remX'])
|
||||||
|
}
|
||||||
|
if (ref.type === 'HIM' && ref.warning) {
|
||||||
|
return omit(ref, ['type', 'himX'])
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
matches['**.msgL'].forEach(([refs, parents]) => {
|
||||||
|
// todo: store as parents[0].(hints|warnings)
|
||||||
|
parents[0].remarkRefs = refs
|
||||||
|
.map(parseRemarkRef)
|
||||||
|
.filter(ref => ref !== null)
|
||||||
|
})
|
||||||
|
|
||||||
common.locations = []
|
common.locations = []
|
||||||
if (Array.isArray(c.locL)) {
|
if (Array.isArray(c.locL)) {
|
||||||
common.locations = c.locL.map(loc => profile.parseLocation(ctx, loc))
|
common.locations = c.locL.map(loc => profile.parseLocation(ctx, loc))
|
||||||
|
@ -101,22 +120,6 @@ const parseCommonData = (_ctx) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve .msgL[] references
|
|
||||||
const parseRemarkRef = (ref) => {
|
|
||||||
if (ref.type === 'REM' && ref.hint) {
|
|
||||||
return omit(ref, ['type', 'remX'])
|
|
||||||
}
|
|
||||||
if (ref.type === 'HIM' && ref.warning) {
|
|
||||||
return omit(ref, ['type', 'himX'])
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
matches['**.msgL'].forEach(([refs, parents]) => {
|
|
||||||
parents[0].remarkRefs = refs
|
|
||||||
.map(parseRemarkRef)
|
|
||||||
.filter(ref => ref !== null)
|
|
||||||
})
|
|
||||||
|
|
||||||
common.polylines = []
|
common.polylines = []
|
||||||
if ((opt.polylines || opt.polyline) && Array.isArray(c.polyL)) {
|
if ((opt.polylines || opt.polyline) && Array.isArray(c.polyL)) {
|
||||||
common.polylines = c.polyL.map(p => profile.parsePolyline(ctx, p))
|
common.polylines = c.polyL.map(p => profile.parsePolyline(ctx, p))
|
||||||
|
|
Loading…
Add table
Reference in a new issue