shapely 1.2.10__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 (88) hide show
  1. {Shapely-1.2.10 → Shapely-1.2.12}/CHANGES.txt +15 -0
  2. {Shapely-1.2.10 → Shapely-1.2.12}/CREDITS.txt +3 -1
  3. {Shapely-1.2.10/Shapely.egg-info → Shapely-1.2.12}/PKG-INFO +16 -1
  4. {Shapely-1.2.10 → Shapely-1.2.12/Shapely.egg-info}/PKG-INFO +16 -1
  5. {Shapely-1.2.10 → Shapely-1.2.12}/setup.py +16 -3
  6. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/ctypes_declarations.py +5 -0
  7. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/base.py +4 -1
  8. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/linestring.py +8 -13
  9. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/multilinestring.py +0 -3
  10. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/multipoint.py +3 -2
  11. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/polygon.py +19 -39
  12. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geos.py +7 -6
  13. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/predicates.py +2 -2
  14. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/prepared.py +4 -1
  15. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/speedups/__init__.py +3 -0
  16. Shapely-1.2.12/shapely/tests/test_prepared.py +28 -0
  17. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/topology.py +6 -8
  18. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/wkb.py +2 -2
  19. Shapely-1.2.10/shapely/tests/test_prepared.py +0 -15
  20. {Shapely-1.2.10 → Shapely-1.2.12}/LICENSE.txt +0 -0
  21. {Shapely-1.2.10 → Shapely-1.2.12}/README.txt +0 -0
  22. {Shapely-1.2.10 → Shapely-1.2.12}/Shapely.egg-info/SOURCES.txt +0 -0
  23. {Shapely-1.2.10 → Shapely-1.2.12}/Shapely.egg-info/dependency_links.txt +0 -0
  24. {Shapely-1.2.10 → Shapely-1.2.12}/Shapely.egg-info/top_level.txt +0 -0
  25. {Shapely-1.2.10 → Shapely-1.2.12}/docs/manual.txt +0 -0
  26. {Shapely-1.2.10 → Shapely-1.2.12}/setup.cfg +0 -0
  27. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/__init__.py +0 -0
  28. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/algorithms/__init__.py +0 -0
  29. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/algorithms/cga.py +0 -0
  30. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/coords.py +0 -0
  31. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/examples/__init__.py +0 -0
  32. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/examples/dissolve.py +0 -0
  33. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/examples/geoms.py +0 -0
  34. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/examples/intersect.py +0 -0
  35. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/examples/world.py +0 -0
  36. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/ftools.py +0 -0
  37. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/__init__.py +0 -0
  38. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/collection.py +0 -0
  39. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/geo.py +0 -0
  40. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/multipolygon.py +0 -0
  41. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/point.py +0 -0
  42. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/geometry/proxy.py +0 -0
  43. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/impl.py +0 -0
  44. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/iterops.py +0 -0
  45. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/linref.py +0 -0
  46. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/ops.py +0 -0
  47. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/speedups/_speedups.c +0 -0
  48. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/speedups/_speedups.pyx +0 -0
  49. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/Array.txt +0 -0
  50. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/GeoInterface.txt +0 -0
  51. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/IterOps.txt +0 -0
  52. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/LineString.txt +0 -0
  53. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/MultiLineString.txt +0 -0
  54. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/MultiPoint.txt +0 -0
  55. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/MultiPolygon.txt +0 -0
  56. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/Operations.txt +0 -0
  57. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/Persist.txt +0 -0
  58. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/Point.txt +0 -0
  59. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/Polygon.txt +0 -0
  60. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/Predicates.txt +0 -0
  61. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/__init__.py +0 -0
  62. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/attribute-chains.txt +0 -0
  63. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/binascii_hex.txt +0 -0
  64. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/cascaded_union.txt +0 -0
  65. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/dimensions.txt +0 -0
  66. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/invalid_intersection.txt +0 -0
  67. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/linemerge.txt +0 -0
  68. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/polygonize.txt +0 -0
  69. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_box.py +0 -0
  70. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_cga.py +0 -0
  71. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_collection.py +0 -0
  72. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_delegated.py +0 -0
  73. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_dlls.py +0 -0
  74. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_doctests.py +0 -0
  75. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_emptiness.py +0 -0
  76. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_equality.py +0 -0
  77. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_geomseq.py +0 -0
  78. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_linear_referencing.py +0 -0
  79. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_mapping.py +0 -0
  80. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_products_z.py +0 -0
  81. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_singularity.py +0 -0
  82. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_speedups.py +0 -0
  83. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_validation.py +0 -0
  84. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/test_xy.py +0 -0
  85. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/threading_test.py +0 -0
  86. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/tests/wkt_locale.txt +0 -0
  87. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/validation.py +0 -0
  88. {Shapely-1.2.10 → Shapely-1.2.12}/shapely/wkt.py +0 -0
