shapely 1.2b6__tar.gz → 1.2b7__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.
Files changed (66) hide show
  1. {Shapely-1.2b6 → Shapely-1.2b7}/CHANGES.txt +4 -0
  2. {Shapely-1.2b6 → Shapely-1.2b7}/PKG-INFO +1 -1
  3. {Shapely-1.2b6 → Shapely-1.2b7}/Shapely.egg-info/PKG-INFO +1 -1
  4. {Shapely-1.2b6 → Shapely-1.2b7}/setup.py +1 -1
  5. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/base.py +14 -6
  6. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/linestring.py +4 -18
  7. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/point.py +7 -18
  8. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/polygon.py +7 -35
  9. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/proxy.py +18 -11
  10. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geos.py +2 -1
  11. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/__init__.py +2 -1
  12. {Shapely-1.2b6 → Shapely-1.2b7}/CREDITS.txt +0 -0
  13. {Shapely-1.2b6 → Shapely-1.2b7}/LICENSE.txt +0 -0
  14. {Shapely-1.2b6 → Shapely-1.2b7}/MANIFEST.in +0 -0
  15. {Shapely-1.2b6 → Shapely-1.2b7}/README.txt +0 -0
  16. {Shapely-1.2b6 → Shapely-1.2b7}/Shapely.egg-info/SOURCES.txt +0 -0
  17. {Shapely-1.2b6 → Shapely-1.2b7}/Shapely.egg-info/dependency_links.txt +0 -0
  18. {Shapely-1.2b6 → Shapely-1.2b7}/Shapely.egg-info/top_level.txt +0 -0
  19. {Shapely-1.2b6 → Shapely-1.2b7}/examples/dissolve.py +0 -0
  20. {Shapely-1.2b6 → Shapely-1.2b7}/examples/intersect.py +0 -0
  21. {Shapely-1.2b6 → Shapely-1.2b7}/setup.cfg +0 -0
  22. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/__init__.py +0 -0
  23. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/coords.py +0 -0
  24. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/ctypes_declarations.py +0 -0
  25. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/__init__.py +0 -0
  26. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/collection.py +0 -0
  27. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/geo.py +0 -0
  28. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/multilinestring.py +0 -0
  29. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/multipoint.py +0 -0
  30. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geometry/multipolygon.py +0 -0
  31. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/geoms.py +0 -0
  32. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/impl.py +0 -0
  33. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/iterops.py +0 -0
  34. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/linref.py +0 -0
  35. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/ops.py +0 -0
  36. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/predicates.py +0 -0
  37. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/prepared.py +0 -0
  38. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/Array.txt +0 -0
  39. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/GeoInterface.txt +0 -0
  40. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/IterOps.txt +0 -0
  41. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/LineString.txt +0 -0
  42. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/MultiLineString.txt +0 -0
  43. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/MultiPoint.txt +0 -0
  44. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/MultiPolygon.txt +0 -0
  45. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/Operations.txt +0 -0
  46. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/Persist.txt +0 -0
  47. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/Point.txt +0 -0
  48. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/Polygon.txt +0 -0
  49. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/Predicates.txt +0 -0
  50. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/attribute-chains.txt +0 -0
  51. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/binascii_hex.txt +0 -0
  52. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/dimensions.txt +0 -0
  53. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/invalid_intersection.txt +0 -0
  54. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/linear-referencing.txt +0 -0
  55. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/linemerge.txt +0 -0
  56. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/polygonize.txt +0 -0
  57. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/test_doctests.py +0 -0
  58. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/test_equality.py +0 -0
  59. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/test_geomseq.py +0 -0
  60. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/test_prepared.py +0 -0
  61. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/test_xy.py +0 -0
  62. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/threading_test.py +0 -0
  63. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/tests/wkt_locale.txt +0 -0
  64. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/topology.py +0 -0
  65. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/wkb.py +0 -0
  66. {Shapely-1.2b6 → Shapely-1.2b7}/shapely/wkt.py +0 -0
@@ -1,5 +1,9 @@
1
1
  All tickets are children of http://trac.gispython.org/lab/ticket.
2
2
 
3
+ 1.2b7 (2010-04-22)
4
+ ------------------
5
+ - Memory leak associated with new empty geometry state fixed.
6
+
3
7
  1.2b6 (2010-04-13)
4
8
  ------------------
5
9
  - Broken GeometryCollection fixed.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.2b6
3
+ Version: 1.2b7
4
4
  Summary: Planar geometries, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/lab/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.2b6
3
+ Version: 1.2b7
4
4
  Summary: Planar geometries, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/lab/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -16,7 +16,7 @@ readme_text = file('README.txt', 'rb').read()
16
16
  setup_args = dict(
17
17
  metadata_version = '1.2',
18
18
  name = 'Shapely',
19
- version = '1.2b6',
19
+ version = '1.2b7',
20
20
  requires_python = '>=2.5,<3',
21
21
  requires_external = 'libgeos_c (>=3.1)',
22
22
  description = 'Planar geometries, predicates, and operations',
@@ -53,6 +53,7 @@ def exceptNull(func):
53
53
  return func(*args, **kwargs)
54
54
  return wrapper
55
55
 
56
+ EMPTY = wkb.deserialize('010700000000000000'.decode('hex'))
56
57
 
57
58
  class BaseGeometry(object):
58
59
  """
@@ -78,7 +79,7 @@ class BaseGeometry(object):
78
79
  # _owned : bool
79
80
  # True if this object's GEOS geometry is owned by another as in the case
80
81
  # of a multipart geometry member.
81
- __geom__ = None
82
+ __geom__ = EMPTY
82
83
  __p__ = None
83
84
  _ctypes_data = None
84
85
  _ndim = None
@@ -88,13 +89,18 @@ class BaseGeometry(object):
88
89
  # Backend config
89
90
  impl = DefaultImplementation
90
91
 
91
- def __init__(self):
92
- self.__geom__ = wkb.deserialize('010700000000000000'.decode('hex'))
92
+ @property
93
+ def _is_empty(self):
94
+ return self.__geom__ in [EMPTY, None]
93
95
 
94
- def __del__(self):
95
- if self.__geom__ is not None and not self._owned:
96
+ def empty(self):
97
+ if not (self._owned or self._is_empty):
96
98
  from shapely.geos import lgeos
97
99
  lgeos.GEOSGeom_destroy(self.__geom__)
100
+ self.__geom__ = EMPTY
101
+
102
+ def __del__(self):
103
+ self.empty()
98
104
  self.__geom__ = None
99
105
  self.__p__ = None
100
106
 
@@ -106,12 +112,14 @@ class BaseGeometry(object):
106
112
  return (self.__class__, (), self.to_wkb())
107
113
 
108
114
  def __setstate__(self, state):
115
+ self.empty()
109
116
  self.__geom__ = wkb.deserialize(state)
110
117
 
111
118
  # The _geom property
112
119
  def _get_geom(self):
113
120
  return self.__geom__
114
121
  def _set_geom(self, val):
122
+ self.empty()
115
123
  self.__geom__ = val
116
124
  _geom = property(_get_geom, _set_geom)
117
125
 
@@ -320,7 +328,7 @@ class BaseGeometry(object):
320
328
  @property
321
329
  def is_empty(self):
322
330
  """True if the set of points in this geometry is empty, else False"""
323
- return bool(self.impl['is_empty'](self))
331
+ return bool(self.impl['is_empty'](self)) or (self._geom is None)
324
332
 
325
333
  @property
326
334
  def is_ring(self):
@@ -37,14 +37,8 @@ class LineString(BaseGeometry):
37
37
  2.0
38
38
  """
39
39
  BaseGeometry.__init__(self)
40
- self._init_geom(coordinates)
41
-
42
- def _init_geom(self, coordinates):
43
- if coordinates is None:
44
- # allow creation of null lines, to support unpickling
45
- pass
46
- else:
47
- self._geom, self._ndim = geos_linestring_from_py(coordinates)
40
+ if coordinates is not None:
41
+ self._set_coords(coordinates)
48
42
 
49
43
  @property
50
44
  def __geo_interface__(self):
@@ -66,14 +60,9 @@ class LineString(BaseGeometry):
66
60
  __array_interface__ = property(array_interface)
67
61
 
68
62
  # Coordinate access
69
-
70
63
  def _set_coords(self, coordinates):
71
- if self.is_empty:
72
- lgeos.GEOSGeom_destroy(self.__geom__)
73
- self.__geom__ = None
74
- if self._geom is None:
75
- self._init_geom(coordinates)
76
- update_linestring_from_py(self, coordinates)
64
+ self.empty()
65
+ self._geom, self._ndim = geos_linestring_from_py(coordinates)
77
66
 
78
67
  coords = property(BaseGeometry._get_coords, _set_coords)
79
68
 
@@ -94,9 +83,6 @@ class LineString(BaseGeometry):
94
83
 
95
84
  class LineStringAdapter(CachingGeometryProxy, LineString):
96
85
 
97
- context = None
98
- _owned = False
99
-
100
86
  def __init__(self, context):
101
87
  self.context = context
102
88
  self.factory = geos_linestring_from_py
@@ -45,17 +45,8 @@ class Point(BaseGeometry):
45
45
  Easting, northing, and elevation.
46
46
  """
47
47
  BaseGeometry.__init__(self)
48
- self._init_geom(*args)
49
-
50
- def _init_geom(self, *args):
51
- if len(args) == 0:
52
- # allow creation of null points, to support unpickling
53
- pass
54
- else:
55
- if len(args) == 1:
56
- self._geom, self._ndim = geos_point_from_py(args[0])
57
- else:
58
- self._geom, self._ndim = geos_point_from_py(tuple(args))
48
+ if len(args) > 0:
49
+ self._set_coords(*args)
59
50
 
60
51
  # Coordinate getters and setters
61
52
 
@@ -110,14 +101,12 @@ class Point(BaseGeometry):
110
101
 
111
102
  # Coordinate access
112
103
 
113
- def _set_coords(self, coordinates):
114
- if self.is_empty:
115
- lgeos.GEOSGeom_destroy(self.__geom__)
116
- self.__geom__ = None
117
- if self._geom is None:
118
- self._init_geom(coordinates)
104
+ def _set_coords(self, *args):
105
+ self.empty()
106
+ if len(args) == 1:
107
+ self._geom, self._ndim = geos_point_from_py(args[0])
119
108
  else:
120
- update_point_from_py(self, coordinates)
109
+ self._geom, self._ndim = geos_point_from_py(tuple(args))
121
110
 
122
111
  coords = property(BaseGeometry._get_coords, _set_coords)
123
112
 
@@ -20,11 +20,6 @@ class LinearRing(LineString):
20
20
  invalid and operations on it may fail.
21
21
  """
22
22
 
23
- _ndim = None
24
- __geom__ = None
25
- __p__ = None
26
- _owned = False
27
-
28
23
  def __init__(self, coordinates=None):
29
24
  """
30
25
  Parameters
@@ -46,14 +41,8 @@ class LinearRing(LineString):
46
41
  4.0
47
42
  """
48
43
  BaseGeometry.__init__(self)
49
- self._init_geom(coordinates)
50
-
51
- def _init_geom(self, coordinates):
52
- if coordinates is None:
53
- # allow creation of null lines, to support unpickling
54
- pass
55
- else:
56
- self._geom, self._ndim = geos_linearring_from_py(coordinates)
44
+ if coordinates is not None:
45
+ self._set_coords(coordinates)
57
46
 
58
47
  @property
59
48
  def __geo_interface__(self):
@@ -67,30 +56,19 @@ class LinearRing(LineString):
67
56
  _get_coords = BaseGeometry._get_coords
68
57
 
69
58
  def _set_coords(self, coordinates):
70
- if self.is_empty:
71
- lgeos.GEOSGeom_destroy(self.__geom__)
72
- self.__geom__ = None
73
- if self._geom is None:
74
- self._init_geom(coordinates)
75
- update_linearring_from_py(self, coordinates)
59
+ self.empty()
60
+ self._geom, self._ndim = geos_linearring_from_py(coordinates)
76
61
 
77
62
  coords = property(_get_coords, _set_coords)
78
63
 
79
64
 
80
65
  class LinearRingAdapter(LineStringAdapter):
81
66
 
82
- context = None
83
- __geom__ = None
84
67
  __p__ = None
85
- _owned = False
86
68
 
87
- @property
88
- def _geom(self):
89
- """Keeps the GEOS geometry in synch with the context."""
90
- if self.__geom__ is not None:
91
- lgeos.GEOSGeom_destroy(self.__geom)
92
- self.__geom, n = geos_linearring_from_py(self.context)
93
- return self.__geom
69
+ def __init__(self, context):
70
+ self.context = context
71
+ self.factory = geos_linearring_from_py
94
72
 
95
73
  @property
96
74
  def __geo_interface__(self):
@@ -194,8 +172,6 @@ class Polygon(BaseGeometry):
194
172
  _exterior = None
195
173
  _interiors = []
196
174
  _ndim = 2
197
- __geom__ = None
198
- _owned = False
199
175
 
200
176
  def __init__(self, shell=None, holes=None):
201
177
  """
@@ -276,10 +252,6 @@ class Polygon(BaseGeometry):
276
252
 
277
253
  class PolygonAdapter(PolygonProxy, Polygon):
278
254
 
279
- context = None
280
- __geom__ = None
281
- _owned = False
282
-
283
255
  def __init__(self, shell, holes=None):
284
256
  self.shell = shell
285
257
  self.holes = holes
@@ -2,27 +2,37 @@
2
2
  """
3
3
 
4
4
  from shapely.geos import lgeos
5
+ from shapely import wkb
6
+
7
+ EMPTY = wkb.deserialize('010700000000000000'.decode('hex'))
5
8
 
6
9
 
7
10
  class CachingGeometryProxy(object):
8
11
 
9
12
  context = None
10
13
  factory = None
11
- __geom__ = None
14
+ __geom__ = EMPTY
12
15
  _gtag = None
13
16
 
14
17
  def __init__(self, context):
15
18
  self.context = context
16
19
 
20
+ @property
21
+ def _is_empty(self):
22
+ return self.__geom__ in [EMPTY, None]
23
+
24
+ def empty(self):
25
+ if not self._is_empty:
26
+ from shapely.geos import lgeos
27
+ lgeos.GEOSGeom_destroy(self.__geom__)
28
+ self.__geom__ = EMPTY
29
+
17
30
  @property
18
31
  def _geom(self):
19
32
  """Keeps the GEOS geometry in synch with the context."""
20
33
  gtag = self.gtag()
21
- if gtag != self._gtag:
22
- if self.__geom__ is not None:
23
- lgeos.GEOSGeom_destroy(self.__geom__)
24
- self.__geom__, n = self.factory(self.context)
25
- elif self.__geom__ is None:
34
+ if gtag != self._gtag or self._is_empty:
35
+ self.empty()
26
36
  self.__geom__, n = self.factory(self.context)
27
37
  self._gtag = gtag
28
38
  return self.__geom__
@@ -37,11 +47,8 @@ class PolygonProxy(CachingGeometryProxy):
37
47
  def _geom(self):
38
48
  """Keeps the GEOS geometry in synch with the context."""
39
49
  gtag = self.gtag()
40
- if gtag != self._gtag:
41
- if self.__geom__ is not None:
42
- lgeos.GEOSGeom_destroy(self.__geom__)
43
- self.__geom__, n = self.factory(self.context[0], self.context[1])
44
- elif self.__geom__ is None:
50
+ if gtag != self._gtag or self._is_empty:
51
+ self.empty()
45
52
  self.__geom__, n = self.factory(self.context[0], self.context[1])
46
53
  self._gtag = gtag
47
54
  return self.__geom__
@@ -136,6 +136,7 @@ if geos_c_version >= (1,5,0):
136
136
  # Handle special case.
137
137
  _lgeos.initGEOS_r.restype = c_void_p
138
138
  _lgeos.initGEOS_r.argtypes = [c_void_p, c_void_p]
139
+ _lgeos.finishGEOS_r.argtypes = [c_void_p]
139
140
 
140
141
  # Exceptions
141
142
 
@@ -160,7 +161,7 @@ def notice_handler(fmt, list):
160
161
  notice_h = CFUNCTYPE(None, c_char_p, c_char_p)(notice_handler)
161
162
 
162
163
  def cleanup():
163
- if _lgeos is not None:
164
+ if _lgeos is not None :
164
165
  _lgeos.finishGEOS()
165
166
 
166
167
  atexit.register(cleanup)
@@ -1,12 +1,13 @@
1
1
  from unittest import TestSuite
2
2
 
3
3
  import test_doctests, test_prepared, test_equality, test_geomseq, test_xy
4
- import test_collection
4
+ import test_collection, test_emptiness
5
5
 
6
6
  def test_suite():
7
7
  suite = TestSuite()
8
8
  suite.addTest(test_doctests.test_suite())
9
9
  suite.addTest(test_prepared.test_suite())
10
+ suite.addTest(test_emptiness.test_suite())
10
11
  suite.addTest(test_equality.test_suite())
11
12
  suite.addTest(test_geomseq.test_suite())
12
13
  suite.addTest(test_xy.test_suite())
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