o
    iTte‡  ã                   @   s8  d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZmZ ddlmZ e d¡Zd	d
„ ZedeeƒZdd„ ZeeƒZedeeƒZdd„ ZeeƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZeeƒZeeƒZeeƒZeeƒZ eeƒZ!G dd„ dƒZ"dd„ Z#dd„ Z$dS )a  
 This module houses the ctypes initialization procedures, as well
 as the notice and error handler function callbacks (get called
 when an error occurs in GEOS).

 This module also houses GEOS Pointer utilities, including
 get_pointer_arr(), and GEOM_PTR.
é    N)ÚCDLLÚ	CFUNCTYPEÚPOINTERÚ	StructureÚc_char_p)Úfind_library)ÚImproperlyConfigured)ÚSimpleLazyObjectÚcached_property)Úget_version_tuplezdjango.contrib.gisc                  C   sØ   zddl m}  | j}W n ttttfy   d }Y nw |r d }ntjdkr*ddg}ntjdkr4ddg}ntdtj ƒ‚|rL|D ]}t	|ƒ}|d urK nq?|d u rYtd	d
 
|¡ ƒ‚t|ƒ}t|j_tg|j_t|j_|S )Nr   )ÚsettingsÚntÚgeos_czlibgeos_c-1ÚposixÚGEOSzUnsupported OS "%s"z]Could not find the GEOS library (tried "%s"). Try setting GEOS_LIBRARY_PATH in your settings.z", ")Údjango.confr   ÚGEOS_LIBRARY_PATHÚAttributeErrorÚImportErrorr   ÚOSErrorÚosÚnamer   Újoinr   ÚCONTEXT_PTRÚ
initGEOS_rÚrestypeÚfinishGEOS_rÚargtypesr   ÚGEOSversion)r   Úlib_pathÚ	lib_namesÚlib_nameÚ_lgeos© r#   úk/var/www/social.2tendo.club/virtuCedar/venv/lib/python3.10/site-packages/django/contrib/gis/geos/libgeos.pyÚ	load_geos   s<   
ÿ



ÿþÿ	
r%   c                 C   óF   |   ¡ |  ¡ } }z| | }W n ty   | }Y nw t d|¡ d S )NzGEOS_NOTICE: %s
)ÚdecodeÚ	TypeErrorÚloggerÚwarning)ÚfmtÚlstÚwarn_msgr#   r#   r$   Únotice_hO   ó   ÿr.   c                 C   r&   )NzGEOS_ERROR: %s
)r'   r(   r)   Úerror)r+   r,   Úerr_msgr#   r#   r$   Úerror_h]   r/   r2   c                   @   ó   e Zd ZdS )Ú
GEOSGeom_tN©Ú__name__Ú
__module__Ú__qualname__r#   r#   r#   r$   r4   l   ó    r4   c                   @   r3   )ÚGEOSPrepGeom_tNr5   r#   r#   r#   r$   r:   p   r9   r:   c                   @   r3   )ÚGEOSCoordSeq_tNr5   r#   r#   r#   r$   r;   t   r9   r;   c                   @   r3   )ÚGEOSContextHandle_tNr5   r#   r#   r#   r$   r<   x   r9   r<   c                   @   sB   e Zd ZdZdZdZdZddddœdd„Zdd„ Ze	dd	„ ƒZ
dS )
ÚGEOSFuncFactoryz)
    Lazy loading of GEOS functions.
    N)r   Úerrcheckr   c                C   s8   || _ |d ur
|| _|d ur|| _|d ur|| _d S d S ©N)Ú	func_namer   r>   r   )Úselfr@   r   r>   r   r#   r#   r$   Ú__init__Ž   s   
ÿzGEOSFuncFactory.__init__c                 G   s
   | j |Ž S r?   )Úfunc)rA   Úargsr#   r#   r$   Ú__call__—   s   
zGEOSFuncFactory.__call__c                 C   s<   ddl m} || jƒ}| jpg |_| j|_| jr| j|_|S )Nr   )ÚGEOSFunc)Ú-django.contrib.gis.geos.prototypes.threadsaferF   r@   r   r   r>   )rA   rF   rC   r#   r#   r$   rC   š   s   
zGEOSFuncFactory.func)r6   r7   r8   Ú__doc__r   r   r>   rB   rE   r
   rC   r#   r#   r#   r$   r=   †   s    	r=   c                   C   s   t  ¡ S )z.Return the string version of the GEOS library.)Úlgeosr   r#   r#   r#   r$   Úgeos_version¥   s   rJ   c                   C   s   t tƒ  ¡ ƒS )z<Return the GEOS version as a tuple (major, minor, subminor).)r   rJ   r'   r#   r#   r#   r$   Úgeos_version_tupleª   s   rK   )%rH   Úloggingr   Úctypesr   r   r   r   r   Úctypes.utilr   Údjango.core.exceptionsr   Údjango.utils.functionalr	   r
   Údjango.utils.versionr   Ú	getLoggerr)   r%   Ú
NOTICEFUNCr.   Ú	ERRORFUNCr2   r4   r:   r;   r<   ÚGEOM_PTRÚPREPGEOM_PTRÚCS_PTRr   rI   r=   rJ   rK   r#   r#   r#   r$   Ú<module>   s8    
7		