3
(h                 @   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W n  eeeefk
r   dZY nX erdZnFejd	krd
ddddgZn,ejdkrd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	rP qW edkr4eddje eeZejd	kr\d dlmZ eeZ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' oe*e)d' Z-e+e,e-fZ.[)ede	e	eZ/d(d) Z0e/e0Z0d*d+ Z1e1d,e/ge/Z2e2e0 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|  S t|  S dS )z_
    Returns the correct STDCALL function for certain OSR routines on Win32
    platforms.
    r   N)osnamelwingdallgdal)func r   C/tmp/pip-install-q3hcpn_q/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                 s6   t  j } tj|   s$td|   fdddD S )Nz(Could not parse GDAL version string "%s"c                s   i | ]} j ||qS r   )group).0key)mr   r   
<dictcomp>^   s    z%gdal_version_info.<locals>.<dictcomp>majorminorsubminor)r   r    r!   )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   Z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   








