Skip to content
Permalink
Browse files

Merge pull request #8781 from mhugent/get_atlas_print

[server][needs-docs] Get atlas print
  • Loading branch information
mhugent committed Jan 7, 2019
2 parents 0c71e72 + f1d2239 commit 54a5fae0b7ba0b627e5e1aac691da02c04dc0585
@@ -152,6 +152,15 @@ Returns the quality for WMS images defined in a QGIS project.
:param project: the QGIS project

:return: quality if defined in project, -1 otherwise.
%End

int wmsMaxAtlasFeatures( const QgsProject &project );
%Docstring
Returns the maximum number of atlas features which can be printed in a request

:param project: the QGIS project

:return: the number of atlas features
%End

bool wmsUseLayerIds( const QgsProject &project );
@@ -637,6 +637,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWMSImageQualitySpinBox->setValue( imageQuality );
}

mWMSMaxAtlasFeaturesSpinBox->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), 1 ) );

mWMTSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), QString() ) );
mWMTSMinScaleLineEdit->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WMTSMinScale" ), QStringLiteral( "/" ), 5000 ) );

@@ -1260,6 +1262,9 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( QStringLiteral( "WMSImageQuality" ), QStringLiteral( "/" ), imageQualityValue );
}

int maxAtlasFeatures = mWMSMaxAtlasFeaturesSpinBox->value();
QgsProject::instance()->writeEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), maxAtlasFeatures );

QgsProject::instance()->writeEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), mWMTSUrlLineEdit->text() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSMinScale" ), QStringLiteral( "/" ), mWMTSMinScaleLineEdit->value() );
bool wmtsProject = false;
@@ -111,6 +111,11 @@ int QgsServerProjectUtils::wmsImageQuality( const QgsProject &project )
return project.readNumEntry( QStringLiteral( "WMSImageQuality" ), QStringLiteral( "/" ), -1 );
}

int QgsServerProjectUtils::wmsMaxAtlasFeatures( const QgsProject &project )
{
return project.readNumEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), 1 );
}

bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
{
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );
@@ -147,6 +147,13 @@ namespace QgsServerProjectUtils
*/
SERVER_EXPORT int wmsImageQuality( const QgsProject &project );

/**
* Returns the maximum number of atlas features which can be printed in a request
* \param project the QGIS project
* \return the number of atlas features
*/
SERVER_EXPORT int wmsMaxAtlasFeatures( const QgsProject &project );

/**
* Returns if layer ids are used as name in WMS.
* \param project the QGIS project
@@ -23,6 +23,7 @@
#include "qgsserverprojectutils.h"

#include "qgslayoutmanager.h"
#include "qgslayoutatlas.h"
#include "qgsprintlayout.h"
#include "qgslayoutitemmap.h"
#include "qgslayoutitemlabel.h"
@@ -680,6 +681,27 @@ namespace QgsWms
composerTemplateElem.setAttribute( QStringLiteral( "width" ), width.length() );
composerTemplateElem.setAttribute( QStringLiteral( "height" ), height.length() );

//atlas enabled and atlas covering layer
QgsLayoutAtlas *atlas = layout->atlas();
if ( atlas && atlas->enabled() )
{
composerTemplateElem.setAttribute( QStringLiteral( "atlasEnabled" ), QStringLiteral( "1" ) );
QgsVectorLayer *cLayer = atlas->coverageLayer();
if ( cLayer )
{
QString layerName = cLayer->shortName();
if ( QgsServerProjectUtils::wmsUseLayerIds( *project ) )
{
layerName = cLayer->id();
}
else if ( layerName.isEmpty() )
{
layerName = cLayer->name();
}
composerTemplateElem.setAttribute( QStringLiteral( "atlasCoverageLayer" ), layerName );
}
}

//add available composer maps and their size in mm
QList<QgsLayoutItemMap *> layoutMapList;
layout->layoutItems<QgsLayoutItemMap>( layoutMapList );
@@ -1739,6 +1761,22 @@ namespace QgsWms
//displayfield
layerElem.setAttribute( QStringLiteral( "displayField" ), displayField );

//primary key
QgsAttributeList pkAttributes = vLayer->primaryKeyAttributes();
if ( pkAttributes.size() > 0 )
{
QDomElement pkElem = doc.createElement( QStringLiteral( "PrimaryKey" ) );
QgsAttributeList::const_iterator pkIt = pkAttributes.constBegin();
for ( ; pkIt != pkAttributes.constEnd(); ++pkIt )
{
QDomElement pkAttributeElem = doc.createElement( QStringLiteral( "PrimaryKeyAttribute" ) );
QDomText pkAttName = doc.createTextNode( layerFields.at( *pkIt ).name() );
pkAttributeElem.appendChild( pkAttName );
pkElem.appendChild( pkAttributeElem );
}
layerElem.appendChild( pkElem );
}

//geometry type
layerElem.setAttribute( QStringLiteral( "geometryType" ), QgsWkbTypes::displayString( vLayer->wkbType() ) );

@@ -498,6 +498,10 @@ namespace QgsWms

const QgsWmsParameter pWmtver( QgsWmsParameter::WMTVER );
save( pWmtver );

const QgsWmsParameter pAtlasPk( QgsWmsParameter::ATLAS_PK,
QVariant::StringList );
save( pAtlasPk );
}

QgsWmsParameters::QgsWmsParameters( const QgsServerParameters &parameters )
@@ -1134,6 +1138,11 @@ namespace QgsWms
return label;
}

QStringList QgsWmsParameters::atlasPk() const
{
return mWmsParameters[ QgsWmsParameter::ATLAS_PK ].toStringList();
}

QStringList QgsWmsParameters::highlightLabelString() const
{
return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSTRING ].toStringList( ';' );
@@ -168,7 +168,8 @@ namespace QgsWms
GRID_INTERVAL_Y,
WITH_GEOMETRY,
WITH_MAPTIP,
WMTVER
WMTVER,
ATLAS_PK
};
Q_ENUM( Name )

@@ -1148,6 +1149,13 @@ namespace QgsWms
*/
QString layoutParameter( const QString &id, bool &ok ) const;

/**
* Returns the ATLAS_PK parameter
* \returns The ATLAS_PK parameter
* \since QGIS 3.6
*/
QStringList atlasPk() const;

private:
bool loadParameter( const QString &name, const QString &value ) override;

0 comments on commit 54a5fae

Please sign in to comment.
You can’t perform that action at this time.