Fixed #25797 -- Fixed regex for getting units from SRS WKT.
This commit is contained in:
parent
b52b9cf6f2
commit
717a54c883
|
@ -21,12 +21,7 @@ class SpatialRefSysMixin(object):
|
||||||
# TODO: Figure out how to pull out angular units of projected coordinate system and
|
# TODO: Figure out how to pull out angular units of projected coordinate system and
|
||||||
# fix for LOCAL_CS types. GDAL should be highly recommended for performing
|
# fix for LOCAL_CS types. GDAL should be highly recommended for performing
|
||||||
# distance queries.
|
# distance queries.
|
||||||
units_regex = re.compile(
|
units_regex = re.compile(r'.+UNIT ?\["(?P<unit_name>[\w \.\'\(\)]+)", ?(?P<unit>[^ ,\]]+)', re.DOTALL)
|
||||||
r'.+UNIT ?\["(?P<unit_name>[\w \'\(\)]+)", ?(?P<unit>[\d\.]+)'
|
|
||||||
r'(,AUTHORITY\["(?P<unit_auth_name>[\w \'\(\)]+)",'
|
|
||||||
r'"(?P<unit_auth_val>\d+)"\])?\]([\w ]+)?(,'
|
|
||||||
r'AUTHORITY\["(?P<auth_name>[\w \'\(\)]+)","(?P<auth_val>\d+)"\])?\]$'
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def srs(self):
|
def srs(self):
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from unittest import skipUnless
|
||||||
|
|
||||||
from django.contrib.gis.db.models.functions import (
|
from django.contrib.gis.db.models.functions import (
|
||||||
Area, Distance, Length, Perimeter, Transform,
|
Area, Distance, Length, Perimeter, Transform,
|
||||||
)
|
)
|
||||||
|
from django.contrib.gis.gdal import HAS_GDAL
|
||||||
from django.contrib.gis.geos import GEOSGeometry, LineString, Point
|
from django.contrib.gis.geos import GEOSGeometry, LineString, Point
|
||||||
from django.contrib.gis.measure import D # alias for Distance
|
from django.contrib.gis.measure import D # alias for Distance
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.models import F, Q
|
from django.db.models import F, Q
|
||||||
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
|
from django.test import TestCase, ignore_warnings, mock, skipUnlessDBFeature
|
||||||
from django.utils.deprecation import RemovedInDjango20Warning
|
from django.utils.deprecation import RemovedInDjango20Warning
|
||||||
|
|
||||||
from ..utils import no_oracle, oracle, postgis
|
from ..utils import no_oracle, oracle, postgis
|
||||||
|
@ -487,6 +490,7 @@ class DistanceFunctionsTests(TestCase):
|
||||||
tol
|
tol
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@skipUnless(HAS_GDAL, "GDAL is required.")
|
||||||
@skipUnlessDBFeature("has_Distance_function", "has_Transform_function")
|
@skipUnlessDBFeature("has_Distance_function", "has_Transform_function")
|
||||||
def test_distance_projected(self):
|
def test_distance_projected(self):
|
||||||
"""
|
"""
|
||||||
|
@ -509,6 +513,8 @@ class DistanceFunctionsTests(TestCase):
|
||||||
455411.438904354, 519386.252102563, 696139.009211594,
|
455411.438904354, 519386.252102563, 696139.009211594,
|
||||||
232513.278304279, 542445.630586414, 456679.155883207]
|
232513.278304279, 542445.630586414, 456679.155883207]
|
||||||
|
|
||||||
|
for has_gdal in [False, True]:
|
||||||
|
with mock.patch('django.contrib.gis.gdal.HAS_GDAL', has_gdal):
|
||||||
# Testing using different variations of parameters and using models
|
# Testing using different variations of parameters and using models
|
||||||
# with different projected coordinate systems.
|
# with different projected coordinate systems.
|
||||||
dist1 = SouthTexasCity.objects.annotate(distance=Distance('point', lagrange)).order_by('id')
|
dist1 = SouthTexasCity.objects.annotate(distance=Distance('point', lagrange)).order_by('id')
|
||||||
|
|
Loading…
Reference in New Issue