QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgsremappingproxyfeaturesink.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsremappingproxyfeaturesink.h
3 ----------------------
4 begin : April 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSREMAPPINGPROXYFEATURESINK_H
19#define QGSREMAPPINGPROXYFEATURESINK_H
20
21#include "qgis.h"
22#include "qgis_core.h"
24#include "qgsfeaturesink.h"
25#include "qgsproperty.h"
26
39{
40 public:
51 QMap< QString, QgsProperty > fieldMap() const { return mFieldMap; }
52
63 void setFieldMap( const QMap< QString, QgsProperty > &map ) { mFieldMap = map; }
64
74 void addMappedField( const QString &destinationField, const QgsProperty &property ) { mFieldMap.insert( destinationField, property ); }
75
81 QgsCoordinateReferenceSystem sourceCrs() const { return mSourceCrs; }
82
88 void setSourceCrs( const QgsCoordinateReferenceSystem &source ) { mSourceCrs = source; }
89
95 QgsCoordinateReferenceSystem destinationCrs() const { return mDestinationCrs; }
96
102 void setDestinationCrs( const QgsCoordinateReferenceSystem &destination ) { mDestinationCrs = destination; }
103
109 Qgis::WkbType destinationWkbType() const { return mDestinationWkbType; }
110
116 void setDestinationWkbType( Qgis::WkbType type ) { mDestinationWkbType = type; }
117
123 QgsFields destinationFields() const { return mDestinationFields; }
124
130 void setDestinationFields( const QgsFields &fields ) { mDestinationFields = fields; }
131
137 QVariant toVariant() const;
138
144 bool loadVariant( const QVariantMap &map );
145
146 // TODO c++20 - replace with = default
147 bool operator==( const QgsRemappingSinkDefinition &other ) const;
148 bool operator!=( const QgsRemappingSinkDefinition &other ) const;
149
150 private:
151 QMap< QString, QgsProperty > mFieldMap;
152
154 QgsCoordinateReferenceSystem mDestinationCrs;
155
156 Qgis::WkbType mDestinationWkbType = Qgis::WkbType::Unknown;
157
158 QgsFields mDestinationFields;
159};
160
162
163
164
177{
178 public:
179#ifndef SIP_RUN
180
189 QgsRemappingProxyFeatureSink( const QgsRemappingSinkDefinition &mappingDefinition, QgsFeatureSink *sink, bool ownsSink = false );
190#else
191
197#endif
198
200
204 void setExpressionContext( const QgsExpressionContext &context ) const;
205
210
214 QgsFeatureList remapFeature( const QgsFeature &feature ) const;
215
216 bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
217 bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
219 QString lastError() const override;
220
224 QgsFeatureSink *destinationSink() { return mSink; }
225
226 private:
227 QgsRemappingSinkDefinition mDefinition;
228 QgsCoordinateTransform mTransform;
229 QgsFeatureSink *mSink = nullptr;
230 mutable QgsExpressionContext mContext;
231 bool mOwnsSink = false;
232};
233
234#endif // QGSREMAPPINGPROXYFEATURESINK_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
@ Unknown
Unknown.
Definition qgis.h:295
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Handles coordinate transforms between two coordinate systems.
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.
An interface for objects which accept features via addFeature(s) methods.
QFlags< Flag > Flags
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Container of fields for a vector layer.
Definition qgsfields.h:46
A store for object properties.
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.
QgsFeatureSink * destinationSink()
Returns the destination QgsFeatureSink which the proxy will forward features to.
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.
void setDestinationCrs(const QgsCoordinateReferenceSystem &destination)
Sets the destination crs used for reprojecting incoming features to the sink's destination CRS.
void setFieldMap(const QMap< QString, QgsProperty > &map)
Sets the field mapping, which defines how to map the values from incoming features to destination fie...
void setDestinationWkbType(Qgis::WkbType type)
Sets the WKB geometry type for the destination.
QMap< QString, QgsProperty > fieldMap() const
Returns the field mapping, which defines how to map the values from incoming features to destination ...
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source CRS used for reprojecting incoming features to the sink's destination CRS.
void setDestinationFields(const QgsFields &fields)
Sets the fields for the destination sink.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination CRS used for reprojecting incoming features to the sink's destination CRS.
void setSourceCrs(const QgsCoordinateReferenceSystem &source)
Sets the source crs used for reprojecting incoming features to the sink's destination CRS.
QgsFields destinationFields() const
Returns the fields for the destination sink.
void addMappedField(const QString &destinationField, const QgsProperty &property)
Adds a mapping for a destination field.
Qgis::WkbType destinationWkbType() const
Returns the WKB geometry type for the destination.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QList< QgsFeature > QgsFeatureList
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)