Skip to content

Commit 49d4b5e

Browse files
committedApr 26, 2017
QgsFeatureStore is a QgsFeatureSink
Also clean up API for QgsFeatureStore, sipify
1 parent c4578c3 commit 49d4b5e

File tree

7 files changed

+127
-45
lines changed

7 files changed

+127
-45
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ core/qgsvectorsimplifymethod.sip
117117
core/qgscachedfeatureiterator.sip
118118
core/qgscacheindex.sip
119119
core/qgscacheindexfeatureid.sip
120-
core/qgsfeaturestore.sip
121120
core/qgsgeometrycache.sip
122121
core/qgslayerdefinition.sip
123122
core/qgsprojectfiletransform.sip

‎python/core/qgsfeaturestore.sip

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,92 @@
1-
class QgsFeatureStore
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsfeaturestore.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
class QgsFeatureStore : QgsFeatureSink
211
{
12+
%Docstring
13+
A container for features with the same fields and crs.
14+
%End
15+
316
%TypeHeaderCode
4-
#include <qgsfeaturestore.h>
17+
#include "qgsfeaturestore.h"
518
%End
619
public:
7-
//! Constructor
820
QgsFeatureStore();
21+
%Docstring
22+
Constructor
23+
%End
924

10-
//! Constructor
11-
QgsFeatureStore( const QgsFields& fields, const QgsCoordinateReferenceSystem& crs );
25+
QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs );
26+
%Docstring
27+
Constructor
28+
%End
1229

13-
/** Get fields list */
14-
QgsFields& fields();
30+
QgsFields fields() const;
31+
%Docstring
32+
Returns the store's field list.
33+
\see setFields()
34+
:rtype: QgsFields
35+
%End
1536

16-
/** Set fields. Resets feature's fields to pointer to new internal fields. */
17-
void setFields( const QgsFields & fields );
37+
void setFields( const QgsFields &fields );
38+
%Docstring
39+
Sets the store's ``fields``. Every contained feature's fields will be reset to match ``fields``.
40+
\see fields()
41+
%End
1842

19-
/** Get crs */
2043
QgsCoordinateReferenceSystem crs() const;
44+
%Docstring
45+
Returns the store's coordinate reference system.
46+
\see setCrs()
47+
:rtype: QgsCoordinateReferenceSystem
48+
%End
49+
50+
void setCrs( const QgsCoordinateReferenceSystem &crs );
51+
%Docstring
52+
Sets the store's ``crs``.
53+
\see crs()
54+
%End
2155

22-
/** Set crs */
23-
void setCrs( const QgsCoordinateReferenceSystem& crs );
56+
virtual bool addFeature( QgsFeature &feature /In,Out/ );
2457

25-
/** Add feature. Feature's fields will be set to pointer to the store fields.
26-
* @param feature
27-
* @note added in 2.1
28-
*/
29-
void addFeature( const QgsFeature& feature );
58+
virtual bool addFeatures( QgsFeatureList &features /In,Out/ );
3059

31-
/** Get features list reference */
32-
QgsFeatureList& features();
3360

34-
/** Set map of optional parameters */
35-
void setParams( const QMap<QString, QVariant> &params );
61+
QgsFeatureList features() const;
62+
%Docstring
63+
Returns the list of features contained in the store.
64+
:rtype: QgsFeatureList
65+
%End
66+
67+
void setParams( const QMap<QString, QVariant> &parameters );
68+
%Docstring
69+
Sets a map of optional ``parameters`` for the store.
70+
\see params()
71+
%End
3672

37-
/** Get map of optional parameters */
3873
QMap<QString, QVariant> params() const;
74+
%Docstring
75+
Returns the map of optional parameters.
76+
\see setParams()
77+
:rtype: QMap<str, QVariant>
78+
%End
79+
3980
};
81+
82+
typedef QList<QgsFeatureStore> QgsFeatureStoreList;
83+
84+
85+
86+
/************************************************************************
87+
* This file has been generated automatically from *
88+
* *
89+
* src/core/qgsfeaturestore.h *
90+
* *
91+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
92+
************************************************************************/

‎src/app/qgsidentifyresultsdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,8 @@ void QgsIdentifyResultsDialog::copyFeature()
18981898
}
18991899

19001900
QgsFeatureStore featureStore( item->fields(), item->crs() );
1901-
featureStore.features().append( item->feature() );
1901+
QgsFeature f( item->feature() );
1902+
featureStore.addFeature( f );
19021903
emit copyToClipboard( featureStore );
19031904
}
19041905

‎src/core/qgsfeaturestore.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,20 @@ void QgsFeatureStore::setFields( const QgsFields &fields )
3535
}
3636
}
3737

