

_V&                 @   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  Gd d   d e  Z! d S)    N)
aggregates)GeometryFieldLineStringField
PointFieldget_srid_info)	GISLookup)	AreaFieldDistanceField	GeomFieldGMLField)Geometry)AreaDistance)connections)RawSQL)Field)QuerySet)six)RemovedInDjango20WarningRemovedInDjango110Warningc               @   s>  e  Z d  Z d Z d d d  Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d d d d  Z d d d  Z d d d d  Z d d    Z d! d"   Z d# d$   Z d% d&   Z d' d(   Z d) d*   Z d+ d,   Z d- d.   Z d/ d0   Z d1 d2   Z d3 d4 d5  Z d6 d7   Z d d d8 d9  Z d: d;   Z d3 d< d=  Z d> d? d@  Z dA dB   Z  dC dD   Z! dE dE dE dF dG  Z" dE dE d dH dI  Z# dE dE dJ dK  Z$ dE d d dL dM  Z% d dN dO  Z& d dP dQ  Z' dR dS   Z( dE dT dU  Z) dE dE dV dW  Z* dE S)XGeoQuerySetzThe Geographic QuerySet.g?c             K   s  |  j  d d | j d  \ } } i | d 6| d 6d 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)z~
        Returns the area of the geographic field in an `area` attribute on
        each element of this GeoQuerySet.
        area
field_nameprocedure_args	geo_fieldFsetupz%(geo_col)s,%(tolerance)sprocedure_fmt	toleranceZsq_mselect_fieldz2Area on geodetic coordinate systems not supported.)_spatial_setupgetr   dbopsoracler   postgis
spatialite	geographygeodeticr   unit_attname
units_name	Exception_spatial_attribute)selfr   kwargsr   r   s
connectionbackend r1   D/tmp/pip-build-ghmbqnp_/Django/django/contrib/gis/db/models/query.pyr      s$    

		
	%zGeoQuerySet.areac             K   s   |  j  d |  S)z
        Returns the centroid of the geographic field in a `centroid`
        attribute on each element of this GeoQuerySet.
        centroid)_geom_attribute)r,   r-   r1   r1   r2   r3   :   s    zGeoQuerySet.centroidc             K   s)   t  j d t d d |  j t j |  S)z
        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.
        zqThe collect GeoQuerySet method is deprecated. Use the Collect() aggregate in an aggregate() or annotate() method.
stacklevel   )warningswarnr   _spatial_aggregater   ZCollect)r,   r-   r1   r1   r2   collectA   s    zGeoQuerySet.collectc             K   s   |  j  d | |  S)z
        Returns the spatial difference of the geographic field in a `difference`
        attribute on each element of this GeoQuerySet.
        
difference)_geomset_attribute)r,   geomr-   r1   r1   r2   r;   N   s    zGeoQuerySet.differencec             K   s   |  j  d | |  S)a~  
        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.
        distance)_distance_attribute)r,   r=   r-   r1   r1   r2   r>   U   s    zGeoQuerySet.distancec             K   s   |  j  d |  S)z
        Returns a Geometry representing the bounding box of the
        Geometry field in an `envelope` attribute on each element of
        the GeoQuerySet.
        envelope)r4   )r,   r-   r1   r1   r2   r@   g   s    zGeoQuerySet.envelopec             K   s)   t  j d t d d |  j t j |  S)z
        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).
        zoThe extent GeoQuerySet method is deprecated. Use the Extent() aggregate in an aggregate() or annotate() method.r5   r6   )r7   r8   r   r9   r   ZExtent)r,   r-   r1   r1   r2   extento   s    zGeoQuerySet.extentc             K   s)   t  j d t d d |  j t j |  S)z
        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).
        zsThe extent3d GeoQuerySet method is deprecated. Use the Extent3D() aggregate in an aggregate() or annotate() method.r5   r6   )r7   r8   r   r9   r   ZExtent3D)r,   r-   r1   r1   r2   extent3d{   s    zGeoQuerySet.extent3dc             K   s   |  j  d |  S)z
        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.
        	force_rhr)r4   )r,   r-   r1   r1   r2   rC      s    zGeoQuerySet.force_rhr   Fc             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)a\  
        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.
        zFOnly PostGIS 1.3.4+ and SpatiaLite 3.0+ support GeoJSON serialization.z.Precision keyword must be set with an integer.r         r6   ZGeoJSONdesc	precisionoptionsr   z%%(geo_col)s,%(precision)s,%(options)sr   geojson)
r   r!   r"   rJ   NotImplementedError
isinstancer   integer_types	TypeErrorr+   )r,   rH   ZcrsZbboxr-   r0   rI   r.   r1   r1   r2   rJ      s     					

