ó
i4Vdc           @   s  d  d l  Z  d  d l m Z d  d l m Z m Z 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 d  d l m Z 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 d  d l m Z m  Z  d e f d „  ƒ  YZ! d S(   iÿÿÿÿN(   t
   aggregates(   t   GeometryFieldt   LineStringFieldt
   PointFieldt   get_srid_info(   t	   GISLookup(   t	   AreaFieldt   DistanceFieldt	   GeomFieldt   GMLField(   t   Geometry(   t   Areat   Distance(   t   connections(   t   RawSQL(   t   Field(   t   QuerySet(   t   six(   t   RemovedInDjango20Warningt   RemovedInDjango110Warningt   GeoQuerySetc           B   sÁ  e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d e e d „ Z d d „ Z d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z e d d „ Z d „  Z d d  „ Z d! d" „ Z d# „  Z  d$ „  Z! d. d. d. d% „ Z# d. d. d d& „ Z$ d. d. d' „ Z% d. d e d( „ Z& d d) „ Z' d d* „ Z( d+ „  Z) d. d, „ Z* d. d. d- „ Z+ RS(/   s   The Geographic QuerySet.gš™™™™™©?c         K   s  |  j  d d | j d ƒ ƒ\ } } i | d 6| d 6t d 6} t |  j } | j } | j r‰ d | d <| | d d <t d	 ƒ | d
 <nq | j s› | j	 rú | j
 r· t d	 ƒ | d
 <qú | j | ƒ së t t j | j | ƒ ƒ ƒ | d
 <qú t d ƒ ‚ n  |  j d | |  S(   s~   
        Returns the area of the geographic field in an `area` attribute on
        each element of this GeoQuerySet.
        t   areat
   field_namet   procedure_argst	   geo_fieldt   setups   %(geo_col)s,%(tolerance)st   procedure_fmtt	   tolerancet   sq_mt   select_fields2   Area on geodetic coordinate systems not supported.(   t   _spatial_setupt   gett   FalseR   t   dbt   opst   oracleR   t   postgist
   spatialitet	   geographyt   geodeticR   t   unit_attnamet
   units_namet	   Exceptiont   _spatial_attribute(   t   selfR   t   kwargsR   R   t   st
   connectiont   backend(    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR      s$    

		
	%c         K   s   |  j  d |  S(   s…   
        Returns the centroid of the geographic field in a `centroid`
        attribute on each element of this GeoQuerySet.
        t   centroid(   t   _geom_attribute(   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR1   :   s    c         K   s)   t  j d t d d ƒ|  j t j |  S(   sÄ   
        Performs an aggregate collect operation on the given geometry field.
        This is analogous to a union operation, but much faster because
        boundaries are not dissolved.
        sq   The collect GeoQuerySet method is deprecated. Use the Collect() aggregate in an aggregate() or annotate() method.t
   stackleveli   (   t   warningst   warnR   t   _spatial_aggregateR    t   Collect(   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyt   collectA   s    c         K   s   |  j  d | |  S(   s‘   
        Returns the spatial difference of the geographic field in a `difference`
        attribute on each element of this GeoQuerySet.
        t
   difference(   t   _geomset_attribute(   R,   t   geomR-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR9   N   s    c         K   s   |  j  d | |  S(   s~  
        Returns the distance from the given geographic field name to the
        given geometry in a `distance` attribute on each element of the
        GeoQuerySet.

        Keyword Arguments:
         `spheroid`  => If the geometry field is geodetic and PostGIS is
                        the spatial database, then the more accurate
                        spheroid calculation will be used instead of the
                        quicker sphere calculation.

         `tolerance` => Used only for Oracle. The tolerance is
                        in meters -- a default of 5 centimeters (0.05)
                        is used.
        t   distance(   t   _distance_attribute(   R,   R;   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR<   U   s    c         K   s   |  j  d |  S(   s§   
        Returns a Geometry representing the bounding box of the
        Geometry field in an `envelope` attribute on each element of
        the GeoQuerySet.
        t   envelope(   R2   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR>   g   s    c         K   s)   t  j d t d d ƒ|  j t j |  S(   s¯   
        Returns the extent (aggregate) of the features in the GeoQuerySet.  The
        extent will be returned as a 4-tuple, consisting of (xmin, ymin, xmax, ymax).
        so   The extent GeoQuerySet method is deprecated. Use the Extent() aggregate in an aggregate() or annotate() method.R3   i   (   R4   R5   R   R6   R    t   Extent(   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyt   extento   s    c         K   s)   t  j d t d d ƒ|  j t j |  S(   s»   
        Returns the aggregate extent, in 3D, of the features in the
        GeoQuerySet. It is returned as a 6-tuple, comprising:
          (xmin, ymin, zmin, xmax, ymax, zmax).
        ss   The extent3d GeoQuerySet method is deprecated. Use the Extent3D() aggregate in an aggregate() or annotate() method.R3   i   (   R4   R5   R   R6   R    t   Extent3D(   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyt   extent3d{   s    c         K   s   |  j  d |  S(   sø   
        Returns a modified version of the Polygon/MultiPolygon in which
        all of the vertices follow the Right-Hand-Rule.  By default,
        this is attached as the `force_rhr` attribute on each element
        of the GeoQuerySet.
        t	   force_rhr(   R2   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRC   ˆ   s    i   c         K   s¾   t  |  j j } | j s( t d ƒ ‚ n  t | t j ƒ sI t d ƒ ‚ n  d } | rd | rd d } n | rs d } n | r‚ d } n  i d d 6i | d	 6| d
 6d 6d d 6} |  j	 d | |  S(   s\  
        Returns a GeoJSON representation of the geometry field in a `geojson`
        attribute on each element of the GeoQuerySet.

        The `crs` and `bbox` keywords may be set to True if the user wants
        the coordinate reference system and the bounding box to be included
        in the GeoJSON representation of the geometry.
        sF   Only PostGIS 1.3.4+ and SpatiaLite 3.0+ support GeoJSON serialization.s.   Precision keyword must be set with an integer.i    i   i   i   t   GeoJSONt   desct	   precisiont   optionsR   s%   %(geo_col)s,%(precision)s,%(options)sR   t   geojson(
   R   R!   R"   RH   t   NotImplementedErrort
   isinstanceR   t   integer_typest	   TypeErrorR+   (   R,   RF   t   crst   bboxR-   R0   RG   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRH   ‘   s     					

i   c         K   s5   i d d 6i | d 6d 6d d 6} |  j  d | |  S(   s  
        Returns a GeoHash representation of the given field in a `geohash`
        attribute on each element of the GeoQuerySet.

        The `precision` keyword may be used to custom the number of
        _characters_ used in the output GeoHash, the default is 20.
        t   GeoHashRE   RF   R   s   %(geo_col)s,%(precision)sR   t   geohash(   R+   (   R,   RF   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRP   ¯   s    

i   c         K   s…   t  |  j j } i d d 6i | d 6d 6} | j rY d | d <i | d 6| d 6| d <n  | j rr t ƒ  | d <n  |  j d	 | |  S(
   s€   
        Returns GML representation of the given field in a `gml` attribute
        on each element of the GeoQuerySet.
        t   GMLRE   RF   R   s%   %(version)s,%(geo_col)s,%(precision)sR   t   versionR   t   gml(   R   R!   R"   R$   R#   R	   R+   (   R,   RF   RR   R-   R0   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRS   ½   s    	
	c         K   s   |  j  d | |  S(   sœ   
        Returns the spatial intersection of the Geometry field in
        an `intersection` attribute on each element of this
        GeoQuerySet.
        t   intersection(   R:   (   R,   R;   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRT   Ì   s    c         K   sA   i d d 6d d 6i | j  d d ƒ d 6d 6} |  j d | |  S(	   s„   
        Returns KML representation of the geometry field in a `kml`
        attribute on each element of this GeoQuerySet.
        t   KMLRE   s   %(geo_col)s,%(precision)sR   RF   i   R   t   kml(   t   popR+   (   R,   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRV   Ô   s    
c         K   s   |  j  d d |  S(   s   
        Returns the length of the geometry field as a `Distance` object
        stored in a `length` attribute on each element of this GeoQuerySet.
        t   lengthN(   R=   t   None(   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRX   ß   s    c         K   s/   t  j d t d d ƒ|  j t j d t | S(   sà   
        Creates a linestring from all of the PointField geometries in the
        this GeoQuerySet and returns it.  This is a spatial aggregate
        method, and thus returns a geometry rather than a GeoQuerySet.
        st   The make_line GeoQuerySet method is deprecated. Use the MakeLine() aggregate in an aggregate() or annotate() method.R3   i   t   geo_field_type(   R4   R5   R   R6   R    t   MakeLineR   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyt	   make_lineæ   s    c         K   s   |  j  d i  |  S(   s¡   
        Returns the memory size (number of bytes) that the geometry field takes
        in a `mem_size` attribute  on each element of this GeoQuerySet.
        t   mem_size(   R+   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR]   ó   s    c         K   s   |  j  d i  |  S(   sÜ   
        Returns the number of geometries if the field is a
        GeometryCollection or Multi* Field in a `num_geom`
        attribute on each element of this GeoQuerySet; otherwise
        the sets with None.
        t   num_geom(   R+   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR^   ú   s    c         K   s   |  j  d i  |  S(   sÇ   
        Returns the number of points in the first linestring in the
        Geometry field in a `num_points` attribute on each element of
        this GeoQuerySet; otherwise sets with None.
        t
   num_points(   R+   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR_     s    c         K   s   |  j  d d |  S(   s£   
        Returns the perimeter of the geometry field as a `Distance` object
        stored in a `perimeter` attribute on each element of this GeoQuerySet.
        t	   perimeterN(   R=   RY   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR`     s    c         K   s   |  j  d |  S(   sÒ   
        Returns a Point geometry guaranteed to lie on the surface of the
        Geometry field in a `point_on_surface` attribute on each element
        of this GeoQuerySet; otherwise sets with None.
        t   point_on_surface(   R2   (   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRa     s    c         K   sS   i t  ƒ  d 6} | j d d ƒ t |  j j j r@ t | d <n  |  j d | |  S(   s“   
        Reverses the coordinate order of the geometry, and attaches as a
        `reverse` attribute on each element of this GeoQuerySet.
        R   t	   model_attt   reverse_geomRZ   t   reverse(   R   t
   setdefaultR   R!   R"   R#   R   R+   (   R,   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRc     s
    g        c         K   s£   t  |  j j j r] | d k r. t d ƒ ‚ n  i d d 6i | d 6| d 6d 6t ƒ  d 6} n3 i d	 d 6i | d 6| d 6| d
 6d 6t ƒ  d 6} |  j d | |  S(   s|   
        Scales the geometry to a new size by multiplying the ordinates
        with the given x,y,z scale factors.
        g        s'   SpatiaLite does not support 3D scaling.s   %(geo_col)s,%(x)s,%(y)sR   t   xt   yR   R   s   %(geo_col)s,%(x)s,%(y)s,%(z)st   zt   scale(   R   R!   R"   R%   RI   R   R+   (   R,   Rf   Rg   Rh   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRi   %  s    

c         O   s4  t  g  | D] } t | t f t j ƒ ^ q
 k rA t d ƒ ‚ n  t | ƒ } | d k ry | d } d } i | d 6} nŠ | d k r® | \ } }	 d } i | d 6|	 d	 6} nU | d
 k r÷ | \ } }	 }
 } d } i | d 6|	 d	 6|
 d 6| d 6} n t d ƒ ‚ i | d 6| d 6t ƒ  d 6} |  j	 d | |  S(   sg  
        Snap all points of the input geometry to the grid.  How the
        geometry is snapped to the grid depends on how many arguments
        were given:
          - 1 argument : A single size to snap both the X and Y grids to.
          - 2 arguments: X and Y sizes to snap the grid to.
          - 4 arguments: X, Y sizes and the X, Y origins.
        s@   Size argument(s) for the grid must be a float or integer values.i   i    s   %(geo_col)s,%(size)st   sizei   s   %(geo_col)s,%(xsize)s,%(ysize)st   xsizet   ysizei   s7   %(geo_col)s,%(xorigin)s,%(yorigin)s,%(xsize)s,%(ysize)st   xorigint   yorigins4   Must provide 1, 2, or 4 arguments to `snap_to_grid`.R   R   R   t   snap_to_grid(
   R    RJ   t   floatR   RK   RL   t   lent
   ValueErrorR   R+   (   R,   t   argsR-   t   argt   nargsRj   R   R   Rk   Rl   Rm   Rn   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRo   8  s*    	2

c         K   so   t  t | ƒ ƒ } t | t j ƒ s3 t d ƒ ‚ n  i d d 6d d 6i | d 6| d 6d 6} |  j d	 | |  S(
   sº  
        Returns SVG representation of the geographic field in a `svg`
        attribute on each element of this GeoQuerySet.

        Keyword Arguments:
         `relative`  => If set to True, this will evaluate the path in
                        terms of relative moves (rather than absolute).

         `precision` => May be used to set the maximum number of decimal
                        digits used in output (defaults to 8).
        s2   SVG precision keyword argument must be an integer.t   SVGRE   s!   %(geo_col)s,%(rel)s,%(precision)sR   t   relRF   R   t   svg(   t   intt   boolRJ   R   RK   RL   R+   (   R,   t   relativeRF   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRx   \  s    c         K   s   |  j  d | |  S(   s—   
        Returns the symmetric difference of the geographic field in a
        `sym_difference` attribute on each element of this GeoQuerySet.
        t   sym_difference(   R:   (   R,   R;   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR|   u  s    c         K   s£   t  |  j j j r] | d k r. t d ƒ ‚ n  i d d 6i | d 6| d 6d 6t ƒ  d 6} n3 i d	 d 6i | d 6| d 6| d
 6d 6t ƒ  d 6} |  j d | |  S(   sr   
        Translates the geometry to a new location using the given numeric
        parameters as offsets.
        g        s+   SpatiaLite does not support 3D translation.s   %(geo_col)s,%(x)s,%(y)sR   Rf   Rg   R   R   s   %(geo_col)s,%(x)s,%(y)s,%(z)sRh   t	   translate(   R   R!   R"   R%   RI   R   R+   (   R,   Rf   Rg   Rh   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR}   |  s    

iæ  c         K   s`   t  | t j ƒ s! t d ƒ ‚ n  | j d ƒ } |  j d d | ƒ|  j j d | ƒ |  j ƒ  S(   s    
        Transforms the given geometry field to the given SRID.  If no SRID is
        provided, the transformation will default to using 4326 (WGS84).
        s!   An integer SRID must be provided.R   t	   transformt   transformed_srid(	   RJ   R   RK   RL   R   R   t   queryt   add_contextt   _clone(   R,   t   sridR-   R   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR~     s    c         K   s   |  j  d | |  S(   s—   
        Returns the union of the geographic field with the given
        Geometry in a `union` attribute on each element of this GeoQuerySet.
        t   union(   R:   (   R,   R;   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR„   ›  s    c         K   s)   t  j d t d d ƒ|  j t j |  S(   s»   
        Performs an aggregate union on the given geometry field.  Returns
        None if the GeoQuerySet is empty.  The `tolerance` keyword is for
        Oracle backends only.
        sp   The unionagg GeoQuerySet method is deprecated. Use the Union() aggregate in an aggregate() or annotate() method.R3   i   (   R4   R5   R   R6   R    t   Union(   R,   R-   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyt   unionagg¢  s    c   	      C   sé   t  |  j } t | j | t ƒ } | d k r7 | } n  | s\ t d | | j j f ƒ ‚ n  i | d 6} |  j | ƒ } | s‘ t	 d | ƒ ‚ n  | d k	 rÉ t
 | | ƒ rÉ t	 d | | j f ƒ ‚ n  |  j | | ƒ | d <| | f S(   sE   
        Performs set up for executing the spatial function.
        s4   %s stored procedure not available on the %s backend.t   functions+   %s output only available on GeometryFields.s1   "%s" stored procedures may only be called on %ss.t   geo_colN(   R   R!   t   getattrR"   R    RY   RI   t   namet
   _geo_fieldRL   RJ   t   __name__t   _geocol_select(	   R,   t   attRE   R   RZ   R/   t   funcR   R   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR   °  s    	c         C   s¸   |  j  | ƒ } | s+ t d | j ƒ ‚ n  | d k	 rf t | | ƒ rf t d | j | j f ƒ ‚ n  | pr | j } i  } t |  j j j	 r› | | d <n  |  j
 d | | |  ƒ d S(   s   
        DRY routine for calling aggregate spatial stored procedures and
        returning their result to the caller of the function.
        s.   %s aggregate only available on GeometryFields.s'   %s aggregate may only be called on %ss.R   t   geoaggN(   R‹   RL   RŠ   RY   RJ   RŒ   R   R!   R"   R#   t	   aggregate(   R,   R‘   R   RZ   R   R   t   agg_colt
   agg_kwargs(    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR6   Ñ  s    c      	   C   s;  t  j d | t d d ƒ| j d d ƒ | j d d ƒ | j d d ƒ | j d i  ƒ | j d d	 ƒ | j d
 g  ƒ t |  j } | j d t ƒ r|  j	 | d | d d | d | j d ƒ ƒ\ } } x> t
 j | ƒ D]  \ } }	 | d j | |	 ƒ qÝ Wn
 | d } t | t
 j ƒ s)| } n  x• | d D]‰ }
 | j | d |
 ƒ } | j d | d | ƒ} | j | d | ƒ } d |
 } | d } | d j | | ƒ | d <| d
 j | ƒ q4Wd | d } | j d ƒ r| d } | j j rt | _ qn	 t ƒ  } |  j j t | | d | d
 | ƒ | ƒ |  S(   sã  
        DRY routine for calling a spatial stored procedure on a geometry column
        and attaching its output as an attribute of the model.

        Arguments:
         att:
          The name of the spatial attribute that holds the spatial
          SQL function to call.

         settings:
          Dictionary of internal settings to customize for the spatial procedure.

        Public Keyword Arguments:

         field_name:
          The name of the geographic field to call the spatial
          function on.  May also be a lookup to a geometry field
          as part of a foreign key relation.

         model_att:
          The name of the model attribute to attach the output of
          the spatial function to.
        sx   The %s GeoQuerySet method is deprecated. See GeoDjango Functions documentation to find the expression-based replacement.R3   i   RE   t	   geom_argst
   geom_fieldR   R   s   %(geo_col)st   select_paramsR   R   RZ   R   t   containsR/   s   %%(%s)ss   %%ss   %%(function)s(%s)R   N(    (   R4   R5   R   Re   RY   R   R!   R   t   TrueR   R   t	   iteritemsRJ   t   string_typest   get_prep_valuet   get_db_prep_lookupt   get_placeholdert   replacet   extendR"   R#   R    t   empty_strings_allowedR   R€   t   add_annotationR   (   R,   RŽ   t   settingsR   Rb   R/   t   default_argsR   t   kt   vRŠ   R;   t   paramst   geom_placeholdert   old_fmtt   new_fmtt   fmtR   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR+   î  sL    
	


		c         K   sŸ  |  j  | d | j d ƒ ƒ\ } } t |  j } | j | ƒ }	 | j }
 |	 rX d } n t j | j | ƒ ƒ } | d k } | d k } | d k } | p£ | p£ | s¹ t	 d | ƒ ‚ n  | j
 d k } | pÑ d d	 g } | j } | s| j r|	 r|
 r| r| j d
 ƒ n  | j | ƒ } | j d | d | ƒ} t | ƒ } | j r‚| r`d } n | sl| rud } n  | | d <n›|  j j d ƒ } | rÊt | | ƒ \ } } } | j ƒ  | j k }	 n  |	 rì| j j rìt	 d ƒ ‚ n  | rq| r¨t } d | j | f } | j d& k s/| j | k r_| j rR| d | j | f 7} q¥| d 7} q®| j rŽ| d | j | j | j | f 7} q®| d | j | f 7} n d } |
 r|	 r| j st | t  ƒ sât	 d ƒ ‚ n  t! t" t# j$ | d	 j% ƒ ƒ j& ƒ d k st	 d ƒ ‚ qn  | rT| d 7} | j' i | j( d 6| d d
 6ƒ qn| j' i | j) d 6ƒ qn¬ | s}| rd } |
 rÅ|	 rÅ| rÅ| d 7} | j' i | j* d 6| d d
 6ƒ q| r| j j+ r| r÷| j' i | j, d 6ƒ q| r| j' i | j- d 6ƒ qqn  i t. | ƒ d 6t d 6| d  6| d! 6| d" 6} | rmd' | d$ <| | d! d# <n | rŒ| j/ | ƒ g | d% <n  |  j0 | | |  S((   sJ   
        DRY routine for GeoQuerySet distance attribute routines.
        R   t   mR<   RX   R`   s   Unknown distance function: %si   s   POINT (0 0)i    t   spheroidt   distance_lteR/   s"   %(geo_col)s,%(geom)s,%(tolerance)ss   %(geo_col)s,%(tolerance)sR   R   s[   This database does not support linear distance calculations on geodetic coordinate systems.s   %s(%%(geo_col)s, %s)s   , %s(%%%%s, %s)s   , %%ss   , %s(%s(%%%%s, %s), %s)s   %(geo_col)s,%(geom)ss=   Spherical distance calculation only supported on PointFields.t   PointsL   Spherical distance calculation only supported with Point Geometry parameterss   ,'%(spheroid)s'R‡   i   s   %(geo_col)sR   R   R   R   R   R;   R”   R–   N(   R;   (1   R   R   R   R!   R'   R&   R   R(   R)   Rr   t   dimR"   R$   t   appendR›   Rœ   Rz   R#   R€   t   get_contextR   t   lowert   geodetic_unitst   featurest   supports_distance_geodeticR    R~   Rƒ   RY   R%   t	   from_textRJ   R   t   strR
   R   t
   memoryviewt   ewkbt	   geom_typet   updatet   distance_spheroidt   distance_spheret   length_spheroidt   supports_3d_functionst   perimeter3dt   length3dR   t   AdapterR+   (   R,   R   R;   R   R¬   R-   R   R   R/   R'   R&   t   dist_attR<   RX   R`   t   geom_3dt   lookup_paramsR0   R¦   R”   R   Rƒ   t   ut	   unit_nameR.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR=   E  s     $									+
%
% 

c         K   sT   i t  ƒ  d 6} t |  j j j rA d | d <i | d 6| d <n  |  j | | |  S(   s”   
        DRY routine for setting up a GeoQuerySet method that attaches a
        Geometry attribute (e.g., `centroid`, `point_on_surface`).
        R   s   %(geo_col)s,%(tolerance)sR   R   R   (   R   R   R!   R"   R#   R+   (   R,   R   R   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR2   Þ  s
    
c         K   ss   i d	 d 6t  ƒ  d 6d d 6i | d 6d 6} t |  j j j r` | d c d 7<| | d d <n  |  j | | |  S(
   s  
        DRY routine for setting up a GeoQuerySet method that attaches a
        Geometry attribute and takes a Geoemtry parameter.  This is used
        for geometry set-like operations (e.g., intersection, difference,
        union, sym_difference).
        R;   R”   R   s   %(geo_col)s,%(geom)sR   R   s   ,%(tolerance)sR   (   R;   (   R   R   R!   R"   R#   R+   (   R,   R   R;   R   R-   R.   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR:   é  s    
c         C   sî   |  j  j |  j ƒ } |  j j } | | j k r£ |  j  j | g ƒ | j ƒ  x@ | j D]5 \ } } } | j	 | k rW | j
 | | j ƒ d SqW Wt d | ƒ ‚ nG | | j k rÚ | j j j } |  j | | | j j ƒ S|  j | | ƒ Sd S(   sÈ   
        Helper routine for constructing the SQL to select the geographic
        column.  Takes into account if the geographic field is in a
        ForeignKey relation to the current model.
        i    s(   %r not in compiler's related_select_colsN(   R€   t   get_compilerR!   t   modelt   _metat   fieldst   add_select_relatedt   pre_sql_setupt   selectt   output_fieldt   as_sqlR/   Rr   t   local_fieldst   concrete_modelt   _field_columnt   db_table(   R,   R   R   t   compilert   optst   colt   _t   parent_model(    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR   û  s    
c         C   sW   | d k r= x* |  j j j D] } t | t ƒ r | Sq Wt St j |  j j | ƒ Sd S(   s'  
        Returns the first Geometry field encountered or the one specified via
        the `field_name` keyword. The `field_name` may be a string specifying
        the geometry field on this GeoQuerySet's model, or a lookup string
        to a geometry field via a ForeignKey relation.
        N(	   RY   RÉ   RÊ   RË   RJ   R   R    R   t   _check_geo_field(   R,   R   t   field(    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR‹     s    c         C   sP   | d k r! | j j ƒ  j } n  d | j | ƒ | j j j | pH | j ƒ f S(   s§  
        Helper function that returns the database column for the given field.
        The table and column are returned (quoted) in the proper format, e.g.,
        `"geoapp_city"."point"`.  If `table_alias` is not specified, the
        database table associated with the model of this `GeoQuerySet` will be
        used.  If `column` is specified, it will be used instead of the value
        in `field.column`.
        s   %s.%sN(	   RY   R€   t   get_metaRÔ   t   quote_name_unless_aliasR/   R"   t
   quote_namet   column(   R,   RÕ   RÛ   t   table_aliasRß   (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyRÓ   *  s    	N(,   RŒ   t
   __module__t   __doc__R   R1   R8   R9   R<   R>   R@   RB   RC   R    RH   RP   RS   RT   RV   RX   R\   R]   R^   R_   R`   Ra   Rc   Ri   Ro   Rx   R|   R}   R~   R„   R†   RY   R   R6   R+   R=   R2   R:   R   R‹   RÓ   (    (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyR      sR   																					$			!W™	("   R4   t   django.contrib.gis.db.modelsR    t#   django.contrib.gis.db.models.fieldsR   R   R   R   t$   django.contrib.gis.db.models.lookupsR   t    django.contrib.gis.db.models.sqlR   R   R   R	   t#   django.contrib.gis.geometry.backendR
   t   django.contrib.gis.measureR   R   t	   django.dbR   t   django.db.models.expressionsR   t   django.db.models.fieldsR   t   django.db.models.queryR   t   django.utilsR   t   django.utils.deprecationR   R   R   (    (    (    sp   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/db/models/query.pyt   <module>   s   ""