ó
®â0_c           @  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z e j d ƒ Z y d  d l m Z e j Z Wn# e e e e f k
 r× d Z n Xe rç d Z n… e j d	 k r,e d
 ƒ e d ƒ e d ƒ e d ƒ e d ƒ g Z n@ e j d k rYd d d d d d d g Z n e d e j ƒ ‚ e r¢x- e D]" Z e e ƒ Z e d k	 ryPqyqyWn  e d k rÊe d d j e ƒ ƒ ‚ n  e e ƒ Z e j d	 k rd  d l m  Z  e  e ƒ Z! n  d „  Z" e" d ƒ Z# e g e# _$ e e# _% d „  Z& d „  Z' e j( d ƒ Z) d  „  Z* e* ƒ  Z+ e, e+ d! ƒ Z- e, e+ d" ƒ Z. e+ d# o˜e, e+ d# ƒ Z/ e- e. e/ f Z0 [+ e d e	 e	 e ƒ Z1 d$ „  Z2 e1 e2 ƒ Z2 d% „  Z3 e3 d& e1 g e1 ƒ Z4 e4 e2 ƒ d S('   iÿÿÿÿ(   t   unicode_literalsN(   t   CDLLt	   CFUNCTYPEt   c_char_pt   c_int(   t   find_library(   t   GDALException(   t   ImproperlyConfiguredu   django.contrib.gis(   t   settingsu   ntu   gdal201u   gdal20u   gdal111u   gdal110u   gdal19u   posixu   gdalu   GDALu	   gdal2.1.0u	   gdal2.0.0u
   gdal1.11.0u
   gdal1.10.0u	   gdal1.9.0u   GDAL is unsupported on OS "%s".uz   Could not find the GDAL library (tried "%s"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.u   ", "(   t   WinDLLc         C  s#   t  j d k r t |  St |  Sd S(   u_   
    Returns the correct STDCALL function for certain OSR routines on Win32
    platforms.
    u   ntN(   t   ost   namet   lwingdalt   lgdal(   t   func(    (    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   std_call<   s    u   GDALVersionInfoc           C  s
   t  d ƒ S(   u1   Returns only the GDAL version number information.t   RELEASE_NAME(   t   _version_info(    (    (    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   gdal_versionO   s    c           C  s
   t  d ƒ S(   u*   Returns the full GDAL version information.u    (   R   (    (    (    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   gdal_full_versionT   s    u5   ^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+))?c            sK   t  ƒ  j ƒ  }  t j |  ƒ ‰  ˆ  s7 t d |  ƒ ‚ n  ‡  f d †  d Dƒ S(   Nu(   Could not parse GDAL version string "%s"c           s"   i  |  ] } ˆ  j  | ƒ | “ q S(    (   t   group(   t   .0t   key(   t   m(    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pys
   <dictcomp>a   s   	 u   majoru   minoru   subminor(   u   majoru   minoru   subminor(   R   t   decodet   version_regext   matchR   (   t   ver(    (   R   sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   gdal_version_info\   s
    u   majoru   minoru   subminorc         C  s   t  j d | | ƒ d  S(   Nu   GDAL_ERROR %d: %s(   t   loggert   error(   t   error_classt   error_numbert   message(    (    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   err_handlero   s    c         C  s"   t  |  ƒ } | | _ | | _ | S(   N(   R   t   argtypest   restype(   R   t   argsR$   R   (    (    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   functionv   s    		u   CPLSetErrorHandler(5   t
   __future__R    t   loggingR
   t   ret   ctypesR   R   R   R   t   ctypes.utilR   t   django.contrib.gis.gdal.errorR   t   django.core.exceptionsR   t	   getLoggerR   t   django.confR   t   GDAL_LIBRARY_PATHt   lib_patht   AttributeErrort   EnvironmentErrort   ImportErrort   Nonet	   lib_namesR   t   strt   lib_namet   joinR   R	   R   R   R   R#   R$   R   R   t   compileR   R   t   _verinfot   intt   GDAL_MAJOR_VERSIONt   GDAL_MINOR_VERSIONt   GDAL_SUBMINOR_VERSIONt   GDAL_VERSIONt   CPLErrorHandlerR"   R&   t   set_error_handler(    (    (    sA   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/gdal/libgdal.pyt   <module>   sl   "
	6								