https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/gis/db/models/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/gis/db/models/__pycache__/fields.cpython-310.pyc
o

�a6�@sZddlmZmZddlmZmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZddlmZddlmZddlmZee�aed	gd
��Zdd�ZGd
d�de�ZGdd�de�Z Gdd�de �Z!Gdd�de �Z"Gdd�de �Z#Gdd�de �Z$Gdd�de �Z%Gdd�de �Z&Gdd�de �Z'Gdd �d e�Z(Gd!d"�d"e�Z)d#S)$�)�defaultdict�
namedtuple)�forms�gdal)�SpatialProxy)�
GDALException)	�GeometryCollection�
GEOSException�GEOSGeometry�
LineString�MultiLineString�
MultiPoint�MultiPolygon�Point�Polygon)�ImproperlyConfigured)�Field)�gettext_lazy�SRIDCacheEntry��units�
units_name�spheroid�geodeticcs�ddlm}z�j���Wntyd�Ynw�r%�j��fdd�fnd|f\}}|t|vrP||�}|j\}}t||d|d|j	|j
f|jd�t||<t||S)	z�
    Return the units, unit name, and spheroid WKT associated with the
    given SRID from the `spatial_ref_sys` (or equivalent) spatial database
    table for the given database connection.  These results are cached.
    r)�SpatialReferenceNcs�j��j�j|d�jS)N��srid)�objects�using�alias�get�srsr��
SpatialRefSys�
connection��E/usr/lib/python3/dist-packages/django/contrib/gis/db/models/fields.py�<lambda>'szget_srid_info.<locals>.<lambda>zSPHEROID["%s",%s,%s]rr)�django.contrib.gis.gdalr�ops�spatial_ref_sys�NotImplementedErrorr�_srid_cacherr�
semi_major�inverse_flattening�
geographic)rr$rr�get_srsr!rrr%r"r&�
get_srid_infos(���
�r1cs�eZdZdZed�ZdZd�fdd�	Z�fd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Z�fdd�Zdd�Z�fdd�Z�ZS) �BaseSpatialFieldz�
    The Base GIS Field.

    It's used as a base class for GeometryField and RasterField. Defines
    properties that are common to all GIS fields such as the characteristics
    of the spatial reference system of the field.
    zThe base GIS field.FN��Tcs*||_||_||d<t�jdi|��dS)a�
        The initialization function for base spatial fields. Takes the following
        as keyword arguments:

        srid:
         The spatial reference system identifier, an OGC standard.
         Defaults to 4326 (WGS84).

        spatial_index:
         Indicates whether to create a spatial index.  Defaults to True.
         Set this instead of 'db_index' for geographic fields since index
         creation is different for geometry columns.
        �verbose_nameNr%)�
spatial_indexr�super�__init__)�selfr4rr5�kwargs��	__class__r%r&r7CszBaseSpatialField.__init__cs<t���\}}}}|j|d<|jdur|j|d<||||fS)NrTr5)r6�deconstructrr5�r8�name�path�argsr9r:r%r&r<_s



