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
40 changes: 30 additions & 10 deletions internal/engine/bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,30 @@ func New() *Baker { return &Baker{bbox: geo.EmptyBox()} }
// Bounds is the union lat/lon bbox of every ingested cell's primitives.
func (b *Baker) Bounds() geo.BoundingBox { return b.bbox }

// lightCharText returns the light-characteristic label the S-101 rule (LITDSN02,
// via LightFlareAndDescription) produced for a LIGHTS feature — the first DrawText
// in its portrayal. The catalogue is the single source of truth for the
// characteristic string (S-52 LITDSN is a CSP), so the inspector and the
// co-located merge harvest THIS rather than re-deriving it in Go.
func lightCharText(passes []portrayal.FeatureBuildPass) string {
for _, pass := range passes {
for _, p := range pass.Build.Primitives {
if t, ok := p.(portrayal.DrawText); ok {
return t.Text
}
}
}
return ""
}

// groupCoLocatedLights finds LIGHTS features that share an exact position and,
// for each such group, returns the merged multi-line characteristic keyed by the
// first (primary) feature index, plus the set of non-primary indices to suppress.
// S-52 PresLib §LIGHTS06: co-located lights combine into one flare + one stacked
// characteristic label rather than drawing N flares/labels on top of each other.
func groupCoLocatedLights(features []s57.Feature) (primaryText map[int]string, skip map[int]bool) {
// Each light's characteristic comes from the catalogue (lightCharText), not a
// second Go reimplementation.
func (b *Baker) groupCoLocatedLights(features []s57.Feature) (primaryText map[int]string, skip map[int]bool) {
type pos struct{ lat, lon float64 }
groups := map[pos][]int{}
for i := range features {
Expand All @@ -446,7 +464,7 @@ func groupCoLocatedLights(features []s57.Feature) (primaryText map[int]string, s
var lines []string
seen := map[string]bool{}
for _, i := range idxs {
ch := BuildLightCharacteristic(features[i].Attributes())
ch := lightCharText(b.portrayer.Passes(&features[i]))
if ch == "" || seen[ch] {
continue
}
Expand Down Expand Up @@ -618,7 +636,7 @@ func (b *Baker) AddCell(chart *s57.Chart) {
}

// Combine co-located lights (S-52 LIGHTS06): one flare + one merged label.
lightPrimary, lightSkip := groupCoLocatedLights(features)
lightPrimary, lightSkip := b.groupCoLocatedLights(features)
b.seenSector = make(map[sectorKey]struct{})
for i := range features {
f := &features[i]
Expand All @@ -630,20 +648,22 @@ func (b *Baker) AddCell(chart *s57.Chart) {
b.curLight = ""
b.curLightSkip = false
b.curLightText = ""
// Boundary symbolization (S-52 §8.6.1): a style-variant area is built
// twice (plain bnd=0 / symbolized bnd=1) so the client toggles boundary
// style live; everything else is one pass tagged bnd=2.
// The portrayer (the build-time embedded catalogue, or --s101) runs the
// S-101 rules to produce the passes.
passes := b.portrayer.Passes(f)
if f.ObjectClass() == "LIGHTS" {
b.curLight = BuildLightCharacteristic(f.Attributes())
// The characteristic string comes from the catalogue rule (LITDSN02),
// harvested from the portrayal — not re-derived in Go.
b.curLight = lightCharText(passes)
b.curLightSkip = lightSkip[i]
if merged, ok := lightPrimary[i]; ok {
b.curLightText = merged
b.curLight = merged // inspector shows the combined characteristic
}
}
// Boundary symbolization (S-52 §8.6.1): a style-variant area is built
// twice (plain bnd=0 / symbolized bnd=1) so the client toggles boundary
// style live; everything else is one pass tagged bnd=2.
// The portrayer (the build-time embedded catalogue, or --s101) runs the
// S-101 rules to produce the passes.
passes := b.portrayer.Passes(f)
for _, pass := range passes {
fb := pass.Build
bnd := int64(pass.Bnd)
Expand Down
235 changes: 0 additions & 235 deletions internal/engine/bake/lightchar.go

This file was deleted.

Loading