Fixed #26512 -- Added tests for SpatialRefSysMixin.get_units().

This commit is contained in:
Nicolas Noé 2016-04-19 11:35:50 +02:00 committed by Tim Graham
parent 5402f3ab09
commit 23fbd3ff48
2 changed files with 30 additions and 5 deletions

View file

@ -164,15 +164,14 @@ class SpatialRefSysMixin(object):
@classmethod
def get_units(cls, wkt):
"""
Class method used by GeometryField on initialization to
retrieve the units on the given WKT, without having to use
any of the database fields.
Return a tuple of (unit_value, unit_name) for the given WKT without
using any of the database fields.
"""
if gdal.HAS_GDAL:
return gdal.SpatialReference(wkt).units
else:
m = cls.units_regex.match(wkt)
return m.group('unit'), m.group('unit_name')
return float(m.group('unit')), m.group('unit_name')
@classmethod
def get_spheroid(cls, wkt, string=True):