@terrestris/ol-util
    Preparing search index...

    Helper class for working with OpenLayers features.

    FeatureUtil

    Index

    Constructors

    Methods

    • Returns the featureType name out of a given feature. It assumes that the feature has an ID in the following structure FEATURETYPE.FEATUREID.

      Parameters

      • feature: Feature<Geometry>

        The feature to obtain the featureType name from.

      Returns undefined | string

      The (unqualified) name of the featureType or undefined if the name could not be picked.

    • Extracts the featureType name from given GetFeatureInfo URL. This method is mostly useful for raster layers which features could have no ID set.

      Parameters

      • url: string

        GetFeatureInfo URL possibly containing featureType name.

      • qualified: boolean = true

        Whether the qualified featureType name should be returned or not. Default is true.

      Returns undefined | string

      Obtained featureType name as string.

    • Maps an array of features to an array of geometries.

      Parameters

      • features: Feature<Geometry>[]

      Returns Geometry[]

      The geometries of the features

    • Resolves the given template string with the given feature attributes, e.g. the template "Size of area is {{AREA_SIZE}} km²" would be to resolved to "Size of area is 1909 km²" (assuming the feature's attribute AREA_SIZE really exists).

      Parameters

      • feature: Feature<Geometry>

        The feature to get the attributes from.

      • template: string

        The template string to resolve.

      • OptionalnoValueFoundText: string = 'n.v.'

        The text to apply, if the templated value could not be found, default is to 'n.v.'.

      • OptionalvalueAdjust: (key: string, val: any) => any = ...

        A method that will be called with each key/value match, we'll use what this function returns for the actual replacement. Optional, defaults to a function which will return the raw value it received. This can be used for last minute adjustments before replacing happens, e.g. to filter out falsy values or to do number formatting and such.

      • leaveAsUrl: boolean = false

        If set to true, template won't be wrapped into -tag and will be returned as URL. Default is false.

      Returns string

      The resolved template string.