QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsabstractgeopdfexporter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractgeopdfexporter.h
3 --------------------------
4 begin : August 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSABSTRACTGEOPDFEXPORTER_H
17#define QGSABSTRACTGEOPDFEXPORTER_H
18
19#include "qgis_core.h"
20#include <QList>
21#include <QTemporaryDir>
22#include <QMutex>
23#include <QDateTime>
24#include <QPainter>
25
26#include "qgsfeature.h"
28#include "qgspolygon.h"
30
31#define SIP_NO_FILE
32
33
34class QgsGeospatialPdfRenderedFeatureHandler;
35
56{
57 public:
58
65 static bool geospatialPDFCreationAvailable();
66
73 static QString geospatialPDFAvailabilityExplanation();
74
76
78
83 {
84
85 RenderedFeature() = default;
86
90 RenderedFeature( const QgsFeature &feature, const QgsGeometry &renderedBounds )
91 : feature( feature )
92 , renderedBounds( renderedBounds )
93 {}
94
99
104 };
105
111 struct CORE_EXPORT ComponentLayerDetail
112 {
113
115 QString name;
116
118 QString mapLayerId;
119
121 QString group;
122
125
127 QPainter::CompositionMode compositionMode = QPainter::CompositionMode_SourceOver;
128
130 double opacity = 1.0;
131
132 };
133
140 {
141
146 ControlPoint( const QgsPointXY &pagePoint, const QgsPointXY &geoPoint )
147 : pagePoint( pagePoint )
148 , geoPoint( geoPoint )
149 {}
150
153
156 };
157
159 {
160
167
174
177
179 QList< QgsAbstractGeospatialPdfExporter::ControlPoint > controlPoints;
180
181 };
182
190 void pushRenderedFeature( const QString &layerId, const QgsAbstractGeospatialPdfExporter::RenderedFeature &feature, const QString &group = QString() );
191
193 {
196
198 double dpi = 300;
199
201 QList< QgsAbstractGeospatialPdfExporter::GeoReferencedSection > georeferencedSections;
202
204 QString author;
205
207 QString producer;
208
210 QString creator;
211
214
216 QString subject;
217
219 QString title;
220
223
231 bool useIso32000ExtensionFormatGeoreferencing = true;
232
240 bool useOgcBestPracticeFormatGeoreferencing = false;
241
245 bool includeFeatures = true;
246
259 QMap< QString, QString > customLayerTreeGroups;
260
266 QMap< QString, QString > layerIdToPdfLayerTreeNameMap;
267
274 QMap< QString, bool > initialLayerVisibility;
275
285 QStringList layerOrder;
286
298
304 QSet< QString > mutuallyExclusiveGroups;
305
306 };
307
321 bool finalize( const QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > &components, const QString &destinationFile, const ExportDetails &details );
322
326 QString errorMessage() const { return mErrorMessage; }
327
331 QString generateTemporaryFilepath( const QString &filename ) const;
332
339 static bool compositionModeSupported( QPainter::CompositionMode mode );
340
341 protected:
342
347 {
349 QString name;
350
352 QString mapLayerId;
353
355 QString group;
356
359
362
365
366 };
367
368 private:
369
370 QMutex mMutex;
371 QMap< QString, QMap< QString, QgsFeatureList > > mCollatedFeatures;
372
376 virtual VectorComponentDetail componentDetailForLayerId( const QString &layerId ) = 0;
377
378 QList< VectorComponentDetail > mVectorComponents;
379
380 QString mErrorMessage;
381 QTemporaryDir mTemporaryDir;
382
383
384 bool saveTemporaryLayers();
385
386 QString createCompositionXml( const QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > &components, const ExportDetails &details );
387
391 static QString compositionModeToString( QPainter::CompositionMode mode );
392
393 friend class TestQgsLayoutGeospatialPdfExport;
394 friend class TestQgsGeospatialPdfExport;
395};
396
397#endif //QGSABSTRACTGEOPDFEXPORTER_H
398
399
400
Abstract base class for Geospatial PDF exporters.
virtual ~QgsAbstractGeospatialPdfExporter()=default
QString errorMessage() const
Returns the last error message encountered during the export.
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
This class represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A geometry is the spatial representation of a feature.
A class to represent a 2D point.
Definition qgspointxy.h:60
Polygon geometry type.
Definition qgspolygon.h:33
A rectangle specified with double values.
Contains details of a particular input component to be used during PDF composition.
QString mapLayerId
Associated map layer ID, or an empty string if this component layer is not associated with a map laye...
QString group
Optional group name, for arranging layers in top-level groups.
QString name
User-friendly name for the generated PDF layer.
QString sourcePdfPath
File path to the (already created) PDF to use as the source for this component layer.
Contains details of a control point used during georeferencing Geospatial PDF outputs.
QgsPointXY pagePoint
Coordinate on the page of the control point, in millimeters.
QgsPointXY geoPoint
Georeferenced coordinate of the control point, in CRS units.
ControlPoint(const QgsPointXY &pagePoint, const QgsPointXY &geoPoint)
Constructor for ControlPoint, at the specified pagePoint (in millimeters) and geoPoint (in CRS units)...
QMap< QString, QString > customLayerTreeGroups
Optional map of map layer ID to custom logical layer tree group in created PDF file.
QMap< QString, bool > initialLayerVisibility
Optional map of map layer ID to initial visibility state.
QList< QgsAbstractGeospatialPdfExporter::GeoReferencedSection > georeferencedSections
List of georeferenced sections.
QStringList layerOrder
Optional list of layer IDs, in the order desired to appear in the generated Geospatial PDF file.
QMap< QString, QString > layerIdToPdfLayerTreeNameMap
Optional map of map layer ID to custom layer tree name to show in the created PDF file.
QgsAbstractMetadataBase::KeywordMap keywords
Metadata keyword map.
QStringList layerTreeGroupOrder
Specifies the ordering of layer tree groups in the generated Geospatial PDF file.
QDateTime creationDateTime
Metadata creation datetime.
QSet< QString > mutuallyExclusiveGroups
Contains a list of group names which should be considered as mutually exclusive.
QgsRectangle pageBoundsMm
Bounds of the georeferenced section on the page, in millimeters.
QgsCoordinateReferenceSystem crs
Coordinate reference system for georeferenced section.
QList< QgsAbstractGeospatialPdfExporter::ControlPoint > controlPoints
List of control points corresponding to this georeferenced section.
QgsPolygon pageBoundsPolygon
Bounds of the georeferenced section on the page, in millimeters, as a free-form polygon.
Contains information about a feature rendered inside the PDF.
QgsGeometry renderedBounds
Bounds, in PDF units, of rendered feature.
RenderedFeature(const QgsFeature &feature, const QgsGeometry &renderedBounds)
Constructor for RenderedFeature.
Contains information relating to a single PDF layer in the Geospatial PDF export.
QString name
User-friendly name for the generated PDF layer.
QString sourceVectorPath
File path to the (already created) vector dataset to use as the source for this component layer.
QString sourceVectorLayer
Layer name in vector dataset to use as the source.