Draw a depth contour's value in the mariner's unit - #40
Merged
Conversation
SAFCON01 in the portrayal catalogue draws a depth contour's value as one glyph per digit. That rule is metres-only, because S-52 has no other unit. A chart shown in feet therefore drew a metric contour label beside feet soundings: a 5.4 m contour read "5.4" next to soundings reading 17 and 18. Port the rule's composition to Zig with a whole-feet variant, beside the SNDFRM04 port that already does this for soundings. Truncate down, so a contour errs shallow: 5.4 m reads 17 ft, never 18. This adds the composition only. The bake and the render paths still emit the catalogue's metric glyphs.
DEPCNT03 calls SAFCON01 to compose a contour's value one glyph per digit, always in metres. A chart shown in feet drew that metric label beside feet soundings: a 5.4 m contour read "5.4" next to soundings reading 17 and 18. Give Surface an optional draw_contour_label. When a surface declares it, the emitter drops the catalogue's SAFCON glyphs and hands over the raw metres, and the surface composes the same glyphs through safconSyms at its own unit. The pixel, vector and GPU surfaces declare it; ascii, query and inspect have no unit of their own and keep the catalogue's glyphs, so they need no change. The bake stores the contour's raw metres plus both composed runs, so the tile stays unit-independent: it is baked once and read in either unit. Replay hands the value to the surface. Contour labels draw on the plain symbol layer, not the sounding layer, whose extra multiplier is the mariner's sounding preference. The MapLibre style does not yet select between the two runs, so a contour label is absent from the style output until it does. The native paths are complete.
A contour label's glyphs share one anchor, each self-positioned by its own pivot. The GPU surface emitted them as symbols, and a symbol below its band window is a collision candidate, so the digits read as overlapping marks and all but one was culled: a 17 ft contour drew as "1" when zoomed out. Emit them as the sounding kind, which is what that kind means — a digit run at a shared anchor. The size argument still passes refDev, so the mariner's sounding multiplier does not apply.
The baked label feature held the composed glyph runs under safcon/safcon_ft only. The MapLibre style resolves a point's icon-image from symbol_name, so a style consumer drew no contour label at all. Carry the metric run as symbol_name too, the way a sounding's sym_s run serves as its icon-image. Replay still routes on valdco before it reaches symbol_name, so the native paths compose in the mariner's unit and draw the label once. A style that swaps to safcon_ft in feet is still owed.
A depth-contour label rides the point layer as a composed SAFCON glyph run. pointSymbolImage resolved it through symbol_name, which carries the metric run, so a style built for feet drew metric contour labels beside feet soundings. Read safcon in metres and safcon_ft in feet, the swap soundingsIconImage already makes between sym_s and sym_s_ft. A chart baked before the feet run existed has no safcon_ft, and falls through to symbol_name rather than drawing nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEPCNT03 calls SAFCON01 to compose a depth contour's value one glyph per digit, always in metres, because S-52 has no other unit. A chart shown in feet drew that metric label beside feet soundings, so a 5.4 m contour read 5.4 next to soundings reading 17 and 18.
This ports SAFCON01's composition to Zig with a whole-feet variant, beside the SNDFRM04 port that already does the same for soundings. Feet truncate down, so a contour errs shallow: 5.4 m reads 17 ft, never 18.
Surface gains an optional draw_contour_label. A surface that declares it makes the emitter drop the catalogue's SAFCON glyphs and take the raw metres instead, then composes the same glyphs at its own unit. The pixel, vector and GPU surfaces declare it. The ascii, query and inspect surfaces have no unit of their own, keep the catalogue's glyphs, and need no change.
The bake stores the contour's raw metres and both composed runs, so a tile stays unit-independent: it is baked once and read in either unit. The metric run also rides as symbol_name, so a style that knows nothing of depth units still draws the label. pointSymbolImage reads safcon in metres and safcon_ft in feet, which is the swap soundingsIconImage already makes between sym_s and sym_s_ft.
A contour label's glyphs share one anchor, each self-positioned by its own pivot, so the GPU surface emits them as the sounding kind. A symbol below its band window becomes a collision candidate, and that reads digits at a shared anchor as an overlap.
A chart baked before this change carries no safcon_ft and falls through to the metric run rather than drawing nothing. Existing archives need a re-bake to show contour labels in feet.
Verified on a re-baked US5MD1MC at z16.5 and z14.2 with feet selected: the labels read 17 and agree with the soundings beside them. The dredged-area label and the bold safety contour are not in this change.