gridviz 3.0.26 → 3.0.28
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 +126 -128
- package/dist/gridviz.js +8798 -8706
- package/dist/gridviz.min.js +1 -1
- package/package.json +73 -73
- package/src/button/Button.js +67 -67
- package/src/button/FullscreenButton.js +121 -121
- package/src/button/ZoomButtons.js +103 -103
- package/src/core/Dataset.js +154 -154
- package/src/core/Drawable.js +78 -78
- package/src/core/GeoCanvas.js +443 -443
- package/src/core/Layer.js +23 -23
- package/src/core/Legend.js +108 -108
- package/src/core/Map.js +544 -544
- package/src/core/MultiResolutionDataset.js +93 -93
- package/src/core/Style.js +98 -98
- package/src/core/Tooltip.js +182 -182
- package/src/dataset/COGeo.js +25 -25
- 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 +78 -77
- package/src/layer/BackgroundLayer.js +173 -173
- package/src/layer/BackgroundLayerImage.js +81 -81
- package/src/layer/BackgroundLayerWMS.js +104 -104
- package/src/layer/GeoJSONLayer.js +224 -214
- package/src/layer/GridLayer.js +149 -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/ContourStyle.js +21 -21
- 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/ShadingStyle.js +61 -0
- 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/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/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/zoomUtils.js +142 -142
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { Layer } from '../core/Layer.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* A map background layer composed of a single image file, geolocated.
|
|
9
|
-
*
|
|
10
|
-
* @module layer
|
|
11
|
-
* @author Julien Gaffuri
|
|
12
|
-
*/
|
|
13
|
-
export class BackgroundLayerImage extends Layer {
|
|
14
|
-
/**
|
|
15
|
-
* @param {object} opts
|
|
16
|
-
*/
|
|
17
|
-
constructor(opts) {
|
|
18
|
-
super(opts)
|
|
19
|
-
opts = opts || {}
|
|
20
|
-
|
|
21
|
-
/** The image file URL
|
|
22
|
-
* @type {string} */
|
|
23
|
-
this.url = opts.url
|
|
24
|
-
|
|
25
|
-
/** The image left coordinate
|
|
26
|
-
* @type {number} */
|
|
27
|
-
this.xMin = opts.xMin || 0
|
|
28
|
-
/** The image top coordinate
|
|
29
|
-
* @type {number} */
|
|
30
|
-
this.yMax = opts.yMax || 0
|
|
31
|
-
|
|
32
|
-
/** The image width, in geo unit
|
|
33
|
-
* @type {number} */
|
|
34
|
-
this.width = opts.width || 20000
|
|
35
|
-
/** The image height, in geo unit
|
|
36
|
-
* @type {number} */
|
|
37
|
-
this.height = opts.height || 20000
|
|
38
|
-
|
|
39
|
-
/** The image object
|
|
40
|
-
* @type {HTMLImageElement|undefined} */
|
|
41
|
-
this.img = undefined
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {import("../core/GeoCanvas.js").GeoCanvas} geoCanvas The canvas where to draw the layer.
|
|
46
|
-
* @returns {void}
|
|
47
|
-
*/
|
|
48
|
-
draw(geoCanvas) {
|
|
49
|
-
//update map extent
|
|
50
|
-
//geoCanvas.updateExtentGeo(0)
|
|
51
|
-
|
|
52
|
-
if (this.img) {
|
|
53
|
-
//the image was already downloaded: draw it
|
|
54
|
-
|
|
55
|
-
//compute screen coordinates and size ratio
|
|
56
|
-
const x = geoCanvas.geoToPixX(this.xMin)
|
|
57
|
-
const y = geoCanvas.geoToPixY(this.yMax)
|
|
58
|
-
const z = geoCanvas.getView().z
|
|
59
|
-
|
|
60
|
-
//draw image
|
|
61
|
-
geoCanvas.initCanvasTransform()
|
|
62
|
-
geoCanvas.offscreenCtx.drawImage(this.img, x, y, this.width / z, this.height / z)
|
|
63
|
-
} else {
|
|
64
|
-
//retrieve image
|
|
65
|
-
|
|
66
|
-
if (!this.img) {
|
|
67
|
-
this.img = new Image()
|
|
68
|
-
this.img.onload = () => {
|
|
69
|
-
geoCanvas.redraw()
|
|
70
|
-
}
|
|
71
|
-
this.img.onerror = () => {
|
|
72
|
-
//case when no image
|
|
73
|
-
console.warn('Could not retrieve background image from', this.url)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//set URL to launch the download
|
|
78
|
-
this.img.src = this.url
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { Layer } from '../core/Layer.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* A map background layer composed of a single image file, geolocated.
|
|
9
|
+
*
|
|
10
|
+
* @module layer
|
|
11
|
+
* @author Julien Gaffuri
|
|
12
|
+
*/
|
|
13
|
+
export class BackgroundLayerImage extends Layer {
|
|
14
|
+
/**
|
|
15
|
+
* @param {object} opts
|
|
16
|
+
*/
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
super(opts)
|
|
19
|
+
opts = opts || {}
|
|
20
|
+
|
|
21
|
+
/** The image file URL
|
|
22
|
+
* @type {string} */
|
|
23
|
+
this.url = opts.url
|
|
24
|
+
|
|
25
|
+
/** The image left coordinate
|
|
26
|
+
* @type {number} */
|
|
27
|
+
this.xMin = opts.xMin || 0
|
|
28
|
+
/** The image top coordinate
|
|
29
|
+
* @type {number} */
|
|
30
|
+
this.yMax = opts.yMax || 0
|
|
31
|
+
|
|
32
|
+
/** The image width, in geo unit
|
|
33
|
+
* @type {number} */
|
|
34
|
+
this.width = opts.width || 20000
|
|
35
|
+
/** The image height, in geo unit
|
|
36
|
+
* @type {number} */
|
|
37
|
+
this.height = opts.height || 20000
|
|
38
|
+
|
|
39
|
+
/** The image object
|
|
40
|
+
* @type {HTMLImageElement|undefined} */
|
|
41
|
+
this.img = undefined
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {import("../core/GeoCanvas.js").GeoCanvas} geoCanvas The canvas where to draw the layer.
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
48
|
+
draw(geoCanvas) {
|
|
49
|
+
//update map extent
|
|
50
|
+
//geoCanvas.updateExtentGeo(0)
|
|
51
|
+
|
|
52
|
+
if (this.img) {
|
|
53
|
+
//the image was already downloaded: draw it
|
|
54
|
+
|
|
55
|
+
//compute screen coordinates and size ratio
|
|
56
|
+
const x = geoCanvas.geoToPixX(this.xMin)
|
|
57
|
+
const y = geoCanvas.geoToPixY(this.yMax)
|
|
58
|
+
const z = geoCanvas.getView().z
|
|
59
|
+
|
|
60
|
+
//draw image
|
|
61
|
+
geoCanvas.initCanvasTransform()
|
|
62
|
+
geoCanvas.offscreenCtx.drawImage(this.img, x, y, this.width / z, this.height / z)
|
|
63
|
+
} else {
|
|
64
|
+
//retrieve image
|
|
65
|
+
|
|
66
|
+
if (!this.img) {
|
|
67
|
+
this.img = new Image()
|
|
68
|
+
this.img.onload = () => {
|
|
69
|
+
geoCanvas.redraw()
|
|
70
|
+
}
|
|
71
|
+
this.img.onerror = () => {
|
|
72
|
+
//case when no image
|
|
73
|
+
console.warn('Could not retrieve background image from', this.url)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//set URL to launch the download
|
|
78
|
+
this.img.src = this.url
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { Layer } from '../core/Layer.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* A map WMS background layer.
|
|
9
|
-
*
|
|
10
|
-
* @module layer
|
|
11
|
-
* @author Julien Gaffuri
|
|
12
|
-
*/
|
|
13
|
-
export class BackgroundLayerWMS extends Layer {
|
|
14
|
-
/**
|
|
15
|
-
* @param {object} opts
|
|
16
|
-
*/
|
|
17
|
-
constructor(opts) {
|
|
18
|
-
super(opts)
|
|
19
|
-
opts = opts || {}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @type {string} */
|
|
23
|
-
this.url = opts.url
|
|
24
|
-
|
|
25
|
-
/** @type {HTMLImageElement|undefined} */
|
|
26
|
-
this.img = undefined
|
|
27
|
-
|
|
28
|
-
/** @type {number|undefined} */
|
|
29
|
-
this.xMin = undefined
|
|
30
|
-
/** @type {number|undefined} */
|
|
31
|
-
this.xMax = undefined
|
|
32
|
-
/** @type {number|undefined} */
|
|
33
|
-
this.yMin = undefined
|
|
34
|
-
/** @type {number|undefined} */
|
|
35
|
-
this.yMax = undefined
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Check if the view has moved and a new image needs to be retrieved.
|
|
39
|
-
* @private */
|
|
40
|
-
hasMoved(extGeo) {
|
|
41
|
-
if (extGeo.xMin != this.xMin) return true
|
|
42
|
-
else if (extGeo.xMax != this.xMax) return true
|
|
43
|
-
else if (extGeo.yMin != this.yMin) return true
|
|
44
|
-
else if (extGeo.yMax != this.yMax) return true
|
|
45
|
-
else return false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas The canvas where to draw the layer.
|
|
50
|
-
* @returns {void}
|
|
51
|
-
*/
|
|
52
|
-
draw(geoCanvas) {
|
|
53
|
-
//update map extent
|
|
54
|
-
geoCanvas.updateExtentGeo(0)
|
|
55
|
-
|
|
56
|
-
if (!this.hasMoved(geoCanvas.extGeo) && this.img) {
|
|
57
|
-
//the map did not move and the image was already downloaded: draw the image
|
|
58
|
-
geoCanvas.initCanvasTransform()
|
|
59
|
-
geoCanvas.offscreenCtx.drawImage(this.img, 0, 0, geoCanvas.w, geoCanvas.h)
|
|
60
|
-
} else {
|
|
61
|
-
//the map moved: retrieve new image
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
this.xMin = geoCanvas.extGeo.xMin
|
|
65
|
-
this.xMax = geoCanvas.extGeo.xMax
|
|
66
|
-
this.yMin = geoCanvas.extGeo.yMin
|
|
67
|
-
this.yMax = geoCanvas.extGeo.yMax
|
|
68
|
-
|
|
69
|
-
//build WMS URL
|
|
70
|
-
const url = []
|
|
71
|
-
url.push(this.url)
|
|
72
|
-
url.push('&width=')
|
|
73
|
-
url.push(geoCanvas.w)
|
|
74
|
-
url.push('&height=')
|
|
75
|
-
url.push(geoCanvas.h)
|
|
76
|
-
//bbox: xmin ymin xmax ymax
|
|
77
|
-
url.push('&bbox=')
|
|
78
|
-
url.push(geoCanvas.extGeo.xMin)
|
|
79
|
-
url.push(',')
|
|
80
|
-
url.push(geoCanvas.extGeo.yMin)
|
|
81
|
-
url.push(',')
|
|
82
|
-
url.push(geoCanvas.extGeo.xMax)
|
|
83
|
-
url.push(',')
|
|
84
|
-
url.push(geoCanvas.extGeo.yMax)
|
|
85
|
-
|
|
86
|
-
const urlS = url.join('')
|
|
87
|
-
//console.log(urlS)
|
|
88
|
-
|
|
89
|
-
if (!this.img) {
|
|
90
|
-
this.img = new Image()
|
|
91
|
-
this.img.onload = () => {
|
|
92
|
-
geoCanvas.redraw()
|
|
93
|
-
}
|
|
94
|
-
this.img.onerror = () => {
|
|
95
|
-
//case when no image
|
|
96
|
-
console.warn('Could not retrieve WMS background image from', urlS)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//set URL to launch the download
|
|
101
|
-
this.img.src = urlS
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { Layer } from '../core/Layer.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* A map WMS background layer.
|
|
9
|
+
*
|
|
10
|
+
* @module layer
|
|
11
|
+
* @author Julien Gaffuri
|
|
12
|
+
*/
|
|
13
|
+
export class BackgroundLayerWMS extends Layer {
|
|
14
|
+
/**
|
|
15
|
+
* @param {object} opts
|
|
16
|
+
*/
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
super(opts)
|
|
19
|
+
opts = opts || {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @type {string} */
|
|
23
|
+
this.url = opts.url
|
|
24
|
+
|
|
25
|
+
/** @type {HTMLImageElement|undefined} */
|
|
26
|
+
this.img = undefined
|
|
27
|
+
|
|
28
|
+
/** @type {number|undefined} */
|
|
29
|
+
this.xMin = undefined
|
|
30
|
+
/** @type {number|undefined} */
|
|
31
|
+
this.xMax = undefined
|
|
32
|
+
/** @type {number|undefined} */
|
|
33
|
+
this.yMin = undefined
|
|
34
|
+
/** @type {number|undefined} */
|
|
35
|
+
this.yMax = undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Check if the view has moved and a new image needs to be retrieved.
|
|
39
|
+
* @private */
|
|
40
|
+
hasMoved(extGeo) {
|
|
41
|
+
if (extGeo.xMin != this.xMin) return true
|
|
42
|
+
else if (extGeo.xMax != this.xMax) return true
|
|
43
|
+
else if (extGeo.yMin != this.yMin) return true
|
|
44
|
+
else if (extGeo.yMax != this.yMax) return true
|
|
45
|
+
else return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {import("../core/GeoCanvas").GeoCanvas} geoCanvas The canvas where to draw the layer.
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
draw(geoCanvas) {
|
|
53
|
+
//update map extent
|
|
54
|
+
geoCanvas.updateExtentGeo(0)
|
|
55
|
+
|
|
56
|
+
if (!this.hasMoved(geoCanvas.extGeo) && this.img) {
|
|
57
|
+
//the map did not move and the image was already downloaded: draw the image
|
|
58
|
+
geoCanvas.initCanvasTransform()
|
|
59
|
+
geoCanvas.offscreenCtx.drawImage(this.img, 0, 0, geoCanvas.w, geoCanvas.h)
|
|
60
|
+
} else {
|
|
61
|
+
//the map moved: retrieve new image
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
this.xMin = geoCanvas.extGeo.xMin
|
|
65
|
+
this.xMax = geoCanvas.extGeo.xMax
|
|
66
|
+
this.yMin = geoCanvas.extGeo.yMin
|
|
67
|
+
this.yMax = geoCanvas.extGeo.yMax
|
|
68
|
+
|
|
69
|
+
//build WMS URL
|
|
70
|
+
const url = []
|
|
71
|
+
url.push(this.url)
|
|
72
|
+
url.push('&width=')
|
|
73
|
+
url.push(geoCanvas.w)
|
|
74
|
+
url.push('&height=')
|
|
75
|
+
url.push(geoCanvas.h)
|
|
76
|
+
//bbox: xmin ymin xmax ymax
|
|
77
|
+
url.push('&bbox=')
|
|
78
|
+
url.push(geoCanvas.extGeo.xMin)
|
|
79
|
+
url.push(',')
|
|
80
|
+
url.push(geoCanvas.extGeo.yMin)
|
|
81
|
+
url.push(',')
|
|
82
|
+
url.push(geoCanvas.extGeo.xMax)
|
|
83
|
+
url.push(',')
|
|
84
|
+
url.push(geoCanvas.extGeo.yMax)
|
|
85
|
+
|
|
86
|
+
const urlS = url.join('')
|
|
87
|
+
//console.log(urlS)
|
|
88
|
+
|
|
89
|
+
if (!this.img) {
|
|
90
|
+
this.img = new Image()
|
|
91
|
+
this.img.onload = () => {
|
|
92
|
+
geoCanvas.redraw()
|
|
93
|
+
}
|
|
94
|
+
this.img.onerror = () => {
|
|
95
|
+
//case when no image
|
|
96
|
+
console.warn('Could not retrieve WMS background image from', urlS)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//set URL to launch the download
|
|
101
|
+
this.img.src = urlS
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|