1172{
1173 unsigned int nRecordOffset, nRecordSize=0;
1174 int i;
1177
1179
1180
1181
1182
1183
1186
1187
1188
1189
1190
1191
1193 || (
nShapeId >= 0 && nShapeId < psSHP->nRecords) );
1194
1197
1198
1199
1200
1202 {
1204
1209 }
1210
1211
1212
1213
1215 + psObject->
nParts * 8 + 128);
1216
1217
1218
1219
1227 {
1228 int32 nPoints, nParts;
1229 int i;
1230
1232 nParts = psObject->
nParts;
1233
1235
1238
1239 ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
1240 ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
1241
1242 nRecordSize = 52;
1243
1244
1245
1246
1249 for( i = 0; i < psObject->
nParts; i++ )
1250 {
1252 nRecordSize += 4;
1253 }
1254
1255
1256
1257
1259 {
1260 memcpy( pabyRec + nRecordSize, psObject->
panPartType,
1262 for( i = 0; i < psObject->
nParts; i++ )
1263 {
1265 nRecordSize += 4;
1266 }
1267 }
1268
1269
1270
1271
1272 for( i = 0; i < psObject->
nVertices; i++ )
1273 {
1275 ByteCopy( psObject->
padfY + i, pabyRec + nRecordSize + 8, 8 );
1276
1278 SwapWord( 8, pabyRec + nRecordSize );
1279
1281 SwapWord( 8, pabyRec + nRecordSize + 8 );
1282
1283 nRecordSize += 2 * 8;
1284 }
1285
1286
1287
1288
1292 {
1295 nRecordSize += 8;
1296
1299 nRecordSize += 8;
1300
1301 for( i = 0; i < psObject->
nVertices; i++ )
1302 {
1305 nRecordSize += 8;
1306 }
1307 }
1308
1309
1310
1311
1317#endif
1320 {
1323 nRecordSize += 8;
1324
1327 nRecordSize += 8;
1328
1329 for( i = 0; i < psObject->
nVertices; i++ )
1330 {
1333 nRecordSize += 8;
1334 }
1335 }
1336 }
1337
1338
1339
1340
1344 {
1346 int i;
1347
1349
1351
1353 ByteCopy( &nPoints, pabyRec + 44, 4 );
1354
1355 for( i = 0; i < psObject->
nVertices; i++ )
1356 {
1358 ByteCopy( psObject->
padfY + i, pabyRec + 48 + i*16 + 8, 8 );
1359
1362 }
1363
1364 nRecordSize = 48 + 16 * psObject->
nVertices;
1365
1367 {
1370 nRecordSize += 8;
1371
1374 nRecordSize += 8;
1375
1376 for( i = 0; i < psObject->
nVertices; i++ )
1377 {
1380 nRecordSize += 8;
1381 }
1382 }
1383
1387 {
1390 nRecordSize += 8;
1391
1394 nRecordSize += 8;
1395
1396 for( i = 0; i < psObject->
nVertices; i++ )
1397 {
1400 nRecordSize += 8;
1401 }
1402 }
1403 }
1404
1405
1406
1407
1411 {
1414
1417
1418 nRecordSize = 28;
1419
1421 {
1424 nRecordSize += 8;
1425 }
1426
1430 {
1433 nRecordSize += 8;
1434 }
1435 }
1436
1437
1438
1439
1441 {
1442 nRecordSize = 12;
1443 }
1444
1445 else
1446 {
1447
1449 }
1450
1451
1452
1453
1454
1455
1457 {
1458 unsigned int nExpectedSize = psSHP->
nFileSize + nRecordSize;
1459 if( nExpectedSize < psSHP->nFileSize )
1460 {
1462 sprintf(
str,
"Failed to write shape object. "
1463 "File size cannot reach %u + %u.",
1467 return -1;
1468 }
1469
1472
1476 }
1477 else
1478 {
1481 }
1482
1483
1484
1485
1489
1490 i32 = (nRecordSize-8)/2;
1493
1497
1498
1499
1500
1502 {
1503 psSHP->
sHooks.
Error(
"Error in psSHP->sHooks.FSeek() while writing object to .shp file." );
1505 return -1;
1506 }
1508 {
1509 psSHP->
sHooks.
Error(
"Error in psSHP->sHooks.Fwrite() while writing object to .shp file." );
1511 return -1;
1512 }
1513
1515
1516
1517
1518
1523 {
1525 {
1530 }
1531 else
1532 {
1537 }
1538 }
1539
1540 for( i = 0; i < psObject->
nVertices; i++ )
1541 {
1550 }
1551
1553}
#define DISABLE_MULTIPATCH_MEASURE
static void * SfRealloc(void *pMem, int nNewSize)
static void SwapWord(int length, void *wordP)
static void _SHPSetBounds(uchar *pabyRec, SHPObject *psShape)
#define ByteCopy(a, b, c)
void(* Error)(const char *message)
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset(* FSeek)(SAFile file, SAOffset offset, int whence)
unsigned int * panRecSize
unsigned int * panRecOffset