mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
fix #1941
git-svn-id: http://svn.osgeo.org/qgis/trunk@11698 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
17280084fb
commit
5d5883bc99
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user