o
    uvXj  ã                   @   sô  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  d¡Zzd dlmZ ejZW n eeeefyI   dZY nw erOdZnejdkrYg d	¢Znejd
krcg d¢Znedej ƒ‚er{eD ]Ze	eƒZedurz nqnedu rˆedd 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 $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„ Z.e-e.ƒZ.dd „ Z/e/d!e-ge-ƒZ0e0e.ƒ dS )"é    N)ÚCDLLÚ	CFUNCTYPEÚc_char_pÚc_int)Úfind_library)ÚGDALException)ÚImproperlyConfiguredzdjango.contrib.gis)ÚsettingsÚnt)Úgdal203Úgdal202Úgdal201Úgdal20Úgdal111Úposix)ÚgdalÚGDALz	gdal2.3.0z	gdal2.2.0z	gdal2.1.0z	gdal2.0.0z
gdal1.11.0zGDAL is unsupported on OS "%s".zzCould not find the GDAL library (tried "%s"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.z", ")ÚWinDLLc                 C   s   t jdkr	t|  S t|  S )z^
    Return the correct STDCALL function for certain OSR routines on Win32
    platforms.
    r
   )ÚosÚnameÚlwingdalÚlgdal)Úfunc© r   ú\/var/www/html/myproject/venv/lib/python3.10/site-packages/django/contrib/gis/gdal/libgdal.pyÚstd_call:   s   
r   ÚGDALVersionInfoc                   C   ó   t dƒS )z0Return only the GDAL version number information.s   RELEASE_NAME©Ú_version_infor   r   r   r   Úgdal_versionM   ó   r    c                   C   r   )z)Return the full GDAL version information.Ú r   r   r   r   r   Úgdal_full_versionR   r!   r#   z5^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+))?c                     s6   t ƒ  ¡ } t | ¡‰ ˆ std|  ƒ‚‡ fdd„dD ƒS )Nz(Could not parse GDAL version string "%s"c                    s   i | ]}|ˆ   |¡“qS r   )Úgroup)Ú.0Úkey©Úmr   r   Ú
<dictcomp>_   s    z%gdal_version_info.<locals>.<dictcomp>)ÚmajorÚminorÚsubminor)r    ÚdecodeÚversion_regexÚmatchr   )Úverr   r'   r   Úgdal_version_infoZ   s
   

r1   r*   r+   r,   c                 C   s   t  d||¡ d S )NzGDAL_ERROR %d: %s)ÚloggerÚerror)Úerror_classÚerror_numberÚmessager   r   r   Úerr_handlerm   s   r7   c                 C   s   t | ƒ}||_||_|S )N)r   ÚargtypesÚrestype)r   Úargsr9   r   r   r   r   Úfunctiont   s   r;   ÚCPLSetErrorHandler)1Úloggingr   ÚreÚctypesr   r   r   r   Úctypes.utilr   Údjango.contrib.gis.gdal.errorr   Údjango.core.exceptionsr   Ú	getLoggerr2   Údjango.confr	   ÚGDAL_LIBRARY_PATHÚlib_pathÚAttributeErrorÚEnvironmentErrorÚImportErrorÚ	lib_namesr   Úlib_nameÚjoinr   r   r   r   r   r8   r9   r    r#   Úcompiler.   r1   Ú_verinfoÚintÚGDAL_MAJOR_VERSIONÚGDAL_MINOR_VERSIONÚGDAL_SUBMINOR_VERSIONÚGDAL_VERSIONÚCPLErrorHandlerr7   r;   Úset_error_handlerr   r   r   r   Ú<module>   sv    


ÿþ



ÿþÿ


