Unverified Commit 7ca57fa9 authored by kledmundson's avatar kledmundson Committed by GitHub
Browse files

Bug fixed in isisminer to properly handle self-intersecting polygon geometries. (#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: default avatarKris J. Becker <kbecker@orex.lpl.arizona.edu>
parent 275ae63f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+75 −15
Original line number Diff line number Diff line
<?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 
@@ -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 
@@ -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>
@@ -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>
@@ -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>
+10 −0
Original line number Diff line number Diff line
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;
+632 −0

File added.

Preview size limit exceeded, changes collapsed.

+89 −0
Original line number Diff line number Diff line
###############################################################################
#  
# @author 2017-06-24 Kris Becker
#
###############################################################################
Object = IsisMiner

  Name = MakeDatabase
  RequiredParameters = (fromlist, tocsv)

  Object = Strategy
    Name = LoadCaminfoPvls
    Type = PvlReader
    # Debug = true
     RepairInvalidGeometry = true
     InvalidGeometryAction = error
    
    FromList = "%1"
    FromListArgs = "FromList"

  # Resource targets are for reading multiple rows from the DB.  The fields
  # from each row are created as Resources.
    Identity = "%1"
    IdentityArgs = "SourceProductId"

  # Include/exclude conditions
    Excludes = Mapping

  #  Can specify a GIS keyword that will be converted on input
    GisGeometryRef = GisFootprint
    GisType        = WKT
    # Tolerance of 0.0004 <degrees> ~= 0.005 m/p at equator
    GisSimplifyTolerance = 0.05 <degrees>
    GisGeometryPointsKey = GisPoints
    RemoveGisKeywordAfterImport = True
  EndObject

  Object = Strategy
   Name = SetSerialNumber
   Type = Calculator

   InitializersArgs = (IsisId, CkTableStartTime)
   Group = Initializers
     SerialNumber = %1
     ObservationTime =  %2
   EndGroup

   Group = Equations_DNE
     ObservationTime =  CkTableStartTime
   EndGroup

   EndObject


   Object = Strategy
    # Write result of StereoPair strategy for each Resource that has a
    # StereoPairs asset.
    Name = WritePairs
    Type = CsvWriter
    Description = "Write CSV file of caminfo data"

    SkipEmptyLists = True
    CsvFileArgs = ("ToCSV" )
    CsvFile = "%1"
    Keywords = (From, SourceProductId, SerialNumber, Target,
                MeanValue, MinimumValue, MaximumValue, StandardDeviation,
                Lines, Samples, InstrumentId, FilterName, MissionPhase, 
                StartTime, EndTime, ObservationTime, ExposureDuration,
                FocusPosition, CenterLongitude, CenterLatitude, CenterRadius,
                PixelResolution, MeanGroundResolution,
                HasNorthPole, HasSouthPole, HasLongitudeBoundary,
                RightAscension, Declination, OffNadir, SolarLongitude,
                LocalTime, CentroidLine, CentroidSample,
                CentroidLatitude, CentroidLongitude, 
                CentroidRadius, SurfaceArea, GlobalCoverage,
                IncidenceAngle, EmissionAngle, PhaseAngle, 
                SubSolarGroundAzimuth, SubSpacecraftGroundAzimuth,
                SubSpacecraftLongitude, SubSpacecraftLatitude, 
                SubSolarLongitude, SubSolarLatitude, 
                TargetCenterDistance, SlantDistance, 
                ParallaxX, ParallaxY, ShadowX, ShadowY,
                GisFootprint)
    GisGeometryKey = GisFootprint
    GisType        = WKB
  EndObject


EndObject
End
Loading