Skip to content

fix(map): align legend warnings and grid aliases with their data - #2187

Closed
giswqs wants to merge 1 commit into
mainfrom
sweep/interface-quality-2026-11-15
Closed

giswqs wants to merge 1 commit into
mainfrom
sweep/interface-quality-2026-11-15

Conversation

@giswqs

@giswqs giswqs commented Nov 15, 2026

Copy link
Copy Markdown
Member

Summary

Unique Values now avoids a misleading rare-class warning when a legend lists every configured value because its statistics cannot enumerate the raster's values. The new regression covers both the all-values case and the sampled-subset case where the warning still applies.

MGRS measured grids also accept the epsg 32632 spelling already supported by projection lookup. QGIS bookmark imports retain their existing group order while using set membership instead of repeatedly scanning prior groups.

Deferred review points: legend warning, MGRS alias, bookmark groups.

Testing

  • Focused Unique Values legend regression passed in sweep validation.
  • Existing MGRS grid regression, extended with both EPSG spellings, passed in sweep validation.
  • cargo fmt --all --check and git diff --check.
  • Validation uses GDAL 3.13.3.
  • Full workspace tests and WebAssembly validation are pending; this PR is submitted before long-running checks finish, as requested.

UI evidence

Before/after captures have been rendered and are being attached. They show a classified raster reloaded from a source with too many values for an enumerated statistics list: the legend still lists every configured value, and the false rare-class warning disappears.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 97bd5346-e7b6-4eb2-8c4e-83eb20db1f1f
Commits

Reviewing files that changed from the base of the PR and between ce40749 and ca01083.

Files selected for processing: 3

  • crates/map/src/layout.rs
  • crates/map/src/qgis/structure.rs
  • crates/map/src/raster.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@giswqs

giswqs commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Superseded by the combined release-quality PR #2196 so these related fixes can be reviewed together.

@giswqs giswqs closed this Nov 15, 2026
Comment thread crates/map/src/raster.rs
return true;
}
let masked = self.masked_stats();
let stats = masked.as_ref().and_then(|m| m.first()).or_else(|| self.data.as_ref()?.bands.get(*band).map(|b| &b.stats));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality (maintainability), not a bug: the "masked statistics first, else the band's own" selection is now written three times (classes_unknown around line 2162, the stats closure in legend_classes around line 2250, and here). lists_every_class has to pick the same statistics as legend_classes, or the rare-class warning can disagree with the legend it describes. A small shared helper would keep them in step, e.g. fn legend_stats(&self, band: usize) -> Option<Arc<Vec<BandStats>>> or a method returning Option<&BandStats> for the masked-or-band choice, used by all three sites.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Reviewed the 3-file diff (layout.rs, qgis/structure.rs, raster.rs) against AGENTS.md. No prior review threads existed, so there were no earlier concerns to skip.

Bugs

  • None found. I traced the new lists_every_class path through legend_classes, classes_from_sample, classes_from_overview and raster_key_notices. The warnings change only for Unique Values when statistics have no enumerated values, and in that case the legend already lists every configured value, so no class can be missed. The new test expectations (1000, 999, 2, and the all-classes cases) match the code. Confidence: high.
  • utm_zone_of now accepts epsg 32632. Projection lookup already accepts that spelling (crates/map/src/projection.rs, "epsg 3035" comment), so the MGRS path and the map agree. Confidence: high.

Security

  • None. No new parsing of untrusted input beyond the CRS prefix, and no indexing was added.

Performance

  • None. The bookmark HashSet is a small improvement, and the masked-stats cache is reused.

Quality

  • Duplicated statistics selection (inline comment posted on crates/map/src/raster.rs:2181). "Masked statistics first, else the band's own" now appears in classes_unknown, the legend_classes closure and lists_every_class. These must pick the same statistics, so a shared helper is worth doing. Confidence: medium-high.
  • Unrelated change in the PR: the QGIS bookmark group change (crates/map/src/qgis/structure.rs) is not in the title, has no test, and is a refactor. Confidence: high that it is out of scope, low that it's a problem.
  • Nit: std::collections::HashSet::new() is written inline. A use would read better. Left for the release quality pass.

AGENTS.md

  • The tests cover both lossy and clean cases for the warning, as the rule requires.
  • The new test's unwrap() calls are allowed in tests by clippy.toml (allow-unwrap-in-tests = true).
  • No saved-file or schema change, so cargo xtask schema isn't needed.
  • No unsafe, no new panics, no new silent loss.
  • Low confidence (about 25%): with the warning removed, a Unique Values legend over more than 256 values lists configured values the raster may not hold, and nothing says so. That matches the existing all-classes behaviour and the legend's own doc comment, so it is probably acceptable.
  • Note on my inline comment: it ends with a <!-- quality-sweep --> marker. That marker is for replies that defer a point, and this is a new point, so the marker doesn't fit. It is harmless, but it can be ignored.

I checked nothing else, and I did not run the test suite.

Change size

Compared: the whole PR against main (merge base ce40749 to PR head ca01083).

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 259.2 KB
Size after 262.2 KB
Total size change +3.0 KB
Path Before After Change
crates/map/src/raster.rs 147.6 KB 150.4 KB +2.8 KB
crates/map/src/layout.rs 95.9 KB 96.0 KB +149 B
crates/map/src/qgis/structure.rs 15.7 KB 15.7 KB +61 B

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