QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsgcpgeometrytransformer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsgcpgeometrytransformer.cpp
3 ----------------------
4 begin : February 2021
5 copyright : (C) 2021 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
19
20#include "qgsgeometry.h"
21
26
27QgsGcpGeometryTransformer::QgsGcpGeometryTransformer( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &sourceCoordinates, const QVector<QgsPointXY> &destinationCoordinates )
28 : mGcpTransformer( QgsGcpTransformerInterface::createFromParameters( method, sourceCoordinates, destinationCoordinates ) )
29{
30}
31
33
34bool QgsGcpGeometryTransformer::transformPoint( double &x, double &y, double &, double & )
35{
36 if ( !mGcpTransformer )
37 return false;
38
39 return mGcpTransformer->transform( x, y );
40}
41
43{
44 ok = false;
45 if ( geometry.isNull() )
46 {
47 ok = true;
48 return QgsGeometry();
49 }
50
51 std::unique_ptr<QgsAbstractGeometry> res( geometry.constGet()->clone() );
52
53 ok = res->transform( this, feedback );
54
55 return QgsGeometry( std::move( res ) );
56}
57
59{
60 return mGcpTransformer.get();
61}
62
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
void setGcpTransformer(QgsGcpTransformerInterface *transformer)
Sets the underlying GCP transformer used to transform geometries.
QgsGeometry transform(const QgsGeometry &geometry, bool &ok, QgsFeedback *feedback=nullptr)
Transforms the specified input geometry using the GCP based transform.
~QgsGcpGeometryTransformer() override
QgsGcpGeometryTransformer(QgsGcpTransformerInterface *gcpTransformer)
Constructor for QgsGcpGeometryTransformer, which uses the specified gcpTransformer to modify geometri...
bool transformPoint(double &x, double &y, double &z, double &m) override
Transforms the point defined by the coordinates (x, y, z) and the specified m value.
QgsGcpTransformerInterface * gcpTransformer() const
Returns the underlying GCP transformer used to transform geometries.
An interface for Ground Control Points (GCP) based transformations.
TransformMethod
Available transformation methods.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.