Expression

DatatypeDraftv1.0.0-rc.2

An expression: a formula that a criterion, an edge or a variable evaluates. It is a literal, a variable, a Value, or an operation on further expressions. ODS has this one expression language.

https://opendevelopmentstandards.org/schema/1.0.0-rc.2/core/Expression.json

Fields

Forms

A value of this schema takes one of these forms.

  1. Form 1number
  2. Form 2text
  3. Form 3true or false
  4. Form 4null
  5. Form 5object
    • variableRequired
      textnot empty

      The id of a Variable, or the name of a step's input or output.

  6. Form 6object
  7. Form 7object
    • operationRequired
      One ofthe codes below

      The operation.

      and
      True when every argument is true.
      or
      True when any argument is true.
      not
      True when its one argument is false.
      if
      The second argument when the first is true, otherwise the third.
      equal
      True when the two arguments are equal.
      not_equal
      True when the two arguments differ.
      less
      True when the first argument is less than the second.
      less_or_equal
      True when the first argument is at most the second.
      greater
      True when the first argument is more than the second.
      greater_or_equal
      True when the first argument is at least the second.
      in
      True when the first argument is in the list that is the second.
      add
      The sum of the arguments.
      subtract
      The first argument less the second.
      multiply
      The product of the arguments.
      divide
      The first argument divided by the second.
      negate
      The one argument with its sign changed.
      power
      The first argument to the power of the second.
      log10
      The base-10 logarithm of the one argument.
      round
      The first argument rounded to the number of decimals that is the second (0 when left out).
      energy_sum
      The level of the summed powers of levels in decibels.
      energy_mean
      The level of the mean power of levels in decibels.
      count
      The number of items in a list.
      sum
      The sum of the items in a list.
      minimum
      The smallest argument, or the smallest item of one list.
      maximum
      The largest argument, or the largest item of one list.
      mean
      The arithmetic mean of the items in a list.
      extract
      The field of the first argument that the second names, as a dotted path.
      map
      Each item of the first argument, changed by the second; `as` names the item.
      filter
      The items of the first argument for which the second is true; `as` names the item.
      reduce
      The items of the first argument combined into one by the second, from the third as the start.
      distance
      The distance between two places, in metres.
      intersects
      True when two shapes share a point.
      within
      True when the first shape lies inside the second.
      buffer
      The shape that is the first argument grown by the distance in metres that is the second.
      custom
      An operation the producer defines; `description` says what it does. An open evaluator cannot run it.
    • arguments
      List ofExpression (nested)

      The expressions the operation acts on, in order.

    • as
      textmatches ^[a-z][a-z0-9_]*$

      For map, filter and reduce: the name that each item has inside the second argument.

    • description
      text

      What the expression does, in words.

Links

Examples

An id that another example defines opens that record.

Example 2

{
  "operation": "energy_sum",
  "arguments": [
    {
      "variable": "site_level"
    },
    {
      "value": {
        "amount": 35,
        "unit": "dB"
      }
    }
  ]
}
Show 2 more examples

Example 1

{
  "operation": "less_or_equal",
  "arguments": [
    {
      "variable": "night_level"
    },
    {
      "variable": "night_limit"
    }
  ]
}

Example 3

true

Changes and file

Changes

  1. 0.1.0 First version.

Schema file

