@@ -1129,7 +1129,7 @@ def __shpRecord(self, s):
1129
1129
try :
1130
1130
f .write (pack ("<4d" , * self .__bbox (s )))
1131
1131
except error :
1132
- raise ShapefileException ("Failed to write bounding box for record %s. Expected floats." % recNum )
1132
+ raise ShapefileException ("Failed to write bounding box for record %s. Expected floats." % self . shpNum )
1133
1133
# Shape types with parts
1134
1134
if s .shapeType in (3 ,5 ,13 ,15 ,23 ,25 ,31 ):
1135
1135
# Number of parts
@@ -1151,14 +1151,14 @@ def __shpRecord(self, s):
1151
1151
try :
1152
1152
[f .write (pack ("<2d" , * p [:2 ])) for p in s .points ]
1153
1153
except error :
1154
- raise ShapefileException ("Failed to write points for record %s. Expected floats." % recNum )
1154
+ raise ShapefileException ("Failed to write points for record %s. Expected floats." % self . shpNum )
1155
1155
# Write z extremes and values
1156
1156
# Note: missing z values are autoset to 0, but not sure if this is ideal.
1157
1157
if s .shapeType in (13 ,15 ,18 ,31 ):
1158
1158
try :
1159
1159
f .write (pack ("<2d" , * self .__zbox (s )))
1160
1160
except error :
1161
- raise ShapefileException ("Failed to write elevation extremes for record %s. Expected floats." % recNum )
1161
+ raise ShapefileException ("Failed to write elevation extremes for record %s. Expected floats." % self . shpNum )
1162
1162
try :
1163
1163
if hasattr (s ,"z" ):
1164
1164
# if z values are stored in attribute
@@ -1167,15 +1167,15 @@ def __shpRecord(self, s):
1167
1167
# if z values are stored as 3rd dimension
1168
1168
[f .write (pack ("<d" , p [2 ] if len (p ) > 2 else 0 )) for p in s .points ]
1169
1169
except error :
1170
- raise ShapefileException ("Failed to write elevation values for record %s. Expected floats." % recNum )
1170
+ raise ShapefileException ("Failed to write elevation values for record %s. Expected floats." % self . shpNum )
1171
1171
# Write m extremes and values
1172
1172
# When reading a file, pyshp converts NODATA m values to None, so here we make sure to convert them back to NODATA
1173
1173
# Note: missing m values are autoset to NODATA.
1174
1174
if s .shapeType in (13 ,15 ,18 ,23 ,25 ,28 ,31 ):
1175
1175
try :
1176
1176
f .write (pack ("<2d" , * self .__mbox (s )))
1177
1177
except error :
1178
- raise ShapefileException ("Failed to write measure extremes for record %s. Expected floats" % recNum )
1178
+ raise ShapefileException ("Failed to write measure extremes for record %s. Expected floats" % self . shpNum )
1179
1179
try :
1180
1180
if hasattr (s ,"m" ):
1181
1181
# if m values are stored in attribute
@@ -1186,13 +1186,13 @@ def __shpRecord(self, s):
1186
1186
mpos = 3 if s .shapeType in (13 ,15 ,18 ,31 ) else 2
1187
1187
[f .write (pack ("<d" , p [mpos ] if len (p ) > mpos and p [mpos ] is not None else NODATA )) for p in s .points ]
1188
1188
except error :
1189
- raise ShapefileException ("Failed to write measure values for record %s. Expected floats" % recNum )
1189
+ raise ShapefileException ("Failed to write measure values for record %s. Expected floats" % self . shpNum )
1190
1190
# Write a single point
1191
1191
if s .shapeType in (1 ,11 ,21 ):
1192
1192
try :
1193
1193
f .write (pack ("<2d" , s .points [0 ][0 ], s .points [0 ][1 ]))
1194
1194
except error :
1195
- raise ShapefileException ("Failed to write point for record %s. Expected floats." % recNum )
1195
+ raise ShapefileException ("Failed to write point for record %s. Expected floats." % self . shpNum )
1196
1196
# Write a single Z value
1197
1197
# Note: missing z values are autoset to 0, but not sure if this is ideal.
1198
1198
if s .shapeType == 11 :
@@ -1206,15 +1206,15 @@ def __shpRecord(self, s):
1206
1206
s .z = (0 ,)
1207
1207
f .write (pack ("<d" , s .z [0 ]))
1208
1208
except error :
1209
- raise ShapefileException ("Failed to write elevation value for record %s. Expected floats." % recNum )
1209
+ raise ShapefileException ("Failed to write elevation value for record %s. Expected floats." % self . shpNum )
1210
1210
else :
1211
1211
# if z values are stored as 3rd dimension
1212
1212
try :
1213
1213
if len (s .points [0 ])< 3 :
1214
1214
s .points [0 ].append (0 )
1215
1215
f .write (pack ("<d" , s .points [0 ][2 ]))
1216
1216
except error :
1217
- raise ShapefileException ("Failed to write elevation value for record %s. Expected floats." % recNum )
1217
+ raise ShapefileException ("Failed to write elevation value for record %s. Expected floats." % self . shpNum )
1218
1218
# Write a single M value
1219
1219
# Note: missing m values are autoset to NODATA.
1220
1220
if s .shapeType in (11 ,21 ):
@@ -1228,7 +1228,7 @@ def __shpRecord(self, s):
1228
1228
s .m = (NODATA ,)
1229
1229
f .write (pack ("<1d" , s .m [0 ]))
1230
1230
except error :
1231
- raise ShapefileException ("Failed to write measure value for record %s. Expected floats." % recNum )
1231
+ raise ShapefileException ("Failed to write measure value for record %s. Expected floats." % self . shpNum )
1232
1232
else :
1233
1233
# if m values are stored as 3rd/4th dimension
1234
1234
# 0-index position of m value is 3 if z type (x,y,z,m), or 2 if m type (x,y,m)
@@ -1238,7 +1238,7 @@ def __shpRecord(self, s):
1238
1238
s .points [0 ].append (NODATA )
1239
1239
f .write (pack ("<1d" , s .points [0 ][mpos ]))
1240
1240
except error :
1241
- raise ShapefileException ("Failed to write measure value for record %s. Expected floats." % recNum )
1241
+ raise ShapefileException ("Failed to write measure value for record %s. Expected floats." % self . shpNum )
1242
1242
# Finalize record length as 16-bit words
1243
1243
finish = f .tell ()
1244
1244
length = (finish - start ) // 2
0 commit comments