Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "geocortex/infrastructure/FeatureUtils"

Index

Variables

Const anchorPattern

anchorPattern: RegExp

Matches an anchor tag

Let app

Mostly required to log errors properly

Const hrefAnchorPattern

hrefAnchorPattern: RegExp

In the regex below, the command: will only match urls that are of the command scheme. To match any urls, remove 'command:' Note that this is intended to be used on matches from the above and does not match the pattern in a raw feature template string.

Const tokenRegex

tokenRegex: RegExp

A regex to find a value wrapped in curly braces. Used to find 'double wrapped' replacement tokens, which should not be replaced as they are likely part of command parameters.

Functions

equals

  • Checks if the given Geocortex essentials features are equal

    Parameters

    Returns boolean

executeArcadeScript

  • executeArcadeScript(arcadeScript: string, esriFeature: Graphic): number | string | Promise<number | string>
  • Attempt to execute the given string as an Arcade script, using the given feature as context If the script contains '$map' or '$layer' variables these will also be added to the execution context. Please note that '$layer' requires that the feature itself come from a FeatureLayer, and non-FeatureLayers in the map are not accessible through the '$map' global.

    Parameters

    • arcadeScript: string

      The script to run.

    • esriFeature: Graphic

      The feature to use as context for the script.

    Returns number | string | Promise<number | string>

    Arcade scripts can return string or numeric values. Scripts that query other datasources return a promise of this value.

findReplacementTokens

  • findReplacementTokens(template: string): Token[]
  • Uses a bracket counting method to find potential tokens to replace within a template string, eg: {FIELD_NAME} We use this method (rather than a regex) as some replacement tokens can be Arcade scripts, which potentially contain curly braces themselves. To ensure complete accuracy, curly braces inside quotes inside a token will be ignored, so this doesn't cause issues: {$feature.FIELD + "}"}

    Parameters

    • template: string

      The template string to process

    Returns Token[]

isArcadeScript

  • isArcadeScript(script: string): boolean
  • 'Type Guard' for arcade scripts. Checks a string for arcade globals '$feature' '$map' '$layer' '$view' If it doesn't contain one of these we are not going to try to process it.

    Parameters

    • script: string

    Returns boolean

isPromise

  • isPromise(arg: any): boolean
  • A very loose type guard to detect promises made by ESRI, which are not instances of Promise but can be treated as such. Watch out with this though, as the presence of a 'then' method does not mean that everything in the Promise spec has been implemented.

    Parameters

    • arg: any

      The object to test.

    Returns boolean

setArcadeGlobals

  • Parameters

    Returns void

structurallyEquals

  • Determines whether two Geocortex Essentials features are structurally equal

    Structural equality means that two objects are equal because they have equal values.
    It differs from reference equality, which indicates that two object references are equal because they reference the same physical object.
    Note: This comparison does not take geometry into account

    Parameters

    Returns boolean

    true if the two objects are equal; otherwise, false.