24 , mDefinition( mappingDefinition )
26 , mOwnsSink( ownsSink )
49 mContext.setFeature( feature );
53 f.
setFields( mDefinition.destinationFields(),
true );
55 const QMap< QString, QgsProperty > fieldMap = mDefinition.fieldMap();
56 for (
const QgsField &field : mDefinition.destinationFields() )
58 if ( fieldMap.contains( field.name() ) )
60 attributes.append( fieldMap.value( field.name() ).value( mContext ) );
64 attributes.append( QVariant() );
72 const QVector< QgsGeometry > geometries = feature.
geometry().
coerceToType( mDefinition.destinationWkbType() );
73 if ( !geometries.isEmpty() )
75 res.reserve( geometries.size() );
110 return mSink->addFeatures( features, flags );
136 return mSink->lastError();
142 map.insert( QStringLiteral(
"wkb_type" ),
static_cast< quint32
>( mDestinationWkbType ) );
144 QVariantList fieldNames;
145 for (
const QgsField &field : mDestinationFields )
146 fieldNames << field.name();
147 map.insert( QStringLiteral(
"destination_field_names" ), fieldNames );
152 for (
auto it = mFieldMap.constBegin(); it != mFieldMap.constEnd(); ++it )
154 fieldMap.insert( it.key(), it.value().toVariant() );
156 map.insert( QStringLiteral(
"field_map" ),
fieldMap );
165 const QVariantList fieldNames = map.value( QStringLiteral(
"destination_field_names" ) ).toList();
167 for (
const QVariant &field : fieldNames )
171 mDestinationFields = fields;
176 const QVariantMap
fieldMap = map.value( QStringLiteral(
"field_map" ) ).toMap();
182 mFieldMap.insert( it.key(), p );
190 return mDestinationWkbType == other.mDestinationWkbType
191 && mDestinationFields == other.mDestinationFields
192 && mFieldMap == other.mFieldMap
193 && mSourceCrs == other.mSourceCrs
194 && mDestinationCrs == other.mDestinationCrs;
199 return !( *
this == other );
WkbType
The WKB type describes the number of dimensions a geometry has.
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
static QgsCoordinateReferenceSystem fromWkt(const QString &wkt)
Creates a CRS from a WKT spatial ref sys definition string.
Contains information about the context in which a coordinate transform is executed.
Custom exception class for Coordinate Reference System related exceptions.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
An interface for objects which accept features via addFeature(s) methods.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assigns a field map with the feature to allow attribute access by attribute name.
void clearGeometry()
Removes any geometry associated with the feature.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
A geometry is the spatial representation of a feature.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QVector< QgsGeometry > coerceToType(Qgis::WkbType type, double defaultZ=0, double defaultM=0, bool avoidDuplicates=true) const
Attempts to coerce this geometry into the specified destination type.
static void warning(const QString &msg)
Goes to qWarning.
A store for object properties.
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the transform context to use when reprojecting features.
void setExpressionContext(const QgsExpressionContext &context) const
Sets the expression context to use when evaluating mapped field values.
~QgsRemappingProxyFeatureSink() override
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
QString lastError() const override
Returns the most recent error encountered by the sink, e.g.
QgsRemappingProxyFeatureSink(const QgsRemappingSinkDefinition &mappingDefinition, QgsFeatureSink *sink, bool ownsSink=false)
Constructor for QgsRemappingProxyFeatureSink, using the specified mappingDefinition to manipulate fea...
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a single feature to the sink.
QgsFeatureList remapFeature(const QgsFeature &feature) const
Remaps a feature to a set of features compatible with the destination sink.
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
bool operator==(const QgsRemappingSinkDefinition &other) const
QMap< QString, QgsProperty > fieldMap() const
Returns the field mapping, which defines how to map the values from incoming features to destination ...
bool operator!=(const QgsRemappingSinkDefinition &other) const
QVariant toVariant() const
Saves this remapping definition to a QVariantMap, wrapped in a QVariant.
bool loadVariant(const QVariantMap &map)
Loads this remapping definition from a QVariantMap, wrapped in a QVariant.
QList< QgsFeature > QgsFeatureList