PostGIS  2.4.9dev-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 dependency graph for shpopen.c:

Go to the source code of this file.


#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)


typedef unsigned char uchar
typedef unsigned int int32


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)
SHPHandle SHPAPI_CALL SHPOpenLL (const char *pszLayer, const char *pszAccess, SAHooks *psHooks)
void SHPAPI_CALL SHPClose (SHPHandle psSHP)
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=(SHPObject *) calloc(1, sizeof(SHPObject)
 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, NULL, NULL, nVertices, padfX, padfY, padfZ, NULL)
int SHPAPI_CALL SHPWriteObject (SHPHandle psSHP, int nShapeId, SHPObject *psObject)
SHPObject SHPAPI_CALL1SHPReadObject (SHPHandle psSHP, int hEntity){ int nEntitySize, nRequiredSize;SHPObject *psShape;char szErrorMsg[128];if(hEntity< 0||hEntity >=psSHP->nRecords) return(NULL
 if (nEntitySize > psSHP->nBufSize)
 if (psSHP->pabyRec==NULL)
 if (psSHP->sHooks.FSeek(psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0) !=0)
 if (psSHP->sHooks.FRead(psSHP->pabyRec, nEntitySize, 1, psSHP->fpSHP) !=1)
 if (8+4 > nEntitySize)
 if (bBigEndian)
else if (psShape->nSHPType==SHPT_MULTIPOINT||psShape->nSHPType==SHPT_MULTIPOINTM||psShape->nSHPType==SHPT_MULTIPOINTZ)
 return (psShape)
const char SHPAPI_CALL1SHPTypeName (int nSHPType){ switch(nSHPType
const char SHPAPI_CALL1SHPPartTypeName (int nPartType){ switch(nPartType
void SHPAPI_CALL SHPDestroyObject (SHPObject *psShape)
int SHPAPI_CALL SHPRewindObject (SHPHandle hSHP, SHPObject *psObject)


static int bBigEndian
psObject nSHPType = nSHPType
psObject nShapeId = nShapeId
psObject bMeasureIsUsed = FALSE
 bHasZ = FALSE
psObject nVertices = nVertices
 nEntitySize = psSHP->panRecSize[hEntity]+8
 psShape = (SHPObject *) calloc(1,sizeof(SHPObject))