Skip to content

interface

interface

common

This module contains common logic, shared beyond all specialised parts of the QGIS-Server-Light interface.

BBox dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/common.py
143
144
145
146
147
148
149
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
176
177
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
@dataclass(repr=False)
class BBox(BaseInterface):
    x_min: float = field(metadata={"type": "Element"})
    x_max: float = field(metadata={"type": "Element"})
    y_min: float = field(metadata={"type": "Element"})
    y_max: float = field(metadata={"type": "Element"})
    z_min: float = field(default=0.0, metadata={"type": "Element"})
    z_max: float = field(default=0.0, metadata={"type": "Element"})

    def to_list(self) -> list:
        return [self.x_min, self.y_min, self.z_min, self.x_max, self.y_max, self.z_max]

    def to_string(self) -> str:
        return ",".join([str(item) for item in self.to_list()])

    def to_2d_list(self) -> list:
        return [self.x_min, self.y_min, self.x_max, self.y_max]

    def to_2d_string(self) -> str:
        return ",".join([str(item) for item in self.to_2d_list()])

    @staticmethod
    def from_string(bbox_string: str) -> "BBox":
        """
        Takes a CSV string representation of a BBox in the form:
            '<x_min>,<y_min>,<x_max>,<y_max>' or
            '<x_min>,<y_min>,<z_min>,<x_max>,<y_max>,<z_max>'
        """
        coordinates = bbox_string.split(",")
        if len(coordinates) == 4:
            return BBox(
                x_min=float(coordinates[0]),
                y_min=float(coordinates[1]),
                x_max=float(coordinates[2]),
                y_max=float(coordinates[3]),
            )
        elif len(coordinates) == 6:
            return BBox(
                x_min=float(coordinates[0]),
                y_min=float(coordinates[1]),
                z_min=float(coordinates[2]),
                x_max=float(coordinates[3]),
                y_max=float(coordinates[4]),
                z_max=float(coordinates[5]),
            )
        else:
            raise ValueError(f"Invalid bbox string: {bbox_string}")

    @staticmethod
    def from_list(bbox_list: list[float]) -> "BBox":
        """
        Takes a list representation of a BBox in the form:
            [<x_min>,<y_min>,<x_max>,<y_max>] or
            [<x_min>,<y_min>,<z_min>,<x_max>,<y_max>,<z_max>]
        """
        if len(bbox_list) == 4:
            return BBox(
                x_min=bbox_list[0],
                y_min=bbox_list[1],
                x_max=bbox_list[2],
                y_max=bbox_list[3],
            )
        elif len(bbox_list) == 6:
            return BBox(
                x_min=bbox_list[0],
                y_min=bbox_list[1],
                z_min=bbox_list[2],
                x_max=bbox_list[3],
                y_max=bbox_list[4],
                z_max=bbox_list[5],
            )
        else:
            raise ValueError(f"Invalid bbox list: {bbox_list}")
x_max: float = field(metadata={'type': 'Element'}) class-attribute instance-attribute
x_min: float = field(metadata={'type': 'Element'}) class-attribute instance-attribute
y_max: float = field(metadata={'type': 'Element'}) class-attribute instance-attribute
y_min: float = field(metadata={'type': 'Element'}) class-attribute instance-attribute
z_max: float = field(default=0.0, metadata={'type': 'Element'}) class-attribute instance-attribute
z_min: float = field(default=0.0, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(x_min: float, x_max: float, y_min: float, y_max: float, z_min: float = 0.0, z_max: float = 0.0) -> None
from_list(bbox_list: list[float]) -> BBox staticmethod
Takes a list representation of a BBox in the form

[,,,] or [,,,,,]

Source code in src/qgis_server_light/interface/common.py
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
@staticmethod
def from_list(bbox_list: list[float]) -> "BBox":
    """
    Takes a list representation of a BBox in the form:
        [<x_min>,<y_min>,<x_max>,<y_max>] or
        [<x_min>,<y_min>,<z_min>,<x_max>,<y_max>,<z_max>]
    """
    if len(bbox_list) == 4:
        return BBox(
            x_min=bbox_list[0],
            y_min=bbox_list[1],
            x_max=bbox_list[2],
            y_max=bbox_list[3],
        )
    elif len(bbox_list) == 6:
        return BBox(
            x_min=bbox_list[0],
            y_min=bbox_list[1],
            z_min=bbox_list[2],
            x_max=bbox_list[3],
            y_max=bbox_list[4],
            z_max=bbox_list[5],
        )
    else:
        raise ValueError(f"Invalid bbox list: {bbox_list}")
from_string(bbox_string: str) -> BBox staticmethod
Takes a CSV string representation of a BBox in the form

',,,' or ',,,,,'

Source code in src/qgis_server_light/interface/common.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
@staticmethod
def from_string(bbox_string: str) -> "BBox":
    """
    Takes a CSV string representation of a BBox in the form:
        '<x_min>,<y_min>,<x_max>,<y_max>' or
        '<x_min>,<y_min>,<z_min>,<x_max>,<y_max>,<z_max>'
    """
    coordinates = bbox_string.split(",")
    if len(coordinates) == 4:
        return BBox(
            x_min=float(coordinates[0]),
            y_min=float(coordinates[1]),
            x_max=float(coordinates[2]),
            y_max=float(coordinates[3]),
        )
    elif len(coordinates) == 6:
        return BBox(
            x_min=float(coordinates[0]),
            y_min=float(coordinates[1]),
            z_min=float(coordinates[2]),
            x_max=float(coordinates[3]),
            y_max=float(coordinates[4]),
            z_max=float(coordinates[5]),
        )
    else:
        raise ValueError(f"Invalid bbox string: {bbox_string}")
to_2d_list() -> list
Source code in src/qgis_server_light/interface/common.py
158
159
def to_2d_list(self) -> list:
    return [self.x_min, self.y_min, self.x_max, self.y_max]
to_2d_string() -> str
Source code in src/qgis_server_light/interface/common.py
161
162
def to_2d_string(self) -> str:
    return ",".join([str(item) for item in self.to_2d_list()])
to_list() -> list
Source code in src/qgis_server_light/interface/common.py
152
153
def to_list(self) -> list:
    return [self.x_min, self.y_min, self.z_min, self.x_max, self.y_max, self.z_max]
to_string() -> str
Source code in src/qgis_server_light/interface/common.py
155
156
def to_string(self) -> str:
    return ",".join([str(item) for item in self.to_list()])

BaseInterface dataclass

This class should be used as base class for all dataclasses in the interface. It offers useful methods to handle exposed content in a centralized way. Mainly for logging redaction.

Since dataclasses gets a repr method installed automatically when they are created, a dataclass inheriting from this base class has to be defined as follows:

@dataclass(repr=False)
class Config(BaseInterface):
    id: int = field(metadata={"type": "Element"})
    secure: str = field(metadata={"type": "Element"})
    long_content: str = field(metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"long_content"}

    @property
    def redacted_fields(self) -> set:
        return {"secure"}

This way, when an instance of this example class gets logged somewhere it the output will be redacted, meaning the logging output might look like this:

Config(id=1, secure=**REDACTED**, long_content=abc12...io345)
Source code in src/qgis_server_light/interface/common.py
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
@dataclass
class BaseInterface:
    """
    This class should be used as base class for all dataclasses in the interface. It offers
    useful methods to
    handle exposed content in a centralized way. Mainly for logging redaction.

    Since dataclasses gets a __repr__ method installed automatically when they are
    created, a dataclass
    inheriting from this base class has to be defined as follows:

        @dataclass(repr=False)
        class Config(BaseInterface):
            id: int = field(metadata={"type": "Element"})
            secure: str = field(metadata={"type": "Element"})
            long_content: str = field(metadata={"type": "Element"})

            @property
            def shortened_fields(self) -> set:
                return {"long_content"}

            @property
            def redacted_fields(self) -> set:
                return {"secure"}

    This way, when an instance of this example class gets logged somewhere it the output
    will be redacted,
    meaning the logging output might look like this:

        Config(id=1, secure=**REDACTED**, long_content=abc12...io345)

    """

    @property
    def shorten_limit(self) -> int:
        """
        The limit to which the content of a field should be shortened.

        Returns:
            The limit.
        """
        return 5

    @property
    def redacted_fields(self) -> set:
        """
        Field which contents should get redacted before printing them on the log. This is
        mainly used to
        prevent passwords in logs.

        Returns:
            The set of field names which should be redacted
        """
        return set()

    @property
    def shortened_fields(self) -> set:
        """
        Fields which should be shortened to a length, this is manly useful for large content
        fields with
        BLOB etc.

        Returns:
            The set field names which should be shortened.
        """
        return set()

    def _value_string(self, repr_value: str | bytes):
        return (
            f"{repr_value[: self.shorten_limit]}...{repr_value[((1 + self.shorten_limit) * -1) :]}"
        )

    def _type_aware_value_string(self, value, repr_value):
        value_string = self._value_string(repr_value)
        if type(value) in [str]:
            return f"'{value_string}'"
        else:
            return f"{value_string}"

    def __repr__(self):
        members = []
        cls = self.__class__.__name__
        for obj_field in fields(self):
            # this is the original switch dataclasses allow on fields
            if obj_field.repr:
                value = getattr(self, obj_field.name)
                repr_value = str(value)
                if obj_field.name in self.redacted_fields:
                    members.append(f"{obj_field.name}=**REDACTED**")
                elif (
                    obj_field.name in self.shortened_fields
                    and value is not None
                    and len(repr_value) > self.shorten_limit * 2
                ):
                    members.append(
                        f"{obj_field.name}={self._type_aware_value_string(value, repr_value)}"
                    )
                else:
                    members.append(f"{obj_field.name}={value!r}")
        return f"{cls}({', '.join(members)})"
redacted_fields: set property

Field which contents should get redacted before printing them on the log. This is mainly used to prevent passwords in logs.

Returns:

  • set –

    The set of field names which should be redacted

shorten_limit: int property

The limit to which the content of a field should be shortened.

Returns:

  • int –

    The limit.

shortened_fields: set property

Fields which should be shortened to a length, this is manly useful for large content fields with BLOB etc.

Returns:

  • set –

    The set field names which should be shortened.

__init__() -> None
__repr__()
Source code in src/qgis_server_light/interface/common.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
def __repr__(self):
    members = []
    cls = self.__class__.__name__
    for obj_field in fields(self):
        # this is the original switch dataclasses allow on fields
        if obj_field.repr:
            value = getattr(self, obj_field.name)
            repr_value = str(value)
            if obj_field.name in self.redacted_fields:
                members.append(f"{obj_field.name}=**REDACTED**")
            elif (
                obj_field.name in self.shortened_fields
                and value is not None
                and len(repr_value) > self.shorten_limit * 2
            ):
                members.append(
                    f"{obj_field.name}={self._type_aware_value_string(value, repr_value)}"
                )
            else:
                members.append(f"{obj_field.name}={value!r}")
    return f"{cls}({', '.join(members)})"

Crs dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/common.py
218
219
220
221
222
223
224
225
226
227
228
229
@dataclass(repr=False)
class Crs(BaseInterface):
    auth_id: str = field(default=None, metadata={"type": "Element"})
    postgis_srid: int = field(
        default=None,
        metadata={"type": "Element"},
    )
    ogc_uri: str = field(default=None, metadata={"type": "Element"})
    ogc_urn: str = field(default=None, metadata={"type": "Element"})
    # True when the axis order of the crs is north/east (lat/lon) e.g. EPSG:4326, coordinates
    # written with the URN or URI notation have to be swapped
    axis_inverted: bool = field(default=False, metadata={"type": "Element"})
auth_id: str = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
axis_inverted: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
ogc_uri: str = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
ogc_urn: str = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
postgis_srid: int = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(auth_id: str = None, postgis_srid: int = None, ogc_uri: str = None, ogc_urn: str = None, axis_inverted: bool = False) -> None

RedactedString

This special string class can be used to handle secret strings in the application. It works like a normal string but in case it's used to print or log its value is not reveled to the output.

Source code in src/qgis_server_light/interface/common.py
109
110
111
112
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
class RedactedString:
    """
    This special string class can be used to handle secret strings in the application.
    It works like a normal
    string but in case it's used to print or log its value is not reveled to the output.
    """

    def __init__(self, value, redacted_text="**REDACTED**"):
        self._value = value
        self._redacted_text = redacted_text

    def __str__(self):
        return self._redacted_text

    def __repr__(self):
        return f"<RedactedString {self._redacted_text}>"

    def __format__(self, format_spec):
        return self._redacted_text

    def __json__(self):
        return self._redacted_text

    def reveal(self):
        """
        Allows access to the original value when necessary.

        Returns:
            The secret string.
        """

        return self._value
__format__(format_spec)
Source code in src/qgis_server_light/interface/common.py
126
127
def __format__(self, format_spec):
    return self._redacted_text
__init__(value, redacted_text='**REDACTED**')
Source code in src/qgis_server_light/interface/common.py
116
117
118
def __init__(self, value, redacted_text="**REDACTED**"):
    self._value = value
    self._redacted_text = redacted_text
__json__()
Source code in src/qgis_server_light/interface/common.py
129
130
def __json__(self):
    return self._redacted_text
__repr__()
Source code in src/qgis_server_light/interface/common.py
123
124
def __repr__(self):
    return f"<RedactedString {self._redacted_text}>"
__str__()
Source code in src/qgis_server_light/interface/common.py
120
121
def __str__(self):
    return self._redacted_text
reveal()

Allows access to the original value when necessary.

Returns:

  • –

    The secret string.

Source code in src/qgis_server_light/interface/common.py
132
133
134
135
136
137
138
139
140
def reveal(self):
    """
    Allows access to the original value when necessary.

    Returns:
        The secret string.
    """

    return self._value

Style dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/common.py
232
233
234
235
236
237
238
239
@dataclass(repr=False)
class Style(BaseInterface):
    name: str = field(metadata={"type": "Element"})
    definition: str = field(metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"definition"}
definition: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
__init__(name: str, definition: str) -> None

dispatcher

common

JobState dataclass

The state of a job which keeps its state (see RedisStateProtocol) as it was read from the job hash. It gives the dispatcher one thing to hand over instead of the raw redis fields.

Attributes:

  • id (str) –

    The unique identifier of the job.

  • status (Status) –

    The current status of the job.

  • last_update (str | None) –

    ISO timestamp of the last status change.

  • result (JobResult | None) –

    The result of a succeeded job.

  • message (str | None) –

    The error message of a failed job, or why a dismissed one stopped.

  • progress (int | None) –

    The percentage (0-100) the job reported last, None if it reported none (yet).

Source code in src/qgis_server_light/interface/dispatcher/common.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@dataclass
class JobState:
    """The state of a job which keeps its state (see `RedisStateProtocol`) as
    it was read from the job hash. It gives the dispatcher one thing to hand
    over instead of the raw redis fields.

    Attributes:
        id: The unique identifier of the job.
        status: The current status of the job.
        last_update: ISO timestamp of the last status change.
        result: The result of a succeeded job.
        message: The error message of a failed job, or why a dismissed one stopped.
        progress: The percentage (0-100) the job reported last, `None` if it
            reported none (yet).
    """

    id: str = field(metadata={"type": "Element"})
    status: Status = field(metadata={"type": "Element"})
    last_update: str | None = field(default=None, metadata={"type": "Element"})
    result: JobResult | None = field(default=None, metadata={"type": "Element"})
    message: str | None = field(default=None, metadata={"type": "Element"})
    progress: int | None = field(default=None, metadata={"type": "Element"})

    @property
    def finished(self) -> bool:
        """If the job reached a final status, nothing changes on it anymore."""
        return self.status in (Status.SUCCESS, Status.FAILURE, Status.DISMISSED)
finished: bool property

If the job reached a final status, nothing changes on it anymore.

id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
last_update: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
message: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
progress: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
result: JobResult | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
status: Status = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, status: Status, last_update: str | None = None, result: JobResult | None = None, message: str | None = None, progress: int | None = None) -> None
Status

Bases: Enum

Source code in src/qgis_server_light/interface/dispatcher/common.py
 9
10
11
12
13
14
class Status(Enum):
    SUCCESS = "succeed"
    FAILURE = "failed"
    RUNNING = "running"
    QUEUED = "queued"
    DISMISSED = "dismissed"
DISMISSED = 'dismissed' class-attribute instance-attribute
FAILURE = 'failed' class-attribute instance-attribute
QUEUED = 'queued' class-attribute instance-attribute
RUNNING = 'running' class-attribute instance-attribute
SUCCESS = 'succeed' class-attribute instance-attribute
Worker dataclass

A worker the dispatcher has seen alive on the queue. It carries what a consumer needs to tell whether jobs can be served and what the worker is doing right now.

Attributes:

  • id (str) –

    The unique identifier of the worker.

  • last_seen (datetime) –

    The time of the last heartbeat of the worker, always timezone aware.

  • info (EngineInfo) –

    The info the worker published with its last heartbeat (status, QGIS version, start time).

