Skip to content
Permalink
Browse files

[layouts] Warn when previewing an atlas and a feature with no geometry

is encountered, when one or more maps are set to be driven by atlas feature

This situation is definetly not what the user is expecting -- so we
show a warning to them to advise them that the feature has no geometry.

Fixes #36556
  • Loading branch information
nyalldawson committed May 21, 2020
1 parent cf0467a commit 6ce84d2c347f49c9aae0c1953e2b2529228db430
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/app/layout/qgslayoutdesignerdialog.cpp
@@ -4458,7 +4458,24 @@ void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature )
mapCanvas->stopRendering();
mapCanvas->redrawAllLayers();

mView->setSectionLabel( atlas->nameForPage( atlas->currentFeatureNumber() ) );
const QString atlasFeatureName = atlas->nameForPage( atlas->currentFeatureNumber() );
mView->setSectionLabel( atlasFeatureName );

if ( !feature.hasGeometry() || feature.geometry().isEmpty() )
{
// a little sanity check -- if there's any maps in this layout which are set to be atlas controlled,
// and we hit a feature with no geometry attached, then warn the user
QList< QgsLayoutItemMap * > maps;
mLayout->layoutItems( maps );
for ( const QgsLayoutItemMap *map : qgis::as_const( maps ) )
{
if ( map->atlasDriven() )
{
mMessageBar->pushWarning( QString(), tr( "Atlas feature %1 has no geometry — linked map extents cannot be updated" ).arg( atlasFeatureName ) );
break;
}
}
}
}

void QgsLayoutDesignerDialog::loadPredefinedScalesFromProject()

0 comments on commit 6ce84d2

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