mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Nice and friendly API
This commit is contained in:
		
							parent
							
								
									fd7149ac97
								
							
						
					
					
						commit
						d8a6d36780
					
				@ -9,6 +9,7 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class QgsGcpGeometryTransformer : QgsAbstractGeometryTransformer
 | 
			
		||||
{
 | 
			
		||||
%Docstring
 | 
			
		||||
@ -46,6 +47,18 @@ list of source and destination coordinates to transform geometries.
 | 
			
		||||
QgsGcpGeometryTransformer cannot be copied
 | 
			
		||||
%End
 | 
			
		||||
 | 
			
		||||
    QgsGeometry transform( const QgsGeometry &geometry, bool &ok /Out/, QgsFeedback *feedback = 0 );
 | 
			
		||||
%Docstring
 | 
			
		||||
Transforms the specified input ``geometry`` using the GCP based transform.
 | 
			
		||||
 | 
			
		||||
:param geometry: Input geometry to transform
 | 
			
		||||
:param feedback: This optional argument can be used to cancel the transformation before it completes.
 | 
			
		||||
                 If this is done, the geometry will be left in a semi-transformed state.
 | 
			
		||||
 | 
			
		||||
:return: - transformed geometry
 | 
			
		||||
         - ok: will be set to ``True`` if geometry was successfully transformed, or ``False`` if an error occurred
 | 
			
		||||
%End
 | 
			
		||||
 | 
			
		||||
    QgsGcpTransformerInterface *gcpTransformer() const;
 | 
			
		||||
%Docstring
 | 
			
		||||
Returns the underlying GCP transformer used to transform geometries.
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "qgsgcpgeometrytransformer.h"
 | 
			
		||||
 | 
			
		||||
#include "qgsgeometry.h"
 | 
			
		||||
 | 
			
		||||
QgsGcpGeometryTransformer::QgsGcpGeometryTransformer( QgsGcpTransformerInterface *gcpTransformer )
 | 
			
		||||
  : mGcpTransformer( gcpTransformer )
 | 
			
		||||
@ -34,9 +34,24 @@ QgsGcpGeometryTransformer::~QgsGcpGeometryTransformer() = default;
 | 
			
		||||
 | 
			
		||||
bool QgsGcpGeometryTransformer::transformPoint( double &x, double &y, double &, double & )
 | 
			
		||||
{
 | 
			
		||||
  if ( !mGcpTransformer )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  return mGcpTransformer->transform( x, y );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgsGeometry QgsGcpGeometryTransformer::transform( const QgsGeometry &geometry, bool &ok, QgsFeedback *feedback )
 | 
			
		||||
{
 | 
			
		||||
  if ( geometry.isNull() )
 | 
			
		||||
    return QgsGeometry();
 | 
			
		||||
 | 
			
		||||
  std::unique_ptr< QgsAbstractGeometry > res( geometry.constGet()->clone() );
 | 
			
		||||
 | 
			
		||||
  ok = res->transform( this, feedback );
 | 
			
		||||
 | 
			
		||||
  return QgsGeometry( std::move( res ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgsGcpTransformerInterface *QgsGcpGeometryTransformer::gcpTransformer() const
 | 
			
		||||
{
 | 
			
		||||
  return mGcpTransformer.get();
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,8 @@
 | 
			
		||||
#include "qgsgcptransformer.h"
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
class QgsGeometry;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \class QgsGcpGeometryTransformer
 | 
			
		||||
 * \ingroup analysis
 | 
			
		||||
@ -58,6 +60,18 @@ class ANALYSIS_EXPORT QgsGcpGeometryTransformer : public QgsAbstractGeometryTran
 | 
			
		||||
 | 
			
		||||
    bool transformPoint( double &x SIP_INOUT, double &y SIP_INOUT, double &z SIP_INOUT, double &m SIP_INOUT ) override;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Transforms the specified input \a geometry using the GCP based transform.
 | 
			
		||||
     *
 | 
			
		||||
     * \param geometry Input geometry to transform
 | 
			
		||||
     * \param ok will be set to TRUE if geometry was successfully transformed, or FALSE if an error occurred
 | 
			
		||||
     * \param feedback This optional argument can be used to cancel the transformation before it completes.
 | 
			
		||||
     * If this is done, the geometry will be left in a semi-transformed state.
 | 
			
		||||
     *
 | 
			
		||||
     * \returns transformed geometry
 | 
			
		||||
     */
 | 
			
		||||
    QgsGeometry transform( const QgsGeometry &geometry, bool &ok SIP_OUT, QgsFeedback *feedback = nullptr );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the underlying GCP transformer used to transform geometries.
 | 
			
		||||
     *
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user