@@ -2,6 +2,21 @@
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
+
5
20
  1.2.10 (2011-05-09)
6
21
  -------------------
7
22
  - Add optional Cython speedups.
@@ -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.10
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,21 @@ 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
+
169
184
  1.2.10 (2011-05-09)
170
185
  -------------------
171
186
  - Add optional Cython speedups.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.2.10
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,21 @@ 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
+
169
184
  1.2.10 (2011-05-09)
170
185
  -------------------
171
186
  - Add optional Cython speedups.
@@ -15,6 +15,7 @@ from setuptools.extension import Extension
15
15
  from setuptools.command.build_ext import build_ext
16
16
  from setuptools import setup, find_packages
17
17
  import sys
18
+ import platform
18
19
 
19
20
  readme_text = file('README.txt', 'rb').read()
20
21
  changes_text = file('CHANGES.txt', 'rb').read()
@@ -22,7 +23,7 @@ changes_text = file('CHANGES.txt', 'rb').read()
22
23
  setup_args = dict(
23
24
  metadata_version = '1.2',
24
25
  name = 'Shapely',
25
- version = '1.2.10',
26
+ version = '1.2.12',
26
27
  requires_python = '>=2.5,<3',
27
28
  requires_external = 'libgeos_c (>=3.1)',
28
29
  description = 'Geometric objects, predicates, and operations',
@@ -51,11 +52,15 @@ setup_args = dict(
51
52
  if sys.platform == 'win32':
52
53
  if '(AMD64)' in sys.version:
53
54
  setup_args.update(
54
- data_files=[('DLLs', glob.glob('DLLs_AMD64/*.dll'))]
55
+ data_files=[('DLLs', glob.glob('DLLs_AMD64_VC9/*.dll'))]
55
56
  )
57
+ elif platform.python_version().startswith('2.5.'):
58
+ setup_args.update(
59
+ data_files=[('DLLs', glob.glob('DLLs_x86_VC7/*.dll'))]
60
+ )
56
61
  else:
57
62
  setup_args.update(
58
- data_files=[('DLLs', glob.glob('DLLs_x86/*.dll'))]
63
+ data_files=[('DLLs', glob.glob('DLLs_x86_VC9/*.dll'))]
59
64
  )
60
65
 
61
66
 
@@ -88,6 +93,14 @@ class ve_build_ext(build_ext):
88
93
  raise BuildFailed(x)
89
94
 
90
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
91
104
  ext_modules = []
92
105
  else:
93
106
  ext_modules = [
@@ -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
@@ -312,9 +312,10 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
312
312
  assert n == 2 or n == 3
313
313
 
314
314
  # Make pointer to the coordinate array
315
- try:
315
+ if isinstance(array['data'], tuple):
316
+ # numpy tuple (addr, read-only)
316
317
  cp = cast(array['data'][0], POINTER(c_double))
317
- except ArgumentError:
318
+ else:
318
319
  cp = array['data']
319
320
 
320
321
  # Add closing coordinates to sequence?
@@ -335,33 +336,21 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
335
336
 
336
337
  # add to coordinate sequence
337
338
  for i in xrange(m):
338
- dx = c_double(cp[n*i])
339
- dy = c_double(cp[n*i+1])
340
- dz = None
341
- if n == 3:
342
- dz = c_double(cp[n*i+2])
343
-
344
339
  # Because of a bug in the GEOS C API,
345
340
  # always set X before Y
346
- lgeos.GEOSCoordSeq_setX(cs, i, dx)
347
- 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])
348
343
  if n == 3:
349
- lgeos.GEOSCoordSeq_setZ(cs, i, dz)
344
+ lgeos.GEOSCoordSeq_setZ(cs, i, cp[n*i+2])
350
345
 
351
346
  # Add closing coordinates to sequence?
352
- if M > m:
353
- dx = c_double(cp[0])
354
- dy = c_double(cp[1])
355
- dz = None
356
- if n == 3:
357
- dz = c_double(cp[2])
358
-
347
+ if M > m:
359
348
  # Because of a bug in the GEOS C API,
360
349
  # always set X before Y
361
- lgeos.GEOSCoordSeq_setX(cs, M-1, dx)
362
- 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])
363
352
  if n == 3:
