Ticket #398 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

PolygonBuilder::findShell assertion 'shellcount <= 1' failed [JTS fails!]

Reported by: strk Owned by: strk
Priority: major Milestone: 3.3.0
Component: Core Version: svn-trunk
Severity: Unassigned Keywords:
Cc:

Attachments

Screenshot.png Download (5.1 KB) - added by strk 2 years ago.
bug398bis.xml Download (2.2 KB) - added by strk 2 years ago.
the new test, same input and op as old, different expected result, failing JTS

Change History

Changed 2 years ago by strk

  • summary changed from PolygonBuilder::findShell assertion 'shellcount <= 1' failed to PolygonBuilder::findShell assertion 'shellcount <= 1' failed [JTS works!]

r3269 adds an XML version of this test.

Changed 2 years ago by strk

  • owner changed from geos-devel@… to strk
  • status changed from new to assigned

Found the difference: JTS is doing this:

    PlanarGraph.linkResultDirectedEdges(nodes);

right in the PolygonBuilder::add function. GEOS has that call commented out. WHen commenting it in JTS we get the same assertion failure...

Changed 2 years ago by strk

Uhm, false alarm, the GEOS code is indeed inlining the equivalent of that function

Changed 2 years ago by strk

The first real difference between GEOS and JTS is at the point where a minimalEdgeRing infact dimensionally collapsed is considered as an hole by JTS and not by GEOS.

I attach a snapshot showing the two MinimalEdgeRing? geometries. You can see the blue one collapsed.

Changed 2 years ago by strk

Changed 2 years ago by strk

The collapsed geometry according to GEOS, in HEXWKB form:

0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408C26B714B2971B400000000000000000841D588465963540

Haven't tested if JTS considers coordinates of this CW or CCW

Changed 2 years ago by strk

I've checked that JTS gets to the _exact_ same HEXWKB, so obviously JTS considers that thing to be CCW while GEOS does not.

Changed 2 years ago by strk

Ok, JTS's version is _not_ exactly the same. Thanks to robe for finding out, as I was getting mad:

GEOS:
0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408C26B714B2971B400000000000000000841D588465963540
JTS:
0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408E26B714B2971B400000000000000000841D588465963540
---------------------------------------------------------------------------------------------------^ difference here

Now I'm even more curious about whether JTS considers the former clockwise too...

Changed 2 years ago by strk

in any case, turning the assertion failure in a robustness exception triggers engaging of snapping policy which results in an output with the collapsed "ring" removed, which passes the expectances of the tester and seems better for me too.

Changed 2 years ago by strk

Now this is funny. I've modified the testcase to expect GEOS output (the one with the collapsed ring removed) and JTS reacts to that new testcase with the shellcount <= 1 assertion.

It's funny because the input did not change, only the expected output changed.

I attach the new testcase here, in case Martin wants to take a look.

Will commit the new testcase and the exception solution, which I belive makes sense, being this clearly a robusness issue.

Changed 2 years ago by strk

the new test, same input and op as old, different expected result, failing JTS

Changed 2 years ago by strk

  • status changed from assigned to closed
  • summary changed from PolygonBuilder::findShell assertion 'shellcount <= 1' failed [JTS works!] to PolygonBuilder::findShell assertion 'shellcount <= 1' failed [JTS fails!]
  • resolution set to fixed
  • version set to svn-trunk
  • milestone set to 3.3.0

Fixed in r3286

Changed 2 years ago by strk

For the record: JTS agrees with GEOS about the ring computed by GEOS being CW:  http://sourceforge.net/mailarchive/message.php?msg_id=27379769

Our r3288 puts both rings under regression testing.

Changed 2 years ago by warmerdam

  • component changed from Default to Core

With the error report now being an exception it is necessary for the related logic to no longer be run only when NDEBUG is not defined. Fixed in trunk (r3373).

Note: See TracTickets for help on using tickets.