Skip to content

fix(set_style): repoint hex paint to the layer's real value column (#259) - #260

Merged
cboettig merged 1 commit into
mainfrom
fix/set-style-hex-value-column-259
Jun 20, 2026
Merged

fix(set_style): repoint hex paint to the layer's real value column (#259)#260
cboettig merged 1 commit into
mainfrom
fix/set-style-hex-value-column-259

Conversation

@cboettig

Copy link
Copy Markdown
Member

Fixes #259.

Problem

When a user asks to recolor a dynamic hex layer, the agent calls set_style with a plausible data-driven expression — but hardcodes the value property as ["get","count"]. count is only the real column for agg="COUNT" tilesets. On a layer whose property is e.g. species_richness, ["get","count"] resolves to null on every feature, the interpolate yields no color, and the recolor is a silent no-op.

Observed in padus logs (2026-06-20 ~05:16): "show san diego county gbif richness as hex" → "change the colormap" produced set_style against ["get","count"] while the tileset property was species_richness.

Fix (client-side, deterministic)

  • Store valueColumn on the hex layer's state at addHexTileLayer.
  • New pure helper rewriteValueColumn(expr, valueColumn) in hex-layer-helpers.js recursively repoints any value-bearing ["get", X] to the real column. It leaves the per-resolution res key and already-correct expressions untouched, and reports which properties it repointed.
  • setStyle applies the rewrite for hex layers (those carrying valueColumn) and returns a transparent note so the correction isn't silent.
  • get_map_state now exposes valueColumn for hex layers so the agent can discover the right column.
  • set_style tool description gains a short note that for hex-… layers the value column is the one passed to add_hex_tile_layer, not count.

Non-hex layers are unaffected (no valueColumn in state → no rewrite).

Tests

  • rewriteValueColumn: repoint, no-op on correct column, res left alone, distinct-replacement reporting, literal pass-through, longer get forms left alone.
  • setStyle: hex rewrite applies corrected paint + emits note; correct expression unchanged; non-hex layer not rewritten.

Full suite green (312 tests).

)

The agent builds set_style data-driven expressions without a reliable
signal of a dynamic hex layer's value column, so it defaults to
["get","count"]. On a layer whose property is e.g. species_richness that
get resolves to null on every feature and the ramp silently yields no
color — the recolor is a no-op.

- store valueColumn on hex layer state
- rewriteValueColumn() (pure, in hex-layer-helpers) repoints any
  value-bearing get to the real column, leaving `res` and already-correct
  expressions untouched; setStyle applies it and reports a note
- surface valueColumn in get_map_state so the agent can discover it
- note the dynamic-column rule in the set_style tool description

Tests: rewriteValueColumn unit coverage + setStyle hex rewrite path.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 49.79% 3555 / 7139
🔵 Statements 49.77% 3555 / 7142
🔵 Functions 57.79% 126 / 218
🔵 Branches 82.07% 687 / 837
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
app/hex-layer-helpers.js 100% 100% 100% 100%
app/map-manager.js 46.94% 86.11% 36.58% 46.97% 56-145, 152-156, 162-379, 388-432, 442-454, 462-474, 538-539, 556-557, 676-685, 713-714, 720-723, 732-742, 748-755, 811-814, 822-826, 829-845, 851-852, 858-861, 930-931, 951-953, 975-980, 986-989, 999-1017, 1024-1028, 1036-1129, 1136-1214, 1221-1226, 1238-1284, 1308-1327, 1330-1345, 1355-1357, 1402-1409, 1443-1444, 1477-1481, 415
app/map-tools.js 96.3% 88.88% 56% 96.3% 90-92, 110-112, 449-463
Generated in workflow #102 for commit 3a1ebd5 by the Vitest Coverage Report Action

@cboettig
cboettig merged commit 3ea3ea1 into main Jun 20, 2026
1 check passed
@cboettig
cboettig deleted the fix/set-style-hex-value-column-259 branch June 20, 2026 19:21
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.

set_style builds colormap against hardcoded ["get","count"] instead of the layer's value column → colormap doesn't update

1 participant