Opened 5 years ago

Closed 5 years ago

#4568 closed defect (fixed)

Oversimplification of polygon inner rings in ST_Simplify

Reported by: Algunenano Owned by: Algunenano
Priority: high Milestone: PostGIS 3.0.1
Component: postgis Version: 3.0.x
Keywords: Cc:

Description

Initially reported by Komzpa

I went to far when dropping inner rings of polygons in my optimization of inner rings, you can only drop all inner rings when the outer ring collapse, not when any of them collapse.

Bug example:

Select ST_AsText(ST_Simplify('POLYGON((0 0, 100 0, 100 100, 0 100, 0 0), (20 20, 20 40, 40 40, 40 20, 20 20), (1 1, 1 5, 5 5, 5 1, 1 1))'::geometry, 10));
                               st_astext                                
------------------------------------------------------------------------
 POLYGON((0 0,100 0,100 100,0 100,0 0),(20 20,20 40,40 40,40 20,20 20))

Same polygon but with the smaller inner ring first:

Select ST_AsText(ST_Simplify('POLYGON((0 0, 100 0, 100 100, 0 100, 0 0), (1 1, 1 5, 5 5, 5 1, 1 1), (20 20, 20 40, 40 40, 40 20, 20 20))'::geometry, 10));
               st_astext                
----------------------------------------
 POLYGON((0 0,100 0,100 100,0 100,0 0))
(1 row)

PR: https://github.com/postgis/postgis/pull/504 Affected 3.0 and master

Change History (2)

comment:1 by Algunenano, 5 years ago

Owner: changed from pramsey to Algunenano

This seems to also explain an fix #4556

comment:2 by Raul Marin <git@…>, 5 years ago

Resolution: fixed
Status: newclosed

In 570fbdb/git:

Fix oversimplification of polygon inner rings

This also adapts a MVT test which is checking whether it crashes with an
input or not. Since the exact output depends on the backend
(GEOS vs wagyu), we just ensure the input passes through the function.

Closes #4568
Closes #4556
Closes https://github.com/postgis/postgis/pull/504

Note: See TracTickets for help on using tickets.