
    Dvg                     h    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ  G d d          ZdS )	    )GeometryField)Distance)Area)NotSupportedError)cached_propertyc                        e Zd ZdZdZdZdZdZdZdZ	e
d             ZdZdZi Zh dZdZd Zd	 Zd
 Zd Zd Zd Z fdZd Zd Zd Zd Z ee          Z fdZd Z d Z!d Z" xZ#S )BaseSpatialOperationsFN%sc                     | j         S N)selectselfs    k/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/db/backends/base/operations.pyselect_extentz#BaseSpatialOperations.select_extent   s
    {      >"   r   AsGMLAsKMLAsSVGScaleUnionLengthAzimuthFromWKBFromWKTGeoHashIsEmptyIsValidMemSizeReverseCentroidr   Envelope	AsGeoJSON	MakeValid	NumPoints	Perimeter	Transform	Translate
Difference
SnapToGridClosestPointIntersectionNumGeometriesSymDifferenceBoundingCirclePointOnSurfaceLineLocatePointGeometryDistancec                      t          d          )Nz:Aggregate extent not implemented for this spatial backend.NotImplementedErrorr   boxsrids      r   convert_extentz$BaseSpatialOperations.convert_extentN   s    !H
 
 	
r   c                      t          d          )Nz=Aggregate 3D extent not implemented for this spatial backend.r6   r8   s      r   convert_extent3dz&BaseSpatialOperations.convert_extent3dS   s    !K
 
 	
r   c                     d|z  S )Nz'%s'r   )r   names     r   geo_quote_namez$BaseSpatialOperations.geo_quote_nameY   s    }r   c                      t          d          )zh
        Return the database column type for the geometry field on
        the spatial backend.
        zGsubclasses of BaseSpatialOperations must provide a geo_db_type() methodr6   )r   fs     r   geo_db_typez!BaseSpatialOperations.geo_db_type]   s    
 "U
 
 	
r   c                      t          d          )zu
        Return the distance parameters for the given geometry field,
        lookup value, and lookup type.
        z:Distance operations not available on this spatial backend.r6   )r   rB   valuelookup_types       r   get_distancez"BaseSpatialOperations.get_distancef   s    
 "H
 
 	
r   c                 `   d }t          |d          r3 ||j        |          r |                     d          d|j        dndS  |||          r0|                     d          d| j        d|j        d	|j        dS | j        j        j        r| j        d|j        dS d
| j        z  S )a  
        Return the placeholder for the given geometry field with the given
        value.  Depending on the spatial backend, the placeholder may contain a
        stored procedure call to the transformation function of the spatial
        backend.
        c                 *    | d uo| j         |j         k    S r   )r:   )rE   fields     r   transform_valuezCBaseSpatialOperations.get_geom_placeholder.<locals>.transform_valuew   s    $Auz)AAr   as_sqlr)   z(%s, )r
   (z(%s,z), z%s(%%s))hasattroutput_fieldspatial_function_namer:   	from_text
connectionfeatureshas_spatialrefsys_table)r   rB   rE   compilerrK   s        r   get_geom_placeholderz*BaseSpatialOperations.get_geom_placeholdero   s    	B 	B 	B 5(## 	 #?5#5q99!;!;K!H!H!H!H!&&&QQ
 ?5!$$ 	. **;7777


	  _%= 	.#'>>>1666:: t~--r   c                     t          || j                  rt          d|j        z            t	                                          |           d S )NzA%s spatial aggregation is not supported by this database backend.)
isinstancedisallowed_aggregatesr   r?   supercheck_expression_support)r   
expression	__class__s     r   r\   z.BaseSpatialOperations.check_expression_support   sW    j$"<== 	#S/"   	((44444r   c                      t          d          )Nz;Aggregate support not implemented for this spatial backend.r6   )r   agg_names     r   spatial_aggregate_namez,BaseSpatialOperations.spatial_aggregate_name   s    !I
 
 	
r   c                 ~    || j         v rt          d|z            | j                            || j        |z             S )Nz-This backend doesn't support the %s function.)unsupported_functionsr   function_namesgetgeom_func_prefix)r   	func_names     r   rQ   z+BaseSpatialOperations.spatial_function_name   sM    222#?)K   "&&y$2G)2STTTr   c                      t          d          )NzMSubclasses of BaseSpatialOperations must provide a geometry_columns() method.r6   r   s    r   geometry_columnsz&BaseSpatialOperations.geometry_columns   s    !
 
 	
r   c                      t          d          )NzKsubclasses of BaseSpatialOperations must a provide spatial_ref_sys() methodr6   r   s    r   spatial_ref_sysz%BaseSpatialOperations.spatial_ref_sys   s    !
 
 	
r   c                     t                                          |          }t          |j        t                    r(|                    |                     |                     |S r   )r[   get_db_convertersrY   rP   r   appendget_geometry_converter)r   r]   
convertersr^   s      r   rm   z'BaseSpatialOperations.get_db_converters   sX    WW..z::
j-}== 	Gd99*EEFFFr   c                      t          d          )NzSSubclasses of BaseSpatialOperations must provide a get_geometry_converter() method.r6   )r   r]   s     r   ro   z,BaseSpatialOperations.get_geometry_converter   s    !/
 
 	
r   c                     |                     | j                  r"| j        j        j        rdS t	          d          |                    | j                  }|rt          j        |          S d S )Nsq_mz2Area on geodetic coordinate systems not supported.)geodeticrS   rT   supports_area_geodeticr7   
units_nameAreaMeasureunit_attname)r   rJ   rv   s      r   get_area_att_for_fieldz,BaseSpatialOperations.get_area_att_for_field   s|    >>$/** 		<'> v%D   ))$/::J <"/
;;;< <r   c                     d }|                     | j                  r| j        j        j        rd}n0|                    | j                  }|rt          j        |          }|S )Nm)rt   rS   rT   supports_distance_geodeticrv   DistanceMeasurerx   )r   rJ   dist_attunitss       r   get_distance_att_for_fieldz0BaseSpatialOperations.get_distance_att_for_field   se    >>$/** 	?'B $$T_55E ?*7>>r   )$__name__
__module____qualname__postgis
spatialitemariadbmysqloraclespatial_versionr   r   r   rZ   rf   rd   rc   rR   r;   r=   r@   rC   rG   rW   r\   ra   rQ   ri   rk   staticmethodr   distance_expr_for_lookuprm   ro   ry   r   __classcell__)r^   s   @r   r	   r	   	   s        GJGEFO F  _  N# # #L I
 
 


 
 
  
 
 

 
 
. . .>5 5 5 5 5
 
 

U U U
 
 

 
 
  ,|H55    
 
 

< 
< 
<	 	 	 	 	 	 	r   r	   N)django.contrib.gis.db.modelsr   &django.contrib.gis.db.models.functionsr   django.contrib.gis.measurer   rw   r}   	django.dbr   django.utils.functionalr   r	   r   r   r   <module>r      s    6 6 6 6 6 6 ; ; ; ; ; ; : : : : : : B B B B B B ' ' ' ' ' ' 3 3 3 3 3 3I I I I I I I I I Ir   