1340 unsigned int nRecordSize=0;
1344 int bAppendToLastRecord =
FALSE;
1345 int bAppendToFile =
FALSE;
1362 || (
nShapeId >= 0 && nShapeId < psSHP->nRecords) );
1373 unsigned int* panRecOffsetNew;
1374 unsigned int* panRecSizeNew;
1395 + psObject->
nParts * 8 + 128));
1410 int32 nPoints, nParts;
1413 nParts = psObject->
nParts;
1420 ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
1421 ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
1430 for( i = 0; i < psObject->
nParts; i++ )
1441 memcpy( pabyRec + nRecordSize, psObject->
panPartType,
1443 for( i = 0; i < psObject->
nParts; i++ )
1453 for( i = 0; i < psObject->
nVertices; i++ )
1456 ByteCopy( psObject->
padfY + i, pabyRec + nRecordSize + 8, 8 );
1459 SwapWord( 8, pabyRec + nRecordSize );
1462 SwapWord( 8, pabyRec + nRecordSize + 8 );
1464 nRecordSize += 2 * 8;
1482 for( i = 0; i < psObject->
nVertices; i++ )
1510 for( i = 0; i < psObject->
nVertices; i++ )
1533 ByteCopy( &nPoints, pabyRec + 44, 4 );
1535 for( i = 0; i < psObject->
nVertices; i++ )
1538 ByteCopy( psObject->
padfY + i, pabyRec + 48 + i*16 + 8, 8 );
1544 nRecordSize = 48 + 16 * psObject->
nVertices;
1556 for( i = 0; i < psObject->
nVertices; i++ )
1576 for( i = 0; i < psObject->
nVertices; i++ )
1642 bAppendToLastRecord =
TRUE;
1646 if( psSHP->
nFileSize > UINT_MAX - nRecordSize)
1649 snprintf(
str,
sizeof(
str),
"Failed to write shape object. "
1650 "File size cannot reach %u + %u.",
1652 str[
sizeof(
str)-1] =
'\0';
1658 bAppendToFile =
TRUE;
1673 i32 = (nRecordSize-8)/2;
1693 char szErrorMsg[200];
1695 snprintf( szErrorMsg,
sizeof(szErrorMsg),
1696 "Error in psSHP->sHooks.FSeek() while writing object to .shp file: %s",
1698 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
1707 char szErrorMsg[200];
1709 snprintf( szErrorMsg,
sizeof(szErrorMsg),
1710 "Error in psSHP->sHooks.FWrite() while writing object of %u bytes to .shp file: %s",
1711 nRecordSize, strerror(errno) );
1712 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
1721 if( bAppendToLastRecord )
1725 else if( bAppendToFile )
1759 for( i = 0; i < psObject->
nVertices; i++ )
1765 if( psObject->
padfZ )
1770 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