Ë
    ¹ûàg—   ã                   óœ   — d dl mZ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 d dlmZ ddlmZmZmZmZ  G d	„ d
e«      Z G d„ de«      Zy)é    )ÚbyrefÚc_doubleÚc_intÚc_void_p)ÚGDALException)Úraster)ÚGDALRasterBase)Únumpy)Ú	force_stré   )ÚGDAL_COLOR_TYPESÚGDAL_INTEGER_TYPESÚGDAL_PIXEL_TYPESÚGDAL_TO_CTYPESc                   óô   — e Zd ZdZd„ Zd„ Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
dZdd	„Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zej$                  d„ «       Zdd„Zdd„Zdd„Zy)ÚGDALBandzQ
    Wrap a GDAL raster band, needs to be obtained from a GDALRaster object.
    c                 ó\   — || _         t        j                  |j                  |«      | _        y ©N)ÚsourceÚcapiÚget_ds_raster_bandÚ_ptr)Úselfr   Úindexs      úa/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/contrib/gis/gdal/raster/band.pyÚ__init__zGDALBand.__init__   s!   € ØˆŒÜ×+Ñ+¨F¯K©K¸Ó?ˆ�	ó    c                 óF   — | j                   j                  «        d| _        y)z™
        Call the flush method on the Band's parent raster and force a refresh
        of the statistics attribute when requested the next time.
        TN)r   Ú_flushÚ_stats_refresh©r   s    r   r   zGDALBand._flush   s   € ð
 	�‰×ÑÔØ"ˆÕr   c                 óR   — t        t        j                  | j                  «      «      S )z<
        Return the description string of the band.
        )r   r   Úget_band_descriptionr   r!   s    r   ÚdescriptionzGDALBand.description"   s   € ô
 œ×2Ñ2°4·9±9Ó=Ó>Ð>r   c                 ó@   — t        j                  | j                  «      S )z7
        Width (X axis) in pixels of the band.
        )r   Úget_band_xsizer   r!   s    r   ÚwidthzGDALBand.width)   ó   € ô
 ×"Ñ" 4§9¡9Ó-Ð-r   c                 ó@   — t        j                  | j                  «      S )z8
        Height (Y axis) in pixels of the band.
        )r   Úget_band_ysizer   r!   s    r   ÚheightzGDALBand.height0   r(   r   c                 ó4   — | j                   | j                  z  S )zA
        Return the total number of pixels in this band.
        )r'   r+   r!   s    r   Úpixel_countzGDALBand.pixel_count7   s   € ð
 �z‰z˜DŸK™KÑ'Ð'r   Fc           	      ó.  — t        «       t        «       t        «       t        «       f\  }}}}| j                  t        |«      t        |«      t        |«      t        |«      t        |«      t	        «       t	        «       g}|s| j
                  rt        j                  }n-d}	|j                  dt        |	«      «       t        j                  }	  ||Ž  |j                  |j                  |j                  |j                  f}
d| _        |
S # t        $ r d}
Y Œw xY w)a¼  
        Compute statistics on the pixel values of this band.

        The return value is a tuple with the following structure:
        (minimum, maximum, mean, standard deviation).

        If approximate=True, the statistics may be computed based on overviews
        or a subset of image tiles.

        If refresh=True, the statistics will be computed from the data directly,
        and the cache will be updated where applicable.

        For empty bands (where all pixel values are nodata), all statistics
        values are returned as None.

        For raster formats using Persistent Auxiliary Metadata (PAM) services,
        the statistics might be cached in an auxiliary file.
        Té   )NNNNF)r   r   r   r   r   r    r   Úcompute_band_statisticsÚinsertÚget_band_statisticsÚvaluer   )r   ÚrefreshÚapproximateÚsminÚsmaxÚsmeanÚsstdÚ
