QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsprofileexporter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprofileexporter.h
3 ---------------
4 begin : May 2023
5 copyright : (C) 2023 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 QGSPROFILEEXPORTER_H
18#define QGSPROFILEEXPORTER_H
19
20#include "qgis.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgsprofilerequest.h"
25#include "qgstaskmanager.h"
26
29
36class CORE_EXPORT QgsProfileExporter
37{
38 public:
45 QgsProfileExporter( const QList< QgsAbstractProfileSource * > &sources, const QgsProfileRequest &request, Qgis::ProfileExportType type );
46
47 QgsProfileExporter( const QgsProfileExporter &other ) = delete;
49
51
58 void run( QgsFeedback *feedback = nullptr );
59
68 QList< QgsVectorLayer * > toLayers() SIP_FACTORY;
69
70 private:
71#ifdef SIP_RUN
73#endif
74
76 QgsProfileRequest mRequest;
77 std::vector< std::unique_ptr< QgsAbstractProfileGenerator > > mGenerators;
78 QVector< QgsAbstractProfileResults::Feature > mFeatures;
79};
80
87class CORE_EXPORT QgsProfileExporterTask : public QgsTask
88{
89 Q_OBJECT
90
91 public:
95 enum class ExportResult
96 {
97 Success,
98 Empty,
99 DeviceError,
100 DxfExportFailed,
101 LayerExportFailed,
102 Canceled,
103 };
105
113 const QList< QgsAbstractProfileSource * > &sources, const QgsProfileRequest &request, Qgis::ProfileExportType type, const QString &destination, const QgsCoordinateTransformContext &transformContext
114 );
115
116 bool run() override;
117 void cancel() override;
118
127 QList< QgsVectorLayer * > takeLayers() SIP_FACTORY;
128
135
139 QStringList createdFiles() const { return mCreatedFiles; }
140
144 QString error() const { return mError; }
145
146 private:
147 std::unique_ptr< QgsProfileExporter > mExporter;
148 QList< QgsVectorLayer * > mLayers;
149
150 std::unique_ptr< QgsFeedback > mFeedback;
151 QString mDestination;
152 QgsCoordinateTransformContext mTransformContext;
153 ExportResult mResult = ExportResult::Success;
154 QString mError;
155 QStringList mCreatedFiles;
156};
157
158
159#endif // QGSPROFILEEXPORTER_H
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4374
@ Features3D
Export profiles as 3D features, with elevation values stored in exported geometry Z values.
Definition qgis.h:4375
Abstract base class for objects which generate elevation profiles.
Interface for classes which can generate elevation profiles.
Contains information about the context in which a coordinate transform is executed.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
ExportResult
Results of exporting the profile.
QgsProfileExporterTask(const QList< QgsAbstractProfileSource * > &sources, const QgsProfileRequest &request, Qgis::ProfileExportType type, const QString &destination, const QgsCoordinateTransformContext &transformContext)
Constructor for QgsProfileExporterTask, saving results to the specified destination file.
bool run() override
Performs the task's operation.
QgsProfileExporterTask::ExportResult result() const
Returns the result of the export operation.
Q_ENUM(ExportResult)
void cancel() override
Notifies the task that it should terminate.
QString error() const
Returns a descriptive error message, if available.
QStringList createdFiles() const
Returns a list of layer files created during the export.
QList< QgsVectorLayer * > takeLayers()
Returns a list of vector layer containing the exported profile results.
void run(QgsFeedback *feedback=nullptr)
Runs the profile generation.
QgsProfileExporter(const QList< QgsAbstractProfileSource * > &sources, const QgsProfileRequest &request, Qgis::ProfileExportType type)
Constructor for QgsProfileExporter, using the provided list of profile sources to generate the result...
QgsProfileExporter & operator=(const QgsProfileExporter &other)=delete
QList< QgsVectorLayer * > toLayers()
Returns a list of vector layer containing the exported profile results.
QgsProfileExporter(const QgsProfileExporter &other)=delete
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
QgsTask(const QString &description=QString(), QgsTask::Flags flags=AllFlags)
Constructor for QgsTask.
#define SIP_FACTORY
Definition qgis_sip.h:83