GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71817
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends 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 CPL_UNUSED
 
#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 unsigned int int32
 

Functions

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)
 
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)
 
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)
 
 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){intnEntitySize, nRequiredSize;SHPObject *psShape;charszErrorMsg[128];intnSHPType;intnBytesRead;return(NULL
 
 if (psSHP->panRecOffset[hEntity]==0 &&psSHP->fpSHX!=NULL)
 
 if (nEntitySize > psSHP->nBufSize)
 
 if (psSHP->pabyRec==NULL)
 
 snprintf (str, sizeof(str),"Error in fseek() reading object from .shp file at offset %u", psSHP->panRecOffset[hEntity])
 
psSHP sHooks Error (str)
 
 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)
 
int SHPAPI_CALL SHPRewindObject (CPL_UNUSED SHPHandle hSHP, SHPObject *psObject)
 

Variables

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

Macro Definition Documentation

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

Definition at line 296 of file shpopen.c.

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

#define CPL_UNUSED

Definition at line 280 of file shpopen.c.

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

Definition at line 299 of file shpopen.c.

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

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

Definition at line 298 of file shpopen.c.

Referenced by SHPComputeExtents(), and SHPWriteObject().

#define TRUE   1

Definition at line 293 of file shpopen.c.

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

Typedef Documentation

typedef unsigned int int32

Definition at line 288 of file shpopen.c.

typedef unsigned char uchar

Definition at line 283 of file shpopen.c.

Function Documentation

psSHP sHooks Error ( str  )

Definition at line 1403 of file shpopen.c.

References FALSE, and TRUE.

if ( psSHP->  panRecOffset[hEntity] = = 0 && psSHP->fpSHX != NULL)

Definition at line 1998 of file shpopen.c.

References NULL, and snprintf().

if ( nEntitySize  ,
psSHP->  nBufSize 
)

Definition at line 2044 of file shpopen.c.

References int, nEntitySize, NULL, and snprintf().

if ( psSHP->  pabyRec = NULL)

Definition at line 2098 of file shpopen.c.

References NULL.

if ( nBytesRead >=8 &&  nBytesRead = nEntitySize - 8)

Definition at line 2129 of file shpopen.c.

References NULL, and snprintf().

else if ( nBytesRead!  = nEntitySize)

Definition at line 2148 of file shpopen.c.

References NULL, and snprintf().

if ( 8+  4,
nEntitySize   
)

Definition at line 2163 of file shpopen.c.

References NULL, and snprintf().

if ( bBigEndian  )

Definition at line 2173 of file shpopen.c.

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

Definition at line 1173 of file shpopen.c.

References SASetupDefaultHooks(), and SHPCreateLL().

SHPHandle SHPAPI_CALL SHPCreateLL ( const char *  pszLayer,
int  nShapeType,
SAHooks psHooks 
)
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 SHPGetInfo ( SHPHandle  psSHP,
int pnEntities,
int pnShapeType,
double *  padfMinBound,
double *  padfMaxBound 
)
SHPHandle SHPAPI_CALL SHPOpen ( const char *  pszLayer,
const char *  pszAccess 
)

Definition at line 489 of file shpopen.c.

References SASetupDefaultHooks(), and SHPOpenLL().

SHPHandle SHPAPI_CALL SHPOpenLLEx ( const char *  pszLayer,
const char *  pszAccess,
SAHooks psHooks,
int  bRestoreSHX 
)

Definition at line 850 of file shpopen.c.

References NULL, SHPOpenLL(), and SHPRestoreSHX().

const char SHPAPI_CALL1* SHPPartTypeName ( int  nPartType)
SHPObject SHPAPI_CALL1* SHPReadObject ( SHPHandle  psSHP,
int  hEntity 
)
int SHPAPI_CALL SHPRestoreSHX ( const char *  pszLayer,
const char *  pszAccess,
SAHooks psHooks 
)
void SHPAPI_CALL SHPSetFastModeReadObject ( SHPHandle  hSHP,
int  bFastMode 
)

Definition at line 1120 of file shpopen.c.

References SHPInfo::bFastModeReadObject, NULL, and SHPInfo::psCachedObject.

snprintf ( str  ,
sizeof(str)  ,
"Error in fseek() reading object from .shp file at offset %u"  ,
psSHP->  panRecOffset[hEntity] 
)

Variable Documentation

psShape bFastModeReadObject = psSHP->bFastModeReadObject

Definition at line 2195 of file shpopen.c.

bHasZ = FALSE

Definition at line 1423 of file shpopen.c.

psShape bMeasureIsUsed = FALSE

Definition at line 1398 of file shpopen.c.

else
Initial value:
{
bHasM = FALSE
#define FALSE
Definition: shpopen.c:292

Definition at line 1421 of file shpopen.c.

nBytesRead = (int)psSHP->sHooks.FRead( psSHP->pabyRec, 1, nEntitySize, psSHP->fpSHP )

Definition at line 2121 of file shpopen.c.

nEntitySize = psSHP->panRecSize[hEntity]+8

Definition at line 2043 of file shpopen.c.

Referenced by if().

psShape nShapeId = nShapeId

Definition at line 1397 of file shpopen.c.

Referenced by SHPWriteObject().

psShape nSHPType = nSHPType

Definition at line 1396 of file shpopen.c.

return NULL

Definition at line 2118 of file shpopen.c.

psObject nVertices = nVertices

Definition at line 1488 of file shpopen.c.

Referenced by if().

else psShape = (SHPObject *) calloc(1,sizeof(SHPObject))

Definition at line 2191 of file shpopen.c.