QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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
19#include "qgscurve.h"
20#include "qgsterrainprovider.h"
21
23 : mCurve( curve )
24{}
25
27
29 : mCurve( other.mCurve ? other.mCurve->clone() : nullptr )
30 , mCrs( other.mCrs )
31 , mTransformContext( other.mTransformContext )
32 , mTolerance( other.mTolerance )
33 , mStepDistance( other.mStepDistance )
34 , mTerrainProvider( other.mTerrainProvider ? other.mTerrainProvider->clone() : nullptr )
35 , mExpressionContext( other.mExpressionContext )
36{}
37
39{
40 if ( &other == this )
41 return *this;
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 ) || !qgsDoubleNear( mStepDistance, other.mStepDistance ) || mCrs != other.mCrs || !( mTransformContext == other.mTransformContext ) )
56 return false;
57
58 if ( ( !mCurve && other.mCurve ) || ( mCurve && !other.mCurve ) )
59 {
60 return false;
61 }
62 else if ( mCurve && other.mCurve )
63 {
64 if ( !mCurve->equals( *other.mCurve ) )
65 return false;
66 }
67
68 if ( ( mTerrainProvider && !other.mTerrainProvider ) || ( !mTerrainProvider && other.mTerrainProvider ) )
69 {
70 return false;
71 }
72 else if ( mTerrainProvider && other.mTerrainProvider )
73 {
74 if ( !mTerrainProvider->equals( other.mTerrainProvider.get() ) )
75 return false;
76 }
77
78 return true;
79}
80
82{
83 return !( *this == other );
84}
85
87{
88 mCurve.reset( curve );
89 return *this;
90}
91
93{
94 return mCurve.get();
95}
96
98{
99 mCrs = crs;
100 return *this;
101}
102
104{
105 return mCrs;
106}
107
109{
110 return mTransformContext;
111}
112
114{
115 mTransformContext = context;
116 return *this;
117}
118
120{
121 mTolerance = tolerance;
122 return *this;
123}
124
126{
127 mTerrainProvider.reset( provider );
128 return *this;
129}
130
132{
133 return mTerrainProvider.get();
134}
135
137{
138 mStepDistance = distance;
139 return *this;
140}
141
143{
144 mExpressionContext = context;
145 return *this;
146}
Abstract base class for terrain providers.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsProfileRequest & setStepDistance(double distance)
Sets the profile step distance (in crs() units).
QgsAbstractTerrainProvider * terrainProvider() const
Returns the terrain provider.
QgsProfileRequest(QgsCurve *curve)
Constructor for QgsProfileRequest.
QgsProfileRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate expressions.
bool operator==(const QgsProfileRequest &other) const
QgsCoordinateReferenceSystem crs() const
Returns the desired Coordinate Reference System for the profile.
bool operator!=(const QgsProfileRequest &other) const
double tolerance() const
Returns the tolerance of the request (in crs() units).
QgsProfileRequest & setTransformContext(const QgsCoordinateTransformContext &context)
Sets the transform context, for use when transforming coordinates from a source to the request's crs(...
QgsCurve * profileCurve() const
Returns the cross section profile curve, which represents the line along which the profile should be ...
QgsProfileRequest & setTerrainProvider(QgsAbstractTerrainProvider *provider)
Sets the terrain provider.
QgsProfileRequest & setProfileCurve(QgsCurve *curve)
Sets the cross section profile curve, which represents the line along which the profile should be gen...
QgsProfileRequest & setTolerance(double tolerance)
Sets the tolerance of the request (in crs() units).
QgsProfileRequest & setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the desired Coordinate Reference System (crs) for the profile.
QgsProfileRequest & operator=(const QgsProfileRequest &other)
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when transforming coordinates from a source to the request's c...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:6975