Skip to content
Permalink
Browse files

import vector layer: do not change attribute map of the source feature,

do not copy values of un-mapped attributes forward to the destination layer:

avoid features with dirty attribute maps being added to the buffer
  • Loading branch information
brushtyler committed Jul 27, 2012
1 parent 237baea commit 64d1c02f69ac6f3d78e1f200628760b2b9fa3a9c
Showing with 7 additions and 9 deletions.
  1. +7 −9 src/core/qgsvectorlayerimport.cpp
@@ -120,23 +120,21 @@ bool QgsVectorLayerImport::addFeature( QgsFeature& feat )
{
const QgsAttributeMap &attrs = feat.attributeMap();

QgsAttributeMap newAttrs;
QgsFeature newFeat;
newFeat.setGeometry( *feat.geometry() );

for ( QgsAttributeMap::const_iterator it = attrs.begin(); it != attrs.end(); it++ )
{
// add only mapped attributes (un-mapped ones are not present in the
// destination layer)
if ( mOldToNewAttrIdx.contains( it.key() ) )
{
QgsDebugMsgLevel( QString( "moving field from pos %1 to %2" ).arg( it.key() ).arg( mOldToNewAttrIdx.value( it.key() ) ), 3 );
newAttrs.insert( mOldToNewAttrIdx.value( it.key() ), *it );
}
else
{
QgsDebugMsgLevel( QString( "added attr pos %1" ).arg( it.key() ), 3 );
newAttrs.insert( it.key(), *it );
newFeat.addAttribute( mOldToNewAttrIdx.value( it.key() ), *it );
}
}
feat.setAttributeMap( newAttrs );

mFeatureBuffer.append( feat );
mFeatureBuffer.append( newFeat );

if ( mFeatureBuffer.count() >= FEATURE_BUFFER_SIZE )
{

0 comments on commit 64d1c02

Please sign in to comment.
You can’t perform that action at this time.