QgsFeatureSink class
An interface for objects which accept features via addFeature(s) methods.
Contents
- Reference
Derived classes
- class QgsFeaturePool
- A feature pool is based on a vector layer and caches features.
- class QgsFeatureStore
- A container for features with the same fields and crs.
- class QgsProxyFeatureSink
- A simple feature sink which proxies feature addition on to another feature sink.
- class QgsSpatialIndex
- A spatial index for QgsFeature objects.
- class QgsVectorDataProvider
- This is the base class for vector data providers.
- class QgsVectorFileWriter
- A convenience class for writing vector files to disk.
- class QgsVectorLayer
- Represents a vector layer which manages a vector based data sets.
- class QgsVectorLayerExporter
- A convenience class for exporting vector layers to a destination data provider.
- class QgsVectorLayerJoinBuffer
- Manages joined fields for a vector layer.
Public types
- enum Flag { FastInsert = 1 << 1 }
- Flags controlling how features are added to a sink.
- enum SinkFlag { RegeneratePrimaryKey = 1 << 1 }
- Flags that can be set on a QgsFeatureSink.
Public functions
- auto addFeature(QgsFeature& feature, QgsFeatureSink::Flags flags = nullptr) -> bool virtual
- Adds a single feature to the sink.
- auto addFeatures(QgsFeatureList& features, QgsFeatureSink::Flags flags = nullptr) -> bool pure virtual
- Adds a list of features to the sink.
- auto addFeatures(QgsFeatureIterator& iterator, QgsFeatureSink::Flags flags = nullptr) -> bool virtual
- Adds all features from the specified iterator to the sink.
- auto flushBuffer() -> bool virtual
- Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.
Enum documentation
enum QgsFeatureSink:: Flag
Flags controlling how features are added to a sink.
| Enumerators | |
|---|---|
| FastInsert |
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provider. This includes skipping the update of the passed feature IDs to match the resulting feature IDs for the feature within the data provider. Individual sink subclasses may or may not choose to respect this flag, depending on whether or not skipping this update represents a significant speed boost for the operation. |
enum QgsFeatureSink:: SinkFlag
Flags that can be set on a QgsFeatureSink.
Not all sinks may implement all flags.
| Enumerators | |
|---|---|
| RegeneratePrimaryKey |
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should ignore it if somehow possible. This should for example be set for a geopackage file if the field "fid" has a risk to contain duplicate entries. In this case sinks like QgsVectorFileWriter or QgsVectorLayerExporter will prefer to regenerate the fid instead of trying to reuse the fids provided in addFeature calls. |
Function documentation
bool QgsFeatureSink:: addFeature(QgsFeature& feature,
QgsFeatureSink::Flags flags = nullptr) virtual
Adds a single feature to the sink.
| Returns | true in case of success and false in case of failure |
|---|
Feature addition behavior is controlled by the specified flags.
bool QgsFeatureSink:: addFeatures(QgsFeatureList& features,
QgsFeatureSink::Flags flags = nullptr) pure virtual
Adds a list of features to the sink.
| Returns | true in case of success and false in case of failure |
|---|
Feature addition behavior is controlled by the specified flags.
bool QgsFeatureSink:: addFeatures(QgsFeatureIterator& iterator,
QgsFeatureSink::Flags flags = nullptr) virtual
Adds all features from the specified iterator to the sink.
| Returns | true if all features were added successfully, or false if any feature could not be added |
|---|
Feature addition behavior is controlled by the specified flags.
bool QgsFeatureSink:: flushBuffer() virtual
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.
| Returns | false if any buffered features could not be added to the sink. |
|---|