B
    CVvg-  ã               @   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¡}|rJd}|| }x&|rH| | ¡ ¡ |d7 }|| }q$W t  |¡ i }x€|D ]x}t  | j|dkrvdn| ¡ ¡}|s†q^i }d}|| }x2|rÈ| ¡  d¡\}	}
|
||	< |d7 }|| }q˜W |||pÔd< q^W |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-install-o3oxmrkh/Django/django/contrib/gis/gdal/raster/base.pyÚmetadata	   s6    	

zGDALRasterBase.metadatac             C   sf   x`|  ¡ D ]T\}}|dkrdn| ¡ }x6|  ¡ D ]*\}}t | j| ¡ |rR| ¡ nd|¡ q0W q
W 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   2r   N)Zdjango.contrib.gis.gdal.baser   Z"django.contrib.gis.gdal.prototypesr   r   r   r   r   r   r   Ú<module>   s   