gridviz 2.1.16 → 3.0.0

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 +2 -3
  2. package/dist/gridviz.js +4971 -5654
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +3 -2
  5. package/src/button/Button.js +14 -15
  6. package/src/button/FullscreenButton.js +14 -14
  7. package/src/button/ZoomButtons.js +2 -2
  8. package/src/{DatasetComponent.js → core/Dataset.js} +33 -12
  9. package/src/core/Drawable.js +60 -0
  10. package/src/{GeoCanvas.js → core/GeoCanvas.js} +65 -155
  11. package/src/core/Layer.js +24 -0
  12. package/src/{Legend.js → core/Legend.js} +24 -1
  13. package/src/core/Map.js +460 -0
  14. package/src/core/MultiResolutionDataset.js +96 -0
  15. package/src/core/Style.js +84 -0
  16. package/src/dataset/COGeo.js +5 -5
  17. package/src/dataset/CSVGrid.js +43 -41
  18. package/src/dataset/GeoTIFF.js +9 -14
  19. package/src/dataset/{LGrid.js → JSGrid.js} +9 -10
  20. package/src/dataset/TiledGrid.js +68 -45
  21. package/src/index.js +22 -29
  22. package/src/{BackgroundLayer.js → layer/BackgroundLayer.js} +27 -52
  23. package/src/{BackgroundLayerWMS.js → layer/BackgroundLayerWMS.js} +21 -45
  24. package/src/{LineLayer.js → layer/GeoJSONLayer.js} +22 -23
  25. package/src/layer/GridLayer.js +140 -0
  26. package/src/{LabelLayer.js → layer/LabelLayer.js} +25 -23
  27. package/src/legend/ColorCategoryLegend.js +9 -24
  28. package/src/legend/ColorDiscreteLegend.js +20 -24
  29. package/src/legend/ColorLegend.js +21 -33
  30. package/src/legend/OrientationLegend.js +90 -0
  31. package/src/legend/SizeLegend.js +153 -72
  32. package/src/style/CompositionStyle.js +71 -84
  33. package/src/style/ContourStyle.js +2 -36
  34. package/src/style/DotDensityStyle.js +50 -73
  35. package/src/style/IsoFenceStyle.js +59 -70
  36. package/src/style/JoyPlotStyle.js +41 -48
  37. package/src/style/LegoStyle.js +4 -4
  38. package/src/style/MosaicStyle.js +30 -39
  39. package/src/style/NinjaStarStyle.js +45 -68
  40. package/src/style/PillarStyle.js +70 -93
  41. package/src/style/SegmentStyle.js +37 -75
  42. package/src/style/ShapeColorSizeStyle.js +49 -98
  43. package/src/style/SideCategoryStyle.js +112 -0
  44. package/src/style/SideStyle.js +99 -133
  45. package/src/style/{SquareColorCatWGLStyle.js → SquareColorCategoryWebGLStyle.js} +28 -41
  46. package/src/style/{SquareColorWGLStyle.js → SquareColorWebGLStyle.js} +28 -49
  47. package/src/style/StrokeStyle.js +43 -70
  48. package/src/style/TanakaStyle.js +34 -132
  49. package/src/style/TextStyle.js +43 -64
  50. package/src/style/TimeSeriesStyle.js +44 -75
  51. package/src/utils/WebGLSquareColoringAdvanced.js +4 -4
  52. package/src/utils/scale.js +202 -0
  53. package/src/utils/stretching.js +86 -129
  54. package/src/utils/{Utils.js → utils.js} +15 -0
  55. package/src/utils/webGLUtils.js +4 -5
  56. package/src/utils/zoomUtils.js +30 -30
  57. package/src/App.js +0 -760
  58. package/src/Dataset.js +0 -76
  59. package/src/Layer.js +0 -103
  60. package/src/Style.js +0 -131
  61. package/src/dataset/GridTile.js +0 -41
  62. package/src/legend/SegmentOrientationLegend.js +0 -87
  63. package/src/legend/SegmentWidthLegend.js +0 -101
  64. package/src/style/CompositionStyle_.js +0 -293
  65. package/src/style/ShapeColorSizeStyle_.js +0 -108
  66. package/src/style/SideCatStyle.js +0 -172
  67. /package/src/{Tooltip.js → core/Tooltip.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  //@ts-check
2
2
  'use strict'
3
3
 
4
- import { Style } from '../Style.js'
4
+ import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
7
  * @author Julien Gaffuri
@@ -12,13 +12,9 @@ export class MosaicStyle extends Style {
12
12
  super(opts)
13
13
  opts = opts || {}
14
14
 
15
- /** The name of the column/attribute of the tabular data where to retrieve the variable for color.
16
- * @type {string} */
17
- this.colorCol = opts.colorCol
18
-
19
15
  /** A function returning the color of the cell.
20
- * @type {function(number,number,import("../Style").Stat|undefined):string} */
21
- this.color = opts.color || (() => '#EA6BAC')
16
+ * @type {function(import('../core/Dataset.js').Cell, number, number, object):string} */
17
+ this.color = opts.color || (() => "#EA6BAC") //(c,r,z,vs) => {}
22
18
 
23
19
  /** The mosaic factor, within [0,0.5]. Set to 0 for no mosaic effect. Set to 0.5 for strong mosaic effect.
24
20
  * @type {number} */
@@ -35,28 +31,26 @@ export class MosaicStyle extends Style {
35
31
 
36
32
  /**
37
33
  *
38
- * @param {Array.<import("../Dataset").Cell>} cells
34
+ * @param {Array.<import("../core/Dataset").Cell>} cells
35
+ * @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas
39
36
  * @param {number} resolution
40
- * @param {import("../GeoCanvas").GeoCanvas} cg
41
37
  */
42
- draw(cells, resolution, cg) {
38
+ draw(cells, geoCanvas, resolution) {
39
+
43
40
  //filter
44
41
  if (this.filter) cells = cells.filter(this.filter)
45
42
 
46
- //zoom factor
47
- const zf = cg.getZf()
43
+ //
44
+ const z = geoCanvas.view.z
48
45
 
49
- let statColor
50
- if (this.colorCol) {
51
- //compute color variable statistics
52
- statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
53
- }
46
+ //get view scale
47
+ const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
54
48
 
55
49
  //set stroke style, for shadow
56
- cg.ctx.strokeStyle = this.shadowColor
57
- cg.ctx.lineWidth = this.shadowFactor * resolution
58
- cg.ctx.lineJoin = 'round'
59
- cg.ctx.lineCap = 'butt'
50
+ geoCanvas.ctx.strokeStyle = this.shadowColor
51
+ geoCanvas.ctx.lineWidth = this.shadowFactor * resolution
52
+ geoCanvas.ctx.lineJoin = 'round'
53
+ geoCanvas.ctx.lineCap = 'butt'
60
54
 
61
55
  //function to compute position mosaic effect
62
56
  const d = resolution * this.mosaicFactor
@@ -64,17 +58,14 @@ export class MosaicStyle extends Style {
64
58
  return { x: Math.random() * d, y: Math.random() * d }
65
59
  }
66
60
 
67
- //draw with HTML canvas in geo coordinates
68
- cg.setCanvasTransform()
69
-
70
61
  for (let cell of cells) {
71
62
  //set fill color
72
- const col = this.color ? this.color(cell[this.colorCol], resolution, statColor) : undefined
63
+ const col = this.color ? this.color(cell, resolution, z, viewScale) : undefined
73
64
  if (!col || col === 'none') continue
74
- cg.ctx.fillStyle = col
65
+ geoCanvas.ctx.fillStyle = col
75
66
 
76
67
  //get offset
77
- const offset = this.offset(cell, resolution, zf)
68
+ const offset = this.offset(cell, resolution, z)
78
69
 
79
70
  //compute position mosaic effect
80
71
  const ll = mosaic(),
@@ -84,24 +75,24 @@ export class MosaicStyle extends Style {
84
75
 
85
76
  //stroke
86
77
  if (this.shadowFactor > 0) {
87
- cg.ctx.beginPath()
88
- cg.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
89
- cg.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
90
- cg.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
91
- cg.ctx.stroke()
78
+ geoCanvas.ctx.beginPath()
79
+ geoCanvas.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
80
+ geoCanvas.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
81
+ geoCanvas.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
82
+ geoCanvas.ctx.stroke()
92
83
  }
93
84
 
94
85
  //fill
95
86
 
96
- cg.ctx.beginPath()
97
- cg.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
98
- cg.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
99
- cg.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
100
- cg.ctx.lineTo(cell.x + offset.dx + ul.x, cell.y + offset.dy + resolution - ul.y)
101
- cg.ctx.fill()
87
+ geoCanvas.ctx.beginPath()
88
+ geoCanvas.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
89
+ geoCanvas.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
90
+ geoCanvas.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
91
+ geoCanvas.ctx.lineTo(cell.x + offset.dx + ul.x, cell.y + offset.dy + resolution - ul.y)
92
+ geoCanvas.ctx.fill()
102
93
  }
103
94
 
104
95
  //update legends
105
- this.updateLegends({ style: this, r: resolution, zf: zf, sColor: statColor })
96
+ this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
106
97
  }
107
98
  }
@@ -1,7 +1,7 @@
1
1
  //@ts-check
2
2
  'use strict'
3
3
 
4
- import { Style } from '../Style.js'
4
+ import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
7
  *
@@ -13,113 +13,90 @@ export class NinjaStarStyle extends Style {
13
13
  super(opts)
14
14
  opts = opts || {}
15
15
 
16
- /** The name of the column/attribute of the tabular data where to retrieve the variable for color.
17
- * @type {string} */
18
- this.colorCol = opts.colorCol
19
-
20
16
  /** A function returning the color of the cell.
21
- * @type {function(number,number,import("../Style").Stat|undefined,number):string} */
22
- this.color = opts.color || (() => '#EA6BAC') //(v,r,s,zf) => {}
23
-
24
- /** The name of the column/attribute of the tabular data where to retrieve the variable for size.
25
- * @type {string} */
26
- this.sizeCol = opts.sizeCol
17
+ * @type {function(import('../core/Dataset.js').Cell, number, number, object):string} */
18
+ this.color = opts.color || (() => "#EA6BAC") //(c,r,z,vs) => {}
27
19
 
28
20
  /** A function returning the size of a cell, within [0,1]:
29
21
  * - 0, nothing shown
30
22
  * - 1, entire square
31
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
32
- this.size = opts.size
23
+ * @type {function(import('../core/Dataset.js').Cell, number, number, object):number} */
24
+ this.size = opts.size || ((cell, resolution) => resolution) //(c,r,z,vs) => {}
33
25
 
34
26
  /** A function returning the shape.
35
- * @type {function(import("../Dataset").Cell):string} */
27
+ * @type {function(import("../core/Dataset").Cell):string} */
36
28
  this.shape = opts.shape || (() => 'o')
37
29
  }
38
30
 
39
31
  /**
40
32
  *
41
- * @param {Array.<import("../Dataset").Cell>} cells
42
- * @param {number} r
43
- * @param {import("../GeoCanvas").GeoCanvas} cg
33
+ * @param {Array.<import('../core/Dataset.js').Cell>} cells
34
+ * @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas
35
+ * @param {number} resolution
44
36
  */
45
- draw(cells, r, cg) {
37
+ draw(cells, geoCanvas, resolution) {
38
+
46
39
  //filter
47
40
  if (this.filter) cells = cells.filter(this.filter)
48
41
 
49
- //zoom factor
50
- const zf = cg.getZf()
42
+ //
43
+ const z = geoCanvas.view.z
51
44
 
52
- let statSize
53
- if (this.sizeCol) {
54
- //if size is used, sort cells by size so that the biggest are drawn first
55
- cells.sort((c1, c2) => c2[this.sizeCol] - c1[this.sizeCol])
56
- //and compute size variable statistics
57
- statSize = Style.getStatistics(cells, (c) => c[this.sizeCol], true)
58
- }
59
-
60
- let statColor
61
- if (this.colorCol) {
62
- //compute color variable statistics
63
- statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
64
- }
45
+ //get view scale
46
+ const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
65
47
 
66
- //draw with HTML canvas
67
- //in geo coordinates
68
- cg.setCanvasTransform()
69
-
70
- const r2 = r * 0.5
48
+ const r2 = resolution * 0.5
71
49
  for (let cell of cells) {
72
50
  //color
73
- const col = this.color ? this.color(cell[this.colorCol], r, statColor, zf) : undefined
51
+ const col = this.color ? this.color(cell, resolution, z, viewScale) : undefined
74
52
  if (!col || col === 'none') continue
75
- cg.ctx.fillStyle = col
53
+ geoCanvas.ctx.fillStyle = col
54
+
55
+ //size - in geo unit
56
+ let k = this.size(cell, resolution, z, viewScale)
57
+ k = k < 0 ? 0 : k > 1 ? 1 : k
58
+ const sG2 = k * r2
76
59
 
77
60
  //shape
78
61
  const shape = this.shape ? this.shape(cell) : 'o'
79
62
  if (shape === 'none') continue
80
63
 
81
- //size
82
- /** @type {function(number,number,import("../Style").Stat|undefined,number):number} */
83
- let s_ = this.size || (() => 0.5)
84
- //size - in geo unit
85
- const sG2 = s_(cell[this.sizeCol], r, statSize, zf) * r2
86
-
87
64
  //get offset
88
65
  //TODO use
89
- //const offset = this.offset(cell, r, zf)
66
+ //const offset = this.offset(cell, r, z)
90
67
 
91
68
  //center position
92
69
  const cx = cell.x + r2
93
70
  const cy = cell.y + r2
94
71
 
95
72
  if (shape === 'p') {
96
- cg.ctx.beginPath()
97
- cg.ctx.moveTo(cx, cy + r2)
98
- cg.ctx.lineTo(cx + sG2, cy + sG2)
99
- cg.ctx.lineTo(cx + r2, cy)
100
- cg.ctx.lineTo(cx + sG2, cy - sG2)
101
- cg.ctx.lineTo(cx, cy - r2)
102
- cg.ctx.lineTo(cx - sG2, cy - sG2)
103
- cg.ctx.lineTo(cx - r2, cy)
104
- cg.ctx.lineTo(cx - sG2, cy + sG2)
105
- cg.ctx.fill()
73
+ geoCanvas.ctx.beginPath()
74
+ geoCanvas.ctx.moveTo(cx, cy + r2)
75
+ geoCanvas.ctx.lineTo(cx + sG2, cy + sG2)
76
+ geoCanvas.ctx.lineTo(cx + r2, cy)
77
+ geoCanvas.ctx.lineTo(cx + sG2, cy - sG2)
78
+ geoCanvas.ctx.lineTo(cx, cy - r2)
79
+ geoCanvas.ctx.lineTo(cx - sG2, cy - sG2)
80
+ geoCanvas.ctx.lineTo(cx - r2, cy)
81
+ geoCanvas.ctx.lineTo(cx - sG2, cy + sG2)
82
+ geoCanvas.ctx.fill()
106
83
  } else if (shape === 'o') {
107
- cg.ctx.beginPath()
108
- cg.ctx.moveTo(cx, cy + sG2)
109
- cg.ctx.lineTo(cx + r2, cy + r2)
110
- cg.ctx.lineTo(cx + sG2, cy)
111
- cg.ctx.lineTo(cx + r2, cy - r2)
112
- cg.ctx.lineTo(cx, cy - sG2)
113
- cg.ctx.lineTo(cx - r2, cy - r2)
114
- cg.ctx.lineTo(cx - sG2, cy)
115
- cg.ctx.lineTo(cx - r2, cy + r2)
116
- cg.ctx.fill()
84
+ geoCanvas.ctx.beginPath()
85
+ geoCanvas.ctx.moveTo(cx, cy + sG2)
86
+ geoCanvas.ctx.lineTo(cx + r2, cy + r2)
87
+ geoCanvas.ctx.lineTo(cx + sG2, cy)
88
+ geoCanvas.ctx.lineTo(cx + r2, cy - r2)
89
+ geoCanvas.ctx.lineTo(cx, cy - sG2)
90
+ geoCanvas.ctx.lineTo(cx - r2, cy - r2)
91
+ geoCanvas.ctx.lineTo(cx - sG2, cy)
92
+ geoCanvas.ctx.lineTo(cx - r2, cy + r2)
93
+ geoCanvas.ctx.fill()
117
94
  } else {
118
95
  throw new Error('Unexpected shape:' + shape)
119
96
  }
120
97
  }
121
98
 
122
99
  //update legends
123
- this.updateLegends({ style: this, r: r, zf: zf, sSize: statSize, sColor: statColor })
100
+ this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
124
101
  }
125
102
  }
@@ -1,42 +1,33 @@
1
1
  //@ts-check
2
2
  'use strict'
3
3
 
4
- import { Style } from '../Style.js'
4
+ import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
7
  * @author Julien Gaffuri
8
8
  */
9
9
  export class PillarStyle extends Style {
10
- //TODO make a webGL version ?
11
10
 
12
11
  /** @param {object} opts */
13
12
  constructor(opts) {
14
13
  super(opts)
15
14
  opts = opts || {}
16
15
 
17
- /** @type {string} */
18
- this.heightCol = opts.heightCol
19
-
20
16
  /** A function returning the height of the line representing a cell, in geo unit
21
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
17
+ * @type {function(import('../core/Dataset.js').Cell, number, number, object):number} */
22
18
  this.height = opts.height
23
19
 
24
- /** @type {string} */
25
- this.colorCol = opts.colorCol
26
-
27
20
  /** A function returning the color of the line representing a cell.
28
- * @type {function(number,number,import("../Style").Stat|undefined):string} */
29
- this.color = opts.color || (() => '#c08c59') //bb
30
-
31
- /** @type {string} */
32
- this.widthCol = opts.widthCol
21
+ * @type {function(import('../core/Dataset.js').Cell, number, number, object):string} */
22
+ this.color = opts.color || (() => "#c08c59") //(c,r,z,vs) => {}
33
23
 
34
24
  /** A function returning the width of the line representing a cell, in geo unit
35
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
36
- this.width = opts.width || ((v, r) => 0.5 * r)
25
+ * @type {function(import('../core/Dataset.js').Cell, number, number, object):number} */
26
+ this.width = opts.width || ((cell, resolution) => 0.5 * resolution)
37
27
 
38
- /** @type {boolean} */
39
- this.simple = opts.simple == true
28
+ /** A function returning the width of the line representing a cell, in geo unit
29
+ * @type {function(number, number,object):boolean} */
30
+ this.simple = opts.simple || (() => false)
40
31
 
41
32
  /** @type {number} */
42
33
  this.viewHeightFactor = opts.viewHeightFactor || 1.5
@@ -64,81 +55,67 @@ export class PillarStyle extends Style {
64
55
  /**
65
56
  * Draw cells as segments.
66
57
  *
67
- * @param {Array.<import("../Dataset").Cell>} cells
68
- * @param {number} r
69
- * @param {import("../GeoCanvas").GeoCanvas} cg
58
+ * @param {Array.<import("../core/Dataset").Cell>} cells
59
+ * @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas
60
+ * @param {number} resolution
70
61
  */
71
- draw(cells, r, cg) {
62
+ draw(cells, geoCanvas, resolution) {
63
+
72
64
  //filter
73
65
  if (this.filter) cells = cells.filter(this.filter)
74
66
 
75
- //zoom factor
76
- const zf = cg.getZf()
77
-
78
- let statHeight
79
- if (this.heightCol) {
80
- //compute size variable statistics
81
- statHeight = Style.getStatistics(cells, (c) => c[this.heightCol], true)
82
- }
67
+ //
68
+ const z = geoCanvas.view.z
83
69
 
84
- let statColor
85
- if (this.colorCol) {
86
- //compute color variable statistics
87
- statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
88
- }
89
-
90
- let statWidth
91
- if (this.widthCol) {
92
- //and compute size variable statistics
93
- statWidth = Style.getStatistics(cells, (c) => c[this.widthCol], true)
94
- }
70
+ //get view scale
71
+ const viewScale = this.viewScale ? this.viewScale(cells, resolution, z) : undefined
95
72
 
96
73
  //get view center geo position
97
- const cvx = cg.getCenter().x + this.viewSX * cg.w * zf
98
- const cvy = cg.getCenter().y + this.viewSY * cg.h * zf
74
+ const cvx = geoCanvas.view.x + this.viewSX * geoCanvas.w * z
75
+ const cvy = geoCanvas.view.y + this.viewSY * geoCanvas.h * z
99
76
  //get view height
100
- const H = this.viewHeightFactor * (cg.w + cg.h) * 0.5 * zf
77
+ const H = this.viewHeightFactor * (geoCanvas.w + geoCanvas.h) * 0.5 * z
101
78
 
102
79
  //sort cells by y and x
103
80
  //const distToViewCenter = (c) => { const dx = cvx - c.x, dy = cvy - c.y; return Math.sqrt(dx * dx + dy * dy) }
104
81
  cells.sort((c1, c2) => 100000000 * (c2.y - c1.y) + c1.x - c2.x)
105
82
 
106
- cg.ctx.lineCap = this.simple ? 'butt' : 'round'
83
+ //get simple information
84
+ const simple = this.simple(resolution, z, viewScale)
107
85
 
108
- //draw in geo coordinates
109
- cg.setCanvasTransform()
86
+ geoCanvas.ctx.lineCap = simple ? 'butt' : 'round'
110
87
 
111
88
  //draw shadows
112
- cg.ctx.strokeStyle = this.shadowColor
113
- cg.ctx.fillStyle = this.shadowColor
114
- for (let c of cells) {
89
+ geoCanvas.ctx.strokeStyle = this.shadowColor
90
+ geoCanvas.ctx.fillStyle = this.shadowColor
91
+ for (let cell of cells) {
115
92
  //width
116
93
  /** @type {number|undefined} */
117
- const wG = this.width ? this.width(c[this.widthCol], r, statWidth, zf) : undefined
94
+ const wG = this.width ? this.width(cell, resolution, z, viewScale) : undefined
118
95
  if (!wG || wG < 0) continue
119
96
 
120
97
  //height
121
98
  /** @type {number|undefined} */
122
- const hG = this.height ? this.height(c[this.heightCol], r, statHeight, zf) : undefined
99
+ const hG = this.height ? this.height(cell, resolution, z, viewScale) : undefined
123
100
  if (!hG || hG < 0) continue
124
101
 
125
102
  //get offset
126
103
  //TODO use that
127
- const offset = this.offset(c, r, zf)
104
+ //const offset = this.offset(c, resolution, z)
128
105
 
129
106
  //set width
130
- cg.ctx.lineWidth = wG
107
+ geoCanvas.ctx.lineWidth = wG
131
108
 
132
109
  //compute cell centre postition
133
- const cx = c.x + r / 2
134
- const cy = c.y + r / 2
110
+ const cx = cell.x + resolution / 2
111
+ const cy = cell.y + resolution / 2
135
112
  const ls = hG * this.shadowFactor
136
113
 
137
114
  //draw segment
138
- cg.ctx.beginPath()
139
- cg.ctx.moveTo(cx, cy)
140
- cg.ctx.lineTo(cx + ls * Math.cos(this.shadowDirection), cy + ls * Math.sin(this.shadowDirection))
141
- cg.ctx.stroke()
115
+ geoCanvas.ctx.beginPath()
116
+ geoCanvas.ctx.moveTo(cx, cy)
117
+ geoCanvas.ctx.lineTo(cx + ls * Math.cos(this.shadowDirection), cy + ls * Math.sin(this.shadowDirection))
118
+ geoCanvas.ctx.stroke()
142
119
 
143
120
  /*
144
121
  if (this.simple) {
@@ -154,29 +131,29 @@ export class PillarStyle extends Style {
154
131
  }
155
132
 
156
133
  //draw pillars
157
- for (let c of cells) {
134
+ for (let cell of cells) {
158
135
  //color
159
136
  /** @type {string|undefined} */
160
- const col = this.color ? this.color(c[this.colorCol], r, statColor) : undefined
137
+ const col = this.color ? this.color(cell, resolution, z, viewScale) : undefined
161
138
  if (!col) continue
162
139
 
163
140
  //width
164
141
  /** @type {number|undefined} */
165
- const wG = this.width ? this.width(c[this.widthCol], r, statWidth, zf) : undefined
142
+ const wG = this.width ? this.width(cell, resolution, z, viewScale) : undefined
166
143
  if (!wG || wG < 0) continue
167
144
 
168
145
  //height
169
146
  /** @type {number|undefined} */
170
- const hG = this.height ? this.height(c[this.heightCol], r, statHeight, zf) : undefined
147
+ const hG = this.height ? this.height(cell, resolution, z, viewScale) : undefined
171
148
  if (!hG || hG < 0) continue
172
149
 
173
150
  //get offset
174
151
  //TODO use that
175
- const offset = this.offset(c, r, zf)
152
+ //const offset = this.offset(c, resolution, z)
176
153
 
177
154
  //compute cell centre postition
178
- const cx = c.x + r / 2
179
- const cy = c.y + r / 2
155
+ const cx = cell.x + resolution / 2
156
+ const cy = cell.y + resolution / 2
180
157
 
181
158
  //compute angle
182
159
  const dx = cx - cvx,
@@ -185,46 +162,46 @@ export class PillarStyle extends Style {
185
162
  const D = Math.sqrt(dx * dx + dy * dy)
186
163
  const d = (D * hG) / (H - hG)
187
164
 
188
- if (this.simple) {
165
+ if (simple) {
189
166
  //draw segment
190
- cg.ctx.strokeStyle = col
191
- cg.ctx.lineWidth = wG
192
- cg.ctx.beginPath()
193
- cg.ctx.moveTo(cx, cy)
194
- cg.ctx.lineTo(cx + d * Math.cos(a), cy + d * Math.sin(a))
195
- cg.ctx.stroke()
167
+ geoCanvas.ctx.strokeStyle = col
168
+ geoCanvas.ctx.lineWidth = wG
169
+ geoCanvas.ctx.beginPath()
170
+ geoCanvas.ctx.moveTo(cx, cy)
171
+ geoCanvas.ctx.lineTo(cx + d * Math.cos(a), cy + d * Math.sin(a))
172
+ geoCanvas.ctx.stroke()
196
173
  } else {
197
174
  //draw background segment
198
- cg.ctx.strokeStyle = this.outlineCol
199
- cg.ctx.lineWidth = wG + 2 * this.outlineWidthPix * zf
200
- cg.ctx.beginPath()
201
- cg.ctx.moveTo(cx, cy)
202
- cg.ctx.lineTo(cx + d * Math.cos(a), cy + d * Math.sin(a))
203
- cg.ctx.stroke()
175
+ geoCanvas.ctx.strokeStyle = this.outlineCol
176
+ geoCanvas.ctx.lineWidth = wG + 2 * this.outlineWidthPix * z
177
+ geoCanvas.ctx.beginPath()
178
+ geoCanvas.ctx.moveTo(cx, cy)
179
+ geoCanvas.ctx.lineTo(cx + d * Math.cos(a), cy + d * Math.sin(a))
180
+ geoCanvas.ctx.stroke()
204
181
 
205
182
  //draw segment
206
- cg.ctx.strokeStyle = col
207
- cg.ctx.lineWidth = wG
208
- cg.ctx.beginPath()
209
- cg.ctx.moveTo(cx, cy)
210
- cg.ctx.lineTo(cx + d * Math.cos(a), cy + d * Math.sin(a))
211
- cg.ctx.stroke()
183
+ geoCanvas.ctx.strokeStyle = col
184
+ geoCanvas.ctx.lineWidth = wG
185
+ geoCanvas.ctx.beginPath()
186
+ geoCanvas.ctx.moveTo(cx, cy)
187
+ geoCanvas.ctx.lineTo(cx + d * Math.cos(a), cy + d * Math.sin(a))
188
+ geoCanvas.ctx.stroke()
212
189
 
213
190
  //draw top circle
214
- cg.ctx.strokeStyle = this.outlineCol
191
+ geoCanvas.ctx.strokeStyle = this.outlineCol
215
192
  //cg.ctx.fillStyle = "#c08c59"
216
- cg.ctx.lineWidth = this.outlineWidthPix * zf
217
- cg.ctx.beginPath()
218
- cg.ctx.arc(cx + d * Math.cos(a), cy + d * Math.sin(a), wG * 0.5, 0, 2 * Math.PI, false)
219
- cg.ctx.stroke()
193
+ geoCanvas.ctx.lineWidth = this.outlineWidthPix * z
194
+ geoCanvas.ctx.beginPath()
195
+ geoCanvas.ctx.arc(cx + d * Math.cos(a), cy + d * Math.sin(a), wG * 0.5, 0, 2 * Math.PI, false)
196
+ geoCanvas.ctx.stroke()
220
197
  //cg.ctx.fill();
221
198
  }
222
199
  }
223
200
 
224
201
  //in case...
225
- cg.ctx.lineCap = 'butt'
202
+ geoCanvas.ctx.lineCap = 'butt'
226
203
 
227
204
  //update legends
228
- this.updateLegends({ style: this, r: r, zf: zf, sColor: statColor })
205
+ this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
229
206
  }
230
207
  }