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.
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.
It is recommended to check the Add geometry to the object response option.
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 |
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 |
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 |
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.
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.
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.
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.
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.
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.
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.