-
Notifications
You must be signed in to change notification settings - Fork 176
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
Bug fixed in isisminer to properly handle self-intersecting polygon geometries. #5620
Bug fixed in isisminer to properly handle self-intersecting polygon geometries. #5620
Conversation
The build and test suite have started for your pull request. To view your build log, please reference the build with source version: "PR_5620". Additionally, check the latest "dev" source version to identify existing test failures. Please note that you are not responsible for the test failures that exist on both your PR and the dev branch. |
int valid(0); | ||
try { | ||
valid = GEOSisValid(this->m_geom); | ||
} catch (...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading the docs correctly, the catch(...) is not necessary / reachable.
It looks like exceptions are handled within GEOSisValid, and the function returns 2 on exception.
38b1cc2
to
f829674
Compare
The build and test suite have started for your pull request. To view your build log, please reference the build with source version: "PR_5620". Additionally, check the latest "dev" source version to identify existing test failures. Please note that you are not responsible for the test failures that exist on both your PR and the dev branch. |
* GisGeometry was throwing an exception when isValid() was called and the geometry was indeed invalid * GisGeometry - added buffer() method * Strategy was updated to better manage geometries * Strategy - Added RepairInvalidGeometry and InvalidGeometryAction to allow better user control over invalid geometries * Strategy - Apply buffer(0) algorithm when an invalid geometry is detected * Strategy - Added more debug output
…5612. * GisGeometry was throwing an exception when isValid() was called and the geometry was indeed invalid * GisGeometry - added buffer() method * Strategy was updated to better manage geometries * Strategy - Added RepairInvalidGeometry and InvalidGeometryAction to allow better user control over invalid geometries * Strategy - Apply buffer(0) algorithm when an invalid geometry is detected * Strategy - Added more debug output * isisminer - improved handling of invalid/bad geometries * isisminer - Documented new parameters RepairInvalidGeometry and InvalidGeometryAction and updated Calculator strategy documentation
…n geometries were not treated properly. Added pertinent unit tests to GisGeometry and Strategy classes. Fixed incorrect links and minor typos in isisminer documentation. Addresses DOI-USGS#5612.
The build and test suite have started for your pull request. To view your build log, please reference the build with source version: "PR_5620". Additionally, check the latest "dev" source version to identify existing test failures. Please note that you are not responsible for the test failures that exist on both your PR and the dev branch. |
1 similar comment
The build and test suite have started for your pull request. To view your build log, please reference the build with source version: "PR_5620". Additionally, check the latest "dev" source version to identify existing test failures. Please note that you are not responsible for the test failures that exist on both your PR and the dev branch. |
Thanks for reviewing @AustinSanders. I fixed the typo you caught (plus a couple more). Regarding the method GisGeometry::isValid(), we have confirmed that it is correct as written. Verified that in the presence of self-intersecting polygon geometry the catch(...) statement is executed properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not understanding what types of exception can be thrown by GeosIsValid(), which is leading to my confusion about the catch(...). The documentation states that the function returns "1 on true, 0 on false, 2 on exception."
Ultimately, I trust that the code is functioning properly, I just don't understand the circumstances under which the catch(...) is necessary. I'll approve for merge, but I'd also like to understand the code better if you don't mind discussing.
Ok, thanks.
What's going on with this does appear to be a bit cryptic to me as well,
considering the GEOS documentation.
I will rerun again with & without the try/catch in the presence of
self-intersecting polygons and provide more details.
…On Tue, Oct 15, 2024 at 12:30 PM Austin Sanders ***@***.***> wrote:
***@***.**** approved this pull request.
I'm not understanding what types of exception can be thrown by
GeosIsValid(), which is leading to my confusion about the catch(...). The
documentation states that the function returns "1 on true, 0 on false, 2 on
exception."
Ultimately, I trust that the code is functioning properly, I just don't
understand the circumstances under which the catch(...) is necessary. I'll
approve for merge, but I'd also like to understand the code better if you
don't mind discussing.
—
Reply to this email directly, view it on GitHub
<#5620 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUGSUUSJ5Y4XE66H6XNY3TZ3VUNBAVCNFSM6AAAAABOXDIJHOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNZQGM3TIMJZGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Hi @AustinSanders, Kris and I went through this yesterday, here are the details (let us know what you think) ...
< GEOS Notice: Self-intersection at or near point 286.74713584288054 51.271685761047472 91d89
|
That all makes sense! Thanks for writing that up |
…eometries. (DOI-USGS#5620) * Fixed issues with GisGeometry/Strategy classes. Addresses DOI-USGS#5612. * GisGeometry was throwing an exception when isValid() was called and the geometry was indeed invalid * GisGeometry - added buffer() method * Strategy was updated to better manage geometries * Strategy - Added RepairInvalidGeometry and InvalidGeometryAction to allow better user control over invalid geometries * Strategy - Apply buffer(0) algorithm when an invalid geometry is detected * Strategy - Added more debug output * Corrected invalid geometry problems in isisminer. Addresses DOI-USGS#5612. * GisGeometry was throwing an exception when isValid() was called and the geometry was indeed invalid * GisGeometry - added buffer() method * Strategy was updated to better manage geometries * Strategy - Added RepairInvalidGeometry and InvalidGeometryAction to allow better user control over invalid geometries * Strategy - Apply buffer(0) algorithm when an invalid geometry is detected * Strategy - Added more debug output * isisminer - improved handling of invalid/bad geometries * isisminer - Documented new parameters RepairInvalidGeometry and InvalidGeometryAction and updated Calculator strategy documentation * Fixed a bug in isisminer in which bad (e.g. self-intersecting) polygon geometries were not treated properly. Added pertinent unit tests to GisGeometry and Strategy classes. Fixed incorrect links and minor typos in isisminer documentation. Addresses DOI-USGS#5612. * Per reviewer comments, corrected additional typos in GisGeometry.cpp. Addresses DOI-USGS#5612. --------- Co-authored-by: Kris J. Becker <[email protected]>
Description
The isisminer application detects bad polygons, reports them, and terminates instead of attempting to repair them. Often (though not always), self-intersecting polygons can be repaired by creating a buffer of size 0 around the polygon.
Here, the Strategy and GisGeometry classes have been updated to better manage geometries. The buffer(0) method was added to GisGeometry to repair self-intersecting polygons. The RepairInvalidGeometry and InvalidGeometryAction keywords have been added to the Strategy class providing improved user control over invalid geometries.
The RepairInvalidGeometry keyword defaults to true so that invalid geometries will be repaired. Options for the InvalidGeometryAction
keyword are continue, disable or error. For InvalidGeometryAction = continue, the state of the invalid geometry is retained in the Resource (some GIS operations still function) and it is not disabled and no error occurs - the issue is ignored. If InvalidGeometryAction = disable, then the geometry is retained in the Resource but the status is set to "discard". It can be re-enabled by using the ResourceManager strategy. If InvalidGeometryAction = error, then an error is thrown and isisminer terminates. The default value is disable.
Related Issue
https://github.com//issues/5612How Has This Been Validated?
The GisGeometry unit test has been modified to test the validity and repair of a self-intersecting polygon. The Strategy unit test has been updated to test the behavior of the two new keywords RepairInvalidGeometry and InvalidGeometryAction.
GisGeometry unit test result
ctest -R GisGeometry --output-on-failure
Start 108: isis_unit_test_GisGeometry
1/1 Test #108: isis_unit_test_GisGeometry ....... Passed 2.01 sec
Strategy unit test result
ctest -R isis_unit_test_Strategy --output-on-failure
Start 299: isis_unit_test_Strategy
1/1 Test #299: isis_unit_test_Strategy .......... Passed 0.56 sec
Additionally, all isisminer app tests continue to pass.
Types of changes
Checklist:
Licensing
This project is mostly composed of free and unencumbered software released into the public domain, and we are unlikely to accept contributions that are not also released into the public domain. Somewhere near the top of each file should have these words: