Changeset 7012
- Timestamp:
- 01/09/08 13:42:23 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/gdal/geometries.py
r6862 r7012 539 539 "Add the geometry to this Geometry Collection." 540 540 if isinstance(geom, OGRGeometry): 541 ptr = geom._ptr 541 if isinstance(geom, self.__class__): 542 for g in geom: add_geom(self._ptr, g._ptr) 543 else: 544 add_geom(self._ptr, geom._ptr) 542 545 elif isinstance(geom, (StringType, UnicodeType)): 543 546 tmp = OGRGeometry(geom) 544 ptr = tmp._ptr547 add_geom(self._ptr, tmp._ptr) 545 548 else: 546 549 raise OGRException('Must add an OGRGeometry.') 547 add_geom(self._ptr, ptr)548 550 549 551 @property django/branches/gis/django/contrib/gis/tests/test_gdal_geom.py
r6979 r7012 324 324 self.assertEqual(u1, a) 325 325 326 def test14_add(self): 327 "Testing GeometryCollection.add()." 328 # Can't insert a Point into a MultiPolygon. 329 mp = OGRGeometry('MultiPolygon') 330 pnt = OGRGeometry('POINT(5 23)') 331 self.assertRaises(OGRException, mp.add, pnt) 332 333 # GeometryCollection.add may take an OGRGeometry (if another collection 334 # of the same type all child geoms will be added individually) or WKT. 335 for mp in multipolygons: 336 mpoly = OGRGeometry(mp.wkt) 337 mp1 = OGRGeometry('MultiPolygon') 338 mp2 = OGRGeometry('MultiPolygon') 339 mp3 = OGRGeometry('MultiPolygon') 340 341 for poly in mpoly: 342 mp1.add(poly) # Adding a geometry at a time 343 mp2.add(poly.wkt) # Adding WKT 344 mp3.add(mpoly) # Adding a MultiPolygon's entire contents at once. 345 for tmp in (mp1, mp2, mp3): self.assertEqual(mpoly, tmp) 346 326 347 def suite(): 327 348 s = unittest.TestSuite()
