342 uchar abyHeader[100];
348 if (psSHP->fpSHX == NULL)
350 psSHP->sHooks.Error(
"SHPWriteHeader failed : SHX file is closed");
357 for( i = 0; i < 100; i++ )
363 i32 = psSHP->nFileSize/2;
371 i32 = psSHP->nShapeType;
375 dValue = psSHP->adBoundsMin[0];
376 ByteCopy( &dValue, abyHeader+36, 8 );
379 dValue = psSHP->adBoundsMin[1];
380 ByteCopy( &dValue, abyHeader+44, 8 );
383 dValue = psSHP->adBoundsMax[0];
384 ByteCopy( &dValue, abyHeader+52, 8 );
387 dValue = psSHP->adBoundsMax[1];
388 ByteCopy( &dValue, abyHeader+60, 8 );
391 dValue = psSHP->adBoundsMin[2];
392 ByteCopy( &dValue, abyHeader+68, 8 );
395 dValue = psSHP->adBoundsMax[2];
396 ByteCopy( &dValue, abyHeader+76, 8 );
399 dValue = psSHP->adBoundsMin[3];
400 ByteCopy( &dValue, abyHeader+84, 8 );
403 dValue = psSHP->adBoundsMax[3];
404 ByteCopy( &dValue, abyHeader+92, 8 );
410 if( psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 0 ) != 0
411 || psSHP->sHooks.FWrite( abyHeader, 100, 1, psSHP->fpSHP ) != 1 )
413 psSHP->sHooks.Error(
"Failure writing .shp header" );
420 i32 = (psSHP->nRecords * 2 *
sizeof(
int32) + 100)/2;
424 if( psSHP->sHooks.FSeek( psSHP->fpSHX, 0, 0 ) != 0
425 || psSHP->sHooks.FWrite( abyHeader, 100, 1, psSHP->fpSHX ) != 1 )
427 psSHP->sHooks.Error(
"Failure writing .shx header" );
436 for( i = 0; i < psSHP->nRecords; i++ )
438 panSHX[i*2 ] = psSHP->panRecOffset[i]/2;
439 panSHX[i*2+1] = psSHP->panRecSize[i]/2;
444 if( (
int)psSHP->sHooks.FWrite( panSHX,
sizeof(
int32)*2, psSHP->nRecords, psSHP->fpSHX )
447 psSHP->sHooks.Error(
"Failure writing .shx contents" );
455 psSHP->sHooks.FFlush( psSHP->fpSHP );
456 psSHP->sHooks.FFlush( psSHP->fpSHX );
static void SwapWord(int length, void *wordP)
#define ByteCopy(a, b, c)