1 #ifndef SHAPEFILE_H_INCLUDED 2 #define SHAPEFILE_H_INCLUDED 139 #define _FILE_OFFSET_BITS 64 141 #include <sys/types.h> 144 #include <dbmalloc.h> 159 #define TRIM_DBF_WHITESPACE 166 #define DISABLE_MULTIPATCH_MEASURE 197 #ifdef SHAPELIB_DLLEXPORT 198 # define SHPAPI_CALL __declspec(dllexport) 199 # define SHPAPI_CALL1(x) __declspec(dllexport) x 203 # if defined(USE_GCC_VISIBILITY_FLAG) 204 # define SHPAPI_CALL __attribute__ ((visibility("default"))) 205 # define SHPAPI_CALL1(x) __attribute__ ((visibility("default"))) x 212 # define SHPAPI_CALL1(x) x SHPAPI_CALL 219 #ifndef DISABLE_CVSID 220 # if defined(__GNUC__) && __GNUC__ >= 4 221 # define SHP_CVSID(string) static char cpl_cvsid[] __attribute__((used)) = string; 223 # define SHP_CVSID(string) static char cpl_cvsid[] = string; \ 224 static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); } 227 # define SHP_CVSID(string) 234 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 235 # define SHPAPI_WINDOWS 236 # define SHPAPI_UTF8_HOOKS 255 SAFile (*FOpen) (
const char *filename,
const char *access);
256 SAOffset (*FRead) (
void *p, SAOffset
size, SAOffset nmemb, SAFile file);
257 SAOffset (*FWrite)(
void *p, SAOffset
size, SAOffset nmemb, SAFile file);
258 SAOffset (*FSeek) ( SAFile file, SAOffset offset,
int whence );
260 int (*FFlush)( SAFile file );
261 int (*FClose)( SAFile file );
262 int (*Remove) (
const char *filename );
264 void (*Error) (
const char *message );
265 double (*Atof) (
const char *str );
269 #ifdef SHPAPI_UTF8_HOOKS 292 double adBoundsMin[4];
293 double adBoundsMax[4];
309 #define SHPT_POLYGON 5 310 #define SHPT_MULTIPOINT 8 311 #define SHPT_POINTZ 11 313 #define SHPT_POLYGONZ 15 314 #define SHPT_MULTIPOINTZ 18 315 #define SHPT_POINTM 21 317 #define SHPT_POLYGONM 25 318 #define SHPT_MULTIPOINTM 28 319 #define SHPT_MULTIPATCH 31 327 #define SHPP_TRISTRIP 0 328 #define SHPP_TRIFAN 1 329 #define SHPP_OUTERRING 2 330 #define SHPP_INNERRING 3 331 #define SHPP_FIRSTRING 4 374 SHPOpen(
const char * pszShapeFile,
const char * pszAccess );
376 SHPOpenLL(
const char *pszShapeFile,
const char *pszAccess,
379 SHPCreate(
const char * pszShapeFile,
int nShapeType );
381 SHPCreateLL(
const char * pszShapeFile,
int nShapeType,
384 SHPGetInfo( SHPHandle hSHP,
int * pnEntities,
int * pnShapeType,
385 double * padfMinBound,
double * padfMaxBound );
398 const
int * panPartStart, const
int * panPartType,
400 const
double * padfX, const
double * padfY,
401 const
double * padfZ, const
double * padfM );
404 const
double * padfX,
405 const
double * padfY,
406 const
double * padfZ );
424 #define MAX_SUBNODE 4 427 #define MAX_DEFAULT_TREE_DEPTH 12 432 double adfBoundsMin[4];
433 double adfBoundsMax[4];
458 SHPCreateTree( SHPHandle hSHP,
int nDimension,
int nMaxDepth,
459 double *padfBoundsMin,
double *padfBoundsMax );
461 SHPDestroyTree(
SHPTree * hTree );
478 double * padfBoundsMin,
479 double * padfBoundsMax,
482 SHPCheckBoundsOverlap(
double *,
double *,
double *,
double *,
int );
486 double *padfBoundsMin,
double *padfBoundsMax,
505 int *panFieldDecimals;
511 int bCurrentRecordModified;
512 char *pszCurrentRecord;
514 int nWorkFieldLength;
520 double dfDoubleField;
526 typedef DBFInfo * DBFHandle;
537 #define XBASE_FLDHDR_SZ 32 541 DBFOpen(
const char * pszDBFFile,
const char * pszAccess );
543 DBFOpenLL(
const char * pszDBFFile,
const char * pszAccess,
548 DBFCreateEx(
const char * pszDBFFile,
const char * pszCodePage );
557 DBFAddField( DBFHandle hDBF,
const char * pszFieldName,
558 DBFFieldType eType,
int nWidth,
int nDecimals );
562 char chType,
int nWidth,
int nDecimals );
572 char chType,
int nWidth,
int nDecimals );
576 char * pszFieldName,
int * pnWidth,
int * pnDecimals );
597 double dFieldValue );
600 const char * pszFieldValue );
606 const char lFieldValue);
613 DBFWriteTuple(DBFHandle psDBF,
int hEntity,
void * pRawTuple );
SHPObject ** papsShapeObj
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 DBFIsRecordDeleted(DBFHandle psDBF, int iShape)
int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
const char SHPAPI_CALL1 * DBFReadStringAttribute(DBFHandle hDBF, int iShape, int iField);const char SHPAPI_CALL1(*) DBFReadLogicalAttribute(DBFHandle hDBF, int iShape, int iField
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
int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle hDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals)
DBFHandle SHPAPI_CALL DBFCreate(const char *pszDBFFile)
int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple)
const char SHPAPI_CALL1 * DBFReadLogicalAttribute(DBFHandle psDBF, int iRecord, int iField){ return((const char *) DBFReadAttribute(psDBF, iRecord, iField, 'L')
int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
const char SHPAPI_CALL1 * DBFReadTuple(DBFHandle psDBF, int hEntity);int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple
DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszDBFFile, const char *pszAccess, SAHooks *psHooks)
const char SHPAPI_CALL1 * SHPPartTypeName(int nPartType){ switch(nPartType
int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals)
SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType)
struct shape_tree_node * apsSubNode[MAX_SUBNODE]
int SHPAPI_CALL DBFAddField(DBFHandle hDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities, int *pnShapeType, double *padfMinBound, double *padfMaxBound)
void SHPAPI_CALL SHPTreeTrimExtraNodes(SHPTree *hTree)
void SHPAPI_CALL SHPWriteHeader(SHPHandle hSHP)
char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle hDBF, int iField)
unsigned int * panRecOffset
SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, const char *pszAccess)
DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess)
const char SHPAPI_CALL1 * DBFGetCodePage(DBFHandle psDBF){ if(psDBF==NULL) return NULL;return psDBF->pszCodePage;}int SHPAPI_CALLDBFDeleteField(DBFHandle psDBF, int iField
SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszShapeFile, int nShapeType, SAHooks *psHooks)
SHPTree SHPAPI_CALL1 * SHPCreateTree(SHPHandle hSHP, int nDimension, int nMaxDepth, double *padfBoundsMin, double *padfBoundsMax);void SHPAPI_CALL SHPDestroyTree(SHPTree *hTree
int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, void *pValue)
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle hSHP, int iShape);int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject
int SHPAPI_CALL1 * SHPSearchDiskTree(FILE *fp, double *padfBoundsMin, double *padfBoundsMax, int *pnShapeCount);typedef struct{ SAHooks sHooks;SAFile fp;int nRecords;int nRecordLength;int nHeaderLength;int nFields;int *panFieldOffset;int *panFieldSize;int *panFieldDecimals;char *pachFieldType;char *pszHeader;int nCurrentRecord;int bCurrentRecordModified;char *pszCurrentRecord;int nWorkFieldLength;char *pszWorkField;int bNoHeader;int bUpdated;double dfDoubleField;int iLanguageDriver;char *pszCodePage;} DBFInfo;typedef DBFInfo *DBFHandle;typedef enum { FTString, FTInteger, FTDouble, FTLogical, FTDate, FTInvalid} DBFFieldType;#define XBASE_FLDHDR_SZDBFHandle SHPAPI_CALL DBFOpen(const char *pszDBFFile, const char *pszAccess
int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject)
int SHPAPI_CALL SHPWriteTree(SHPTree *hTree, const char *pszFilename)
DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename)
int SHPAPI_CALL SHPTreeRemoveShapeId(SHPTree *hTree, int nShapeId)
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType
int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle hDBF, int iShape, int iField, const char lFieldValue)
int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle hDBF, int iShape, int iField)
double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle hDBF, int iShape, int iField)
int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle hDBF, int iShape, int iField)
int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle hDBF, int iShape, int iField, const char *pszFieldValue)
int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, int bIsDeleted)
int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, int *panMap)
int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject *psObject)
int SHPAPI_CALL SHPTreeAddShapeId(SHPTree *hTree, SHPObject *psObject)
unsigned int * panRecSize
void SHPAPI_CALL DBFUpdateHeader(DBFHandle hDBF)
int SHPAPI_CALL SHPTreeAddObject(SHPTree *hTree, SHPObject *psObject)
SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszShapeFile, const char *pszAccess, SAHooks *psHooks)
int SHPAPI_CALL1 * SHPTreeFindLikelyShapes(SHPTree *hTree, double *padfBoundsMin, double *padfBoundsMax, int *);int SHPAPI_CALL SHPCheckBoundsOverlap(double *, double *, double *, double *, int
int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle hDBF, int iShape, int iField, double dFieldValue)
void SHPAPI_CALL DBFClose(DBFHandle hDBF)
int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle hDBF, int iShape, int iField)
void SHPAPI_CALL SHPClose(SHPHandle hSHP)
int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle hDBF, int iShape, int iField, int nFieldValue)
void SHPAPI_CALL SASetupDefaultHooks(SAHooks *psHooks)
DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszDBFFile, const char *pszCodePage, SAHooks *psHooks)
int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF)
int SHPAPI_CALL DBFDeleteField(DBFHandle hDBF, int iField)
DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszDBFFile, const char *pszCodePage)
struct shape_tree_node SHPTreeNode
void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject)