Aller au contenu | Aller au menu | Aller à la recherche

Evaluate QGIS Expression server side with Lizmap plugin

Since the beginning of Lizmap-Web-Client all the server part was based on PHP code. With Lizmap Web Client 3.4, which will be released very soon, part of the functionality has been developed within the Lizmap plugin to add features to QGIS Server.

QGIS Server is an open source implementation of the WMS 1.3.0, 1.1.1 and 1.0.0, WFS 1.1.0 and 1.0.0 and WCS 1.0.0 standards defined by the Open Geospatial Consortium (OGC). QGIS Server uses QGIS as a backend for GIS layer logic and map rendering. As QGIS desktop and QGIS Server use the same visualization libraries, the maps that are published on the web look the same as in desktop GIS.

To learn more about QGIS Server

Just like QGIS Desktop, QGIS Server is extensible using Python plugins. It is for example possible to create and add new services to QGIS Server. Documentation

The second QGIS Server feature we have implemented in the Lizmap plugin is a QGIS expression evaluation service.

  • SERVICE=EXPRESSION
    • REQUEST=Evaluate
      • EXPRESSION: a QGIS expression
      • EXPRESSIONS: List of QGIS expressions
      • FEATURE: Option a GeoJSON Feature
      • FEATURES: Option a list of GeoJSON Features
      • FORM_SCOPE: Option boolean to add formScope based on provided features
    • REQUEST=replaceExpressionText
      • STRING: A string with expression between [% and %]
      • STRINGS: A list of strings with expression between [% and %]
      • FEATURE: Option a GeoJSON Feature
      • FEATURES: Option a list of GeoJSON Features
      • FORM_SCOPE: Option boolean to add formScope based on provided features
    • REQUEST=GetFeatureWithFormScope
      • LAYER: a WMS Layer Name to be filtered
      • FILTER: a QGIS expression to filter the layer
      • FORM_FEATURE: a GeoJSON Feature
      • FIELDS: Option a list of fields to return
      • WITH_GEOMETRY: Option boolean to return geometry
    • REQUEST=VirtualFields
      • LAYER: a WMS Layer Name to get virtual fields
      • VIRTUALS: a list of key QGIS expression
      • FILTER: Option a QGIS expression to filter layer
      • FIELDS: Option a list of fields to return
      • WITH_GEOMETRY: Option boolean to return geometry

These new queries are used in Lizmap Web Client 3.4 to exploit expressions from QGIS forms. These expressions can be used for :

  • Set default values
  • Set constraints
  • Do drill down
  • Manage field group visibility

Example of using QGIS expression as a form constraint: lizmap-3_4-exp-constraint.png, nov. 2020

Example of use of QGIS expression to manage the visibility of groups of fields Use QGIS Expression to control group visibility

In the case of drill down in forms, it is possible to use geometry to filter the list, for example to select a municipality, a parcel or the nearest street. It is of course possible to use all other values during form entry.

Finally we also added a lizmap service with a GetServerSettings query to retrieve information about QGIS Server and available services.