364
- lgeos.GEOSCoordSeq_setZ(cs, M-1, dz)
353
+ lgeos.GEOSCoordSeq_setZ(cs, M-1, cp[2])
365
354
 
366
355
  except AttributeError:
367
356
  # Fall back on list
@@ -391,34 +380,25 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
391
380
  # add to coordinate sequence
392
381
  for i in xrange(m):
393
382
  coords = ob[i]
394
- dx = c_double(coords[0])
395
- dy = c_double(coords[1])
396
- dz = None
397
- if n == 3:
398
- dz = c_double(coords[2])
399
-
400
383
  # Because of a bug in the GEOS C API,
401
384
  # always set X before Y
402
- lgeos.GEOSCoordSeq_setX(cs, i, dx)
403
- lgeos.GEOSCoordSeq_setY(cs, i, dy)
385
+ lgeos.GEOSCoordSeq_setX(cs, i, coords[0])
386
+ lgeos.GEOSCoordSeq_setY(cs, i, coords[1])
404
387
  if n == 3:
405
- 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")
406
392
 
407
393
  # Add closing coordinates to sequence?
408
394
  if M > m:
409
395
  coords = ob[0]
410
- dx = c_double(coords[0])
411
- dy = c_double(coords[1])
412
- dz = None
413
- if n == 3:
414
- dz = c_double(coords[2])
415
-
416
396
  # Because of a bug in the GEOS C API,
417
397
  # always set X before Y
418
- lgeos.GEOSCoordSeq_setX(cs, M-1, dx)
419
- 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])
420
400
  if n == 3:
421
- lgeos.GEOSCoordSeq_setZ(cs, M-1, dz)
401
+ lgeos.GEOSCoordSeq_setZ(cs, M-1, coords[2])
422
402
 
423
403
  if update_geom is not None:
424
404
  return None
@@ -12,7 +12,7 @@ from ctypes import cdll, CDLL, CFUNCTYPE, c_char_p, c_void_p, string_at
12
12
  from ctypes.util import find_library
13
13
 
14
14
  import ftools
15
- from ctypes_declarations import prototype
15
+ from ctypes_declarations import prototype, EXCEPTION_HANDLER_FUNCTYPE
16
16
 
17
17
 
18
18
 
@@ -43,7 +43,7 @@ def load_dll(libname, fallbacks=None):
43
43
  "Could not find library %s or load any of its variants %s" % (
44
44
  libname, fallbacks or []))
45
45
 
46
- if sys.platform == 'linux2':
46
+ if sys.platform.startswith('linux'):
47
47
  _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
48
48
  free = load_dll('c').free
49
49
  free.argtypes = [c_void_p]
@@ -92,6 +92,7 @@ else: # other *nix systems
92
92
 
93
93
  def _geos_c_version():
94
94
  func = _lgeos.GEOSversion
