1 /***************************************************************************
2                              qgsgeometrytransformer.h
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 
18 #ifndef QGSGEOMETRYTRANSFORMER_H
19 #define QGSGEOMETRYTRANSFORMER_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 
24 /**
25  * \class QgsAbstractGeometryTransformer
26  * \ingroup core
27  * \brief An abstract base class for classes which transform geometries by transforming
28  * input points to output points.
29  *
30  * \since QGIS 3.18
31  */
32 class CORE_EXPORT QgsAbstractGeometryTransformer
33 {
34   public:
35 
36     virtual ~QgsAbstractGeometryTransformer() = default;
37 
38     /**
39      * Transforms the point defined by the coordinates (\a x, \a y, \a z) and the specified \a m value.
40      *
41      * \param x point x coordinate
42      * \param y point y coordinate
43      * \param z point z coordinate, or NaN if the input point is 2D only
44      * \param m point m value, or NaN if not available
45      *
46      * \returns TRUE if point was transformed (or no transformation was required), or FALSE if point could not be transformed successfully.
47      *
48      * ### Example
49      *
50      * A transformer which multiples the x coordinate by 3 and adds 10 to the y coordinate:
51      *
52      * \code{.py}
53      *   class MyTransformer(QgsAbstractGeometryTransformer):
54      *
55      *     def transformPoint(self, x, y, z, m):
56      *       # returns a tuple of True to indicate success, then the modified x/y/z/m values
57      *       return True, x*3, y+10, z, m
58      * \endcode
59      */
60     virtual bool transformPoint( double &x SIP_INOUT, double &y SIP_INOUT, double &z SIP_INOUT, double &m  SIP_INOUT ) = 0;
61 
62 };
63 
64 #endif // QGSGEOMETRYTRANSFORMER_H
65