Skip to content

chore: correct hemisphere letter for negative coords in demo#2027

Merged
no23reason merged 1 commit into
masterfrom
demo-format
Jun 28, 2026
Merged

chore: correct hemisphere letter for negative coords in demo#2027
no23reason merged 1 commit into
masterfrom
demo-format

Conversation

@no23reason

Copy link
Copy Markdown
Owner

Summary

Cleans up formatDegrees in the demo and fixes a latent bug it was hiding.

The old one-liner mutated its parameter mid-expression (degrees = -degrees) to take the absolute value for the minutes calc. Because getDirection(degrees, …) is evaluated last in the template string, it saw the already-mutated (positive) value — so every negative coordinate rendered E/N regardless of hemisphere.

Rewritten with Math.abs / Math.trunc / Math.floor (no mutation, no 0 | x floor hacks) and getDirection now receives the original signed value.

Effect

Degrees/minutes/seconds are byte-for-byte identical (verified across positive and negative samples). Only the direction letter changes — and only for negatives, where it was wrong:

input before after
-122.6789 (lon) -122° 40' 44" E -122° 40' 44" W
-20.123 (lat) -20° 7' 22" N -20° 7' 22" S

Verification

  • npm run docs:build → clean
  • npm test → 4/4 pass

🤖 Generated with Claude Code

Rewrite formatDegrees without the in-expression param mutation and the
`0 | x` floor hacks. The mutation reassigned `degrees` to its absolute
value before getDirection ran, so negative coordinates always rendered
as E/N. Passing the original signed value fixes the direction (W/S).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@no23reason no23reason changed the title fix: correct hemisphere letter for negative coords in demo chore: correct hemisphere letter for negative coords in demo Jun 28, 2026
@no23reason no23reason merged commit b3ce589 into master Jun 28, 2026
6 checks passed
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