test_geom.py 20 KB

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