
    g                        d dl mZmZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ  G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Zeeeeeeeeeeeeeed%Zej?                         D  ci c]  \  } }|| 
 c}} Z y&c c}} w )'    )byrefc_int)datedatetimetime)GDALBase)GDALException)ds)	force_strc                       e Zd ZdZd Zd Zd ZddZd Zd Z	e
d        Ze
d	        Ze
d
        Ze
d        Ze
d        Ze
d        Ze
d        Zy)FieldzL
    Wrap an OGR Field. Needs to be instantiated from a Feature object.
    c                     || _         || _        t        j                  |j                  |      }|st        d      || _        t        | j                     | _        y)zq
        Initialize on the feature object and the integer index of
        the field within the feature.
        z/Cannot create OGR Field, invalid pointer given.N)	_feat_indexcapiget_feat_field_defnptrr	   OGRFieldTypestype	__class__)selffeatindexfld_ptrs       u/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/contrib/gis/gdal/field.py__init__zField.__init__   sR     
 **488U; QRR 'tyy1    c                 H    t        | j                        j                         S )z.Return the string representation of the Field.)strvaluestripr   s    r   __str__zField.__str__%   s    4::$$&&r   c                     | j                   r4t        j                  | j                  j                  | j
                        S dS )z/Retrieve the Field's value as a double (float).N)is_setr   get_field_as_doubler   r   r   r"   s    r   	as_doublezField.as_double*   s8     {{ $$TZZ^^T[[A	
 	
r   c                    |rB| j                   r4t        j                  | j                  j                  | j
                        S dS | j                   r4t        j                  | j                  j                  | j
                        S dS )z)Retrieve the Field's value as an integer.N)r%   r   get_field_as_integer64r   r   r   get_field_as_integer)r   is_64s     r   as_intzField.as_int2   sq     ;; ++DJJNNDKKH  ;; ))$**..$++F r   c                     | j                   syt        j                  | j                  j                  | j
                        }t        || j                  j                  d      S )z'Retrieve the Field's value as a string.NTencodingstrings_only)r%   r   get_field_as_stringr   r   r   r   r/   )r   strings     r   	as_stringzField.as_stringA   sC    {{))$**..$++F$***=*=DQQr   c                    | j                   syt        d      D cg c]  }t                c}\  }}}}}}}t        j                  | j
                  j                  | j                  t        |      t        |      t        |      t        |      t        |      t        |      t        |      	      }	|	r	|||||||fS t        d      c c}w )z@Retrieve the Field's value as a tuple of date & time components.N   z:Unable to retrieve date & time information from the field.)
r%   ranger   r   get_field_as_datetimer   r   r   r   r	   )
r   iyymmddhhmnsstzstatuss
             r   as_datetimezField.as_datetimeH   s    {{7<Qx%@x!egx%@"BBB++JJNNKK"I"I"I"I"I"I"I

 BBB//L  &As   Cc                 j    t        j                  | j                  j                  | j                        S )zCReturn True if the value of this field isn't null, False otherwise.)r   is_field_setr   r   r   r"   s    r   r%   zField.is_set`   s#       ==r   c                     t        j                  | j                        }t        || j                  j
                  d      S )zReturn the name of this Field.Tr.   )r   get_field_namer   r   r   r/   )r   names     r   rF   z
Field.namee   s1     ""488,

(;(;$OOr   c                 @    t        j                  | j                        S )z#Return the precision of this Field.)r   get_field_precisionr   r"   s    r   	precisionzField.precisionk   s     ''11r   c                 @    t        j                  | j                        S )z"Return the OGR type of this Field.)r   get_field_typer   r"   s    r   r   z
Field.typep   s     ""488,,r   c                 @    t        j                  | j                        S )z.Return the OGR field type name for this Field.)r   get_field_type_namer   r"   s    r   	type_namezField.type_nameu   s     ''		22r   c                 "    | j                         S )zReturn the value of this Field.)r3   r"   s    r   r    zField.valuez   s     ~~r   c                 @    t        j                  | j                        S )zReturn the width of this Field.)r   get_field_widthr   r"   s    r   widthzField.width   s     ##DHH--r   N)F)__name__
__module____qualname____doc__r   r#   r'   r,   r3   rA   propertyr%   rF   rI   r   rN   r    rR    r   r   r   r      s    2$'

