QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsvectorwarper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorwarper.h
3 --------------------------------------
4 Date : February 2022
5 Copyright : (C) 2022 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSVECTORWARPER_H
17#define QGSVECTORWARPER_H
18
19#include "qgspoint.h"
20#include "qgis_analysis.h"
21#include "qgis_sip.h"
22#include "qgsgcptransformer.h"
23#include "qgsgcppoint.h"
24#include "qgsfeatureiterator.h"
25#include "qgsfeaturesource.h"
26#include "qgstaskmanager.h"
27#include "qgsvectorfilewriter.h"
29
30class QgsFeatureSink;
31
38class ANALYSIS_EXPORT QgsVectorWarper
39{
40 public:
41
49 explicit QgsVectorWarper( QgsGcpTransformerInterface::TransformMethod method, const QList < QgsGcpPoint > &points,
50 const QgsCoordinateReferenceSystem &destinationCrs );
51
59 bool transformFeatures( QgsFeatureIterator &iterator, QgsFeatureSink *sink,
60 const QgsCoordinateTransformContext &context,
61 QgsFeedback *feedback = nullptr ) const;
62
66 QString error() const { return mError; }
67
68 private:
70 QList < QgsGcpPoint > mPoints;
71 QgsCoordinateReferenceSystem mDestinationCrs;
72
73 mutable QString mError;
74
75};
76
77
84class ANALYSIS_EXPORT QgsVectorWarperTask : public QgsTask
85{
86 Q_OBJECT
87
88 public:
89
99 QgsVectorWarperTask( QgsGcpTransformerInterface::TransformMethod method, const QList < QgsGcpPoint > &points,
100 const QgsCoordinateReferenceSystem &destinationCrs,
101 QgsVectorLayer *layer,
102 const QString &fileName );
103
104 void cancel() override;
105
107 enum class Result
108 {
109 Success,
110 Canceled,
111 Error,
112 };
113
117 Result result() const { return mResult; }
118
122 QString errorMessage() const { return mErrorMessage; }
123
124 protected:
125
126 bool run() override;
127
128 private:
129
131 long long mFeatureCount = 0;
132 std::unique_ptr< QgsVectorLayerFeatureSource > mSource;
133 QList < QgsGcpPoint > mPoints;
134 QgsCoordinateReferenceSystem mDestinationCrs;
135
136 QString mDestFileName;
137
138 std::unique_ptr< QgsFeedback > mFeedback;
139
140 QgsCoordinateTransformContext mTransformContext;
141 QgsFields mFields;
143
144 Result mResult = Result::Success;
145 QString mErrorMessage;
146 double mLastProgress = 0;
147};
148
149
150#endif //QGSVECTORWARPER_H
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Wrapper for iterator of features from vector data provider or vector layer.
An interface for objects which accept features via addFeature(s) methods.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Container of fields for a vector layer.
Definition: qgsfields.h:45
TransformMethod
Available transformation methods.
Abstract base class for long running background tasks.
Represents a vector layer which manages a vector based data sets.
A task for warping a vector layer in a background thread.
QString errorMessage() const
Returns the descriptive error message, if an error occurred.
Result result() const
Returns the result of running the task.
Vector layer warper which warps vector layers based on a list of source and destination GCPs.
QString error() const
Returns the last error obtained during transformation.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70