How to refer to a Grid by Attribute when using TQL

From Tygron Support wiki
Jump to navigation Jump to search

When creating Projects, Project Templates, and smaller elements of complex calculation models, it is a common occurence that an Excel Indicator references the results of a Grid Overlay. In certain scenarios, the GRID_IS_ syntax does not provide the necessary flexibility. This can happen for example when the Excel Indicator is used in a different Project in which the relevant Grid Overlay has a different ID. This also occurs when multiple indicators must either share a Grid Overlay or reference different ones.

To allow for more flexible connections between Excel Indicators (or Excel Panels), the GRID_WITH_ATTRIBUTE_ syntax can be used. This will use a "connecting Attribute" to define which Grid Overlay provides the intended input to the Excel. This requires mutual configuration and allows for (re)wiring Grid Overlays and Excel-based data.

The following steps will assume the Attribute connecting the Grid Overlay and the TQL statement is CONNECTING_ATTRIBUTE.

How to refer to a Grid by Attribute when using TQL:
  1. Add the connecting Attribute to the Overlay by adding an Attribute with the following configuration:
    Name: The name of the Attribute ( CONNECTING_ATTRIBUTE)
    Value: Any positive value ( 1 )
  2. In the Query Tool:
    Create a query of the form SELECT_GRIDAVG_WHERE_GRID_WITH_ATTRIBUTE_IS_..., where the elipses are the desired Attribute ( CONNECTING_ATTRIBUTE )
    Execute the query, and confirm the result is the average of all grid values of the Overlay with the Attribute.
  3. In the Excel (or other location of the TQL statement), ensure:
    All TQL statements referring to the Overlay use the GRID_WITH_ATTRIBUTE syntax.

Notes

  • Only one Grid Overlay should have the "connecting Attribute". Multiple Grid Overlays with the same connecting Attribute cause ambiguity regarding the intended input and trigger a warning.
  • Determining an effective name for the "connecting Attribute" is important, and subject to the following considerations:
    • It should be readible/recognizable to the theme of model it is related to. For example, relating to sight on trees it would make sense to include the words SIGHT_ON_TREES in the Attribute name.
    • It should be unique across functionalities so as to prevent undue collisions. For example, naming the Attribute "SURFACE_WATER" would make sense for an Overlay showing/computing water, but is already an Attribute automatically added to a Water Overlay, which would then either automatically connect with the TQL statement, or collide when multiple exist.
    • A general guideline is to name the attribute "OVERLAY_[calculation_model]". E.g. OVERLAY_SIGHT_ON_TREES, OVERLAY_AVERAGE_SHADE, etc.

See also