diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 4e5409d..8051526 100644
a
|
b
|
class GEOSGeometry(GEOSBase, ListMixin):
|
465 | 465 | def ogr(self): |
466 | 466 | "Returns the OGR Geometry for this Geometry." |
467 | 467 | if gdal.HAS_GDAL: |
| 468 | # Only ewkb keeps the 3D data |
| 469 | wkb = self.ewkb if GEOS_PREPARE and self.hasz else self.wkb |
468 | 470 | if self.srid: |
469 | | return gdal.OGRGeometry(self.wkb, self.srid) |
| 471 | return gdal.OGRGeometry(wkb, self.srid) |
470 | 472 | else: |
471 | | return gdal.OGRGeometry(self.wkb) |
| 473 | return gdal.OGRGeometry(wkb) |
472 | 474 | else: |
473 | 475 | raise GEOSException('GDAL required to convert to an OGRGeometry.') |
474 | 476 | |
… |
… |
class GEOSGeometry(GEOSBase, ListMixin):
|
513 | 515 | raise GEOSException("GDAL library is not available to transform() geometry.") |
514 | 516 | |
515 | 517 | # Creating an OGR Geometry, which is then transformed. |
516 | | g = gdal.OGRGeometry(self.wkb, srid) |
| 518 | g = self.ogr |
517 | 519 | g.transform(ct) |
518 | 520 | # Getting a new GEOS pointer |
519 | 521 | ptr = wkb_r().read(g.wkb) |
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index 7300ab9..3800b2e 100644
a
|
b
|
class GEOSTest(unittest.TestCase, TestDataMixin):
|
829 | 829 | def test_gdal(self): |
830 | 830 | "Testing `ogr` and `srs` properties." |
831 | 831 | g1 = fromstr('POINT(5 23)') |
832 | | self.assertEqual(True, isinstance(g1.ogr, gdal.OGRGeometry)) |
833 | | self.assertEqual(g1.srs, None) |
| 832 | self.assertIsInstance(g1.ogr, gdal.OGRGeometry) |
| 833 | self.assertIsNone(g1.srs) |
| 834 | |
| 835 | if GEOS_PREPARE: |
| 836 | g1_3d = fromstr('POINT(5 23 8)') |
| 837 | self.assertIsInstance(g1_3d.ogr, gdal.OGRGeometry) |
| 838 | self.assertEqual(g1_3d.ogr.z, 8) |
834 | 839 | |
835 | 840 | g2 = fromstr('LINESTRING(0 0, 5 5, 23 23)', srid=4326) |
836 | | self.assertEqual(True, isinstance(g2.ogr, gdal.OGRGeometry)) |
837 | | self.assertEqual(True, isinstance(g2.srs, gdal.SpatialReference)) |
| 841 | self.assertIsInstance(g2.ogr, gdal.OGRGeometry) |
| 842 | self.assertIsInstance(g2.srs, gdal.SpatialReference) |
838 | 843 | self.assertEqual(g2.hex, g2.ogr.hex) |
839 | 844 | self.assertEqual('WGS 84', g2.srs.name) |
840 | 845 | |
… |
… |
class GEOSTest(unittest.TestCase, TestDataMixin):
|
847 | 852 | self.assertNotEqual(poly._ptr, cpy1._ptr) |
848 | 853 | self.assertNotEqual(poly._ptr, cpy2._ptr) |
849 | 854 | |
850 | | @unittest.skipUnless(gdal.HAS_GDAL, "gdal is required") |
| 855 | @unittest.skipUnless(gdal.HAS_GDAL, "gdal is required to transform geometries") |
851 | 856 | def test_transform(self): |
852 | 857 | "Testing `transform` method." |
853 | 858 | orig = GEOSGeometry('POINT (-104.609 38.255)', 4326) |
… |
… |
class GEOSTest(unittest.TestCase, TestDataMixin):
|
872 | 877 | self.assertAlmostEqual(trans.x, p.x, prec) |
873 | 878 | self.assertAlmostEqual(trans.y, p.y, prec) |
874 | 879 | |
| 880 | @unittest.skipUnless(gdal.HAS_GDAL, "gdal is required to transform geometries") |
| 881 | def test_transform_3d(self): |
| 882 | p3d = GEOSGeometry('POINT (5 23 100)', 4326) |
| 883 | p3d.transform(2774) |
| 884 | if GEOS_PREPARE: |
| 885 | self.assertAlmostEqual(p3d.z, 0) |
| 886 | else: |
| 887 | self.assertIsNone(p3d.z) |
| 888 | |
875 | 889 | def test_transform_noop(self): |
876 | 890 | """ Testing `transform` method (SRID match) """ |
877 | 891 | # transform() should no-op if source & dest SRIDs match, |