GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-835afb4352
shpopen.c File Reference
#include "shapefil.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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

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=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)
 
SHPObject SHPAPI_CALL1SHPReadObject (SHPHandle psSHP, int hEntity){ 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)
 
int SHPAPI_CALL SHPRewindObject (CPL_UNUSED SHPHandle hSHP, SHPObject *psObject)
 

Variables

psObject nSHPType = nSHPType
 
psObject nShapeId = nShapeId
 
psObject bMeasureIsUsed = FALSE
 
bool bHasM
 
bool bHasZ = false
 
 else
 
psObject nVertices = nVertices
 
const int nEntitySize = psSHP->panRecSize[hEntity] + 8
 
const int nBytesRead
 
psShape bFastModeReadObject = psSHP->bFastModeReadObject
 

Macro Definition Documentation

◆ ByteCopy

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

Definition at line 62 of file shpopen.c.

◆ CPL_UNUSED

#define CPL_UNUSED

Definition at line 84 of file shpopen.c.

◆ FALSE

#define FALSE   0

Definition at line 58 of file shpopen.c.

◆ MAX

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

Definition at line 65 of file shpopen.c.

◆ MIN

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

Definition at line 64 of file shpopen.c.

◆ SHPLIB_NULLPTR

#define SHPLIB_NULLPTR   NULL

Definition at line 101 of file shpopen.c.

◆ STATIC_CAST

#define STATIC_CAST (   type,
  x 
)    ((type)(x))

Definition at line 100 of file shpopen.c.

◆ TRUE

#define TRUE   1

Definition at line 59 of file shpopen.c.

Typedef Documentation

◆ int32

typedef unsigned int int32

Definition at line 54 of file shpopen.c.

◆ uchar

typedef unsigned char uchar

Definition at line 49 of file shpopen.c.

Function Documentation

◆ if() [1/10]

if ( 8+  4,
nEntitySize   
)

Definition at line 1953 of file shpopen.c.

References nEntitySize, and SHPLIB_NULLPTR.

◆ if() [2/10]

if ( bBigEndian  )

Definition at line 1965 of file shpopen.c.

◆ if() [3/10]

Definition at line 1937 of file shpopen.c.

References nEntitySize, and SHPLIB_NULLPTR.

◆ if() [4/10]

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

Definition at line 1918 of file shpopen.c.

◆ if() [5/10]

if ( nEntitySize  ,
psSHP->  nBufSize 
)

Definition at line 1819 of file shpopen.c.

References nEntitySize, SHPLIB_NULLPTR, and STATIC_CAST.

◆ if() [6/10]

Definition at line 1167 of file shpopen.c.

References bHasM, and bHasZ.

◆ if() [7/10]

◆ if() [8/10]

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

◆ if() [9/10]

if ( psSHP->  pabyRec = SHPLIB_NULLPTR)

Definition at line 1882 of file shpopen.c.

References SHPLIB_NULLPTR.

◆ if() [10/10]

if ( psSHP->sHooks.FSeek(psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0) !  = 0)

Definition at line 1889 of file shpopen.c.

References SHPLIB_NULLPTR.

◆ return() [1/2]

return ( psObject  )

◆ return() [2/2]

return ( psShape  )

◆ SHPClose()

◆ SHPComputeExtents() [1/2]

SHPComputeExtents ( psObject  )

◆ SHPComputeExtents() [2/2]

◆ SHPCreate()

SHPHandle SHPAPI_CALL SHPCreate ( const char *  pszLayer,
int  nShapeType 
)

Definition at line 944 of file shpopen.c.

References SASetupDefaultHooks(), and SHPCreateLL().

◆ SHPCreateLL()

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

Definition at line 960 of file shpopen.c.

Referenced by SHPCreate().

◆ SHPCreateObject()

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 
)

References STATIC_CAST.

Referenced by SHPCreateSimpleObject().

◆ SHPCreateSimpleObject()

SHPObject SHPAPI_CALL1* SHPCreateSimpleObject ( int  nSHPType,
int  nVertices,
const double *  padfX,
const double *  padfY,
const double *  padfZ 
)

