File manager - Edit - /usr/local/CyberPanel/lib/python3.10/site-packages/django/contrib/gis/db/models/__pycache__/proxy.cpython-310.pyc
Back
o �he � @ s$ d Z ddlmZ G dd� 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). � )�DeferredAttributec s4 e Zd Zd� fdd� Zd� fdd� Zdd� Z� ZS ) �SpatialProxyNc s || _ |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__� �X/usr/local/CyberPanel/lib/python3.10/site-packages/django/contrib/gis/db/models/proxy.pyr s zSpatialProxy.__init__c s� |du r| S z |j | jj }W n ty t� �||�}Y nw t|| j�r*|}|S |du s2|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__� isinstancer r �setattr)r �instance�cls� geo_value�geo_objr r r r s �� �zSpatialProxy.__get__c C s� | j j}|dkr|du st|tt| jf�rn*t|| j�r'|jdu r&| j j|_n|du s2t|ttf�r3n td|j j |t|�f ��||j| j j <