QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsprofilerequest.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprofilerequest.cpp
3  ---------------
4  begin : February 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 #include "qgsprofilerequest.h"
18 #include "qgscurve.h"
19 #include "qgsterrainprovider.h"
20 
22  : mCurve( curve )
23 {
24 
25 }
26 
28 
30  : mCurve( other.mCurve ? other.mCurve->clone() : nullptr )
31  , mCrs( other.mCrs )
32  , mTransformContext( other.mTransformContext )
33  , mTolerance( other.mTolerance )
34  , mStepDistance( other.mStepDistance )
35  , mTerrainProvider( other.mTerrainProvider ? other.mTerrainProvider->clone() : nullptr )
36  , mExpressionContext( other.mExpressionContext )
37 {
38 
39 }
40 
42 {
43  mCurve.reset( other.mCurve ? other.mCurve->clone() : nullptr );
44  mCrs = other.mCrs;
45  mTransformContext = other.mTransformContext;
46  mTolerance = other.mTolerance;
47  mStepDistance = other.mStepDistance;
48  mTerrainProvider.reset( other.mTerrainProvider ? other.mTerrainProvider->clone() : nullptr );
49  mExpressionContext = other.mExpressionContext;
50  return *this;
51 }
52 
54 {
55  if ( !qgsDoubleNear( mTolerance, other.mTolerance )
56  || !qgsDoubleNear( mStepDistance, other.mStepDistance )
57  || mCrs != other.mCrs
58  || !( mTransformContext == other.mTransformContext ) )
59  return false;
60 
61  if ( ( !mCurve && other.mCurve )
62  || ( mCurve && !other.mCurve ) )
63  {
64  return false;
65  }
66  else if ( mCurve && other.mCurve )
67  {
68  if ( !mCurve->equals( *other.mCurve ) )
69  return false;
70  }
71 
72  if ( ( mTerrainProvider && !other.mTerrainProvider )
73  || ( !mTerrainProvider && other.mTerrainProvider ) )
74  {
75  return false;
76  }
77  else if ( mTerrainProvider && other.mTerrainProvider )
78  {
79  if ( !mTerrainProvider->equals( other.mTerrainProvider.get() ) )
80  return false;
81  }
82 
83  return true;
84 }
85 
87 {
88  return !( *this == other );
89 }
90 
92 {
93  mCurve.reset( curve );
94  return *this;
95 }
96 
98 {
99  return mCurve.get();
100 }
101 
103 {
104  mCrs = crs;
105  return *this;
106 }
107 
109 {
110  return mCrs;
111 }
112 
114 {
115  return mTransformContext;
116 }
117 
119 {
120  mTransformContext = context;
121  return *this;
122 }
123 
125 {
126  mTolerance = tolerance;
127  return *this;
128 }
129 
131 {
132  mTerrainProvider.reset( provider );
133  return *this;
134 }
135 
137 {
138  return mTerrainProvider.get();
139 }
140 
142 {
143  mStepDistance = distance;
144  return *this;
145 }
146 
148 {
149  mExpressionContext = context;
150  return *this;
151 }
152 
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
QgsProfileRequest::setTerrainProvider
QgsProfileRequest & setTerrainProvider(QgsAbstractTerrainProvider *provider)
Sets the terrain provider.
Definition: qgsprofilerequest.cpp:130
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsProfileRequest::~QgsProfileRequest
~QgsProfileRequest()
QgsProfileRequest::setProfileCurve
QgsProfileRequest & setProfileCurve(QgsCurve *curve)
Sets the cross section profile curve, which represents the line along which the profile should be gen...
Definition: qgsprofilerequest.cpp:91
QgsProfileRequest::operator=
QgsProfileRequest & operator=(const QgsProfileRequest &other)
Assignment operator.
Definition: qgsprofilerequest.cpp:41
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsProfileRequest::operator==
bool operator==(const QgsProfileRequest &other) const
Definition: qgsprofilerequest.cpp:53
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsProfileRequest::terrainProvider
QgsAbstractTerrainProvider * terrainProvider() const
Returns the terrain provider.
Definition: qgsprofilerequest.cpp:136
QgsProfileRequest::setStepDistance
QgsProfileRequest & setStepDistance(double distance)
Sets the profile step distance (in crs() units).
Definition: qgsprofilerequest.cpp:141
QgsProfileRequest::setTolerance
QgsProfileRequest & setTolerance(double tolerance)
Sets the tolerance of the request (in crs() units).
Definition: qgsprofilerequest.cpp:124
QgsProfileRequest::setTransformContext
QgsProfileRequest & setTransformContext(const QgsCoordinateTransformContext &context)
Sets the transform context, for use when transforming coordinates from a source to the request's crs(...
Definition: qgsprofilerequest.cpp:118
QgsProfileRequest::profileCurve
QgsCurve * profileCurve() const
Returns the cross section profile curve, which represents the line along which the profile should be ...
Definition: qgsprofilerequest.cpp:97
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:2265
qgsprofilerequest.h
QgsProfileRequest
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Definition: qgsprofilerequest.h:37
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsProfileRequest::crs
QgsCoordinateReferenceSystem crs() const
Returns the desired Coordinate Reference System for the profile.
Definition: qgsprofilerequest.cpp:108
qgscurve.h
QgsProfileRequest::tolerance
double tolerance() const
Returns the tolerance of the request (in crs() units).
Definition: qgsprofilerequest.h:141
QgsProfileRequest::setExpressionContext
QgsProfileRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate expressions.
Definition: qgsprofilerequest.cpp:147
QgsProfileRequest::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when transforming coordinates from a source to the request's c...
Definition: qgsprofilerequest.cpp:113
qgsterrainprovider.h
QgsProfileRequest::setCrs
QgsProfileRequest & setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the desired Coordinate Reference System (crs) for the profile.
Definition: qgsprofilerequest.cpp:102
QgsAbstractTerrainProvider
Abstract base class for terrain providers.
Definition: qgsterrainprovider.h:40
QgsProfileRequest::QgsProfileRequest
QgsProfileRequest(QgsCurve *curve)
Constructor for QgsProfileRequest.
Definition: qgsprofilerequest.cpp:21
QgsProfileRequest::operator!=
bool operator!=(const QgsProfileRequest &other) const
Definition: qgsprofilerequest.cpp:86