Moved check_aggregate_support to BaseSpatialOperations
This commit is contained in:
parent
9801d419b9
commit
67bcae1e58
|
@ -102,6 +102,11 @@ class BaseSpatialOperations(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('subclasses of BaseSpatialOperations must provide a geo_db_placeholder() method')
|
raise NotImplementedError('subclasses of BaseSpatialOperations must provide a geo_db_placeholder() method')
|
||||||
|
|
||||||
|
def check_aggregate_support(self, aggregate):
|
||||||
|
if aggregate.contains_aggregate == 'gis':
|
||||||
|
return aggregate.name in self.valid_aggregates
|
||||||
|
return super(BaseSpatialOperations, self).check_aggregate_support(aggregate)
|
||||||
|
|
||||||
# Spatial SQL Construction
|
# Spatial SQL Construction
|
||||||
def spatial_aggregate_sql(self, agg):
|
def spatial_aggregate_sql(self, agg):
|
||||||
raise NotImplementedError('Aggregate support not implemented for this spatial backend.')
|
raise NotImplementedError('Aggregate support not implemented for this spatial backend.')
|
||||||
|
|
|
@ -4,7 +4,7 @@ from django.contrib.gis.db.backends.utils import SpatialOperator
|
||||||
from django.db.backends.mysql.operations import DatabaseOperations
|
from django.db.backends.mysql.operations import DatabaseOperations
|
||||||
|
|
||||||
|
|
||||||
class MySQLOperations(DatabaseOperations, BaseSpatialOperations):
|
class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
mysql = True
|
mysql = True
|
||||||
name = 'mysql'
|
name = 'mysql'
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SDORelate(SpatialOperator):
|
||||||
return super(SDORelate, self).as_sql(connection, lookup, template_params, sql_params)
|
return super(SDORelate, self).as_sql(connection, lookup, template_params, sql_params)
|
||||||
|
|
||||||
|
|
||||||
class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
class OracleOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
name = 'oracle'
|
name = 'oracle'
|
||||||
oracle = True
|
oracle = True
|
||||||
|
|
|
@ -43,7 +43,7 @@ class PostGISDistanceOperator(PostGISOperator):
|
||||||
return super(PostGISDistanceOperator, self).as_sql(connection, lookup, template_params, sql_params)
|
return super(PostGISDistanceOperator, self).as_sql(connection, lookup, template_params, sql_params)
|
||||||
|
|
||||||
|
|
||||||
class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
|
class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
name = 'postgis'
|
name = 'postgis'
|
||||||
postgis = True
|
postgis = True
|
||||||
geography = True
|
geography = True
|
||||||
|
@ -179,14 +179,6 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
|
||||||
version = vtup[1:]
|
version = vtup[1:]
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def check_aggregate_support(self, aggregate):
|
|
||||||
"""
|
|
||||||
Checks if the given aggregate name is supported (that is, if it's
|
|
||||||
in `self.valid_aggregates`).
|
|
||||||
"""
|
|
||||||
agg_name = aggregate.__class__.__name__
|
|
||||||
return agg_name in self.valid_aggregates
|
|
||||||
|
|
||||||
def convert_extent(self, box, srid):
|
def convert_extent(self, box, srid):
|
||||||
"""
|
"""
|
||||||
Returns a 4-tuple extent for the `Extent` aggregate by converting
|
Returns a 4-tuple extent for the `Extent` aggregate by converting
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.utils import six
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
|
||||||
class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
|
class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
name = 'spatialite'
|
name = 'spatialite'
|
||||||
spatialite = True
|
spatialite = True
|
||||||
version_regex = re.compile(r'^(?P<major>\d)\.(?P<minor1>\d)\.(?P<minor2>\d+)')
|
version_regex = re.compile(r'^(?P<major>\d)\.(?P<minor1>\d)\.(?P<minor2>\d+)')
|
||||||
|
@ -121,15 +121,6 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
|
||||||
def geojson(self):
|
def geojson(self):
|
||||||
return 'AsGeoJSON' if self.spatial_version >= (3, 0, 0) else None
|
return 'AsGeoJSON' if self.spatial_version >= (3, 0, 0) else None
|
||||||
|
|
||||||
def check_aggregate_support(self, aggregate):
|
|
||||||
"""
|
|
||||||
Checks if the given aggregate name is supported (that is, if it's
|
|
||||||
in `self.valid_aggregates`).
|
|
||||||
"""
|
|
||||||
super(SpatiaLiteOperations, self).check_aggregate_support(aggregate)
|
|
||||||
agg_name = aggregate.__class__.__name__
|
|
||||||
return agg_name in self.valid_aggregates
|
|
||||||
|
|
||||||
def convert_extent(self, box, srid):
|
def convert_extent(self, box, srid):
|
||||||
"""
|
"""
|
||||||
Convert the polygon data received from Spatialite to min/max values.
|
Convert the polygon data received from Spatialite to min/max values.
|
||||||
|
|
|
@ -7,6 +7,7 @@ __all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union']
|
||||||
class GeoAggregate(Aggregate):
|
class GeoAggregate(Aggregate):
|
||||||
template = None
|
template = None
|
||||||
function = None
|
function = None
|
||||||
|
contains_aggregate = 'gis'
|
||||||
is_extent = False
|
is_extent = False
|
||||||
|
|
||||||
def as_sql(self, compiler, connection):
|
def as_sql(self, compiler, connection):
|
||||||
|
|
|
@ -224,6 +224,7 @@ class BaseDatabaseFeatures(object):
|
||||||
def supports_stddev(self):
|
def supports_stddev(self):
|
||||||
"""Confirm support for STDDEV and related stats functions."""
|
"""Confirm support for STDDEV and related stats functions."""
|
||||||
class StdDevPop(object):
|
class StdDevPop(object):
|
||||||
|
contains_aggregate = True
|
||||||
sql_function = 'STDDEV_POP'
|
sql_function = 'STDDEV_POP'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue