Skip to content

Commit 0862fd1

Browse files
author
mhugent
committedMay 31, 2009
Fix for problem with features that cannot be exported to shape
git-svn-id: http://svn.osgeo.org/qgis/trunk@10867 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 63a5d29 commit 0862fd1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎src/providers/wfs/qgswfsdata.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,24 @@ void QgsWFSData::endElement( const XML_Char* el )
313313
}
314314
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "featureMember" )
315315
{
316+
//MH090531: Check if all feature attributes are initialised, sometimes attribute values are missing.
317+
//We fill the not initialized ones with empty strings, otherwise the feature cannot be exported to shp later
318+
QgsAttributeMap currentFeatureAttributes = mCurrentFeature->attributeMap();
319+
QMap<QString, QPair<int, QgsField> >::const_iterator att_it = mThematicAttributes.constBegin();
320+
for(; att_it != mThematicAttributes.constEnd(); ++att_it)
321+
{
322+
int attIndex = att_it.value().first;
323+
QgsAttributeMap::const_iterator findIt = currentFeatureAttributes.find(attIndex);
324+
if(findIt == currentFeatureAttributes.constEnd())
325+
{
326+
mCurrentFeature->addAttribute(attIndex, QVariant(""));
327+
}
328+
}
329+
330+
316331
mCurrentFeature->setGeometryAndOwnership( mCurrentWKB, mCurrentWKBSize );
317332
mFeatures << mCurrentFeature;
318333
++mFeatureCount;
319-
//qWarning("Removing featureMember from stack");
320334
mParseModeStack.pop();
321335
}
322336
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Point" )

0 commit comments

Comments
 (0)
Please sign in to comment.