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

(cherry picked from commit 6ce84d2)
  • Loading branch information
nyalldawson committed Jun 19, 2020
1 parent f52652b commit c12c1eb9b6714e0b60b650241aa7c65e52e3eff3
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/app/layout/qgslayoutdesignerdialog.cpp
@@ -4374,7 +4374,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 c12c1eb

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