Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#741 closed defect (fixed)

[PATCH] GEOSSimplify() returns empty polygon if inner ring dimension < simplify distance

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

Description

Demonstrated with OGR scripting, but the issue is in GEOS

from osgeo import ogr
ogr_geom = ogr.CreateGeometryFromWkt('POLYGON ((-180 90,180 90,180 -90,180 -90,-180 -90,-180 90),(0 0,0 0.0001,0.0001 0.0001,0 0))')
simple_geom = ogr_geom.Simplify(0.005)
print simple_geom # prints POLYGON EMPTY --> unexpected

ogr_geom = ogr.CreateGeometryFromWkt('POLYGON ((-180 90,180 90,180 -90,180 -90,-180 -90,-180 90),(0 0,0 0.0001,0.0001 0.0001,0 0))')
simple_geom = ogr_geom.Simplify(0.00005) # prints POLYGON ((-180 90,180 90,180 -90,-180 -90,-180 90),(0 0,0.0001 0.0001,0.0 0.0001,0 0)) --> OK

The above is an artificial example reproducing a real world situation

It seems to be an issue failed simplification of the inner ring.

Reproduced with latest GEOS trunk r4082

Attachments (1)

geossimplify_small_innerring_741.patch (3.0 KB) - added by rouault 6 years ago.
Proposed patch

Download all attachments as: .zip

Change History (18)

comment:1 Changed 6 years ago by rouault

When stepping through GEOS, the "Geometry::AutoPtr? roughGeom(GeometryTransformer::transformMultiPolygon(geom, parent));" at line 149 of DouglasPeuckerSimplifier?.cpp returns a collection of a linearring (OK) and a linestring (OK ???). Then createValidArea() and the underlying buffer(0) returns an empty polygon (line 395 of BufferBuilder?.cpp)

comment:2 Changed 6 years ago by strk

Martin, can you check if this also happens in JTS?

Changed 6 years ago by rouault

Proposed patch

comment:3 Changed 6 years ago by rouault

Summary: GEOSSimplify() returns empty polygon if inner ring dimension < simplify distance[PATCH] GEOSSimplify() returns empty polygon if inner ring dimension < simplify distance

Attached a patch + new test step that fixes the issue

comment:4 Changed 6 years ago by strk

Martin can you take a look at this, sounds sensible to me.

comment:5 Changed 5 years ago by strk

Milestone: 3.4.33.6.1

Ticket retargeted after milestone deleted

comment:6 Changed 5 years ago by rouault

Any chance this gets applied ?

comment:7 Changed 5 years ago by strk

In 4311:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

comment:8 Changed 5 years ago by strk

Resolution: fixed
Status: newclosed

In 4313:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
Closes #741

comment:9 Changed 5 years ago by strk

Done in trunk and 3.6 branch (for 3.6.1) - thanks

comment:10 Changed 4 years ago by Sandro Santilli <strk@…>

In 4f943df/git:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

git-svn-id: http://svn.osgeo.org/geos/trunk@4311 5242fede-7e19-0410-aef8-94bd7d2200fb

comment:11 Changed 4 years ago by Sandro Santilli <strk@…>

In 4f943df/git:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

git-svn-id: http://svn.osgeo.org/geos/trunk@4311 5242fede-7e19-0410-aef8-94bd7d2200fb

comment:12 Changed 4 years ago by Sandro Santilli <strk@…>

In 4f943df/git:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

git-svn-id: http://svn.osgeo.org/geos/trunk@4311 5242fede-7e19-0410-aef8-94bd7d2200fb

comment:13 in reply to:  9 Changed 4 years ago by Bas Couwenberg

Replying to strk:

Done in trunk and 3.6 branch (for 3.6.1) - thanks

Can the change also be included in the 3.5 branch?

comment:14 Changed 4 years ago by Bas Couwenberg

Cc: sebastic@… added

comment:15 Changed 4 years ago by strk

Could you prepare a patch for that ? Can be a pull request for the git repository (official hoster or any mirror).

comment:16 Changed 4 years ago by Bas Couwenberg <sebastic@…>

In 710ddbe/git:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

git-svn-id: http://svn.osgeo.org/geos/trunk@4311 5242fede-7e19-0410-aef8-94bd7d2200fb

comment:17 Changed 4 years ago by Bas Couwenberg <sebastic@…>

In 710ddbe/git:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

git-svn-id: http://svn.osgeo.org/geos/trunk@4311 5242fede-7e19-0410-aef8-94bd7d2200fb

Note: See TracTickets for help on using tickets.