Working with Rules
Rules should be built with a specific question in mind:
"What does the Rule need to check about an object from a class to identify whether it conforms to the standards being worked to?"
Identifying what individual questions need to be asked about an object and/or its attributes will help you develop your Rule. Each question will return True or False, filtering out more objects with each question asked.
Note: While Rules can be built without worrying about the ordering too much, the efficiency can be increased by making sure to Order Predicates Efficiently.
There are two main types of Rule: one that checks a single object and those that check an object against another.
Rules that check an object
A simple Rule may only check the attributes of an object, for example it could:
-
Check the geometry is of a certain type.
-
Check that an attribute is not null.
-
If one attribute is set to X then check the other attribute is set to Y.
These are handled by having Predicates, such as a Check That, operating with other Predicates, such as an If…Then…Else or a logical operator; AND, OR, and NOT.
Rules that check other objects
More complex Rules check the current object against other loaded objects, for example:
-
Check that a building's geometry does not sit on top of other objects.
-
Check that a valve is connected by two pipes.
-
Check that an attribute has a Value from a specified class of allowed Values.
Note: When checking an object against one of the same type, make sure to use Name Parameters to differentiate the two instances.
The techniques below are used to identify the other objects, which are subsequently used to perform checks against. Ultimately, the eventual checks are typically comparisons (X=Y), range checks (X=[1..5]) or reference checks (is there a reference, such as a foreign key, defined between these objects?).
Existence
When you are interested in the number of other objects, Existence will return 'True' if it identifies the correct number of objects that meet a set criteria.
Example: 'This building MUST have no other overlapping buildings', 'This valve MUST have two connected pipes' and 'This object MUST have an attribute Value that equals one other object Value from a class of allowed Values'.
For All
When you want to see if any instances of an object meet a set criteria, it will return 'True' if any instance does.
This is often used to check that everything is correct and not in need of fixing.
Example: 'Are there any pipes with X pressure', 'Do any areas contain more than one Fire Station' and 'For all houses within 500m of a fibre optics network box, are any not connected'.
For the Nearest
This checks for the closest n number of objects to the current object and sees if they fulfil a criteria.
Example: 'Is the nearest street name present in a building's address'
An optional filter will only count closest objects that meet another criteria first.
Example: 'Are the nearest buildings residential and are they not blocks of flats.'
Aggregate Functions
Aggregate Functions are a Value rather than a Predicate; they return a single Value (count, sum, average, or other function) calculated by visiting a number of related objects such as, the maximum voltage of all connected cables. This also works for geometries (e.g. find the union of the objects' geometries).
The result of the Aggregate Function can then be used in a Predicate.
Example: 'Check that the union of all referenced road centrelines is a single-part geometry'