### General Algorithm Description Example Source: https://docs.qgis.org/3.44/en/docs/documentation_guidelines/writing.html Start algorithm descriptions with general expressions rather than specific actions. This example describes a point layer input generating a polygon layer output. ```rst Takes a point layer and generates a polygon layer containing the... ``` -------------------------------- ### Install QGIS Server Package Source: https://docs.qgis.org/3.44/en/docs/training_manual/qgis_server/install.html Installs the QGIS Server package. Use the second command to also install server plugins. ```bash apt install qgis-server --no-install-recommends --no-install-suggests ``` ```bash # if you want to install server plugins, also: apt install python3-qgis ``` -------------------------------- ### Install QtCreator on Debian Source: https://docs.qgis.org/3.44/en/docs/developers_guide/qtcreator.html Use this command to install QtCreator and its documentation on Debian-based systems. ```bash sudo apt install qtcreator qtcreator-doc ``` -------------------------------- ### QgsTask Execution Output Example Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/tasks.html Illustrates the typical output logs generated during the execution of QgsTask instances, showing task start, completion, and final results. ```text 1RandomIntegerSumTask(0): Started task "waste cpu subtask shortest" 2RandomIntegerSumTask(0): Started task "waste cpu short" 3RandomIntegerSumTask(0): Started task "waste cpu mini" 4RandomIntegerSumTask(0): Started task "waste cpu subtask long" 5RandomIntegerSumTask(3): Task "waste cpu subtask shortest" completed 6RandomTotal: 25452 (with 100 iterations) 7RandomIntegerSumTask(3): Task "waste cpu mini" completed 8RandomTotal: 23810 (with 100 iterations) 9RandomIntegerSumTask(3): Task "waste cpu subtask long" completed 10RandomTotal: 26308 (with 100 iterations) 11RandomIntegerSumTask(0): Started task "waste cpu long" 12RandomIntegerSumTask(3): Task "waste cpu long" completed 13RandomTotal: 22534 (with 100 iterations) ``` -------------------------------- ### Install NGINX Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Installs the NGINX web server, an alternative to Apache for serving QGIS Server. ```bash apt install nginx ``` -------------------------------- ### Install pyogctest Source: https://docs.qgis.org/3.44/en/docs/developers_guide/ogcconformancetesting.html Install pyogctest in a virtual environment. Ensure you activate the environment before installation. ```bash virtualenv venv source venv/bin/activate pip install pyogctest ``` -------------------------------- ### Install Apache Service on Windows Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Run the apache-install.bat script as administrator to install the Apache OSGeo4W Web Server service. ```bash > apache-install.bat Installing the 'Apache OSGeo4W Web Server' service The 'Apache OSGeo4W Web Server' service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the service can be started. ... ``` -------------------------------- ### Test QGIS Server Installation Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Run this command to verify if QGIS Server is installed correctly. A successful output indicates the server is functioning. ```bash /usr/lib/cgi-bin/qgis_mapserv.fcgi ``` -------------------------------- ### Install spawn-fcgi Package Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Command to install the spawn-fcgi package, recommended for production use due to better performance. ```bash apt install spawn-fcgi ``` -------------------------------- ### Enable, Start, and Check Xvfb Service Status Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Enables the Xvfb service to start on boot, starts it immediately, and checks its current status using systemd. ```bash systemctl enable --now xvfb.service systemctl status xvfb.service ``` -------------------------------- ### Install fcgiwrap Package Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Command to install the fcgiwrap package. Easier to set up than spawn-fcgi but slower due to process creation per request. ```bash apt install fcgiwrap ``` -------------------------------- ### Install Qt Tools for Translation Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/plugins/plugins.html Install the necessary Qt development tools for managing translation files on Debian-based systems. ```bash sudo apt install qttools5-dev-tools ``` -------------------------------- ### Enable and Start QGIS Server systemd Service Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Commands to enable the QGIS Server systemd service to start on boot and start it immediately. ```bash systemctl enable --now qgis-server ``` -------------------------------- ### QGIS Development Server Output Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/development_server.html This is an example of the log output you might see when the QGIS Development Server is running and handling requests. ```log QGIS Development Server listening on http://localhost:8000 CTRL+C to exit 127.0.0.1 [lun gen 20 15:16:41 2020] 5140 103ms "GET /wfs3/?MAP=/tests/testdata/qgis_server/test_project.qgs HTTP/1.1" 200 127.0.0.1 [lun gen 20 15:16:41 2020] 3298 2ms "GET /wfs3/static/jsonFormatter.min.js HTTP/1.1" 200 127.0.0.1 [lun gen 20 15:16:41 2020] 1678 3ms "GET /wfs3/static/jsonFormatter.min.css HTTP/1.1" 200 127.0.0.1 [lun gen 20 15:16:41 2020] 1310 5ms "GET /wfs3/static/style.css HTTP/1.1" 200 127.0.0.1 [lun gen 20 15:16:43 2020] 4285 13ms "GET /wfs3/collections?MAP=/tests/testdata/qgis_server/test_project.qgs HTTP/1.1" 200 ``` -------------------------------- ### GetCapabilities Request URL Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/basics.html Example of a URL to execute a GetCapabilities request. The REQUEST parameter specifies the request name. ```url http://localhost/qgisserver? REQUEST=GetCapabilities &... ``` -------------------------------- ### Install Xvfb Package Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Installs the X Virtual Frame Buffer package using apt. This is required for running QGIS Server in a headless environment. ```bash apt install xvfb ``` -------------------------------- ### Set Default Project and Serve Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Configure the QGIS_PROJECT_FILE environment variable to specify a default project and then start QGIS Server using spawn-fcgi. ```bash export QGIS_PROJECT_FILE=/home/qgis/projects/world.qgs spawn-fcgi -f /usr/lib/bin/cgi-bin/qgis_mapserv.fcgi \ -s /var/run/qgisserver.socket \ -U www-data -G www-data -n ``` -------------------------------- ### DescribeLayer Request Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wms.html Example URL for a DescribeLayer request to get information about layers in QGIS Server. ```http http://localhost/qgisserver? SERVICE=WMS &REQUEST=DescribeLayer &SLD_VERSION=1.1.0 &LAYERS=mylayer1 ``` -------------------------------- ### Setting Up Task Dependencies Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/tasks.html This example demonstrates how to set up dependencies between tasks. Tasks can be configured to run after other tasks, before their parent task, or with no specific order. Use addSubTask() to define these relationships. ```python longtask = RandomIntegerSumTask('waste cpu long', 20) shorttask = RandomIntegerSumTask('waste cpu short', 10) minitask = RandomIntegerSumTask('waste cpu mini', 5) shortsubtask = RandomIntegerSumTask('waste cpu subtask short', 5) longsubtask = RandomIntegerSumTask('waste cpu subtask long', 10) shortestsubtask = RandomIntegerSumTask('waste cpu subtask shortest', 4) # Add a subtask (shortsubtask) to shorttask that must run after # minitask and longtask has finished shorttask.addSubTask(shortsubtask, [minitask, longtask]) # Add a subtask (longsubtask) to longtask that must be run # before the parent task longtask.addSubTask(longsubtask, [], QgsTask.ParentDependsOnSubTask) # Add a subtask (shortestsubtask) to longtask longtask.addSubTask(shortestsubtask) QgsApplication.taskManager().addTask(longtask) ``` -------------------------------- ### Install HelloWorld Plugin Manually Source: https://docs.qgis.org/3.44/en/docs/server_manual/plugins.html Steps to manually install the HelloWorld plugin for QGIS Server testing. This involves creating a directory, downloading the plugin ZIP, and unzipping it. ```bash mkdir -p /var/www/qgis-server/plugins cd /var/www/qgis-server/plugins wget https://github.com/elpaso/qgis-helloserver/archive/master.zip unzip master.zip mv qgis-helloserver-master HelloServer ``` -------------------------------- ### DescribeFeatureType WFS Request Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wfs.html Example URL for a DescribeFeatureType request to get schema information for a specific layer. Ensure the MAP parameter points to a valid QGIS project file. ```http http://localhost/qgisserver? SERVICE=WFS &VERSION=1.1.0 &REQUEST=DescribeFeatureType &TYPENAME=countries ``` -------------------------------- ### Filter Airports by Name Pattern Source: https://docs.qgis.org/3.44/en/docs/user_manual/print_layout/layout_items/layout_tables.html Example of filtering features using a LIKE operator to exclude names starting with 'AN'. ```sql NAME NOT LIKE 'AN%' ``` -------------------------------- ### Load Data Files on Startup Source: https://docs.qgis.org/3.44/en/docs/user_manual/introduction/qgis_configuration.html Starts QGIS with specified vector and raster files loaded. Ensure you are in the correct directory or provide the full path to the files. ```bash qgis ./raster/landcover.img ./gml/lakes.gml ``` -------------------------------- ### Get Start Point of Geometry Source: https://docs.qgis.org/3.44/en/docs/user_manual/expressions/functions_list.html Returns the first node of a geometry. Useful for identifying the origin of a linestring or other linear geometries. ```sql geom_to_wkt(start_point(geom_from_wkt('LINESTRING(4 0, 4 2, 0 2)'))) ``` -------------------------------- ### Get First Vertex of Polygon Boundary Source: https://docs.qgis.org/3.44/en/docs/training_manual/spatial_databases/geometry.html Extract the starting point (vertex) of the linestring that forms the boundary of a polygon geometry from 'myPolygonTable'. ```sql select st_startpoint(myGeometry) from ( select st_boundary(geom) as myGeometry from myPolygonTable) as foo; ``` -------------------------------- ### Get Nth Element of Array Source: https://docs.qgis.org/3.44/en/docs/user_manual/expressions/functions_list.html Retrieves an element from an array by its position (index). Supports positive indices from the start and negative indices from the end. ```qgis_expression array_get(array('a','b','c'),1) ``` ```qgis_expression array_get(array('a','b','c'),-1) ``` -------------------------------- ### Start QGIS with a Specific Project Source: https://docs.qgis.org/3.44/en/docs/user_manual/introduction/qgis_configuration.html Use the `--project` option to open QGIS with a predefined project file. All layers within the specified project will be loaded. ```bash qgis --project /path/to/your/project.qgz ``` -------------------------------- ### Lesson Introduction Markup Source: https://docs.qgis.org/3.44/en/docs/training_manual/appendix/contribute.html Begin a lesson by writing the markup phrase 'Lesson', followed by the lesson name, and then a line of equal signs for the title underline. A short description and introduction follow. ```rst **The goal for this lesson:** ``` -------------------------------- ### Get QGIS Prefix Path Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/intro.html This code snippet demonstrates how to retrieve the QGIS installation prefix path. This is useful for configuring standalone scripts. ```python QgsApplication.prefixPath() ``` -------------------------------- ### Example metadata.txt for a QGIS Plugin Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/plugins/plugins.html A comprehensive example of a metadata.txt file, including mandatory and optional fields like name, version, author, description, and advanced options such as plugin dependencies and experimental flags. ```ini ; the next section is mandatory [general] name=HelloWorld email=me@example.com author=Just Me qgisMinimumVersion=3.0 description=This is an example plugin for greeting the world. Multiline is allowed: lines starting with spaces belong to the same field, in this case to the "description" field. HTML formatting is not allowed. about=This paragraph can contain a detailed description of the plugin. Multiline is allowed, HTML is not. version=version 1.2 tracker=http://bugs.itopen.it repository=http://www.itopen.it/repo ; end of mandatory metadata ; start of optional metadata category=Raster changelog=The changelog lists the plugin versions and their changes as in the example below: 1.0 - First stable release 0.9 - All features implemented 0.8 - First testing release ; Tags are in comma separated value format, spaces are allowed within the ; tag name. ; Tags should be in English language. Please also check for existing tags and ; synonyms before creating a new one. tags=wkt,raster,hello world ; these metadata can be empty, they will eventually become mandatory. homepage=https://www.itopen.it icon=icon.png ; experimental flag (applies to the single version) experimental=True ; deprecated flag (applies to the whole plugin and not only to the uploaded version) deprecated=False ; if empty, it will be automatically set to major version + .99 qgisMaximumVersion=3.99 ; Since QGIS 3.8, a comma separated list of plugins to be installed ; (or upgraded) can be specified. ; The example below will try to install (or upgrade) "MyOtherPlugin" version 1.12 ; and any version of "YetAnotherPlugin". ; Both "MyOtherPlugin" and "YetAnotherPlugin" names come from their own metadata's ; name field plugin_dependencies=MyOtherPlugin==1.12,YetAnotherPlugin ``` -------------------------------- ### Task Execution Log Output Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/tasks.html Example log output showing the sequence of events during task execution, including task start, progress, and completion messages. ```log 1RandomIntegerSumTask(0): Started task "waste cpu subtask short" 2RandomTaskFromFunction(0): Started task Waste cpu 1 3RandomTaskFromFunction(0): Started task Waste cpu 2 4RandomTaskFromFunction(0): Task Waste cpu 2 completed 5RandomTotal: 23263 ( with 100 iterations) 6RandomTaskFromFunction(0): Task Waste cpu 1 completed 7RandomTotal: 25044 ( with 100 iterations) ``` -------------------------------- ### Test QGIS Server Binary with Query String Source: https://docs.qgis.org/3.44/en/docs/server_manual/config.html This example demonstrates how to test the QGIS server binary from the command line using the QUERY_STRING variable, useful for simulating requests like GetCapabilities. ```bash PGSERVICEFILE=/etc/pg_service.conf \ QUERY_STRING="MAP=/home/projects/world.qgs&SERVICE=WMS&REQUEST=GetCapabilities" \ /usr/lib/cgi-bin/qgis_mapserv.fcgi ``` -------------------------------- ### Plugin Zip Structure Example Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/plugins/releasing.html Illustrates the expected directory and file layout for a QGIS plugin's zip archive to ensure proper validation and installation. ```plaintext plugin.zip pluginfolder/ |-- i18n | |-- translation_file_de.ts |-- img | |-- icon.png | |-- iconsource.svg |-- __init__.py |-- LICENSE |-- Makefile |-- metadata.txt |-- more_code.py |-- main_code.py |-- README |-- ui_Qt_user_interface_file.ui ``` -------------------------------- ### Get Vector Layer Renderer Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/vector.html Retrieve the renderer object associated with a vector layer to inspect or modify its symbology. This is the starting point for controlling how features are drawn. ```python renderer = layer.renderer() ``` -------------------------------- ### Example of running QGIS Server container Source: https://docs.qgis.org/3.44/en/docs/server_manual/containerized_deployment.html Output showing a QGIS Server container running, including its ID, image, command, status, and port mappings. ```text CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4de8192da76e qgis-server "/tini -- /home/qgis…" 3 seconds ago Up 2 seconds 0.0.0.0:5555->5555/tcp qgis-server ``` -------------------------------- ### Get Y Coordinate of Specific Vertex in Geometry Source: https://docs.qgis.org/3.44/en/docs/user_manual/expressions/functions_list.html Retrieves the y coordinate of a specific vertex within a geometry. Vertex indices start at 0, and negative indices count from the end. ```sql y_at( geom_from_wkt( 'POINT(4 5)' ), 0 ) ``` -------------------------------- ### Run QGIS from Build Directory Source: https://docs.qgis.org/3.44/en/docs/developers_guide/qtcreator.html Navigate to the build directory and execute the QGIS binary to run the compiled application. ```bash cd $HOME/dev/cpp/QGIS/build-master-qtcreator ./output/bin/qgis ``` -------------------------------- ### Prevent Plugins from Loading at Startup Source: https://docs.qgis.org/3.44/en/docs/user_manual/introduction/qgis_configuration.html Use `--noplugins` to avoid loading all installed plugins when QGIS starts. Plugins can still be accessed and managed via the Plugins Manager. ```bash qgis --noplugins ``` -------------------------------- ### Get Measure Coordinate at Vertex Source: https://docs.qgis.org/3.44/en/docs/user_manual/expressions/functions_list.html Retrieves the m coordinate of a specific vertex in a geometry. Indices start at 0, and negative values count from the end. Returns NULL if the geometry has no m value. ```sql m_at(geom_from_wkt('LineStringZM(0 0 0 0, 10 10 0 5, 10 10 0 0)'), 1) ``` -------------------------------- ### Load a QGIS Project Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/loadproject.html Instantiate QgsProject and load a project file. Ensure necessary imports if not in the QGIS console. ```python from qgis.core import QgsProject # Get the project instance project = QgsProject.instance() # Print the current project file name (might be empty in case no projects have been loaded) # print(project.fileName()) # Load another project project.read('testdata/01_project.qgs') print(project.fileName()) ``` -------------------------------- ### Enable Apache Modules and Site Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Enables the `fcgid` and `rewrite` Apache modules and activates the QGIS Server virtual host configuration. ```bash a2enmod fcgid a2enmod rewrite a2ensite qgis.demo ``` -------------------------------- ### Execute SQL Query with REGEXP - DB Manager Source: https://docs.qgis.org/3.44/en/docs/user_manual/plugins/core_plugins/plugins_db_manager.html Use the REGEXP function in SQL queries within the DB Manager for pattern matching. This example filters features where the 'name' field starts with 'A'. ```sql SELECT * FROM places WHERE name REGEXP '^A'; ``` -------------------------------- ### Get Z Coordinate of Specific Vertex in Geometry Source: https://docs.qgis.org/3.44/en/docs/user_manual/expressions/functions_list.html Retrieves the z coordinate of a specific vertex within a geometry. Returns NULL if the geometry has no z value. Vertex indices start at 0, and negative indices count from the end. ```sql z_at(geom_from_wkt('LineStringZ(0 0 0, 10 10 5, 10 10 0)'), 1) ``` -------------------------------- ### QGIS Development Server Help Output Source: https://docs.qgis.org/3.44/en/docs/server_manual/development_server.html Invoking the server with the -h flag displays available command-line options for configuration. ```bash Usage: qgis_mapserver [options] [address:port] QGIS Development Server Options: -h, --help Displays this help. -v, --version Displays version information. -l Sets log level (default: 0) 0: INFO 1: WARNING 2: CRITICAL -p Path to a QGIS project file (*.qgs or *.qgz), if specified it will override the query string MAP argument and the QGIS_PROJECT_FILE environment variable Arguments: addressAndPort Listen to address and port (default: "localhost:8000") address and port can also be specified with the environment variables QGIS_SERVER_ADDRESS and QGIS_SERVER_PORT ``` -------------------------------- ### Configure RPATH and Installation Properties Source: https://docs.qgis.org/3.44/en/docs/developers_guide/unittesting.html Sets target properties for the executable, including RPATH settings for build and installation, and defines installation destinations. ```cmake SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES # skip the full RPATH for the build tree SKIP_BUILD_RPATHTRUE # when building, use the install RPATH already # (so it doesn't need to relink when installing) BUILD_WITH_INSTALL_RPATH TRUE # the RPATH to be used when installing INSTALL_RPATH ${QGIS_LIB_DIR} # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH INSTALL_RPATH_USE_LINK_PATH true) ``` -------------------------------- ### Download and Prepare Sample Project Data Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html These commands download and extract sample QGIS project data, including a world map and a spatialite database, which can be used for testing QGIS Server. ```bash mkdir /home/qgis/projects/ cd /home/qgis/projects/ wget https://github.com/qgis/QGIS-Training-Data/archive/release_3.22.zip unzip release_3.22.zip mv QGIS-Training-Data-release_3.22/exercise_data/qgis-server-tutorial-data/world.qgs . mv QGIS-Training-Data-release_3.22/exercise_data/qgis-server-tutorial-data/naturalearth.sqlite . ``` -------------------------------- ### Pagination Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/ogcapif.html Demonstrates how to paginate through a long list of features using `limit` and `offset` query parameters. ```APIDOC ## GET /collections/{collectionId}/items?limit=10&offset=10 ### Description Retrieves features with pagination applied. ### Endpoint `/collections/{collectionId}/items.json?offset=10&limit=10` ``` -------------------------------- ### PostgreSQL Service File Example Source: https://docs.qgis.org/3.44/en/docs/user_manual/managing_data_source/opening_data.html Define connection parameters using a service name in a `.pg_service.conf` file. This allows for reusable connection configurations. ```ini [water_service] host=192.168.0.45 port=5433 dbname=gisdb user=paul password=paulspass [wastewater_service] host=dbserver.com dbname=water user=waterpass ``` -------------------------------- ### DescribeLayerResponse XML Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wms.html Example XML response for a DescribeLayer request, showing layer descriptions. ```xml 1.1.0 wfs my_vector_layer wcs my_raster_layer ``` -------------------------------- ### WFS GetFeature response example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wfs.html This is an example of a WFS FeatureCollection response, showing sorted features. ```xml ... Zagreb Yerevan Yaounde ``` -------------------------------- ### authorizedLayerAttributes Example Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/server.html Example of implementing `authorizedLayerAttributes` to hide specific attributes, such as the 'role' attribute, from the user. ```APIDOC ## authorizedLayerAttributes ### Description Used to limit the visibility of a specific subset of attributes. The `attributes` argument returns the current set of visible attributes. ### Method `authorizedLayerAttributes(self, layer, attributes)` ### Parameters * `layer` (`QgsMapLayer`): The layer for which to authorize attributes. * `attributes` (`list`): A list of currently authorized attribute names. ### Returns * `list`: A list of attribute names that should be visible. ### Example ```python def authorizedLayerAttributes(self, layer, attributes): return [a for a in attributes if a != "role"] ``` ``` -------------------------------- ### Layer Type Parameters Example Source: https://docs.qgis.org/3.44/en/docs/developers_guide/processingtesting.html Demonstrates specifying vector or raster layers as parameters, including their type and relative path. ```yaml params: PAR: 2 STR: string LAYER: type: vector name: polys.gml OTHER: another param ``` -------------------------------- ### Example Action URL Construction Source: https://docs.qgis.org/3.44/en/docs/user_manual/working_with_vector/vector_properties.html This example demonstrates how to construct a URL for an action, incorporating map functions and URL encoding. It's useful for passing parameters to web tools or external applications. ```html http://localhost:8000?/[% url_encode(map('file', 'index.php')) %] ``` -------------------------------- ### layerFilterExpression Example Source: https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/server.html Example of implementing `layerFilterExpression` to restrict results to features where the 'role' attribute is 'user'. ```APIDOC ## layerFilterExpression ### Description Used to add an Expression to limit the results. For example, to limit to features where the attribute `role` is equal to `user`. ### Method `layerFilterExpression(self, layer)` ### Parameters * `layer` (`QgsMapLayer`): The layer for which to apply the filter. ### Returns * `string`: An expression string. ### Example ```python def layerFilterExpression(self, layer): return "$role = 'user'" ``` ``` -------------------------------- ### Install Apache and mod_fcgid Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Installs the necessary Apache web server and the mod_fcgid module for FastCGI support. ```bash apt install apache2 libapache2-mod-fcgid ``` -------------------------------- ### QGIS Command Line Options Overview Source: https://docs.qgis.org/3.44/en/docs/user_manual/introduction/qgis_configuration.html This is a comprehensive list of QGIS command-line options. Each option controls a specific aspect of QGIS startup or behavior, such as displaying version information, creating snapshots, setting the interface language, or loading projects. ```bash QGIS is a user friendly Open Source Geographic Information System. Usage: /usr/bin/qgis.bin [OPTION] [FILE] OPTION: [-v, --version] display version information and exit [-s, --snapshot filename] emit snapshot of loaded datasets to given file [-w, --width width] width of snapshot to emit [-h, --height height] height of snapshot to emit [-l, --lang language] use language for interface text (changes existing override) [-p, --project projectfile] load the given QGIS project [-e, --extent xmin,ymin,xmax,ymax] set initial map extent [-n, --nologo] hide splash screen [-V, --noversioncheck] don't check for new version of QGIS at startup [-P, --noplugins] don't restore plugins on startup [-B, --skipbadlayers] don't prompt for missing layers [-C, --nocustomization] don't apply GUI customization [-z, --customizationfile path] use the given ini file as GUI customization [-g, --globalsettingsfile path] use the given ini file as Global Settings (defaults) [-a, --authdbdirectory path] use the given directory for authentication database [-f, --code path] run the given python file on load [-F, --py-args arguments] arguments for python. These arguments will be available for each python execution via 'sys.argv' including the file specified by '--code'. All arguments till '--' are passed to python and ignored by QGIS. [-d, --defaultui] start by resetting user ui settings to default [--hide-browser] hide the browser widget [--dxf-export filename.dxf] emit dxf output of loaded datasets to given file [--dxf-extent xmin,ymin,xmax,ymax] set extent to export to dxf [--dxf-symbology-mode none|symbollayer|feature] symbology mode for dxf output [--dxf-scale-denom scale] scale for dxf output [--dxf-encoding encoding] encoding to use for dxf output [--dxf-map-theme maptheme] map theme to use for dxf output [--take-screenshots output_path] take screen shots for the user documentation [--screenshots-categories categories] specify the categories of screenshot to be used (see QgsAppScreenShots::Categories). [--profile name] load a named profile from the user's profiles folder. [-S, --profiles-path path] path to store user profile folders. Will create profiles inside a {path}\profiles folder [--version-migration] force the settings migration from older version if found [--openclprogramfolder] path to the folder containing the sources for OpenCL programs. [--help] this text [--] treat all following arguments as FILEs FILE: Files specified on the command line can include rasters, vectors, and QGIS project files (.qgs and .qgz): 1. Rasters - supported formats include GeoTiff, DEM and others supported by GDAL 2. Vectors - supported formats include ESRI Shapefiles and others supported by OGR and PostgreSQL layers using the PostGIS extension ``` -------------------------------- ### GetStyles Request Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wms.html Example URL for a GetStyles request to retrieve layer styles from QGIS Server. ```http http://localhost/qgisserver? SERVICE=WMS &REQUEST=GetStyles &LAYERS=mylayer1,mylayer2 ``` -------------------------------- ### Enable and Start QGIS Server Service Source: https://docs.qgis.org/3.44/en/docs/server_manual/getting_started.html Enables and starts multiple QGIS Server service instances using systemd. This command iterates through four instances. ```bash for i in 1 2 3 4; do systemctl enable --now qgis-server@$i.service; done ``` -------------------------------- ### WMS GetFeatureInfo URL Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wms.html An example URL demonstrating the structure of a GetFeatureInfo request with various parameters. ```http http://localhost/qgisserver? SERVICE=WMS &VERSION=1.3.0 &REQUEST=GetMap &MAP=/home/qgis/projects/world.qgs &LAYERS=mylayer1,mylayer2,mylayer3 &CRS=EPSG:4326 &WIDTH=400 &HEIGHT=400 &INFO_FORMAT=text/xml &TRANSPARENT=TRUE &QUERY_LAYERS=mylayer1 &FEATURE_COUNT=3 &I=250 &J=250 ``` -------------------------------- ### DescribeFeatureType Response Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wfs.html An example XML response from a DescribeFeatureType request, detailing the schema of the 'countries' layer. ```xml ``` -------------------------------- ### Test HelloWorld Plugin Source: https://docs.qgis.org/3.44/en/docs/server_manual/plugins.html Use this command to test the HelloWorld plugin on the QGIS Server. It sends a SERVICE=HELLO request and expects 'HelloServer!' as a response. ```bash wget -q -O - "http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=HELLO" HelloServer! ``` -------------------------------- ### WMTS GetCapabilities Request Example Source: https://docs.qgis.org/3.44/en/docs/server_manual/services/wmts.html Example URL for requesting WMTS capabilities. Requires specifying the service, request type, and the QGIS project file. ```http http://localhost/? ``` ```http SERVICE=WMTS &REQUEST=GetCapabilities &MAP=/home/qgis/projects/world.qgs ```