Show the JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opendevelopmentstandards.org/schema/1.0.0-rc.2/core/Expression.json",
  "title": "Expression",
  "description": "An expression: a formula that a criterion, an edge or a variable evaluates. It is a literal, a variable, a Value, or an operation on further expressions. ODS has this one expression language.",
  "anyOf": [
    {
      "type": "number"
    },
    {
      "type": "string"
    },
    {
      "type": "boolean"
    },
    {
      "type": "null"
    },
    {
      "type": "object",
      "properties": {
        "variable": {
          "type": "string",
          "description": "The id of a Variable, or the name of a step's input or output.",
          "minLength": 1
        }
      },
      "required": [
        "variable"
      ],
      "patternProperties": {
        "^x-": {}
      },
      "unevaluatedProperties": false
    },
    {
      "type": "object",
      "properties": {
        "value": {
          "$ref": "Value.json",
          "description": "A literal amount with its unit."
        }
      },
      "required": [
        "value"
      ],
      "patternProperties": {
        "^x-": {}
      },
      "unevaluatedProperties": false
    },
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "and",
            "or",
            "not",
            "if",
            "equal",
            "not_equal",
            "less",
            "less_or_equal",
            "greater",
            "greater_or_equal",
            "in",
            "add",
            "subtract",
            "multiply",
            "divide",
            "negate",
            "power",
            "log10",
            "round",
            "energy_sum",
            "energy_mean",
            "count",
            "sum",
            "minimum",
            "maximum",
            "mean",
            "extract",
            "map",
            "filter",
            "reduce",
            "distance",
            "intersects",
            "within",
            "buffer",
            "custom"
          ],
          "description": "The operation.",
          "x-ods-options": [
            {
              "value": "and",
              "title": "And",
              "description": "True when every argument is true."
            },
            {
              "value": "or",
              "title": "Or",
              "description": "True when any argument is true."
            },
            {
              "value": "not",
              "title": "Not",
              "description": "True when its one argument is false."
            },
            {
              "value": "if",
              "title": "If",
              "description": "The second argument when the first is true, otherwise the third."
            },
            {
              "value": "equal",
              "title": "Equal",
              "description": "True when the two arguments are equal."
            },
            {
              "value": "not_equal",
              "title": "Not equal",
              "description": "True when the two arguments differ."
            },
            {
              "value": "less",
              "title": "Less",
              "description": "True when the first argument is less than the second."
            },
            {
              "value": "less_or_equal",
              "title": "Less or equal",
              "description": "True when the first argument is at most the second."
            },
            {
              "value": "greater",
              "title": "Greater",
              "description": "True when the first argument is more than the second."
            },
            {
              "value": "greater_or_equal",
              "title": "Greater or equal",
              "description": "True when the first argument is at least the second."
            },
            {
              "value": "in",
              "title": "In",
              "description": "True when the first argument is in the list that is the second."
            },
            {
              "value": "add",
              "title": "Add",
              "description": "The sum of the arguments."
            },
            {
              "value": "subtract",
              "title": "Subtract",
              "description": "The first argument less the second."
            },
            {
              "value": "multiply",
              "title": "Multiply",
              "description": "The product of the arguments."
            },
            {
              "value": "divide",
              "title": "Divide",
              "description": "The first argument divided by the second."
            },
            {
              "value": "negate",
              "title": "Negate",
              "description": "The one argument with its sign changed."
            },
            {
              "value": "power",
              "title": "Power",
              "description": "The first argument to the power of the second."
            },
            {
              "value": "log10",
              "title": "Base-10 logarithm",
              "description": "The base-10 logarithm of the one argument."
            },
            {
              "value": "round",
              "title": "Round",
              "description": "The first argument rounded to the number of decimals that is the second (0 when left out)."
            },
            {
              "value": "energy_sum",
              "title": "Energy sum",
              "description": "The level of the summed powers of levels in decibels."
            },
            {
              "value": "energy_mean",
              "title": "Energy mean",
              "description": "The level of the mean power of levels in decibels."
            },
            {
              "value": "count",
              "title": "Count",
              "description": "The number of items in a list."
            },
            {
              "value": "sum",
              "title": "Sum",
              "description": "The sum of the items in a list."
            },
            {
              "value": "minimum",
              "title": "Minimum",
              "description": "The smallest argument, or the smallest item of one list."
            },
            {
              "value": "maximum",
              "title": "Maximum",
              "description": "The largest argument, or the largest item of one list."
            },
            {
              "value": "mean",
              "title": "Mean",
              "description": "The arithmetic mean of the items in a list."
            },
            {
              "value": "extract",
              "title": "Extract",
              "description": "The field of the first argument that the second names, as a dotted path."
            },
            {
              "value": "map",
              "title": "Map",
              "description": "Each item of the first argument, changed by the second; `as` names the item."
            },
            {
              "value": "filter",
              "title": "Filter",
              "description": "The items of the first argument for which the second is true; `as` names the item."
            },
            {
              "value": "reduce",
              "title": "Reduce",
              "description": "The items of the first argument combined into one by the second, from the third as the start."
            },
            {
              "value": "distance",
              "title": "Distance",
              "description": "The distance between two places, in metres."
            },
            {
              "value": "intersects",
              "title": "Intersects",
              "description": "True when two shapes share a point."
            },
            {
              "value": "within",
              "title": "Within",
              "description": "True when the first shape lies inside the second."
            },
            {
              "value": "buffer",
              "title": "Buffer",
              "description": "The shape that is the first argument grown by the distance in metres that is the second."
            },
            {
              "value": "custom",
              "title": "Custom",
              "description": "An operation the producer defines; `description` says what it does. An open evaluator cannot run it."
            }
          ]
        },
        "arguments": {
          "type": "array",
          "items": {
            "$ref": "#"
          },
          "description": "The expressions the operation acts on, in order."
        },
        "as": {
          "type": "string",
          "description": "For map, filter and reduce: the name that each item has inside the second argument.",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "description": {
          "type": "string",
          "description": "What the expression does, in words."
        }
      },
      "required": [
        "operation"
      ],
      "patternProperties": {
        "^x-": {}
      },
      "unevaluatedProperties": false
    }
  ],
  "examples": [
    {
      "operation": "less_or_equal",
      "arguments": [
        {
          "variable": "night_level"
        },
        {
          "variable": "night_limit"
        }
      ]
    },
    {
      "operation": "energy_sum",
      "arguments": [
        {
          "variable": "site_level"
        },
        {
          "value": {
            "amount": 35,
            "unit": "dB"
          }
        }
      ]
    },
    true
  ],
  "x-ods-status": "draft",
  "x-ods-kind": "datatype",
  "x-ods-module": "core",
  "x-ods-changes": {
    "0.1.0": "First version."
  }
}