[1.1.X] Fixed #13256 -- OGRGeometry
no longer raises an exception when compared to instances of different types. Thanks, ninowalker for the bug report.
Backport of r12905 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
33052458c5
commit
adfeb96227
@ -163,11 +163,14 @@ class OGRGeometry(GDALBase):
|
|||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"Is this Geometry equal to the other?"
|
"Is this Geometry equal to the other?"
|
||||||
|
if isinstance(other, OGRGeometry):
|
||||||
return self.equals(other)
|
return self.equals(other)
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"Tests for inequality."
|
"Tests for inequality."
|
||||||
return not self.equals(other)
|
return not (self == other)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"WKT is used for the string representation."
|
"WKT is used for the string representation."
|
||||||
|
@ -461,6 +461,11 @@ class OGRGeomTest(unittest.TestCase):
|
|||||||
self.assertEqual(3, geom[0].coord_dim)
|
self.assertEqual(3, geom[0].coord_dim)
|
||||||
self.assertEqual(wkt_3d, geom.wkt)
|
self.assertEqual(wkt_3d, geom.wkt)
|
||||||
|
|
||||||
|
def test19_equivalence_regression(self):
|
||||||
|
"Testing equivalence methods with non-OGRGeometry instances."
|
||||||
|
self.assertNotEqual(None, OGRGeometry('POINT(0 0)'))
|
||||||
|
self.assertEqual(False, OGRGeometry('LINESTRING(0 0, 1 1)') == 3)
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
s = unittest.TestSuite()
|
s = unittest.TestSuite()
|
||||||
s.addTest(unittest.makeSuite(OGRGeomTest))
|
s.addTest(unittest.makeSuite(OGRGeomTest))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user