PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ DBFGetFieldInfo()

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

Definition at line 1265 of file dbfopen.c.

1268 {
1269  if( iField < 0 || iField >= psDBF->nFields )
1270  return( FTInvalid );
1271 
1272  if( pnWidth != SHPLIB_NULLPTR )
1273  *pnWidth = psDBF->panFieldSize[iField];
1274 
1275  if( pnDecimals != SHPLIB_NULLPTR )
1276  *pnDecimals = psDBF->panFieldDecimals[iField];
1277 
1278  if( pszFieldName != SHPLIB_NULLPTR )
1279  {
1280  int i;
1281 
1282  strncpy( pszFieldName, STATIC_CAST(char *,psDBF->pszHeader)+iField*XBASE_FLDHDR_SZ,
1284  pszFieldName[XBASE_FLDNAME_LEN_READ] = '\0';
1285  for( i = XBASE_FLDNAME_LEN_READ - 1; i > 0 && pszFieldName[i] == ' '; i-- )
1286  pszFieldName[i] = '\0';
1287  }
1288 
1289  if ( psDBF->pachFieldType[iField] == 'L' )
1290  return( FTLogical );
1291 
1292  else if( psDBF->pachFieldType[iField] == 'D' )
1293  return( FTDate );
1294 
1295  else if( psDBF->pachFieldType[iField] == 'N'
1296  || psDBF->pachFieldType[iField] == 'F' )
1297  {
1298  if( psDBF->panFieldDecimals[iField] > 0
1299  || psDBF->panFieldSize[iField] >= 10 )
1300  return( FTDouble );
1301  else
1302  return( FTInteger );
1303  }
1304  else
1305  {
1306  return( FTString );
1307  }
1308 }
#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: