Skip to content
Permalink
Browse files
fix #1941
git-svn-id: http://svn.osgeo.org/qgis/trunk@11698 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 21, 2009
1 parent 1728008 commit 5d5883b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
@@ -116,7 +116,9 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& shapefileName,
QgsDebugMsg( "creating " + QString::number( fields.size() ) + " fields" );

mFields = fields;
mAttrIdxToOgrIdx.clear();

int ogrIdx = 0;
QgsFieldMap::const_iterator fldIt;
for ( fldIt = fields.begin(); fldIt != fields.end(); ++fldIt )
{
@@ -178,6 +180,8 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& shapefileName,
mError = ErrAttributeCreationFailed;
return;
}

mAttrIdxToOgrIdx.insert( fldIt.key(), ogrIdx++ );
}

QgsDebugMsg( "Done creating fields" );
@@ -218,8 +222,14 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
continue;
}

int ogrField = fldIt.key();
const QVariant& attrValue = feature.attributeMap()[ ogrField ];
if ( !mAttrIdxToOgrIdx.contains( fldIt.key() ) )
{
QgsDebugMsg( QString( "no ogr field for field %1" ).arg( fldIt.key() ) );
continue;
}

const QVariant& attrValue = feature.attributeMap()[ fldIt.key()];
int ogrField = mAttrIdxToOgrIdx[ fldIt.key()];

switch ( attrValue.type() )
{
@@ -98,6 +98,9 @@ class CORE_EXPORT QgsVectorFileWriter

/** geometry type which is being used */
QGis::WkbType mWkbType;

/** map attribute indizes to OGR field indexes */
QMap<int, int> mAttrIdxToOgrIdx;
};

#endif

0 comments on commit 5d5883b

Please sign in to comment.