Skip to content
Permalink
Browse files

Ensures that features (properly) fetched from provider (via nextFeature)

are set as valid
Ensures that only valid features are rendered on the map canvas


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10272 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer
cfarmer committed Mar 11, 2009
1 parent 62787bc commit 61e0d642c376e7269053fbe196082880c5db3430
@@ -3343,7 +3343,7 @@ void QgsVectorLayer::drawFeature( QPainter* p,
// used in all cases of the statement (otherwise they may get
// executed, but never used, in a bit of code where performance is
// critical).

if (! fet.isValid() ) { return; }
#if defined(Q_WS_X11)
bool needToTrim = false;
#endif
@@ -129,6 +129,7 @@ int QgsGPXProvider::capabilities() const

bool QgsGPXProvider::nextFeature( QgsFeature& feature )
{
feature.setValid( false );
bool result = false;

QgsAttributeList::const_iterator iter;
@@ -403,6 +404,10 @@ bool QgsGPXProvider::nextFeature( QgsFeature& feature )

}
}
if ( result )
{
feature.setValid( true );
}
return result;
}

@@ -290,6 +290,7 @@ QString QgsGrassProvider::storageType() const

bool QgsGrassProvider::nextFeature( QgsFeature& feature )
{
feature.setValid( false );
int cat, type, id;
unsigned char *wkb;
int wkbsize;
@@ -412,6 +413,8 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )

setFeatureAttributes( mLayerId, cat, &feature, mAttributesToFetch );

feature.setValid( true );

return true;
}

@@ -62,6 +62,7 @@ QString QgsMemoryProvider::storageType() const

bool QgsMemoryProvider::nextFeature( QgsFeature& feature )
{
feature.setValid( false );
bool hasFeature = FALSE;

// option 1: using spatial index
@@ -128,8 +129,9 @@ bool QgsMemoryProvider::nextFeature( QgsFeature& feature )
{
feature = mSelectIterator.value();
mSelectIterator++;
feature.setValid( true );
}

return hasFeature;
}

@@ -341,6 +341,8 @@ bool QgsOgrProvider::featureAtId( int featureId,

bool QgsOgrProvider::nextFeature( QgsFeature& feature )
{
feature.setValid( false );

if ( !valid )
{
QgsLogger::warning( "Read attempt on an invalid shapefile data source" );
@@ -410,6 +412,7 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature )
if ( fet )
{
OGR_F_Destroy( fet );
feature.setValid( true );
return true;
}
else
@@ -568,6 +568,7 @@ void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle

bool QgsPostgresProvider::nextFeature( QgsFeature& feature )
{
feature.setValid( false );
QString cursorName = QString( "qgisf%1" ).arg( providerId );

if ( !valid )
@@ -621,7 +622,8 @@ bool QgsPostgresProvider::nextFeature( QgsFeature& feature )
feature.setAttributeMap( mFeatureQueue.front().attributeMap() );

mFeatureQueue.pop();


feature.setValid( true );
return true;
}

@@ -65,6 +65,8 @@ QgsWFSProvider::~QgsWFSProvider()

bool QgsWFSProvider::nextFeature( QgsFeature& feature )
{
feature.setValid( false );

while ( true ) //go through the loop until we find a feature in the filter
{
if ( mSelectedFeatures.size() == 0 || mFeatureIterator == mSelectedFeatures.end() )
@@ -92,6 +94,7 @@ bool QgsWFSProvider::nextFeature( QgsFeature& feature )
{
if ( feature.geometry() && feature.geometry()->intersects( mSpatialFilter ) )
{
feature.setValid( true );
return true;
}
else
@@ -101,6 +104,7 @@ bool QgsWFSProvider::nextFeature( QgsFeature& feature )
}
else
{
feature.setValid( true );
return true;
}
}

0 comments on commit 61e0d64

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