
    h                     v    S SK Jr  S SKJr  S SKJr  S SKJrJr  S SK	J
r  S SK	Jr  S SKJrJr   " S S	\5      rg
)    )GDALBase)GDALException)Field)OGRGeometryOGRGeomType)ds)geom)force_bytes	force_strc                       \ rS rSrSr\R                  rS rS r	S r
S rS r\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       rS rS rSrg)Feature   zU
This class that wraps an OGR Feature, needs to be instantiated
from a Layer object.
c                 @    U(       d  [        S5      eXl        X l        g)z9
Initialize Feature from a pointer and its Layer object.
z1Cannot create OGR Feature, invalid pointer given.N)r   ptr_layer)selffeatlayers      Q/var/www/html/env/lib/python3.13/site-packages/django/contrib/gis/gdal/feature.py__init__Feature.__init__   s      STT    c                     [        U[        5      (       a  U R                  U5      nO+SUs=::  a  U R                  :  a  O  OUnO[	        SU-  5      e[        X5      $ )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   is      r   __getitem__Feature.__getitem__   sV     eS!!

5!A%)$//)AKeS  T~r   c                     U R                   $ )z+Return the count of fields in this feature.)r   r   s    r   __len__Feature.__len__0   s    r   c                 8    SU R                   U R                  4-  $ )zThe string name of the feature.zFeature FID %d in Layer<%s>)fid
layer_namer#   s    r   __str__Feature.__str__4   s    ,$///JJJr   c                 j    [        [        R                  " U R                  UR                  5      5      $ )z'Do equivalence testing on the features.)boolcapifeature_equalr   _ptr)r   others     r   __eq__Feature.__eq__8   s"    D&&txx<==r   c                 B    U R                   R                  R                  $ )N)r   _dsencodingr#   s    r   r5   Feature.encoding=   s    {{'''r   c                 B    [         R                  " U R                  5      $ )zReturn the feature identifier.)r-   get_fidr   r#   s    r   r'   Feature.fidA   s     ||DHH%%r   c                 ~    [         R                  " U R                  R                  5      n[	        XR
                  SS9$ )z-Return the name of the layer for the feature.Tstrings_only)r-   get_feat_namer   _ldefnr   r5   )r   names     r   r(   Feature.layer_nameF   s/     !!$++"4"45}}4@@r   c                 B    [         R                  " U R                  5      $ )z+Return the number of fields in the Feature.)r-   get_feat_field_countr   r#   s    r   r   Feature.num_fieldsL   s     ((22r   c                     [        U R                  5       Vs/ s HU  n[        [        R                  " [        R
                  " U R                  R                  U5      5      U R                  SS9PMW     sn$ s  snf )z'Return a list of fields in the Feature.Tr;   )	ranger   r   r-   get_field_nameget_field_defnr   r>   r5   )r   r   s     r   fieldsFeature.fieldsQ   sj     4??+
 , ##D$7$78J8JA$NO!
 ,
 	
 
s   AA7c                     [         R                  " U R                  5      n[        [        R
                  " U5      5      $ )z)Return the OGR Geometry for this Feature.)r-   get_feat_geom_refr   r   geom_api
clone_geom)r   geom_ptrs     r   r	   Feature.geom]   s.     ))$((38..x899r   c                 h    [        [        R                  " U R                  R                  5      5      $ )z.Return the OGR Geometry Type for this Feature.)r   r-   get_fd_geom_typer   r>   r#   s    r   	geom_typeFeature.geom_typed   s$     4001C1CDEEr   c                 8    [        USU5      nX   R                  $ )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?   )getattrvalue)r   field
field_names      r   getFeature.getj   s!     UFE2
%%%r   c                     [         R                  " U R                  [        U5      5      nUS:  a  [	        SU-  5      eU$ )z)Return the index of the given field name.r   z!Invalid OFT field name given: %s.)r-   get_field_indexr   r
   r   )r   rX   r   s      r   r   Feature.indexs   s:      ;z+BCq5@:MNNr   )r   r   N)__name__
__module____qualname____firstlineno____doc__r-   destroy_feature
destructorr   r    r$   r)   r1   propertyr5   r'   r(   r   rH   r	   rR   rY   r   __static_attributes__ r   r   r   r      s    
 %%J"K>
 ( ( & & A A
 3 3 	
 	
 : : F F
&r   r   N)django.contrib.gis.gdal.baser   django.contrib.gis.gdal.errorr   django.contrib.gis.gdal.fieldr   "django.contrib.gis.gdal.geometriesr   r   "django.contrib.gis.gdal.prototypesr   r-   r	   rL   django.utils.encodingr
   r   r   rg   r   r   <module>rn      s(    1 7 / G 9 ? 8jh jr   