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__/functions.cpython-310.pyc
o

�aUD�@s2ddlmZddlmZmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZmZmZmZddlmZdd	lmZeeefZGd
d�d�ZGdd
�d
ee�ZGdd�de�Z Gdd�d�Z!Gdd�d�Z"Gdd�de"e�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&Gdd�de�Z'Gdd�de�Z(Gd d!�d!e�Z)Gd"d#�d#e�Z*Gd$d%�d%e"e �Z+Gd&d'�d'e"e �Z,Gd(d)�d)e"e �Z-Gd*d+�d+�Z.Gd,d-�d-e.e"e�Z/Gd.d/�d/e �Z0Gd0d1�d1e �Z1Gd2d3�d3e�Z2Gd4d5�d5e�Z3Gd6d7�d7e"e �Z4ej5Gd8d9�d9e"ee��Z6Gd:d;�d;e.e"e�Z7Gd<d=�d=e�Z8Gd>d?�d?e �Z9Gd@dA�dAe�Z:GdBdC�dCe�Z;GdDdE�dEe�Z<GdFdG�dGe.e"e�Z=GdHdI�dIe"e �Z>GdJdK�dKe�Z?GdLdM�dMe!e �Z@GdNdO�dOe!e �ZAGdPdQ�dQe"e �ZBGdRdS�dSe �ZGdTdU�dUe@�ZCGdVdW�dWe"e �ZDdXS)Y�)�Decimal)�BaseSpatialField�
GeometryField)�	AreaField�
DistanceField)�GEOSGeometry)�
FieldError)�NotSupportedError)�BinaryField�BooleanField�
FloatField�Func�IntegerField�	TextField�	Transform�Value)�Cast)�cached_propertycs`eZdZdZdZ�fdd�Zedd��Zedd��Z	d�fd	d
�	Z
�fdd�Zddd�Z�Z
S)�GeoFuncMixinN)rc	s�t�j|i|��|jD]P}|j|}t|t�sqz|j}Wnty)d}Ynw|j}t|t	�r9|rDt|t
�sDtd|j|df��|j
sM|sMtd��|s\t|t
|j
d�d�|j|<qdS)Nz9%s function requires a geometric argument in position %d.�z$SRID is required for all geometries.��srid)�output_field)�super�__init__�geom_param_pos�source_expressions�
isinstancerrr�valuerr�	TypeError�namer�
ValueError)�self�expressions�extra�pos�exprr�geom��	__class__��H/usr/lib/python3/dist-packages/django/contrib/gis/db/models/functions.pyrs&



�
��zGeoFuncMixin.__init__cCs|jjS�N)r)�__name__�r"r*r*r+r *szGeoFuncMixin.namecCs|j|jdjS�Nr)rr�fieldr.r*r*r+�	geo_field.szGeoFuncMixin.geo_fieldcs:|jdur|dur|j�|j�}t�j||fd|i|��S)N�function)r2�ops�spatial_function_namer r�as_sql)r"�compiler�
connectionr2�
extra_contextr(r*r+r52szGeoFuncMixin.as_sqlc
s�t�j|i|��}|��}|jD]}||}t|t�s*td|j|dt|�j	f��q|j
j}|jdd�D]}|j|}|j
j}	|	|krSt||�j|i|��|j|<q6|S)Nz<%s function requires a GeometryField in position %s, got %s.r)r�resolve_expression�get_source_fieldsrrrrr �typer-r1rrrr)
r"�args�kwargs�res�
source_fieldsr%r0�	base_sridr&�	expr_sridr(r*r+r97s&

���
�zGeoFuncMixin.resolve_expression�cCs,t|d�s|rt||�std||f��|S)Nr9z2The %s parameter has the wrong type: should be %s.)�hasattrrr)r"r�
param_name�check_typesr*r*r+�
_handle_paramNs
��zGeoFuncMixin._handle_paramr,�rBN)r-�
__module__�__qualname__r2rr�propertyr rr1r5r9rF�
__classcell__r*r*r(r+rs

rc@�eZdZdS)�GeoFuncN�r-rHrIr*r*r*r+rMX�rMc@seZdZedd��ZdS)�GeomOutputGeoFunccCst|jjd�S)Nr)rr1rr.r*r*r+r]szGeomOutputGeoFunc.output_fieldN)r-rHrIrrr*r*r*r+rP\srPc@�eZdZdZdd�ZdS)�SQLiteDecimalToFloatMixinz�
    By default, Decimal values are converted to str by the SQLite backend, which
    is not acceptable by the GIS functions expecting numeric values.
    cKs4|��}|�dd�|��D��|j||fi|��S)NcSs4g|]}t|d�rt|jt�rtt|j��n|�qS)r)rCrrrr�float)�.0r&r*r*r+�
<listcomp>is
$��z7SQLiteDecimalToFloatMixin.as_sqlite.<locals>.<listcomp>)�copy�set_source_expressions�get_source_expressionsr5)r"r6r7r8rVr*r*r+�	as_sqlitegs

�z#SQLiteDecimalToFloatMixin.as_sqliteN)r-rHrI�__doc__rYr*r*r*r+rRbsrRc@rQ)�OracleToleranceMixing�������?cKsPt|�|j�d|j�dt��}|��}|�g|���|��|j	||fi|��S)N�	tolerance)
rrFr$�getr\�
NUMERIC_TYPESrVrWrXr5)r"r6r7r8r\�cloner*r*r+�	as_oraclets�zOracleToleranceMixin.as_oracleN)r-rHrIr\r`r*r*r*r+r[qsr[cs4eZdZdZedd��Z�fdd�Zdd�Z�ZS)�ArearcC�
t|j�Sr,)rr1r.r*r*r+r��
zArea.output_fieldcs2|jjs|j�|�rtd��t�j||fi|��S)Nz2Area on geodetic coordinate systems not supported.)�features�supports_area_geodeticr1�geodeticr	rr5�r"r6r7r8r(r*r+r5��zArea.as_sqlcKs0|j�|�rd|d<d|d<|j||fi|��S)Nz+%(function)s(%(expressions)s, %(spheroid)d)�templateT�spheroid)r1rfr5rgr*r*r+rY�szArea.as_sqlite)	r-rHrI�arityrrr5rYrKr*r*r(r+ras
rac@�eZdZe�ZdZdZdS)�Azimuth��rrN�r-rHrIrrrkrr*r*r*r+rm��rmcs0eZdZe�Zd�fdd�	Z�fdd�Z�ZS)�	AsGeoJSONF�csj|g}|dur|�|�|dt��d}|r|rd}n	|rd}n|r#d}|r*|�|�t�j|i|��dS)N�	precisionr�rrn��appendrF�intrr)r"�
expression�bbox�crsrtr$r#�optionsr(r*r+r�s
zAsGeoJSON.__init__cs<|��}|��}|�|dd��tt|�j||fi|��S)Nr)rXrVrWrrrr5)r"r6r7r8rr_r(r*r+r`�szAsGeoJSON.as_oracle)FFrs)r-rHrIrrrr`rKr*r*r(r+rr�srrcs4eZdZdZe�Zd�fdd�	Z�fdd�Z�ZS)	�AsGML)rrnrscs:||g}|dur|�|�|dt��t�j|i|��dS�Nrtrv)r"ry�versionrtr$r#r(r*r+r�szAsGML.__init__csX|��}|d}|��}|�|dg�|jdkrdnd|d<tt|�j||fi|��S)NrrruzSDO_UTIL.TO_GML311GEOMETRYzSDO_UTIL.TO_GMLGEOMETRYr2)rXrVrWrrr}r5)r"r6r7r8rrr_r(r*r+r`�szAsGML.as_oracle)rnrs)	r-rHrIrrrrr`rKr*r*r(r+r}�s
r}cs$eZdZe�Zd�fdd�	Z�ZS)�AsKMLrsc�8|g}|dur|�|�|dt��t�j|i|��dSr~rv�r"ryrtr$r#r(r*r+r��zAsKML.__init__)rs�r-rHrIrrrrKr*r*r(r+r���r�cs$eZdZe�Zd�fdd�	Z�ZS)�AsSVGFrscs@t|d�r|nt|�}|||�|dt�g}t�j|i|��dS)Nr9rt)rCrxrFrr)r"ry�relativertr$r#r(r*r+r�s�zAsSVG.__init__)Frsr�r*r*r(r+r��r�r�c@�eZdZe�ZdZdS)�AsWKBrN)r-rHrIr
rrkr*r*r*r+r���r�c@r�)�AsWKTrN)r-rHrIrrrkr*r*r*r+r��r�r�cs*eZdZd�fdd�	Z�fdd�Z�ZS)�BoundingCircle�0cst�j||fi|��dSr,)rr)r"ry�num_segr$r(r*r+r�szBoundingCircle.__init__cs6|��}|�|��dg�tt|�j||fi|��Sr/)rVrWrXrr�r`�r"r6r7r8r_r(r*r+r`�szBoundingCircle.as_oracle)r�)r-rHrIrr`rKr*r*r(r+r��sr�c@�eZdZdZdS)�CentroidrN�r-rHrIrkr*r*r*r+r���r�c@�eZdZdZdZdS)�
DifferencernroN�r-rHrIrkrr*r*r*r+r���r�c@s eZdZedd��Zdd�ZdS)�DistanceResultMixincCrbr,)rr1r.r*r*r+r�rcz DistanceResultMixin.output_fieldcCs|jjo	|jjdkS)Ni�)r1�	geographyrr.r*r*r+�source_is_geography�sz'DistanceResultMixin.source_is_geographyN)r-rHrIrrr�r*r*r*r+r��s
r�cs>eZdZdZdZd	�fdd�	Z�fdd�Z�fdd�Z�ZS)
�DistanceroNcs6||g}|dur|�|dt�|_t�j|i|��dS)Nrj)rF�boolrjrr)r"�expr1�expr2rjr$r#r(r*r+rszDistance.__init__cs�|��}d}|jd}|��}|jj|kr-t|t�r||j_nt|t|jj	|d��|jd<|sQ|j
�|�rQ|jrK|j
�d�}|j�t|j
�|���n|j
�d�}tt|�j||fd|i|��S)Nr)rr��DistanceSpheroid�DistanceSpherer2)rVrr�rr�rrrrrr1rfrjr3r4rwrr�r5)r"r6r7r8r_r2r�r�r(r*r+�
as_postgresqls"



