Skip to content

s57: decode the pick report in the engine - #45

Merged
beetlebugorg merged 3 commits into
mainfrom
feat/s57-decode
Aug 3, 2026
Merged

s57: decode the pick report in the engine#45
beetlebugorg merged 3 commits into
mainfrom
feat/s57-decode

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

This branch moves the pick-report decode into the engine so every shell prints the same report.

  • Add the S-57 attribute catalogue as data: 186 attribute labels and 102 enum tables with 1112 values, transcribed from Appendix A, Chapter 2. A code that the source does not confirm is omitted and passes through unchanged.
  • Add the tool "tile57 fcattrs". It reads the vendored S-101 Feature Catalogue XML and writes the S-101 vocabulary: 221 attribute labels, 1022 listed values, and the class names. S-57 acronyms and S-101 codes read separate tables because S-101 changed attributes that it took from S-57. A class alias is used only when exactly one S-101 feature claims it.
  • Add tile57_s57_report. It composes the report a shell renders: a title with the object's key fact, a subtitle, a chip name, notes, decoded rows in reading order, a provenance footnote, and an empty marker when there is nothing to read.

Unknown values stay unchanged at every step. Regenerate the S-101 tables with "tile57 fcattrs <FeatureCatalogue.xml>".

catalog.zig holds the S-57 edition 3.1 attribute catalogue as data: 186
attribute labels and 102 enum tables with 1112 values. The source is
Appendix A, Chapter 2 (November 2000). A code that the source does not
confirm is omitted. An omitted code passes through the report unchanged.

decode.zig reads the catalogue and adds the print rules the catalogue
does not contain: chart abbreviations for light characteristics (LITCHR
4 prints as Q), units for plain numbers, signal sequences, SCAMIN as
'1:30,000 and larger', SORIND as 'Chart 12283 (US)', and S-57 dates.
A '--MMDD' date prints as a yearly date. Unknown values stay unchanged.
The tool 'tile57 fcattrs' reads the vendored S-101 Feature Catalogue XML
and writes catalog_s101.zig: 221 attribute labels and 1022 listed
values, keyed by S-101 attribute code. The decode reads S-57 acronyms
from the S-57 catalogue and S-101 codes from this file.

The two catalogues stay separate. S-101 changed attributes that it took
from S-57: CATTRK became the boolean basedOnFixedMarks, BUISHP keeps
five shapes, CATCOA drops its shore types. 104 S-57 codes are absent or
different in the Feature Catalogue. A decode of an S-57 code through the
S-101 tables would give a wrong value.

Regenerate with:
    tile57 fcattrs <S-101_FC_1.1.0_20230202.xml>
tile57_s57_report turns one queried feature into the report JSON that a
shell renders. The input is the class, the cell name, and the attribute
JSON from the query callback. The output contains: a title with the
object's key fact (a light's characteristic, a depth area's range, a
wreck's least depth), a subtitle, a chip name, notes from INFORM, the
rows decoded and sorted into reading order, a one-line provenance
footnote, and an 'empty' field when there is nothing to read.

fcattrs now also collects the Feature Catalogue's feature types. Class
names did not change in S-101, so the S-57 alias maps safely: HULKES
reads as Hulk. The meta and collection classes that S-101 does not
contain are in a small table in decode.zig.
@beetlebugorg
beetlebugorg merged commit 39d516d into main Aug 3, 2026
5 checks passed
@beetlebugorg
beetlebugorg deleted the feat/s57-decode branch August 3, 2026 23:30
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.

1 participant