PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ DBFGetFieldInfo()

DBFFieldType SHPAPI_CALL DBFGetFieldInfo ( DBFHandle  psDBF,
int  iField,
char *  pszFieldName,
int *  pnWidth,
int *  pnDecimals 
)

Definition at line 1274 of file dbfopen.c.

1277{
1278 if( iField < 0 || iField >= psDBF->nFields )
1279 return( FTInvalid );
1280
1281 if( pnWidth != SHPLIB_NULLPTR )
1282 *pnWidth = psDBF->panFieldSize[iField];
1283
1284 if( pnDecimals != SHPLIB_NULLPTR )
1285 *pnDecimals = psDBF->panFieldDecimals[iField];
1286
1287 if( pszFieldName != SHPLIB_NULLPTR )
1288 {
1289 int i;
1290
1291 strncpy( pszFieldName, STATIC_CAST(char *,psDBF->pszHeader)+iField*XBASE_FLDHDR_SZ,
1293 pszFieldName[XBASE_FLDNAME_LEN_READ] = '\0';
1294 for( i = XBASE_FLDNAME_LEN_READ - 1; i > 0 && pszFieldName[i] == ' '; i-- )
1295 pszFieldName[i] = '\0';
1296 }
1297
1298 if ( psDBF->pachFieldType[iField] == 'L' )
1299 return( FTLogical );
1300
1301 else if( psDBF->pachFieldType[iField] == 'D' )
1302 return( FTDate );
1303
1304 else if( psDBF->pachFieldType[iField] == 'N'
1305 || psDBF->pachFieldType[iField] == 'F' )
1306 {
1307 if( psDBF->panFieldDecimals[iField] > 0
1308 || psDBF->panFieldSize[iField] >= 10 )
1309 return( FTDouble );
1310 else
1311 return( FTInteger );
1312 }
1313 else
1314 {
1315 return( FTString );
1316 }
1317}
#define STATIC_CAST(type, x)
Definition dbfopen.c:96
#define SHPLIB_NULLPTR
Definition dbfopen.c:99
@ FTDouble
Definition shapefil.h:641
@ FTString
Definition shapefil.h:639
@ FTInvalid
Definition shapefil.h:644
@ FTLogical
Definition shapefil.h:642
@ FTDate
Definition shapefil.h:643
@ FTInteger
Definition shapefil.h:640
#define XBASE_FLDHDR_SZ
Definition shapefil.h:648
#define XBASE_FLDNAME_LEN_READ
Definition shapefil.h:650
int * panFieldDecimals
Definition shapefil.h:603
int nFields
Definition shapefil.h:600
int * panFieldSize
Definition shapefil.h:602
char * pszHeader
Definition shapefil.h:606
char * pachFieldType
Definition shapefil.h:604

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(), and ShpLoaderOpenShape().

Here is the caller graph for this function: