QGIS API Documentation  3.20.0-Odense (decaadbb31)
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_core.h"
22 #include "qgis.h"
23 #include "qgsfeaturesink.h"
24 #include "qgsproperty.h"
25 
37 class CORE_EXPORT QgsRemappingSinkDefinition
38 {
39  public:
40 
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  QgsWkbTypes::Type destinationWkbType() const { return mDestinationWkbType; }
110 
116  void setDestinationWkbType( QgsWkbTypes::Type 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  bool operator==( const QgsRemappingSinkDefinition &other ) const;
147  bool operator!=( const QgsRemappingSinkDefinition &other ) const;
148 
149  private:
150 
151  QMap< QString, QgsProperty > mFieldMap;
152 
153  QgsCoordinateReferenceSystem mSourceCrs;
154  QgsCoordinateReferenceSystem mDestinationCrs;
155 
156  QgsWkbTypes::Type mDestinationWkbType = QgsWkbTypes::Unknown;
157 
158  QgsFields mDestinationFields;
159 
160 };
161 
163 
164 
165 
166 
179 {
180  public:
181 
182 #ifndef SIP_RUN
183 
192  QgsRemappingProxyFeatureSink( const QgsRemappingSinkDefinition &mappingDefinition, QgsFeatureSink *sink, bool ownsSink = false );
193 #else
194 
200 #endif
201 
202  ~QgsRemappingProxyFeatureSink() override;
203 
207  void setExpressionContext( const QgsExpressionContext &context );
208 
212  void setTransformContext( const QgsCoordinateTransformContext &context );
213 
217  QgsFeatureList remapFeature( const QgsFeature &feature ) const;
218 
219  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
220  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
221  bool addFeatures( QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
222  QString lastError() const override;
223 
227  QgsFeatureSink *destinationSink() { return mSink; }
228 
229  private:
230 
231  QgsRemappingSinkDefinition mDefinition;
232  QgsCoordinateTransform mTransform;
233  QgsFeatureSink *mSink = nullptr;
234  mutable QgsExpressionContext mContext;
235  bool mOwnsSink = false;
236 };
237 
238 #endif // QGSREMAPPINGPROXYFEATURESINK_H
239 
240 
241 
242 
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Class for doing transforms between two map 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.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
A store for object properties.
Definition: qgsproperty.h:232
A QgsFeatureSink which proxies incoming features to a destination feature sink, after applying transf...
QgsFeatureSink * destinationSink()
Returns the destination QgsFeatureSink which the proxy will forward features to.
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...
QgsWkbTypes::Type destinationWkbType() const
Returns 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 ...
void setDestinationWkbType(QgsWkbTypes::Type type)
Sets the WKB geometry type for the 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.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:736
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)