Class for managing a WX dataset and its related operations.

Instances of this class handle metadata, variables, valid times, zoom levels, and URI construction for WX datasets. @metoceanapi/wxtiles-common/managers/BaseDatasetManager/BaseDatasetManager

Usage Note: Do not create instances directly using the constructor. Use createDatasetManager instead.

Example

async function fetchWxDataset() {
try {
const wxapi = new WxAPI({ dataServerURL: "https://example.com" });
const wxDatasetManager = await wxapi.createDatasetManager("gfs.global");

console.log(wxDatasetManager.getAllVariables());
} catch (error) {
console.error("Error fetching dataset:", error);
}
}

fetchWxDataset();

Hierarchy

  • BaseDatasetManager
    • WxDataSetManager

Constructors

Properties

datasetName: string

The name of the dataset being managed.

wxAPI: WxAPI

A reference to the WX API instance that created this manager.

Methods

  • Internal

    Checks if variable is a vector component.

    Argument

    variable - variable name

    Returns

    • [variable] or [variable.eastward, variable.northward]

    Parameters

    • variable: string

    Returns WxLayerVarsNames

  • Constructs the URI for fetching dataset tiles.

    Returns

    • A URI ready for fetching tiles.

    Throws

    • If the variable is invalid.

    Example

    const uri = wxDatasetManager.createURI("temperature", "2024-06-10T12:00:00Z");
    console.log(uri);

    Parameters

    • variable: string

      The variable name (e.g., "temperature").

    • validTime: string

      The valid time step for the dataset.

    • Optional ext: "webp" = "webp"

      File extension (must be 'webp').

    Returns string

  • Retrieves all available variables for the dataset.

    Returns

    • List of all variable names in the dataset.

    Returns string[]

  • Get dataset's boundaries.

    Returns

    • dataset's boundaries

    Returns undefined | WxAllBoundariesMeta

  • Get dataset's metadata for the given instance.

    Returns

    Parameters

    • Optional instance: string

    Returns WxDatasetMeta

  • Get the variable meta from the instanced dataset.

    Argument

    variable - variable name

    Argument

    instance - instance name

    Returns

    • dataset variable's meta for the given instance

    Parameters

    • variable: string
    • Optional instance: string

    Returns undefined | WxVariableMeta

  • Finds the nearest valid time in the dataset based on the input.

    • If time is an empty string, the last available time is returned.
    • If time is a string matching a valid time, that time is returned.
    • If time is a number:
      • Negative: Returns the first time.
      • Within range: Returns the corresponding indexed time.
    • Otherwise, finds the closest time in milliseconds.

    Returns

    • The nearest valid time from the dataset's time steps.

    Example

    const nearestTime = wxDatasetManager.getNearestValidTime("2024-06-10T12:00:00Z");
    console.log(nearestTime); // Closest valid time

    Parameters

    • Optional time: WxDate = ...

      Input time as a string, number, or Date object.

    Returns string

  • Get the variable's meta from the dataset.

    Argument

    variable - variable name

    Returns

    • dataset variable's meta

    Parameters

    • variable: string

    Returns undefined | WxVariableMeta

  • Check if given variable is available in the dataset.

    Argument

    variable - variable name

    Returns

    • true if variable is available in the dataset

    Parameters

    • variable: string

    Returns boolean

Generated using TypeDoc