QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
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 "qgis_analysis.h"
20#include "qgis_sip.h"
21#include "qgsgcptransformer.h"
22#include "qgsgcppoint.h"
23#include "qgsfeatureiterator.h"
24#include "qgstaskmanager.h"
26
27class QgsFeatureSink;
28
35class ANALYSIS_EXPORT QgsVectorWarper
36{
37 public:
38
46 explicit QgsVectorWarper( QgsGcpTransformerInterface::TransformMethod method, const QList < QgsGcpPoint > &points,
47 const QgsCoordinateReferenceSystem &destinationCrs );
48
56 bool transformFeatures( QgsFeatureIterator &iterator, QgsFeatureSink *sink,
57 const QgsCoordinateTransformContext &context,
58 QgsFeedback *feedback = nullptr ) const;
59
63 QString error() const { return mError; }
64
65 private:
67 QList < QgsGcpPoint > mPoints;
68 QgsCoordinateReferenceSystem mDestinationCrs;
69
70 mutable QString mError;
71
72};
73
74
81class ANALYSIS_EXPORT QgsVectorWarperTask : public QgsTask
82{
83 Q_OBJECT
84
85 public:
86
96 QgsVectorWarperTask( QgsGcpTransformerInterface::TransformMethod method, const QList < QgsGcpPoint > &points,
97 const QgsCoordinateReferenceSystem &destinationCrs,
98 QgsVectorLayer *layer,
99 const QString &fileName );
100
101 void cancel() override;
102
104 enum class Result
105 {
106 Success,
107 Canceled,
108 Error,
109 };
110
114 Result result() const { return mResult; }
115
119 QString errorMessage() const { return mErrorMessage; }
120
121 protected:
122
123 bool run() override;
124
125 private:
126
128 long long mFeatureCount = 0;
129 std::unique_ptr< QgsVectorLayerFeatureSource > mSource;
130 QList < QgsGcpPoint > mPoints;
131 QgsCoordinateReferenceSystem mDestinationCrs;
132
133 QString mDestFileName;
134
135 std::unique_ptr< QgsFeedback > mFeedback;
136
137 QgsCoordinateTransformContext mTransformContext;
138 QgsFields mFields;
140
141 Result mResult = Result::Success;
142 QString mErrorMessage;
143 double mLastProgress = 0;
144};
145
146
147#endif //QGSVECTORWARPER_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:201
@ Unknown
Unknown.
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:44
Container of fields for a vector layer.
Definition qgsfields.h:46
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.