Skip to content

Add attribute classes, object codes above 160 and LNAM helpers - #51

Merged
philliphoff merged 1 commit into
mainfrom
claude/s57-catalogue-codes-lnam
Nov 3, 2026
Merged

philliphoff merged 1 commit into
mainfrom
claude/s57-catalogue-codes-lnam

Conversation

@philliphoff

Copy link
Copy Markdown
Owner

Summary

Items 1–3 of #49. The issue's "nice to have" items are in a separate PR.

1. Attribute classes.

  • S57AttributeDefinition gains Class (S57AttributeClass: Feature, National, Spatial, Cartographic) and IsNational. The docs say national attributes go in NATF and spatial attributes in ATTV (S-57 Part 3, 4.5 and 7.6.4).
  • The generator reads GDAL's Class column and writes it for non-feature attributes only, through an optional constructor parameter that defaults to Feature. It fails on an unknown class.
  • The IHO and Inland ENC tables were regenerated from GDAL v3.12.0. Only the 17 non-feature IHO attributes changed; the Inland ENC table is identical.
  • The AML .g.cs files are untouched. IHO attributes keep their class through the IHO base catalogue, and AML-only codes (20000 and up) default to Feature. This is documented in the XML docs and docs/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. S57ObjectCode above 160.

Correction to the issue: TS_PRH…T_TIMS aren'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, 162 ASLXIS and 163 NEWOBJ, from the Edition 3.1 supplement. The OBJL 163 in the NOAA corpus is NEWOBJ.

  • the cartographic $ classes, named Cartographic + class name, since C# names can't contain $:

    Acronym Code Enum member
    $AREAS 500 CartographicArea
    $LINES 501 CartographicLine
    $CSYMB 502 CartographicSymbol
    $COMPS 503 CartographicCompass
    $TEXTS 504 CartographicText

    C_AREAS was avoided because the C_ prefix already means a collection class. The enum's remarks explain the mapping.

The writer's DSSI NOCR counting uses code ranges, and nothing calls Enum.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.

  • S57LongName gets LnamLength (8), FromLnam(ReadOnlySpan<byte>), ToLnam() and TryWriteLnam(Span<byte>). The layout is AGEN, FIDN, FIDS, each little-endian.
  • S57RecordName.FromLongName(S57LongName) keeps a FIDN above int.MaxValue as the int with the same bits; FeatureId is documented to match. The int properties stay int so the public API doesn't break.
  • The reader's private FFPT LNAM decoder 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) and docs/reading-aml-data-sets.md (attribute classes).

Left open: the ARCSLN/ASLXIS/NEWOBJ docs 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

  • ISO/IEC 8211 (iso8211)
  • S-57 records, topology, updates or exchange sets (s57-enc)
  • Legacy chart viewer, maintenance only (chart-viewer)
  • N/A: build, CI, docs or tooling only

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 LNAM layout.

Tests

  • Added or updated xUnit tests under tests/. They cover:
    • attribute classes
    • each new code
    • every catalogue cartographic class having a member
    • LNAM round trips at uint.MaxValue, int.MaxValue + 1 and the AGEN/FIDS limits
    • hand-built byte-order examples and wrong lengths
    • an FFPT write/read at the limits
  • Test input is built in memory; no real ENC cells are committed
  • dotnet test --configuration Release passes: 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

  • Updated the affected package's src/<project>/README.md
  • Updated guides under docs/ if user-facing behavior changed
  • New public APIs have XML doc comments
  • docfx docfx.json --warningsAsErrors passes, if docs changed

Dependencies

  • No new NuGet dependencies

Breaking changes

None to the binary API; dotnet pack package validation against 0.8.1 passes. Behavioral: S57ObjectCode values 161–163 and 500–504 now have names, so their ToString() is a name rather than a number.


Generated by Claude Code

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
@philliphoff
philliphoff merged commit b00109d into main Nov 3, 2026
12 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.

2 participants