LuciadRIA (2026.1.02)
    Preparing search index...

    Class Store<TFeature>Abstract

    The store object provides the link between the FeatureModel and the data provider. The function of the store is to query the server for data, convert the response of the server to LuciadRIA Feature instances, and to perform optional CRUD operations: get, create, update and delete.

    Most of the Store implementations separate the communication with a data provider (e.g., a WFS service) from the actual parsing of the server response. The conversion of the server response to LuciadRIA Feature instances is left to a Codec. For example, the WFSFeatureStore can be configured with a dedicated Codec if your WFS server, which the WFSFeatureStore connects to, does not support GeoJson as an output format.

    A typical sequence of method calls on a set of a FeatureModel - Store - Codec is the following (without considering the asynchronous nature of those methods):

    • FeatureModel#query gets called to perform the query on the server side.
    • The FeatureModel passes the query parameters to the Store#query method.
    • The Store performs the query and passes the response value to the Codec for decoding.
    • The Codec returns the Feature instances to the Store, which passes them back to the FeatureModel.

    Note: Every Store supports Store.query. The other operations - the ones that isOperationSupported can be asked about - are declared by every Store but do not have to be supported: a Store can support get but not add, put and remove, for example. Calling an unsupported operation throws a ProgrammingError. Which operations a Store supports also affects the functionality of the FeatureModel paired with it, as explained in the documentation of that class.

    Users of this class can call query unconditionally, but should always check any other operation with Store.isOperationSupported before calling it, as illustrated below:

    if (store.isOperationSupported("add")) {
    //The "add" operation is supported and can be called
    store.add(feature);
    }

    To create a custom store, extend Store and implement Store.query: it is the only abstract operation. Every other operation is implemented as unsupported - it throws a ProgrammingError when called, and Store.isOperationSupported returns false for it - so a store that only reads data needs nothing else. Override an operation to support it, override Store.isOperationSupported to report it, and report the changes it makes with Store.emitStoreChangedEvent.

    // Extending Store means you only implement the operations your store offers.
    // Every operation you do not override throws when called, and isOperationSupported reports
    // it as unsupported. This store supports "query" and "add", so it reports "add".
    export class CustomStore extends Store {

    override add(feature: Feature, options?: any): FeatureId | Promise<FeatureId> {
    //Add the logic to actually store the feature

    //Report the change, so that listeners such as the FeatureModel pick it up
    this.emitStoreChangedEvent("add", feature, feature.id);
    return feature.id;
    }

    query(query?: any, options?: any): Cursor | Promise<Cursor> {
    //Create a Cursor with the correct results.
    return new CursorImplementation();
    }

    // Report every operation this store implements
    override isOperationSupported(methodName: StoreOperationName): boolean {
    return methodName === "add";
    }
    }

    Note: overriding an operation without reporting it from Store.isOperationSupported leaves the operation unused: LuciadRIA never calls an operation that the store does not report as supported.

    Type Parameters

    • TFeature extends Feature = Feature

      Represents the type of Feature instances that are handled by the store.

    Hierarchy (View Summary)

    Implements

    • Adds a Feature to the store.

      Throws a ProgrammingError. Override this method to support the operation, and report "add" from Store.isOperationSupported. LuciadRIA never calls an operation that the store does not report as supported.

      When the addition is successful, the Store must:

      • Update the ID of the Feature to reflect the ID assigned by the server, if the Feature's ID was undefined prior to addition. If an ID was already defined, the Store should respect the provided ID unless overridden by the server.

      • Emit a "StoreChanged" event with:

        • eventType: "add"
        • feature: The added Feature, including its updated ID.
        • id: The updated identifier of the Feature.

        Failure to do so will result in a map not displaying newly added features.

      Parameters

      • feature: TFeature

        The Feature to add.

      • Optionaloptions: any

        An optional object for additional implementation-specific parameters.

      Returns FeatureId | Promise<FeatureId>

      Returns the identifier of the Feature on success, or a promise that resolves to the identifier.

      ProgrammingError if this store does not support the "add" operation, as reported by Store.isOperationSupported.

      2026.1

    • Emits the StoreChanged event to report that the contents of this store changed. Call this from add, put and remove when the operation succeeds.

      Parameters

      • eventType: "add" | "update" | "remove"

        "add", "update" or "remove".

      • feature: TFeature | undefined

        The Feature that was added, updated or removed. May be undefined for "remove".

      • id: FeatureId

        The identifier of the affected Feature.

      Returns void

      2026.1

    • Retrieves a Feature by id from the data provider.

      Throws a ProgrammingError. Override this method to support the operation, and report "get" from Store.isOperationSupported. LuciadRIA never calls an operation that the store does not report as supported.

      Parameters

      • id: FeatureId

        The identifier of the Feature.

      • Optionaloptions: any

        An optional object that can be used in a specific implementation of the method.

      Returns TFeature | Promise<TFeature | undefined> | undefined

      May return the Feature, or a promise for the Feature. When no feature with that id exists, the returned value must be undefined, whether the implementation is synchronous or asynchronous (a promise resolving to undefined). Reject the promise only for an actual failure, such as a network or parsing error.

      ProgrammingError if this store does not support the "get" operation, as reported by Store.isOperationSupported.

      2026.1

    • Indicates whether the given store operation is supported.

      LuciadRIA uses this method to determine whether an operation can be called. A Store defines all operations, so the presence of a method does not imply that it is supported. Return true for each supported operation and false otherwise. Calling an unsupported operation throws a ProgrammingError.

      The result must remain stable for the lifetime of the store. A FeatureLayer reads it when it is added to a map, and does not pick up later changes.

      Returns false for every operation. Override this method to report the operations that this store implements.

      Parameters

      Returns boolean

      true if methodName can be called on this store.

      2026.1

    • Updates an existing Feature in the store or adds it if it does not already exist.

      Throws a ProgrammingError. Override this method to support the operation, and report "put" from Store.isOperationSupported. LuciadRIA never calls an operation that the store does not report as supported.

      When the operation is successful, the Store must emit a "StoreChanged" event. The event should contain:

      • eventType: "update" if an existing feature is updated, or "add" if a new feature is added.
      • feature: The updated or newly added Feature.
      • id: The identifier of the affected Feature.

      Failure to do so will result in a map not displaying updated features.

      The implementation of this method may follow the semantics of an HTTP PUT request. This means that if the feature does not already exist in the store, it may be added as a new entry.

      Parameters

      • feature: TFeature

        The Feature to update or add.

      • Optionaloptions: any

        An optional object for additional implementation-specific parameters.

      Returns FeatureId | Promise<FeatureId>

      Returns the identifier of the Feature on success, or a promise that resolves to the identifier.

      ProgrammingError if this store does not support the "put" operation, as reported by Store.isOperationSupported.

      2026.1

    • Queries the store for objects.

      Every Store must implement this operation, so callers can invoke it without checking Store.isOperationSupported first.

      Parameters

      • Optionalquery: any

        An object that represents a query filter that is understood by the underlying data provider. The structure of this object depends on a specific store implementation.

      • Optionaloptions: QueryOptions

        An optional object that can be used in a specific implementation of the method.

      Returns Cursor<TFeature> | Promise<Cursor<TFeature>>

      A Cursor over a set of Feature instances or a promise for that Cursor.

    • Removes a Feature from the store by its ID.

      Throws a ProgrammingError. Override this method to support the operation, and report "remove" from Store.isOperationSupported. LuciadRIA never calls an operation that the store does not report as supported.

      When the removal is successful, the Store must emit a "StoreChanged" event, which contains an eventType of "remove" and the ID of the removed Feature.

      If the Store does not emit the "StoreChanged" event, the map visualization will not reflect the removal of the feature.

      Parameters

      • id: FeatureId

        The identifier of the Feature to be removed.

      Returns boolean | Promise<boolean>

      Returns true on successful removal, or a promise that resolves to true.

      ProgrammingError if this store does not support the "remove" operation, as reported by Store.isOperationSupported.

      2026.1

    • Queries the store for objects within a spatial extent.

      Throws a ProgrammingError. Override this method to support the operation, and report "spatialQuery" from Store.isOperationSupported. LuciadRIA never calls an operation that the store does not report as supported.

      Note: LuciadRIA determines the layer's default loading strategy based on whether the store reports "spatialQuery" as supported. If it does, the default loading strategy is LoadSpatially. Otherwise it is LoadEverything.

      Note: When the map reference and the model reference are incompatible, for example a Cartesian reference and a geodetic reference, the layer falls back to LoadEverything.

      Note: WFSFeatureStore implements this operation by creating an OGC BBOX filter based on the bounds parameter.

      Parameters

      • Optionalbounds: Bounds

        The spatial extent to return features for.

      • Optionalquery: any

        An object that represents a query filter that is understood by the underlying data provider. The structure of this object depends on a specific store implementation.

      • Optionaloptions: QueryOptions

        An optional object that can be used in a specific implementation of the method.

      Returns Cursor<TFeature> | Promise<Cursor<TFeature>>

      A Cursor.

      ProgrammingError if this store does not support the "spatialQuery" operation, as reported by Store.isOperationSupported.

      2026.1

    • An event that is emitted when the contents of the store change. A store that performs create, update, or delete operations must report them with Store.emitStoreChangedEvent, to ensure that changes are communicated properly to listeners.

      Parameters

      • event: "StoreChanged"

        The "StoreChanged" event.

      • callback: (
            eventType: "add" | "update" | "remove",
            feature: TFeature,
            id: FeatureId,
        ) => any

        The callback to be invoked when the contents of the store change. The callback has three parameters:

        • eventType: The type of change.
        • feature: The Feature that was added, updated, or removed. For the "remove" event type, the value should be undefined.
        • id: The identifier of the Feature that was affected by the change.
      • Optionalcontext: any

        An optional value used as the this context when executing the callback.

      • Optionaloptions: StoreChangedOptions

        An optional object specifying additional options for the event listener. The inherited implementation ignores StoreChangedOptions.query: override this method to filter the events that this store reports. StoreChanged

      Returns Handle

      2026.1