zGeoQuerySet.geojson   c             K   s5   i d d 6i | d 6d 6d d 6} |  j  d | |  S)a  
        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.
        ZGeoHashrG   rH   r   z%(geo_col)s,%(precision)sr   geohash)r+   )r,   rH   r-   r.   r1   r1   r2   rP      s    

zGeoQuerySet.geohashr6   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)
z
        Returns GML representation of the given field in a `gml` attribute
        on each element of the GeoQuerySet.
        ZGMLrG   rH   r   z%%(version)s,%(geo_col)s,%(precision)sr   versionr   gml)r   r!   r"   r$   r#   r   r+   )r,   rH   rQ   r-   r0   r.   r1   r1   r2   rR      s    	
	zGeoQuerySet.gmlc             K   s   |  j  d | |  S)z
        Returns the spatial intersection of the Geometry field in
        an `intersection` attribute on each element of this
        GeoQuerySet.
        intersection)r<   )r,   r=   r-   r1   r1   r2   rS      s    zGeoQuerySet.intersectionc             K   sA   i d d 6d d 6i | j  d d  d 6d 6} |  j d | |  S)	z
        Returns KML representation of the geometry field in a `kml`
        attribute on each element of this GeoQuerySet.
        ZKMLrG   z%(geo_col)s,%(precision)sr   rH   rD   r   kml)popr+   )r,   r-   r.   r1   r1   r2   rT      s    
zGeoQuerySet.kmlc             K   s   |  j  d d |  S)z
        Returns the length of the geometry field as a `Distance` object
        stored in a `length` attribute on each element of this GeoQuerySet.
        lengthN)r?   )r,   r-   r1   r1   r2   rV      s    zGeoQuerySet.lengthc             K   s/   t  j d t d d |  j t j d t | S)z
        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.
        ztThe make_line GeoQuerySet method is deprecated. Use the MakeLine() aggregate in an aggregate() or annotate() method.r5   r6   geo_field_type)r7   r8   r   r9   r   ZMakeLiner   )r,   r-   r1   r1   r2   	make_line   s    zGeoQuerySet.make_linec             K   s   |  j  d i  |  S)z
        Returns the memory size (number of bytes) that the geometry field takes
        in a `mem_size` attribute  on each element of this GeoQuerySet.
        mem_size)r+   )r,   r-   r1   r1   r2   rY      s    zGeoQuerySet.mem_sizec             K   s   |  j  d i  |  S)z
        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.
        num_geom)r+   )r,   r-   r1   r1   r2   rZ      s    zGeoQuerySet.num_geomc             K   s   |  j  d i  |  S)z
        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.
        
num_points)r+   )r,   r-   r1   r1   r2   r[     s    zGeoQuerySet.num_pointsc             K   s   |  j  d d |  S)z
        Returns the perimeter of the geometry field as a `Distance` object
        stored in a `perimeter` attribute on each element of this GeoQuerySet.
        	perimeterN)r?   )r,   r-   r1   r1   r2   r\     s    zGeoQuerySet.perimeterc             K   s   |  j  d |  S)z
        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.
        point_on_surface)r4   )r,   r-   r1   r1   r2   r]     s    zGeoQuerySet.point_on_surfacec             K   sS   i t    d 6} | j d d  t |  j j j r@ t | d <n  |  j d | |  S)z
        Reverses the coordinate order of the geometry, and attaches as a
        `reverse` attribute on each element of this GeoQuerySet.
        r   	model_attreverse_geomrW   reverse)r
   
setdefaultr   r!   r"   r#   r   r+   )r,   r-   r.   r1   r1   r2   r_     s
    zGeoQuerySet.reverse_geomg        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)z|
        Scales the geometry to a new size by multiplying the ordinates
        with the given x,y,z scale factors.
        g        z'SpatiaLite does not support 3D scaling.z%(geo_col)s,%(x)s,%(y)sr   xyr   r   z%(geo_col)s,%(x)s,%(y)s,%(z)szscale)r   r!   r"   r%   rK   r
   r+   )r,   rb   rc   rd   r-   r.   r1   r1   r2   re   %  s    

