diff --git a/python/auto_sip.blacklist b/python/auto_sip.blacklist index b6e79c47e99..d689211a25f 100644 --- a/python/auto_sip.blacklist +++ b/python/auto_sip.blacklist @@ -117,7 +117,6 @@ core/qgsvectorsimplifymethod.sip core/qgscachedfeatureiterator.sip core/qgscacheindex.sip core/qgscacheindexfeatureid.sip -core/qgsfeaturestore.sip core/qgsgeometrycache.sip core/qgslayerdefinition.sip core/qgsprojectfiletransform.sip diff --git a/python/core/qgsfeaturestore.sip b/python/core/qgsfeaturestore.sip index 6b55152cf58..aae8f95b4f9 100644 --- a/python/core/qgsfeaturestore.sip +++ b/python/core/qgsfeaturestore.sip @@ -1,39 +1,92 @@ -class QgsFeatureStore +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/qgsfeaturestore.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + +class QgsFeatureStore : QgsFeatureSink { +%Docstring + A container for features with the same fields and crs. +%End + %TypeHeaderCode -#include +#include "qgsfeaturestore.h" %End public: - //! Constructor QgsFeatureStore(); +%Docstring +Constructor +%End - //! Constructor - QgsFeatureStore( const QgsFields& fields, const QgsCoordinateReferenceSystem& crs ); + QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs ); +%Docstring +Constructor +%End - /** Get fields list */ - QgsFields& fields(); + QgsFields fields() const; +%Docstring + Returns the store's field list. + \see setFields() + :rtype: QgsFields +%End - /** Set fields. Resets feature's fields to pointer to new internal fields. */ - void setFields( const QgsFields & fields ); + void setFields( const QgsFields &fields ); +%Docstring + Sets the store's ``fields``. Every contained feature's fields will be reset to match ``fields``. + \see fields() +%End - /** Get crs */ QgsCoordinateReferenceSystem crs() const; +%Docstring + Returns the store's coordinate reference system. + \see setCrs() + :rtype: QgsCoordinateReferenceSystem +%End - /** Set crs */ - void setCrs( const QgsCoordinateReferenceSystem& crs ); + void setCrs( const QgsCoordinateReferenceSystem &crs ); +%Docstring + Sets the store's ``crs``. + \see crs() +%End - /** Add feature. Feature's fields will be set to pointer to the store fields. - * @param feature - * @note added in 2.1 - */ - void addFeature( const QgsFeature& feature ); + virtual bool addFeature( QgsFeature &feature /In,Out/ ); - /** Get features list reference */ - QgsFeatureList& features(); + virtual bool addFeatures( QgsFeatureList &features /In,Out/ ); - /** Set map of optional parameters */ - void setParams( const QMap ¶ms ); - /** Get map of optional parameters */ + QgsFeatureList features() const; +%Docstring + Returns the list of features contained in the store. + :rtype: QgsFeatureList +%End + + void setParams( const QMap ¶meters ); +%Docstring + Sets a map of optional ``parameters`` for the store. + \see params() +%End + QMap params() const; +%Docstring + Returns the map of optional parameters. + \see setParams() + :rtype: QMap +%End + }; + +typedef QList QgsFeatureStoreList; + + + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/qgsfeaturestore.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index 6d0dbbfe2f9..05265266a88 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -1898,7 +1898,8 @@ void QgsIdentifyResultsDialog::copyFeature() } QgsFeatureStore featureStore( item->fields(), item->crs() ); - featureStore.features().append( item->feature() ); + QgsFeature f( item->feature() ); + featureStore.addFeature( f ); emit copyToClipboard( featureStore ); } diff --git a/src/core/qgsfeaturestore.cpp b/src/core/qgsfeaturestore.cpp index f8af3d9b5e7..3f3e7409483 100644 --- a/src/core/qgsfeaturestore.cpp +++ b/src/core/qgsfeaturestore.cpp @@ -35,9 +35,20 @@ void QgsFeatureStore::setFields( const QgsFields &fields ) } } -void QgsFeatureStore::addFeature( const QgsFeature &feature ) +bool QgsFeatureStore::addFeature( QgsFeature &feature ) { QgsFeature f( feature ); f.setFields( mFields ); mFeatures.append( f ); + return true; +} + +bool QgsFeatureStore::addFeatures( QgsFeatureList &features ) +{ + QgsFeatureList::iterator fIt = features.begin(); + for ( ; fIt != features.end(); ++fIt ) + { + addFeature( *fIt ); + } + return true; } diff --git a/src/core/qgsfeaturestore.h b/src/core/qgsfeaturestore.h index 81c8677dd03..2804106fa4e 100644 --- a/src/core/qgsfeaturestore.h +++ b/src/core/qgsfeaturestore.h @@ -19,15 +19,16 @@ #include "qgis.h" #include "qgsfeature.h" #include "qgsfields.h" +#include "qgsfeaturesink.h" #include "qgscoordinatereferencesystem.h" #include #include #include /** \ingroup core - * Container for features with the same fields and crs. + * A container for features with the same fields and crs. */ -class CORE_EXPORT QgsFeatureStore +class CORE_EXPORT QgsFeatureStore : public QgsFeatureSink { public: //! Constructor @@ -36,31 +37,48 @@ class CORE_EXPORT QgsFeatureStore //! Constructor QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs ); - //! Get fields list - QgsFields &fields() { return mFields; } + /** + * Returns the store's field list. + * \see setFields() + */ + QgsFields fields() const { return mFields; } - //! Set fields. Resets feature's fields to pointer to new internal fields. + /** + * Sets the store's \a fields. Every contained feature's fields will be reset to match \a fields. + * \see fields() + */ void setFields( const QgsFields &fields ); - //! Get crs + /** + * Returns the store's coordinate reference system. + * \see setCrs() + */ QgsCoordinateReferenceSystem crs() const { return mCrs; } - //! Set crs + /** + * Sets the store's \a crs. + * \see crs() + */ void setCrs( const QgsCoordinateReferenceSystem &crs ) { mCrs = crs; } - /** Add feature. Feature's fields will be set to pointer to the store fields. - * \param feature - * \since QGIS 2.1 + bool addFeature( QgsFeature &feature SIP_INOUT ) override; + bool addFeatures( QgsFeatureList &features SIP_INOUT ) override; + + /** + * Returns the list of features contained in the store. */ - void addFeature( const QgsFeature &feature ); + QgsFeatureList features() const { return mFeatures; } - //! Get features list reference - QgsFeatureList &features() { return mFeatures; } + /** + * Sets a map of optional \a parameters for the store. + * \see params() + */ + void setParams( const QMap ¶meters ) { mParams = parameters; } - //! Set map of optional parameters - void setParams( const QMap ¶ms ) { mParams = params; } - - //! Get map of optional parameters + /** + * Returns the map of optional parameters. + * \see setParams() + */ QMap params() const { return mParams; } private: diff --git a/src/providers/arcgisrest/qgsamsprovider.cpp b/src/providers/arcgisrest/qgsamsprovider.cpp index a92e1f9348d..ba99c963bb7 100644 --- a/src/providers/arcgisrest/qgsamsprovider.cpp +++ b/src/providers/arcgisrest/qgsamsprovider.cpp @@ -430,7 +430,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPoint &point, QgsRast params[QStringLiteral( "sublayer" )] = resultMap[QStringLiteral( "layerName" )].toString(); params[QStringLiteral( "featureType" )] = attributesMap[resultMap[QStringLiteral( "displayFieldName" )].toString()].toString(); store.setParams( params ); - store.features().append( feature ); + store.addFeature( feature ); entries.insert( entries.size(), qVariantFromValue( QList() << store ) ); } } diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index 490bcf8c1d0..63a6727a101 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -2938,7 +2938,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint &point, QgsRast g.transform( coordinateTransform ); feature->setGeometry( g ); } - featureStore.features().append( QgsFeature( *feature ) ); + featureStore.addFeature( *feature ); } featureStoreList.append( featureStore ); } @@ -3073,7 +3073,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint &point, QgsRast featureStore.setParams( params ); feature.setValid( true ); - featureStore.features().append( feature ); + featureStore.addFeature( feature ); featureStoreList.append( featureStore ); }