gridviz 3.0.19 → 3.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -128
- package/dist/gridviz.js +7875 -7857
- package/dist/gridviz.min.js +1 -1
- package/package.json +74 -74
- package/src/button/ZoomButtons.js +101 -101
- package/src/core/Dataset.js +154 -154
- package/src/core/Drawable.js +78 -60
- package/src/core/GeoCanvas.js +430 -430
- package/src/core/Layer.js +23 -23
- package/src/core/Legend.js +108 -108
- package/src/core/Map.js +516 -516
- package/src/core/MultiResolutionDataset.js +93 -93
- package/src/core/Style.js +98 -98
- package/src/dataset/CSVGrid.js +112 -112
- package/src/dataset/GeoTIFF.js +122 -122
- package/src/dataset/JSGrid.js +55 -55
- package/src/dataset/TiledGrid.js +302 -302
- package/src/dataset/worker.js +18 -18
- package/src/index.js +77 -77
- package/src/layer/BackgroundLayer.js +162 -162
- package/src/layer/BackgroundLayerImage.js +81 -81
- package/src/layer/BackgroundLayerWMS.js +104 -104
- package/src/layer/GeoJSONLayer.js +214 -214
- package/src/layer/GridLayer.js +148 -148
- package/src/layer/LabelLayer.js +194 -194
- package/src/legend/ColorCategoryLegend.js +109 -109
- package/src/legend/ColorDiscreteLegend.js +100 -100
- package/src/legend/ColorLegend.js +115 -115
- package/src/legend/OrientationLegend.js +89 -89
- package/src/legend/SizeLegend.js +224 -224
- package/src/legend/TernaryLegend.js +302 -302
- package/src/style/CompositionStyle.js +291 -291
- package/src/style/DotDensityStyle.js +133 -133
- package/src/style/ImageStyle.js +100 -100
- package/src/style/IsoFenceStyle.js +217 -217
- package/src/style/JoyPlotStyle.js +127 -127
- package/src/style/LegoStyle.js +110 -110
- package/src/style/MosaicStyle.js +99 -99
- package/src/style/NinjaStarStyle.js +102 -102
- package/src/style/PillarStyle.js +207 -207
- package/src/style/SegmentStyle.js +105 -105
- package/src/style/ShapeColorSizeStyle.js +147 -147
- package/src/style/SideCategoryStyle.js +112 -112
- package/src/style/SideStyle.js +212 -212
- package/src/style/SquareColorCategoryWebGLStyle.js +107 -107
- package/src/style/SquareColorWebGLStyle.js +126 -126
- package/src/style/StrokeStyle.js +135 -135
- package/src/style/TanakaStyle.js +69 -69
- package/src/style/TextStyle.js +110 -110
- package/src/style/TimeSeriesStyle.js +222 -222
- package/src/utils/scale.js +218 -218
- package/src/utils/stretching.js +120 -120
- package/src/utils/ternary.js +208 -208
- package/src/utils/utils.js +58 -58
- package/src/utils/webGLUtils.js +72 -72
package/src/utils/webGLUtils.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} width
|
|
6
|
-
* @param {string} height
|
|
7
|
-
* @param {object} opts
|
|
8
|
-
* @returns {{canvas:HTMLCanvasElement, gl:WebGLRenderingContext}}
|
|
9
|
-
*/
|
|
10
|
-
export function makeWebGLCanvas(width, height, opts = {}) {
|
|
11
|
-
const canvas = document.createElement('canvas')
|
|
12
|
-
canvas.setAttribute('width', width)
|
|
13
|
-
canvas.setAttribute('height', height)
|
|
14
|
-
/** @type {WebGLRenderingContext} */
|
|
15
|
-
const gl = canvas.getContext('webgl', opts)
|
|
16
|
-
if (!gl) {
|
|
17
|
-
throw new Error('Unable to initialize WebGL. Your browser or machine may not support it.')
|
|
18
|
-
}
|
|
19
|
-
return { canvas: canvas, gl: gl }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Initialize a shader program, so WebGL knows how to draw our data
|
|
24
|
-
*
|
|
25
|
-
* @param {WebGLRenderingContext} gl
|
|
26
|
-
* @param {...WebGLShader} shaders
|
|
27
|
-
* @returns {WebGLProgram}
|
|
28
|
-
*/
|
|
29
|
-
export function initShaderProgram(gl, ...shaders) {
|
|
30
|
-
/** @type {WebGLProgram|null} */
|
|
31
|
-
const program = gl.createProgram()
|
|
32
|
-
if (program == null) throw new Error('Cannot create webGL program')
|
|
33
|
-
for (const shader of shaders) gl.attachShader(program, shader)
|
|
34
|
-
gl.linkProgram(program)
|
|
35
|
-
if (gl.getProgramParameter(program, gl.LINK_STATUS)) return program
|
|
36
|
-
throw new Error(gl.getProgramInfoLog(program) || 'Cannot create webGL program (2)')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Creates a shader of the given type, uploads the source and compiles it.
|
|
41
|
-
*
|
|
42
|
-
* @param {WebGLRenderingContext} gl
|
|
43
|
-
* @param {number} type
|
|
44
|
-
* @param {...string} sources
|
|
45
|
-
* @returns {WebGLShader}
|
|
46
|
-
*/
|
|
47
|
-
export function createShader(gl, type, ...sources) {
|
|
48
|
-
/** @type {WebGLShader|null} */
|
|
49
|
-
const shader = gl.createShader(type)
|
|
50
|
-
if (shader == null) throw new Error('Cannot create webGL shader')
|
|
51
|
-
gl.shaderSource(shader, sources.join('\n'))
|
|
52
|
-
gl.compileShader(shader)
|
|
53
|
-
if (gl.getShaderParameter(shader, gl.COMPILE_STATUS)) return shader
|
|
54
|
-
throw new Error(gl.getShaderInfoLog(shader) || 'Cannot create webGL shader (2)')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Check if webGL is supported
|
|
59
|
-
*
|
|
60
|
-
* @returns {boolean}
|
|
61
|
-
*/
|
|
62
|
-
export function checkWebGLSupport() {
|
|
63
|
-
try {
|
|
64
|
-
const canvas = document.createElement('canvas')
|
|
65
|
-
return !!(
|
|
66
|
-
!!window.WebGLRenderingContext &&
|
|
67
|
-
(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
|
|
68
|
-
)
|
|
69
|
-
} catch (err) {
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} width
|
|
6
|
+
* @param {string} height
|
|
7
|
+
* @param {object} opts
|
|
8
|
+
* @returns {{canvas:HTMLCanvasElement, gl:WebGLRenderingContext}}
|
|
9
|
+
*/
|
|
10
|
+
export function makeWebGLCanvas(width, height, opts = {}) {
|
|
11
|
+
const canvas = document.createElement('canvas')
|
|
12
|
+
canvas.setAttribute('width', width)
|
|
13
|
+
canvas.setAttribute('height', height)
|
|
14
|
+
/** @type {WebGLRenderingContext} */
|
|
15
|
+
const gl = canvas.getContext('webgl', opts)
|
|
16
|
+
if (!gl) {
|
|
17
|
+
throw new Error('Unable to initialize WebGL. Your browser or machine may not support it.')
|
|
18
|
+
}
|
|
19
|
+
return { canvas: canvas, gl: gl }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Initialize a shader program, so WebGL knows how to draw our data
|
|
24
|
+
*
|
|
25
|
+
* @param {WebGLRenderingContext} gl
|
|
26
|
+
* @param {...WebGLShader} shaders
|
|
27
|
+
* @returns {WebGLProgram}
|
|
28
|
+
*/
|
|
29
|
+
export function initShaderProgram(gl, ...shaders) {
|
|
30
|
+
/** @type {WebGLProgram|null} */
|
|
31
|
+
const program = gl.createProgram()
|
|
32
|
+
if (program == null) throw new Error('Cannot create webGL program')
|
|
33
|
+
for (const shader of shaders) gl.attachShader(program, shader)
|
|
34
|
+
gl.linkProgram(program)
|
|
35
|
+
if (gl.getProgramParameter(program, gl.LINK_STATUS)) return program
|
|
36
|
+
throw new Error(gl.getProgramInfoLog(program) || 'Cannot create webGL program (2)')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a shader of the given type, uploads the source and compiles it.
|
|
41
|
+
*
|
|
42
|
+
* @param {WebGLRenderingContext} gl
|
|
43
|
+
* @param {number} type
|
|
44
|
+
* @param {...string} sources
|
|
45
|
+
* @returns {WebGLShader}
|
|
46
|
+
*/
|
|
47
|
+
export function createShader(gl, type, ...sources) {
|
|
48
|
+
/** @type {WebGLShader|null} */
|
|
49
|
+
const shader = gl.createShader(type)
|
|
50
|
+
if (shader == null) throw new Error('Cannot create webGL shader')
|
|
51
|
+
gl.shaderSource(shader, sources.join('\n'))
|
|
52
|
+
gl.compileShader(shader)
|
|
53
|
+
if (gl.getShaderParameter(shader, gl.COMPILE_STATUS)) return shader
|
|
54
|
+
throw new Error(gl.getShaderInfoLog(shader) || 'Cannot create webGL shader (2)')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Check if webGL is supported
|
|
59
|
+
*
|
|
60
|
+
* @returns {boolean}
|
|
61
|
+
*/
|
|
62
|
+
export function checkWebGLSupport() {
|
|
63
|
+
try {
|
|
64
|
+
const canvas = document.createElement('canvas')
|
|
65
|
+
return !!(
|
|
66
|
+
!!window.WebGLRenderingContext &&
|
|
67
|
+
(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
|
|
68
|
+
)
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
}
|