QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include "qgsgeometry.h"
20
22 : mGcpTransformer( gcpTransformer )
23{
24}
25
26QgsGcpGeometryTransformer::QgsGcpGeometryTransformer( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &sourceCoordinates, const QVector<QgsPointXY> &destinationCoordinates )
27 : mGcpTransformer( QgsGcpTransformerInterface::createFromParameters( method, sourceCoordinates, destinationCoordinates ) )
28{
29}
30
32
33bool QgsGcpGeometryTransformer::transformPoint( double &x, double &y, double &, double & )
34{
35 if ( !mGcpTransformer )
36 return false;
37
38 return mGcpTransformer->transform( x, y );
39}
40
42{
43 ok = false;
44 if ( geometry.isNull() )
45 {
46 ok = true;
47 return QgsGeometry();
48 }
49
50 std::unique_ptr<QgsAbstractGeometry> res( geometry.constGet()->clone() );
51
52 ok = res->transform( this, feedback );
53
54 return QgsGeometry( std::move( res ) );
55}
56
58{
59 return mGcpTransformer.get();
60}
61
63{
64 mGcpTransformer.reset( gcpTransformer );
65}
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.