shapely 1.3.2__tar.gz → 1.3.3__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 (98) hide show
  1. {Shapely-1.3.2 → Shapely-1.3.3}/CHANGES.txt +5 -5
  2. {Shapely-1.3.2/Shapely.egg-info → Shapely-1.3.3}/PKG-INFO +21 -7
  3. {Shapely-1.3.2 → Shapely-1.3.3}/README.rst +15 -1
  4. {Shapely-1.3.2 → Shapely-1.3.3/Shapely.egg-info}/PKG-INFO +21 -7
  5. {Shapely-1.3.2 → Shapely-1.3.3}/Shapely.egg-info/SOURCES.txt +5 -1
  6. Shapely-1.3.3/VERSION.txt +1 -0
  7. {Shapely-1.3.2 → Shapely-1.3.3}/docs/manual.txt +12 -5
  8. {Shapely-1.3.2 → Shapely-1.3.3}/setup.py +47 -15
  9. Shapely-1.3.3/shapely/__init__.py +1 -0
  10. Shapely-1.3.3/shapely/_geos.pxi +52 -0
  11. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/affinity.py +1 -1
  12. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/coords.py +7 -2
  13. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/base.py +50 -12
  14. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/linestring.py +23 -3
  15. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/multilinestring.py +22 -1
  16. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/multipoint.py +24 -1
  17. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/multipolygon.py +25 -1
  18. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/point.py +21 -1
  19. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/polygon.py +22 -2
  20. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/proxy.py +3 -3
  21. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/ops.py +26 -9
  22. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/speedups/_speedups.c +1550 -1383
  23. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/__init__.py +1 -1
  24. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_affinity.py +4 -0
  25. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_transform.py +6 -0
  26. Shapely-1.3.3/shapely/tests/test_vectorized.py +107 -0
  27. Shapely-1.3.3/shapely/vectorized/__init__.py +3 -0
  28. Shapely-1.3.3/shapely/vectorized/_vectorized.pyx +120 -0
  29. Shapely-1.3.2/VERSION.txt +0 -1
  30. Shapely-1.3.2/shapely/__init__.py +0 -1
  31. {Shapely-1.3.2 → Shapely-1.3.3}/CREDITS.txt +0 -0
  32. {Shapely-1.3.2 → Shapely-1.3.3}/LICENSE.txt +0 -0
  33. {Shapely-1.3.2 → Shapely-1.3.3}/Shapely.egg-info/dependency_links.txt +0 -0
  34. {Shapely-1.3.2 → Shapely-1.3.3}/Shapely.egg-info/top_level.txt +0 -0
  35. {Shapely-1.3.2 → Shapely-1.3.3}/setup.cfg +0 -0
  36. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/algorithms/__init__.py +0 -0
  37. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/algorithms/cga.py +0 -0
  38. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/ctypes_declarations.py +0 -0
  39. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/examples/__init__.py +0 -0
  40. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/examples/dissolve.py +0 -0
  41. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/examples/geoms.py +0 -0
  42. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/examples/intersect.py +0 -0
  43. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/examples/world.py +0 -0
  44. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/ftools.py +0 -0
  45. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/__init__.py +0 -0
  46. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/collection.py +0 -0
  47. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geometry/geo.py +0 -0
  48. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/geos.py +0 -0
  49. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/impl.py +0 -0
  50. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/iterops.py +0 -0
  51. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/linref.py +0 -0
  52. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/predicates.py +0 -0
  53. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/prepared.py +0 -0
  54. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/speedups/__init__.py +0 -0
  55. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/binascii_hex.txt +0 -0
  56. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_box.py +0 -0
  57. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_cga.py +0 -0
  58. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_collection.py +0 -0
  59. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_delegated.py +0 -0
  60. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_dlls.py +0 -0
  61. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_doctests.py +0 -0
  62. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_emptiness.py +0 -0
  63. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_equality.py +0 -0
  64. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_geointerface.py +0 -0
  65. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_geomseq.py +0 -0
  66. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_getitem.py +0 -0
  67. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_invalid_geometries.py +0 -0
  68. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_iterops.py +0 -0
  69. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_linear_referencing.py +0 -0
  70. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_linemerge.py +0 -0
  71. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_linestring.py +0 -0
  72. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_locale.py +0 -0
  73. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_mapping.py +0 -0
  74. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_multilinestring.py +0 -0
  75. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_multipoint.py +0 -0
  76. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_multipolygon.py +0 -0
  77. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_ndarrays.py +0 -0
  78. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_operations.py +0 -0
  79. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_operators.py +0 -0
  80. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_persist.py +0 -0
  81. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_pickle.py +0 -0
  82. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_point.py +0 -0
  83. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_polygon.py +0 -0
  84. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_polygonize.py +0 -0
  85. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_predicates.py +0 -0
  86. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_prepared.py +0 -0
  87. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_products_z.py +0 -0
  88. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_singularity.py +0 -0
  89. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_speedups.py +0 -0
  90. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_styles.py +0 -0
  91. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_union.py +0 -0
  92. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_validation.py +0 -0
  93. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/test_xy.py +0 -0
  94. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/tests/threading_test.py +0 -0
  95. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/topology.py +0 -0
  96. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/validation.py +0 -0
  97. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/wkb.py +0 -0
  98. {Shapely-1.3.2 → Shapely-1.3.3}/shapely/wkt.py +0 -0
