QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsterrainprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsterrainprovider.h
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#ifndef QGSTERRAINPROVIDER_H
18#define QGSTERRAINPROVIDER_H
19
20#include "qgis_core.h"
21#include "qgsmaplayerref.h"
22#include "qgsmeshlayer.h"
23#include "qgsrange.h"
24#include "qgsrasterlayer.h"
25#include "qgstriangularmesh.h"
26#include "qgsunittypes.h"
27
28#include <QObject>
29#include <QString>
30
31using namespace Qt::StringLiterals;
32
33class QDomElement;
35class QDomDocument;
36
44{
45
46#ifdef SIP_RUN
48 if ( sipCpp->type().compare( "flat"_L1 ) == 0 )
49 {
50 sipType = sipType_QgsFlatTerrainProvider;
51 }
52 else if ( sipCpp->type().compare( "raster"_L1 ) == 0 )
53 {
54 sipType = sipType_QgsRasterDemTerrainProvider;
55 }
56 else if ( sipCpp->type().compare( "mesh"_L1 ) == 0 )
57 {
58 sipType = sipType_QgsMeshTerrainProvider;
59 }
60 else
61 {
62 sipType = 0;
63 }
65#endif
66
67 public:
68
70
72
76 virtual bool equals( const QgsAbstractTerrainProvider *other ) const = 0;
77
81 virtual void resolveReferences( const QgsProject *project );
82
87 virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
88
93 virtual QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
94
98 virtual QString type() const = 0;
99
106
113 virtual void prepare() = 0 SIP_FACTORY;
114
119
125 virtual double heightAt( double x, double y ) const = 0;
126
133 double scale() const { return mScale; }
134
141 void setScale( double scale ) { mScale = scale; }
142
149 double offset() const { return mOffset; }
150
157 void setOffset( double offset ) { mOffset = offset; }
158
159 protected:
160
162
163#ifndef SIP_RUN
165#endif
166
170 void writeCommonProperties( QDomElement &element, const QgsReadWriteContext &context ) const;
171
175 void readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
176
178 double mScale = 1.0;
179
181 double mOffset = 0.0;
182
183 private:
184
185#ifdef SIP_RUN
187#endif
188
189};
190
191
199{
200 public:
201
203
204 QString type() const override;
205 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
206 QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const override;
207 QgsCoordinateReferenceSystem crs() const override;
208 double heightAt( double x, double y ) const override;
209 QgsFlatTerrainProvider *clone() const override SIP_FACTORY;
210 void prepare() override;
211 bool equals( const QgsAbstractTerrainProvider *other ) const override;
212};
213
221{
222 public:
223
225
226#ifndef SIP_RUN
228#endif
229
230 QString type() const override;
231 void resolveReferences( const QgsProject *project ) override;
232 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
233 QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const override;
234 QgsCoordinateReferenceSystem crs() const override;
235 double heightAt( double x, double y ) const override;
237 bool equals( const QgsAbstractTerrainProvider *other ) const override;
238 void prepare() override;
239
246
252 QgsRasterLayer *layer() const;
253
254
255 private:
257
258 _LayerRef<QgsRasterLayer> mRasterLayer;
259 std::unique_ptr< QgsRasterDataProvider > mRasterProvider;
260
261};
262
263
271{
272 public:
273
275
276#ifndef SIP_RUN
278#endif
279
280 QString type() const override;
281 void resolveReferences( const QgsProject *project ) override;
282 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
283 QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const override;
284 QgsCoordinateReferenceSystem crs() const override;
285 double heightAt( double x, double y ) const override;
286 QgsMeshTerrainProvider *clone() const override SIP_FACTORY;
287 bool equals( const QgsAbstractTerrainProvider *other ) const override;
288 void prepare() override;
289
295 void setLayer( QgsMeshLayer *layer );
296
302 QgsMeshLayer *layer() const;
303
304 private:
306
307 _LayerRef<QgsMeshLayer> mMeshLayer;
308 QgsTriangularMesh mTriangularMesh;
309};
310
311#endif // QGSTERRAINPROVIDER_H
QgsAbstractTerrainProvider & operator=(const QgsAbstractTerrainProvider &other)=delete
virtual bool equals(const QgsAbstractTerrainProvider *other) const =0
Returns true if the provider is equal to other.
virtual QString type() const =0
Returns the unique type ID string for the provider.
virtual double heightAt(double x, double y) const =0
Returns the height at the point (x,y) in the terrain provider's native crs().
void readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from a DOM element.
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the terrain provider state from a DOM element.
virtual ~QgsAbstractTerrainProvider()
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the native coordinate reference system of the terrain provider.
virtual void prepare()=0
Called on the main thread prior to accessing the provider from a background thread.
void writeCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Writes common properties to a DOM element.
double offset() const
Returns the vertical offset value, used for adjusting the heights from the terrain provider.
double scale() const
Returns the vertical scale factor, which can be used to exaggerate vertical heights.
virtual QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const =0
Returns a DOM element representing the state of the terrain provider.
virtual void resolveReferences(const QgsProject *project)
Resolves reference to layers from stored layer ID (if it has not been resolved already).
QgsAbstractTerrainProvider()=default
void setOffset(double offset)
Returns the vertical offset value, used for adjusting the heights from the terrain provider.
void setScale(double scale)
Sets the vertical scale factor, which can be used to exaggerate vertical heights.
virtual QgsAbstractTerrainProvider * clone() const =0
Creates a clone of the provider and returns the new object.
Represents a coordinate reference system (CRS).
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the terrain provider state from a DOM element.
bool equals(const QgsAbstractTerrainProvider *other) const override
Returns true if the provider is equal to other.
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const override
Returns a DOM element representing the state of the terrain provider.
QgsFlatTerrainProvider * clone() const override
Creates a clone of the provider and returns the new object.
QgsCoordinateReferenceSystem crs() const override
Returns the native coordinate reference system of the terrain provider.
QgsFlatTerrainProvider()=default
void prepare() override
Called on the main thread prior to accessing the provider from a background thread.
double heightAt(double x, double y) const override
Returns the height at the point (x,y) in the terrain provider's native crs().
QString type() const override
Returns the unique type ID string for the provider.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
void setLayer(QgsMeshLayer *layer)
Sets the mesh layer to be used as the terrain source.
QgsMeshTerrainProvider()=default
QgsMeshTerrainProvider * clone() const override
Creates a clone of the provider and returns the new object.
bool equals(const QgsAbstractTerrainProvider *other) const override
Returns true if the provider is equal to other.
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const override
Returns a DOM element representing the state of the terrain provider.
void prepare() override
Called on the main thread prior to accessing the provider from a background thread.
QString type() const override
Returns the unique type ID string for the provider.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the terrain provider state from a DOM element.
void resolveReferences(const QgsProject *project) override
Resolves reference to layers from stored layer ID (if it has not been resolved already).
double heightAt(double x, double y) const override
Returns the height at the point (x,y) in the terrain provider's native crs().
QgsMeshLayer * layer() const
Returns the mesh layer to be used as the terrain source.
QgsCoordinateReferenceSystem crs() const override
Returns the native coordinate reference system of the terrain provider.
const QgsMeshTerrainProvider * operator=(const QgsMeshTerrainProvider &other)=delete
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:112
Base class for raster data providers.
QgsRasterDemTerrainProvider * clone() const override
Creates a clone of the provider and returns the new object.
void setLayer(QgsRasterLayer *layer)
Sets the raster layer with elevation model to be used as the terrain source.
QgsCoordinateReferenceSystem crs() const override
Returns the native coordinate reference system of the terrain provider.
void prepare() override
Called on the main thread prior to accessing the provider from a background thread.
void resolveReferences(const QgsProject *project) override
Resolves reference to layers from stored layer ID (if it has not been resolved already).
const QgsRasterDemTerrainProvider * operator=(const QgsRasterDemTerrainProvider &other)=delete
QgsRasterLayer * layer() const
Returns the raster layer with elevation model to be used as the terrain source.
bool equals(const QgsAbstractTerrainProvider *other) const override
Returns true if the provider is equal to other.
double heightAt(double x, double y) const override
Returns the height at the point (x,y) in the terrain provider's native crs().
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const override
Returns a DOM element representing the state of the terrain provider.
QString type() const override
Returns the unique type ID string for the provider.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the terrain provider state from a DOM element.
Represents a raster layer.
A container for the context for various read/write operations on objects.
A triangular/derived mesh with vertices in map coordinates.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216
Internal structure to keep weak pointer to QgsMapLayer or layerId if the layer is not available yet.