OwlCyberSecurity - MANAGER
Edit File: feature.cpython-39.pyc
a jH�f� � @ sp d dl mZ d dlmZ d dlmZ d dlmZmZ d dl m Z d dl mZ d dlmZmZ G dd � d e�Zd S )� )�GDALBase)� GDALException)�Field)�OGRGeometry�OGRGeomType)�ds)�geom)�force_bytes� force_strc @ s� e Zd ZdZejZdd� Zdd� Zdd� Z dd � Z d d� Zedd � �Z edd� �Zedd� �Zedd� �Zedd� �Zedd� �Zedd� �Zdd� Zdd� ZdS )�Featureza This class that wraps an OGR Feature, needs to be instantiated from a Layer object. c C s |st d��|| _|| _dS )zI Initialize Feature from a pointer and its Layer object. z1Cannot create OGR Feature, invalid pointer given.N)r �ptr�_layer)�selfZfeat�layer� r �a/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/feature.py�__init__ s zFeature.__init__c C sL t |t�r| �|�}n,d| kr,| jk r6n n|}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. r z9Index out of range when accessing field in a feature: %s.)� isinstance�str�index� num_fields� IndexErrorr )r r �ir r r �__getitem__ s �zFeature.__getitem__c C s | j S )z+Return the count of fields in this feature.)r �r r r r �__len__0 s zFeature.__len__c C s d| j | jf S )zThe string name of the feature.zFeature FID %d in Layer<%s>)�fid� layer_namer r r r �__str__4 s zFeature.__str__c C s t t�| j|j��S )z'Do equivalence testing on the features.)�bool�capiZ feature_equalr Z_ptr)r �otherr r r �__eq__8 s zFeature.__eq__c C s | j jjS )N)r Z_ds�encodingr r r r r# = s zFeature.encodingc C s t �| j�S )zReturn the feature identifier.)r Zget_fidr r r r r r A s zFeature.fidc C s t �| jj�}t|| jdd�S )z-Return the name of the layer for the feature.T�Zstrings_only)r Z get_feat_namer �_ldefnr r# )r �namer r r r F s zFeature.layer_namec C s t �| j�S )z+Return the number of fields in the Feature.)r Zget_feat_field_countr r r r r r L s zFeature.num_fieldsc s � fdd�t � j�D �S )z'Return a list of fields in the Feature.c s. g | ]&}t t�t�� jj|��� jd d��qS )Tr$ )r r Zget_field_nameZget_field_defnr r% r# )�.0r r r r � <listcomp>T s ��z"Feature.fields.<locals>.<listcomp>)�ranger r r r r �fieldsQ s �zFeature.fieldsc C s t �| j�}tt�|��S )z)Return the OGR Geometry for this Feature.)r Zget_feat_geom_refr r �geom_apiZ clone_geom)r Zgeom_ptrr r r r ] s zFeature.geomc C s t t�| jj��S )z.Return the OGR Geometry Type for this Feature.)r r Zget_fd_geom_typer r% r r r r � geom_typed s zFeature.geom_typec C s t |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&