Removed more GeoQuerySet leftovers.

Follow up to a0d166306f.
This commit is contained in:
Sergey Fedoseev 2017-03-21 18:13:18 +05:00 committed by Tim Graham
parent 816c5753ac
commit 08972528c2
5 changed files with 11 additions and 39 deletions

View File

@ -134,23 +134,14 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
)
if internal_type in geometry_fields:
converters.append(self.convert_textfield_value)
if hasattr(expression.output_field, 'geom_type'):
converters.append(self.convert_geometry)
return converters
def convert_geometry(self, value, expression, connection, context):
if value:
value = Geometry(value)
if 'transformed_srid' in context:
value.srid = context['transformed_srid']
return value
def convert_extent(self, clob, srid):
def convert_extent(self, clob):
if clob:
# Generally, Oracle returns a polygon for the extent -- however,
# it can return a single point if there's only one Point in the
# table.
ext_geom = Geometry(clob.read(), srid)
ext_geom = Geometry(clob.read())
gtype = str(ext_geom.geom_type)
if gtype == 'Polygon':
# Construct the 4-tuple from the coordinates in the polygon.

View File

@ -206,7 +206,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
version = vtup[1:]
return version
def convert_extent(self, box, srid):
def convert_extent(self, box):
"""
Return a 4-tuple extent for the `Extent` aggregate by converting
the bounding box text returned by PostGIS (`box` argument), for
@ -219,7 +219,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
xmax, ymax = map(float, ur.split())
return (xmin, ymin, xmax, ymax)
def convert_extent3d(self, box3d, srid):
def convert_extent3d(self, box3d):
"""
Return a 6-tuple extent for the `Extent3D` aggregate by converting
the 3d bounding-box text returned by PostGIS (`box3d` argument), for

View File

@ -113,13 +113,13 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.0.0 and above.')
return version
def convert_extent(self, box, srid):
def convert_extent(self, box):
"""
Convert the polygon data received from SpatiaLite to min/max values.
"""
if box is None:
return None
shell = Geometry(box, srid).shell
shell = Geometry(box).shell
xmin, ymin = shell[0][:2]
xmax, ymax = shell[2][:2]
return (xmin, ymin, xmax, ymax)
@ -242,16 +242,3 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
def spatial_ref_sys(self):
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys
return SpatialiteSpatialRefSys
def get_db_converters(self, expression):
converters = super().get_db_converters(expression)
if hasattr(expression.output_field, 'geom_type'):
converters.append(self.convert_geometry)
return converters
def convert_geometry(self, value, expression, connection, context):
if value:
value = Geometry(value)
if 'transformed_srid' in context:
value.srid = context['transformed_srid']
return value

View File

@ -43,7 +43,7 @@ class Extent(GeoAggregate):
super().__init__(expression, output_field=ExtentField(), **extra)
def convert_value(self, value, expression, connection, context):
return connection.ops.convert_extent(value, context.get('transformed_srid'))
return connection.ops.convert_extent(value)
class Extent3D(GeoAggregate):
@ -54,7 +54,7 @@ class Extent3D(GeoAggregate):
super().__init__(expression, output_field=ExtentField(), **extra)
def convert_value(self, value, expression, connection, context):
return connection.ops.convert_extent3d(value, context.get('transformed_srid'))
return connection.ops.convert_extent3d(value)
class MakeLine(GeoAggregate):

View File

@ -57,18 +57,12 @@ class GeoSelectFormatMixin:
other fields, return a simple '%s' format string.
"""
connection = compiler.connection
srid = compiler.query.get_context('transformed_srid')
if srid:
sel_fmt = '%s(%%s, %s)' % (connection.ops.transform, srid)
else:
sel_fmt = '%s'
if connection.ops.select:
# This allows operations to be done on fields in the SELECT,
# overriding their values -- used by the Oracle and MySQL
# spatial backends to get database values as WKT, and by the
# `transform` method.
sel_fmt = connection.ops.select % sel_fmt
return sel_fmt % sql, params
# spatial backends to get database values as WKT.
sql = connection.ops.select % sql
return sql, params
class BaseSpatialField(Field):