shapely 1.0a7__tar.gz → 1.0b2__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.0a7 → Shapely-1.0b2}/CREDITS.txt +1 -0
- Shapely-1.0b2/HISTORY.txt +0 -0
- Shapely-1.0b2/LICENSE.txt +28 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/PKG-INFO +17 -8
- {Shapely-1.0a7 → Shapely-1.0b2}/README.txt +12 -3
- {Shapely-1.0a7 → Shapely-1.0b2}/Shapely.egg-info/PKG-INFO +17 -8
- {Shapely-1.0a7 → Shapely-1.0b2}/Shapely.egg-info/SOURCES.txt +6 -2
- {Shapely-1.0a7 → Shapely-1.0b2}/setup.py +7 -6
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/base.py +33 -2
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/linestring.py +6 -14
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/multipoint.py +6 -14
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/point.py +7 -14
- Shapely-1.0b2/shapely/kml.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/topology.py +11 -1
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/Persist.txt +0 -2
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/Point.txt +1 -1
- Shapely-1.0b2/tests/__init__.py +2 -0
- Shapely-1.0b2/tests/binascii_hex.txt +47 -0
- Shapely-1.0b2/tests/invalid_intersection.txt +29 -0
- Shapely-1.0b2/tests/rungrind.dist +4 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/test_doctests.py +5 -2
- Shapely-1.0b2/tests/valgrind-python.supp +240 -0
- Shapely-1.0a7/tests/__init__.py +0 -1
- Shapely-1.0a7/tests/runalldoctests.py +0 -49
- Shapely-1.0a7/tests/rungrind.dist +0 -4
- Shapely-1.0a7/tests/runtests.dist +0 -4
- /Shapely-1.0a7/shapely/kml.py → /Shapely-1.0b2/CHANGES.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/Shapely.egg-info/dependency_links.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/Shapely.egg-info/requires.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/Shapely.egg-info/top_level.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/examples/geoms.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/examples/world.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/setup.cfg +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/__init__.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/__init__.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/collection.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/geo.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/multilinestring.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/multipolygon.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geometry/polygon.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/geos.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/iterops.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/predicates.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/wkb.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/shapely/wkt.py +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/Array.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/GeoInterface.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/IterOps.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/LineString.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/MultiLineString.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/MultiPoint.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/MultiPolygon.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/Operations.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/Polygon.txt +0 -0
- {Shapely-1.0a7 → Shapely-1.0b2}/tests/Predicates.txt +0 -0
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
Copyright (c) 2007, Sean C. Gillies
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
documentation and/or other materials provided with the distribution.
|
|
13
|
+
* Neither the name of Sean C. Gillies nor the names of
|
|
14
|
+
its contributors may be used to endorse or promote products derived from
|
|
15
|
+
this software without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
21
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
@@ -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
|
|
@@ -12,9 +12,6 @@ applications. For more information, see:
|
|
|
12
12
|
Shapely requires Python 2.4+. (I've also begun to port it to Python 3.0:
|
|
13
13
|
http://zcologia.com/news/564/shapely-for-python-3-0/.)
|
|
14
14
|
|
|
15
|
-
.. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
|
|
16
|
-
.. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
|
|
17
|
-
|
|
18
15
|
Dependencies
|
|
19
16
|
------------
|
|
20
17
|
|
|
@@ -113,3 +110,15 @@ Several of the modules have docstring doctests::
|
|
|
113
110
|
There are also two test runners under tests/. test_doctests.py requires
|
|
114
111
|
zope.testing. runalldoctests.py does not.
|
|
115
112
|
|
|
113
|
+
Support
|
|
114
|
+
-------
|
|
115
|
+
|
|
116
|
+
For current information about this project, see the wiki_.
|
|
117
|
+
|
|
118
|
+
.. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
|
|
119
|
+
.. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
|
|
120
|
+
|
|
121
|
+
If you have questions, please consider joining our community list:
|
|
122
|
+
|
|
123
|
+
http://trac.gispython.org/projects/PCL/wiki/CommunityList
|
|
124
|
+
|
|
@@ -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
|
|
@@ -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
|
|
@@ -5,24 +5,25 @@ from setuptools import setup, Extension
|
|
|
5
5
|
readme_text = file('README.txt', 'rb').read()
|
|
6
6
|
|
|
7
7
|
setup(name = 'Shapely',
|
|
8
|
-
version = '1.
|
|
8
|
+
version = '1.0b2',
|
|
9
9
|
description = 'Geospatial geometries, predicates, and operations',
|
|
10
|
-
license = '
|
|
10
|
+
license = 'BSD',
|
|
11
11
|
keywords = 'geometry topology',
|
|
12
12
|
author = 'Sean Gillies',
|
|
13
13
|
author_email = 'sgillies@frii.com',
|
|
14
14
|
maintainer = 'Sean Gillies',
|
|
15
15
|
maintainer_email = 'sgillies@frii.com',
|
|
16
|
-
url = 'http://trac.gispython.org/projects/PCL/wiki/
|
|
16
|
+
url = 'http://trac.gispython.org/projects/PCL/wiki/Shapely',
|
|
17
17
|
long_description = readme_text,
|
|
18
18
|
packages = ['shapely', 'shapely.geometry'],
|
|
19
19
|
install_requires = ['setuptools', 'ctypes'],
|
|
20
|
-
tests_require = ['
|
|
20
|
+
#tests_require = ['numpy'], -- not working with "tests" command
|
|
21
|
+
test_suite = 'tests.test_suite',
|
|
21
22
|
classifiers = [
|
|
22
|
-
'Development Status ::
|
|
23
|
+
'Development Status :: 4 - Beta',
|
|
23
24
|
'Intended Audience :: Developers',
|
|
24
25
|
'Intended Audience :: Science/Research',
|
|
25
|
-
'License :: OSI Approved ::
|
|
26
|
+
'License :: OSI Approved :: BSD License',
|
|
26
27
|
'Operating System :: OS Independent',
|
|
27
28
|
'Programming Language :: Python',
|
|
28
29
|
'Topic :: Scientific/Engineering :: GIS',
|
|
@@ -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."""
|
|
@@ -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
|
|
|
@@ -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):
|
|
@@ -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)
|
|
File without changes
|
|
@@ -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):
|
|
@@ -74,7 +74,6 @@ Modify coordinates
|
|
|
74
74
|
>>> p.__geo_interface__
|
|
75
75
|
{'type': 'Point', 'coordinates': (0.0, 0.0)}
|
|
76
76
|
|
|
77
|
-
|
|
78
77
|
Adapter
|
|
79
78
|
-------
|
|
80
79
|
|
|
@@ -117,6 +116,7 @@ Adapter
|
|
|
117
116
|
|
|
118
117
|
Now, the inverse
|
|
119
118
|
|
|
119
|
+
>>> ai = pa.__array_interface__
|
|
120
120
|
>>> as = asarray(pa)
|
|
121
121
|
>>> as
|
|
122
122
|
array([ 1., 4.])
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Round-tripping geometries through hex-encoded binary
|
|
2
|
+
====================================================
|
|
3
|
+
|
|
4
|
+
Hex-encoded binary is the PostGIS geometry representation, and so this is a
|
|
5
|
+
test of the ability to store Shapely geometries in PostGIS.
|
|
6
|
+
|
|
7
|
+
Point
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
>>> from shapely.geometry import Point
|
|
11
|
+
>>> point = Point(0.0, 0.0)
|
|
12
|
+
>>> import binascii
|
|
13
|
+
>>> x = binascii.b2a_hex(point.wkb)
|
|
14
|
+
>>> from shapely import wkb
|
|
15
|
+
>>> shape = wkb.loads(binascii.a2b_hex(x))
|
|
16
|
+
>>> shape # doctest: +ELLIPSIS
|
|
17
|
+
<shapely.geometry.point.Point object at ...>
|
|
18
|
+
|
|
19
|
+
LineString
|
|
20
|
+
----------
|
|
21
|
+
|
|
22
|
+
>>> from shapely.geometry import LineString
|
|
23
|
+
>>> line = LineString(((0.0, 0.0), (1.0, 1.0)))
|
|
24
|
+
>>> x = binascii.b2a_hex(line.wkb)
|
|
25
|
+
>>> shape = wkb.loads(binascii.a2b_hex(x))
|
|
26
|
+
>>> shape # doctest: +ELLIPSIS
|
|
27
|
+
<shapely.geometry.linestring.LineString object at ...>
|
|
28
|
+
|
|
29
|
+
Polygon
|
|
30
|
+
----------
|
|
31
|
+
|
|
32
|
+
>>> from shapely.geometry import Polygon
|
|
33
|
+
>>> polygon = Polygon(((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)))
|
|
34
|
+
>>> x = binascii.b2a_hex(polygon.wkb)
|
|
35
|
+
>>> shape = wkb.loads(binascii.a2b_hex(x))
|
|
36
|
+
>>> shape # doctest: +ELLIPSIS
|
|
37
|
+
<shapely.geometry.polygon.Polygon object at ...>
|
|
38
|
+
|
|
39
|
+
Polygon with hole
|
|
40
|
+
-----------------
|
|
41
|
+
|
|
42
|
+
>>> polygon = Polygon(((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)), [((0.1,0.1), (0.1,0.2), (0.2,0.2), (0.2,0.1))])
|
|
43
|
+
>>> x = binascii.b2a_hex(polygon.wkb)
|
|
44
|
+
>>> shape = wkb.loads(binascii.a2b_hex(x))
|
|
45
|
+
>>> shape # doctest: +ELLIPSIS
|
|
46
|
+
<shapely.geometry.polygon.Polygon object at ...>
|
|
47
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Test recovery from operation on invalid geometries
|
|
2
|
+
==================================================
|
|
3
|
+
|
|
4
|
+
Make a self-intersecting polygon
|
|
5
|
+
|
|
6
|
+
>>> from shapely.geometry import Polygon
|
|
7
|
+
>>> polygon_invalid = Polygon(((0, 0), (1, 1), (1, -1), (0, 1), (0, 0)))
|
|
8
|
+
>>> polygon_invalid.is_valid
|
|
9
|
+
False
|
|
10
|
+
|
|
11
|
+
Intersect with a valid polygon
|
|
12
|
+
|
|
13
|
+
>>> polygon = Polygon(((-.5, -.5), (-.5, .5), (.5, .5), (.5, -5)))
|
|
14
|
+
>>> polygon.is_valid
|
|
15
|
+
True
|
|
16
|
+
>>> polygon_invalid.intersects(polygon)
|
|
17
|
+
True
|
|
18
|
+
>>> result = polygon_invalid.intersection(polygon) # doctest: +ELLIPSIS
|
|
19
|
+
Traceback (most recent call last):
|
|
20
|
+
...
|
|
21
|
+
TopologicalError: The operation 'GEOSIntersection' produced a null geometry. Likely cause is invalidity of the geometry <shapely.geometry.polygon.Polygon object at ...>
|
|
22
|
+
|
|
23
|
+
Check exception symmetry
|
|
24
|
+
|
|
25
|
+
>>> result = polygon.intersection(polygon_invalid) # doctest: +ELLIPSIS
|
|
26
|
+
Traceback (most recent call last):
|
|
27
|
+
...
|
|
28
|
+
TopologicalError: The operation 'GEOSIntersection' produced a null geometry. Likely cause is invalidity of the 'other' geometry <shapely.geometry.polygon.Polygon object at ...>
|
|
29
|
+
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import doctest
|
|
1
2
|
import unittest
|
|
2
3
|
import glob
|
|
3
4
|
import os
|
|
4
5
|
|
|
5
|
-
from zope.testing import doctest
|
|
6
|
-
|
|
7
6
|
optionflags = (doctest.REPORT_ONLY_FIRST_FAILURE |
|
|
8
7
|
doctest.NORMALIZE_WHITESPACE |
|
|
9
8
|
doctest.ELLIPSIS)
|
|
@@ -29,3 +28,7 @@ def test_suite():
|
|
|
29
28
|
setUp=setUp)
|
|
30
29
|
for filename
|
|
31
30
|
in list_doctests()])
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
runner = unittest.TextTestRunner()
|
|
34
|
+
runner.run(test_suite())
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This is a valgrind suppression file that should be used when using valgrind.
|
|
3
|
+
#
|
|
4
|
+
# Here's an example of running valgrind:
|
|
5
|
+
#
|
|
6
|
+
# cd python/dist/src
|
|
7
|
+
# valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \
|
|
8
|
+
# ./python -E -tt ./Lib/test/regrtest.py -u bsddb,network
|
|
9
|
+
#
|
|
10
|
+
# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER
|
|
11
|
+
# to use the preferred suppressions with Py_ADDRESS_IN_RANGE.
|
|
12
|
+
#
|
|
13
|
+
# If you do not want to recompile Python, you can uncomment
|
|
14
|
+
# suppressions for PyObject_Free and PyObject_Realloc.
|
|
15
|
+
#
|
|
16
|
+
# See Misc/README.valgrind for more information.
|
|
17
|
+
|
|
18
|
+
# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
|
|
19
|
+
{
|
|
20
|
+
ADDRESS_IN_RANGE/Invalid read of size 4
|
|
21
|
+
Memcheck:Addr4
|
|
22
|
+
fun:Py_ADDRESS_IN_RANGE
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
ADDRESS_IN_RANGE/Invalid read of size 4
|
|
27
|
+
Memcheck:Value4
|
|
28
|
+
fun:Py_ADDRESS_IN_RANGE
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
|
|
33
|
+
Memcheck:Cond
|
|
34
|
+
fun:Py_ADDRESS_IN_RANGE
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
ADDRESS_IN_RANGE/Invalid read of size 4
|
|
39
|
+
Memcheck:Addr4
|
|
40
|
+
fun:PyObject_Free
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
ADDRESS_IN_RANGE/Invalid read of size 4
|
|
45
|
+
Memcheck:Value4
|
|
46
|
+
fun:PyObject_Free
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
|
|
51
|
+
Memcheck:Cond
|
|
52
|
+
fun:PyObject_Free
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
ADDRESS_IN_RANGE/Invalid read of size 4
|
|
57
|
+
Memcheck:Addr4
|
|
58
|
+
fun:PyObject_Realloc
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
ADDRESS_IN_RANGE/Invalid read of size 4
|
|
63
|
+
Memcheck:Value4
|
|
64
|
+
fun:PyObject_Realloc
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
|
|
69
|
+
Memcheck:Cond
|
|
70
|
+
fun:PyObject_Realloc
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
###
|
|
74
|
+
### All the suppressions below are for errors that occur within libraries
|
|
75
|
+
### that Python uses. The problems to not appear to be related to Python's
|
|
76
|
+
### use of the libraries.
|
|
77
|
+
###
|
|
78
|
+
{
|
|
79
|
+
GDBM problems, see test_gdbm
|
|
80
|
+
Memcheck:Param
|
|
81
|
+
write(buf)
|
|
82
|
+
fun:write
|
|
83
|
+
fun:gdbm_open
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
###
|
|
88
|
+
### These occur from somewhere within the SSL, when running
|
|
89
|
+
### test_socket_sll. They are too general to leave on by default.
|
|
90
|
+
###
|
|
91
|
+
###{
|
|
92
|
+
### somewhere in SSL stuff
|
|
93
|
+
### Memcheck:Cond
|
|
94
|
+
### fun:memset
|
|
95
|
+
###}
|
|
96
|
+
###{
|
|
97
|
+
### somewhere in SSL stuff
|
|
98
|
+
### Memcheck:Value4
|
|
99
|
+
### fun:memset
|
|
100
|
+
###}
|
|
101
|
+
###
|
|
102
|
+
###{
|
|
103
|
+
### somewhere in SSL stuff
|
|
104
|
+
### Memcheck:Cond
|
|
105
|
+
### fun:MD5_Update
|
|
106
|
+
###}
|
|
107
|
+
###
|
|
108
|
+
###{
|
|
109
|
+
### somewhere in SSL stuff
|
|
110
|
+
### Memcheck:Value4
|
|
111
|
+
### fun:MD5_Update
|
|
112
|
+
###}
|
|
113
|
+
|
|
114
|
+
#
|
|
115
|
+
# All of these problems come from using test_socket_ssl
|
|
116
|
+
#
|
|
117
|
+
{
|
|
118
|
+
from test_socket_ssl
|
|
119
|
+
Memcheck:Cond
|
|
120
|
+
fun:BN_bin2bn
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
from test_socket_ssl
|
|
125
|
+
Memcheck:Cond
|
|
126
|
+
fun:BN_num_bits_word
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
{
|
|
130
|
+
from test_socket_ssl
|
|
131
|
+
Memcheck:Value4
|
|
132
|
+
fun:BN_num_bits_word
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
{
|
|
136
|
+
from test_socket_ssl
|
|
137
|
+
Memcheck:Cond
|
|
138
|
+
fun:BN_mod_exp_mont_word
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
{
|
|
142
|
+
from test_socket_ssl
|
|
143
|
+
Memcheck:Cond
|
|
144
|
+
fun:BN_mod_exp_mont
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
{
|
|
148
|
+
from test_socket_ssl
|
|
149
|
+
Memcheck:Param
|
|
150
|
+
write(buf)
|
|
151
|
+
fun:write
|
|
152
|
+
obj:/usr/lib/libcrypto.so.0.9.7
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
{
|
|
156
|
+
from test_socket_ssl
|
|
157
|
+
Memcheck:Cond
|
|
158
|
+
fun:RSA_verify
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
{
|
|
162
|
+
from test_socket_ssl
|
|
163
|
+
Memcheck:Value4
|
|
164
|
+
fun:RSA_verify
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
{
|
|
168
|
+
from test_socket_ssl
|
|
169
|
+
Memcheck:Value4
|
|
170
|
+
fun:DES_set_key_unchecked
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
{
|
|
174
|
+
from test_socket_ssl
|
|
175
|
+
Memcheck:Value4
|
|
176
|
+
fun:DES_encrypt2
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
{
|
|
180
|
+
from test_socket_ssl
|
|
181
|
+
Memcheck:Cond
|
|
182
|
+
obj:/usr/lib/libssl.so.0.9.7
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
{
|
|
186
|
+
from test_socket_ssl
|
|
187
|
+
Memcheck:Value4
|
|
188
|
+
obj:/usr/lib/libssl.so.0.9.7
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
{
|
|
192
|
+
from test_socket_ssl
|
|
193
|
+
Memcheck:Cond
|
|
194
|
+
fun:BUF_MEM_grow_clean
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
{
|
|
198
|
+
from test_socket_ssl
|
|
199
|
+
Memcheck:Cond
|
|
200
|
+
fun:memcpy
|
|
201
|
+
fun:ssl3_read_bytes
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
from test_socket_ssl
|
|
206
|
+
Memcheck:Cond
|
|
207
|
+
fun:SHA1_Update
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
{
|
|
211
|
+
from test_socket_ssl
|
|
212
|
+
Memcheck:Value4
|
|
213
|
+
fun:SHA1_Update
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
# some extra lxml specific (?) suppressions..
|
|
218
|
+
|
|
219
|
+
{
|
|
220
|
+
Test
|
|
221
|
+
Memcheck:Param
|
|
222
|
+
sigaction(act)
|
|
223
|
+
fun:__libc_sigaction
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
{
|
|
227
|
+
ld
|
|
228
|
+
Memcheck:Cond
|
|
229
|
+
obj:/lib/ld-2.6.so
|
|
230
|
+
obj:/lib/ld-2.6.so
|
|
231
|
+
obj:*
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
{
|
|
235
|
+
ld
|
|
236
|
+
Memcheck:Addr4
|
|
237
|
+
obj:/lib/ld-2.6.so
|
|
238
|
+
obj:/lib/ld-2.6.so
|
|
239
|
+
obj:*
|
|
240
|
+
}
|
Shapely-1.0a7/tests/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# package
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
try:
|
|
3
|
-
import pkg_resources
|
|
4
|
-
pkg_resources.require('Shapely')
|
|
5
|
-
except:
|
|
6
|
-
pass
|
|
7
|
-
|
|
8
|
-
if __name__ == '__main__':
|
|
9
|
-
import doctest
|
|
10
|
-
import getopt
|
|
11
|
-
import glob
|
|
12
|
-
import sys
|
|
13
|
-
|
|
14
|
-
verbosity = 0
|
|
15
|
-
pattern = None
|
|
16
|
-
|
|
17
|
-
try:
|
|
18
|
-
opts, args = getopt.getopt(sys.argv[1:], 'vt:')
|
|
19
|
-
for o, a in opts:
|
|
20
|
-
if o == '-v':
|
|
21
|
-
verbosity = verbosity + 1
|
|
22
|
-
if o == '-t':
|
|
23
|
-
pattern = a
|
|
24
|
-
except:
|
|
25
|
-
pass
|
|
26
|
-
|
|
27
|
-
docfiles = [
|
|
28
|
-
'Array.txt',
|
|
29
|
-
'GeoInterface.txt',
|
|
30
|
-
'IterOps.txt',
|
|
31
|
-
'LineString.txt',
|
|
32
|
-
'MultiLineString.txt',
|
|
33
|
-
'MultiPoint.txt',
|
|
34
|
-
'MultiPolygon.txt',
|
|
35
|
-
'Operations.txt',
|
|
36
|
-
'Persist.txt',
|
|
37
|
-
'Point.txt',
|
|
38
|
-
'Polygon.txt',
|
|
39
|
-
'Predicates.txt'
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
if pattern:
|
|
43
|
-
tests = [f for f in docfiles if f.find(pattern) == 0]
|
|
44
|
-
else:
|
|
45
|
-
tests = docfiles
|
|
46
|
-
|
|
47
|
-
for file in tests:
|
|
48
|
-
doctest.testfile(file, verbose=verbosity)
|
|
49
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|