Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 9, 2012
1 parent e110855 commit f217a7f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 51 deletions.
2 changes: 2 additions & 0 deletions python/core/qgsfeature.sip
Expand Up @@ -14,6 +14,8 @@ typedef QMap<int, QString> QgsFieldNameMap;


typedef QList<QgsFeature> QgsFeatureList; typedef QList<QgsFeature> QgsFeatureList;


typedef QMap<int, QgsField> QgsFieldMap;



class QgsFeature class QgsFeature
{ {
Expand Down
47 changes: 10 additions & 37 deletions python/core/qgsvectordataprovider.sip
Expand Up @@ -49,46 +49,22 @@ class QgsVectorDataProvider : QgsDataProvider
*/ */
virtual QString storageType() const; virtual QString storageType() const;


/** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
* @param fetchAttributes list of attributes which should be fetched
* @param rect spatial filter
* @param fetchGeometry true if the feature geometry should be fetched
* @param useIntersect true if an accurate intersection test should be used,
* false if a test based on bounding box is sufficient
*/
virtual void select( QList<int> fetchAttributes = QList<int>(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
bool useIntersect = false ) = 0;

/** /**
* This function does nothing useful, it's kept only for compatibility. * Query the provider for features specified in request.
* @todo to be removed
*/ */
virtual long updateFeatureCount() /Deprecated/; virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() ) = 0;


/** // temporary
* Gets the feature at the given feature ID. QgsFeatureIterator select( QList<int> fetchAttributes = QList<int>(),
* @param featureId id of the feature QgsRectangle rect = QgsRectangle(),
* @param feature feature which will receive the data bool fetchGeometry = true,
* @param fetchGeometry if true, geometry will be fetched from the provider bool useIntersect = false ) /Deprecated/;
* @param fetchAttributes a list containing the indexes of the attribute fields to copy
* @return True when feature was found, otherwise false
*
* Default implementation traverses all features until it finds the one with correct ID.
* In case the provider supports reading the feature directly, override this function.
*/
virtual bool featureAtId( qint64 featureId,
QgsFeature& feature,
bool fetchGeometry = true,
QList<int> fetchAttributes = QList<int>());


/** /**
* Get the next feature resulting from a select operation. * This function does nothing useful, it's kept only for compatibility.
* @param feature feature which will receive data from the provider * @todo to be removed
* @return true when there was a feature to fetch, false when end was hit
*/ */
virtual bool nextFeature( QgsFeature& feature ) = 0; virtual long updateFeatureCount() /Deprecated/;


/** /**
* Get feature type. * Get feature type.
Expand Down Expand Up @@ -120,9 +96,6 @@ class QgsVectorDataProvider : QgsDataProvider
*/ */
virtual QString dataComment() const; virtual QString dataComment() const;


/** Restart reading features from previous select operation */
virtual void rewind() = 0;

/** /**
* Returns the minimum value of an attribute * Returns the minimum value of an attribute
* @param index the index of the attribute * @param index the index of the attribute
Expand Down
13 changes: 5 additions & 8 deletions src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -69,9 +69,7 @@ void QgsAtlasComposition::beginRender()
mTransform.setSourceCrs( coverage_crs ); mTransform.setSourceCrs( coverage_crs );
mTransform.setDestCRS( destination_crs ); mTransform.setDestCRS( destination_crs );


QgsVectorDataProvider* provider = mCoverageLayer->dataProvider(); QgsFieldMap fieldmap = mCoverageLayer->pendingFields();

QgsFieldMap fieldmap = provider->fields();


if ( mFilenamePattern.size() > 0 ) if ( mFilenamePattern.size() > 0 )
{ {
Expand All @@ -88,12 +86,12 @@ void QgsAtlasComposition::beginRender()
} }


// select all features with all attributes // select all features with all attributes
provider->select( provider->attributeIndexes() ); mCoverageLayer->select( mCoverageLayer->pendingAllAttributesList() );


// We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process // We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
// We thus store the feature ids for future extraction // We thus store the feature ids for future extraction
QgsFeature feat; QgsFeature feat;
while ( provider->nextFeature( feat ) ) while ( mCoverageLayer->nextFeature( feat ) )
{ {
mFeatureIds.push_back( feat.id() ); mFeatureIds.push_back( feat.id() );
} }
Expand All @@ -115,7 +113,7 @@ void QgsAtlasComposition::beginRender()


// special columns for expressions // special columns for expressions
QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) ); QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )provider->featureCount() ) ); QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mCoverageLayer->pendingFeatureCount() ) );
} }


void QgsAtlasComposition::endRender() void QgsAtlasComposition::endRender()
Expand Down Expand Up @@ -161,9 +159,8 @@ void QgsAtlasComposition::prepareForFeature( size_t featureI )
return; return;
} }


QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
// retrieve the next feature, based on its id // retrieve the next feature, based on its id
provider->featureAtId( mFeatureIds[ featureI ], mCurrentFeature, /* fetchGeometry = */ true, provider->attributeIndexes() ); mCoverageLayer->featureAtId( mFeatureIds[ featureI ], mCurrentFeature, /* fetchGeometry = */ true, /* fetchAttributes = */ true );


if ( mFilenamePattern.size() > 0 ) if ( mFilenamePattern.size() > 0 )
{ {
Expand Down
10 changes: 4 additions & 6 deletions tests/src/core/testqgscomposerlabel.cpp
Expand Up @@ -125,13 +125,11 @@ void TestQgsComposerLabel::evaluation()


void TestQgsComposerLabel::feature_evaluation() void TestQgsComposerLabel::feature_evaluation()
{ {
QgsVectorDataProvider* provider = mVectorLayer->dataProvider(); QgsAttributeList allAttrs = mVectorLayer->pendingAllAttributesList();

mVectorLayer->select( allAttrs );
QgsAttributeList allAttrs = provider->attributeIndexes();
provider->select( allAttrs );
QgsFeature feat; QgsFeature feat;


provider->nextFeature( feat ); mVectorLayer->nextFeature( feat );
{ {
// evaluation with a feature // evaluation with a feature
mComposerLabel->setExpressionContext( &feat, mVectorLayer ); mComposerLabel->setExpressionContext( &feat, mVectorLayer );
Expand All @@ -140,7 +138,7 @@ void TestQgsComposerLabel::feature_evaluation()
QString expected = "Basse-Normandie_ok"; QString expected = "Basse-Normandie_ok";
QCOMPARE( evaluated, expected ); QCOMPARE( evaluated, expected );
} }
provider->nextFeature( feat ); mVectorLayer->nextFeature( feat );
{ {
// evaluation with a feature // evaluation with a feature
mComposerLabel->setExpressionContext( &feat, mVectorLayer ); mComposerLabel->setExpressionContext( &feat, mVectorLayer );
Expand Down

0 comments on commit f217a7f

Please sign in to comment.