QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
226  QgsFeatureSink *destinationSink() { return mSink; }
227 
228  private:
229 
230  QgsRemappingSinkDefinition mDefinition;
231  QgsCoordinateTransform mTransform;
232  QgsFeatureSink *mSink = nullptr;
233  mutable QgsExpressionContext mContext;
234  bool mOwnsSink = false;
235 };
236 
237 #endif // QGSREMAPPINGPROXYFEATURESINK_H
238 
239 
240 
241 
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
QgsRemappingProxyFeatureSink::destinationSink
QgsFeatureSink * destinationSink()
Returns the destination QgsFeatureSink which the proxy will forward features to.
Definition: qgsremappingproxyfeaturesink.h:226
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
QgsRemappingSinkDefinition::setDestinationWkbType
void setDestinationWkbType(QgsWkbTypes::Type type)
Sets the WKB geometry type for the destination.
Definition: qgsremappingproxyfeaturesink.h:116
QgsProperty
A store for object properties.
Definition: qgsproperty.h:231
QgsRemappingSinkDefinition::setDestinationCrs
void setDestinationCrs(const QgsCoordinateReferenceSystem &destination)
Sets the destination crs used for reprojecting incoming features to the sink's destination CRS.
Definition: qgsremappingproxyfeaturesink.h:102
QgsRemappingSinkDefinition
Definition: qgsremappingproxyfeaturesink.h:37
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:399
QgsRemappingSinkDefinition::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination CRS used for reprojecting incoming features to the sink's destination CRS.
Definition: qgsremappingproxyfeaturesink.h:95
QgsFields
Definition: qgsfields.h:44
qgsfeaturesink.h
QgsRemappingSinkDefinition::destinationWkbType
QgsWkbTypes::Type destinationWkbType() const
Returns the WKB geometry type for the destination.
Definition: qgsremappingproxyfeaturesink.h:109
qgis.h
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsRemappingSinkDefinition::fieldMap
QMap< QString, QgsProperty > fieldMap() const
Returns the field mapping, which defines how to map the values from incoming features to destination ...
Definition: qgsremappingproxyfeaturesink.h:51
operator!=
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:404
QgsRemappingSinkDefinition::setSourceCrs
void setSourceCrs(const QgsCoordinateReferenceSystem &source)
Sets the source crs used for reprojecting incoming features to the sink's destination CRS.
Definition: qgsremappingproxyfeaturesink.h:88
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsWkbTypes::Unknown
@ Unknown
Definition: qgswkbtypes.h:70
QgsRemappingSinkDefinition::setDestinationFields
void setDestinationFields(const QgsFields &fields)
Sets the fields for the destination sink.
Definition: qgsremappingproxyfeaturesink.h:130
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:572
QgsRemappingSinkDefinition::addMappedField
void addMappedField(const QString &destinationField, const QgsProperty &property)
Adds a mapping for a destination field.
Definition: qgsremappingproxyfeaturesink.h:74
QgsRemappingSinkDefinition::destinationFields
QgsFields destinationFields() const
Returns the fields for the destination sink.
Definition: qgsremappingproxyfeaturesink.h:123
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsRemappingProxyFeatureSink
Definition: qgsremappingproxyfeaturesink.h:178
QgsRemappingSinkDefinition::setFieldMap
void setFieldMap(const QMap< QString, QgsProperty > &map)
Sets the field mapping, which defines how to map the values from incoming features to destination fie...
Definition: qgsremappingproxyfeaturesink.h:63
qgsproperty.h
QgsFeature
Definition: qgsfeature.h:55
QgsRemappingSinkDefinition::sourceCrs
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source CRS used for reprojecting incoming features to the sink's destination CRS.
Definition: qgsremappingproxyfeaturesink.h:81
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
QgsFeatureIterator
Definition: qgsfeatureiterator.h:263
QgsFeatureSink
Definition: qgsfeaturesink.h:33