270 #if UINT_MAX == 65535
271 typedef unsigned long int32;
281 #define ByteCopy( a, b, c ) memcpy( b, a, c )
283 # define MIN(a,b) ((a<b) ? a : b)
284 # define MAX(a,b) ((a>b) ? a : b)
287 #if defined(WIN32) || defined(_WIN32)
289 # define snprintf _snprintf
308 for( i=0; i < length/2; i++ )
310 temp = ((
uchar *) wordP)[i];
311 ((
uchar *)wordP)[i] = ((
uchar *) wordP)[length-i-1];
312 ((
uchar *) wordP)[length-i-1] = temp;
327 return( (
void *)
malloc(nNewSize) );
329 return( (
void *) realloc(pMem,nNewSize) );
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++ )
376 ByteCopy( &dValue, abyHeader+36, 8 );
380 ByteCopy( &dValue, abyHeader+44, 8 );
384 ByteCopy( &dValue, abyHeader+52, 8 );
388 ByteCopy( &dValue, abyHeader+60, 8 );
392 ByteCopy( &dValue, abyHeader+68, 8 );
396 ByteCopy( &dValue, abyHeader+76, 8 );
400 ByteCopy( &dValue, abyHeader+84, 8 );
404 ByteCopy( &dValue, abyHeader+92, 8 );
413 psSHP->
sHooks.
Error(
"Failure writing .shp header" );
427 psSHP->
sHooks.
Error(
"Failure writing .shx header" );
436 for( i = 0; i < psSHP->
nRecords; i++ )
447 psSHP->
sHooks.
Error(
"Failure writing .shx contents" );
464 SHPOpen(
const char * pszLayer,
const char * pszAccess )
471 return SHPOpenLL( pszLayer, pszAccess, &sHooks );
485 char *pszFullname, *pszBasename;
497 if( strcmp(pszAccess,
"rb+") == 0 || strcmp(pszAccess,
"r+b") == 0
498 || strcmp(pszAccess,
"r+") == 0 )
507 if( *((
uchar *) &i) == 1 )
524 pszBasename = (
char *)
malloc(strlen(pszLayer)+5);
525 strcpy( pszBasename, pszLayer );
526 for( i = strlen(pszBasename)-1;
527 i > 0 && pszBasename[i] !=
'.' && pszBasename[i] !=
'/'
528 && pszBasename[i] !=
'\\';
531 if( pszBasename[i] ==
'.' )
532 pszBasename[i] =
'\0';
538 pszFullname = (
char *)
malloc(strlen(pszBasename) + 5);
539 sprintf( pszFullname,
"%s.shp", pszBasename ) ;
541 if( psSHP->
fpSHP == NULL )
543 sprintf( pszFullname,
"%s.SHP", pszBasename );
547 if( psSHP->
fpSHP == NULL )
549 char *pszMessage = (
char *)
malloc(strlen(pszBasename)*2+256);
550 sprintf( pszMessage,
"Unable to open %s.shp or %s.SHP.",
551 pszBasename, pszBasename );
552 psHooks->
Error( pszMessage );
560 sprintf( pszFullname,
"%s.shx", pszBasename );
562 if( psSHP->
fpSHX == NULL )
564 sprintf( pszFullname,
"%s.SHX", pszBasename );
568 if( psSHP->
fpSHX == NULL )
570 char *pszMessage = (
char *)
malloc(strlen(pszBasename)*2+256);
571 sprintf( pszMessage,
"Unable to open %s.shx or %s.SHX.",
572 pszBasename, pszBasename );
573 psHooks->
Error( pszMessage );
592 psSHP->
nFileSize = ((
unsigned int)pabyBuf[24] * 256 * 256 * 256
593 + (
unsigned int)pabyBuf[25] * 256 * 256
594 + (
unsigned int)pabyBuf[26] * 256
595 + (
unsigned int)pabyBuf[27]) * 2;
603 || pabyBuf[2] != 0x27
604 || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) )
606 psSHP->
sHooks.
Error(
".shx file is unreadable, or corrupt." );
614 psSHP->
nRecords = pabyBuf[27] + pabyBuf[26] * 256
615 + pabyBuf[25] * 256 * 256 + pabyBuf[24] * 256 * 256 * 256;
625 "Record count in .shp header is %d, which seems\n"
626 "unreasonable. Assuming header is corrupt.",
641 memcpy( &dValue, pabyBuf+36, 8 );
645 memcpy( &dValue, pabyBuf+44, 8 );
649 memcpy( &dValue, pabyBuf+52, 8 );
653 memcpy( &dValue, pabyBuf+60, 8 );
657 memcpy( &dValue, pabyBuf+68, 8 );
661 memcpy( &dValue, pabyBuf+76, 8 );
665 memcpy( &dValue, pabyBuf+84, 8 );
669 memcpy( &dValue, pabyBuf+92, 8 );
693 "Not enough memory to allocate requested memory (nRecords=%d).\n"
694 "Probably broken SHP file",
701 if (pabyBuf)
free( pabyBuf );
712 "Failed to read all values for %d records in .shx file.",
728 if (strcmp(pszAccess,
"rb") == 0)
734 for( i = 0; i < psSHP->
nRecords; i++ )
736 int32 nOffset, nLength;
738 memcpy( &nOffset, pabyBuf + i * 8, 4 );
741 memcpy( &nLength, pabyBuf + i * 8 + 4, 4 );
777 if ( psSHP->
fpSHX != NULL)
797 double * padfMinBound,
double * padfMaxBound )
805 if( pnEntities != NULL )
808 if( pnShapeType != NULL )
811 for( i = 0; i < 4; i++ )
813 if( padfMinBound != NULL )
815 if( padfMaxBound != NULL )
835 return SHPCreateLL( pszLayer, nShapeType, &sHooks );
849 char *pszBasename = NULL, *pszFullname = NULL;
851 SAFile fpSHP = NULL, fpSHX = NULL;
852 uchar abyHeader[100];
860 if( *((
uchar *) &i) == 1 )
869 pszBasename = (
char *)
malloc(strlen(pszLayer)+5);
870 strcpy( pszBasename, pszLayer );
871 for( i = strlen(pszBasename)-1;
872 i > 0 && pszBasename[i] !=
'.' && pszBasename[i] !=
'/'
873 && pszBasename[i] !=
'\\';
876 if( pszBasename[i] ==
'.' )
877 pszBasename[i] =
'\0';
882 pszFullname = (
char *)
malloc(strlen(pszBasename) + 5);
883 sprintf( pszFullname,
"%s.shp", pszBasename );
884 fpSHP = psHooks->
FOpen(pszFullname,
"wb" );
887 psHooks->
Error(
"Failed to create file .shp file." );
891 sprintf( pszFullname,
"%s.shx", pszBasename );
892 fpSHX = psHooks->
FOpen(pszFullname,
"wb" );
895 psHooks->
Error(
"Failed to create file .shx file." );
899 free( pszFullname ); pszFullname = NULL;
900 free( pszBasename ); pszBasename = NULL;
905 for( i = 0; i < 100; i++ )
924 ByteCopy( &dValue, abyHeader+36, 8 );
925 ByteCopy( &dValue, abyHeader+44, 8 );
926 ByteCopy( &dValue, abyHeader+52, 8 );
927 ByteCopy( &dValue, abyHeader+60, 8 );
932 if( psHooks->
FWrite( abyHeader, 100, 1, fpSHP ) != 1 )
934 psHooks->
Error(
"Failed to write .shp header." );
945 if( psHooks->
FWrite( abyHeader, 100, 1, fpSHX ) != 1 )
947 psHooks->
Error(
"Failed to write .shx header." );
957 return(
SHPOpenLL( pszLayer,
"r+b", psHooks ) );
960 if (pszFullname)
free(pszFullname);
961 if (pszBasename)
free(pszBasename);
962 if (fpSHP) psHooks->
FClose( fpSHP );
963 if (fpSHX) psHooks->
FClose( fpSHX );
1015 for( i = 0; i < psObject->
nVertices; i++ )
1038 const
int * panPartStart, const
int * panPartType,
1039 int nVertices, const
double *padfX, const
double *padfY,
1040 const
double * padfZ, const
double * padfM )
1044 int i, bHasM,
bHasZ;
1089 calloc(
sizeof(
int), psObject->
nParts);
1096 for( i = 0; i < nParts; i++ )
1101 if( panPartType != NULL )
1124 psObject->
padfX[i] = padfX[i];
1126 psObject->
padfY[i] = padfY[i];
1127 if( padfZ != NULL &&
bHasZ )
1128 psObject->
padfZ[i] = padfZ[i];
1129 if( padfM != NULL && bHasM )
1130 psObject->
padfM[i] = padfM[i];
1132 if( padfM != NULL && bHasM )
1154 const
double * padfX, const
double * padfY,
1155 const
double * padfZ )
1159 nVertices, padfX, padfY, padfZ, NULL ) );
1173 unsigned int nRecordOffset, nRecordSize=0;
1193 || (
nShapeId >= 0 && nShapeId < psSHP->nRecords) );
1215 + psObject->
nParts * 8 + 128);
1228 int32 nPoints, nParts;
1232 nParts = psObject->
nParts;
1239 ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
1240 ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
1249 for( i = 0; i < psObject->
nParts; i++ )
1260 memcpy( pabyRec + nRecordSize, psObject->
panPartType,
1262 for( i = 0; i < psObject->
nParts; i++ )
1272 for( i = 0; i < psObject->
nVertices; i++ )
1275 ByteCopy( psObject->
padfY + i, pabyRec + nRecordSize + 8, 8 );
1278 SwapWord( 8, pabyRec + nRecordSize );
1281 SwapWord( 8, pabyRec + nRecordSize + 8 );
1283 nRecordSize += 2 * 8;
1301 for( i = 0; i < psObject->
nVertices; i++ )
1329 for( i = 0; i < psObject->
nVertices; i++ )
1353 ByteCopy( &nPoints, pabyRec + 44, 4 );
1355 for( i = 0; i < psObject->
nVertices; i++ )
1358 ByteCopy( psObject->
padfY + i, pabyRec + 48 + i*16 + 8, 8 );
1364 nRecordSize = 48 + 16 * psObject->
nVertices;
1376 for( i = 0; i < psObject->
nVertices; i++ )
1396 for( i = 0; i < psObject->
nVertices; i++ )
1458 unsigned int nExpectedSize = psSHP->
nFileSize + nRecordSize;
1459 if( nExpectedSize < psSHP->nFileSize )
1462 sprintf( str,
"Failed to write shape object. "
1463 "File size cannot reach %u + %u.",
1490 i32 = (nRecordSize-8)/2;
1503 psSHP->
sHooks.
Error(
"Error in psSHP->sHooks.FSeek() while writing object to .shp file." );
1509 psSHP->
sHooks.
Error(
"Error in psSHP->sHooks.Fwrite() while writing object to .shp file." );
1540 for( i = 0; i < psObject->
nVertices; i++ )
1568 char szErrorMsg[128];
1573 if( hEntity < 0 || hEntity >= psSHP->nRecords )
1583 if (psSHP->pabyRec == NULL)
1588 psSHP->pabyRec =
malloc(psSHP->nBufSize);
1591 "Not enough memory to allocate requested memory (nBufSize=%d). "
1592 "Probably broken SHP file", psSHP->nBufSize );
1593 psSHP->sHooks.Error( szError );
1602 if (psSHP->pabyRec == NULL)
1610 if( psSHP->sHooks.FSeek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ) != 0 )
1618 "Error in fseek() reading object from .shp file at offset %u",
1619 psSHP->panRecOffset[hEntity]);
1621 psSHP->sHooks.Error( str );
1625 if( psSHP->sHooks.FRead( psSHP->pabyRec,
nEntitySize, 1, psSHP->fpSHP ) != 1 )
1633 "Error in fread() reading object of size %u at offset %u from .shp file",
1636 psSHP->sHooks.Error( str );
1649 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1650 "Corrupted .shp file : shape %d : nEntitySize = %d",
1652 psSHP->sHooks.Error( szErrorMsg );
1656 memcpy( &
psShape->nSHPType, psSHP->pabyRec + 8, 4 );
1670 int32 nPoints, nParts;
1675 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1676 "Corrupted .shp file : shape %d : nEntitySize = %d",
1678 psSHP->sHooks.Error( szErrorMsg );
1685 memcpy( &(
psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 );
1686 memcpy( &(
psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
1687 memcpy( &(
psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
1688 memcpy( &(
psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
1699 memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
1700 memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
1705 if (nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000)
1707 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1708 "Corrupted .shp file : shape %d, nPoints=%d, nParts=%d.",
1709 hEntity, nPoints, nParts);
1710 psSHP->sHooks.Error( szErrorMsg );
1718 nRequiredSize = 44 + 8 + 4 * nParts + 16 * nPoints;
1723 nRequiredSize += 16 + 8 * nPoints;
1727 nRequiredSize += 4 * nParts;
1731 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1732 "Corrupted .shp file : shape %d, nPoints=%d, nParts=%d, nEntitySize=%d.",
1734 psSHP->sHooks.Error( szErrorMsg );
1740 psShape->padfX = (
double *) calloc(nPoints,
sizeof(
double));
1741 psShape->padfY = (
double *) calloc(nPoints,
sizeof(
double));
1742 psShape->padfZ = (
double *) calloc(nPoints,
sizeof(
double));
1743 psShape->padfM = (
double *) calloc(nPoints,
sizeof(
double));
1746 psShape->panPartStart = (
int *) calloc(nParts,
sizeof(
int));
1747 psShape->panPartType = (
int *) calloc(nParts,
sizeof(
int));
1753 psShape->panPartStart == NULL ||
1756 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1757 "Not enough memory to allocate requested memory (nPoints=%d, nParts=%d) for shape %d. "
1758 "Probably broken SHP file", hEntity, nPoints, nParts );
1759 psSHP->sHooks.Error( szErrorMsg );
1764 for( i = 0; i < nParts; i++ )
1770 memcpy(
psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
1771 for( i = 0; i < nParts; i++ )
1776 if (
psShape->panPartStart[i] < 0
1780 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1781 "Corrupted .shp file : shape %d : panPartStart[%d] = %d, nVertices = %d",
1783 psSHP->sHooks.Error( szErrorMsg );
1787 if (i > 0 &&
psShape->panPartStart[i] <=
psShape->panPartStart[i-1])
1789 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1790 "Corrupted .shp file : shape %d : panPartStart[%d] = %d, panPartStart[%d] = %d",
1791 hEntity, i,
psShape->panPartStart[i], i - 1,
psShape->panPartStart[i - 1]);
1792 psSHP->sHooks.Error( szErrorMsg );
1798 nOffset = 44 + 8 + 4*nParts;
1805 memcpy(
psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
1806 for( i = 0; i < nParts; i++ )
1811 nOffset += 4*nParts;
1817 for( i = 0; i < nPoints; i++ )
1820 psSHP->pabyRec + nOffset + i * 16,
1824 psSHP->pabyRec + nOffset + i * 16 + 8,
1831 nOffset += 16*nPoints;
1840 memcpy( &(
psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
1841 memcpy( &(
psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
1846 for( i = 0; i < nPoints; i++ )
1849 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
1853 nOffset += 16 + 8*nPoints;
1864 memcpy( &(
psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
1865 memcpy( &(
psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
1870 for( i = 0; i < nPoints; i++ )
1873 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
1892 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1893 "Corrupted .shp file : shape %d : nEntitySize = %d",
1895 psSHP->sHooks.Error( szErrorMsg );
1899 memcpy( &nPoints, psSHP->pabyRec + 44, 4 );
1903 if (nPoints > 50 * 1000 * 1000)
1905 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1906 "Corrupted .shp file : shape %d : nPoints = %d",
1908 psSHP->sHooks.Error( szErrorMsg );
1913 nRequiredSize = 48 + nPoints * 16;
1916 nRequiredSize += 16 + nPoints * 8;
1920 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1921 "Corrupted .shp file : shape %d : nPoints = %d, nEntitySize = %d",
1923 psSHP->sHooks.Error( szErrorMsg );
1929 psShape->padfX = (
double *) calloc(nPoints,
sizeof(
double));
1930 psShape->padfY = (
double *) calloc(nPoints,
sizeof(
double));
1931 psShape->padfZ = (
double *) calloc(nPoints,
sizeof(
double));
1932 psShape->padfM = (
double *) calloc(nPoints,
sizeof(
double));
1939 snprintf(szErrorMsg,
sizeof(szErrorMsg),
1940 "Not enough memory to allocate requested memory (nPoints=%d) for shape %d. "
1941 "Probably broken SHP file", hEntity, nPoints );
1942 psSHP->sHooks.Error( szErrorMsg );
1947 for( i = 0; i < nPoints; i++ )
1949 memcpy(
psShape->padfX+i, psSHP->pabyRec + 48 + 16 * i, 8 );
1950 memcpy(
psShape->padfY+i, psSHP->pabyRec + 48 + 16 * i + 8, 8 );
1956 nOffset = 48 + 16*nPoints;
1961 memcpy( &(
psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 );
1962 memcpy( &(
psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
1963 memcpy( &(
psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
1964 memcpy( &(
psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
1976 memcpy( &(
psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
1977 memcpy( &(
psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
1982 for( i = 0; i < nPoints; i++ )
1985 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
1989 nOffset += 16 + 8*nPoints;
2000 memcpy( &(
psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
2001 memcpy( &(
psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
2006 for( i = 0; i < nPoints; i++ )
2009 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
2026 psShape->padfX = (
double *) calloc(1,
sizeof(
double));
2027 psShape->padfY = (
double *) calloc(1,
sizeof(
double));
2028 psShape->padfZ = (
double *) calloc(1,
sizeof(
double));
2029 psShape->padfM = (
double *) calloc(1,
sizeof(
double));
2033 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2034 "Corrupted .shp file : shape %d : nEntitySize = %d",
2036 psSHP->sHooks.Error( szErrorMsg );
2040 memcpy(
psShape->padfX, psSHP->pabyRec + 12, 8 );
2041 memcpy(
psShape->padfY, psSHP->pabyRec + 20, 8 );
2053 memcpy(
psShape->padfZ, psSHP->pabyRec + nOffset, 8 );
2068 memcpy(
psShape->padfM, psSHP->pabyRec + nOffset, 8 );
2110 return "MultiPoint";
2122 return "MultiPointZ";
2134 return "MultiPointM";
2137 return "MultiPatch";
2140 return "UnknownShapeType";
2155 return "TriangleStrip";
2158 return "TriangleFan";
2173 return "UnknownPartType";
2197 if(
psShape->panPartStart != NULL )
2199 if(
psShape->panPartType != NULL )
2216 int iOpRing, bAltered = 0;
2232 for( iOpRing = 0; iOpRing < psObject->
nParts; iOpRing++ )
2234 int bInner, iVert, nVertCount, nVertStart, iCheckRing;
2235 double dfSum, dfTestX, dfTestY;
2255 for( iCheckRing = 0; iCheckRing < psObject->
nParts; iCheckRing++ )
2259 if( iCheckRing == iOpRing )
2264 if( iCheckRing == psObject->
nParts-1 )
2271 for( iEdge = 0; iEdge < nVertCount; iEdge++ )
2275 if( iEdge < nVertCount-1 )
2284 if ( ( psObject->
padfY[iEdge+nVertStart] < dfTestY
2285 && dfTestY <= psObject->padfY[iNext+nVertStart] )
2286 || ( psObject->
padfY[iNext+nVertStart] < dfTestY
2287 && dfTestY <= psObject->
padfY[iEdge+nVertStart] ) )
2292 double const intersect =
2293 ( psObject->
padfX[iEdge+nVertStart]
2294 + ( dfTestY - psObject->
padfY[iEdge+nVertStart] )
2295 / ( psObject->
padfY[iNext+nVertStart] - psObject->
padfY[iEdge+nVertStart] )
2296 * ( psObject->
padfX[iNext+nVertStart] - psObject->
padfX[iEdge+nVertStart] ) );
2298 if (intersect < dfTestX)
2312 if( iOpRing == psObject->
nParts-1 )
2321 dfSum = psObject->
padfX[nVertStart] * (psObject->
padfY[nVertStart+1] - psObject->
padfY[nVertStart+nVertCount-1]);
2322 for( iVert = nVertStart + 1; iVert < nVertStart+nVertCount-1; iVert++ )
2324 dfSum += psObject->
padfX[iVert] * (psObject->
padfY[iVert+1] - psObject->
padfY[iVert-1]);
2327 dfSum += psObject->
padfX[iVert] * (psObject->
padfY[nVertStart] - psObject->
padfY[iVert-1]);
2332 if( (dfSum < 0.0 && bInner) || (dfSum > 0.0 && !bInner) )
2337 for( i = 0; i < nVertCount/2; i++ )
2342 dfSaved = psObject->
padfX[nVertStart+i];
2343 psObject->
padfX[nVertStart+i] =
2344 psObject->
padfX[nVertStart+nVertCount-i-1];
2345 psObject->
padfX[nVertStart+nVertCount-i-1] = dfSaved;
2348 dfSaved = psObject->
padfY[nVertStart+i];
2349 psObject->
padfY[nVertStart+i] =
2350 psObject->
padfY[nVertStart+nVertCount-i-1];
2351 psObject->
padfY[nVertStart+nVertCount-i-1] = dfSaved;
2354 if( psObject->
padfZ )
2356 dfSaved = psObject->
padfZ[nVertStart+i];
2357 psObject->
padfZ[nVertStart+i] =
2358 psObject->
padfZ[nVertStart+nVertCount-i-1];
2359 psObject->
padfZ[nVertStart+nVertCount-i-1] = dfSaved;
2363 if( psObject->
padfM )
2365 dfSaved = psObject->
padfM[nVertStart+i];
2366 psObject->
padfM[nVertStart+i] =
2367 psObject->
padfM[nVertStart+nVertCount-i-1];
2368 psObject->
padfM[nVertStart+nVertCount-i-1] = dfSaved;
void SASetupDefaultHooks(SAHooks *psHooks)
#define SHP_CVSID(string)
#define DISABLE_MULTIPATCH_MEASURE
SHPHandle SHPAPI_CALL SHPOpen(const char *pszLayer, const char *pszAccess)
SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, SAHooks *psHooks)
SHPObject SHPAPI_CALL1 * SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ){ return(SHPCreateObject(nSHPType, -1, 0, NULL, NULL, nVertices, padfX, padfY, padfZ, NULL)
SHPHandle SHPAPI_CALL SHPCreate(const char *pszLayer, int nShapeType)
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle psSHP, int hEntity){ int32 nEntitySize, nRequiredSize;SHPObject *psShape;char szErrorMsg[128];if(hEntity< 0||hEntity >=psSHP->nRecords) return(NULL
SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, SAHooks *psHooks)
void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject)
static void SwapWord(int length, void *wordP)
void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP)
void SHPAPI_CALL SHPClose(SHPHandle psSHP)
void SHPAPI_CALL SHPGetInfo(SHPHandle psSHP, int *pnEntities, int *pnShapeType, double *padfMinBound, double *padfMaxBound)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psShape)
SHPObject SHPAPI_CALL1 * SHPCreateObject(int nSHPType, int nShapeId, int nParts, const int *panPartStart, const int *panPartType, int nVertices, const double *padfX, const double *padfY, const double *padfZ, const double *padfM){ SHPObject *psObject;int i, bHasM, bHasZ;psObject=(SHPObject *) calloc(1, sizeof(SHPObject)
static void * SfRealloc(void *pMem, int nNewSize)
static void _SHPSetBounds(uchar *pabyRec, SHPObject *psShape)
int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject)
int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject *psObject)
#define ByteCopy(a, b, c)
const char SHPAPI_CALL1 * SHPPartTypeName(int nPartType){ switch(nPartType
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType){ switch(nSHPType
void(* Error)(const char *message)
SAFile(* FOpen)(const char *filename, const char *access)
int(* FFlush)(SAFile file)
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
int(* FClose)(SAFile file)
SAOffset(* FRead)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset(* FSeek)(SAFile file, SAOffset offset, int whence)
unsigned int * panRecSize
unsigned int * panRecOffset