QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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"
26
39{
40 public:
41
52 QMap< QString, QgsProperty > fieldMap() const { return mFieldMap; }
53
64 void setFieldMap( const QMap< QString, QgsProperty > &map ) { mFieldMap = map; }
65
75 void addMappedField( const QString &destinationField, const QgsProperty &property ) { mFieldMap.insert( destinationField, property ); }
76
82 QgsCoordinateReferenceSystem sourceCrs() const { return mSourceCrs; }
83
89 void setSourceCrs( const QgsCoordinateReferenceSystem &source ) { mSourceCrs = source; }
90
96 QgsCoordinateReferenceSystem destinationCrs() const { return mDestinationCrs; }
97
103 void setDestinationCrs( const QgsCoordinateReferenceSystem &destination ) { mDestinationCrs = destination; }
104
110 QgsWkbTypes::Type destinationWkbType() const { return mDestinationWkbType; }
111
117 void setDestinationWkbType( QgsWkbTypes::Type type ) { mDestinationWkbType = type; }
118
124 QgsFields destinationFields() const { return mDestinationFields; }
125
131 void setDestinationFields( const QgsFields &fields ) { mDestinationFields = fields; }
132
138 QVariant toVariant() const;
139
145 bool loadVariant( const QVariantMap &map );
146
147 // TODO c++20 - replace with = default
148 bool operator==( const QgsRemappingSinkDefinition &other ) const;
149 bool operator!=( const QgsRemappingSinkDefinition &other ) const;
150
151 private:
152
153 QMap< QString, QgsProperty > mFieldMap;
154
156 QgsCoordinateReferenceSystem mDestinationCrs;
157
158 QgsWkbTypes::Type mDestinationWkbType = QgsWkbTypes::Unknown;
159
160 QgsFields mDestinationFields;
161
162};
163
165
166
167
168
181{
182 public:
183
184#ifndef SIP_RUN
185
194 QgsRemappingProxyFeatureSink( const QgsRemappingSinkDefinition &mappingDefinition, QgsFeatureSink *sink, bool ownsSink = false );
195#else
196
202#endif
203
205
209 void setExpressionContext( const QgsExpressionContext &context ) const;
210
214 void setTransformContext( const QgsCoordinateTransformContext &context );
215
219 QgsFeatureList remapFeature( const QgsFeature &feature ) const;
220
221 bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
222 bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
223 bool addFeatures( QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
224 QString lastError() const override;
225
229 QgsFeatureSink *destinationSink() { return mSink; }
230
231 private:
232
233 QgsRemappingSinkDefinition mDefinition;
234 QgsCoordinateTransform mTransform;
235 QgsFeatureSink *mSink = nullptr;
236 mutable QgsExpressionContext mContext;
237 bool mOwnsSink = false;
238};
239
240#endif // QGSREMAPPINGPROXYFEATURESINK_H
241
242
243
244
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:230
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
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:922
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)