Source code in src/qgis_server_light/interface/dispatcher/common.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@dataclass
class Worker:
    """A worker the dispatcher has seen alive on the queue. It carries what a
    consumer needs to tell whether jobs can be served and what the worker is doing
    right now.

    Attributes:
        id: The unique identifier of the worker.
        last_seen: The time of the last heartbeat of the worker, always timezone aware.
        info: The info the worker published with its last heartbeat (status, QGIS
            version, start time).
    """

    id: str
    last_seen: datetime
    info: EngineInfo
id: str instance-attribute
info: EngineInfo instance-attribute
last_seen: datetime instance-attribute
__init__(id: str, last_seen: datetime, info: EngineInfo) -> None

protocol

This contains the protocol definition about how a job is passed around a redis queue. It is shared by the dispatcher and the worker and therefore must not depend on anything else than the standard library.

RedisProtocol

Names of the redis queue, the job hash fields and the notification channel a job is exchanged with. It is the common ground of both ways a job result is delivered, the concrete queue is defined by the subclasses RedisPublishProtocol and RedisStateProtocol.

A job is put into redis as hash under job:{id} (see job_key) and its id is pushed onto the list returned by queue_name. A worker listens on the queue of the protocol it is built on. The hash holds the fields:

  • info: The job info serialized as JSON.
  • info_type: The class name of the job info, used to parse info.
  • status: The current Status value of the job.
  • timestamp.{status}: ISO timestamp when the job entered that status.
  • timestamp.last_update: ISO timestamp of the last status change.
  • duration: Seconds since the job was posted, as string.

The channel notifications:{id} (see channel) is used to tell a waiting dispatcher that the job is finished. What is sent over it depends on the subclass.

A worker registers itself as hash under worker:{id} (see worker_key) and adds its id to the set worker_list_name. The hash holds the fields:

  • info: The engine info serialized as JSON.
  • last_seen: ISO timestamp (UTC) of the last heartbeat.
  • processes: The descriptions of the processes a process-worker serves (ProcessDescriptions) as JSON, only written by process-workers.

Attributes:

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
class RedisProtocol:
    """Names of the redis queue, the job hash fields and the notification
    channel a job is exchanged with. It is the common ground of both ways a
    job result is delivered, the concrete queue is defined by the subclasses
    `RedisPublishProtocol` and `RedisStateProtocol`.

    A job is put into redis as hash under `job:{id}` (see `job_key`) and its
    id is pushed onto the list returned by `queue_name`. A worker listens on
    the queue of the protocol it is built on. The hash holds the fields:

    - `info`: The job info serialized as JSON.
    - `info_type`: The class name of the job info, used to parse `info`.
    - `status`: The current `Status` value of the job.
    - `timestamp.{status}`: ISO timestamp when the job entered that status.
    - `timestamp.last_update`: ISO timestamp of the last status change.
    - `duration`: Seconds since the job was posted, as string.

    The channel `notifications:{id}` (see `channel`) is used to tell a waiting
    dispatcher that the job is finished. What is sent over it depends on the
    subclass.

    A worker registers itself as hash under `worker:{id}` (see `worker_key`) and
    adds its id to the set `worker_list_name`. The hash holds the fields:

    - `info`: The engine info serialized as JSON.
    - `last_seen`: ISO timestamp (UTC) of the last heartbeat.
    - `processes`: The descriptions of the processes a process-worker serves
      (`ProcessDescriptions`) as JSON, only written by process-workers.

    Attributes:
        job_queue_name: The name of the redis list the ids of the jobs are
            queued on. Set by the subclasses.
        job_info_key: The hash field holding the serialized job info.
        job_info_type_key: The hash field holding the class name of the job info.
        job_channel_name: The prefix of the channel a finished job is notified on.
        job_status_key: The hash field holding the job status.
        job_duration_key: The hash field holding the job duration.
        job_timestamp_key: The prefix of the hash fields holding the timestamps.
        job_last_update_key: The hash field holding the timestamp of the last update.
        worker_list_name: The name of the redis set the worker ids are registered in.
        worker_info_key: The hash field holding the serialized engine info.
        worker_last_seen_key: The hash field holding the timestamp of the last heartbeat.
        worker_heartbeat_interval: Seconds between two heartbeats of a worker.
        worker_alive_age: Seconds a heartbeat may be old for the worker to count as alive.
        worker_processes_key: The hash field holding the descriptions of the processes
            the worker serves.
    """

    job_queue_name: str
    job_info_key: str = "info"
    job_info_type_key: str = "info_type"
    job_channel_name: str = "notifications"
    job_status_key: str = "status"
    job_duration_key: str = "duration"
    job_timestamp_key: str = "timestamp"
    job_last_update_key: str = f"{job_timestamp_key}.last_update"
    worker_list_name: str = "workers"
    worker_info_key: str = "info"
    worker_last_seen_key: str = "last_seen"
    worker_heartbeat_interval: int = 1
    worker_alive_age: int = 10 * worker_heartbeat_interval
    worker_processes_key: str = "processes"

    @staticmethod
    def job_key(job_id: str) -> str:
        """The key of the redis hash holding the job.

        Args:
            job_id: The unique identifier of the job.
        """
        return f"job:{job_id}"

    @classmethod
    def queue_name(cls) -> str:
        """The name of the queue the jobs of this protocol are queued on. It is
        a method on purpose, so the place where the name is decided stays the
        same if it ever needs to be assembled."""
        return cls.job_queue_name

    @classmethod
    def channel(cls, job_id: str) -> str:
        """The channel a finished job is notified on.

        Args:
            job_id: The unique identifier of the job.
        """
        return f"{cls.job_channel_name}:{job_id}"

    @staticmethod
    def worker_key(worker_id: str) -> str:
        """The key of the redis hash holding the worker registration.

        Args:
            worker_id: The unique identifier of the worker.
        """
        return f"worker:{worker_id}"
job_channel_name: str = 'notifications' class-attribute instance-attribute
job_duration_key: str = 'duration' class-attribute instance-attribute
job_info_key: str = 'info' class-attribute instance-attribute
job_info_type_key: str = 'info_type' class-attribute instance-attribute
job_last_update_key: str = f'{job_timestamp_key}.last_update' class-attribute instance-attribute
job_queue_name: str instance-attribute
job_status_key: str = 'status' class-attribute instance-attribute
job_timestamp_key: str = 'timestamp' class-attribute instance-attribute
worker_alive_age: int = 10 * worker_heartbeat_interval class-attribute instance-attribute
worker_heartbeat_interval: int = 1 class-attribute instance-attribute
worker_info_key: str = 'info' class-attribute instance-attribute
worker_last_seen_key: str = 'last_seen' class-attribute instance-attribute
worker_list_name: str = 'workers' class-attribute instance-attribute
worker_processes_key: str = 'processes' class-attribute instance-attribute
channel(job_id: str) -> str classmethod

The channel a finished job is notified on.

Parameters:

  • job_id (str) –

    The unique identifier of the job.

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
87
88
89
90
91
92
93
94
@classmethod
def channel(cls, job_id: str) -> str:
    """The channel a finished job is notified on.

    Args:
        job_id: The unique identifier of the job.
    """
    return f"{cls.job_channel_name}:{job_id}"
job_key(job_id: str) -> str staticmethod

The key of the redis hash holding the job.

Parameters:

  • job_id (str) –

    The unique identifier of the job.

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
71
72
73
74
75
76
77
78
@staticmethod
def job_key(job_id: str) -> str:
    """The key of the redis hash holding the job.

    Args:
        job_id: The unique identifier of the job.
    """
    return f"job:{job_id}"
queue_name() -> str classmethod

The name of the queue the jobs of this protocol are queued on. It is a method on purpose, so the place where the name is decided stays the same if it ever needs to be assembled.

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
80
81
82
83
84
85
@classmethod
def queue_name(cls) -> str:
    """The name of the queue the jobs of this protocol are queued on. It is
    a method on purpose, so the place where the name is decided stays the
    same if it ever needs to be assembled."""
    return cls.job_queue_name
worker_key(worker_id: str) -> str staticmethod

The key of the redis hash holding the worker registration.

Parameters:

  • worker_id (str) –

    The unique identifier of the worker.

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
 96
 97
 98
 99
100
101
102
103
@staticmethod
def worker_key(worker_id: str) -> str:
    """The key of the redis hash holding the worker registration.

    Args:
        worker_id: The unique identifier of the worker.
    """
    return f"worker:{worker_id}"
RedisPublishProtocol

Bases: RedisProtocol

The protocol of short living jobs a dispatcher waits for, like rendering a map or a legend. The worker publishes the pickled JobResult over the channel and the dispatcher deletes the job hash after it has received it. Nothing is kept, a result is only there for the one who is listening.

Attributes:

  • job_queue_name (str) –

    The name of the redis list the ids of the jobs are queued on.

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
106
107
108
109
110
111
112
113
114
115
116
117
118
class RedisPublishProtocol(RedisProtocol):
    """The protocol of short living jobs a dispatcher waits for, like
    rendering a map or a legend. The worker publishes the pickled `JobResult`
    over the channel and the dispatcher deletes the job hash after it has
    received it. Nothing is kept, a result is only there for the one who is
    listening.

    Attributes:
        job_queue_name: The name of the redis list the ids of the jobs are
            queued on.
    """

    job_queue_name: str = "jobs"
job_queue_name: str = 'jobs' class-attribute instance-attribute
RedisStateProtocol

Bases: RedisProtocol

The protocol of jobs which keep their state, these are the processes. The worker writes the result (or the error message) into the job hash in the same transaction as the final status, so whoever reads the hash never sees a finished job without its result. The hash expires after job_expire seconds, it is the only place the result lives.

Only the status value is sent over the channel and only if the job was submitted with ExecutionMode.SYNC. It just wakes the waiting dispatcher, which then reads the job hash. Asynchronous jobs are polled, nobody waits for a notification there.

Processes are queued on their own list, so long-running processes never block map related jobs.

Additional hash fields:

  • result: The data of the JobResult of a succeeded job.
  • result_content_type: The content type of result.
  • message: The error message of a failed job.
  • progress: The percentage (0-100) the running job reported, only if it reports any. It is written while the job runs, outside the transaction.
  • cancel: Set by the dispatcher to dismiss a job the worker took already. The worker cancels the job and finishes it as dismissed.

Attributes:

  • job_queue_name (str) –

    The name of the redis list the ids of the jobs are queued on.

  • job_result_key (str) –

    The hash field holding the result data.

  • job_result_content_type_key (str) –

    The hash field holding the content type of the result data.

  • job_message_key (str) –

    The hash field holding the error message.

  • job_progress_key (str) –

    The hash field holding the progress in percent.

  • job_cancel_key (str) –

    The hash field asking the worker to cancel the job.

  • job_expire (int) –

    Seconds the job hash is kept after it was submitted and again after it is finished.

Source code in src/qgis_server_light/interface/dispatcher/protocol.py
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
class RedisStateProtocol(RedisProtocol):
    """The protocol of jobs which keep their state, these are the processes.
    The worker writes the result (or the error message) into the job hash in
    the same transaction as the final status, so whoever reads the hash never
    sees a finished job without its result. The hash expires after
    `job_expire` seconds, it is the only place the result lives.

    Only the status value is sent over the channel and only if the job was
    submitted with `ExecutionMode.SYNC`. It just wakes the waiting dispatcher,
    which then reads the job hash. Asynchronous jobs are polled, nobody waits
    for a notification there.

    Processes are queued on their own list, so long-running processes never
    block map related jobs.

    Additional hash fields:

    - `result`: The data of the `JobResult` of a succeeded job.
    - `result_content_type`: The content type of `result`.
    - `message`: The error message of a failed job.
    - `progress`: The percentage (0-100) the running job reported, only if it
      reports any. It is written while the job runs, outside the transaction.
    - `cancel`: Set by the dispatcher to dismiss a job the worker took already.
      The worker cancels the job and finishes it as `dismissed`.

    Attributes:
        job_queue_name: The name of the redis list the ids of the jobs are
            queued on.
        job_result_key: The hash field holding the result data.
        job_result_content_type_key: The hash field holding the content type
            of the result data.
        job_message_key: The hash field holding the error message.
        job_progress_key: The hash field holding the progress in percent.
        job_cancel_key: The hash field asking the worker to cancel the job.
        job_expire: Seconds the job hash is kept after it was submitted and
            again after it is finished.
    """

    job_queue_name: str = "jobs:process"
    job_result_key: str = "result"
    job_result_content_type_key: str = "result_content_type"
    job_message_key: str = "message"
    job_progress_key: str = "progress"
    job_cancel_key: str = "cancel"
    job_expire: int = 86400
job_cancel_key: str = 'cancel' class-attribute instance-attribute
job_expire: int = 86400 class-attribute instance-attribute
job_message_key: str = 'message' class-attribute instance-attribute
job_progress_key: str = 'progress' class-attribute instance-attribute
job_queue_name: str = 'jobs:process' class-attribute instance-attribute
job_result_content_type_key: str = 'result_content_type' class-attribute instance-attribute
job_result_key: str = 'result' class-attribute instance-attribute

exporter

api

ExportParameters dataclass

Bases: BaseInterface

The serializable request parameters which are accepted by the exporter service.

Source code in src/qgis_server_light/interface/exporter/api.py
 6
 7
 8
 9
10
11
12
13
14
@dataclass(repr=False)
class ExportParameters(BaseInterface):
    """
    The serializable request parameters which are accepted by the exporter service.
    """

    project_path: str = field(metadata={"type": "Element"})
    unify_layer_names_by_group: bool = field(metadata={"type": "Element"}, default=False)
    output_format: str = field(metadata={"type": "Element"}, default="json")
output_format: str = field(metadata={'type': 'Element'}, default='json') class-attribute instance-attribute
project_path: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
unify_layer_names_by_group: bool = field(metadata={'type': 'Element'}, default=False) class-attribute instance-attribute
__init__(project_path: str, unify_layer_names_by_group: bool = False, output_format: str = 'json') -> None
ExportResult dataclass

Bases: BaseInterface

The serializable response which is provided by the exporter service.

Source code in src/qgis_server_light/interface/exporter/api.py
17
18
19
20
21
22
23
24
@dataclass(repr=False)
class ExportResult(BaseInterface):
    """
    The serializable response which is provided by the exporter service.
    """

    successful: bool = field(metadata={"type": "Element"})
    content: str = field(metadata={"type": "Element"})
content: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
successful: bool = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(successful: bool, content: str) -> None

extract

This module contains all interface definition to translate from QGIS project to QGIS-Server-Light logic and to write the JSON export of the QGIS project

AbstractDataset dataclass

Bases: LayerLike

Source code in src/qgis_server_light/interface/exporter/extract.py
222
223
224
@dataclass(repr=False)
class AbstractDataset(LayerLike):
    title: str = field(metadata={"type": "Element"})
title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, is_checked: bool, title: str) -> None
Config dataclass

Bases: ResultWithMessages

Source code in src/qgis_server_light/interface/exporter/extract.py
951
952
953
954
955
956
957
958
959
@dataclass(repr=False)
class Config(ResultWithMessages):
    meta_data: MetaData = field(metadata={"type": "Element"})
    tree: Tree = field(metadata={"type": "Element"})
    datasets: Datasets = field(metadata={"type": "Element"})
    relations: list[Relation] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
datasets: Datasets = field(metadata={'type': 'Element'}) class-attribute instance-attribute
meta_data: MetaData = field(metadata={'type': 'Element'}) class-attribute instance-attribute
relations: list[Relation] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
tree: Tree = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(project: Project, exporter: Exporter, meta_data: MetaData, tree: Tree, datasets: Datasets, relations: list[Relation] = list(), *, messages: list[ExportMessage] = list()) -> None
Custom dataclass

Bases: DataSet

Source code in src/qgis_server_light/interface/exporter/extract.py
707
708
709
@dataclass(repr=False)
class Custom(DataSet):
    pass
__init__(id: str, name: str, is_checked: bool, title: str, source: DataSource, driver: str, bbox: BBox | None = None, bbox_wgs84: BBox | None = None, crs: Crs | None = None, styles: list[Style] = list(), minimum_scale: float | None = None, maximum_scale: float | None = None, style_name: str = 'default', is_spatial: bool = True, is_background: bool = False) -> None
DataSet dataclass

Bases: AbstractDataset

Source code in src/qgis_server_light/interface/exporter/extract.py
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
@dataclass(repr=False)
class DataSet(AbstractDataset):
    source: DataSource = field(metadata={"type": "Element"})
    driver: str = field(metadata={"type": "Element"})
    bbox: BBox | None = field(default=None, metadata={"type": "Element"})
    bbox_wgs84: BBox | None = field(default=None, metadata={"type": "Element"})
    crs: Crs | None = field(default=None, metadata={"type": "Element"})
    styles: list[Style] = field(default_factory=list, metadata={"type": "Element"})
    minimum_scale: float | None = field(default=None, metadata={"type": "Element"})
    maximum_scale: float | None = field(default=None, metadata={"type": "Element"})
    style_name: str = field(default="default", metadata={"type": "Element"})
    is_spatial: bool = field(default=True, metadata={"type": "Element"})
    is_background: bool = field(default=False, metadata={"type": "Element"})

    def get_style_by_name(self, name: str) -> Style | None:
        for style in self.styles:
            if name == style.name:
                return style
        return None

    def style(self) -> Style | None:
        return self.get_style_by_name(self.style_name)
