DOI-USGS / ISIS3

Integrated Software for Imagers and Spectrometers v3. ISIS3 is a digital image processing software package to manipulate imagery collected by current and past NASA and International planetary missions.
https://isis.astrogeology.usgs.gov
Other
200 stars 168 forks source link

Isisminer does not properly handle the presence of bad (e.g. self-intersecting) polygons. #5612

Closed kledmundson closed 1 month ago

kledmundson commented 2 months ago

ISIS version(s) affected: x.y.z dev

Description

The footprintinit application will sometimes create invalid, self-intersecting polygons. The isisminer application detects bad polygons, reports them, and terminates instead of attempting to repair them.

Solution

In many cases, self-intersecting polygons can be repaired by creating a buffer of size 0 around the polygon. This is analogous to stretching a rubber band around all points in the polygon (see slide below). The buffer(0) approach will likely fix many (though possibly not all) self-intersecting polygons. While the fix should be incorporated into footprintinit, it should also be implemented in isisminer.

Additional context

The slide below shows a polygon with a highlighted self-intersection in blue. The self-intersection was repaired (shown in orange) by applying a buffer of 0.1 around all polygon vertices. Note that typically a buffer of size 0 is applied. Here, a buffer of 0.1 was used for illustration purposes only.

selfIntersectingPolygons
acpaquette commented 2 months ago

@kledmundson Couple insights/questions. Is there a planned fix from the yourself or Kris coming in for this? Second, is seems related to #5553

kledmundson commented 2 months ago

Yes, fix is coming.

Relation to #5553 I'm not sure about, will have to look.

On Thu, Sep 12, 2024 at 11:27 AM Adam Paquette @.***> wrote:

@kledmundson https://github.com/kledmundson Couple insights/questions. Is there a planned fix from the yourself or Kris coming in for this? Second, is seems related to #5553 https://github.com/DOI-USGS/ISIS3/pull/5553

— Reply to this email directly, view it on GitHub https://github.com/DOI-USGS/ISIS3/issues/5612#issuecomment-2346969537, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUGSUXEHFHUGZGBVU3CCS3ZWHMJ5AVCNFSM6AAAAABODWQW4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBWHE3DSNJTG4 . You are receiving this because you were mentioned.Message ID: @.***>

KrisBecker commented 2 months ago

This fix is not directly related to #5553 because GisGeometry uses the GEOS C-API. Code in PolygonTools uses the C++ API so they are separate. We added a buffer() method to GisGeometry.

They are likely related as some GIsFootprints created by ISIS have self-intersections. These leak through into isisminer processing and aborts the run. The fix that @kledmundson is providing runs a buffer( 0 ) on the whole polygon in an attempt to fix them. Most all occurrences are fixed using this technique.

kledmundson commented 1 month ago

Closed via https://github.com/DOI-USGS/ISIS3/pull/5620.