[postgis-tickets] [PostGIS] #2864: ST_Envelope does not contain all points of invalid geometry
PostGIS
trac at osgeo.org
Wed Jul 30 08:48:37 PDT 2014
#2864: ST_Envelope does not contain all points of invalid geometry
---------------------+------------------------------------------------------
Reporter: dbaston | Owner: pramsey
Type: defect | Status: new
Priority: high | Milestone:
Component: postgis | Version: 2.1.x
Keywords: |
---------------------+------------------------------------------------------
I'm calling this a "defect" although I understand that is open to
debate...
When called on an invalid polygon whose interior rings go outside of an
exterior ring, ST_Envelope can return a box that does not contain all
points that make up the geometry. Simple example:
{{{ SELECT ST_AsText(ST_Envelope('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0),
(1 1, 1 2, 2 2, 2 1, 1 -20, 1 1))'::geometry)) -- returns POLYGON((0 0,0
10,10 10,10 0,0 0)) }}}
I can see that the concept of an "envelope" becomes fuzzy for a
meaningless polygon, but a downstream effect is that ST_YMin gives a
result that is not the minimum y coordinate:
{{{ SELECT ST_YMin('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2
2, 2 1, 1 -20, 1 1))'::geometry) -- returns 0 }}}
I didn't look into how PostGIS is determining an envelope (GEOS?) but the
behaviour of PostGIS in this case _is_ consistent with JTS.
(My use case here? Finding all geometries that had coordinates mistakenly
altered from 40 to 4, 30 to 3, etc.)
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2864>
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