本文整理汇总了C++中OGRFeature::UnsetField方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeature::UnsetField方法的具体用法?C++ OGRFeature::UnsetField怎么用?C++ OGRFeature::UnsetField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeature
的用法示例。
在下文中一共展示了OGRFeature::UnsetField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _addFeature
void OgrWriter::_addFeature(OGRLayer* layer, shared_ptr<Feature> f, shared_ptr<Geometry> g)
{
OGRFeature* poFeature = OGRFeature::CreateFeature( layer->GetLayerDefn() );
// set all the column values.
const QVariantMap& vm = f->getValues();
for (QVariantMap::const_iterator it = vm.constBegin(); it != vm.constEnd(); ++it)
{
const QVariant& v = it.value();
QByteArray ba = it.key().toUtf8();
// If the field DOESN'T exist in the output layer, skip it.
if (poFeature->GetFieldIndex(ba.constData()) == -1)
{
continue;
}
switch (v.type())
{
case QVariant::Invalid:
poFeature->UnsetField(poFeature->GetFieldIndex(ba.constData()));
break;
case QVariant::Int:
poFeature->SetField(ba.constData(), v.toInt());
break;
case QVariant::Double:
poFeature->SetField(ba.constData(), v.toDouble());
break;
case QVariant::String:
{
QByteArray vba = v.toString().toUtf8();
poFeature->SetField(ba.constData(), vba.constData());
break;
}
default:
strictError("Can't convert the provided value into an OGR value. (" + v.toString() + ")");
return;
}
}
// convert the geometry.
shared_ptr<GeometryCollection> gc = dynamic_pointer_cast<GeometryCollection>(g);
if (gc.get() != 0)
{
for (size_t i = 0; i < gc->getNumGeometries(); i++)
{
const Geometry* child = gc->getGeometryN(i);
_addFeatureToLayer(layer, f, child, poFeature);
}
}
else
{
_addFeatureToLayer(layer, f, g.get(), poFeature);
}
OGRFeature::DestroyFeature(poFeature);
}