shapely 1.2.10__py2.7-win32.egg → 1.2.12__py2.7-win32.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.
- DLLs/geos.dll +0 -0
- DLLs/geos_c.dll +0 -0
- EGG-INFO/PKG-INFO +16 -1
- EGG-INFO/native_libs.txt +1 -0
- shapely/ctypes_declarations.py +5 -0
- shapely/ctypes_declarations.pyc +0 -0
- shapely/examples/__init__.py +1 -0
- shapely/examples/__init__.pyc +0 -0
- shapely/examples/dissolve.py +53 -0
- shapely/examples/dissolve.pyc +0 -0
- shapely/examples/geoms.py +51 -0
- shapely/examples/geoms.pyc +0 -0
- shapely/examples/intersect.py +81 -0
- shapely/examples/intersect.pyc +0 -0
- shapely/examples/world.py +21 -0
- shapely/examples/world.pyc +0 -0
- shapely/geometry/base.py +4 -1
- shapely/geometry/base.pyc +0 -0
- shapely/geometry/linestring.py +8 -13
- shapely/geometry/linestring.pyc +0 -0
- shapely/geometry/multilinestring.py +0 -3
- shapely/geometry/multilinestring.pyc +0 -0
- shapely/geometry/multipoint.py +3 -2
- shapely/geometry/multipoint.pyc +0 -0
- shapely/geometry/polygon.py +19 -39
- shapely/geometry/polygon.pyc +0 -0
- shapely/geos.py +8 -7
- shapely/geos.pyc +0 -0
- shapely/predicates.py +2 -2
- shapely/predicates.pyc +0 -0
- shapely/prepared.py +4 -1
- shapely/prepared.pyc +0 -0
- shapely/speedups/__init__.py +42 -0
- shapely/speedups/__init__.pyc +0 -0
- shapely/speedups/_speedups.py +7 -0
- shapely/speedups/_speedups.pyc +0 -0
- shapely/speedups/_speedups.pyd +0 -0
- shapely/tests/__init__.py +28 -0
- shapely/tests/__init__.pyc +0 -0
- shapely/tests/test_box.py +19 -0
- shapely/tests/test_box.pyc +0 -0
- shapely/tests/test_cga.py +33 -0
- shapely/tests/test_cga.pyc +0 -0
- shapely/tests/test_collection.py +11 -0
- shapely/tests/test_collection.pyc +0 -0
- shapely/tests/test_delegated.py +26 -0
- shapely/tests/test_delegated.pyc +0 -0
- shapely/tests/test_dlls.py +16 -0
- shapely/tests/test_dlls.pyc +0 -0
- shapely/tests/test_doctests.py +35 -0
- shapely/tests/test_doctests.pyc +0 -0
- shapely/tests/test_emptiness.py +19 -0
- shapely/tests/test_emptiness.pyc +0 -0
- shapely/tests/test_equality.py +30 -0
- shapely/tests/test_equality.pyc +0 -0
- shapely/tests/test_geomseq.py +11 -0
- shapely/tests/test_geomseq.pyc +0 -0
- shapely/tests/test_linear_referencing.py +67 -0
- shapely/tests/test_linear_referencing.pyc +0 -0
- shapely/tests/test_mapping.py +11 -0
- shapely/tests/test_mapping.pyc +0 -0
- shapely/tests/test_prepared.py +28 -0
- shapely/tests/test_prepared.pyc +0 -0
- shapely/tests/test_products_z.py +14 -0
- shapely/tests/test_products_z.pyc +0 -0
- shapely/tests/test_singularity.py +15 -0
- shapely/tests/test_singularity.pyc +0 -0
- shapely/tests/test_speedups.py +38 -0
- shapely/tests/test_speedups.pyc +0 -0
- shapely/tests/test_validation.py +10 -0
- shapely/tests/test_validation.pyc +0 -0
- shapely/tests/test_xy.py +14 -0
- shapely/tests/test_xy.pyc +0 -0
- shapely/tests/threading_test.py +37 -0
- shapely/tests/threading_test.pyc +0 -0
- shapely/topology.py +6 -8
- shapely/topology.pyc +0 -0
- shapely/wkb.py +2 -2
- shapely/wkb.pyc +0 -0
- DLLs/libgeos-3-2-2.dll +0 -0
DLLs/geos.dll
CHANGED
|
Binary file
|
DLLs/geos_c.dll
ADDED
|
Binary file
|
EGG-INFO/PKG-INFO
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: Shapely
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.12
|
|
4
4
|
Summary: Geometric objects, predicates, and operations
|
|
5
5
|
Home-page: http://trac.gispython.org/lab/wiki/Shapely
|
|
6
6
|
Author: Sean Gillies
|
|
@@ -166,6 +166,21 @@ Description: ======
|
|
|
166
166
|
CHANGES
|
|
167
167
|
=======
|
|
168
168
|
|
|
169
|
+
1.2.12 (2011-08-15)
|
|
170
|
+
-------------------
|
|
171
|
+
- Build Windows distributions with VC7 or VC9 as appropriate.
|
|
172
|
+
- More verbose report on failure to speed up.
|
|
173
|
+
- Fix for prepared geometries broken in 1.2.11.
|
|
174
|
+
- DO NOT INSTALL 1.2.11
|
|
175
|
+
|
|
176
|
+
1.2.11 (2011-08-04)
|
|
177
|
+
-------------------
|
|
178
|
+
- Ignore AttributeError during exit.
|
|
179
|
+
- PyPy 1.5 support.
|
|
180
|
+
- Prevent operation on prepared geometry crasher (#12).
|
|
181
|
+
- Optional Cython speedups for Windows.
|
|
182
|
+
- Linux 3 platform support.
|
|
183
|
+
|
|
169
184
|
1.2.10 (2011-05-09)
|
|
170
185
|
-------------------
|
|
171
186
|
- Add optional Cython speedups.
|
EGG-INFO/native_libs.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
shapely/speedups/_speedups.pyd
|
shapely/ctypes_declarations.py
CHANGED
|
@@ -6,12 +6,17 @@ import ctypes
|
|
|
6
6
|
class allocated_c_char_p(ctypes.c_char_p):
|
|
7
7
|
pass
|
|
8
8
|
|
|
9
|
+
EXCEPTION_HANDLER_FUNCTYPE = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_char_p)
|
|
10
|
+
|
|
9
11
|
def prototype(lgeos, geosVersion):
|
|
10
12
|
|
|
13
|
+
lgeos.initGEOS.argtypes = [EXCEPTION_HANDLER_FUNCTYPE, EXCEPTION_HANDLER_FUNCTYPE]
|
|
11
14
|
lgeos.initGEOS.restype = None
|
|
12
15
|
|
|
16
|
+
lgeos.finishGEOS.argtypes = []
|
|
13
17
|
lgeos.finishGEOS.restype = None
|
|
14
18
|
|
|
19
|
+
lgeos.GEOSversion.argtypes = []
|
|
15
20
|
lgeos.GEOSversion.restype = ctypes.c_char_p
|
|
16
21
|
|
|
17
22
|
lgeos.GEOSGeomFromWKT.restype = ctypes.c_void_p
|
shapely/ctypes_declarations.pyc
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Examples module
|
|
Binary file
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# dissolve.py
|
|
2
|
+
#
|
|
3
|
+
# Demonstrate how Shapely can be used to build up a collection of patches by
|
|
4
|
+
# dissolving circular regions and how Shapely supports plotting of the results.
|
|
5
|
+
|
|
6
|
+
from functools import partial
|
|
7
|
+
import random
|
|
8
|
+
|
|
9
|
+
import pylab
|
|
10
|
+
|
|
11
|
+
from shapely.geometry import Point
|
|
12
|
+
from shapely.ops import cascaded_union
|
|
13
|
+
|
|
14
|
+
# Use a partial function to make 100 points uniformly distributed in a 40x40
|
|
15
|
+
# box centered on 0,0.
|
|
16
|
+
r = partial(random.uniform, -20.0, 20.0)
|
|
17
|
+
points = [Point(r(), r()) for i in range(100)]
|
|
18
|
+
|
|
19
|
+
# Buffer the points, producing 100 polygon spots
|
|
20
|
+
spots = [p.buffer(2.5) for p in points]
|
|
21
|
+
|
|
22
|
+
# Perform a cascaded union of the polygon spots, dissolving them into a
|
|
23
|
+
# collection of polygon patches
|
|
24
|
+
patches = cascaded_union(spots)
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
# Illustrate the results using matplotlib's pylab interface
|
|
28
|
+
pylab.figure(num=None, figsize=(4, 4), dpi=180)
|
|
29
|
+
|
|
30
|
+
for patch in patches.geoms:
|
|
31
|
+
assert patch.geom_type in ['Polygon']
|
|
32
|
+
assert patch.is_valid
|
|
33
|
+
|
|
34
|
+
# Fill and outline each patch
|
|
35
|
+
x, y = patch.exterior.xy
|
|
36
|
+
pylab.fill(x, y, color='#cccccc', aa=True)
|
|
37
|
+
pylab.plot(x, y, color='#666666', aa=True, lw=1.0)
|
|
38
|
+
|
|
39
|
+
# Do the same for the holes of the patch
|
|
40
|
+
for hole in patch.interiors:
|
|
41
|
+
x, y = hole.xy
|
|
42
|
+
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
43
|
+
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
44
|
+
|
|
45
|
+
# Plot the original points
|
|
46
|
+
pylab.plot([p.x for p in points], [p.y for p in points], 'b,', alpha=0.75)
|
|
47
|
+
|
|
48
|
+
# Write the number of patches and the total patch area to the figure
|
|
49
|
+
pylab.text(-25, 25,
|
|
50
|
+
"Patches: %d, total area: %.2f" % (len(patches.geoms), patches.area))
|
|
51
|
+
|
|
52
|
+
pylab.savefig('dissolve.png')
|
|
53
|
+
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from numpy import asarray
|
|
2
|
+
import pylab
|
|
3
|
+
from shapely.geometry import Point, LineString, Polygon
|
|
4
|
+
|
|
5
|
+
polygon = Polygon(((-1.0, -1.0), (-1.0, 1.0), (1.0, 1.0), (1.0, -1.0)))
|
|
6
|
+
|
|
7
|
+
point_r = Point(-1.5, 1.2)
|
|
8
|
+
point_g = Point(-1.0, 1.0)
|
|
9
|
+
point_b = Point(-0.5, 0.5)
|
|
10
|
+
|
|
11
|
+
line_r = LineString(((-0.5, 0.5), (0.5, 0.5)))
|
|
12
|
+
line_g = LineString(((1.0, -1.0), (1.8, 0.5)))
|
|
13
|
+
line_b = LineString(((-1.8, -1.2), (1.8, 0.5)))
|
|
14
|
+
|
|
15
|
+
def plot_point(g, o, l):
|
|
16
|
+
pylab.plot([g.x], [g.y], o, label=l)
|
|
17
|
+
|
|
18
|
+
def plot_line(g, o):
|
|
19
|
+
a = asarray(g)
|
|
20
|
+
pylab.plot(a[:,0], a[:,1], o)
|
|
21
|
+
|
|
22
|
+
def fill_polygon(g, o):
|
|
23
|
+
a = asarray(g.exterior)
|
|
24
|
+
pylab.fill(a[:,0], a[:,1], o, alpha=0.5)
|
|
25
|
+
|
|
26
|
+
def fill_multipolygon(g, o):
|
|
27
|
+
for g in g.geoms:
|
|
28
|
+
fill_polygon(g, o)
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
from numpy import asarray
|
|
32
|
+
import pylab
|
|
33
|
+
|
|
34
|
+
fig = pylab.figure(1, figsize=(4, 3), dpi=150)
|
|
35
|
+
#pylab.axis([-2.0, 2.0, -1.5, 1.5])
|
|
36
|
+
pylab.axis('tight')
|
|
37
|
+
|
|
38
|
+
a = asarray(polygon.exterior)
|
|
39
|
+
pylab.fill(a[:,0], a[:,1], 'c')
|
|
40
|
+
|
|
41
|
+
plot_point(point_r, 'ro', 'b')
|
|
42
|
+
plot_point(point_g, 'go', 'c')
|
|
43
|
+
plot_point(point_b, 'bo', 'd')
|
|
44
|
+
|
|
45
|
+
plot_line(line_r, 'r')
|
|
46
|
+
plot_line(line_g, 'g')
|
|
47
|
+
plot_line(line_b, 'b')
|
|
48
|
+
|
|
49
|
+
pylab.show()
|
|
50
|
+
|
|
51
|
+
|
|
Binary file
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# intersect.py
|
|
2
|
+
#
|
|
3
|
+
# Demonstrate how Shapely can be used to analyze and plot the intersection of
|
|
4
|
+
# a trajectory and regions in space.
|
|
5
|
+
|
|
6
|
+
from functools import partial
|
|
7
|
+
import random
|
|
8
|
+
|
|
9
|
+
import pylab
|
|
10
|
+
|
|
11
|
+
from shapely.geometry import LineString, Point
|
|
12
|
+
from shapely.ops import cascaded_union
|
|
13
|
+
|
|
14
|
+
# Build patches as in dissolved.py
|
|
15
|
+
r = partial(random.uniform, -20.0, 20.0)
|
|
16
|
+
points = [Point(r(), r()) for i in range(100)]
|
|
17
|
+
spots = [p.buffer(2.5) for p in points]
|
|
18
|
+
patches = cascaded_union(spots)
|
|
19
|
+
|
|
20
|
+
# Represent the following geolocation parameters
|
|
21
|
+
#
|
|
22
|
+
# initial position: -25, -25
|
|
23
|
+
# heading: 45.0
|
|
24
|
+
# speed: 50*sqrt(2)
|
|
25
|
+
#
|
|
26
|
+
# as a line
|
|
27
|
+
vector = LineString(((-25.0, -25.0), (25.0, 25.0)))
|
|
28
|
+
|
|
29
|
+
# Find intercepted and missed patches. List the former so we can count them
|
|
30
|
+
# later
|
|
31
|
+
intercepts = [patch for patch in patches.geoms if vector.intersects(patch)]
|
|
32
|
+
misses = (patch for patch in patches.geoms if not vector.intersects(patch))
|
|
33
|
+
|
|
34
|
+
# Plot the intersection
|
|
35
|
+
intersection = vector.intersection(patches)
|
|
36
|
+
assert intersection.geom_type in ['MultiLineString']
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
# Illustrate the results using matplotlib's pylab interface
|
|
40
|
+
pylab.figure(num=None, figsize=(4, 4), dpi=180)
|
|
41
|
+
|
|
42
|
+
# Plot the misses
|
|
43
|
+
for spot in misses:
|
|
44
|
+
x, y = spot.exterior.xy
|
|
45
|
+
pylab.fill(x, y, color='#cccccc', aa=True)
|
|
46
|
+
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
47
|
+
|
|
48
|
+
# Do the same for the holes of the patch
|
|
49
|
+
for hole in spot.interiors:
|
|
50
|
+
x, y = hole.xy
|
|
51
|
+
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
52
|
+
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
53
|
+
|
|
54
|
+
# Plot the intercepts
|
|
55
|
+
for spot in intercepts:
|
|
56
|
+
x, y = spot.exterior.xy
|
|
57
|
+
pylab.fill(x, y, color='red', alpha=0.25, aa=True)
|
|
58
|
+
pylab.plot(x, y, color='red', alpha=0.5, aa=True, lw=1.0)
|
|
59
|
+
|
|
60
|
+
# Do the same for the holes of the patch
|
|
61
|
+
for hole in spot.interiors:
|
|
62
|
+
x, y = hole.xy
|
|
63
|
+
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
64
|
+
pylab.plot(x, y, color='red', alpha=0.5, aa=True, lw=1.0)
|
|
65
|
+
|
|
66
|
+
# Draw the projected trajectory
|
|
67
|
+
pylab.arrow(-25, -25, 50, 50, color='#999999', aa=True,
|
|
68
|
+
head_width=1.0, head_length=1.0)
|
|
69
|
+
|
|
70
|
+
for segment in intersection.geoms:
|
|
71
|
+
x, y = segment.xy
|
|
72
|
+
pylab.plot(x, y, color='red', aa=True, lw=1.5)
|
|
73
|
+
|
|
74
|
+
# Write the number of patches and the total patch area to the figure
|
|
75
|
+
pylab.text(-28, 25,
|
|
76
|
+
"Patches: %d/%d (%d), total length: %.1f" \
|
|
77
|
+
% (len(intercepts), len(patches.geoms),
|
|
78
|
+
len(intersection.geoms), intersection.length))
|
|
79
|
+
|
|
80
|
+
pylab.savefig('intersect.png')
|
|
81
|
+
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ogr
|
|
2
|
+
import pylab
|
|
3
|
+
from numpy import asarray
|
|
4
|
+
|
|
5
|
+
from shapely.wkb import loads
|
|
6
|
+
|
|
7
|
+
source = ogr.Open("/var/gis/data/world/world_borders.shp")
|
|
8
|
+
borders = source.GetLayerByName("world_borders")
|
|
9
|
+
|
|
10
|
+
fig = pylab.figure(1, figsize=(4,2), dpi=300)
|
|
11
|
+
|
|
12
|
+
while 1:
|
|
13
|
+
feature = borders.GetNextFeature()
|
|
14
|
+
if not feature:
|
|
15
|
+
break
|
|
16
|
+
|
|
17
|
+
geom = loads(feature.GetGeometryRef().ExportToWkb())
|
|
18
|
+
a = asarray(geom)
|
|
19
|
+
pylab.plot(a[:,0], a[:,1])
|
|
20
|
+
|
|
21
|
+
pylab.show()
|
|
Binary file
|
shapely/geometry/base.py
CHANGED
|
@@ -104,7 +104,10 @@ class BaseGeometry(object):
|
|
|
104
104
|
# TODO: defer cleanup to the implementation. We shouldn't be
|
|
105
105
|
# explicitly calling a lgeos method here.
|
|
106
106
|
if not (self._owned or self._is_empty):
|
|
107
|
-
|
|
107
|
+
try:
|
|
108
|
+
self._lgeos.GEOSGeom_destroy(self.__geom__)
|
|
109
|
+
except AttributeError:
|
|
110
|
+
pass # _lgeos might be empty on shutdown
|
|
108
111
|
self.__geom__ = EMPTY
|
|
109
112
|
|
|
110
113
|
def __del__(self):
|
shapely/geometry/base.pyc
CHANGED
|
Binary file
|
shapely/geometry/linestring.py
CHANGED
|
@@ -167,9 +167,10 @@ def geos_linestring_from_py(ob, update_geom=None, update_ndim=0):
|
|
|
167
167
|
assert n == 2 or n == 3
|
|
168
168
|
|
|
169
169
|
# Make pointer to the coordinate array
|
|
170
|
-
|
|
170
|
+
if isinstance(array['data'], tuple):
|
|
171
|
+
# numpy tuple (addr, read-only)
|
|
171
172
|
cp = cast(array['data'][0], POINTER(c_double))
|
|
172
|
-
|
|
173
|
+
else:
|
|
173
174
|
cp = array['data']
|
|
174
175
|
|
|
175
176
|
# Create a coordinate sequence
|
|
@@ -226,21 +227,15 @@ def geos_linestring_from_py(ob, update_geom=None, update_ndim=0):
|
|
|
226
227
|
# add to coordinate sequence
|
|
227
228
|
for i in xrange(m):
|
|
228
229
|
coords = ob[i]
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
# Because of a bug in the GEOS C API,
|
|
231
|
+
# always set X before Y
|
|
232
|
+
lgeos.GEOSCoordSeq_setX(cs, i, coords[0])
|
|
233
|
+
lgeos.GEOSCoordSeq_setY(cs, i, coords[1])
|
|
232
234
|
if n == 3:
|
|
233
235
|
try:
|
|
234
|
-
|
|
236
|
+
lgeos.GEOSCoordSeq_setZ(cs, i, coords[2])
|
|
235
237
|
except IndexError:
|
|
236
238
|
raise ValueError("Inconsistent coordinate dimensionality")
|
|
237
|
-
|
|
238
|
-
# Because of a bug in the GEOS C API,
|
|
239
|
-
# always set X before Y
|
|
240
|
-
lgeos.GEOSCoordSeq_setX(cs, i, dx)
|
|
241
|
-
lgeos.GEOSCoordSeq_setY(cs, i, dy)
|
|
242
|
-
if n == 3:
|
|
243
|
-
lgeos.GEOSCoordSeq_setZ(cs, i, dz)
|
|
244
239
|
|
|
245
240
|
if update_geom is not None:
|
|
246
241
|
return None
|
shapely/geometry/linestring.pyc
CHANGED
|
Binary file
|
|
Binary file
|
shapely/geometry/multipoint.py
CHANGED
|
@@ -138,9 +138,10 @@ def geos_multipoint_from_py(ob):
|
|
|
138
138
|
assert n == 2 or n == 3
|
|
139
139
|
|
|
140
140
|
# Make pointer to the coordinate array
|
|
141
|
-
|
|
141
|
+
if isinstance(array['data'], tuple):
|
|
142
|
+
# numpy tuple (addr, read-only)
|
|
142
143
|
cp = cast(array['data'][0], POINTER(c_double))
|
|
143
|
-
|
|
144
|
+
else:
|
|
144
145
|
cp = array['data']
|
|
145
146
|
|
|
146
147
|
# Array of pointers to sub-geometries
|
shapely/geometry/multipoint.pyc
CHANGED
|
Binary file
|
shapely/geometry/polygon.py
CHANGED
|
@@ -312,9 +312,10 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
|
|
|
312
312
|
assert n == 2 or n == 3
|
|
313
313
|
|
|
314
314
|
# Make pointer to the coordinate array
|
|
315
|
-
|
|
315
|
+
if isinstance(array['data'], tuple):
|
|
316
|
+
# numpy tuple (addr, read-only)
|
|
316
317
|
cp = cast(array['data'][0], POINTER(c_double))
|
|
317
|
-
|
|
318
|
+
else:
|
|
318
319
|
cp = array['data']
|
|
319
320
|
|
|
320
321
|
# Add closing coordinates to sequence?
|
|
@@ -335,33 +336,21 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
|
|
|
335
336
|
|
|
336
337
|
# add to coordinate sequence
|
|
337
338
|
for i in xrange(m):
|
|
338
|
-
dx = c_double(cp[n*i])
|
|
339
|
-
dy = c_double(cp[n*i+1])
|
|
340
|
-
dz = None
|
|
341
|
-
if n == 3:
|
|
342
|
-
dz = c_double(cp[n*i+2])
|
|
343
|
-
|
|
344
339
|
# Because of a bug in the GEOS C API,
|
|
345
340
|
# always set X before Y
|
|
346
|
-
lgeos.GEOSCoordSeq_setX(cs, i,
|
|
347
|
-
lgeos.GEOSCoordSeq_setY(cs, i,
|
|
341
|
+
lgeos.GEOSCoordSeq_setX(cs, i, cp[n*i])
|
|
342
|
+
lgeos.GEOSCoordSeq_setY(cs, i, cp[n*i+1])
|
|
348
343
|
if n == 3:
|
|
349
|
-
lgeos.GEOSCoordSeq_setZ(cs, i,
|
|
344
|
+
lgeos.GEOSCoordSeq_setZ(cs, i, cp[n*i+2])
|
|
350
345
|
|
|
351
346
|
# Add closing coordinates to sequence?
|
|
352
|
-
if M > m:
|
|
353
|
-
dx = c_double(cp[0])
|
|
354
|
-
dy = c_double(cp[1])
|
|
355
|
-
dz = None
|
|
356
|
-
if n == 3:
|
|
357
|
-
dz = c_double(cp[2])
|
|
358
|
-
|
|
347
|
+
if M > m:
|
|
359
348
|
# Because of a bug in the GEOS C API,
|
|
360
349
|
# always set X before Y
|
|
361
|
-
lgeos.GEOSCoordSeq_setX(cs, M-1,
|
|
362
|
-
lgeos.GEOSCoordSeq_setY(cs, M-1,
|
|
350
|
+
lgeos.GEOSCoordSeq_setX(cs, M-1, cp[0])
|
|
351
|
+
lgeos.GEOSCoordSeq_setY(cs, M-1, cp[1])
|
|
363
352
|
if n == 3:
|
|
364
|
-
lgeos.GEOSCoordSeq_setZ(cs, M-1,
|
|
353
|
+
lgeos.GEOSCoordSeq_setZ(cs, M-1, cp[2])
|
|
365
354
|
|
|
366
355
|
except AttributeError:
|
|
367
356
|
# Fall back on list
|
|
@@ -391,34 +380,25 @@ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
|
|
|
391
380
|
# add to coordinate sequence
|
|
392
381
|
for i in xrange(m):
|
|
393
382
|
coords = ob[i]
|
|
394
|
-
dx = c_double(coords[0])
|
|
395
|
-
dy = c_double(coords[1])
|
|
396
|
-
dz = None
|
|
397
|
-
if n == 3:
|
|
398
|
-
dz = c_double(coords[2])
|
|
399
|
-
|
|
400
383
|
# Because of a bug in the GEOS C API,
|
|
401
384
|
# always set X before Y
|
|
402
|
-
lgeos.GEOSCoordSeq_setX(cs, i,
|
|
403
|
-
lgeos.GEOSCoordSeq_setY(cs, i,
|
|
385
|
+
lgeos.GEOSCoordSeq_setX(cs, i, coords[0])
|
|
386
|
+
lgeos.GEOSCoordSeq_setY(cs, i, coords[1])
|
|
404
387
|
if n == 3:
|
|
405
|
-
|
|
388
|
+
try:
|
|
389
|
+
lgeos.GEOSCoordSeq_setZ(cs, i, coords[2])
|
|
390
|
+
except IndexError:
|
|
391
|
+
raise ValueError("Inconsistent coordinate dimensionality")
|
|
406
392
|
|
|
407
393
|
# Add closing coordinates to sequence?
|
|
408
394
|
if M > m:
|
|
409
395
|
coords = ob[0]
|
|
410
|
-
dx = c_double(coords[0])
|
|
411
|
-
dy = c_double(coords[1])
|
|
412
|
-
dz = None
|
|
413
|
-
if n == 3:
|
|
414
|
-
dz = c_double(coords[2])
|
|
415
|
-
|
|
416
396
|
# Because of a bug in the GEOS C API,
|
|
417
397
|
# always set X before Y
|
|
418
|
-
lgeos.GEOSCoordSeq_setX(cs, M-1,
|
|
419
|
-
lgeos.GEOSCoordSeq_setY(cs, M-1,
|
|
398
|
+
lgeos.GEOSCoordSeq_setX(cs, M-1, coords[0])
|
|
399
|
+
lgeos.GEOSCoordSeq_setY(cs, M-1, coords[1])
|
|
420
400
|
if n == 3:
|
|
421
|
-
lgeos.GEOSCoordSeq_setZ(cs, M-1,
|
|
401
|
+
lgeos.GEOSCoordSeq_setZ(cs, M-1, coords[2])
|
|
422
402
|
|
|
423
403
|
if update_geom is not None:
|
|
424
404
|
return None
|
shapely/geometry/polygon.pyc
CHANGED
|
Binary file
|
shapely/geos.py
CHANGED
|
@@ -12,7 +12,7 @@ from ctypes import cdll, CDLL, CFUNCTYPE, c_char_p, c_void_p, string_at
|
|
|
12
12
|
from ctypes.util import find_library
|
|
13
13
|
|
|
14
14
|
import ftools
|
|
15
|
-
from ctypes_declarations import prototype
|
|
15
|
+
from ctypes_declarations import prototype, EXCEPTION_HANDLER_FUNCTYPE
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -43,7 +43,7 @@ def load_dll(libname, fallbacks=None):
|
|
|
43
43
|
"Could not find library %s or load any of its variants %s" % (
|
|
44
44
|
libname, fallbacks or []))
|
|
45
45
|
|
|
46
|
-
if sys.platform
|
|
46
|
+
if sys.platform.startswith('linux'):
|
|
47
47
|
_lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
|
|
48
48
|
free = load_dll('c').free
|
|
49
49
|
free.argtypes = [c_void_p]
|
|
@@ -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
|
-
|
|
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)
|
|
@@ -92,6 +92,7 @@ else: # other *nix systems
|
|
|
92
92
|
|
|
93
93
|
def _geos_c_version():
|
|
94
94
|
func = _lgeos.GEOSversion
|
|
95
|
+
func.argtypes = []
|
|
95
96
|
func.restype = c_char_p
|
|
96
97
|
v = func().split('-')[2]
|
|
97
98
|
return tuple(int(n) for n in v.split('.'))
|
|
@@ -129,7 +130,7 @@ if geos_c_version >= (1,5,0):
|
|
|
129
130
|
|
|
130
131
|
# Handle special case.
|
|
131
132
|
_lgeos.initGEOS_r.restype = c_void_p
|
|
132
|
-
_lgeos.initGEOS_r.argtypes = [
|
|
133
|
+
_lgeos.initGEOS_r.argtypes = [EXCEPTION_HANDLER_FUNCTYPE, EXCEPTION_HANDLER_FUNCTYPE]
|
|
133
134
|
_lgeos.finishGEOS_r.argtypes = [c_void_p]
|
|
134
135
|
|
|
135
136
|
# Exceptions
|
|
@@ -148,11 +149,11 @@ class PredicateError(Exception):
|
|
|
148
149
|
|
|
149
150
|
def error_handler(fmt, list):
|
|
150
151
|
LOG.error("%s", list)
|
|
151
|
-
error_h =
|
|
152
|
+
error_h = EXCEPTION_HANDLER_FUNCTYPE(error_handler)
|
|
152
153
|
|
|
153
154
|
def notice_handler(fmt, list):
|
|
154
155
|
LOG.warning("%s", list)
|
|
155
|
-
notice_h =
|
|
156
|
+
notice_h = EXCEPTION_HANDLER_FUNCTYPE(notice_handler)
|
|
156
157
|
|
|
157
158
|
def cleanup():
|
|
158
159
|
if _lgeos is not None :
|
|
@@ -166,7 +167,7 @@ def errcheck_wkb(result, func, argtuple):
|
|
|
166
167
|
if not result:
|
|
167
168
|
return None
|
|
168
169
|
size_ref = argtuple[-1]
|
|
169
|
-
size = size_ref.
|
|
170
|
+
size = size_ref.contents
|
|
170
171
|
retval = ctypes.string_at(result, size.value)[:]
|
|
171
172
|
lgeos.GEOSFree(result)
|
|
172
173
|
return retval
|
shapely/geos.pyc
CHANGED
|
Binary file
|
shapely/predicates.py
CHANGED
|
@@ -7,13 +7,13 @@ from shapely.topology import Delegating
|
|
|
7
7
|
class BinaryPredicate(Delegating):
|
|
8
8
|
def __call__(self, this, other, *args):
|
|
9
9
|
self._validate(this)
|
|
10
|
-
self._validate(other)
|
|
10
|
+
self._validate(other, stop_prepared=True)
|
|
11
11
|
return self.fn(this._geom, other._geom, *args)
|
|
12
12
|
|
|
13
13
|
class RelateOp(Delegating):
|
|
14
14
|
def __call__(self, this, other):
|
|
15
15
|
self._validate(this)
|
|
16
|
-
self._validate(other)
|
|
16
|
+
self._validate(other, stop_prepared=True)
|
|
17
17
|
return self.fn(this._geom, other._geom)
|
|
18
18
|
|
|
19
19
|
class UnaryPredicate(Delegating):
|
shapely/predicates.pyc
CHANGED
|
Binary file
|
shapely/prepared.py
CHANGED
|
@@ -27,7 +27,10 @@ class PreparedGeometry(object):
|
|
|
27
27
|
|
|
28
28
|
def __del__(self):
|
|
29
29
|
if self.__geom__ is not None:
|
|
30
|
-
|
|
30
|
+
try:
|
|
31
|
+
lgeos.GEOSPreparedGeom_destroy(self.__geom__)
|
|
32
|
+
except AttributeError:
|
|
33
|
+
pass # lgeos might be empty on shutdown
|
|
31
34
|
self.__geom__ = None
|
|
32
35
|
self.context = None
|
|
33
36
|
|
shapely/prepared.pyc
CHANGED
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
from shapely.geometry import linestring, polygon
|
|
4
|
+
from shapely import coords
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
from shapely.speedups import _speedups
|
|
8
|
+
available = True
|
|
9
|
+
import_error_msg = None
|
|
10
|
+
except ImportError:
|
|
11
|
+
import sys
|
|
12
|
+
available = False
|
|
13
|
+
import_error_msg = tuple(sys.exc_info()[1])
|
|
14
|
+
|
|
15
|
+
__all__ = ['available', 'enable', 'disable']
|
|
16
|
+
_orig = {}
|
|
17
|
+
|
|
18
|
+
def enable():
|
|
19
|
+
if not available:
|
|
20
|
+
warnings.warn("shapely.speedups not available", RuntimeWarning)
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
if _orig:
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
_orig['CoordinateSequence.ctypes'] = coords.CoordinateSequence.ctypes
|
|
27
|
+
coords.CoordinateSequence.ctypes = property(_speedups.coordseq_ctypes)
|
|
28
|
+
|
|
29
|
+
_orig['geos_linestring_from_py'] = linestring.geos_linestring_from_py
|
|
30
|
+
linestring.geos_linestring_from_py = _speedups.geos_linestring_from_py
|
|
31
|
+
|
|
32
|
+
_orig['geos_linearring_from_py'] = polygon.geos_linearring_from_py
|
|
33
|
+
polygon.geos_linearring_from_py = _speedups.geos_linearring_from_py
|
|
34
|
+
|
|
35
|
+
def disable():
|
|
36
|
+
if not _orig:
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
coords.CoordinateSequence.ctypes = _orig['CoordinateSequence.ctypes']
|
|
40
|
+
linestring.geos_linestring_from_py = _orig['geos_linestring_from_py']
|
|
41
|
+
polygon.geos_linearring_from_py = _orig['geos_linearring_from_py']
|
|
42
|
+
_orig.clear()
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
def __bootstrap__():
|
|
2
|
+
global __bootstrap__, __loader__, __file__
|
|
3
|
+
import sys, pkg_resources, imp
|
|
4
|
+
__file__ = pkg_resources.resource_filename(__name__,'_speedups.pyd')
|
|
5
|
+
__loader__ = None; del __bootstrap__, __loader__
|
|
6
|
+
imp.load_dynamic(__name__,__file__)
|
|
7
|
+
__bootstrap__()
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from unittest import TestSuite
|
|
2
|
+
|
|
3
|
+
import test_doctests, test_prepared, test_equality, test_geomseq, test_xy
|
|
4
|
+
import test_collection, test_emptiness, test_singularity, test_validation
|
|
5
|
+
import test_mapping, test_delegated, test_dlls, test_linear_referencing
|
|
6
|
+
import test_products_z, test_box, test_speedups, test_cga
|
|
7
|
+
|
|
8
|
+
def test_suite():
|
|
9
|
+
suite = TestSuite()
|
|
10
|
+
suite.addTest(test_doctests.test_suite())
|
|
11
|
+
suite.addTest(test_prepared.test_suite())
|
|
12
|
+
suite.addTest(test_emptiness.test_suite())
|
|
13
|
+
suite.addTest(test_equality.test_suite())
|
|
14
|
+
suite.addTest(test_geomseq.test_suite())
|
|
15
|
+
suite.addTest(test_xy.test_suite())
|
|
16
|
+
suite.addTest(test_collection.test_suite())
|
|
17
|
+
suite.addTest(test_singularity.test_suite())
|
|
18
|
+
suite.addTest(test_validation.test_suite())
|
|
19
|
+
suite.addTest(test_mapping.test_suite())
|
|
20
|
+
suite.addTest(test_delegated.test_suite())
|
|
21
|
+
suite.addTest(test_dlls.test_suite())
|
|
22
|
+
suite.addTest(test_linear_referencing.test_suite())
|
|
23
|
+
suite.addTest(test_products_z.test_suite())
|
|
24
|
+
suite.addTest(test_box.test_suite())
|
|
25
|
+
suite.addTest(test_speedups.test_suite())
|
|
26
|
+
suite.addTest(test_cga.test_suite())
|
|
27
|
+
return suite
|
|
28
|
+
|
|
Binary file
|