1 #ifndef _SHAPEFILE_H_INCLUDED
2 #define _SHAPEFILE_H_INCLUDED
102 #include <dbmalloc.h>
106 #include "cpl_error.h"
122 #define TRIM_DBF_WHITESPACE
129 #define DISABLE_MULTIPATCH_MEASURE
160 #ifdef SHAPELIB_DLLEXPORT
161 # define SHPAPI_CALL __declspec(dllexport)
162 # define SHPAPI_CALL1(x) __declspec(dllexport) x
166 # if defined(USE_GCC_VISIBILITY_FLAG)
167 # define SHPAPI_CALL __attribute__ ((visibility("default")))
168 # define SHPAPI_CALL1(x) __attribute__ ((visibility("default"))) x
175 # define SHPAPI_CALL1(x) x SHPAPI_CALL
182 #ifndef DISABLE_CVSID
183 # define SHP_CVSID(string) static char cpl_cvsid[] = string; \
184 static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
186 # define SHP_CVSID(string)
199 SAFile (*FOpen) (
const char *filename,
const char *path);
231 double adBoundsMin[4];
232 double adBoundsMax[4];
248 #define SHPT_POLYGON 5
249 #define SHPT_MULTIPOINT 8
250 #define SHPT_POINTZ 11
252 #define SHPT_POLYGONZ 15
253 #define SHPT_MULTIPOINTZ 18
254 #define SHPT_POINTM 21
256 #define SHPT_POLYGONM 25
257 #define SHPT_MULTIPOINTM 28
258 #define SHPT_MULTIPATCH 31
266 #define SHPP_TRISTRIP 0
267 #define SHPP_TRIFAN 1
268 #define SHPP_OUTERRING 2
269 #define SHPP_INNERRING 3
270 #define SHPP_FIRSTRING 4
313 SHPOpen(
const char * pszShapeFile,
const char * pszAccess );
315 SHPOpenLL(
const char *pszShapeFile,
const char *pszAccess,
318 SHPCreate(
const char * pszShapeFile,
int nShapeType );
320 SHPCreateLL(
const char * pszShapeFile,
int nShapeType,
323 SHPGetInfo( SHPHandle hSHP,
int * pnEntities,
int * pnShapeType,
324 double * padfMinBound,
double * padfMaxBound );
337 const
int * panPartStart, const
int * panPartType,
339 const
double * padfX, const
double * padfY,
340 const
double * padfZ, const
double * padfM );
343 const
double * padfX,
344 const
double * padfY,
345 const
double * padfZ );
363 #define MAX_SUBNODE 4
366 #define MAX_DEFAULT_TREE_DEPTH 12
397 SHPCreateTree( SHPHandle hSHP,
int nDimension,
int nMaxDepth,
398 double *padfBoundsMin,
double *padfBoundsMax );
400 SHPDestroyTree(
SHPTree * hTree );
419 double * padfBoundsMin,
420 double * padfBoundsMax,
423 SHPCheckBoundsOverlap(
double *,
double *,
double *,
double *,
int );
427 double *padfBoundsMin,
double *padfBoundsMax,
446 int *panFieldDecimals;
452 int bCurrentRecordModified;
453 char *pszCurrentRecord;
455 int nWorkFieldLength;
461 double dfDoubleField;
464 typedef DBFInfo * DBFHandle;
474 #define XBASE_FLDHDR_SZ 32
478 DBFOpen(
const char * pszDBFFile,
const char * pszAccess );
480 DBFOpenLL(
const char * pszDBFFile,
const char * pszAccess,
492 DBFAddField( DBFHandle hDBF,
const char * pszFieldName,
493 DBFFieldType eType,
int nWidth,
int nDecimals );
497 char chType,
int nWidth,
int nDecimals );
501 char * pszFieldName,
int * pnWidth,
int * pnDecimals );
522 double dFieldValue );
525 const
char * pszFieldValue );
531 const
char lFieldValue);
538 DBFWriteTuple(DBFHandle psDBF,
int hEntity,
void * pRawTuple );
int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle psDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals)
int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord, int iField, int nValue)
double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle psDBF, int iRecord, int iField)
const char SHPAPI_CALL1 * DBFReadLogicalAttribute(DBFHandle psDBF, int iRecord, int iField){return((const char *) DBFReadAttribute(psDBF, iRecord, iField, 'L')
void SHPAPI_CALL DBFClose(DBFHandle psDBF)
int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, int bIsDeleted)
void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject)
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)
struct shape_tree_node SHPTreeNode
void SHPAPI_CALL SHPTreeTrimExtraNodes(SHPTree *hTree)
DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, SAHooks *psHooks)
int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject)
DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename)
char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField)
const char SHPAPI_CALL1 * DBFReadStringAttribute(DBFHandle psDBF, int iRecord, int iField){return((const char *) DBFReadAttribute(psDBF, iRecord, iField, 'C')
void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities, int *pnShapeType, double *padfMinBound, double *padfMaxBound)
int SHPAPI_CALL DBFAddField(DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
SHPObject ** papsShapeObj
int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle psDBF, int iRecord, int iField, const char lValue)
void SHPAPI_CALL SHPClose(SHPHandle hSHP)
int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF)
int SHPAPI_CALL SHPTreeAddShapeId(SHPTree *hTree, SHPObject *psObject)
DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals)
int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle psDBF, int iRecord, int iField, double dValue)
int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord, int iField, const char *pszValue)
int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField)
DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess)
int SHPAPI_CALL1 * SHPTreeFindLikelyShapes(SHPTree *hTree, double *padfBoundsMin, double *padfBoundsMax, int *);intSHPAPI_CALLSHPCheckBoundsOverlap(double *, double *, double *, double *, int
int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape)
int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject *psObject)
void SASetupDefaultHooks(SAHooks *psHooks)
SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszShapeFile, const char *pszAccess, SAHooks *psHooks)
SHPTree SHPAPI_CALL1 * SHPCreateTree(SHPHandle hSHP, int nDimension, int nMaxDepth, double *padfBoundsMin, double *padfBoundsMax);voidSHPAPI_CALLSHPDestroyTree(SHPTree *hTree
SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType)
DBFHandle SHPAPI_CALL DBFCreate(const char *pszFilename)
DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, SAHooks *psHooks)
SHPTree SHPAPI_CALL SHPReadTree(const char *pszFilename)
int SHPAPI_CALL SHPTreeRemoveShapeId(SHPTree *hTree, int nShapeId)
int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple)
const char SHPAPI_CALL1 * DBFReadTuple(DBFHandle psDBF, int hEntity){return(NULL
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_CALL1 * SHPSearchDiskTree(FILE *fp, double *padfBoundsMin, double *padfBoundsMax, int *pnShapeCount);typedef struct{SAHooks sHooks;SAFile fp;intnRecords;intnRecordLength;intnHeaderLength;intnFields;int *panFieldOffset;int *panFieldSize;int *panFieldDecimals;char *pachFieldType;char *pszHeader;intnCurrentRecord;intbCurrentRecordModified;char *pszCurrentRecord;intnWorkFieldLength;char *pszWorkField;intbNoHeader;intbUpdated;doubledfDoubleField;}DBFInfo;typedef DBFInfo *DBFHandle;typedef enum{FTString, FTInteger, FTDouble, FTLogical, FTInvalid}DBFFieldType;#define XBASE_FLDHDR_SZDBFHandle SHPAPI_CALLDBFOpen(const char *pszDBFFile, const char *pszAccess
struct shape_tree_node * apsSubNode[MAX_SUBNODE]
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle hSHP, int iShape);int SHPAPI_CALLSHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject
SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszShapeFile, 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
const char SHPAPI_CALL1 * SHPPartTypeName(int nPartType){switch(nPartType
SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, const char *pszAccess)
void SHPAPI_CALL SHPWriteHeader(SHPHandle hSHP)
int SHPAPI_CALL SHPWriteTree(SHPTree *hTree, const char *pszFilename)
int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle psDBF, int iRecord, int iField)
int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, void *pValue)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
int SHPAPI_CALL SHPTreeAddObject(SHPTree *hTree, SHPObject *psObject)
int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField)
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType