@@ -2314,16 +2314,17 @@ def __shpRecord(self, s):
23142314 f .write (pack ("<i" , len (s .points )))
23152315 # Write part indexes
23162316 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 ))
23192318 # Part types for Multipatch (31)
23202319 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 ))
23232321 # Write points for multiple-point records
23242322 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 ])
23252326 try :
2326- [ f .write (pack ("<2d" , * p [: 2 ])) for p in s . points ]
2327+ f .write (pack ("<%sd" % len ( x_ys ) , * x_ys ))
23272328 except error :
23282329 raise ShapefileException (
23292330 "Failed to write points for record %s. Expected floats."
@@ -2345,7 +2346,8 @@ def __shpRecord(self, s):
23452346 f .write (pack ("<%sd" % len (s .z ), * s .z ))
23462347 else :
23472348 # 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 ))
23492351 except error :
23502352 raise ShapefileException (
23512353 "Failed to write elevation values for record %s. Expected floats."
0 commit comments