Skip to content

Object model for NATO Additional Military Layers (AML) cells #42

Closed

Description

@philliphoff

EncDotNet.S57 reads NATO Additional Military Layers (AML) cells today, but only as bare numbers. AML is the S-57-encoded family of military overlay products defined in STANAG 7170 and distributed by UKHO. It uses the same ISO 8211 records as ENC, with its own object and attribute catalogues. This issue adds an object model so AML cells can be identified, named and inspected. Portrayal is out of scope: the AML portrayal specification is an S-52 .dai file released only to holders of the S-52 Presentation Library.

What we know

All public sources are on the Admiralty AML page: product specifications, the AML Implementation Guidance Document (Edition 1, 2018), the Handbook, the catalogues and test data.

A scan of the public test data with EncDotNet.S57 0.8.1 found:

  • All 76 unique cells parse without errors. They are the UKHO AML 1.0 base, update and representative sets, and the Bundeswehr AML 3.0 trials data.

  • Detection from the dataset header:

    DSID PRSP PRED PROF
    AML 1.0/2.1 51 MFF, 52 RAL, 53 LBO, 54 CLB, 55 ESB, 56 SBO 1.0 or 2.1 Per product, base and update (e.g. CLB 4/5, ESB 6/7, LBO 10/11, MFF 12/13, RAL 16/17, SBO 18/19)
    AML 3.0 57 (not listed in the 2018 guidance document) 3.0 20

    FRID GRUP is always 255.

  • Codes. AML-specific object and attribute codes start at 20484 and use lowercase acronyms. AML 3.0 adds codes 40101 and up. Codes used in the data are fully covered by the matching catalogue, apart from two standard IHO codes (C_ASSO and attribute 189) used in 1.0 cells:

    Catalogue Object classes Attributes
    O&A Catalogue v1.1.6 (AML 1.0) 171 385
    O&A Catalogue v2.x (AML 2.1) 174 387
    Feature and Attribute Catalogue v3.0.1 (AML 3.0) 258 473 (plus enumerations and feature–attribute bindings)
  • DSID COMT is structured. It carries title=…; IDO Status = …; Protective Marking = …; Owner Authority = …. The guidance says systems should display the protective marking prominently. In the 1.0 sample cells the degree sign in title decodes as U+FFFD, so the text encoding of this field needs checking.

  • Geometry. One RAL cell uses ARCC/AR2D arcs. They parse, but S57VectorRecord doesn't expose them, so arc edges lose their curve. CLB uses SG3D, which is already supported.

Scope

  • Object catalogue abstraction. A lookup from object and attribute codes to acronym, name, attribute type and enumerated values. Ship tables for standard IHO S-57, IENC extensions (17000+), and AML 1.0, 2.1 and 3.0. Generate the AML tables from the public catalogues as our own code tables. Don't redistribute the spreadsheets or their definition text: they are UKHO/NATO documents with no stated licence.
  • AML detection. Identify a cell's AML product and version from PRSP/PRED/PROF, and choose the matching catalogue.
  • AML header metadata. Parse COMT into title, IDO status, protective marking, owner authority and caveat. Fix the decoding if it is wrong.
  • Arc geometry. Expose ARCC/AR2D on vector records, ideally with a densified polyline helper.

Rendering is out of scope here. So is AML+ / S-501, the S-100 successor, which is still a draft.

Done when

  • Every code in the public AML test data resolves to a named class or attribute in the right catalogue version.
  • Tests use small synthetic cells built with the ISO 8211 writer. The UKHO and Bundeswehr test data stays local and is not committed.
  • A RAL arc edge round-trips with its arc parameters.

Downstream: EncDotNet.S100 will route AML cells away from the S-57 → S-101 translation and report them as AML.

