
    g                     `    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y)	    )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    /var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/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      r6 ||j                  |      r!| j                  d      d|j                  dS dS  |||      r;| j                  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xr | j                   |j                   k7  S r   )r:   )rE   fields     r   transform_valuezCBaseSpatialOperations.get_geom_placeholder.<locals>.transform_valuew   s    $Auzz)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 5(# #5#5#5q9 "&!;!;K!H!&&Q 
 5!$ **;7

	  __%%==#'>>166:: t~~--r   c                     t        || j                        rt        d|j                  z        t        |   |       y )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   s>    j$"<"<=#S//"  	(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                  || 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   sK    222#?)K  ""&&y$2G2G)2S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 |j                  | j                  |             |S r   )r[   get_db_convertersrY   rP   r   appendget_geometry_converter)r   r]   
convertersr^   s      r   rm   z'BaseSpatialOperations.get_db_converters   sA    W.z:
j--}=d99*E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                  | j                        r,| j                  j                  j                  ryt	        d      |j                  | j                        }|rt        j                  |      S y )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   sg    >>$//*''>>%D  ))$//:J"//
;; r   c                     d }|j                  | j                        r$| j                  j                  j                  rd}|S |j	                  | 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   sd    >>$//*''BB
  $$T__5E*7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

U

  ,H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 ; : B ' 3I Ir   