summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-11-07 15:11:44 +0100
committerClaude Paroz <claude@2xlibre.net>2015-11-07 15:12:54 +0100
commit24c1605aa0bf88b78c261210698d0ae75756cac0 (patch)
tree5dc497690ba2388e49f929237b3145082a27cbc6
parentac750dbbc0533dcf9c2f6c0f09957adf6f976d3e (diff)
Fixed GIS test failures when GDAL is not installed
Thanks Iacopo Spalletti for the report and testing.
-rw-r--r--django/contrib/gis/geos/geometry.py6
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py1
2 files changed, 4 insertions, 3 deletions
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 3da1eb6ca2..82fc02667a 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -493,6 +493,9 @@ class GEOSGeometry(GEOSBase, ListMixin):
else:
return
+ if not gdal.HAS_GDAL:
+ raise GEOSException("GDAL library is not available to transform() geometry.")
+
if isinstance(ct, gdal.CoordTransform):
# We don't care about SRID because CoordTransform presupposes
# source SRS.
@@ -500,9 +503,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
elif srid is None or srid < 0:
raise GEOSException("Calling transform() with no SRID set is not supported")
- if not gdal.HAS_GDAL:
- raise GEOSException("GDAL library is not available to transform() geometry.")
-
# Creating an OGR Geometry, which is then transformed.
g = gdal.OGRGeometry(self.wkb, srid)
g.transform(ct)
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index 5ad884da62..b0f3a80ac4 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -989,6 +989,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
self.assertEqual(g1.srid, 4326)
self.assertIsNot(g1, g, "Clone didn't happen")
+ @skipUnless(HAS_GDAL, "GDAL is required.")
def test_transform_nosrid(self):
""" Testing `transform` method (no SRID or negative SRID) """