ó
r±E^c           @   s½   d  d l  m Z d  d l m Z d d d d d g Z d e f d	 „  ƒ  YZ d e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 d S(   iÿÿÿÿ(   t   ExtentField(   t	   Aggregatet   Collectt   Extentt   Extent3Dt   MakeLinet   Uniont   GeoAggregatec           B   s>   e  Z d Z e Z d  „  Z d „  Z d e d e e d „ Z	 RS(   c         C   sA   | j  j |  ƒ | j  j |  j ƒ |  _ t t |  ƒ j | | ƒ S(   N(   t   opst   check_expression_supportt   spatial_aggregate_namet   namet   functiont   superR   t   as_sql(   t   selft   compilert
   connection(    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR      s    c         C   sP   t  |  d ƒ s d |  _ n  |  j |  j d <|  j s@ d |  _ n  |  j | | ƒ S(   Nt	   tolerancegš™™™™™©?s8   %(function)s(SDOAGGRTYPE(%(expressions)s,%(tolerance)s))(   t   hasattrR   t   extrat	   is_extentt   templateR   (   R   R   R   (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyt	   as_oracle   s    	c         C   s`   t  t |  ƒ j | | | | | ƒ } x5 | j ƒ  D]' } t | j d ƒ s1 t d ƒ ‚ q1 q1 W| S(   Nt	   geom_types6   Geospatial aggregates only allowed on geometry fields.(   R   R   t   resolve_expressiont   get_source_expressionsR   t   fieldt
   ValueError(   R   t   queryt   allow_joinst   reuset	   summarizet   for_savet   ct   expr(    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR      s
    $N(
   t   __name__t
   __module__t   NoneR   t   FalseR   R   R   t   TrueR   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR      s
   		c           B   s   e  Z d  Z RS(   R   (   R$   R%   R   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR   "   s   c           B   s&   e  Z d  Z d Z d „  Z d „  Z RS(   R   t   2Dc         K   s&   t  t |  ƒ j | d t ƒ  | �d  S(   Nt   output_field(   R   R   t   __init__R    (   R   t
   expressionR   (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR+   *   s    c         C   s   | j  j | | j d ƒ ƒ S(   Nt   transformed_srid(   R   t   convert_extentt   get(   R   t   valueR,   R   t   context(    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyt   convert_value-   s    (   R$   R%   R   R   R+   R2   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR   &   s   	c           B   s&   e  Z d  Z d Z d „  Z d „  Z RS(   R   t   3Dc         K   s&   t  t |  ƒ j | d t ƒ  | �d  S(   NR*   (   R   R   R+   R    (   R   R,   R   (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR+   5   s    c         C   s   | j  j | | j d ƒ ƒ S(   NR-   (   R   t   convert_extent3dR/   (   R   R0   R,   R   R1   (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR2   8   s    (   R$   R%   R   R   R+   R2   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR   1   s   	c           B   s   e  Z d  Z RS(   R   (   R$   R%   R   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR   <   s   c           B   s   e  Z d  Z RS(   R   (   R$   R%   R   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyR   @   s   N(   t#   django.contrib.gis.db.models.fieldsR    t   django.db.models.aggregatesR   t   __all__R   R   R   R   R   R   (    (    (    sI   /tmp/pip-unpacked-wheel-4tV8Ix/django/contrib/gis/db/models/aggregates.pyt   <module>   s   