Parameterized Rule

Rules can be parameterized, i.e. a parameter signature can be defined and the matching signature is chosen during generation.

Note: No explicit parameter type is required, the CGA compiler automatically finds the simple type of the parameter. There are three simple types in the CGA grammar: float, boolean and string. The float type is used for all numbers (also integers).

Example 1

Lot               --> s(’0.8,’1,’0.8) 
Footprint(height) --> extrude(height*0.8) 
During execution of rule Lot, a new shape with shape symbol Footprint and float parameter "20" is generated. During execution of rule lot, the height parameter will have the value 20. Note that arbitrary mathematical expressions can be built with float parameters.

Example 2

Lot                    --> s(’0.8,’1,’0.8) 

Footprint(height,area) --> t(0,0,1) 

Envelope(area)         --> split(y){ ~4 : Floor(area) }*

Here, the Footprint rule takes two parameters and the Envelope as well as the Floor rule takes one parameter. Note how area is passed from rule to rule.

Example 3

Lot                    --> Footprint("just an example")

Footprint(height,area) --> t(0,0,1) 
Footprint(text)        --> print(text)

Finally, rule overloading is shown in example 3. There are two Footprint rules, one with two float parameters and one with one string parameter. The compiler automatically makes sure that only the matching one is used during shape creation (i.e. during execution of the Lot rule above, a Footprint shape with a string parameter is created).

Note: If no matching rule exists a new leaf is generated.


Copyright ©2008-2016 Esri R&D Center Zurich. All rights reserved.