Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent users from entering impossible geographic coordinates in the editor #2159

Closed
robyngit opened this issue Jul 13, 2023 · 7 comments · Fixed by #2216
Closed

Prevent users from entering impossible geographic coordinates in the editor #2159

robyngit opened this issue Jul 13, 2023 · 7 comments · Fixed by #2216
Assignees
Labels
ADC CI-09 Enhanced data submission tools & portals (ADC deliverable) editor enhancement UX
Milestone

Comments

@robyngit
Copy link
Member

Describe the feature you'd like
Build some logic In the geographic coverage section of the editor that prevents users from entering in coordinates that don't make sense, like a bounding box that has the south point further north than the north point.

Additional context
A dataset seems to have reversed the north and south coordinate of the bounding box, and this prevented it from being indexed properly in Solr. As a result, the dataset did not appear on the catalog search map:
Screen Shot 2023-07-13 at 9 34 45 AM. See #2158.

Related to: #303

@robyngit robyngit added enhancement UX editor ADC CI-09 Enhanced data submission tools & portals (ADC deliverable) labels Jul 13, 2023
@robyngit robyngit self-assigned this Jul 13, 2023
@robyngit robyngit added this to the 2.26.0 milestone Jul 13, 2023
@mbjones
Copy link
Member

mbjones commented Jul 13, 2023

In addition to inverted coordinates, another thing to check for may be bounding boxes that attempt to traverse the international dateline or tries to contain the north or south poles, which don't really work.

@robyngit robyngit modified the milestones: 2.26.0, 2.27.0 Aug 4, 2023
@robyngit
Copy link
Member Author

We now have a GeoBoundingBox model with its own validation rules (in the feature-2180-draw-on-map branch at the time of writing). We can use this in the EML editor to make sure coordinates are valid.

robyngit added a commit that referenced this issue Nov 1, 2023
robyngit added a commit that referenced this issue Nov 2, 2023
- Show validation error when N coord is less than S coord
- Fix the HTML input pattern for decimal degrees (was throwing an error)
- Add a test for reversed coords to the EMLGeoCoverage model spec

Issue #2159
robyngit added a commit that referenced this issue Nov 2, 2023
- Add validation rule to prevent bounding boxes from: containing the poles or crossing the anti-meridian
- Add unit tests for the new validation rules

Issue #2159
@robyngit
Copy link
Member Author

robyngit commented Nov 2, 2023

In the develop branch, we now check for and show validation errors for all the scenarios discussed above:

Screenshot 2023-11-01 at 20 38 33

These validation rules are included in new tests for the EMLGeoCoverage model:

Screenshot 2023-11-01 at 20 41 30

@mbjones
Copy link
Member

mbjones commented Nov 2, 2023

These are great. Could the errors also include solutions? For example, something like:

The bounding box cannot cross the anti-meridian. Please use multiple bounding boxes that meet at the anti-meridian instead.

Maybe it could be shorter, but that's the idea.

@robyngit
Copy link
Member Author

robyngit commented Nov 2, 2023

Yes, good idea!

robyngit added a commit that referenced this issue Nov 2, 2023
- For each error type, provide solutions for invalid geo coverages
- Move error messages to an object in the model (rather than a switch statement)
- Update tests to get error messages from the model

Issue #2159
@robyngit
Copy link
Member Author

robyngit commented Nov 2, 2023

✅ Done! (@mbjones please let me know if any of these should be tweaked)

Screenshot 2023-11-02 at 09 13 07
errorMessages: {
  "default": "Please correct the geographic coverage.",
  "north": "Northwest latitude out of range, must be >-90 and <90. Please correct the latitude.",
  "east": "Southeast longitude out of range (-180 to 180). Please adjust the longitude.",
  "south": "Southeast latitude out of range, must be >-90 and <90. Please correct the latitude.",
  "west": "Northwest longitude out of range (-180 to 180). Check and correct the longitude.",
  "missing": "Latitude and longitude are required for each coordinate. Please complete all fields.",
  "description": "Missing location description. Please add a brief description.",
  "needPair": "Location requires at least one coordinate pair. Please add coordinates.",
  "northSouthReversed": "North latitude should be greater than South. Please swap the values.",
  "crossesAntiMeridian": "Bounding box crosses the anti-meridian. Please use multiple boxes that meet at the anti-meridian instead.",
  "containsPole": "Coordinates include a pole. Latitudes should be >-90 and <90."
}

@robyngit robyngit closed this as completed Nov 2, 2023
@mbjones
Copy link
Member

mbjones commented Nov 2, 2023

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADC CI-09 Enhanced data submission tools & portals (ADC deliverable) editor enhancement UX
Development

Successfully merging a pull request may close this issue.

2 participants