2071 int32 nPoints, nParts;
2078 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2079 "Corrupted .shp file : shape %d : nEntitySize = %d",
2081 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2082 psSHP->sHooks.Error( szErrorMsg );
2089 memcpy( &(
psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 );
2090 memcpy( &(
psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
2091 memcpy( &(
psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
2092 memcpy( &(
psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
2103 memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
2104 memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
2111 nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000)
2113 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2114 "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u.",
2115 hEntity, nPoints, nParts);
2116 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2117 psSHP->sHooks.Error( szErrorMsg );
2125 nRequiredSize = 44 + 8 + 4 * nParts + 16 * nPoints;
2130 nRequiredSize += 16 + 8 * nPoints;
2134 nRequiredSize += 4 * nParts;
2138 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2139 "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u, nEntitySize=%d.",
2141 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2142 psSHP->sHooks.Error( szErrorMsg );
2147 if(
psShape->bFastModeReadObject )
2149 int nObjectBufSize = 4 *
sizeof(double) * nPoints + 2 *
sizeof(
int) * nParts;
2151 ppBuffer = &pBuffer;
2171 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2172 "Not enough memory to allocate requested memory (nPoints=%u, nParts=%u) for shape %d. "
2173 "Probably broken SHP file", nPoints, nParts, hEntity );
2174 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2175 psSHP->sHooks.Error( szErrorMsg );
2186 memcpy(
psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
2192 if (
psShape->panPartStart[i] < 0
2197 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2198 "Corrupted .shp file : shape %d : panPartStart[%d] = %d, nVertices = %d",
2200 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2201 psSHP->sHooks.Error( szErrorMsg );
2205 if (i > 0 &&
psShape->panPartStart[i] <=
psShape->panPartStart[i-1])
2207 snprintf(szErrorMsg,
sizeof(szErrorMsg),
2208 "Corrupted .shp file : shape %d : panPartStart[%d] = %d, panPartStart[%d] = %d",
2209 hEntity, i,
psShape->panPartStart[i], i - 1,
psShape->panPartStart[i - 1]);
2210 szErrorMsg[
sizeof(szErrorMsg)-1] =
'\0';
2211 psSHP->sHooks.Error( szErrorMsg );
2217 nOffset = 44 + 8 + 4*nParts;
2224 memcpy(
psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
2230 nOffset += 4*nParts;
2239 psSHP->pabyRec + nOffset + i * 16,
2243 psSHP->pabyRec + nOffset + i * 16 + 8,
2250 nOffset += 16*nPoints;
2259 memcpy( &(
psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
2260 memcpy( &(
psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
2268 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
2272 nOffset += 16 + 8*nPoints;
2274 else if(
psShape->bFastModeReadObject )
2287 memcpy( &(
psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
2288 memcpy( &(
psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
2296 psSHP->pabyRec + nOffset + 16 + i*8, 8 );
2301 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)