zGeoQuerySet.scalec             O   s  d d d   | D k r( t  d   n  t |  } | d k r` | 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)ag  
        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.
        Fc             S   s)   g  |  ] } t  | t f t j   q Sr1   )rL   floatr   rM   ).0argr1   r1   r2   
<listcomp>A  s   	 z,GeoQuerySet.snap_to_grid.<locals>.<listcomp>z@Size argument(s) for the grid must be a float or integer values.rF   r   z%(geo_col)s,%(size)ssizer6   z%(geo_col)s,%(xsize)s,%(ysize)sxsizeysize   z7%(geo_col)s,%(xorigin)s,%(yorigin)s,%(xsize)s,%(ysize)sxoriginyoriginz4Must provide 1, 2, or 4 arguments to `snap_to_grid`.r   r   r   snap_to_grid)rN   len
ValueErrorr
   r+   )r,   argsr-   nargsrj   r   r   rk   rl   rn   ro   r.   r1   r1   r2   rp   8  s*    	

zGeoQuerySet.snap_to_gridc             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)
a  
        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).
        z2SVG precision keyword argument must be an integer.ZSVGrG   z!%(geo_col)s,%(rel)s,%(precision)sr   relrH   r   svg)intboolrL   r   rM   rN   r+   )r,   ZrelativerH   r-   r.   r1   r1   r2   rv   \  s    zGeoQuerySet.svgc             K   s   |  j  d | |  S)z
        Returns the symmetric difference of the geographic field in a
        `sym_difference` attribute on each element of this GeoQuerySet.
        sym_difference)r<   )r,   r=   r-   r1   r1   r2   ry   u  s    zGeoQuerySet.sym_differencec             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)zr
        Translates the geometry to a new location using the given numeric
        parameters as offsets.
        g        z+SpatiaLite does not support 3D translation.z%(geo_col)s,%(x)s,%(y)sr   rb   rc   r   r   z%(geo_col)s,%(x)s,%(y)s,%(z)srd   	translate)r   r!   r"   r%   rK   r
   r+   )r,   rb   rc   rd   r-   r.   r1   r1   r2   rz   |  s    

zGeoQuerySet.translatei  c             K   s`   t  | t j  s! t d   n  | j d  } |  j d d | |  j j d |  |  j   S)z
        Transforms the given geometry field to the given SRID.  If no SRID is
        provided, the transformation will default to using 4326 (WGS84).
        z!An integer SRID must be provided.r   	transformtransformed_srid)	rL   r   rM   rN   r    r   queryZadd_contextZ_clone)r,   sridr-   r   r1   r1   r2   r{     s    zGeoQuerySet.transformc             K   s   |  j  d | |  S)z
        Returns the union of the geographic field with the given
        Geometry in a `union` attribute on each element of this GeoQuerySet.
        union)r<   )r,   r=   r-   r1   r1   r2   r     s    zGeoQuerySet.unionc             K   s)   t  j d t d d |  j t j |  S)z
        Performs an aggregate union on the given geometry field.  Returns
        None if the GeoQuerySet is empty.  The `tolerance` keyword is for
        Oracle backends only.
        zpThe unionagg GeoQuerySet method is deprecated. Use the Union() aggregate in an aggregate() or annotate() method.r5   r6   )r7   r8   r   r9   r   Union)r,   r-   r1   r1   r2   unionagg  s    zGeoQuerySet.unionaggNc       	      C   s   t  |  j } t | j | d  } | 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)zE
        Performs set up for executing the spatial function.
        FNz4%s stored procedure not available on the %s backend.functionz+%s output only available on GeometryFields.z1"%s" stored procedures may only be called on %ss.Zgeo_col)r   r!   getattrr"   rK   name
_geo_fieldrN   rL   __name___geocol_select)	r,   attrG   r   rW   r/   funcr   r   r1   r1   r2   r     s    	zGeoQuerySet._spatial_setupc             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)z
        DRY routine for calling aggregate spatial stored procedures and
        returning their result to the caller of the function.
        z.%s aggregate only available on GeometryFields.Nz'%s aggregate may only be called on %ss.r   Zgeoagg)
r   rN   r   rL   r   r   r!   r"   r#   	aggregate)r,   r   r   rW   r   r   Zagg_colZ
agg_kwargsr1   r1   r2   r9     s    zGeoQuerySet._spatial_aggregatec          	   C   s;  t  j d | t d d | j d d  | j d f   | j d d  | j d i   | j d	 d
  | j d g   t |  j } | j d d  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d | _ qn	 t   } |  j j t | | d | d |  |  |  S)a  
        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.
        zxThe %s GeoQuerySet method is deprecated. See GeoDjango Functions documentation to find the expression-based replacement.r5   r6   rG   N	geom_argsZ
