11import re
22
3- from django .core .exceptions import FieldDoesNotExist
4- from django .db .models .constants import LOOKUP_SEP
53from django .db .models .expressions import Col , Expression
64from django .db .models .lookups import Lookup , Transform
75from django .db .models .sql .query import Query
@@ -25,46 +23,6 @@ def __init__(self, *args, **kwargs):
2523 super ().__init__ (* args , ** kwargs )
2624 self .template_params = {}
2725
28- @classmethod
29- def _check_geo_field (cls , opts , lookup ):
30- """
31- Check the given lookup with the given model options.
32- The lookup is a string either specifying the geographic field, e.g.
33- 'point, 'the_geom', or a related lookup on a geographic field like
34- 'address__point'.
35-
36- Return a BaseSpatialField if one exists according to the given lookup
37- on the model options, otherwise return None.
38- """
39- from django .contrib .gis .db .models .fields import BaseSpatialField
40- # This takes into account the situation where the lookup is a
41- # lookup to a related geographic field, e.g., 'address__point'.
42- field_list = lookup .split (LOOKUP_SEP )
43-
44- # Reversing so list operates like a queue of related lookups,
45- # and popping the top lookup.
46- field_list .reverse ()
47- fld_name = field_list .pop ()
48-
49- try :
50- geo_fld = opts .get_field (fld_name )
51- # If the field list is still around, then it means that the
52- # lookup was for a geometry field across a relationship --
53- # thus we keep on getting the related model options and the
54- # model field associated with the next field in the list
55- # until there's no more left.
56- while len (field_list ):
57- opts = geo_fld .remote_field .model ._meta
58- geo_fld = opts .get_field (field_list .pop ())
59- except (FieldDoesNotExist , AttributeError ):
60- return False
61-
62- # Finally, make sure we got a Geographic field and return.
63- if isinstance (geo_fld , BaseSpatialField ):
64- return geo_fld
65- else :
66- return False
67-
6826 def process_band_indices (self , only_lhs = False ):
6927 """
7028 Extract the lhs band index from the band transform class and the rhs
0 commit comments