HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/django/contrib/gis/db/models/__pycache__/proxy.cpython-310.pyc
o

3�a2�@s$dZddlmZGdd�de�ZdS)a
The SpatialProxy object allows for lazy-geometries and lazy-rasters. The proxy
uses Python descriptors for instantiating and setting Geometry or Raster
objects corresponding to geographic model fields.

Thanks to Robert Coup for providing this functionality (see #4322).
�)�DeferredAttributecs4eZdZd�fdd�	Zd�fdd�	Zdd�Z�ZS)	�SpatialProxyNcs ||_|p||_t��|�dS)zy
        Initialize on the given Geometry or Raster class (not an instance)
        and the corresponding field.
        N)�_klass�
_load_func�super�__init__)�self�klass�field�	load_func��	__class__��D/usr/lib/python3/dist-packages/django/contrib/gis/db/models/proxy.pyrs
zSpatialProxy.__init__cs�|dur|Sz	|j|jj}Wntyt��||�}Ynwt||j�r*|}|S|dus2|dkr6d}|S|�|�}t	||jj|�|S)z�
        Retrieve the geometry or raster, initializing it using the
        corresponding class specified during initialization and the value of
        the field. Currently, GEOS or OGR geometries as well as GDALRasters are
        supported.
        N�)
�__dict__r
�attname�KeyErrorr�__get__�
isinstancerr�setattr)r�instance�cls�	geo_value�geo_objrrrrs ��
�zSpatialProxy.__get__cCs�|jj}|dkr|dust|tt|jf�rn*t||j�r'|jdur&|jj|_n|dus2t|ttf�r3n
td|j	j
|t|�f��||j|jj
<|S)z�
        Retrieve the proxied geometry or raster with the corresponding class
        specified during initialization.

        To set geometries, use values of None, HEXEWKB, or WKT.
        To set rasters, use JSON or dict values.
        �RASTERNz6Cannot set %s SpatialProxy (%s) with value of type: %s)r
�	geom_typer�str�dictr�srid�
memoryview�	TypeErrorr
�__name__�typerr)rr�value�gtyperrr�__set__1s	"

��zSpatialProxy.__set__)N)r"�
__module__�__qualname__rrr&�
__classcell__rrrrrs	rN)�__doc__�django.db.models.query_utilsrrrrrr�<module>s