-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add layout validity check for map crs
- Loading branch information
1 parent
102f075
commit ec55304
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
|
||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters