Class: GriddedDataLayer

GriddedDataLayer(displayName, gridDataUrl)

A GriddedDataLayer layer for visualising vector data.

Constructor

new GriddedDataLayer(displayName, gridDataUrl)

Constructs a GriddedDataLayer. The GriddedDataLayer displays vector GRIB data as moving particles with trails. The GRIB data is loaded from a JSON file as outputed by the grib2json library. Alternatively apps can load the JSON file themselves and set the gridData property.
Parameters:
Name Type Description
displayName String This layer's display name.
gridDataUrl String An url from which to load the grib data
Source:
Examples
var windLayer = new GriddedDataLayer('Wind', './wind.json');
var windLayer = new GriddedDataLayer('Wind');
fetch('./wind.json')
    .then(res => res.json())
    .then(windGribData => windLayer.gridData = windLayer.createGridData(windGribData));

Extends

Members

colors :Object

An object describing a color gradient. The keys are the color stops (between 0 and 1) and the values are valid CSS colors.
Type:
  • Object
Source:

crossOrigin :string

Indicates whether credentials are sent when requesting images from a different origin. Allowed values are anonymous and use-credentials.
Type:
  • string
Inherited From:
Default Value:
  • anonymous
Source:
See:

detailControl :Number

Controls the level of detail switching for this layer. The next highest resolution level is used when an image's texel size is greater than this number of pixels, up to the maximum resolution of this layer.
Type:
  • Number
Inherited From:
Default Value:
  • 1.75
Source:

displayName :String

This layer's display name.
Type:
  • String
Overrides:
Default Value:
  • "Layer"
Source:

dropRate :Number

Controls how often the particles move to a random place
Type:
  • Number
Default Value:
  • 0.003
Source:

dropRateMultiplier :Number

Controls the drop rate of a particle relative to individual particle speed.
Type:
  • Number
Default Value:
  • 0.01
Source:

enabled :Boolean

Indicates whether to display this layer.
Type:
  • Boolean
Inherited From:
Default Value:
  • true
Source:

eyeAltitudeReduction :Number

Reduces the eye altitude by the specified amount (default is 15%). By reducing the eye a more precise boundig secor cand be determined by culling tile on the edges of the globe. Setting this value to 0 will render all visible tiles.
Type:
  • Number
Default Value:
  • 0.15
Source:

eyeAltitudeReductionTrehshold :Number

Specifies the maxmimum altitude at which visible tile will be culled. At altitudes higher than this value all visible tiles are rendered (eyeAltitudeReduction is considred to be 0)
Type:
  • Number
Default Value:
  • 20e6
Source:

fadeOpacity :Number

Controls how fast the particle trails fade on each frame. A number between [0, 1)
Type:
  • Number
Default Value:
  • 0.996
Source:

gridData :Object

The gridData as outputed by the createGridData method.
Type:
  • Object
Source:

(readonly) inCurrentFrame :Boolean

Indicates whether elements of this layer were drawn in the most recently generated frame.
Type:
  • Boolean
Overrides:
Source:

maxActiveAltitude :Number

The eye altitude below which this layer is displayed, in meters.
Type:
  • Number
Inherited From:
Default Value:
  • Number.MAX_VALUE (always displayed)
Source:

minActiveAltitude :Number

The eye altitude above which this layer is displayed, in meters.
Type:
  • Number
Inherited From:
Default Value:
  • -Number.MAX_VALUE (always displayed)
Source:

numParticles :Number

The number of particles to render.
Type:
  • Number
Default Value:
  • 16384
Source:

opacity :Number

This layer's opacity, which is combined with the opacity of shapes within layers. Opacity is in the range [0, 1], with 1 indicating fully opaque.
Type:
  • Number
Inherited From:
Default Value:
  • 1
Source:

pickEnabled :Boolean

Indicates whether this layer is pickable.
Type:
  • Boolean
Inherited From:
Default Value:
  • true
Source:

retrievalQueueSize :Number

Controls how many concurrent tile requests are allowed for this layer.
Type:
  • Number
Inherited From:
Default Value:
  • WorldWind.configuration.layerRetrievalQueueSize
Source:

(readonly) sector :Sector

The bounding sector of this layer as computed from the tiles.
Type:
Source:

speedFactor :Number

Controls how fast the particles move
Type:
  • Number
Default Value:
  • 0.25
Source:

time :Date

The time to display. This property selects the layer contents that represents the specified time. If null, layer-type dependent contents are displayed.
Type:
  • Date
Inherited From:
Source:

waitTime :Number

Rendering pauses when the globe is moving and resumes some time after the globe is not moving anymore. The time, in miliseconds, after which rendering resumes.
Type:
  • Number
Default Value:
  • 334
Source:

Methods

bind(dc)

Binds the teture of the offscreen framebuffer to be drawn on the terrain.
Parameters:
Name Type Description
dc DrawContext
Source:

clearGroundFbo(dc)

Clears the ground fbo's textures.
Parameters:
Name Type Description
dc DrawContext
Source:

createColorGradient(colors) → {Uint8ClampedArray}

Creates a color gradient for the given colors.
Parameters:
Name Type Description
colors Object An object with the keys as numbers between 0 - 1 and the values as a valid css color string.
Source:
Returns:
Type
Uint8ClampedArray

createColorsTexture(dc, key) → {WebGLTexture}

Creates a WebGLTexture for the color gradient.
Parameters:
Name Type Description
dc DrawContext
key String The gpuCache key
Source:
Returns:
Type
WebGLTexture

createGridData(gribData) → {Object}

Transforms the gribData as outputed by the grib2json library to a format suitable for rendering in an offsreen framebuffer
Parameters:
Name Type Description
gribData Object The grib data as outputed by the grib2json library
Source:
Returns:
The grid data needed for rendering in an offsreen framebuffer
Type
Object

createGridTexture(dc, key) → {WebGLTexture}

Creates a WebGLTexture for the grib data.
Parameters:
Name Type Description
dc DrawContext
key String The gpuCache key
Source:
Returns:
Type
WebGLTexture

createGroundFbo(dc, key) → {DoubleBufferedFbo}

Creates a DoubleBufferedFbo for the particle ground texture.
Parameters:
Name Type Description
dc DrawContext
key String The gpuCache key
Source:
Returns:
Type
DoubleBufferedFbo

createParticleVbo(dc, key) → {WebGLBuffer}

Creates a WebGLBuffer for the particles.
Parameters:
Name Type Description
dc DrawContext
key String The gpuCache key
Source:
Returns:
Type
WebGLBuffer

createQuadVbo(dc, key) → {WebGLBuffer}

Creates a WebGLBuffer for a quad.
Parameters:
Name Type Description
dc DrawContext
key String The gpuCache key
Source:
Returns:
Type
WebGLBuffer

createSimFbo(dc, key) → {DoubleBufferedFbo}

Creates a DoubleBufferedFbo for the particle simulation.
Parameters:
Name Type Description
dc DrawContext
key String The gpuCache key
Source:
Returns:
Type
DoubleBufferedFbo

createTexture(dc, data, options) → {WebGLTexture}

Creates a WebGLTexture for a given typed array and options.
Parameters:
Name Type Description
dc DrawContext
data Unit8Array A typped array, ussually a Unit8Array
options Object Options for the width, height, wrap, min and max filters. Width and height are mandatory.
Source:
Returns:
Type
WebGLTexture

cullTilesHorizon(dc, tiles) → {Array}

Removes tiles that are behind the horizon. The eyeAltitudeReduction parameter of this layer can be used to futher cull tiles that are on the edge of the globe and barely visible. Setting the eyeAltitudeReduction to 0 will not cull tiles that are visible. The eyeAltitudeReductionTrehshold parameter of this layer controlls if a reduction should apply. When the altitude is very high, tiles that are perfectly visible might get culled.
Parameters:
Name Type Description
dc DrawContext
tiles Array
Source:
Returns:
The tiles that are visible.
Type
Array

(protected) doRender(dc)

Subclass method called to display this layer. Subclasses should implement this method rather than the render method, which determines enable, pick and active altitude status and does not call this doRender method if the layer should not be displayed.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Overrides:
Source:

getBoundingBox(sector, bbox) → {Array}

