Skip to content

Commit

Permalink
Bug fixed in isisminer to properly handle self-intersecting polygon g…
Browse files Browse the repository at this point in the history
…eometries. (#5620)

* Fixed issues with GisGeometry/Strategy classes. Addresses #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 #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 #5612.

* Per reviewer comments, corrected additional typos in GisGeometry.cpp. Addresses #5612.

---------

Co-authored-by: Kris J. Becker <kbecker@orex.lpl.arizona.edu>
  • Loading branch information
kledmundson and KrisBecker authored Oct 17, 2024
1 parent 275ae63 commit 7ca57fa
Show file tree
Hide file tree
Showing 15 changed files with 1,121 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ release.
- Updated pixel2map documentation

### Fixed
- 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. Issue: [5612](https://github.com/DOI-USGS/ISIS3/issues/5612)
- Fixed a bug in kaguyasp2isis that doesn't work for data with a detached label.

## [8.3.0] - 2024-09-30
Expand Down
90 changes: 75 additions & 15 deletions isis/src/base/apps/isisminer/isisminer.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: isisminer.xml 6513 2016-01-14 23:04:44Z kbecker@GS.DOI.NET $ -->
<application name="isisminer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">
<!-- <application name="isisminer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd"> -->
<application name="isisminer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/usgs/pkgs/isis3/isis/doc/Schemas/Application/application.xsd">

<brief>
Run a series of algorithms (Strategies) that perform various operations on input
Expand Down Expand Up @@ -48,8 +49,8 @@
in well-known-text (WKT) or well-known-binary (WKB) as conversions are
restricted to text representations of geometries (format requirements are
the same as functions like
<a href="http://www.postgis.org/docs/ST_GeomFromText.html">ST_GeomFromWKT</a> and
<a href="http://www.postgis.org/docs/ST_GeomFromWKB.html">ST_GeomFromWKB</a>,
<a href="http://postgis.net/docs/ST_GeomFromText.html">ST_GeomFromWKT</a> and
<a href="http://postgis.net/docs/ST_GeomFromWKB.html">ST_GeomFromWKB</a>,
respectively). Resources may also contain Assets. Assets are typically
another list of Resources created from Strategies that are attached to a
(parent) Resource. If Assets are represented as Resource lists, they can
Expand Down Expand Up @@ -340,6 +341,40 @@
as these strings can be quite large.
</TD>
</TR>
<TR>
<TD>RepairInvalidGeometry</TD>
<TD>Optional</TD>
<TD>
There are times when invalid geometries will be passed into <b>isisminer</b>.
One of the most common invalid geometries encountered is self-intersecting
geometries. <b>footprintinit</b> will at times create self-intersecting geometries,
usually when it uses the shape model in projecting/intersecting to ground,
that are often read by <b>isisminer</b> as output from <b>caminfo</b>.
These types of invalid geometries can
be repaired by applying the GIS buffer algorithm with a width of 0. If an
invalid geometry occurs in isisminer, and RepairInvalidGeometry = True, the
buffer algorithm will be run to attempt to repair the geometry. The default
value of this keyword is true so that invalid geometries will be repaired.
See also InvalidGeometryAction.
</TD>
</TR>
<TR>
<TD>InvalidGeometryAction</TD>
<TD>Optional</TD>
<TD>
This parameter determines the action taken when an invalid geometry occurs
and is either not repaired (RepairInvalidGeometry = False) or could not be
sucessfully repaired (RepairInvalidGeometry = True). The options 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 <b>isisminer</b> terminates. The default is to
disable the Resource.
</TD>
</TR>
<TR>
<TD>GisSimplifyTolerance</TD>
<TD>Optional</TD>
Expand Down Expand Up @@ -990,6 +1025,23 @@ EndObject
not already exist in the Resources.
</TD>
</TR>
<TR>
<TD>InitializersArgs</TD>
<TD>Optional</TD>
<TD>
Using this parameter, users can list existing keywords in a Resource or
from the global parameter pool in this keyword to create new variables
in the Initializers group. This works by substituting ordered numerical index
values specified as %1, %2, etc..., with a keyword value referenced by
the index in the InitializersArgs array keyword. The InitializersArgs keyword
should have the same number of keywords as %[index], where index is
numbered from 1 to n, specified in the keywords found in the
Initializers group. These initialzers should not involve equations as
they are not resovled in this step.
Note: This is the only way to create new keywords specificially in
<b>isisminer</b>.
</TD>
</TR>
<TR>
<TD>Equation</TD>
<TD>Optional</TD>
Expand Down Expand Up @@ -4655,14 +4707,14 @@ End
feature.
</change>
<change name="Kris Becker" date="2015-06-12">
Improved GisOverlap and StereoPair strategies. StereoAngle can now be
computed from the GIS centroid of the overlapping region, providing a
much higher degree of accuracy. Improved global variable pool management
whilst traversing through Strategy/Resource depths in the mining process.
Ensure Asset is cleared when Mode = Create is used in AssetSideBar strategy.
Improved GisOverlap and StereoPair strategies. StereoAngle can now be
computed from the GIS centroid of the overlapping region, providing a
much higher degree of accuracy. Improved global variable pool management
whilst traversing through Strategy/Resource depths in the mining process.
Ensure Asset is cleared when Mode = Create is used in AssetSideBar strategy.
</change>
<change name="Kris Becker" date="2015-06-17">
Fixed bug in creation of GEOS SRTree when only one geometry occurs
Fixed bug in creation of GEOS SRTree when only one geometry occurs
(requires two or more). Changed name of IsisMiner objects within the
GisOverlap strategy (since we now have two of them) to CandidateMiner and
OverlapMiner. Added feature to simplify geometry whilst preserving
Expand All @@ -4674,21 +4726,21 @@ End
Add ability to process the set of GisOverlap results for each Resource
as they are matched. This is handled in the OverlapMiner Strategy object.
</change>
<change name="Kris Becker" date="2015-07-07">
<change name="Kris Becker" date="2015-07-07">
Added more content to documentation and added an example demonstrating a
real application of the isisminer application.
</change>
<change name="Kris Becker" date="2015-09-27">
</change>
<change name="Kris Becker" date="2015-09-27">
Refactored the Resource class to contain all but the active status so
that copies can be maintained in separate instances. Reworked the
AssetSidebar strategy to take advantage of this work.
</change>
<change name="Kris Becker" date="2015-10-11">
</change>
<change name="Kris Becker" date="2015-10-11">
Fixed bug in argument scanning when the number of arguments reached 10 or
more as %1 was replacing %10, etc... Scan and replace i reverse order
corrected this problem. Enhanced the Calculator strategy to provide
argument replacement in the Initializers group.
</change>
</change>
<change name="Kris Becker" date="2015-11-01">
Modified CsvReader strategy to have the provided header length determine
the number of keywords created/Resource. This allows the jigsaw residual
Expand All @@ -4699,6 +4751,14 @@ End
tests to gtest format. Moved some data from isis data area to
"isis/tests/data/isisminer".
</change>
<change name="Ken Edmundson" date="2024-09-23">
Originally implemented in UofA OSIRIS-REx code by Kris Becker, 2018-07-31.
Corrected problems with invalid geometries causeing isisminer to abort.
Added two new parameters, RepairInvalidGeometry and InvalidGeometryAction,
to allow user more control over how invalid geometries are managed. Updated
documentation. Ken Edmundson added unit tests to GisGeometry and Strategy
classes to address these changes.
</change>
</history>

<groups>
Expand Down
10 changes: 10 additions & 0 deletions isis/src/base/apps/isisminer/tsts/badgeomfix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
APPNAME = isisminer

include $(ISISROOT)/make/isismake.tsts

commands:
$(LS) $(INPUT)/*.pvl >& $(OUTPUT)/badgeomfix_data.lis;
$(APPNAME) config=$(INPUT)/badgeomfix.conf \
parameters="fromlist:$(OUTPUT)/badgeomfix_data.lis@tocsv:$(OUTPUT)/badgeomfix.csv" > /dev/null
$(RM) $(OUTPUT)/badgeomfix_data.lis;

Loading

0 comments on commit 7ca57fa

Please sign in to comment.