pihmLIBS/shpopen.c File Reference

#include "shapefil.h"
#include <math.h>
#include <limits.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

Include dependency graph for shpopen.c:

Go to the source code of this file.

Defines

#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

static void SwapWord (int length, void *wordP)
static void * SfRealloc (void *pMem, int nNewSize)
static void SHPWriteHeader (SHPHandle psSHP)
SHPHandle SHPAPI_CALL SHPOpen (const char *pszLayer, const char *pszAccess)
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)
static void _SHPSetBounds (uchar *pabyRec, SHPObject *psShape)
void SHPAPI_CALL SHPComputeExtents (SHPObject *psObject)
SHPObject SHPAPI_CALL1 * SHPCreateObject (int nSHPType, int nShapeId, int nParts, int *panPartStart, int *panPartType, int nVertices, double *padfX, double *padfY, double *padfZ, 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_CALL1 * SHPCreateSimpleObject (int nSHPType, int nVertices, double *padfX, double *padfY, 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){SHPObject *psShape;if(hEntity< 0||hEntity >=psSHP->nRecords) return(NULL
 if (psSHP->panRecSize[hEntity]+8 > psSHP->nBufSize)
 fseek (psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0)
 fread (psSHP->pabyRec, psSHP->panRecSize[hEntity]+8, 1, psSHP->fpSHP)
 memcpy (&psShape->nSHPType, psSHP->pabyRec+8, 4)
 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

static char rcsid []
static int bBigEndian
psObject nSHPType = nSHPType
psObject nShapeId = nShapeId
 psShape = (SHPObject *) calloc(1,sizeof(SHPObject))
psShape nShapeId = hEntity


Define Documentation

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

Definition at line 185 of file shpopen.c.

Referenced by _SHPSetBounds(), SHPCreate(), SHPWriteHeader(), and SHPWriteObject().

#define FALSE   0

Definition at line 181 of file shpopen.c.

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

Definition at line 188 of file shpopen.c.

Referenced by SHPComputeExtents(), SHPOpen(), streamGen(), streamGenShp(), and streamSegmentationShp().

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

Definition at line 187 of file shpopen.c.

Referenced by SHPComputeExtents().

#define TRUE   1

Definition at line 182 of file shpopen.c.


Typedef Documentation

typedef int int32

Definition at line 177 of file shpopen.c.

typedef unsigned char uchar

Definition at line 172 of file shpopen.c.


Function Documentation

static void _SHPSetBounds ( uchar pabyRec,
SHPObject psShape 
) [static]

Definition at line 724 of file shpopen.c.

References bBigEndian, ByteCopy, psShape, and SwapWord().

Referenced by SHPWriteObject().

Here is the call graph for this function:

fread ( psSHP->  pabyRec,
psSHP->panRecSize+  8[hEntity],
,
psSHP->  fpSHP 
)

Referenced by DBFClose(), DBFOpen(), DBFReadAttribute(), DBFWriteAttribute(), DBFWriteAttributeDirectly(), DBFWriteTuple(), if(), and SHPOpen().

fseek ( psSHP->  fpSHP,
psSHP->  panRecOffset[hEntity],
 
)

Referenced by DBFClose(), DBFFlushRecord(), DBFOpen(), DBFReadAttribute(), DBFWriteAttribute(), DBFWriteAttributeDirectly(), DBFWriteHeader(), DBFWriteTuple(), eol(), if(), and SHPWriteHeader().

else if ( psShape->  nSHPType = = SHPT_MULTIPOINT || psShape->nSHPType == SHPT_MULTIPOINTM || psShape->nSHPType == SHPT_MULTIPOINTZ  ) 

Definition at line 1454 of file shpopen.c.

References memcpy(), SHPInfo::pabyRec, psShape, and SwapWord().

Here is the call graph for this function:

if ( bBigEndian   ) 

Definition at line 1309 of file shpopen.c.

if ( psSHP->panRecSize+  8[hEntity],
psSHP->  nBufSize 
)

Definition at line 1290 of file shpopen.c.

References SHPInfo::nBufSize, SHPInfo::pabyRec, SHPInfo::panRecSize, and SfRealloc().

Here is the call graph for this function:

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

Definition at line 803 of file shpopen.c.

References FALSE, and TRUE.

memcpy ( &psShape->  nSHPType,
psSHP->pabyRec 8,
 
)

return ( psShape   ) 

return ( psObject   ) 

static void* SfRealloc ( void *  pMem,
int  nNewSize 
) [static]

Definition at line 221 of file shpopen.c.

References NULL.

void SHPAPI_CALL SHPClose ( SHPHandle  psSHP  ) 

Definition at line 553 of file shpopen.c.

References SHPInfo::bUpdated, SHPInfo::fpSHP, SHPInfo::fpSHX, NULL, SHPInfo::pabyRec, SHPInfo::panRecOffset, SHPInfo::panRecSize, and SHPWriteHeader().

Referenced by addSOrder(), addToFromNode(), catchmentPoly(), createTinShapeFile(), extractRiver4mTIN(), generateShape(), mergeFeatures(), simplifyPolySHP(), splitLineAtVertices(), and streamSegmentationShp().

Here is the call graph for this function:

SHPComputeExtents ( psObject   ) 

void SHPAPI_CALL SHPComputeExtents ( SHPObject psObject  ) 

Definition at line 749 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.

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

Definition at line 617 of file shpopen.c.

References bBigEndian, ByteCopy, FALSE, NULL, SHPOpen(), SwapWord(), and TRUE.

Referenced by catchmentPoly(), createTinShapeFile(), extractRiver4mTIN(), generateShape(), mergeFeatures(), polygonToPolyline(), simplifyPolySHP(), splitLineAtVertices(), and streamSegmentationShp().

Here is the call graph for this function:

SHPObject SHPAPI_CALL1* SHPCreateObject ( int  nSHPType,
int  nShapeId,
int  nParts,
int *  panPartStart,
int *  panPartType,
int  nVertices,
double *  padfX,
double *  padfY,
double *  padfZ,
double *  padfM 
)

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

Referenced by catchmentPoly(), extractRiver4mTIN(), simplifyPolySHP(), splitLineAtVertices(), and streamGenShp().

void SHPAPI_CALL SHPDestroyObject ( SHPObject psShape  ) 

Definition at line 1694 of file shpopen.c.

References NULL, and psShape.

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

Definition at line 588 of file shpopen.c.

References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, SHPInfo::nRecords, SHPInfo::nShapeType, and NULL.

Referenced by generatePolyFile(), generateShape(), and polygonToPolyLineDialogDlg::run().

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

Definition at line 341 of file shpopen.c.

References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, bBigEndian, SHPInfo::bUpdated, FALSE, SHPInfo::fpSHP, SHPInfo::fpSHX, fread(), MAX, memcpy(), SHPInfo::nFileSize, SHPInfo::nMaxRecords, SHPInfo::nRecords, SHPInfo::nShapeType, NULL, SHPInfo::panRecOffset, SHPInfo::panRecSize, SwapWord(), and TRUE.

Referenced by addSOrder(), addToFromNode(), extractRiver4mTIN(), generatePolyFile(), generateShape(), mergeFeatures(), polygonToPolyline(), attFileDlg::run(), polygonToPolyLineDialogDlg::run(), SHPCreate(), simplifyPolySHP(), and splitLineAtVertices().

Here is the call graph for this function:

const char SHPAPI_CALL1* SHPPartTypeName (  ) 

Definition at line 1660 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 1725 of file shpopen.c.

References FALSE, SHPObject::nParts, SHPObject::nSHPType, SHPObject::nVertices, SHPObject::padfX, SHPObject::padfY, SHPObject::panPartStart, SHPT_POLYGON, SHPT_POLYGONM, and SHPT_POLYGONZ.

const char SHPAPI_CALL1* SHPTypeName (  ) 

Definition at line 1603 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.

static void SHPWriteHeader ( SHPHandle  psSHP  )  [static]

Definition at line 237 of file shpopen.c.

References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, bBigEndian, ByteCopy, SHPInfo::fpSHP, SHPInfo::fpSHX, fseek(), SHPInfo::nFileSize, SHPInfo::nRecords, SHPInfo::nShapeType, SHPInfo::panRecOffset, SHPInfo::panRecSize, and SwapWord().

Referenced by SHPClose().

Here is the call graph for this function:

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

Definition at line 914 of file shpopen.c.

References _SHPSetBounds(), bBigEndian, SHPInfo::bUpdated, ByteCopy, memcpy(), SHPInfo::nMaxRecords, SHPObject::nParts, SHPInfo::nRecords, SHPInfo::nShapeType, SHPObject::nSHPType, SHPObject::nVertices, pabyRec, SHPObject::panPartStart, SHPObject::panPartType, SHPInfo::panRecOffset, SHPInfo::panRecSize, SfRealloc(), SHPT_ARC, SHPT_ARCM, SHPT_ARCZ, SHPT_MULTIPATCH, SHPT_NULL, SHPT_POLYGON, SHPT_POLYGONM, SHPT_POLYGONZ, SwapWord(), and TRUE.

Referenced by catchmentPoly(), createTinShapeFile(), extractRiver4mTIN(), generateShape(), mergeFeatures(), simplifyPolySHP(), splitLineAtVertices(), and streamGenShp().

Here is the call graph for this function:

static void SwapWord ( int  length,
void *  wordP 
) [static]

Definition at line 200 of file shpopen.c.

Referenced by _SHPSetBounds(), if(), SHPCreate(), SHPOpen(), SHPWriteHeader(), and SHPWriteObject().


Variable Documentation

int bBigEndian [static]

Definition at line 191 of file shpopen.c.

Referenced by _SHPSetBounds(), SHPCreate(), SHPOpen(), SHPWriteHeader(), and SHPWriteObject().

psShape nShapeId = hEntity

Definition at line 1306 of file shpopen.c.

psObject nShapeId = nShapeId

Definition at line 798 of file shpopen.c.

psObject nSHPType = nSHPType

Definition at line 797 of file shpopen.c.

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

Definition at line 1305 of file shpopen.c.

Referenced by _SHPSetBounds(), if(), and SHPDestroyObject().

char rcsid[] [static]

Initial value:

 
  "$Id: shpopen.c,v 1.39 2002/08/26 06:46:56 warmerda Exp $"

Definition at line 161 of file shpopen.c.


Generated on Sun Aug 5 17:34:49 2007 for PIHMgis by  doxygen 1.5.2