Skip to content

Fix logbook grid-coverage heatmap dropping the northern hemisphere#577

Open
patrickrb wants to merge 1 commit into
devfrom
optio/task-7db9969d-5748-4eb8-9de0-1fd7fb08f740
Open

Fix logbook grid-coverage heatmap dropping the northern hemisphere#577
patrickrb wants to merge 1 commit into
devfrom
optio/task-7db9969d-5748-4eb8-9de0-1fd7fb08f740

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Summary

The Grid Square coverage heatmap on the logbook Stats screen (GridSquareHeatmap in LogbookScreen.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

  • Iterate the full 18 latitude rows so the grid is 18×18 (324 fields, AA..RR), matching the longitude axis.
  • Extracted the pure decision/geometry logic out of the @Composable into testable top-level internal helpers (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

  • Added GridSquareHeatmapTest (pure JVM, JUnit4 + Truth — no Robolectric): asserts full 18×18 coverage / 324 distinct fields, that northern-hemisphere fields (FN and every ?K/?R band) are generated and flag worked, and the field-extraction rules (first-two-chars upper-cased, null/short skipped, deduped).
  • Verified the regression is captured: 4 of the 7 cases fail on the old rows = 10 and 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

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

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.16%. Comparing base (4d2e930) to head (c3a0d7d).

Files with missing lines Patch % Lines
...lin/radio/ks3ckc/ft8af/ui/logbook/LogbookScreen.kt 57.14% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
android 14.62% <57.14%> (+0.88%) ⬆️
native 9.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...lin/radio/ks3ckc/ft8af/ui/logbook/LogbookScreen.kt 6.60% <57.14%> (+0.77%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 internal helpers (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()
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.

2 participants