95
+ func.argtypes = []
95
96
  func.restype = c_char_p
96
97
  v = func().split('-')[2]
97
98
  return tuple(int(n) for n in v.split('.'))
@@ -129,7 +130,7 @@ if geos_c_version >= (1,5,0):
129
130
 
130
131
  # Handle special case.
131
132
  _lgeos.initGEOS_r.restype = c_void_p
132
- _lgeos.initGEOS_r.argtypes = [c_void_p, c_void_p]
133
+ _lgeos.initGEOS_r.argtypes = [EXCEPTION_HANDLER_FUNCTYPE, EXCEPTION_HANDLER_FUNCTYPE]
133
134
  _lgeos.finishGEOS_r.argtypes = [c_void_p]
134
135
 
135
136
  # Exceptions
@@ -148,11 +149,11 @@ class PredicateError(Exception):
148
149
 
149
150
  def error_handler(fmt, list):
150
151
  LOG.error("%s", list)
151
- error_h = CFUNCTYPE(None, c_char_p, c_char_p)(error_handler)
152
+ error_h = EXCEPTION_HANDLER_FUNCTYPE(error_handler)
152
153
 
153
154
  def notice_handler(fmt, list):
154
155
  LOG.warning("%s", list)
155
- notice_h = CFUNCTYPE(None, c_char_p, c_char_p)(notice_handler)
156
+ notice_h = EXCEPTION_HANDLER_FUNCTYPE(notice_handler)
156
157
 
157
158
  def cleanup():
158
159
  if _lgeos is not None :
@@ -166,7 +167,7 @@ def errcheck_wkb(result, func, argtuple):
166
167
  if not result:
167
168
  return None
168
169
  size_ref = argtuple[-1]
169
- size = size_ref._obj
170
+ size = size_ref.contents
170
171
  retval = ctypes.string_at(result, size.value)[:]
171
172
  lgeos.GEOSFree(result)
172
173
  return retval
@@ -7,13 +7,13 @@ from shapely.topology import Delegating
7
7
  class BinaryPredicate(Delegating):
8
8
  def __call__(self, this, other, *args):
9
9
  self._validate(this)
10
- self._validate(other)
10
+ self._validate(other, stop_prepared=True)
11
11
  return self.fn(this._geom, other._geom, *args)
12
12
 
13
13
  class RelateOp(Delegating):
14
14
  def __call__(self, this, other):
15
15
  self._validate(this)
16
- self._validate(other)
16
+ self._validate(other, stop_prepared=True)
17
17
  return self.fn(this._geom, other._geom)
18
18
 
19
19
  class UnaryPredicate(Delegating):
@@ -27,7 +27,10 @@ class PreparedGeometry(object):
27
27
 
28
28
  def __del__(self):
29
29
  if self.__geom__ is not None:
30
- lgeos.GEOSPreparedGeom_destroy(self.__geom__)
30
+ try:
31
+ lgeos.GEOSPreparedGeom_destroy(self.__geom__)
32
+ except AttributeError:
33
+ pass # lgeos might be empty on shutdown
31
34
  self.__geom__ = None
32
35
  self.context = None
33
36
 
@@ -6,8 +6,11 @@ from shapely import coords
6
6
  try:
7
7
  from shapely.speedups import _speedups
8
8
  available = True
9
+ import_error_msg = None
9
10
  except ImportError:
11
+ import sys
10
12
  available = False
13
+ import_error_msg = tuple(sys.exc_info()[1])
11
14
 
12
15
  __all__ = ['available', 'enable', 'disable']
13
16
  _orig = {}
