Opened 7 years ago

Closed 6 years ago

Last modified 5 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 7 years ago.
Proposed patch

Download all attachments as: .zip

Change History (18)

comment:1 by rouault, 7 years ago

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 by strk, 7 years ago

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

by rouault, 7 years ago

Proposed patch

comment:3 by rouault, 7 years ago

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 by strk, 7 years ago

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

comment:5 by strk, 6 years ago

Milestone: 3.4.33.6.1

Ticket retargeted after milestone deleted

comment:6 by rouault, 6 years ago

Any chance this gets applied ?

comment:7 by strk, 6 years ago

In 4311:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
See #741

comment:8 by strk, 6 years ago

Resolution: fixed
Status: newclosed

In 4313:

Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
Closes #741

comment:9 by strk, 6 years ago

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

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

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 by Sandro Santilli <strk@…>, 5 years ago

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 by Sandro Santilli <strk@…>, 5 years ago

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

in reply to:  9 comment:13 by Bas Couwenberg, 5 years ago

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 by Bas Couwenberg, 5 years ago

Cc: sebastic@… added

comment:15 by strk, 5 years ago

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

comment:16 by Bas Couwenberg <sebastic@…>, 5 years ago

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 by Bas Couwenberg <sebastic@…>, 5 years ago

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.