QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 }
26 
27 QgsGcpGeometryTransformer::QgsGcpGeometryTransformer( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &sourceCoordinates, const QVector<QgsPointXY> &destinationCoordinates )
28  : mGcpTransformer( QgsGcpTransformerInterface::createFromParameters( method, sourceCoordinates, destinationCoordinates ) )
29 {
30 
31 }
32 
34 
35 bool QgsGcpGeometryTransformer::transformPoint( double &x, double &y, double &, double & )
36 {
37  if ( !mGcpTransformer )
38  return false;
39 
40  return mGcpTransformer->transform( x, y );
41 }
42 
44 {
45  ok = false;
46  if ( geometry.isNull() )
47  {
48  ok = true;
49  return QgsGeometry();
50  }
51 
52  std::unique_ptr< QgsAbstractGeometry > res( geometry.constGet()->clone() );
53 
54  ok = res->transform( this, feedback );
55 
56  return QgsGeometry( std::move( res ) );
57 }
58 
60 {
61  return mGcpTransformer.get();
62 }
63 
65 {
66  mGcpTransformer.reset( gcpTransformer );
67 }
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:45
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.
Definition: qgsgeometry.h:125
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Q_GADGET bool isNull
Definition: qgsgeometry.h:127