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 );
static void SwapWord(int length, void *wordP)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psShape)