fix: avoid scientific notation in CMR URL coordinate parameters#113
Open
stark256-spec wants to merge 1 commit into
Open
fix: avoid scientific notation in CMR URL coordinate parameters#113stark256-spec wants to merge 1 commit into
stark256-spec wants to merge 1 commit into
Conversation
Python's default float formatting uses scientific notation for numbers outside roughly [1e-4, 1e16) — e.g. 0.00001 becomes 1e-05. CMR rejects scientific notation in URL parameters with "is not a valid URL encoded point", causing otherwise valid queries to fail silently. Add _format_float() which falls back to fixed-point formatting whenever the default %g representation contains 'e' or 'E'. Apply it in all five coordinate methods: point(), circle(), polygon(), bounding_box(), line(). Fixes nasa#108
chuckwondo
requested changes
Jun 3, 2026
Collaborator
chuckwondo
left a comment
There was a problem hiding this comment.
Thanks @stark256-spec. This is looking good. Please add some unit tests.
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.
Fixes #73.
Problem
Python switches to scientific notation for floats outside roughly
[1e-4, 1e16)— for examplestr(0.00001)returns"1e-05". CMR rejects scientific notation in URL parameters with"is not a valid URL encoded point", so queries using very small coordinate values silently fail.Fix
Adds
_format_float(value)which usesstr()as the base representation and only converts to a fixed-point decimal string when scientific notation is detected:_format_floatis applied to all coordinate parameters:point,circle,polygon,bounding_box, andline.Using
str()as the base preserves the natural representation of each type — integers stay as"1000"(not"1000.0"), floats stay as"1.0"— so no existing behaviour changes for normal-range values.Tests
All 122 existing tests pass. The fix is a one-commit change on top of
develop.