
vÅÏ^À  ã               @   sv   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z m	 Z
 d  d l m Z m Z Gd d „  d e ƒ Z d S)	é    )Úc_void_p)ÚGDALBase)ÚGDALException)ÚdsÚraster)Úforce_bytesÚ	force_strc               @   s    e  Z d  Z d Z d d d d d d d d d d d	 d
 d d
 d d d d i	 Z d d „  Z d d „  Z e d d „  ƒ Z e d d „  ƒ Z	 e
 d d „  ƒ Z d S)ÚDriverz°
    Wrap a GDAL/OGR Data Source Driver.
    For more information, see the C API source code:
    https://www.gdal.org/gdal_8h.html - https://www.gdal.org/ogr__api_8h.html
    ZesrizESRI ShapefileZshpÚshapeZtigerZTIGERz
tiger/lineZtiffZGTiffZtifZjpegZJPEGZjpgc             C   s   t  | t ƒ r† |  j ƒ  | j ƒ  |  j k rD |  j | j ƒ  } n | } x° t t f D]( } t | j t	 | ƒ ƒ ƒ } | rW PqW Wnw t  | t
 ƒ rÏ |  j ƒ  x[ t t f D] } | j | ƒ } | r¬ Pq¬ Wn. t  | t ƒ rç | } n t d t | ƒ ƒ ‚ | st d | ƒ ‚ | |  _ d S)zT
        Initialize an GDAL/OGR driver on either a string or integer input.
        z/Unrecognized input type for GDAL/OGR Driver: %sz1Could not initialize GDAL/OGR Driver on input: %sN)Ú
isinstanceÚstrÚensure_registeredÚlowerÚ_aliasÚvcapiÚrcapir   Zget_driver_by_namer   ÚintZ
get_driverr   ÚtypeÚptr)ÚselfZdr_inputÚnameZifaceZdriver© r   ú@/tmp/pip-build-8lau8j11/django/django/contrib/gis/gdal/driver.pyÚ__init__"   s*    

	zDriver.__init__c             C   s   |  j  S)N)r   )r   r   r   r   Ú__str__F   s    zDriver.__str__c             C   s0   t  j ƒ  s t  j ƒ  t j ƒ  s, t j ƒ  d S)zB
        Attempt to register all the data source drivers.
        N)r   Úget_driver_countZregister_allr   )Úclsr   r   r   r   I   s    
zDriver.ensure_registeredc             C   s   t  j ƒ  t j ƒ  S)zO
        Return the number of GDAL/OGR data source drivers registered.
        )r   r   r   )r   r   r   r   Údriver_countU   s    zDriver.driver_countc             C   s   t  t j |  j ƒ ƒ S)zA
        Return description/name string for this driver.
        )r   r   Zget_driver_descriptionr   )r   r   r   r   r   \   s    zDriver.nameN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úclassmethodr   r   Úpropertyr   r   r   r   r   r	   	   s   $r	   N)Úctypesr   Zdjango.contrib.gis.gdal.baser   Zdjango.contrib.gis.gdal.errorr   Z"django.contrib.gis.gdal.prototypesr   r   r   r   Zdjango.utils.encodingr   r   r	   r   r   r   r   Ú<module>   s
   