File manager - Edit - /usr/local/CyberPanel/lib/python3.10/site-packages/django/contrib/gis/gdal/__pycache__/feature.cpython-310.pyc
Back
o �h� � @ 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)�self�feat�layer� r �U/usr/local/CyberPanel/lib/python3.10/site-packages/django/contrib/gis/gdal/feature.py�__init__ s zFeature.__init__c C sL t |t�r| �|�}nd| kr| jk rn 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�capi� feature_equalr �_ptr)r �otherr r r �__eq__8 s zFeature.__eq__c C s | j jjS )N)r �_ds�encodingr r r r r'