Computes a normalized bounding box for the given sector and saves the result in the provides bbox. The x axis coresponds with longitude, 0 coresponds with -180 and 1 coresponds with 180. The y axis coresponds with latitude, 0 coresponds with 90 and 1 coresponds with -90.
Parameters:
Name Type Description
sector Sector The sector for which to compute the bounding box
bbox Float32Array An array in which to store the result. The format is: [xMin, yMin, xMax, yMax]
Source:
Returns:
The provided bbox
Type
Array

getBoundingSector(tiles, sector) → {Sector}

Computes the bounding sector for a list of tiles and saves the result in the provides sector.
Parameters:
Name Type Description
tiles Array The list of tiles
sector Sector The sector in which to save the result
Source:
Returns:
The bounding sector
Type
Sector

(protected) isLayerInView(dc) → {boolean}

Indicates whether this layer is within the current view. Subclasses may override this method and when called determine whether the layer contents are visible in the current view frustum. The default implementation always returns true.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:
Returns:
true If this layer is within the current view, otherwise false.
Type
boolean

isPrePopulated(wwd) → {Boolean}

Indicates whether this layer's level 0 tile images have been retrieved and associated with the tiles. Use prePopulate to initiate retrieval of level 0 images.
Parameters:
Name Type Description
wwd WorldWindow The WorldWindow associated with this layer.
Inherited From:
Source:
Throws:
If the specified WorldWindow is null or undefined.
Type
ArgumentError
Returns:
true if all level 0 images have been retrieved, otherwise false.
Type
Boolean

loadGridData(url)

Loads the grid json data from the specified url.
Parameters:
Name Type Description
url String
Source:

prePopulate(wwd)

Initiates retrieval of this layer's level 0 images. Use isPrePopulated to determine when the images have been retrieved and associated with the level 0 tiles. Pre-populating is not required. It is used to eliminate the visual effect of loading tiles incrementally, but only for level 0 tiles. An application might pre-populate a layer in order to delay displaying it within a time series until all the level 0 images have been retrieved and added to memory.
Parameters:
Name Type Description
wwd WorldWindow The WorldWindow for which to pre-populate this layer.
Inherited From:
Source:
Throws:
If the specified WorldWindow is null or undefined.
Type
ArgumentError

prePopulateCurrentTiles(wwd)

Initiates retrieval of this layer's tiles that are visible in the specified WorldWindow. Pre-populating is not required. It is used to eliminate the visual effect of loading tiles incrementally.
Parameters:
Name Type Description
wwd WorldWindow The WorldWindow for which to pre-populate this layer.
Inherited From:
Source:
Throws:
If the specified WorldWindow is null or undefined.
Type
ArgumentError

refresh()

Refreshes the data associated with this layer. The behavior of this function varies with the layer type. For image layers, it causes the images to be re-retrieved from their origin.
Inherited From:
Source:

render(dc)

Displays this layer. Subclasses should generally not override this method but should instead override the doRender method. This method calls that method after verifying that the layer is enabled, the eye point is within this layer's active altitudes and the layer is in view.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:

renderToTexture(dc)

Renders the grid data as particles with trails to an offsreeen framebuffer.
Parameters:
Name Type Description
dc DrawContext
Source:

(protected) resourceUrlForTile(tile, imageFormat) → {String}

Returns the URL string for the resource.
Parameters:
Name Type Description
tile ImageTile The tile whose image is returned
imageFormat String The mime type of the image format desired.
Inherited From:
Source:
Returns:
The URL string, or null if the string can not be formed.
Type
String

restoreGLState(dc)

Restores the WebGL state after rendering to an offsreeen framebuffer.
Parameters:
Name Type Description
dc DrawContext
Source:

(protected) retrieveTileImage(dc, tile, suppressRedraw)

Retrieves the image for the specified tile. Subclasses should override this method in order to retrieve, compute or otherwise create the image.
Parameters:
Name Type Description
dc DrawContext The current draw context.
tile ImageTile The tile for which to retrieve the resource.
suppressRedraw Boolean true to suppress generation of redraw events when an image is successfully retrieved, otherwise false.
Overrides:
Source: