DictionaryRenderer Class

  • DictionaryRenderer
  • class Esri::ArcGISRuntime::DictionaryRenderer

    Renders geoelements using symbols generated from a DictionarySymbolStyle. More...

    Header: #include <DictionaryRenderer.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::Renderer

    Public Functions

    DictionaryRenderer(Esri::ArcGISRuntime::DictionarySymbolStyle *dictionarySymbolStyle, QObject *parent = nullptr)
    DictionaryRenderer(Esri::ArcGISRuntime::DictionarySymbolStyle *dictionarySymbolStyle, const QMap<QString, QString> &symbologyFieldOverrides, const QMap<QString, QString> &textFieldOverrides, QObject *parent = nullptr)
    virtual ~DictionaryRenderer() override
    Esri::ArcGISRuntime::DictionarySymbolStyle *dictionarySymbolStyle() const
    Esri::ArcGISRuntime::ArcadeExpression *scaleExpression() const
    void setScaleExpression(Esri::ArcGISRuntime::ArcadeExpression *scaleExpression)
    QMap<QString, QString> symbologyFieldOverrides() const
    QMap<QString, QString> textFieldOverrides() const

    Detailed Description

    The dictionary renderer applies symbols to features or graphics according to a set of input attribute values. The symbol primitives and logic (rule engine) for applying symbols is provided by an associated DictionarySymbolStyle.

    The DictionarySymbolStyle depends on attribute names to define the symbology of each feature. The attributes reference different symbol components in the style, which are assembled to create a complex symbol. In order to display geoelements using the dictionary renderer, attributes in your data must either use the expected attribute names or be mapped to the proper style attributes.

    The DictionarySymbolStyle is created using a given specification such as "mil2525d". Each specification depends on attribute names that define the symbology and text of each feature. For example, the mil2525d specification looks for attributes named "identity", "symbolset", "symbolentity", and "modifier1", among many others. These attributes reference different symbols in the style file that are assembled to create a unique symbol. In order to display features using the DictionaryRenderer, you must make sure the DictionaryRenderer and associated DictionarySymbolStyle know which attributes in your data to use. This can be achieved in multiple ways:

    • Pre-author your data so that the attribute names match the attributes needed by the specification. In the case of the mil2525d specification, author a feature service (or other data source) with a field named "identity", another named "symbolset", and so on. In this scenario, you create a FeatureTable from the source data, create a FeatureLayer from the FeatureTable, apply the DictionaryRenderer to the FeatureLayer, and the symbols are generated automatically and applied to the layer in the map. The same workflow applies for Graphics in a GraphicsOverlay. Ideally when creating graphics on the fly, you can give the attributes names that match the specification. When fields in the FeatureTable and attributes in Graphics have expected names, the DictionaryRenderer automatically finds them.
    • Manually map your attribute names to those expected by the specification. You can map as many attribute names as necessary for the specification, but only need to map attribute names that do not match the specification (all matching attribute names will be automatically matched by the renderer). For example, an expected attribute "symbolset" might appear as the "symbol_set" field in your FeatureTable. In this scenario, you can create a ServiceFeatureTable from a feature service, create a FeatureLayer from that feature table, create a DictionaryRenderer by manually mapping the "symbol_set" name to the "symbolset" name expected by the specification, and finally apply the renderer to the FeatureLayer.

    A DictionaryRenderer can be applied to pre-authored data, such as feature services, mobile geodatabases (generated from ArcMap or a sync-enabled feature service), and feature layers in a mobile map package. You can also apply it to a GraphicsOverlay, which allow for on-the-fly graphic generation.

    Note: For mil2525d, symbolset, entity, and identity fields are required to create a symbol.

    Note: Esri builds and maintains some dictionary web styles according to the US and NATO military symbol specifications. These desktop and web styles are hosted online and are publicly available. Refer to the ArcGIS Online Dictionary Symbology Styles group for the latest versions of the styles available.

    Example:

    Apply a DictionaryRenderer to a FeatureLayer:

    // Create a layer and set the feature table
    FeatureLayer* layer = new FeatureLayer(table, this);
    
    // Create a dictionary renderer and apply to the layer
    DictionaryRenderer* renderer = new DictionaryRenderer(dictionarySymbolStyle, this);
    layer->setRenderer(renderer);

    Note: For details on the currently support military standards, please see the DictionarySymbolStyle API reference.

    Member Function Documentation

    [explicit] DictionaryRenderer::DictionaryRenderer(Esri::ArcGISRuntime::DictionarySymbolStyle *dictionarySymbolStyle, QObject *parent = nullptr)

    Constructor that creates a new dictionary renderer object with the given DictionarySymbolStyle, with an optional parent.

    • dictionarySymbolStyle - The dictionary symbol style to be used with the renderer.
    • parent - The optional parent QObject.

    DictionaryRenderer::DictionaryRenderer(Esri::ArcGISRuntime::DictionarySymbolStyle *dictionarySymbolStyle, const QMap<QString, QString> &symbologyFieldOverrides, const QMap<QString, QString> &textFieldOverrides, QObject *parent = nullptr)

    Creates a new dictionary renderer object.

    • dictionarySymbolStyle - The dictionary symbol style to be used with the renderer.
    • symbologyFieldOverrides - A Dictionary containing QString types.
    • textFieldOverrides - An Dictionary containing QString types.
    • parent - The optional parent QObject.

    Use this constructor in the case where your source data's field names do not match what the DictionarySymbolStyle specification expects. The symbologyFieldOverrides and textFieldOverrides should be used to map your field names to the specification's, where the key is the specification name (e.g. "symbolset"), and the value is your field's name (e.g. "symbol_set").

    To obtain the valid symbology and text fields in a symbol dictionary, use with DictionarySymbolStyle::symbologyFieldNames and DictionarySymbolStyle::textFieldNames.

    [override virtual] DictionaryRenderer::~DictionaryRenderer()

    Destructor.

    Esri::ArcGISRuntime::DictionarySymbolStyle *DictionaryRenderer::dictionarySymbolStyle() const

    Returns the DictionarySymbolStyle to be applied by the DictionaryRenderer.

    [since Esri::ArcGISRuntime 100.11] Esri::ArcGISRuntime::ArcadeExpression *DictionaryRenderer::scaleExpression() const

    Returns an arcade expression object with an expression for scaling symbols in a dictionary renderer.

    The ArcadeExpression is evaluated at rendering time. If the expression is not valid or results in an invalid value, symbols will not be scaled and will display at their original size. For example, to scale symbols based on an attribute value, you can set ArcadeExpression::expression as follows. This expression `if($feature.Symbol_Set == 40, 2.5, 1) scales the symbol size 2.5 times when symbol_set is 40`.

    This function was introduced in Esri::ArcGISRuntime 100.11.

    See also setScaleExpression().

    [since Esri::ArcGISRuntime 100.11] void DictionaryRenderer::setScaleExpression(Esri::ArcGISRuntime::ArcadeExpression *scaleExpression)

    Sets the scaleExpression to scaleExpression.

    This function was introduced in Esri::ArcGISRuntime 100.11.

    See also scaleExpression.

    QMap<QString, QString> DictionaryRenderer::symbologyFieldOverrides() const

    Returns the map of a symbology attribute and its override used to fetch a symbol from the dictionary symbol style.

    A DictionarySymbolStyle uses a collection of expected attribute names to build a symbol based on input values. When initialized, fields in the input dataset are mapped to the expected attribute names using case-insensitive matching. If your data uses a different name for an expected symbol attribute, use the symbologyFieldOverrides to map an expected field to the correct field in your data. You can also exclude an expected field by providing an empty string for it in the overrides.

    QMap<QString, QString> DictionaryRenderer::textFieldOverrides() const

    Returns the map of text field overrides set in the constructor.

    A DictionarySymbolStyle uses a collection of expected attribute names to build a symbol based on input values. When initialized, fields in the input dataset are mapped to the expected attribute names using case-insensitive matching. If your data uses a different name for an expected text attribute, use the textFieldOverrides to map an expected field to the correct field in your data. You can also exclude an expected field by providing an empty string for it in the overrides.

    To obtain the valid symbology fields in a symbol dictionary, use DictionarySymbolStyle::symbologyFieldNames.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.