QGIS API Documentation 3.99.0-Master (26c88405ac0)
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 "qgsfeatureiterator.h"
22#include "qgsgcppoint.h"
23#include "qgsgcptransformer.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, const QgsCoordinateReferenceSystem &destinationCrs );
47
55 bool transformFeatures( QgsFeatureIterator &iterator, QgsFeatureSink *sink, const QgsCoordinateTransformContext &context, QgsFeedback *feedback = nullptr ) const;
56
60 QString error() const { return mError; }
61
62 private:
64 QList<QgsGcpPoint> mPoints;
65 QgsCoordinateReferenceSystem mDestinationCrs;
66
67 mutable QString mError;
68};
69
70
77class ANALYSIS_EXPORT QgsVectorWarperTask : public QgsTask
78{
79 Q_OBJECT
80
81 public:
82
92 QgsVectorWarperTask( QgsGcpTransformerInterface::TransformMethod method, const QList<QgsGcpPoint> &points, const QgsCoordinateReferenceSystem &destinationCrs, QgsVectorLayer *layer, const QString &fileName );
93
94 void cancel() override;
95
97 enum class Result
98 {
99 Success,
100 Canceled,
101 Error,
102 };
103
107 Result result() const { return mResult; }
108
112 QString errorMessage() const { return mErrorMessage; }
113
114 protected:
115 bool run() override;
116
117 private:
119 long long mFeatureCount = 0;
120 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
121 QList<QgsGcpPoint> mPoints;
122 QgsCoordinateReferenceSystem mDestinationCrs;
123
124 QString mDestFileName;
125
126 std::unique_ptr<QgsFeedback> mFeedback;
127
128 QgsCoordinateTransformContext mTransformContext;
129 QgsFields mFields;
131
132 Result mResult = Result::Success;
133 QString mErrorMessage;
134 double mLastProgress = 0;
135};
136
137
138#endif //QGSVECTORWARPER_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:277
@ Unknown
Unknown.
Definition qgis.h:278
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.
QgsTask(const QString &description=QString(), QgsTask::Flags flags=AllFlags)
Constructor for QgsTask.
Represents a vector layer which manages a vector based dataset.
QString errorMessage() const
Returns the descriptive error message, if an error occurred.
Result result() const
Returns the result of running the task.
void cancel() override
Notifies the task that it should terminate.
QgsVectorWarperTask(QgsGcpTransformerInterface::TransformMethod method, const QList< QgsGcpPoint > &points, const QgsCoordinateReferenceSystem &destinationCrs, QgsVectorLayer *layer, const QString &fileName)
Constructor for QgsVectorWarperTask.
QString error() const
Returns the last error obtained during transformation.
bool transformFeatures(QgsFeatureIterator &iterator, QgsFeatureSink *sink, const QgsCoordinateTransformContext &context, QgsFeedback *feedback=nullptr) const
Transforms the features from iterator and adds the results to the specified sink.
QgsVectorWarper(QgsGcpTransformerInterface::TransformMethod method, const QList< QgsGcpPoint > &points, const QgsCoordinateReferenceSystem &destinationCrs)
Constructor for QgsVectorWarper.