o
    iK                     @   s   d dl mZmZmZmZ d dlmZmZmZ d dl	m
Z
 g dZG dd deZG dd deZG d	d
 d
eZG dd deZG dd deZG dd deZdS )    )ExtentFieldGeometryCollectionFieldGeometryFieldLineStringField)	AggregateFuncValue)cached_property)CollectExtentExtent3DMakeLineUnionc                       sJ   e Zd ZdZdZedd Zd fdd	Zdd Z	d fd
d	Z	  Z
S )GeoAggregateNFc                 C   s   |  | jd jjS )Nr   )output_field_classsource_expressionsoutput_fieldsrid)self r   g/var/www/html/formularioweb/env/lib/python3.10/site-packages/django/contrib/gis/db/models/aggregates.pyr      s   zGeoAggregate.output_fieldc                    s4   |j |  t j||fd|p|j | ji|S )Nfunction)opscheck_expression_supportsuperas_sqlspatial_aggregate_namename)r   compiler
connectionr   extra_context	__class__r   r   r      s   zGeoAggregate.as_sqlc                 K   s   | j s?| jdpt| dd}|  }|  }|  tg |t|R d| j	d}|| j
g}|| |j||fi |S | j||fi |S )N	toleranceg?SDOAGGRTYPE)r   r   )	is_extentextragetgetattrcopyget_source_expressionspopr   r   r   filterset_source_expressionsr   )r   r   r   r    r#   cloner   spatial_type_exprr   r   r   	as_oracle    s"   

zGeoAggregate.as_oracleTc                    s8   t  |||||}| D ]}t|dstdq|S )N	geom_typez6Geospatial aggregates only allowed on geometry fields.)r   resolve_expressionget_source_fieldshasattr
ValueError)r   queryallow_joinsreuse	summarizefor_savecfieldr!   r   r   r2   1   s   
zGeoAggregate.resolve_expressionN)NTNFF)__name__
__module____qualname__r   r%   r	   r   r   r0   r2   __classcell__r   r   r!   r   r      s    
r   c                   @      e Zd Zd ZeZdS )r
   N)r>   r?   r@   r   r   r   r   r   r   r   r
   =       r
   c                       ,   e Zd Zd ZdZ fddZdd Z  ZS )r   2Dc                       t  j|fdt i| d S Nr   r   __init__r   r   
expressionr&   r!   r   r   rI   F      zExtent.__init__c                 C      |j |S r=   )r   convert_extentr   valuerK   r   r   r   r   convert_valueI      zExtent.convert_valuer>   r?   r@   r   r%   rI   rQ   rA   r   r   r!   r   r   B   
    r   c                       rD   )r   3Dc                    rF   rG   rH   rJ   r!   r   r   rI   Q   rL   zExtent3D.__init__c                 C   rM   r=   )r   convert_extent3drO   r   r   r   rQ   T   rR   zExtent3D.convert_valuerS   r   r   r!   r   r   M   rT   r   c                   @   rB   )r   N)r>   r?   r@   r   r   r   r   r   r   r   r   X   rC   r   c                   @   rB   )r   N)r>   r?   r@   r   r   r   r   r   r   r   r   ]   rC   r   N)#django.contrib.gis.db.models.fieldsr   r   r   r   django.db.modelsr   r   r   django.utils.functionalr	   __all__r   r
   r   r   r   r   r   r   r   r   <module>   s    0