o aW@shddlmZddlmZddlmZddlmZmZddl m Z m Z ddlmZmZGdddeZd S) )GDALBase) GDALException)Field) OGRGeometry OGRGeomType)dsgeom) force_bytes force_strc@seZdZdZejZddZddZddZ dd Z d d Z e d d Z e ddZe ddZe ddZe ddZe ddZe ddZddZddZdS)Featureza This class that wraps an OGR Feature, needs to be instantiated from a Layer object. cCs|std||_||_dS)zI Initialize Feature from a pointer and its Layer object. z1Cannot create OGR Feature, invalid pointer given.N)rptr_layer)selffeatlayerrA/usr/lib/python3/dist-packages/django/contrib/gis/gdal/feature.py__init__s zFeature.__init__cCsLt|tr ||}nd|kr|jkrnn|}ntd|t||S)a. Get the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a Field instance. rz9Index out of range when accessing field in a feature: %s.) isinstancestrindex num_fields IndexErrorr)rrirrr __getitem__s    zFeature.__getitem__cCs|jS)z+Return the count of fields in this feature.)rrrrr__len__,szFeature.__len__cCsd|j|jfS)zThe string name of the feature.zFeature FID %d in Layer<%s>)fid layer_namerrrr__str__0szFeature.__str__cCstt|j|jS)z'Do equivalence testing on the features.)boolcapi feature_equalr _ptr)rotherrrr__eq__4szFeature.__eq__cCs |jjjS)N)r _dsencodingrrrrr'9s zFeature.encodingcC t|jS)zReturn the feature identifier.)r!get_fidr rrrrr= z Feature.fidcCst|jj}t||jddS)z-Return the name of the layer for the feature.T strings_only)r! get_feat_namer _ldefnr r')rnamerrrrBszFeature.layer_namecCr()z+Return the number of fields in the Feature.)r!get_feat_field_countr rrrrrHr*zFeature.num_fieldscsfddtjDS)z'Return a list of fields in the Feature.c s.g|]}tttjj|jddqS)Tr+)r r!get_field_nameget_field_defnr r.r').0rrrr Psz"Feature.fields..)rangerrrrrfieldsMs zFeature.fieldscCst|j}tt|S)z)Return the OGR Geometry for this Feature.)r!get_feat_geom_refr rgeom_api clone_geom)rgeom_ptrrrrrXs z Feature.geomcCstt|jjS)z.Return the OGR Geometry Type for this Feature.)rr!get_fd_geom_typer r.rrrr geom_type_szFeature.geom_typecCst|d|}||jS)z Return the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters. r/)getattrvalue)rfield field_namerrrgetes  z Feature.getcCs*t|jt|}|dkrtd||S)z)Return the index of the given field name.rz!Invalid OFT field name given: %s.)r!get_field_indexr r r)rr@rrrrrns z Feature.indexN)__name__ __module__ __qualname____doc__r!destroy_feature destructorrrrrr%propertyr'rrrr6rr<rArrrrrr s0         r N)django.contrib.gis.gdal.baserdjango.contrib.gis.gdal.errorrdjango.contrib.gis.gdal.fieldr"django.contrib.gis.gdal.geometriesrr"django.contrib.gis.gdal.prototypesrr!rr8django.utils.encodingr r r rrrrs