Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom to WMS Extent #732

Merged
merged 3 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions app/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,29 @@ 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.set( WMSExtent[0].toDouble(), WMSExtent[1].toDouble(), WMSExtent[2].toDouble(), 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
5 changes: 5 additions & 0 deletions docs/users/project_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down