@@ -1,14 +1,14 @@
1
1
  Changes
2
2
  =======
3
3
 
4
- 1.3.2 (2014-05-13)
4
+ 1.3.3 (2014-07-23)
5
5
  ------------------
6
- - Let LineString() take a sequence of Points (#130).
6
+ - Allow single-part geometries as argument to ops.cacaded_union() (#135).
7
+ - Support affine transformations of LinearRings (#112).
7
8
 
8
- 1.3.1 (2014-04-22)
9
+ 1.3.2 (2014-05-13)
9
10
  ------------------
10
- - More reliable proxy cleanup on exit (#106).
11
- - More robust DLL loading on all platforms (#114).
11
+ - Let LineString() take a sequence of Points (#130).
12
12
 
13
13
  1.3.0 (2013-12-31)
14
14
  ------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Shapely
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: https://github.com/Toblerity/Shapely
6
6
  Author: Sean Gillies
@@ -133,7 +133,7 @@ Description: =======
133
133
  (env)$ pip install -r requirements-dev.txt
134
134
  (env)$ python setup.py develop
135
135
 
136
- Shapely uses a Zope-stye suite of unittests and doctests, exercised via
136
+ Shapely's suite of unittests and doctests, exercised via
137
137
  setup.py.::
138
138
 
139
139
  (env)$ python setup.py test
@@ -141,6 +141,20 @@ Description: =======
141
141
  Nosetests won't run the tests properly; Zope doctest suites are not currently
142
142
  supported well by nose.
143
143
 
144
+ Roadmap and Maintenance
145
+ =======================
146
+
147
+ Shapely 1.2.x is a maintenance-only branch which supports Python 2.4-2.6, but
148
+ not Python 3+. There will be no new features in Shapely 1.2.x and only fixes
149
+ for major bugs.
150
+
151
+ Shapely 1.3.x is a maintenance-only branch supporting Pythons 2.7 and 3+.
152
+
153
+ "Shapely 3000" is the name of the next milestone. New features will include
154
+ vectorized operations, better integration with IPython Notebook, support for
155
+ fixed precision models, and more. Less ctypes and more Cython is another theme
156
+ in this branch. A 1.4 release should come out of this by Summer, 2014.
157
+
144
158
  Support
145
159
  =======
146
160
 
@@ -213,14 +227,14 @@ Description: =======
213
227
  Changes
214
228
  =======
215
229
 
216
- 1.3.2 (2014-05-13)
230
+ 1.3.3 (2014-07-23)
217
231
  ------------------
218
- - Let LineString() take a sequence of Points (#130).
232
+ - Allow single-part geometries as argument to ops.cacaded_union() (#135).
233
+ - Support affine transformations of LinearRings (#112).
219
234
 
220
- 1.3.1 (2014-04-22)
235
+ 1.3.2 (2014-05-13)
221
236
  ------------------
222
- - More reliable proxy cleanup on exit (#106).
223
- - More robust DLL loading on all platforms (#114).
237
+ - Let LineString() take a sequence of Points (#130).
224
238
 
225
239
  1.3.0 (2013-12-31)
226
240
  ------------------
@@ -125,7 +125,7 @@ Use of a virtual environment is strongly recommended.::
125
125
  (env)$ pip install -r requirements-dev.txt
126
126
  (env)$ python setup.py develop
127
127
 
128
- Shapely uses a Zope-stye suite of unittests and doctests, exercised via
128
+ Shapely's suite of unittests and doctests, exercised via
129
129
  setup.py.::
130
130
 
131
131
  (env)$ python setup.py test
@@ -133,6 +133,20 @@ setup.py.::
133
133
  Nosetests won't run the tests properly; Zope doctest suites are not currently
134
134
  supported well by nose.
135
135
 
136
+ Roadmap and Maintenance
137
+ =======================
138
+
139
+ Shapely 1.2.x is a maintenance-only branch which supports Python 2.4-2.6, but
140
+ not Python 3+. There will be no new features in Shapely 1.2.x and only fixes
141
+ for major bugs.
142
+
143
+ Shapely 1.3.x is a maintenance-only branch supporting Pythons 2.7 and 3+.
144
+
145
+ "Shapely 3000" is the name of the next milestone. New features will include
146
+ vectorized operations, better integration with IPython Notebook, support for
147
+ fixed precision models, and more. Less ctypes and more Cython is another theme
148
+ in this branch. A 1.4 release should come out of this by Summer, 2014.
149
+
136
150
  Support
137
151
  =======
138
152
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Shapely
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: https://github.com/Toblerity/Shapely
6
6
  Author: Sean Gillies
@@ -133,7 +133,7 @@ Description: =======
133
133
  (env)$ pip install -r requirements-dev.txt
134
134
  (env)$ python setup.py develop
135
135
 
136
- Shapely uses a Zope-stye suite of unittests and doctests, exercised via
136
+ Shapely's suite of unittests and doctests, exercised via
137
137
  setup.py.::
138
138
 
139
139
  (env)$ python setup.py test
@@ -141,6 +141,20 @@ Description: =======
141
141
  Nosetests won't run the tests properly; Zope doctest suites are not currently
142
142
  supported well by nose.
143
143
 
144
+ Roadmap and Maintenance
145
+ =======================
146
+
147
+ Shapely 1.2.x is a maintenance-only branch which supports Python 2.4-2.6, but
148
+ not Python 3+. There will be no new features in Shapely 1.2.x and only fixes
149
+ for major bugs.
150
+
151
+ Shapely 1.3.x is a maintenance-only branch supporting Pythons 2.7 and 3+.
152
+
153
+ "Shapely 3000" is the name of the next milestone. New features will include
154
+ vectorized operations, better integration with IPython Notebook, support for
155
+ fixed precision models, and more. Less ctypes and more Cython is another theme
156
+ in this branch. A 1.4 release should come out of this by Summer, 2014.
157
+
144
158
  Support
145
159
  =======
146
160
 
@@ -213,14 +227,14 @@ Description: =======
213
227
  Changes
214
228
  =======
215
229
 
216
- 1.3.2 (2014-05-13)
230
+ 1.3.3 (2014-07-23)
217
231
  ------------------
218
- - Let LineString() take a sequence of Points (#130).
232
+ - Allow single-part geometries as argument to ops.cacaded_union() (#135).
233
+ - Support affine transformations of LinearRings (#112).
219
234
 
220
- 1.3.1 (2014-04-22)
235
+ 1.3.2 (2014-05-13)
221
236
  ------------------
222
- - More reliable proxy cleanup on exit (#106).
223
- - More robust DLL loading on all platforms (#114).
237
+ - Let LineString() take a sequence of Points (#130).
224
238
 
225
239
  1.3.0 (2013-12-31)
226
240
  ------------------
@@ -10,6 +10,7 @@ Shapely.egg-info/dependency_links.txt
10
10
  Shapely.egg-info/top_level.txt
11
11
  docs/manual.txt
12
12
  shapely/__init__.py
13
+ shapely/_geos.pxi
13
14
  shapely/affinity.py
14
15
  shapely/coords.py
15
16
  shapely/ctypes_declarations.py
@@ -86,5 +87,8 @@ shapely/tests/test_styles.py
86
87
  shapely/tests/test_transform.py
87
88
  shapely/tests/test_union.py
88
89
  shapely/tests/test_validation.py
90
+ shapely/tests/test_vectorized.py
89
91
  shapely/tests/test_xy.py
90
- shapely/tests/threading_test.py
92
+ shapely/tests/threading_test.py
93
+ shapely/vectorized/__init__.py
94
+ shapely/vectorized/_vectorized.pyx
@@ -0,0 +1 @@
1
+ 1.3.3
@@ -346,8 +346,14 @@ copy.
346
346
  >>> LineString(line)
347
347
  <shapely.geometry.linestring.LineString object at 0x...>
348
348
 
349
- A sequence of `Point` instances is not a valid constructor parameter. A
350
- `LineString` is described by points, but is not composed of `Point` instances.
349
+ A `LineString` may also be constructed using a a sequence of mixed `Point`
350
+ instances or coordinate tuples. The individual coordinates are copied into
351
+ the new object.
352
+
353
+ .. sourcecode:: pycon
354
+
355
+ >>> LineString([Point(0.0, 1.0), (2.0, 3.0), Point(4.0, 5.0)])
356
+ <shapely.geometry.linestring.LineString object at 0x...>
351
357
 
352
358
  .. _linearrings:
353
359
 
@@ -1387,7 +1393,7 @@ Constructive Methods
1387
1393
  Shapely geometric object have several methods that yield new objects not
1388
1394
  derived from set-theoretic analysis.
1389
1395
 
1390
- .. method:: object.buffer(distance, resolution=16, cap_style=1, join_style=1, mitre_limit=1.0)
1396
+ .. method:: object.buffer(distance, resolution=16, cap_style=1, join_style=1, mitre_limit=5.0)
1391
1397
 
1392
1398
  Returns an approximate representation of all points within a given `distance`
1393
1399
  of the this geometric object.
@@ -1519,7 +1525,7 @@ Figure 10. Convex hull (blue) of 2 points (left) and of 6 points (right).
1519
1525
  >>> MultiPoint([(0, 0), (1, 1)]).envelope
1520
1526
  <shapely.geometry.polygon.Polygon object at 0x...>
1521
1527
 
1522
- .. method:: object.parallel_offset(distance, side, resolution=16, join_style=1, mitre_limit=1.0)
1528
+ .. method:: object.parallel_offset(distance, side, resolution=16, join_style=1, mitre_limit=5.0)
1523
1529
 
1524
1530
  Returns a LineString or MultiLineString geometry at a distance from the
1525
1531
  object on its right or its left side.
@@ -1811,12 +1817,13 @@ for `func`.
1811
1817
 
1812
1818
  .. sourcecode:: python
1813
1819
 
1820
+ from shapely.ops import transform
1814
1821
  from functools import partial
1815
1822
  import pyproj
1816
1823
 
1817
1824
  project = partial(
1818
1825
  pyproj.transform,
1819
- pyproj.Proj(init='espg:4326'),
1826
+ pyproj.Proj(init='epsg:4326'),
1820
1827
  pyproj.Proj(init='epsg:26913'))
1821
1828
 
1822
1829
  g2 = transform(project, g1)
@@ -14,6 +14,7 @@ except ImportError:
14
14
  from distutils.cmd import Command
15
15
  from distutils.errors import CCompilerError, DistutilsExecError, \
16
16
  DistutilsPlatformError
17
+ from distutils.sysconfig import get_config_var
17
18
  import errno
18
19
  import glob
19
20
  import os
@@ -22,6 +23,7 @@ import shutil
22
23
  import subprocess
23
24
  import sys
24
25
 
26
+
25
27
  class test(Command):
26
28
  """Run unit tests after in-place build"""
27
29
  description = __doc__
@@ -57,6 +59,7 @@ class test(Command):
57
59
  if not result.wasSuccessful():
58
60
  sys.exit(1)
59
61
 
62
+
60
63
  # Get the version from the shapely module
61
64
  version = None
62
65
  with open('shapely/__init__.py', 'r') as fp:
@@ -100,6 +103,7 @@ setup_args = dict(
100
103
  'shapely.examples',
101
104
  'shapely.speedups',
102
105
  'shapely.tests',
106
+ 'shapely.vectorized',
103
107
  ],
104
108
  cmdclass = {'test': test},
105
109
  classifiers = [
@@ -113,6 +117,7 @@ setup_args = dict(
113
117
  'Programming Language :: Python :: 3',
114
118
  'Topic :: Scientific/Engineering :: GIS',
115
119
  ],
120
+ data_files = [('shapely', ['shapely/_geos.pxi'])]
116
121
  )
117
122
 
118
123
  # Add DLLs for Windows
@@ -152,20 +157,23 @@ class BuildFailed(Exception):
152
157
  pass
153
158
 
154
159
 
155
- class build_ext(distutils_build_ext):
156
- # This class allows C extension building to fail.
157
-
158
- def run(self):
159
- try:
160
- distutils_build_ext.run(self)
161
- except DistutilsPlatformError as x:
162
- raise BuildFailed(x)
160
+ def construct_build_ext(build_ext):
161
+ class WrappedBuildExt(build_ext):
162
+ # This class allows C extension building to fail.
163
+
164
+ def run(self):
165
+ try:
166
+ build_ext.run(self)
167
+ except DistutilsPlatformError as x:
168
+ raise BuildFailed(x)
169
+
170
+ def build_extension(self, ext):
171
+ try:
172
+ build_ext.build_extension(self, ext)
173
+ except ext_errors as x:
174
+ raise BuildFailed(x)
175
+ return WrappedBuildExt
163
176
 
164
- def build_extension(self, ext):
165
- try:
166
- distutils_build_ext.build_extension(self, ext)
167
- except ext_errors as x:
168
- raise BuildFailed(x)
169
177
 
170
178
  if (hasattr(platform, 'python_implementation')
171
179
  and platform.python_implementation() == 'PyPy'):
@@ -177,6 +185,7 @@ elif sys.platform == 'win32':
177
185
  else:
178
186
  libraries = ['geos_c']
179
187
 
188
+
180
189
  if os.path.exists("MANIFEST.in"):
181
190
  pyx_file = "shapely/speedups/_speedups.pyx"
182
191
  c_file = "shapely/speedups/_speedups.c"
@@ -202,12 +211,35 @@ ext_modules = [
202
211
  Extension(
203
212
  "shapely.speedups._speedups",
204
213
  ["shapely/speedups/_speedups.c"],
205
- libraries=libraries)
214
+ libraries=libraries,
215
+ include_dirs=[get_config_var('INCLUDEDIR')],),
206
216
  ]
207
217
 
218
+ try:
219
+ import numpy as np
220
+ from Cython.Distutils import build_ext as cython_build_ext
221
+ from distutils.extension import Extension as DistutilsExtension
222
+
223
+ cmd_classes = setup_args.setdefault('cmdclass', {})
224
+ if 'build_ext' in cmd_classes:
225
+ raise ValueError('We need to put the Cython build_ext in '
226
+ 'cmd_classes, but it is already defined.')
227
+ cmd_classes['build_ext'] = cython_build_ext
228
+
229
+ ext_modules.append(DistutilsExtension("shapely.vectorized._vectorized",
230
+ sources=["shapely/vectorized/_vectorized.pyx"],
231
+ libraries=libraries + [np.get_include()],
232
+ include_dirs=[get_config_var('INCLUDEDIR'), np.get_include()],
233
+ ))
234
+ except ImportError:
235
+ print("Numpy or Cython not available, shapely.vectorized submodule not "
236
+ "being built.")
237
+
238
+
208
239
  try:
209
240
  # try building with speedups
210
- setup_args['cmdclass']['build_ext'] = build_ext
241
+ existing_build_ext = setup_args['cmdclass'].get('build_ext', distutils_build_ext)
242
+ setup_args['cmdclass']['build_ext'] = construct_build_ext(existing_build_ext)
211
243
  setup(
212
244
  ext_modules=ext_modules,
213
245
  **setup_args
@@ -0,0 +1 @@
1
+ __version__ = "1.3.3"
@@ -0,0 +1,52 @@
1
+ # The beginnings of a Cython definition of GEOS. In the future much of this
2
+ # could be auto-generated.
3
+
4
+ ctypedef long ptr
5
+
6
+
7
+ cdef extern from "geos_c.h":
8
+ ctypedef void *GEOSContextHandle_t
9
+ ctypedef struct GEOSGeometry
10
+ ctypedef struct GEOSCoordSequence
11
+ ctypedef struct GEOSPreparedGeometry
12
+
13
+ GEOSCoordSequence *GEOSCoordSeq_create_r(GEOSContextHandle_t, unsigned int, unsigned int) nogil
14
+ GEOSCoordSequence *GEOSGeom_getCoordSeq_r(GEOSContextHandle_t, GEOSGeometry *) nogil
15
+
16
+ int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, GEOSCoordSequence *, int *) nogil
17
+ int GEOSCoordSeq_setX_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
18
+ int GEOSCoordSeq_setY_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
19
+ int GEOSCoordSeq_setZ_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
20
+ int GEOSCoordSeq_getX_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double *) nogil
21
+ int GEOSCoordSeq_getY_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double *) nogil
22
+ int GEOSCoordSeq_getZ_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double *) nogil
23
+
24
+ GEOSGeometry *GEOSGeom_createPoint_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
25
+ GEOSGeometry *GEOSGeom_createLineString_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
26
+ GEOSGeometry *GEOSGeom_createLinearRing_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
27
+
28
+ void GEOSGeom_destroy_r(GEOSContextHandle_t, GEOSGeometry *) nogil
29
+
30
+ char GEOSPreparedContains_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
31
+ char GEOSPreparedContainsProperly_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
32
+ char GEOSPreparedCoveredBy_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
33
+ char GEOSPreparedCovers_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
34
+ char GEOSPreparedCrosses_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
35
+ char GEOSPreparedDisjoint_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
36
+ char GEOSPreparedIntersects_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
37
+ char GEOSPreparedOverlaps_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
38
+ char GEOSPreparedTouches_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
39
+ char GEOSPreparedWithin_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
40
+
41
+
42
+ cdef GEOSContextHandle_t get_geos_context_handle():
43
+ # Note: This requires that lgeos is defined, so needs to be imported as:
44
+ from shapely.geos import lgeos
45
+ cdef ptr handle = lgeos.geos_handle
46
+ return <GEOSContextHandle_t>handle
47
+
48
+
49
+ cdef GEOSPreparedGeometry *geos_from_prepared(shapely_geom) except *:
50
+ """Get the Prepared GEOS geometry pointer from the given shapely geometry."""
51
+ cdef ptr geos_geom = shapely_geom._geom
52
+ return <GEOSPreparedGeometry *>geos_geom
@@ -77,7 +77,7 @@ def affine_transform(geom, matrix):
77
77
  yield (xp, yp, zp)
78
78
 
79
79
  # Process coordinates from each supported geometry type
80
- if geom.type in ('Point', 'LineString'):
80
+ if geom.type in ('Point', 'LineString', 'LinearRing'):
81
81
  return type(geom)(list(affine_pts(geom.coords)))
82
82
  elif geom.type == 'Polygon':
83
83
  ring = geom.exterior
@@ -21,8 +21,13 @@ def required(ob):
21
21
  """Return an object that meets Shapely requirements for self-owned
22
22
  C-continguous data, copying if necessary, or just return the original
23
23
  object."""
24
- if has_numpy and hasattr(ob, '__array_interface__'):
25
- return numpy.require(ob, numpy.float64, ["C", "OWNDATA"])
24
+ if (hasattr(ob, '__array_interface__')
25
+ and ob.__array_interface__.get('strides')):
26
+ if has_numpy:
27
+ return numpy.require(ob, numpy.float64, ["C", "OWNDATA"])
28
+ else:
29
+ # raise an error if strided. See issue #52.
30
+ raise ValueError("C-contiguous data is required")
26
31
  else:
27
32
  return ob
28
33
 
@@ -160,7 +160,7 @@ class BaseGeometry(object):
160
160
  # _crs : object
161
161
  # Coordinate reference system. Available for Shapely extensions, but
162
162
  # not implemented here.
163
- # _owned : bool
163
+ # _other_owned : bool
164
164
  # True if this object's GEOS geometry is owned by another as in the
165
165
  # case of a multipart geometry member.
166
166
  __geom__ = EMPTY
@@ -168,7 +168,7 @@ class BaseGeometry(object):
168
168
  _ctypes_data = None
169
169
  _ndim = None
170
170
  _crs = None
171
- _owned = False
171
+ _other_owned = False
172
172
 
173
173
  # Backend config
174
174
  impl = DefaultImplementation
@@ -180,19 +180,18 @@ class BaseGeometry(object):
180
180
  # a reference to the so/dll proxy to preserve access during clean up
181
181
  _lgeos = lgeos
182
182
 
183
- def empty(self):
183
+ def empty(self, val=EMPTY):
184
184
  # TODO: defer cleanup to the implementation. We shouldn't be
185
185
  # explicitly calling a lgeos method here.
186
- if not (self._owned or self._is_empty):
186
+ if not self._is_empty and not self._other_owned and self.__geom__:
187
187
  try:
188
188
  self._lgeos.GEOSGeom_destroy(self.__geom__)
189
189
  except AttributeError:
190
190
  pass # _lgeos might be empty on shutdown
191
- self.__geom__ = EMPTY
191
+ self.__geom__ = val
192
192
 
193
193
  def __del__(self):
194
- self.empty()
195
- self.__geom__ = None
194
+ self.empty(val=None)
196
195
  self.__p__ = None
197
196
 
198
197
  def __str__(self):
@@ -324,6 +323,36 @@ class BaseGeometry(object):
324
323
  """WKB hex representation of the geometry"""
325
324
  return WKBWriter(lgeos).write_hex(self)
326
325
 
326
+ def svg(self, scale_factor=1.):
327
+ """
328
+ SVG representation of the geometry. Scale factor is multiplied by
329
+ the size of the SVG symbol so it can be scaled consistently for a
330
+ consistent appearance based on the canvas size.
331
+ """
332
+ raise NotImplementedError
333
+
334
+ def _repr_svg_(self):
335
+ """SVG representation for iPython notebook"""
336
+ #Pick an arbitrary size for the SVG canvas
337
+
338
+
339
+ xmin, ymin, xmax, ymax = self.buffer(1).bounds
340
+ x_size = min([max([100., xmax - xmin]), 300])
341
+ y_size = min([max([100., ymax - ymin]), 300])
342
+ try:
343
+ scale_factor = max([xmax - xmin, ymax - ymin]) / max([x_size, y_size])
344
+ except ZeroDivisionError:
345
+ scale_factor = 1
346
+ buffered_box = "{0} {1} {2} {3}".format(xmin, ymin, xmax - xmin, ymax - ymin)
347
+ return """<svg
348
+ preserveAspectRatio="xMinYMin meet"
349
+ viewBox="{0}"
350
+ width="{1}"
351
+ height="{2}"
352
+ transform="translate(0, {1}),scale(1, -1)">
353
+ {3}
354
+ </svg>""".format(buffered_box, x_size, y_size, self.svg(scale_factor))
355
+
327
356
  @property
328
357
  def geom_type(self):
329
358
  """Name of the geometry's type, such as 'Point'"""
@@ -394,7 +423,7 @@ class BaseGeometry(object):
394
423
 
395
424
  def buffer(self, distance, resolution=16, quadsegs=None,
396
425
  cap_style=CAP_STYLE.round, join_style=JOIN_STYLE.round,
397
- mitre_limit=0):
426
+ mitre_limit=5.0):
398
427
  """Returns a geometry with an envelope at a distance from the object's
399
428
  envelope
400
429
 
@@ -433,7 +462,6 @@ class BaseGeometry(object):
433
462
  >>> g.buffer(1.0, cap_style='square').area
434
463
  4.0
435
464
  """
436
-
437
465
  if quadsegs is not None:
438
466
  warn(
439
467
  "The `quadsegs` argument is deprecated. Use `resolution`.",
@@ -441,7 +469,9 @@ class BaseGeometry(object):
441
469
  res = quadsegs
442
470
  else:
443
471
  res = resolution
444
-
472
+ if mitre_limit == 0.0:
473
+ raise ValueError(
474
+ 'Cannot compute offset from zero-length line segment')
445
475
  if cap_style == CAP_STYLE.round and join_style == JOIN_STYLE.round:
446
476
  return geom_factory(self.impl['buffer'](self, distance, res))
447
477
 
@@ -657,6 +687,14 @@ class BaseMultipartGeometry(BaseGeometry):
657
687
  else:
658
688
  return ()[index]
659
689
 
690
+ def svg(self, scale_factor=1.):
691
+ """
692
+ SVG representation of the geometry. Scale factor is multiplied by
693
+ the size of the SVG symbol so it can be scaled consistently for a
694
+ consistent appearance based on the canvas size.
695
+ """
696
+ return "\n".join([g.svg(scale_factor) for g in self])
697
+
660
698
 
661
699
  class GeometrySequence(object):
662
700
  """
@@ -688,7 +726,7 @@ class GeometrySequence(object):
688
726
 
689
727
  def _get_geom_item(self, i):
690
728
  g = self.shape_factory()
691
- g._owned = True
729
+ g._other_owned = True
692
730
  g._geom = lgeos.GEOSGetGeometryN(self._geom, i)
693
731
  g._ndim = self._ndim
694
732
  g.__p__ = self
@@ -746,7 +784,7 @@ class HeterogeneousGeometrySequence(GeometrySequence):
746
784
  def _get_geom_item(self, i):
747
785
  sub = lgeos.GEOSGetGeometryN(self._geom, i)
748
786
  g = geom_factory(sub, parent=self)
749
- g._owned = True
787
+ g._other_owned = True
750
788
  return g
751
789
 
752
790
 
@@ -53,6 +53,24 @@ class LineString(BaseGeometry):
53
53
  'coordinates': tuple(self.coords)
54
54
  }
55
55
 
56
+ def svg(self, scale_factor=1.):
57
+ """
58
+ SVG representation of the geometry. Scale factor is multiplied by
59
+ the size of the SVG symbol so it can be scaled consistently for a
60
+ consistent appearance based on the canvas size.
61
+ """
62
+ pnt_format = " ".join(["{0},{1}".format(*c) for c in self.coords])
63
+ return """<polyline
64
+ fill="none"
65
+ stroke="{2}"
66
+ stroke-width={1}
67
+ points="{0}"
68
+ opacity=".8"
69
+ />""".format(
70
+ pnt_format,
71
+ 2.*scale_factor,
72
+ "#66cc99" if self.is_valid else "#ff3333")
73
+
56
74
  @property
57
75
  def ctypes(self):
58
76
  if not self._ctypes_data:
@@ -88,7 +106,7 @@ class LineString(BaseGeometry):
88
106
 
89
107
  def parallel_offset(
90
108
  self, distance, side,
91
- resolution=16, join_style=JOIN_STYLE.round, mitre_limit=1.0):
109
+ resolution=16, join_style=JOIN_STYLE.round, mitre_limit=5.0):
92
110
 
93
111
  """Returns a LineString or MultiLineString geometry at a distance from
94
112
  the object on its right or its left side.
@@ -108,12 +126,14 @@ class LineString(BaseGeometry):
108
126
  far beyond the original geometry. To prevent unreasonable geometry, the
109
127
  mitre limit allows controlling the maximum length of the join corner.
110
128
  Corners with a ratio which exceed the limit will be beveled."""
111
-
129
+ if mitre_limit == 0.0:
130
+ raise ValueError(
131
+ 'Cannot compute offset from zero-length line segment')
112
132
  try:
113
133
  return geom_factory(self.impl['parallel_offset'](
114
134
  self, distance, resolution, join_style, mitre_limit,
115
135
  bool(side == 'left')))
116
- except WindowsError:
136
+ except OSError:
117
137
  raise TopologicalError()
118
138
 
119
139
 
@@ -61,11 +61,32 @@ class MultiLineString(BaseMultipartGeometry):
61
61
  'coordinates': tuple(tuple(c for c in g.coords) for g in self.geoms)
62
62
  }
63
63
 
64
+ def svg(self, scale_factor=1.):
65
+ """
66
+ SVG representation of the geometry. Scale factor is multiplied by
67
+ the size of the SVG symbol so it can be scaled consistently for a
68
+ consistent appearance based on the canvas size.
69
+ """
70
+ parts = []
71
+ for part in self.geoms:
72
+ pnt_format = " ".join(["{0},{1}".format(*c) for c in part.coords])
73
+ parts.append("""<polyline
74
+ fill="none"
75
+ stroke="{2}"
76
+ stroke-width={1}
77
+ points="{0}"
78
+ opacity=".8"
79
+ />""".format(
80
+ pnt_format,
81
+ 2.*scale_factor,
82
+ "#66cc99" if self.is_valid else "#ff3333"))
83
+ return "\n".join(parts)
84
+
64
85
 
65
86
  class MultiLineStringAdapter(CachingGeometryProxy, MultiLineString):
66
87
 
67
88
  context = None
68
- _owned = False
89
+ _other_owned = False
69
90
 
70
91
  def __init__(self, context):
71
92
  self.context = context