�zDistance.as_postgresqlcs<|j�|�rd|d<tt|j��|d<t�j||fi|��S)Nz8COALESCE(%(function)s(%(expressions)s, %(spheroid)s), 0)rirj)r1rfrxr�rjrr5rgr(r*r+rY$szDistance.as_sqliter,)	r-rHrIrrjrr�rYrKr*r*r(r+r�sr�c@r�)�EnveloperNr�r*r*r*r+r�,r�r�c@r�)�ForcePolygonCWrNr�r*r*r*r+r�0r�r�cs,eZdZe�Zd�fdd�	Zdd�Z�ZS)�GeoHashNcr�r~rvr�r(r*r+r7r�zGeoHash.__init__cKs:|��}t|j�dkr|j�td��|j||fi|��S)Nrn�d)rV�lenrrwrr5r�r*r*r+�as_mysql=szGeoHash.as_mysqlr,)r-rHrIrrrr�rKr*r*r(r+r�4sr�c@s"eZdZe�ZdZdZdZdZdS)�GeometryDistancernrBz <-> roN)	r-rHrIrrrkr2�
arg_joinerrr*r*r*r+r�Esr�c@r�)�IntersectionrnroNr�r*r*r*r+r�Mr�r�cs&eZdZdZe�Z�fdd�Z�ZS)�IsValid�isvalidcs&t�j||fi|��\}}d||fS)Nz%CASE %s WHEN 'TRUE' THEN 1 ELSE 0 END)rr`)r"r6r7r8�sql�paramsr(r*r+r`WszIsValid.as_oracle)r-rHrI�lookup_namerrr`rKr*r*r(r+r�Rsr�csBeZdZd
�fdd�	Z�fdd�Z�fdd�Z�fdd	�Z�ZS)�LengthTcs||_t�j|fi|��dSr,)rjrr)r"r�rjr$r(r*r+r]szLength.__init__cs2|j�|�r|jjstd��t�j||fi|��S)Nz6This backend doesn't support Length on geodetic fields)r1rfrd�supports_length_geodeticr	rr5rgr(r*r+r5arhz
Length.as_sqlcs�|��}d}|��r|j�t|j��n,|j�|�r-|j�	d�}|j�t|j�|���nt
dd�|��D��}|dkr@|jj}t
t|�j||fd|i|��S)N�LengthSpheroidcss�|]}|r|jVqdSr,��dim�rT�fr*r*r+�	<genexpr>ps�z'Length.as_postgresql.<locals>.<genexpr>rnr2)rVr�rrwrrjr1rfr3r4�minr:�length3drr�r5)r"r6r7r8r_r2r�r(r*r+r�fszLength.as_postgresqlcs8d}|j�|�r|jr
dnd}t�j||fd|i|��S)N�GeodesicLength�GreatCircleLengthr2)r1rfrjrr5)r"r6r7r8r2r(r*r+rYuszLength.as_sqlite)T)r-rHrIrr5r�rYrKr*r*r(r+r�\s
r�c@rl)�LineLocatePointrnroNrpr*r*r*r+r�|rqr�c@rL)�	MakeValidNrNr*r*r*r+r��rOr�c@r�)�MemSizerN�r-rHrIrrrkr*r*r*r+r��r�r�c@r�)�
NumGeometriesrNr�r*r*r*r+r��r�r�c@r�)�	NumPointsrNr�r*r*r*r+r��r�r�cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�	Perimeterrcs`d}|j�|�r|��std��tdd�|��D��}|dkr#|jj}t�j	||fd|i|��S)Nz<ST_Perimeter cannot use a non-projected non-geography field.css�|]}|jVqdSr,r�r�r*r*r+r��s�z*Perimeter.as_postgresql.<locals>.<genexpr>rnr2)
r1rfr�r	r�r:r3�perimeter3drr5)r"r6r7r8r2r�r(r*r+r��szPerimeter.as_postgresqlcs*|j�|�r
td��t�j||fi|��S)Nz+Perimeter cannot use a non-projected field.)r1rfr	rr5rgr(r*r+rY�szPerimeter.as_sqlite)r-rHrIrkr�rYrKr*r*r(r+r��s	r�c@r�)�PointOnSurfacerNr�r*r*r*r+r��r�r�c@r�)�ReverserNr�r*r*r*r+r��r�r�cseZdZd�fdd�	Z�ZS)�Scale�csP||�|dt�|�|dt�g}|dkr|�|�|dt��t�j|i|��dS)N�x�yr��z)rFr^rwrr)r"ryr�r�r�r$r#r(r*r+r�s�zScale.__init__)r��r-rHrIrrKr*r*r(r+r��sr�c�eZdZ�fdd�Z�ZS)�
SnapToGridcs�t|�}|g}|dvr|��fdd�|D��n'|dkr;|g�fdd�|dd�D���fdd�|d	d�D��7}ntd
��t�j|i|��dS)N)rrncsg|]	}��|dt��qS)rB�rFr^�rT�argr.r*r+rU�sz'SnapToGrid.__init__.<locals>.<listcomp>�c3��|]
}��|dt�VqdSrGr�r�r.r*r+r����z&SnapToGrid.__init__.<locals>.<genexpr>rnc3r�rGr�r�r.r*r+r��r�rz2Must provide 1, 2, or 4 arguments to `SnapToGrid`.)r��extendr!rr)r"ryr<r$�nargsr#r(r.r+r�s���zSnapToGrid.__init__r�r*r*r(r+r���r�c@r�)�
SymDifferencernroNr�r*r*r*r+r��r�r�cr�)rcs>||�|dt�g}d|vrt|d�|d<t�j|i|��dS)Nrrr)rFrxrrr)r"ryrr$r#r(r*r+r�s�zTransform.__init__r�r*r*r(r+r�r�rcr�)�	Translatecs@|��}t|j�dkr|j�td��tt|�j||fi|��S)Nr�r)rVr�rrwrrr�rYr�r(r*r+rY�szTranslate.as_sqlite)r-rHrIrYrKr*r*r(r+r��r�r�c@r�)�UnionrnroNr�r*r*r*r+r��r�r�N)E�decimalr�#django.contrib.gis.db.models.fieldsrr� django.contrib.gis.db.models.sqlrr�django.contrib.gis.geosr�django.core.exceptionsr�	django.dbr	�django.db.modelsr
rrr
rrrr�django.db.models.functionsr�django.utils.functionalrrxrSr^rrMrPrRr[rarmrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r��register_lookupr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r*r*r*r+�<module>sd(
F


	+	 	

https://t.me/RX1948 - 2025