ó
®â0_c           @   sê  d  d l  m Z d  d l m Z m Z d  d l m Z d  d l m Z d  d l	 m
 Z m Z d  d l m Z d  d l m Z m Z m Z m Z d  d l m Z m Z d  d	 l m Z e j e e f 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" 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" e f d „  ƒ  YZ' d  e" e f d! „  ƒ  YZ( d" e" e f d# „  ƒ  YZ) d$ e  f d% „  ƒ  YZ* d& e* e" e f d' „  ƒ  YZ d( e f d) „  ƒ  YZ+ d* e f d+ „  ƒ  YZ, d, e f d- „  ƒ  YZ- d. e" e f d/ „  ƒ  YZ. d0 e" e f d1 „  ƒ  YZ/ d2 e* e" e f d3 „  ƒ  YZ0 d4 e f d5 „  ƒ  YZ1 d6 e f d7 „  ƒ  YZ2 d8 e f d9 „  ƒ  YZ3 d: e f d; „  ƒ  YZ4 d< e* e" e f d= „  ƒ  YZ5 d> e" e f d? „  ƒ  YZ6 d@ e f dA „  ƒ  YZ7 dB e! e f dC „  ƒ  YZ8 dD e! e f dE „  ƒ  YZ9 dF e" e f dG „  ƒ  YZ: dH e f dI „  ƒ  YZ; dJ e8 f dK „  ƒ  YZ< dL e" e f dM „  ƒ  YZ= dN S(O   iÿÿÿÿ(   t   Decimal(   t   GeometryFieldt   RasterField(   t	   AreaField(   t   Geometry(   t   Areat   Distance(   t
   FieldError(   t   BooleanFieldt
   FloatFieldt   IntegerFieldt	   TextField(   t   Funct   Value(   t   sixt   GeoFuncc           B   sq   e  Z d	 Z d	 Z d  Z d „  Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 d „  Z d „  Z d d	 d „ Z RS(
   i    c         O   sE   d | k r( |  j  r( |  j  ƒ  | d <n  t t |  ƒ j | | Ž  d  S(   Nt   output_field(   t   output_field_classt   superR   t   __init__(   t   selft   expressionst   extra(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR      s    c         C   s
   |  j  j S(   N(   t	   __class__t   __name__(   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   name   s    c         C   sS   |  j  |  j } t | d ƒ r& | j Sy | j j SWn t t f k
 rN d  SXd  S(   Nt   srid(   t   source_expressionst   geom_param_post   hasattrR   t   fieldt   AttributeErrorR   t   None(   R   t   expr(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR      s    c         C   s   |  j  r t d |  j  ƒ Sd  S(   NR   (   R   R   R    (   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt	   geo_field)   s    c         K   sq   |  j  d  k r* | j j |  j ƒ |  _  n  t d „  |  j ƒ  Dƒ ƒ rU t d ƒ ‚ n  t t	 |  ƒ j
 | | |  S(   Nc         s   s   |  ] } t  | t ƒ Vq d  S(   N(   t
   isinstanceR   (   t   .0R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pys	   <genexpr>0   s    s3   Geometry functions not supported for raster fields.(   t   functionR    t   opst   spatial_function_nameR   t   anyt   get_source_fieldst	   TypeErrorR   R   t   as_sql(   R   t   compilert
   connectiont   extra_context(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR+   -   s
    c         O   sª   t  t |  ƒ j | | Ž  } | j } | s9 t d ƒ ‚ n  xj t | j d d d ƒD]O \ } } t | t ƒ rS | j | k rS t	 | | ƒ j | | Ž  | j | <qS qS W| S(   Ns9   Geometry functions can only operate on geometric content.i   t   start(
   R   R   t   resolve_expressionR   R*   t	   enumerateR   R#   t	   GeomValuet	   Transform(   R   t   argst   kwargst   rest	   base_sridt   posR!   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR0   4   s    	&)t    c         C   sK   t  | d ƒ sG | rG t | | ƒ rG t d | t | ƒ f ƒ ‚ qG n  | S(   NR0   s2   The %s parameter has the wrong type: should be %s.(   R   R#   R*   t   str(   R   t   valuet
   param_namet   check_types(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   _handle_param@   s    N(   R   t
   __module__R    R%   R   R   R   t   propertyR   R   R"   R+   R0   R>   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR      s   	
		R2   c           B   s8   e  Z e Z e d  „  ƒ Z d „  Z d „  Z d „  Z RS(   c         C   s
   |  j  j S(   N(   R;   R   (   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   M   s    c         C   s/   d | j  j |  j f | j  j |  j ƒ g f S(   Ns   %s(%%s, %s)(   R&   t	   from_textR   t   AdapterR;   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR+   Q   s    c         C   s&   d | j  j | j  j |  j ƒ g f S(   Ns   %s(%%s)(   R&   RA   RB   R;   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   as_mysqlT   s    c         C   s^   |  j  r- | j j |  j d |  j  ƒ|  _ n | j j |  j ƒ |  _ t t |  ƒ j | | ƒ S(   Nt	   geography(   RD   R&   RB   R;   R   R2   R+   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   as_postgresqlW   s    	$(	   R   R?   t   FalseRD   R@   R   R+   RC   RE   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR2   J   s
   		t   GeoFuncWithGeoParamc           B   s   e  Z d  „  Z RS(   c         O   sp   t  | t ƒ s t d ƒ ‚ n  t | d ƒ s8 | j rG t d ƒ ‚ n  t t |  ƒ j | t	 | ƒ | | Ž d  S(   Ns!   Please provide a geometry object.R   s8   Please provide a geometry attribute with a defined SRID.(
   R#   R   R*   R   R   t
   ValueErrorR   RG   R   R2   (   R   t
   expressiont   geomR   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   `   s
    (   R   R?   R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRG   _   s   t   SQLiteDecimalToFloatMixinc           B   s   e  Z d  Z d „  Z RS(   s›   
    By default, Decimal values are converted to str by the SQLite backend, which
    is not acceptable by the GIS functions expecting numeric values.
    c         C   sf   xJ |  j  ƒ  D]< } t | d ƒ r t | j t ƒ r t | j ƒ | _ q q Wt t |  ƒ j | | ƒ S(   NR;   (	   t   get_source_expressionsR   R#   R;   R    t   floatR   RK   R+   (   R   R,   R-   R!   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt	   as_sqlitem   s    !(   R   R?   t   __doc__RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRK   h   s   t   OracleToleranceMixinc           B   s   e  Z d  Z d „  Z RS(   gš™™™™™©?c         C   sM   |  j  |  j j d |  j ƒ d t ƒ } d | |  _ t t |  ƒ j | | ƒ S(   Nt	   tolerances#   %%(function)s(%%(expressions)s, %s)(	   R>   R   t   getRQ   t   NUMERIC_TYPESt   templateR   RP   R+   (   R   R,   R-   t   tol(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt	   as_oraclew   s    	(   R   R?   RQ   RV   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRP   t   s   R   c           B   s/   e  Z e Z d  Z d „  Z d „  Z d „  Z RS(   i   c         K   s¦   | j  j r d |  j _ no |  j } | j | ƒ r] | j j rN d |  j _ qŠ t d ƒ ‚ n- | j	 | ƒ } | rŠ t
 j | ƒ |  j _ n  t t |  ƒ j | | |  S(   Nt   sq_ms2   Area on geodetic coordinate systems not supported.(   R&   RD   R   t   area_attR"   t   geodetict   featurest   supports_area_geodetict   NotImplementedErrort
   units_namet   AreaMeasuret   unit_attnameR   R   R+   (   R   R,   R-   R.   R"   R]   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR+   …   s    	c         C   s(   t  d ƒ |  _ t t |  ƒ j | | ƒ S(   NRW   (   R   R   R   R   RV   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRV   —   s    c         K   s<   |  j  j | ƒ r) d | d <t | d <n  |  j | | |  S(   Ns+   %(function)s(%(expressions)s, %(spheroid)d)RT   t   spheroid(   R"   RY   t   TrueR+   (   R   R,   R-   R.   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRN   ›   s    
(   R   R?   R   R   t   arityR+   RV   RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR      s
   		t	   AsGeoJSONc           B   s    e  Z e Z e e d  d „ Z RS(   i   c         K   s£   | g } | d  k	 r7 | j |  j | d t j ƒ ƒ n  d } | rR | rR d } n | ra d } n | rp d } n  | r† | j | ƒ n  t t |  ƒ j | | Ž  d  S(   Nt	   precisioni    i   i   i   (   R    t   appendR>   R   t   integer_typesR   Rc   R   (   R   RI   t   bboxt   crsRd   R   R   t   options(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   ¥   s    	"			(   R   R?   R   R   RF   R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRc   ¢   s   t   AsGMLc           B   s,   e  Z d  Z e Z d d d „ Z d „  Z RS(   i   i   i   c         K   sW   | | g } | d  k	 r: | j |  j | d t j ƒ ƒ n  t t |  ƒ j | | Ž  d  S(   NRd   (   R    Re   R>   R   Rf   R   Rj   R   (   R   RI   t   versionRd   R   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   ¹   s    "c         K   sq   |  j  ƒ  } | d } |  j ƒ  } | j | d g ƒ | j d k rK d n d | d <t t | ƒ j | | |  S(   Ni    i   i   s   SDO_UTIL.TO_GML311GEOMETRYs   SDO_UTIL.TO_GMLGEOMETRYR%   (   RL   t   copyt   set_source_expressionsR;   R   Rj   R+   (   R   R,   R-   R.   R   Rk   t   clone(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRV   ¿   s    
(   R   R?   R   R   R   R   RV   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRj   µ   s   t   AsKMLc           B   s   e  Z d  „  Z RS(   c         C   s3   |  j  ƒ  } | j |  j ƒ  d ƒ | j | | ƒ S(   Ni   (   Rl   Rm   RL   R+   (   R   R,   R-   Rn   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRN   É   s    (   R   R?   RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRo   È   s   t   AsSVGc           B   s   e  Z e Z e d  d „ Z RS(   i   c         K   s_   t  | d ƒ r | n	 t | ƒ } | | |  j | d t j ƒ g } t t |  ƒ j | | Ž  d  S(   NR0   Rd   (   R   t   intR>   R   Rf   R   Rp   R   (   R   RI   t   relativeRd   R   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   Ó   s
    !(   R   R?   R   R   RF   R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRp   Ð   s   t   BoundingCirclec           B   s   e  Z d  d „ Z d „  Z RS(   i0   c         K   s#   t  t |  ƒ j | | g | Ž  d  S(   N(   R   Rs   R   (   R   RI   t   num_segR   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   Þ   s    c         C   s?   |  j  ƒ  } | j |  j ƒ  d g ƒ t t | ƒ j | | ƒ S(   Ni    (   Rl   Rm   RL   R   Rs   RV   (   R   R,   R-   Rn   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRV   á   s    (   R   R?   R   RV   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRs   Ý   s   t   Centroidc           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRu   ç   s   t
   Differencec           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRv   ë   s   t   DistanceResultMixinc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s    |  j  ƒ  d j o |  j d k S(   Ni    iæ  (   R)   RD   R   (   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   source_is_geographyð   s    c         C   sy   | d  k r d  S|  j } | j | ƒ r1 d } n- | j | ƒ } | rX t j | ƒ } n d  } | ru t i | | 6  S| S(   Nt   m(   R    R"   RY   R]   t   DistanceMeasureR_   (   R   R;   RI   R-   t   contextR"   t   dist_attt   units(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   convert_valueó   s    		(   R   R?   Rx   R~   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRw   ï   s   	R   c           B   s;   e  Z e Z d Z d d  „ Z d „  Z d „  Z d „  Z	 RS(   c         K   s]   | | g } | d  k	 r@ | |  _ | |  j | d t ƒ f 7} n  t t |  ƒ j | | Ž  d  S(   NR`   (   R    R`   R>   t   boolR   R   R   (   R   t   expr1t   expr2R`   R   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR     s
    	c         C   së   t  d |  j ƒ } |  j ƒ  rt x± t |  j |  j d d |  j d ƒD]' \ } } t | t ƒ rF t | _	 qF qF Wn^ | j
 | ƒ rÒ |  j rº | j j d ƒ |  _ t | j ƒ |  j d <qÒ | j j d ƒ |  _ n  t t |  ƒ j | | ƒ S(   NR   i   R/   t   DistanceSpheroidi   t   DistanceSphere(   R   R   Rx   R1   R   R   R#   R2   Ra   RD   RY   R`   R&   R'   R%   R   t	   _spheroidR   R   R+   (   R   R,   R-   R"   R8   R!   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRE     s    .	c         C   s5   |  j  r |  j j d ƒ n  t t |  ƒ j | | ƒ S(   Ni   (   R`   R   t   popR   R   RV   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRV   "  s    	c         K   sp   |  j  r |  j j d ƒ n  |  j j | ƒ rT d | d <t t |  j  ƒ ƒ | d <n  t t |  ƒ j	 | | |  S(   Ni   s8   COALESCE(%(function)s(%(expressions)s, %(spheroid)s), 0)RT   R`   (
   R`   R   R…   R"   RY   Rq   R   R   R   R+   (   R   R,   R-   R.   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRN   '  s    	
N(
   R   R?   R	   R   R    R`   R   RE   RV   RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR     s   		t   Envelopec           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR†   1  s   t   ForceRHRc           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR‡   5  s   t   GeoHashc           B   s   e  Z e Z d d  „ Z RS(   c         K   sT   | g } | d  k	 r7 | j |  j | d t j ƒ ƒ n  t t |  ƒ j | | Ž  d  S(   NRd   (   R    Re   R>   R   Rf   R   Rˆ   R   (   R   RI   Rd   R   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   <  s    	"N(   R   R?   R   R   R    R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRˆ   9  s   t   Intersectionc           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR‰   C  s   t   IsValidc           B   s   e  Z e Z d  „  Z RS(   c         K   s2   t  t |  ƒ j | | |  \ } } d | | f S(   Ns%   CASE %s WHEN 'TRUE' THEN 1 ELSE 0 END(   R   RŠ   RV   (   R   R,   R-   R.   t   sqlt   params(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRV   J  s    $(   R   R?   R   R   RV   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRŠ   G  s   t   Lengthc           B   s5   e  Z e Z e d  „ Z d „  Z d „  Z d „  Z RS(   c         K   s&   | |  _  t t |  ƒ j | |  d  S(   N(   R`   R   R   R   (   R   R€   R`   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   R  s    	c         C   sV   t  d |  j ƒ } | j | ƒ r= | j j r= t d ƒ ‚ n  t t |  ƒ j | | ƒ S(   NR   s6   This backend doesn't support Length on geodetic fields(	   R   R   RY   RZ   t   supports_length_geodeticR\   R   R   R+   (   R   R,   R-   R"   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR+   V  s    c         C   sÍ   t  d |  j ƒ } |  j ƒ  r: |  j j t |  j ƒ ƒ nz | j | ƒ rz | j j	 d ƒ |  _
 |  j j t | j ƒ ƒ n: t d „  |  j ƒ  Dƒ ƒ } | d k r´ | j j |  _
 n  t t |  ƒ j | | ƒ S(   NR   t   LengthSpheroidc         s   s   |  ] } | r | j  Vq d  S(   N(   t   dim(   R$   t   f(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pys	   <genexpr>e  s    i   (   R   R   Rx   R   Re   R   R`   RY   R&   R'   R%   R„   t   minR)   t   length3dR   R   R+   (   R   R,   R-   R"   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRE   \  s    c         C   s[   t  d |  j ƒ } | j | ƒ rB |  j r6 d |  _ qB d |  _ n  t t |  ƒ j | | ƒ S(   NR   t   GeodesicLengtht   GreatCircleLength(   R   R   RY   R`   R%   R   R   R+   (   R   R,   R-   R"   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRN   j  s    	(	   R   R?   R	   R   Ra   R   R+   RE   RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   O  s
   		t	   MakeValidc           B   s   e  Z RS(    (   R   R?   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR–   t  s   t   MemSizec           B   s   e  Z e Z d  Z RS(   i   (   R   R?   R
   R   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR—   x  s   t   NumGeometriesc           B   s   e  Z e Z d  Z RS(   i   (   R   R?   R
   R   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR˜   }  s   t	   NumPointsc           B   s   e  Z e Z d  Z d „  Z RS(   i   c         C   sS   |  j  |  j j j d k r: | j j s: t d ƒ ‚ q: n  t t |  ƒ j	 | | ƒ S(   Nt
   LINESTRINGsB   NumPoints can only operate on LineString content on this database.(
   R   R   R   t	   geom_typeRZ   t   supports_num_points_polyR*   R   R™   R+   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR+   †  s    (   R   R?   R
   R   Rb   R+   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR™   ‚  s   t	   Perimeterc           B   s&   e  Z e Z d  Z d „  Z d „  Z RS(   i   c         C   s   t  d |  j ƒ } | j | ƒ r= |  j ƒ  r= t d ƒ ‚ n  t d „  |  j ƒ  Dƒ ƒ } | d k rw | j j |  _	 n  t
 t |  ƒ j | | ƒ S(   NR   s<   ST_Perimeter cannot use a non-projected non-geography field.c         s   s   |  ] } | j  Vq d  S(   N(   R   (   R$   R‘   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pys	   <genexpr>•  s    i   (   R   R   RY   Rx   R\   R’   R)   R&   t   perimeter3dR%   R   R   R+   (   R   R,   R-   R"   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRE   ‘  s    c         C   sI   t  d |  j ƒ } | j | ƒ r0 t d ƒ ‚ n  t t |  ƒ j | | ƒ S(   NR   s+   Perimeter cannot use a non-projected field.(   R   R   RY   R\   R   R   R+   (   R   R,   R-   R"   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRN   š  s    (   R   R?   R	   R   Rb   RE   RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR     s   		t   PointOnSurfacec           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRŸ   ¡  s   t   Reversec           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR    ¥  s   t   Scalec           B   s   e  Z d  d „ Z RS(   g        c         K   su   | |  j  | d t ƒ |  j  | d t ƒ g } | d k rX | j |  j  | d t ƒ ƒ n  t t |  ƒ j | | Ž  d  S(   Nt   xt   yg        t   z(   R>   RS   Re   R   R¡   R   (   R   RI   R¢   R£   R¤   R   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   ª  s    (   R   R?   R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR¡   ©  s   t
   SnapToGridc           B   s   e  Z d  „  Z RS(   c         O   sô   t  | ƒ } | g } | d k rS | j g  | D] } |  j | d t ƒ ^ q. ƒ n„ | d k rË | j g  | d D] } |  j | d t ƒ ^ qp ƒ | j g  | d d !D] } |  j | d t ƒ ^ q¦ ƒ n t d ƒ ‚ t t |  ƒ j | | Ž  d  S(   Ni   i   R9   i   i    s2   Must provide 1, 2, or 4 arguments to `SnapToGrid`.(   i   i   (   t   lent   extendR>   RS   RH   R   R¥   R   (   R   RI   R4   R   t   nargsR   t   arg(    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   ¶  s    	,-3(   R   R?   R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR¥   µ  s   t   SymDifferencec           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRª   Ê  s   R3   c           B   s    e  Z d  „  Z e d „  ƒ Z RS(   c         K   s]   | |  j  | d t j ƒ g } d | k r@ t d | ƒ | d <n  t t |  ƒ j | | Ž  d  S(   NR   R   (   R>   R   Rf   R   R   R3   R   (   R   RI   R   R   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   Ï  s
    c         C   s   |  j  |  j d j S(   Ni   (   R   R   R;   (   R   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR   Ø  s    (   R   R?   R   R@   R   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR3   Î  s   		t	   Translatec           B   s   e  Z d  „  Z RS(   c         C   sG   t  |  j ƒ d k  r. |  j j t d ƒ ƒ n  t t |  ƒ j | | ƒ S(   Ni   i    (   R¦   R   Re   R   R   R«   RN   (   R   R,   R-   (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyRN   ß  s    (   R   R?   RN   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR«   Þ  s   t   Unionc           B   s   e  Z d  Z RS(   i   (   R   R?   Rb   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyR¬   æ  s   N(>   t   decimalR    t#   django.contrib.gis.db.models.fieldsR   R   t    django.contrib.gis.db.models.sqlR   t#   django.contrib.gis.geometry.backendR   t   django.contrib.gis.measureR   R^   R   Rz   t   django.core.exceptionsR   t   django.db.modelsR   R	   R
   R   t   django.db.models.expressionsR   R   t   django.utilsR   Rf   RM   RS   R   R2   RG   t   objectRK   RP   Rc   Rj   Ro   Rp   Rs   Ru   Rv   Rw   R†   R‡   Rˆ   R‰   RŠ   R   R–   R—   R˜   R™   R   RŸ   R    R¡   R¥   Rª   R3   R«   R¬   (    (    (    sH   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/db/models/functions.pyt   <module>   sV   "9	!
-
%