bbox: BBox | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
bbox_wgs84: BBox | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
crs: Crs | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
driver: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
is_background: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
is_spatial: bool = field(default=True, metadata={'type': 'Element'}) class-attribute instance-attribute
maximum_scale: float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
minimum_scale: float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
source: DataSource = field(metadata={'type': 'Element'}) class-attribute instance-attribute
style_name: str = field(default='default', metadata={'type': 'Element'}) class-attribute instance-attribute
styles: list[Style] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, is_checked: bool, title: str, source: DataSource, driver: str, bbox: BBox | None = None, bbox_wgs84: BBox | None = None, crs: Crs | None = None, styles: list[Style] = list(), minimum_scale: float | None = None, maximum_scale: float | None = None, style_name: str = 'default', is_spatial: bool = True, is_background: bool = False) -> None
get_style_by_name(name: str) -> Style | None
Source code in src/qgis_server_light/interface/exporter/extract.py
660
661
662
663
664
def get_style_by_name(self, name: str) -> Style | None:
    for style in self.styles:
        if name == style.name:
            return style
    return None
style() -> Style | None
Source code in src/qgis_server_light/interface/exporter/extract.py
666
667
def style(self) -> Style | None:
    return self.get_style_by_name(self.style_name)
DataSource dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
@dataclass(repr=False)
class DataSource(BaseInterface):
    postgres: PostgresSource | None = field(default=None, metadata={"type": "Element"})
    wmts: WmtsSource | None = field(default=None, metadata={"type": "Element"})
    wms: WmsSource | None = field(default=None, metadata={"type": "Element"})
    ogr: OgrSource | None = field(default=None, metadata={"type": "Element"})
    gdal: GdalSource | None = field(default=None, metadata={"type": "Element"})
    wfs: WfsSource | None = field(default=None, metadata={"type": "Element"})
    vector_tile: VectorTileSource | None = field(default=None, metadata={"type": "Element"})
    xyz: XYZSource | None = field(default=None, metadata={"type": "Element"})
    wcs: WcsSource | None = field(default=None, metadata={"type": "Element"})

    @property
    def definition(
        self,
    ) -> (
        PostgresSource
        | WmtsSource
        | WmsSource
        | OgrSource
        | GdalSource
        | WfsSource
        | VectorTileSource
        | XYZSource
        | WcsSource
        | None
    ):
        for dataclass_field in fields(self):
            name = dataclass_field.name
            value = getattr(self, name)
            if value:
                return value
        logging.error(f"No source was definied at {self.__class__.__name__}, this is not expected")
        return None
definition: PostgresSource | WmtsSource | WmsSource | OgrSource | GdalSource | WfsSource | VectorTileSource | XYZSource | WcsSource | None property
gdal: GdalSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
ogr: OgrSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
postgres: PostgresSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
vector_tile: VectorTileSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
wcs: WcsSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
wfs: WfsSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
wms: WmsSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
wmts: WmtsSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
xyz: XYZSource | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(postgres: PostgresSource | None = None, wmts: WmtsSource | None = None, wms: WmsSource | None = None, ogr: OgrSource | None = None, gdal: GdalSource | None = None, wfs: WfsSource | None = None, vector_tile: VectorTileSource | None = None, xyz: XYZSource | None = None, wcs: WcsSource | None = None) -> None
Datasets dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
@dataclass(repr=False)
class Datasets(BaseInterface):
    vector: list[Vector] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    raster: list[Raster] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    custom: list[Custom] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    group: list[Group] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )

    def find_dataset_by_id(self, id: str) -> Vector | Raster | Custom | None:
        """
        Finds a dataset by id in the list of passed datasets.

        Args:
            id: The id value which should be looked up

        Returns:
            The found dataset or None
        """
        for dataset in self.vector + self.raster + self.custom:
            if dataset.id == id:
                return dataset
        return None

    def find_group_by_id(self, identifier: str) -> Group | None:
        for g in self.group:
            if g.id == identifier:
                return g
        return None
custom: list[Custom] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
group: list[Group] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
raster: list[Raster] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
vector: list[Vector] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(vector: list[Vector] = list(), raster: list[Raster] = list(), custom: list[Custom] = list(), group: list[Group] = list()) -> None
find_dataset_by_id(id: str) -> Vector | Raster | Custom | None

Finds a dataset by id in the list of passed datasets.

Parameters:

  • id (str) –

    The id value which should be looked up

Returns:

Source code in src/qgis_server_light/interface/exporter/extract.py
831
832
833
834
835
836
837
838
839
840
841
842
843
844
def find_dataset_by_id(self, id: str) -> Vector | Raster | Custom | None:
    """
    Finds a dataset by id in the list of passed datasets.

    Args:
        id: The id value which should be looked up

    Returns:
        The found dataset or None
    """
    for dataset in self.vector + self.raster + self.custom:
        if dataset.id == id:
            return dataset
    return None
find_group_by_id(identifier: str) -> Group | None
Source code in src/qgis_server_light/interface/exporter/extract.py
846
847
848
849
850
def find_group_by_id(self, identifier: str) -> Group | None:
    for g in self.group:
        if g.id == identifier:
            return g
    return None
EditorWidget dataclass

Bases: BaseInterface

Holds the configuration of the editor widget of a field. Only one of the attributes is set, matching Field.editor_widget_type.

Source code in src/qgis_server_light/interface/exporter/extract.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
@dataclass(repr=False)
class EditorWidget(BaseInterface):
    """
    Holds the configuration of the editor widget of a field. Only one of the
    attributes is set, matching `Field.editor_widget_type`.
    """

    value_map: ValueMap | None = field(default=None, metadata={"type": "Element"})
    value_relation: ValueRelation | None = field(default=None, metadata={"type": "Element"})
    relation_reference: RelationReference | None = field(default=None, metadata={"type": "Element"})
    range: Range | None = field(default=None, metadata={"type": "Element"})

    @property
    def definition(self) -> ValueMap | ValueRelation | RelationReference | Range | None:
        for dataclass_field in fields(self):
            value = getattr(self, dataclass_field.name)
            if value:
                return value
        logging.error(
            f"No configuration was defined at {self.__class__.__name__}, this is not expected"
        )
        return None
definition: ValueMap | ValueRelation | RelationReference | Range | None property
range: Range | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
relation_reference: RelationReference | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
value_map: ValueMap | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
value_relation: ValueRelation | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(value_map: ValueMap | None = None, value_relation: ValueRelation | None = None, relation_reference: RelationReference | None = None, range: Range | None = None) -> None
ExportMessage dataclass

Bases: BaseInterface

A warning or error produced while exporting the QGIS project.

Source code in src/qgis_server_light/interface/exporter/extract.py
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
@dataclass(repr=False)
class ExportMessage(BaseInterface):
    """A warning or error produced while exporting the QGIS project."""

    class Level(StrEnum):
        WARNING = "warning"
        ERROR = "error"

    class Code(StrEnum):
        PROJECT_READ_FAILED = "project_read_failed"
        PROJECT_VERSION_UNSUPPORTED = "project_version_unsupported"
        TREE_NODE_UNSUPPORTED = "tree_node_unsupported"
        LAYER_INVALID = "layer_invalid"
        LAYER_EMPTY = "layer_empty"
        LAYER_EXTENT_MISSING = "layer_extent_missing"
        LAYER_EXTENT_FROM_PROJECT = "layer_extent_from_project"
        LAYER_EXTENT_REPROJECTION_FAILED = "layer_extent_reprojection_failed"
        LAYER_PROVIDER_UNSUPPORTED = "layer_provider_unsupported"
        LAYER_TYPE_UNSUPPORTED = "layer_type_unsupported"
        FIELD_EDITOR_WIDGET_TYPE_UNSUPPORTED = "field_editor_widget_type_unsupported"
        UNEXPECTED_ERROR = "unexpected_error"

    level: Level = field(metadata={"type": "Element"})
    message: str = field(metadata={"type": "Element"})
    code: Code = field(metadata={"type": "Element"})
    layer_id: str | None = field(default=None, metadata={"type": "Element"})
code: Code = field(metadata={'type': 'Element'}) class-attribute instance-attribute
layer_id: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
level: Level = field(metadata={'type': 'Element'}) class-attribute instance-attribute
message: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
Code

Bases: StrEnum

Source code in src/qgis_server_light/interface/exporter/extract.py
906
907
908
909
910
911
912
913
914
915
916
917
918
class Code(StrEnum):
    PROJECT_READ_FAILED = "project_read_failed"
    PROJECT_VERSION_UNSUPPORTED = "project_version_unsupported"
    TREE_NODE_UNSUPPORTED = "tree_node_unsupported"
    LAYER_INVALID = "layer_invalid"
    LAYER_EMPTY = "layer_empty"
    LAYER_EXTENT_MISSING = "layer_extent_missing"
    LAYER_EXTENT_FROM_PROJECT = "layer_extent_from_project"
    LAYER_EXTENT_REPROJECTION_FAILED = "layer_extent_reprojection_failed"
    LAYER_PROVIDER_UNSUPPORTED = "layer_provider_unsupported"
    LAYER_TYPE_UNSUPPORTED = "layer_type_unsupported"
    FIELD_EDITOR_WIDGET_TYPE_UNSUPPORTED = "field_editor_widget_type_unsupported"
    UNEXPECTED_ERROR = "unexpected_error"
FIELD_EDITOR_WIDGET_TYPE_UNSUPPORTED = 'field_editor_widget_type_unsupported' class-attribute instance-attribute
LAYER_EMPTY = 'layer_empty' class-attribute instance-attribute
LAYER_EXTENT_FROM_PROJECT = 'layer_extent_from_project' class-attribute instance-attribute
LAYER_EXTENT_MISSING = 'layer_extent_missing' class-attribute instance-attribute
LAYER_EXTENT_REPROJECTION_FAILED = 'layer_extent_reprojection_failed' class-attribute instance-attribute
LAYER_INVALID = 'layer_invalid' class-attribute instance-attribute
LAYER_PROVIDER_UNSUPPORTED = 'layer_provider_unsupported' class-attribute instance-attribute
LAYER_TYPE_UNSUPPORTED = 'layer_type_unsupported' class-attribute instance-attribute
PROJECT_READ_FAILED = 'project_read_failed' class-attribute instance-attribute
PROJECT_VERSION_UNSUPPORTED = 'project_version_unsupported' class-attribute instance-attribute
TREE_NODE_UNSUPPORTED = 'tree_node_unsupported' class-attribute instance-attribute
UNEXPECTED_ERROR = 'unexpected_error' class-attribute instance-attribute
Level

Bases: StrEnum

Source code in src/qgis_server_light/interface/exporter/extract.py
902
903
904
class Level(StrEnum):
    WARNING = "warning"
    ERROR = "error"
ERROR = 'error' class-attribute instance-attribute
WARNING = 'warning' class-attribute instance-attribute
__init__(level: Level, message: str, code: Code, layer_id: str | None = None) -> None
Exporter dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
893
894
895
@dataclass(repr=False)
class Exporter(BaseInterface):
    qgis_version: str = field(metadata={"type": "Element"})
qgis_version: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(qgis_version: str) -> None
Field dataclass

Bases: BaseInterface

Transportable (serializable) form of a QGIS vector job_layer_definition fiel (attribute). It contains the information of the original data datatype and its translated versions and the editor widget one as well.

Attributes:

Source code in src/qgis_server_light/interface/exporter/extract.py
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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
@dataclass(repr=False)
class Field(BaseInterface):
    """
    Transportable (serializable) form of a QGIS vector job_layer_definition fiel (attribute).
    It contains the information of
    the original data datatype and its translated versions and the editor widget one as well.

    Attributes:
        name: Machine readable name of the field
        type: Original type as defined by data source (PostGIS, GPKG, etc.)
        is_primary_key: if the field is considered to be primary key.
        is_generated: if the value of the primary key is generated by the source on insert.
        type_wfs: Translated type for further usage. Based on the simple types of
            [XSD spec](https://www.w3.org/TR/xmlschema11-2/#built-in-primitive-datatypes).
        type_oapif: Translated type based on the types of the
            [OpenAPI Spec](https://spec.openapis.org/oas/latest.html#data-types)
        type_oapif_format: Format of the above-mentioned type based on the
            [OpenAPI Spec](https://spec.openapis.org/oas/latest.html#data-types)
        alias: Human readable name.
        comment: Field description.
        nullable: If this field can be NULL or not.
        length: The limitation in length on the field value.
        precision: The precision of the field value (float types)
        editor_widget_type: The original type how it is defined in the QGIS form.
        editor_widget_type_wfs: The translated type based on the simple types of
            [XSD spec](https://www.w3.org/TR/xmlschema11-2/#built-in-primitive-datatypes).
        editor_widget_type_oapif: Translated type based on the types of the
            [OpenAPI Spec](https://spec.openapis.org/oas/latest.html#data-types)
        editor_widget_type_oapif_format: Format of the above-mentioned type based on the
            [OpenAPI Spec](https://spec.openapis.org/oas/latest.html#data-types)
        editor_widget: The configuration of the editor widget. None if the widget type
            is not one of the exported ones.
        constraints: The constraints of the field. None for exports which did not
            contain constraints yet.
    """

    name: str = field(metadata={"type": "Element"})
    type: str = field(metadata={"type": "Element"})
    is_primary_key: bool = field(
        default=False,
        metadata={"type": "Element"},
    )
    is_generated: bool = field(
        default=False,
        metadata={"type": "Element"},
    )
    type_wfs: str | None = field(default=None, metadata={"type": "Element"})
    type_oapif: str | None = field(default=None, metadata={"type": "Element"})
    type_oapif_format: str | None = field(default=None, metadata={"type": "Element"})
    alias: str | None = field(default=None, metadata={"type": "Element"})
    comment: str | None = field(default=None, metadata={"type": "Element"})
    nullable: bool = field(default=True, metadata={"type": "Element"})
    length: int | None = field(default=None, metadata={"type": "Element"})
    precision: int | None = field(default=None, metadata={"type": "Element"})
    editor_widget_type: str | None = field(default=None, metadata={"type": "Element"})
    editor_widget_type_wfs: str | None = field(default=None, metadata={"type": "Element"})
    editor_widget_type_oapif: str | None = field(default=None, metadata={"type": "Element"})
    editor_widget_type_oapif_format: str | None = field(default=None, metadata={"type": "Element"})
    editor_widget: EditorWidget | None = field(default=None, metadata={"type": "Element"})
    constraints: FieldConstraints | None = field(default=None, metadata={"type": "Element"})
alias: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
comment: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
constraints: FieldConstraints | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
editor_widget: EditorWidget | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
editor_widget_type: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
editor_widget_type_oapif: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
editor_widget_type_oapif_format: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
editor_widget_type_wfs: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
is_generated: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
is_primary_key: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
length: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
nullable: bool = field(default=True, metadata={'type': 'Element'}) class-attribute instance-attribute
precision: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
type: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
type_oapif: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
type_oapif_format: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
type_wfs: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(name: str, type: str, is_primary_key: bool = False, is_generated: bool = False, type_wfs: str | None = None, type_oapif: str | None = None, type_oapif_format: str | None = None, alias: str | None = None, comment: str | None = None, nullable: bool = True, length: int | None = None, precision: int | None = None, editor_widget_type: str | None = None, editor_widget_type_wfs: str | None = None, editor_widget_type_oapif: str | None = None, editor_widget_type_oapif_format: str | None = None, editor_widget: EditorWidget | None = None, constraints: FieldConstraints | None = None) -> None
FieldConstraints dataclass

Bases: BaseInterface

The constraints of a field as defined in QGIS (provider or layer).

Attributes:

  • not_null (bool) –

    If the field must not be NULL.

  • unique (bool) –

    If the field value must be unique.

  • expression (str | None) –

    The QGIS expression the field value has to fulfill.

Source code in src/qgis_server_light/interface/exporter/extract.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@dataclass(repr=False)
class FieldConstraints(BaseInterface):
    """
    The constraints of a field as defined in QGIS (provider or layer).

    Attributes:
        not_null: If the field must not be NULL.
        unique: If the field value must be unique.
        expression: The QGIS expression the field value has to fulfill.
    """

    not_null: bool = field(default=False, metadata={"type": "Element"})
    unique: bool = field(default=False, metadata={"type": "Element"})
    expression: str | None = field(default=None, metadata={"type": "Element"})
expression: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
not_null: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
unique: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(not_null: bool = False, unique: bool = False, expression: str | None = None) -> None
GdalSource dataclass

Bases: Source

