forked from ZOO-Project/ZOO-Project
/
qgsgcppoint.h
140 lines (119 loc) · 4.21 KB
/
qgsgcppoint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/***************************************************************************
qgsgcppoint.h
--------------------------------------
Date : February 2022
Copyright : (C) 2022 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 QGSGCPPOINT_H
#define QGSGCPPOINT_H
//#include "qgis_analysis.h"
#include "qgscoordinatereferencesystem.h"
class QgsCoordinateTransformContext;
/**
* \ingroup analysis
* \brief Contains properties of a ground control point (GCP).
*
* \since QGIS 3.26
*/
class ANALYSIS_EXPORT QgsGcpPoint
{
public:
//! Coordinate point types
enum class PointType
{
Source, //!< Source point
Destination, //!< Destination point
};
/**
* Constructor for QgsGcpPoint.
*
* \param sourcePoint source coordinates. This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
* \param destinationPoint destination coordinates
* \param destinationPointCrs CRS of destination point
* \param enabled whether the point is currently enabled
*/
QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint,
const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled = true );
/**
* Returns the source coordinates.
*
* This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
*
* \see setSourcePoint()
*/
QgsPointXY sourcePoint() const { return mSourcePoint; }
/**
* Sets the source coordinates.
*
* This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
*
* \see sourcePoint()
*/
void setSourcePoint( QgsPointXY point ) { mSourcePoint = point; }
/**
* Returns the destination coordinates.
*
* \see setDestinationPoint()
*/
QgsPointXY destinationPoint() const { return mDestinationPoint; }
/**
* Sets the destination coordinates.
*
* \see destinationPoint()
*/
void setDestinationPoint( QgsPointXY point ) { mDestinationPoint = point; }
/**
* Returns the CRS of the destination point.
*
* \see setDestinationPointCrs()
*/
QgsCoordinateReferenceSystem destinationPointCrs() const;
/**
* Sets the \a crs of the destination point.
*
* \see destinationPointCrs()
*/
void setDestinationPointCrs( const QgsCoordinateReferenceSystem &crs );
/**
* Returns the destionationPoint() transformed to the given target CRS.
*/
QgsPointXY transformedDestinationPoint( const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const;
/**
* Returns TRUE if the point is currently enabled.
*
* \see setEnabled()
*/
bool isEnabled() const { return mEnabled; }
/**
* Sets whether the point is currently enabled.
*
* \see isEnabled()
*/
void setEnabled( bool enabled ) { mEnabled = enabled; }
// TODO c++20 - replace with = default
bool operator==( const QgsGcpPoint &other ) const
{
return mEnabled == other.mEnabled
&& mSourcePoint == other.mSourcePoint
&& mDestinationPoint == other.mDestinationPoint
&& mDestinationCrs == other.mDestinationCrs;
}
bool operator!=( const QgsGcpPoint &other ) const
{
return !( *this == other );
}
private:
QgsPointXY mSourcePoint;
QgsPointXY mDestinationPoint;
QgsCoordinateReferenceSystem mDestinationCrs;
bool mEnabled = true;
};
#endif //QGSGCPPOINT_H