On Feb 3, 2009, at 6:20 AM, Eric Lemoine wrote:
> Hello
>
> I stumbled accross an issue with Shapely. See the following test case:
>
>>>> from shapely import wkt
>>>> g1 = wkt.loads('POLYGON ((0.0000000000000000 0.0000000000000000,
>>>> 1.0000000000000000 1.0000000000000000, 1.0000000000000000
>>>> 0.0000000000000000, 0.0000000000000000 0.0000000000000000),
>>>> (0.5000000000000000 0.5000000000000000, 0.7000000000000000
>>>> 0.7000000000000000, 0.7000000000000000 0.5000000000000000,
>>>> 0.5000000000000000 0.5000000000000000))')
>>>> g2 = wkt.loads('POLYGON ((0.0000000000000000 0.0000000000000000,
>>>> 1.0000000000000000 1.0000000000000000, 1.0000000000000000
>>>> 0.0000000000000000, 0.0000000000000000 0.0000000000000000),
>>>> (0.5000000000000000 0.5000000000000000, 0.7000000000000000
>>>> 0.7000000000000000, 0.7000000000000000 0.5000000000000000,
>>>> 0.5000000000000000 0.5000000000000000))')
>>>> g1.equals(g2)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/home/eric/public_html/mapfish/env/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 "/home/eric/public_html/mapfish/env/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
> 0xb7c285dc>
>
> Any idea?
>
> --
> Eric
Yes, they are invalid. Shapely 1.1 will expose a new diagnostic
function from GEOS 3.1, see below
(gispy-lab)$ labpy
>>> from shapely import wkt
>>> g1 = wkt.loads('POLYGON ((0.0000000000000000 0.0000000000000000,
1.0000000000000000 1.0000000000000000, 1.0000000000000000
0.0000000000000000, 0.0000000000000000 0.0000000000000000),
(0.5000000000000000 0.5000000000000000, 0.7000000000000000
0.7000000000000000, 0.7000000000000000 0.5000000000000000,
0.5000000000000000 0.5000000000000000))')
>>> g2 = wkt.loads('POLYGON ((0.0000000000000000 0.0000000000000000,
1.0000000000000000 1.0000000000000000, 1.0000000000000000
0.0000000000000000, 0.0000000000000000 0.0000000000000000),
(0.5000000000000000 0.5000000000000000, 0.7000000000000000
0.7000000000000000, 0.7000000000000000 0.5000000000000000,
0.5000000000000000 0.5000000000000000))')
>>> g1.equals(g2)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/seang/code/gispy-lab/src/Shapely/shapely/
predicates.py", line 38, in __call__
return bool(self.fn(self.context._geom, other._geom))
File "/Users/seang/code/gispy-lab/src/Shapely/shapely/geos.py",
line 141, in __call__
return self.func(thread_data.geos_handle, *args)
File "/Users/seang/code/gispy-lab/src/Shapely/shapely/
predicates.py", line 30, in errcheck
raise PredicateError, "Failed to evaluate %s" % repr(self.fn)
PredicateError: Failed to evaluate <shapely.geos.wrapper object at
0x725a10>
>>> g1.is_valid
False
>>> g1.is_valid_reason()
'Self-intersection [0.5 0.5]'
>>> g2.is_valid
False
>>> g2.is_valid_reason()
'Self-intersection [0.5 0.5]'
I'm not sure about the final form of that method. Any ideas?
Sean
--
Sean Gillies
[email protected]
http://sgillies.net
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community