[postgis-tickets] [PostGIS] #4183: Invalid output of ST_ClipByBox2D with an invalid polygon
PostGIS
trac at osgeo.org
Wed Sep 19 09:40:03 PDT 2018
#4183: Invalid output of ST_ClipByBox2D with an invalid polygon
------------------------+--------------------------
Reporter: Algunenano | Owner: Algunenano
Type: defect | Status: assigned
Priority: medium | Milestone: PostGIS GEOS
Component: postgis | Version: trunk
Keywords: |
------------------------+--------------------------
I start with a valid polygon:
{{{
Select St_IsValid('SRID=3857;MULTIPOLYGON(((-8231365.02893734
4980355.83678553,-8231366.94866817 4980350.2976052,-8231368.82883367
4980344.52250402,-8231370.96255986 4980333.47364302,-8231372.09200747
4980327.69798564,-8231372.84505222 4980323.68014243,-8231374.2255656
4980316.77455645,-8231375.10554947 4980309.86865218,-8231380.6311111
4980275.9676398,-8231394.82332406 4980186.31880185,-8231394.8569833
4980133.57928934,-8231367.43081065 4979982.17443372,-8231372.85765532
4979985.17751813,-8231395.25669799 4980132.93828551,-8231396.69199339
4980227.59327083,-8231377.30092207 4980340.77515211,-8231368.35061694
4980357.62467295,-8231365.02893734 4980355.83678553)))'::geometry);
st_isvalid
------------
t
}}}
I pass this polygon through `ST_Simplify and ST_RemoveRepeatedPoints` and
it comes up as invalid:
{{{
Select
St_IsValid(ST_Simplify(ST_RemoveRepeatedPoints('SRID=3857;MULTIPOL...'),
19.109257221221924), 19.109257221221924, true));
st_isvalid
------------
f
(1 row)
}}}
Then I pass it through ST_ClipByBox2D:
{{{
Select St_AsEWKT(ST_ClipByBox2D(
'MULTIPOLYGON(((-8231365.02893734 4980355.83678553,-8231394.82332406
4980186.31880185,-8231367.43081065 4979982.17443372,-8231396.69199339
4980227.59327083,-8231365.02893734 4980355.83678553)))'::geometry,
'POLYGON((-8228215.28157305 4980103.20610541,-8228215.28157305
4970163.3879457,-8238155.09973276 4970163.3879457,-8238155.09973276
4980103.20610541,-8228215.28157305 4980103.20610541))'::geometry
));
POLYGON((-8238155.09973276 4970163.3879457,-8238155.09973276
4980103.20610541,-8231383.67109061 4980103.20610541,-8231367.43081065
4979982
.17443372,-8231381.86136498 4980103.20610541,-8228215.28157305
4980103.20610541,-8228215.28157305 4970163.3879457,-8238155.09973276
4970163
.3879457))
}}}
The result seen is not the intersection (as expected) but the result of
subtracting the geometry area to the box.
In truth this series of chained calls come from St_AsMVTGeom where this
functions are called inside the same C function, but seeing the individual
calls makes it easier to spot the issue.
I've traced this behaviour back to GEOS
(https://github.com/Algunenano/geos/commit/1737fa1a34e6cc30fb26b2898f607d5db3b176a6).
Does anyone know if GEOSClipByRect is supposed to handle invalid
geometries correctly or to just give an invalid output as the one seen
above?
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4183>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list