Skip to content

Commit

Permalink
add check for wms extent in project file
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasMizera committed May 26, 2020
1 parent 42a12e4 commit c8cb8dc
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions app/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,32 @@ void Loader::zoomToProject( QgsQuickMapSettings *mapSettings )
{
if ( !mapSettings )
{
qDebug() << "Cannot zoom to layers extent, mapSettings is not defined";
qDebug() << "Cannot zoom to extent, mapSettings is not defined";
return;
}

const QVector<QgsMapLayer *> layers = mProject->layers<QgsMapLayer *>();
QgsRectangle extent;
for ( const QgsMapLayer *layer : layers )

// Check if WMSExtent is set in project
bool hasWMS;
QStringList WMSExtent = mProject->readListEntry( "WMSExtent", QStringLiteral( "/" ), QStringList(), &hasWMS );

if ( hasWMS && ( WMSExtent.length() == 4 ) )
{
extent.setXMinimum(WMSExtent[0].toDouble());
extent.setYMinimum(WMSExtent[1].toDouble());
extent.setXMaximum(WMSExtent[2].toDouble());
extent.setYMaximum(WMSExtent[3].toDouble());
}
else // set layers extent
{
QgsRectangle layerExtent = mapSettings->mapSettings().layerExtentToOutputExtent( layer, layer->extent() );
extent.combineExtentWith( layerExtent );
const QVector<QgsMapLayer *> layers = mProject->layers<QgsMapLayer *>();
for ( const QgsMapLayer *layer : layers )
{
QgsRectangle layerExtent = mapSettings->mapSettings().layerExtentToOutputExtent( layer, layer->extent() );
extent.combineExtentWith( layerExtent );
}
}

if ( extent.isEmpty() )
{
extent.grow( mProject->crs().isGeographic() ? 0.01 : 1000.0 );
Expand Down

4 comments on commit c8cb8dc

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win-apk: x86_64 (SDK: win-7)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios-1.4.200526135917 (SDK: ios-4)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: armeabi-v7a (SDK: android-13)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: arm64-v8a (SDK: android-13)

Please sign in to comment.