PostGIS  3.4.0dev-r@@SVN_REVISION@@
shpopen.c File Reference
#include "shapefil.h"
#include <math.h>
#include <limits.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
Include dependency graph for shpopen.c:

Go to the source code of this file.

Macros

#define FALSE   0
 
#define TRUE   1
 
#define ByteCopy(a, b, c)   memcpy( b, a, c )
 
#define MIN(a, b)   ((a<b) ? a : b)
 
#define MAX(a, b)   ((a>b) ? a : b)
 
#define CPL_UNUSED
 
#define STATIC_CAST(type, x)   ((type)(x))
 
#define SHPLIB_NULLPTR   NULL
 

Typedefs

typedef unsigned char uchar
 
typedef unsigned int int32
 

Functions

static void SwapWord (int length, void *wordP)
 
static void * SfRealloc (void *pMem, int nNewSize)
 
void SHPAPI_CALL SHPWriteHeader (SHPHandle psSHP)
 
SHPHandle SHPAPI_CALL SHPOpen (const char *pszLayer, const char *pszAccess)
 
static int SHPGetLenWithoutExtension (const char *pszBasename)
 
SHPHandle SHPAPI_CALL SHPOpenLL (const char *pszLayer, const char *pszAccess, SAHooks *psHooks)
 
SHPHandle SHPAPI_CALL SHPOpenLLEx (const char *pszLayer, const char *pszAccess, SAHooks *psHooks, int bRestoreSHX)
 
int SHPAPI_CALL SHPRestoreSHX (const char *pszLayer, const char *pszAccess, SAHooks *psHooks)
 
void SHPAPI_CALL SHPClose (SHPHandle psSHP)
 
void SHPAPI_CALL SHPSetFastModeReadObject (SHPHandle hSHP, int bFastMode)
 
void SHPAPI_CALL SHPGetInfo (SHPHandle psSHP, int *pnEntities, int *pnShapeType, double *padfMinBound, double *padfMaxBound)
 
SHPHandle SHPAPI_CALL SHPCreate (const char *pszLayer, int nShapeType)
 
SHPHandle SHPAPI_CALL SHPCreateLL (const char *pszLayer, int nShapeType, SAHooks *psHooks)
 
static void _SHPSetBounds (uchar *pabyRec, SHPObject *psShape)
 
void SHPAPI_CALL SHPComputeExtents (SHPObject *psObject)
 
SHPObject SHPAPI_CALL1SHPCreateObject (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=STATIC_CAST(SHPObject *, calloc(1, sizeof(SHPObject))
 
 if (nSHPType==SHPT_ARCM||nSHPType==SHPT_POINTM||nSHPType==SHPT_POLYGONM||nSHPType==SHPT_MULTIPOINTM)
 
 if (nVertices > 0)
 
 SHPComputeExtents (psObject)
 
 return (psObject)
 
SHPObject SHPAPI_CALL1SHPCreateSimpleObject (int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ){ return(SHPCreateObject(nSHPType, -1, 0, SHPLIB_NULLPTR, SHPLIB_NULLPTR, nVertices, padfX, padfY, padfZ, SHPLIB_NULLPTR)
 
int SHPAPI_CALL SHPWriteObject (SHPHandle psSHP, int nShapeId, SHPObject *psObject)
 
static void * SHPAllocBuffer (unsigned char **pBuffer, int nSize)
 
static unsigned char * SHPReallocObjectBufIfNecessary (SHPHandle psSHP, int nObjectBufSize)
 
SHPObject SHPAPI_CALL1SHPReadObject (SHPHandle psSHP, int hEntity){ int nEntitySize, nRequiredSize;SHPObject *psShape;char szErrorMsg[160];int nSHPType;int nBytesRead;if(hEntity< 0||hEntity >=psSHP->nRecords) return SHPLIB_NULLPTR;if(psSHP->panRecOffset[hEntity]==0 &&psSHP->fpSHX !=SHPLIB_NULLPTR
 
 if (nEntitySize > psSHP->nBufSize)
 
 if (psSHP->pabyRec==SHPLIB_NULLPTR)
 
 if (psSHP->sHooks.FSeek(psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0) !=0)
 
 if (nBytesRead >=8 &&nBytesRead==nEntitySize - 8)
 
else if (nBytesRead !=nEntitySize)
 
 if (8+4 > nEntitySize)
 
 if (bBigEndian)
 
 if (psShape->nSHPType==SHPT_POLYGON||psShape->nSHPType==SHPT_ARC||psShape->nSHPType==SHPT_POLYGONZ||psShape->nSHPType==SHPT_POLYGONM||psShape->nSHPType==SHPT_ARCZ||psShape->nSHPType==SHPT_ARCM||psShape->nSHPType==SHPT_MULTIPATCH)
 
 return (psShape)
 
const char SHPAPI_CALL1SHPTypeName (int nSHPType){ switch(nSHPType
 
const char SHPAPI_CALL1SHPPartTypeName (int nPartType){ switch(nPartType
 
void SHPAPI_CALL SHPDestroyObject (SHPObject *psShape)
 
static int SHPGetPartVertexCount (const SHPObject *psObject, int iPart)
 
static int SHPRewindIsInnerRing (const SHPObject *psObject, int iOpRing, double dfTestX, double dfTestY)
 
int SHPAPI_CALL SHPRewindObject (CPL_UNUSED SHPHandle hSHP, SHPObject *psObject)
 

Variables

static int bBigEndian
 
psObject nSHPType = nSHPType
 
psObject nShapeId = nShapeId
 
psObject bMeasureIsUsed = FALSE
 
 else
 
 bHasZ = FALSE
 
psObject nVertices = nVertices
 
 nEntitySize = psSHP->panRecSize[hEntity]+8
 
 nBytesRead = STATIC_CAST(int, psSHP->sHooks.FRead( psSHP->pabyRec, 1, nEntitySize, psSHP->fpSHP ))
 
else psShape = STATIC_CAST(SHPObject *, calloc(1,sizeof(SHPObject)))
 
psShape bFastModeReadObject = psSHP->bFastModeReadObject