Skip to content

Fix ISO 8211 parsing of 8-byte binary format controls (b48)#10

Merged
philliphoff merged 1 commit into
mainfrom
philliphoff/fix-iso8211-b48-binary-width
Jun 18, 2026
Merged

Fix ISO 8211 parsing of 8-byte binary format controls (b48)#10
philliphoff merged 1 commit into
mainfrom
philliphoff/fix-iso8211-b48-binary-width

Conversation

@philliphoff

Copy link
Copy Markdown
Owner

Summary

Fixes #9.

Iso8211FieldReader mis-parsed binary format controls of the form bWN where the type digit is 4 (IEEE-754 floating-point), e.g. b48 — the 8-byte origin shifts used by the S-100/S-101 DSSI field (3b48,10b14).

Root cause

Iso8211DataDescriptiveRecordReader.ParseBinaryFormat treated the first digit of a bWN control as a sign indicator that only handled 1 (unsigned) and 2 (signed), returning null for any other type. For b48 the first digit is 4 (floating-point), so the method returned null and the three 8-byte DCOX/DCOY/DCOZ subfields were silently dropped. This shifted every later subfield by 12 bytes, decoding CMFX/CMFY/CMFZ as 0 and reading the record counts off by three slots.

Downstream S-101 code masked the X/Y loss with a hard-coded 1e7 fallback, but the Z (sounding/height) factor fell back to the S-57 SOMF=10 default, making charted soundings ~10× too deep.

Fix

  • Added a FloatingPoint format type (b4x/b5x, IEEE 754) to Iso8211SubfieldFormatType.
  • ParseBinaryFormat now maps the type digit 1→unsigned, 2→signed, 4/5→floating-point, and honors the second digit as the byte width — so (3b48,10b14) expands to three 8-byte floats followed by ten 4-byte unsigned ints.
  • Added ConvertFloatingBinary (width 4→float, 8→double) in Iso8211FieldReader; updated ToString/ByteSize.

Test

Added regression test GetSubfield_DssiFieldWith8ByteBinaryControls_DecodesCorrectly, which parses the 64-byte DSSI blob from the issue and asserts CMFX=10000000, CMFY=10000000, CMFZ=100, NOIR=85, NOPN=4800, NOMN=5.

Full suite: 438/438 passing. No package version bump.

The binary format-control parser treated the first digit of a bWN control
as a sign indicator handling only 1 (unsigned) and 2 (signed), returning
null for floating-point types such as b48. This dropped the three 8-byte
DCOX/DCOY/DCOZ origin-shift subfields in the S-100/S-101 DSSI field
(3b48,10b14), shifting every later subfield by 12 bytes and decoding
CMFX/CMFY/CMFZ as 0.

Honor the second digit as the byte width and add a FloatingPoint format
type for b4x/b5x (IEEE 754) so (3b48,10b14) expands to three 8-byte
floating-point subfields followed by ten 4-byte unsigned integers. Adds a
regression test parsing the 64-byte DSSI blob from issue #9.

Fixes #9

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@philliphoff philliphoff merged commit cc19240 into main Jun 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iso8211FieldReader mis-parses 8-byte binary format controls (b48) — DSSI factors decoded as 0, soundings 10× too deep

1 participant