o Úøa‡ã@s8dZddlZddlZddlmZmZmZmZmZddl m Z ddl m Z ddl mZmZddlmZe d¡Zd d „ZedeeƒZd d „ZeeƒZedeeƒZd d„ZeeƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZeeƒZeeƒZeeƒZeeƒZ eeƒZ!Gdd„dƒZ"dd„Z#dd„Z$dS)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_tuplezdjango.contrib.gisc CsØz ddlm}|j}Wnttttfyd}Ynw|r d}ntjdkr*ddg}ntjdkr4ddg}ntdtjƒ‚|rL|D] }t |ƒ}|durKnq?|durYtd d   |¡ƒ‚t |ƒ}t |j _t g|j_t|j_|S) Nr)ÚsettingsÚntÚgeos_cz libgeos_c-1ÚposixÚGEOSzUnsupported 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#úA/usr/lib/python3/dist-packages/django/contrib/gis/geos/libgeos.pyÚ load_geoss<  ÿ    ÿþÿ  r%cCóF| ¡| ¡}}z||}Wn ty|}Ynwt d|¡dS)NzGEOS_NOTICE: %s )ÚdecodeÚ TypeErrorÚloggerÚwarning)ÚfmtÚlstÚwarn_msgr#r#r$Únotice_hOó  ÿr.cCr&)NzGEOS_ERROR: %s )r'r(r)Úerror)r+r,Úerr_msgr#r#r$Úerror_h]r/r2c@ó eZdZdS)Ú GEOSGeom_tN©Ú__name__Ú __module__Ú __qualname__r#r#r#r$r4lór4c@r3)ÚGEOSPrepGeom_tNr5r#r#r#r$r:pr9r:c@r3)ÚGEOSCoordSeq_tNr5r#r#r#r$r;tr9r;c@r3)ÚGEOSContextHandle_tNr5r#r#r#r$r<xr9r<c@sBeZdZdZdZdZdZddddœdd„Zdd„Ze dd „ƒZ dS) ÚGEOSFuncFactoryz) Lazy loading of GEOS functions. N)rÚerrcheckrcCs8||_|dur ||_|dur||_|dur||_dSdS©N)Ú func_namerr>r)Úselfr@rr>rr#r#r$Ú__init__Žs ÿzGEOSFuncFactory.__init__cGs |j|ŽSr?)Úfunc)rAÚargsr#r#r$Ú__call__—s zGEOSFuncFactory.__call__cCs<ddlm}||jƒ}|jpg|_|j|_|jr|j|_|S)Nr)ÚGEOSFunc)Ú-django.contrib.gis.geos.prototypes.threadsaferFr@rrr>)rArFrCr#r#r$rCšs   zGEOSFuncFactory.func) r6r7r8Ú__doc__rrr>rBrEr rCr#r#r#r$r=†s r=cCst ¡S)z.Return the string version of the GEOS library.)Úlgeosrr#r#r#r$Ú geos_version¥srJcCsttƒ ¡ƒS)zs8     7