Skip to content

Define relations between features

rinzeb edited this page Mar 25, 2016 · 2 revisions

Feature relations

Defining relations between features is done by defining a PropertyType in the feature's ResourceType. Several options are available to specify which features should be linked. These include the scope of the search (all layers, specific layers, current layer) and what keys to search (propertyKey or Feature ID). Three properties define the behaviour:

  • subject: the search value. Defaults to the feature ID when not specified. Specifying a string will use the value of the feature property (feature.properties[subject])
  • target: the searched item. Defaults to the feature ID when not specified. Specifying a string will use the value of the feature property (feature.properties[target])
  • targetlayers: the layers to search in. Defaults to the layer of the selected feature when not specified. Specifying a stringarray of ID's will search all layers with those ID's. Specifying a wildcard ['*'] will search in all layers.

Example

As an example, we show how an event that triggers several tasks can be linked. We define two relations: the first lists all tasks that belong to a certain event. This will be shown when you click an event. The second lists the event(s) a certain task belongs to, which will be shown when you select the task.

In the ResourceType, define a new PropertyType:

"eventtasks": {
    "label": "eventtasks",
    "title": "Event tasks",
    "description": "The tasks for this event",
    "type": "relation",
    "target": "event_id",
    "subject": null,
    "targetlayers": null,
    "visibleInCallOut": true,
    "canEdit": false
}

The target 'event_id' specifies that we should search in the value of property with key 'event_id'. In case you want to search for a feature's id instead of a property value, set it to null.

The value we will be searching for is the "subject". In this example it is null, which means the search value will be the selected feature id.

Because 'targetlayers' is null, only the current layer is searched. This means that your events and tasks should be in the same layer! In case you want to search in another layer, change it to e.g. "targetlayers": ["layerIdOfTasks"] to search in another layer, or to "targetlayers": ["*"] to search in all layers.

If we now add the PropertyType 'eventtasks' to the PropertyKeys, the relations will be shown in the RightPanel when you select an event.

Feature relations

The relation can also be reversed, such that the parent event will be showns when you select a task. The code to achieve this is:

"taskevent": {
    "label": "taskevent",
    "title": "Parent event",
    "description": "The event this task belongs to",
    "type": "relation",
    "target": null,
    "targetlayers": null,
    "subject": "event_id",
    "visibleInCallOut": true,
    "canEdit": false
},

Don't forget to add "taskevent" to the propertyKeys of you "Task"-featureType.