本文整理汇总了C++中CField::SetType方法的典型用法代码示例。如果您正苦于以下问题:C++ CField::SetType方法的具体用法?C++ CField::SetType怎么用?C++ CField::SetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CField
的用法示例。
在下文中一共展示了CField::SetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitFields
void CShapefileFeatureClass::InitFields()
{
m_allFields.clear();
int iField;
int lFieldnum =DBFGetFieldCount(m_dbfHandle);
char szFieldName[20];
int nWidth, nPrecision;
char chNativeType;
DBFFieldType eDBFType;
//获得属性字段的信息
for( iField = 0;
m_dbfHandle != NULL && iField < lFieldnum;
iField++ )
{
CField *pField =new CField();
chNativeType = DBFGetNativeFieldType( m_dbfHandle, iField );
eDBFType = DBFGetFieldInfo( m_dbfHandle, iField, szFieldName,
&nWidth, &nPrecision );
pField->SetName(szFieldName);
pField->SetLength(nWidth);
pField->SetPrecision(nPrecision);
if( chNativeType == 'D' )
{
/* XXX - mloskot:
* Shapefile date has following 8-chars long format: 20060101.
* OGR splits it as YYYY/MM/DD, so 2 additional characters are required.
* Is this correct assumtion? What about time part of date?
* Shouldn't this format look as datetime: YYYY/MM/DD HH:MM:SS
* with 4 additional characters?
*/
pField->SetLength( nWidth + 2 );
pField->SetType( FTYPE_DATE );
}
else if( eDBFType == FTDouble )
pField->SetType( FTYPE_DOUBLE);
else if( eDBFType == FTInteger )
pField->SetType(FTYPE_LONG);
else if(eDBFType==FTLogical)
pField->SetType(FTYPE_BOOL);
else
pField->SetType( FTYPE_STRING);
m_allFields.push_back(CFieldPtr(pField));
}
}
示例2: Init
void CShapefileFeatureClass::Init()
{
//获得矢量的图形类型
switch( m_shpHandle->nShapeType )
{
case SHPT_POINT:
case SHPT_POINTM:
case SHPT_POINTZ:
m_lshptype =GEOMETRY::geom::GEOS_POINT;
break;
case SHPT_ARC:
case SHPT_ARCM:
case SHPT_ARCZ:
m_lshptype =GEOMETRY::geom::GEOS_MULTILINESTRING;
break;
case SHPT_MULTIPOINT:
case SHPT_MULTIPOINTM:
case SHPT_MULTIPOINTZ:
m_lshptype =GEOMETRY::geom::GEOS_MULTIPOINT;
break;
case SHPT_POLYGON:
case SHPT_POLYGONM:
case SHPT_POLYGONZ:
m_lshptype =GEOMETRY::geom::GEOS_POLYGON;
break;
default:
m_lshptype =GEOMETRY::geom::GEOM_NULL;
break;
}
int iField;
int lFieldnum =DBFGetFieldCount(m_dbfHandle);
char szFieldName[20];
int nWidth, nPrecision;
char chNativeType;
DBFFieldType eDBFType;
//获得属性字段的信息
for( iField = 0;
m_dbfHandle != NULL && iField < lFieldnum;
iField++ )
{
CField *pField =new CField();
chNativeType = DBFGetNativeFieldType( m_dbfHandle, iField );
eDBFType = DBFGetFieldInfo( m_dbfHandle, iField, szFieldName,
&nWidth, &nPrecision );
pField->SetName(szFieldName);
pField->SetLength(nWidth);
pField->SetPrecision(nPrecision);
if( chNativeType == 'D' )
{
/* XXX - mloskot:
* Shapefile date has following 8-chars long format: 20060101.
* OGR splits it as YYYY/MM/DD, so 2 additional characters are required.
* Is this correct assumtion? What about time part of date?
* Shouldn't this format look as datetime: YYYY/MM/DD HH:MM:SS
* with 4 additional characters?
*/
pField->SetLength( nWidth + 2 );
pField->SetType( FTYPE_DATE );
}
else if( eDBFType == FTDouble )
pField->SetType( FTYPE_DOUBLE);
else if( eDBFType == FTInteger )
pField->SetType(FTYPE_LONG);
else
pField->SetType( FTYPE_STRING);
m_allFields.push_back(CFieldPtr(pField));
}
//获得投影信息
ReadPrj();
//如果记录大于10000条,则建立空间索引
if(m_shpHandle->nRecords>=SPATIALINDEX_MIN_SHAPE)
{
BuildSpatialIndex();
}
}