shapely 1.5.8__tar.gz → 1.5.10__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 (114) hide show
  1. {Shapely-1.5.8 → Shapely-1.5.10}/CHANGES.txt +9 -0
  2. {Shapely-1.5.8/Shapely.egg-info → Shapely-1.5.10}/PKG-INFO +15 -5
  3. {Shapely-1.5.8 → Shapely-1.5.10}/README.rst +4 -3
  4. {Shapely-1.5.8 → Shapely-1.5.10/Shapely.egg-info}/PKG-INFO +15 -5
  5. {Shapely-1.5.8 → Shapely-1.5.10}/Shapely.egg-info/SOURCES.txt +4 -0
  6. Shapely-1.5.10/VERSION.txt +1 -0
  7. {Shapely-1.5.8 → Shapely-1.5.10}/docs/manual.rst +37 -5
  8. {Shapely-1.5.8 → Shapely-1.5.10}/setup.py +136 -54
  9. Shapely-1.5.10/shapely/__init__.py +1 -0
  10. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/_geos.pxi +1 -1
  11. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/ctypes_declarations.py +17 -5
  12. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/base.py +22 -7
  13. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/linestring.py +8 -7
  14. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/multipoint.py +1 -1
  15. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/polygon.py +2 -2
  16. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geos.py +35 -115
  17. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/impl.py +28 -3
  18. Shapely-1.5.10/shapely/libgeos.py +236 -0
  19. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/linref.py +1 -3
  20. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/speedups/__init__.py +1 -1
  21. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/speedups/_speedups.c +2984 -1563
  22. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/speedups/_speedups.pyx +27 -25
  23. {Shapely-1.5.8 → Shapely-1.5.10}/tests/__init__.py +8 -1
  24. Shapely-1.5.10/tests/test_default_impl.py +24 -0
  25. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_dlls.py +1 -1
  26. Shapely-1.5.10/tests/test_multi.py +8 -0
  27. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_multilinestring.py +8 -2
  28. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_multipoint.py +7 -2
  29. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_multipolygon.py +8 -2
  30. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_operations.py +9 -2
  31. Shapely-1.5.10/tests/test_parallel_offset.py +33 -0
  32. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_predicates.py +21 -2
  33. Shapely-1.5.8/VERSION.txt +0 -1
  34. Shapely-1.5.8/shapely/__init__.py +0 -1
  35. {Shapely-1.5.8 → Shapely-1.5.10}/CREDITS.txt +0 -0
  36. {Shapely-1.5.8 → Shapely-1.5.10}/LICENSE.txt +0 -0
  37. {Shapely-1.5.8 → Shapely-1.5.10}/Shapely.egg-info/dependency_links.txt +0 -0
  38. {Shapely-1.5.8 → Shapely-1.5.10}/Shapely.egg-info/top_level.txt +0 -0
  39. {Shapely-1.5.8 → Shapely-1.5.10}/docs/design.rst +0 -0
  40. {Shapely-1.5.8 → Shapely-1.5.10}/docs/index.rst +0 -0
  41. {Shapely-1.5.8 → Shapely-1.5.10}/docs/project.rst +0 -0
  42. {Shapely-1.5.8 → Shapely-1.5.10}/setup.cfg +1 -1
  43. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/affinity.py +0 -0
  44. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/algorithms/__init__.py +0 -0
  45. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/algorithms/cga.py +0 -0
  46. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/coords.py +0 -0
  47. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/examples/__init__.py +0 -0
  48. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/examples/dissolve.py +0 -0
  49. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/examples/geoms.py +0 -0
  50. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/examples/intersect.py +0 -0
  51. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/ftools.py +0 -0
  52. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/__init__.py +0 -0
  53. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/collection.py +0 -0
  54. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/geo.py +0 -0
  55. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/multilinestring.py +0 -0
  56. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/multipolygon.py +0 -0
  57. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/point.py +0 -0
  58. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/geometry/proxy.py +0 -0
  59. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/iterops.py +0 -0
  60. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/ops.py +0 -0
  61. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/predicates.py +0 -0
  62. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/prepared.py +0 -0
  63. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/strtree.py +0 -0
  64. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/topology.py +0 -0
  65. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/validation.py +0 -0
  66. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/vectorized/__init__.py +0 -0
  67. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/vectorized/_vectorized.pyx +0 -0
  68. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/wkb.py +0 -0
  69. {Shapely-1.5.8 → Shapely-1.5.10}/shapely/wkt.py +0 -0
  70. {Shapely-1.5.8 → Shapely-1.5.10}/tests/binascii_hex.txt +0 -0
  71. {Shapely-1.5.8 → Shapely-1.5.10}/tests/conftest.py +0 -0
  72. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_affinity.py +0 -0
  73. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_box.py +0 -0
  74. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_cga.py +0 -0
  75. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_collection.py +0 -0
  76. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_coords.py +0 -0
  77. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_delaunay.py +0 -0
  78. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_delegated.py +0 -0
  79. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_doctests.py +0 -0
  80. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_emptiness.py +0 -0
  81. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_equality.py +0 -0
  82. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_geointerface.py +0 -0
  83. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_geomseq.py +0 -0
  84. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_geos_err_handler.py +0 -0
  85. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_getitem.py +0 -0
  86. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_hash.py +0 -0
  87. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_invalid_geometries.py +0 -0
  88. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_iterops.py +0 -0
  89. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_linear_referencing.py +0 -0
  90. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_linemerge.py +0 -0
  91. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_linestring.py +0 -0
  92. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_locale.py +0 -0
  93. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_mapping.py +0 -0
  94. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_ndarrays.py +0 -0
  95. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_nearest.py +0 -0
  96. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_operators.py +0 -0
  97. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_persist.py +0 -0
  98. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_pickle.py +0 -0
  99. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_point.py +0 -0
  100. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_polygon.py +0 -0
  101. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_polygonize.py +0 -0
  102. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_prepared.py +0 -0
  103. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_products_z.py +0 -0
  104. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_singularity.py +0 -0
  105. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_snap.py +0 -0
  106. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_strtree.py +0 -0
  107. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_styles.py +0 -0
  108. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_svg.py +0 -0
  109. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_transform.py +0 -0
  110. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_union.py +0 -0
  111. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_validation.py +0 -0
  112. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_vectorized.py +0 -0
  113. {Shapely-1.5.8 → Shapely-1.5.10}/tests/test_xy.py +0 -0
  114. {Shapely-1.5.8 → Shapely-1.5.10}/tests/threading_test.py +0 -0
