gridviz 3.0.35 → 3.0.36

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.
Files changed (67) hide show
  1. package/README.md +129 -129
  2. package/dist/gridviz.js +17486 -17486
  3. package/dist/gridviz.min.js +2 -2
  4. package/package.json +73 -73
  5. package/src/button/Button.js +67 -67
  6. package/src/button/FullscreenButton.js +121 -121
  7. package/src/button/ZoomButtons.js +103 -103
  8. package/src/core/Dataset.js +154 -154
  9. package/src/core/Drawable.js +78 -78
  10. package/src/core/GeoCanvas.js +443 -443
  11. package/src/core/Layer.js +23 -23
  12. package/src/core/Legend.js +108 -108
  13. package/src/core/Map.js +568 -568
  14. package/src/core/MultiResolutionDataset.js +93 -93
  15. package/src/core/Style.js +98 -98
  16. package/src/core/Tooltip.js +182 -182
  17. package/src/dataset/COGeo.js +25 -25
  18. package/src/dataset/CSVGrid.js +112 -112
  19. package/src/dataset/GeoTIFF.js +122 -122
  20. package/src/dataset/JSGrid.js +55 -55
  21. package/src/dataset/TiledGrid.js +302 -302
  22. package/src/dataset/worker.js +18 -18
  23. package/src/index.js +79 -79
  24. package/src/layer/BackgroundLayer.js +173 -173
  25. package/src/layer/BackgroundLayerImage.js +81 -81
  26. package/src/layer/BackgroundLayerWMS.js +104 -104
  27. package/src/layer/GeoJSONLayer.js +276 -276
  28. package/src/layer/GridLayer.js +166 -166
  29. package/src/layer/LabelLayer.js +194 -194
  30. package/src/legend/ColorCategoryLegend.js +109 -109
  31. package/src/legend/ColorDiscreteLegend.js +100 -100
  32. package/src/legend/ColorLegend.js +115 -115
  33. package/src/legend/OrientationLegend.js +89 -89
  34. package/src/legend/SizeLegend.js +224 -224
  35. package/src/legend/TernaryLegend.js +302 -302
  36. package/src/style/CompositionStyle.js +291 -291
  37. package/src/style/DotDensityStyle.js +133 -133
  38. package/src/style/ImageStyle.js +100 -100
  39. package/src/style/Interpolator.js +258 -258
  40. package/src/style/IsoFenceStyle.js +217 -217
  41. package/src/style/JoyPlotStyle.js +180 -180
  42. package/src/style/LegoStyle.js +132 -132
  43. package/src/style/MosaicStyle.js +99 -99
  44. package/src/style/NinjaStarStyle.js +102 -102
  45. package/src/style/PillarStyle.js +207 -207
  46. package/src/style/SegmentStyle.js +105 -105
  47. package/src/style/ShadingRayStyle.js +280 -280
  48. package/src/style/ShadingStyle.js +72 -72
  49. package/src/style/ShapeColorSizeStyle.js +147 -147
  50. package/src/style/SideCategoryStyle.js +112 -112
  51. package/src/style/SideStyle.js +217 -217
  52. package/src/style/SideTanakaStyle.js +154 -154
  53. package/src/style/SquareColorCategoryWebGLStyle.js +307 -294
  54. package/src/style/SquareColorWebGLStyle.js +126 -126
  55. package/src/style/StrokeStyle.js +135 -135
  56. package/src/style/TextStyle.js +110 -110
  57. package/src/style/TimeSeriesStyle.js +222 -222
  58. package/src/utils/WebGLRectangleColoring.js +106 -106
  59. package/src/utils/WebGLSquareColoring.js +118 -118
  60. package/src/utils/WebGLSquareColoringAdvanced.js +227 -227
  61. package/src/utils/WebGLSquareColoringKS.js +153 -153
  62. package/src/utils/scale.js +255 -255
  63. package/src/utils/stretching.js +120 -120
  64. package/src/utils/ternary.js +208 -208
  65. package/src/utils/utils.js +125 -125
  66. package/src/utils/webGLUtils.js +73 -73
  67. package/src/utils/zoomUtils.js +142 -142
