parseCommon: resolve **.msgL[] before **.locX

This commit is contained in:
Jannis R 2021-01-26 21:02:50 +01:00
parent 6c4785b05b
commit 0f284e09b8
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -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 = []
if (Array.isArray(c.locL)) {
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 = []
if ((opt.polylines || opt.polyline) && Array.isArray(c.polyL)) {
common.polylines = c.polyL.map(p => profile.parsePolyline(ctx, p))