Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<h1 align="center">tile57</h1>

<p align="center">
<b>⚓ An S-57/S-101 chart engine: vector tiles, S-52 styles, PNG and PDF.</b><br>
tile57 turns IHO S-57 ENC cells into vector tiles (MLT or MVT) with a matching MapLibre
S-52 style, or renders finished charts directly to PNG and PDF — one Zig library with a
C ABI, compiled natively or to WASM.
<b>⚓ An S-101 / S-57 chart engine: vector tiles, S-52 styles, PNG and PDF.</b><br>
tile57 reads native IHO <b>S-101</b> ENC charts — and legacy <b>S-57</b> cells — and turns
them into vector tiles (MLT or MVT) with a matching MapLibre S-52 style, or renders finished
charts directly to PNG and PDF — one Zig library with a C ABI, compiled natively or to WASM.
</p>

<p align="center">
Expand Down Expand Up @@ -32,9 +32,9 @@ entirely with AI assistance. A few specific goals shape its design:
Claude and reviewed by a human. The project tests how far AI can carry the heavy lifting of
spec interpretation, test coverage, and implementation correctness on a non-trivial domain.

- **Spec adherence first.** The goal is to implement S-57 decoding, S-101 portrayal, and S-52
display as faithfully as possible, using the actual IHO spec documents and the official
Portrayal Catalogue — not approximations or shortcuts.
- **Spec adherence first.** The goal is to implement native S-101 and S-57 decoding, S-101
portrayal, and S-52 display as faithfully as possible, using the actual IHO spec documents
and the official Portrayal Catalogue — not approximations or shortcuts.

- **Cross-platform via Zig.** Zig's build system and cross-compilation support let the same
core compile to native (Linux, macOS, Windows) and **WASM** without code changes. Go and Zig
Expand All @@ -59,14 +59,17 @@ entirely with AI assistance. A few specific goals shape its design:

---

**tile57** decodes NOAA/IHO **S-57** ENC cells and generates **vector tiles** by
`(z, x, y)` — MapLibre Tiles (MLT, the default; MapLibre GL JS ≥ 5.12
decodes them natively) or Mapbox Vector Tiles — running the
official IHO **S-101 Portrayal Catalogue** in embedded Lua to produce S-52
nautical portrayal. Alongside the tiles it emits a **MapLibre GL style** and the
portrayal **assets** it references — colour tables, line styles, and the sprite
+ area-fill pattern atlases — so a renderer like
[MapLibre](https://github.com/maplibre/maplibre-native) can draw a chart directly.
**tile57** reads native IHO **S-101** ENC charts (S-100 Part 10a) *and* legacy
NOAA/IHO **S-57** ENC cells — the format is detected from the `.000` file itself —
and generates **vector tiles** by `(z, x, y)`: MapLibre Tiles (MLT, the default;
MapLibre GL JS ≥ 5.12 decodes them natively) or Mapbox Vector Tiles. A native
S-101 dataset feeds the portrayal engine directly; an S-57 cell is converted to
the S-101 model first. Either way, the official IHO **S-101 Portrayal Catalogue**
runs in embedded Lua to produce S-52 nautical portrayal. Alongside the tiles it
emits a **MapLibre GL style** and the portrayal **assets** it references — colour
tables, line styles, and the sprite + area-fill pattern atlases — so a renderer
like [MapLibre](https://github.com/maplibre/maplibre-native) can draw a chart
directly.

It holds only its working set:

Expand All @@ -83,13 +86,18 @@ It holds only its working set:

## Pipeline

Both source formats converge on the same S-101 feature records — a native S-101
dataset produces them directly; an S-57 cell is adapted into them:

```
S-57 ENC cell (.000)
│ ISO 8211 decode src/iso8211/
S-57 feature + geometry model src/s57/
│ adapt S-57 → S-101 features src/s101/ (adapter)
S-101 ENC (.000) S-57 ENC cell (.000)
│ ISO 8211 decode │ ISO 8211 decode src/iso8211/
▼ ▼
S-100 spatial + feature S-57 feature + geometry src/s57/ · src/s101/
records model
│ assemble to S-101 │ adapt S-57 → S-101 (native.zig / adapter.zig)
└──────────────┬──────────────┘
S-101 feature records
│ S-101 portrayal (embedded Lua) src/portray/ + rules
Expand All @@ -100,10 +108,14 @@ render Surface ──► MVT / MLT tiles (src/tiles/) + MapLibre style.json +
└───► PNG raster / vector PDF / terminal text (src/render/)
```

The stages are separate Zig modules — `iso8211`, `s57`, `s101`, `tiles`,
`render`, `scene`, `style` — pure Zig with no libc; only the Lua portrayal
(`portray`) and the sprite rasterizer (`sprite`) pull in C. See
[the architecture docs](docs/docs/architecture.md).
A native S-101 chart is read straight into the S-101 model — its in-band code
tables already carry the S-101 class and attribute names — so no conversion runs;
its `.001…` update files are applied on load. An S-57 cell is read into the S-57
model and adapted (a best-effort, S-65-guided step; see
[limitations](docs/docs/limitations.md)). The stages are separate Zig modules —
`iso8211`, `s57`, `s101`, `tiles`, `render`, `scene`, `style` — pure Zig with no
libc; only the Lua portrayal (`portray`) and the sprite rasterizer (`sprite`) pull
in C. See [the architecture docs](docs/docs/architecture.md).

## Use it from Zig

Expand Down Expand Up @@ -151,6 +163,8 @@ and the asset/atlas generators. See [the C API docs](docs/docs/c-api.md).

The offline tool bakes charts and emits portrayal assets:

Any `.000` — native S-101 or S-57 — works everywhere; the format is auto-detected.

```sh
zig build # builds zig-out/bin/tile57
tile57 bake CELL.000 -o out/ # one cell -> out/tiles/<CELL>.pmtiles + partition.tpart
Expand All @@ -159,6 +173,7 @@ tile57 assets -o assets/ # colortables + linestyles + sprite
tile57 png ENC_ROOT --view -76.48,38.974,15 --size 1600x1200 -o chart.png
tile57 pdf ENC_ROOT --view -76.48,38.974,15 --size 1600x1200 -o chart.pdf
tile57 ascii CELL.000 --view -76.48,38.974,13 --ansi --tui # the chart in your terminal
tile57 s101 CELL.000 # inspect a native S-101 dataset
```

## Build
Expand Down
5 changes: 4 additions & 1 deletion docs/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ uses the engine from Zig and C. It assumes you have finished
## 1. Bake a chart with the CLI

The `tile57` binary is the offline tool. It bakes ENC charts to PMTiles and emits
the portrayal assets a renderer needs:
the portrayal assets a renderer needs. Every `CELL.000` below can be a native S-101
chart or an S-57 cell — the format is detected from the file, so the same commands
work on either:

```sh
zig build # builds zig-out/bin/tile57
Expand All @@ -39,6 +41,7 @@ $T pdf CELL.000 --view -76.48,38.974,15 --size 1600x1200 -o chart.pdf
# Inspect / summarise
$T inspect out/tiles/US5MD1MC.pmtiles # zoom range + tile counts for one chart
$T cell CELL.000 # summarise an S-57 chart
$T s101 CELL.000 # inspect a native S-101 dataset
$T version
```

Expand Down
Loading