diff --git a/src/frame.ts b/src/frame.ts index 0738fcc..fc96f89 100644 --- a/src/frame.ts +++ b/src/frame.ts @@ -427,12 +427,11 @@ export class Frame implements IFrame { // Emit comment section as we parse if (withStructure) { - const commentFields: Field[] = [{ type: FieldType.STRING, name: "text", length: comment.length }]; structure.push({ name: "comment", data: new TextEncoder().encode(remainder).buffer, isString: true, - fields: [...(extras.fields || []), ...commentFields] + fields: extras.fields || [] }); } } else if (withStructure && extras.fields) { @@ -441,7 +440,7 @@ export class Frame implements IFrame { name: "comment", data: new TextEncoder().encode("").buffer, isString: true, - fields: [...(extras.fields || [])] + fields: extras.fields || [] }); } @@ -807,7 +806,7 @@ export class Frame implements IFrame { type: FieldType.STRING, name: "altitude", data: new TextEncoder().encode(altMatch[1]).buffer, - value: altitude.toFixed(3) + "m", + value: altitude.toFixed(1) + "m", length: 6 } ]; @@ -845,7 +844,7 @@ export class Frame implements IFrame { type: FieldType.STRING, name: "range (rrrr)", length: 4, - value: extras.range.toString() + "km" + value: extras.range.toFixed(1) + "km" } ); } @@ -1091,7 +1090,6 @@ export class Frame implements IFrame { { type: FieldType.STRING, name: "comment", - value: commentBefore, length: commentBefore.length } ] @@ -1102,7 +1100,6 @@ export class Frame implements IFrame { { type: FieldType.STRING, name: "comment", - value: comment, length: comment.length } ] @@ -1324,14 +1321,11 @@ export class Frame implements IFrame { }); if (comment && comment.length > 0) { - const commentFields: Field[] = [ - { type: FieldType.STRING, name: "comment", length: comment.length, value: comment } - ]; segments.push({ name: "comment", data: new TextEncoder().encode(remainder).buffer, isString: true, - fields: [...(extras.fields || []), ...commentFields] + fields: extras.fields || [] }); } else if (extras.fields) { segments.push({ @@ -1648,20 +1642,19 @@ export class Frame implements IFrame { position.comment = comment; if (withStructure) { - const commentFields: Field[] = [{ type: FieldType.STRING, name: "comment", length: comment.length }]; segment.push({ - name: "Comment", + name: "comment", data: new TextEncoder().encode(remainder).buffer, isString: true, - fields: [...(extras.fields || []), ...commentFields] + fields: extras.fields || [] }); } } else if (withStructure && extras.fields) { segment.push({ - name: "Comment", + name: "comment", data: new TextEncoder().encode(remainder).buffer, isString: true, - fields: [...(extras.fields || [])] + fields: extras.fields || [] }); } @@ -1784,29 +1777,26 @@ export class Frame implements IFrame { const doNotArchive = remainder.includes(DO_NOT_ARCHIVE_MARKER); let comment = remainder; - const extrasItem = this.parseCommentExtras(comment, withStructure); - comment = extrasItem.comment; + const extras = this.parseCommentExtras(comment, withStructure); + comment = extras.comment; if (comment) { position.comment = comment; if (withStructure) { - const commentFields: Field[] = [ - { type: FieldType.STRING, name: "comment", length: comment.length, value: comment } - ]; segment.push({ - name: "Comment", + name: "comment", data: new TextEncoder().encode(remainder).buffer, isString: true, - fields: [...(extrasItem.fields || []), ...commentFields] + fields: extras.fields || [] }); } - } else if (withStructure && extrasItem.fields) { + } else if (withStructure && extras.fields) { // No free-text comment, but extras fields exist: emit comment-only segment segment.push({ - name: "Comment", + name: "comment", data: new TextEncoder().encode(remainder).buffer, isString: true, - fields: [...(extrasItem.fields || [])] + fields: extras.fields || [] }); } @@ -1817,7 +1807,7 @@ export class Frame implements IFrame { alive, position }; - this.attachExtras(payload, extrasItem); + this.attachExtras(payload, extras); if (withStructure) { return { payload, segment };