description
description
This module translates QGIS processing algorithms into the process descriptions of the
QGIS-Server-Light interface (interface.job.process.description), shaped along
OGC API - Processes.
The schemas are mapped with the strategy pattern. Each kind of QGIS parameter or output
definition has its SchemaStrategy, ProcessDescriptionMapper picks it from a flat
lookup table by the exact QGIS class. The layer strategies share the derivation of the
QslLayerMarker as template method (LayerSchemaStrategy.map_schema), each one only
tells which source types it accepts.
It was chosen because QGIS knows many definition classes and each one maps differently. Supporting a new one is one strategy and one entry in the table, nothing else changes. The exact class is looked up on purpose: a QGIS subclass is never served by accident through its parent, a definition without strategy is unsupported and its algorithm is skipped.
EnumSchemaStrategy
Bases: SchemaStrategy[QgsProcessingParameterEnum]
The options as one_of. The value is the option itself when the parameter uses
static strings, otherwise the index of the option, as QGIS expects it.
Source code in src/qgis_server_light/processing/description.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
map_schema(definition: QgsProcessingParameterEnum) -> Schema
The schema of the enum, each option an entry of one_of with const and
title.
Raises:
-
ValueError–If the parameter allows multiple options.
Source code in src/qgis_server_light/processing/description.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
FeatureSourceSchemaStrategy
Bases: LayerSchemaStrategy[QgsProcessingParameterFeatureSource | QgsProcessingParameterVectorLayer]
A vector layer, restricted to the geometry types the parameter accepts.
Source code in src/qgis_server_light/processing/description.py
269 270 271 272 273 274 275 276 277 278 279 | |
source_types(definition: QgsProcessingParameterFeatureSource | QgsProcessingParameterVectorLayer) -> list[int]
Source code in src/qgis_server_light/processing/description.py
274 275 276 277 278 279 | |
FileOutputSchemaStrategy
Bases: SchemaStrategy[QgsProcessingOutputDefinition]
An output the worker writes to a file, offered in each of the given media types. The first one is the default.
Source code in src/qgis_server_light/processing/description.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
media_types = media_types
instance-attribute
__init__(media_types: list[str])
Source code in src/qgis_server_light/processing/description.py
316 317 | |
map_schema(definition: QgsProcessingOutputDefinition) -> Schema
Source code in src/qgis_server_light/processing/description.py
319 320 321 322 323 324 325 | |
LayerSchemaStrategy
Bases: SchemaStrategy[D], ABC
A layer value (QslJobLayer), marked with a QslLayerMarker. The marker is derived
from the Qgis.ProcessingSourceType values the definition accepts. Source types QSL
can't serve as layer (mesh, point cloud, vector tile, file, ...) are left out.
Source code in src/qgis_server_light/processing/description.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
geometry_types_by_source_type: dict[Qgis.ProcessingSourceType, list[str]] = {Qgis.ProcessingSourceType.MapLayer: [Qgis.GeometryType.Point.name, Qgis.GeometryType.Line.name, Qgis.GeometryType.Polygon.name, Qgis.GeometryType.Null.name], Qgis.ProcessingSourceType.Vector: [Qgis.GeometryType.Point.name, Qgis.GeometryType.Line.name, Qgis.GeometryType.Polygon.name, Qgis.GeometryType.Null.name], Qgis.ProcessingSourceType.VectorAnyGeometry: [Qgis.GeometryType.Point.name, Qgis.GeometryType.Line.name, Qgis.GeometryType.Polygon.name], Qgis.ProcessingSourceType.VectorPoint: [Qgis.GeometryType.Point.name], Qgis.ProcessingSourceType.VectorLine: [Qgis.GeometryType.Line.name], Qgis.ProcessingSourceType.VectorPolygon: [Qgis.GeometryType.Polygon.name], Qgis.ProcessingSourceType.Raster: []}
class-attribute
instance-attribute
layer_kinds_by_source_type: dict[Qgis.ProcessingSourceType, list[QslLayerKind]] = {Qgis.ProcessingSourceType.MapLayer: [QslLayerKind.VECTOR, QslLayerKind.RASTER], Qgis.ProcessingSourceType.Vector: [QslLayerKind.VECTOR], Qgis.ProcessingSourceType.VectorAnyGeometry: [QslLayerKind.VECTOR], Qgis.ProcessingSourceType.VectorPoint: [QslLayerKind.VECTOR], Qgis.ProcessingSourceType.VectorLine: [QslLayerKind.VECTOR], Qgis.ProcessingSourceType.VectorPolygon: [QslLayerKind.VECTOR], Qgis.ProcessingSourceType.Raster: [QslLayerKind.RASTER]}
class-attribute
instance-attribute
map_schema(definition: D) -> Schema
The schema of a layer value, a string marked with QSL_LAYER_FORMAT and the
kinds and geometry types of all servable source types in the marker.
Raises:
-
ValueError–If none of the source types can be served as layer.
Source code in src/qgis_server_light/processing/description.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
source_types(definition: D) -> list[int]
abstractmethod
The Qgis.ProcessingSourceType values the definition accepts.
Parameters:
-
definition(D) –The QGIS parameter or output definition.
Returns:
-
list[int]–The source types as QGIS hands them out, as int.
Source code in src/qgis_server_light/processing/description.py
222 223 224 225 226 227 228 229 230 231 232 | |
LiteralOutputSchemaStrategy
Bases: SchemaStrategy[QgsProcessingOutputDefinition]
An output with a plain JSON Schema type.
Source code in src/qgis_server_light/processing/description.py
103 104 105 106 107 108 109 110 | |
json_type = json_type
instance-attribute
__init__(json_type: str)
Source code in src/qgis_server_light/processing/description.py
106 107 | |
map_schema(definition: QgsProcessingOutputDefinition) -> Schema
Source code in src/qgis_server_light/processing/description.py
109 110 | |
LiteralSchemaStrategy
Bases: SchemaStrategy[QgsProcessingParameterDefinition]
A parameter with a plain JSON Schema type and the QGIS default as default.
Source code in src/qgis_server_light/processing/description.py
93 94 95 96 97 98 99 100 | |
json_type = json_type
instance-attribute
__init__(json_type: str)
Source code in src/qgis_server_light/processing/description.py
96 97 | |
map_schema(definition: QgsProcessingParameterDefinition) -> Schema
Source code in src/qgis_server_light/processing/description.py
99 100 | |
MapLayerSchemaStrategy
Bases: LayerSchemaStrategy[QgsProcessingParameterMapLayer]
Any layer QSL can serve, a vector or a raster layer.
Source code in src/qgis_server_light/processing/description.py
282 283 284 285 286 287 | |
source_types(definition: QgsProcessingParameterMapLayer) -> list[int]
Source code in src/qgis_server_light/processing/description.py
285 286 287 | |
MultipleLayersSchemaStrategy
Bases: LayerSchemaStrategy[QgsProcessingParameterMultipleLayers]
Multiple layers are multiple values of the input, each one layer.
Source code in src/qgis_server_light/processing/description.py
297 298 299 300 301 302 303 304 305 306 307 308 309 | |
occurs(definition: QgsProcessingParameterMultipleLayers, optional: bool) -> tuple[int, int | str]
Source code in src/qgis_server_light/processing/description.py
303 304 305 306 307 308 309 | |
source_types(definition: QgsProcessingParameterMultipleLayers) -> list[int]
Source code in src/qgis_server_light/processing/description.py
300 301 | |
NumberSchemaStrategy
Bases: SchemaStrategy[QgsProcessingParameterNumber]
A number with its bounds, number or integer as QGIS types it.
Source code in src/qgis_server_light/processing/description.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
bounds(definition: QgsProcessingParameterNumber) -> tuple[float | None, float | None]
The bounds of the number, None where QGIS sets no bound.
Source code in src/qgis_server_light/processing/description.py
116 117 118 119 120 121 122 | |
map_schema(definition: QgsProcessingParameterNumber) -> Schema
The schema of the number, the bounds QGIS sets are its minimum and maximum.
Raises:
-
ValueError–If the number type is not supported.
Source code in src/qgis_server_light/processing/description.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
ProcessDescriptionMapper
Maps a QGIS processing algorithm onto its process description. The schema of each parameter and output is mapped by the strategy registered for its exact QGIS class, definitions without a strategy are not supported.
Source code in src/qgis_server_light/processing/description.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
__init__() -> None
Source code in src/qgis_server_light/processing/description.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
input_description(param: QgsProcessingParameterDefinition) -> InputDescription
The description of a parameter as input, an optional one needs no value.
Raises:
-
ValueError–If the parameter type is not supported.
Source code in src/qgis_server_light/processing/description.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
output_description(output: QgsProcessingOutputDefinition) -> OutputDescription
The description of an output, a file output with the formats it is offered in.
Raises:
-
ValueError–If the output type is not supported.
Source code in src/qgis_server_light/processing/description.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
process_description(algorithm: QgsProcessingAlgorithm) -> ProcessDescription
The description of the algorithm as process. Destination parameters are no inputs, the worker sets them.
Source code in src/qgis_server_light/processing/description.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
RasterLayerSchemaStrategy
Bases: LayerSchemaStrategy[QgsProcessingParameterRasterLayer]
A raster layer.
Source code in src/qgis_server_light/processing/description.py
290 291 292 293 294 | |
source_types(definition: QgsProcessingParameterRasterLayer) -> list[int]
Source code in src/qgis_server_light/processing/description.py
293 294 | |
SchemaStrategy
Bases: ABC
Maps one kind of QGIS parameter or output definition onto the schema of its value.
D is the QGIS definition class the strategy handles.
Source code in src/qgis_server_light/processing/description.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
default(definition: QgsProcessingParameterDefinition)
staticmethod
The default of the parameter, None if it has none.
Source code in src/qgis_server_light/processing/description.py
83 84 85 86 87 88 89 90 | |
map_schema(definition: D) -> Schema
abstractmethod
The schema of a single value of the parameter or output.
Parameters:
-
definition(D) –The QGIS parameter or output definition.
Returns:
-
Schema–The schema of the value.
Source code in src/qgis_server_light/processing/description.py
59 60 61 62 63 64 65 66 67 68 69 | |
occurs(definition: D, optional: bool) -> tuple[int, int | str]
The minimal and maximal number of values of an input.
Parameters:
-
definition(D) –The QGIS parameter definition.
-
optional(bool) –If the parameter is optional.
Returns:
-
tuple[int, int | str]–The minimal and the maximal number, a single value by default.
Source code in src/qgis_server_light/processing/description.py
71 72 73 74 75 76 77 78 79 80 81 | |