î
ªÍ Xë  ã               @   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 Yn Xe rè d Z ng e j d	 k rd
 d d d d g Z n@ e j d k r<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	 r\Pq\q\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 d „  Z  e  d ƒ Z! e g e! _" e e! _# d d „  Z$ d  d! „  Z% e j& d" ƒ Z' d# d$ „  Z( e( ƒ  Z) e* e) d% ƒ Z+ e* e) d& ƒ Z, e) d' o‡e* e) d' ƒ Z- e+ e, e- f Z. [) e d e	 e	 e ƒ Z/ d( d) „  Z0 e/ e0 ƒ Z0 d* d+ „  Z1 e1 d, e/ g e/ ƒ Z2 e2 e0 ƒ d S)-é    )Úunicode_literalsN)ÚCDLLÚ	CFUNCTYPEÚc_char_pÚc_int)Úfind_library)ÚGDALException)ÚImproperlyConfiguredzdjango.contrib.gis)ÚsettingsÚntZgdal111Zgdal110Zgdal19Zgdal18Zgdal17ÚposixZgdalZGDALz
gdal1.11.0z
gdal1.10.0z	gdal1.9.0z	gdal1.8.0z	gdal1.7.0zUnsupported OS "%s"z]Could not find the GDAL library (tried "%s"). Try setting GDAL_LIBRARY_PATH in your settings.z", ")ÚWinDLLc             C   s#   t  j d k r t |  St |  Sd S)z_
    Returns the correct STDCALL function for certain OSR routines on Win32
    platforms.
    r   N)ÚosÚnameÚlwingdalÚlgdal)Úfunc© r   úM/home/ubuntu/projects/ifolica/build/django/django/contrib/gis/gdal/libgdal.pyÚstd_call;   s    r   ZGDALVersionInfoc               C   s
   t  d ƒ S)z1Returns only the GDAL version number information.s   RELEASE_NAME)Ú_version_infor   r   r   r   Úgdal_versionM   s    r   c               C   s
   t  d ƒ S)z*Returns the full GDAL version information.Ú )r   r   r   r   r   Úgdal_full_versionR   s    r   z5^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+))?c                 sN   t  ƒ  j ƒ  }  t j |  ƒ ‰  ˆ  s7 t d |  ƒ ‚ n  ‡  f d d †  d Dƒ S)Nz(Could not parse GDAL version string "%s"c                s"   i  |  ] } ˆ  j  | ƒ | “ q Sr   )Úgroup)Ú.0Úkey)Úmr   r   ú
<dictcomp>^   s   	 z%gdal_version_info.<locals>.<dictcomp>ÚmajorÚminorÚsubminor)zmajorzminorr!   )r   ÚdecodeÚversion_regexÚmatchr   )Úverr   )r   r   Úgdal_version_infoY   s
    r&   r   r    r!   c             C   s   t  j d | | ƒ d  S)NzGDAL_ERROR %d: %s)ÚloggerÚerror)Zerror_classZerror_numberÚmessager   r   r   Úerr_handlerk   s    r*   c             C   s"   t  |  ƒ } | | _ | | _ | S)N)r   ÚargtypesÚrestype)r   Úargsr,   r   r   r   r   Úfunctionp   s    		r.   ZCPLSetErrorHandler)3Ú
__future__r   Úloggingr   ÚreÚctypesr   r   r   r   Úctypes.utilr   Zdjango.contrib.gis.gdal.errorr   Zdjango.core.exceptionsr	   Ú	getLoggerr'   Zdjango.confr
   ZGDAL_LIBRARY_PATHZlib_pathÚAttributeErrorÚEnvironmentErrorÚImportErrorZ	lib_namesr   Zlib_nameÚjoinr   r   r   r   r   r+   r,   r   r   Úcompiler#   r&   Z_verinfoÚintZGDAL_MAJOR_VERSIONZGDAL_MINOR_VERSIONZGDAL_SUBMINOR_VERSIONZGDAL_VERSIONZCPLErrorHandlerr*   r.   Zset_error_handlerr   r   r   r   Ú<module>   sl   "			