Skip to content

Commit

Permalink
[needs-docs] Expose choice of GeoPDF export format to users
Browse files Browse the repository at this point in the history
Either "ISO3200 extension" or "OGC 'best practice'" options are availab.e

ISO3200 format is recommended, and results in Geospatial PDF files compatible
with the built-in Acrobat geospatial tools.

The OGC Best Practice format results in GeoPDF files compatible with the TerraGo
suite of tools, but can break compatibility with the built-in Acrobat
geospatial tools (yes, GeoPDF format is a mess!).
  • Loading branch information
nyalldawson committed Aug 19, 2019
1 parent 913f53a commit 446eb06
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 20 deletions.
3 changes: 1 addition & 2 deletions python/core/auto_generated/qgsmaprenderertask.sip.in
Expand Up @@ -35,8 +35,7 @@ task. This can be used to draw maps without blocking the QGIS interface.
QgsMapRendererTask( const QgsMapSettings &ms,
const QString &fileName,
const QString &fileFormat = QString( "PNG" ),
bool forceRaster = false,
bool geoPdf = false, const QgsAbstractGeoPdfExporter::ExportDetails &geoPdfExportDetails = QgsAbstractGeoPdfExporter::ExportDetails() );
bool forceRaster = false );
%Docstring
Constructor for QgsMapRendererTask to render a map to an image file.

Expand Down
13 changes: 13 additions & 0 deletions src/app/qgsmapsavedialog.cpp
Expand Up @@ -130,6 +130,8 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co
else
{
mGeoPDFOptionsStackedWidget->setCurrentIndex( 1 );
mGeoPdfFormatComboBox->addItem( tr( "ISO 32000 Extension (recommended)" ) );
mGeoPdfFormatComboBox->addItem( tr( "OGC Best Practice" ) );
}
break;
}
Expand Down Expand Up @@ -499,6 +501,17 @@ void QgsMapSaveDialog::onAccepted()
geoPdfExportDetails.title = QgsProject::instance()->metadata().title();
geoPdfExportDetails.keywords = QgsProject::instance()->metadata().keywords();
}

if ( mGeoPdfFormatComboBox->currentIndex() == 0 )
{
geoPdfExportDetails.useIso32000ExtensionFormatGeoreferencing = true;
geoPdfExportDetails.useOgcBestPracticeFormatGeoreferencing = false;
}
else
{
geoPdfExportDetails.useIso32000ExtensionFormatGeoreferencing = false;
geoPdfExportDetails.useOgcBestPracticeFormatGeoreferencing = true;
}
}
QgsMapRendererTask *mapRendererTask = new QgsMapRendererTask( ms, fileName, QStringLiteral( "PDF" ), saveAsRaster(), mGeoPDFGroupBox->isChecked(), geoPdfExportDetails );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsabstractgeopdfexporter.cpp
Expand Up @@ -296,8 +296,8 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
#if 0
QDomElement georeferencing = doc.createElement( QStringLiteral( "Georeferencing" ) );
georeferencing.setAttribute( QStringLiteral( "id" ), QStringLiteral( "georeferenced" ) );
georeferencing.setAttribute( QStringLiteral( "OGCBestPracticeFormat" ), QStringLiteral( "false" ) );
georeferencing.setAttribute( QStringLiteral( "ISO32000ExtensionFormat" ), QStringLiteral( "true" ) );
georeferencing.setAttribute( QStringLiteral( "OGCBestPracticeFormat" ), details.useOgcBestPracticeFormatGeoreferencing ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
georeferencing.setAttribute( QStringLiteral( "ISO32000ExtensionFormat" ), details.useIso32000ExtensionFormatGeoreferencing ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
QDomElement srs = doc.createElement( QStringLiteral( "SRS" ) );
// srs.setAttribute( QStringLiteral( "dataAxisToSRSAxisMapping" ), QStringLiteral( "2,1" ) );
srs.appendChild( doc.createTextNode( QStringLiteral( "EPSG:4326" ) ) );
Expand Down
17 changes: 17 additions & 0 deletions src/core/qgsabstractgeopdfexporter.h
Expand Up @@ -159,6 +159,23 @@ class CORE_EXPORT QgsAbstractGeoPdfExporter
//! Metadata keyword map
QgsAbstractMetadataBase::KeywordMap keywords;

/**
* TRUE if ISO3200 extension format georeferencing should be used.
*
* This is a recommended setting which results in Geospatial PDF files compatible
* with the built-in Acrobat geospatial tools.
*/
bool useIso32000ExtensionFormatGeoreferencing = true;

/**
* TRUE if OGC "best practice" format georeferencing should be used.
*
* \warning This results in GeoPDF files compatible with the TerraGo suite of tools, but
* can break compatibility with the built-in Acrobat geospatial tools (yes, GeoPDF
* format is a mess!).
*/
bool useOgcBestPracticeFormatGeoreferencing = false;

};

/**
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsmaprenderertask.h
Expand Up @@ -61,11 +61,18 @@ class CORE_EXPORT QgsMapRendererTask : public QgsTask
* If the output \a fileFormat is set to PDF, the \a geoPdf argument controls whether a GeoPDF file is created.
* See QgsAbstractGeoPdfExporter::geoPDFCreationAvailable() for conditions on GeoPDF creation availability.
*/
#ifndef SIP_RUN
QgsMapRendererTask( const QgsMapSettings &ms,
const QString &fileName,
const QString &fileFormat = QString( "PNG" ),
bool forceRaster = false,
bool geoPdf = false, const QgsAbstractGeoPdfExporter::ExportDetails &geoPdfExportDetails = QgsAbstractGeoPdfExporter::ExportDetails() );
#else
QgsMapRendererTask( const QgsMapSettings &ms,
const QString &fileName,
const QString &fileFormat = QString( "PNG" ),
bool forceRaster = false );
#endif

/**
* Constructor for QgsMapRendererTask to render a map to a QPainter object.
Expand Down
42 changes: 26 additions & 16 deletions src/ui/qgsmapsavedialog.ui
Expand Up @@ -84,7 +84,7 @@
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1">
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -97,30 +97,27 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>102</height>
</size>
</property>
</spacer>
<item row="1" column="1">
<widget class="QComboBox" name="mGeoPdfFormatComboBox"/>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="mExportMetadataCheckBox">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Export RDF metadata (title, author, etc.)</string>
<string>Format</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mExportMetadataCheckBox">
<property name="text">
<string>Export RDF metadata (title, author, etc.)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -306,6 +303,19 @@ Rasterizing the map is recommended when such effects are used.</string>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
Expand Down

0 comments on commit 446eb06

Please sign in to comment.