1338 unsigned int nRecordSize=0;
1342 int bAppendToLastRecord =
FALSE;
1343 int bAppendToFile =
FALSE;
1360 || (
nShapeId >= 0 && nShapeId < psSHP->nRecords) );
1371 unsigned int* panRecOffsetNew;
1372 unsigned int* panRecSizeNew;
1393 + psObject->
nParts * 8 + 128));
1408 int32 nPoints, nParts;
1411 nParts = psObject->
nParts;
1418 ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
1419 ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
1428 for( i = 0; i < psObject->
nParts; i++ )
1439 memcpy( pabyRec + nRecordSize, psObject->
panPartType,
1441 for( i = 0; i < psObject->
nParts; i++ )
1451 for( i = 0; i < psObject->
nVertices; i++ )
1454 ByteCopy( psObject->
padfY + i, pabyRec + nRecordSize + 8, 8 );
1457 SwapWord( 8, pabyRec + nRecordSize );
1460 SwapWord( 8, pabyRec + nRecordSize + 8 );
1462 nRecordSize += 2 * 8;
1480 for( i = 0; i < psObject->
nVertices; i++ )
1508 for( i = 0; i < psObject->
nVertices; i++ )
1531 ByteCopy( &nPoints, pabyRec + 44, 4 );
1533 for( i = 0; i < psObject->
nVertices; i++ )
1536 ByteCopy( psObject->
padfY + i, pabyRec + 48 + i*16 + 8, 8 );
1542 nRecordSize = 48 + 16 * psObject->
nVertices;
1554 for( i = 0; i < psObject->
nVertices; i++ )
1574 for( i = 0; i < psObject->
nVertices; i++ )
1640 bAppendToLastRecord =
TRUE;
1644 if( psSHP->
nFileSize > UINT_MAX - nRecordSize)
1647 snprintf(
str,
sizeof(
str),
"Failed to write shape object. "
1648 "File size cannot reach %u + %u.",
1650 str[
sizeof(
str)-1] =
'\0';
1656 bAppendToFile =
TRUE;
1671 i32 = (nRecordSize-8)/2;
1691 char szErrorMsg[200];
1693 snprintf( szErrorMsg,
sizeof(szErrorMsg),
1694 "Error in psSHP->sHooks.FSeek() while writing object to .shp file: %s",
1696 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
1705 char szErrorMsg[200];
1707 snprintf( szErrorMsg,
sizeof(szErrorMsg),
1708 "Error in psSHP->sHooks.FWrite() while writing object of %u bytes to .shp file: %s",
1709 nRecordSize, strerror(errno) );
1710 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
1719 if( bAppendToLastRecord )
1723 else if( bAppendToFile )
1757 for( i = 0; i < psObject->
nVertices; i++ )
1763 if( psObject->
padfZ )
1768 if( psObject->
padfM )
#define DISABLE_MULTIPATCH_MEASURE
static void SwapWord(int length, void *wordP)
#define STATIC_CAST(type, x)
static void * SfRealloc(void *pMem, int nNewSize)
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