gridviz 2.1.17 → 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.
- package/README.md +2 -3
- package/dist/gridviz.js +4971 -5654
- package/dist/gridviz.min.js +1 -1
- package/package.json +3 -2
- package/src/button/Button.js +14 -15
- package/src/button/FullscreenButton.js +14 -14
- package/src/button/ZoomButtons.js +2 -2
- package/src/{DatasetComponent.js → core/Dataset.js} +33 -12
- package/src/core/Drawable.js +60 -0
- package/src/{GeoCanvas.js → core/GeoCanvas.js} +65 -155
- package/src/core/Layer.js +24 -0
- package/src/{Legend.js → core/Legend.js} +24 -1
- package/src/core/Map.js +460 -0
- package/src/core/MultiResolutionDataset.js +96 -0
- package/src/core/Style.js +84 -0
- package/src/dataset/COGeo.js +5 -5
- package/src/dataset/CSVGrid.js +43 -41
- package/src/dataset/GeoTIFF.js +9 -14
- package/src/dataset/{LGrid.js → JSGrid.js} +9 -10
- package/src/dataset/TiledGrid.js +68 -45
- package/src/index.js +22 -29
- package/src/{BackgroundLayer.js → layer/BackgroundLayer.js} +27 -52
- package/src/{BackgroundLayerWMS.js → layer/BackgroundLayerWMS.js} +21 -45
- package/src/{LineLayer.js → layer/GeoJSONLayer.js} +22 -23
- package/src/layer/GridLayer.js +140 -0
- package/src/{LabelLayer.js → layer/LabelLayer.js} +25 -23
- package/src/legend/ColorCategoryLegend.js +9 -24
- package/src/legend/ColorDiscreteLegend.js +20 -24
- package/src/legend/ColorLegend.js +21 -33
- package/src/legend/OrientationLegend.js +90 -0
- package/src/legend/SizeLegend.js +153 -72
- package/src/style/CompositionStyle.js +71 -84
- package/src/style/ContourStyle.js +2 -36
- package/src/style/DotDensityStyle.js +50 -73
- package/src/style/IsoFenceStyle.js +59 -70
- package/src/style/JoyPlotStyle.js +41 -48
- package/src/style/LegoStyle.js +4 -4
- package/src/style/MosaicStyle.js +30 -39
- package/src/style/NinjaStarStyle.js +45 -68
- package/src/style/PillarStyle.js +70 -93
- package/src/style/SegmentStyle.js +37 -75
- package/src/style/ShapeColorSizeStyle.js +49 -98
- package/src/style/SideCategoryStyle.js +112 -0
- package/src/style/SideStyle.js +99 -133
- package/src/style/{SquareColorCatWGLStyle.js → SquareColorCategoryWebGLStyle.js} +28 -41
- package/src/style/{SquareColorWGLStyle.js → SquareColorWebGLStyle.js} +28 -49
- package/src/style/StrokeStyle.js +43 -70
- package/src/style/TanakaStyle.js +34 -132
- package/src/style/TextStyle.js +43 -64
- package/src/style/TimeSeriesStyle.js +44 -75
- package/src/utils/WebGLSquareColoringAdvanced.js +4 -4
- package/src/utils/scale.js +202 -0
- package/src/utils/stretching.js +86 -129
- package/src/utils/{Utils.js → utils.js} +15 -0
- package/src/utils/webGLUtils.js +4 -5
- package/src/utils/zoomUtils.js +30 -30
- package/src/App.js +0 -760
- package/src/Dataset.js +0 -76
- package/src/Layer.js +0 -103
- package/src/Style.js +0 -131
- package/src/dataset/GridTile.js +0 -41
- package/src/legend/SegmentOrientationLegend.js +0 -87
- package/src/legend/SegmentWidthLegend.js +0 -101
- package/src/style/CompositionStyle_.js +0 -293
- package/src/style/ShapeColorSizeStyle_.js +0 -108
- package/src/style/SideCatStyle.js +0 -172
- /package/src/{Tooltip.js → core/Tooltip.js} +0 -0
package/src/style/MosaicStyle.js
CHANGED
|
@@ -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(
|
|
21
|
-
this.color = opts.color || (() =>
|
|
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,
|
|
38
|
+
draw(cells, geoCanvas, resolution) {
|
|
39
|
+
|
|
43
40
|
//filter
|
|
44
41
|
if (this.filter) cells = cells.filter(this.filter)
|
|
45
42
|
|
|
46
|
-
//
|
|
47
|
-
const
|
|
43
|
+
//
|
|
44
|
+
const z = geoCanvas.view.z
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
63
|
+
const col = this.color ? this.color(cell, resolution, z, viewScale) : undefined
|
|
73
64
|
if (!col || col === 'none') continue
|
|
74
|
-
|
|
65
|
+
geoCanvas.ctx.fillStyle = col
|
|
75
66
|
|
|
76
67
|
//get offset
|
|
77
|
-
const offset = this.offset(cell, resolution,
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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,
|
|
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(
|
|
22
|
-
this.color = opts.color || (() =>
|
|
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
|
-
|
|
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(
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
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,
|
|
37
|
+
draw(cells, geoCanvas, resolution) {
|
|
38
|
+
|
|
46
39
|
//filter
|
|
47
40
|
if (this.filter) cells = cells.filter(this.filter)
|
|
48
41
|
|
|
49
|
-
//
|
|
50
|
-
const
|
|
42
|
+
//
|
|
43
|
+
const z = geoCanvas.view.z
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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
|
|
51
|
+
const col = this.color ? this.color(cell, resolution, z, viewScale) : undefined
|
|
74
52
|
if (!col || col === 'none') continue
|
|
75
|
-
|
|
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,
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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,
|
|
100
|
+
this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
|
|
124
101
|
}
|
|
125
102
|
}
|
package/src/style/PillarStyle.js
CHANGED
|
@@ -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(
|
|
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(
|
|
29
|
-
this.color = opts.color || (() =>
|
|
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(
|
|
36
|
-
this.width = opts.width || ((
|
|
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
|
-
/**
|
|
39
|
-
|
|
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 {
|
|
69
|
-
* @param {
|
|
58
|
+
* @param {Array.<import("../core/Dataset").Cell>} cells
|
|
59
|
+
* @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas
|
|
60
|
+
* @param {number} resolution
|
|
70
61
|
*/
|
|
71
|
-
draw(cells,
|
|
62
|
+
draw(cells, geoCanvas, resolution) {
|
|
63
|
+
|
|
72
64
|
//filter
|
|
73
65
|
if (this.filter) cells = cells.filter(this.filter)
|
|
74
66
|
|
|
75
|
-
//
|
|
76
|
-
const
|
|
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
|
-
|
|
85
|
-
|
|
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 =
|
|
98
|
-
const cvy =
|
|
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 * (
|
|
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
|
-
|
|
83
|
+
//get simple information
|
|
84
|
+
const simple = this.simple(resolution, z, viewScale)
|
|
107
85
|
|
|
108
|
-
|
|
109
|
-
cg.setCanvasTransform()
|
|
86
|
+
geoCanvas.ctx.lineCap = simple ? 'butt' : 'round'
|
|
110
87
|
|
|
111
88
|
//draw shadows
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
for (let
|
|
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(
|
|
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(
|
|
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,
|
|
104
|
+
//const offset = this.offset(c, resolution, z)
|
|
128
105
|
|
|
129
106
|
//set width
|
|
130
|
-
|
|
107
|
+
geoCanvas.ctx.lineWidth = wG
|
|
131
108
|
|
|
132
109
|
//compute cell centre postition
|
|
133
|
-
const cx =
|
|
134
|
-
const cy =
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
|
134
|
+
for (let cell of cells) {
|
|
158
135
|
//color
|
|
159
136
|
/** @type {string|undefined} */
|
|
160
|
-
const col = this.color ? this.color(
|
|
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(
|
|
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(
|
|
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,
|
|
152
|
+
//const offset = this.offset(c, resolution, z)
|
|
176
153
|
|
|
177
154
|
//compute cell centre postition
|
|
178
|
-
const cx =
|
|
179
|
-
const cy =
|
|
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 (
|
|
165
|
+
if (simple) {
|
|
189
166
|
//draw segment
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
191
|
+
geoCanvas.ctx.strokeStyle = this.outlineCol
|
|
215
192
|
//cg.ctx.fillStyle = "#c08c59"
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
202
|
+
geoCanvas.ctx.lineCap = 'butt'
|
|
226
203
|
|
|
227
204
|
//update legends
|
|
228
|
-
this.updateLegends({ style: this,
|
|
205
|
+
this.updateLegends({ style: this, resolution: resolution, z: z, viewScale: viewScale })
|
|
229
206
|
}
|
|
230
207
|
}
|