QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsfeaturestore.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturestore.h
3  --------------------------------------
4  Date : February 2013
5  Copyright : (C) 2013 by Radim Blazek
6  Email : [email protected]
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSFEATURESTORE_H
16 #define QGSFEATURESTORE_H
17 
18 #include "qgis_core.h"
19 #include "qgis.h"
20 #include "qgsfeature.h"
21 #include "qgsfields.h"
22 #include "qgsfeaturesink.h"
24 #include <QList>
25 #include <QMetaType>
26 #include <QVariant>
27 
32 class CORE_EXPORT QgsFeatureStore : public QgsFeatureSink
33 {
34  public:
36  QgsFeatureStore() = default;
37 
39  QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs );
40 
45  QgsFields fields() const { return mFields; }
46 
51  void setFields( const QgsFields &fields );
52 
57  QgsCoordinateReferenceSystem crs() const { return mCrs; }
58 
63  void setCrs( const QgsCoordinateReferenceSystem &crs ) { mCrs = crs; }
64 
65  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) override;
66  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) override;
67 
71  int count() const { return mFeatures.size(); }
72 
73 #ifdef SIP_RUN
74 
78  int __len__() const;
79  % MethodCode
80  sipRes = sipCpp->count();
81  % End
82 #endif
83 
87  QgsFeatureList features() const { return mFeatures; }
88 
93  void setParams( const QMap<QString, QVariant> &parameters ) { mParams = parameters; }
94 
99  QMap<QString, QVariant> params() const { return mParams; }
100 
101  private:
102  QgsFields mFields;
103 
105 
106  QgsFeatureList mFeatures;
107 
108  // Optional parameters
109  QMap<QString, QVariant> mParams;
110 };
111 
112 typedef QList<QgsFeatureStore> QgsFeatureStoreList;
113 
115 
117 
118 #endif
A container for features with the same fields and crs.
QList< QgsFeatureStore > QgsFeatureStoreList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:549
An interface for objects which accept features via addFeature(s) methods.
void setParams(const QMap< QString, QVariant > &parameters)
Sets a map of optional parameters for the store.
Container of fields for a vector layer.
Definition: qgsfields.h:42
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
Q_DECLARE_METATYPE(QModelIndex)
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the store&#39;s crs.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr)
Adds a single feature to the sink.
virtual bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr)=0
Adds a list of features to the sink.
QgsFields fields() const
Returns the store&#39;s field list.
This class represents a coordinate reference system (CRS).
QMap< QString, QVariant > params() const
Returns the map of optional parameters.
QgsCoordinateReferenceSystem crs() const
Returns the store&#39;s coordinate reference system.
QgsFeatureList features() const
Returns the list of features contained in the store.
int count() const
Returns the number of features contained in the store.