An insight can be defined by either:
- Starting from scratch by configuring it with a combination of parameters, operators, and constants that determine if a matching Event is forecasted to occur
- Starting from any of our rich collection of Templates, based on real industry use-cases
- Subscribing to an Insight Category (that encompasses various similar events reported by our sources)
- Insights are current supported only for the metric system
You can create an insight by either our Rules language (Recommended), or using conditions - AST Trees,
Rules Language (Recommended)
The language is a simplified expression language designed to create dynamic conditions for querying insights in the API. This document provides an overview of the operators and syntax available in language.
Operators
The following table lists the operators available in language:
Operator | Description | Example |
---|---|---|
AND | Logical AND | (temperature > 30 AND cloudCover IS NULL) |
OR | Logical OR | (windSpeed > 100 OR humidity < 10) |
> | Greater Than | temperature > 30 |
< | Less Than | cloudCeiling < 3000 |
>= | Greater Than or Equal To | snowAccumulation >= 10 |
<= | Less Than or Equal To | windDirection <= 180 |
== | Equal To | windSpeed == 20 |
IS NULL | Check if parameter is null | cloudCover IS NULL |
! | Negation (NOT operator) | !(temperature > 30) |
Syntax
The syntax of the language is based on simple expressions composed of parameters, comparison operators, and logical operators. Here's a breakdown of the syntax elements:
Parameters: Parameters represent the values you want to compare. For example, "temperature", "windSpeed", or "cloudCover" can be parameters in your conditions.
Comparison Operators: Comparison operators allow you to compare parameters with constants or other parameters. Examples of comparison operators include >, <, >=, <=, and ==. These operators are used to create conditional statements within your expressions.
Logical Operators: Logical operators enable you to combine multiple conditions. the language supports the logical AND operator (AND), which evaluates to true only if all conditions are true, and the logical OR operator (OR), which evaluates to true if any of the conditions are true.
Negation Operator: The negation operator, represented by !, allows you to negate a condition. It negates the result of the condition, effectively flipping its logical value.
IS NULL Operator: The "IS NULL" operator checks if a parameter is null. It is used to specifically validate if a parameter holds a null value.
Examples
To help you understand how to use the language, here are a few examples of valid expressions and their interpretations:
Example 1:
Expression: !(hailBinary == 0)
Interpretation: Select insights where the hailBinary is not equal to 0.
Example 2:
Expression: (temperature > 30 AND cloudCover IS NULL)
Interpretation: Select insights where the temperature is greater than 30 and the cloudCover parameter is null.
Example 3:
Expression: (windSpeed > 100 OR humidity < 10)
Interpretation: Select insights where the windSpeed is greater than 100 or the humidity is less than 10.
Example 4:
Expression: temperature > 30
Interpretation: Select insights where the temperature is greater than 30.
Example 5:
Expression: !(snowAccumulation >= 10)
Interpretation: Select insights where the snowAccumulation is not greater than or equal to 10.
Example 8:
Expression: ( (temperature > 30 AND cloudCover IS NULL) OR (windSpeed > 20 AND !( (rainIntensity > 10 AND snowAccumulation IS NULL) OR humidity < 50 )) )
Interpretation: Select insights where either:
The temperature is greater than 30 and the cloudCover is null, or
The windSpeed is greater than 20 and neither of the following conditions are met:
The rainIntensity is greater than 10 and the snowAccumulation is null, or
The humidity is less than 50.
Conditions Language (AST Trees)
The simplest form of a condition consists of an OPERATOR
, a PARAMETER
, and a CONST
. When the engine runs, the operator is used to compare the parameter against the constant. If the result is truthy, the condition passes.
Each operator node has three properties:
type
: astring
that sets the type of the node - alwaysOPERATOR
content
: anobject
that contains the definition of the operator - for exampleoperator: AND
children
: anarray
with the collection of chained conditions
{
"type": "OPERATOR",
"content": {
"operator": "AND"
},
"children": [{
"type": "OPERATOR",
"content": {
"operator": "EQUAL"
},
"children": [{
"type": "PARAMETER",
"content": {
"parameter": "precipitationType"
}
},
{
"type": "CONST",
"content": {
"const": 1
}
}
]
},
{
"type": "OPERATOR",
"content": {
"operator": "GREATER"
},
"children": [{
"type": "PARAMETER",
"content": {
"parameter": "precipitationIntensity"
}
},
{
"type": "CONST",
"content": {
"const": 0.5
}
}
]
}
]
}
Logical Operators:
These operators must have at least two child nodes, of type OPERATOR
. Notice that AND
and OR
can be nested within one another to produce complex boolean expressions. These operators must have at least two children.
Operator | Description |
---|---|
AND | specifies that all child conditions contained within must be truthy for the condition to be considered a success |
OR | requires one child condition to be truthy for the condition to succeed |
Comparison Operators:
These operators must have one child node of type PARAMETER
and another of type CONST
in this order, such that their value types match. For example precipitationType
can only have string values and therefor the constant it is compared against must be a string.
Operator | Description |
---|---|
GREATER | PARAMETER must be greater than CONST to be considered truthy |
GREATER_EQUAL | PARAMETER must be greater than or equal to CONST to be considered truthy |
LESS | PARAMETER must be less than CONST to be considered truthy |
LESS_EQUAL | PARAMETER must be less than or equal to CONST to be considered truthy |
EQUAL | PARAMETER must equal CONST to be considered truthy |
Time Operator:
These operators must have two child nodes, either PARAMETER
or CONST
types, such that they describe a time period within a single day (00:00 until 23:59) in a monitored Location's timezone. Using sunriseTime
and sunsetTime
parameter that match the Location's specific times.
Operator | Description |
---|---|
TIME_IN_DAY | must occur in the time in day between the first and second child to be considered truthy, whereas a child is defined by a PARAMETER (like sunsetTime or sunriseTime ) or CONST like (18:00 ) |
Parameters
For non-logical operators, PARAMETER
children represent the conditions of observed/forecasted values at the monitored location. Read more about facts in the next section.
In case a field name suffix is not defined, Polygons will use the default type (see Data Layers). In case an Insight has a Min/Max/Average suffix and is checked for a Point location, the suffix will be omitted.
Each parameter node has two properties:
type
: astring
that sets the type of the node - alwaysPARAMETER
content
: anobject
that contains the definition of the data field name for the parameter to check against a constant (or operator such asTIME_IN_DAY
) - such asprecipitationType
,precipitationIntensity
orsunsetTime
Constants
For non-logical operators, CONST
children represent constant values to check the other child value against (can be parameters, constants, or other operators).
Each const node has two properties:
type
: astring
that sets the type of the node - alwaysCONST
content
: anobject
that contains the value to check against the parameter (or operator such asTIME_IN_DAY
) - for example,rain
,15
, or18:00
and must match the same type (like string, float etc).