feat(queries): implement coordinate order validation and UserWarnings for spatial queries (#66)#105
Open
angel-cm-dev wants to merge 1 commit intonasa:developfrom
Open
feat(queries): implement coordinate order validation and UserWarnings for spatial queries (#66)#105angel-cm-dev wants to merge 1 commit intonasa:developfrom
angel-cm-dev wants to merge 1 commit intonasa:developfrom
Conversation
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.
🚀 Overview
This Pull Request addresses Issue #66 by implementing proactive validation for coordinate ordering in
bounding_boxandpolygonmethods within theGranuleQueryclass.The primary goal is to prevent common user errors—such as flipped latitude/longitude pairs—that lead to unintentional antimeridian crossings or empty API results. By providing immediate feedback via
UserWarning, we improve the developer experience and reduce unnecessary load on the CMR API.✅ Key Changes
float()casting for all spatial parameters. This ensures type safety and prevents potential string-injection issues in the generated query parameters.lower_left_lon > upper_right_lonor if latitudes are flipped, triggering aUserWarningwith clear descriptive feedback.🧪 Testing & Verification
I have performed rigorous testing to ensure the robustness of these changes:
tests/test_issue_66.pyutilizingunittest.TestCase.assertWarns. This verifies that warnings are triggered exactly when expected and silenced during valid queries.cmr.uat.earthdata.nasa.gov).bounding_box=10.0,0.0,-10.0,5.0).🔗 Related Issues
Closes #66