QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
45 explicit QgsVectorWarper( QgsGcpTransformerInterface::TransformMethod method, const QList<QgsGcpPoint> &points, const QgsCoordinateReferenceSystem &destinationCrs );
46
54 bool transformFeatures( QgsFeatureIterator &iterator, QgsFeatureSink *sink, const QgsCoordinateTransformContext &context, QgsFeedback *feedback = nullptr ) const;
55
59 QString error() const { return mError; }
60
61 private:
63 QList<QgsGcpPoint> mPoints;
64 QgsCoordinateReferenceSystem mDestinationCrs;
65
66 mutable QString mError;
67};
68
69
76class ANALYSIS_EXPORT QgsVectorWarperTask : public QgsTask
77{
78 Q_OBJECT
79
80 public:
90 QgsVectorWarperTask( QgsGcpTransformerInterface::TransformMethod method, const QList<QgsGcpPoint> &points, const QgsCoordinateReferenceSystem &destinationCrs, QgsVectorLayer *layer, const QString &fileName );
91
92 void cancel() override;
93
95 enum class Result
96 {
97 Success,
98 Canceled,
99 Error,
100 };
101
105 Result result() const { return mResult; }
106
110 QString errorMessage() const { return mErrorMessage; }
111
112 protected:
113 bool run() override;
114
115 private:
117 long long mFeatureCount = 0;
118 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
119 QList<QgsGcpPoint> mPoints;
120 QgsCoordinateReferenceSystem mDestinationCrs;
121
122 QString mDestFileName;
123
124 std::unique_ptr<QgsFeedback> mFeedback;
125
126 QgsCoordinateTransformContext mTransformContext;
127 QgsFields mFields;
129
130 Result mResult = Result::Success;
131 QString mErrorMessage;
132 double mLastProgress = 0;
133};
134
135
136#endif //QGSVECTORWARPER_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
@ 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.