From c8cb8dc7f5899088d42f2b967db654436affbfbc Mon Sep 17 00:00:00 2001 From: tomasMizera Date: Tue, 26 May 2020 14:57:14 +0200 Subject: [PATCH 1/3] add check for wms extent in project file --- app/loader.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/loader.cpp b/app/loader.cpp index b2ac5fa8f..d1c783382 100644 --- a/app/loader.cpp +++ b/app/loader.cpp @@ -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 layers = mProject->layers(); 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 layers = mProject->layers(); + 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 ); From b53b855bc4409f9d918b2ec10e6dda6fd20b24db Mon Sep 17 00:00:00 2001 From: tomasMizera Date: Tue, 26 May 2020 16:09:26 +0200 Subject: [PATCH 2/3] set extent in one line --- app/loader.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/loader.cpp b/app/loader.cpp index d1c783382..968f0830a 100644 --- a/app/loader.cpp +++ b/app/loader.cpp @@ -122,10 +122,7 @@ void Loader::zoomToProject( QgsQuickMapSettings *mapSettings ) 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()); + extent.set( WMSExtent[0].toDouble(), WMSExtent[1].toDouble(), WMSExtent[2].toDouble(), WMSExtent[3].toDouble() ); } else // set layers extent { From 7d1cb66ad797616c201a9793b0d91fc3ef9182b6 Mon Sep 17 00:00:00 2001 From: Saber Razmjooei Date: Tue, 26 May 2020 16:32:45 +0100 Subject: [PATCH 3/3] updated the relevant part of the doc --- docs/users/project_config.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/users/project_config.md b/docs/users/project_config.md index 0c0e4b154..2f94af70c 100644 --- a/docs/users/project_config.md +++ b/docs/users/project_config.md @@ -24,6 +24,11 @@ If you are using a vector layer for background layer: - All vector layers not intended to be used as survey layers, have to be set as read-only. To make a vector layer read-only in QGIS, from the main menu select Project \> Properties. Within the window, select Data Source tab and select the Read-only option for the layers you do not want to be used as survey layer in Input. +## Project extent +In Input app, there is an option to zoom to the project extent. If not set, Input zooms to all visible layers. This is not particularly convenient when you have a layer with a large/global extent (e.g. Open Street Map). + +To set the project extent: from **Project** > **Properties**, select **QGIS Server** (not the most obvious location!). Under **WMS capabilities** select the option for **Advertised extent** and either enter the coordinate extent of your project bounding box or use the canvas extent. + ## Survey layer Vector layers can be used as survey layer