Weather Alerts structure

Weather Alerts structure

Below is a complete description of the weather triggers and alerts data structures. All request and response parameters are also explained further in this section.

Struct Example
{
   "__v":0,
   "_id":"585268b72516b90010058184",
   "alerts":{

   },
   "area":[
      {
         "type":"Point",
         "_id":"585268b72516b90010058185",
         "coordinates":[
            53,
            37
         ]
      }
   ],
   "conditions":[
      {
         "name":"temp",
         "expression":"$gt",
         "amount":299,
         "_id":"585268b72516b90010058186"
      }
   ],
   "time_period":{
      "end":{
         "expression":"after",
         "amount":432000000
      },
      "start":{
         "expression":"after",
         "amount":132000000
      }
   }
}

All parameters

Parameter Description
_id Document id
owner user's id
time_period Time interval's scope used to do the matching between the weather data and the trigger conditions
conditions A set of conditions required for an alert creation
area A set of locations where the weather data will be collected and matched with a trigger conditions
alerts The named set of this trigger's current alerts

All fields contain a nested structure except the _id and the owner fields.

time_period

The structure of a time_period contains start and end fields. These fields also contain nested structures describing the beginning and the end of a time interval which is used to check the conditions.

The beginning and the end of a time interval represents a set of instructions for dynamic timestamp estimation. Timestamp is calculated considering the current time at the moment when conditions are being checked.

Parameter Description
amount Number of milliseconds
expression Specifies how to process value of the amount field

The field expression has three admissible values:

  • exact - the field amount will be interpreted as a timestamp indicating an exact date/time
  • аfter - the field amount will be interpreted as a number of milliseconds which needs to be added to the current timestamp at the moment of validation to receive a chosen date/time.
  • before - the field amount will be interpreted as a number of milliseconds which needs to be subtracted from the current timestamp at the moment of validation to receive a chosen date/time.
Struct example
{
   "time_period":{
      "end":{
         "amount":432000000,
         "expression":"after"
      },
      "start":{
         "amount":132000000,
         "expression":"after"
      }
   }
}

conditions

The field conditions contains an array of objects describing the parameters that are used to do the comparison.

Parameter Description
name The name of the parameter to be compared with
expression The expression which will be used to compare
amount Numerical value to be compared with

In the field name the following values are allowed: temp, pressure, humidity, wind_speed, wind_direction, clouds. Value of the name field specifies the corresponding parameter in a response from the Weather API which will be compared with.

Field expression indicates how exactly to perform comparison. The following values are available:

  • $gt - more than a value specified in amount.
  • $lt - less than a value specified in amount.
  • $gte - greater than or equals to a value specified in amount.
  • $lte - less than or equals to a value specified in amount.
  • $eq - equals to a value specified in amount.
  • $ne - not equals to a value specified in amount.
Struct example
{
   "conditions":[
      {
         "name":"temp",
         "expression":"$gt",
         "amount":299,
         "_id":"57fcdd4d13b0c80024ac1faa"
      }
   ]
}

area

Field area is an array of objects, each of which could be interpreted as a point, a point set, polygon or set of polygons.

Parameter Description
type Object type
coordinates Set of coordinates

GeoJson is taken as a syntactic basis. In the type field the following values are allowed: Point, MultiPoint, Polygon, MultiPolygon.

Suchlike content is expected in the coordinates field, depending on the specified type:

type coordinates
Point [100.0, 0.0]
MultiPoint [ [100.0, 0.0], [101.0, 1.0] ]
Polygon (without hole) [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ]
Polygon (with hole) [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ] ]
MultiPolygon [ [ [ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0,3.0], [102.0, 2.0] ] ],[ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ] ] ]
Struct example
{
   "area":[
      {
         "type":"Point",
         "_id":"57fcdd4d13b0c80024ac1fa9",
         "coordinates":[
            53,
            37
         ]
      }
   ]
}

alerts

The field alerts contains a set of key/value pairs. The MD5 line is an alert identifier and serves as a key. An identification key is composed of three parameters:

  • Timestamp, weather data was received for.
  • Type of weather API.
  • The coordinates of the query to weather API.
Parameter Description
conditions Current value and condition to fire on
last_update Time of the last check when this condition have been fired on
date Time of the measurement that matched a trigger's conditions
coordinates Coordinates, for which measurements were requested
Struct example
{
   "alerts":{
      "671e2e711b86117906b4b81aa61c9bab":{
         "conditions":[
            {
               "current_value":{
                  "min":270.636,
                  "max":270.636
               },
               "condition":{
                  "name":"temp",
                  "expression":"$gt",
                  "amount":100,
                  "_id":"5832d39802ec0200200abe83"
               }
            }
         ],
         "last_update":1479902521846,
         "date":1480280400000,
         "coordinates":{
            "lon":53,
            "lat":37
         }
      }
   }
}

history_alerts

Data model in the history of alerts almost repeats the structure of alerts in a trigger object, but with two additional fields: owner and triggerId.

Parameter Description
_id Document id
owner user's id
triggerId id of a trigger
conditions Current value and condition to fire on
last_update Time of the last check when this condition have been fired on
date Time of the measurement that matched a trigger's conditions
coordinates Coordinates, for which measurements were requested