Opened 3 years ago
Last modified 3 years ago
#1074 new defect
Setting precision on some but not all geometries causes intersection results to use the smallest nonzero gridSize
Reported by: | Brendan Ward | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 3.11.0 |
Component: | Default | Version: | 3.8.0 |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
According to the comments in "geos_c.h.in" for GEOSGeom_setPrecision_r: "
- Note that operations will always be performed in the precision
- of the geometry with higher precision (smaller "gridSize").
- That same precision will be attached to the operation outputs.
"
Given inputs:
- "POLYGON ((0 0, 0 0.9, 0.9 0.9, 0.9 0, 0 0))"
- "POLYGON ((0.75 0, 0.75 0.75, 1.75 0.75, 1.75 0, 0.75 0))"
I then used GEOSGeom_setPrecision_r with a gridSize of 0.5 for the first geometry, which returns "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))", and reports a gridSize of 0.5 via GEOSGeom_getPrecision_r.
Performing an intersection via GEOSIntersection_r, I get back "POLYGON ((1 0.75, 1 0, 0.75 0, 0.75 0.75, 1 0.75))" which reports a gridSize of 0.5 (second geometry reports a gridSize of 0).
If I then set a precision of 1 on the second geometry, which produces: "POLYGON ((1 0, 1 1, 2 1, 2 0, 1 0))" (second geometry then reports a gridSize of 1)
I get back "LINESTRING (1 1, 1 0)" from intersection, which reports a gridSize of 0.5
This may be expected behavior, but the comment in the code implies that the higher precision, in this case full precision as denoted by a gridSize of 0, would be used. If so, perhaps the comment could be clarified to note something like:
- if inputs both have nonzero gridSize, operations will be performed using the higher precision (smaller "gridSize").
- if one but not all of the inputs have a nonzero gridSize, and others have a gridSize of 0, the smallest gridSize will be used.
(only tested on GEOS 3.8 via C API)
Change History (2)
comment:1 by , 3 years ago
Milestone: | → 3.10.0 |
---|
comment:2 by , 3 years ago
Milestone: | 3.10.0 → 3.11.0 |
---|
Retargeting in prep for GEOS 3.10.0 release