@@ -136,7 +136,7 @@ def test03_multipoints(self):
136
136
self .assertEqual (mgeom1 , mgeom3 )
137
137
self .assertEqual (mp .points , mgeom2 .tuple )
138
138
self .assertEqual (mp .n_p , mgeom2 .point_count )
139
-
139
+
140
140
def test04_linestring (self ):
141
141
"Testing LineString objects."
142
142
prev = OGRGeometry ('POINT(0 0)' )
@@ -172,7 +172,7 @@ def test05_multilinestring(self):
172
172
for ls in mlinestr :
173
173
self .assertEqual (2 , ls .geom_type )
174
174
self .assertEqual ('LINESTRING' , ls .geom_name )
175
- self .assertRaises (OGRIndexError , mlinestr .__getitem__ , len (mlinestr ))
175
+ self .assertRaises (OGRIndexError , mlinestr .__getitem__ , len (mlinestr ))
176
176
177
177
def test06_linearring (self ):
178
178
"Testing LinearRing objects."
@@ -190,7 +190,7 @@ def test07a_polygons(self):
190
190
"Testing Polygon objects."
191
191
192
192
# Testing `from_bbox` class method
193
- bbox = (- 180 ,- 90 ,180 ,90 )
193
+ bbox = (- 180 ,- 90 ,180 ,90 )
194
194
p = OGRGeometry .from_bbox ( bbox )
195
195
self .assertEqual (bbox , p .extent )
196
196
@@ -211,13 +211,13 @@ def test07a_polygons(self):
211
211
# Testing equivalence
212
212
self .assertEqual (True , poly == OGRGeometry (p .wkt ))
213
213
self .assertEqual (True , poly != prev )
214
-
214
+
215
215
if p .ext_ring_cs :
216
216
ring = poly [0 ]
217
217
self .assertEqual (p .ext_ring_cs , ring .tuple )
218
218
self .assertEqual (p .ext_ring_cs , poly [0 ].tuple )
219
219
self .assertEqual (len (p .ext_ring_cs ), ring .point_count )
220
-
220
+
221
221
for r in poly :
222
222
self .assertEqual ('LINEARRING' , r .geom_name )
223
223
@@ -269,11 +269,11 @@ def test09a_srs(self):
269
269
sr = SpatialReference ('WGS84' )
270
270
mpoly = OGRGeometry (mp .wkt , sr )
271
271
self .assertEqual (sr .wkt , mpoly .srs .wkt )
272
-
272
+
273
273
# Ensuring that SRS is propagated to clones.
274
274
klone = mpoly .clone ()
275
275
self .assertEqual (sr .wkt , klone .srs .wkt )
276
-
276
+
277
277
# Ensuring all children geometries (polygons and their rings) all
278
278
# return the assigned spatial reference as well.
279
279
for poly in mpoly :
@@ -295,7 +295,7 @@ def test09a_srs(self):
295
295
mpoly .srs = SpatialReference (4269 )
296
296
self .assertEqual (4269 , mpoly .srid )
297
297
self .assertEqual ('NAD83' , mpoly .srs .name )
298
-
298
+
299
299
# Incrementing through the multipolyogn after the spatial reference
300
300
# has been re-assigned.
301
301
for poly in mpoly :
@@ -341,7 +341,7 @@ def test09c_transform_dim(self):
341
341
"Testing coordinate dimension is the same on transformed geometries."
342
342
ls_orig = OGRGeometry ('LINESTRING(-104.609 38.255)' , 4326 )
343
343
ls_trans = OGRGeometry ('LINESTRING(992385.4472045 481455.4944650)' , 2774 )
344
-
344
+
345
345
prec = 3
346
346
ls_orig .transform (ls_trans .srs )
347
347
# Making sure the coordinate dimension is still 2D.
@@ -388,7 +388,7 @@ def test12_symdifference(self):
388
388
self .assertEqual (d1 , a ^ b ) # __xor__ is symmetric difference operator
389
389
a ^= b # testing __ixor__
390
390
self .assertEqual (d1 , a )
391
-
391
+
392
392
def test13_union (self ):
393
393
"Testing union()."
394
394
for i in xrange (len (topology_geoms )):
@@ -455,7 +455,31 @@ def test17_pickle(self):
455
455
self .assertEqual (g1 , g2 )
456
456
self .assertEqual (4326 , g2 .srs .srid )
457
457
self .assertEqual (g1 .srs .wkt , g2 .srs .wkt )
458
-
458
+
459
+ def test18_ogrgeometry_transform_workaround (self ):
460
+ "Testing coordinate dimensions on geometries after transformation."
461
+ # A bug in GDAL versions prior to 1.7 changes the coordinate
462
+ # dimension of a geometry after it has been transformed.
463
+ # This test ensures that the bug workarounds employed within
464
+ # `OGRGeometry.transform` indeed work.
465
+ wkt_2d = "MULTILINESTRING ((0 0,1 1,2 2))"
466
+ wkt_3d = "MULTILINESTRING ((0 0 0,1 1 1,2 2 2))"
467
+ srid = 4326
468
+
469
+ # For both the 2D and 3D MultiLineString, ensure _both_ the dimension
470
+ # of the collection and the component LineString have the expected
471
+ # coordinate dimension after transform.
472
+ geom = OGRGeometry (wkt_2d , srid )
473
+ geom .transform (srid )
474
+ self .assertEqual (2 , geom .coord_dim )
475
+ self .assertEqual (2 , geom [0 ].coord_dim )
476
+ self .assertEqual (wkt_2d , geom .wkt )
477
+
478
+ geom = OGRGeometry (wkt_3d , srid )
479
+ geom .transform (srid )
480
+ self .assertEqual (3 , geom .coord_dim )
481
+ self .assertEqual (3 , geom [0 ].coord_dim )
482
+ self .assertEqual (wkt_3d , geom .wkt )
459
483
460
484
def suite ():
461
485
s = unittest .TestSuite ()
0 commit comments