stats_argsÚfuncÚforceÚresults              r   Ú
statisticszGDALBand.statistics@   sí   € ô( #+£*¬h«j¼(»*ÄhÃjÐ"PÑˆˆd�E˜4à�I‰IÜ�+ÓÜ�$‹KÜ�$‹KÜ�%‹LÜ�$‹KÜ‹JÜ‹Jð	
ˆ
ñ �d×)Ò)Ü×/Ñ/‰Dð ˆEØ×Ñ˜a¤ u£Ô.Ü×+Ñ+ˆDð	.Ù�*ÑØ—Z‘Z §¡¨U¯[©[¸$¿*¹*ÐDˆFð $ˆÔàˆøô ò 	.Ø-ŠFð	.ús   Ã
3D ÄDÄDc                 ó(   — | j                  «       d   S )z?
        Return the minimum pixel value for this band.
        r   ©r>   r!   s    r   ÚminzGDALBand.mint   ó   € ð
 �‰Ó  Ñ#Ð#r   c                 ó(   — | j                  «       d   S )z?
        Return the maximum pixel value for this band.
        r   r@   r!   s    r   ÚmaxzGDALBand.max{   rB   r   c                 ó(   — | j                  «       d   S )zC
        Return the mean of all pixel values of this band.
        r/   r@   r!   s    r   ÚmeanzGDALBand.mean‚   rB   r   c                 ó(   — | j                  «       d   S )zQ
        Return the standard deviation of all pixel values of this band.
        é   r@   r!   s    r   ÚstdzGDALBand.std‰   rB   r   c                 ó¨   — t        «       }t        j                  | j                  |«      }|sd}|S | j	                  «       t
        v rt        |«      }|S )zQ
        Return the nodata value for this band, or None if it isn't set.
        N)r   r   Úget_band_nodata_valuer   Údatatyper   Úint)r   Únodata_existsr3   s      r   Únodata_valuezGDALBand.nodata_value�   sO   € ô ›ˆÜ×*Ñ*¨4¯9©9°mÓDˆÙØˆEð ˆð �]‰]‹_Ô 2Ñ2Ü˜“JˆEØˆr   c                 óê   — |€ t        j                  | j                  «       nAt        |t        t
        f«      st        d«      ‚t        j                  | j                  |«       | j                  «        y)z5
        Set the nodata value for this band.
        Nz%Nodata value must be numeric or None.)	r   Údelete_band_nodata_valuer   Ú
isinstancerM   ÚfloatÚ
ValueErrorÚset_band_nodata_valuer   )r   r3   s     r   rO   zGDALBand.nodata_valueŸ   sR   € ð
 ˆ=Ü×)Ñ)¨$¯)©)Õ4Ü˜E¤C¬ <Ô0ÜÐDÓEÐEä×&Ñ& t§y¡y°%Ô8Ø�‰�r   c                 óZ   — t        j                  | j                  «      }|r	t        |   }|S )z?
        Return the GDAL Pixel Datatype for this band.
        )r   Úget_band_datatyper   r   )r   Ú	as_stringÚdtypes      r   rL   zGDALBand.datatype¬   s*   € ô ×&Ñ& t§y¡yÓ1ˆÙÜ$ UÑ+ˆEØˆr   c                 óZ   — t        j                  | j                  «      }|r	t        |   }|S )z3Return the GDAL color interpretation for this band.)r   Úget_band_color_interpr   r   )r   rX   Úcolors      r   Úcolor_interpzGDALBand.color_interpµ   s(   € ä×*Ñ*¨4¯9©9Ó5ˆÙÜ$ UÑ+ˆEØˆr   Nc                 óœ  — |xs d}|xs$ | j                   |d   z
  | j                  |d   z
  f}|xs |}t        d„ |D «       «      rt        d«      ‚|d   | j                   kD  s|d   | j                  kD  rt        d«      ‚t        | j                  «          |d   |d   z  z  }|€
d} |«       }nOd}t        |t        t        f«      s t        r,t        |t        j                  «      r|j                  |«      }n ||Ž }t        j                  | j                  ||d   |d   |d   |d   t        |«      |d   |d   | j                  «       dd«       |€i|rt        |«      S t        rKt        j                   |t        j"                  |«      ¬«      j%                  t'        t)        |«      «      «      S t+        |«      S | j-                  «        y)	ae  
        Read or writes pixel values for this band. Blocks of data can
        be accessed by specifying the width, height and offset of the
        desired block. The same specification can be used to update
        parts of a raster by providing an array of values.

        Allowed input data types are bytes, memoryview, list, tuple, and array.
        )r   r   r   r   c              3   ó&   K  — | ]	  }|d k  –— Œ y­w)r   N© )Ú.0Úxs     r   ú	<genexpr>z GDALBand.data.<locals>.<genexpr>È   s   è ø€ Ò$˜!ˆq�A�vÑ$ùs   ‚zOffset too big for this raster.zSize is larger than raster.N)rY   )r'   r+   ÚanyrT   r   rL   rR   ÚbytesÚ
