Repository navigation
Add attribute classes, object codes above 160 and LNAM helpers - #51
Merged
Merged
Conversation
Items 1-3 of #49: - S57AttributeClass (Feature, National, Spatial, Cartographic) and S57AttributeDefinition.Class/IsNational, from the Class column of GDAL's s57attributes.csv (S-57 Appendix A, Chapter 2). The generator writes it and the IHO table is regenerated from GDAL v3.12.0; the Inland ENC table is unchanged. The AML tables aren't regenerated: their own attributes (20000 and up) take the constructor's Feature default, and the IHO attributes they include keep their IHO class. - S57ObjectCode gains ARCSLN (161), ASLXIS (162) and NEWOBJ (163), and the cartographic classes 500-504 as CartographicArea ($AREAS), CartographicLine ($LINES), CartographicSymbol ($CSYMB), CartographicCompass ($COMPS) and CartographicText ($TEXTS), since '$' can't appear in an identifier. The writer's DSSI counts use code ranges, so they're unchanged. - S57LongName.FromLnam, ToLnam, TryWriteLnam and LnamLength pack and unpack the 8-byte binary LNAM; the reader and writer now use them. S57RecordName.FromLongName(S57LongName) keeps a FIDN above int.MaxValue as the int with the same bits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAmJZEwPd4NoCtWnEjgT9t
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
Items 1–3 of #49. The issue's "nice to have" items are in a separate PR.
1. Attribute classes.
S57AttributeDefinitiongainsClass(S57AttributeClass:Feature,National,Spatial,Cartographic) andIsNational. The docs say national attributes go in NATF and spatial attributes in ATTV (S-57 Part 3, 4.5 and 7.6.4).Classcolumn and writes it for non-feature attributes only, through an optional constructor parameter that defaults toFeature. It fails on an unknown class..g.csfiles are untouched. IHO attributes keep their class through the IHO base catalogue, and AML-only codes (20000 and up) default toFeature. This is documented in the XML docs anddocs/reading-aml-data-sets.md.With the existing
S57ObjectCatalogue, this covers EncDotNet.S100's hand-written tables: code ↔ acronym, type (List vs Enumerated), and NATF.2.
S57ObjectCodeabove 160.Correction to the issue:
TS_PRH…T_TIMSaren't codes 161–167. S-57 Appendix A gives them as 136–142, and the enum already had them. The codes actually missing were:161
ARCSLN, 162ASLXISand 163NEWOBJ, from the Edition 3.1 supplement. The OBJL 163 in the NOAA corpus isNEWOBJ.the cartographic
$classes, namedCartographic+ class name, since C# names can't contain$:$AREASCartographicArea$LINESCartographicLine$CSYMBCartographicSymbol$COMPSCartographicCompass$TEXTSCartographicTextC_AREASwas avoided because theC_prefix already means a collection class. The enum's remarks explain the mapping.The writer's DSSI
NOCRcounting uses code ranges, and nothing callsEnum.IsDefined, so behaviour is unchanged. The one visible effect: codes 500–504 now print as names rather than numbers, for example in the ChartViewer's feature display.3. Long-name helpers.
S57LongNamegetsLnamLength(8),FromLnam(ReadOnlySpan<byte>),ToLnam()andTryWriteLnam(Span<byte>). The layout is AGEN, FIDN, FIDS, each little-endian.S57RecordName.FromLongName(S57LongName)keeps a FIDN aboveint.MaxValueas theintwith the same bits;FeatureIdis documented to match. Theintproperties stayintso the public API doesn't break.LNAMdecoder and the writer's FFPT encoding now use these helpers, so there's one implementation.Docs: short notes in
docs/reading-s57-charts.md(LNAM helpers) anddocs/reading-aml-data-sets.md(attribute classes).Left open: the
ARCSLN/ASLXIS/NEWOBJdocs say "added by a supplement to S-57 Edition 3.1" without naming which one, because the supplement number couldn't be confirmed from the standards in the repo.Standards alignment
iso8211)s57-enc)chart-viewer)Standard section references cited in code or docs: S-57 Part 3 4.5 and 7.6.4 (NATF/ATTV); Appendix A chapters 1 and 2 (object and attribute codes); Part 3 FFPT
LNAMlayout.Tests
tests/. They cover:uint.MaxValue,int.MaxValue + 1and the AGEN/FIDS limitsdotnet test --configuration Releasepasses: 1052 unit tests (1 skipped, the AML real-data test) and 14 performance tests, with no budget changes. 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 to the binary API;
dotnet packpackage validation against 0.8.1 passes. Behavioral:S57ObjectCodevalues 161–163 and 500–504 now have names, so theirToString()is a name rather than a number.Generated by Claude Code