2073 int32 nPoints, nParts;
2080 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2081 "Corrupted .shp file : shape %d : nEntitySize = %d",
2083 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2084 psSHP->sHooks.Error( szErrorMsg );
2091 memcpy( &(
psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 );
2092 memcpy( &(
psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
2093 memcpy( &(
psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
2094 memcpy( &(
psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
2105 memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
2106 memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
2113 nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000)
2115 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2116 "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u.",
2117 hEntity, nPoints, nParts);
2118 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2119 psSHP->sHooks.Error( szErrorMsg );
2127 nRequiredSize = 44 + 8 + 4 * nParts + 16 * nPoints;
2132 nRequiredSize += 16 + 8 * nPoints;
2136 nRequiredSize += 4 * nParts;
2140 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2141 "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u, nEntitySize=%d.",
2143 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2144 psSHP->sHooks.Error( szErrorMsg );
2149 if(
psShape->bFastModeReadObject )
2151 int nObjectBufSize = 4 *
sizeof(double) * nPoints + 2 *
sizeof(
int) * nParts;
2153 ppBuffer = &pBuffer;
2173 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2174 "Not enough memory to allocate requested memory (nPoints=%u, nParts=%u) for shape %d. "
2175 "Probably broken SHP file", nPoints, nParts, hEntity );
2176 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2177 psSHP->sHooks.Error( szErrorMsg );
2188 memcpy(
psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
2194 if (
psShape->panPartStart[i] < 0
2199 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2200 "Corrupted .shp file : shape %d : panPartStart[%d] = %d, nVertices = %d",
2202 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2203 psSHP->sHooks.Error( szErrorMsg );
2207 if (i > 0 &&
psShape->panPartStart[i] <=
psShape->panPartStart[i-1])
2209 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2210 "Corrupted .shp file : shape %d : panPartStart[%d] = %d, panPartStart[%d] = %d",
2211 hEntity, i,
psShape->panPartStart[i], i - 1,
psShape->panPartStart[i - 1]);
2212 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2213 psSHP->sHooks.Error( szErrorMsg );
2219 nOffset = 44 + 8 + 4*nParts;
2226 memcpy(
psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
2232 nOffset += 4*nParts;
2241 psSHP->pabyRec + nOffset + i * 16,
2245 psSHP->pabyRec + nOffset + i * 16 + 8,
2252 nOffset += 16*nPoints;
2261 memcpy( &(
psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
2262 memcpy( &(
psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
2270 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
2274 nOffset += 16 + 8*nPoints;
2276 else if(
psShape->bFastModeReadObject )
2289 memcpy( &(
psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
2290 memcpy( &(
psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
2298 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
2303 else if(
psShape->bFastModeReadObject )
static unsigned char * SHPReallocObjectBufIfNecessary(SHPHandle psSHP, int nObjectBufSize)
static void SwapWord(int length, void *wordP)
#define STATIC_CAST(type, x)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psShape)
static void * SHPAllocBuffer(unsigned char **pBuffer, int nSize)