Skip to content
Permalink
Browse files

Create class QgsGcpGeometryTransformer, which allows transformation

of geometry objects via a ground control points based transformation
  • Loading branch information
nyalldawson committed Feb 21, 2021
1 parent ce54321 commit fd7149ac97a67447113400623af2199cecfa72f0
@@ -1,5 +1,6 @@
// Include auto-generated SIP files
%Include auto_generated/qgsanalysis.sip
%Include auto_generated/georeferencing/qgsgcpgeometrytransformer.sip
%Include auto_generated/georeferencing/qgsgcptransformer.sip
%Include auto_generated/interpolation/qgsgridfilewriter.sip
%Include auto_generated/interpolation/qgsidwinterpolator.sip
@@ -0,0 +1,75 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/georeferencing/qgsgcpgeometrytransformer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsGcpGeometryTransformer : QgsAbstractGeometryTransformer
{
%Docstring
A geometry transformer which uses an underlying Ground Control Points (GCP) based transformation to modify geometries.

.. versionadded:: 3.18
%End

%TypeHeaderCode
#include "qgsgcpgeometrytransformer.h"
%End
public:

QgsGcpGeometryTransformer( QgsGcpTransformerInterface *gcpTransformer /Transfer/ );
%Docstring
Constructor for QgsGcpGeometryTransformer, which uses the specified ``gcpTransformer`` to
modify geometries.

Ownership of ``gcpTransformer`` is transferred to the geometry transformer.
%End

QgsGcpGeometryTransformer( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &sourceCoordinates, const QVector<QgsPointXY> &destinationCoordinates );
%Docstring
Constructor for QgsGcpGeometryTransformer, which uses the specified transform ``method`` and
list of source and destination coordinates to transform geometries.
%End

~QgsGcpGeometryTransformer();



virtual bool transformPoint( double &x /In,Out/, double &y /In,Out/, double &z /In,Out/, double &m /In,Out/ );

%Docstring
QgsGcpGeometryTransformer cannot be copied
%End

QgsGcpTransformerInterface *gcpTransformer() const;
%Docstring
Returns the underlying GCP transformer used to transform geometries.

.. seealso:: :py:func:`setGcpTransformer`
%End

void setGcpTransformer( QgsGcpTransformerInterface *transformer /Transfer/ );
%Docstring
Sets the underlying GCP ``transformer`` used to transform geometries.

Ownership is transferred to this object.

.. seealso:: :py:func:`gcpTransformer`
%End

private:
QgsGcpGeometryTransformer( const QgsGcpGeometryTransformer &other );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/georeferencing/qgsgcpgeometrytransformer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -3,6 +3,8 @@

set(QGIS_ANALYSIS_SRCS
qgsanalysis.cpp

georeferencing/qgsgcpgeometrytransformer.cpp
georeferencing/qgsgcptransformer.cpp
georeferencing/qgsleastsquares.cpp

@@ -285,6 +287,7 @@ set(QGIS_ANALYSIS_SRCS
set(QGIS_ANALYSIS_HDRS
qgsanalysis.h

georeferencing/qgsgcpgeometrytransformer.h
georeferencing/qgsgcptransformer.h

interpolation/Bezier3D.h
@@ -0,0 +1,48 @@
/***************************************************************************
qgsgcpgeometrytransformer.cpp
----------------------
begin : February 2021
copyright : (C) 2021 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsgcpgeometrytransformer.h"


QgsGcpGeometryTransformer::QgsGcpGeometryTransformer( QgsGcpTransformerInterface *gcpTransformer )
: mGcpTransformer( gcpTransformer )
{

}

QgsGcpGeometryTransformer::QgsGcpGeometryTransformer( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &sourceCoordinates, const QVector<QgsPointXY> &destinationCoordinates )
: mGcpTransformer( QgsGcpTransformerInterface::createFromParameters( method, sourceCoordinates, destinationCoordinates ) )
{

}

QgsGcpGeometryTransformer::~QgsGcpGeometryTransformer() = default;

bool QgsGcpGeometryTransformer::transformPoint( double &x, double &y, double &, double & )
{
return mGcpTransformer->transform( x, y );
}

QgsGcpTransformerInterface *QgsGcpGeometryTransformer::gcpTransformer() const
{
return mGcpTransformer.get();
}

void QgsGcpGeometryTransformer::setGcpTransformer( QgsGcpTransformerInterface *gcpTransformer )
{
mGcpTransformer.reset( gcpTransformer );
}
@@ -0,0 +1,86 @@
/***************************************************************************
qgsgcpgeometrytransformer.h
----------------------
begin : February 2021
copyright : (C) 2021 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSGCPGEOMETRYTRANSFORMER_H
#define QGSGCPGEOMETRYTRANSFORMER_H

#include "qgis_analysis.h"
#include "qgsgeometrytransformer.h"
#include "qgsgcptransformer.h"
#include <memory>

/**
* \class QgsGcpGeometryTransformer
* \ingroup analysis
* A geometry transformer which uses an underlying Ground Control Points (GCP) based transformation to modify geometries.
*
* \since QGIS 3.18
*/
class ANALYSIS_EXPORT QgsGcpGeometryTransformer : public QgsAbstractGeometryTransformer
{
public:

/**
* Constructor for QgsGcpGeometryTransformer, which uses the specified \a gcpTransformer to
* modify geometries.
*
* Ownership of \a gcpTransformer is transferred to the geometry transformer.
*/
QgsGcpGeometryTransformer( QgsGcpTransformerInterface *gcpTransformer SIP_TRANSFER );

/**
* Constructor for QgsGcpGeometryTransformer, which uses the specified transform \a method and
* list of source and destination coordinates to transform geometries.
*/
QgsGcpGeometryTransformer( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &sourceCoordinates, const QVector<QgsPointXY> &destinationCoordinates );

~QgsGcpGeometryTransformer() override;

//! QgsGcpGeometryTransformer cannot be copied
QgsGcpGeometryTransformer( const QgsGcpGeometryTransformer &other ) = delete;

//! QgsGcpGeometryTransformer cannot be copied
QgsGcpGeometryTransformer &operator=( const QgsGcpGeometryTransformer &other ) = delete;

bool transformPoint( double &x SIP_INOUT, double &y SIP_INOUT, double &z SIP_INOUT, double &m SIP_INOUT ) override;

/**
* Returns the underlying GCP transformer used to transform geometries.
*
* \see setGcpTransformer()
*/
QgsGcpTransformerInterface *gcpTransformer() const;

/**
* Sets the underlying GCP \a transformer used to transform geometries.
*
* Ownership is transferred to this object.
*
* \see gcpTransformer()
*/
void setGcpTransformer( QgsGcpTransformerInterface *transformer SIP_TRANSFER );

private:
#ifdef SIP_RUN
QgsGcpGeometryTransformer( const QgsGcpGeometryTransformer &other );
#endif

std::unique_ptr< QgsGcpTransformerInterface > mGcpTransformer;

};

#endif // QGSGCPGEOMETRYTRANSFORMER_H

0 comments on commit fd7149a

Please sign in to comment.