R0 > > P P
 2 2 - - 3 3    
 . .r   r   c                   0    e Zd ZdZed        Zed        Zy)
OFTIntegerFc                 8    | j                  | j                        S )z*Return an integer contained in this field.)r,   _bit64r"   s    r   r    zOFTInteger.value   s     {{4;;''r   c                      y)z
        GDAL uses OFTReals to represent OFTIntegers in created
        shapefiles -- forcing the type here since the underlying field
        type may actually be OFTReal.
        r   rX   r"   s    r   r   zOFTInteger.type   s     r   N)rS   rT   rU   r\   rW   r    r   rX   r   r   rZ   rZ      s-    F( (  r   rZ   c                       e Zd Zed        Zy)OFTRealc                 "    | j                         S )z'Return a float contained in this field.)r'   r"   s    r   r    zOFTReal.value   s     ~~r   NrS   rT   rU   rW   r    rX   r   r   r_   r_      s       r   r_   c                       e Zd Zy)	OFTStringNrS   rT   rU   rX   r   r   rc   rc          r   rc   c                       e Zd Zy)OFTWideStringNrd   rX   r   r   rg   rg      re   r   rg   c                       e Zd Zy)	OFTBinaryNrd   rX   r   r   ri   ri      re   r   ri   c                       e Zd Zed        Zy)OFTDatec                     	 | j                         \  }}}}}}}t        |j                  |j                  |j                        S # t        t        t
        f$ r Y yw xY w)z4Return a Python `date` object for the OFTDate field.N)rA   r   r    	TypeError
ValueErrorr	   r   r9   r:   r;   r<   r=   r>   r?   s           r   r    zOFTDate.value   sX    	)-)9)9);&BBBB"((BHH55:}5 		s   AA AANra   rX   r   r   rk   rk           r   rk   c                       e Zd Zed        Zy)OFTDateTimec                     	 | j                         \  }}}}}}}t        |j                  |j                  |j                  |j                  |j                  |j                        S # t        t        t
        f$ r Y yw xY w)z=Return a Python `datetime` object for this OFTDateTime field.N)rA   r   r    rm   rn   r	   ro   s           r   r    zOFTDateTime.value   sj    	)-)9)9);&BBBBBHHbhh"((BHHbhhWW:}5 		s   A#A& &A=<A=Nra   rX   r   r   rr   rr      s    
 
r   rr   c                       e Zd Zed        Zy)OFTTimec                     	 | j                         \  }}}}}}}t        |j                  |j                  |j                        S # t        t        f$ r Y yw xY w)z5Return a Python `time` object for this OFTTime field.N)rA   r   r    rn   r	   ro   s           r   r    zOFTTime.value   sV    	)-)9)9);&BBBB"((BHH55M* 		s   AA AANra   rX   r   r   ru   ru      rp   r   ru   c                       e Zd ZdZy)OFTInteger64TN)rS   rT   rU   r\   rX   r   r   rx   rx      s    Fr   rx   c                       e Zd Zy)OFTIntegerListNrd   rX   r   r   rz   rz      re   r   rz   c                       e Zd Zy)OFTRealListNrd   rX   r   r   r|   r|      re   r   r|   c                       e Zd Zy)OFTStringListNrd   rX   r   r   r~   r~      re   r   r~   c                       e Zd Zy)OFTWideStringListNrd   rX   r   r   r   r      re   r   r   c                       e Zd Zy)OFTInteger64ListNrd   rX   r   r   r   r      re   r   r   )r                     r5      	   
            N)!ctypesr   r   r   r   r   django.contrib.gis.gdal.baser   django.contrib.gis.gdal.errorr	   "django.contrib.gis.gdal.prototypesr
   r   django.utils.encodingr   r   rZ   r_   rc   rg   ri   rk   rr   ru   rx   rz   r|   r~   r   r   r   itemsROGRFieldTypes)numclss   00r   <module>r      s0    ) ) 1 7 9 +u.H u.r $ e  	 		E 		 	
e % e : 
	U 		% 		E 		 		u 	   ,9+>+>+@A+@xsC#s(+@AAs   4D