Fix logbook grid-coverage heatmap dropping the northern hemisphere#577
Open
patrickrb wants to merge 1 commit into
Open
Fix logbook grid-coverage heatmap dropping the northern hemisphere#577patrickrb wants to merge 1 commit into
patrickrb wants to merge 1 commit into
Conversation
The GridSquareHeatmap in the logbook Stats screen drew one cell per Maidenhead field but iterated only 10 latitude rows (`rows = 10`), generating latitude fields A..J = latitudes <= +10°N. Both Maidenhead field axes span A..R (18 divisions of 20° longitude / 10° latitude), so every worked grid north of +10° — latitude field K onward, i.e. essentially all of North America, Europe, and Japan (e.g. FN, JO, PM) — was never generated and could never highlight, leaving the heatmap blank across the most-worked bands. Root cause: the latitude field is a letter (A..R), not a digit; the loop bound treated it as 0..9. Fixed by iterating the full 18 latitude rows, matching the 18 longitude columns already used. Extracted the pure grid/worked-field logic out of the @composable into testable internal helpers (workedGridFields, buildGridHeatmapCells) per the project's Compose-testing convention; the composable is now a thin wrapper. Added GridSquareHeatmapTest (pure JVM) covering full 18x18 coverage, northern-hemisphere fields, and the field-extraction rules; 4 of its cases fail on the old rows=10 and pass after. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #577 +/- ##
============================================
+ Coverage 27.83% 28.16% +0.33%
- Complexity 165 197 +32
============================================
Files 175 177 +2
Lines 23388 23781 +393
Branches 3192 3265 +73
============================================
+ Hits 6509 6699 +190
- Misses 16686 16860 +174
- Partials 193 222 +29
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Fixes the logbook Stats grid-square coverage heatmap so it generates the full Maidenhead field grid (A..R × A..R) instead of truncating latitude rows and silently dropping most of the northern hemisphere from being displayable/highlightable.
Changes:
- Corrected the heatmap grid dimensions to 18×18 (324 fields) to cover the full Maidenhead field latitude range A..R.
- Extracted field-detection and grid-building logic into
internalhelpers (workedGridFields,buildGridHeatmapCells) so it can be unit-tested. - Added JVM unit tests to validate full coverage and “worked” flagging for northern-hemisphere fields.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/ui/logbook/LogbookScreen.kt | Fixes heatmap row iteration and refactors the heatmap logic into testable helpers. |
| ft8af/app/src/test/kotlin/radio/ks3ckc/ft8af/ui/logbook/GridSquareHeatmapTest.kt | Adds unit tests ensuring 18×18 field generation and correct worked-field detection/flagging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+905
to
+908
| internal fun workedGridFields(grids: List<String?>): Set<String> = | ||
| grids.mapNotNull { grid -> | ||
| if (grid != null && grid.length >= 2) grid.substring(0, 2).uppercase() else null | ||
| }.toSet() |
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.
Summary
The Grid Square coverage heatmap on the logbook Stats screen (
GridSquareHeatmapinLogbookScreen.kt) draws one cell per Maidenhead field, but iterated only 10 latitude rows (rows = 10). Both Maidenhead field axes span A..R (18) — longitude is 18 divisions of 20°, latitude 18 divisions of 10°. With only 10 rows the grid generated latitude fields A..J = latitudes ≤ +10°N, so every worked grid north of +10° (latitude field K onward — essentially all of North America, Europe, and Japan, e.g.FN,JO,PM) was never generated and could never highlight. The heatmap therefore stayed blank across exactly the bands most operators work.Root cause
The latitude portion of a Maidenhead field is a letter (A..R), not a digit; the row loop treated it as
0..9. The stale comment even mislabeled it as "latitude digits down". The 18 longitude columns were already correct — only the latitude bound was wrong.Fix
@Composableinto testable top-levelinternalhelpers (workedGridFields,buildGridHeatmapCells), per the project's Compose-testing convention. The composable is now a thin wrapper over them. Happy path (worked-field detection, cell coloring) is unchanged.Testing
GridSquareHeatmapTest(pure JVM, JUnit4 + Truth — no Robolectric): asserts full 18×18 coverage / 324 distinct fields, that northern-hemisphere fields (FNand every?K/?Rband) are generated and flag worked, and the field-extraction rules (first-two-chars upper-cased, null/short skipped, deduped).rows = 10and pass after the fix../gradlew :app:testDebugUnitTest --tests 'radio.ks3ckc.ft8af.ui.logbook.*'green.Risk assessment
Low. Display-only change confined to one logbook stat card; no DSP, decoder, protocol, or transport code touched. The extra latitude rows only add cells that were previously (incorrectly) omitted; existing cells render identically.
🤖 Generated with Claude Code