Django

Code

Show
Ignore:
Timestamp:
07/04/08 15:16:22 (5 months ago)
Author:
jbronn
Message:

gis: Merged revisions 7772-7808,7811-7814,7816-7823,7826-7829,7831-7833,7835 via svnmerge from trunk. Modified GeoWhereNode accordingly for changes in r7835.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis

    • Property svnmerge-integrated changed from /django/trunk:1-7767 to /django/trunk:1-7835
  • django/branches/gis/django/contrib/gis/db/backend/mysql/query.py

    r7699 r7836  
    3939MYSQL_GIS_TERMS  = MYSQL_GIS_FUNCTIONS.keys() 
    4040MYSQL_GIS_TERMS += MISC_TERMS 
    41 MYSQL_GIS_TERMS = tuple(MYSQL_GIS_TERMS) # Making immutable 
     41MYSQL_GIS_TERMS = dict((term, None) for term in MYSQL_GIS_TERMS) # Making dictionary  
    4242 
    43 def get_geo_where_clause(lookup_type, table_prefix, field, value): 
     43def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): 
    4444    "Returns the SQL WHERE clause for use in MySQL spatial SQL construction." 
    4545    # Getting the quoted field as `geo_col`. 
    46     geo_col = '%s.%s' % (qn(table_prefix), qn(field.column)) 
     46    geo_col = '%s.%s' % (qn(table_alias), qn(name)) 
    4747 
    4848    # See if a MySQL Geometry function matches the lookup type next 
     
    5555    # geometries in its spatial indices. 
    5656    if lookup_type == 'isnull': 
    57         return "%s IS %sNULL" % (geo_col, (not value and 'NOT ' or '')) 
     57        return "%s IS %sNULL" % (geo_col, (not geo_annot.value and 'NOT ' or '')) 
    5858 
    5959    raise TypeError("Got invalid lookup_type: %s" % repr(lookup_type)) 
  • django/branches/gis/django/contrib/gis/db/backend/oracle/query.py

    r7641 r7836  
    111111 
    112112#### The `get_geo_where_clause` function for Oracle #### 
    113 def get_geo_where_clause(lookup_type, table_prefix, field, value): 
     113def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): 
    114114    "Returns the SQL WHERE clause for use in Oracle spatial SQL construction." 
    115115    # Getting the quoted table name as `geo_col`. 
    116     geo_col = '%s.%s' % (qn(table_prefix), qn(field.column)) 
     116    geo_col = '%s.%s' % (qn(table_alias), qn(name)) 
    117117 
    118118    # See if a Oracle Geometry function matches the lookup type next 
     
    127127 
    128128            # Ensuring that a tuple _value_ was passed in from the user 
    129             if not isinstance(value, tuple): 
     129            if not isinstance(geo_annot.value, tuple): 
    130130                raise TypeError('Tuple required for `%s` lookup type.' % lookup_type) 
    131             if len(value) != 2:  
     131            if len(geo_annot.value) != 2:  
    132132                raise ValueError('2-element tuple required for %s lookup type.' % lookup_type) 
    133133             
    134134            # Ensuring the argument type matches what we expect. 
    135             if not isinstance(value[1], arg_type): 
    136                 raise TypeError('Argument type should be %s, got %s instead.' % (arg_type, type(value[1]))) 
     135            if not isinstance(geo_annot.value[1], arg_type): 
     136                raise TypeError('Argument type should be %s, got %s instead.' % (arg_type, type(geo_annot.value[1]))) 
    137137 
    138138            if lookup_type == 'relate': 
    139139                # The SDORelate class handles construction for these queries,  
    140140                # and verifies the mask argument. 
    141                 return sdo_op(value[1]).as_sql(geo_col) 
     141                return sdo_op(geo_annot.value[1]).as_sql(geo_col) 
    142142            else: 
    143143                # Otherwise, just call the `as_sql` method on the SDOOperation instance. 
     
    150150    elif lookup_type == 'isnull': 
    151151        # Handling 'isnull' lookup type 
    152         return "%s IS %sNULL" % (geo_col, (not value and 'NOT ' or '')) 
     152        return "%s IS %sNULL" % (geo_col, (not geo_annot.value and 'NOT ' or '')) 
    153153 
    154154    raise TypeError("Got invalid lookup_type: %s" % repr(lookup_type)) 
  • django/branches/gis/django/contrib/gis/db/backend/postgis/query.py

    r7641 r7836  
    219219POSTGIS_TERMS += POSTGIS_GEOMETRY_FUNCTIONS.keys() # Adding on the Geometry Functions 
    220220POSTGIS_TERMS += MISC_TERMS # Adding any other miscellaneous terms (e.g., 'isnull') 
    221 POSTGIS_TERMS = tuple(POSTGIS_TERMS) # Making immutable 
     221POSTGIS_TERMS = dict((term, None) for term in POSTGIS_TERMS) # Making a dictionary for fast lookups 
    222222 
    223223# For checking tuple parameters -- not very pretty but gets job done. 
     
    229229 
    230230#### The `get_geo_where_clause` function for PostGIS. #### 
    231 def get_geo_where_clause(lookup_type, table_prefix, field, value): 
     231def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): 
    232232    "Returns the SQL WHERE clause for use in PostGIS SQL construction." 
    233233    # Getting the quoted field as `geo_col`. 
    234     geo_col = '%s.%s' % (qn(table_prefix), qn(field.column)) 
     234    geo_col = '%s.%s' % (qn(table_alias), qn(name)) 
    235235    if lookup_type in POSTGIS_OPERATORS: 
    236236        # See if a PostGIS operator matches the lookup type. 
     
    249249 
    250250            # Ensuring that a tuple _value_ was passed in from the user 
    251             if not isinstance(value, (tuple, list)):  
     251            if not isinstance(geo_annot.value, (tuple, list)):  
    252252                raise TypeError('Tuple required for `%s` lookup type.' % lookup_type) 
     253            
    253254            # Number of valid tuple parameters depends on the lookup type. 
    254             nparams = len(value) 
     255            nparams = len(geo_annot.value) 
    255256            if not num_params(lookup_type, nparams): 
    256257                raise ValueError('Incorrect number of parameters given for `%s` lookup type.' % lookup_type) 
    257258             
    258259            # Ensuring the argument type matches what we expect. 
    259             if not isinstance(value[1], arg_type): 
    260                 raise TypeError('Argument type should be %s, got %s instead.' % (arg_type, type(value[1]))) 
     260            if not isinstance(geo_annot.value[1], arg_type): 
     261                raise TypeError('Argument type should be %s, got %s instead.' % (arg_type, type(geo_annot.value[1]))) 
    261262 
    262263            # For lookup type `relate`, the op instance is not yet created (has 
    263264            # to be instantiated here to check the pattern parameter). 
    264265            if lookup_type == 'relate':  
    265                 op = op(value[1]) 
     266                op = op(geo_annot.value[1]) 
    266267            elif lookup_type in DISTANCE_FUNCTIONS and lookup_type != 'dwithin': 
    267                 if field.geodetic: 
     268                if geo_annot.geodetic: 
    268269                    # Geodetic distances are only availble from Points to PointFields. 
    269                     if field._geom != 'POINT': 
     270                    if geo_annot.geom_type != 'POINT': 
    270271                        raise TypeError('PostGIS spherical operations are only valid on PointFields.') 
    271                     if value[0].geom_typeid != 0: 
     272                    if geo_annot.value[0].geom_typeid != 0: 
    272273                        raise TypeError('PostGIS geometry distance parameter is required to be of type Point.') 
    273274                    # Setting up the geodetic operation appropriately. 
    274                     if nparams == 3 and value[2] == 'spheroid': op = op[2] 
     275                    if nparams == 3 and geo_annot.value[2] == 'spheroid': op = op[2] 
    275276                    else: op = op[1] 
    276277                else: 
     
    282283    elif lookup_type == 'isnull': 
    283284        # Handling 'isnull' lookup type 
    284         return "%s IS %sNULL" % (geo_col, (not value and 'NOT ' or '')) 
     285        return "%s IS %sNULL" % (geo_col, (not geo_annot.value and 'NOT ' or '')) 
    285286 
    286287    raise TypeError("Got invalid lookup_type: %s" % repr(lookup_type))