QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
elevation
qgsprofilepoint.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsprofilepoint.h
3
---------------
4
begin : April 2022
5
copyright : (C) 2022 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
#ifndef QGSPROFILEPOINT_H
18
#define QGSPROFILEPOINT_H
19
20
#include "
qgis.h
"
21
#include "qgis_core.h"
22
#include "
qgis_sip.h
"
23
24
#include <QString>
25
26
using namespace
Qt::StringLiterals;
27
34
class
CORE_EXPORT
QgsProfilePoint
35
{
36
public
:
40
QgsProfilePoint
() =
default
;
41
42
// clang-format off
46
QgsProfilePoint
(
double
distance
,
double
elevation
)
SIP_HOLDGIL
47
// clang-format on
48
: mDistance(
distance
)
49
, mElevation(
elevation
)
50
, mIsEmpty(
false
)
51
{}
52
58
void
setDistance
(
double
distance
)
SIP_HOLDGIL
59
{
60
mDistance =
distance
;
61
mIsEmpty =
false
;
62
}
63
69
void
setElevation
(
double
elevation
)
SIP_HOLDGIL
70
{
71
mElevation =
elevation
;
72
mIsEmpty =
false
;
73
}
74
80
double
distance
() const
SIP_HOLDGIL
{
return
mDistance; }
81
87
double
elevation
() const
SIP_HOLDGIL
{
return
mElevation; }
88
94
bool
isEmpty
() const
SIP_HOLDGIL
{
return
mIsEmpty; }
95
96
bool
operator==
(
const
QgsProfilePoint
&other )
SIP_HOLDGIL
97
{
98
if
(
isEmpty
() && other.isEmpty() )
99
return
true
;
100
if
(
isEmpty
() && !other.isEmpty() )
101
return
false
;
102
if
( !
isEmpty
() && other.isEmpty() )
103
return
false
;
104
105
bool
equal =
true
;
106
equal &=
qgsDoubleNear
( other.mDistance, mDistance, 1E-8 );
107
equal &=
qgsDoubleNear
( other.mElevation, mElevation, 1E-8 );
108
109
return
equal;
110
}
111
112
bool
operator!=
(
const
QgsProfilePoint
&other )
const
SIP_HOLDGIL
113
{
114
if
(
isEmpty
() && other.isEmpty() )
115
return
false
;
116
if
(
isEmpty
() && !other.isEmpty() )
117
return
true
;
118
if
( !
isEmpty
() && other.isEmpty() )
119
return
true
;
120
121
bool
equal =
true
;
122
equal &=
qgsDoubleNear
( other.mDistance, mDistance, 1E-8 );
123
equal &=
qgsDoubleNear
( other.mElevation, mElevation, 1E-8 );
124
125
return
!equal;
126
}
127
128
// clang-format off
129
#ifdef SIP_RUN
130
SIP_PYOBJECT __repr__();
131
% MethodCode
132
const
QString str = sipCpp->isEmpty()
133
? u
"<QgsProfilePoint: EMPTY>"
_s
134
: u
"<QgsProfilePoint: %1, %2>"
_s.arg( sipCpp->distance() ).arg( sipCpp->elevation() );
135
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
136
% End
137
138
int
__len__();
139
% MethodCode
140
sipRes = 2;
141
% End
142
143
SIP_PYOBJECT __getitem__(
int
);
144
% MethodCode
145
if
( a0 == 0 )
146
{
147
sipRes = Py_BuildValue(
"d"
, sipCpp->distance() );
148
}
149
else
if
( a0 == 1 )
150
{
151
sipRes = Py_BuildValue(
"d"
, sipCpp->elevation() );
152
}
153
else
154
{
155
QString msg = QString(
"Bad index: %1"
).arg( a0 );
156
PyErr_SetString( PyExc_IndexError, msg.toLatin1().constData() );
157
}
158
% End
159
#endif
160
// clang-format on
161
162
private
:
163
double
mDistance = 0;
164
double
mElevation = 0;
165
bool
mIsEmpty =
true
;
166
};
167
168
#endif
// QGSPROFILEPOINT_H
QgsProfilePoint::QgsProfilePoint
QgsProfilePoint()=default
Constructor for an empty point.
QgsProfilePoint::setDistance
void setDistance(double distance)
Sets the distance of the point.
Definition
qgsprofilepoint.h:58
QgsProfilePoint::operator==
bool operator==(const QgsProfilePoint &other)
Definition
qgsprofilepoint.h:96
QgsProfilePoint::QgsProfilePoint
QgsProfilePoint(double distance, double elevation)
Create a point at the specified distance and elevation coordinates.
Definition
qgsprofilepoint.h:46
QgsProfilePoint::operator!=
bool operator!=(const QgsProfilePoint &other) const
Definition
qgsprofilepoint.h:112
QgsProfilePoint::elevation
double elevation() const
Returns the elevation of the point.
Definition
qgsprofilepoint.h:87
QgsProfilePoint::distance
double distance() const
Returns the distance of the point.
Definition
qgsprofilepoint.h:80
QgsProfilePoint::isEmpty
bool isEmpty() const
Returns true if the point is empty.
Definition
qgsprofilepoint.h:94
QgsProfilePoint::setElevation
void setElevation(double elevation)
Sets the elevation of the point.
Definition
qgsprofilepoint.h:69
qgis.h
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition
qgis.h:7771
qgis_sip.h
SIP_HOLDGIL
#define SIP_HOLDGIL
Definition
qgis_sip.h:183
Generated on
for QGIS API Documentation by
1.17.0