A non-persistent Feature instances in memory.

The store can be created with spatial capabilities by setting MemoryStoreConstructorOptions.spatialIndex property to true. LuciadRIA will choose a default loading strategy for a layer with this store depending if the store supports spatial capabilities or not.

Please note that MemoryStoreConstructorOptions.reference should be defined in order to store features in an optimized spatial cache.

As the Features are stored in memory, there is no need to convert them to a "server-specific format". As such, this Store does not use a Codec.

Type Parameters

  • TFeature extends Feature = Feature

    Represents the type of Feature instances that are handled by the store. The default type is inferred from features passed in MemoryStoreConstructorOptions.data, if the field is provided, otherwise the type is Feature without restrictions on shape and properties.

    // Creates a new MemoryStore that type-guards its feature instances.
    // Here the store will accept features that have a polyline or a polygon shape only.
    const store1 = new MemoryStore<Feature<Polyline | Polygon>>();

    // Here the feature type is inferred from the initial data.
    const store2 = new MemoryStore({ data: [featureWithPolyline, featureWithPolygon] });

    // In both cases TypeScript will complain if you try to insert a feature that has a shape different than a polyline or a polygon.

    // You can still relax the type
    // Here the store will accept features with all kind of shapes.
    const store3 = new MemoryStore<Feature>({ data: [featureWithPolyline, featureWithPolygon] });

Hierarchy

  • MemoryStore

Implements

Constructors

Accessors

  • get spatialIndex(): boolean
  • States if this store instance supports spatial capabilities. If the returned value is true then MemoryStore.spatialQuery method is available.

    Returns boolean

    Since

    2021.0

Methods

  • Add a new Feature to the store. If an id is present on the feature, the Store may not yet contain a Feature with that same ID.

    Parameters

    • feature: TFeature

      the Feature to add.

    • Optional options: object

      Object literal containing options for the add method. The current implementation does not support any options.

    Returns FeatureId

    The identifier of the newly added Feature. An "add" event is triggered if adding is successful.

  • Removes all Features from the store

    Returns boolean

    True. A "remove" event is also triggered for every successful removal

    Since

    2018.0

  • Retrieve a Feature from this store by id.

    Parameters

    Returns undefined | TFeature

    The Feature with the specified id. Undefined if it does not exist.

  • Update an existing Feature in the store. If an object with the same identifier does not exist yet, the object will be added to the store. A corresponding StoreChanged will be fired.

    Parameters

    • feature: TFeature

      the Feature to update.

    • Optional options: object

      Object literal containing options for the put method. The current implementation does not support any options.

    Returns FeatureId

    The identifier of the Feature. An "update" or "add" event is triggered, depending on whether the id already exists in the Store.

  • Query the store for objects. The current implementation returns all Features contained in this Store.

    Parameters

    • Optional query: ((feature) => boolean)

      An optional function that is used to filter the results of the query. The supplied function will receive an individual feature as parameter and should return a truthy value to indicate that that feature should be included in the cursor. If the function returns a falsy value then the feature will be excluded from the cursor. If no function is specified, then all features will be returned.

    Returns Cursor<TFeature>

    A cursor for the result set.

  • Clears the Features in the store and loads a new set of features

    Parameters

    • features: TFeature[]

      The new data to load.

    Returns boolean

    True. A "remove" event is triggered for every successful removal and an "add" event is triggered for every successful addition.

    Since

    2018.0

  • Removes a Feature from the store by id.

    Parameters

    Returns boolean

    True if removal was successful. If successful, a "remove" event is also triggered.

  • Queries the store for objects within a spatial extent. This method is available only when the store is created with spatial index. Please see MemoryStoreConstructorOptions.spatialIndex property for more details.

    Parameters

    • Optional bounds: Bounds

      The spatial extent to return features for.

    • Optional query: FilterPredicateType

      An object which represents a predicate function that filters features.

    Returns Cursor<TFeature>

    A Cursor.

    Since

    2021.0

Events

"StoreChanged" event

  • on("StoreChanged", callback: ((eventType, feature, id) => any), context?: any) : Handle
  • An event that is emitted when the contents of the store changes.

    Parameters

    • event: "StoreChanged"

      the "StoreChanged" event.

    • callback: ((eventType, feature, id) => any)

      the callback to be invoked when the contents of the store changes. The callback has 3 parameters:

      • eventType: "add", "update" or "remove"
      • feature: the Feature that was added, updated or removed. In case of the "remove" event type, it may be undefined.
      • id: the identifier of the Feature.
        • (eventType, feature, id): any
        • Parameters

          • eventType: string
          • feature: TFeature
          • id: FeatureId

          Returns any

    • Optional context: any

      value to use as this when executing callback

    • Optional options: StoreChangedOptions

      An option object which has a 'query' property, which represents a query which may be understood and satisfied by the store. The structure of this object is dependent on the specific store. If specified, the listener function must only be invoked for features that match the query. "StoreChanged"

    Returns Handle