U
    Ha-  ã                   @   s,   d dl mZ d dlmZ G dd„ deƒZdS )é    )ÚGDALBase)Úrasterc                   @   s*   e Zd ZdZedd„ ƒZejdd„ ƒZdS )ÚGDALRasterBasez@
    Attributes that exist on both GDALRaster and GDALBand.
    c                 C   sÒ   dg}t  | j¡}|rFd}|| }|rF| | ¡ ¡ |d7 }|| }q"t  |¡ i }|D ]t}t  | j|dkrpdn| ¡ ¡}|s€qXi }d}|| }|rÀ| ¡  d¡\}	}
|
||	< |d7 }|| }q|||pÊd< qX|S )zô
        Return the metadata for this raster or band. The return value is a
        nested dictionary, where the first-level key is the metadata domain and
        the second-level is the metadata item names and values for that domain.
        ÚDEFAULTr   é   Nú=)	ÚcapiZget_ds_metadata_domain_listÚ_ptrÚappendÚdecodeZfree_dslZget_ds_metadataÚencodeÚsplit)ÚselfZdomain_listZ	meta_listÚcounterÚdomainÚresultÚdataZdomain_metaÚitemÚkeyÚval© r   úG/tmp/pip-unpacked-wheel-3jxiddxt/django/contrib/gis/gdal/raster/base.pyÚmetadata	   s8    	

þ
zGDALRasterBase.metadatac                 C   s^   |  ¡ D ]P\}}|dkrdn| ¡ }|  ¡ D ]*\}}t | j| ¡ |rN| ¡ nd|¡ q,qdS )zo
        Set the metadata. Update only the domains that are contained in the
        value dictionary.
        r   N)Úitemsr   r   Zset_ds_metadata_itemr	   )r   Úvaluer   r   Z	meta_nameZ
meta_valuer   r   r   r   ;   s     ýN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   Úsetterr   r   r   r   r      s
   
1r   N)Zdjango.contrib.gis.gdal.baser   Z"django.contrib.gis.gdal.prototypesr   r   r   r   r   r   r   Ú<module>   s   