Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1043 closed defect (fixed)

[OverlayNG] tests/general/TestOverlayLL.xml fails

Reported by: strk Owned by: geos-devel@…
Priority: major Milestone: 3.9.0
Component: Default Version: main
Severity: Unassigned Keywords:
Cc:

Description

A simple test is failing with --overlay-ng. Passes with JTS:

        Description: LrL - LinearRing bug
        Geometry A: LINEARRING (0 0, 0 5, 5 5, 5 0, 0 0)
        Geometry B: LINESTRING (2 2, 5 5)
        Expected result: POINT (5 5)
        Obtained result: LINESTRING EMPTY

The test is in the tests/general/TestOverlayLL.xml file

Change History (6)

comment:1 by strk, 4 years ago

Adding debugging to the OverlayNG GEOS class I'm seeing this graph:

OverlayNG::extractResult: graph: OGRPH 
NODEMAP [2]
 2 2 OE( 2 2 .. 5 5 ) A:e/B:eL / Sym: A:e/B:eL
 5 5 OE( 5 5 .. 2 2 ) A:e/B:eL / Sym: A:e/B:eL
EDGES [2]
 OE( 2 2 .. 5 5 ) A:e/B:eL / Sym: A:e/B:eL 
 OE( 5 5 .. 2 2 ) A:e/B:eL / Sym: A:e/B:eL 

The JTS class does not have a toString method, so not sure how to compare (should add one).

comment:2 by strk, 4 years ago

Changing the LINEARRING type to a POLYGON or LINESTRING fixes the test, so this seems to be a simple bug which was fixed in old OverlayOP but not the new OverlayNG

comment:3 by strk, 4 years ago

OverlayGraph::addEdge is called only once, in GEOS, while it's called 3 times in JTS. The missing 2 times are for both directions of the linearring edge

comment:4 by strk, 4 years ago

Found the culprit: EdgeNodingBuilder::add, in GEOS, uses getGeometryTypeID to decide what to do, and decides to do NOTHING for LineaRing. Instead JTS uses an instanceOf operator (like a dynamic cast) which would see LinearRing as being an instance of a LINESTRING

comment:5 by Sandro Santilli <strk@…>, 4 years ago

Resolution: fixed
Status: newclosed

In e6ffc18/git:

[OverlayNG] Fix handling of LinearRing

Closes #1043

comment:6 by pramsey, 4 years ago

Very nice catch.

Note: See TracTickets for help on using tickets.