GRASS Programmer's Manual
6.5.svn(2014)-r66266
|
#include <grass/shapefil.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.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) |
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_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;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_CALL1 * | SHPCreateSimpleObject (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_CALL1 * | SHPReadObject (SHPHandle psSHP, int hEntity){intnEntitySize, nRequiredSize;SHPObject *psShape;charpszErrorMsg[128];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_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 (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 | |
psShape = (SHPObject *) calloc(1,sizeof(SHPObject)) | |
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().
Definition at line 252 of file shpopen.c.
Referenced by SHPComputeExtents(), SHPOpenLL(), and SHPWriteObject().
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().
if | ( | nSHPType | = = SHPT_ARCM || nSHPType == SHPT_POINTM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_MULTIPOINTM | ) |
if | ( | nVertices | , |
0 | |||
) |
Definition at line 1072 of file shpopen.c.
References SHPObject::bMeasureIsUsed, NULL, nVertices, SHPObject::padfM, SHPObject::padfX, SHPObject::padfY, SHPObject::padfZ, and TRUE.
if | ( | nEntitySize | , |
psSHP-> | nBufSize | ||
) |
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 | |||
) |
Definition at line 1571 of file shpopen.c.
References NULL, and SHPDestroyObject().
else if | ( | psShape-> | nSHPType = = SHPT_MULTIPOINT || psShape->nSHPType == SHPT_MULTIPOINTM || psShape->nSHPType == SHPT_MULTIPOINTZ | ) |
Definition at line 1801 of file shpopen.c.
References SHPObject::bMeasureIsUsed, SHPObject::dfMMax, SHPObject::dfMMin, SHPObject::dfXMax, SHPObject::dfXMin, SHPObject::dfYMax, SHPObject::dfYMin, SHPObject::dfZMax, SHPObject::dfZMin, SHPObject::nSHPType, NULL, SHPObject::nVertices, SHPObject::padfM, SHPObject::padfX, SHPObject::padfY, SHPObject::padfZ, SHPDestroyObject(), SHPT_MULTIPOINTZ, and TRUE.
return | ( | psObject | ) |
return | ( | psShape | ) |
void SHPAPI_CALL SHPClose | ( | SHPHandle | psSHP | ) |
Definition at line 720 of file shpopen.c.
References SHPInfo::bUpdated, SAHooks::FClose, SHPInfo::fpSHP, SHPInfo::fpSHX, free(), NULL, SHPInfo::pabyRec, SHPInfo::panRecOffset, SHPInfo::panRecSize, SHPInfo::sHooks, and SHPWriteHeader().
void SHPAPI_CALL SHPComputeExtents | ( | SHPObject * | psObject | ) |
Definition at line 957 of file shpopen.c.
References SHPObject::dfMMax, SHPObject::dfMMin, SHPObject::dfXMax, SHPObject::dfXMin, SHPObject::dfYMax, SHPObject::dfYMin, SHPObject::dfZMax, SHPObject::dfZMin, MAX, MIN, SHPObject::nVertices, SHPObject::padfM, SHPObject::padfX, SHPObject::padfY, and SHPObject::padfZ.
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, free(), SAHooks::FWrite, malloc(), NULL, SHPOpenLL(), sprintf(), 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 | ) |
Definition at line 2096 of file shpopen.c.
References free(), NULL, SHPObject::padfM, SHPObject::padfX, SHPObject::padfY, SHPObject::padfZ, SHPObject::panPartStart, and SHPObject::panPartType.
Referenced by if().
void SHPAPI_CALL SHPGetInfo | ( | SHPHandle | psSHP, |
int * | pnEntities, | ||
int * | pnShapeType, | ||
double * | padfMinBound, | ||
double * | padfMaxBound | ||
) |
Definition at line 757 of file shpopen.c.
References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, SHPInfo::nRecords, SHPInfo::nShapeType, and NULL.
SHPHandle SHPAPI_CALL SHPOpen | ( | const char * | pszLayer, |
const char * | pszAccess | ||
) |
Definition at line 426 of file shpopen.c.
References SASetupDefaultHooks(), and SHPOpenLL().
SHPHandle SHPAPI_CALL SHPOpenLL | ( | const char * | pszLayer, |
const char * | pszAccess, | ||
SAHooks * | psHooks | ||
) |
Definition at line 444 of file shpopen.c.
References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, SHPInfo::bUpdated, SAHooks::Error, FALSE, SAHooks::FClose, SAHooks::FOpen, SHPInfo::fpSHP, SHPInfo::fpSHX, SAHooks::FRead, free(), malloc(), MAX, SHPInfo::nFileSize, SHPInfo::nMaxRecords, SHPInfo::nRecords, SHPInfo::nShapeType, NULL, SHPInfo::panRecOffset, SHPInfo::panRecSize, SHPInfo::sHooks, sprintf(), and TRUE.
Referenced by SHPCreateLL(), and SHPOpen().
const char SHPAPI_CALL1* SHPPartTypeName | ( | int | nPartType | ) |
Definition at line 2063 of file shpopen.c.
References SHPP_FIRSTRING, SHPP_INNERRING, SHPP_OUTERRING, SHPP_RING, SHPP_TRIFAN, and SHPP_TRISTRIP.
SHPObject SHPAPI_CALL1* SHPReadObject | ( | SHPHandle | psSHP, |
int | hEntity | ||
) |
int SHPAPI_CALL SHPRewindObject | ( | SHPHandle | hSHP, |
SHPObject * | psObject | ||
) |
Definition at line 2127 of file shpopen.c.
References FALSE, SHPObject::nParts, SHPObject::nSHPType, SHPObject::nVertices, SHPObject::padfM, SHPObject::padfX, SHPObject::padfY, SHPObject::padfZ, SHPObject::panPartStart, SHPT_POLYGON, SHPT_POLYGONM, and SHPT_POLYGONZ.
const char SHPAPI_CALL1* SHPTypeName | ( | int | nSHPType | ) |
Definition at line 2006 of file shpopen.c.
References 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 SHPWriteHeader | ( | SHPHandle | psSHP | ) |
Definition at line 301 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, NULL, SHPInfo::panRecOffset, SHPInfo::panRecSize, and SHPInfo::sHooks.
Referenced by SHPClose().
int SHPAPI_CALL SHPWriteObject | ( | SHPHandle | psSHP, |
int | nShapeId, | ||
SHPObject * | psObject | ||
) |
Definition at line 1129 of file shpopen.c.
References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, SHPObject::bMeasureIsUsed, SHPInfo::bUpdated, ByteCopy, SHPObject::dfMMax, SHPObject::dfMMin, SHPObject::dfZMax, SHPObject::dfZMin, DISABLE_MULTIPATCH_MEASURE, SAHooks::Error, FALSE, SHPInfo::fpSHP, free(), SAHooks::FSeek, SAHooks::FWrite, int, malloc(), MAX, MIN, SHPInfo::nFileSize, SHPInfo::nMaxRecords, SHPObject::nParts, SHPInfo::nRecords, nShapeId, SHPInfo::nShapeType, SHPObject::nSHPType, SHPObject::nVertices, SHPObject::padfM, SHPObject::padfX, SHPObject::padfY, SHPObject::padfZ, SHPObject::panPartStart, SHPObject::panPartType, SHPInfo::panRecOffset, SHPInfo::panRecSize, SHPInfo::sHooks, 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, SHPT_POLYGONZ, and TRUE.
else |
nEntitySize = psSHP->panRecSize[hEntity]+8 |
psShape nShapeId = nShapeId |
Definition at line 1006 of file shpopen.c.
Referenced by SHPWriteObject().