Source code in src/qgis_server_light/interface/exporter/extract.py
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
@dataclass(repr=False)
class GdalSource(Source):
    path: str = field(metadata={"type": "Element"})
    layer_name: str | None = field(default=None, metadata={"type": "Element"})
    vsi_prefix: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def remote(self):
        return self.decide_remote(self.path)

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = {"path": self.path}
        if self.layer_name is not None:
            connection_dict["layerName"] = self.layer_name
        if self.vsi_prefix is not None:
            connection_dict["vsiPrefix"] = self.vsi_prefix
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        return cls(
            path=decoded_uri["path"],
            layer_name=decoded_uri.get("layerName"),
            vsi_prefix=decoded_uri.get("vsiPrefix"),
        )
layer_name: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
path: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
remote property
to_qgis_decoded_uri: dict property
vsi_prefix: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(path: str, layer_name: str | None = None, vsi_prefix: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
265
266
267
268
269
270
271
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    return cls(
        path=decoded_uri["path"],
        layer_name=decoded_uri.get("layerName"),
        vsi_prefix=decoded_uri.get("vsiPrefix"),
    )
Group dataclass

Bases: AbstractDataset

Holds meta information of a group. It's position in the tree and its children can be derived by id matching.

Source code in src/qgis_server_light/interface/exporter/extract.py
712
713
714
715
716
717
@dataclass(repr=False)
class Group(AbstractDataset):
    """Holds meta information of a group. It's position in the tree and its children can
    be derived by id matching."""

    is_expanded: bool = field(metadata={"type": "Element"})
is_expanded: bool = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, is_checked: bool, title: str, is_expanded: bool) -> None
LayerLike dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
16
17
18
19
20
@dataclass(repr=False)
class LayerLike(BaseInterface):
    id: str = field(metadata={"type": "Element"})
    name: str = field(metadata={"type": "Element"})
    is_checked: bool = field(metadata={"type": "Element"})
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
is_checked: bool = field(metadata={'type': 'Element'}) class-attribute instance-attribute
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, is_checked: bool) -> None
MetaData dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
@dataclass(repr=False)
class MetaData(BaseInterface):
    service: Service = field(metadata={"type": "Element"})
    links: list[str] | None = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    language: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    categories: list[str] | None = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    creationDateTime: str = field(
        default=None,
        metadata={"type": "Element"},
    )
    author: str | None = field(default=None, metadata={"type": "Element"})

    def __post_init__(self):
        if self.creationDateTime is None:
            self.creationDateTime = datetime.now(UTC).isoformat()
author: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
categories: list[str] | None = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
creationDateTime: str = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
language: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
service: Service = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(service: Service, links: list[str] | None = list(), language: str | None = None, categories: list[str] | None = list(), creationDateTime: str = None, author: str | None = None) -> None
__post_init__()
Source code in src/qgis_server_light/interface/exporter/extract.py
777
778
779
def __post_init__(self):
    if self.creationDateTime is None:
        self.creationDateTime = datetime.now(UTC).isoformat()
OgrSource dataclass

Bases: GdalSource

Source code in src/qgis_server_light/interface/exporter/extract.py
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
@dataclass(repr=False)
class OgrSource(GdalSource):
    layer_id: str | None = field(default=None, metadata={"type": "Element"})
    subset: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = super().to_qgis_decoded_uri
        if self.layer_id:
            connection_dict["layerId"] = self.layer_id
        if self.subset:
            connection_dict["subset"] = self.subset
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        base_class_instance = GdalSource.from_qgis_decoded_uri(decoded_uri)
        return cls(
            path=base_class_instance.path,
            layer_name=base_class_instance.layer_name,
            vsi_prefix=base_class_instance.vsi_prefix,
            layer_id=decoded_uri.get("layerId"),
            subset=decoded_uri.get("subset"),
        )

    @property
    def encoded_uri_separator(self) -> str:
        return "|"
encoded_uri_separator: str property
layer_id: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
subset: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
to_qgis_decoded_uri: dict property
__init__(path: str, layer_name: str | None = None, vsi_prefix: str | None = None, layer_id: str | None = None, subset: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
288
289
290
291
292
293
294
295
296
297
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    base_class_instance = GdalSource.from_qgis_decoded_uri(decoded_uri)
    return cls(
        path=base_class_instance.path,
        layer_name=base_class_instance.layer_name,
        vsi_prefix=base_class_instance.vsi_prefix,
        layer_id=decoded_uri.get("layerId"),
        subset=decoded_uri.get("subset"),
    )
PostgresSource dataclass

Bases: Source

Source code in src/qgis_server_light/interface/exporter/extract.py
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
@dataclass(repr=False)
class PostgresSource(Source):
    key: str = field(metadata={"type": "Element"})
    table: str = field(metadata={"type": "Element"})
    schema: str | None = field(default=None, metadata={"type": "Element"})
    geometry_column: str | None = field(default=None, metadata={"type": "Element"})
    dbname: str | None = field(default=None, metadata={"type": "Element"})
    host: str | None = field(default=None, metadata={"type": "Element"})
    password: str | None = field(default=None, metadata={"type": "Element"})
    port: int | None = field(default=None, metadata={"type": "Element"})
    type: int | None = field(default=None, metadata={"type": "Element"})
    username: str | None = field(default=None, metadata={"type": "Element"})
    srid: str | None = field(default=None, metadata={"type": "Element"})
    sslmode: int | None = field(default=None, metadata={"type": "Element"})
    ssl_mode_text: str | None = field(default=None, metadata={"type": "Element"})
    service: str | None = field(default=None, metadata={"type": "Element"})
    check_primary_key_unicity: str | None = field(default=None, metadata={"type": "Element"})
    sql: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def redacted_fields(self) -> set:
        return {"password"}

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = {"key": self.key, "schema": self.schema, "table": self.table}
        if self.geometry_column is not None:
            connection_dict["geometrycolumn"] = self.geometry_column
        if self.dbname is not None:
            connection_dict["dbname"] = self.dbname
        if self.host is not None:
            connection_dict["host"] = self.host
        if self.password is not None:
            connection_dict["password"] = self.password
        if self.port is not None:
            connection_dict["port"] = self.port
        if self.type is not None:
            connection_dict["type"] = self.type
        if self.username is not None:
            connection_dict["username"] = self.username
        if self.srid is not None:
            connection_dict["srid"] = self.srid
        if self.sslmode is not None:
            connection_dict["sslmode"] = self.sslmode
        if self.service is not None:
            connection_dict["service"] = self.service
        if self.check_primary_key_unicity is not None:
            connection_dict["checkPrimaryKeyUnicity"] = self.check_primary_key_unicity
        if self.sql is not None:
            connection_dict["sql"] = self.sql
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        return cls(
            key=decoded_uri["key"],
            schema=decoded_uri.get("schema"),
            table=decoded_uri["table"],
            geometry_column=decoded_uri.get("geometrycolumn"),
            dbname=decoded_uri.get("dbname"),
            host=decoded_uri.get("host"),
            password=decoded_uri.get("password"),
            port=int(decoded_uri.get("port")) if decoded_uri.get("port") is not None else None,
            type=int(decoded_uri.get("type")) if decoded_uri.get("type") is not None else None,
            username=decoded_uri.get("username") or decoded_uri.get("user"),
            srid=decoded_uri.get("srid"),
            sslmode=(
                int(decoded_uri.get("sslmode")) if decoded_uri.get("sslmode") is not None else None
            ),
            service=decoded_uri.get("service"),
            check_primary_key_unicity=decoded_uri.get("check_primary_key_unicity"),
            sql=decoded_uri.get("sql"),
        )

    @property
    def remote(self):
        return True
check_primary_key_unicity: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
dbname: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
geometry_column: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
host: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
key: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
password: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
port: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
redacted_fields: set property
remote property
schema: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
service: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
sql: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
srid: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
ssl_mode_text: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
sslmode: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
table: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
to_qgis_decoded_uri: dict property
type: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
username: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(key: str, table: str, schema: str | None = None, geometry_column: str | None = None, dbname: str | None = None, host: str | None = None, password: str | None = None, port: int | None = None, type: int | None = None, username: str | None = None, srid: str | None = None, sslmode: int | None = None, ssl_mode_text: str | None = None, service: str | None = None, check_primary_key_unicity: str | None = None, sql: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    return cls(
        key=decoded_uri["key"],
        schema=decoded_uri.get("schema"),
        table=decoded_uri["table"],
        geometry_column=decoded_uri.get("geometrycolumn"),
        dbname=decoded_uri.get("dbname"),
        host=decoded_uri.get("host"),
        password=decoded_uri.get("password"),
        port=int(decoded_uri.get("port")) if decoded_uri.get("port") is not None else None,
        type=int(decoded_uri.get("type")) if decoded_uri.get("type") is not None else None,
        username=decoded_uri.get("username") or decoded_uri.get("user"),
        srid=decoded_uri.get("srid"),
        sslmode=(
            int(decoded_uri.get("sslmode")) if decoded_uri.get("sslmode") is not None else None
        ),
        service=decoded_uri.get("service"),
        check_primary_key_unicity=decoded_uri.get("check_primary_key_unicity"),
        sql=decoded_uri.get("sql"),
    )
Project dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
782
783
784
785
@dataclass(repr=False)
class Project(BaseInterface):
    version: str = field(metadata={"type": "Element"})
    name: str = field(metadata={"type": "Element"})
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
version: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(version: str, name: str) -> None
Range dataclass

Bases: BaseInterface

Configuration of the QGIS Range editor widget.

Attributes:

  • minimum (float | None) –

    The smallest allowed value.

  • maximum (float | None) –

    The biggest allowed value.

  • step (float | None) –

    The step of the widget.

Source code in src/qgis_server_light/interface/exporter/extract.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
@dataclass(repr=False)
class Range(BaseInterface):
    """
    Configuration of the QGIS `Range` editor widget.

    Attributes:
        minimum: The smallest allowed value.
        maximum: The biggest allowed value.
        step: The step of the widget.
    """

    minimum: float | None = field(default=None, metadata={"type": "Element"})
    maximum: float | None = field(default=None, metadata={"type": "Element"})
    step: float | None = field(default=None, metadata={"type": "Element"})
maximum: float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
minimum: float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
step: float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(minimum: float | None = None, maximum: float | None = None, step: float | None = None) -> None
Raster dataclass

Bases: DataSet

A real QGIS Raster job_layer_definition. That are usually all QgsRasterLayer in opposition to QgsVectorTileLayer which is not a real QgsRasterLayer.

Source code in src/qgis_server_light/interface/exporter/extract.py
670
671
672
673
674
675
676
@dataclass(repr=False)
class Raster(DataSet):
    """
    A real QGIS Raster job_layer_definition. That are usually all `QgsRasterLayer`
    in opposition to `QgsVectorTileLayer`
    which is not a real `QgsRasterLayer`.
    """
__init__(id: str, name: str, is_checked: bool, title: str, source: DataSource, driver: str, bbox: BBox | None = None, bbox_wgs84: BBox | None = None, crs: Crs | None = None, styles: list[Style] = list(), minimum_scale: float | None = None, maximum_scale: float | None = None, style_name: str = 'default', is_spatial: bool = True, is_background: bool = False) -> None
Relation dataclass

Bases: BaseInterface

Transportable form of a QGIS project relation (QgsRelation). The layers are exported as QGIS layer ids, they are not resolved.

Attributes:

  • id (str) –

    The id of the relation, referenced by RelationReference.relation_id.

  • name (str) –

    The human readable name of the relation.

  • referencing_layer_id (str) –

    The QGIS layer id of the referencing (child) layer.

  • referenced_layer_id (str) –

    The QGIS layer id of the referenced (parent) layer.

  • field_pairs (list[RelationFieldPair]) –

    The field pairs, more than one for composite keys.

  • strength (str) –

    The strength as named by QGIS, Association or Composition.

Source code in src/qgis_server_light/interface/exporter/extract.py
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
@dataclass(repr=False)
class Relation(BaseInterface):
    """
    Transportable form of a QGIS project relation (`QgsRelation`). The layers are
    exported as QGIS layer ids, they are not resolved.

    Attributes:
        id: The id of the relation, referenced by `RelationReference.relation_id`.
        name: The human readable name of the relation.
        referencing_layer_id: The QGIS layer id of the referencing (child) layer.
        referenced_layer_id: The QGIS layer id of the referenced (parent) layer.
        field_pairs: The field pairs, more than one for composite keys.
        strength: The strength as named by QGIS, `Association` or `Composition`.
    """

    id: str = field(metadata={"type": "Element"})
    name: str = field(metadata={"type": "Element"})
    referencing_layer_id: str = field(metadata={"type": "Element"})
    referenced_layer_id: str = field(metadata={"type": "Element"})
    field_pairs: list[RelationFieldPair] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    strength: str = field(default="Association", metadata={"type": "Element"})
field_pairs: list[RelationFieldPair] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
referenced_layer_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
referencing_layer_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
strength: str = field(default='Association', metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, referencing_layer_id: str, referenced_layer_id: str, field_pairs: list[RelationFieldPair] = list(), strength: str = 'Association') -> None
RelationFieldPair dataclass

Bases: BaseInterface

One field pair of a QGIS project relation.

Attributes:

Source code in src/qgis_server_light/interface/exporter/extract.py
853
854
855
856
857
858
859
860
861
862
863
864
@dataclass(repr=False)
class RelationFieldPair(BaseInterface):
    """
    One field pair of a QGIS project relation.

    Attributes:
        referencing_field: The field of the referencing (child) layer.
        referenced_field: The field of the referenced (parent) layer.
    """

    referencing_field: str = field(metadata={"type": "Element"})
    referenced_field: str = field(metadata={"type": "Element"})
referenced_field: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
referencing_field: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(referencing_field: str, referenced_field: str) -> None
RelationReference dataclass

Bases: BaseInterface

Configuration of the QGIS RelationReference editor widget.

Attributes:

  • relation_id (str) –

    The id of the project relation, see Relation.id.

Source code in src/qgis_server_light/interface/exporter/extract.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
@dataclass(repr=False)
class RelationReference(BaseInterface):
    """
    Configuration of the QGIS `RelationReference` editor widget.

    Attributes:
        relation_id: The id of the project relation, see `Relation.id`.
    """

    relation_id: str = field(metadata={"type": "Element"})
relation_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(relation_id: str) -> None
ResultWithMessages dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
@dataclass(repr=False)
class ResultWithMessages(BaseInterface):
    project: Project = field(metadata={"type": "Element"})
    exporter: Exporter = field(metadata={"type": "Element"})
    messages: list[ExportMessage] = field(
        default_factory=list, kw_only=True, metadata={"type": "Element"}
    )

    def warning(self, message: str, code: ExportMessage.Code, layer_id: str | None = None):
        logging.warning(message, extra={"code": code, "layer_id": layer_id})
        self.messages.append(
            ExportMessage(ExportMessage.Level.WARNING, message, code=code, layer_id=layer_id)
        )

    def error(self, message: str, code: ExportMessage.Code, layer_id: str | None = None):
        logging.error(message, extra={"code": code, "layer_id": layer_id})
        self.messages.append(
            ExportMessage(ExportMessage.Level.ERROR, message, code=code, layer_id=layer_id)
        )

    @property
    def has_errors(self) -> bool:
        return any(m.level == ExportMessage.Level.ERROR for m in self.messages)
exporter: Exporter = field(metadata={'type': 'Element'}) class-attribute instance-attribute
has_errors: bool property
messages: list[ExportMessage] = field(default_factory=list, kw_only=True, metadata={'type': 'Element'}) class-attribute instance-attribute
project: Project = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(project: Project, exporter: Exporter, *, messages: list[ExportMessage] = list()) -> None
error(message: str, code: ExportMessage.Code, layer_id: str | None = None)
Source code in src/qgis_server_light/interface/exporter/extract.py
940
941
942
943
944
def error(self, message: str, code: ExportMessage.Code, layer_id: str | None = None):
    logging.error(message, extra={"code": code, "layer_id": layer_id})
    self.messages.append(
        ExportMessage(ExportMessage.Level.ERROR, message, code=code, layer_id=layer_id)
    )
warning(message: str, code: ExportMessage.Code, layer_id: str | None = None)
Source code in src/qgis_server_light/interface/exporter/extract.py
934
935
936
937
938
def warning(self, message: str, code: ExportMessage.Code, layer_id: str | None = None):
    logging.warning(message, extra={"code": code, "layer_id": layer_id})
    self.messages.append(
        ExportMessage(ExportMessage.Level.WARNING, message, code=code, layer_id=layer_id)
    )
Service dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
@dataclass(repr=False)
class Service(BaseInterface):
    contact_organization: str | None = field(metadata={"type": "Element"})
    contact_mail: str | None = field(metadata={"type": "Element"})
    contact_person: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    contact_phone: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    contact_position: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    fees: str | None = field(default=None, metadata={"type": "Element"})
    keyword_list: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    online_resource: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    service_abstract: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    service_title: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    resource_url: str | None = field(default=None, metadata={"type": "Element"})
contact_mail: str | None = field(metadata={'type': 'Element'}) class-attribute instance-attribute
contact_organization: str | None = field(metadata={'type': 'Element'}) class-attribute instance-attribute
contact_person: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
contact_phone: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
contact_position: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
fees: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
keyword_list: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
online_resource: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
resource_url: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
service_abstract: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
service_title: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(contact_organization: str | None, contact_mail: str | None, contact_person: str | None = None, contact_phone: str | None = None, contact_position: str | None = None, fees: str | None = None, keyword_list: str | None = None, online_resource: str | None = None, service_abstract: str | None = None, service_title: str | None = None, resource_url: str | None = None) -> None
Source dataclass

Bases: BaseInterface, ABC

Source code in src/qgis_server_light/interface/exporter/extract.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
@dataclass(repr=False)
class Source(BaseInterface, ABC):
    @staticmethod
    def decide_remote(path: str) -> bool:
        return path.startswith("http")

    @property
    def to_qgis_decoded_uri(self) -> dict:
        raise NotImplementedError(
            "This is a base class, the method has to be defined at implementation level."
        )

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        raise NotImplementedError(
            "This is a base class, the method has to be defined at implementation level."
        )
to_qgis_decoded_uri: dict property
__init__() -> None
decide_remote(path: str) -> bool staticmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
229
230
231
@staticmethod
def decide_remote(path: str) -> bool:
    return path.startswith("http")
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
239
240
241
242
243
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    raise NotImplementedError(
        "This is a base class, the method has to be defined at implementation level."
    )
Tree dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
@dataclass(repr=False)
class Tree(BaseInterface):
    members: list[TreeGroup] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )

    @property
    def root(self):
        return self.find_by_name("")

    def find_by_name(self, name: str) -> TreeGroup | None:
        for member in self.members:
            if member.name == name:
                return member
        return None

    def find_by_id(self, identifier: str) -> TreeGroup | None:
        for member in self.members:
            if member.id == identifier:
                return member
        return None
members: list[TreeGroup] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
root property
__init__(members: list[TreeGroup] = list()) -> None
find_by_id(identifier: str) -> TreeGroup | None
Source code in src/qgis_server_light/interface/exporter/extract.py
805
806
807
808
809
def find_by_id(self, identifier: str) -> TreeGroup | None:
    for member in self.members:
        if member.id == identifier:
            return member
    return None
find_by_name(name: str) -> TreeGroup | None
Source code in src/qgis_server_light/interface/exporter/extract.py
799
800
801
802
803
def find_by_name(self, name: str) -> TreeGroup | None:
    for member in self.members:
        if member.name == name:
            return member
    return None
TreeGroup dataclass

Bases: TreeLayer

Source code in src/qgis_server_light/interface/exporter/extract.py
28
29
30
31
@dataclass(repr=False)
class TreeGroup(TreeLayer):
    children: list[str] = field(metadata={"type": "Element"})
    is_expanded: bool = field(metadata={"type": "Element"})
children: list[str] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
is_expanded: bool = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, is_checked: bool, children: list[str], is_expanded: bool) -> None
TreeLayer dataclass

