Publish QGIS Project

Description

This section explains how to publish a QGIS project with Giswater in QWC2.

Configuration in QGIS

Once we have the QGIS project we want to publish ready, we must configure the project to be valid for QGIS Server. Next, a basic configuration is explained, although all possible configurations are listed later.

For this basic configuration, all information is located in the Properties and QGIS Server tabs in our QGIS project.

In the Service Capabilities tab, check the Enable Service Capabilities option.

../../../../_images/qgis_2.png

In the WMS tab, we should add an Advertised Extent, which will be the initial visible extent of the theme in the viewer. We can calculate it from a layer or use the current extent. Then, add the project’s spatial reference system in CRS Restrictions.

../../../../_images/qgis_3.png

It is recommended to check the Add geometry to the object response option.

../../../../_images/qgis_4.png

This table indicates the configurations in the QGIS project that will influence how the Theme will be displayed in the viewer.

What

Where

Description

Map projection

Project properties → CRS

Map projection used in QWC.

Service metadata

Project properties → QGIS Server → Service Capabilities

They are shown in the theme information dialog, accessible from the title bar of the Layers Tree panel.

Title, keywords

Project properties → QGIS Server → Service Capabilities

Theme title shown in the Themes Selector, and useful keywords for filtering.

Map extent

Project properties → QGIS Server → WMS → Advertised Extent

Extent used as the initial map extent when loading the theme, unless it is overridden in themesConfig.json.

Queryable layers

Project properties → Data sources

Marks the layers as identifiable by the client.

Geometry in FeatureInfo

Project properties → QGIS Server → WMS Capabilities → Add geometry to the object response.

Returns geometries in the GetFeatureInfo request. Allows the client to highlight the selected entities.

Layer display field

Vector layer properties → Rendering

Field used in the identification results.

Popup information (Map Tip)

Vector layer properties → Rendering

Content of the Map Tip shown when hovering over the layers, if Map Tips display is enabled in the Layers Tree.

Layer metadata

Layer properties → QGIS Server

Shown in the Layer Information dialog in the client.

Scale range

Layer properties → Rendering → Scale-dependent visibility

Scale range within which the layer is visible; useful for improving performance.

Initial visibility

Layers panel

Initial visibility of layers and groups.

Rendering order

Layers Order Panel or Layers panel

Rendering order of the layers. If reordering is enabled in config.json, the order from the Layers Order Panel is ignored.

Print layouts

Layout administrator

Print layouts offered in the Print plugin.

Print layout labels

Layout administrator

Design labels with an ID will be shown in the Print plugin. Note: a label whose ID starts with __ will not be exposed.

External layers

Layer properties → QGIS Server → Data URL

Marks the layer as external to avoid cascading requests.

Upload project to QWC2

Once we have the configured QGIS project, we must upload it to QWC2. To do so, go to the Themes section in the administration backoffice and upload the .qgs file from the Upload files section.

../../../../_images/publicar_1.png

Create Theme in QWC2

Once the QGIS project has been published, to publish it you need to create a Theme that uses it in QWC2. You can do this from the Themes section and Theme settings.

../../../../_images/publicar_2.png

The first step will be to indicate in Project the corresponding QGIS project name among all the available ones. Then, you need to add the following information:

  • Title: The title that will be shown in the viewer for this theme.

  • Thumbnail: The image (Mapthumb) that will be shown in the viewer for this theme.

  • CRS: The project’s projection. It must match the projection of the QGIS project

  • Search providers: Active providers for the search.

  • Default: Check this box so that the Theme is the default when loading the viewer for all users.

../../../../_images/publicar_3.png

There are other interesting fields to configure within the Theme, such as the visualization or print scales, description, etc.

At the end of the form, the background layers that will be shown on the map are added, and you can select one to be active when opening the Theme.

../../../../_images/publicar_4.png

Finally, click the Save button to create the theme.

Giswater Configuration

So that Giswater features work correctly in the viewer, we must configure the Theme in the Giswater configuration from the Giswater config section.

../../../../_images/giswaterconfig_1.png

This configuration is in JSON format; in this configuration the following are indicated:

  • db_url_read: The Giswater database connection for reading data, defined in pg_service.conf.

  • db_url_write: The Giswater database connection for writing data, defined in pg_service.conf.

  • themes: The theme configuration.

Within the configuration of each theme, the following are indicated:

  • The theme name (as indicated in the theme creation form) as the primary key.

  • schema: The Giswater database schema where the data is located.

  • tiled: Whether the theme is tiled or not.

  • layers: The layer relationship of the QGIS project (name) with the tables or views in the Giswater database.

../../../../_images/giswaterconfig_2.png

Generate service configuration

As the last step, we must generate the services configuration so that QWC2 can use it. To do this, press the Generate service configuration button in the Home section.

../../../../_images/inicio_1.png