summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-04-01 01:02:28 +0500
committerTim Graham <timograham@gmail.com>2017-04-07 12:45:52 -0400
commitdf8f1d018fcbf780e4e8eb98f550b2db6ad2d4c0 (patch)
tree88ae19bd60e146ee3d7d96b73ad65ec60545fd24
parente2bd2539b6d30a6f60dacdad9b8e15a2d4085484 (diff)
Fixed #27972 -- Made BaseSpatialField.geodetic() use SpatialReference.geographic.
-rw-r--r--django/contrib/gis/db/models/fields.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py
index e27ff2dcf3..925087a4c7 100644
--- a/django/contrib/gis/db/models/fields.py
+++ b/django/contrib/gis/db/models/fields.py
@@ -15,7 +15,7 @@ from django.utils.translation import gettext_lazy as _
_srid_cache = defaultdict(dict)
-SRIDCacheEntry = namedtuple('SRIDCacheEntry', ['units', 'units_name', 'spheroid'])
+SRIDCacheEntry = namedtuple('SRIDCacheEntry', ['units', 'units_name', 'spheroid', 'geodetic'])
def get_srid_info(srid, connection):
@@ -45,6 +45,7 @@ def get_srid_info(srid, connection):
units=units,
units_name=units_name,
spheroid='SPHEROID["%s",%s,%s]' % (srs['spheroid'], srs.semi_major, srs.inverse_flattening),
+ geodetic=srs.geographic,
)
return _srid_cache[alias][srid]
@@ -77,8 +78,6 @@ class BaseSpatialField(Field):
"""
description = _("The base GIS field.")
empty_strings_allowed = False
- # Geodetic units.
- geodetic_units = ('decimal degree', 'degree')
def __init__(self, verbose_name=None, srid=4326, spatial_index=True, **kwargs):
"""
@@ -134,8 +133,7 @@ class BaseSpatialField(Field):
Return true if this field's SRID corresponds with a coordinate
system that uses non-projected units (e.g., latitude/longitude).
"""
- units_name = self.units_name(connection)
- return units_name.lower() in self.geodetic_units if units_name else self.srid == 4326
+ return get_srid_info(self.srid, connection).geodetic
def get_placeholder(self, value, compiler, connection):
"""