GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
|
#include "shapefil.h"
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
Go to the source code of this file.
Macros | |
#define | STRCASECMP(a, b) (strcasecmp(a, b)) |
#define | CPLsprintf sprintf |
#define | CPLsnprintf snprintf |
#define | FALSE 0 |
#define | TRUE 1 |
#define | XBASE_FILEHDR_SZ 32 |
#define | HEADER_RECORD_TERMINATOR 0x0D |
#define | END_OF_FILE_CHARACTER 0x1A |
#define | CPL_IGNORE_RET_VAL_INT(x) x |
#define | STATIC_CAST(type, x) ((type)(x)) |
#define | REINTERPRET_CAST(type, x) ((type)(x)) |
#define | CONST_CAST(type, x) ((type)(x)) |
#define | SHPLIB_NULLPTR NULL |
Functions | |
void SHPAPI_CALL | DBFUpdateHeader (DBFHandle psDBF) |
void SHPAPI_CALL | DBFSetLastModifiedDate (DBFHandle psDBF, int nYYSince1900, int nMM, int nDD) |
DBFHandle SHPAPI_CALL | DBFOpen (const char *pszFilename, const char *pszAccess) |
DBFHandle SHPAPI_CALL | DBFOpenLL (const char *pszFilename, const char *pszAccess, SAHooks *psHooks) |
void SHPAPI_CALL | DBFClose (DBFHandle psDBF) |
DBFHandle SHPAPI_CALL | DBFCreate (const char *pszFilename) |
DBFHandle SHPAPI_CALL | DBFCreateEx (const char *pszFilename, const char *pszCodePage) |
DBFHandle SHPAPI_CALL | DBFCreateLL (const char *pszFilename, const char *pszCodePage, SAHooks *psHooks) |
int SHPAPI_CALL | DBFAddField (DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals) |
int SHPAPI_CALL | DBFAddNativeFieldType (DBFHandle psDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals) |
int SHPAPI_CALL | DBFReadIntegerAttribute (DBFHandle psDBF, int iRecord, int iField) |
double SHPAPI_CALL | DBFReadDoubleAttribute (DBFHandle psDBF, int iRecord, int iField) |
const char SHPAPI_CALL1 * | DBFReadStringAttribute (DBFHandle psDBF, int iRecord, int iField){ return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'C') |
const char SHPAPI_CALL1 * | DBFReadLogicalAttribute (DBFHandle psDBF, int iRecord, int iField){ return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'L') |
int SHPAPI_CALL | DBFIsAttributeNULL (DBFHandle psDBF, int iRecord, int iField) |
int SHPAPI_CALL | DBFGetFieldCount (DBFHandle psDBF) |
int SHPAPI_CALL | DBFGetRecordCount (DBFHandle psDBF) |
DBFFieldType SHPAPI_CALL | DBFGetFieldInfo (DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals) |
int SHPAPI_CALL | DBFWriteAttributeDirectly (DBFHandle psDBF, int hEntity, int iField, void *pValue) |
int SHPAPI_CALL | DBFWriteDoubleAttribute (DBFHandle psDBF, int iRecord, int iField, double dValue) |
int SHPAPI_CALL | DBFWriteIntegerAttribute (DBFHandle psDBF, int iRecord, int iField, int nValue) |
int SHPAPI_CALL | DBFWriteStringAttribute (DBFHandle psDBF, int iRecord, int iField, const char *pszValue) |
int SHPAPI_CALL | DBFWriteNULLAttribute (DBFHandle psDBF, int iRecord, int iField) |
int SHPAPI_CALL | DBFWriteLogicalAttribute (DBFHandle psDBF, int iRecord, int iField, const char lValue) |
int SHPAPI_CALL | DBFWriteTuple (DBFHandle psDBF, int hEntity, void *pRawTuple) |
const char SHPAPI_CALL1 * | DBFReadTuple (DBFHandle psDBF, int hEntity){ if(hEntity< 0||hEntity >=psDBF->nRecords) return SHPLIB_NULLPTR;if(!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR;return STATIC_CAST(const char *, psDBF->pszCurrentRecord |
DBFHandle SHPAPI_CALL | DBFCloneEmpty (DBFHandle psDBF, const char *pszFilename) |
char SHPAPI_CALL | DBFGetNativeFieldType (DBFHandle psDBF, int iField) |
int SHPAPI_CALL | DBFGetFieldIndex (DBFHandle psDBF, const char *pszFieldName) |
int SHPAPI_CALL | DBFIsRecordDeleted (DBFHandle psDBF, int iShape) |
int SHPAPI_CALL | DBFMarkRecordDeleted (DBFHandle psDBF, int iShape, int bIsDeleted) |
const char SHPAPI_CALL1 * | DBFGetCodePage (DBFHandle psDBF){ if(psDBF==SHPLIB_NULLPTR) return SHPLIB_NULLPTR;return psDBF->pszCodePage;}int SHPAPI_CALL DBFDeleteField(DBFHandle psDBF, int iField |
int SHPAPI_CALL | DBFReorderFields (DBFHandle psDBF, int *panMap) |
int SHPAPI_CALL | DBFAlterFieldDefn (DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals) |
void SHPAPI_CALL | DBFSetWriteEndOfFileChar (DBFHandle psDBF, int bWriteFlag) |
int SHPAPI_CALL DBFAddField | ( | DBFHandle | psDBF, |
const char * | pszFieldName, | ||
DBFFieldType | eType, | ||
int | nWidth, | ||
int | nDecimals | ||
) |
int SHPAPI_CALL DBFAddNativeFieldType | ( | DBFHandle | psDBF, |
const char * | pszFieldName, | ||
char | chType, | ||
int | nWidth, | ||
int | nDecimals | ||
) |
Definition at line 792 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFUpdateHeader(), END_OF_FILE_CHARACTER, SAHooks::Error, FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::sHooks, STATIC_CAST, TRUE, XBASE_FLD_MAX_WIDTH, XBASE_FLDHDR_SZ, and XBASE_FLDNAME_LEN_WRITE.
Referenced by DBFAddField().
int SHPAPI_CALL DBFAlterFieldDefn | ( | DBFHandle | psDBF, |
int | iField, | ||
const char * | pszFieldName, | ||
char | chType, | ||
int | nWidth, | ||
int | nDecimals | ||
) |
Definition at line 1989 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFUpdateHeader(), END_OF_FILE_CHARACTER, FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::sHooks, STATIC_CAST, TRUE, XBASE_FLD_MAX_WIDTH, XBASE_FLDHDR_SZ, and XBASE_FLDNAME_LEN_WRITE.
DBFHandle SHPAPI_CALL DBFCloneEmpty | ( | DBFHandle | psDBF, |
const char * | pszFilename | ||
) |
Definition at line 1574 of file dbfopen.c.
References DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFClose(), DBFCreateEx(), DBFOpen(), DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszHeader, SHPLIB_NULLPTR, STATIC_CAST, TRUE, and XBASE_FLDHDR_SZ.
void SHPAPI_CALL DBFClose | ( | DBFHandle | psDBF | ) |
Definition at line 572 of file dbfopen.c.
References DBFInfo::bNoHeader, DBFInfo::bUpdated, CPL_IGNORE_RET_VAL_INT, DBFUpdateHeader(), SAHooks::FClose, DBFInfo::fp, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::pszWorkField, DBFInfo::sHooks, and SHPLIB_NULLPTR.
Referenced by DBFCloneEmpty(), and DBFOpenLL().
DBFHandle SHPAPI_CALL DBFCreate | ( | const char * | pszFilename | ) |
Definition at line 620 of file dbfopen.c.
References DBFCreateEx().
DBFHandle SHPAPI_CALL DBFCreateEx | ( | const char * | pszFilename, |
const char * | pszCodePage | ||
) |
Definition at line 631 of file dbfopen.c.
References DBFCreateLL(), and SASetupDefaultHooks().
Referenced by DBFCloneEmpty(), and DBFCreate().
DBFHandle SHPAPI_CALL DBFCreateLL | ( | const char * | pszFilename, |
const char * | pszCodePage, | ||
SAHooks * | psHooks | ||
) |
Definition at line 647 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bRequireNextWriteSeek, CONST_CAST, DBFSetLastModifiedDate(), DBFSetWriteEndOfFileChar(), FALSE, SAHooks::FClose, SAHooks::FOpen, DBFInfo::fp, SAHooks::FWrite, DBFInfo::iLanguageDriver, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, SAHooks::Remove, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, TRUE, and XBASE_FILEHDR_SZ.
Referenced by DBFCreateEx().
const char SHPAPI_CALL1 * DBFGetCodePage | ( | DBFHandle | psDBF | ) |
Definition at line 1730 of file dbfopen.c.
References SHPLIB_NULLPTR.
int SHPAPI_CALL DBFGetFieldCount | ( | DBFHandle | psDBF | ) |
Definition at line 1174 of file dbfopen.c.
References DBFInfo::nFields.
Referenced by DBFGetFieldIndex().
int SHPAPI_CALL DBFGetFieldIndex | ( | DBFHandle | psDBF, |
const char * | pszFieldName | ||
) |
Definition at line 1649 of file dbfopen.c.
References DBFGetFieldCount(), DBFGetFieldInfo(), name, SHPLIB_NULLPTR, STRCASECMP, and XBASE_FLDNAME_LEN_READ.
DBFFieldType SHPAPI_CALL DBFGetFieldInfo | ( | DBFHandle | psDBF, |
int | iField, | ||
char * | pszFieldName, | ||
int * | pnWidth, | ||
int * | pnDecimals | ||
) |
Definition at line 1200 of file dbfopen.c.
References FTDate, FTDouble, FTInteger, FTInvalid, FTLogical, FTString, DBFInfo::nFields, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldSize, DBFInfo::pszHeader, SHPLIB_NULLPTR, STATIC_CAST, XBASE_FLDHDR_SZ, and XBASE_FLDNAME_LEN_READ.
Referenced by DBFGetFieldIndex().
char SHPAPI_CALL DBFGetNativeFieldType | ( | DBFHandle | psDBF, |
int | iField | ||
) |
Definition at line 1632 of file dbfopen.c.
References DBFInfo::pachFieldType.
int SHPAPI_CALL DBFGetRecordCount | ( | DBFHandle | psDBF | ) |
Definition at line 1186 of file dbfopen.c.
References DBFInfo::nRecords.
int SHPAPI_CALL DBFIsAttributeNULL | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField | ||
) |
Definition at line 1158 of file dbfopen.c.
References DBFReadStringAttribute(), DBFInfo::pachFieldType, SHPLIB_NULLPTR, and TRUE.
int SHPAPI_CALL DBFIsRecordDeleted | ( | DBFHandle | psDBF, |
int | iShape | ||
) |
Definition at line 1668 of file dbfopen.c.
References FALSE, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, and TRUE.
int SHPAPI_CALL DBFMarkRecordDeleted | ( | DBFHandle | psDBF, |
int | iShape, | ||
int | bIsDeleted | ||
) |
Definition at line 1692 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bUpdated, FALSE, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, and TRUE.
DBFHandle SHPAPI_CALL DBFOpen | ( | const char * | pszFilename, |
const char * | pszAccess | ||
) |
Definition at line 346 of file dbfopen.c.
References DBFOpenLL(), and SASetupDefaultHooks().
Referenced by DBFCloneEmpty().
DBFHandle SHPAPI_CALL DBFOpenLL | ( | const char * | pszFilename, |
const char * | pszAccess, | ||
SAHooks * | psHooks | ||
) |
Definition at line 378 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bRequireNextWriteSeek, DBFClose(), DBFSetLastModifiedDate(), DBFSetWriteEndOfFileChar(), FALSE, SAHooks::FClose, SAHooks::FOpen, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, HEADER_RECORD_TERMINATOR, DBFInfo::iLanguageDriver, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, REINTERPRET_CAST, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, TRUE, XBASE_FILEHDR_SZ, and XBASE_FLDHDR_SZ.
Referenced by DBFOpen().
double SHPAPI_CALL DBFReadDoubleAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField | ||
) |
Definition at line 1068 of file dbfopen.c.
References SHPLIB_NULLPTR, and STATIC_CAST.
int SHPAPI_CALL DBFReadIntegerAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField | ||
) |
Definition at line 1050 of file dbfopen.c.
References SHPLIB_NULLPTR, and STATIC_CAST.
const char SHPAPI_CALL1 * DBFReadLogicalAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField | ||
) | const |
References STATIC_CAST.
const char SHPAPI_CALL1 * DBFReadStringAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField | ||
) | const |
References STATIC_CAST.
Referenced by DBFIsAttributeNULL().
const char SHPAPI_CALL1 * DBFReadTuple | ( | DBFHandle | psDBF, |
int | hEntity | ||
) | -> nRecords) return SHPLIB_NULLPTR;if(!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR;return STATIC_CAST(const char *, psDBF->pszCurrentRecord |
References SHPLIB_NULLPTR, and STATIC_CAST.
int SHPAPI_CALL DBFReorderFields | ( | DBFHandle | psDBF, |
int * | panMap | ||
) |
Definition at line 1869 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFUpdateHeader(), FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszHeader, DBFInfo::sHooks, STATIC_CAST, TRUE, and XBASE_FLDHDR_SZ.
void SHPAPI_CALL DBFSetLastModifiedDate | ( | DBFHandle | psDBF, |
int | nYYSince1900, | ||
int | nMM, | ||
int | nDD | ||
) |
Definition at line 332 of file dbfopen.c.
References DBFInfo::nUpdateDay, DBFInfo::nUpdateMonth, and DBFInfo::nUpdateYearSince1900.
Referenced by DBFCreateLL(), and DBFOpenLL().
void SHPAPI_CALL DBFSetWriteEndOfFileChar | ( | DBFHandle | psDBF, |
int | bWriteFlag | ||
) |
Definition at line 2228 of file dbfopen.c.
References DBFInfo::bWriteEndOfFileChar.
Referenced by DBFCreateLL(), and DBFOpenLL().
void SHPAPI_CALL DBFUpdateHeader | ( | DBFHandle | psDBF | ) |
Definition at line 298 of file dbfopen.c.
References DBFInfo::bNoHeader, SAHooks::FFlush, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nRecords, DBFInfo::nUpdateDay, DBFInfo::nUpdateMonth, DBFInfo::nUpdateYearSince1900, DBFInfo::sHooks, STATIC_CAST, and XBASE_FILEHDR_SZ.
Referenced by DBFAddNativeFieldType(), DBFAlterFieldDefn(), DBFClose(), and DBFReorderFields().
int SHPAPI_CALL DBFWriteAttributeDirectly | ( | DBFHandle | psDBF, |
int | hEntity, | ||
int | iField, | ||
void * | pValue | ||
) |
Definition at line 1372 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, FALSE, DBFInfo::nCurrentRecord, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, REINTERPRET_CAST, STATIC_CAST, and TRUE.
int SHPAPI_CALL DBFWriteDoubleAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField, | ||
double | dValue | ||
) |
Definition at line 1436 of file dbfopen.c.
References STATIC_CAST.
int SHPAPI_CALL DBFWriteIntegerAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField, | ||
int | nValue | ||
) |
Definition at line 1449 of file dbfopen.c.
References STATIC_CAST.
int SHPAPI_CALL DBFWriteLogicalAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField, | ||
const char | lValue | ||
) |
Definition at line 1491 of file dbfopen.c.
References CONST_CAST, and STATIC_CAST.
int SHPAPI_CALL DBFWriteNULLAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField | ||
) |
Definition at line 1479 of file dbfopen.c.
References SHPLIB_NULLPTR.
int SHPAPI_CALL DBFWriteStringAttribute | ( | DBFHandle | psDBF, |
int | iRecord, | ||
int | iField, | ||
const char * | pszValue | ||
) |
Definition at line 1464 of file dbfopen.c.
References CONST_CAST, and STATIC_CAST.
int SHPAPI_CALL DBFWriteTuple | ( | DBFHandle | psDBF, |
int | hEntity, | ||
void * | pRawTuple | ||
) |
Definition at line 1506 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, FALSE, DBFInfo::nCurrentRecord, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, REINTERPRET_CAST, and TRUE.