Repository navigation
Add typed DSID/DSPM codes and a lexical-level helper - #52
Merged
Merged
Conversation
Closes the "smaller, nice to have" items of #49. Typed codes: enums whose values are the exact S-57 codes, so callers can cast to and from the existing int properties on S57DataSetIdentification and S57DataSetParameters (left unchanged, with no new properties, so the API baseline and the record ToString fingerprints are unaffected): - S57ExchangePurpose (EXPP), S57ProductSpecification (PRSP: ENC, ODD, Inland ENC 10; AML 51-57 stay with AmlProduct), S57ApplicationProfile (PROF), S57DataStructure (DSTR) - S57HorizontalDatum (HDAT, HORDAT's 131 values), S57VerticalDatum (VDAT/SDAT, VERDAT's 30 values), S57DepthUnits, S57HeightUnits, S57PositionalAccuracyUnits, S57CoordinateUnits (COUN) Each int property's docs name its enum. Lexical levels: S57LexicalLevel names AALL/NALL levels 0-2, and S57LexicalLevels offers Lowest(IEnumerable<string?>), CanEncode and an opt-in WithLowestLevels(S57Document) that sets AALL/NALL from the document's ATTF/NATF values. They share S57FieldEncoder's checks with the writer. Characters outside the BMP (and unpaired surrogates) can't be encoded at any level, so Lowest throws ArgumentException for them. The writer's default output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAmJZFjoPbwaxxeU38tpqC
This was referenced Nov 3, 2026
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
The "Smaller, nice to have" items of #49. Items 1–3 are in a separate PR.
Typed codes. Each enum value is the exact S-57 code, so callers can cast to and from the existing
intproperties, and codes an enum doesn't name still cast through as numbers. Theintproperties and the records'ToStringoutput are unchanged; each property's XML docs now name its enum.EXPPS57ExchangePurpose(New 1, Revision 2)PRSPS57ProductSpecification(Enc 1, DataDictionary 2, InlandEnc 10)PROFS57ApplicationProfile(EncNew 1, EncRevision 2, DataDictionary 3)DSTRS57DataStructure(1–4, TopologyNotRelevant 255)HDATS57HorizontalDatum(all 131HORDATvalues;WGS84= 2)VDAT/SDATS57VerticalDatum(all 30VERDATvalues)DUNI/HUNI/PUNIS57DepthUnits,S57HeightUnits,S57PositionalAccuracyUnitsCOUNS57CoordinateUnitsS57ProductSpecificationis there for writers.S57ProductKindis for reading and can't be cast back to a code: itsInlandEncis 3, not 10. The AML codes 51–57 stay withAmlProduct, whose values are already PRSP codes.Lexical levels.
S57LexicalLevelnames the levels:Ascii0,Latin11,Ucs22.S57LexicalLevels.Lowest(IEnumerable<string?>)returns the lowest level that can encode every string. An empty set givesAscii.S57LexicalLevels.CanEncode(string?, S57LexicalLevel)checks a single string.S57LexicalLevels.WithLowestLevels(S57Document)is an opt-in way to setAALL/NALLfrom a document'sATTF/NATFvalues. It throws if anATTFvalue needs UCS-2, whichATTFdoesn't allow. The writer's default output is unchanged.LowestthrowsArgumentException.S57FieldEncoder), so the two can't disagree. Its surrogate check moved into a shared method; the bytes written are the same.This replaces EncDotNet.S100's
S101ToS57LexicalLevels.Docs. In
docs/writing-s57-charts.md, the example uses the enums, there's a subfield-to-enum table, andWithLowestLevelsis explained.Left open:
S57ApplicationProfilenames only the S-57 codes 1–3. The AML profile codes 4–20 cast through as unnamed values.TryLowestvariant for non-BMP text.Standards alignment
iso8211)s57-enc)chart-viewer)Standard section references cited in code or docs: S-57 Part 3 §7.3.1.1 (DSID/DSSI), §7.3.2.1 (DSPM) and clause 2.4 (lexical levels); Appendix A attributes
HORDATandVERDAT.Tests
tests/. They cover:HORDAT/VERDATWithLowestLevelsreproducing the golden cell byte for bytedotnet test --configuration Releasepasses: 1036 unit tests and 14 performance tests. It also passes merged with the other EncDotNet.S57: attribute catalogue, object codes 161+ and long-name helpers #49 PR.Documentation
src/<project>/README.mddocs/if user-facing behavior changeddocfx docfx.json --warningsAsErrorspasses, if docs changedDependencies
Breaking changes
None. All the types are new, and existing properties and writer output are unchanged.
dotnet packpackage validation against 0.8.1 passes.Generated by Claude Code