Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
83 additions
and 0 deletions.
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
qgslayoutvaliditychecks.cpp | ||
--------------------------- | ||
begin : November 2018 | ||
copyright : (C) 2018 Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutvaliditychecks.h" | ||
#include "qgsvaliditycheckcontext.h" | ||
#include "qgslayoutitemmap.h" | ||
#include "qgslayout.h" | ||
|
||
QList<QgsValidityCheckResult> QgsLayoutMapCrsValidityCheck::runCheck( const QgsValidityCheckContext *context, QgsFeedback * ) const | ||
{ | ||
QList<QgsValidityCheckResult> results; | ||
const QgsLayoutValidityCheckContext *layoutContext = dynamic_cast< const QgsLayoutValidityCheckContext * >( context ); | ||
if ( !layoutContext ) | ||
return results; | ||
|
||
QList< QgsLayoutItemMap * > mapItems; | ||
layoutContext->layout->layoutItems( mapItems ); | ||
for ( QgsLayoutItemMap *map : qgis::as_const( mapItems ) ) | ||
{ | ||
if ( map->crs().authid() == QStringLiteral( "EPSG:3857" ) ) | ||
{ | ||
QgsValidityCheckResult res; | ||
res.type = QgsValidityCheckResult::Warning; | ||
res.title = tr( "Map projection is misleading" ); | ||
res.detailedDescription = tr( "The projection for the map item %1 is set to <i>Web Mercator (EPSG:3857)</i> which misrepresents areas and shapes. Consider using an appropriate local projection instead." ).arg( map->displayName() ); | ||
results.append( res ); | ||
} | ||
} | ||
|
||
return results; | ||
} |
@@ -0,0 +1,33 @@ | ||
/*************************************************************************** | ||
qgslayoutvaliditychecks.h | ||
--------------------------- | ||
begin : November 2018 | ||
copyright : (C) 2018 Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsabstractvaliditycheck.h" | ||
|
||
class QgsLayoutMapCrsValidityCheck : public QgsAbstractValidityCheck | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
QString id() const override { return "map_crs_check"; } | ||
int checkType() const override { return QgsAbstractValidityCheck::TypeLayoutCheck; } | ||
QString name() const override { return "Map CRS Check"; } | ||
QList< QgsValidityCheckResult > runCheck( const QgsValidityCheckContext *context, QgsFeedback *feedback ) const override; | ||
|
||
|
||
|
||
|
||
}; |