shapely 1.2.13__py2.7-win-amd64.egg → 1.2.18__py2.7-win-amd64.egg
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.
- EGG-INFO/PKG-INFO +452 -377
- EGG-INFO/SOURCES.txt +96 -0
- EGG-INFO/dependency_links.txt +1 -0
- EGG-INFO/native_libs.txt +2 -0
- EGG-INFO/not-zip-safe +1 -1
- EGG-INFO/top_level.txt +1 -0
- shapely/DLLs/geos.dll +0 -0
- shapely/DLLs/geos_c.dll +0 -0
- shapely/__init__.py +1 -2
- shapely/__init__.pyc +0 -0
- shapely/affinity.py +252 -0
- shapely/affinity.pyc +0 -0
- shapely/algorithms/__init__.pyc +0 -0
- shapely/algorithms/cga.pyc +0 -0
- shapely/coords.py +53 -21
- shapely/coords.pyc +0 -0
- shapely/ctypes_declarations.py +16 -3
- shapely/ctypes_declarations.pyc +0 -0
- shapely/examples/__init__.pyc +0 -0
- shapely/examples/dissolve.pyc +0 -0
- shapely/examples/geoms.pyc +0 -0
- shapely/examples/intersect.pyc +0 -0
- shapely/examples/world.pyc +0 -0
- shapely/ftools.pyc +0 -0
- shapely/geometry/__init__.py +4 -4
- shapely/geometry/__init__.pyc +0 -0
- shapely/geometry/base.py +155 -54
- shapely/geometry/base.pyc +0 -0
- shapely/geometry/collection.pyc +0 -0
- shapely/geometry/geo.py +2 -2
- shapely/geometry/geo.pyc +0 -0
- shapely/geometry/linestring.py +24 -19
- shapely/geometry/linestring.pyc +0 -0
- shapely/geometry/multilinestring.py +2 -2
- shapely/geometry/multilinestring.pyc +0 -0
- shapely/geometry/multipoint.py +4 -0
- shapely/geometry/multipoint.pyc +0 -0
- shapely/geometry/multipolygon.py +8 -5
- shapely/geometry/multipolygon.pyc +0 -0
- shapely/geometry/point.py +7 -0
- shapely/geometry/point.pyc +0 -0
- shapely/geometry/polygon.py +28 -9
- shapely/geometry/polygon.pyc +0 -0
- shapely/geometry/proxy.py +1 -3
- shapely/geometry/proxy.pyc +0 -0
- shapely/geos.py +45 -14
- shapely/geos.pyc +0 -0
- shapely/impl.py +8 -5
- shapely/impl.pyc +0 -0
- shapely/iterops.pyc +0 -0
- shapely/linref.pyc +0 -0
- shapely/ops.py +125 -3
- shapely/ops.pyc +0 -0
- shapely/predicates.pyc +0 -0
- shapely/prepared.pyc +0 -0
- shapely/speedups/__init__.pyc +0 -0
- shapely/speedups/_speedups.c +5201 -0
- shapely/speedups/_speedups.pyc +0 -0
- shapely/speedups/_speedups.pyd +0 -0
- shapely/tests/Array.txt +86 -0
- shapely/tests/GeoInterface.txt +69 -0
- shapely/tests/IterOps.txt +31 -0
- shapely/tests/LineString.txt +134 -0
- shapely/tests/MultiLineString.txt +81 -0
- shapely/tests/MultiPoint.txt +101 -0
- shapely/tests/MultiPolygon.txt +71 -0
- shapely/tests/Operations.txt +89 -0
- shapely/tests/Operators.txt +18 -0
- shapely/tests/Persist.txt +35 -0
- shapely/tests/Point.txt +148 -0
- shapely/tests/Polygon.txt +143 -0
- shapely/tests/Predicates.txt +51 -0
- shapely/tests/__init__.py +10 -1
- shapely/tests/__init__.pyc +0 -0
- shapely/tests/attribute-chains.txt +38 -0
- shapely/tests/binascii_hex.txt +47 -0
- shapely/tests/cascaded_union.txt +26 -0
- shapely/tests/dimensions.txt +17 -0
- shapely/tests/invalid_intersection.txt +29 -0
- shapely/tests/linemerge.txt +61 -0
- shapely/tests/polygonize.txt +40 -0
- shapely/tests/test_affinity.py +239 -0
- shapely/tests/test_affinity.pyc +0 -0
- shapely/tests/test_box.pyc +0 -0
- shapely/tests/test_cga.pyc +0 -0
- shapely/tests/test_collection.py +15 -0
- shapely/tests/test_collection.pyc +0 -0
- shapely/tests/test_delegated.pyc +0 -0
- shapely/tests/test_dlls.py +1 -1
- shapely/tests/test_dlls.pyc +0 -0
- shapely/tests/test_doctests.pyc +0 -0
- shapely/tests/test_emptiness.py +41 -8
- shapely/tests/test_emptiness.pyc +0 -0
- shapely/tests/test_equality.pyc +0 -0
- shapely/tests/test_geomseq.pyc +0 -0
- shapely/tests/test_getitem.py +113 -0
- shapely/tests/test_getitem.pyc +0 -0
- shapely/tests/test_linear_referencing.pyc +0 -0
- shapely/tests/test_mapping.pyc +0 -0
- shapely/tests/test_ndarrays.py +35 -0
- shapely/tests/test_ndarrays.pyc +0 -0
- shapely/tests/test_pickle.py +15 -0
- shapely/tests/test_pickle.pyc +0 -0
- shapely/tests/test_prepared.pyc +0 -0
- shapely/tests/test_products_z.pyc +0 -0
- shapely/tests/test_singularity.pyc +0 -0
- shapely/tests/test_speedups.pyc +0 -0
- shapely/tests/test_styles.py +17 -0
- shapely/tests/test_styles.pyc +0 -0
- shapely/tests/test_transform.py +61 -0
- shapely/tests/test_transform.pyc +0 -0
- shapely/tests/test_unary_union.py +40 -0
- shapely/tests/test_unary_union.pyc +0 -0
- shapely/tests/test_validation.pyc +0 -0
- shapely/tests/test_xy.pyc +0 -0
- shapely/tests/threading_test.pyc +0 -0
- shapely/tests/wkt_locale.txt +28 -0
- shapely/topology.pyc +0 -0
- shapely/validation.pyc +0 -0
- shapely/wkb.py +3 -17
- shapely/wkb.pyc +0 -0
- shapely/wkt.py +3 -13
- shapely/wkt.pyc +0 -0
- DLLs/geos.dll +0 -0
- DLLs/geos_c.dll +0 -0
EGG-INFO/SOURCES.txt
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
CHANGES.txt
|
|
2
|
+
CREDITS.txt
|
|
3
|
+
LICENSE.txt
|
|
4
|
+
README.rst
|
|
5
|
+
VERSION.txt
|
|
6
|
+
setup.cfg
|
|
7
|
+
setup.py
|
|
8
|
+
Shapely.egg-info/PKG-INFO
|
|
9
|
+
Shapely.egg-info/SOURCES.txt
|
|
10
|
+
Shapely.egg-info/dependency_links.txt
|
|
11
|
+
Shapely.egg-info/top_level.txt
|
|
12
|
+
docs/manual.txt
|
|
13
|
+
shapely/__init__.py
|
|
14
|
+
shapely/affinity.py
|
|
15
|
+
shapely/coords.py
|
|
16
|
+
shapely/ctypes_declarations.py
|
|
17
|
+
shapely/ftools.py
|
|
18
|
+
shapely/geos.py
|
|
19
|
+
shapely/impl.py
|
|
20
|
+
shapely/iterops.py
|
|
21
|
+
shapely/linref.py
|
|
22
|
+
shapely/ops.py
|
|
23
|
+
shapely/predicates.py
|
|
24
|
+
shapely/prepared.py
|
|
25
|
+
shapely/topology.py
|
|
26
|
+
shapely/validation.py
|
|
27
|
+
shapely/wkb.py
|
|
28
|
+
shapely/wkt.py
|
|
29
|
+
shapely/speedups/_speedups.c
|
|
30
|
+
shapely/algorithms/__init__.py
|
|
31
|
+
shapely/algorithms/cga.py
|
|
32
|
+
shapely/examples/__init__.py
|
|
33
|
+
shapely/examples/dissolve.py
|
|
34
|
+
shapely/examples/geoms.py
|
|
35
|
+
shapely/examples/intersect.py
|
|
36
|
+
shapely/examples/world.py
|
|
37
|
+
shapely/geometry/__init__.py
|
|
38
|
+
shapely/geometry/base.py
|
|
39
|
+
shapely/geometry/collection.py
|
|
40
|
+
shapely/geometry/geo.py
|
|
41
|
+
shapely/geometry/linestring.py
|
|
42
|
+
shapely/geometry/multilinestring.py
|
|
43
|
+
shapely/geometry/multipoint.py
|
|
44
|
+
shapely/geometry/multipolygon.py
|
|
45
|
+
shapely/geometry/point.py
|
|
46
|
+
shapely/geometry/polygon.py
|
|
47
|
+
shapely/geometry/proxy.py
|
|
48
|
+
shapely/speedups/__init__.py
|
|
49
|
+
shapely/speedups/_speedups.c
|
|
50
|
+
shapely/tests/Array.txt
|
|
51
|
+
shapely/tests/GeoInterface.txt
|
|
52
|
+
shapely/tests/IterOps.txt
|
|
53
|
+
shapely/tests/LineString.txt
|
|
54
|
+
shapely/tests/MultiLineString.txt
|
|
55
|
+
shapely/tests/MultiPoint.txt
|
|
56
|
+
shapely/tests/MultiPolygon.txt
|
|
57
|
+
shapely/tests/Operations.txt
|
|
58
|
+
shapely/tests/Operators.txt
|
|
59
|
+
shapely/tests/Persist.txt
|
|
60
|
+
shapely/tests/Point.txt
|
|
61
|
+
shapely/tests/Polygon.txt
|
|
62
|
+
shapely/tests/Predicates.txt
|
|
63
|
+
shapely/tests/__init__.py
|
|
64
|
+
shapely/tests/attribute-chains.txt
|
|
65
|
+
shapely/tests/binascii_hex.txt
|
|
66
|
+
shapely/tests/cascaded_union.txt
|
|
67
|
+
shapely/tests/dimensions.txt
|
|
68
|
+
shapely/tests/invalid_intersection.txt
|
|
69
|
+
shapely/tests/linemerge.txt
|
|
70
|
+
shapely/tests/polygonize.txt
|
|
71
|
+
shapely/tests/test_affinity.py
|
|
72
|
+
shapely/tests/test_box.py
|
|
73
|
+
shapely/tests/test_cga.py
|
|
74
|
+
shapely/tests/test_collection.py
|
|
75
|
+
shapely/tests/test_delegated.py
|
|
76
|
+
shapely/tests/test_dlls.py
|
|
77
|
+
shapely/tests/test_doctests.py
|
|
78
|
+
shapely/tests/test_emptiness.py
|
|
79
|
+
shapely/tests/test_equality.py
|
|
80
|
+
shapely/tests/test_geomseq.py
|
|
81
|
+
shapely/tests/test_getitem.py
|
|
82
|
+
shapely/tests/test_linear_referencing.py
|
|
83
|
+
shapely/tests/test_mapping.py
|
|
84
|
+
shapely/tests/test_ndarrays.py
|
|
85
|
+
shapely/tests/test_pickle.py
|
|
86
|
+
shapely/tests/test_prepared.py
|
|
87
|
+
shapely/tests/test_products_z.py
|
|
88
|
+
shapely/tests/test_singularity.py
|
|
89
|
+
shapely/tests/test_speedups.py
|
|
90
|
+
shapely/tests/test_styles.py
|
|
91
|
+
shapely/tests/test_transform.py
|
|
92
|
+
shapely/tests/test_unary_union.py
|
|
93
|
+
shapely/tests/test_validation.py
|
|
94
|
+
shapely/tests/test_xy.py
|
|
95
|
+
shapely/tests/threading_test.py
|
|
96
|
+
shapely/tests/wkt_locale.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
EGG-INFO/native_libs.txt
CHANGED
EGG-INFO/not-zip-safe
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
EGG-INFO/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
shapely
|
shapely/DLLs/geos.dll
ADDED
|
Binary file
|
shapely/DLLs/geos_c.dll
ADDED
|
Binary file
|
shapely/__init__.py
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
__version__ = "1.2.
|
|
2
|
-
|
|
1
|
+
__version__ = "1.2.18"
|
shapely/__init__.pyc
CHANGED
|
Binary file
|
shapely/affinity.py
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
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
|
+
|
|
8
|
+
def affine_transform(geom, matrix):
|
|
9
|
+
"""Returns a transformed geometry using an affine transformation matrix.
|
|
10
|
+
|
|
11
|
+
The coefficient matrix is provided as a list or tuple with 6 or 12 items
|
|
12
|
+
for 2D or 3D transformations, respectively.
|
|
13
|
+
|
|
14
|
+
For 2D affine transformations, the 6 parameter matrix is:
|
|
15
|
+
|
|
16
|
+
[a, b, d, e, xoff, yoff]
|
|
17
|
+
|
|
18
|
+
which represents the augmented matrix:
|
|
19
|
+
|
|
20
|
+
/ a b xoff \
|
|
21
|
+
[x' y' 1] = [x y 1] | d e yoff |
|
|
22
|
+
\ 0 0 1 /
|
|
23
|
+
|
|
24
|
+
or the equations for the transformed coordinates:
|
|
25
|
+
|
|
26
|
+
x' = a * x + b * y + xoff
|
|
27
|
+
y' = d * x + e * y + yoff
|
|
28
|
+
|
|
29
|
+
For 3D affine transformations, the 12 parameter matrix is:
|
|
30
|
+
|
|
31
|
+
[a, b, c, d, e, f, g, h, i, xoff, yoff, zoff]
|
|
32
|
+
|
|
33
|
+
which represents the augmented matrix:
|
|
34
|
+
|
|
35
|
+
/ a b c xoff \
|
|
36
|
+
[x' y' z' 1] = [x y z 1] | d e f yoff |
|
|
37
|
+
| g h i zoff |
|
|
38
|
+
\ 0 0 0 1 /
|
|
39
|
+
|
|
40
|
+
or the equations for the transformed coordinates:
|
|
41
|
+
|
|
42
|
+
x' = a * x + b * y + c * z + xoff
|
|
43
|
+
y' = d * x + e * y + f * z + yoff
|
|
44
|
+
z' = g * x + h * y + i * z + zoff
|
|
45
|
+
"""
|
|
46
|
+
if len(matrix) == 6:
|
|
47
|
+
ndim = 2
|
|
48
|
+
a, b, d, e, xoff, yoff = matrix
|
|
49
|
+
if geom.has_z:
|
|
50
|
+
ndim = 3
|
|
51
|
+
i = 1.0
|
|
52
|
+
c = f = g = h = zoff = 0.0
|
|
53
|
+
matrix = a, b, c, d, e, f, g, h, i, xoff, yoff, zoff
|
|
54
|
+
elif len(matrix) == 12:
|
|
55
|
+
ndim = 3
|
|
56
|
+
a, b, c, d, e, f, g, h, i, xoff, yoff, zoff = matrix
|
|
57
|
+
if not geom.has_z:
|
|
58
|
+
ndim = 2
|
|
59
|
+
matrix = a, b, d, e, xoff, yoff
|
|
60
|
+
else:
|
|
61
|
+
raise ValueError("'matrix' expects either 6 or 12 coefficients")
|
|
62
|
+
|
|
63
|
+
def affine_pts(pts):
|
|
64
|
+
"""Internal function to yield affine transform of coordinate tuples"""
|
|
65
|
+
if ndim == 2:
|
|
66
|
+
for x, y in pts:
|
|
67
|
+
xp = a * x + b * y + xoff
|
|
68
|
+
yp = d * x + e * y + yoff
|
|
69
|
+
yield (xp, yp)
|
|
70
|
+
elif ndim == 3:
|
|
71
|
+
for x, y, z in pts:
|
|
72
|
+
xp = a * x + b * y + c * z + xoff
|
|
73
|
+
yp = d * x + e * y + f * z + yoff
|
|
74
|
+
zp = g * x + h * y + i * z + zoff
|
|
75
|
+
yield (xp, yp, zp)
|
|
76
|
+
|
|
77
|
+
# Process coordinates from each supported geometry type
|
|
78
|
+
if geom.type in ('Point', 'LineString'):
|
|
79
|
+
return type(geom)(list(affine_pts(geom.coords)))
|
|
80
|
+
elif geom.type == 'Polygon':
|
|
81
|
+
ring = geom.exterior
|
|
82
|
+
shell = type(ring)(list(affine_pts(ring.coords)))
|
|
83
|
+
holes = list(geom.interiors)
|
|
84
|
+
for pos, ring in enumerate(holes):
|
|
85
|
+
holes[pos] = type(ring)(list(affine_pts(ring.coords)))
|
|
86
|
+
return type(geom)(shell, holes)
|
|
87
|
+
elif geom.type.startswith('Multi') or geom.type == 'GeometryCollection':
|
|
88
|
+
# Recursive call
|
|
89
|
+
# TODO: fix GeometryCollection constructor
|
|
90
|
+
return type(geom)([affine_transform(part, matrix) for part in geom.geoms])
|
|
91
|
+
else:
|
|
92
|
+
raise ValueError('Type %r not recognized' % geom.type)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def interpret_origin(geom, origin, ndim):
|
|
96
|
+
"""Returns interpreted coordinate tuple for origin parameter.
|
|
97
|
+
|
|
98
|
+
This is a helper function for other transform functions.
|
|
99
|
+
|
|
100
|
+
The point of origin can be a keyword 'center' for the 2D bounding box
|
|
101
|
+
center, 'centroid' for the geometry's 2D centroid, a Point object or a
|
|
102
|
+
coordinate tuple (x0, y0, z0).
|
|
103
|
+
"""
|
|
104
|
+
# get coordinate tuple from 'origin' from keyword or Point type
|
|
105
|
+
if origin == 'center':
|
|
106
|
+
# bounding box center
|
|
107
|
+
minx, miny, maxx, maxy = geom.bounds
|
|
108
|
+
origin = ((maxx + minx)/2.0, (maxy + miny)/2.0)
|
|
109
|
+
elif origin == 'centroid':
|
|
110
|
+
origin = geom.centroid.coords[0]
|
|
111
|
+
elif isinstance(origin, str):
|
|
112
|
+
raise ValueError("'origin' keyword %r is not recognized" % origin)
|
|
113
|
+
elif hasattr(origin, 'type') and origin.type == 'Point':
|
|
114
|
+
origin = origin.coords[0]
|
|
115
|
+
|
|
116
|
+
# origin should now be tuple-like
|
|
117
|
+
if len(origin) not in (2, 3):
|
|
118
|
+
raise ValueError("Expected number of items in 'origin' to be "
|
|
119
|
+
"either 2 or 3")
|
|
120
|
+
if ndim == 2:
|
|
121
|
+
return origin[0:2]
|
|
122
|
+
else: # 3D coordinate
|
|
123
|
+
if len(origin) == 2:
|
|
124
|
+
return origin + (0.0,)
|
|
125
|
+
else:
|
|
126
|
+
return origin
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def rotate(geom, angle, origin='center', use_radians=False):
|
|
130
|
+
"""Returns a rotated geometry on a 2D plane.
|
|
131
|
+
|
|
132
|
+
The angle of rotation can be specified in either degrees (default) or
|
|
133
|
+
radians by setting ``use_radians=True``. Positive angles are
|
|
134
|
+
counter-clockwise and negative are clockwise rotations.
|
|
135
|
+
|
|
136
|
+
The point of origin can be a keyword 'center' for the bounding box
|
|
137
|
+
center (default), 'centroid' for the geometry's centroid, a Point object
|
|
138
|
+
or a coordinate tuple (x0, y0).
|
|
139
|
+
|
|
140
|
+
The affine transformation matrix for 2D rotation is:
|
|
141
|
+
|
|
142
|
+
/ cos(r) -sin(r) xoff \
|
|
143
|
+
| sin(r) cos(r) yoff |
|
|
144
|
+
\ 0 0 1 /
|
|
145
|
+
|
|
146
|
+
where the offsets are calculated from the origin Point(x0, y0):
|
|
147
|
+
|
|
148
|
+
xoff = x0 - x0 * cos(r) + y0 * sin(r)
|
|
149
|
+
yoff = y0 - x0 * sin(r) - y0 * cos(r)
|
|
150
|
+
"""
|
|
151
|
+
if not use_radians: # convert from degrees
|
|
152
|
+
angle *= pi/180.0
|
|
153
|
+
cosp = cos(angle)
|
|
154
|
+
sinp = sin(angle)
|
|
155
|
+
if abs(cosp) < 2.5e-16:
|
|
156
|
+
cosp = 0.0
|
|
157
|
+
if abs(sinp) < 2.5e-16:
|
|
158
|
+
sinp = 0.0
|
|
159
|
+
x0, y0 = interpret_origin(geom, origin, 2)
|
|
160
|
+
|
|
161
|
+
matrix = (cosp, -sinp, 0.0,
|
|
162
|
+
sinp, cosp, 0.0,
|
|
163
|
+
0.0, 0.0, 1.0,
|
|
164
|
+
x0 - x0 * cosp + y0 * sinp, y0 - x0 * sinp - y0 * cosp, 0.0)
|
|
165
|
+
return affine_transform(geom, matrix)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def scale(geom, xfact=1.0, yfact=1.0, zfact=1.0, origin='center'):
|
|
169
|
+
"""Returns a scaled geometry, scaled by factors along each dimension.
|
|
170
|
+
|
|
171
|
+
The point of origin can be a keyword 'center' for the 2D bounding box
|
|
172
|
+
center (default), 'centroid' for the geometry's 2D centroid, a Point
|
|
173
|
+
object or a coordinate tuple (x0, y0, z0).
|
|
174
|
+
|
|
175
|
+
Negative scale factors will mirror or reflect coordinates.
|
|
176
|
+
|
|
177
|
+
The general 3D affine transformation matrix for scaling is:
|
|
178
|
+
|
|
179
|
+
/ xfact 0 0 xoff \
|
|
180
|
+
| 0 yfact 0 yoff |
|
|
181
|
+
| 0 0 zfact zoff |
|
|
182
|
+
\ 0 0 0 1 /
|
|
183
|
+
|
|
184
|
+
where the offsets are calculated from the origin Point(x0, y0, z0):
|
|
185
|
+
|
|
186
|
+
xoff = x0 - x0 * xfact
|
|
187
|
+
yoff = y0 - y0 * yfact
|
|
188
|
+
zoff = z0 - z0 * zfact
|
|
189
|
+
"""
|
|
190
|
+
x0, y0, z0 = interpret_origin(geom, origin, 3)
|
|
191
|
+
|
|
192
|
+
matrix = (xfact, 0.0, 0.0,
|
|
193
|
+
0.0, yfact, 0.0,
|
|
194
|
+
0.0, 0.0, zfact,
|
|
195
|
+
x0 - x0 * xfact, y0 - y0 * yfact, z0 - z0 * zfact)
|
|
196
|
+
return affine_transform(geom, matrix)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def skew(geom, xs=0.0, ys=0.0, origin='center', use_radians=False):
|
|
200
|
+
"""Returns a skewed geometry, sheared by angles along x and y dimensions.
|
|
201
|
+
|
|
202
|
+
The shear angle can be specified in either degrees (default) or radians
|
|
203
|
+
by setting ``use_radians=True``.
|
|
204
|
+
|
|
205
|
+
The point of origin can be a keyword 'center' for the bounding box
|
|
206
|
+
center (default), 'centroid' for the geometry's centroid, a Point object
|
|
207
|
+
or a coordinate tuple (x0, y0).
|
|
208
|
+
|
|
209
|
+
The general 2D affine transformation matrix for skewing is:
|
|
210
|
+
|
|
211
|
+
/ 1 tan(xs) xoff \
|
|
212
|
+
| tan(ys) 1 yoff |
|
|
213
|
+
\ 0 0 1 /
|
|
214
|
+
|
|
215
|
+
where the offsets are calculated from the origin Point(x0, y0):
|
|
216
|
+
|
|
217
|
+
xoff = -y0 * tan(xs)
|
|
218
|
+
yoff = -x0 * tan(ys)
|
|
219
|
+
"""
|
|
220
|
+
if not use_radians: # convert from degrees
|
|
221
|
+
xs *= pi/180.0
|
|
222
|
+
ys *= pi/180.0
|
|
223
|
+
tanx = tan(xs)
|
|
224
|
+
tany = tan(ys)
|
|
225
|
+
if abs(tanx) < 2.5e-16:
|
|
226
|
+
tanx = 0.0
|
|
227
|
+
if abs(tany) < 2.5e-16:
|
|
228
|
+
tany = 0.0
|
|
229
|
+
x0, y0 = interpret_origin(geom, origin, 2)
|
|
230
|
+
|
|
231
|
+
matrix = (1.0, tanx, 0.0,
|
|
232
|
+
tany, 1.0, 0.0,
|
|
233
|
+
0.0, 0.0, 1.0,
|
|
234
|
+
-y0 * tanx, -x0 * tany, 0.0)
|
|
235
|
+
return affine_transform(geom, matrix)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def translate(geom, xoff=0.0, yoff=0.0, zoff=0.0):
|
|
239
|
+
"""Returns a translated geometry shifted by offsets along each dimension.
|
|
240
|
+
|
|
241
|
+
The general 3D affine transformation matrix for translation is:
|
|
242
|
+
|
|
243
|
+
/ 1 0 0 xoff \
|
|
244
|
+
| 0 1 0 yoff |
|
|
245
|
+
| 0 0 1 zoff |
|
|
246
|
+
\ 0 0 0 1 /
|
|
247
|
+
"""
|
|
248
|
+
matrix = (1.0, 0.0, 0.0,
|
|
249
|
+
0.0, 1.0, 0.0,
|
|
250
|
+
0.0, 0.0, 1.0,
|
|
251
|
+
xoff, yoff, zoff)
|
|
252
|
+
return affine_transform(geom, matrix)
|
shapely/affinity.pyc
ADDED
|
Binary file
|
shapely/algorithms/__init__.pyc
CHANGED
|
Binary file
|
shapely/algorithms/cga.pyc
CHANGED
|
Binary file
|
shapely/coords.py
CHANGED
|
@@ -8,6 +8,21 @@ import sys
|
|
|
8
8
|
from shapely.geos import lgeos
|
|
9
9
|
from shapely.topology import Validating
|
|
10
10
|
|
|
11
|
+
try:
|
|
12
|
+
import numpy
|
|
13
|
+
has_numpy = True
|
|
14
|
+
except ImportError:
|
|
15
|
+
has_numpy = False
|
|
16
|
+
|
|
17
|
+
def required(ob):
|
|
18
|
+
"""Return an object that meets Shapely requirements for self-owned
|
|
19
|
+
C-continguous data, copying if necessary, or just return the original
|
|
20
|
+
object."""
|
|
21
|
+
if has_numpy and hasattr(ob, '__array_interface__'):
|
|
22
|
+
return numpy.require(ob, numpy.float64, ["C", "OWNDATA"])
|
|
23
|
+
else:
|
|
24
|
+
return ob
|
|
25
|
+
|
|
11
26
|
|
|
12
27
|
class CoordinateSequence(object):
|
|
13
28
|
"""
|
|
@@ -30,7 +45,7 @@ class CoordinateSequence(object):
|
|
|
30
45
|
# _ndim : int
|
|
31
46
|
# Number of dimensions (2 or 3, generally)
|
|
32
47
|
# __p__ : object
|
|
33
|
-
# Parent (Shapely) geometry
|
|
48
|
+
# Parent (Shapely) geometry
|
|
34
49
|
_cseq = None
|
|
35
50
|
_ndim = None
|
|
36
51
|
__p__ = None
|
|
@@ -41,7 +56,7 @@ class CoordinateSequence(object):
|
|
|
41
56
|
def _update(self):
|
|
42
57
|
self._ndim = self.__p__._ndim
|
|
43
58
|
self._cseq = lgeos.GEOSGeom_getCoordSeq(self.__p__._geom)
|
|
44
|
-
|
|
59
|
+
|
|
45
60
|
def __len__(self):
|
|
46
61
|
self._update()
|
|
47
62
|
cs_len = c_uint(0)
|
|
@@ -53,38 +68,56 @@ class CoordinateSequence(object):
|
|
|
53
68
|
dx = c_double()
|
|
54
69
|
dy = c_double()
|
|
55
70
|
dz = c_double()
|
|
56
|
-
|
|
71
|
+
has_z = self._ndim == 3
|
|
72
|
+
for i in xrange(self.__len__()):
|
|
57
73
|
lgeos.GEOSCoordSeq_getX(self._cseq, i, byref(dx))
|
|
58
74
|
lgeos.GEOSCoordSeq_getY(self._cseq, i, byref(dy))
|
|
59
|
-
if
|
|
75
|
+
if has_z:
|
|
60
76
|
lgeos.GEOSCoordSeq_getZ(self._cseq, i, byref(dz))
|
|
61
77
|
yield (dx.value, dy.value, dz.value)
|
|
62
78
|
else:
|
|
63
79
|
yield (dx.value, dy.value)
|
|
64
80
|
|
|
65
|
-
def __getitem__(self,
|
|
81
|
+
def __getitem__(self, key):
|
|
66
82
|
self._update()
|
|
67
|
-
M = self.__len__()
|
|
68
|
-
if i + M < 0 or i >= M:
|
|
69
|
-
raise IndexError("index out of range")
|
|
70
|
-
if i < 0:
|
|
71
|
-
ii = M + i
|
|
72
|
-
else:
|
|
73
|
-
ii = i
|
|
74
83
|
dx = c_double()
|
|
75
84
|
dy = c_double()
|
|
76
85
|
dz = c_double()
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
m = self.__len__()
|
|
87
|
+
has_z = self._ndim == 3
|
|
88
|
+
if isinstance(key, int):
|
|
89
|
+
if key + m < 0 or key >= m:
|
|
90
|
+
raise IndexError("index out of range")
|
|
91
|
+
if key < 0:
|
|
92
|
+
i = m + key
|
|
93
|
+
else:
|
|
94
|
+
i = key
|
|
95
|
+
lgeos.GEOSCoordSeq_getX(self._cseq, i, byref(dx))
|
|
96
|
+
lgeos.GEOSCoordSeq_getY(self._cseq, i, byref(dy))
|
|
97
|
+
if has_z:
|
|
98
|
+
lgeos.GEOSCoordSeq_getZ(self._cseq, i, byref(dz))
|
|
99
|
+
return (dx.value, dy.value, dz.value)
|
|
100
|
+
else:
|
|
101
|
+
return (dx.value, dy.value)
|
|
102
|
+
elif isinstance(key, slice):
|
|
103
|
+
res = []
|
|
104
|
+
start, stop, stride = key.indices(m)
|
|
105
|
+
for i in xrange(start, stop, stride):
|
|
106
|
+
lgeos.GEOSCoordSeq_getX(self._cseq, i, byref(dx))
|
|
107
|
+
lgeos.GEOSCoordSeq_getY(self._cseq, i, byref(dy))
|
|
108
|
+
if has_z:
|
|
109
|
+
lgeos.GEOSCoordSeq_getZ(self._cseq, i, byref(dz))
|
|
110
|
+
res.append((dx.value, dy.value, dz.value))
|
|
111
|
+
else:
|
|
112
|
+
res.append((dx.value, dy.value))
|
|
113
|
+
return res
|
|
82
114
|
else:
|
|
83
|
-
|
|
115
|
+
raise TypeError("key must be an index or slice")
|
|
84
116
|
|
|
85
117
|
@property
|
|
86
118
|
def ctypes(self):
|
|
87
119
|
self._update()
|
|
120
|
+
has_z = self._ndim == 3
|
|
88
121
|
n = self._ndim
|
|
89
122
|
m = self.__len__()
|
|
90
123
|
array_type = c_double * (m * n)
|
|
@@ -95,7 +128,7 @@ class CoordinateSequence(object):
|
|
|
95
128
|
data[n*i] = temp.value
|
|
96
129
|
lgeos.GEOSCoordSeq_getY(self._cseq, i, byref(temp))
|
|
97
130
|
data[n*i+1] = temp.value
|
|
98
|
-
if
|
|
131
|
+
if has_z:
|
|
99
132
|
lgeos.GEOSCoordSeq_getZ(self._cseq, i, byref(temp))
|
|
100
133
|
data[n*i+2] = temp.value
|
|
101
134
|
return data
|
|
@@ -133,7 +166,7 @@ class CoordinateSequence(object):
|
|
|
133
166
|
lgeos.GEOSCoordSeq_getY(self._cseq, i, byref(temp))
|
|
134
167
|
y.append(temp.value)
|
|
135
168
|
return x, y
|
|
136
|
-
|
|
169
|
+
|
|
137
170
|
|
|
138
171
|
class BoundsOp(Validating):
|
|
139
172
|
|
|
@@ -163,4 +196,3 @@ class BoundsOp(Validating):
|
|
|
163
196
|
if y < miny: miny = y
|
|
164
197
|
if y > maxy: maxy = y
|
|
165
198
|
return (minx, miny, maxx, maxy)
|
|
166
|
-
|
shapely/coords.pyc
CHANGED
|
Binary file
|
shapely/ctypes_declarations.py
CHANGED
|
@@ -100,6 +100,11 @@ def prototype(lgeos, geosVersion):
|
|
|
100
100
|
lgeos.GEOSBuffer.restype = ctypes.c_void_p
|
|
101
101
|
lgeos.GEOSBuffer.argtypes = [ctypes.c_void_p, ctypes.c_double, ctypes.c_int]
|
|
102
102
|
|
|
103
|
+
lgeos.GEOSBufferWithStyle.restype = ctypes.c_void_p
|
|
104
|
+
lgeos.GEOSBufferWithStyle.argtypes = [ctypes.c_void_p, ctypes.c_double,
|
|
105
|
+
ctypes.c_int, ctypes.c_int,
|
|
106
|
+
ctypes.c_int, ctypes.c_double]
|
|
107
|
+
|
|
103
108
|
lgeos.GEOSSimplify.restype = ctypes.c_void_p
|
|
104
109
|
lgeos.GEOSSimplify.argtypes = [ctypes.c_void_p, ctypes.c_double]
|
|
105
110
|
|
|
@@ -271,14 +276,22 @@ def prototype(lgeos, geosVersion):
|
|
|
271
276
|
lgeos.GEOSProject.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
|
|
272
277
|
|
|
273
278
|
lgeos.GEOSProjectNormalized.restype = ctypes.c_double
|
|
274
|
-
lgeos.GEOSProjectNormalized.argtypes = [ctypes.c_void_p,
|
|
279
|
+
lgeos.GEOSProjectNormalized.argtypes = [ctypes.c_void_p,
|
|
275
280
|
ctypes.c_void_p]
|
|
276
281
|
|
|
277
282
|
lgeos.GEOSInterpolate.restype = ctypes.c_void_p
|
|
278
|
-
lgeos.GEOSInterpolate.argtypes = [ctypes.c_void_p,
|
|
283
|
+
lgeos.GEOSInterpolate.argtypes = [ctypes.c_void_p,
|
|
279
284
|
ctypes.c_double]
|
|
280
285
|
|
|
281
286
|
lgeos.GEOSInterpolateNormalized.restype = ctypes.c_void_p
|
|
282
|
-
lgeos.GEOSInterpolateNormalized.argtypes = [ctypes.c_void_p,
|
|
287
|
+
lgeos.GEOSInterpolateNormalized.argtypes = [ctypes.c_void_p,
|
|
283
288
|
ctypes.c_double]
|
|
284
289
|
|
|
290
|
+
# TODO: Find out what version of geos_c came with geos 3.3.0
|
|
291
|
+
if geosVersion >= (1, 6, 3):
|
|
292
|
+
lgeos.GEOSUnaryUnion.restype = ctypes.c_void_p
|
|
293
|
+
lgeos.GEOSUnaryUnion.argtypes = [ctypes.c_void_p]
|
|
294
|
+
|
|
295
|
+
lgeos.GEOSPolygonize_full.restype = ctypes.c_void_p
|
|
296
|
+
lgeos.GEOSPolygonize_full.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p]
|
|
297
|
+
|
shapely/ctypes_declarations.pyc
CHANGED
|
Binary file
|
shapely/examples/__init__.pyc
CHANGED
|
Binary file
|
shapely/examples/dissolve.pyc
CHANGED
|
Binary file
|
shapely/examples/geoms.pyc
CHANGED
|
Binary file
|
shapely/examples/intersect.pyc
CHANGED
|
Binary file
|
shapely/examples/world.pyc
CHANGED
|
Binary file
|
shapely/ftools.pyc
CHANGED
|
Binary file
|
shapely/geometry/__init__.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"""Geometry classes and factories
|
|
2
2
|
"""
|
|
3
3
|
|
|
4
|
+
from base import CAP_STYLE, JOIN_STYLE
|
|
4
5
|
from geo import box, shape, asShape, mapping
|
|
5
6
|
from point import Point, asPoint
|
|
6
7
|
from linestring import LineString, asLineString
|
|
7
|
-
from polygon import Polygon, asPolygon
|
|
8
|
+
from polygon import Polygon, asPolygon, LinearRing, asLinearRing
|
|
8
9
|
from multipoint import MultiPoint, asMultiPoint
|
|
9
10
|
from multilinestring import MultiLineString, asMultiLineString
|
|
10
11
|
from multipolygon import MultiPolygon, asMultiPolygon
|
|
@@ -14,7 +15,6 @@ __all__ = [
|
|
|
14
15
|
'box', 'shape', 'asShape', 'Point', 'asPoint', 'LineString', 'asLineString',
|
|
15
16
|
'Polygon', 'asPolygon', 'MultiPoint', 'asMultiPoint',
|
|
16
17
|
'MultiLineString', 'asMultiLineString', 'MultiPolygon', 'asMultiPolygon',
|
|
17
|
-
'GeometryCollection', 'mapping'
|
|
18
|
+
'GeometryCollection', 'mapping', 'LinearRing', 'asLinearRing',
|
|
19
|
+
'CAP_STYLE', 'JOIN_STYLE'
|
|
18
20
|
]
|
|
19
|
-
|
|
20
|
-
|
shapely/geometry/__init__.pyc
CHANGED
|
Binary file
|