Skip to content

Commit

Permalink
Add factory method which creates an initialized transformer from meth…
Browse files Browse the repository at this point in the history
…od and list of GCPs
  • Loading branch information
nyalldawson committed Feb 21, 2021
1 parent 125c33b commit f2f1d70
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Expand Up @@ -68,6 +68,16 @@ Returns a translated string representing the specified transform ``method``.
%Docstring %Docstring
Creates a new QgsGcpTransformerInterface subclass representing the specified transform ``method``. Creates a new QgsGcpTransformerInterface subclass representing the specified transform ``method``.


Caller takes ownership of the returned object.
%End

static QgsGcpTransformerInterface *createFromParameters( TransformMethod method, const QVector<QgsPointXY> &mapCoordinates, const QVector<QgsPointXY> &pixelCoordinates ) /Factory/;
%Docstring
Creates a new QgsGcpTransformerInterface subclass representing the specified transform ``method``, initialized
using the given lists of map and pixel coordinates.

If the parameters cannot be fit to a transform ``None`` will be returned.

Caller takes ownership of the returned object. Caller takes ownership of the returned object.
%End %End


Expand Down
12 changes: 12 additions & 0 deletions src/analysis/georeferencing/qgsgcptransformer.cpp
Expand Up @@ -72,6 +72,18 @@ QgsGcpTransformerInterface *QgsGcpTransformerInterface::create( QgsGcpTransforme
} }
} }


QgsGcpTransformerInterface *QgsGcpTransformerInterface::createFromParameters( QgsGcpTransformerInterface::TransformMethod method, const QVector<QgsPointXY> &mapCoordinates, const QVector<QgsPointXY> &pixelCoordinates )
{
std::unique_ptr< QgsGcpTransformerInterface > transformer( create( method ) );
if ( !transformer )
return nullptr;

if ( !transformer->updateParametersFromGcps( mapCoordinates, pixelCoordinates ) )
return nullptr;

return transformer.release();
}



// //
// QgsLinearGeorefTransform // QgsLinearGeorefTransform
Expand Down
10 changes: 10 additions & 0 deletions src/analysis/georeferencing/qgsgcptransformer.h
Expand Up @@ -88,6 +88,16 @@ class ANALYSIS_EXPORT QgsGcpTransformerInterface SIP_ABSTRACT
*/ */
static QgsGcpTransformerInterface *create( TransformMethod method ) SIP_FACTORY; static QgsGcpTransformerInterface *create( TransformMethod method ) SIP_FACTORY;


/**
* Creates a new QgsGcpTransformerInterface subclass representing the specified transform \a method, initialized
* using the given lists of map and pixel coordinates.
*
* If the parameters cannot be fit to a transform NULLPTR will be returned.
*
* Caller takes ownership of the returned object.
*/
static QgsGcpTransformerInterface *createFromParameters( TransformMethod method, const QVector<QgsPointXY> &mapCoordinates, const QVector<QgsPointXY> &pixelCoordinates ) SIP_FACTORY;

#ifndef SIP_RUN #ifndef SIP_RUN


/** /**
Expand Down

0 comments on commit f2f1d70

Please sign in to comment.