GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
|
#include "shapefil_private.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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) |
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, const SAHooks *psHooks) |
SHPHandle SHPAPI_CALL | SHPOpenLLEx (const char *pszLayer, const char *pszAccess, const SAHooks *psHooks, int bRestoreSHX) |
int SHPAPI_CALL | SHPRestoreSHX (const char *pszLayer, const char *pszAccess, const SAHooks *psHooks) |
void SHPAPI_CALL | SHPClose (SHPHandle psSHP) |
void SHPAPI_CALL | SHPSetFastModeReadObject (SHPHandle hSHP, int bFastMode) |
void SHPAPI_CALL | SHPGetInfo (const 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, const SAHooks *psHooks) |
void SHPAPI_CALL | SHPComputeExtents (SHPObject *psObject) |
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 *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_CALL1 * | SHPCreateSimpleObject (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, const SHPObject *psObject) |
SHPObject SHPAPI_CALL1 * | SHPReadObject (const 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 (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_CALL1 * | SHPTypeName (int nSHPType){ switch(nSHPType |
const char SHPAPI_CALL1 * | SHPPartTypeName (int nPartType){ switch(nPartType |
void SHPAPI_CALL | SHPDestroyObject (SHPObject *psShape) |
int SHPAPI_CALL | SHPRewindObject (const 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 |
SHPObject * | psShape |
psShape | bFastModeReadObject = psSHP->bFastModeReadObject |
if | ( | 8+ | 4, |
nEntitySize | |||
) |
Definition at line 1978 of file shpopen.c.
References nEntitySize, and SHPLIB_NULLPTR.
else if | ( | nBytesRead ! | = nEntitySize | ) |
Definition at line 1962 of file shpopen.c.
References nEntitySize, and SHPLIB_NULLPTR.
if | ( | nBytesRead >=8 && | nBytesRead = = nEntitySize - 8 | ) |
Definition at line 1942 of file shpopen.c.
References nBytesRead, SHP_SWAP32, and SHPLIB_NULLPTR.
if | ( | nEntitySize | , |
psSHP-> | nBufSize | ||
) |
Definition at line 1843 of file shpopen.c.
References nEntitySize, SHPLIB_NULLPTR, and STATIC_CAST.
if | ( | nSHPType | = = SHPT_ARCM || nSHPType == SHPT_POINTM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_MULTIPOINTM | ) |
Definition at line 1149 of file shpopen.c.
Referenced by SHPWriteObject().
if | ( | nVertices | , |
0 | |||
) |
Definition at line 1199 of file shpopen.c.
References bHasM, bHasZ, tagSHPObject::bMeasureIsUsed, malloc(), nVertices, tagSHPObject::padfM, tagSHPObject::padfX, tagSHPObject::padfY, tagSHPObject::padfZ, SHPLIB_NULLPTR, STATIC_CAST, and TRUE.
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 | ) |
Definition at line 2019 of file shpopen.c.
References tagSHPObject::bFastModeReadObject, tagSHPObject::dfXMax, tagSHPObject::dfXMin, tagSHPObject::dfYMax, tagSHPObject::dfYMin, nEntitySize, tagSHPObject::nSHPType, psShape, SHP_SWAP32, SHP_SWAPDOUBLE_CPY, SHPDestroyObject(), SHPLIB_NULLPTR, SHPT_ARCZ, SHPT_MULTIPATCH, and SHPT_POLYGONZ.
if | ( | psSHP-> | pabyRec = = SHPLIB_NULLPTR | ) |
Definition at line 1906 of file shpopen.c.
References SHPLIB_NULLPTR.
if | ( | psSHP->sHooks.FSeek(psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0) ! | = 0 | ) |
Definition at line 1913 of file shpopen.c.
References SHPLIB_NULLPTR.
return | ( | psObject | ) |
Referenced by gvl_file_set_slices_param().
return | ( | psShape | ) |
void SHPAPI_CALL SHPClose | ( | SHPHandle | psSHP | ) |
Definition at line 821 of file shpopen.c.
References SHPInfo::bUpdated, SAHooks::FClose, SHPInfo::fpSHP, SHPInfo::fpSHX, free(), SHPInfo::pabyObjectBuf, SHPInfo::pabyRec, SHPInfo::panRecOffset, SHPInfo::panRecSize, SHPInfo::psCachedObject, SHPInfo::sHooks, SHPLIB_NULLPTR, and SHPWriteHeader().
SHPComputeExtents | ( | psObject | ) |
void SHPAPI_CALL SHPComputeExtents | ( | SHPObject * | psObject | ) |
Definition at line 1099 of file shpopen.c.
References tagSHPObject::dfMMax, tagSHPObject::dfMMin, tagSHPObject::dfXMax, tagSHPObject::dfXMin, tagSHPObject::dfYMax, tagSHPObject::dfYMin, tagSHPObject::dfZMax, tagSHPObject::dfZMin, MAX, MIN, tagSHPObject::nVertices, tagSHPObject::padfM, tagSHPObject::padfX, tagSHPObject::padfY, and tagSHPObject::padfZ.
SHPHandle SHPAPI_CALL SHPCreate | ( | const char * | pszLayer, |
int | nShapeType | ||
) |
Definition at line 914 of file shpopen.c.
References SASetupDefaultHooks(), and SHPCreateLL().
SHPHandle SHPAPI_CALL SHPCreateLL | ( | const char * | pszLayer, |
int | nShapeType, | ||
const SAHooks * | psHooks | ||
) |
Definition at line 930 of file shpopen.c.
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 | ||
) |
References STATIC_CAST.
Referenced by SHPCreateSimpleObject().
SHPObject SHPAPI_CALL1* SHPCreateSimpleObject | ( | int | nSHPType, |
int | nVertices, | ||
const double * | padfX, | ||
const double * | padfY, | ||
const double * | padfZ | ||
) |
References nSHPType, nVertices, SHPCreateObject(), and SHPLIB_NULLPTR.
void SHPAPI_CALL SHPDestroyObject | ( | SHPObject * | psShape | ) |
Definition at line 2654 of file shpopen.c.
References tagSHPObject::bFastModeReadObject, FALSE, free(), tagSHPObject::padfM, tagSHPObject::padfX, tagSHPObject::padfY, tagSHPObject::padfZ, tagSHPObject::panPartStart, tagSHPObject::panPartType, psShape, and SHPLIB_NULLPTR.
Referenced by if().
void SHPAPI_CALL SHPGetInfo | ( | const SHPHandle | psSHP, |
int * | pnEntities, | ||
int * | pnShapeType, | ||
double * | padfMinBound, | ||
double * | padfMaxBound | ||
) |
Definition at line 886 of file shpopen.c.
References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, SHPInfo::nRecords, SHPInfo::nShapeType, and SHPLIB_NULLPTR.
SHPHandle SHPAPI_CALL SHPOpen | ( | const char * | pszLayer, |
const char * | pszAccess | ||
) |
Definition at line 213 of file shpopen.c.
References SASetupDefaultHooks(), and SHPOpenLL().
SHPHandle SHPAPI_CALL SHPOpenLL | ( | const char * | pszLayer, |
const char * | pszAccess, | ||
const SAHooks * | psHooks | ||
) |
Definition at line 245 of file shpopen.c.
References SHPInfo::bUpdated, FALSE, SHPInfo::sHooks, SHPLIB_NULLPTR, and STATIC_CAST.
Referenced by SHPOpen(), and SHPOpenLLEx().
SHPHandle SHPAPI_CALL SHPOpenLLEx | ( | const char * | pszLayer, |
const char * | pszAccess, | ||
const SAHooks * | psHooks, | ||
int | bRestoreSHX | ||
) |
Definition at line 586 of file shpopen.c.
References SHPLIB_NULLPTR, SHPOpenLL(), and SHPRestoreSHX().
const char SHPAPI_CALL1* SHPPartTypeName | ( | int | nPartType | ) |
Definition at line 2624 of file shpopen.c.
References SHPP_FIRSTRING, SHPP_INNERRING, SHPP_OUTERRING, SHPP_RING, SHPP_TRIFAN, and SHPP_TRISTRIP.
SHPObject SHPAPI_CALL1* SHPReadObject | ( | const SHPHandle | psSHP, |
int | hEntity | ||
) |
Definition at line 1785 of file shpopen.c.
References SHP_SWAP32, SHPLIB_NULLPTR, and STATIC_CAST.
int SHPAPI_CALL SHPRestoreSHX | ( | const char * | pszLayer, |
const char * | pszAccess, | ||
const SAHooks * | psHooks | ||
) |
Definition at line 607 of file shpopen.c.
Referenced by SHPOpenLLEx().
int SHPAPI_CALL SHPRewindObject | ( | const SHPHandle | hSHP, |
SHPObject * | psObject | ||
) |
Definition at line 2785 of file shpopen.c.
References FALSE, tagSHPObject::nParts, tagSHPObject::nSHPType, tagSHPObject::nVertices, tagSHPObject::padfZ, tagSHPObject::panPartStart, SHPT_POLYGON, SHPT_POLYGONM, SHPT_POLYGONZ, and TRUE.
void SHPAPI_CALL SHPSetFastModeReadObject | ( | SHPHandle | hSHP, |
int | bFastMode | ||
) |
Definition at line 867 of file shpopen.c.
References assert, SHPInfo::bFastModeReadObject, SHPInfo::psCachedObject, SHPLIB_NULLPTR, and STATIC_CAST.
const char SHPAPI_CALL1* SHPTypeName | ( | int | nSHPType | ) |
Definition at line 2570 of file shpopen.c.
References nSHPType, SHPT_ARC, SHPT_ARCM, SHPT_ARCZ, SHPT_MULTIPATCH, SHPT_MULTIPOINT, SHPT_MULTIPOINTM, SHPT_MULTIPOINTZ, SHPT_NULL, SHPT_POINT, SHPT_POINTM, SHPT_POINTZ, SHPT_POLYGON, SHPT_POLYGONM, and SHPT_POLYGONZ.
void SHPAPI_CALL SHPWriteHeader | ( | SHPHandle | psSHP | ) |
Definition at line 56 of file shpopen.c.
References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, ByteCopy, SAHooks::Error, SAHooks::FFlush, SHPInfo::fpSHP, SHPInfo::fpSHX, free(), SAHooks::FSeek, SAHooks::FWrite, malloc(), SHPInfo::nFileSize, SHPInfo::nRecords, SHPInfo::nShapeType, SHPInfo::panRecOffset, SHPInfo::panRecSize, SHPInfo::sHooks, SHP_SWAP32, SHP_SWAP64, SHPLIB_NULLPTR, and STATIC_CAST.
Referenced by SHPClose().
int SHPAPI_CALL SHPWriteObject | ( | SHPHandle | psSHP, |
int | nShapeId, | ||
const SHPObject * | psObject | ||
) |
Definition at line 1256 of file shpopen.c.
References assert, SHPInfo::bUpdated, SAHooks::Error, if(), malloc(), SHPInfo::nMaxRecords, tagSHPObject::nParts, SHPInfo::nRecords, nShapeId, SHPInfo::nShapeType, tagSHPObject::nSHPType, tagSHPObject::nVertices, SHPInfo::panRecOffset, SHPInfo::panRecSize, SHPInfo::sHooks, SHPLIB_NULLPTR, SHPT_ARC, SHPT_ARCM, SHPT_ARCZ, SHPT_MULTIPATCH, SHPT_NULL, SHPT_POLYGON, SHPT_POLYGONM, SHPT_POLYGONZ, STATIC_CAST, and TRUE.
else |
const int nBytesRead |
Definition at line 1929 of file shpopen.c.
Referenced by if().
const int nEntitySize = psSHP->panRecSize[hEntity] + 8 |
psShape nShapeId = nShapeId |
Definition at line 1140 of file shpopen.c.
Referenced by SHPWriteObject().
psShape nSHPType = nSHPType |
Definition at line 1139 of file shpopen.c.
Referenced by SHPCreateSimpleObject(), and SHPTypeName().
psObject nVertices = nVertices |
Definition at line 1228 of file shpopen.c.
Referenced by if(), and SHPCreateSimpleObject().
SHPObject* psShape |
Definition at line 1997 of file shpopen.c.
Referenced by if(), and SHPDestroyObject().