QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsfeaturestore.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturestore.cpp
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 
16 #include "qgsfeaturestore.h"
17 
18 
20  : mFields( fields )
21  , mCrs( crs )
22 {
23 }
24 
26 {
27  mFields = fields;
28  QgsFeatureList::iterator it = mFeatures.begin();
29  for ( ; it != mFeatures.end(); ++it )
30  {
31  ( *it ).setFields( mFields );
32  }
33 }
34 
35 bool QgsFeatureStore::addFeature( QgsFeature &feature, Flags )
36 {
37  QgsFeature f( feature );
38  f.setFields( mFields );
39  mFeatures.append( f );
40  return true;
41 }
42 
43 bool QgsFeatureStore::addFeatures( QgsFeatureList &features, Flags flags )
44 {
45  QgsFeatureList::iterator fIt = features.begin();
46  for ( ; fIt != features.end(); ++fIt )
47  {
48  addFeature( *fIt, flags );
49  }
50  return true;
51 }
QgsFeatureStore::features
QgsFeatureList features() const
Returns the list of features contained in the store.
Definition: qgsfeaturestore.h:93
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsFeatureStore::addFeature
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a single feature to the sink.
Definition: qgsfeaturestore.cpp:35
QgsFeature::setFields
void setFields(const QgsFields &fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
Definition: qgsfeature.cpp:164
QgsFeatureStore::setFields
void setFields(const QgsFields &fields)
Sets the store's fields.
Definition: qgsfeaturestore.cpp:25
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:583
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsFeatureStore::addFeatures
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
Definition: qgsfeaturestore.cpp:43
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsFeatureStore::fields
QgsFields fields() const
Returns the store's field list.
Definition: qgsfeaturestore.h:45
qgsfeaturestore.h
QgsFeatureStore::QgsFeatureStore
QgsFeatureStore()=default
Constructor.