Bases: LayerLike

Source code in src/qgis_server_light/interface/exporter/extract.py
23
24
25
@dataclass(repr=False)
class TreeLayer(LayerLike):
    pass
__init__(id: str, name: str, is_checked: bool) -> None
ValueMap dataclass

Bases: BaseInterface

Configuration of the QGIS ValueMap editor widget.

Attributes:

  • entries (list[ValueMapEntry]) –

    The key / description pairs in the order defined in QGIS. The entry representing NULL is not part of it.

  • null_representation (str | None) –

    The description QGIS shows for NULL, if the widget defines one.

Source code in src/qgis_server_light/interface/exporter/extract.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@dataclass(repr=False)
class ValueMap(BaseInterface):
    """
    Configuration of the QGIS `ValueMap` editor widget.

    Attributes:
        entries: The key / description pairs in the order defined in QGIS. The entry
            representing NULL is not part of it.
        null_representation: The description QGIS shows for NULL, if the widget
            defines one.
    """

    entries: list[ValueMapEntry] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    null_representation: str | None = field(default=None, metadata={"type": "Element"})
entries: list[ValueMapEntry] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
null_representation: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(entries: list[ValueMapEntry] = list(), null_representation: str | None = None) -> None
ValueMapEntry dataclass

Bases: BaseInterface

One entry of a QGIS ValueMap editor widget.

Attributes:

  • key (str) –

    The value which is stored in the field.

  • description (str) –

    The human readable representation of the value.

Source code in src/qgis_server_light/interface/exporter/extract.py
34
35
36
37
38
39
40
41
42
43
44
45
@dataclass(repr=False)
class ValueMapEntry(BaseInterface):
    """
    One entry of a QGIS `ValueMap` editor widget.

    Attributes:
        key: The value which is stored in the field.
        description: The human readable representation of the value.
    """

    key: str = field(metadata={"type": "Element"})
    description: str = field(metadata={"type": "Element"})
description: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
key: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(key: str, description: str) -> None
ValueRelation dataclass

Bases: BaseInterface

Configuration of the QGIS ValueRelation editor widget. The referenced layer is exported as QGIS layer id, it is not resolved.

Attributes:

  • layer_id (str) –

    The QGIS layer id of the layer the values are taken from.

  • key_field (str) –

    The field of the referenced layer which is stored.

  • value_field (str) –

    The field of the referenced layer which is shown.

  • filter_expression (str | None) –

    The QGIS expression to filter the referenced layer. It may use form context functions like current_value().

  • allow_multi (bool) –

    If more than one value can be selected.

  • order_by_value (bool) –

    If the values are ordered by the value field instead of the key field.

Source code in src/qgis_server_light/interface/exporter/extract.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@dataclass(repr=False)
class ValueRelation(BaseInterface):
    """
    Configuration of the QGIS `ValueRelation` editor widget. The referenced layer is
    exported as QGIS layer id, it is not resolved.

    Attributes:
        layer_id: The QGIS layer id of the layer the values are taken from.
        key_field: The field of the referenced layer which is stored.
        value_field: The field of the referenced layer which is shown.
        filter_expression: The QGIS expression to filter the referenced layer. It may
            use form context functions like `current_value()`.
        allow_multi: If more than one value can be selected.
        order_by_value: If the values are ordered by the value field instead of the
            key field.
    """

    layer_id: str = field(metadata={"type": "Element"})
    key_field: str = field(metadata={"type": "Element"})
    value_field: str = field(metadata={"type": "Element"})
    filter_expression: str | None = field(default=None, metadata={"type": "Element"})
    allow_multi: bool = field(default=False, metadata={"type": "Element"})
    order_by_value: bool = field(default=False, metadata={"type": "Element"})
allow_multi: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
filter_expression: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
key_field: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
layer_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
order_by_value: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
value_field: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(layer_id: str, key_field: str, value_field: str, filter_expression: str | None = None, allow_multi: bool = False, order_by_value: bool = False) -> None
Vector dataclass

Bases: DataSet

A real QGIS Vector job_layer_definition. That are usually all QgsVectorLayer in opposition to QgsVectorTileLayer which is not a real QgsVectorLayer.

Source code in src/qgis_server_light/interface/exporter/extract.py
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
@dataclass(repr=False)
class Vector(DataSet):
    """
    A real QGIS Vector job_layer_definition. That are usually all `QgsVectorLayer`
    in opposition to `QgsVectorTileLayer`
    which is not a real `QgsVectorLayer`.
    """

    fields: list[Field] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
    geometry_type_simple: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    geometry_type_wkb: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )

    def get_field_by_name(self, name: str) -> Field | None:
        for dataclass_field in self.fields:
            if dataclass_field.name == name:
                return dataclass_field
        return None
fields: list[Field] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
geometry_type_simple: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
geometry_type_wkb: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, is_checked: bool, title: str, source: DataSource, driver: str, bbox: BBox | None = None, bbox_wgs84: BBox | None = None, crs: Crs | None = None, styles: list[Style] = list(), minimum_scale: float | None = None, maximum_scale: float | None = None, style_name: str = 'default', is_spatial: bool = True, is_background: bool = False, fields: list[Field] = list(), geometry_type_simple: str | None = None, geometry_type_wkb: str | None = None) -> None
get_field_by_name(name: str) -> Field | None
Source code in src/qgis_server_light/interface/exporter/extract.py
700
701
702
703
704
def get_field_by_name(self, name: str) -> Field | None:
    for dataclass_field in self.fields:
        if dataclass_field.name == name:
            return dataclass_field
    return None
VectorTileSource dataclass

Bases: Source

Source code in src/qgis_server_light/interface/exporter/extract.py
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
@dataclass(repr=False)
class VectorTileSource(Source):
    type: str = field(metadata={"type": "Element"})
    zmin: int | None = field(metadata={"type": "Element"})
    zmax: int | None = field(metadata={"type": "Element"})
    url: str | None = field(default=None, metadata={"type": "Element"})
    path: str | None = field(default=None, metadata={"type": "Element"})
    style_url: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def remote(self):
        return self.decide_remote(self.path or self.url)

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = {"type": self.type, "zmin": self.zmin, "zmax": self.zmax}
        if self.url is not None:
            connection_dict["url"] = self.url
        if self.path is not None:
            connection_dict["path"] = self.path
        if self.style_url is not None:
            connection_dict["styleUrl"] = self.style_url
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        return cls(
            type=decoded_uri["type"],
            zmin=decoded_uri.get("zmin"),
            zmax=decoded_uri.get("zmax"),
            url=decoded_uri.get("url"),
            path=decoded_uri.get("path"),
            style_url=decoded_uri.get("styleUrl"),
        )
