test_geom.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. import json
  2. from binascii import b2a_hex
  3. try:
  4. from django.utils.six.moves import cPickle as pickle
  5. except ImportError:
  6. import pickle
  7. from django.contrib.gis.gdal import HAS_GDAL
  8. from django.contrib.gis.geometry.test_data import TestDataMixin
  9. from django.utils.six.moves import xrange
  10. from django.utils import unittest
  11. from django.utils.unittest import skipUnless
  12. if HAS_GDAL:
  13. from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType,
  14. OGRException, OGRIndexError, SpatialReference, CoordTransform,
  15. GDAL_VERSION)
  16. @skipUnless(HAS_GDAL, "GDAL is required")
  17. class OGRGeomTest(unittest.TestCase, TestDataMixin):
  18. "This tests the OGR Geometry."
  19. def test00a_geomtype(self):
  20. "Testing OGRGeomType object."
  21. # OGRGeomType should initialize on all these inputs.
  22. try:
  23. g = OGRGeomType(1)
  24. g = OGRGeomType(7)
  25. g = OGRGeomType('point')
  26. g = OGRGeomType('GeometrycollectioN')
  27. g = OGRGeomType('LINearrING')
  28. g = OGRGeomType('Unknown')
  29. except:
  30. self.fail('Could not create an OGRGeomType object!')
  31. # Should throw TypeError on this input
  32. self.assertRaises(OGRException, OGRGeomType, 23)
  33. self.assertRaises(OGRException, OGRGeomType, 'fooD')
  34. self.assertRaises(OGRException, OGRGeomType, 9)
  35. # Equivalence can take strings, ints, and other OGRGeomTypes
  36. self.assertEqual(True, OGRGeomType(1) == OGRGeomType(1))
  37. self.assertEqual(True, OGRGeomType(7) == 'GeometryCollection')
  38. self.assertEqual(True, OGRGeomType('point') == 'POINT')
  39. self.assertEqual(False, OGRGeomType('point') == 2)
  40. self.assertEqual(True, OGRGeomType('unknown') == 0)
  41. self.assertEqual(True, OGRGeomType(6) == 'MULtiPolyGON')
  42. self.assertEqual(False, OGRGeomType(1) != OGRGeomType('point'))
  43. self.assertEqual(True, OGRGeomType('POINT') != OGRGeomType(6))
  44. # Testing the Django field name equivalent property.
  45. self.assertEqual('PointField', OGRGeomType('Point').django)
  46. self.assertEqual('GeometryField', OGRGeomType('Unknown').django)
  47. self.assertEqual(None, OGRGeomType('none').django)
  48. # 'Geometry' initialization implies an unknown geometry type.
  49. gt = OGRGeomType('Geometry')
  50. self.assertEqual(0, gt.num)
  51. self.assertEqual('Unknown', gt.name)
  52. def test00b_geomtype_25d(self):
  53. "Testing OGRGeomType object with 25D types."
  54. wkb25bit = OGRGeomType.wkb25bit
  55. self.assertTrue(OGRGeomType(wkb25bit + 1) == 'Point25D')
  56. self.assertTrue(OGRGeomType('MultiLineString25D') == (5 + wkb25bit))
  57. self.assertEqual('GeometryCollectionField', OGRGeomType('GeometryCollection25D').django)
  58. def test01a_wkt(self):
  59. "Testing WKT output."
  60. for g in self.geometries.wkt_out:
  61. geom = OGRGeometry(g.wkt)
  62. self.assertEqual(g.wkt, geom.wkt)
  63. def test01a_ewkt(self):
  64. "Testing EWKT input/output."
  65. for ewkt_val in ('POINT (1 2 3)', 'LINEARRING (0 0,1 1,2 1,0 0)'):
  66. # First with ewkt output when no SRID in EWKT
  67. self.assertEqual(ewkt_val, OGRGeometry(ewkt_val).ewkt)
  68. # No test consumption with an SRID specified.
  69. ewkt_val = 'SRID=4326;%s' % ewkt_val
  70. geom = OGRGeometry(ewkt_val)
  71. self.assertEqual(ewkt_val, geom.ewkt)
  72. self.assertEqual(4326, geom.srs.srid)
  73. def test01b_gml(self):
  74. "Testing GML output."
  75. for g in self.geometries.wkt_out:
  76. geom = OGRGeometry(g.wkt)
  77. exp_gml = g.gml
  78. if GDAL_VERSION >= (1, 8):
  79. # In GDAL 1.8, the non-conformant GML tag <gml:GeometryCollection> was
  80. # replaced with <gml:MultiGeometry>.
  81. exp_gml = exp_gml.replace('GeometryCollection', 'MultiGeometry')
  82. self.assertEqual(exp_gml, geom.gml)
  83. def test01c_hex(self):
  84. "Testing HEX input/output."
  85. for g in self.geometries.hex_wkt:
  86. geom1 = OGRGeometry(g.wkt)
  87. self.assertEqual(g.hex.encode(), geom1.hex)
  88. # Constructing w/HEX
  89. geom2 = OGRGeometry(g.hex)
  90. self.assertEqual(geom1, geom2)
  91. def test01d_wkb(self):
  92. "Testing WKB input/output."
  93. for g in self.geometries.hex_wkt:
  94. geom1 = OGRGeometry(g.wkt)
  95. wkb = geom1.wkb
  96. self.assertEqual(b2a_hex(wkb).upper(), g.hex.encode())
  97. # Constructing w/WKB.
  98. geom2 = OGRGeometry(wkb)
  99. self.assertEqual(geom1, geom2)
  100. def test01e_json(self):
  101. "Testing GeoJSON input/output."
  102. for g in self.geometries.json_geoms:
  103. geom = OGRGeometry(g.wkt)
  104. if not hasattr(g, 'not_equal'):
  105. # Loading jsons to prevent decimal differences
  106. self.assertEqual(json.loads(g.json), json.loads(geom.json))
  107. self.assertEqual(json.loads(g.json), json.loads(geom.geojson))
  108. self.assertEqual(OGRGeometry(g.wkt), OGRGeometry(geom.json))
  109. def test02_points(self):
  110. "Testing Point objects."
  111. prev = OGRGeometry('POINT(0 0)')
  112. for p in self.geometries.points:
  113. if not hasattr(p, 'z'): # No 3D
  114. pnt = OGRGeometry(p.wkt)
  115. self.assertEqual(1, pnt.geom_type)
  116. self.assertEqual('POINT', pnt.geom_name)
  117. self.assertEqual(p.x, pnt.x)
  118. self.assertEqual(p.y, pnt.y)
  119. self.assertEqual((p.x, p.y), pnt.tuple)
  120. def test03_multipoints(self):
  121. "Testing MultiPoint objects."
  122. for mp in self.geometries.multipoints:
  123. mgeom1 = OGRGeometry(mp.wkt) # First one from WKT
  124. self.assertEqual(4, mgeom1.geom_type)
  125. self.assertEqual('MULTIPOINT', mgeom1.geom_name)
  126. mgeom2 = OGRGeometry('MULTIPOINT') # Creating empty multipoint
  127. mgeom3 = OGRGeometry('MULTIPOINT')
  128. for g in mgeom1:
  129. mgeom2.add(g) # adding each point from the multipoints
  130. mgeom3.add(g.wkt) # should take WKT as well
  131. self.assertEqual(mgeom1, mgeom2) # they should equal
  132. self.assertEqual(mgeom1, mgeom3)
  133. self.assertEqual(mp.coords, mgeom2.coords)
  134. self.assertEqual(mp.n_p, mgeom2.point_count)
  135. def test04_linestring(self):
  136. "Testing LineString objects."
  137. prev = OGRGeometry('POINT(0 0)')
  138. for ls in self.geometries.linestrings:
  139. linestr = OGRGeometry(ls.wkt)
  140. self.assertEqual(2, linestr.geom_type)
  141. self.assertEqual('LINESTRING', linestr.geom_name)
  142. self.assertEqual(ls.n_p, linestr.point_count)
  143. self.assertEqual(ls.coords, linestr.tuple)
  144. self.assertEqual(True, linestr == OGRGeometry(ls.wkt))
  145. self.assertEqual(True, linestr != prev)
  146. self.assertRaises(OGRIndexError, linestr.__getitem__, len(linestr))
  147. prev = linestr
  148. # Testing the x, y properties.
  149. x = [tmpx for tmpx, tmpy in ls.coords]
  150. y = [tmpy for tmpx, tmpy in ls.coords]
  151. self.assertEqual(x, linestr.x)
  152. self.assertEqual(y, linestr.y)
  153. def test05_multilinestring(self):
  154. "Testing MultiLineString objects."
  155. prev = OGRGeometry('POINT(0 0)')
  156. for mls in self.geometries.multilinestrings:
  157. mlinestr = OGRGeometry(mls.wkt)
  158. self.assertEqual(5, mlinestr.geom_type)
  159. self.assertEqual('MULTILINESTRING', mlinestr.geom_name)
  160. self.assertEqual(mls.n_p, mlinestr.point_count)
  161. self.assertEqual(mls.coords, mlinestr.tuple)
  162. self.assertEqual(True, mlinestr == OGRGeometry(mls.wkt))
  163. self.assertEqual(True, mlinestr != prev)
  164. prev = mlinestr
  165. for ls in mlinestr:
  166. self.assertEqual(2, ls.geom_type)
  167. self.assertEqual('LINESTRING', ls.geom_name)
  168. self.assertRaises(OGRIndexError, mlinestr.__getitem__, len(mlinestr))
  169. def test06_linearring(self):
  170. "Testing LinearRing objects."
  171. prev = OGRGeometry('POINT(0 0)')
  172. for rr in self.geometries.linearrings:
  173. lr = OGRGeometry(rr.wkt)
  174. #self.assertEqual(101, lr.geom_type.num)
  175. self.assertEqual('LINEARRING', lr.geom_name)
  176. self.assertEqual(rr.n_p, len(lr))
  177. self.assertEqual(True, lr == OGRGeometry(rr.wkt))
  178. self.assertEqual(True, lr != prev)
  179. prev = lr
  180. def test07a_polygons(self):
  181. "Testing Polygon objects."
  182. # Testing `from_bbox` class method
  183. bbox = (-180,-90,180,90)
  184. p = OGRGeometry.from_bbox( bbox )
  185. self.assertEqual(bbox, p.extent)
  186. prev = OGRGeometry('POINT(0 0)')
  187. for p in self.geometries.polygons:
  188. poly = OGRGeometry(p.wkt)
  189. self.assertEqual(3, poly.geom_type)
  190. self.assertEqual('POLYGON', poly.geom_name)
  191. self.assertEqual(p.n_p, poly.point_count)
  192. self.assertEqual(p.n_i + 1, len(poly))
  193. # Testing area & centroid.
  194. self.assertAlmostEqual(p.area, poly.area, 9)
  195. x, y = poly.centroid.tuple
  196. self.assertAlmostEqual(p.centroid[0], x, 9)
  197. self.assertAlmostEqual(p.centroid[1], y, 9)
  198. # Testing equivalence
  199. self.assertEqual(True, poly == OGRGeometry(p.wkt))
  200. self.assertEqual(True, poly != prev)
  201. if p.ext_ring_cs:
  202. ring = poly[0]
  203. self.assertEqual(p.ext_ring_cs, ring.tuple)
  204. self.assertEqual(p.ext_ring_cs, poly[0].tuple)
  205. self.assertEqual(len(p.ext_ring_cs), ring.point_count)
  206. for r in poly:
  207. self.assertEqual('LINEARRING', r.geom_name)
  208. def test07b_closepolygons(self):
  209. "Testing closing Polygon objects."
  210. # Both rings in this geometry are not closed.
  211. poly = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5), (1 1, 2 1, 2 2, 2 1))')
  212. self.assertEqual(8, poly.point_count)
  213. with self.assertRaises(OGRException):
  214. _ = poly.centroid
  215. poly.close_rings()
  216. self.assertEqual(10, poly.point_count) # Two closing points should've been added
  217. self.assertEqual(OGRGeometry('POINT(2.5 2.5)'), poly.centroid)
  218. def test08_multipolygons(self):
  219. "Testing MultiPolygon objects."
  220. prev = OGRGeometry('POINT(0 0)')
  221. for mp in self.geometries.multipolygons:
  222. mpoly = OGRGeometry(mp.wkt)
  223. self.assertEqual(6, mpoly.geom_type)
  224. self.assertEqual('MULTIPOLYGON', mpoly.geom_name)
  225. if mp.valid:
  226. self.assertEqual(mp.n_p, mpoly.point_count)
  227. self.assertEqual(mp.num_geom, len(mpoly))
  228. self.assertRaises(OGRIndexError, mpoly.__getitem__, len(mpoly))
  229. for p in mpoly:
  230. self.assertEqual('POLYGON', p.geom_name)
  231. self.assertEqual(3, p.geom_type)
  232. self.assertEqual(mpoly.wkt, OGRGeometry(mp.wkt).wkt)
  233. def test09a_srs(self):
  234. "Testing OGR Geometries with Spatial Reference objects."
  235. for mp in self.geometries.multipolygons:
  236. # Creating a geometry w/spatial reference
  237. sr = SpatialReference('WGS84')
  238. mpoly = OGRGeometry(mp.wkt, sr)
  239. self.assertEqual(sr.wkt, mpoly.srs.wkt)
  240. # Ensuring that SRS is propagated to clones.
  241. klone = mpoly.clone()
  242. self.assertEqual(sr.wkt, klone.srs.wkt)
  243. # Ensuring all children geometries (polygons and their rings) all
  244. # return the assigned spatial reference as well.
  245. for poly in mpoly:
  246. self.assertEqual(sr.wkt, poly.srs.wkt)
  247. for ring in poly:
  248. self.assertEqual(sr.wkt, ring.srs.wkt)
  249. # Ensuring SRS propagate in topological ops.
  250. a = OGRGeometry(self.geometries.topology_geoms[0].wkt_a, sr)
  251. b = OGRGeometry(self.geometries.topology_geoms[0].wkt_b, sr)
  252. diff = a.difference(b)
  253. union = a.union(b)
  254. self.assertEqual(sr.wkt, diff.srs.wkt)
  255. self.assertEqual(sr.srid, union.srs.srid)
  256. # Instantiating w/an integer SRID
  257. mpoly = OGRGeometry(mp.wkt, 4326)
  258. self.assertEqual(4326, mpoly.srid)
  259. mpoly.srs = SpatialReference(4269)
  260. self.assertEqual(4269, mpoly.srid)
  261. self.assertEqual('NAD83', mpoly.srs.name)
  262. # Incrementing through the multipolyogn after the spatial reference
  263. # has been re-assigned.
  264. for poly in mpoly:
  265. self.assertEqual(mpoly.srs.wkt, poly.srs.wkt)
  266. poly.srs = 32140
  267. for ring in poly:
  268. # Changing each ring in the polygon
  269. self.assertEqual(32140, ring.srs.srid)
  270. self.assertEqual('NAD83 / Texas South Central', ring.srs.name)
  271. ring.srs = str(SpatialReference(4326)) # back to WGS84
  272. self.assertEqual(4326, ring.srs.srid)
  273. # Using the `srid` property.
  274. ring.srid = 4322
  275. self.assertEqual('WGS 72', ring.srs.name)
  276. self.assertEqual(4322, ring.srid)
  277. def test09b_srs_transform(self):
  278. "Testing transform()."
  279. orig = OGRGeometry('POINT (-104.609 38.255)', 4326)
  280. trans = OGRGeometry('POINT (992385.4472045 481455.4944650)', 2774)
  281. # Using an srid, a SpatialReference object, and a CoordTransform object
  282. # or transformations.
  283. t1, t2, t3 = orig.clone(), orig.clone(), orig.clone()
  284. t1.transform(trans.srid)
  285. t2.transform(SpatialReference('EPSG:2774'))
  286. ct = CoordTransform(SpatialReference('WGS84'), SpatialReference(2774))
  287. t3.transform(ct)
  288. # Testing use of the `clone` keyword.
  289. k1 = orig.clone()
  290. k2 = k1.transform(trans.srid, clone=True)
  291. self.assertEqual(k1, orig)
  292. self.assertNotEqual(k1, k2)
  293. prec = 3
  294. for p in (t1, t2, t3, k2):
  295. self.assertAlmostEqual(trans.x, p.x, prec)
  296. self.assertAlmostEqual(trans.y, p.y, prec)
  297. def test09c_transform_dim(self):
  298. "Testing coordinate dimension is the same on transformed geometries."
  299. ls_orig = OGRGeometry('LINESTRING(-104.609 38.255)', 4326)
  300. ls_trans = OGRGeometry('LINESTRING(992385.4472045 481455.4944650)', 2774)
  301. prec = 3
  302. ls_orig.transform(ls_trans.srs)
  303. # Making sure the coordinate dimension is still 2D.
  304. self.assertEqual(2, ls_orig.coord_dim)
  305. self.assertAlmostEqual(ls_trans.x[0], ls_orig.x[0], prec)
  306. self.assertAlmostEqual(ls_trans.y[0], ls_orig.y[0], prec)
  307. def test10_difference(self):
  308. "Testing difference()."
  309. for i in xrange(len(self.geometries.topology_geoms)):
  310. a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
  311. b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
  312. d1 = OGRGeometry(self.geometries.diff_geoms[i].wkt)
  313. d2 = a.difference(b)
  314. self.assertEqual(d1, d2)
  315. self.assertEqual(d1, a - b) # __sub__ is difference operator
  316. a -= b # testing __isub__
  317. self.assertEqual(d1, a)
  318. def test11_intersection(self):
  319. "Testing intersects() and intersection()."
  320. for i in xrange(len(self.geometries.topology_geoms)):
  321. a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
  322. b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
  323. i1 = OGRGeometry(self.geometries.intersect_geoms[i].wkt)
  324. self.assertEqual(True, a.intersects(b))
  325. i2 = a.intersection(b)
  326. self.assertEqual(i1, i2)
  327. self.assertEqual(i1, a & b) # __and__ is intersection operator
  328. a &= b # testing __iand__
  329. self.assertEqual(i1, a)
  330. def test12_symdifference(self):
  331. "Testing sym_difference()."
  332. for i in xrange(len(self.geometries.topology_geoms)):
  333. a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
  334. b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
  335. d1 = OGRGeometry(self.geometries.sdiff_geoms[i].wkt)
  336. d2 = a.sym_difference(b)
  337. self.assertEqual(d1, d2)
  338. self.assertEqual(d1, a ^ b) # __xor__ is symmetric difference operator
  339. a ^= b # testing __ixor__
  340. self.assertEqual(d1, a)
  341. def test13_union(self):
  342. "Testing union()."
  343. for i in xrange(len(self.geometries.topology_geoms)):
  344. a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
  345. b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
  346. u1 = OGRGeometry(self.geometries.union_geoms[i].wkt)
  347. u2 = a.union(b)
  348. self.assertEqual(u1, u2)
  349. self.assertEqual(u1, a | b) # __or__ is union operator
  350. a |= b # testing __ior__
  351. self.assertEqual(u1, a)
  352. def test14_add(self):
  353. "Testing GeometryCollection.add()."
  354. # Can't insert a Point into a MultiPolygon.
  355. mp = OGRGeometry('MultiPolygon')
  356. pnt = OGRGeometry('POINT(5 23)')
  357. self.assertRaises(OGRException, mp.add, pnt)
  358. # GeometryCollection.add may take an OGRGeometry (if another collection
  359. # of the same type all child geoms will be added individually) or WKT.
  360. for mp in self.geometries.multipolygons:
  361. mpoly = OGRGeometry(mp.wkt)
  362. mp1 = OGRGeometry('MultiPolygon')
  363. mp2 = OGRGeometry('MultiPolygon')
  364. mp3 = OGRGeometry('MultiPolygon')
  365. for poly in mpoly:
  366. mp1.add(poly) # Adding a geometry at a time
  367. mp2.add(poly.wkt) # Adding WKT
  368. mp3.add(mpoly) # Adding a MultiPolygon's entire contents at once.
  369. for tmp in (mp1, mp2, mp3): self.assertEqual(mpoly, tmp)
  370. def test15_extent(self):
  371. "Testing `extent` property."
  372. # The xmin, ymin, xmax, ymax of the MultiPoint should be returned.
  373. mp = OGRGeometry('MULTIPOINT(5 23, 0 0, 10 50)')
  374. self.assertEqual((0.0, 0.0, 10.0, 50.0), mp.extent)
  375. # Testing on the 'real world' Polygon.
  376. poly = OGRGeometry(self.geometries.polygons[3].wkt)
  377. ring = poly.shell
  378. x, y = ring.x, ring.y
  379. xmin, ymin = min(x), min(y)
  380. xmax, ymax = max(x), max(y)
  381. self.assertEqual((xmin, ymin, xmax, ymax), poly.extent)
  382. def test16_25D(self):
  383. "Testing 2.5D geometries."
  384. pnt_25d = OGRGeometry('POINT(1 2 3)')
  385. self.assertEqual('Point25D', pnt_25d.geom_type.name)
  386. self.assertEqual(3.0, pnt_25d.z)
  387. self.assertEqual(3, pnt_25d.coord_dim)
  388. ls_25d = OGRGeometry('LINESTRING(1 1 1,2 2 2,3 3 3)')
  389. self.assertEqual('LineString25D', ls_25d.geom_type.name)
  390. self.assertEqual([1.0, 2.0, 3.0], ls_25d.z)
  391. self.assertEqual(3, ls_25d.coord_dim)
  392. def test17_pickle(self):
  393. "Testing pickle support."
  394. g1 = OGRGeometry('LINESTRING(1 1 1,2 2 2,3 3 3)', 'WGS84')
  395. g2 = pickle.loads(pickle.dumps(g1))
  396. self.assertEqual(g1, g2)
  397. self.assertEqual(4326, g2.srs.srid)
  398. self.assertEqual(g1.srs.wkt, g2.srs.wkt)
  399. def test18_ogrgeometry_transform_workaround(self):
  400. "Testing coordinate dimensions on geometries after transformation."
  401. # A bug in GDAL versions prior to 1.7 changes the coordinate
  402. # dimension of a geometry after it has been transformed.
  403. # This test ensures that the bug workarounds employed within
  404. # `OGRGeometry.transform` indeed work.
  405. wkt_2d = "MULTILINESTRING ((0 0,1 1,2 2))"
  406. wkt_3d = "MULTILINESTRING ((0 0 0,1 1 1,2 2 2))"
  407. srid = 4326
  408. # For both the 2D and 3D MultiLineString, ensure _both_ the dimension
  409. # of the collection and the component LineString have the expected
  410. # coordinate dimension after transform.
  411. geom = OGRGeometry(wkt_2d, srid)
  412. geom.transform(srid)
  413. self.assertEqual(2, geom.coord_dim)
  414. self.assertEqual(2, geom[0].coord_dim)
  415. self.assertEqual(wkt_2d, geom.wkt)
  416. geom = OGRGeometry(wkt_3d, srid)
  417. geom.transform(srid)
  418. self.assertEqual(3, geom.coord_dim)
  419. self.assertEqual(3, geom[0].coord_dim)
  420. self.assertEqual(wkt_3d, geom.wkt)
  421. def test19_equivalence_regression(self):
  422. "Testing equivalence methods with non-OGRGeometry instances."
  423. self.assertNotEqual(None, OGRGeometry('POINT(0 0)'))
  424. self.assertEqual(False, OGRGeometry('LINESTRING(0 0, 1 1)') == 3)