QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 "qgsfeature.h"
26 #include "qgspolygon.h"
27 
28 #define SIP_NO_FILE
29 
30 
31 class QgsGeoPdfRenderedFeatureHandler;
32 
52 class CORE_EXPORT QgsAbstractGeoPdfExporter
53 {
54  public:
55 
62  static bool geoPDFCreationAvailable();
63 
70  static QString geoPDFAvailabilityExplanation();
71 
75  QgsAbstractGeoPdfExporter() = default;
76 
77  virtual ~QgsAbstractGeoPdfExporter() = default;
78 
83  {
84 
88  RenderedFeature() = default;
89 
93  RenderedFeature( const QgsFeature &feature, const QgsGeometry &renderedBounds )
94  : feature( feature )
95  , renderedBounds( renderedBounds )
96  {}
97 
102 
107  };
108 
114  struct CORE_EXPORT ComponentLayerDetail
115  {
116 
118  QString name;
119 
121  QString mapLayerId;
122 
124  QString group;
125 
127  QString sourcePdfPath;
128 
129  };
130 
137  {
138 
143  ControlPoint( const QgsPointXY &pagePoint, const QgsPointXY &geoPoint )
144  : pagePoint( pagePoint )
145  , geoPoint( geoPoint )
146  {}
147 
150 
153  };
154 
156  {
157 
164 
171 
174 
176  QList< QgsAbstractGeoPdfExporter::ControlPoint > controlPoints;
177 
178  };
179 
187  void pushRenderedFeature( const QString &layerId, const QgsAbstractGeoPdfExporter::RenderedFeature &feature, const QString &group = QString() );
188 
190  {
192  QSizeF pageSizeMm;
193 
195  double dpi = 300;
196 
198  QList< QgsAbstractGeoPdfExporter::GeoReferencedSection > georeferencedSections;
199 
201  QString author;
202 
204  QString producer;
205 
207  QString creator;
208 
210  QDateTime creationDateTime;
211 
213  QString subject;
214 
216  QString title;
217 
220 
227  bool useIso32000ExtensionFormatGeoreferencing = true;
228 
236  bool useOgcBestPracticeFormatGeoreferencing = false;
237 
241  bool includeFeatures = true;
242 
253  QMap< QString, QString > customLayerTreeGroups;
254 
255  };
256 
270  bool finalize( const QList< QgsAbstractGeoPdfExporter::ComponentLayerDetail > &components, const QString &destinationFile, const ExportDetails &details );
271 
275  QString errorMessage() { return mErrorMessage; }
276 
280  QString generateTemporaryFilepath( const QString &filename ) const;
281 
282  protected:
283 
288  {
290  QString name;
291 
293  QString mapLayerId;
294 
296  QString group;
297 
300 
303 
306 
307  };
308 
309  private:
310 
311  QMutex mMutex;
312  QMap< QString, QMap< QString, QgsFeatureList > > mCollatedFeatures;
313 
317  virtual VectorComponentDetail componentDetailForLayerId( const QString &layerId ) = 0;
318 
319  QList< VectorComponentDetail > mVectorComponents;
320 
321  QString mErrorMessage;
322  QTemporaryDir mTemporaryDir;
323 
324  bool saveTemporaryLayers();
325 
326  QString createCompositionXml( const QList< QgsAbstractGeoPdfExporter::ComponentLayerDetail > &components, const ExportDetails &details );
327 
328  friend class TestQgsLayoutGeoPdfExport;
329  friend class TestQgsGeoPdfExport;
330 };
331 
332 #endif //QGSABSTRACTGEOPDFEXPORTER_H
333 
334 
335 
Abstract base class for GeoPDF exporters.
QList< QgsAbstractGeoPdfExporter::GeoReferencedSection > georeferencedSections
List of georeferenced sections.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QString mapLayerId
Associated map layer ID, or an empty string if this component layer is not associated with a map laye...
ControlPoint(const QgsPointXY &pagePoint, const QgsPointXY &geoPoint)
Constructor for ControlPoint, at the specified pagePoint (in millimeters) and geoPoint (in CRS units)...
A class to represent a 2D point.
Definition: qgspointxy.h:43
QgsGeometry renderedBounds
Bounds, in PDF units, of rendered feature.
QgsAbstractMetadataBase::KeywordMap keywords
Metadata keyword map.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:122
QString sourceVectorLayer
Layer name in vector dataset to use as the source.
QSizeF pageSizeMm
Page size, in millimeters.
QMap< QString, QString > customLayerTreeGroups
Optional map of map layer ID to custom logical layer tree group in created PDF file.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
QDateTime creationDateTime
Metadata creation datetime.
Contains details of a control point used during georeferencing GeoPDF outputs.
RenderedFeature(const QgsFeature &feature, const QgsGeometry &renderedBounds)
Constructor for RenderedFeature.
QList< QgsAbstractGeoPdfExporter::ControlPoint > controlPoints
List of control points corresponding to this georeferenced section.
QgsCoordinateReferenceSystem crs
Coordinate reference system for georeferenced section.
Contains information about a feature rendered inside the PDF.
QString sourceVectorPath
File path to the (already created) vector dataset to use as the source for this component layer...
Contains information relating to a single PDF layer in the GeoPDF export.
QString errorMessage()
Returns the last error message encountered during the export.
QgsRectangle pageBoundsMm
Bounds of the georeferenced section on the page, in millimeters.
QString group
Optional group name, for arranging layers in top-level groups.
Contains details of a particular input component to be used during PDF composition.
QString name
User-friendly name for the generated PDF layer.
QgsPolygon pageBoundsPolygon
Bounds of the georeferenced section on the page, in millimeters, as a free-form polygon.
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
This class represents a coordinate reference system (CRS).
QString sourcePdfPath
File path to the (already created) PDF to use as the source for this component layer.
QgsPointXY pagePoint
Coordinate on the page of the control point, in millimeters.
Polygon geometry type.
Definition: qgspolygon.h:31
QgsPointXY geoPoint
Georeferenced coordinate of the control point, in CRS units.
QString name
User-friendly name for the generated PDF layer.