Changeset 1043
- Timestamp:
- 02/07/08 21:02:31
- Files:
-
- Shapely/trunk/shapely/geometry/base.py (modified) (5 diffs)
- Shapely/trunk/shapely/geometry/linestring.py (modified) (2 diffs)
- Shapely/trunk/shapely/geometry/multilinestring.py (modified) (1 diff)
- Shapely/trunk/shapely/geometry/multipoint.py (modified) (1 diff)
- Shapely/trunk/shapely/geometry/multipolygon.py (modified) (1 diff)
- Shapely/trunk/shapely/geometry/point.py (modified) (3 diffs)
- Shapely/trunk/shapely/geometry/polygon.py (modified) (3 diffs)
- Shapely/trunk/tests/Polygon.txt (modified) (2 diffs)
- Shapely/trunk/tests/test_doctests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Shapely/trunk/shapely/geometry/base.py
r1005 r1043 48 48 49 49 class CoordinateSequence(object): 50 50 51 _geom = None 51 52 _cseq = None 52 53 _ndim = None … … 55 56 56 57 def __init__(self, geom): 57 self._ cseq = lgeos.GEOSGeom_getCoordSeq(geom._geom)58 self._geom = geom._geom 58 59 self._ndim = geom._ndim 59 60 self.update_cseq() 61 62 def update_cseq(self): 63 self._cseq = lgeos.GEOSGeom_getCoordSeq(self._geom) 64 60 65 def __iter__(self): 61 66 self.index = 0 67 self.update_cseq() 62 68 self._length = self.__len__() 63 69 return self … … 87 93 88 94 def __getitem__(self, i): 95 self.update_cseq() 89 96 M = self.__len__() 90 97 if i + M < 0 or i >= M: … … 219 226 # in __geom so that geometries and geometry adapters can share __del__ 220 227 221 def get_geom(self):228 def _get_geom(self): 222 229 return self.__geom 223 def set_geom(self, val): 230 231 def _set_geom(self, val): 224 232 self.__geom = val 225 _geom = property(get_geom, set_geom) 233 234 _geom = property(_get_geom, _set_geom) 226 235 227 236 # Array and ctypes interfaces … … 254 263 255 264 @exceptNull 256 def get_coords(self):265 def _get_coords(self): 257 266 return CoordinateSequence(self) 258 267 259 def set_coords(self, ob):268 def _set_coords(self, ob): 260 269 raise NotImplementedError, \ 261 270 "set_coords must be provided by derived classes" 262 271 263 coords = property( get_coords,set_coords)272 coords = property(_get_coords, _set_coords) 264 273 265 274 # Python feature protocol Shapely/trunk/shapely/geometry/linestring.py
r1006 r1043 167 167 # Coordinate access 168 168 169 def set_coords(self, coordinates):169 def _set_coords(self, coordinates): 170 170 if self._geom is None: 171 171 self._init_geom(coordinates) 172 172 update_linestring_from_py(self, coordinates) 173 173 174 coords = property(BaseGeometry. get_coords,set_coords)174 coords = property(BaseGeometry._get_coords, _set_coords) 175 175 176 176 … … 216 216 return self.array_interface() 217 217 218 coords = property(BaseGeometry.get_coords) 218 _get_coords = BaseGeometry._get_coords 219 220 def _set_coords(self, ob): 221 raise NotImplementedError, \ 222 "Component rings have coordinate sequences, but the polygon does not" 223 224 coords = property(_get_coords) 219 225 220 226 Shapely/trunk/shapely/geometry/multilinestring.py
r1005 r1043 97 97 "Multi-part geometries do not themselves provide the array interface" 98 98 99 def _get_coords(self): 100 raise NotImplementedError, \ 101 "Component rings have coordinate sequences, but the polygon does not" 102 103 def _set_coords(self, ob): 104 raise NotImplementedError, \ 105 "Component rings have coordinate sequences, but the polygon does not" 106 99 107 @property 100 108 def coords(self): Shapely/trunk/shapely/geometry/multipoint.py
r1005 r1043 119 119 __array_interface__ = property(array_interface) 120 120 121 def _get_coords(self): 122 raise NotImplementedError, \ 123 "Component rings have coordinate sequences, but the polygon does not" 124 125 def _set_coords(self, ob): 126 raise NotImplementedError, \ 127 "Component rings have coordinate sequences, but the polygon does not" 128 121 129 @property 122 130 def coords(self): Shapely/trunk/shapely/geometry/multipolygon.py
r1005 r1043 83 83 "Multi-part geometries do not themselves provide the array interface" 84 84 85 def _get_coords(self): 86 raise NotImplementedError, \ 87 "Component rings have coordinate sequences, but the polygon does not" 88 89 def _set_coords(self, ob): 90 raise NotImplementedError, \ 91 "Component rings have coordinate sequences, but the polygon does not" 92 85 93 @property 86 94 def coords(self): Shapely/trunk/shapely/geometry/point.py
r1006 r1043 191 191 # Coordinate access 192 192 193 def set_coords(self, coordinates):193 def _set_coords(self, coordinates): 194 194 if self._geom is None: 195 195 self._init_geom(coordinates) … … 197 197 update_point_from_py(self, coordinates) 198 198 199 coords = property(BaseGeometry. get_coords,set_coords)199 coords = property(BaseGeometry._get_coords, _set_coords) 200 200 201 201 … … 242 242 return self.array_interface() 243 243 244 coords = property(BaseGeometry.get_coords) 244 _get_coords = BaseGeometry._get_coords 245 246 def _set_coords(self, ob): 247 raise NotImplementedError, \ 248 "Component rings have coordinate sequences, but the polygon does not" 249 250 coords = property(_get_coords) 245 251 246 252 Shapely/trunk/shapely/geometry/polygon.py
r1006 r1043 183 183 # Coordinate access 184 184 185 def set_coords(self, coordinates): 185 _get_coords = BaseGeometry._get_coords 186 187 def _set_coords(self, coordinates): 186 188 if self._geom is None: 187 189 self._init_geom(coordinates) 188 190 update_linearring_from_py(self, coordinates) 189 191 190 coords = property( BaseGeometry.get_coords,set_coords)192 coords = property(_get_coords, _set_coords) 191 193 192 194 … … 212 214 } 213 215 214 coords = property(BaseGeometry. get_coords)216 coords = property(BaseGeometry._get_coords) 215 217 216 218 … … 364 366 "A polygon does not itself provide the array interface. Its rings do." 365 367 368 def _get_coords(self): 369 raise NotImplementedError, \ 370 "Component rings have coordinate sequences, but the polygon does not" 371 372 def _set_coords(self, ob): 373 raise NotImplementedError, \ 374 "Component rings have coordinate sequences, but the polygon does not" 375 366 376 @property 367 377 def coords(self): Shapely/trunk/tests/Polygon.txt
r1006 r1043 89 89 IndexError: index out of range 90 90 91 Coordinate getters and setters raise exceptions 92 93 >>> polygon._get_coords() 94 Traceback (most recent call last): 95 ... 96 NotImplementedError: Component rings have coordinate sequences, but the polygon does not 97 >>> polygon.coords 98 Traceback (most recent call last): 99 ... 100 NotImplementedError: Component rings have coordinate sequences, but the polygon does not 101 91 102 92 103 Geo interface … … 129 140 3.414... 130 141 142 Shapely/trunk/tests/test_doctests.py
r963 r1043 31 31 32 32 if __name__ == "__main__": 33 runner = unittest.TextTestRunner( )33 runner = unittest.TextTestRunner(verbosity=1) 34 34 runner.run(test_suite())