Activity

  1. added
    enhancement
    on Nov 2, 2026
  2. philliphoff commented on Nov 2, 2026

    @philliphoff
    OwnerAuthor

    Downstream: philliphoff/EncDotNet.S100#1236 (recognise AML cells instead of translating them to S-101).

  3. philliphoff commented on Nov 3, 2026

    @philliphoff
    OwnerAuthor

    Implementation plan

    Direction: AML data sets stay S57Documents

    An AML cell should be read as a plain S57Document and S57Chart. Don't make a separate document type, and don't add a shared base type. Put an AML layer on top that looks up the product and its catalogue and wraps the document, rather than inheriting from it.

    • Nothing in the document model depends on the catalogue. The reader, writer, ApplyChanges, S57Chart topology, the exchange-set and CATALOG.031 code, and S-63 checks only deal with records and fields. All 76 test cells already parse unchanged. Only two places assume the ENC catalogue:
      • S57ObjectCode is an enum named for IHO codes. AML codes such as 20484 still fit in it as numbers; they just have no name.
      • S57Chart.CoverageAreas uses M_COVR. That's a standard IHO meta class, so it still applies to AML.
    • There's already a precedent. Inland ENC cells (PRSP = 10) come through S57Document today. AML is the same kind of case: same encoding, different catalogue.
    • The product is only known after reading. It's identified from DSID inside the file, so separate types would mean the reader returning a union, or callers checking the file before choosing a reader.
    • A shared base type would break things for little gain. S57Document and S57Chart are sealed records with public constructors. An abstract base, or generics over a catalogue type, would change the public API. The real differences are what the codes mean and what the header says, so they belong in a separate layer.
    • It suits the downstream issue. EncDotNet.S100 only needs to answer "is this AML?" from a document it has already read.

    Naming: type names use DataSet, following S-57 and the existing S57DataSetIdentification and S57DataSetParameters. Prose keeps saying "cell".

    1. Catalogue abstraction (core, works for any S-57 product)

    • Add S57ObjectCatalogue. It looks up an object class by code or acronym (acronym, name, primitives) and an attribute by code or acronym (acronym, name, type E/L/F/I/A/S, enumerated values).
    • Ship these built-in tables: IHO (S-57 Edition 3.1), Inland ENC (IHO plus codes from 17000), and AML 1.0, 2.1 and 3.0.
      • Generate the AML tables with a script under scripts/. It reads the UKHO spreadsheets from a local path and writes C# code tables with codes, acronyms, types and enumerations only, no definition text. The spreadsheets are never committed.
      • The AML tables are built as IHO plus the AML entries, which also covers C_ASSO and attribute 189 in the 1.0 cells.
    • Add S57ObjectCatalogue.For(S57DataSetIdentification) to choose the table from PRSP/PRED, falling back to IHO.
    • Keep S57ObjectCode as it is, with no AML members. Catalogues are versioned, and an enum can't give the same code a different meaning in a different version.

    2. Product detection

    • Add S57ProductIdentity with Kind (Enc, InlandEnc, Aml, Unknown), the AML product (MFF, RAL, LBO, CLB, ESB, SBO, and 57 for the integrated 3.0 product), Version, and base or update from PROF. Use the mappings in the table above.
    • Expose it as S57DataSetIdentification.Product. This is the only thing EncDotNet.S100 needs.

    3. AML header metadata

    • Fix how DSID COMT is decoded. It's currently read through the generic string path, so the degree sign becomes U+FFFD. Decode it as Latin-1, the way ATTF text at lexical level 1 already is. Do the same for DSPM and FFPT COMT, and make the writer encode it the same way.
    • Add AmlDataSetMetadata.TryParse(string comment). It splits on ; and =, matches keys case-insensitively, and keeps unknown keys in a dictionary. It returns title, IDO status, protective marking, owner authority and caveat.

    4. AmlDataSet view (by composition)

    • Add AmlDataSet, built from an S57Chart or S57Document. It exposes the product identity, the metadata, the chosen catalogue, and helpers that resolve a feature's object class and attributes. Building one from a non-AML data set throws; TryCreate returns false instead.
    • Put it in an EncDotNet.S57.Aml namespace in the existing package. It could become a separate EncDotNet.Aml package, like EncDotNet.Noaa, if the core package should stay IHO-only. Product detection stays in core either way.

    5. Arc geometry

    • Read ARCC and AR2D (and ELLP/EL2D if wanted) into S57VectorRecord. Write them back out in S57DocumentWriter, add their fields to the DDR builder, and check that ApplyChanges keeps them.
    • Add a densify helper that turns an arc into a polyline. Have S57Edge and the line and area geometry builders use it, so arc edges keep their curve.

    6. Tests and docs

    • Build small synthetic cells with the ISO 8211 writer:
      • detection for each PRSP/PRED/PROF combination
      • COMT with Latin-1 bytes
      • code lookup in each catalogue version
      • a RAL arc edge round-tripping with its arc parameters
    • Add a local-only test, skipped when an environment variable isn't set, that checks every code in the UKHO and Bundeswehr test data resolves in its catalogue. The data itself is never committed.
    • Add a docs page for reading AML data sets, and update docs/architecture.md to say the document model is shared and the catalogue depends on the product.

    Order

    1. Fix COMT decoding and expose arcs. These are independent fixes.
    2. Catalogue abstraction with the IHO and Inland ENC tables.
    3. Product detection. This unblocks EncDotNet.S100.
    4. The AML catalogue tables, generated by the script.
    5. AmlDataSet and the metadata parsing.

    Each step is a reasonable PR on its own. Steps 2 and 4 add public API, so the package validation baseline will need to accept the new types.

    Open question: does AML 3.0 reuse any 1.0 or 2.1 code with a different meaning? If not, a single combined AML table plus version flags would be simpler than three tables.


    Generated by Claude Code

  4. philliphoff commented on Nov 3, 2026

    @philliphoff
    OwnerAuthor

    Done, and released in v0.10.0.

    Done-when check. The local-only test AmlDataSetCorpusTests passes on all 82 unique cells of the public AML sample and test data (#54). These are the 76 cells described above plus the 6 cells of the AML 2.1 base exchange set, with 281,045 feature records and 835,069 attribute values. For every cell:

    • the cell is detected as AML
    • every OBJL and ATTL resolves in its catalogue (AML 1.0, 2.1 or 3.0)
    • the cell builds an S57Chart

    The update cells also build on their own.

    What landed:

    PR Change
    #43 COMT is read and written as Latin-1, so the degree sign no longer decodes as U+FFFD. AmlDataSetMetadata parses title, IDO status, protective marking, owner authority and caveat.
    #44 S57DataSetIdentification.Product (S57ProductIdentity) detects ENC, Inland ENC and AML from PRSP/PRED/PROF.
    #45, #47 S57ObjectCatalogue with IHO and Inland ENC tables. For(...) and GetObjectCatalogue() choose a catalogue by product.
    #46 ARCC/AR2D/EL2D/CT2D arcs are read, written and kept through updates. S57ArcDensifier turns them into polylines, so arc edges keep their curve.
    #48 The AML 1.0, 2.1 and 3.0 catalogues, generated by scripts/GenerateAmlCatalogues.cs from the UKHO spreadsheets. The tables hold codes, acronyms, names, types and values, but no definition text. No code changes meaning in a way that could share one table, so there are three tables.
    #50 The AmlDataSet view, the local real-data test and docs/reading-aml-data-sets.md.
    #54 Fixes to the real-data test: it now skips CATALOG.031, and it only parses a COMT written as key=value pairs.

    Next, downstream: philliphoff/EncDotNet.S100#1236 can now detect AML cells with document.DataSetIdentification?.Product.Kind == S57ProductKind.Aml and report them as AML instead of translating them to S-101.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions