mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
gis: geos: Fixed bug in transform
where coordinate sequence pointer was not after transformation (and added tests). Thanks robotika.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7101 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ead0dad735
commit
c703452841
@ -406,12 +406,14 @@ class GEOSGeometry(object):
|
|||||||
wkb = str(g.wkb)
|
wkb = str(g.wkb)
|
||||||
ptr = from_wkb(wkb, len(wkb))
|
ptr = from_wkb(wkb, len(wkb))
|
||||||
if ptr:
|
if ptr:
|
||||||
# Reassigning pointer, and resetting the SRID.
|
# Reassigning pointer, and getting the new coordinate sequence pointer.
|
||||||
destroy_geom(self.ptr)
|
destroy_geom(self.ptr)
|
||||||
self._ptr = ptr
|
self._ptr = ptr
|
||||||
self.srid = g.srid
|
self._set_cs()
|
||||||
else:
|
|
||||||
pass
|
# Some coordinate transformations do not have an SRID associated
|
||||||
|
# with them; only set if one exists.
|
||||||
|
if g.srid: self.srid = g.srid
|
||||||
|
|
||||||
#### Topology Routines ####
|
#### Topology Routines ####
|
||||||
def _topology(self, gptr):
|
def _topology(self, gptr):
|
||||||
|
@ -5,7 +5,7 @@ from django.contrib.gis.geos.base import HAS_GDAL
|
|||||||
from django.contrib.gis.tests.geometries import *
|
from django.contrib.gis.tests.geometries import *
|
||||||
|
|
||||||
if HAS_NUMPY: from numpy import array
|
if HAS_NUMPY: from numpy import array
|
||||||
if HAS_GDAL: from django.contrib.gis.gdal import OGRGeometry, SpatialReference
|
if HAS_GDAL: from django.contrib.gis.gdal import OGRGeometry, SpatialReference, CoordTransform
|
||||||
|
|
||||||
class GEOSTest(unittest.TestCase):
|
class GEOSTest(unittest.TestCase):
|
||||||
|
|
||||||
@ -673,6 +673,25 @@ class GEOSTest(unittest.TestCase):
|
|||||||
self.assertNotEqual(poly._ptr, cpy1._ptr)
|
self.assertNotEqual(poly._ptr, cpy1._ptr)
|
||||||
self.assertNotEqual(poly._ptr, cpy2._ptr)
|
self.assertNotEqual(poly._ptr, cpy2._ptr)
|
||||||
|
|
||||||
|
def test23_transform(self):
|
||||||
|
"Testing `transform` method."
|
||||||
|
if not HAS_GDAL: return
|
||||||
|
orig = GEOSGeometry('POINT (-104.609 38.255)', 4326)
|
||||||
|
trans = GEOSGeometry('POINT (992385.4472045 481455.4944650)', 2774)
|
||||||
|
|
||||||
|
# Using a srid, a SpatialReference object, and a CoordTransform object
|
||||||
|
# for transformations.
|
||||||
|
t1, t2, t3 = orig.clone(), orig.clone(), orig.clone()
|
||||||
|
t1.transform(trans.srid)
|
||||||
|
t2.transform(SpatialReference('EPSG:2774'))
|
||||||
|
ct = CoordTransform(SpatialReference('WGS84'), SpatialReference(2774))
|
||||||
|
t3.transform(ct)
|
||||||
|
|
||||||
|
for p in (t1, t2, t3):
|
||||||
|
prec = 3
|
||||||
|
self.assertAlmostEqual(trans.x, p.x, prec)
|
||||||
|
self.assertAlmostEqual(trans.y, p.y, prec)
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
s = unittest.TestSuite()
|
s = unittest.TestSuite()
|
||||||
s.addTest(unittest.makeSuite(GEOSTest))
|
s.addTest(unittest.makeSuite(GEOSTest))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user