Open Pioneer Trails Packages
    Preparing search index...

    Interface defining the backing storage for feature editing operations.

    The FeatureWriter provides callback functions for creating, updating, and deleting features in the editing workflow. Implementations of this interface are responsible for persisting feature changes to the appropriate underlying data structures or storage systems.

    Note that the FeatureWriter does not load features. Features and their attributes are taken from the map.

    If any function throws an error, an error message will be shown to the user via the NotificationService. On success, a success notification is shown.

    const featureWriter: FeatureWriter = {
    addFeature: async ({feature, template, projection}) => {
    // Persist the new feature to your backend
    },
    updateFeature: async ({feature, layer, projection}) => {
    // Update the existing feature in your backend
    },
    deleteFeature: async ({feature, layer, projection}) => {
    // Delete the feature from your backend
    }
    };

    If any function rejects with an error, that error will be logged and a generic error message will be presented to the user. Return an instance of StorageError instead if you want to include an additional user-visible message.

    const featureWriter: FeatureWriter = {
    addFeature: async ({feature, template, projection}) => {
    // Option 1: Exceptions are logged and result in a generic error message
    throw new Error("Something went wrong");

    // Option 2: Custom user-visible error message
    LOG.error("Failed to do X", error);
    return { kind: "error", message: "Insufficient permissions" };
    },
    };
    interface FeatureWriter {
        addFeature(options: AddFeatureOptions): Promise<StorageResult>;
        deleteFeature(options: DeleteFeatureOptions): Promise<StorageResult>;
        updateFeature(options: UpdateFeatureOptions): Promise<StorageResult>;
    }
    Index

    Methods

    • Called for adding a new feature.

      Called when a user creates a new feature using a feature template. The implementation should persist the feature to a backend service. If the function throws an error, an error notification is displayed to the user; otherwise, a success notification is shown.

      Parameters

      Returns Promise<StorageResult>

      A promise that resolves when the feature has been successfully added, or rejects with an error if the operation fails.

    • Called for updating an existing feature.

      Called when a user modifies an existing feature's geometry or properties. The implementation should persist the changes to a backend service. If the function throws an error, an error notification is displayed to the user; otherwise, a success notification is shown.

      Parameters

      Returns Promise<StorageResult>

      A promise that resolves when the feature has been successfully updated, or rejects with an error if the operation fails.