Skip to content
Permalink
Browse files

Add factory method which creates an initialized transformer from meth…

…od and list of GCPs
  • Loading branch information
nyalldawson committed Feb 21, 2021
1 parent 125c33b commit f2f1d70fa78eedaa7f0801aa3c8b9db45122cce8
@@ -68,6 +68,16 @@ Returns a translated string representing the specified transform ``method``.
%Docstring
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.
%End

@@ -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
@@ -88,6 +88,16 @@ class ANALYSIS_EXPORT QgsGcpTransformerInterface SIP_ABSTRACT
*/
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

/**

0 comments on commit f2f1d70

Please sign in to comment.