38-
void QgsFeatureStore::addFeature( const QgsFeature &feature )
38+
bool QgsFeatureStore::addFeature( QgsFeature &feature )
3939
{
4040
QgsFeature f( feature );
4141
f.setFields( mFields );
4242
mFeatures.append( f );
43+
return true;
44+
}
45+
46+
bool QgsFeatureStore::addFeatures( QgsFeatureList &features )
47+
{
48+
QgsFeatureList::iterator fIt = features.begin();
49+
for ( ; fIt != features.end(); ++fIt )
50+
{
51+
addFeature( *fIt );
52+
}
53+
return true;
4354
}

‎src/core/qgsfeaturestore.h

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
#include "qgis.h"
2020
#include "qgsfeature.h"
2121
#include "qgsfields.h"
22+
#include "qgsfeaturesink.h"
2223
#include "qgscoordinatereferencesystem.h"
2324
#include <QList>
2425
#include <QMetaType>
2526
#include <QVariant>
2627

2728
/** \ingroup core
28-
* Container for features with the same fields and crs.
29+
* A container for features with the same fields and crs.
2930
*/
30-
class CORE_EXPORT QgsFeatureStore
31+
class CORE_EXPORT QgsFeatureStore : public QgsFeatureSink
3132
{
3233
public:
3334
//! Constructor
@@ -36,31 +37,48 @@ class CORE_EXPORT QgsFeatureStore
3637
//! Constructor
3738
QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs );
3839

39-
//! Get fields list
40-
QgsFields &fields() { return mFields; }
40+
/**
41+
* Returns the store's field list.
42+
* \see setFields()
43+
*/
44+
QgsFields fields() const { return mFields; }
4145

42-
//! Set fields. Resets feature's fields to pointer to new internal fields.
46+
/**
47+
* Sets the store's \a fields. Every contained feature's fields will be reset to match \a fields.
48+
* \see fields()
49+
*/
4350
void setFields( const QgsFields &fields );
4451

45-
//! Get crs
52+
/**
53+
* Returns the store's coordinate reference system.
54+
* \see setCrs()
55+
*/
4656
QgsCoordinateReferenceSystem crs() const { return mCrs; }
4757

48-
//! Set crs
58+
/**
59+
* Sets the store's \a crs.
60+
* \see crs()
61+
*/
4962
void setCrs( const QgsCoordinateReferenceSystem &crs ) { mCrs = crs; }
5063

51-
/** Add feature. Feature's fields will be set to pointer to the store fields.
52-
* \param feature
53-
* \since QGIS 2.1
54-
*/
55-
void addFeature( const QgsFeature &feature );
64+
bool addFeature( QgsFeature &feature SIP_INOUT ) override;
65+
bool addFeatures( QgsFeatureList &features SIP_INOUT ) override;
5666

57-
//! Get features list reference
58-
QgsFeatureList &features() { return mFeatures; }
67+
/**
68+
* Returns the list of features contained in the store.
69+
*/
70+
QgsFeatureList features() const { return mFeatures; }
5971

60-
//! Set map of optional parameters
61-
void setParams( const QMap<QString, QVariant> &params ) { mParams = params; }
72+
/**
73+
* Sets a map of optional \a parameters for the store.
74+
* \see params()
75+
*/
76+
void setParams( const QMap<QString, QVariant> &parameters ) { mParams = parameters; }
6277

63-
//! Get map of optional parameters
78+
/**
79+
* Returns the map of optional parameters.
80+
* \see setParams()
81+
*/
6482
QMap<QString, QVariant> params() const { return mParams; }
6583

6684
private:

‎src/providers/arcgisrest/qgsamsprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPoint &point, QgsRast
430430
params[QStringLiteral( "sublayer" )] = resultMap[QStringLiteral( "layerName" )].toString();
431431
params[QStringLiteral( "featureType" )] = attributesMap[resultMap[QStringLiteral( "displayFieldName" )].toString()].toString();
432432
store.setParams( params );
433-
store.features().append( feature );
433+
store.addFeature( feature );
434434
entries.insert( entries.size(), qVariantFromValue( QList<QgsFeatureStore>() << store ) );
435435
}
436436
}

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,7 +2938,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint &point, QgsRast
29382938
g.transform( coordinateTransform );
29392939
feature->setGeometry( g );
29402940
}
2941-
featureStore.features().append( QgsFeature( *feature ) );
2941+
featureStore.addFeature( *feature );
29422942
}
29432943
featureStoreList.append( featureStore );
29442944
}
@@ -3073,7 +3073,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint &point, QgsRast
30733073
featureStore.setParams( params );
30743074

30753075
feature.setValid( true );
3076-
featureStore.features().append( feature );
3076+
featureStore.addFeature( feature );
30773077

30783078
featureStoreList.append( featureStore );
30793079
}

0 commit comments

Comments
 (0)
Please sign in to comment.