zBaseSpatialField.deconstructcCs|j�|�S�N)r)�geo_db_type�r8r$r%r%r&�db_typeh�zBaseSpatialField.db_typecC�t|j|�jSrA)r1rrrCr%r%r&rk�zBaseSpatialField.spheroidcCrFrA)r1rrrCr%r%r&rnrGzBaseSpatialField.unitscCrFrA)r1rrrCr%r%r&rqrGzBaseSpatialField.units_namecCrF)z�
        Return true if this field's SRID corresponds with a coordinate
        system that uses non-projected units (e.g., latitude/longitude).
        )r1rrrCr%r%r&rtszBaseSpatialField.geodeticcCs|j�|||�S)z\
        Return the placeholder for the spatial column for the
        given value.
        )r)�get_geom_placeholder)r8�value�compilerr$r%r%r&�get_placeholder{sz BaseSpatialField.get_placeholdercCs4|j}|dus|jdks|dkr|jdkr|jS|S)a
        Return the default SRID for the given geometry or raster, taking into
        account the SRID set for the field. For example, if the input geometry
        or raster doesn't have an SRID, then the SRID of the field will be
        returned.
        N���r)r8�objrr%r%r&�get_srid�s$zBaseSpatialField.get_sridcsR|durdS|jjt�j||g|�Ri|��fi|jr%|jjr%ddi��Si��S)N�	geographyT)r)�Adapterr6�get_db_prep_valuerO�features�supports_geography)r8rIr$r@r9r:r%r&rQ�s�����z"BaseSpatialField.get_db_prep_valuecCslt|tj�r|S|rzt�|�WStyYdSwt|t�r4zt�|�WSty3td|��wdS)zY
        Return a GDALRaster if conversion is successful, otherwise return None.
        �6Couldn't create spatial object from lookup value '%s'.N)�
isinstancer�
GDALRasterr�dict�
ValueError)r8rI�is_candidater%r%r&�get_raster_prep_value�s�
��z&BaseSpatialField.get_raster_prep_valuec	s�t��|�}|durdSt|t�rn8t|ttf�pt|d�}|�||�}|r)|}n!|rAzt|�}Wntt	fy@t
d|��wt
dt|�j��|�
|�|_|S)N�__geo_interface__rTz>Cannot use object with type %s for a spatial lookup parameter.)r6�get_prep_valuerUr
�bytes�str�hasattrrZr	rrX�type�__name__rNr)r8rIrMrY�rasterr:r%r&r\�s$
�zBaseSpatialField.get_prep_value)Nr3T)ra�
__module__�__qualname__�__doc__�_�description�empty_strings_allowedr7r<rDrrrrrKrNrQrZr\�
__classcell__r%r%r:r&r28s 	
r2csleZdZdZed�ZejZdZ	dZ
dddd	��fd
d�Z�fdd
�Z�fdd�Z
�fdd�Zdd�Z�ZS)�
GeometryFieldzU
    The base Geometry field -- maps to the OpenGIS Specification Geometry type.
    uLThe base Geometry field — maps to the OpenGIS Specification Geometry type.�GEOMETRYN�F�g�f�g�V�g�f@g�V@皙�����?)�extent�	tolerancecs2||_||_||_||_t�jdd|i|��dS)a�
        The initialization function for geometry fields. In addition to the
        parameters from BaseSpatialField, it takes the following as keyword
        arguments:

        dim:
         The number of dimensions for this geometry.  Defaults to 2.

        extent:
         Customize the extent, in a 4-tuple of WGS 84 coordinates, for the
         geometry field entry in the `USER_SDO_GEOM_METADATA` table.  Defaults
         to (-180.0, -90.0, 180.0, 90.0).

        tolerance:
         Define the tolerance, in meters, to use for the geometry field
         entry in the `USER_SDO_GEOM_METADATA` table.  Defaults to 0.05.
        r4Nr%)�dimrO�_extent�
_tolerancer6r7)r8r4rqrOrorpr9r:r%r&r7�s
zGeometryField.__init__csnt���\}}}}|jdkr|j|d<|jdur|j|d<|jdkr'|j|d<|jdkr1|j|d<||||fS)	NrlrqFrOrmrornrp)r6r<rqrOrrrsr=r:r%r&r<�s







zGeometryField.deconstructcs8t�j||fi|��t||jt|jpt|td��dS)N)�	load_func)r6�contribute_to_class�setattr�attnamer�
geom_classr
�r8�clsr>r9r:r%r&rus"z!GeometryField.contribute_to_classcsR|j|j|jd�|�}|jdkr t|djdd�s |�dtj�t	�j
di|��S)N)�
form_class�	geom_typerrlr{�supports_3dF�widgetr%)r{r|rrq�getattrr~�
setdefaultr�Textarear6�	formfield)r8r9�defaultsr:r%r&r�s��zGeometryField.formfieldcCs"|jjs
|jjj||fS||fS)z�
        Return the selection format string, depending on the requirements
        of the spatial backend. For example, Oracle and MySQL require custom
        selection formats in order to retrieve geometries in OGC WKB.
        )�query�subqueryr$r)�select)r8rJ�sql�paramsr%r%r&�
