
    Dvg                     \   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d& e                                D             Z d'S )(    )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dS )FieldzL
    Wrap an OGR Field. Needs to be instantiated from a Feature object.
    c                     || _         || _        t          j        |j        |          }|st          d          || _        t          | j                 | _        dS )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       Z/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/gdal/field.py__init__zField.__init__   s[     
 *48U;; 	S QRRR 'ty1    c                 N    t          | 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         r$t          j        | j        j        | j                  n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*   s.     {D$TZ^T[AAA	
r   Fc                     |r-| j         r$t          j        | j        j        | j                  ndS | j         r$t          j        | j        j        | j                  n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   sb     	 ;+DJNDKHHH ;)$*.$+FFFr   c                     | j         sdS 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    { 	4)$*.$+FF$**=DQQQQr   c                    | j         sdS d t          d          D             \  }}}}}}}t          j        | j        j        | j        t          |          t          |          t          |          t          |          t          |          t          |          t          |          	  	        }|r	|||||||fS t          d          )z@Retrieve the Field's value as a tuple of date & time components.Nc                 *    g | ]}t                      S  )r   ).0is     r   
<listcomp>z%Field.as_datetime.<locals>.<listcomp>L   s    %@%@%@!egg%@%@%@r      z:Unable to retrieve date & time information from the field.)	r%   ranger   get_field_as_datetimer   r   r   r   r	   )	r   yymmddhhmnsstzstatuss	            r   as_datetimezField.as_datetimeH   s    { 	4%@%@uQxx%@%@%@"BBB+JNK"II"II"II"II"II"II"II

 

  	BBB//L  r   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                 l    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   rJ   z
Field.namee   s0     "48,,
(;$OOOOr   c                 4    t          j        | j                  S )z#Return the precision of this Field.)r   get_field_precisionr   r"   s    r   	precisionzField.precisionk   s     '111r   c                 4    t          j        | j                  S )z"Return the OGR type of this Field.)r   get_field_typer   r"   s    r   r   z
Field.typep   s     "48,,,r   c                 4    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22r   c                 *    |                                  S )zReturn the value of this Field.)r3   r"   s    r   r    zField.valuez   s     ~~r   c                 4    t          j        | j                  S )zReturn the width of this Field.)r   get_field_widthr   r"   s    r   widthzField.width   s     #DH---r   N)F)__name__
__module____qualname____doc__r   r#   r'   r,   r3   rE   propertyr%   rJ   rM   r   rR   r    rV   r6   r   r   r   r      s@        2 2 2$' ' '

 
 
   R R R  0 > > X> P P XP
 2 2 X2 - - X- 3 3 X3     X 
 . . X. . .r   r   c                   >    e Zd ZdZed             Zed             ZdS )
OFTIntegerFc                 6    |                      | j                  S )z*Return an integer contained in this field.)r,   _bit64r"   s    r   r    zOFTInteger.value   s     {{4;'''r   c                     dS )z
        GDAL uses OFTReals to represent OFTIntegers in created
        shapefiles -- forcing the type here since the underlying field
        type may actually be OFTReal.
        r   r6   r"   s    r   r   zOFTInteger.type   s	     qr   N)rW   rX   rY   r_   r[   r    r   r6   r   r   r]   r]      sM        F( ( X(   X  r   r]   c                   $    e Zd Zed             ZdS )OFTRealc                 *    |                                  S )z'Return a float contained in this field.)r'   r"   s    r   r    zOFTReal.value   s     ~~r   NrW   rX   rY   r[   r    r6   r   r   rb   rb      s-            X     r   rb   c                       e Zd ZdS )	OFTStringNrW   rX   rY   r6   r   r   rf   rf              Dr   rf   c                       e Zd ZdS )OFTWideStringNrg   r6   r   r   rj   rj      rh   r   rj   c                       e Zd ZdS )	OFTBinaryNrg   r6   r   r   rl   rl      rh   r   rl   c                   $    e Zd Zed             ZdS )OFTDatec                     	 |                                  \  }}}}}}}t          |j        |j        |j                  S # t          t          t
          f$ r Y dS w xY w)z4Return a Python `date` object for the OFTDate field.N)rE   r   r    	TypeError
ValueErrorr	   r   r=   r>   r?   r@   rA   rB   rC   s           r   r    zOFTDate.value   sh    	)-)9)9););&BBBB"(BH555:}5 	 	 	44	s   ;> AANrd   r6   r   r   rn   rn      -          X  r   rn   c                   $    e Zd Zed             ZdS )OFTDateTimec                     	 |                                  \  }}}}}}}t          |j        |j        |j        |j        |j        |j                  S # t          t          t
          f$ r Y dS w xY w)z=Return a Python `datetime` object for this OFTDateTime field.N)rE   r   r    rp   rq   r	   rr   s           r   r    zOFTDateTime.value   st    	)-)9)9););&BBBBBHbh"(BHbhWWW:}5 	 	 	44	s   AA A+*A+Nrd   r6   r   r   ru   ru      s-        
 
 X
 
 
r   ru   c                   $    e Zd Zed             ZdS )OFTTimec                     	 |                                  \  }}}}}}}t          |j        |j        |j                  S # t          t          f$ r Y dS w xY w)z5Return a Python `time` object for this OFTTime field.N)rE   r   r    rq   r	   rr   s           r   r    zOFTTime.value   sf    	)-)9)9););&BBBB"(BH555M* 	 	 	44	s   ;> AANrd   r6   r   r   rx   rx      rs   r   rx   c                       e Zd ZdZdS )OFTInteger64TN)rW   rX   rY   r_   r6   r   r   r{   r{      s        FFFr   r{   c                       e Zd ZdS )OFTIntegerListNrg   r6   r   r   r}   r}      rh   r   r}   c                       e Zd ZdS )OFTRealListNrg   r6   r   r   r   r      rh   r   r   c                       e Zd ZdS )OFTStringListNrg   r6   r   r   r   r      rh   r   r   c                       e Zd ZdS )OFTWideStringListNrg   r6   r   r   r   r      rh   r   r   c                       e Zd ZdS )OFTInteger64ListNrg   r6   r   r   r   r      rh   r   r   )r                     r:      	   
            c                     i | ]\  }}||	S r6   r6   )r7   numclss      r   
<dictcomp>r      s    AAAxsC#sAAAr   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   r]   rb   rf   rj   rl   rn   ru   rx   r{   r}   r   r   r   r   r   itemsROGRFieldTypesr6   r   r   <module>r      s`           ) ) ) ) ) ) ) ) ) ) 1 1 1 1 1 1 7 7 7 7 7 7 9 9 9 9 9 9 + + + + + +u. u. u. u. u.H u. u. u.r       $         e      	 	 	 	 	 	 	 		 	 	 	 	E 	 	 		 	 	 	 	 	 	 	
    e       %       e       :   
	 	 	 	 	U 	 	 		 	 	 	 	% 	 	 		 	 	 	 	E 	 	 		 	 	 	 	 	 	 		 	 	 	 	u 	 	 	    BA=+>+>+@+@AAAr   