gisserver.extensions.functions module

Functions to be callable from query filters.

By using the function_registry, custom stored functions can be registered in this server. These are called by the filter queries using the Function element. Out of the box, various built-in functions are present.

Built-in options are documented in Using Functions.

Most of the out-of-the box options are inspired by GeoServer. Functions which already have a fes-syntax equivalent have been are omitted.

class gisserver.extensions.functions.FesFunction(name: str, body: Func | Callable[[...], Func], arguments: dict[str, XsdTypes] | None = None, returns: XsdTypes | None = None)

Bases: object

A registered database function that can be used by <fes:Function name="...">.

The Function class will resolve these registered functions by name, and call build_query() to include them in the database query. This will actually insert a Django ORM function in the query!

This wrapper class also provides the metadata and type descriptions of the function, which is exposed in the GetCapabilities call.

__init__(name: str, body: Func | Callable[[...], Func], arguments: dict[str, XsdTypes] | None = None, returns: XsdTypes | None = None) None
arguments: dict[str, XsdTypes] | None = None

The argument names with their XSD types

body: Func | Callable[[...], Func]

The function body

build_query(*expressions: Combinable | Q) Func

Build the query expression for the function.

name: str

Name of the function

returns: XsdTypes | None = None

The XSD return type

class gisserver.extensions.functions.FesFunctionRegistry

Bases: object

Registry of functions to be callable by <fes:Function>.

The registered functions should be capable of running an SQL function.

__init__()
register(name=None, body: Func | Callable[[...], Func] | None = None, *, arguments: dict[str, XsdTypes] | None = None, returns: XsdTypes | None = None)

Decorator to register a function.

It’s not recommended to register the Django Func objects directly, as the parameters are passed on from the client-side. Instead, create a wrapper function that enforces a controlled set of parameters.

resolve_function(function_name) FesFunction

Resole the function using its name.

gisserver.extensions.functions.function_registry = <gisserver.extensions.functions.FesFunctionRegistry object>

The function registry