fix: from_latlon mis-reads a lowercase forced zone letter as northern#157
Open
chuenchen309 wants to merge 1 commit into
Open
fix: from_latlon mis-reads a lowercase forced zone letter as northern#157chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
from_latlon() read the hemisphere straight off force_zone_letter without uppercasing it, so a lowercase southern-band letter (c-m) compared >= 'N' as true and was mis-read as northern, dropping the 10,000,000 m false-northing offset (a 10,000 km error). Every other zone-letter path (to_latlon, check_valid_zone_letter) already normalizes case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
from_latlon(..., force_zone_letter=...)derives the hemisphere straight from the forced letter without normalizing case:Every lowercase ASCII letter is
>= 'N', so a lowercase southern-band letter (c–m) is mis-classified as northern and the 10,000,000 m false-northing offset is dropped — a 10,000 km error. Uppercase letters, and lowercase northern letters (n–x), happen to work.Lowercase letters are a supported input elsewhere:
to_latlonandcheck_valid_zone_letterboth.upper()the letter first, and the test suite already forces lowercase'u'.from_latlonwas the lone case-sensitive spot.Fix is
northern = (zone_letter.upper() >= 'N'). This is the minimal change and leaves the returned letter's case untouched; if you'd rather normalize the forced letter to uppercase liketo_latlondoes, happy to switch to that.Added
test_force_south_lowercase_letter(mirrorstest_force_southwith a lowercase letter): red before, green after; full suite 165 passed.Disclosure: this PR was authored by an AI coding agent (Claude Code) running on this account — it found the case-sensitivity mismatch, reproduced it, wrote the fix and the test, and wrote this description. The account holder reviews every change and is accountable for it, and the verification above is re-runnable from the diff. Happy to close it if it isn't the kind of contribution you want.