o
    i#                     @   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 redde eeZejdkrd dlmZ eeZdd ZedZege_ ee_!dd Z"dd Z#dd Z$e$ Z%edeeeZ&dd Z'e&e'Z'dd Z(e(de&ge&Z)e)e' dS )    N)CDLL	CFUNCTYPEc_char_pc_int)find_library)GDALException)ImproperlyConfiguredzdjango.contrib.gis)settingsnt)
gdal310gdal309gdal308gdal307gdal306gdal305gdal304gdal303gdal302gdal301posix)gdalGDALz
gdal3.10.0z	gdal3.9.0z	gdal3.8.0z	gdal3.7.0z	gdal3.6.0z	gdal3.5.0z	gdal3.4.0z	gdal3.3.0z	gdal3.2.0z	gdal3.1.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/formularioweb/env/lib/python3.10/site-packages/django/contrib/gis/gdal/libgdal.pystd_callS   s   
r    GDALVersionInfoc                   C      t dS )z0Return only the GDAL version number information.s   RELEASE_NAME_version_infor   r   r   r   gdal_versionf      r%   c                   C   r"   )z)Return the full GDAL version information.    r#   r   r   r   r   gdal_full_versionk   r&   r(   c                  C   sJ   t  } td| }|std|  | \}}}t|t||o#t|fS )Ns7   ^(?P<major>\d+)\.(?P<minor>\d+)(?:\.(?P<subminor>\d+))?z(Could not parse GDAL version string "%s")r%   rematchr   groupsint)vermmajorminorsubminorr   r   r   gdal_version_infop   s   r2   c                 C   s   t d|| d S )NzGDAL_ERROR %d: %s)loggererror)error_classerror_numbermessager   r   r   err_handler   s   r8   c                 C   s   t | }||_||_|S )N)r    argtypesrestype)r   argsr:   r   r   r   r   function   s   r<   CPLSetErrorHandler)*loggingr   r)   ctypesr   r   r   r   ctypes.utilr   django.contrib.gis.gdal.errorr   django.core.exceptionsr   	getLoggerr3   django.confr	   GDAL_LIBRARY_PATHlib_pathAttributeErrorImportErrorOSError	lib_namesr   lib_namejoinr   r   r   r    r$   r9   r:   r%   r(   r2   GDAL_VERSIONCPLErrorHandlerr8   r<   set_error_handlerr   r   r   r   <module>   sf    






	