Fixed #30552 -- Fixed loss of SRID when calling reverse() on LineString/Point.
Thanks Mariusz Felisiak for contributing the Point part.
This commit is contained in:
parent
4122d9d3f1
commit
3c6d32e0b2
|
@ -105,6 +105,7 @@ class LineString(LinearGeometryMixin, GEOSGeometry):
|
||||||
def _set_list(self, length, items):
|
def _set_list(self, length, items):
|
||||||
ndim = self._cs.dims
|
ndim = self._cs.dims
|
||||||
hasz = self._cs.hasz # I don't understand why these are different
|
hasz = self._cs.hasz # I don't understand why these are different
|
||||||
|
srid = self.srid
|
||||||
|
|
||||||
# create a new coordinate sequence and populate accordingly
|
# create a new coordinate sequence and populate accordingly
|
||||||
cs = GEOSCoordSeq(capi.create_cs(length, ndim), z=hasz)
|
cs = GEOSCoordSeq(capi.create_cs(length, ndim), z=hasz)
|
||||||
|
@ -115,6 +116,8 @@ class LineString(LinearGeometryMixin, GEOSGeometry):
|
||||||
if ptr:
|
if ptr:
|
||||||
capi.destroy_geom(self.ptr)
|
capi.destroy_geom(self.ptr)
|
||||||
self.ptr = ptr
|
self.ptr = ptr
|
||||||
|
if srid is not None:
|
||||||
|
self.srid = srid
|
||||||
self._post_init()
|
self._post_init()
|
||||||
else:
|
else:
|
||||||
# can this happen?
|
# can this happen?
|
||||||
|
|
|
@ -76,8 +76,11 @@ class Point(GEOSGeometry):
|
||||||
def _set_list(self, length, items):
|
def _set_list(self, length, items):
|
||||||
ptr = self._create_point(length, items)
|
ptr = self._create_point(length, items)
|
||||||
if ptr:
|
if ptr:
|
||||||
|
srid = self.srid
|
||||||
capi.destroy_geom(self.ptr)
|
capi.destroy_geom(self.ptr)
|
||||||
self._ptr = ptr
|
self._ptr = ptr
|
||||||
|
if srid is not None:
|
||||||
|
self.srid = srid
|
||||||
self._post_init()
|
self._post_init()
|
||||||
else:
|
else:
|
||||||
# can this happen?
|
# can this happen?
|
||||||
|
|
|
@ -280,6 +280,12 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
|
||||||
|
|
||||||
prev = pnt # setting the previous geometry
|
prev = pnt # setting the previous geometry
|
||||||
|
|
||||||
|
def test_point_reverse(self):
|
||||||
|
point = GEOSGeometry('POINT(144.963 -37.8143)', 4326)
|
||||||
|
self.assertEqual(point.srid, 4326)
|
||||||
|
point.reverse()
|
||||||
|
self.assertEqual(point.ewkt, 'SRID=4326;POINT (-37.8143 144.963)')
|
||||||
|
|
||||||
def test_multipoints(self):
|
def test_multipoints(self):
|
||||||
"Testing MultiPoint objects."
|
"Testing MultiPoint objects."
|
||||||
for mp in self.geometries.multipoints:
|
for mp in self.geometries.multipoints:
|
||||||
|
@ -348,6 +354,12 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
|
||||||
# Test __iter__().
|
# Test __iter__().
|
||||||
self.assertEqual(list(LineString((0, 0), (1, 1), (2, 2))), [(0, 0), (1, 1), (2, 2)])
|
self.assertEqual(list(LineString((0, 0), (1, 1), (2, 2))), [(0, 0), (1, 1), (2, 2)])
|
||||||
|
|
||||||
|
def test_linestring_reverse(self):
|
||||||
|
line = GEOSGeometry('LINESTRING(144.963 -37.8143,151.2607 -33.887)', 4326)
|
||||||
|
self.assertEqual(line.srid, 4326)
|
||||||
|
line.reverse()
|
||||||
|
self.assertEqual(line.ewkt, 'SRID=4326;LINESTRING (151.2607 -33.887, 144.963 -37.8143)')
|
||||||
|
|
||||||
def test_multilinestring(self):
|
def test_multilinestring(self):
|
||||||
"Testing MultiLineString objects."
|
"Testing MultiLineString objects."
|
||||||
prev = fromstr('POINT(0 0)')
|
prev = fromstr('POINT(0 0)')
|
||||||
|
|
Loading…
Reference in New Issue