A model that contains LuciadRIA features.

Each model must be configured with an object Store. The Store is used to retrieve/update/... the Feature instances of this model. Consult the class documentation of the Store class for more information.

Each FeatureModel provides methods to retrieve/update/query/... the underlying data of the model. The presence of those methods is determined by the available methods in the Store of the model. Users of this class should always check whether such a method is available before calling the method, as illustrated below:

  const model = new FeatureModel(store);
if (typeof model.add === "function") {
//add method is available and can be called
model.add( ... );
}

Hierarchy

Implements

Constructors

Accessors

  • get bounds(): null | Bounds
  • The spatial extent of the data in this model. If the property is null, the extent is unknown.

    Returns null | Bounds

Methods

  • Add a feature to the model. Note that this function will only be available if the underlying store also provides an add function.

    Parameters

    • feature: Feature<null | Shape, FeatureProperties>

      The feature to add to the model.

    • Optional options: any

      Object literal that will be passed as is to the model's store.

    Returns FeatureId | Promise<FeatureId>

    Returns the identifier of the feature, or a promise for the identifier.

  • Update an existing feature in the model object. Note that this function will only be available if the underlying store also provides a put function.

    Parameters

    • feature: Feature<null | Shape, FeatureProperties>

      The feature to update.

    • Optional options: any

      Object literal that will be passed as is to the model's store.

    Returns FeatureId | Promise<FeatureId>

    Returns the identifier of the feature, or a promise for the identifier.

  • Removes a feature from the model by id. Note that this function will only be available if the underlying store also provides a remove function.

    Parameters

    Returns boolean | Promise<boolean>

    true or promise for true on successful removal, otherwise false.

Events

"ModelChanged" event

  • on("ModelChanged", callback: ((modelChangeType, feature, id) => void), context?: any) : Handle
  • Note: the FeatureModel requires a Store which supports events in order to automatically fire ModelChanged events. When the store does not support events, it is up to the user of this class to fire those events manually.

    Parameters

    • event: "ModelChanged"

      The "ModelChanged" event type

    • callback: ((modelChangeType, feature, id) => void)

      the feature that was added, updated or removed. In case of remove events, this may be undefined.

    • Optional context: any

      the context in which the callback function should be invoked. implementation dependent.

      An event that is emitted when the contents of the model changes.

      "ModelChanged"

    Returns Handle