GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
shpopen.c File Reference
#include <grass/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.

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)

Typedefs

typedef unsigned char uchar
typedef int int32

Functions

void 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)
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;inti, bHasM, bHasZ;psObject=(SHPObject *) calloc(1, sizeof(SHPObject)
 if (nSHPType==SHPT_ARCM||nSHPType==SHPT_POINTM||nSHPType==SHPT_POLYGONM||nSHPType==SHPT_MULTIPOINTM)
 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){intnEntitySize, nRequiredSize;SHPObject *psShape;charpszErrorMsg[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||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)

Variables

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

Macro Definition Documentation

#define ByteCopy (   a,
  b,
 
)    memcpy( b, a, c )

Definition at line 249 of file shpopen.c.

Referenced by SHPCreateLL(), SHPWriteHeader(), and SHPWriteObject().

#define FALSE   0

Definition at line 245 of file shpopen.c.

Referenced by if(), SHPCreateLL(), SHPOpenLL(), SHPRewindObject(), and SHPWriteObject().

#define MAX (   a,
  b 
)    ((a>b) ? a : b)

Definition at line 252 of file shpopen.c.

Referenced by SHPComputeExtents(), SHPOpenLL(), and SHPWriteObject().

#define MIN (   a,
  b 
)    ((a<b) ? a : b)

Definition at line 251 of file shpopen.c.

Referenced by SHPComputeExtents(), and SHPWriteObject().

#define TRUE   1

Definition at line 246 of file shpopen.c.

Referenced by if(), SHPCreateLL(), SHPOpenLL(), and SHPWriteObject().

Typedef Documentation

typedef int int32

Definition at line 241 of file shpopen.c.

typedef unsigned char uchar

Definition at line 236 of file shpopen.c.

Function Documentation

else if ( nSHPType  = SHPT_ARCM || nSHPType == SHPT_POINTM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_MULTIPOINTM)

Definition at line 1008 of file shpopen.c.

References FALSE, and TRUE.

if ( nEntitySize  ,
psSHP->  nBufSize 
)

Definition at line 1517 of file shpopen.c.

References nEntitySize, and NULL.

if ( psSHP->  pabyRec = NULL)

Definition at line 1539 of file shpopen.c.

References NULL.

if ( psSHP->sHooks.FSeek(psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0)!  = 0 || psSHP->sHooks.FRead( psSHP->pabyRec, nEntitySize, 1,                   psSHP->fpSHP ) != 1)

Definition at line 1547 of file shpopen.c.

References NULL.

if ( 8+  4,
nEntitySize   
)

Definition at line 1567 of file shpopen.c.

References NULL, and SHPDestroyObject().

if ( bBigEndian  )

Definition at line 1577 of file shpopen.c.

return ( psObject  )
return ( psShape  )
SHPComputeExtents ( psObject  )
SHPHandle SHPAPI_CALL SHPCreate ( const char *  pszLayer,
int  nShapeType 
)

Definition at line 789 of file shpopen.c.

References SASetupDefaultHooks(), and SHPCreateLL().

SHPHandle SHPAPI_CALL SHPCreateLL ( const char *  pszLayer,
int  nShapeType,
SAHooks psHooks 
)

Definition at line 807 of file shpopen.c.

References ByteCopy, SAHooks::Error, FALSE, SAHooks::FClose, SAHooks::FOpen, SAHooks::FWrite, NULL, SHPOpenLL(), and TRUE.

Referenced by SHPCreate().

SHPObject SHPAPI_CALL1* SHPCreateObject ( 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 SHPAPI_CALL1* SHPCreateSimpleObject ( int  nSHPType,
int  nVertices,
const double *  padfX,
const double *  padfY,
const double *  padfZ 
)
void SHPAPI_CALL SHPDestroyObject ( SHPObject psShape)
void SHPAPI_CALL SHPGetInfo ( SHPHandle  psSHP,
int *  pnEntities,
int *  pnShapeType,
double *  padfMinBound,
double *  padfMaxBound 
)
SHPHandle SHPAPI_CALL SHPOpen ( const char *  pszLayer,
const char *  pszAccess 
)

Definition at line 426 of file shpopen.c.

References SASetupDefaultHooks(), and SHPOpenLL().

const char SHPAPI_CALL1* SHPPartTypeName ( int  nPartType)
SHPObject SHPAPI_CALL1* SHPReadObject ( SHPHandle  psSHP,
int  hEntity 
)

Variable Documentation

psShape bMeasureIsUsed = FALSE

Definition at line 1003 of file shpopen.c.

nEntitySize = psSHP->panRecSize[hEntity]+8

Definition at line 1516 of file shpopen.c.

Referenced by if().

psShape nShapeId = nShapeId

Definition at line 1002 of file shpopen.c.

Referenced by SHPWriteObject().

psObject nSHPType = nSHPType

Definition at line 1001 of file shpopen.c.

memcpy & psShape = (SHPObject *) calloc(1,sizeof(SHPObject))

Definition at line 1563 of file shpopen.c.