Opened 4 years ago
Closed 4 years ago
#4725 closed defect (fixed)
ST_MakeValid causes drastic loss of precision
Reported by: | atlight | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS GEOS |
Component: | postgis | Version: | 3.0.x |
Keywords: | Cc: |
Description
ST_MakeValid experiences a drastic loss of precision on a particular polygon input. It is a complex polygon with five somewhat pathological interior rings.
The bug only occurs when all five of the interior rings (holes) are present. When one is removed, no precision loss occurs.
What is especially problematic is, when this polygon is part of a MultiPolygon
and ST_MakeValid is applied to the MultiPolygon
, the entire MultiPolygon
loses precision in this manner, rendering the geometry useless.
I've uploaded the WKB of the offending polygon as an attachment. When inserted into a table a
with geometry column geom
, I get the following output:
scratch=# SELECT SUBSTRING(ST_AsText(geom) FROM 1 FOR 100) FROM a; substring ------------------------------------------------------------------------------------------------------ POLYGON Z ((144.96322622986 -37.741979743636 0,144.96322622986 -37.741979743636 0,144.963225440888 - (1 row) scratch=# SELECT SUBSTRING(ST_AsText(ST_MakeValid(geom)) FROM 1 FOR 100) FROM a; substring ------------------------------------------------------------------------------------------------------ GEOMETRYCOLLECTION Z (MULTIPOLYGON Z (((144.963224 -37.74198 0,144.963222 -37.74198 0,144.963221 -37 (1 row)
Attachments (1)
Change History (4)
by , 4 years ago
Attachment: | pathpolybin added |
---|
comment:1 by , 4 years ago
Milestone: | PostGIS 3.0.2 → PostGIS 3.1.0 |
---|---|
Version: | 2.5.x → 3.0.x |
comment:2 by , 4 years ago
Milestone: | PostGIS 3.1.0 → PostGIS GEOS |
---|
As expected, this is a result of GEOS precision reduction routines in the old overlay engine trying to back off from repeated topology failures during overlay. And as hoped, the new overlay engine does not display the same behaviour. A valid output is generated, and the precision is basically the same.
postgis31=# select st_xmin(ST_MakeValid(geom)) FROM a; st_xmin ------------------- 144.9632208323141 (1 row) postgis31=# select st_xmin(geom) FROM a; st_xmin ------------------- 144.9632208323141 (1 row)
The solution will be to upgrade to GEOS 3.9 when it is released.
Hex WKB of offending polygon