path: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
remote property
style_url: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
to_qgis_decoded_uri: dict property
type: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
url: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
zmax: int | None = field(metadata={'type': 'Element'}) class-attribute instance-attribute
zmin: int | None = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(type: str, zmin: int | None, zmax: int | None, url: str | None = None, path: str | None = None, style_url: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
598
599
600
601
602
603
604
605
606
607
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    return cls(
        type=decoded_uri["type"],
        zmin=decoded_uri.get("zmin"),
        zmax=decoded_uri.get("zmax"),
        url=decoded_uri.get("url"),
        path=decoded_uri.get("path"),
        style_url=decoded_uri.get("styleUrl"),
    )
WcsSource dataclass

Bases: Source

Source of a layer of the QGIS wcs provider. The attributes are the uri parameters read by the provider (QgsWcsProvider::parseUri and QgsWcsCapabilities in QGIS src/providers/wcs). Credentials (username, password, authcfg) and http headers are intentionally not exported.

Source code in src/qgis_server_light/interface/exporter/extract.py
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
@dataclass(repr=False)
class WcsSource(Source):
    """
    Source of a layer of the QGIS `wcs` provider. The attributes are the uri
    parameters read by the provider (`QgsWcsProvider::parseUri` and
    `QgsWcsCapabilities` in QGIS `src/providers/wcs`). Credentials (`username`,
    `password`, `authcfg`) and http headers are intentionally not exported.
    """

    url: str = field(metadata={"type": "Element"})
    identifier: str = field(metadata={"type": "Element"})
    crs: str | None = field(default=None, metadata={"type": "Element"})
    format: str | None = field(default=None, metadata={"type": "Element"})
    time: str | None = field(default=None, metadata={"type": "Element"})
    bbox: str | None = field(default=None, metadata={"type": "Element"})
    version: str | None = field(default=None, metadata={"type": "Element"})
    cache: str | None = field(default=None, metadata={"type": "Element"})
    # workarounds for misconfigured servers, set from the checkboxes of the QGIS WCS
    # connection. The provider enables them when the parameter is present in the
    # uri, whatever its value.
    ignore_get_map_url: bool = field(default=False, metadata={"type": "Element"})
    ignore_axis_orientation: bool = field(default=False, metadata={"type": "Element"})
    invert_axis_orientation: bool = field(default=False, metadata={"type": "Element"})

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = {
            "url": self.url,
            "identifier": self.identifier,
            "crs": self.crs,
            "format": self.format,
            "time": self.time,
            "bbox": self.bbox,
            "version": self.version,
            "cache": self.cache,
        }
        # the WCS provider applies its own defaults to the missing keys
        connection_dict = {
            key: value for key, value in connection_dict.items() if value is not None
        }
        # "1" is the value QGIS writes for these parameters
        if self.ignore_get_map_url:
            connection_dict["IgnoreGetMapUrl"] = "1"
        if self.ignore_axis_orientation:
            connection_dict["IgnoreAxisOrientation"] = "1"
        if self.invert_axis_orientation:
            connection_dict["InvertAxisOrientation"] = "1"
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        return cls(
            url=decoded_uri["url"],
            identifier=decoded_uri["identifier"],
            crs=decoded_uri.get("crs"),
            format=decoded_uri.get("format"),
            time=decoded_uri.get("time"),
            bbox=decoded_uri.get("bbox"),
            version=decoded_uri.get("version"),
            cache=decoded_uri.get("cache"),
            ignore_get_map_url="IgnoreGetMapUrl" in decoded_uri,
            ignore_axis_orientation="IgnoreAxisOrientation" in decoded_uri,
            invert_axis_orientation="InvertAxisOrientation" in decoded_uri,
        )

    @property
    def remote(self):
        return True
bbox: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
cache: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
crs: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
format: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
identifier: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
ignore_axis_orientation: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
ignore_get_map_url: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
invert_axis_orientation: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
remote property
time: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
to_qgis_decoded_uri: dict property
url: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
version: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(url: str, identifier: str, crs: str | None = None, format: str | None = None, time: str | None = None, bbox: str | None = None, version: str | None = None, cache: str | None = None, ignore_get_map_url: bool = False, ignore_axis_orientation: bool = False, invert_axis_orientation: bool = False) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    return cls(
        url=decoded_uri["url"],
        identifier=decoded_uri["identifier"],
        crs=decoded_uri.get("crs"),
        format=decoded_uri.get("format"),
        time=decoded_uri.get("time"),
        bbox=decoded_uri.get("bbox"),
        version=decoded_uri.get("version"),
        cache=decoded_uri.get("cache"),
        ignore_get_map_url="IgnoreGetMapUrl" in decoded_uri,
        ignore_axis_orientation="IgnoreAxisOrientation" in decoded_uri,
        invert_axis_orientation="InvertAxisOrientation" in decoded_uri,
    )
WfsSource dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/exporter/extract.py
304
305
306
307
308
@dataclass(repr=False)
class WfsSource(BaseInterface):
    # currently not implemented because qgis does not allow to
    # use the decode uri approach on that URI
    pass
__init__() -> None
WmsSource dataclass

Bases: Source

Source code in src/qgis_server_light/interface/exporter/extract.py
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
@dataclass(repr=False)
class WmsSource(Source):
    crs: str = field(metadata={"type": "Element"})
    format: str = field(metadata={"type": "Element"})
    layers: str = field(metadata={"type": "Element"})
    url: str = field(metadata={"type": "Element"})
    dpi_mode: str | None = field(default=None, metadata={"type": "Element"})
    feature_count: int | None = field(default=None, metadata={"type": "Element"})
    contextual_wms_legend: str | None = field(default=None, metadata={"type": "Element"})
    styles: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = {
            "crs": self.crs,
            "format": self.format,
            "layers": self.layers,
            "url": self.url,
            "styles": self.styles,
        }
        if self.dpi_mode is not None:
            connection_dict["dpiMode"] = self.dpi_mode
        if self.feature_count is not None:
            connection_dict["featureCount"] = self.feature_count
        if self.contextual_wms_legend is not None:
            connection_dict["contextualWMSLegend"] = self.contextual_wms_legend
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        return cls(
            crs=decoded_uri["crs"],
            format=decoded_uri["format"],
            layers=decoded_uri["layers"],
            url=decoded_uri["url"],
            dpi_mode=decoded_uri.get("dpiMode"),
            feature_count=decoded_uri.get("featureCount"),
            contextual_wms_legend=decoded_uri.get("contextualWMSLegend"),
            styles=decoded_uri.get("styles"),
        )

    @property
    def remote(self):
        return True
contextual_wms_legend: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
crs: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
dpi_mode: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
feature_count: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
format: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
layers: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
remote property
styles: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
to_qgis_decoded_uri: dict property
url: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(crs: str, format: str, layers: str, url: str, dpi_mode: str | None = None, feature_count: int | None = None, contextual_wms_legend: str | None = None, styles: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
370
371
372
373
374
375
376
377
378
379
380
381
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    return cls(
        crs=decoded_uri["crs"],
        format=decoded_uri["format"],
        layers=decoded_uri["layers"],
        url=decoded_uri["url"],
        dpi_mode=decoded_uri.get("dpiMode"),
        feature_count=decoded_uri.get("featureCount"),
        contextual_wms_legend=decoded_uri.get("contextualWMSLegend"),
        styles=decoded_uri.get("styles"),
    )
WmtsSource dataclass

Bases: WmsSource

Source code in src/qgis_server_light/interface/exporter/extract.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
@dataclass(repr=False, kw_only=True)
class WmtsSource(WmsSource):
    tile_matrix_set: str = field(metadata={"type": "Element"})
    tile_dimensions: str | None = field(
        default=None,
        metadata={"type": "Element"},
    )
    tile_pixel_ratio: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = super().to_qgis_decoded_uri
        connection_dict["tileMatrixSet"] = self.tile_matrix_set
        if self.tile_dimensions is not None:
            connection_dict["tileDimensions"] = self.tile_dimensions
        if self.tile_pixel_ratio is not None:
            connection_dict["tilePixelRatio"] = self.tile_pixel_ratio
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        base_class_instance = WmsSource.from_qgis_decoded_uri(decoded_uri)
        return cls(
            crs=base_class_instance.crs,
            format=base_class_instance.format,
            layers=base_class_instance.layers,
            url=base_class_instance.url,
            dpi_mode=base_class_instance.dpi_mode,
            feature_count=base_class_instance.feature_count,
            contextual_wms_legend=base_class_instance.contextual_wms_legend,
            styles=base_class_instance.styles,
            tile_matrix_set=decoded_uri["tileMatrixSet"],
            tile_dimensions=decoded_uri.get("tileDimensions"),
            tile_pixel_ratio=decoded_uri.get("tilePixelRatio"),
        )
tile_dimensions: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
tile_matrix_set: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
tile_pixel_ratio: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
to_qgis_decoded_uri: dict property
__init__(crs: str, format: str, layers: str, url: str, dpi_mode: str | None = None, feature_count: int | None = None, contextual_wms_legend: str | None = None, styles: str | None = None, *, tile_matrix_set: str, tile_dimensions: str | None = None, tile_pixel_ratio: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    base_class_instance = WmsSource.from_qgis_decoded_uri(decoded_uri)
    return cls(
        crs=base_class_instance.crs,
        format=base_class_instance.format,
        layers=base_class_instance.layers,
        url=base_class_instance.url,
        dpi_mode=base_class_instance.dpi_mode,
        feature_count=base_class_instance.feature_count,
        contextual_wms_legend=base_class_instance.contextual_wms_legend,
        styles=base_class_instance.styles,
        tile_matrix_set=decoded_uri["tileMatrixSet"],
        tile_dimensions=decoded_uri.get("tileDimensions"),
        tile_pixel_ratio=decoded_uri.get("tilePixelRatio"),
    )
XYZSource dataclass

Bases: Source

Source code in src/qgis_server_light/interface/exporter/extract.py
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
@dataclass(repr=False)
class XYZSource(Source):
    url: str = field(metadata={"type": "Element"})
    zmin: int | None = field(default=None, metadata={"type": "Element"})
    zmax: int | None = field(default=None, metadata={"type": "Element"})
    type: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def to_qgis_decoded_uri(self) -> dict:
        connection_dict = {
            "url": self.url,
            "zmin": self.zmin,
            "zmax": self.zmax,
            "type": self.type,
        }
        return connection_dict

    @classmethod
    def from_qgis_decoded_uri(cls, decoded_uri: dict):
        return cls(
            url=decoded_uri["url"],
            zmin=decoded_uri.get("zmin"),
            zmax=decoded_uri.get("zmax"),
            type=decoded_uri.get("type"),
        )

    @property
    def remote(self):
        return self.decide_remote(self.url)
remote property
to_qgis_decoded_uri: dict property
type: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
url: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
zmax: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
zmin: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(url: str, zmin: int | None = None, zmax: int | None = None, type: str | None = None) -> None
from_qgis_decoded_uri(decoded_uri: dict) classmethod
Source code in src/qgis_server_light/interface/exporter/extract.py
328
329
330
331
332
333
334
335
@classmethod
def from_qgis_decoded_uri(cls, decoded_uri: dict):
    return cls(
        url=decoded_uri["url"],
        zmin=decoded_uri.get("zmin"),
        zmax=decoded_uri.get("zmax"),
        type=decoded_uri.get("type"),
    )

job

common

input
AbstractFilter dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/job/common/input.py
66
67
68
69
70
71
72
@dataclass(repr=False)
class AbstractFilter(BaseInterface):
    definition: str = field(metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"definition"}
definition: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
__init__(definition: str) -> None
ExecutionMode

Bases: Enum

If the dispatcher waits for the job (SYNC) or asks for its state later (ASYNC). Only jobs which keep their state (RedisStateProtocol) use it.

Source code in src/qgis_server_light/interface/job/common/input.py
17
18
19
20
21
22
23
class ExecutionMode(Enum):
    """If the dispatcher waits for the job (`SYNC`) or asks for its state later
    (`ASYNC`). Only jobs which keep their state (`RedisStateProtocol`) use it.
    """

    SYNC = "sync"
    ASYNC = "async"
ASYNC = 'async' class-attribute instance-attribute
SYNC = 'sync' class-attribute instance-attribute
OgcFilter110 dataclass

Bases: AbstractFilter

A filter which definition conforms to https://schemas.opengis.net/filter/1.1.0/filter.xsd and which is consumable by qgis.core.QgsOgcUtils.expressionFromOgcFilter.

Source code in src/qgis_server_light/interface/job/common/input.py
75
76
77
78
79
80
81
@dataclass(repr=False)
class OgcFilter110(AbstractFilter):
    """
    A filter which definition conforms to
    https://schemas.opengis.net/filter/1.1.0/filter.xsd
    and which is consumable by `qgis.core.QgsOgcUtils.expressionFromOgcFilter`.
    """
__init__(definition: str) -> None
OgcFilterFES20 dataclass

Bases: AbstractFilter

A filter which definition conforms to https://www.opengis.net/fes/2.0 and which is consumable by qgis.core.QgsOgcUtils.expressionFromOgcFilter.

Source code in src/qgis_server_light/interface/job/common/input.py
84
85
86
87
88
89
@dataclass(repr=False)
class OgcFilterFES20(AbstractFilter):
    """
    A filter which definition conforms to https://www.opengis.net/fes/2.0
    and which is consumable by `qgis.core.QgsOgcUtils.expressionFromOgcFilter`.
    """
__init__(definition: str) -> None
QslJobInfoParameter dataclass

Bases: ABC

The common minimal interface of a job which is shipped around. Each job for QSL has to implement at least this interface.

Attributes:

  • id (str) –

    The unique identifier which is used to recognize the job all over its lifecycle.

  • type (str) –

    A string based identifier of the job, this is used to quickly determine its nature serialized state.

  • job (QslJobParameter) –

    The actual job parameters. This is a domain specific dataclass depending on the nature of the actual job.

  • execution_mode (ExecutionMode) –

    With ExecutionMode.SYNC the worker notifies the waiting dispatcher when the job is finished. Only used by jobs which keep their state.

Source code in src/qgis_server_light/interface/job/common/input.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@dataclass
class QslJobInfoParameter(ABC):  # noqa: B024
    """The common minimal interface of a job which is
    shipped around. Each job for QSL has to implement at least this
    interface.

    Attributes:
        id: The unique identifier which is used to recognize the job
            all over its lifecycle.
        type: A string based identifier of the job, this is used to quickly
            determine its nature serialized state.
        job: The actual job parameters. This is a domain specific dataclass
            depending on the nature of the actual job.
        execution_mode: With `ExecutionMode.SYNC` the worker notifies the waiting
            dispatcher when the job is finished. Only used by jobs which keep their
            state.
    """

    id: str = field(metadata={"type": "Element"})
    type: str = field(metadata={"type": "Element"})
    job: QslJobParameter = field(metadata={"type": "Element"})
    execution_mode: ExecutionMode = field(metadata={"type": "Element"}, default=ExecutionMode.SYNC)

    @property
    def channel_name(self) -> str:
        return f"notification_{self.execution_mode.value}"
channel_name: str property
execution_mode: ExecutionMode = field(metadata={'type': 'Element'}, default=(ExecutionMode.SYNC)) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
job: QslJobParameter = field(metadata={'type': 'Element'}) class-attribute instance-attribute
type: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameter, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobLayer dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/job/common/input.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
@dataclass(repr=False)
class QslJobLayer(BaseInterface):
    id: str = field(metadata={"type": "Element"})
    name: str = field(metadata={"type": "Element"})
    source: str = field(metadata={"type": "Element"})
    remote: bool = field(metadata={"type": "Element"})
    folder_name: str = field(metadata={"type": "Element"})
    driver: str = field(metadata={"type": "Element"})
    style: Style | None = field(default=None, metadata={"type": "Element"})
    filter: OgcFilter110 | OgcFilterFES20 | None = field(default=None, metadata={"type": "Element"})

    @property
    def redacted_fields(self) -> set:
        return {"source"}
driver: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
filter: OgcFilter110 | OgcFilterFES20 | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
folder_name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
redacted_fields: set property
remote: bool = field(metadata={'type': 'Element'}) class-attribute instance-attribute
source: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
style: Style | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, name: str, source: str, remote: bool, folder_name: str, driver: str, style: Style | None = None, filter: OgcFilter110 | OgcFilterFES20 | None = None) -> None
QslJobParameter dataclass

Bases: ABC

The minimal interface of a job parameter interface. In the domain specific refinement it holds the relevant information about a job.

Source code in src/qgis_server_light/interface/job/common/input.py
 8
 9
10
11
12
13
14
@dataclass
class QslJobParameter(ABC):  # noqa: B024
    """The minimal interface of a job parameter interface. In the domain
    specific refinement it holds the relevant information about a job.
    """

    pass
__init__() -> None
QslJobParameterMapRelated dataclass

Bases: QslJobParameter

The minimal interface of a job parameter interface for jobs rendering things in the end.

Attributes:

  • svg_paths (list[str]) –

    A list of paths to svg's (folders) which are necessary for the job to render nicely.

Source code in src/qgis_server_light/interface/job/common/input.py
54
55
56
57
58
59
60
61
62
63
@dataclass
class QslJobParameterMapRelated(QslJobParameter):
    """The minimal interface of a job parameter interface for jobs rendering things in the end.

    Attributes:
        svg_paths: A list of paths to svg's (folders) which are necessary for
            the job to render nicely.
    """

    svg_paths: list[str] = field(default_factory=list, metadata={"type": "Element"})
svg_paths: list[str] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(svg_paths: list[str] = list()) -> None
output
JobResult dataclass

Bases: BaseInterface

Source code in src/qgis_server_light/interface/job/common/output.py
 7
 8
 9
10
11
12
13
14
15
16
17
@dataclass
class JobResult(BaseInterface):
    id: str = field(metadata={"type": "Element"})
    data: Any = field(metadata={"type": "Element"})
    content_type: str = field(metadata={"type": "Element"})
    worker_id: str | None = field(default=None, metadata={"type": "Element"})
    worker_host_name: str | None = field(default=None, metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"data"}
content_type: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
data: Any = field(metadata={'type': 'Element'}) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
worker_host_name: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
worker_id: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, data: Any, content_type: str, worker_id: str | None = None, worker_host_name: str | None = None) -> None

crs

input
QslJobInfoCrs dataclass

Bases: QslJobInfoParameter

Source code in src/qgis_server_light/interface/job/crs/input.py
22
23
24
@dataclass
class QslJobInfoCrs(QslJobInfoParameter):
    job: QslJobParameterCrs = field(metadata={"type": "Element"})
job: QslJobParameterCrs = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameterCrs, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobParameterCrs dataclass

Bases: QslJobParameter

Resolves crs identifiers into the full crs information as QGIS knows it. This way consuming applications get all identifiers and the axis order without own crs knowledge.

Attributes:

  • identifiers (list[str]) –

    The crs identifiers to resolve, e.g. EPSG:4326, URN or URI notation.

Source code in src/qgis_server_light/interface/job/crs/input.py
 9
10
11
12
13
14
15
16
17
18
19
@dataclass
class QslJobParameterCrs(QslJobParameter):
    """Resolves crs identifiers into the full crs information as QGIS knows it. This way
    consuming applications get all identifiers and the axis order without own crs
    knowledge.

    Attributes:
        identifiers: The crs identifiers to resolve, e.g. `EPSG:4326`, URN or URI notation.
    """

    identifiers: list[str] = field(metadata={"type": "Element"})
identifiers: list[str] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(identifiers: list[str]) -> None
output
CrsCollection dataclass

Bases: BaseInterface

Holds the resolved crs. The order in the list has to be not changed, so that consuming applications can map the response to the passed identifiers.

Attributes:

  • crs (list[Crs]) –

    The resolved crs in the order of the passed identifiers.

Source code in src/qgis_server_light/interface/job/crs/output.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
@dataclass(repr=False)
class CrsCollection(BaseInterface):
    """Holds the resolved crs. The order in the list has to be not changed, so that
    consuming applications can map the response to the passed identifiers.

    Attributes:
        crs: The resolved crs in the order of the passed identifiers.
    """

    crs: list[Crs] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
crs: list[Crs] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(crs: list[Crs] = list()) -> None

feature

input
FeatureQuery dataclass

Bases: BaseInterface

Represents definitions of a query to obtain features from a list of layers. Be aware, that filters are not applied to the QslJobLayer in this implementation since passed filters can contain inter-layer-references.

Attributes:

  • layers (list[QslJobLayer]) –

    A list layers which should only reference vector sources and be queried.

  • aliases (list[str]) –

    An optional list of alias names. This has to be the same length as the

  • filter (OgcFilterFES20) –

    An optional filter which might reference all passed layers thats why layers has to be added

  • crs (Crs | None) –

    An optional crs the geometries of the features are transformed to. If not set, geometries stay in the crs of the layer.

Source code in src/qgis_server_light/interface/job/feature/input.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@dataclass
class FeatureQuery(BaseInterface):
    """Represents definitions of a query to obtain features from a list of layers.
    Be aware, that filters are not applied to the QslJobLayer in this implementation
    since passed filters can contain inter-layer-references.

    Attributes:
        layers: A list layers which should only reference vector sources and be queried.
        aliases: An optional list of alias names. This has to be the same length as the
        list of datasets.
        filter: An optional filter which might reference all passed layers thats why layers
            has to be added
        crs: An optional crs the geometries of the features are transformed to. If not
            set, geometries stay in the crs of the layer.
    """

    layers: list[QslJobLayer] = field(metadata={"type": "Element"})
    aliases: list[str] = field(default_factory=list, metadata={"type": "Element"})
    filter: OgcFilterFES20 = field(default=None, metadata={"type": "Element"})
    crs: Crs | None = field(default=None, metadata={"type": "Element"})
aliases: list[str] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
crs: Crs | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
filter: OgcFilterFES20 = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
layers: list[QslJobLayer] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(layers: list[QslJobLayer], aliases: list[str] = list(), filter: OgcFilterFES20 = None, crs: Crs | None = None) -> None
QslJobInfoFeature dataclass

Bases: QslJobInfoParameter

Source code in src/qgis_server_light/interface/job/feature/input.py
60
61
62
@dataclass
class QslJobInfoFeature(QslJobInfoParameter):
    job: QslJobParameterFeature = field(metadata={"type": "Element"})
job: QslJobParameterFeature = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameterFeature, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobParameterFeature dataclass

Bases: QslJobParameter

As defined in WFS 2.0 specs, a request can be subdivided in a list of queries. This class is representing that.

Attributes:

  • queries (list[FeatureQuery]) –

    A list of queries which features should be extracted for.

  • start_index (int) –

    The offset for paging reason.

  • count (int | None) –

    The number of results to return.

Source code in src/qgis_server_light/interface/job/feature/input.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@dataclass
class QslJobParameterFeature(QslJobParameter):
    """As defined in WFS 2.0 specs, a request can be subdivided in a list of queries.
    This class is representing that.

    Attributes:
        queries: A list of queries which features should be extracted for.
        start_index: The offset for paging reason.
        count: The number of results to return.
    """

    queries: list[FeatureQuery] = field(metadata={"type": "Element"})
    start_index: int = field(
        default=0,
        metadata={
            "type": "Element",
        },
    )
    count: int | None = field(
        default=None,
        metadata={
            "type": "Element",
        },
    )
count: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
queries: list[FeatureQuery] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
start_index: int = field(default=0, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(queries: list[FeatureQuery], start_index: int = 0, count: int | None = None) -> None
output
Attribute dataclass

Bases: BaseInterface

An attribute belonging to a feature. The aim here is to drill down to simple types which can be used in consuming applications without further handling. This does not include the geometry attribute!

Attributes:

  • name (str) –

    The name of the attribute. Has to match with the name used for exported fields with Field class.

  • value (int | float | str | bool | bytes | None) –

    Value as simple as possible. It has to be pickleable

Source code in src/qgis_server_light/interface/job/feature/output.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@dataclass(repr=False)
class Attribute(BaseInterface):
    """An attribute belonging to a feature. The aim here is to
    drill down to simple types which can be used in consuming
    applications without further handling. This does not include
    the geometry attribute!

    Attributes:
        name: The name of the attribute. Has to match with the
            name used for exported fields with `Field` class.
        value: Value as simple as possible. It has to be
            [pickleable](https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled)

    """

    name: str = field(metadata={"type": "Element"})
    value: int | float | str | bool | bytes | None = field(
        metadata={"type": "Element", "format": "base64"}
    )
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
value: int | float | str | bool | bytes | None = field(metadata={'type': 'Element', 'format': 'base64'}) class-attribute instance-attribute
__init__(name: str, value: int | float | str | bool | bytes | None) -> None
Feature dataclass

Bases: BaseInterface

Feature to hold information of extracted QgsFeature.

Attributes:

Source code in src/qgis_server_light/interface/job/feature/output.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@dataclass(repr=False)
class Feature(BaseInterface):
    """Feature to hold information of extracted QgsFeature.

    Attributes:
        geometry: The geometry representing the feature.
        attributes: List of attributes defined in this feature.
    """

    geometry: Geometry | None = field(default=None, metadata={"type": "Element"})
    attributes: list[Attribute] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
attributes: list[Attribute] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
geometry: Geometry | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(geometry: Geometry | None = None, attributes: list[Attribute] = list()) -> None
FeatureCollection dataclass

Bases: BaseInterface

This construction is used to abstract the content of extracted features for pickelable transportation from QSL to the queue. This way we ensure how things are constructed and transported.

Attributes:

  • name (str) –

    The name of the feature collection. This is the key to match it to requested layers.

  • features (list[Feature]) –

    The features belonging to the feature collection.

Source code in src/qgis_server_light/interface/job/feature/output.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@dataclass(repr=False)
class FeatureCollection(BaseInterface):
    """This construction is used to abstract the content of extracted
    features for pickelable transportation from QSL to the queue.
    This way we ensure how things are constructed and transported.

    Attributes:
        name: The name of the feature collection. This is the key to
            match it to requested layers.
        features: The features belonging to the feature collection.
    """

    name: str = field(metadata={"type": "Element"})
    features: list[Feature] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
features: list[Feature] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(name: str, features: list[Feature] = list()) -> None
Geometry dataclass

Bases: Attribute

Source code in src/qgis_server_light/interface/job/feature/output.py
27
28
29
30
31
32
33
34
@dataclass(repr=False)
class Geometry(Attribute):
    name: str = field(default="geometry", metadata={"type": "Element"})
    value: bytes | None = field(default=None, metadata={"type": "Element", "format": "base64"})

    @property
    def shortened_fields(self) -> set:
        return {"value"}
name: str = field(default='geometry', metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
value: bytes | None = field(default=None, metadata={'type': 'Element', 'format': 'base64'}) class-attribute instance-attribute
__init__(name: str = 'geometry', value: bytes | None = None) -> None
QueryCollection dataclass

Bases: BaseInterface

Holds all feature collections which are bound to the passed queries. The order in the list has to be not changed, so that consuming applications can map the response to the passed queries.

Attributes:

Source code in src/qgis_server_light/interface/job/feature/output.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@dataclass(repr=False)
class QueryCollection(BaseInterface):
    """Holds all feature collections which are bound to the
    passed queries. The order in the list has to be not changed,
    so that consuming applications can map the response to the
    passed queries.

    Attributes:
        numbers_matched: Information about how many matches are fund for the executed query.
        feature_collections: The feature collections belonging to the passed queries.
    """

    numbers_matched: str | int = field(
        default="unknown",
        metadata={"type": "Element"},
    )
    feature_collections: list[FeatureCollection] = field(
        default_factory=list,
        metadata={"type": "Element"},
    )
feature_collections: list[FeatureCollection] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
numbers_matched: str | int = field(default='unknown', metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(numbers_matched: str | int = 'unknown', feature_collections: list[FeatureCollection] = list()) -> None

feature_info

input
QslJobInfoFeatureInfo dataclass

Bases: QslJobInfoParameter

Source code in src/qgis_server_light/interface/job/feature_info/input.py
42
43
44
@dataclass
class QslJobInfoFeatureInfo(QslJobInfoParameter):
    job: QslJobParameterFeatureInfo = field(metadata={"type": "Element", "required": True})
job: QslJobParameterFeatureInfo = field(metadata={'type': 'Element', 'required': True}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameterFeatureInfo, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobParameterFeatureInfo dataclass

Bases: QslJobParameter

A runner to extract feature info

Source code in src/qgis_server_light/interface/job/feature_info/input.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@dataclass(kw_only=True)
class QslJobParameterFeatureInfo(QslJobParameter):
    """A runner to extract feature info"""

    # mime type, only application/json supported
    INFO_FORMAT: str = field(metadata={"type": "Element"})
    QUERY_LAYERS: str = field(metadata={"type": "Element"})
    X: str | None = field(default=None, metadata={"type": "Element"})
    Y: str | None = field(default=None, metadata={"type": "Element"})
    I: str | None = field(default=None, metadata={"type": "Element"})  # noqa: E741
    J: str | None = field(default=None, metadata={"type": "Element"})

    def __post_init__(self):
        x = int(self.I or self.X)
        y = int(self.J or self.Y)
        if x is None or y is None:
            raise KeyError("Parameter `I` or `X` and `J` or `Y`  are mandatory for GetFeatureInfo")
        if self.QUERY_LAYERS is None:
            raise KeyError("QUERY_LAYERS is mandatory in this request")

    @property
    def decide_x(self) -> int:
        return int(self.I or self.X)

    @property
    def decide_y(self) -> int:
        return int(self.J or self.Y)

    @property
    def query_layers_list(self):
        return self.QUERY_LAYERS.split(",")
I: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
INFO_FORMAT: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
J: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
QUERY_LAYERS: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
X: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
Y: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
decide_x: int property
decide_y: int property
query_layers_list property
__init__(*, INFO_FORMAT: str, QUERY_LAYERS: str, X: str | None = None, Y: str | None = None, I: str | None = None, J: str | None = None) -> None
__post_init__()
Source code in src/qgis_server_light/interface/job/feature_info/input.py
21
22
23
24
25
26
27
def __post_init__(self):
    x = int(self.I or self.X)
    y = int(self.J or self.Y)
    if x is None or y is None:
        raise KeyError("Parameter `I` or `X` and `J` or `Y`  are mandatory for GetFeatureInfo")
    if self.QUERY_LAYERS is None:
        raise KeyError("QUERY_LAYERS is mandatory in this request")
output

legend

input
QslJobInfoLegend dataclass

Bases: QslJobInfoParameter

Source code in src/qgis_server_light/interface/job/legend/input.py
29
30
31
@dataclass
class QslJobInfoLegend(QslJobInfoParameter):
    job: QslJobParameterLegend = field(metadata={"type": "Element", "required": True})
job: QslJobParameterLegend = field(metadata={'type': 'Element', 'required': True}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameterLegend, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobParameterLegend dataclass

Bases: QslJobParameter

Render legend graphics for one or more layers.

Source code in src/qgis_server_light/interface/job/legend/input.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@dataclass(kw_only=True)
class QslJobParameterLegend(QslJobParameter):
    """Render legend graphics for one or more layers."""

    layers: list[QslJobLayer] = field(metadata={"type": "Element"})
    format: str = field(default="image/png", metadata={"type": "Element"})
    width: int | None = field(default=None, metadata={"type": "Element"})
    height: int | None = field(default=None, metadata={"type": "Element"})
    dpi: int = field(default=91, metadata={"type": "Element"})
    scale: float | None = field(default=None, metadata={"type": "Element"})
    layer_title: bool = field(default=False, metadata={"type": "Element"})

    def get_layer_by_name(self, name: str) -> QslJobLayer:
        for layer in self.layers:
            if layer.name == name:
                return layer
        raise LookupError(f'No layer with name "{name}" was found.')
dpi: int = field(default=91, metadata={'type': 'Element'}) class-attribute instance-attribute
format: str = field(default='image/png', metadata={'type': 'Element'}) class-attribute instance-attribute
height: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
layer_title: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
layers: list[QslJobLayer] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
scale: float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
width: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, layers: list[QslJobLayer], format: str = 'image/png', width: int | None = None, height: int | None = None, dpi: int = 91, scale: float | None = None, layer_title: bool = False) -> None
get_layer_by_name(name: str) -> QslJobLayer
Source code in src/qgis_server_light/interface/job/legend/input.py
22
23
24
25
26
def get_layer_by_name(self, name: str) -> QslJobLayer:
    for layer in self.layers:
        if layer.name == name:
            return layer
    raise LookupError(f'No layer with name "{name}" was found.')
output

process

description

This module contains the description of the processes a process-worker serves. It is shaped along the process description of OGC API - Processes - Part 1: Core (https://schemas.opengis.net/ogcapi/processes/part1/1.0/openapi/schemas/process.yaml), so a consumer can expose its elements as they are and only adds what belongs to the API around (links, job control options, conformance, ...).

Optional values default to None. Serialized with xsdata.formats.dataclass.serializers.dict.DictFactory.FILTER_NONE they are left out, which gives a plain JSON Schema for each Schema.

QSL_LAYER_FORMAT = 'qsl-layer' module-attribute
InputDescription dataclass

Bases: BaseInterface

The description of one input of a process.

OGC API - Processes holds the inputs as map by id. xsdata can't bind a map of dataclasses, therefore the id is part of the description and the inputs are a list.

Attributes:

  • id (str) –

    The identifier of the input, the QGIS parameter name.

  • title (str) –

    Human readable name.

  • description (str | None) –

    Human readable help text.

  • schema (Schema) –

    The schema of one value.

  • min_occurs (int) –

    The minimal number of values.

  • max_occurs (int | str) –

    The maximal number of values, unbounded for any.

Source code in src/qgis_server_light/interface/job/process/description.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
@dataclass(repr=False, kw_only=True)
class InputDescription(BaseInterface):
    """The description of one input of a process.

    OGC API - Processes holds the inputs as map by id. xsdata can't bind a map of
    dataclasses, therefore the id is part of the description and the inputs are a list.

    Attributes:
        id: The identifier of the input, the QGIS parameter name.
        title: Human readable name.
        description: Human readable help text.
        schema: The schema of one value.
        min_occurs: The minimal number of values.
        max_occurs: The maximal number of values, `unbounded` for any.
    """

    id: str = field(metadata={"type": "Element"})
    title: str = field(metadata={"type": "Element"})
    description: str | None = field(default=None, metadata={"type": "Element"})
    schema: Schema = field(metadata={"type": "Element"})
    min_occurs: int = field(default=1, metadata={"type": "Element", "name": "minOccurs"})
    max_occurs: int | str = field(default=1, metadata={"type": "Element", "name": "maxOccurs"})

    @property
    def shortened_fields(self) -> set:
        return {"description"}
description: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
max_occurs: int | str = field(default=1, metadata={'type': 'Element', 'name': 'maxOccurs'}) class-attribute instance-attribute
min_occurs: int = field(default=1, metadata={'type': 'Element', 'name': 'minOccurs'}) class-attribute instance-attribute
schema: Schema = field(metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, id: str, title: str, description: str | None = None, schema: Schema, min_occurs: int = 1, max_occurs: int | str = 1) -> None
OutputDescription dataclass

Bases: BaseInterface

The description of one output of a process. The id is part of the description, see InputDescription.

Attributes:

  • id (str) –

    The identifier of the output, the QGIS output name.

  • title (str) –

    Human readable name.

  • schema (Schema) –

    The schema of the value.

Source code in src/qgis_server_light/interface/job/process/description.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@dataclass(repr=False, kw_only=True)
class OutputDescription(BaseInterface):
    """The description of one output of a process. The id is part of the description,
    see `InputDescription`.

    Attributes:
        id: The identifier of the output, the QGIS output name.
        title: Human readable name.
        schema: The schema of the value.
    """

    id: str = field(metadata={"type": "Element"})
    title: str = field(metadata={"type": "Element"})
    schema: Schema = field(metadata={"type": "Element"})
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
schema: Schema = field(metadata={'type': 'Element'}) class-attribute instance-attribute
title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, id: str, title: str, schema: Schema) -> None
ProcessDescription dataclass

Bases: BaseInterface

The description of one process.

Attributes:

  • id (str) –

    The identifier of the process, the QGIS algorithm id.

  • title (str) –

    Human readable name.

  • description (str | None) –

    Human readable help text.

  • inputs (list[InputDescription]) –

    The inputs which are passed by the client. Destinations are not part of it, they are set by the worker.

  • outputs (list[OutputDescription]) –

    The outputs the process produces.

  • internal (bool | None) –

    If the process is for internal use of the consumer only and must not be published. Left out (None) for a publishable process.

Source code in src/qgis_server_light/interface/job/process/description.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@dataclass(repr=False, kw_only=True)
class ProcessDescription(BaseInterface):
    """The description of one process.

    Attributes:
        id: The identifier of the process, the QGIS algorithm id.
        title: Human readable name.
        description: Human readable help text.
        inputs: The inputs which are passed by the client. Destinations are not part of
            it, they are set by the worker.
        outputs: The outputs the process produces.
        internal: If the process is for internal use of the consumer only and must not be
            published. Left out (`None`) for a publishable process.
    """

    id: str = field(metadata={"type": "Element"})
    title: str = field(metadata={"type": "Element"})
    description: str | None = field(default=None, metadata={"type": "Element"})
    inputs: list[InputDescription] = field(default_factory=list, metadata={"type": "Element"})
    outputs: list[OutputDescription] = field(default_factory=list, metadata={"type": "Element"})
    internal: bool | None = field(default=None, metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"description"}
description: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
inputs: list[InputDescription] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
internal: bool | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
outputs: list[OutputDescription] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, id: str, title: str, description: str | None = None, inputs: list[InputDescription] = list(), outputs: list[OutputDescription] = list(), internal: bool | None = None) -> None
ProcessDescriptions dataclass

Bases: BaseInterface

The processes a process-worker serves (see RedisProtocol.worker_processes_key), or all process-workers together as the dispatcher merges them.

Attributes:

Source code in src/qgis_server_light/interface/job/process/description.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
@dataclass(repr=False)
class ProcessDescriptions(BaseInterface):
    """The processes a process-worker serves (see `RedisProtocol.worker_processes_key`),
    or all process-workers together as the dispatcher merges them.

    Attributes:
        processes: The description per process.
        warnings: The processes the workers don't agree on, only set by the dispatcher.
    """

    processes: list[ProcessDescription] = field(default_factory=list, metadata={"type": "Element"})
    warnings: list[ProcessWarning] = field(default_factory=list, metadata={"type": "Element"})

    def process_by_id(self, process_id: str) -> ProcessDescription:
        """
        Args:
            process_id: The identifier of the process.

        Raises:
            LookupError: If no process with this id is described.
        """
        for process in self.processes:
            if process.id == process_id:
                return process
        raise LookupError(f"Process `{process_id}` is not described")
processes: list[ProcessDescription] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
warnings: list[ProcessWarning] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(processes: list[ProcessDescription] = list(), warnings: list[ProcessWarning] = list()) -> None
process_by_id(process_id: str) -> ProcessDescription

Parameters:

  • process_id (str) –

    The identifier of the process.

Raises:

  • LookupError –

    If no process with this id is described.

Source code in src/qgis_server_light/interface/job/process/description.py
187
188
189
190
191
192
193
194
195
196
197
198
def process_by_id(self, process_id: str) -> ProcessDescription:
    """
    Args:
        process_id: The identifier of the process.

    Raises:
        LookupError: If no process with this id is described.
    """
    for process in self.processes:
        if process.id == process_id:
            return process
    raise LookupError(f"Process `{process_id}` is not described")
ProcessWarning dataclass

Bases: BaseInterface

Tells that the process-workers serving a process don't agree on it. They run different QGIS versions or describe the process differently, so a job behaves differently depending on the worker which takes it. The deployment needs to be corrected then.

Attributes:

  • process_id (str) –

    The identifier of the process.

  • qgis_versions (list[str]) –

    The QGIS versions of the workers serving the process, the newest first.

  • descriptions_differ (bool) –

    If the workers describe the process differently.

Source code in src/qgis_server_light/interface/job/process/description.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@dataclass(repr=False, kw_only=True)
class ProcessWarning(BaseInterface):
    """Tells that the process-workers serving a process don't agree on it. They run
    different QGIS versions or describe the process differently, so a job behaves
    differently depending on the worker which takes it. The deployment needs to be
    corrected then.

    Attributes:
        process_id: The identifier of the process.
        qgis_versions: The QGIS versions of the workers serving the process, the newest
            first.
        descriptions_differ: If the workers describe the process differently.
    """

    process_id: str = field(metadata={"type": "Element"})
    qgis_versions: list[str] = field(default_factory=list, metadata={"type": "Element"})
    descriptions_differ: bool = field(default=False, metadata={"type": "Element"})
descriptions_differ: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute
process_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
qgis_versions: list[str] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, process_id: str, qgis_versions: list[str] = list(), descriptions_differ: bool = False) -> None
QslLayerKind

Bases: Enum

The kinds of layer QSL can load as value of a process input.

Source code in src/qgis_server_light/interface/job/process/description.py
20
21
22
23
24
class QslLayerKind(Enum):
    """The kinds of layer QSL can load as value of a process input."""

    VECTOR = "vector"
    RASTER = "raster"
RASTER = 'raster' class-attribute instance-attribute
VECTOR = 'vector' class-attribute instance-attribute
QslLayerMarker dataclass

Bases: BaseInterface

Marks a schema whose value is a layer (QslJobLayer) instead of a literal. A consumer replaces the marked schema with the layers it offers which match the marker.

Attributes:

  • kinds (list[QslLayerKind]) –

    The kinds of layer which are accepted.

  • geometry_types (list[str]) –

    The geometry types of a vector layer which are accepted, named as qgis.core.Qgis.GeometryType (Point, Line, Polygon, Null). Matches Vector.geometry_type_simple of the exported project. Applies to vector layers only, empty when no vector layer is accepted.

  • source (str | None) –

    The class name of the QGIS parameter or output the marker was derived from.

Source code in src/qgis_server_light/interface/job/process/description.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@dataclass(repr=False)
class QslLayerMarker(BaseInterface):
    """Marks a schema whose value is a layer (`QslJobLayer`) instead of a literal. A
    consumer replaces the marked schema with the layers it offers which match the marker.

    Attributes:
        kinds: The kinds of layer which are accepted.
        geometry_types: The geometry types of a vector layer which are accepted, named as
            `qgis.core.Qgis.GeometryType` (`Point`, `Line`, `Polygon`, `Null`). Matches
            `Vector.geometry_type_simple` of the exported project. Applies to vector layers
            only, empty when no vector layer is accepted.
        source: The class name of the QGIS parameter or output the marker was derived from.
    """

    kinds: list[QslLayerKind] = field(metadata={"type": "Element"})
    geometry_types: list[str] = field(default_factory=list, metadata={"type": "Element"})
    source: str | None = field(default=None, metadata={"type": "Element"})
geometry_types: list[str] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
kinds: list[QslLayerKind] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
source: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(kinds: list[QslLayerKind], geometry_types: list[str] = list(), source: str | None = None) -> None
Schema dataclass

Bases: BaseInterface

The subset of JSON Schema which is used to describe the values of inputs and outputs.

Attributes:

  • type (str | None) –

    The JSON Schema type (string, number, integer, boolean, ...).

  • format (str | None) –

    The format of the value. Layer values carry QSL_LAYER_FORMAT.

  • title (str | None) –

    Human readable name, used on the entries of one_of.

  • minimum (int | float | None) –

    The inclusive minimum of a numeric value.

  • maximum (int | float | None) –

    The inclusive maximum of a numeric value.

  • const (bool | int | float | str | None) –

    The only valid value, used on the entries of one_of.

  • default (bool | int | float | str | None) –

    The value used when none is passed.

  • one_of (list[Schema] | None) –

    The valid values, each as schema with const and title. For a file output the formats it is offered in, each as schema with content_media_type, the first one is the default.

  • content_media_type (str | None) –

    The media type of a value which is a file.

  • x_qsl_layer (QslLayerMarker | None) –

    The marker of a layer value.

Source code in src/qgis_server_light/interface/job/process/description.py
46
47
48
49
50
51
52
53
54
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
@dataclass(repr=False, kw_only=True)
class Schema(BaseInterface):
    """The subset of JSON Schema which is used to describe the values of inputs and
    outputs.

    Attributes:
        type: The JSON Schema type (`string`, `number`, `integer`, `boolean`, ...).
        format: The format of the value. Layer values carry `QSL_LAYER_FORMAT`.
        title: Human readable name, used on the entries of `one_of`.
        minimum: The inclusive minimum of a numeric value.
        maximum: The inclusive maximum of a numeric value.
        const: The only valid value, used on the entries of `one_of`.
        default: The value used when none is passed.
        one_of: The valid values, each as schema with `const` and `title`. For a file
            output the formats it is offered in, each as schema with
            `content_media_type`, the first one is the default.
        content_media_type: The media type of a value which is a file.
        x_qsl_layer: The marker of a layer value.
    """

    type: str | None = field(default=None, metadata={"type": "Element"})
    format: str | None = field(default=None, metadata={"type": "Element"})
    title: str | None = field(default=None, metadata={"type": "Element"})
    minimum: int | float | None = field(default=None, metadata={"type": "Element"})
    maximum: int | float | None = field(default=None, metadata={"type": "Element"})
    const: bool | int | float | str | None = field(default=None, metadata={"type": "Element"})
    default: bool | int | float | str | None = field(default=None, metadata={"type": "Element"})
    one_of: list["Schema"] | None = field(
        default=None, metadata={"type": "Element", "name": "oneOf"}
    )
    content_media_type: str | None = field(
        default=None, metadata={"type": "Element", "name": "contentMediaType"}
    )
    x_qsl_layer: QslLayerMarker | None = field(
        default=None, metadata={"type": "Element", "name": "x-qsl-layer"}
    )
const: bool | int | float | str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
content_media_type: str | None = field(default=None, metadata={'type': 'Element', 'name': 'contentMediaType'}) class-attribute instance-attribute
default: bool | int | float | str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
format: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
maximum: int | float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
minimum: int | float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
one_of: list[Schema] | None = field(default=None, metadata={'type': 'Element', 'name': 'oneOf'}) class-attribute instance-attribute
title: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
type: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
x_qsl_layer: QslLayerMarker | None = field(default=None, metadata={'type': 'Element', 'name': 'x-qsl-layer'}) class-attribute instance-attribute
__init__(*, type: str | None = None, format: str | None = None, title: str | None = None, minimum: int | float | None = None, maximum: int | float | None = None, const: bool | int | float | str | None = None, default: bool | int | float | str | None = None, one_of: list[Schema] | None = None, content_media_type: str | None = None, x_qsl_layer: QslLayerMarker | None = None) -> None
input

This module contains the execute request of a process job. It is shaped along the execute request of OGC API - Processes - Part 1: Core (https://schemas.opengis.net/ogcapi/processes/part1/1.0/openapi/schemas/execute.yaml), carrying its inputs and outputs. OGC API - Processes holds them as maps by id, xsdata can't bind a map of dataclasses, therefore the id is part of each entry and they are lists (see InputDescription).

ExecuteInput dataclass

The value of one input of a process.

Attributes:

  • id (str) –

    The identifier of the input, the QGIS parameter name.

  • value (list[QslJobLayer | str | int | float | bool]) –

    The values of the input, one entry for an input taking a single value. A layer value is substituted in place by its QslJobLayer.

Source code in src/qgis_server_light/interface/job/process/input.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@dataclass
class ExecuteInput:
    """The value of one input of a process.

    Attributes:
        id: The identifier of the input, the QGIS parameter name.
        value: The values of the input, one entry for an input taking a single value. A
            layer value is substituted in place by its `QslJobLayer`.
    """

    id: str = field(metadata={"type": "Element"})
    value: list[QslJobLayer | str | int | float | bool] = field(
        default_factory=list, metadata={"type": "Element"}
    )
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
value: list[QslJobLayer | str | int | float | bool] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, value: list[QslJobLayer | str | int | float | bool] = list()) -> None
ExecuteOutput dataclass

The format a client wants a file output in.

Attributes:

  • id (str) –

    The identifier of the output, the QGIS output name.

  • format (Format) –

    The format the output is written in.

Source code in src/qgis_server_light/interface/job/process/input.py
45
46
47
48
49
50
51
52
53
54
55
@dataclass
class ExecuteOutput:
    """The format a client wants a file output in.

    Attributes:
        id: The identifier of the output, the QGIS output name.
        format: The format the output is written in.
    """

    id: str = field(metadata={"type": "Element"})
    format: Format = field(metadata={"type": "Element"})
format: Format = field(metadata={'type': 'Element'}) class-attribute instance-attribute
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, format: Format) -> None
Format dataclass

The format of a file output.

Attributes:

  • media_type (str) –

    One of the media types the description offers for the output.

Source code in src/qgis_server_light/interface/job/process/input.py
34
35
36
37
38
39
40
41
42
@dataclass
class Format:
    """The format of a file output.

    Attributes:
        media_type: One of the media types the description offers for the output.
    """

    media_type: str = field(metadata={"type": "Element", "name": "mediaType"})
media_type: str = field(metadata={'type': 'Element', 'name': 'mediaType'}) class-attribute instance-attribute
__init__(media_type: str) -> None
QslJobInfoExecuteProcess dataclass

Bases: QslJobInfoParameter

The job of a process execution, queued with RedisStateQueue.submit.

Source code in src/qgis_server_light/interface/job/process/input.py
74
75
76
77
78
@dataclass
class QslJobInfoExecuteProcess(QslJobInfoParameter):
    """The job of a process execution, queued with `RedisStateQueue.submit`."""

    job: QslJobParameterExecuteProcess = field(metadata={"type": "Element", "required": True})
job: QslJobParameterExecuteProcess = field(metadata={'type': 'Element', 'required': True}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameterExecuteProcess, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobParameterExecuteProcess dataclass

Bases: QslJobParameter

The execute request of a process.

Attributes:

  • process_id (str) –

    The identifier of the process, the QGIS algorithm id.

  • inputs (list[ExecuteInput]) –

    The values of the inputs, an input which is left out takes its default.

  • outputs (list[ExecuteOutput]) –

    The formats chosen for file outputs, an output which is left out is written in the first format its description offers.

Source code in src/qgis_server_light/interface/job/process/input.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@dataclass(kw_only=True)
class QslJobParameterExecuteProcess(QslJobParameter):
    """The execute request of a process.

    Attributes:
        process_id: The identifier of the process, the QGIS algorithm id.
        inputs: The values of the inputs, an input which is left out takes its default.
        outputs: The formats chosen for file outputs, an output which is left out is
            written in the first format its description offers.
    """

    process_id: str = field(metadata={"type": "Element"})
    inputs: list[ExecuteInput] = field(default_factory=list, metadata={"type": "Element"})
    outputs: list[ExecuteOutput] = field(default_factory=list, metadata={"type": "Element"})
inputs: list[ExecuteInput] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
outputs: list[ExecuteOutput] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
process_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, process_id: str, inputs: list[ExecuteInput] = list(), outputs: list[ExecuteOutput] = list()) -> None
output

This module contains the result of a process job. It is shaped along the results of OGC API - Processes - Part 1: Core (https://schemas.opengis.net/ogcapi/processes/part1/1.0/openapi/schemas/results.yaml), per output either the literal value or a reference to the file. The outputs are a list of entries with their id instead of a map by id, see ExecuteInput.

ProcessResult dataclass

Bases: BaseInterface

The result of a process. A worker ships it as xsdata JSON in the data of the JobResult, so the dispatcher can parse it back without knowing anything about QGIS.

Attributes:

  • outputs (list[ResultOutput]) –

    The outputs of the process.

  • log (str) –

    The log the QGIS algorithm wrote while it was running. It has no place in the results of OGC API - Processes and travels next to the outputs.

Source code in src/qgis_server_light/interface/job/process/output.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@dataclass(repr=False)
class ProcessResult(BaseInterface):
    """The result of a process. A worker ships it as xsdata JSON in the data of
    the `JobResult`, so the dispatcher can parse it back without knowing
    anything about QGIS.

    Attributes:
        outputs: The outputs of the process.
        log: The log the QGIS algorithm wrote while it was running. It has no place in
            the results of OGC API - Processes and travels next to the outputs.
    """

    outputs: list[ResultOutput] = field(default_factory=list, metadata={"type": "Element"})
    log: str = field(default="", metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"log"}
log: str = field(default='', metadata={'type': 'Element'}) class-attribute instance-attribute
outputs: list[ResultOutput] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute
shortened_fields: set property
__init__(outputs: list[ResultOutput] = list(), log: str = '') -> None
Reference dataclass

A file a process wrote into the process output dir of the worker.

Attributes:

  • href (str) –

    The path of the file relative to the process output dir.

  • type (str) –

    The media type of the file.

Source code in src/qgis_server_light/interface/job/process/output.py
13
14
15
16
17
18
19
20
21
22
23
@dataclass
class Reference:
    """A file a process wrote into the process output dir of the worker.

    Attributes:
        href: The path of the file relative to the process output dir.
        type: The media type of the file.
    """

    href: str = field(metadata={"type": "Element"})
    type: str = field(metadata={"type": "Element"})
href: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
type: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(href: str, type: str) -> None
ResultOutput dataclass

A single output of a process, the counterpart of ExecuteInput.

Attributes:

  • id (str) –

    The identifier of the output, the QGIS output name.

  • value (Reference | str | int | float | bool) –

    The file the output was written to, or the literal value of the output.

Source code in src/qgis_server_light/interface/job/process/output.py
26
27
28
29
30
31
32
33
34
35
36
37
@dataclass
class ResultOutput:
    """A single output of a process, the counterpart of `ExecuteInput`.

    Attributes:
        id: The identifier of the output, the QGIS output name.
        value: The file the output was written to, or the literal value of the
            output.
    """

    id: str = field(metadata={"type": "Element"})
    value: Reference | str | int | float | bool = field(metadata={"type": "Element"})
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
value: Reference | str | int | float | bool = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, value: Reference | str | int | float | bool) -> None

render

input
QslJobInfoRender dataclass

Bases: QslJobInfoParameter

Source code in src/qgis_server_light/interface/job/render/input.py
30
31
32
@dataclass
class QslJobInfoRender(QslJobInfoParameter):
    job: QslJobParameterRender = field(metadata={"type": "Element", "required": True})
job: QslJobParameterRender = field(metadata={'type': 'Element', 'required': True}) class-attribute instance-attribute
__init__(id: str, type: str, job: QslJobParameterRender, execution_mode: ExecutionMode = ExecutionMode.SYNC) -> None
QslJobParameterRender dataclass

Bases: QslJobParameter

A runner to be rendered as an image

Source code in src/qgis_server_light/interface/job/render/input.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@dataclass(kw_only=True)
class QslJobParameterRender(QslJobParameter):
    """A runner to be rendered as an image"""

    layers: list[QslJobLayer] = field(metadata={"type": "Element"})
    bbox: BBox = field(metadata={"type": "Element"})
    crs: str = field(metadata={"type": "Element"})
    width: int = field(metadata={"type": "Element"})
    height: int = field(metadata={"type": "Element"})
    dpi: int | None = field(default=None, metadata={"type": "Element"})
    format: str = field(default="image/png", metadata={"type": "Element"})

    def get_layer_by_name(self, name: str) -> QslJobLayer:
        for layer in self.layers:
            if layer.name == name:
                return layer
        raise LookupError(f'No layer with name "{name}" was found."')
bbox: BBox = field(metadata={'type': 'Element'}) class-attribute instance-attribute
crs: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
dpi: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute
format: str = field(default='image/png', metadata={'type': 'Element'}) class-attribute instance-attribute
height: int = field(metadata={'type': 'Element'}) class-attribute instance-attribute
layers: list[QslJobLayer] = field(metadata={'type': 'Element'}) class-attribute instance-attribute
width: int = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(*, layers: list[QslJobLayer], bbox: BBox, crs: str, width: int, height: int, dpi: int | None = None, format: str = 'image/png') -> None
get_layer_by_name(name: str) -> QslJobLayer
Source code in src/qgis_server_light/interface/job/render/input.py
23
24
25
26
27
def get_layer_by_name(self, name: str) -> QslJobLayer:
    for layer in self.layers:
        if layer.name == name:
            return layer
    raise LookupError(f'No layer with name "{name}" was found."')
output

worker

info

This part defines the structure how a running QSL worker exposes its capabilities.

EngineInfo dataclass
Source code in src/qgis_server_light/interface/worker/info.py
33
34
35
36
37
38
@dataclass
class EngineInfo:
    id: str = field(metadata={"type": "Element"})
    qgis_info: QgisInfo = field(metadata={"type": "Element"})
    status: Status = field(metadata={"type": "Element"})
    started: float = field(metadata={"type": "Element"})
id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
qgis_info: QgisInfo = field(metadata={'type': 'Element'}) class-attribute instance-attribute
started: float = field(metadata={'type': 'Element'}) class-attribute instance-attribute
status: Status = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(id: str, qgis_info: QgisInfo, status: Status, started: float) -> None
QgisInfo dataclass

Information container to ship minimal knowledge of the underlying QGIS.

Attributes:

  • version (int) –

    The integer representation of the QGIS version e.g. 34400

  • version_name (str) –

    The string representation which also includes the codename e.g. "QGIS Version 4.0.0-Norrköping"

Source code in src/qgis_server_light/interface/worker/info.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@dataclass
class QgisInfo:
    """
    Information container to ship minimal knowledge of the underlying
    QGIS.

    Attributes:
        version: The integer representation of the QGIS version e.g. 34400
        version_name: The string representation which also includes the codename e.g.
            "QGIS Version 4.0.0-Norrköping"

    """

    version: int = field(metadata={"type": "Element"})
    version_name: str = field(metadata={"type": "Element"})
    path: str = field(metadata={"type": "Element"})
path: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
version: int = field(metadata={'type': 'Element'}) class-attribute instance-attribute
version_name: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute
__init__(version: int, version_name: str, path: str) -> None
Status

Bases: StrEnum

Source code in src/qgis_server_light/interface/worker/info.py
 8
 9
10
11
12
class Status(StrEnum):
    STARTING = "starting"
    CRASHED = "crashed"
    WAITING = "waiting"
    PROCESSING = "processing"
CRASHED = 'crashed' class-attribute instance-attribute
PROCESSING = 'processing' class-attribute instance-attribute
STARTING = 'starting' class-attribute instance-attribute
WAITING = 'waiting' class-attribute instance-attribute