mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Made gis_terms be a set, rather than a dict with None for all keys.
This commit is contained in:
@@ -18,6 +18,7 @@ from django.contrib.gis.geometry.backend import Geometry
|
||||
from django.contrib.gis.measure import Distance
|
||||
from django.utils import six
|
||||
|
||||
|
||||
class SDOOperation(SpatialFunction):
|
||||
"Base class for SDO* Oracle operations."
|
||||
sql_template = "%(function)s(%(geo_col)s, %(geometry)s) %(operator)s '%(result)s'"
|
||||
@@ -32,6 +33,7 @@ class SDODistance(SpatialFunction):
|
||||
sql_template = ('%(function)s(%(geo_col)s, %(geometry)s, %(tolerance)s) '
|
||||
'%(operator)s %(result)s')
|
||||
dist_func = 'SDO_GEOM.SDO_DISTANCE'
|
||||
|
||||
def __init__(self, op, tolerance=0.05):
|
||||
super(SDODistance, self).__init__(self.dist_func,
|
||||
tolerance=tolerance,
|
||||
@@ -40,6 +42,7 @@ class SDODistance(SpatialFunction):
|
||||
class SDODWithin(SpatialFunction):
|
||||
dwithin_func = 'SDO_WITHIN_DISTANCE'
|
||||
sql_template = "%(function)s(%(geo_col)s, %(geometry)s, %%s) = 'TRUE'"
|
||||
|
||||
def __init__(self):
|
||||
super(SDODWithin, self).__init__(self.dwithin_func)
|
||||
|
||||
@@ -48,6 +51,7 @@ class SDOGeomRelate(SpatialFunction):
|
||||
relate_func = 'SDO_GEOM.RELATE'
|
||||
sql_template = ("%(function)s(%(geo_col)s, '%(mask)s', %(geometry)s, "
|
||||
"%(tolerance)s) %(operator)s '%(mask)s'")
|
||||
|
||||
def __init__(self, mask, tolerance=0.05):
|
||||
# SDO_GEOM.RELATE(...) has a peculiar argument order: column, mask, geom, tolerance.
|
||||
# Moreover, the runction result is the mask (e.g., 'DISJOINT' instead of 'TRUE').
|
||||
@@ -60,6 +64,7 @@ class SDORelate(SpatialFunction):
|
||||
mask_regex = re.compile(r'^(%s)(\+(%s))*$' % (masks, masks), re.I)
|
||||
sql_template = "%(function)s(%(geo_col)s, %(geometry)s, 'mask=%(mask)s') = 'TRUE'"
|
||||
relate_func = 'SDO_RELATE'
|
||||
|
||||
def __init__(self, mask):
|
||||
if not self.mask_regex.match(mask):
|
||||
raise ValueError('Invalid %s mask: "%s"' % (self.relate_func, mask))
|
||||
@@ -79,12 +84,12 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
Adaptor = Adapter # Backwards-compatibility alias.
|
||||
|
||||
area = 'SDO_GEOM.SDO_AREA'
|
||||
gml= 'SDO_UTIL.TO_GMLGEOMETRY'
|
||||
gml = 'SDO_UTIL.TO_GMLGEOMETRY'
|
||||
centroid = 'SDO_GEOM.SDO_CENTROID'
|
||||
difference = 'SDO_GEOM.SDO_DIFFERENCE'
|
||||
distance = 'SDO_GEOM.SDO_DISTANCE'
|
||||
extent= 'SDO_AGGR_MBR'
|
||||
intersection= 'SDO_GEOM.SDO_INTERSECTION'
|
||||
extent = 'SDO_AGGR_MBR'
|
||||
intersection = 'SDO_GEOM.SDO_INTERSECTION'
|
||||
length = 'SDO_GEOM.SDO_LENGTH'
|
||||
num_geom = 'SDO_UTIL.GETNUMELEM'
|
||||
num_points = 'SDO_UTIL.GETNUMVERTICES'
|
||||
@@ -127,9 +132,8 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
}
|
||||
geometry_functions.update(distance_functions)
|
||||
|
||||
gis_terms = ['isnull']
|
||||
gis_terms += list(geometry_functions)
|
||||
gis_terms = dict([(term, None) for term in gis_terms])
|
||||
gis_terms = set(['isnull'])
|
||||
gis_terms.update(geometry_functions)
|
||||
|
||||
truncate_params = {'relate' : None}
|
||||
|
||||
@@ -272,7 +276,8 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
given Aggregate instance.
|
||||
"""
|
||||
agg_name = agg.__class__.__name__.lower()
|
||||
if agg_name == 'union' : agg_name += 'agg'
|
||||
if agg_name == 'union':
|
||||
agg_name += 'agg'
|
||||
if agg.is_extent:
|
||||
sql_template = '%(function)s(%(field)s)'
|
||||
else:
|
||||
@@ -295,5 +300,5 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
"""
|
||||
# This code doesn't work for bulk insert cases.
|
||||
assert len(placeholders) == 1
|
||||
return [[param for pholder,param
|
||||
return [[param for pholder, param
|
||||
in six.moves.zip(placeholders[0], params[0]) if pholder != 'NULL'], ]
|
||||
|
||||
Reference in New Issue
Block a user