From 0f284e09b811a8a2d67a3e2513cab8e2a8f6dac8 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 26 Jan 2021 21:02:50 +0100 Subject: [PATCH] parseCommon: resolve **.msgL[] before **.locX --- parse/common.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/parse/common.js b/parse/common.js index 410adb84..70af04e9 100644 --- a/parse/common.js +++ b/parse/common.js @@ -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))