U
    %ìdu  ã                   @   s8   d Z ddlmZmZ dadd„ ZdZG dd„ deƒZdS )	z» Read GDAL files.

Backend: `GDAL <https://gdal.org/>`_

.. note::
    To use this plugin you have to install its backend::

        pip install imageio[gdal]

Parameters
----------
none
é   )ÚFormatÚ
has_moduleNc                   C   s2   zdd l ma W n tk
r,   tdƒ‚Y nX tS )Né    zhThe GDAL format relies on the GDAL package.Please refer to http://www.gdal.org/for further instructions.)Z
osgeo.gdalZgdalÚ_gdalÚImportError© r   r   ú8/tmp/pip-unpacked-wheel-x84omsqu/imageio/plugins/gdal.pyÚload_lib   s    ÿ
r	   )z.tiffz .tifz.imgú.ecwz.jpgz.jpegc                   @   s2   e Zd ZdZdd„ Zdd„ ZG dd„ dejƒZdS )	Ú
GdalFormatzSee :mod:`imageio.plugins.gdal`c                 C   s&   |j dkrdS tdƒr"|j | jkS d S )N)r
   Tz
osgeo.gdal)Ú	extensionr   Ú
extensions©ÚselfÚrequestr   r   r   Ú	_can_read*   s    
zGdalFormat._can_readc                 C   s   dS )NFr   r   r   r   r   Ú
_can_write0   s    zGdalFormat._can_writec                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )zGdalFormat.Readerc                 C   s    t s
tƒ  t  | j ¡ ¡| _d S ©N)r   r	   ZOpenr   Zget_local_filenameÚ_ds©r   r   r   r   Ú_open6   s    zGdalFormat.Reader._openc                 C   s   | ` d S r   )r   r   r   r   r   Ú_close;   s    zGdalFormat.Reader._closec                 C   s   dS )Né   r   r   r   r   r   Ú_get_length>   s    zGdalFormat.Reader._get_lengthc                 C   s$   |dkrt dƒ‚| j ¡ |  |¡fS )Nr   z#Gdal file contains only one dataset)Ú
IndexErrorr   ZReadAsArrayÚ_get_meta_data©r   Úindexr   r   r   Ú	_get_dataA   s    zGdalFormat.Reader._get_datac                 C   s
   | j  ¡ S r   )r   ZGetMetadatar   r   r   r   r   F   s    z GdalFormat.Reader._get_meta_dataN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   ÚReader5   s
   r"   N)r   r    r!   Ú__doc__r   r   r   r"   r   r   r   r   r   '   s   r   )r#   Úcorer   r   r   r	   ZGDAL_FORMATSr   r   r   r   r   Ú<module>   s
   