◆ SHPDestroyObject()

◆ SHPGetInfo()

void SHPAPI_CALL SHPGetInfo ( SHPHandle  psSHP,
int *  pnEntities,
int *  pnShapeType,
double *  padfMinBound,
double *  padfMaxBound 
)

◆ SHPOpen()

SHPHandle SHPAPI_CALL SHPOpen ( const char *  pszLayer,
const char *  pszAccess 
)

Definition at line 289 of file shpopen.c.

References SASetupDefaultHooks(), and SHPOpenLL().

◆ SHPOpenLL()

SHPHandle SHPAPI_CALL SHPOpenLL ( const char *  pszLayer,
const char *  pszAccess,
SAHooks psHooks 
)

Definition at line 321 of file shpopen.c.

References SHPLIB_NULLPTR.

Referenced by SHPOpen(), and SHPOpenLLEx().

◆ SHPOpenLLEx()

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

Definition at line 659 of file shpopen.c.

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

◆ SHPPartTypeName()

const char SHPAPI_CALL1* SHPPartTypeName ( int  nPartType)

◆ SHPReadObject()

SHPObject SHPAPI_CALL1* SHPReadObject ( SHPHandle  psSHP,
int  hEntity 
)

Definition at line 1761 of file shpopen.c.

References SHPLIB_NULLPTR.

◆ SHPRestoreSHX()

int SHPAPI_CALL SHPRestoreSHX ( const char *  pszLayer,
const char *  pszAccess,
SAHooks psHooks 
)

Definition at line 680 of file shpopen.c.

Referenced by SHPOpenLLEx().

◆ SHPRewindObject()

◆ SHPSetFastModeReadObject()

void SHPAPI_CALL SHPSetFastModeReadObject ( SHPHandle  hSHP,
int  bFastMode 
)

◆ SHPTypeName()

◆ SHPWriteHeader()

void SHPAPI_CALL SHPWriteHeader ( SHPHandle  psSHP)

Definition at line 142 of file shpopen.c.

References ByteCopy, SAHooks::Error, SHPInfo::fpSHX, SHPInfo::nFileSize, SHPInfo::sHooks, and SHPLIB_NULLPTR.

Referenced by SHPClose().

◆ SHPWriteObject()

int SHPAPI_CALL SHPWriteObject ( SHPHandle  psSHP,
int  nShapeId,
SHPObject psObject 
)

Variable Documentation

◆ bFastModeReadObject

psShape bFastModeReadObject = psSHP->bFastModeReadObject

Definition at line 1988 of file shpopen.c.

◆ bHasM

bool bHasM

Definition at line 1164 of file shpopen.c.

Referenced by if().

◆ bHasZ

bHasZ = false

Definition at line 1165 of file shpopen.c.

Referenced by if().

◆ bMeasureIsUsed

psShape bMeasureIsUsed = FALSE

Definition at line 1159 of file shpopen.c.

◆ else

else
Initial value:
{
bHasM = false
bool bHasM
Definition: shpopen.c:1164

Definition at line 1178 of file shpopen.c.

◆ nBytesRead

const int nBytesRead
Initial value:
int, psSHP->sHooks.FRead(psSHP->pabyRec, 1, nEntitySize, psSHP->fpSHP))
const int nEntitySize
Definition: shpopen.c:1818
#define STATIC_CAST(type, x)
Definition: shpopen.c:100

Definition at line 1905 of file shpopen.c.

◆ nEntitySize

const int nEntitySize = psSHP->panRecSize[hEntity] + 8

Definition at line 1818 of file shpopen.c.

Referenced by if().

◆ nShapeId

psShape nShapeId = nShapeId

Definition at line 1158 of file shpopen.c.

Referenced by SHPWriteObject().

◆ nSHPType

psShape nSHPType = nSHPType

Definition at line 1157 of file shpopen.c.

Referenced by SHPCreateSimpleObject(), and SHPTypeName().

◆ nVertices

psObject nVertices = nVertices

Definition at line 1247 of file shpopen.c.

Referenced by if(), and SHPCreateSimpleObject().