Skip to content

feat(format-v2): display precipitation in millimeters when metric units requested - #1298

Open
AdamMagued wants to merge 1 commit into
chubin:masterfrom
AdamMagued:fix-issue-1297
Open

AdamMagued wants to merge 1 commit into
chubin:masterfrom
AdamMagued:fix-issue-1297

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #1297

Description

In format v2 rendering, the precipitation sparkline previously extracted hourly data strictly from PrecipMM and formatted the sparkline peak label with a hardcoded mm unit string, regardless of user-selected unit options. When USCS or imperial units were selected (for example with ?u), the value and unit label failed to reflect the imperial measurement system.

Changes

  • Updated internal/renderer/v2/renderer.go to extract h.PrecipInches when imperial or USCS units are requested (opts.UseImperial || opts.UseUscs), while preserving h.PrecipMM for metric requests and default configurations.
  • Updated drawRainSpark in internal/renderer/v2/block_rain.go to accept query options and format the peak label with in when imperial units are active, and mm when metric units are active.
  • Added bounds checks to prevent slice index panics in drawRainSpark when data slice lengths are smaller than width.
  • Added automated unit tests in internal/renderer/v2/block_rain_test.go and internal/renderer/v2/renderer_test.go covering metric and imperial precipitation label output as well as edge cases.
  • Added test runner verification in test/test_v2_precipitation.py.

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.

Data-rich output format (v2) showing millimeters instead of inches when the "?u" option is used.

1 participant