[Community] Polygon.contains() fails after being called few dozen times
sgillies at frii.com
sgillies at frii.com
Thu Jun 26 18:12:04 EEST 2008
> Jaakko Salli wrote:
>> Brent Pedersen wrote:
>>> On Wed, Jun 25, 2008 at 8:52 AM, Jaakko Salli <jaakko.salli at pp.inet.fi>
>>> wrote:
>>>> Hi all,
>>>>
>>>> I have encountered strange problem with Polygon.contains(Point). It
>>>> seems it stops functioning correctly after being called 21 times. At
>>>> that point, instead of checking if point is inside the polygon, it
>>>> just
>>>> check if it is inside polygon's bounding box.
>>>>
>>>> Here is code to reproduce the issue (I have tried it with Python 2.5.2
>>>> and Shapely SVN trunk):
>>>>
>>>> from shapely.geometry import Point, Polygon
>>>>
>>>> # Form a 'L' shaped polygon
>>>> points = [(0.0, 0.0),
>>>> (1.0, 0.0),
>>>> (1.0, 1.0),
>>>> (2.0, 1.0),
>>>> (2.0, 2.0),
>>>> (0.0, 2.0),
>>>> (0.0, 0.0)]
>>>>
>>>> poly = Polygon(points)
>>>>
>>>> # Create point that should be outside polygon, but
>>>> # inside its bounding box
>>>> pt_outside_but_inside_bbox = Point(1.5, 0.5)
>>>>
>>>> # Create point that should be outside polygon,
>>>> # even outside its bounding box
>>>> pt_outside_even_bbox = Point(2.5, 0.5)
>>>>
>>>> # At iteration number 22, poly.contains effectively becomes
>>>> # poly_bounding_box.contains
>>>> for i in range(1,100):
>>>> res1 = poly.contains(pt_outside_but_inside_bbox)
>>>> res2 = poly.contains(pt_outside_even_bbox)
>>>> print '#%i: poly.contains(pt_outside_but_inside_bbox) = %s'%(i,
>>>> res1)
>>>> print ' poly.contains(pt_outside_even_bbox) = %s'%(res2)
>>>> if res1 != False:
>>>> print "poly.contains failed at try #%i!"%(i)
>>>> break
>>>>
>>>>
>>>> Thanks,
>>>> Jaakko Salli
>>>>
>>>>
>>>> _______________________________________________
>>>> Community mailing list
>>>> Community at lists.gispython.org
>>>> http://lists.gispython.org/mailman/listinfo/community
>>>>
>>> thankfully, i dont see this with r1117. that scared me.
>>> even upped the range to 100K and no problems.
>>> fwiw, i'm using geos 3.0.0, not an rc...
>> I'm using the geos DLL provided with the Windows installer
>> (also using Windows XP SP2, if that matters).
> I have now built geos 3.0.0 DLL with msys+MingW32. Seems to have fixed
> the issue.
>
> Sorry for bothering :)
>
> Thanks,
> Jaakko
Jaakko, would you be willing to put that DLL online so I can download and
compare it to the one I am distributing?
Cheers,
Sean
More information about the Community
mailing list