shapely 1.2.9__tar.gz → 1.2.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. {Shapely-1.2.9 → Shapely-1.2.12}/CHANGES.txt +22 -0
  2. {Shapely-1.2.9 → Shapely-1.2.12}/CREDITS.txt +3 -1
  3. {Shapely-1.2.9/Shapely.egg-info → Shapely-1.2.12}/PKG-INFO +23 -1
  4. {Shapely-1.2.9 → Shapely-1.2.12/Shapely.egg-info}/PKG-INFO +23 -1
  5. {Shapely-1.2.9 → Shapely-1.2.12}/Shapely.egg-info/SOURCES.txt +7 -0
  6. {Shapely-1.2.9 → Shapely-1.2.12}/docs/manual.txt +64 -2
  7. Shapely-1.2.12/setup.py +129 -0
  8. Shapely-1.2.12/shapely/algorithms/__init__.py +0 -0
  9. Shapely-1.2.12/shapely/algorithms/cga.py +17 -0
  10. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/ctypes_declarations.py +5 -0
  11. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/base.py +4 -1
  12. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/linestring.py +8 -13
  13. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/multilinestring.py +0 -3
  14. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/multipoint.py +3 -2
  15. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/polygon.py +40 -39
  16. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geos.py +7 -6
  17. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/impl.py +4 -0
  18. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/predicates.py +2 -2
  19. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/prepared.py +4 -1
  20. Shapely-1.2.12/shapely/speedups/__init__.py +42 -0
  21. Shapely-1.2.12/shapely/speedups/_speedups.c +4551 -0
  22. Shapely-1.2.12/shapely/speedups/_speedups.pyx +295 -0
  23. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/__init__.py +3 -1
  24. Shapely-1.2.12/shapely/tests/test_cga.py +33 -0
  25. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_dlls.py +3 -2
  26. Shapely-1.2.12/shapely/tests/test_prepared.py +28 -0
  27. Shapely-1.2.12/shapely/tests/test_speedups.py +38 -0
  28. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/topology.py +6 -8
  29. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/wkb.py +2 -2
  30. Shapely-1.2.9/setup.py +0 -57
  31. Shapely-1.2.9/shapely/tests/test_prepared.py +0 -15
  32. {Shapely-1.2.9 → Shapely-1.2.12}/LICENSE.txt +0 -0
  33. {Shapely-1.2.9 → Shapely-1.2.12}/README.txt +0 -0
  34. {Shapely-1.2.9 → Shapely-1.2.12}/Shapely.egg-info/dependency_links.txt +0 -0
  35. {Shapely-1.2.9 → Shapely-1.2.12}/Shapely.egg-info/top_level.txt +0 -0
  36. {Shapely-1.2.9 → Shapely-1.2.12}/setup.cfg +0 -0
  37. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/__init__.py +0 -0
  38. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/coords.py +0 -0
  39. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/examples/__init__.py +0 -0
  40. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/examples/dissolve.py +0 -0
  41. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/examples/geoms.py +0 -0
  42. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/examples/intersect.py +0 -0
  43. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/examples/world.py +0 -0
  44. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/ftools.py +0 -0
  45. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/__init__.py +0 -0
  46. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/collection.py +0 -0
  47. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/geo.py +0 -0
  48. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/multipolygon.py +0 -0
  49. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/point.py +0 -0
  50. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/geometry/proxy.py +0 -0
  51. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/iterops.py +0 -0
  52. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/linref.py +0 -0
  53. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/ops.py +0 -0
  54. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/Array.txt +0 -0
  55. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/GeoInterface.txt +0 -0
  56. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/IterOps.txt +0 -0
  57. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/LineString.txt +0 -0
  58. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/MultiLineString.txt +0 -0
  59. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/MultiPoint.txt +0 -0
  60. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/MultiPolygon.txt +0 -0
  61. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/Operations.txt +0 -0
  62. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/Persist.txt +0 -0
  63. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/Point.txt +0 -0
  64. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/Polygon.txt +0 -0
  65. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/Predicates.txt +0 -0
  66. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/attribute-chains.txt +0 -0
  67. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/binascii_hex.txt +0 -0
  68. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/cascaded_union.txt +0 -0
  69. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/dimensions.txt +0 -0
  70. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/invalid_intersection.txt +0 -0
  71. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/linemerge.txt +0 -0
  72. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/polygonize.txt +0 -0
  73. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_box.py +0 -0
  74. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_collection.py +0 -0
  75. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_delegated.py +0 -0
  76. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_doctests.py +0 -0
  77. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_emptiness.py +0 -0
  78. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_equality.py +0 -0
  79. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_geomseq.py +0 -0
  80. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_linear_referencing.py +0 -0
  81. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_mapping.py +0 -0
  82. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_products_z.py +0 -0
  83. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_singularity.py +0 -0
  84. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_validation.py +0 -0
  85. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/test_xy.py +0 -0
  86. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/threading_test.py +0 -0
  87. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/tests/wkt_locale.txt +0 -0
  88. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/validation.py +0 -0
  89. {Shapely-1.2.9 → Shapely-1.2.12}/shapely/wkt.py +0 -0
