def __setitem__(self, index, geom): "Sets the Geometry at the specified index." self._checkindex(index) if not isinstance(geom, self._allowed): raise TypeError('Incompatible Geometry for collection.') ngeoms = len(self) geoms = get_pointer_arr(ngeoms) for i in xrange(ngeoms): if i == index: geoms[i] = geom_clone(geom.ptr) else: geoms[i] = geom_clone(get_geomn(self.ptr, i)) # Creating a new collection, and destroying the contents of the previous poiner. prev_ptr = self.ptr srid = self.srid self._ptr = create_collection(c_int(self._typeid), byref(geoms), c_uint(ngeoms)) if srid: self.srid = srid destroy_geom(prev_ptr)
def _get_single_internal(self, index): return capi.get_geomn(self.ptr, index)
def __getitem__(self, index): "Returns the Geometry from this Collection at the given index (0-based)." # Checking the index and returning the corresponding GEOS geometry. self._checkindex(index) return GEOSGeometry(geom_clone(get_geomn(self.ptr, index)), srid=self.srid)
"""
def _getitem_internal(self, index): return capi.get_geomn(self.ptr, index)