Changeset 7406
- Timestamp:
- 04/07/08 16:43:36 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/gdal/geometries.py
r7127 r7406 326 326 geom_close_rings(self._ptr) 327 327 328 def transform(self, coord_trans): 329 """ 330 Transforms this geometry to a different spatial reference system. May take 331 either a CoordTransform object or a SpatialReference object. 332 """ 328 def transform(self, coord_trans, clone=False): 329 """ 330 Transforms this geometry to a different spatial reference system. 331 May take a CoordTransform object, a SpatialReference object, string 332 WKT or PROJ.4, and/or an integer SRID. By default nothing is returned 333 and the geometry is transformed in-place. However, if the `clone` 334 keyword is set, then a transformed clone of this geometry will be 335 returned. 336 """ 337 if clone: 338 klone = self.clone() 339 klone.transform(coord_trans) 340 return klone 333 341 if isinstance(coord_trans, CoordTransform): 334 342 geom_transform(self._ptr, coord_trans._ptr) … … 339 347 geom_transform_to(self._ptr, sr._ptr) 340 348 else: 341 raise TypeError(' Either a CoordTransform or a SpatialReference object required for transformation.')349 raise TypeError('Transform only accepts CoordTransform, SpatialReference, string, and integer objects.') 342 350 343 351 def transform_to(self, srs): … … 432 440 def union(self, other): 433 441 """ 434 Returns a new geometry consisting of the region which is the union of 442 Returns a new geometry consisting of the region which is the union of 435 443 this geometry and the other. 436 444 """ django/branches/gis/django/contrib/gis/gdal/srs.py
r7102 r7406 140 140 return self.attr_value(target) 141 141 142 def __nonzero__(self):143 "Returns True if this SpatialReference object is valid."144 try:145 self.validate()146 return True147 except OGRException:148 return False149 150 142 def __str__(self): 151 143 "The string representation uses 'pretty' WKT." django/branches/gis/django/contrib/gis/tests/test_gdal_geom.py
r7113 r7406 282 282 t3.transform(ct) 283 283 284 for p in (t1, t2, t3): 285 prec = 3 284 # Testing use of the `clone` keyword. 285 k1 = orig.clone() 286 k2 = k1.transform(trans.srid, clone=True) 287 self.assertEqual(k1, orig) 288 self.assertNotEqual(k1, k2) 289 290 prec = 3 291 for p in (t1, t2, t3, k2): 286 292 self.assertAlmostEqual(trans.x, p.x, prec) 287 293 self.assertAlmostEqual(trans.y, p.y, prec)