memoryviewr
   ÚndarrayÚfrom_buffer_copyr   Úband_ior   r   Ú
frombufferrY   ÚreshapeÚtupleÚreversedÚlistr   )	r   ÚdataÚoffsetÚsizeÚshapeÚas_memoryviewÚctypes_arrayÚaccess_flagÚ
data_arrays	            r   ro   zGDALBand.data¼   s·  € ð Ò!˜6ˆØÒH˜Ÿ
™
 V¨A¡YÑ.°·±¸fÀQ¹iÑ0GÐHˆØ’˜ˆÜÑ$˜tÔ$Ô$ÜÐ>Ó?Ð?à�‰7�T—Z‘ZÒ 4¨¡7¨T¯[©[Ò#8ÜÐ:Ó;Ð;ô & d§m¡m£oÑ6¸%À¹(ÀUÈ1ÁXÑ:MÑNˆàˆ<àˆKá%›‰Jð ˆKô ˜$¤¬
Ð 3Ô4Ýœ* T¬5¯=©=Ô9à)×:Ñ:¸4Ó@‘
á)¨4Ð0�
ô 	�‰Ø�I‰IØØ�1‰IØ�1‰IØ�‰GØ�‰GÜ�*ÓØ�!‰HØ�!‰HØ�M‰M‹OØØô	
ð  ˆ<ÙÜ! *Ó-Ð-Ýä×'Ñ'Ø¤e§k¡k°*Ó&=ôç‘'œ%¤¨£Ó/Ó0ð1ô ˜JÓ'Ð'à�K‰K�Mr   )FF)F)NNNNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úpropertyr$   r'   r+   r-   r    r>   rA   rD   rF   rI   rO   ÚsetterrL   r]   ro   r`   r   r   r   r      sý   „ ñò@ò#ð ñ?ó ð?ð ñ.ó ð.ð ñ.ó ð.ð ñ(ó ð(ð €Nó2ðh ñ$ó ð$ð ñ$ó ð$ð ñ$ó ð$ð ñ$ó ð$ð ñó ðð ×Ññ
ó ð
óóôBr   r   c                   ó0   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zd„ Zˆ xZS )ÚBandListc                 ó0   •— || _         t        ‰| �	  «        y r   )r   Úsuperr   )r   r   Ú	__class__s     €r   r   zBandList.__init__  s   ø€ ØˆŒÜ‰ÑÕr   c              #   óv   K  — t        dt        | «      dz   «      D ]  }t        | j                  |«      –— Œ y ­w)Nr   )ÚrangeÚlenr   r   )r   Úidxs     r   Ú__iter__zBandList.__iter__  s5   è ø€ Ü˜œC ›I¨™MÓ*ò 	-ˆCÜ˜4Ÿ;™;¨Ó,Ó,ñ	-ùs   ‚79c                 óT   — t        j                  | j                  j                  «      S r   )r   Úget_ds_raster_countr   r   r!   s    r   Ú__len__zBandList.__len__
  s   € Ü×'Ñ'¨¯©×(8Ñ(8Ó9Ð9r   c                 ól   — 	 t        | j                  |dz   «      S # t        $ r t        d|z  «      ‚w xY w)Nr   zUnable to get band index %d)r   r   r   )r   r   s     r   Ú__getitem__zBandList.__getitem__  s?   € ð	GÜ˜DŸK™K¨°©Ó3Ð3øÜò 	GÜÐ =ÀÑ EÓFÐFð	Gús   ‚ ›3)rw   rx   ry   r   r†   r‰   r‹   Ú__classcell__)r�   s   @r   r~   r~     s   ø„ ôò-ò:öGr   r~   N)Úctypesr   r   r   r   Údjango.contrib.gis.gdal.errorr   Ú"django.contrib.gis.gdal.prototypesr   r   Ú#django.contrib.gis.gdal.raster.baser	   Údjango.contrib.gis.shortcutsr
   Údjango.utils.encodingr   Úconstr   r   r   r   r   rn   r~   r`   r   r   ú<module>r”      sA   ðß 3Ó 3å 7Ý =Ý >Ý .Ý +÷ó ômˆ~ô mô`Gˆtõ Gr   