From 08972528c264c2d6c0a7680874cf4a10c681dfa3 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Tue, 21 Mar 2017 18:13:18 +0500 Subject: [PATCH] Removed more GeoQuerySet leftovers. Follow up to a0d166306fbdc41f49e6fadf4ec84b17eb147daa. --- .../gis/db/backends/oracle/operations.py | 13 ++----------- .../gis/db/backends/postgis/operations.py | 4 ++-- .../gis/db/backends/spatialite/operations.py | 17 ++--------------- django/contrib/gis/db/models/aggregates.py | 4 ++-- django/contrib/gis/db/models/fields.py | 12 +++--------- 5 files changed, 11 insertions(+), 39 deletions(-) diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 207784e343..e030af1da3 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -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. diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 7bb66b8a0c..d002c5d18c 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -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 diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 0b71f07b4e..d2fc68b4c0 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -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 diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index 95dce944c5..131ef0e676 100644 --- a/django/contrib/gis/db/models/aggregates.py +++ b/django/contrib/gis/db/models/aggregates.py @@ -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): diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index f63190e9a9..9ea62400c5 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -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):