[postgis-tickets] [PostGIS] #3679: Invalid geometries: equal and disjoint?

PostGIS trac at osgeo.org
Thu Dec 8 19:20:47 PST 2016


#3679: Invalid geometries: equal and disjoint?
---------------------+---------------------------
 Reporter:  mwtoews  |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 2.3.2
Component:  postgis  |    Version:  2.2.x
 Keywords:           |
---------------------+---------------------------
 It seems that GEOS and JTS think that invalid geometries are disjoint. For
 example, GEOS 3.5.0 from shapely:
 {{{#!python
 from shapely import geos, wkt
 geos.geos_version_string  # 3.5.0-CAPI-1.9.0 r4084
 g = wkt.loads('LINESTRING(1 1, 1 1)')
 g.is_valid  # False, Too few points in geometry component at or near point
 1 1
 g.relate(g)   # FFFFFFFF2
 g.equals(g)   # False
 g.disjoint(g) # True
 }}}
 And same from JTS. This is also the same behaviour of PostGIS up to
 version 2.1
 {{{
 SELECT PostGIS_Version(), PostGIS_GEOS_Version(),
     ST_Relate(g, g), ST_Equals(g, g), ST_Disjoint(g, g)
 FROM (SELECT 'LINESTRING(1 1,1 1)'::geometry g) g;
 -[ RECORD 1 ]--------+--------------------------------------
 postgis_version      | 2.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
 postgis_geos_version | 3.4.2-CAPI-1.8.2 r3924
 st_relate            | FFFFFFFF2
 st_equals            | f
 st_disjoint          | t
 }}}

 However, since PostGIS 2.2, the invalid geometry may also be equal:
 {{{
 SELECT PostGIS_Version(), PostGIS_GEOS_Version(),
     ST_Relate(g, g), ST_Equals(g, g), ST_Disjoint(g, g)
 FROM (SELECT 'LINESTRING(1 1,1 1)'::geometry g) g;
 -[ RECORD 1 ]--------+--------------------------------------
 postgis_version      | 2.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
 postgis_geos_version | 3.5.0-CAPI-1.9.0 r4090
 st_relate            | FFFFFFFF2
 st_equals            | t
 st_disjoint          | t
 }}}
 Unless this change was intentional, I'd expect invalid geometries to
 always be disjoint, and never equal. Disjoint and equal are opposite, so
 it is surprising to see this result.

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3679>
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