@@ -2314,16 +2314,17 @@ def __shpRecord(self, s):
2314
2314
f .write (pack ("<i" , len (s .points )))
2315
2315
# Write part indexes
2316
2316
if s .shapeType in (3 , 5 , 13 , 15 , 23 , 25 , 31 ):
2317
- for p in s .parts :
2318
- f .write (pack ("<i" , p ))
2317
+ f .write (pack ("<%si" % len (s .parts ), * s .parts ))
2319
2318
# Part types for Multipatch (31)
2320
2319
if s .shapeType == 31 :
2321
- for pt in s .partTypes :
2322
- f .write (pack ("<i" , pt ))
2320
+ f .write (pack ("<%si" % len (s .partTypes ), * s .partTypes ))
2323
2321
# Write points for multiple-point records
2324
2322
if s .shapeType in (3 , 5 , 8 , 13 , 15 , 18 , 23 , 25 , 28 , 31 ):
2323
+ x_ys = []
2324
+ for point in s .points :
2325
+ x_ys .extend (point [:2 ])
2325
2326
try :
2326
- [ f .write (pack ("<2d" , * p [: 2 ])) for p in s . points ]
2327
+ f .write (pack ("<%sd" % len ( x_ys ) , * x_ys ))
2327
2328
except error :
2328
2329
raise ShapefileException (
2329
2330
"Failed to write points for record %s. Expected floats."
@@ -2345,7 +2346,8 @@ def __shpRecord(self, s):
2345
2346
f .write (pack ("<%sd" % len (s .z ), * s .z ))
2346
2347
else :
2347
2348
# if z values are stored as 3rd dimension
2348
- [f .write (pack ("<d" , p [2 ] if len (p ) > 2 else 0 )) for p in s .points ]
2349
+ zs = [p [2 ] if len (p ) > 2 else 0 for p in s .points ]
2350
+ f .write (pack ("<%sd" % len (zs ), * zs ))
2349
2351
except error :
2350
2352
raise ShapefileException (
2351
2353
"Failed to write elevation values for record %s. Expected floats."
0 commit comments