Enforcing Business Rules in CGA Code

180510_10

One great capability of rules-based architecture is that code can reflect, well… RULES like zoning regulations, laws, ordinances, policies, and other constraints: we can program our models to automatically restrict building types to houses, garages and outbuildings in a single-family residential area; restrict building heights to 25 meters in suburban areas; set and enforce setback requirements in areas zoned as Commercial.

Here are two examples from within the rule files of ESRI’s 3D Transect tutorial:

File: Buildings_Advanced_Building/Support/Zoning.cga

We start by using constants (unchangable values) to set up two transect * areas, T1 and T6. The text in quotes to the right of the "equals" sign * is what will appeear in the shape inspector drop down menu.

const Transect_T1 = "T1 Natural" 
const Transect_T2 = "T2 Rural"

The constant value "transect" is passed along to the floorCountMinPerTransect and * floorCountMaxPerTransect rules via the parenthesis. Based on the value, the minimum/maximum floor count for a building is 1/1 in Transect Area T1 and 4/8 in Transect Area T6.

floorCountMinPerTransect(transect) = 
 case transect == Transect_T1: 1
 case transect == Transect_T6: 4
 else: 1
 
floorCountMaxPerTransect(transect) = 
 case transect == Transect_T1: 1
 case transect == Transect_T6: 8
 else: 1

In the illustration at the top of the page, there are six dropdowns where we can set values for floor counts within buildings divided into use zones. The code below sets the two dropdown boxes for Zone 2 parameters under the "USAGE" section.

@Group ("USAGE") @Order(12) 
@Range(0,5) 
attr Zone_2_Floor_Count = 0 
@Range("None", "Commercial", "Office", "Residential", "Parking", "Other") 
attr Zone_2_Usage = "Office"

The illustration shows 10 Office floors have been programmed for Zone 2. This code counts or "indexes" the number of floors in each zone in a building and assigns usage to individual floors accordingly:

If the floor number is greater or equal to the designated start floor for Zone 1 AND of if is less than or equal to the highest numbered floor of Zone 1, then the Zone_1_Usage parameter is assigned to the floor... and so on up the structure.

usagePerFloor(floorNumber) =
      case Zone_1_Floor_Count <= 0: Zone_1_Usage
      case floorNumber >= zone1StartFloor && floorNumber <= zone1EndFloor: 
          Zone_1_Usage
      case floorNumber >= zone2StartFloor && floorNumber <= zone2EndFloor: 
          Zone_2_Usage
      case floorNumber >= zone3StartFloor && floorNumber <= zone3EndFloor: 
          Zone_3_Usage
      else: ""

To see building use zones as in the next figure, go to "Display Options" group at the top of the inspector and select Display Thematics > Usage.

With these rules in place, you cannot accidentally violate the parameters.  Your options will be presented to you within the shape inspector. Rules can sometimes be overridden by entering new values in the form for a particular shape.

*   *   *   *   *

Leave a Reply

Your email address will not be published. Required fields are marked *