Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.1.X] Fixed #13256 -- `OGRGeometry` no longer raises an exception w…

…hen 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
  • Loading branch information...
commit adfeb962273a9c0f918a3078e1612c6ac95f3cd6 1 parent 3305245
Justin Bronn jbronn authored
7 django/contrib/gis/gdal/geometries.py
View
@@ -163,11 +163,14 @@ def __xor__(self, other):
def __eq__(self, other):
"Is this Geometry equal to the other?"
- return self.equals(other)
+ if isinstance(other, OGRGeometry):
+ return self.equals(other)
+ else:
+ return False
def __ne__(self, other):
"Tests for inequality."
- return not self.equals(other)
+ return not (self == other)
def __str__(self):
"WKT is used for the string representation."
5 django/contrib/gis/gdal/tests/test_geom.py
View
@@ -461,6 +461,11 @@ def test18_ogrgeometry_transform_workaround(self):
self.assertEqual(3, geom[0].coord_dim)
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():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(OGRGeomTest))
Please sign in to comment.
Something went wrong with that request. Please try again.