gridviz 2.0.45 → 2.0.46
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 +119 -119
- package/dist/gridviz.js +6937 -6937
- package/package.json +76 -76
- package/src/App.js +668 -668
- package/src/BackgroundLayer.js +182 -182
- package/src/BackgroundLayerWMS.js +131 -131
- package/src/Dataset.js +76 -76
- package/src/DatasetComponent.js +101 -101
- package/src/GeoCanvas.js +420 -420
- package/src/LabelLayer.js +190 -190
- package/src/Layer.js +92 -92
- package/src/Legend.js +86 -86
- package/src/LineLayer.js +150 -150
- package/src/Style.js +114 -114
- package/src/Tooltip.js +172 -172
- package/src/dataset/COGeo.js +24 -24
- package/src/dataset/CSVGrid.js +104 -104
- package/src/dataset/GeoTIFF.js +127 -127
- package/src/dataset/GridTile.js +41 -41
- package/src/dataset/TiledGrid.js +264 -264
- package/src/index.js +177 -176
- package/src/legend/ColorCategoryLegend.js +124 -124
- package/src/legend/ColorDiscreteLegend.js +103 -103
- package/src/legend/ColorLegend.js +124 -124
- package/src/legend/SegmentOrientationLegend.js +87 -87
- package/src/legend/SegmentWidthLegend.js +97 -97
- package/src/legend/SizeLegend.js +141 -141
- package/src/style/CompositionStyle.js +300 -300
- package/src/style/ContourStyle.js +54 -54
- package/src/style/DotDensityStyle.js +156 -156
- package/src/style/JoyPlotStyle.js +135 -135
- package/src/style/LegoStyle.js +112 -112
- package/src/style/MosaicStyle.js +107 -107
- package/src/style/NinjaStarStyle.js +124 -124
- package/src/style/PillarStyle.js +230 -230
- package/src/style/SegmentStyle.js +142 -142
- package/src/style/ShapeColorSizeStyle.js +126 -126
- package/src/style/SideCatStyle.js +172 -172
- package/src/style/SideStyle.js +218 -218
- package/src/style/SquareColorCatWGLStyle.js +120 -120
- package/src/style/SquareColorWGLStyle.js +146 -146
- package/src/style/StrokeStyle.js +131 -131
- package/src/style/TanakaStyle.js +160 -160
- package/src/style/TextStyle.js +132 -132
- package/src/utils/Utils.js +35 -35
- package/src/utils/WebGLRectangleColoring.js +106 -106
- package/src/utils/WebGLSquareColoring.js +118 -118
- package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
- package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
- package/src/utils/WebGLSquareColoringKS.js +153 -153
- package/src/utils/stretching.js +131 -131
- package/src/utils/webGLUtils.js +71 -71
- package/src/utils/zoomUtils.js +142 -142
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { initShaderProgram, createShader } from './webGLUtils.js'
|
|
5
|
-
import { color } from 'd3-color'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Everything to easily draw colored squares with webGL.
|
|
9
|
-
* All the same size, but different fill color.
|
|
10
|
-
*/
|
|
11
|
-
export class WebGLSquareColoring {
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {WebGLRenderingContext} gl
|
|
15
|
-
*/
|
|
16
|
-
constructor(gl, sizePix) {
|
|
17
|
-
this.gl = gl
|
|
18
|
-
this.sizePix = sizePix || 10.0
|
|
19
|
-
|
|
20
|
-
this.program = initShaderProgram(
|
|
21
|
-
gl,
|
|
22
|
-
createShader(
|
|
23
|
-
gl,
|
|
24
|
-
gl.VERTEX_SHADER,
|
|
25
|
-
`
|
|
26
|
-
attribute vec2 pos;
|
|
27
|
-
uniform float sizePix;
|
|
28
|
-
uniform mat3 mat;
|
|
29
|
-
attribute vec4 color;
|
|
30
|
-
varying vec4 vColor;
|
|
31
|
-
void main() {
|
|
32
|
-
gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
|
|
33
|
-
gl_PointSize = sizePix;
|
|
34
|
-
vColor = color;
|
|
35
|
-
}
|
|
36
|
-
`
|
|
37
|
-
),
|
|
38
|
-
createShader(
|
|
39
|
-
gl,
|
|
40
|
-
gl.FRAGMENT_SHADER,
|
|
41
|
-
`
|
|
42
|
-
precision mediump float;
|
|
43
|
-
varying vec4 vColor;
|
|
44
|
-
void main(void) {
|
|
45
|
-
vec4 vColor_ = vColor / 255.0;
|
|
46
|
-
vColor_[3] = 255.0 * vColor_[3];
|
|
47
|
-
gl_FragColor = vColor_;
|
|
48
|
-
}`
|
|
49
|
-
)
|
|
50
|
-
)
|
|
51
|
-
gl.useProgram(this.program)
|
|
52
|
-
|
|
53
|
-
//buffer data
|
|
54
|
-
this.verticesBuffer = []
|
|
55
|
-
this.colorsBuffer = []
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Add data to vertices/size/color buffers for color squares drawing */
|
|
59
|
-
addPointData(xC, yC, col) {
|
|
60
|
-
//convert color
|
|
61
|
-
const cc = color(col)
|
|
62
|
-
//const cc = {r:45,g:87,b:98,opacity:0.9}
|
|
63
|
-
if (!cc) return
|
|
64
|
-
|
|
65
|
-
//vertices
|
|
66
|
-
this.verticesBuffer.push(xC, yC)
|
|
67
|
-
//color
|
|
68
|
-
this.colorsBuffer.push(cc.r, cc.g, cc.b, cc.opacity)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
addPointData2(xC, yC, r, g, b, opacity) {
|
|
72
|
-
//vertices
|
|
73
|
-
this.verticesBuffer.push(xC, yC)
|
|
74
|
-
//color
|
|
75
|
-
this.colorsBuffer.push(r, g, b, opacity)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** */
|
|
79
|
-
draw(transfoMat) {
|
|
80
|
-
const gl = this.gl
|
|
81
|
-
|
|
82
|
-
//vertice data
|
|
83
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
|
|
84
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.verticesBuffer), gl.STATIC_DRAW)
|
|
85
|
-
const position = gl.getAttribLocation(this.program, 'pos')
|
|
86
|
-
gl.vertexAttribPointer(
|
|
87
|
-
position,
|
|
88
|
-
2, //numComponents
|
|
89
|
-
gl.FLOAT, //type
|
|
90
|
-
false, //normalise
|
|
91
|
-
0, //stride
|
|
92
|
-
0 //offset
|
|
93
|
-
)
|
|
94
|
-
gl.enableVertexAttribArray(position)
|
|
95
|
-
|
|
96
|
-
//color data
|
|
97
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
|
|
98
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.colorsBuffer), gl.STATIC_DRAW)
|
|
99
|
-
var color = gl.getAttribLocation(this.program, 'color')
|
|
100
|
-
gl.vertexAttribPointer(color, 4, gl.FLOAT, false, 0, 0)
|
|
101
|
-
gl.enableVertexAttribArray(color)
|
|
102
|
-
|
|
103
|
-
//sizePix
|
|
104
|
-
gl.uniform1f(gl.getUniformLocation(this.program, 'sizePix'), 1.0 * this.sizePix)
|
|
105
|
-
|
|
106
|
-
//transformation
|
|
107
|
-
gl.uniformMatrix3fv(gl.getUniformLocation(this.program, 'mat'), false, new Float32Array(transfoMat))
|
|
108
|
-
|
|
109
|
-
// Enable the depth test
|
|
110
|
-
//gl.enable(gl.DEPTH_TEST);
|
|
111
|
-
// Clear the color buffer bit
|
|
112
|
-
gl.clear(gl.COLOR_BUFFER_BIT)
|
|
113
|
-
// Set the view port
|
|
114
|
-
//gl.viewport(0, 0, cg.w, cg.h);
|
|
115
|
-
|
|
116
|
-
gl.drawArrays(gl.POINTS, 0, this.verticesBuffer.length / 2)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { initShaderProgram, createShader } from './webGLUtils.js'
|
|
5
|
+
import { color } from 'd3-color'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Everything to easily draw colored squares with webGL.
|
|
9
|
+
* All the same size, but different fill color.
|
|
10
|
+
*/
|
|
11
|
+
export class WebGLSquareColoring {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {WebGLRenderingContext} gl
|
|
15
|
+
*/
|
|
16
|
+
constructor(gl, sizePix) {
|
|
17
|
+
this.gl = gl
|
|
18
|
+
this.sizePix = sizePix || 10.0
|
|
19
|
+
|
|
20
|
+
this.program = initShaderProgram(
|
|
21
|
+
gl,
|
|
22
|
+
createShader(
|
|
23
|
+
gl,
|
|
24
|
+
gl.VERTEX_SHADER,
|
|
25
|
+
`
|
|
26
|
+
attribute vec2 pos;
|
|
27
|
+
uniform float sizePix;
|
|
28
|
+
uniform mat3 mat;
|
|
29
|
+
attribute vec4 color;
|
|
30
|
+
varying vec4 vColor;
|
|
31
|
+
void main() {
|
|
32
|
+
gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
|
|
33
|
+
gl_PointSize = sizePix;
|
|
34
|
+
vColor = color;
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
),
|
|
38
|
+
createShader(
|
|
39
|
+
gl,
|
|
40
|
+
gl.FRAGMENT_SHADER,
|
|
41
|
+
`
|
|
42
|
+
precision mediump float;
|
|
43
|
+
varying vec4 vColor;
|
|
44
|
+
void main(void) {
|
|
45
|
+
vec4 vColor_ = vColor / 255.0;
|
|
46
|
+
vColor_[3] = 255.0 * vColor_[3];
|
|
47
|
+
gl_FragColor = vColor_;
|
|
48
|
+
}`
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
gl.useProgram(this.program)
|
|
52
|
+
|
|
53
|
+
//buffer data
|
|
54
|
+
this.verticesBuffer = []
|
|
55
|
+
this.colorsBuffer = []
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Add data to vertices/size/color buffers for color squares drawing */
|
|
59
|
+
addPointData(xC, yC, col) {
|
|
60
|
+
//convert color
|
|
61
|
+
const cc = color(col)
|
|
62
|
+
//const cc = {r:45,g:87,b:98,opacity:0.9}
|
|
63
|
+
if (!cc) return
|
|
64
|
+
|
|
65
|
+
//vertices
|
|
66
|
+
this.verticesBuffer.push(xC, yC)
|
|
67
|
+
//color
|
|
68
|
+
this.colorsBuffer.push(cc.r, cc.g, cc.b, cc.opacity)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
addPointData2(xC, yC, r, g, b, opacity) {
|
|
72
|
+
//vertices
|
|
73
|
+
this.verticesBuffer.push(xC, yC)
|
|
74
|
+
//color
|
|
75
|
+
this.colorsBuffer.push(r, g, b, opacity)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** */
|
|
79
|
+
draw(transfoMat) {
|
|
80
|
+
const gl = this.gl
|
|
81
|
+
|
|
82
|
+
//vertice data
|
|
83
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
|
|
84
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.verticesBuffer), gl.STATIC_DRAW)
|
|
85
|
+
const position = gl.getAttribLocation(this.program, 'pos')
|
|
86
|
+
gl.vertexAttribPointer(
|
|
87
|
+
position,
|
|
88
|
+
2, //numComponents
|
|
89
|
+
gl.FLOAT, //type
|
|
90
|
+
false, //normalise
|
|
91
|
+
0, //stride
|
|
92
|
+
0 //offset
|
|
93
|
+
)
|
|
94
|
+
gl.enableVertexAttribArray(position)
|
|
95
|
+
|
|
96
|
+
//color data
|
|
97
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
|
|
98
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.colorsBuffer), gl.STATIC_DRAW)
|
|
99
|
+
var color = gl.getAttribLocation(this.program, 'color')
|
|
100
|
+
gl.vertexAttribPointer(color, 4, gl.FLOAT, false, 0, 0)
|
|
101
|
+
gl.enableVertexAttribArray(color)
|
|
102
|
+
|
|
103
|
+
//sizePix
|
|
104
|
+
gl.uniform1f(gl.getUniformLocation(this.program, 'sizePix'), 1.0 * this.sizePix)
|
|
105
|
+
|
|
106
|
+
//transformation
|
|
107
|
+
gl.uniformMatrix3fv(gl.getUniformLocation(this.program, 'mat'), false, new Float32Array(transfoMat))
|
|
108
|
+
|
|
109
|
+
// Enable the depth test
|
|
110
|
+
//gl.enable(gl.DEPTH_TEST);
|
|
111
|
+
// Clear the color buffer bit
|
|
112
|
+
gl.clear(gl.COLOR_BUFFER_BIT)
|
|
113
|
+
// Set the view port
|
|
114
|
+
//gl.viewport(0, 0, cg.w, cg.h);
|
|
115
|
+
|
|
116
|
+
gl.drawArrays(gl.POINTS, 0, this.verticesBuffer.length / 2)
|
|
117
|
+
}
|
|
118
|
+
}
|