# Template

(Difference between revisions)
 Revision as of 16:30, 20 March 2020 (view source)Martin (Talk | contribs)← Older edit Revision as of 12:16, 25 March 2020 (view source)Martin (Talk | contribs) Newer edit → Line 15: Line 15: The following example shows a template used to: The following example shows a template used to: * Calculate the farest distance of two distance attributes and * Calculate the farest distance of two distance attributes and - * Call another template that aggregates the results to different spatial levels + * [[Case instantion|Instantiate another template]] that aggregates the results to different spatial levels Template CombineDistWithANDcond Template CombineDistWithANDcond

## Introduction

In modelling with data, it is often useful to apply the same model logic on different sets of parameters. The GeoDMS therefore uses templates.

A template is defined as a set of calculation rules (model logic) with at least one case parameter.

A template can be compared with a function in a programming language.

In a template data items can not be calculated, as the value(s) for the case parameter(s) are not known. To calculate the results, values need to be set for the case parameters.

A case is defined as an instantiated template with values set for each case parameter.

With the GeoDMS results of cases can easily be compared, as results of multiple cases can be available as different tree items simultaneously.

## How to configure a template

The following example shows a template used to:

• Calculate the farest distance of two distance attributes and
• Instantiate another template that aggregates the results to different spatial levels
```Template CombineDistWithANDcond
{
// begin case parameters
attribute<meter> dist1 (bag/vbo);
attribute<meter> dist2 (bag/vbo);
// end case parameters

attribute<meter> farest_dist (bag/vbo) := max_elem(dist1, dist1);

container aggregations := Aggtemplate(farest_dist);
}
```

## Name

The template CombineDistWithANDcond is the parent item of the template and also in use as name of the template.

## Case parameters

In the example two case parameter are configured: dist1 and dist2. Case parameters are always configured as the first subitems of the template.

## Model logic

After the configuration of the case parameters, an attribute and a container are configured. These items contain the model logic of this template.The case parameters are suppliers of the first attribute. This first attribute is supplier in the expression of the second item, the container aggregations. This container calls another template, called Aggtemplate and uses the first attribute as case parameter for this Aggtemplate to configure a case instantion.

This way a nested structure of templates calling other templates can be set up.

## Original Syntax

Until GeoDMS version 7.120 the syntax:

```container templateName: IsTemplate = "True"
```

was used.

This syntax is still supported, but the new syntax is advised as it is shorter.