select_formatszGeometryField.select_format)NrlF)rarcrdrerfrgrrjr{r|rxr7r<rur�r�rir%r%r:r&rj�s� 
rjc@�"eZdZdZeZejZe	d�Z
dS)�
PointField�POINTrN)rarcrdr|rrxrr�r{rfrgr%r%r%r&r��
r�c@r�)�LineStringField�
LINESTRINGzLine stringN)rarcrdr|rrxrr�r{rfrgr%r%r%r&r�$r�r�c@r�)�PolygonField�POLYGONrN)rarcrdr|rrxrr�r{rfrgr%r%r%r&r�+r�r�c@r�)�MultiPointField�
MULTIPOINTzMulti-pointN)rarcrdr|r
rxrr�r{rfrgr%r%r%r&r�2r�r�c@r�)�MultiLineStringField�MULTILINESTRINGzMulti-line stringN)rarcrdr|rrxrr�r{rfrgr%r%r%r&r�9r�r�c@r�)�MultiPolygonField�MULTIPOLYGONz
Multi polygonN)rarcrdr|rrxrr�r{rfrgr%r%r%r&r�@r�r�c@r�)�GeometryCollectionField�GEOMETRYCOLLECTIONzGeometry collectionN)rarcrdr|rrxrr�r{rfrgr%r%r%r&r�Gr�r�c@s(eZdZdZed�Zdd�Zdd�ZdS)�ExtentFieldz/Used as a return value from an extent aggregatezExtent Aggregate FieldcCsdS)Nr�r%)r8r%r%r&�get_internal_typeSszExtentField.get_internal_typecCs"|jjj}|r
|||fS||fSrA)r$r)�
select_extent)r8rJr�r�r�r%r%r&r�Vs
zExtentField.select_formatN)rarcrdrerfrgr�r�r%r%r%r&r�Ns
r�csXeZdZdZed�ZdZdZdd�Z�fdd�Z	d	d
�Z
�fdd�Z�fd
d�Z�Z
S)�RasterFieldzJ
    Raster field for GeoDjango -- evaluates into GDALRaster objects.
    zRaster Field�RASTERFcCs|jjr|jjstd��dS)Nz3Raster fields require backends with raster support.)rR�gis_enabled�supports_rasterrrCr%r%r&�_check_connectionds�zRasterField._check_connectioncs|�|�t��|�SrA)r�r6rDrCr:r%r&rDis
zRasterField.db_typecCs|j�|�SrA)r)�parse_raster)r8rI�
expressionr$r%r%r&�
from_db_valuemrEzRasterField.from_db_valuecs0t�j||fi|��t||jttj|��dSrA)r6rurvrwrrrVryr:r%r&rupszRasterField.contribute_to_classcsHddlm}zt|�}td|fd|i�WStyYnwt��|�S)Nr)�RasterBandTransform�SpecificRasterBandTransform�
band_index)�$django.contrib.gis.db.models.lookupsr��intr`rXr6�
get_transform)r8r>r�r�r:r%r&r�xs��zRasterField.get_transform)rarcrdrerfrgr|rOr�rDr�rur�rir%r%r:r&r�[sr�N)*�collectionsrr�django.contrib.gisrr�"django.contrib.gis.db.models.proxyr�django.contrib.gis.gdal.errorr�django.contrib.gis.geosrr	r
rrr
rrr�django.core.exceptionsr�django.db.modelsr�django.utils.translationrrfrWr,rr1r2rjr�r�r�r�r�r�r�r�r�r%r%r%r&�<module>s.,!T

https://t.me/RX1948 - 2025