#1071 closed defect (wontfix)
Setting lower precision of polygon always collapses polygon
Reported by: | Brendan Ward | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 3.11.0 |
Component: | Default | Version: | 3.5.1 |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
Used via C API GEOSGeom_setPrecision_r.
Given an input polygon WKT: "POLYGON ((0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0))" and a gridSize of 1.
With flags unset (0), this causes the polygon to collapse to an empty polygon (expected): "POLYGON EMPTY"
With flags set to keep collapsed elements, the polygon is still collapsed to an empty polygon (unexpected).
The expected output is "POLYGON ((0 0, 0 0, 0 0, 0 0, 0 0))".
In contrast, a linear ring behaves as expected. Given an input of "LINEARRING (0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0)":
flag not set: "LINEARRING EMPTY" flag set: "LINEARRING (0 0, 0 0, 0 0, 0 0, 0 0)"
Change History (5)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
It might be useful to clarify the intent of the flag to keep collapsed elements; it is not clear what collapsed elements should be retained, since their collapse implies that they are no longer toplogically valid.
Decisions here also affect line strings as well. Given an input of "LINESTRING (0 0, 0.1 0.1)" and gridSize of 1, with this flag set, it returns "LINESTRING (0 0, 0 0)", which is not valid (according to GEOSisValid_r).
(have not tested on 3.9 / master)
comment:3 by , 3 years ago
Milestone: | → 3.10.0 |
---|
comment:4 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
It's hard, some systems both (a) want only homogeneous feature types and (b) want to preserve collapsed components.
So you can't for example convert a LINESTRING(0 0, 0 0) into a POINT(0 0).
Nor can you drop it, because the user wants to *see* the result.
I'm going to close this because I don't see a fix path, just an interesting conversation over beers.
The goal of GEOS operations is to always produce valid output. A polygon with zero extent is invalid, so the closest valid result is
POLYGON EMPTY
. Another way to put this is that if a polygon collapses completely due to rounding, it disappears rather than becoming a point.The collapsed LinearRing result is in fact also invalid. So probably the current result is out of spec, and should be changed to become
LINEARRING EMPTY
. (In fact this should be the behaviour of the latest GEOS version incorporating OverlayNG).