Fix ISO 8211 parsing of 8-byte binary format controls (b48)#10
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #9.
Iso8211FieldReadermis-parsed binary format controls of the formbWNwhere the type digit is4(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.ParseBinaryFormattreated the first digit of abWNcontrol as a sign indicator that only handled1(unsigned) and2(signed), returningnullfor any other type. Forb48the first digit is4(floating-point), so the method returnednulland the three 8-byteDCOX/DCOY/DCOZsubfields were silently dropped. This shifted every later subfield by 12 bytes, decodingCMFX/CMFY/CMFZas0and reading the record counts off by three slots.Downstream S-101 code masked the X/Y loss with a hard-coded
1e7fallback, but the Z (sounding/height) factor fell back to the S-57SOMF=10default, making charted soundings ~10× too deep.Fix
FloatingPointformat type (b4x/b5x, IEEE 754) toIso8211SubfieldFormatType.ParseBinaryFormatnow maps the type digit1→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.ConvertFloatingBinary(width 4→float, 8→double) inIso8211FieldReader; updatedToString/ByteSize.Test
Added regression test
GetSubfield_DssiFieldWith8ByteBinaryControls_DecodesCorrectly, which parses the 64-byte DSSI blob from the issue and assertsCMFX=10000000,CMFY=10000000,CMFZ=100,NOIR=85,NOPN=4800,NOMN=5.Full suite: 438/438 passing. No package version bump.