@@ -2,6 +2,28 @@
2
2
  CHANGES
3
3
  =======
4
4
 
5
+ 1.2.12 (2011-08-15)
6
+ -------------------
7
+ - Build Windows distributions with VC7 or VC9 as appropriate.
8
+ - More verbose report on failure to speed up.
9
+ - Fix for prepared geometries broken in 1.2.11.
10
+ - DO NOT INSTALL 1.2.11
11
+
12
+ 1.2.11 (2011-08-04)
13
+ -------------------
14
+ - Ignore AttributeError during exit.
15
+ - PyPy 1.5 support.
16
+ - Prevent operation on prepared geometry crasher (#12).
17
+ - Optional Cython speedups for Windows.
18
+ - Linux 3 platform support.
19
+
20
+ 1.2.10 (2011-05-09)
21
+ -------------------
22
+ - Add optional Cython speedups.
23
+ - Add is_cww predicate to LinearRing.
24
+ - Add function that forces orientation of Polygons.
25
+ - Disable build of speedups on Windows pending packaging work.
26
+
5
27
  1.2.9 (2011-03-31)
6
28
  ------------------
7
29
  - Remove extra glob import.
@@ -3,6 +3,7 @@ Shapely is written by:
3
3
  * Sean Gillies
4
4
  * Aron Bierbaum
5
5
  * Kai Lautaportti
6
+ * Oliver Tonnhofer
6
7
 
7
8
  Patches contributed by:
8
9
 
@@ -11,7 +12,6 @@ Patches contributed by:
11
12
  * Eric Lemoine
12
13
  * Jonathan Tartley
13
14
  * Kristian Thy
14
- * Oliver Tonnhofer
15
15
 
16
16
  Additional help from:
17
17
 
@@ -22,3 +22,5 @@ Additional help from:
22
22
 
23
23
  Major portions of this work were supported by a grant (for Pleiades_) from the
24
24
  U.S. National Endowment for the Humanities (http://www.neh.gov).
25
+
26
+ .. _Pleiades: http://pleiades.stoa.org
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.2.9
3
+ Version: 1.2.12
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/lab/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -166,6 +166,28 @@ Description: ======
166
166
  CHANGES
167
167
  =======
168
168
 
169
+ 1.2.12 (2011-08-15)
170
+ -------------------
171
+ - Build Windows distributions with VC7 or VC9 as appropriate.
172
+ - More verbose report on failure to speed up.
173
+ - Fix for prepared geometries broken in 1.2.11.
174
+ - DO NOT INSTALL 1.2.11
175
+
176
+ 1.2.11 (2011-08-04)
177
+ -------------------
178
+ - Ignore AttributeError during exit.
179
+ - PyPy 1.5 support.
180
+ - Prevent operation on prepared geometry crasher (#12).
181
+ - Optional Cython speedups for Windows.
182
+ - Linux 3 platform support.
183
+
184
+ 1.2.10 (2011-05-09)
185
+ -------------------
186
+ - Add optional Cython speedups.
187
+ - Add is_cww predicate to LinearRing.
188
+ - Add function that forces orientation of Polygons.
189
+ - Disable build of speedups on Windows pending packaging work.
190
+
169
191
  1.2.9 (2011-03-31)
170
192
  ------------------
171
193
  - Remove extra glob import.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.2.9
3
+ Version: 1.2.12
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/lab/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -166,6 +166,28 @@ Description: ======
166
166
  CHANGES
167
167
  =======
168
168
 
169
+ 1.2.12 (2011-08-15)
170
+ -------------------
171
+ - Build Windows distributions with VC7 or VC9 as appropriate.
172
+ - More verbose report on failure to speed up.
173
+ - Fix for prepared geometries broken in 1.2.11.
174
+ - DO NOT INSTALL 1.2.11
175
+
176
+ 1.2.11 (2011-08-04)
177
+ -------------------
178
+ - Ignore AttributeError during exit.
179
+ - PyPy 1.5 support.
180
+ - Prevent operation on prepared geometry crasher (#12).
181
+ - Optional Cython speedups for Windows.
182
+ - Linux 3 platform support.
183
+
184
+ 1.2.10 (2011-05-09)
185
+ -------------------
186
+ - Add optional Cython speedups.
187
+ - Add is_cww predicate to LinearRing.
188
+ - Add function that forces orientation of Polygons.
189
+ - Disable build of speedups on Windows pending packaging work.
190
+
169
191
  1.2.9 (2011-03-31)
170
192
  ------------------
171
193
  - Remove extra glob import.
@@ -24,6 +24,8 @@ shapely/topology.py
24
24
  shapely/validation.py
25
25
  shapely/wkb.py
26
26
  shapely/wkt.py
27
+ shapely/algorithms/__init__.py
28
+ shapely/algorithms/cga.py
27
29
  shapely/examples/__init__.py
28
30
  shapely/examples/dissolve.py
29
31
  shapely/examples/geoms.py
@@ -40,6 +42,9 @@ shapely/geometry/multipolygon.py
40
42
  shapely/geometry/point.py
41
43
  shapely/geometry/polygon.py
42
44
  shapely/geometry/proxy.py
45
+ shapely/speedups/__init__.py
46
+ shapely/speedups/_speedups.c
47
+ shapely/speedups/_speedups.pyx
43
48
  shapely/tests/Array.txt
44
49
  shapely/tests/GeoInterface.txt
45
50
  shapely/tests/IterOps.txt
@@ -61,6 +66,7 @@ shapely/tests/invalid_intersection.txt
61
66
  shapely/tests/linemerge.txt
62
67
  shapely/tests/polygonize.txt
63
68
  shapely/tests/test_box.py
69
+ shapely/tests/test_cga.py
64
70
  shapely/tests/test_collection.py
65
71
  shapely/tests/test_delegated.py
66
72
  shapely/tests/test_dlls.py
@@ -73,6 +79,7 @@ shapely/tests/test_mapping.py
73
79
  shapely/tests/test_prepared.py
74
80
  shapely/tests/test_products_z.py
75
81
  shapely/tests/test_singularity.py
82
+ shapely/tests/test_speedups.py
76
83
  shapely/tests/test_validation.py
77
84
  shapely/tests/test_xy.py
78
85
  shapely/tests/threading_test.py
@@ -3,8 +3,8 @@ The Shapely User Manual
3
3
  =======================
4
4
 
5
5
  :Author: Sean Gillies, <sean.gillies@gmail.com>
6
- :Revision: 1.2.9
7
- :Date: 31 March 2011
6
+ :Revision: 1.2.10
7
+ :Date: 2 May 2011
8
8
  :Copyright:
9
9
  This work is licensed under a `Creative Commons Attribution 3.0
10
10
  United States License`__.
@@ -493,6 +493,17 @@ For example:
493
493
 
494
494
  This is the first appearance of an explicit polygon handedness in Shapely.
495
495
 
496
+ To obtain a polygon with a known orientation, use
497
+ :func:`shapely.geometry.polygon.orient()`:
498
+
499
+ .. function:: shapely.geometry.polygon.orient(polygon, sign=1.0)
500
+
501
+ Returns a properly oriented copy of the given polygon. The signed area of the
502
+ result will have the given sign. A sign of 1.0 means that the coordinates of the
503
+ product's exterior ring will be oriented counter-clockwise.
504
+
505
+ `New in version 1.2.10`.
506
+
496
507
  .. _collections:
497
508
 
498
509
  Collections
@@ -835,6 +846,29 @@ example will be shown for each.
835
846
  >>> Point(0, 0, 0).has_z
836
847
  True
837
848
 
849
+ .. attribute:: object.is_ccw
850
+
851
+ Returns ``True`` if coordinates are in counter-clockwise order (bounding a region
852
+ with positive signed area). This method applies to `LinearRing` objects only.
853
+
854
+ `New in version 1.2.10`.
855
+
856
+ .. sourcecode:: pycon
857
+
858
+ >>> LinearRing([(1,0), (1,1), (0,0)]).is_ccw
859
+ True
860
+
861
+ A ring with an undesired orientation can be reversed like this:
862
+
863
+ .. sourcecode:: pycon
864
+
865
+ >>> ring = LinearRing([(0,0), (1,1), (1,0)])
866
+ >>> ring.is_ccw
867
+ False
868
+ >>> ring.coords = list(ring.coords)[::-1]
869
+ >>> ring.is_ccw
870
+ True
871
+
838
872
  .. attribute:: object.is_empty
839
873
 
840
874
  Returns ``True`` if the feature's `interior` and `boundary` (in point set
@@ -1756,6 +1790,34 @@ For example, using the same `GeoThing` class:
1756
1790
  >>> m['coordinates']
1757
1791
  (0.0, 0.0)}
1758
1792
 
1793
+
1794
+ Performance
1795
+ ===========
1796
+
1797
+ Shapely uses the GEOS_ library for all operations. GEOS is written in C++ and
1798
+ used in many applications and you can expect that all operations are highly
1799
+ optimized. Only the creation of new geometries involves some overhead that
1800
+ might slow down your code, if you create lots of geometries with a large number
1801
+ of coordinates.
1802
+
1803
+ .. versionadded:: 1.2.10
1804
+
1805
+ The :mod:`shapely.speedups` module contains performance enhancements written
1806
+ in C. They are automaticaly installed when Python has access to a compiler
1807
+ during installation.
1808
+
1809
+ You can check if the speedups are installed with the :attr:`available`
1810
+ attribute. To enable the speedups call :func:`enable`. You can revert to the
1811
+ default implementation with :func:`disable`.
1812
+
1813
+ .. sourcecode:: pycon
1814
+
1815
+ >>> from shapely import speedups
1816
+ >>> speedups.available
1817
+ True
1818
+ >>> speedups.enable()
1819
+
1820
+
1759
1821
  Conclusion
1760
1822
  ==========
1761
1823
 
@@ -0,0 +1,129 @@
1
+ import glob
2
+ import warnings
3
+
4
+ try:
5
+ from distribute_setup import use_setuptools
6
+ use_setuptools()
7
+ except:
8
+ warnings.warn(
9
+ "Failed to import distribute_setup, continuing without distribute.",
10
+ Warning)
11
+
12
+ from distutils.errors import CCompilerError, DistutilsExecError, \
13
+ DistutilsPlatformError
14
+ from setuptools.extension import Extension
15
+ from setuptools.command.build_ext import build_ext
16
+ from setuptools import setup, find_packages
17
+ import sys
18
+ import platform
19
+
20
+ readme_text = file('README.txt', 'rb').read()
21
+ changes_text = file('CHANGES.txt', 'rb').read()
22
+
23
+ setup_args = dict(
24
+ metadata_version = '1.2',
25
+ name = 'Shapely',
26
+ version = '1.2.12',
27
+ requires_python = '>=2.5,<3',
28
+ requires_external = 'libgeos_c (>=3.1)',
29
+ description = 'Geometric objects, predicates, and operations',
30
+ license = 'BSD',
31
+ keywords = 'geometry topology gis',
32
+ author = 'Sean Gillies',
33
+ author_email = 'sean.gillies@gmail.com',
34
+ maintainer = 'Sean Gillies',
35
+ maintainer_email = 'sean.gillies@gmail.com',
36
+ url = 'http://trac.gispython.org/lab/wiki/Shapely',
37
+ long_description = readme_text + "\n" + changes_text,
38
+ packages = find_packages(),
39
+ test_suite = 'shapely.tests.test_suite',
40
+ classifiers = [
41
+ 'Development Status :: 5 - Production/Stable',
42
+ 'Intended Audience :: Developers',
43
+ 'Intended Audience :: Science/Research',
44
+ 'License :: OSI Approved :: BSD License',
45
+ 'Operating System :: OS Independent',
46
+ 'Programming Language :: Python',
47
+ 'Topic :: Scientific/Engineering :: GIS',
48
+ ],
49
+ )
50
+
51
+ # Add DLLs for Windows
52
+ if sys.platform == 'win32':
53
+ if '(AMD64)' in sys.version:
54
+ setup_args.update(
55
+ data_files=[('DLLs', glob.glob('DLLs_AMD64_VC9/*.dll'))]
56
+ )
57
+ elif platform.python_version().startswith('2.5.'):
58
+ setup_args.update(
59
+ data_files=[('DLLs', glob.glob('DLLs_x86_VC7/*.dll'))]
60
+ )
61
+ else:
62
+ setup_args.update(
63
+ data_files=[('DLLs', glob.glob('DLLs_x86_VC9/*.dll'))]
64
+ )
65
+
66
+
67
+ # Optional compilation of speedups
68
+ # setuptools stuff from Bob Ippolito's simplejson project
69
+ if sys.platform == 'win32' and sys.version_info > (2, 6):
70
+ # 2.6's distutils.msvc9compiler can raise an IOError when failing to
71
+ # find the compiler
72
+ ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
73
+ IOError)
74
+ else:
75
+ ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
76
+
77
+ class BuildFailed(Exception):
78
+ pass
79
+
80
+ class ve_build_ext(build_ext):
81
+ # This class allows C extension building to fail.
82
+
83
+ def run(self):
84
+ try:
85
+ build_ext.run(self)
86
+ except DistutilsPlatformError, x:
87
+ raise BuildFailed(x)
88
+
89
+ def build_extension(self, ext):
90
+ try:
91
+ build_ext.build_extension(self, ext)
92
+ except ext_errors, x:
93
+ raise BuildFailed(x)
94
+
95
+ if sys.platform == 'win32':
96
+ # geos DLL is geos.dll instead of geos_c.dll on Windows
97
+ ext_modules = [
98
+ Extension("shapely.speedups._speedups",
99
+ ["shapely/speedups/_speedups.c"], libraries=['geos']),
100
+ ]
101
+ elif (hasattr(platform, 'python_implementation')
102
+ and platform.python_implementation() == 'PyPy'):
103
+ # python_implementation >= 2.6
104
+ ext_modules = []
105
+ else:
106
+ ext_modules = [
107
+ Extension("shapely.speedups._speedups",
108
+ ["shapely/speedups/_speedups.c"], libraries=['geos_c']),
109
+ ]
110
+
111
+ try:
112
+ # try building with speedups
113
+ setup(
114
+ cmdclass={'build_ext': ve_build_ext},
115
+ ext_modules=ext_modules,
116
+ **setup_args
117
+ )
118
+ except BuildFailed, ex:
119
+ BUILD_EXT_WARNING = "Warning: The C extension could not be compiled, speedups are not enabled."
120
+ print ex
121
+ print BUILD_EXT_WARNING
122
+ print "Failure information, if any, is above."
123
+ print "I'm retrying the build without the C extension now."
124
+
125
+ setup(**setup_args)
126
+
127
+ print BUILD_EXT_WARNING
128
+ print "Plain-Python installation succeeded."
129
+
File without changes
@@ -0,0 +1,17 @@
1
+ from itertools import islice, izip
2
+
3
+ def signed_area(ring):
4
+ """Return the signed area enclosed by a ring in linear time using the
5
+ algorithm at: http://www.cgafaq.info/wiki/Polygon_Area.
6
+ """
7
+ xs, ys = ring.coords.xy
8
+ xs.append(xs[1])
9
+ ys.append(ys[1])
10
+ return sum(xs[i]*(ys[i+1]-ys[i-1]) for i in range(1, len(ring.coords)))/2.0
11
+
12
+ def is_ccw_impl(name):
13
+ """Predicate implementation"""
14
+ def is_ccw_op(ring):
15
+ return signed_area(ring) >= 0.0
16
+ return is_ccw_op
17
+
@@ -6,12 +6,17 @@ import ctypes
6
6
  class allocated_c_char_p(ctypes.c_char_p):
7
7
  pass
8
8
 
9
+ EXCEPTION_HANDLER_FUNCTYPE = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_char_p)
10
+
9
11
  def prototype(lgeos, geosVersion):
10
12
 
13
+ lgeos.initGEOS.argtypes = [EXCEPTION_HANDLER_FUNCTYPE, EXCEPTION_HANDLER_FUNCTYPE]
11
14
  lgeos.initGEOS.restype = None
12
15
 
16
+ lgeos.finishGEOS.argtypes = []
13
17
  lgeos.finishGEOS.restype = None
14
18
 
19
+ lgeos.GEOSversion.argtypes = []
15
20
  lgeos.GEOSversion.restype = ctypes.c_char_p
16
21
 
17
22
  lgeos.GEOSGeomFromWKT.restype = ctypes.c_void_p
@@ -104,7 +104,10 @@ class BaseGeometry(object):
104
104
  # TODO: defer cleanup to the implementation. We shouldn't be
105
105
  # explicitly calling a lgeos method here.
106
106
  if not (self._owned or self._is_empty):
107
- self._lgeos.GEOSGeom_destroy(self.__geom__)
107
+ try:
108
+ self._lgeos.GEOSGeom_destroy(self.__geom__)
109
+ except AttributeError:
110
+ pass # _lgeos might be empty on shutdown
108
111
  self.__geom__ = EMPTY
109
112
 
110
113
  def __del__(self):
@@ -167,9 +167,10 @@ def geos_linestring_from_py(ob, update_geom=None, update_ndim=0):
167
167
  assert n == 2 or n == 3
168
168
 
169
169
  # Make pointer to the coordinate array
170
- try:
170
+ if isinstance(array['data'], tuple):
171
+ # numpy tuple (addr, read-only)
171
172
  cp = cast(array['data'][0], POINTER(c_double))
172
- except ArgumentError:
173
+ else:
173
174
  cp = array['data']
174
175
 
175
176
  # Create a coordinate sequence
@@ -226,21 +227,15 @@ def geos_linestring_from_py(ob, update_geom=None, update_ndim=0):
226
227
  # add to coordinate sequence
227
228
  for i in xrange(m):
228
229
  coords = ob[i]
229
- dx = c_double(coords[0])
230
- dy = c_double(coords[1])
231
- dz = None
230
+ # Because of a bug in the GEOS C API,
231
+ # always set X before Y
232
+ lgeos.GEOSCoordSeq_setX(cs, i, coords[0])
233
+ lgeos.GEOSCoordSeq_setY(cs, i, coords[1])
232
234
  if n == 3:
233
235
  try:
234
- dz = c_double(coords[2])
236
+ lgeos.GEOSCoordSeq_setZ(cs, i, coords[2])
235
237
  except IndexError:
236
238
  raise ValueError("Inconsistent coordinate dimensionality")
237
-
238
- # Because of a bug in the GEOS C API,
239
- # always set X before Y
240
- lgeos.GEOSCoordSeq_setX(cs, i, dx)
241
- lgeos.GEOSCoordSeq_setY(cs, i, dy)
242
- if n == 3:
243
- lgeos.GEOSCoordSeq_setZ(cs, i, dz)
244
239
 
245
240
  if update_geom is not None:
246
241
  return None
@@ -93,9 +93,6 @@ def geos_multilinestring_from_py(ob):
93
93
  L = array['shape'][0]
94
94
  assert L >= 1
95
95
 
96
- # Make pointer to the coordinate array
97
- cp = cast(array['data'][0], POINTER(c_double))
98
-
99
96
  # Array of pointers to sub-geometries
100
97
  subs = (c_void_p * L)()
101
98
 
@@ -138,9 +138,10 @@ def geos_multipoint_from_py(ob):
138
138
  assert n == 2 or n == 3
139
139
 
140
140
  # Make pointer to the coordinate array
141
- try:
141
+ if isinstance(array['data'], tuple):
142
+ # numpy tuple (addr, read-only)
142
143
  cp = cast(array['data'][0], POINTER(c_double))
143
- except ArgumentError:
144
+ else:
144
145
  cp = array['data']
145
146
 
146
147
  # Array of pointers to sub-geometries
@@ -4,6 +4,8 @@
4
4
  from ctypes import c_double, c_void_p, cast, POINTER
5
5
  from ctypes import ArgumentError
6
6
  import weakref
7
+
8
+ from shapely.algorithms.cga import signed_area
7
9
  from shapely.geos import lgeos
8
10
  from shapely.geometry.base import BaseGeometry
9
11
  from shapely.geometry.linestring import LineString, LineStringAdapter
@@ -61,6 +63,11 @@ class LinearRing(LineString):
61
63
 
62
64
  coords = property(_get_coords, _set_coords)
63
65
 
66
+ @property
67
+ def is_ccw(self):
68
+ """Brand new"""
69
+ return bool(self.impl['is_ccw'](self))
70
+
64
71
 
65
72
  class LinearRingAdapter(LineStringAdapter):
66
73
 
@@ -277,6 +284,20 @@ def asPolygon(shell, holes=None):
277
284
  """Adapt objects to the Polygon interface"""
278
285
  return PolygonAdapter(shell, holes)
279
286
 
287
+ def orient(polygon, sign=1.0):
288
+ s = float(sign)
289
+ rings = []
290
+ ring = polygon.exterior
291
+ if signed_area(ring)/s >= 0.0:
292
+ rings.append(ring)
293
+ else:
294
+ rings.append(list(ring.coords)[::-1])
295
+ for ring in polygon.interiors:
296
+ if signed_area(ring)/s <= 0.0:
297
+ rings.append(ring)
298
+ else:
299
+ rings.append(list(ring.coords)[::-1])
300
+ return Polygon(rings[0], rings[1:])
280
301
 
281
302
  def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
282
303
  try:
@@ -291,9 +312,10 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
291
312
  assert n == 2 or n == 3
292
313
 
293
314
  # Make pointer to the coordinate array
294
- try:
315
+ if isinstance(array['data'], tuple):
316
+ # numpy tuple (addr, read-only)
295
317
  cp = cast(array['data'][0], POINTER(c_double))
296
- except ArgumentError:
318
+ else:
297
319
  cp = array['data']
298
320
 
299
321
  # Add closing coordinates to sequence?
@@ -314,33 +336,21 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
314
336
 
315
337
  # add to coordinate sequence
316
338
  for i in xrange(m):
317
- dx = c_double(cp[n*i])
318
- dy = c_double(cp[n*i+1])
319
- dz = None
320
- if n == 3:
321
- dz = c_double(cp[n*i+2])
322
-
323
339
  # Because of a bug in the GEOS C API,
324
340
  # always set X before Y
325
- lgeos.GEOSCoordSeq_setX(cs, i, dx)
326
- lgeos.GEOSCoordSeq_setY(cs, i, dy)
341
+ lgeos.GEOSCoordSeq_setX(cs, i, cp[n*i])
342
+ lgeos.GEOSCoordSeq_setY(cs, i, cp[n*i+1])
327
343
  if n == 3:
328
- lgeos.GEOSCoordSeq_setZ(cs, i, dz)
344
+ lgeos.GEOSCoordSeq_setZ(cs, i, cp[n*i+2])
329
345
 
330
346
  # Add closing coordinates to sequence?
331
- if M > m:
332
- dx = c_double(cp[0])
333
- dy = c_double(cp[1])
334
- dz = None
335
- if n == 3:
336
- dz = c_double(cp[2])
337
-
347
+ if M > m:
338
348
  # Because of a bug in the GEOS C API,
339
349
  # always set X before Y
340
- lgeos.GEOSCoordSeq_setX(cs, M-1, dx)
341
- lgeos.GEOSCoordSeq_setY(cs, M-1, dy)
350
+ lgeos.GEOSCoordSeq_setX(cs, M-1, cp[0])
351
+ lgeos.GEOSCoordSeq_setY(cs, M-1, cp[1])
342
352
  if n == 3:
343
- lgeos.GEOSCoordSeq_setZ(cs, M-1, dz)
353
+ lgeos.GEOSCoordSeq_setZ(cs, M-1, cp[2])
344
354
 
345
355
  except AttributeError:
346
356
  # Fall back on list
@@ -370,34 +380,25 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
370
380
  # add to coordinate sequence
371
381
  for i in xrange(m):
372
382
  coords = ob[i]
373
- dx = c_double(coords[0])
374
- dy = c_double(coords[1])
375
- dz = None
376
- if n == 3:
377
- dz = c_double(coords[2])
378
-
379
383
  # Because of a bug in the GEOS C API,
380
384
  # always set X before Y
381
- lgeos.GEOSCoordSeq_setX(cs, i, dx)
382
- lgeos.GEOSCoordSeq_setY(cs, i, dy)
385
+ lgeos.GEOSCoordSeq_setX(cs, i, coords[0])
386
+ lgeos.GEOSCoordSeq_setY(cs, i, coords[1])
383
387
  if n == 3:
384
- lgeos.GEOSCoordSeq_setZ(cs, i, dz)
388
+ try:
389
+ lgeos.GEOSCoordSeq_setZ(cs, i, coords[2])
390
+ except IndexError:
391
+ raise ValueError("Inconsistent coordinate dimensionality")
385
392
 
386
393
  # Add closing coordinates to sequence?
387
394
  if M > m:
388
395
  coords = ob[0]
389
- dx = c_double(coords[0])
390
- dy = c_double(coords[1])
391
- dz = None
392
- if n == 3:
393
- dz = c_double(coords[2])
394
-
395
396
  # Because of a bug in the GEOS C API,
396
397
  # always set X before Y
397
- lgeos.GEOSCoordSeq_setX(cs, M-1, dx)
398
- lgeos.GEOSCoordSeq_setY(cs, M-1, dy)
398
+ lgeos.GEOSCoordSeq_setX(cs, M-1, coords[0])
399
+ lgeos.GEOSCoordSeq_setY(cs, M-1, coords[1])
399
400
  if n == 3:
400
- lgeos.GEOSCoordSeq_setZ(cs, M-1, dz)
401
+ lgeos.GEOSCoordSeq_setZ(cs, M-1, coords[2])
401
402
 
402
403
  if update_geom is not None:
403
404
  return None