mirror of https://github.com/django/django.git
[4.2.x] Fixed #34302 -- Fixed SpatialReference.srid for objects without top-level authority.
Backport of eacf6b73d8
from main
This commit is contained in:
parent
341f33ed15
commit
efcc0f25a7
|
@ -208,7 +208,7 @@ class SpatialReference(GDALBase):
|
||||||
def srid(self):
|
def srid(self):
|
||||||
"Return the SRID of top-level authority, or None if undefined."
|
"Return the SRID of top-level authority, or None if undefined."
|
||||||
try:
|
try:
|
||||||
return int(self.attr_value("AUTHORITY", 1))
|
return int(self.auth_code(target=None))
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,10 @@ srlist = (
|
||||||
ang_name="Degree",
|
ang_name="Degree",
|
||||||
lin_units=0.3048006096012192,
|
lin_units=0.3048006096012192,
|
||||||
ang_units=0.0174532925199,
|
ang_units=0.0174532925199,
|
||||||
auth={"PROJCS": (None, None)},
|
auth={
|
||||||
|
None: (None, None), # Top-level authority.
|
||||||
|
"PROJCS": (None, None),
|
||||||
|
},
|
||||||
attr=(
|
attr=(
|
||||||
("PROJCS|GeOgCs|spheroid", "GRS 1980"),
|
("PROJCS|GeOgCs|spheroid", "GRS 1980"),
|
||||||
(("projcs", 9), "UNIT"),
|
(("projcs", 9), "UNIT"),
|
||||||
|
@ -391,3 +394,10 @@ class SpatialRefTest(SimpleTestCase):
|
||||||
self.assertIn('DATUM["D_North_American_1983"', srs.wkt)
|
self.assertIn('DATUM["D_North_American_1983"', srs.wkt)
|
||||||
srs.from_esri()
|
srs.from_esri()
|
||||||
self.assertIn('DATUM["North_American_Datum_1983"', srs.wkt)
|
self.assertIn('DATUM["North_American_Datum_1983"', srs.wkt)
|
||||||
|
|
||||||
|
def test_srid(self):
|
||||||
|
"""The srid property returns top-level authority code."""
|
||||||
|
for s in srlist:
|
||||||
|
if hasattr(s, "epsg"):
|
||||||
|
srs = SpatialReference(s.wkt)
|
||||||
|
self.assertEqual(srs.srid, s.epsg)
|
||||||
|
|
Loading…
Reference in New Issue