From 0166dd2f8c54b62a65735c395825b66eeb39788c Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 11 Feb 2017 05:47:20 -0500 Subject: [PATCH] Fixed #25524 -- Removed GISOperations.get_distance()'s handle_spheroid param. --- django/contrib/gis/db/backends/oracle/operations.py | 2 +- .../contrib/gis/db/backends/postgis/operations.py | 13 ++----------- .../gis/db/backends/spatialite/operations.py | 2 +- django/contrib/gis/db/models/lookups.py | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 67216ba89d..6c82996692 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -191,7 +191,7 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations): """ return 'MDSYS.SDO_GEOMETRY' - def get_distance(self, f, value, lookup_type, **kwargs): + def get_distance(self, f, value, lookup_type): """ Return the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index cf50a58686..574aa5ff4a 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -285,7 +285,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): else: return 'geometry(%s,%d)' % (geom_type, f.srid) - def get_distance(self, f, dist_val, lookup_type, handle_spheroid=True): + def get_distance(self, f, dist_val, lookup_type): """ Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. @@ -316,16 +316,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): # Assuming the distance is in the units of the field. dist_param = value - params = [dist_param] - # handle_spheroid *might* be dropped in Django 2.0 as PostGISDistanceOperator - # also handles it (#25524). - if handle_spheroid and len(dist_val) > 1: - option = dist_val[1] - if not geography and geodetic and lookup_type != 'dwithin' and option == 'spheroid': - # using distance_spheroid requires the spheroid of the field as - # a parameter. - params.insert(0, f._spheroid) - return params + return [dist_param] def get_geom_placeholder(self, f, value, compiler): """ diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 8df20f9da4..33c69dc1a7 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -150,7 +150,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): """ return None - def get_distance(self, f, value, lookup_type, **kwargs): + def get_distance(self, f, value, lookup_type): """ Return the distance parameters for the given geometry field, lookup value, and lookup type. diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py index 639570b000..58ca90072e 100644 --- a/django/contrib/gis/db/models/lookups.py +++ b/django/contrib/gis/db/models/lookups.py @@ -436,7 +436,7 @@ class DistanceLookupBase(GISLookup): else: params += connection.ops.get_distance( self.lhs.output_field, (dist_param,) + self.rhs[2:], - self.lookup_name, handle_spheroid=False + self.lookup_name, ) rhs = connection.ops.get_geom_placeholder(self.lhs.output_field, params[0], compiler) return (rhs, params)