@@ -0,0 +1,28 @@
1
+ import unittest
2
+ from shapely import prepared
3
+ from shapely import geometry
4
+
5
+
6
+ class PreparedGeometryTestCase(unittest.TestCase):
7
+
8
+ def test_prepared(self):
9
+ polygon = geometry.Polygon([
10
+ (0, 0), (1, 0), (1, 1), (0, 1)
11
+ ])
12
+ p = prepared.PreparedGeometry(polygon)
13
+ self.assertTrue(p.contains(geometry.Point(0.5, 0.5)))
14
+ self.assertFalse(p.contains(geometry.Point(0.5, 1.5)))
15
+
16
+ def test_op_not_allowed(self):
17
+ p = prepared.PreparedGeometry(geometry.Point(0.0, 0.0).buffer(1.0))
18
+ self.assertRaises(ValueError, geometry.Point(0.0, 0.0).union, p)
19
+
20
+ def test_predicate_not_allowed(self):
21
+ p = prepared.PreparedGeometry(geometry.Point(0.0, 0.0).buffer(1.0))
22
+ self.assertRaises(ValueError, geometry.Point(0.0, 0.0).contains, p)
23
+
24
+
25
+ def test_suite():
26
+ return unittest.TestLoader().loadTestsFromTestCase(
27
+ PreparedGeometryTestCase
28
+ )
@@ -10,14 +10,12 @@ These methods return ctypes objects that should be recast by the caller.
10
10
  from ctypes import byref, c_double
11
11
  from shapely.geos import TopologicalError, lgeos
12
12
 
13
-
14
13
  class Validating(object):
15
- def _validate(self, ob):
16
- try:
17
- assert ob is not None
18
- assert ob._geom is not None
19
- except AssertionError:
14
+ def _validate(self, ob, stop_prepared=False):
15
+ if ob is None or ob._geom is None:
20
16
  raise ValueError("Null geometry supports no operations")
17
+ if stop_prepared and not hasattr(ob, 'type'):
18
+ raise ValueError("Prepared geometries cannot be operated on")
21
19
 
22
20
  class Delegating(Validating):
23
21
  def __init__(self, name):
@@ -26,7 +24,7 @@ class Delegating(Validating):
26
24
  class BinaryRealProperty(Delegating):
27
25
  def __call__(self, this, other):
28
26
  self._validate(this)
29
- self._validate(other)
27
+ self._validate(other, stop_prepared=True)
30
28
  d = c_double()
31
29
  retval = self.fn(this._geom, other._geom, byref(d))
32
30
  return d.value
@@ -41,7 +39,7 @@ class UnaryRealProperty(Delegating):
41
39
  class BinaryTopologicalOp(Delegating):
42
40
  def __call__(self, this, other, *args):
43
41
  self._validate(this)
44
- self._validate(other)
42
+ self._validate(other, stop_prepared=True)
45
43
  product = self.fn(this._geom, other._geom, *args)
46
44
  if product is None:
47
45
  if not this.is_valid:
@@ -1,7 +1,7 @@
1
1
  """Load/dump geometries using the well-known binary (WKB) format
2
2
  """
3
3
 
4
- from ctypes import byref, c_size_t, c_char_p, c_void_p
4
+ from ctypes import pointer, c_size_t, c_char_p, c_void_p
5
5
 
6
6
  from shapely.geos import lgeos, ReadingError
7
7
 
@@ -30,7 +30,7 @@ def dumps(ob):
30
30
  if ob is None or ob._geom is None:
31
31
  raise ValueError("Null geometry supports no operations")
32
32
  size = c_size_t()
33
- return lgeos.GEOSGeomToWKB_buf(c_void_p(ob._geom), byref(size))
33
+ return lgeos.GEOSGeomToWKB_buf(c_void_p(ob._geom), pointer(size))
34
34
 
35
35
  def dump(ob, fp):
36
36
  """Dump a geometry to an open file."""
@@ -1,15 +0,0 @@
1
- import unittest
2
- from shapely import prepared
3
- from shapely import geometry
4
-
5
-
6
- class PreparedGeometryTestCase(unittest.TestCase):
7
-
8
- def test_prepared(self):
9
- p = prepared.PreparedGeometry(geometry.Point(0.0, 0.0))
10
-
11
-
12
- def test_suite():
13
- return unittest.TestLoader().loadTestsFromTestCase(
14
- PreparedGeometryTestCase
15
- )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes