[geos-devel] [GEOS] #1074: Setting precision on some but not all geometries causes intersection results to use the smallest nonzero gridSize
GEOS
geos-trac at osgeo.org
Tue Nov 24 10:42:51 PST 2020
#1074: Setting precision on some but not all geometries causes intersection
results to use the smallest nonzero gridSize
--------------------------+--------------------------
Reporter: Brendan Ward | Owner: geos-devel@…
Type: defect | Status: new
Priority: major | Milestone:
Component: Default | Version: 3.8.0
Severity: Unassigned | Keywords:
--------------------------+--------------------------
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)
--
Ticket URL: <https://trac.osgeo.org/geos/ticket/1074>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).
More information about the geos-devel
mailing list