diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index 29589855d05..164b2753012 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -532,10 +532,10 @@ class GEOSGeometry(GEOSBase, ListMixin): raise GEOSException("Calling transform() with no SRID set is not supported") # Creating an OGR Geometry, which is then transformed. - g = gdal.OGRGeometry(self.wkb, srid) + g = gdal.OGRGeometry(self._ogr_ptr(), srid) g.transform(ct) # Getting a new GEOS pointer - ptr = wkb_r().read(g.wkb) + ptr = g._geos_ptr() if clone: # User wants a cloned transformed geometry returned. return GEOSGeometry(ptr, srid=g.srid) diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py index c70171e4c52..176ae3d482a 100644 --- a/tests/gis_tests/geos_tests/test_geos.py +++ b/tests/gis_tests/geos_tests/test_geos.py @@ -1359,6 +1359,10 @@ class GEOSTest(SimpleTestCase, TestDataMixin): p = Point(srid=4326) self.assertEqual(p.ogr.ewkt, p.ewkt) + self.assertEqual(p.transform(2774, clone=True), Point(srid=2774)) + p.transform(2774) + self.assertEqual(p, Point(srid=2774)) + @ignore_warnings(category=RemovedInDjango20Warning) def test_deprecated_srid_getters_setters(self): p = Point(1, 2, srid=123)