AW: [Qgis-developer] patch for split feature issue
Hugentobler Marco
marco.hugentobler at karto.baug.ethz.ch
Thu Jun 5 06:47:06 EDT 2008
Hi Adrien,
Thanks a lot for providing this fix!
I'm going to look at it when I'm back in office tomorrow.
Regards,
Marco
-----Ursprüngliche Nachricht-----
Von: qgis-developer-bounces at lists.osgeo.org im Auftrag von Adrien Gruson
Gesendet: Do 05.06.2008 11:41
An: qgis-developer at lists.osgeo.org
Betreff: [Qgis-developer] patch for split feature issue
Hi all,
i was post 2 week ago a bug in the trac
(http://trac.osgeo.org/qgis/ticket/1103) because some case the copy of
attributs have some issues.
The problem was in QgsVectorLayer::featuresInRectangle :
The problem is in this code
|for(changedIt = mChangedGeometries.begin(); changedIt !=
mChangedGeometries.end(); ++changedIt)
{
[...]
if(fetchAttributes)
{
QgsFeature tmpFeature;
mDataProvider->getFeatureAtId(changedIt.key(), tmpFeature, false,
mDataProvider->allAttributesList());
newFeature.setAttributeMap(tmpFeature.attributeMap());
}
features.push_back(newFeature);
}}
|
Because if the feature is in mAddedFeature the function |getFeatureAtId
|Return no attribut (because the feature isn't commited).||
||
Regards,
Adrien Gruson.
_
Patch :_
Index: /raid/homes/agruson/workspace/SVN_Src_Qgis/core/qgsvectorlayer.cpp
===================================================================
---
/raid/homes/agruson/workspace/SVN_Src_Qgis/core/qgsvectorlayer.cpp
(revision 8593)
+++
/raid/homes/agruson/workspace/SVN_Src_Qgis/core/qgsvectorlayer.cpp
(working copy)
@@ -1273,10 +1273,30 @@
}
if(fetchAttributes)
{
- QgsFeature tmpFeature;
- mDataProvider->getFeatureAtId(changedIt.key(), tmpFeature,
false, mDataProvider->allAttributesList());
- newFeature.setAttributeMap(tmpFeature.attributeMap());
-
+ if(changedIt.key()<0)
+ {
+ //The feature is in mAddedFeature's list because its id<0
+ bool findMyFeature = false;
+ for (QgsFeatureList::iterator iter =
mAddedFeatures.begin(); iter != mAddedFeatures.end(); ++iter)
+ {
+ if(iter->featureId()==changedIt.key())
+ {
+ findMyFeature = true;
+ newFeature.setAttributeMap(iter->attributeMap());
+ break;
+ }
+ }
+ if(!findMyFeature)
+ {
+ QgsLogger::warning("No attribute for the feature");
+ }
+ }
+ else
+ {
+ QgsFeature tmpFeature;
+ mDataProvider->getFeatureAtId(changedIt.key(),
tmpFeature, false, mDataProvider->allAttributesList());
+ newFeature.setAttributeMap(tmpFeature.attributeMap());
+ }
}
features.push_back(newFeature);
}
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the Qgis-developer
mailing list