diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 1c09cf74..45d1e68a 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -35,7 +35,7 @@ jobs: - name: Install Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..524f04fe --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e7671685..d04a381c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: image: qgis/qgis:3.34 steps: - uses: actions/checkout@v4 - - name: install system dependencies + - name: install system dependencies run: apt update && apt install -y python3-poetry python3-flask python3-boto3 - name: Install Python dependencies working-directory: qsa-api diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..af701b2d --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,12 @@ +{ + "no-inline-html": false, + "line-length": false, + "no-duplicate-heading": false, + "no-alt-text": false, + "first-line-heading": false, + "MD014": false, + "globs": [ + "docs/**/*.md", + "*.md" + ] +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..fd9fc332 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-xml + - id: detect-private-key + - id: mixed-line-ending + +- repo: https://github.com/DavidAnson/markdownlint-cli2 + rev: v0.13.0 + hooks: + - id: markdownlint-cli2 diff --git a/CHANGELOG.md b/CHANGELOG.md index b53425fa..c358bb53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,78 +5,74 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). - ## [1.1.0] - 2024-09-24 ### Added -- Add Python files after installation of dependencies in Dockerfile : https://github.com/pblottiere/QSA/pull/68 -- Add basic cache entrypoints : https://github.com/pblottiere/QSA/pull/74 -- Add data type and band counts metadata for raster layers : https://github.com/pblottiere/QSA/pull/80 +- Add Python files after installation of dependencies in Dockerfile : +- Add basic cache entrypoints : +- Add data type and band counts metadata for raster layers : ### Fixed -- Always create parent directory for internal sqlite database : https://github.com/pblottiere/QSA/pull/73 -- Clear MapProxy legends cache : https://github.com/pblottiere/QSA/pull/78 - +- Always create parent directory for internal sqlite database : +- Clear MapProxy legends cache : ## [1.0.0] - 2024-07-31 ### Added -- Add qsa-plugin, qsa-cli and doc: https://github.com/pblottiere/QSA/pull/8 -- Add raster layer support: https://github.com/pblottiere/QSA/pull/9 -- Add a CHANGELOG file: https://github.com/pblottiere/QSA/pull/10 -- Add basic badges in README: https://github.com/pblottiere/QSA/pull/11 -- Add qsa-cli stats command: https://github.com/pblottiere/QSA/pull/13 -- Add PostgreSQL support for storing QGIS projects: https://github.com/pblottiere/QSA/pull/15 -- Add doc for raster layer in sandbox: https://github.com/pblottiere/QSA/pull/16 -- Add basic support for raster style: https://github.com/pblottiere/QSA/pull/17 -- Add support for min/max settings in raster style: https://github.com/pblottiere/QSA/pull/18 -- CRS is now optional when adding a layer: https://github.com/pblottiere/QSA/pull/19 -- Manage optional CRS when MapProxy is enabled: https://github.com/pblottiere/QSA/pull/20 -- Optimize raster cache config: https://github.com/pblottiere/QSA/pull/21 -- Add PostGIS support for vector layers: https://github.com/pblottiere/QSA/pull/22 -- Add option to build overview if necessary: https://github.com/pblottiere/QSA/pull/24 -- Add QSA_LOGLEVEL environment variable: https://github.com/pblottiere/QSA/pull/27 -- Add check on epsg code validity: https://github.com/pblottiere/QSA/pull/29 -- Optimize MapProxy clear cache: https://github.com/pblottiere/QSA/pull/31 -- Homogenize gray band properties with red/green/blue: https://github.com/pblottiere/QSA/pull/32 -- Optimize min/max statistics computation: https://github.com/pblottiere/QSA/pull/34 -- Update QSA app to be used with a proper WSGI HTTP production server: https://github.com/pblottiere/QSA/pull/38 -- Add singleband pseudocolor renderer: https://github.com/pblottiere/QSA/pull/39 -- Use QGIS 3.38 in sandbox: https://github.com/pblottiere/QSA/pull/41 -- Add support for WMS TIME parameter: https://github.com/pblottiere/QSA/pull/42 -- Add gradient stops for singlebandpseudocolor renderer: https://github.com/pblottiere/QSA/pull/43 -- Adapt docs how to run tests: https://github.com/pblottiere/QSA/pull/49 -- Add /api/processing/raster/calculator entrypoint: https://github.com/pblottiere/QSA/pull/45 -- Add /api/processing/raster/histogram: https://github.com/pblottiere/QSA/pull/52 -- Activate legend in MapProxy configuration: https://github.com/pblottiere/QSA/pull/53 -- CI: add unit test without Postgres dependency: https://github.com/pblottiere/QSA/pull/50 -- Add MapProxy s3 cache support: https://github.com/pblottiere/QSA/pull/55 -- Move histogram computation in dedicated process: https://github.com/pblottiere/QSA/pull/56 -- Build 'dev' container image on push to 'main' branch: https://github.com/pblottiere/QSA/pull/61 -- Optimize project opening: https://github.com/pblottiere/QSA/pull/58 -- Add global try/except for requests: https://github.com/pblottiere/QSA/pull/62 -- Add badge for CI: https://github.com/pblottiere/QSA/pull/63 +- Add qsa-plugin, qsa-cli and doc: +- Add raster layer support: +- Add a CHANGELOG file: +- Add basic badges in README: +- Add qsa-cli stats command: +- Add PostgreSQL support for storing QGIS projects: +- Add doc for raster layer in sandbox: +- Add basic support for raster style: +- Add support for min/max settings in raster style: +- CRS is now optional when adding a layer: +- Manage optional CRS when MapProxy is enabled: +- Optimize raster cache config: +- Add PostGIS support for vector layers: +- Add option to build overview if necessary: +- Add QSA_LOGLEVEL environment variable: +- Add check on epsg code validity: +- Optimize MapProxy clear cache: +- Homogenize gray band properties with red/green/blue: +- Optimize min/max statistics computation: +- Update QSA app to be used with a proper WSGI HTTP production server: +- Add singleband pseudocolor renderer: +- Use QGIS 3.38 in sandbox: +- Add support for WMS TIME parameter: +- Add gradient stops for singlebandpseudocolor renderer: +- Adapt docs how to run tests: +- Add /api/processing/raster/calculator entrypoint: +- Add /api/processing/raster/histogram: +- Activate legend in MapProxy configuration: +- CI: add unit test without Postgres dependency: +- Add MapProxy s3 cache support: +- Move histogram computation in dedicated process: +- Build 'dev' container image on push to 'main' branch: +- Optimize project opening: +- Add global try/except for requests: +- Add badge for CI: ### Fixed -- Fix projects in cache in qsa-plugin: https://github.com/pblottiere/QSA/pull/12 -- Fix docs: https://github.com/pblottiere/QSA/pull/14 -- Deactivate multithreading: https://github.com/pblottiere/QSA/pull/23 -- Fix get style for raster (and homogenize vector style): https://github.com/pblottiere/QSA/pull/25 -- Remove log in staticmethod: https://github.com/pblottiere/QSA/pull/30 -- Remove useless print in tests: https://github.com/pblottiere/QSA/pull/54 - +- Fix projects in cache in qsa-plugin: +- Fix docs: +- Deactivate multithreading: +- Fix get style for raster (and homogenize vector style): +- Remove log in staticmethod: +- Remove useless print in tests: ## [0.0.2] - 2024-02-15 ### Added -- Support simple symbol properties for lines and polygons: https://github.com/pblottiere/QSA/pull/1 -- Add support for simple marker style: https://github.com/pblottiere/QSA/pull/2 - +- Support simple symbol properties for lines and polygons: +- Add support for simple marker style: ## [0.0.1] - 2024-02-12 diff --git a/README.md b/README.md index 22b6599e..5297c217 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ Components: * `qsa-cli`: Command line tool Main features: + * Create and manage QGIS projects stored on filesystem or in PostgreSQL * Create and update vector and raster layers: symbology, theme, ... * Inspect online QGIS Server instances * Cache management with MapProxy - See QGIS Server Administration tool's [documentation](https://pblottiere.github.io/QSA/) for more details. diff --git a/docs/src/DEVELOPERS.md b/docs/src/DEVELOPERS.md index 3e1f238c..ce9a73b5 100644 --- a/docs/src/DEVELOPERS.md +++ b/docs/src/DEVELOPERS.md @@ -1,27 +1,33 @@ # Developers -Documentation: +## Documentation ```` console $ mdbook build docs ```` -Unit tests: +## Unit tests -```` console -$ cat ~/.pg_service.conf +Ensure you have a valid `qsa_test` section in `~/.pg_service.conf`: + +```` conf [qsa_test] host=localhost port=5432 dbname=qsa_test user=myusername password= +```` + +Run the tests with: + +```` console $ createdb qsa_test $ cd qsa-api $ pytest -sv tests ```` -Integration tests: +## Integration tests ```` console $ cd sandbox @@ -29,3 +35,12 @@ $ docker-compose up -d $ cd ../qsa-api $ QSA_GEOTIFF="/landsat_4326.tif" QSA_GPKG="/data.gpkg" QSA_HOST=127.0.01 QSA_PORT=5000 pytest -sv tests ```` + +## Quality tests + +Ensure your changes are correctly formatted with `pre-commit` (see [installation](https://pre-commit.com/#installation)): + +```` console +# activate in repository +$ pre-commit install +```` diff --git a/docs/src/README.md b/docs/src/README.md index 54a2837f..915f006a 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -1,6 +1,5 @@ Welcome to QGIS Server Administration tool's documentation. - [QGIS Server](https://docs.qgis.org/3.34/en/docs/server_manual/introduction.html) is a map-server based on the QGIS core library and rendering engine which provides numerous classical services like WMS, WFS, WCS, WMTS and OGC API Features. @@ -15,6 +14,7 @@ Components: * [QSA cli](qsa-cli/): Command line tool Features: + * Create and manage QGIS projects stored on the filesystem or in PostgreSQL * Create and update vector and raster layers : symbology, theme, ... * Inspect online QGIS Server instances @@ -23,6 +23,7 @@ Features: ![QSA](images/qsa_archi.png) Roadmap: + * Add more documentation * Add PostgreSQL support to store QGIS styles and QSA internals data * Publish `qsa-cli` on PyPI diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 55890579..7ab83ae7 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -1,4 +1,5 @@ [Introduction](README.md) + - [QSA REST API](qsa-api/README.md) - [Installation](qsa-api/installation.md) - [Configuration](qsa-api/configuration.md) diff --git a/docs/src/images/qsa_archi.excalidraw b/docs/src/images/qsa_archi.excalidraw index 6f923a2f..498a5994 100644 --- a/docs/src/images/qsa_archi.excalidraw +++ b/docs/src/images/qsa_archi.excalidraw @@ -943,4 +943,4 @@ "viewBackgroundColor": "#ffffff" }, "files": {} -} \ No newline at end of file +} diff --git a/docs/src/qsa-api/configuration.md b/docs/src/qsa-api/configuration.md index 517dee74..590055e3 100644 --- a/docs/src/qsa-api/configuration.md +++ b/docs/src/qsa-api/configuration.md @@ -13,14 +13,12 @@ QSA web server can be configured thanks to the next environment variables: | No | `QSA_MAPPROXY_CACHE_S3_BUCKET` | Activate S3 cache for MapProxy if bucket is set | | No | `QSA_MAPPROXY_CACHE_S3_DIR` | S3 cache directory for MapProxy. Default to `/mapproxy/cache` | -
MapProxy Time dimension caching is not supported with S3 backend storage.
- ## PostgreSQL support {#postgresql-support} When PostgreSQL support is enabled to store QGIS projects thanks to the @@ -30,10 +28,11 @@ well as QGIS QML styles. The PostgreSQL support relies on a `service` defined in a [PostgreSQL connection service file](https://www.postgresql.org/docs/current/libpq-pgservice.html). -For example with `QSA_QGISSERVER_PROJECTS_PSQL_SERVICE=qsa_projects`: -```` shell -$ cat ~/.pg_service.conf +For example with `QSA_QGISSERVER_PROJECTS_PSQL_SERVICE=qsa_projects`, a proper +`qsa_projects` section is needed in `~/.pg_service.conf`: + +```` conf [qsa_projects] host=localhost port=5432 diff --git a/docs/src/qsa-api/endpoints/README.md b/docs/src/qsa-api/endpoints/README.md index 601aa60f..ab90b19c 100644 --- a/docs/src/qsa-api/endpoints/README.md +++ b/docs/src/qsa-api/endpoints/README.md @@ -7,13 +7,13 @@ The QSA REST API provides several endpoints: * [/api/instances](instances.md) * [/api/processing](processing.md) -### PostgreSQL schema +## PostgreSQL schema When PostgreSQL support is enabled, a query string parameter `schema` may be used to specify the schema in which the QGIS project is stored in the database (`public` is used by default). -```` shell +```` console # call a specific endpoint using projects stored in PostgreSQL schema named `myschema` $ curl "http://localhost/api/xxx/yyy?schema=myschema" ```` diff --git a/docs/src/qsa-api/endpoints/instances.md b/docs/src/qsa-api/endpoints/instances.md index 4eb63c5d..a7b0600d 100644 --- a/docs/src/qsa-api/endpoints/instances.md +++ b/docs/src/qsa-api/endpoints/instances.md @@ -1,6 +1,5 @@ # QSA REST API : /api/instances - When `qsa-plugin` is installed, an `/api/instances` endpoint is available to retrieve information about QGIS Server underlying instances. diff --git a/docs/src/qsa-api/endpoints/processing.md b/docs/src/qsa-api/endpoints/processing.md index 18fb4fe3..2552c96d 100644 --- a/docs/src/qsa-api/endpoints/processing.md +++ b/docs/src/qsa-api/endpoints/processing.md @@ -8,10 +8,9 @@ rasters or get histogram for raster layers. | POST | `/api/processing/raster/histogram/{project}/{layer}` | Return an histogram in JSON | | POST | `/api/processing/raster/calculator/{project}` | Create a raster based on an `expression` and an `output` filename | - Examples: -``` shell +``` console # create a new layer based on a QGIS expression $ curl "http://localhost/api/projects/" \ -X POST \ @@ -22,7 +21,6 @@ $ curl "http://localhost/api/projects/" \ }' ``` -
Processing diff --git a/docs/src/qsa-api/endpoints/projects.md b/docs/src/qsa-api/endpoints/projects.md index d7c81025..5d36edcf 100644 --- a/docs/src/qsa-api/endpoints/projects.md +++ b/docs/src/qsa-api/endpoints/projects.md @@ -18,7 +18,7 @@ A QSA project is defined by: Examples: -``` shell +``` console # create a project and store the QGIS project in PostgreSQL within `my_schema` $ curl "http://localhost/api/projects/" \ -X POST \ @@ -54,22 +54,22 @@ empty. | POST | `/api/projects/{project}/layers/{layer}/style` | Add/Update layer's style with `name` (style name) and `current` (`true` or `false`) | | DELETE | `/api/projects/{project}/layers/{layer}` | Remove layer from project | -#### Layer definition {#layer-definition} +### Layer definition {#layer-definition} A layer can be added to a project thanks to the next parameters: -- `type` : `raster` or `vector` -- `name` : the layer's name -- `datasource` : the link to the datasource according to the storage backend - - filesystem : `/tmp/raster.tif` - - AWS S3 : `/vsis3/bucket/raster.tif` - - PostGIS : `service=qsa table=\"public\".\"lines\" (geom)` -- `overview` (optional) : automatically build overviews for raster layers stored in S3 buckets -- `crs` (optional) : CRS (automatically detected by default) +* `type` : `raster` or `vector` +* `name` : the layer's name +* `datasource` : the link to the datasource according to the storage backend + * filesystem : `/tmp/raster.tif` + * AWS S3 : `/vsis3/bucket/raster.tif` + * PostGIS : `service=qsa table=\"public\".\"lines\" (geom)` +* `overview` (optional) : automatically build overviews for raster layers stored in S3 buckets +* `crs` (optional) : CRS (automatically detected by default) Example: -```` shell +```` console # Add a FlatGeobuf vector layer stored on S3 bucket in project `my_project` $ curl "http://localhost/api/projects/my_project/layers" \ -X POST \ @@ -96,19 +96,19 @@ automatically used when a vector layer is added to a QSA project. | POST | `/api/projects/{project}/styles/default` | Set a default layer's style. See [Vector style](#vector-style) and [Raster style](#raster-style) for more information. | | DELETE | `/api/projects/{project}/styles/{style}` | Remove style from project | - -#### Vector style {#vector-style} +### Vector style {#vector-style} For vector layers, a style can be defined with the parameters listed below: -- `type` : `vector` -- `name` : the name of the style -- `rendering` : rendering parameters (only `opacity` is supported for now) -- `symbology` : dictionary with `type` (only `single_symbol` is supported for + +* `type` : `vector` +* `name` : the name of the style +* `rendering` : rendering parameters (only `opacity` is supported for now) +* `symbology` : dictionary with `type` (only `single_symbol` is supported for now), `symbol` and `properties` Example: -```` shell +```` console # Add a style for point geometry vector layers $ curl "http://localhost:5000/api/projects/my_project/styles" \ -X POST \ @@ -130,22 +130,23 @@ $ curl "http://localhost:5000/api/projects/my_project/styles" \ ```` To set a default style for a specific geometry, the parameters listed below are available: -- `name` : the name of the style to use by default -- `geometry` : the geometry for which the style needs to be applied +* `name` : the name of the style to use by default +* `geometry` : the geometry for which the style needs to be applied #### Raster style {#raster-style} For raster layers, a style can be defined with the parameters listed below: -- `type` : `raster` -- `name` : the name of the style -- `rendering` : rendering parameters -- `symbology` : dictionary with `type` (only `singlebandgray` and + +* `type` : `raster` +* `name` : the name of the style +* `rendering` : rendering parameters +* `symbology` : dictionary with `type` (only `singlebandgray` and `multibandcolor` are supported for now) and `properties` Example: -```` shell +```` console # Add a style for multiband raster $ curl "http://localhost:5000/api/projects/my_project/styles" \ -X POST \ @@ -185,7 +186,7 @@ $ curl "http://localhost:5000/api/projects/my_project/styles" \ Example: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/cache" { "valid":true, diff --git a/docs/src/qsa-api/endpoints/symbology.md b/docs/src/qsa-api/endpoints/symbology.md index 400521ce..e13b8b68 100644 --- a/docs/src/qsa-api/endpoints/symbology.md +++ b/docs/src/qsa-api/endpoints/symbology.md @@ -23,7 +23,7 @@ version. Examples: -```` shell +```` console # Return single symbol properties for polygon layers $ curl "http://localhost:5000/api/symbology/vector/polygon/single_symbol/fill/properties" | jq { diff --git a/docs/src/qsa-api/installation.md b/docs/src/qsa-api/installation.md index 6ff70581..9a70209b 100644 --- a/docs/src/qsa-api/installation.md +++ b/docs/src/qsa-api/installation.md @@ -2,7 +2,7 @@ ## From sources -```` shell +```` console $ cd qsa-api $ virtualenv --system-site-packages venv # system aware for pyqgis $ . venv/bin/activate @@ -14,7 +14,7 @@ $ . venv/bin/activate A prebuilt image can be found on `ghcr.io/pblottiere/qsa`: -```` shell +```` console $ docker pull ghcr.io/pblottiere/qsa:1.1.0 ```` diff --git a/docs/src/qsa-cli/installation.md b/docs/src/qsa-cli/installation.md index b2ae6c72..93b65f66 100644 --- a/docs/src/qsa-cli/installation.md +++ b/docs/src/qsa-cli/installation.md @@ -4,7 +4,7 @@ From sources: ```` console $ cd qsa-cli -$ virtualenv venv +$ virtualenv venv $ . venv/bin/activate (venv)$ pip install poetry (venv)$ poetry install diff --git a/docs/src/qsa-plugin/README.md b/docs/src/qsa-plugin/README.md index 04ce058a..864b2cb7 100644 --- a/docs/src/qsa-plugin/README.md +++ b/docs/src/qsa-plugin/README.md @@ -4,5 +4,6 @@ which starts a dedicated thread with a TCP autoregistering client. Features: + * Return metadata, logs, ... about QGIS Server without interfering with the rendering loop * TODO : Influence the QGIS Server behavior through communication with the main thread diff --git a/docs/src/sandbox/README.md b/docs/src/sandbox/README.md index a031e74b..35439312 100644 --- a/docs/src/sandbox/README.md +++ b/docs/src/sandbox/README.md @@ -3,10 +3,9 @@ The sandbox directory provides a plug-and-play `Docker` environment to discover QSA tools with PostgreSQL support enabled. - First, a QSA REST API server is set up with 4 QGIS Server instances: -```` shell +```` console $ cd sandbox $ docker-compose up --scale qgisserver=4 -d $ docker ps diff --git a/docs/src/sandbox/inspect.md b/docs/src/sandbox/inspect.md index 4129371e..279473e5 100644 --- a/docs/src/sandbox/inspect.md +++ b/docs/src/sandbox/inspect.md @@ -3,13 +3,12 @@ `qsa-cli` allows to inspect online QGIS Server instances registered to `qsa-api` server, but it's also possible to use the REST API. -### List online instances +## List online instances To list these instances with `qsa-cli`: -```` shell -$ export QSA_SERVER_URL=http://localhost:5000 -$ qsa ps +```` console +$ QSA_SERVER_URL=http://localhost:5000 qsa ps INSTANCE ID IP STATUS ------------- ---------- ----------------------- 6773ca08 172.20.0.2 Binded 1096 seconds ago @@ -20,7 +19,7 @@ c0047e66 172.20.0.6 Binded 1096 seconds ago Or with the API: -```` shell +```` console $ curl http://localhost:5000/api/instances/ | jq { "servers": [ @@ -48,12 +47,11 @@ $ curl http://localhost:5000/api/instances/ | jq } ```` - -### Get metadata +## Get metadata To get some metadata about a specific QGIS Server instance with `qsa-cli`: -```` shell +```` console $ qsa inspect 4464d3c5 { "cache": { @@ -98,14 +96,13 @@ $ qsa inspect 4464d3c5 } ```` -Or with the API ``curl http://localhost:5000/api/instances/4464d3c5``. - +Or with the API `curl http://localhost:5000/api/instances/4464d3c5`. -### Fetch the log +## Fetch the log A bad request to QGIS Server to have something in the log: -```` shell +```` console $ curl http://172.20.0.4/ogc/ Project file error. For OWS services: please provide a SERVICE and a MAP parameter pointing to a valid QGIS project file @@ -113,7 +110,7 @@ $ curl http://172.20.0.4/ogc/ Then to fetch the log of the corresponding QGIS Server instance with `qsa-cli`: -```` shell +```` console $ qsa logs 4464d3c5 Server plugin qsa loaded! Server python plugins loaded @@ -142,12 +139,11 @@ Trying URL path: '/ogc/' for '/wfs3' Request finished in 3 ms ```` - -### Display stats +## Display stats To display stats for all QGIS Server online instances: -```` shell +```` console $ qsa stats INSTANCE ID COUNT TIME SERVICE REQUEST PROJECT ------------- ------- ---------- --------- --------- --------- diff --git a/docs/src/sandbox/projects.md b/docs/src/sandbox/projects.md index 4d122508..67e0d08d 100644 --- a/docs/src/sandbox/projects.md +++ b/docs/src/sandbox/projects.md @@ -1,17 +1,17 @@ # Sandbox : projects -### Create and delete projects in PostgreSQL +## Create and delete projects in PostgreSQL First we create a schema to store QGIS projects: -```` shell +```` console $ psql -h localhost -p 5433 -U qsa qsa -c "create schema my_schema" CREATE SCHEMA ```` Then we create a QSA project: -```` shell +```` console $ curl "http://localhost:5000/api/projects/" \ -X POST \ -H 'Content-Type: application/json' \ @@ -20,20 +20,19 @@ $ curl "http://localhost:5000/api/projects/" \ "author":"pblottiere", "schema":"my_schema" }' -true ```` In this case, a directory has been created on the filesystem with the internal QSA database: -```` shell +```` console $ file projects/qsa/my_schema_my_project/qsa.db SQLite 3.x database ```` And a QGIS project has been created in PostgreSQL: -```` shell +```` console $ psql -h localhost -p 5433 -U qsa qsa -c "select name from my_schema.qgis_projects" name ------------ @@ -44,7 +43,7 @@ $ psql -h localhost -p 5433 -U qsa qsa -c "select name from my_schema.qgis_proje To create another project in `public` schema and list available projects thanks to the QSA API: -```` shell +```` console $ curl "http://localhost:5000/api/projects/" \ -X POST \ -H 'Content-Type: application/json' \ @@ -61,7 +60,7 @@ $ curl "http://localhost:5000/api/projects/?schema=my_schema" To delete a project: -```` shell +```` console $ curl -X DELETE "http://localhost:5000/api/projects/my_project_2" true $ curl "http://localhost:5000/api/projects/" @@ -70,7 +69,7 @@ $ curl "http://localhost:5000/api/projects/" To list project metadata: -```` shell +```` console $ curl http://localhost:5000/api/projects/my_project?schema=my_schema | jq { "author": "pblottiere", diff --git a/docs/src/sandbox/raster/layers.md b/docs/src/sandbox/raster/layers.md index 79c0bb07..3171cde3 100644 --- a/docs/src/sandbox/raster/layers.md +++ b/docs/src/sandbox/raster/layers.md @@ -2,12 +2,11 @@ Layer is based on the `landsat_4326.tif` file mounted in the Docker containers. - -### Add layers +## Add layers To add a raster layer to a project: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -16,13 +15,11 @@ $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" \ "name":"dem", "type":"raster" }' -true ```` +## List layers and get metadata -### List layers and get metadata - -```` shell +```` console # list layers $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" ["polygons","dem"] @@ -45,12 +42,11 @@ $ curl "http://localhost:5000/api/projects/my_project/layers/dem?schema=my_schem } ```` - -### Map sample +## Map sample To execute a WMS `GetMap` request with basic parameters: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/dem/map?schema=my_schema" --output map.png ```` diff --git a/docs/src/sandbox/raster/processing.md b/docs/src/sandbox/raster/processing.md index 48edd471..58800442 100644 --- a/docs/src/sandbox/raster/processing.md +++ b/docs/src/sandbox/raster/processing.md @@ -1,11 +1,10 @@ # Sandbox : raster processing - -### Histogram +## Histogram To get an histogram for a specific raster layer: -```` shell +```` console $ curl "http://localhost:5000/api/processing/raster/histogram/my_project/dem?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -13,5 +12,4 @@ $ curl "http://localhost:5000/api/processing/raster/histogram/my_project/dem?sch "min": 0, "count": 100 }' -true ```` diff --git a/docs/src/sandbox/raster/styles.md b/docs/src/sandbox/raster/styles.md index 57d39738..f01810bc 100644 --- a/docs/src/sandbox/raster/styles.md +++ b/docs/src/sandbox/raster/styles.md @@ -1,11 +1,10 @@ # Sandbox : raster styles - -### Add style to project +## Add style to project To add a style for a multiband raster layer: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/styles?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -30,22 +29,20 @@ $ curl "http://localhost:5000/api/projects/my_project/styles?schema=my_schema" \ "contrast": 100 } }' -true ```` To list styles for a specific project: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/styles?schema=my_schema" ["my_singlebandgray_style"] ```` - -### Apply style to layer +## Apply style to layer To apply a specific style to a layer: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/dem/style?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -53,12 +50,11 @@ $ curl "http://localhost:5000/api/projects/my_project/layers/dem/style?schema=my "name":"my_singlebandgray_style", "current":true }' -true ```` The layer rendering has changed now: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/dem/map?schema=my_schema" --output map.png ```` diff --git a/docs/src/sandbox/vector/layers.md b/docs/src/sandbox/vector/layers.md index 22bf903c..c8a6c2c7 100644 --- a/docs/src/sandbox/vector/layers.md +++ b/docs/src/sandbox/vector/layers.md @@ -2,12 +2,11 @@ Layers are based on the `data.gpkg` file mounted in the Docker containers. - -### Add layers +## Add layers To add a polygon layer from a geopackage to a project: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -17,12 +16,11 @@ $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" \ "name":"polygons", "type":"vector" }' -true ```` And a line layer from PostGIS: -```` shell +```` console # copy geopackage table to PostGIS $ ogr2ogr -f PostgreSQL "PG:dbname=qsa password=qsa user=qsa port=5433 host=localhost" data.gpkg lines @@ -36,16 +34,16 @@ $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" \ "name":"lines", "type":"vector" }' -true ```` +## List layers and get metadata -### List layers and get metadata - -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" ["lines","polygons"] +```` +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/lines?schema=my_schema" | jq { "bbox": "-117.62319839219100004 23.20820580488510032, -82.32264950769270229 46.18290982947510059", @@ -62,23 +60,20 @@ $ curl "http://localhost:5000/api/projects/my_project/layers/lines?schema=my_sch } ```` - -### Map sample +## Map sample To execute a WMS `GetMap` request with basic parameters: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/polygons/map?schema=my_schema" --output map.png ```` +## Delete layers -### Delete layers - -```` shell +```` console $ curl -X DELETE "http://localhost:5000/api/projects/my_project/layers/lines?schema=my_schema" -true $ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema" ["polygons"] diff --git a/docs/src/sandbox/vector/styles.md b/docs/src/sandbox/vector/styles.md index ad47130b..d3179464 100644 --- a/docs/src/sandbox/vector/styles.md +++ b/docs/src/sandbox/vector/styles.md @@ -1,11 +1,10 @@ # Sandbox : vector styles - -### Add style to project +## Add style to project To list available properties for the polygon single symbol renderer: -```` shell +```` console $ curl "http://localhost:5000/api/symbology/vector/polygon/single_symbol/fill/properties" | jq { "border_width_map_unit_scale": "3x:0,0,0,0,0,0", @@ -24,7 +23,7 @@ $ curl "http://localhost:5000/api/symbology/vector/polygon/single_symbol/fill/pr To add a style for a polygon layer: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/styles?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -43,22 +42,20 @@ $ curl "http://localhost:5000/api/projects/my_project/styles?schema=my_schema" \ }, "rendering": {} }' -true ```` To list styles for a specific project: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/styles?schema=my_schema" ["my_fill_style"] ```` - -### Apply style to layer +## Apply style to layer To apply a specific style to a layer: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/polygons/style?schema=my_schema" \ -X POST \ -H 'Content-Type: application/json' \ @@ -66,12 +63,11 @@ $ curl "http://localhost:5000/api/projects/my_project/layers/polygons/style?sche "name":"my_fill_style", "current":true }' -true ```` The layer rendering has changed now: -```` shell +```` console $ curl "http://localhost:5000/api/projects/my_project/layers/polygons/map?schema=my_schema" --output map.png ````