Sean Gillies wrote:
> Jaakko Salli wrote:
>> Sean Gillies wrote:
>>> Jaakko Salli wrote:
>>>> [EMAIL PROTECTED] wrote:
>>>>>> Jaakko Salli wrote:
>>>>>>> Brent Pedersen wrote:
>>>>>>>> On Wed, Jun 25, 2008 at 8:52 AM, Jaakko Salli <[EMAIL PROTECTED]>
>>>>>>>> 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
>>>>>>>>> [email protected]
>>>>>>>>> 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?
>>>> Here you go:
>>>>
>>>> http://personal.inet.fi/private/jmsalli/geos_dlls.zip
>>>>
>>>> I didn't use any configure options, but did run 'strip -d' after make was
>>>> done.
>>>>
>>>> Jaakko
>>> Jaakko,
>>>
>>> I'm back in my office, trying to reproduce the problem, and have run
>>> into something that disturbs me ...
>>>
>>> Save the attached doctest file and run it like
>>>
>>> >>> import doctest
>>> >>> doctest.testfile('ops-repeat.txt')
>>>
>>> On Linux (w/ Python 2.5, GEOS 3.0) the test passes. The test also passes
>>> when I use your new DLLs. I can confirm that if I use the geos.dll I
>>> have been distributing, the test fails on the 22nd interation. I have no
>>> idea WTF is going on in that case :(
>>>
>>> I'm not a Windows platform expert at all ... will your DLLs work on all
>>> Win32 systems? I'm testing on Windows 2000 here.
>>>
>>> Cheers,
>>> Sean
>> Sorry, I can only test with XP, but since it works on your Windows 2000
>> I can't think of any reason why low-level stuff like this would not work
>> on all modern NT-based versions of Windows (ie. Win2K and later).
>> Win95-based ones are another matter, although I still think that it will
>> work.
>>
>> One thing however: On Windows, Python 2.5 extensions are supposed to be
>> built with Visual C++ 7, but your included makefile failed for me. So, I
>> tried mingw, and was surprised that the resulting DLLs worked. Mingw
>> links with the same CRT as VC7, so that probably helped.
>>
>> Jaakko
>
> Jaakko,
>
> I'd like to use your DLLs for future Shapely windows installers. Can the
> size of the second be reduced at all?
Do you know any additional configure flags that I can use to reduce the
binary size?
Currently, using CXXFLAGS=Os and strip, I get following sizes:
geos.dll 348kb
libgeos-3-0-0.dll 1,24Mb
I did some profiling with hotshot to see how -Os affected performance.
With -Os:
ncalls tottime percall cumtime percall filename:lineno(function)
88725 1131.105 0.013 1131.105 0.013 base.py:74(next)
14742 1096.408 0.074 1096.408 0.074
polygon.py:13(geos_linearring_from_py)
190944 220.017 0.0011522 220.017 0.001 base.py:283(_get_geom)
32868 144.263 0.004 144.263 0.004
base.py:24(geometry_type_name)
29484 134.660 0.005 134.660 0.005 base.py:65(update_cseq)
31176 34.807 0.0011164 34.807 0.001
polygon.py:173(_init_geom)
With -O2:
ncalls tottime percall cumtime percall filename:lineno(function)
138775 1671.761 0.012 1671.761 0.012 base.py:74(next)
23058 1722.861 0.075 1722.861 0.075
polygon.py:13(geos_linearring_from_py)
298320 334.852 0.0011224 334.852 0.001 base.py:283(_get_geom)
51348 217.887 0.004 217.887 0.004
base.py:24(geometry_type_name)
46116 207.142 0.004 207.142 0.004 base.py:65(update_cseq)
48732 52.525 0.0010778 52.525 0.001
polygon.py:173(_init_geom)
Not much in this case (few percents).
(number of calls in tests don't match as I did it by moving some objects
in gui)
Let me know if you want these new DLLs uploaded.
Jaakko
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community