@@ -1,6 +1,15 @@
1
1
  Changes
2
2
  =======
3
3
 
4
+ 1.5.10 (2015-08-22)
5
+ -------------------
6
+ - Monkey patch affinity module by absolute reference (#299).
7
+ - Raise TopologicalError in relate() instead of crashing (#294, #295, #303).
8
+
9
+ 1.5.9 (2015-05-27)
10
+ ------------------
11
+ - Fix for 64 bit speedups compatibility (#274).
12
+
4
13
  1.5.8 (2015-04-29)
5
14
  ------------------
6
15
  - Setup file encoding bug fix (#254).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Shapely
3
- Version: 1.5.8
3
+ Version: 1.5.10
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: https://github.com/Toblerity/Shapely
6
6
  Author: Sean Gillies
@@ -52,12 +52,13 @@ Description: =======
52
52
 
53
53
  $ pip install shapely
54
54
 
55
- If you've installed GEOS to a non-standard location, you can use the
56
- geos-config program to find compiler and linker options.
55
+ If you've installed GEOS to a non-standard location, the geos-config program
56
+ will be used to get compiler and linker options. If it is not on the PATH,
57
+ it can be specified with a GEOS_CONFIG environment variable, e.g.:
57
58
 
58
59
  .. code-block:: console
59
60
 
60
- $ CFLAGS=`geos-config --cflags` LDFLAGS=`geos-config --clibs` pip install shapely
61
+ $ GEOS_CONFIG=/path/to/geos-config pip install shapely
61
62
 
62
63
  If your system's GEOS version is < 3.3.0 you cannot use Shapely 1.3+ and must
63
64
  stick to 1.2.x as shown below.
@@ -215,6 +216,15 @@ Description: =======
215
216
  Changes
216
217
  =======
217
218
 
219
+ 1.5.10 (2015-08-22)
220
+ -------------------
221
+ - Monkey patch affinity module by absolute reference (#299).
222
+ - Raise TopologicalError in relate() instead of crashing (#294, #295, #303).
223
+
224
+ 1.5.9 (2015-05-27)
225
+ ------------------
226
+ - Fix for 64 bit speedups compatibility (#274).
227
+
218
228
  1.5.8 (2015-04-29)
219
229
  ------------------
220
230
  - Setup file encoding bug fix (#254).
@@ -588,4 +598,4 @@ Classifier: Programming Language :: Python :: 2.7
588
598
  Classifier: Programming Language :: Python :: 3
589
599
  Classifier: Topic :: Scientific/Engineering :: GIS
590
600
  Requires: Python (>=2.6)
591
- Requires: libgeos_c (>=3.1)
601
+ Requires: libgeos_c (>=3.3)
@@ -44,12 +44,13 @@ system library path, and install Shapely from the Python package index.
44
44
 
45
45
  $ pip install shapely
46
46
 
47
- If you've installed GEOS to a non-standard location, you can use the
48
- geos-config program to find compiler and linker options.
47
+ If you've installed GEOS to a non-standard location, the geos-config program
48
+ will be used to get compiler and linker options. If it is not on the PATH,
49
+ it can be specified with a GEOS_CONFIG environment variable, e.g.:
49
50
 
50
51
  .. code-block:: console
51
52
 
52
- $ CFLAGS=`geos-config --cflags` LDFLAGS=`geos-config --clibs` pip install shapely
53
+ $ GEOS_CONFIG=/path/to/geos-config pip install shapely
53
54
 
54
55
  If your system's GEOS version is < 3.3.0 you cannot use Shapely 1.3+ and must
55
56
  stick to 1.2.x as shown below.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Shapely
3
- Version: 1.5.8
3
+ Version: 1.5.10
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: https://github.com/Toblerity/Shapely
6
6
  Author: Sean Gillies
@@ -52,12 +52,13 @@ Description: =======
52
52
 
53
53
  $ pip install shapely
54
54
 
55
- If you've installed GEOS to a non-standard location, you can use the
56
- geos-config program to find compiler and linker options.
55
+ If you've installed GEOS to a non-standard location, the geos-config program
56
+ will be used to get compiler and linker options. If it is not on the PATH,
57
+ it can be specified with a GEOS_CONFIG environment variable, e.g.:
57
58
 
58
59
  .. code-block:: console
59
60
 
60
- $ CFLAGS=`geos-config --cflags` LDFLAGS=`geos-config --clibs` pip install shapely
61
+ $ GEOS_CONFIG=/path/to/geos-config pip install shapely
61
62
 
62
63
  If your system's GEOS version is < 3.3.0 you cannot use Shapely 1.3+ and must
63
64
  stick to 1.2.x as shown below.
@@ -215,6 +216,15 @@ Description: =======
215
216
  Changes
216
217
  =======
217
218
 
219
+ 1.5.10 (2015-08-22)
220
+ -------------------
221
+ - Monkey patch affinity module by absolute reference (#299).
222
+ - Raise TopologicalError in relate() instead of crashing (#294, #295, #303).
223
+
224
+ 1.5.9 (2015-05-27)
225
+ ------------------
226
+ - Fix for 64 bit speedups compatibility (#274).
227
+
218
228
  1.5.8 (2015-04-29)
219
229
  ------------------
220
230
  - Setup file encoding bug fix (#254).
@@ -588,4 +598,4 @@ Classifier: Programming Language :: Python :: 2.7
588
598
  Classifier: Programming Language :: Python :: 3
589
599
  Classifier: Topic :: Scientific/Engineering :: GIS
590
600
  Requires: Python (>=2.6)
591
- Requires: libgeos_c (>=3.1)
601
+ Requires: libgeos_c (>=3.3)
@@ -21,6 +21,7 @@ shapely/ftools.py
21
21
  shapely/geos.py
22
22
  shapely/impl.py
23
23
  shapely/iterops.py
24
+ shapely/libgeos.py
24
25
  shapely/linref.py
25
26
  shapely/ops.py
26
27
  shapely/predicates.py
@@ -60,6 +61,7 @@ tests/test_box.py
60
61
  tests/test_cga.py
61
62
  tests/test_collection.py
62
63
  tests/test_coords.py
64
+ tests/test_default_impl.py
63
65
  tests/test_delaunay.py
64
66
  tests/test_delegated.py
65
67
  tests/test_dlls.py
@@ -78,6 +80,7 @@ tests/test_linemerge.py
78
80
  tests/test_linestring.py
79
81
  tests/test_locale.py
80
82
  tests/test_mapping.py
83
+ tests/test_multi.py
81
84
  tests/test_multilinestring.py
82
85
  tests/test_multipoint.py
83
86
  tests/test_multipolygon.py
@@ -85,6 +88,7 @@ tests/test_ndarrays.py
85
88
  tests/test_nearest.py
86
89
  tests/test_operations.py
87
90
  tests/test_operators.py
91
+ tests/test_parallel_offset.py
88
92
  tests/test_persist.py
89
93
  tests/test_pickle.py
90
94
  tests/test_point.py
@@ -0,0 +1 @@
1
+ 1.5.10
@@ -1054,8 +1054,9 @@ differently.
1054
1054
 
1055
1055
  .. method:: object.contains(other)
1056
1056
 
1057
- Returns ``True`` if the object's `interior` contains the `boundary` and
1058
- `interior` of the other object and their boundaries do not touch at all.
1057
+ Returns ``True`` if no points of `other` lie in the exterior of the `object`
1058
+ and at least one point of the interior of `other` lies in the interior of
1059
+ `object`.
1059
1060
 
1060
1061
  This predicate applies to all types, and is inverse to :meth:`within`. The
1061
1062
  expression ``a.contains(b) == b.within(a)`` always evaluates to ``True``.
@@ -1124,8 +1125,8 @@ This predicate applies to all types and is the inverse of :meth:`intersects`.
1124
1125
  Returns ``True`` if the `boundary` and `interior` of the object intersect in
1125
1126
  any way with those of the other.
1126
1127
 
1127
- This predicate is equivalent to the OR-ing of :meth:`contains`, :meth:`crosses`,
1128
- :meth:`equals`, :meth:`touches`, and :meth:`within`.
1128
+ In other words, geometric objects intersect if they have any boundary or
1129
+ interior point in common.
1129
1130
 
1130
1131
  .. method:: object.touches(other)
1131
1132
 
@@ -1234,6 +1235,37 @@ elements.
1234
1235
  >>> Point(0, 0).relate(LineString([(0, 0), (1, 1)]))
1235
1236
  'F0FFFF102'
1236
1237
 
1238
+ .. method:: object.relate_pattern(other, pattern)
1239
+
1240
+ Returns True if the DE-9IM string code for the relationship between the
1241
+ geometries satisfies the pattern, otherwise False.
1242
+
1243
+ The :meth:`relate_pattern` compares the DE-9IM code string for two geometries
1244
+ against a specified pattern. If the string matches the pattern then ``True`` is
1245
+ returned, otherwise ``False``. The pattern specified can be an exact match
1246
+ (``0``, ``1`` or ``2``), a boolean match (``T`` or ``F``), or a wildcard
1247
+ (``*``). For example, the pattern for the `within` predicate is ``T*****FF*``.
1248
+
1249
+ .. code-block:: pycon
1250
+
1251
+ >> point = Point(0.5, 0.5)
1252
+ >> square = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
1253
+ >> square.relate_pattern(point, 'T*****FF*')
1254
+ True
1255
+ >> point.within(square)
1256
+ True
1257
+
1258
+ Note that the order or the geometries is significant, as demonstrated below.
1259
+ In this example the square contains the point, but the point does not contain
1260
+ the square.
1261
+
1262
+ .. code-block:: pycon
1263
+
1264
+ >>> point.relate(square)
1265
+ '0FFFFF212'
1266
+ >>> square.relate(point)
1267
+ '0F2FF1FF2'
1268
+
1237
1269
  Further discussion of the DE-9IM matrix is beyond the scope of this manual. See
1238
1270
  [4]_ and http://pypi.python.org/pypi/de9im.
1239
1271
 
@@ -2037,7 +2069,7 @@ one geometry to the vertices in a second geometry with a given tolerance.
2037
2069
  The `tolerance` argument specifies the minimum distance between vertices for
2038
2070
  them to be snapped.
2039
2071
 
2040
- `New in version 1.4.5`
2072
+ `New in version 1.5.0`
2041
2073
 
2042
2074
  .. code-block:: pycon
2043
2075
 
@@ -1,7 +1,24 @@
1
1
  #!/usr/bin/env python
2
2
 
3
- from __future__ import print_function
3
+ # Two environment variables influence this script.
4
+ #
5
+ # GEOS_LIBRARY_PATH: a path to a GEOS C shared library.
6
+ #
7
+ # GEOS_CONFIG: the path to a geos-config program that points to GEOS version,
8
+ # headers, and libraries.
9
+ #
10
+ # NB: within this setup scripts, software versions are evaluated according
11
+ # to https://www.python.org/dev/peps/pep-0440/.
4
12
 
13
+ import errno
14
+ import glob
15
+ import logging
16
+ import os
17
+ import platform
18
+ import re
19
+ import shutil
20
+ import subprocess
21
+ import sys
5
22
  try:
6
23
  # If possible, use setuptools
7
24
  from setuptools import setup
@@ -11,36 +28,54 @@ except ImportError:
11
28
  from distutils.core import setup
12
29
  from distutils.extension import Extension
13
30
  from distutils.command.build_ext import build_ext as distutils_build_ext
14
- from distutils.cmd import Command
15
31
  from distutils.errors import CCompilerError, DistutilsExecError, \
16
32
  DistutilsPlatformError
17
- from distutils.sysconfig import get_config_var
18
- import errno
19
- import glob
20
- import os
21
- import platform
22
- import shutil
23
- import subprocess
24
- import sys
25
33
 
34
+ from packaging.version import Version
35
+
36
+ # Get geos_version from GEOS dynamic library, which depends on
37
+ # GEOS_LIBRARY_PATH and/or GEOS_CONFIG environment variables
38
+ from shapely.libgeos import geos_version_string, geos_version, \
39
+ geos_config, get_geos_config
40
+
41
+ logging.basicConfig()
42
+ log = logging.getLogger(__file__)
43
+
44
+ # python -W all setup.py ...
45
+ if 'all' in sys.warnoptions:
46
+ log.level = logging.DEBUG
26
47
 
27
48
  # Get the version from the shapely module
28
- version = None
49
+ shapely_version = None
29
50
  with open('shapely/__init__.py', 'r') as fp:
30
51
  for line in fp:
31
- if "__version__" in line:
32
- exec(line.replace('_', ''))
52
+ if line.startswith("__version__"):
53
+ shapely_version = Version(
54
+ line.split("=")[1].strip().strip("\"'"))
33
55
  break
34
- if version is None:
56
+
57
+ if not shapely_version:
35
58
  raise ValueError("Could not determine Shapely's version")
36
59
 
60
+ # Fail installation if the GEOS shared library does not meet the minimum
61
+ # version. We ship it with Shapely for Windows, so no need to check on
62
+ # that platform.
63
+ log.debug('GEOS shared library: %s %s', geos_version_string, geos_version)
64
+ if (set(sys.argv).intersection(['install', 'build', 'build_ext']) and
65
+ shapely_version >= Version('1.3') and
66
+ geos_version < (3, 3)):
67
+ log.critical(
68
+ "Shapely >= 1.3 requires GEOS >= 3.3. "
69
+ "Install GEOS 3.3+ and reinstall Shapely.")
70
+ sys.exit(1)
71
+
37
72
  # Handle UTF-8 encoding of certain text files.
38
73
  open_kwds = {}
39
74
  if sys.version_info >= (3,):
40
75
  open_kwds['encoding'] = 'utf-8'
41
76
 
42
77
  with open('VERSION.txt', 'w', **open_kwds) as fp:
43
- fp.write(version)
78
+ fp.write(str(shapely_version))
44
79
 
45
80
  with open('README.rst', 'r', **open_kwds) as fp:
46
81
  readme = fp.read()
@@ -55,8 +90,8 @@ long_description = readme + '\n\n' + credits + '\n\n' + changes
55
90
 
56
91
  setup_args = dict(
57
92
  name = 'Shapely',
58
- version = version,
59
- requires = ['Python (>=2.6)', 'libgeos_c (>=3.1)'],
93
+ version = str(shapely_version),
94
+ requires = ['Python (>=2.6)', 'libgeos_c (>=3.3)'],
60
95
  description = 'Geometric objects, predicates, and operations',
61
96
  license = 'BSD',
62
97
  keywords = 'geometry topology gis',
@@ -74,7 +109,6 @@ setup_args = dict(
74
109
  'shapely.speedups',
75
110
  'shapely.vectorized',
76
111
  ],
77
- cmdclass = {},
78
112
  classifiers = [
79
113
  'Development Status :: 5 - Production/Stable',
80
114
  'Intended Audience :: Developers',
@@ -86,7 +120,8 @@ setup_args = dict(
86
120
  'Programming Language :: Python :: 3',
87
121
  'Topic :: Scientific/Engineering :: GIS',
88
122
  ],
89
- data_files = [('shapely', ['shapely/_geos.pxi'])]
123
+ data_files = [('shapely', ['shapely/_geos.pxi'])],
124
+ cmdclass = {},
90
125
  )
91
126
 
92
127
  # Add DLLs for Windows
@@ -111,6 +146,47 @@ if sys.platform == 'win32':
111
146
  )
112
147
 
113
148
 
149
+ # Prepare build opts and args for the speedups extension module.
150
+ include_dirs = []
151
+ library_dirs = []
152
+ libraries = []
153
+ extra_link_args = []
154
+
155
+ try:
156
+ # Get the version from geos-config. Show error if this version tuple is
157
+ # different to the GEOS version loaded from the dynamic library.
158
+ geos_config_version_string = get_geos_config('--version')
159
+ res = re.findall(r'(\d+)\.(\d+)\.(\d+)', geos_config_version_string)
160
+ geos_config_version = tuple(int(x) for x in res[0])
161
+
162
+ if geos_config_version != geos_version:
163
+ log.error("The GEOS dynamic library version is %s %s,",
164
+ geos_version_string, geos_version)
165
+ log.error("but the version reported by %s is %s %s.", geos_config,
166
+ geos_config_version_string, geos_config_version)
167
+ sys.exit(1)
168
+ except OSError as ex:
169
+ log.error(ex)
170
+ log.error('Cannot find geos-config to get headers and check version.')
171
+ log.error('If available, specify a path to geos-config with a '
172
+ 'GEOS_CONFIG environment variable')
173
+ geos_config = None
174
+
175
+ if geos_config:
176
+ # Collect other options from GEOS
177
+ for item in get_geos_config('--cflags').split():
178
+ if item.startswith("-I"):
179
+ include_dirs.extend(item[2:].split(":"))
180
+ for item in get_geos_config('--clibs').split():
181
+ if item.startswith("-L"):
182
+ library_dirs.extend(item[2:].split(":"))
183
+ elif item.startswith("-l"):
184
+ libraries.append(item[2:])
185
+ else:
186
+ # e.g. -framework GEOS
187
+ extra_link_args.append(item)
188
+
189
+
114
190
  # Optional compilation of speedups
115
191
  # setuptools stuff from Bob Ippolito's simplejson project
116
192
  if sys.platform == 'win32' and sys.version_info > (2, 6):
@@ -149,10 +225,6 @@ if (hasattr(platform, 'python_implementation')
149
225
  # python_implementation is only available since 2.6
150
226
  ext_modules = []
151
227
  libraries = []
152
- elif sys.platform == 'win32':
153
- libraries = ['geos']
154
- else:
155
- libraries = ['geos_c']
156
228
 
157
229
 
158
230
  if os.path.exists("MANIFEST.in"):
@@ -166,67 +238,77 @@ if os.path.exists("MANIFEST.in"):
166
238
  try:
167
239
  if (force_cython or not os.path.exists(c_file)
168
240
  or os.path.getmtime(pyx_file) > os.path.getmtime(c_file)):
169
- print("Updating C extension with Cython.", file=sys.stderr)
241
+ log.info("Updating C extension with Cython.")
170
242
  subprocess.check_call(["cython", "shapely/speedups/_speedups.pyx"])
171
243
  except (subprocess.CalledProcessError, OSError):
172
- print("Warning: Could not (re)create C extension with Cython.",
173
- file=sys.stderr)
244
+ log.warn("Could not (re)create C extension with Cython.")
174
245
  if force_cython:
175
246
  raise
176
- if not os.path.exists("shapely/speedups/_speedups.c"):
177
- print("Warning: speedup extension not found", file=sys.stderr)
247
+ if not os.path.exists(c_file):
248
+ log.warn("speedup extension not found")
178
249
 
179
250
  ext_modules = [
180
251
  Extension(
181
252
  "shapely.speedups._speedups",
182
253
  ["shapely/speedups/_speedups.c"],
254
+ include_dirs=include_dirs,
255
+ library_dirs=library_dirs,
183
256
  libraries=libraries,
184
- include_dirs=[get_config_var('INCLUDEDIR')],),
257
+ extra_link_args=extra_link_args,
258
+ ),
185
259
  ]
186
260
 
187
261
  cmd_classes = setup_args.setdefault('cmdclass', {})
188
262
 
189
263
  try:
190
- import numpy as np
264
+ import numpy
191
265
  from Cython.Distutils import build_ext as cython_build_ext
192
266
  from distutils.extension import Extension as DistutilsExtension
193
267
 
194
- if 'build_ext' in cmd_classes:
268
+ if 'build_ext' in setup_args['cmdclass']:
195
269
  raise ValueError('We need to put the Cython build_ext in '
196
270
  'cmd_classes, but it is already defined.')
197
- cmd_classes['build_ext'] = cython_build_ext
198
-
199
- ext_modules.append(DistutilsExtension("shapely.vectorized._vectorized",
200
- sources=["shapely/vectorized/_vectorized.pyx"],
201
- libraries=libraries + [np.get_include()],
202
- include_dirs=[get_config_var('INCLUDEDIR'),
203
- np.get_include()],
204
- ))
271
+ setup_args['cmdclass']['build_ext'] = cython_build_ext
272
+
273
+ include_dirs.append(numpy.get_include())
274
+ libraries.append(numpy.get_include())
275
+
276
+ ext_modules.append(DistutilsExtension(
277
+ "shapely.vectorized._vectorized",
278
+ sources=["shapely/vectorized/_vectorized.pyx"],
279
+ include_dirs=include_dirs,
280
+ library_dirs=library_dirs,
281
+ libraries=libraries,
282
+ extra_link_args=extra_link_args,
283
+ ))
205
284
  except ImportError:
206
- print("Numpy or Cython not available, shapely.vectorized submodule not "
207
- "being built.")
285
+ log.info("Numpy or Cython not available, shapely.vectorized submodule "
286
+ "not being built.")
208
287
 
209
288
 
210
289
  try:
211
290
  # try building with speedups
212
- existing_build_ext = setup_args['cmdclass'].get('build_ext', distutils_build_ext)
213
- setup_args['cmdclass']['build_ext'] = construct_build_ext(existing_build_ext)
214
- setup(
215
- ext_modules=ext_modules,
216
- **setup_args
217
- )
291
+ existing_build_ext = setup_args['cmdclass'].\
292
+ get('build_ext', distutils_build_ext)
293
+ setup_args['cmdclass']['build_ext'] = \
294
+ construct_build_ext(existing_build_ext)
295
+ setup(ext_modules=ext_modules, **setup_args)
218
296
  except BuildFailed as ex:
219
- BUILD_EXT_WARNING = "Warning: The C extension could not be compiled, " \
297
+ BUILD_EXT_WARNING = "The C extension could not be compiled, " \
220
298
  "speedups are not enabled."
221
- print(ex)
222
- print(BUILD_EXT_WARNING)
223
- print("Failure information, if any, is above.")
224
- print("I'm retrying the build without the C extension now.")
299
+ log.warn(ex)
300
+ log.warn(BUILD_EXT_WARNING)
301
+ log.warn("Failure information, if any, is above.")
302
+ log.warn("I'm retrying the build without the C extension now.")
303
+
304
+ # Remove any previously defined build_ext command class.
305
+ if 'build_ext' in setup_args['cmdclass']:
306
+ del setup_args['cmdclass']['build_ext']
225
307
 
226
308
  if 'build_ext' in cmd_classes:
227
309
  del cmd_classes['build_ext']
228
310
 
229
311
  setup(**setup_args)
230
312
 
231
- print(BUILD_EXT_WARNING)
232
- print("Plain-Python installation succeeded.")
313
+ log.warn(BUILD_EXT_WARNING)
314
+ log.info("Plain-Python installation succeeded.")
@@ -0,0 +1 @@
1
+ __version__ = "1.5.10"
@@ -13,7 +13,7 @@ cdef extern from "geos_c.h":
13
13
  GEOSCoordSequence *GEOSCoordSeq_create_r(GEOSContextHandle_t, unsigned int, unsigned int) nogil
14
14
  GEOSCoordSequence *GEOSGeom_getCoordSeq_r(GEOSContextHandle_t, GEOSGeometry *) nogil
15
15
 
16
- int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, GEOSCoordSequence *, int *) nogil
16
+ int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, GEOSCoordSequence *, unsigned int *) nogil
17
17
  int GEOSCoordSeq_setX_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
18
18
  int GEOSCoordSeq_setY_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
19
19
  int GEOSCoordSeq_setZ_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
@@ -129,8 +129,16 @@ def prototype(lgeos, geos_version):
129
129
  lgeos.GEOSBufferWithStyle.restype = c_void_p
130
130
  lgeos.GEOSBufferWithStyle.argtypes = [c_void_p, c_double, c_int, c_int, c_int, c_double]
131
131
 
132
- lgeos.GEOSSingleSidedBuffer.restype = c_void_p
133
- lgeos.GEOSSingleSidedBuffer.argtypes = [c_void_p, c_double, c_int, c_int, c_double, c_int]
132
+ if geos_version >= (3, 3, 0):
133
+
134
+ lgeos.GEOSOffsetCurve.restype = c_void_p
135
+ lgeos.GEOSOffsetCurve.argtypes = [c_void_p, c_double, c_int, c_int, c_double]
136
+
137
+ else:
138
+
139
+ # deprecated in GEOS 3.3.0 in favour of GEOSOffsetCurve
140
+ lgeos.GEOSSingleSidedBuffer.restype = c_void_p
141
+ lgeos.GEOSSingleSidedBuffer.argtypes = [c_void_p, c_double, c_int, c_int, c_double, c_int]
134
142
 
135
143
  '''
136
144
  Geometry constructors
@@ -290,12 +298,16 @@ def prototype(lgeos, geos_version):
290
298
  Dimensionally Extended 9 Intersection Model related
291
299
  '''
292
300
 
293
- lgeos.GEOSRelatePattern.restype = c_char
294
- lgeos.GEOSRelatePattern.argtypes = [c_void_p, c_void_p, c_char_p]
295
-
296
301
  lgeos.GEOSRelate.restype = allocated_c_char_p
297
302
  lgeos.GEOSRelate.argtypes = [c_void_p, c_void_p]
298
303
 
304
+ lgeos.GEOSRelatePattern.restype = c_byte
305
+ lgeos.GEOSRelatePattern.argtypes = [c_void_p, c_void_p, c_char_p]
306
+
307
+ if geos_version >= (3, 3, 0):
308
+ lgeos.GEOSRelatePatternMatch.restype = c_byte
309
+ lgeos.GEOSRelatePatternMatch.argtypes = [c_char_p, c_char_p]
310
+
299
311
  '''
300
312
  Prepared Geometry Binary predicates
301
313
  Return 2 on exception, 1 on true, 0 on false
@@ -14,6 +14,16 @@ from shapely.impl import DefaultImplementation, delegated
14
14
 
15
15
  if sys.version_info[0] < 3:
16
16
  range = xrange
17
+ integer_types = (int, long)
18
+ else:
19
+ integer_types = (int,)
20
+
21
+ try:
22
+ import numpy as np
23
+ integer_types = integer_types + (np.integer,)
24
+ except ImportError:
25
+ pass
26
+
17
27
 
18
28
  GEOMETRY_TYPES = [
19
29
  'Point',
@@ -63,7 +73,7 @@ def geom_factory(g, parent=None):
63
73
  [geom_type],
64
74
  )
65
75
  ob.__class__ = getattr(mod, geom_type)
66
- ob.__geom__ = g
76
+ ob._geom = g
67
77
  ob.__p__ = parent
68
78
  if lgeos.methods['has_z'](g):
69
79
  ob._ndim = 3
@@ -188,14 +198,11 @@ class BaseGeometry(object):
188
198
  _ndim = None
189
199
  _crs = None
190
200
  _other_owned = False
201
+ _is_empty = True
191
202
 
192
203
  # Backend config
193
204
  impl = DefaultImplementation
194
205
 
195
- @property
196
- def _is_empty(self):
197
- return self.__geom__ in [EMPTY, None]
198
-
199
206
  # a reference to the so/dll proxy to preserve access during clean up
200
207
  _lgeos = lgeos
201
208
 
@@ -207,6 +214,7 @@ class BaseGeometry(object):
207
214
  self._lgeos.GEOSGeom_destroy(self.__geom__)
208
215
  except AttributeError:
209
216
  pass # _lgeos might be empty on shutdown
217
+ self._is_empty = True
210
218
  self.__geom__ = val
211
219
 
212
220
  def __del__(self):
@@ -235,6 +243,7 @@ class BaseGeometry(object):
235
243
  @_geom.setter
236
244
  def _geom(self, val):
237
245
  self.empty()
246
+ self._is_empty = val in [EMPTY, None]
238
247
  self.__geom__ = val
239
248
 
240
249
  # Operators
@@ -528,7 +537,7 @@ class BaseGeometry(object):
528
537
 
529
538
  @delegated
530
539
  def simplify(self, tolerance, preserve_topology=True):
531
- """Returns a simplified geometry produced by the Douglas-Puecker
540
+ """Returns a simplified geometry produced by the Douglas-Peucker
532
541
  algorithm
533
542
 
534
543
  Coordinates of the simplified geometry will be no more than the
@@ -663,6 +672,12 @@ class BaseGeometry(object):
663
672
  specified decimal place"""
664
673
  return self.equals_exact(other, 0.5 * 10**(-decimal))
665
674
 
675
+ def relate_pattern(self, other, pattern):
676
+ """Returns True if the DE-9IM string code for the relationship between
677
+ the geometries satisfies the pattern, else False"""
678
+ pattern = c_char_p(pattern.encode('ascii'))
679
+ return bool(self.impl['relate_pattern'](self, other, pattern))
680
+
666
681
  # Linear referencing
667
682
  # ------------------
668
683
 
@@ -828,7 +843,7 @@ class GeometrySequence(object):
828
843
  def __getitem__(self, key):
829
844
  self._update()
830
845
  m = self.__len__()
831
- if isinstance(key, int):
846
+ if isinstance(key, integer_types):
832
847
  if key + m < 0 or key >= m:
833
848
  raise IndexError("index out of range")
834
849
  if key < 0: