Opened 15 years ago

Closed 15 years ago

#239 closed defect (invalid)

Bug in GEOSEquals predicate

Reported by: pleroux Owned by: sgillies
Priority: major Milestone: 3.1.1
Component: SWIG Python Version: 3.0.3
Severity: Unassigned Keywords:
Cc:

Description

while searching for intersections between polygons (buildings), I have found shapes that make "equals" predicate crash. With simpler shapes, it occurs too :

>>> from shapely.geometry import Polygon
>>> p1 = Polygon(((0,0),(0,10),(10,10),(10,0),(8,0),(8,8),(2,8),(2,0)))
>>> p2 = Polygon(((2,0),(2,8),(8,8),(7,4),(8,0)))
>>> inter = p1.intersection(p2)
>>> inter.is_valid and p1.is_valid and p2.is_valid
True
>>> inter.wkt
'GEOMETRYCOLLECTION (POINT (8.0000000000000000 0.0000000000000000),
LINESTRING (8.0000000000000000 8.0000000000000000, 2.0000000000000000
8.0000000000000000), LINESTRING (2.0000000000000000 8.0000000000000000,
2.0000000000000000 0.0000000000000000))'
>>> inter.equals(p1)
False
>>> inter.equals(p2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py",
line 34, in __call__
    return bool(self.fn(self.context._geom, other._geom))
  File
"/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py",
line 21, in errcheck
    raise PredicateError, "Failed to evaluate %s" % repr(self.fn)
shapely.geos.PredicateError: Failed to evaluate <_FuncPtr object at
0x96a3bf4>

I have got a Bus Error on MacOSX (libgeos version 3.0.0) and a Segmentation Fault on Ubuntu (libgeos version 3.0.3) with an equivalent code written in C (so I think Shapely is not involved).

Attached files :

simple.wkt contains the 2 polygons used in the Python script below

equals_errors.hexwkb : the original polygons (4 couples of polygons : errors occur with polygons 0 and 1, polygons 2 and 3, etc ...)

Attachments (2)

simple.wkt (90 bytes ) - added by pleroux 15 years ago.
equals_errors.hexwkb (4.9 KB ) - added by pleroux 15 years ago.

Download all attachments as: .zip

Change History (7)

by pleroux, 15 years ago

Attachment: simple.wkt added

by pleroux, 15 years ago

Attachment: equals_errors.hexwkb added

comment:1 by pleroux, 15 years ago

I think it is a more general problem, linked to the intersection geometry.
With the same variable names as in the script above :

>>> p1.contains(inter)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py", line 34, in __call__
    return bool(self.fn(self.context._geom, other._geom))
  File "/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py", line 21, in errcheck
    raise PredicateError, "Failed to evaluate %s" % repr(self.fn)
shapely.geos.PredicateError: Failed to evaluate <_FuncPtr object at 0x8a8a984>
>>> 
>>> p2.contains(inter)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py", line 34, in __call__
    return bool(self.fn(self.context._geom, other._geom))
  File "/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py", line 21, in errcheck
    raise PredicateError, "Failed to evaluate %s" % repr(self.fn)
shapely.geos.PredicateError: Failed to evaluate <_FuncPtr object at 0x8a8a984>

comment:2 by (none), 15 years ago

Milestone: 3.1.0

Milestone 3.1.0 deleted

comment:3 by pramsey, 15 years ago

Milestone: 3.1.1

comment:4 by strk, 15 years ago

Component: DefaultSWIG Python
Owner: changed from geos-devel@… to sgillies

In pure GEOS it has no problems, as of current SVN:

Matrix for your 'inter' (A) and 'p2' (B)

Equals: AB=F, BA=F

Disjoint: AB=F, BA=F

Intersects: AB=T, BA=T

Touches: AB=T, BA=T Crosses: AB=F, BA=F

Within: AB=F, BA=F

Contains: AB=F, BA=F Overlaps: AB=F, BA=F

comment:5 by pramsey, 15 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.