@@ -1,126 +1,126 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Style } from '../core/Style.js'
5
- import { makeWebGLCanvas } from '../utils/webGLUtils.js'
6
- import { WebGLSquareColoringAdvanced } from '../utils/WebGLSquareColoringAdvanced.js'
7
-
8
- /**
9
- * Style based on webGL
10
- * To show cells as colored squares, with computation of the colors on GPU side (faster than JavaScript side).
11
- * Alls squares with the same size
12
- *
13
- * @module style
14
- * @author Julien Gaffuri
15
- */
16
- export class SquareColorWebGLStyle extends Style {
17
- /** @param {object} opts */
18
- constructor(opts) {
19
- super(opts)
20
- opts = opts || {}
21
-
22
- /**
23
- * A function returning a t value (within [0,1]) for a cell.
24
- * @type {function(import('../core/Dataset.js').Cell,number,number,object):number} */
25
- this.tFun = opts.tFun //(c,r,z,vs) => {}
26
-
27
- /**
28
- * Distribution stretching method.
29
- * The stretching is performed on GPU side (fragment shader).
30
- * @type {{ fun:string, alpha:number }} */
31
- this.stretching = opts.stretching
32
-
33
- /**
34
- * The sample of the color ramp.
35
- * The color is computed on GPU side (fragment shader) based on those values (linear interpolation).
36
- * @type {Array.<string>} */
37
- this.colors =
38
- opts.colors ||
39
- [
40
- 'rgb(158, 1, 66)',
41
- 'rgb(248, 142, 83)',
42
- 'rgb(251, 248, 176)',
43
- 'rgb(137, 207, 165)',
44
- 'rgb(94, 79, 162)',
45
- ].reverse()
46
- if (opts.color)
47
- this.colors = [
48
- opts.color(0),
49
- opts.color(0.2),
50
- opts.color(0.4),
51
- opts.color(0.6),
52
- opts.color(0.8),
53
- opts.color(1),
54
- ]
55
-
56
- /**
57
- * Define the opacity of the style, within [0,1].
58
- * If this opacity is defined, the individual color opacity will be ignored.
59
- * @type {function(number,number):number} */
60
- this.opacity = opts.opacity // (r,z) => ...
61
-
62
- /**
63
- * A function returning the size of the cells, in geographical unit. All cells have the same size.
64
- * @type {function(number,number):number} */
65
- this.size = opts.size // (resolution, z) => ...
66
- }
67
-
68
- /**
69
- * @param {Array.<import("../core/Dataset.js").Cell>} cells
70
- * @param {import("../core/GeoCanvas.js").GeoCanvas} geoCanvas
71
- * @param {number} resolution
72
- */
73
- draw(cells, geoCanvas, resolution) {
74
- //filter
75
- if (this.filter) cells = cells.filter(this.filter)
76
-
77
- //
78
- const z = geoCanvas.view.z
79
-
80
- //get view scale
81
- const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
82
-
83
- //create canvas and webgl renderer
84
- //for opacity control, see: https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html
85
- const cvWGL = makeWebGLCanvas(
86
- geoCanvas.w + '',
87
- geoCanvas.h + '',
88
- this.opacity != undefined ? { premultipliedAlpha: false } : undefined
89
- )
90
- if (!cvWGL) {
91
- console.error('No webGL')
92
- return
93
- }
94
-
95
- //add vertice and fragment data
96
- const r2 = resolution / 2
97
- const verticesBuffer = []
98
- const tBuffer = []
99
- for (let cell of cells) {
100
- const t = this.tFun(cell, resolution, z, viewScale)
101
- if (t == null || t == undefined) continue
102
- verticesBuffer.push(cell.x + r2, cell.y + r2)
103
- tBuffer.push(t > 1 ? 1 : t < 0 ? 0 : t)
104
- }
105
-
106
- //compute pixel size
107
- const sizeGeo = this.size ? this.size(resolution, z) : resolution + 0.2 * z
108
-
109
- //compute opacity
110
- const op = this.opacity ? this.opacity(resolution, z) : undefined
111
-
112
- //
113
- const wgp = new WebGLSquareColoringAdvanced(cvWGL.gl, this.colors, this.stretching, sizeGeo / z, op)
114
-
115
- //draw
116
- wgp.draw(verticesBuffer, tBuffer, geoCanvas.getWebGLTransform())
117
-
118
- // draw in canvas geo
119
- // NOTE: drawing each tile this way is very inefficient. WebGL is best used with fewer, heavier/larger draw calls.
120
- geoCanvas.initCanvasTransform()
121
- geoCanvas.offscreenCtx.drawImage(cvWGL.canvas, 0, 0)
122
-
123
- //update legends
124
- this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
125
- }
126
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Style } from '../core/Style.js'
5
+ import { makeWebGLCanvas } from '../utils/webGLUtils.js'
6
+ import { WebGLSquareColoringAdvanced } from '../utils/WebGLSquareColoringAdvanced.js'
7
+
8
+ /**
9
+ * Style based on webGL
10
+ * To show cells as colored squares, with computation of the colors on GPU side (faster than JavaScript side).
11
+ * Alls squares with the same size
12
+ *
13
+ * @module style
14
+ * @author Julien Gaffuri
15
+ */
16
+ export class SquareColorWebGLStyle extends Style {
17
+ /** @param {object} opts */
18
+ constructor(opts) {
19
+ super(opts)
20
+ opts = opts || {}
21
+
22
+ /**
23
+ * A function returning a t value (within [0,1]) for a cell.
24
+ * @type {function(import('../core/Dataset.js').Cell,number,number,object):number} */
25
+ this.tFun = opts.tFun //(c,r,z,vs) => {}
26
+
27
+ /**
28
+ * Distribution stretching method.
29
+ * The stretching is performed on GPU side (fragment shader).
30
+ * @type {{ fun:string, alpha:number }} */
31
+ this.stretching = opts.stretching
32
+
33
+ /**
34
+ * The sample of the color ramp.
35
+ * The color is computed on GPU side (fragment shader) based on those values (linear interpolation).
36
+ * @type {Array.<string>} */
37
+ this.colors =
38
+ opts.colors ||
39
+ [
40
+ 'rgb(158, 1, 66)',
41
+ 'rgb(248, 142, 83)',
42
+ 'rgb(251, 248, 176)',
43
+ 'rgb(137, 207, 165)',
44
+ 'rgb(94, 79, 162)',
45
+ ].reverse()
46
+ if (opts.color)
47
+ this.colors = [
48
+ opts.color(0),
49
+ opts.color(0.2),
50
+ opts.color(0.4),
51
+ opts.color(0.6),
52
+ opts.color(0.8),
53
+ opts.color(1),
54
+ ]
55
+
56
+ /**
57
+ * Define the opacity of the style, within [0,1].
58
+ * If this opacity is defined, the individual color opacity will be ignored.
59
+ * @type {function(number,number):number} */
60
+ this.opacity = opts.opacity // (r,z) => ...
61
+
62
+ /**
63
+ * A function returning the size of the cells, in geographical unit. All cells have the same size.
64
+ * @type {function(number,number):number} */
65
+ this.size = opts.size // (resolution, z) => ...
66
+ }
67
+
68
+ /**
69
+ * @param {Array.<import("../core/Dataset.js").Cell>} cells
70
+ * @param {import("../core/GeoCanvas.js").GeoCanvas} geoCanvas
71
+ * @param {number} resolution
72
+ */
73
+ draw(cells, geoCanvas, resolution) {
74
+ //filter
75
+ if (this.filter) cells = cells.filter(this.filter)
76
+
77
+ //
78
+ const z = geoCanvas.view.z
79
+
80
+ //get view scale
81
+ const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
82
+
83
+ //create canvas and webgl renderer
84
+ //for opacity control, see: https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html
85
+ const cvWGL = makeWebGLCanvas(
86
+ geoCanvas.w + '',
87
+ geoCanvas.h + '',
88
+ this.opacity != undefined ? { premultipliedAlpha: false } : undefined
89
+ )
90
+ if (!cvWGL) {
91
+ console.error('No webGL')
92
+ return
93
+ }
94
+
95
+ //add vertice and fragment data
96
+ const r2 = resolution / 2
97
+ const verticesBuffer = []
98
+ const tBuffer = []
99
+ for (let cell of cells) {
100
+ const t = this.tFun(cell, resolution, z, viewScale)
101
+ if (t == null || t == undefined) continue
102
+ verticesBuffer.push(cell.x + r2, cell.y + r2)
103
+ tBuffer.push(t > 1 ? 1 : t < 0 ? 0 : t)
104
+ }
105
+
106
+ //compute pixel size
107
+ const sizeGeo = this.size ? this.size(resolution, z) : resolution + 0.2 * z
108
+
109
+ //compute opacity
110
+ const op = this.opacity ? this.opacity(resolution, z) : undefined
111
+
112
+ //
113
+ const wgp = new WebGLSquareColoringAdvanced(cvWGL.gl, this.colors, this.stretching, sizeGeo / z, op)
114
+
115
+ //draw
116
+ wgp.draw(verticesBuffer, tBuffer, geoCanvas.getWebGLTransform())
117
+
118
+ // draw in canvas geo
119
+ // NOTE: drawing each tile this way is very inefficient. WebGL is best used with fewer, heavier/larger draw calls.
120
+ geoCanvas.initCanvasTransform()
121
+ geoCanvas.offscreenCtx.drawImage(cvWGL.canvas, 0, 0)
122
+
123
+ //update legends
124
+ this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
125
+ }
126
+ }
@@ -1,135 +1,135 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Style } from '../core/Style.js'
5
-
6
- /**
7
- * @module style
8
- * @author Julien Gaffuri
9
- */
10
- export class StrokeStyle extends Style {
11
- /** @param {object} opts */
12
- constructor(opts) {
13
- super(opts)
14
- opts = opts || {}
15
-
16
- /** A function returning the color of the cell.
17
- * @type {function(import('../core/Dataset.js').Cell,number,number,object):string} */
18
- this.strokeColor = opts.strokeColor || (() => '#666') //(c,r,z,vs) => {}
19
-
20
- /** A function returning the size of a cell in geographical unit.
21
- * @type {function(import('../core/Dataset.js').Cell,number,number,object):number} */
22
- this.size = opts.size || ((cell, resolution) => resolution) //(c,r,z,vs) => {}
23
-
24
- /** The stroke line width in geographical unit.
25
- * @type {function(import('../core/Dataset.js').Cell,number,number,object):number} */
26
- this.strokeWidth = opts.strokeWidth || ((cell, resolution, z) => z * 1.5) //(c,r,z,vs) => {}
27
-
28
- /** A function returning the shape of a cell.
29
- * @type {function(import("../core/Dataset.js").Cell,number,number,object):import("../core/Style.js").Shape} */
30
- this.shape = opts.shape || (() => 'square') //(c,r,z,vs) => {}
31
- }
32
-
33
- /**
34
- * Draw cells as squares, with various colors and size.
35
- *
36
- * @param {Array.<import("../core/Dataset").Cell>} cells
37
- * @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas
38
- * @param {number} resolution
39
- */
40
- draw(cells, geoCanvas, resolution) {
41
- //filter
42
- if (this.filter) cells = cells.filter(this.filter)
43
-
44
- //
45
- const z = geoCanvas.view.z
46
- const ctx = geoCanvas.offscreenCtx
47
-
48
- //get view scale
49
- const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
50
-
51
- const r2 = resolution * 0.5
52
- for (let c of cells) {
53
- //color
54
- const col = this.strokeColor ? this.strokeColor(c, resolution, z, viewScale) : undefined
55
- if (!col || col === 'none') continue
56
- ctx.strokeStyle = col
57
-
58
- //size - in geo unit
59
- const size = this.size ? this.size(c, resolution, z, viewScale) : resolution
60
-
61
- //width
62
- const wi = this.strokeWidth ? this.strokeWidth(c, resolution, z, viewScale) : 1 * z
63
- if (!wi || wi <= 0) continue
64
- ctx.lineWidth = wi
65
-
66
- //shape
67
- const shape = this.shape ? this.shape(c, resolution, z, viewScale) : 'square'
68
- if (shape === 'none') continue
69
-
70
- //get offset
71
- const offset = this.offset(c, resolution, z)
72
-
73
- if (shape === 'square') {
74
- //draw square
75
- const d = resolution * (1 - size / resolution) * 0.5
76
- ctx.beginPath()
77
- ctx.rect(c.x + d + offset.dx, c.y + d + offset.dy, size, size)
78
- ctx.stroke()
79
- } else if (shape === 'circle') {
80
- //draw circle
81
- ctx.beginPath()
82
- ctx.arc(c.x + r2 + offset.dx, c.y + r2 + offset.dy, size * 0.5, 0, 2 * Math.PI, false)
83
- ctx.stroke()
84
- } else if (shape === 'diamond') {
85
- const s2 = size * 0.5
86
- ctx.beginPath()
87
- ctx.moveTo(c.x + r2 - s2, c.y + r2)
88
- ctx.lineTo(c.x + r2, c.y + r2 + s2)
89
- ctx.lineTo(c.x + r2 + s2, c.y + r2)
90
- ctx.lineTo(c.x + r2, c.y + r2 - s2)
91
- ctx.lineTo(c.x + r2 - s2, c.y + r2)
92
- ctx.stroke()
93
- } else if (shape === 'donut') {
94
- console.error('Not implemented')
95
- } else if (shape === 'triangle_up') {
96
- const dr2 = (size - resolution) / 2
97
- ctx.beginPath()
98
- ctx.moveTo(c.x - dr2, c.y - dr2)
99
- ctx.lineTo(c.x + r2, c.y + resolution + dr2)
100
- ctx.lineTo(c.x + resolution + dr2, c.y - dr2)
101
- ctx.closePath()
102
- ctx.stroke()
103
- } else if (shape === 'triangle_down') {
104
- const dr2 = (size - resolution) / 2
105
- ctx.beginPath()
106
- ctx.moveTo(c.x - dr2, c.y + resolution + dr2)
107
- ctx.lineTo(c.x + r2, c.y - dr2)
108
- ctx.lineTo(c.x + resolution + dr2, c.y + resolution + dr2)
109
- ctx.closePath()
110
- ctx.stroke()
111
- } else if (shape === 'triangle_left') {
112
- const dr2 = (size - resolution) / 2
113
- ctx.beginPath()
114
- ctx.moveTo(c.x + resolution + dr2, c.y + resolution + dr2)
115
- ctx.lineTo(c.x - dr2, c.y + r2)
116
- ctx.lineTo(c.x + resolution + dr2, c.y - dr2)
117
- ctx.closePath()
118
- ctx.stroke()
119
- } else if (shape === 'triangle_right') {
120
- const dr2 = (size - resolution) / 2
121
- ctx.beginPath()
122
- ctx.moveTo(c.x - dr2, c.y - dr2)
123
- ctx.lineTo(c.x + resolution + dr2, c.y + r2)
124
- ctx.lineTo(c.x - dr2, c.y + resolution + dr2)
125
- ctx.closePath()
126
- ctx.stroke()
127
- } else {
128
- throw new Error('Unexpected shape:' + shape)
129
- }
130
- }
131
-
132
- //update legends
133
- this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
134
- }
135
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Style } from '../core/Style.js'
5
+
6
+ /**
7
+ * @module style
8
+ * @author Julien Gaffuri
9
+ */
10
+ export class StrokeStyle extends Style {
11
+ /** @param {object} opts */
12
+ constructor(opts) {
13
+ super(opts)
14
+ opts = opts || {}
15
+
16
+ /** A function returning the color of the cell.
17
+ * @type {function(import('../core/Dataset.js').Cell,number,number,object):string} */
18
+ this.strokeColor = opts.strokeColor || (() => '#666') //(c,r,z,vs) => {}
19
+
20
+ /** A function returning the size of a cell in geographical unit.
21
+ * @type {function(import('../core/Dataset.js').Cell,number,number,object):number} */
22
+ this.size = opts.size || ((cell, resolution) => resolution) //(c,r,z,vs) => {}
23
+
24
+ /** The stroke line width in geographical unit.
25
+ * @type {function(import('../core/Dataset.js').Cell,number,number,object):number} */
26
+ this.strokeWidth = opts.strokeWidth || ((cell, resolution, z) => z * 1.5) //(c,r,z,vs) => {}
27
+
28
+ /** A function returning the shape of a cell.
29
+ * @type {function(import("../core/Dataset.js").Cell,number,number,object):import("../core/Style.js").Shape} */
30
+ this.shape = opts.shape || (() => 'square') //(c,r,z,vs) => {}
31
+ }
32
+
33
+ /**
34
+ * Draw cells as squares, with various colors and size.
35
+ *
36
+ * @param {Array.<import("../core/Dataset").Cell>} cells
37
+ * @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas
38
+ * @param {number} resolution
39
+ */
40
+ draw(cells, geoCanvas, resolution) {
41
+ //filter
42
+ if (this.filter) cells = cells.filter(this.filter)
43
+
44
+ //
45
+ const z = geoCanvas.view.z
46
+ const ctx = geoCanvas.offscreenCtx
47
+
48
+ //get view scale
49
+ const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
50
+
51
+ const r2 = resolution * 0.5
52
+ for (let c of cells) {
53
+ //color
54
+ const col = this.strokeColor ? this.strokeColor(c, resolution, z, viewScale) : undefined
55
+ if (!col || col === 'none') continue
56
+ ctx.strokeStyle = col
57
+
58
+ //size - in geo unit
59
+ const size = this.size ? this.size(c, resolution, z, viewScale) : resolution
60
+
61
+ //width
62
+ const wi = this.strokeWidth ? this.strokeWidth(c, resolution, z, viewScale) : 1 * z
63
+ if (!wi || wi <= 0) continue
64
+ ctx.lineWidth = wi
65
+
66
+ //shape
67
+ const shape = this.shape ? this.shape(c, resolution, z, viewScale) : 'square'
68
+ if (shape === 'none') continue
69
+
70
+ //get offset
71
+ const offset = this.offset(c, resolution, z)
72
+
73
+ if (shape === 'square') {
74
+ //draw square
75
+ const d = resolution * (1 - size / resolution) * 0.5
76
+ ctx.beginPath()
77
+ ctx.rect(c.x + d + offset.dx, c.y + d + offset.dy, size, size)
78
+ ctx.stroke()
79
+ } else if (shape === 'circle') {
80
+ //draw circle
81
+ ctx.beginPath()
82
+ ctx.arc(c.x + r2 + offset.dx, c.y + r2 + offset.dy, size * 0.5, 0, 2 * Math.PI, false)
83
+ ctx.stroke()
84
+ } else if (shape === 'diamond') {
85
+ const s2 = size * 0.5
86
+ ctx.beginPath()
87
+ ctx.moveTo(c.x + r2 - s2, c.y + r2)
88
+ ctx.lineTo(c.x + r2, c.y + r2 + s2)
89
+ ctx.lineTo(c.x + r2 + s2, c.y + r2)
90
+ ctx.lineTo(c.x + r2, c.y + r2 - s2)
91
+ ctx.lineTo(c.x + r2 - s2, c.y + r2)
92
+ ctx.stroke()
93
+ } else if (shape === 'donut') {
94
+ console.error('Not implemented')
95
+ } else if (shape === 'triangle_up') {
96
+ const dr2 = (size - resolution) / 2
97
+ ctx.beginPath()
98
+ ctx.moveTo(c.x - dr2, c.y - dr2)
99
+ ctx.lineTo(c.x + r2, c.y + resolution + dr2)
100
+ ctx.lineTo(c.x + resolution + dr2, c.y - dr2)
101
+ ctx.closePath()
102
+ ctx.stroke()
103
+ } else if (shape === 'triangle_down') {
104
+ const dr2 = (size - resolution) / 2
105
+ ctx.beginPath()
106
+ ctx.moveTo(c.x - dr2, c.y + resolution + dr2)
107
+ ctx.lineTo(c.x + r2, c.y - dr2)
108
+ ctx.lineTo(c.x + resolution + dr2, c.y + resolution + dr2)
109
+ ctx.closePath()
110
+ ctx.stroke()
111
+ } else if (shape === 'triangle_left') {
112
+ const dr2 = (size - resolution) / 2
113
+ ctx.beginPath()
114
+ ctx.moveTo(c.x + resolution + dr2, c.y + resolution + dr2)
115
+ ctx.lineTo(c.x - dr2, c.y + r2)
116
+ ctx.lineTo(c.x + resolution + dr2, c.y - dr2)
117
+ ctx.closePath()
118
+ ctx.stroke()
119
+ } else if (shape === 'triangle_right') {
120
+ const dr2 = (size - resolution) / 2
121
+ ctx.beginPath()
122
+ ctx.moveTo(c.x - dr2, c.y - dr2)
123
+ ctx.lineTo(c.x + resolution + dr2, c.y + r2)
124
+ ctx.lineTo(c.x - dr2, c.y + resolution + dr2)
125
+ ctx.closePath()
126
+ ctx.stroke()
127
+ } else {
128
+ throw new Error('Unexpected shape:' + shape)
129
+ }
130
+ }
131
+
132
+ //update legends
133
+ this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
134
+ }
135
+ }