Skip to content

fix(style): render complex linestyles on the MapLibre path#19

Merged
beetlebugorg merged 2 commits into
mainfrom
fix/maplibre-complex-linestyles
Jul 13, 2026
Merged

fix(style): render complex linestyles on the MapLibre path#19
beetlebugorg merged 2 commits into
mainfrom
fix/maplibre-complex-linestyles

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

Complex (symbolised) linestyles — cables, IALA/caution/restricted-area
boundaries, anchorages — drew as plain solid strokes on chartplotter-go.

Since the bake stores each run un-tessellated (tagged ls_style) for every
client to re-walk at its own display scale, the generated MapLibre style is
what turns them into dashes + symbols — but those style layers had been
stripped out earlier, so the runs fell through lines-solid and lost their
dashes and embedded marks.

Fix (engine-side only — everything renders from /api/style.json):

  • style.json gains one line-dasharray layer per LineStyles id + a
    symbol-placement:line layer per embedded symbol; lines-solid excludes
    ls_style so nothing double-draws. Patterns ride tile57:linestyles
    metadata so a mariner rebuild keeps them.
  • Line-placed symbols use SYMBOL_SCALE/0.08 (≈0.354), matching the
    tessellated ones — not the full atlas size.
  • tile57_style_template + tile57 style feed the embedded catalogue's
    linestyles in.

Validated: tile57 style --sprite → 64 dasharray + 157 symbol layers
(CTNARE51/ENTRES51/NAVARE51/RESARE51/ACHARE51); restored Go binding test
covers the C-ABI template + BuildStyle round-trip.

Known follow-up: native and MapLibre use different px-per-mm constants
(2.8345 vs 3.7797), so linestyle spacing differs between the two renderers.

Since 2face3a the bake stores each complex-linestyle run UN-tessellated
(tagged ls_style + color_token + width_px), so every client re-walks the
run at its own display scale: replay.zig does it natively for the OpenCPN
plugin, and the generated MapLibre style is supposed to do it via
line-dasharray + symbol-placement:line layers. But c64de73 had stripped
those style layers out (back when the bake tessellated into tiles), leaving
only the dead complexLineLayer stub. Result: the ls_style runs fell through
the lines-solid coalesce filter and drew as plain solid strokes — cables,
the IALA/caution/restricted-area boundaries and anchorages lost their dashes
and embedded chevrons on chartplotter-go.

Restore the engine-side decoration (df39f97), which is where it belongs:
everything renders from the engine style (/api/style.json), so the fix is
one place and the OpenCPN plugin needs no change — both consume the same
un-tessellated runs.

  - style.json gains one line-dasharray layer per analysed LineStyles id
    plus a line-placed symbol layer per embedded symbol (sprite permitting),
    filtered on ls_style; lines-solid now excludes ls_style so nothing
    double-draws. The analysed patterns ride "tile57:linestyles" metadata so
    a mariner rebuild from the template keeps the layers.
  - tile57_style_template + the `tile57 style` CLI feed the embedded
    catalogue's linestyles.json into the style (via bundle.linestylesBytes).

The baker's ls_style gate (registry, period >= 0.5 at 2.8345 px/mm) is a
strict subset of the ids linestylesJson keeps (period >= 0.5 at 3.7797
px/mm), so no baked run is ever left without a matching layer.

Validated: `tile57 style --sprite` emits 64 dasharray line layers + 157
line-placed symbol layers incl. CTNARE51/ENTRES51/NAVARE51/RESARE51/
ACHARE51; the restored Go binding test drives the C ABI template + the
BuildStyle mariner-rebuild round-trip through the metadata carrier.
…tlas size

The restored linestyleLayers used ICON_SIZE for the symbol layers, but that
expression is scale/0.08 read from a per-feature `scale` tile property — and
the un-tessellated ls_style runs carry no such property, so it coalesced to
0.08/0.08 = 1.0 (full atlas size). The embedded chevrons/anchors drew ~2.8x
too large on the MapLibre path.

Pin them to LS_ICON_SIZE = SYMBOL_SCALE/0.08 (≈0.354), the ratio the sprite
atlas is sized for, so the style-placed symbols match the tessellated ones
(scene/linestyle.zig draws them at SYMBOL_SCALE). Re-applies 042dd5e, which
landed after the df39f97 layers this branch restored.
@beetlebugorg beetlebugorg merged commit 8f61fc6 into main Jul 13, 2026
5 checks passed
@beetlebugorg beetlebugorg deleted the fix/maplibre-complex-linestyles branch July 13, 2026 09:15
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