shapely 1.0a7__py2.4.egg → 1.0b2__py2.4.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 +17 -8
- EGG-INFO/SOURCES.txt +6 -2
- shapely/geometry/base.py +33 -2
- shapely/geometry/base.pyc +0 -0
- shapely/geometry/linestring.py +6 -14
- shapely/geometry/linestring.pyc +0 -0
- shapely/geometry/multipoint.py +6 -14
- shapely/geometry/multipoint.pyc +0 -0
- shapely/geometry/point.py +7 -14
- shapely/geometry/point.pyc +0 -0
- shapely/topology.py +11 -1
- shapely/topology.pyc +0 -0
- shapely/json.py +0 -47
- shapely/json.pyc +0 -0
EGG-INFO/PKG-INFO
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: Shapely
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.0b2
|
|
4
4
|
Summary: Geospatial geometries, predicates, and operations
|
|
5
|
-
Home-page: http://trac.gispython.org/projects/PCL/wiki/
|
|
5
|
+
Home-page: http://trac.gispython.org/projects/PCL/wiki/Shapely
|
|
6
6
|
Author: Sean Gillies
|
|
7
7
|
Author-email: sgillies@frii.com
|
|
8
|
-
License:
|
|
8
|
+
License: BSD
|
|
9
9
|
Description: Shapely
|
|
10
10
|
=======
|
|
11
11
|
|
|
@@ -20,9 +20,6 @@ Description: Shapely
|
|
|
20
20
|
Shapely requires Python 2.4+. (I've also begun to port it to Python 3.0:
|
|
21
21
|
http://zcologia.com/news/564/shapely-for-python-3-0/.)
|
|
22
22
|
|
|
23
|
-
.. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
|
|
24
|
-
.. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
|
|
25
|
-
|
|
26
23
|
Dependencies
|
|
27
24
|
------------
|
|
28
25
|
|
|
@@ -121,13 +118,25 @@ Description: Shapely
|
|
|
121
118
|
There are also two test runners under tests/. test_doctests.py requires
|
|
122
119
|
zope.testing. runalldoctests.py does not.
|
|
123
120
|
|
|
121
|
+
Support
|
|
122
|
+
-------
|
|
123
|
+
|
|
124
|
+
For current information about this project, see the wiki_.
|
|
125
|
+
|
|
126
|
+
.. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
|
|
127
|
+
.. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
|
|
128
|
+
|
|
129
|
+
If you have questions, please consider joining our community list:
|
|
130
|
+
|
|
131
|
+
http://trac.gispython.org/projects/PCL/wiki/CommunityList
|
|
132
|
+
|
|
124
133
|
|
|
125
134
|
Keywords: geometry topology
|
|
126
135
|
Platform: UNKNOWN
|
|
127
|
-
Classifier: Development Status ::
|
|
136
|
+
Classifier: Development Status :: 4 - Beta
|
|
128
137
|
Classifier: Intended Audience :: Developers
|
|
129
138
|
Classifier: Intended Audience :: Science/Research
|
|
130
|
-
Classifier: License :: OSI Approved ::
|
|
139
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
131
140
|
Classifier: Operating System :: OS Independent
|
|
132
141
|
Classifier: Programming Language :: Python
|
|
133
142
|
Classifier: Topic :: Scientific/Engineering :: GIS
|
EGG-INFO/SOURCES.txt
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
CHANGES.txt
|
|
1
2
|
CREDITS.txt
|
|
3
|
+
HISTORY.txt
|
|
4
|
+
LICENSE.txt
|
|
2
5
|
README.txt
|
|
3
6
|
setup.py
|
|
4
7
|
Shapely.egg-info/PKG-INFO
|
|
@@ -39,7 +42,8 @@ tests/Point.txt
|
|
|
39
42
|
tests/Polygon.txt
|
|
40
43
|
tests/Predicates.txt
|
|
41
44
|
tests/__init__.py
|
|
42
|
-
tests/
|
|
45
|
+
tests/binascii_hex.txt
|
|
46
|
+
tests/invalid_intersection.txt
|
|
43
47
|
tests/rungrind.dist
|
|
44
|
-
tests/runtests.dist
|
|
45
48
|
tests/test_doctests.py
|
|
49
|
+
tests/valgrind-python.supp
|
shapely/geometry/base.py
CHANGED
|
@@ -3,17 +3,34 @@ Base geometry class and utilities.
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from ctypes import string_at, byref, c_int, c_size_t, c_char_p, c_double
|
|
6
|
+
import sys
|
|
6
7
|
|
|
7
8
|
from shapely.geos import lgeos
|
|
8
9
|
from shapely.predicates import BinaryPredicate, UnaryPredicate
|
|
9
10
|
from shapely.topology import BinaryTopologicalOp, UnaryTopologicalOp
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
GEOMETRY_TYPES = [
|
|
14
|
+
'Point',
|
|
15
|
+
'LineString',
|
|
16
|
+
'LinearRing',
|
|
17
|
+
'Polygon',
|
|
18
|
+
'MultiPoint',
|
|
19
|
+
'MultiLineString',
|
|
20
|
+
'MultiPolygon',
|
|
21
|
+
'GeometryCollection'
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
def geometry_type_name(g):
|
|
25
|
+
return GEOMETRY_TYPES[lgeos.GEOSGeomTypeId(g)]
|
|
26
|
+
|
|
12
27
|
# Abstract geometry factory for use with topological methods below
|
|
13
28
|
|
|
14
29
|
def geom_factory(g):
|
|
30
|
+
if not g:
|
|
31
|
+
raise ValueError, "No Shapely geometry can be created from this null value"
|
|
15
32
|
ob = BaseGeometry()
|
|
16
|
-
geom_type =
|
|
33
|
+
geom_type = geometry_type_name(g)
|
|
17
34
|
# TODO: check cost of dynamic import by profiling
|
|
18
35
|
mod = __import__(
|
|
19
36
|
'shapely.geometry',
|
|
@@ -186,6 +203,20 @@ class BaseGeometry(object):
|
|
|
186
203
|
To be overridden by extension classes."""
|
|
187
204
|
raise NotImplementedError
|
|
188
205
|
|
|
206
|
+
@property
|
|
207
|
+
def array_interface_base(self):
|
|
208
|
+
if sys.byteorder == 'little':
|
|
209
|
+
typestr = '<f8'
|
|
210
|
+
elif sys.byteorder == 'big':
|
|
211
|
+
typestr = '>f8'
|
|
212
|
+
else:
|
|
213
|
+
raise ValueError, "Unsupported byteorder: neither little nor big-endian"
|
|
214
|
+
return {
|
|
215
|
+
'version': 3,
|
|
216
|
+
'typestr': typestr,
|
|
217
|
+
'data': self.ctypes,
|
|
218
|
+
}
|
|
219
|
+
|
|
189
220
|
@property
|
|
190
221
|
def __array_interface__(self):
|
|
191
222
|
"""Provide the Numpy array protocol."""
|
|
@@ -214,7 +245,7 @@ class BaseGeometry(object):
|
|
|
214
245
|
|
|
215
246
|
def geometryType(self):
|
|
216
247
|
"""Returns a string representing the geometry type, e.g. 'Polygon'."""
|
|
217
|
-
return
|
|
248
|
+
return geometry_type_name(self._geom)
|
|
218
249
|
|
|
219
250
|
def to_wkb(self):
|
|
220
251
|
"""Returns a WKB byte string representation of the geometry."""
|
shapely/geometry/base.pyc
CHANGED
|
Binary file
|
shapely/geometry/linestring.py
CHANGED
|
@@ -154,15 +154,12 @@ class LineString(BaseGeometry):
|
|
|
154
154
|
self._ctypes_data = data
|
|
155
155
|
return self._ctypes_data
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
def __array_interface__(self):
|
|
157
|
+
def array_interface(self):
|
|
159
158
|
"""Provide the Numpy array protocol."""
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
'data': self.ctypes,
|
|
165
|
-
}
|
|
159
|
+
ai = self.array_interface_base
|
|
160
|
+
ai.update({'shape': (len(self.coords), self._ndim)})
|
|
161
|
+
return ai
|
|
162
|
+
__array_interface__ = property(array_interface)
|
|
166
163
|
|
|
167
164
|
# Coordinate access
|
|
168
165
|
|
|
@@ -210,12 +207,7 @@ class LineStringAdapter(LineString):
|
|
|
210
207
|
try:
|
|
211
208
|
return self.context.__array_interface__
|
|
212
209
|
except AttributeError:
|
|
213
|
-
return
|
|
214
|
-
'version': 3,
|
|
215
|
-
'shape': (self._ndim,),
|
|
216
|
-
'typestr': '<f8',
|
|
217
|
-
'data': self.ctypes,
|
|
218
|
-
}
|
|
210
|
+
return self.array_interface()
|
|
219
211
|
|
|
220
212
|
coords = property(BaseGeometry.get_coords)
|
|
221
213
|
|
shapely/geometry/linestring.pyc
CHANGED
|
Binary file
|
shapely/geometry/multipoint.py
CHANGED
|
@@ -108,15 +108,12 @@ class MultiPoint(BaseGeometry):
|
|
|
108
108
|
self._ctypes_data = data
|
|
109
109
|
return self._ctypes_data
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
def __array_interface__(self):
|
|
111
|
+
def array_interface(self):
|
|
113
112
|
"""Provide the Numpy array protocol."""
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'data': self.ctypes,
|
|
119
|
-
}
|
|
113
|
+
ai = self.array_interface_base
|
|
114
|
+
ai.update({'shape': (len(self.geoms), self._ndim)})
|
|
115
|
+
return ai
|
|
116
|
+
__array_interface__ = property(array_interface)
|
|
120
117
|
|
|
121
118
|
@property
|
|
122
119
|
def coords(self):
|
|
@@ -166,12 +163,7 @@ class MultiPointAdapter(MultiPoint):
|
|
|
166
163
|
try:
|
|
167
164
|
return self.context.__array_interface__
|
|
168
165
|
except AttributeError:
|
|
169
|
-
return
|
|
170
|
-
'version': 3,
|
|
171
|
-
'shape': (self._ndim,),
|
|
172
|
-
'typestr': '<f8',
|
|
173
|
-
'data': self.ctypes,
|
|
174
|
-
}
|
|
166
|
+
return self.array_interface()
|
|
175
167
|
|
|
176
168
|
|
|
177
169
|
def asMultiPoint(context):
|
shapely/geometry/multipoint.pyc
CHANGED
|
Binary file
|
shapely/geometry/point.py
CHANGED
|
@@ -159,15 +159,12 @@ class Point(BaseGeometry):
|
|
|
159
159
|
self._ctypes_data = array
|
|
160
160
|
return self._ctypes_data
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
def __array_interface__(self):
|
|
162
|
+
def array_interface(self):
|
|
164
163
|
"""Provide the Numpy array protocol."""
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
'data': self.ctypes,
|
|
170
|
-
}
|
|
164
|
+
ai = self.array_interface_base
|
|
165
|
+
ai.update({'shape': (self._ndim,)})
|
|
166
|
+
return ai
|
|
167
|
+
__array_interface__ = property(array_interface)
|
|
171
168
|
|
|
172
169
|
@property
|
|
173
170
|
def bounds(self):
|
|
@@ -225,15 +222,11 @@ class PointAdapter(Point):
|
|
|
225
222
|
try:
|
|
226
223
|
return self.context.__array_interface__
|
|
227
224
|
except AttributeError:
|
|
228
|
-
return
|
|
229
|
-
'version': 3,
|
|
230
|
-
'shape': (self._ndim,),
|
|
231
|
-
'typestr': '<f8',
|
|
232
|
-
'data': self.ctypes,
|
|
233
|
-
}
|
|
225
|
+
return self.array_interface()
|
|
234
226
|
|
|
235
227
|
coords = property(BaseGeometry.get_coords)
|
|
236
228
|
|
|
229
|
+
|
|
237
230
|
def asPoint(context):
|
|
238
231
|
"""Factory for PointAdapter instances."""
|
|
239
232
|
return PointAdapter(context)
|
shapely/geometry/point.pyc
CHANGED
|
Binary file
|
shapely/topology.py
CHANGED
|
@@ -26,7 +26,17 @@ class BinaryTopologicalOp(object):
|
|
|
26
26
|
return self
|
|
27
27
|
|
|
28
28
|
def __call__(self, other):
|
|
29
|
-
|
|
29
|
+
product = self.fn(self.context._geom, other._geom)
|
|
30
|
+
if not product:
|
|
31
|
+
# Check validity of geometries
|
|
32
|
+
if not self.context.is_valid:
|
|
33
|
+
raise TopologicalError, \
|
|
34
|
+
"The operation '%s' produced a null geometry. Likely cause is invalidity of the geometry %s" % (self.fn.__name__, repr(self.context))
|
|
35
|
+
elif not other.is_valid:
|
|
36
|
+
raise TopologicalError, \
|
|
37
|
+
"The operation '%s' produced a null geometry. Likely cause is invalidity of the 'other' geometry %s" % (self.fn.__name__, repr(other))
|
|
38
|
+
|
|
39
|
+
return self.factory(product)
|
|
30
40
|
|
|
31
41
|
|
|
32
42
|
class UnaryTopologicalOp(object):
|
shapely/topology.pyc
CHANGED
|
Binary file
|
shapely/json.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Load/dump geometries using JSON.
|
|
3
|
-
|
|
4
|
-
Includes a JSON-based abstract geometry factory.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import geojson
|
|
8
|
-
|
|
9
|
-
def json_factory(ob):
|
|
10
|
-
"""Attempts to create a geometry from JSON.
|
|
11
|
-
|
|
12
|
-
Else, returns the original data.
|
|
13
|
-
"""
|
|
14
|
-
try:
|
|
15
|
-
coords = ob.get('coordinates', [])
|
|
16
|
-
geom_type = str(ob.get('type'))
|
|
17
|
-
mod = __import__(
|
|
18
|
-
'shapely.geometry',
|
|
19
|
-
globals(),
|
|
20
|
-
locals(),
|
|
21
|
-
[geom_type],
|
|
22
|
-
)
|
|
23
|
-
geom_class = getattr(mod, geom_type)
|
|
24
|
-
return geom_class(*coords)
|
|
25
|
-
except (KeyError, TypeError):
|
|
26
|
-
raise
|
|
27
|
-
return ob
|
|
28
|
-
|
|
29
|
-
# Pickle-like convenience functions
|
|
30
|
-
|
|
31
|
-
def loads(data):
|
|
32
|
-
"""Load a geometry from a GeoJSON representation."""
|
|
33
|
-
return geojson.loads(data, json_factory)
|
|
34
|
-
|
|
35
|
-
def load(fp):
|
|
36
|
-
"""Load a geometry from an open file."""
|
|
37
|
-
data = fp.read()
|
|
38
|
-
return loads(data)
|
|
39
|
-
|
|
40
|
-
def dumps(ob):
|
|
41
|
-
"""Dump a GeoJSON representation of a geometry to a string."""
|
|
42
|
-
return geojson.dumps(ob)
|
|
43
|
-
|
|
44
|
-
def dump(ob, fp):
|
|
45
|
-
"""Dump a geometry to an open file."""
|
|
46
|
-
fp.write(dumps(ob))
|
|
47
|
-
|
shapely/json.pyc
DELETED
|
Binary file
|