geom_fieldr   r   z%(geo_col)sselect_paramsr   Tr   rW   r   containsr/   z%%(%s)sz%%sz%%(function)s(%s)r   F)r7   r8   r   ra   r   r!   r    r   r   	iteritemsrL   string_typesget_prep_valueget_db_prep_lookupZget_placeholderreplaceextendr"   r#   Zempty_strings_allowedr   r}   Zadd_annotationr   )r,   r   settingsr   r^   r/   Zdefault_argsr   kvr   r=   paramsZgeom_placeholderZold_fmtZnew_fmtfmtr   r1   r1   r2   r+     sL    
	


		zGeoQuerySet._spatial_attributec             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d } 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  6d d! 6| d" 6| d# 6| d$ 6} | rmd( | d& <| | d# d% <n | r| j- |  g | d' <n  |  j. | | |  S))zJ
        DRY routine for GeoQuerySet distance attribute routines.
        r   mr>   rV   r\   zUnknown distance function: %srE   zPOINT (0 0)r   spheroidZdistance_lter/   z"%(geo_col)s,%(geom)s,%(tolerance)sz%(geo_col)s,%(tolerance)sr   r|   z[This database does not support linear distance calculations on geodetic coordinate systems.Fz%s(%%(geo_col)s, %s)Nz, %s(%%%%s, %s)z, %%sz, %s(%s(%%%%s, %s), %s)z%(geo_col)s,%(geom)sz=Spherical distance calculation only supported on PointFields.ZPointzLSpherical distance calculation only supported with Point Geometry parametersz,'%(spheroid)s'r   rF   z%(geo_col)sr   r   r   r   r   r=   r   r   )zgeom)/r   r    r   r!   r'   r&   r   r(   r)   rr   Zdimr"   r$   appendr   r   rx   r#   r}   Zget_contextr   lowerZgeodetic_unitsfeaturesZsupports_distance_geodeticr{   r~   r%   Z	from_textrL   r   strr   r   
memoryviewZewkbZ	geom_typeupdateZdistance_spheroidZdistance_sphereZlength_spheroidZsupports_3d_functionsZperimeter3dZlength3dr	   ZAdapterr+   )r,   r   r=   r   r   r-   r   r   r/   r'   r&   Zdist_attr>   rV   r\   Zgeom_3dZlookup_paramsr0   r   r   r   r~   uZ	unit_namer.   r1   r1   r2   r?   E  s    $									+
%
% 

zGeoQuerySet._distance_attributec             K   sT   i t    d 6} t |  j j j rA d | d <i | d 6| d <n  |  j | | |  S)z
        DRY routine for setting up a GeoQuerySet method that attaches a
        Geometry attribute (e.g., `centroid`, `point_on_surface`).
        r   z%(geo_col)s,%(tolerance)sr   r   r   )r
   r   r!   r"   r#   r+   )r,   r   r   r-   r.   r1   r1   r2   r4     s
    
zGeoQuerySet._geom_attributec             K   sq   i d	 d 6t    d 6d d 6i | d 6d 6} t |  j j j r^ | d d 7<| | d d <n  |  j | | |  S)
a  
        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   z%(geo_col)s,%(geom)sr   r   z,%(tolerance)sr   )zgeom)r
   r   r!   r"   r#   r+   )r,   r   r=   r   r-   r.   r1   r1   r2   r<     s    
zGeoQuerySet._geomset_attributec             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)z
        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.
        r   z(%r not in compiler's related_select_colsN)r}   Zget_compilerr!   model_metafieldsZadd_select_relatedZpre_sql_setupselectZoutput_fieldZas_sqlr/   rr   Zlocal_fieldsZconcrete_model_field_columndb_table)r,   r   r   compileroptscol_Zparent_modelr1   r1   r2   r     s    
zGeoQuerySet._geocol_selectc             C   sW   | d k r= x* |  j  j j D] } t | t  r | Sq Wd St j |  j  j |  Sd S)a'  
        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.
        NF)r   r   r   rL   r   r   Z_check_geo_field)r,   r   fieldr1   r1   r2   r     s    zGeoQuerySet._geo_fieldc             C   sP   | d k r! | j  j   j } n  d | j |  | j j j | pH | j  f S)a  
        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`.
        Nz%s.%s)r}   Zget_metar   Zquote_name_unless_aliasr/   r"   Z
quote_namecolumn)r,   r   r   Ztable_aliasr   r1   r1   r2   r   *  s    	zGeoQuerySet._field_column)+r   
__module____qualname____doc__r   r3   r:   r;   r>   r@   rA   rB   rC   rJ   rP   rR   rS   rT   rV   rX   rY   rZ   r[   r\   r]   r_   re   rp   rv   ry   rz   r{   r   r   r   r9   r+   r?   r4   r<   r   r   r   r1   r1   r1   r2   r      sR   		$!Wr   )"r7   Zdjango.contrib.gis.db.modelsr   Z#django.contrib.gis.db.models.fieldsr   r   r   r   Z$django.contrib.gis.db.models.lookupsr   Z django.contrib.gis.db.models.sqlr   r	   r
   r   Z#django.contrib.gis.geometry.backendr   Zdjango.contrib.gis.measurer   r   Z	django.dbr   Zdjango.db.models.expressionsr   Zdjango.db.models.fieldsr   Zdjango.db.models.queryr   Zdjango.utilsr   Zdjango.utils.deprecationr   r   r   r1   r1   r1   r2   <module>   s   ""