本文整理汇总了C++中qgsfeaturemap::iterator类的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iterator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addAttributes
bool QgsMemoryProvider::addAttributes( const QList<QgsField> &attributes )
{
for ( QList<QgsField>::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
{
// Why are attributes restricted to int,double and string only?
switch ( it->type() )
{
case QVariant::Int:
case QVariant::Double:
case QVariant::String:
case QVariant::Date:
case QVariant::LongLong:
break;
default:
QgsDebugMsg( "Field type not supported: " + it->typeName() );
continue;
}
// add new field as a last one
mFields.append( *it );
for ( QgsFeatureMap::iterator fit = mFeatures.begin(); fit != mFeatures.end(); ++fit )
{
QgsFeature& f = fit.value();
f.attributes().append( QVariant() );
}
}
return true;
}
示例2: undo
void QgsVectorLayerUndoCommandChangeGeometry::undo()
{
if ( FID_IS_NEW( mFid ) )
{
// modify added features
QgsFeatureMap::iterator it = mBuffer->mAddedFeatures.find( mFid );
Q_ASSERT( it != mBuffer->mAddedFeatures.end() );
it.value().setGeometry( mOldGeom );
emit mBuffer->geometryChanged( mFid, mOldGeom );
}
else
{
// existing feature
if ( mOldGeom.isNull() )
{
mBuffer->mChangedGeometries.remove( mFid );
QgsFeature f;
if ( layer()->getFeatures( QgsFeatureRequest().setFilterFid( mFid ).setNoAttributes() ).nextFeature( f ) && f.hasGeometry() )
{
emit mBuffer->geometryChanged( mFid, f.geometry() );
}
}
else
{
mBuffer->mChangedGeometries[mFid] = mOldGeom;
emit mBuffer->geometryChanged( mFid, mOldGeom );
}
}
}
示例3: updateExtent
void QgsMemoryProvider::updateExtent()
{
if ( mFeatures.count() == 0 )
{
mExtent = QgsRectangle();
}
else
{
mExtent = mFeatures.begin().value().geometry()->boundingBox();
for ( QgsFeatureMap::iterator it = mFeatures.begin(); it != mFeatures.end(); ++it )
mExtent.unionRect( it.value().geometry()->boundingBox() );
}
}
示例4: changeAttributeValues
bool QgsMemoryProvider::changeAttributeValues( const QgsChangedAttributesMap & attr_map )
{
for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
QgsFeatureMap::iterator fit = mFeatures.find( it.key() );
if ( fit == mFeatures.end() )
continue;
const QgsAttributeMap& attrs = it.value();
for ( QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2 )
fit->changeAttribute( it2.key(), it2.value() );
}
return TRUE;
}
示例5: redo
void QgsVectorLayerUndoCommandChangeGeometry::redo()
{
if ( FID_IS_NEW( mFid ) )
{
// modify added features
QgsFeatureMap::iterator it = mBuffer->mAddedFeatures.find( mFid );
Q_ASSERT( it != mBuffer->mAddedFeatures.end() );
it.value().setGeometry( mNewGeom );
}
else
{
mBuffer->mChangedGeometries[ mFid ] = mNewGeom;
}
emit mBuffer->geometryChanged( mFid, mNewGeom );
}
示例6: handleAttributeAdded
void QgsVectorLayerEditBuffer::handleAttributeAdded( int index )
{
// go through the changed attributes map and adapt indices
for ( int i = 0; i < mChangedAttributeValues.size(); ++i )
{
updateAttributeMapIndex( mChangedAttributeValues[i], index, + 1 );
}
// go through added features and adapt attributes
QgsFeatureMap::iterator featureIt = mAddedFeatures.begin();
for ( ; featureIt != mAddedFeatures.end(); ++featureIt )
{
QgsAttributes& attrs = featureIt->attributes();
attrs.insert( index, QVariant() );
}
}
示例7: undo
void QgsVectorLayerUndoCommandDeleteAttribute::undo()
{
if ( mProviderField )
{
mBuffer->mDeletedAttributeIds.removeOne( mOriginIndex );
}
else
{
// newly added attribute
mBuffer->mAddedAttributes.insert( mOriginIndex, mOldField );
}
mBuffer->updateLayerFields();
mBuffer->handleAttributeAdded( mFieldIndex ); // update changed attributes + new features
if ( !mOldName.isEmpty() )
{
mBuffer->mRenamedAttributes[ mFieldIndex ] = mOldName;
mBuffer->updateLayerFields();
}
// set previously used attributes of new features
for ( QgsFeatureMap::iterator it = mBuffer->mAddedFeatures.begin(); it != mBuffer->mAddedFeatures.end(); ++it )
{
QgsFeature& f = it.value();
f.setAttribute( mFieldIndex, mDeletedValues.value( f.id() ) );
}
// set previously used changed attributes
for ( QMap<QgsFeatureId, QVariant>::const_iterator it = mDeletedValues.constBegin(); it != mDeletedValues.constEnd(); ++it )
{
if ( !FID_IS_NEW( it.key() ) )
{
QgsAttributeMap& attrs = mBuffer->mChangedAttributeValues[it.key()]; // also adds record if nonexistant
attrs.insert( mFieldIndex, it.value() );
}
}
QgsEditFormConfig formConfig = mBuffer->L->editFormConfig();
formConfig.setWidgetConfig( mFieldName, mOldEditorWidgetConfig );
mBuffer->L->setEditFormConfig( formConfig );
emit mBuffer->attributeAdded( mFieldIndex );
}
示例8: deleteAttributes
bool QgsMemoryProvider::deleteAttributes( const QgsAttributeIds& attributes )
{
QList<int> attrIdx = attributes.toList();
qSort( attrIdx.begin(), attrIdx.end(), qGreater<int>() );
// delete attributes one-by-one with decreasing index
for ( QList<int>::const_iterator it = attrIdx.constBegin(); it != attrIdx.constEnd(); ++it )
{
int idx = *it;
mFields.remove( idx );
for ( QgsFeatureMap::iterator fit = mFeatures.begin(); fit != mFeatures.end(); ++fit )
{
QgsFeature& f = fit.value();
f.attributes().remove( idx );
}
}
return true;
}
示例9: handleAttributeDeleted
void QgsVectorLayerEditBuffer::handleAttributeDeleted( int index )
{
// go through the changed attributes map and adapt indices
for ( int i = 0; i < mChangedAttributeValues.size(); ++i )
{
QgsAttributeMap& attrMap = mChangedAttributeValues[i];
// remove the attribute
if ( attrMap.contains( index ) )
attrMap.remove( index );
// update attribute indices
updateAttributeMapIndex( attrMap, index, -1 );
}
// go through added features and adapt attributes
QgsFeatureMap::iterator featureIt = mAddedFeatures.begin();
for ( ; featureIt != mAddedFeatures.end(); ++featureIt )
{
QgsAttributes& attrs = featureIt->attributes();
attrs.remove( index );
}
}
示例10: changeGeometryValues
bool QgsMemoryProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
{
for ( QgsGeometryMap::const_iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
{
QgsFeatureMap::iterator fit = mFeatures.find( it.key() );
if ( fit == mFeatures.end() )
continue;
// update spatial index
if ( mSpatialIndex )
mSpatialIndex->deleteFeature( *fit );
fit->setGeometry( it.value() );
// update spatial index
if ( mSpatialIndex )
mSpatialIndex->insertFeature( *fit );
}
updateExtent();
return TRUE;
}