Skip to content

Commit

Permalink
GeoPDF creation requires GDAL 3 or later, add API to determine whethe…
Browse files Browse the repository at this point in the history
…r it's available at runtime
  • Loading branch information
nyalldawson committed Aug 17, 2019
1 parent 0ea60cc commit a0b6350
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/core/qgsabstractgeopdfexporter.cpp
Expand Up @@ -32,8 +32,29 @@
#include <QDomElement>


bool QgsAbstractGeoPdfExporter::geoPDFCreationAvailable()
{
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,0,0)
return false;
#else
return true;
#endif
}

QString QgsAbstractGeoPdfExporter::geoPDFAvailabilityExplanation()
{
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,0,0)
return QObject::tr( "GeoPDF creation requires GDAL version 3.0 or later." );
#else
return QString();
#endif
}

bool QgsAbstractGeoPdfExporter::finalize( const QList<ComponentLayerDetail> &components, const QString &destinationFile )
{
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,0,0)
return false;
#else
if ( !saveTemporaryLayers() )
return false;

Expand Down Expand Up @@ -72,13 +93,15 @@ bool QgsAbstractGeoPdfExporter::finalize( const QList<ComponentLayerDetail> &com
CSLDestroy( papszOptions );

return res;
#endif
}

QString QgsAbstractGeoPdfExporter::generateTemporaryFilepath( const QString &filename ) const
{
return mTemporaryDir.filePath( filename );
}


void QgsAbstractGeoPdfExporter::pushRenderedFeature( const QString &layerId, const QgsAbstractGeoPdfExporter::RenderedFeature &feature )
{
// because map layers may be rendered in parallel, we need a mutex here
Expand Down
22 changes: 19 additions & 3 deletions src/core/qgsabstractgeopdfexporter.h
Expand Up @@ -50,12 +50,27 @@ class CORE_EXPORT QgsAbstractGeoPdfExporter
{
public:

/**
* Returns TRUE if the current QGIS build is capable of GeoPDF support.
*
* If FALSE is returned, a user-friendly explanation why can be retrieved via
* geoPDFAvailabilityExplanation().
*/
static bool geoPDFCreationAvailable();

/**
* Returns a user-friendly, translated string explaining why GeoPDF export
* support is not available on the current QGIS build (or an empty string if
* GeoPDF support IS available).
* \see geoPDFCreationAvailable()
*/
static QString geoPDFAvailabilityExplanation();

/**
* Constructor for QgsAbstractGeoPdfExporter.
*/
QgsAbstractGeoPdfExporter() = default;


virtual ~QgsAbstractGeoPdfExporter() = default;

/**
Expand Down Expand Up @@ -164,8 +179,9 @@ class CORE_EXPORT QgsAbstractGeoPdfExporter
QMutex mMutex;
QMap< QString, QgsFeatureList > mCollatedFeatures;



/**
* Returns the PDF output component details for the layer with given \a layerId.
*/
virtual VectorComponentDetail componentDetailForLayerId( const QString &layerId ) = 0;

QList< VectorComponentDetail > mVectorComponents;
Expand Down

0 comments on commit a0b6350

Please sign in to comment.