ó
    µRj—   ã                   óœ   • S SK JrJrJrJr  S SKJr  S SKJr	  S SK
Jr  S SKJr  S SKJr  SSKJrJrJrJr   " S	 S
\5      r " S S\5      rg)é    )Ú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                   ó  • \ rS rSrSrS rS r\S 5       r\S 5       r	\S 5       r
\S 5       rS	rSS
 jr\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\R&                  S 5       rSS jrSS jrSS jrSrg)ÚGDALBandé   zI
Wrap a GDAL raster band, needs to be obtained from a GDALRaster object.
c                 ó\   • Xl         [        R                  " UR                  U5      U l        g ©N)ÚsourceÚcapiÚget_ds_raster_bandÚ_ptr)Úselfr   Úindexs      ÚOD:\diplom_project\venv\Lib\site-packages\django/contrib/gis/gdal/raster/band.pyÚ__init__ÚGDALBand.__init__   s   € ØŒÜ×+Ò+¨F¯K©K¸Ó?ˆ�	ó    c                 óF   • U R                   R                  5         SU l        g)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!   ÚGDALBand._flush   s   € ð
 	�‰×ÑÔØ"ˆÕr   c                 óT   • [        [        R                  " U R                  5      5      $ )z,
Return the description string of the band.
)r   r   Úget_band_descriptionr   r#   s    r   ÚdescriptionÚGDALBand.description"   s   € ô
 œ×2Ò2°4·9±9Ó=Ó>Ð>r   c                 óB   • [         R                  " U R                  5      $ )z'
Width (X axis) in pixels of the band.
)r   Úget_band_xsizer   r#   s    r   ÚwidthÚGDALBand.width)   ó   € ô
 ×"Ò" 4§9¡9Ó-Ð-r   c                 óB   • [         R                  " U R                  5      $ )z(
Height (Y axis) in pixels of the band.
)r   Úget_band_ysizer   r#   s    r   ÚheightÚGDALBand.height0   r-   r   c                 ó4   • U R                   U R                  -  $ )z1
Return the total number of pixels in this band.
)r+   r0   r#   s    r   Úpixel_countÚGDALBand.pixel_count7   s   € ð
 �z‰z˜DŸK™KÑ'Ð'r   Fc           	      ó@  • [        5       [        5       [        5       [        5       4u  p4pVU R                  [        U5      [        U5      [        U5      [        U5      [        U5      [	        5       [	        5       /nU(       d  U R
                  (       a  [        R                  nO-Sn	UR                  S[        U	5      5        [        R                  n U" U6   UR                  UR                  UR                  UR                  4n
SU l        U
$ ! [         a    Sn
 Nf = f)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   Ú
statisticsÚGDALBand.statistics@   sé   € ô( #+£*¬h«j¼(»*ÄhÃjÐ"PÑˆ�Eà�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                 ó(   • U R                  5       S   $ )z/
Return the minimum pixel value for this band.
r   ©rE   r#   s    r   ÚminÚGDALBand.mint   ó   € ð
 �‰Ó  Ñ#Ð#r   c                 ó(   • U R                  5       S   $ )z/
Return the maximum pixel value for this band.
r   rH   r#   s    r   ÚmaxÚGDALBand.max{   rK   r   c                 ó(   • U R                  5       S   $ )z3
Return the mean of all pixel values of this band.
r6   rH   r#   s    r   ÚmeanÚGDALBand.mean‚   rK   r   c                 ó(   • U R                  5       S   $ )zA
Return the standard deviation of all pixel values of this band.
é   rH   r#   s    r   ÚstdÚGDALBand.std‰   rK   r   c                 ó¸   • [        5       n[        R                  " U R                  U5      nU(       d  SnU$ U R	                  5       [
        ;   a  [        U5      nU$ )zA
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_existsr:   s      r   Únodata_valueÚGDALBand.nodata_value�   sO   € ô ›ˆÜ×*Ò*¨4¯9©9°mÓDˆÞØˆEð ˆð �]‰]‹_Ô 2Ó2Ü˜“JˆEØˆr   c                 óú   • Uc!  [         R                  " U R                  5        OG[        U[        [
        45      (       d  [        S5      e[         R                  " U R                  U5        U R                  5         g)z%
Set the nodata value for this band.
Nz%Nodata value must be numeric or None.)	r   Údelete_band_nodata_valuer   Ú
isinstancerY   ÚfloatÚ
ValueErrorÚset_band_nodata_valuer!   )r   r:   s     r   r[   r\   Ÿ   sU   € ð
 ‰=Ü×)Ò)¨$¯)©)Õ4Ü˜E¤C¬ <×0Ñ0ÜÐDÓEÐEä×&Ò& t§y¡y°%Ô8Ø�‰�r   c                 óf   • [         R                  " U R                  5      nU(       a	  [        U   nU$ )z/
Return the GDAL Pixel Datatype for this band.
)r   Úget_band_datatyper   r   )r   Ú	as_stringÚdtypes      r   rX   ÚGDALBand.datatype¬   s*   € ô ×&Ò& t§y¡yÓ1ˆÞÜ$ UÑ+ˆEØˆr   c                 óf   • [         R                  " U R                  5      nU(       a	  [        U   nU$ )z3Return the GDAL color interpretation for this band.)r   Úget_band_color_interpr   r   )r   re   Úcolors      r   Úcolor_interpÚGDALBand.color_interpµ   s(   € ä×*Ò*¨4¯9©9Ó5ˆÞÜ$ UÑ+ˆEØˆr   Nc                 óþ  • U=(       d    SnU=(       d$    U R                   US   -
  U R                  US   -
  4nU=(       d    Un[        S U 5       5      (       a  [        S5      eUS   U R                   :”  d  US   U R                  :”  a  [        S5      e[        U R                  5          US   US   -  -  nUc
  SnU" 5       nO^Sn[        U[        [        45      (       d*  [        (       a1  [        U[        R                  5      (       a  UR                  U5      nOU" U6 n[        R                  " U R                  UUS   US   US   US   [        U5      US   US   U R                  5       SS5        Ucr  U(       a  [        U5      $ [        (       aJ  [        R                   " U[        R"                  " U5      S9R%                  ['        [)        U5      5      5      $ [+        U5      $ U R-                  5         g)	a5  
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   ó*   #   • U  H	  oS :*  v •  M     g7f)r   N© )Ú.0Úxs     r   Ú	<genexpr>Ú GDALBand.data.<locals>.<genexpr>È   s   é € Ð$št˜!�AŽvštùs   ‚zOffset too big for this raster.zSize is larger than raster.N)rf   )r+   r0   Úanyra   r   rX   r_   ÚbytesÚ
memoryviewr
   ÚndarrayÚfrom_buffer_copyr   Úband_ior   r   Ú
frombufferrf   ÚreshapeÚtupleÚreversedÚlistr!   )	r   ÚdataÚoffsetÚsizeÚshapeÚas_memoryviewÚctypes_arrayÚaccess_flagÚ
data_arrays	            r   r   Ú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Ñ4ß’œ* T¬5¯=©=×9Ñ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   )r   r"   r   )FF)F)NNNNF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r!   Úpropertyr'   r+   r0   r3   r"   rE   rI   rM   rP   rT   r[   ÚsetterrX   rk   r   Ú__static_attributes__ro   r   r   r   r      sý   † ñò@ò#ð ñ?ó ð?ð ñ.ó ð.ð ñ.ó ð.ð ñ(ó ð(ð €Nô2ðh ñ$ó ð$ð ñ$ó ð$ð ñ$ó ð$ð ñ$ó ð$ð ñó ðð ×Ññ
ó ð
ôô÷Br   r   c                   ó:   ^ • \ rS rSrU 4S jrS rS rS rSrU =r	$ )ÚBandListi  c                 ó.   >• Xl         [        TU ]	  5         g r   )r   Úsuperr   )r   r   Ú	__class__s     €r   r   ÚBandList.__init__  s   ø€ ØŒÜ‰ÑÕr   c              #   óz   #   • [        S[        U 5      S-   5       H  n[        U R                  U5      v •  M     g 7f)Nr   )ÚrangeÚlenr   r   )r   Úidxs     r   Ú__iter__ÚBandList.__iter__  s/   é € Ü˜œC ›I¨™MÖ*ˆCÜ˜4Ÿ;™;¨Ó,Ô,ò +ùs   ‚9;c                 óV   • [         R                  " U R                  R                  5      $ r   )r   Úget_ds_raster_countr   r   r#   s    r   Ú__len__ÚBandList.__len__
  s   € Ü×'Ò'¨¯©×(8Ñ(8Ó9Ð9r   c                 ón   •  [        U R                  US-   5      $ ! [         a    [        SU-  5      ef = f)Nr   zUnable to get band index %d)r   r   r   )r   r   s     r   Ú__getitem__ÚBandList.__getitem__  s?   € ð	GÜ˜DŸK™K¨°©Ó3Ð3øÜó 	GÜÐ =ÀÑ EÓFÐFð	Gús   ‚ ›4)r   )
rˆ   r‰   rŠ   r‹   r   rš   rž   r¡   r�   Ú__classcell__)r”   s   @r   r‘   r‘     s   ø† õò-ò:÷Gð 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   r~   r‘   ro   r   r   Ú<module>r«      sA   ðß 3Ó 3å 7Ý =Ý >Ý .Ý +÷ó ômˆ~ô mô`Gˆtõ Gr   