Toggle menu

Geographical Querying

You can make location based queries to find indexed process instances and tasks that contain geographical data stored in a named process variable. Both getQueryProcesses and getQueryTasks support filters that will return data within a rectangle or a set distance from a point.

Creating Geographical Data

If the forms used in workflow processes include fields that capture location data, that data can be used in the filters for querying tasks and processes. For location data to be indexed into the search, the "summary form" used by the process (set in the Workflow - Start Action field) must include the field you want to be indexed. By default the summary form is the same form as the one used to start the process.

The standard fields that capture location data are:

These input fields must also be set as "searchable". This is done in the field settings:

Setting a field as searchable

Once a searchable location field exists in the form definition, and has been passed to your process as a variable, it can be updated in your process model with new long/lat coordinates. To create searchable location data within your process model (eg via script activities) create placeholder variables in your forms using the hidden location field then set the value in your process.

Query Filters

The following three predicates are supported. They can be used with getQueryProcesses and getQueryTasks.

The key for each is the name of the process variable that contains the location data.

GEOGKEYEXISTS

Checks that a key exists and that it contains geographic data. It then returns/excludes processes depending upon the operator it is used with. Its value should be the name of the variable to test.

Example

This query would return all process instances that have this variable containing location data.

function(params, credentials) {
    let result = this.callWorkerMethod("workflow", "getQueryProcesses", {
        "useQueryService": true,
        "filter": {
            "GEOGKEYEXISTS": "form_LOCATIONPICKERFIELD"
        }
    });
    return result;
}

GEOGDISTLT

Filters by processes containing geographic data a given distance from a point.

PropertyTypeDescription
KeyString, requiredThe name of the variable containing the location data
GEOGDISTLTInteger, requiredThe distance in metres from the supplied point
toObject, requiredThe point to test from
to.typeString, requiredAlways Point
to.coordinatesArray, requiredLong/lat coordinates representing a point

Example

This example combines two operators using AND. It limits the search to tasks of a single process within 4000 metres of a point.

function(params, credentials) {
    let result = this.callWorkerMethod("workflow", "getQueryTasks", {
        "useQueryService": true,
        "filter": {
            "AND": [{
                "key": "form_LOCATIONPICKERFIELD",
                "GEOGDISTLT": 4000,
                "to": {
                    "type": "Point",
                    "coordinates": [
                        -0.1847076416015625, 51.465130385364795
                    ]
                }
            }, {
                "key": "processDefinitionKey",
                "EQ": "timsgeotest"
            }]
        }
    });
    return result;
}

GEOGWITHIN

Filters by processes containing geographic data within a polygon. Note that only rectangles are currently supported.

PropertyTypeDescription
keyString, requiredThe name of the variable containing the location data
GEOGWITHINObject, requiredThe area to check within
GEOGWITHIN.typeString, requiredAlways Polygon
GEOGWITHIN.coordinatesArray, requiredLong/lat coordinates representing a rectangle

Example

This example returns all process instances of any type that have location data (stored in the named variable) within a rectangle.

function(params, credentials) {
    let result = this.callWorkerMethod("workflow", "getQueryProcesses", {
        "useQueryService": true,
        "filter": {
            "key": "form_LOCATIONPICKERFIELD",
            "GEOGWITHIN": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [-0.1847076416015625, 51.465130385364795],
                        [-0.03398895263671874, 51.465130385364795],
                        [-0.03398895263671874, 51.519852590742715],
                        [-0.1847076416015625, 51.519852590742715],
                        [-0.1847076416015625, 51.465130385364795]
                    ]
                ]
            }
        }
    });
    return result;
}

Last modified on August 01, 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon