shapely 1.2.16__tar.gz → 1.2.17__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.
- {Shapely-1.2.16 → Shapely-1.2.17}/CHANGES.txt +9 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/CREDITS.txt +2 -0
- {Shapely-1.2.16/Shapely.egg-info → Shapely-1.2.17}/PKG-INFO +16 -5
- {Shapely-1.2.16 → Shapely-1.2.17}/README.rst +4 -4
- {Shapely-1.2.16 → Shapely-1.2.17/Shapely.egg-info}/PKG-INFO +16 -5
- {Shapely-1.2.16 → Shapely-1.2.17}/Shapely.egg-info/SOURCES.txt +3 -0
- Shapely-1.2.17/VERSION.txt +1 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/docs/manual.txt +4 -4
- {Shapely-1.2.16 → Shapely-1.2.17}/setup.py +17 -10
- Shapely-1.2.17/shapely/__init__.py +1 -0
- Shapely-1.2.17/shapely/affinity.py +248 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/base.py +39 -7
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/proxy.py +1 -3
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geos.py +1 -1
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/speedups/_speedups.c +1 -1
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/__init__.py +3 -1
- Shapely-1.2.17/shapely/tests/test_affinity.py +239 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_dlls.py +1 -1
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_emptiness.py +5 -0
- Shapely-1.2.17/shapely/tests/test_pickle.py +15 -0
- Shapely-1.2.17/shapely/wkb.py +24 -0
- Shapely-1.2.17/shapely/wkt.py +24 -0
- Shapely-1.2.16/VERSION.txt +0 -1
- Shapely-1.2.16/shapely/__init__.py +0 -1
- Shapely-1.2.16/shapely/wkb.py +0 -38
- Shapely-1.2.16/shapely/wkt.py +0 -34
- {Shapely-1.2.16 → Shapely-1.2.17}/LICENSE.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/Shapely.egg-info/dependency_links.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/Shapely.egg-info/top_level.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/setup.cfg +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/algorithms/__init__.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/algorithms/cga.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/coords.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/ctypes_declarations.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/examples/__init__.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/examples/dissolve.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/examples/geoms.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/examples/intersect.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/examples/world.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/ftools.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/__init__.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/collection.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/geo.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/linestring.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/multilinestring.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/multipoint.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/multipolygon.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/point.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/geometry/polygon.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/impl.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/iterops.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/linref.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/ops.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/predicates.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/prepared.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/speedups/__init__.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/Array.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/GeoInterface.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/IterOps.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/LineString.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/MultiLineString.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/MultiPoint.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/MultiPolygon.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/Operations.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/Persist.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/Point.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/Polygon.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/Predicates.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/attribute-chains.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/binascii_hex.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/cascaded_union.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/dimensions.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/invalid_intersection.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/linemerge.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/polygonize.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_box.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_cga.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_collection.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_delegated.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_doctests.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_equality.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_geomseq.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_getitem.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_linear_referencing.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_mapping.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_ndarrays.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_prepared.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_products_z.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_singularity.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_speedups.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_unary_union.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_validation.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/test_xy.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/threading_test.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/tests/wkt_locale.txt +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/topology.py +0 -0
- {Shapely-1.2.16 → Shapely-1.2.17}/shapely/validation.py +0 -0
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
Changes
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
+
1.2.17 (2013-01-27)
|
|
5
|
+
-------------------
|
|
6
|
+
- Avoid circular import between wkt/wkb and geometry.base by moving calls
|
|
7
|
+
to GEOS serializers to the latter module.
|
|
8
|
+
- Set _ndim when unpickling (issue #6).
|
|
9
|
+
- Don't install DLLs to Python's DLL directory (#37).
|
|
10
|
+
- Add affinity module of affine transformation (#31).
|
|
11
|
+
- Fix NameError that blocked installation with PyPy (#40, #41).
|
|
12
|
+
|
|
4
13
|
1.2.16 (2012-09-18)
|
|
5
14
|
-------------------
|
|
6
15
|
- Add ops.unary_union function.
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: Shapely
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.17
|
|
4
4
|
Summary: Geometric objects, predicates, and operations
|
|
5
5
|
Home-page: https://github.com/Toblerity/Shapely
|
|
6
6
|
Author: Sean Gillies
|
|
7
7
|
Author-email: sean.gillies@gmail.com
|
|
8
8
|
License: BSD
|
|
9
|
-
Description:
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
Description: =======
|
|
10
|
+
Shapely
|
|
11
|
+
=======
|
|
12
12
|
|
|
13
13
|
PostGIS-ish operations outside a database context for Pythoneers and
|
|
14
14
|
Pythonistas.
|
|
15
15
|
|
|
16
|
-
.. image::
|
|
16
|
+
.. image:: http://farm3.staticflickr.com/2738/4511827859_b5822043b7_o_d.png
|
|
17
17
|
:width: 800
|
|
18
18
|
:height: 400
|
|
19
19
|
|
|
@@ -150,6 +150,8 @@ Description: ======
|
|
|
150
150
|
* Jonathan Tartley
|
|
151
151
|
* Kristian Thy
|
|
152
152
|
* Mike Toews (https://github.com/mwtoews)
|
|
153
|
+
* Phil Elson (https://github.com/pelson)
|
|
154
|
+
* Jeethu Rao (https://github.com/jeethu)
|
|
153
155
|
|
|
154
156
|
Additional help from:
|
|
155
157
|
|
|
@@ -168,6 +170,15 @@ Description: ======
|
|
|
168
170
|
Changes
|
|
169
171
|
=======
|
|
170
172
|
|
|
173
|
+
1.2.17 (2013-01-27)
|
|
174
|
+
-------------------
|
|
175
|
+
- Avoid circular import between wkt/wkb and geometry.base by moving calls
|
|
176
|
+
to GEOS serializers to the latter module.
|
|
177
|
+
- Set _ndim when unpickling (issue #6).
|
|
178
|
+
- Don't install DLLs to Python's DLL directory (#37).
|
|
179
|
+
- Add affinity module of affine transformation (#31).
|
|
180
|
+
- Fix NameError that blocked installation with PyPy (#40, #41).
|
|
181
|
+
|
|
171
182
|
1.2.16 (2012-09-18)
|
|
172
183
|
-------------------
|
|
173
184
|
- Add ops.unary_union function.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
=======
|
|
2
|
+
Shapely
|
|
3
|
+
=======
|
|
4
4
|
|
|
5
5
|
PostGIS-ish operations outside a database context for Pythoneers and
|
|
6
6
|
Pythonistas.
|
|
7
7
|
|
|
8
|
-
.. image::
|
|
8
|
+
.. image:: http://farm3.staticflickr.com/2738/4511827859_b5822043b7_o_d.png
|
|
9
9
|
:width: 800
|
|
10
10
|
:height: 400
|
|
11
11
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: Shapely
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.17
|
|
4
4
|
Summary: Geometric objects, predicates, and operations
|
|
5
5
|
Home-page: https://github.com/Toblerity/Shapely
|
|
6
6
|
Author: Sean Gillies
|
|
7
7
|
Author-email: sean.gillies@gmail.com
|
|
8
8
|
License: BSD
|
|
9
|
-
Description:
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
Description: =======
|
|
10
|
+
Shapely
|
|
11
|
+
=======
|
|
12
12
|
|
|
13
13
|
PostGIS-ish operations outside a database context for Pythoneers and
|
|
14
14
|
Pythonistas.
|
|
15
15
|
|
|
16
|
-
.. image::
|
|
16
|
+
.. image:: http://farm3.staticflickr.com/2738/4511827859_b5822043b7_o_d.png
|
|
17
17
|
:width: 800
|
|
18
18
|
:height: 400
|
|
19
19
|
|
|
@@ -150,6 +150,8 @@ Description: ======
|
|
|
150
150
|
* Jonathan Tartley
|
|
151
151
|
* Kristian Thy
|
|
152
152
|
* Mike Toews (https://github.com/mwtoews)
|
|
153
|
+
* Phil Elson (https://github.com/pelson)
|
|
154
|
+
* Jeethu Rao (https://github.com/jeethu)
|
|
153
155
|
|
|
154
156
|
Additional help from:
|
|
155
157
|
|
|
@@ -168,6 +170,15 @@ Description: ======
|
|
|
168
170
|
Changes
|
|
169
171
|
=======
|
|
170
172
|
|
|
173
|
+
1.2.17 (2013-01-27)
|
|
174
|
+
-------------------
|
|
175
|
+
- Avoid circular import between wkt/wkb and geometry.base by moving calls
|
|
176
|
+
to GEOS serializers to the latter module.
|
|
177
|
+
- Set _ndim when unpickling (issue #6).
|
|
178
|
+
- Don't install DLLs to Python's DLL directory (#37).
|
|
179
|
+
- Add affinity module of affine transformation (#31).
|
|
180
|
+
- Fix NameError that blocked installation with PyPy (#40, #41).
|
|
181
|
+
|
|
171
182
|
1.2.16 (2012-09-18)
|
|
172
183
|
-------------------
|
|
173
184
|
- Add ops.unary_union function.
|
|
@@ -11,6 +11,7 @@ Shapely.egg-info/dependency_links.txt
|
|
|
11
11
|
Shapely.egg-info/top_level.txt
|
|
12
12
|
docs/manual.txt
|
|
13
13
|
shapely/__init__.py
|
|
14
|
+
shapely/affinity.py
|
|
14
15
|
shapely/coords.py
|
|
15
16
|
shapely/ctypes_declarations.py
|
|
16
17
|
shapely/ftools.py
|
|
@@ -65,6 +66,7 @@ shapely/tests/dimensions.txt
|
|
|
65
66
|
shapely/tests/invalid_intersection.txt
|
|
66
67
|
shapely/tests/linemerge.txt
|
|
67
68
|
shapely/tests/polygonize.txt
|
|
69
|
+
shapely/tests/test_affinity.py
|
|
68
70
|
shapely/tests/test_box.py
|
|
69
71
|
shapely/tests/test_cga.py
|
|
70
72
|
shapely/tests/test_collection.py
|
|
@@ -78,6 +80,7 @@ shapely/tests/test_getitem.py
|
|
|
78
80
|
shapely/tests/test_linear_referencing.py
|
|
79
81
|
shapely/tests/test_mapping.py
|
|
80
82
|
shapely/tests/test_ndarrays.py
|
|
83
|
+
shapely/tests/test_pickle.py
|
|
81
84
|
shapely/tests/test_prepared.py
|
|
82
85
|
shapely/tests/test_products_z.py
|
|
83
86
|
shapely/tests/test_singularity.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.2.17
|
|
@@ -5,8 +5,8 @@ The Shapely User Manual
|
|
|
5
5
|
=======================
|
|
6
6
|
|
|
7
7
|
:Author: Sean Gillies, <sean.gillies@gmail.com>
|
|
8
|
-
:Revision: 1.2.
|
|
9
|
-
:Date:
|
|
8
|
+
:Revision: 1.2.15
|
|
9
|
+
:Date: 8 July 2012
|
|
10
10
|
:Copyright:
|
|
11
11
|
This work is licensed under a `Creative Commons Attribution 3.0
|
|
12
12
|
United States License`__.
|
|
@@ -646,7 +646,7 @@ Collections of Lines
|
|
|
646
646
|
|
|
647
647
|
Figure 1: On the left, a `simple`, disconnected `MultiLineString`, and on the
|
|
648
648
|
right, a non-simple `MultiLineString`. The points defining the objects are
|
|
649
|
-
|
|
649
|
+
shown in gray, the boundaries of the objects in black.
|
|
650
650
|
|
|
651
651
|
A `MultiLineString` has zero area and non-zero length.
|
|
652
652
|
|
|
@@ -771,7 +771,7 @@ longer empty.
|
|
|
771
771
|
Linear Referencing Methods
|
|
772
772
|
--------------------------
|
|
773
773
|
|
|
774
|
-
It can useful to specify position along linear features such as `LineStrings`
|
|
774
|
+
It can be useful to specify position along linear features such as `LineStrings`
|
|
775
775
|
and `MultiLineStrings` with a 1-dimensional referencing system. Shapely
|
|
776
776
|
supports linear referencing based on length or distance, evaluating the
|
|
777
777
|
distance along a geometric object to the projection of a given point, or the
|
|
@@ -10,12 +10,14 @@ except:
|
|
|
10
10
|
|
|
11
11
|
from distutils.errors import CCompilerError, DistutilsExecError, \
|
|
12
12
|
DistutilsPlatformError
|
|
13
|
+
import errno
|
|
13
14
|
import glob
|
|
14
15
|
import os
|
|
15
16
|
import platform
|
|
16
17
|
from setuptools.extension import Extension
|
|
17
18
|
from setuptools import setup, find_packages
|
|
18
19
|
from setuptools.command.build_ext import build_ext as distutils_build_ext
|
|
20
|
+
import shutil
|
|
19
21
|
import subprocess
|
|
20
22
|
import sys
|
|
21
23
|
|
|
@@ -68,18 +70,23 @@ setup_args = dict(
|
|
|
68
70
|
|
|
69
71
|
# Add DLLs for Windows
|
|
70
72
|
if sys.platform == 'win32':
|
|
73
|
+
try:
|
|
74
|
+
os.mkdir('shapely/DLLs')
|
|
75
|
+
except OSError, ex:
|
|
76
|
+
if ex.errno != errno.EEXIST: raise
|
|
71
77
|
if '(AMD64)' in sys.version:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
78
|
+
for dll in glob.glob('DLLs_AMD64_VC9/*.dll'):
|
|
79
|
+
shutil.copy(dll, 'shapely/DLLs')
|
|
75
80
|
elif platform.python_version().startswith('2.5.'):
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
)
|
|
81
|
+
for dll in glob.glob('DLLs_x86_VC7/*.dll'):
|
|
82
|
+
shutil.copy(dll, 'shapely/DLLs')
|
|
79
83
|
else:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
for dll in glob.glob('DLLs_x86_VC9/*.dll'):
|
|
85
|
+
shutil.copy(dll, 'shapely/DLLs')
|
|
86
|
+
setup_args.update(
|
|
87
|
+
package_data={'shapely': ['shapely/DLLs/*.dll']},
|
|
88
|
+
include_package_data=True,
|
|
89
|
+
)
|
|
83
90
|
|
|
84
91
|
|
|
85
92
|
# Optional compilation of speedups
|
|
@@ -114,7 +121,7 @@ if (hasattr(platform, 'python_implementation')
|
|
|
114
121
|
and platform.python_implementation() == 'PyPy'):
|
|
115
122
|
# python_implementation is only available since 2.6
|
|
116
123
|
ext_modules = []
|
|
117
|
-
|
|
124
|
+
libraries = []
|
|
118
125
|
elif sys.platform == 'win32':
|
|
119
126
|
libraries = ['geos']
|
|
120
127
|
else:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.2.17"
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""Affine transforms, both in general and specific, named transforms."""
|
|
2
|
+
|
|
3
|
+
from math import sin, cos, tan, pi
|
|
4
|
+
|
|
5
|
+
__all__ = ['affine_transform', 'rotate', 'scale', 'skew', 'translate']
|
|
6
|
+
|
|
7
|
+
def affine_transform(geom, matrix):
|
|
8
|
+
"""Return a transformed geometry using an affine transformation matrix.
|
|
9
|
+
|
|
10
|
+
The coefficient matrix is provided as a list or tuple with 6 or 12 items
|
|
11
|
+
for 2D or 3D transformations, respectively.
|
|
12
|
+
|
|
13
|
+
For 2D affine transformations, the 6 parameter matrix is:
|
|
14
|
+
|
|
15
|
+
[a, b, d, e, xoff, yoff]
|
|
16
|
+
|
|
17
|
+
which represents the augmented matrix:
|
|
18
|
+
|
|
19
|
+
/ a b xoff \
|
|
20
|
+
[x' y' 1] = [x y 1] | d e yoff |
|
|
21
|
+
\ 0 0 1 /
|
|
22
|
+
|
|
23
|
+
or the equations for the transformed coordinates:
|
|
24
|
+
|
|
25
|
+
x' = a * x + b * y + xoff
|
|
26
|
+
y' = d * x + e * y + yoff
|
|
27
|
+
|
|
28
|
+
For 3D affine transformations, the 12 parameter matrix is:
|
|
29
|
+
|
|
30
|
+
[a, b, c, d, e, f, g, h, i, xoff, yoff, zoff]
|
|
31
|
+
|
|
32
|
+
which represents the augmented matrix:
|
|
33
|
+
|
|
34
|
+
/ a b c xoff \
|
|
35
|
+
[x' y' z' 1] = [x y z 1] | d e f yoff |
|
|
36
|
+
| g h i zoff |
|
|
37
|
+
\ 0 0 0 1 /
|
|
38
|
+
|
|
39
|
+
or the equations for the transformed coordinates:
|
|
40
|
+
|
|
41
|
+
x' = a * x + b * y + c * z + xoff
|
|
42
|
+
y' = d * x + e * y + f * z + yoff
|
|
43
|
+
z' = g * x + h * y + i * z + zoff
|
|
44
|
+
"""
|
|
45
|
+
if len(matrix) == 6:
|
|
46
|
+
ndim = 2
|
|
47
|
+
a, b, d, e, xoff, yoff = matrix
|
|
48
|
+
if geom.has_z:
|
|
49
|
+
ndim = 3
|
|
50
|
+
i = 1.0
|
|
51
|
+
c = f = g = h = zoff = 0.0
|
|
52
|
+
matrix = a, b, c, d, e, f, g, h, i, xoff, yoff, zoff
|
|
53
|
+
elif len(matrix) == 12:
|
|
54
|
+
ndim = 3
|
|
55
|
+
a, b, c, d, e, f, g, h, i, xoff, yoff, zoff = matrix
|
|
56
|
+
if not geom.has_z:
|
|
57
|
+
ndim = 2
|
|
58
|
+
matrix = a, b, d, e, xoff, yoff
|
|
59
|
+
else:
|
|
60
|
+
raise ValueError("`matrix` expects either 6 or 12 coefficients")
|
|
61
|
+
|
|
62
|
+
def affine_pts(pts):
|
|
63
|
+
"""Internal function to yield affine transform of coordinate tuples"""
|
|
64
|
+
if ndim == 2:
|
|
65
|
+
for x, y in pts:
|
|
66
|
+
xp = a * x + b * y + xoff
|
|
67
|
+
yp = d * x + e * y + yoff
|
|
68
|
+
yield (xp, yp)
|
|
69
|
+
elif ndim == 3:
|
|
70
|
+
for x, y, z in pts:
|
|
71
|
+
xp = a * x + b * y + c * z + xoff
|
|
72
|
+
yp = d * x + e * y + f * z + yoff
|
|
73
|
+
zp = g * x + h * y + i * z + zoff
|
|
74
|
+
yield (xp, yp, zp)
|
|
75
|
+
|
|
76
|
+
# Process coordinates from each supported geometry type
|
|
77
|
+
if geom.type in ('Point', 'LineString'):
|
|
78
|
+
return type(geom)(list(affine_pts(geom.coords)))
|
|
79
|
+
elif geom.type == 'Polygon':
|
|
80
|
+
ring = geom.exterior
|
|
81
|
+
shell = type(ring)(list(affine_pts(ring.coords)))
|
|
82
|
+
holes = list(geom.interiors)
|
|
83
|
+
for pos, ring in enumerate(holes):
|
|
84
|
+
holes[pos] = type(ring)(list(affine_pts(ring.coords)))
|
|
85
|
+
return type(geom)(shell, holes)
|
|
86
|
+
elif geom.type.startswith('Multi') or geom.type == 'GeometryCollection':
|
|
87
|
+
# Recursive call
|
|
88
|
+
# TODO: fix GeometryCollection constructor
|
|
89
|
+
return type(geom)([affine_transform(part, matrix) for part in geom.geoms])
|
|
90
|
+
else:
|
|
91
|
+
raise ValueError('Type %r not recognized'%geom.type)
|
|
92
|
+
|
|
93
|
+
def interpret_origin(geom, origin, ndim):
|
|
94
|
+
"""Return interpreted coordinate tuple for origin parameter.
|
|
95
|
+
|
|
96
|
+
This is a helper function for other transform functions.
|
|
97
|
+
|
|
98
|
+
The point of origin can be a keyword 'center' for the 2D bounding box
|
|
99
|
+
center, 'centroid' for the geometry's 2D centroid, a Point object or a
|
|
100
|
+
coordinate tuple (x0, y0, z0).
|
|
101
|
+
"""
|
|
102
|
+
# get coordinate tuple from `origin` from keyword or Point type
|
|
103
|
+
if origin == 'center':
|
|
104
|
+
# bounding box center
|
|
105
|
+
minx, miny, maxx, maxy = geom.bounds
|
|
106
|
+
origin = ((maxx + minx)/2.0, (maxy + miny)/2.0)
|
|
107
|
+
elif origin == 'centroid':
|
|
108
|
+
origin = geom.centroid.coords[0]
|
|
109
|
+
elif isinstance(origin, str):
|
|
110
|
+
raise ValueError('`origin` keyword %r is not recognized'%origin)
|
|
111
|
+
elif hasattr(origin, 'type') and origin.type == 'Point':
|
|
112
|
+
origin = origin.coords[0]
|
|
113
|
+
|
|
114
|
+
# origin should now be tuple-like
|
|
115
|
+
if len(origin) not in (2, 3):
|
|
116
|
+
raise ValueError('Expected number of items in `origin` to be '\
|
|
117
|
+
'either 2 or 3')
|
|
118
|
+
if ndim == 2:
|
|
119
|
+
return origin[0:2]
|
|
120
|
+
else: # 3D coordinate
|
|
121
|
+
if len(origin) == 2:
|
|
122
|
+
return origin + (0.0,)
|
|
123
|
+
else:
|
|
124
|
+
return origin
|
|
125
|
+
|
|
126
|
+
def rotate(geom, angle, origin='center', use_radians=False):
|
|
127
|
+
"""Return a rotated geometry on a 2D plane.
|
|
128
|
+
|
|
129
|
+
The angle of rotation can be specified in either degrees (default) or
|
|
130
|
+
radians by setting `use_radians=True`. Positive angles are
|
|
131
|
+
counter-clockwise and negative are clockwise rotations.
|
|
132
|
+
|
|
133
|
+
The point of origin can be a keyword 'center' for the bounding box
|
|
134
|
+
center (default), 'centroid' for the geometry's centroid, a Point object
|
|
135
|
+
or a coordinate tuple (x0, y0).
|
|
136
|
+
|
|
137
|
+
The transformation matrix for 2D rotation is:
|
|
138
|
+
|
|
139
|
+
/ cos(r) -sin(r) xoff \
|
|
140
|
+
| sin(r) cos(r) yoff |
|
|
141
|
+
\ 0 0 1 /
|
|
142
|
+
|
|
143
|
+
where the offsets are calculated from the origin Point(x0, y0):
|
|
144
|
+
|
|
145
|
+
xoff = x0 - x0 * cos(r) + y0 * sin(r)
|
|
146
|
+
yoff = y0 - x0 * sin(r) - y0 * cos(r)
|
|
147
|
+
"""
|
|
148
|
+
if not use_radians: # convert from degrees
|
|
149
|
+
angle *= pi/180.0
|
|
150
|
+
cosp = cos(angle)
|
|
151
|
+
sinp = sin(angle)
|
|
152
|
+
if abs(cosp) < 2.5e-16:
|
|
153
|
+
cosp = 0.0
|
|
154
|
+
if abs(sinp) < 2.5e-16:
|
|
155
|
+
sinp = 0.0
|
|
156
|
+
x0, y0 = interpret_origin(geom, origin, 2)
|
|
157
|
+
|
|
158
|
+
matrix = (cosp, -sinp, 0.0,
|
|
159
|
+
sinp, cosp, 0.0,
|
|
160
|
+
0.0, 0.0, 1.0,
|
|
161
|
+
x0 - x0 * cosp + y0 * sinp, y0 - x0 * sinp - y0 * cosp, 0.0)
|
|
162
|
+
return affine_transform(geom, matrix)
|
|
163
|
+
|
|
164
|
+
def scale(geom, xfact=1.0, yfact=1.0, zfact=1.0, origin='center'):
|
|
165
|
+
"""Return a scaled geometry, scaled by factors along each dimension.
|
|
166
|
+
|
|
167
|
+
The point of origin can be a keyword 'center' for the 2D bounding box
|
|
168
|
+
center (default), 'centroid' for the geometry's 2D centroid, a Point
|
|
169
|
+
object or a coordinate tuple (x0, y0, z0).
|
|
170
|
+
|
|
171
|
+
Negative scale factors will mirror or reflect coordinates.
|
|
172
|
+
|
|
173
|
+
The general 3D affine transformation matrix for scaling is:
|
|
174
|
+
|
|
175
|
+
/ xfact 0 0 xoff \
|
|
176
|
+
| 0 yfact 0 yoff |
|
|
177
|
+
| 0 0 zfact zoff |
|
|
178
|
+
\ 0 0 0 1 /
|
|
179
|
+
|
|
180
|
+
where the offsets are calculated from the origin Point(x0, y0, z0):
|
|
181
|
+
|
|
182
|
+
xoff = x0 - x0 * xfact
|
|
183
|
+
yoff = y0 - y0 * yfact
|
|
184
|
+
zoff = z0 - z0 * zfact
|
|
185
|
+
"""
|
|
186
|
+
x0, y0, z0 = interpret_origin(geom, origin, 3)
|
|
187
|
+
|
|
188
|
+
matrix = (xfact, 0.0, 0.0,
|
|
189
|
+
0.0, yfact, 0.0,
|
|
190
|
+
0.0, 0.0, zfact,
|
|
191
|
+
x0 - x0 * xfact, y0 - y0 * yfact, z0 - z0 * zfact)
|
|
192
|
+
return affine_transform(geom, matrix)
|
|
193
|
+
|
|
194
|
+
def skew(geom, xs=0.0, ys=0.0, origin='center', use_radians=False):
|
|
195
|
+
"""Return a skewed geometry, sheared by angles along x and y dimensions.
|
|
196
|
+
|
|
197
|
+
The shear angle can be specified in either degrees (default) or radians
|
|
198
|
+
by setting `use_radians=True`.
|
|
199
|
+
|
|
200
|
+
The point of origin can be a keyword 'center' for the bounding box
|
|
201
|
+
center (default), 'centroid' for the geometry's centroid, a Point object
|
|
202
|
+
or a coordinate tuple (x0, y0).
|
|
203
|
+
|
|
204
|
+
The general 2D affine transformation matrix for skewing is:
|
|
205
|
+
|
|
206
|
+
/ 1 tan(xs) xoff \
|
|
207
|
+
| tan(ys) 1 yoff |
|
|
208
|
+
\ 0 0 1 /
|
|
209
|
+
|
|
210
|
+
where the offsets are calculated from the origin Point(x0, y0):
|
|
211
|
+
|
|
212
|
+
xoff = -y0 * tan(xs)
|
|
213
|
+
yoff = -x0 * tan(ys)
|
|
214
|
+
"""
|
|
215
|
+
if not use_radians: # convert from degrees
|
|
216
|
+
xs *= pi/180.0
|
|
217
|
+
ys *= pi/180.0
|
|
218
|
+
tanx = tan(xs)
|
|
219
|
+
tany = tan(ys)
|
|
220
|
+
if abs(tanx) < 2.5e-16:
|
|
221
|
+
tanx = 0.0
|
|
222
|
+
if abs(tany) < 2.5e-16:
|
|
223
|
+
tany = 0.0
|
|
224
|
+
x0, y0 = interpret_origin(geom, origin, 2)
|
|
225
|
+
|
|
226
|
+
matrix = (1.0, tanx, 0.0,
|
|
227
|
+
tany, 1.0, 0.0,
|
|
228
|
+
0.0, 0.0, 1.0,
|
|
229
|
+
-y0 * tanx, -x0 * tany, 0.0)
|
|
230
|
+
return affine_transform(geom, matrix)
|
|
231
|
+
|
|
232
|
+
def translate(geom, xoff=0.0, yoff=0.0, zoff=0.0):
|
|
233
|
+
"""Return a translated geometry shifted by offsets along each dimension.
|
|
234
|
+
|
|
235
|
+
The general 3D affine transformation matrix for translation is:
|
|
236
|
+
|
|
237
|
+
/ 1 0 0 xoff \
|
|
238
|
+
| 0 1 0 yoff |
|
|
239
|
+
| 0 0 1 zoff |
|
|
240
|
+
\ 0 0 0 1 /
|
|
241
|
+
"""
|
|
242
|
+
matrix = (1.0, 0.0, 0.0,
|
|
243
|
+
0.0, 1.0, 0.0,
|
|
244
|
+
0.0, 0.0, 1.0,
|
|
245
|
+
xoff, yoff, zoff)
|
|
246
|
+
return affine_transform(geom, matrix)
|
|
247
|
+
|
|
248
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"""Base geometry class and utilities
|
|
2
2
|
"""
|
|
3
3
|
|
|
4
|
+
from ctypes import pointer, c_size_t, c_char_p, c_void_p
|
|
4
5
|
import sys
|
|
5
6
|
import warnings
|
|
6
7
|
|
|
7
8
|
from shapely.coords import CoordinateSequence
|
|
8
9
|
from shapely.ftools import wraps
|
|
9
|
-
from shapely.geos import lgeos
|
|
10
|
+
from shapely.geos import lgeos, ReadingError
|
|
10
11
|
from shapely.impl import DefaultImplementation, delegated
|
|
11
|
-
from shapely import wkb, wkt
|
|
12
12
|
|
|
13
13
|
GEOMETRY_TYPES = [
|
|
14
14
|
'Point',
|
|
@@ -48,6 +48,34 @@ def geom_factory(g, parent=None):
|
|
|
48
48
|
ob._ndim = 2
|
|
49
49
|
return ob
|
|
50
50
|
|
|
51
|
+
def geom_from_wkt(data):
|
|
52
|
+
geom = lgeos.GEOSGeomFromWKT(c_char_p(data))
|
|
53
|
+
if not geom:
|
|
54
|
+
raise ReadingError, \
|
|
55
|
+
"Could not create geometry because of errors while reading input."
|
|
56
|
+
return geom_factory(geom)
|
|
57
|
+
|
|
58
|
+
def geom_to_wkt(ob):
|
|
59
|
+
if ob is None or ob._geom is None:
|
|
60
|
+
raise ValueError("Null geometry supports no operations")
|
|
61
|
+
return lgeos.GEOSGeomToWKT(ob._geom)
|
|
62
|
+
|
|
63
|
+
def deserialize_wkb(data):
|
|
64
|
+
geom = lgeos.GEOSGeomFromWKB_buf(c_char_p(data), c_size_t(len(data)));
|
|
65
|
+
if not geom:
|
|
66
|
+
raise ReadingError(
|
|
67
|
+
"Could not create geometry because of errors while reading input.")
|
|
68
|
+
return geom
|
|
69
|
+
|
|
70
|
+
def geom_from_wkb(data):
|
|
71
|
+
return geom_factory(deserialize_wkb(data))
|
|
72
|
+
|
|
73
|
+
def geom_to_wkb(ob):
|
|
74
|
+
if ob is None or ob._geom is None:
|
|
75
|
+
raise ValueError("Null geometry supports no operations")
|
|
76
|
+
size = c_size_t()
|
|
77
|
+
return lgeos.GEOSGeomToWKB_buf(c_void_p(ob._geom), pointer(size))
|
|
78
|
+
|
|
51
79
|
def exceptNull(func):
|
|
52
80
|
"""Decorator which helps avoid GEOS operations on null pointers."""
|
|
53
81
|
@wraps(func)
|
|
@@ -57,7 +85,7 @@ def exceptNull(func):
|
|
|
57
85
|
return func(*args, **kwargs)
|
|
58
86
|
return wrapper
|
|
59
87
|
|
|
60
|
-
EMPTY =
|
|
88
|
+
EMPTY = deserialize_wkb('010700000000000000'.decode('hex'))
|
|
61
89
|
|
|
62
90
|
class BaseGeometry(object):
|
|
63
91
|
"""
|
|
@@ -124,7 +152,11 @@ class BaseGeometry(object):
|
|
|
124
152
|
|
|
125
153
|
def __setstate__(self, state):
|
|
126
154
|
self.empty()
|
|
127
|
-
self.__geom__ =
|
|
155
|
+
self.__geom__ = deserialize_wkb(state)
|
|
156
|
+
if lgeos.methods['has_z'](self.__geom__):
|
|
157
|
+
self._ndim = 3
|
|
158
|
+
else:
|
|
159
|
+
self._ndim = 2
|
|
128
160
|
|
|
129
161
|
# The _geom property
|
|
130
162
|
def _get_geom(self):
|
|
@@ -200,10 +232,10 @@ class BaseGeometry(object):
|
|
|
200
232
|
return self.geometryType()
|
|
201
233
|
|
|
202
234
|
def to_wkb(self):
|
|
203
|
-
return
|
|
235
|
+
return geom_to_wkb(self)
|
|
204
236
|
|
|
205
237
|
def to_wkt(self):
|
|
206
|
-
return
|
|
238
|
+
return geom_to_wkt(self)
|
|
207
239
|
|
|
208
240
|
geom_type = property(geometryType,
|
|
209
241
|
doc="""Name of the geometry's type, such as 'Point'"""
|
|
@@ -354,7 +386,7 @@ class BaseGeometry(object):
|
|
|
354
386
|
@property
|
|
355
387
|
def is_empty(self):
|
|
356
388
|
"""True if the set of points in this geometry is empty, else False"""
|
|
357
|
-
return bool(self.impl['is_empty'](self))
|
|
389
|
+
return (self._geom is None) or bool(self.impl['is_empty'](self))
|
|
358
390
|
|
|
359
391
|
@property
|
|
360
392
|
def is_ring(self):
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"""Proxy for coordinates stored outside Shapely geometries
|
|
2
2
|
"""
|
|
3
3
|
|
|
4
|
+
from shapely.geometry.base import deserialize_wkb, EMPTY
|
|
4
5
|
from shapely.geos import lgeos
|
|
5
|
-
from shapely import wkb
|
|
6
|
-
|
|
7
|
-
EMPTY = wkb.deserialize('010700000000000000'.decode('hex'))
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
class CachingGeometryProxy(object):
|
|
@@ -64,7 +64,7 @@ elif sys.platform == 'darwin':
|
|
|
64
64
|
elif sys.platform == 'win32':
|
|
65
65
|
try:
|
|
66
66
|
egg_dlls = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
|
67
|
-
r"
|
|
67
|
+
r"DLLs"))
|
|
68
68
|
wininst_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
|
|
69
69
|
original_path = os.environ['PATH']
|
|
70
70
|
os.environ['PATH'] = "%s;%s;%s" % (egg_dlls, wininst_dlls, original_path)
|
|
@@ -4,7 +4,7 @@ import test_doctests, test_prepared, test_equality, test_geomseq, test_xy
|
|
|
4
4
|
import test_collection, test_emptiness, test_singularity, test_validation
|
|
5
5
|
import test_mapping, test_delegated, test_dlls, test_linear_referencing
|
|
6
6
|
import test_products_z, test_box, test_speedups, test_cga, test_getitem
|
|
7
|
-
import test_ndarrays, test_unary_union
|
|
7
|
+
import test_ndarrays, test_unary_union, test_pickle, test_affinity
|
|
8
8
|
|
|
9
9
|
def test_suite():
|
|
10
10
|
suite = TestSuite()
|
|
@@ -28,5 +28,7 @@ def test_suite():
|
|
|
28
28
|
suite.addTest(test_getitem.test_suite())
|
|
29
29
|
suite.addTest(test_ndarrays.test_suite())
|
|
30
30
|
suite.addTest(test_unary_union.test_suite())
|
|
31
|
+
suite.addTest(test_pickle.test_suite())
|
|
32
|
+
suite.addTest(test_affinity.test_suite())
|
|
31
33
|
return suite
|
|
32
34
|
|