gridviz 2.1.9 → 2.1.10

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 (57) hide show
  1. package/README.md +125 -125
  2. package/dist/gridviz.js +8036 -8024
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +77 -77
  5. package/src/App.js +705 -705
  6. package/src/BackgroundLayer.js +182 -182
  7. package/src/BackgroundLayerWMS.js +131 -131
  8. package/src/Dataset.js +76 -76
  9. package/src/DatasetComponent.js +113 -101
  10. package/src/GeoCanvas.js +420 -420
  11. package/src/LabelLayer.js +190 -190
  12. package/src/Layer.js +103 -103
  13. package/src/Legend.js +86 -86
  14. package/src/LineLayer.js +150 -150
  15. package/src/Style.js +129 -129
  16. package/src/Tooltip.js +180 -180
  17. package/src/dataset/COGeo.js +24 -24
  18. package/src/dataset/CSVGrid.js +104 -104
  19. package/src/dataset/GeoTIFF.js +127 -127
  20. package/src/dataset/GridTile.js +41 -41
  21. package/src/dataset/LGrid.js +54 -54
  22. package/src/dataset/TiledGrid.js +264 -264
  23. package/src/index.js +71 -71
  24. package/src/legend/ColorCategoryLegend.js +124 -124
  25. package/src/legend/ColorDiscreteLegend.js +103 -103
  26. package/src/legend/ColorLegend.js +124 -124
  27. package/src/legend/SegmentOrientationLegend.js +87 -87
  28. package/src/legend/SegmentWidthLegend.js +97 -97
  29. package/src/legend/SizeLegend.js +141 -141
  30. package/src/style/CompositionStyle.js +300 -300
  31. package/src/style/ContourStyle.js +54 -54
  32. package/src/style/DotDensityStyle.js +156 -156
  33. package/src/style/IsoFenceStyle.js +262 -262
  34. package/src/style/JoyPlotStyle.js +135 -135
  35. package/src/style/LegoStyle.js +112 -112
  36. package/src/style/MosaicStyle.js +107 -107
  37. package/src/style/NinjaStarStyle.js +125 -125
  38. package/src/style/PillarStyle.js +230 -230
  39. package/src/style/SegmentStyle.js +142 -142
  40. package/src/style/ShapeColorSizeStyle.js +126 -126
  41. package/src/style/SideCatStyle.js +172 -172
  42. package/src/style/SideStyle.js +216 -216
  43. package/src/style/SquareColorCatWGLStyle.js +120 -120
  44. package/src/style/SquareColorWGLStyle.js +146 -146
  45. package/src/style/StrokeStyle.js +131 -131
  46. package/src/style/TanakaStyle.js +160 -160
  47. package/src/style/TextStyle.js +132 -132
  48. package/src/style/TimeSeriesStyle.js +250 -250
  49. package/src/utils/Utils.js +35 -35
  50. package/src/utils/WebGLRectangleColoring.js +106 -106
  51. package/src/utils/WebGLSquareColoring.js +118 -118
  52. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  53. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  54. package/src/utils/WebGLSquareColoringKS.js +153 -153
  55. package/src/utils/stretching.js +131 -131
  56. package/src/utils/webGLUtils.js +71 -71
  57. package/src/utils/zoomUtils.js +142 -142
package/src/Dataset.js CHANGED
@@ -1,76 +1,76 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- /**
5
- * A grid cell.
6
- * @typedef {{x: number, y: number}} Cell */
7
- /**
8
- * An envelope.
9
- * @typedef { {xMin: number, xMax: number, yMin: number, yMax: number} } Envelope */
10
-
11
- /**
12
- * A multi resolution dataset of grid cells.
13
- * It consists of different {@link DatasetComponent}s for each resolution.
14
- *
15
- * @abstract
16
- *
17
- * @author Joseph Davies, Julien Gaffuri
18
- */
19
- export class Dataset {
20
- /**
21
- * @param {Array.<import("./DatasetComponent").DatasetComponent>} datasetComponents The dataset components
22
- * @param {Array.<number>} resolutions The resolutions of the dataset components, in CRS geographical unit
23
- * @param { {preprocess?:function(Cell):boolean} } opts Options. preprocess: A function to apply on each dataset cell to prepare its values. Can be used also to select cells to keep.
24
- */
25
- constructor(datasetComponents, resolutions, opts = {}) {
26
- opts = opts || {}
27
-
28
- /** The dataset components.
29
- * @type {Array.<import("./DatasetComponent").DatasetComponent>} */
30
- this.datasetComponents = datasetComponents
31
-
32
- /** The resolutions of the dataset components, in CRS geographical unit.
33
- * @type {Array.<number>} */
34
- this.resolutions = resolutions
35
-
36
- //there must be as many dataset components as resolutions
37
- if (this.datasetComponents.length > 1 && this.datasetComponents.length != this.resolutions.length)
38
- throw new Error(
39
- 'Uncompatible number of datasets and resolutions: ' +
40
- this.datasetComponents.length +
41
- ' ' +
42
- this.resolutions.length
43
- )
44
-
45
- //set dataset preprocesses if specified
46
- if (opts.preprocess) this.setPrepocesses(opts.preprocess)
47
- }
48
-
49
- /**
50
- * Set a preprocess function for all dataset components.
51
- * This is a function applied on each cell after it has been loaded.
52
- *
53
- * @param {function(Cell):boolean} preprocess
54
- * @returns {this}
55
- */
56
- setPrepocesses(preprocess) {
57
- for (let ds of this.datasetComponents) ds.preprocess = preprocess
58
- return this
59
- }
60
-
61
- /**
62
- * A function to ease the creation of datasets from their components.
63
- *
64
- * @param {Array.<number>} resolutions The resolutions of the dataset components, in CRS geographical unit
65
- * @param {function(number):import("./DatasetComponent").DatasetComponent} resToDatasetComponent Function returning a dataset component from a resolution
66
- * @param { {preprocess?:function(Cell):boolean} } opts Options. preprocess: A function to apply on each dataset cell to prepare its values
67
- * @returns {Dataset}
68
- */
69
- static make(resolutions, resToDatasetComponent, opts) {
70
- //make dataset components
71
- const dsc = []
72
- for (const res of resolutions) dsc.push(resToDatasetComponent(res))
73
- //make dataset
74
- return new Dataset(dsc, resolutions, opts)
75
- }
76
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ /**
5
+ * A grid cell.
6
+ * @typedef {{x: number, y: number}} Cell */
7
+ /**
8
+ * An envelope.
9
+ * @typedef { {xMin: number, xMax: number, yMin: number, yMax: number} } Envelope */
10
+
11
+ /**
12
+ * A multi resolution dataset of grid cells.
13
+ * It consists of different {@link DatasetComponent}s for each resolution.
14
+ *
15
+ * @abstract
16
+ *
17
+ * @author Joseph Davies, Julien Gaffuri
18
+ */
19
+ export class Dataset {
20
+ /**
21
+ * @param {Array.<import("./DatasetComponent").DatasetComponent>} datasetComponents The dataset components
22
+ * @param {Array.<number>} resolutions The resolutions of the dataset components, in CRS geographical unit
23
+ * @param { {preprocess?:function(Cell):boolean} } opts Options. preprocess: A function to apply on each dataset cell to prepare its values. Can be used also to select cells to keep.
24
+ */
25
+ constructor(datasetComponents, resolutions, opts = {}) {
26
+ opts = opts || {}
27
+
28
+ /** The dataset components.
29
+ * @type {Array.<import("./DatasetComponent").DatasetComponent>} */
30
+ this.datasetComponents = datasetComponents
31
+
32
+ /** The resolutions of the dataset components, in CRS geographical unit.
33
+ * @type {Array.<number>} */
34
+ this.resolutions = resolutions
35
+
36
+ //there must be as many dataset components as resolutions
37
+ if (this.datasetComponents.length > 1 && this.datasetComponents.length != this.resolutions.length)
38
+ throw new Error(
39
+ 'Uncompatible number of datasets and resolutions: ' +
40
+ this.datasetComponents.length +
41
+ ' ' +
42
+ this.resolutions.length
43
+ )
44
+
45
+ //set dataset preprocesses if specified
46
+ if (opts.preprocess) this.setPrepocesses(opts.preprocess)
47
+ }
48
+
49
+ /**
50
+ * Set a preprocess function for all dataset components.
51
+ * This is a function applied on each cell after it has been loaded.
52
+ *
53
+ * @param {function(Cell):boolean} preprocess
54
+ * @returns {this}
55
+ */
56
+ setPrepocesses(preprocess) {
57
+ for (let ds of this.datasetComponents) ds.preprocess = preprocess
58
+ return this
59
+ }
60
+
61
+ /**
62
+ * A function to ease the creation of datasets from their components.
63
+ *
64
+ * @param {Array.<number>} resolutions The resolutions of the dataset components, in CRS geographical unit
65
+ * @param {function(number):import("./DatasetComponent").DatasetComponent} resToDatasetComponent Function returning a dataset component from a resolution
66
+ * @param { {preprocess?:function(Cell):boolean} } opts Options. preprocess: A function to apply on each dataset cell to prepare its values
67
+ * @returns {Dataset}
68
+ */
69
+ static make(resolutions, resToDatasetComponent, opts) {
70
+ //make dataset components
71
+ const dsc = []
72
+ for (const res of resolutions) dsc.push(resToDatasetComponent(res))
73
+ //make dataset
74
+ return new Dataset(dsc, resolutions, opts)
75
+ }
76
+ }
@@ -1,101 +1,113 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- /**
5
- * A dataset component, of grid cells.
6
- * @abstract
7
- *
8
- * @author Joseph Davies, Julien Gaffuri
9
- */
10
- export class DatasetComponent {
11
- /**
12
- * @param {string} url The URL of the dataset.
13
- * @param {number} resolution The dataset resolution, in the CRS geographical unit.
14
- * @param {{preprocess?:function(import("./Dataset").Cell):boolean}} opts
15
- * @abstract
16
- */
17
- constructor(url, resolution, opts = {}) {
18
- opts = opts || {}
19
-
20
- /**
21
- * The url of the dataset.
22
- * @protected
23
- * @type {string} */
24
- this.url = url
25
-
26
- /**
27
- * The dataset resolution in geographical unit.
28
- * @protected
29
- * @type {number} */
30
- this.resolution = resolution
31
-
32
- /**
33
- * A preprocess to run on each cell after loading. It can be used to apply some specific treatment before or compute a new column. And also to determine which cells to keep after loading.
34
- * @type {(function(import("./Dataset").Cell):boolean )| undefined } */
35
- this.preprocess = opts.preprocess || undefined
36
-
37
- /** The cells within the view
38
- * @protected
39
- * @type {Array.<import("./Dataset").Cell>} */
40
- this.cellsViewCache = []
41
- }
42
-
43
- /**
44
- * Request data within a geographic envelope.
45
- *
46
- * @abstract
47
- * @param {import("./Dataset").Envelope|undefined} extGeo
48
- * @param {function():void} callback
49
- * @returns {this}
50
- */
51
- getData(extGeo, callback) {
52
- throw new Error('Method getData not implemented.')
53
- }
54
-
55
- /**
56
- * Fill the view cache with all cells which are within a geographical envelope.
57
- * @abstract
58
- * @param {import("./Dataset").Envelope} extGeo The view geographical envelope.
59
- * @returns {void}
60
- */
61
- updateViewCache(extGeo) {
62
- throw new Error('Method updateViewCache not implemented.')
63
- }
64
-
65
- /**
66
- * Get a cell under a given position, if any.
67
- *
68
- * @param {{x:number,y:number}} posGeo
69
- * @param {Array.<import("./Dataset").Cell>} cells Some cells from the dataset (a subset if necessary, usually the view cache).
70
- * @returns {import("./Dataset").Cell|undefined}
71
- */
72
- getCellFromPosition(posGeo, cells) {
73
- //compute candidate cell position
74
- /** @type {number} */
75
- const r = this.getResolution()
76
- /** @type {number} */
77
- const cellX = r * Math.floor(posGeo.x / r)
78
- /** @type {number} */
79
- const cellY = r * Math.floor(posGeo.y / r)
80
-
81
- //get cell
82
- for (const cell of cells) {
83
- if (cell.x != cellX) continue
84
- if (cell.y != cellY) continue
85
- return cell
86
- }
87
- return undefined
88
- }
89
-
90
- //getters and setters
91
-
92
- /** @returns {number} */
93
- getResolution() {
94
- return this.resolution
95
- }
96
-
97
- /** @returns {Array.<import("./Dataset").Cell>} */
98
- getViewCache() {
99
- return this.cellsViewCache
100
- }
101
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ /**
5
+ * A dataset component, of grid cells.
6
+ * @abstract
7
+ *
8
+ * @author Joseph Davies, Julien Gaffuri
9
+ */
10
+ export class DatasetComponent {
11
+ /**
12
+ * @param {string} url The URL of the dataset.
13
+ * @param {number} resolution The dataset resolution, in the CRS geographical unit.
14
+ * @param {{preprocess?:function(import("./Dataset").Cell):boolean}} opts
15
+ * @abstract
16
+ */
17
+ constructor(url, resolution, opts = {}) {
18
+ opts = opts || {}
19
+
20
+ /**
21
+ * The url of the dataset.
22
+ * @protected
23
+ * @type {string} */
24
+ this.url = url
25
+
26
+ /**
27
+ * The dataset resolution in geographical unit.
28
+ * @protected
29
+ * @type {number} */
30
+ this.resolution = resolution
31
+
32
+ /**
33
+ * A preprocess to run on each cell after loading. It can be used to apply some specific treatment before or compute a new column. And also to determine which cells to keep after loading.
34
+ * @type {(function(import("./Dataset").Cell):boolean )| undefined } */
35
+ this.preprocess = opts.preprocess || undefined
36
+
37
+ /** The cells within the view
38
+ * @protected
39
+ * @type {Array.<import("./Dataset").Cell>} */
40
+ this.cellsViewCache = []
41
+ }
42
+
43
+ /**
44
+ * Request data within a geographic envelope.
45
+ *
46
+ * @abstract
47
+ * @param {import("./Dataset").Envelope|undefined} extGeo
48
+ * @param {function():void} callback
49
+ * @returns {this}
50
+ */
51
+ getData(extGeo, callback) {
52
+ throw new Error('Method getData not implemented.')
53
+ }
54
+
55
+ /**
56
+ * Fill the view cache with all cells which are within a geographical envelope.
57
+ * @abstract
58
+ * @param {import("./Dataset").Envelope} extGeo The view geographical envelope.
59
+ * @returns {void}
60
+ */
61
+ updateViewCache(extGeo) {
62
+ throw new Error('Method updateViewCache not implemented.')
63
+ }
64
+
65
+ /**
66
+ * Get a cell under a given position, if any.
67
+ *
68
+ * @param {{x:number,y:number}} posGeo
69
+ * @param {Array.<import("./Dataset").Cell>} cells Some cells from the dataset (a subset if necessary, usually the view cache).
70
+ * @returns {import("./Dataset").Cell|undefined}
71
+ */
72
+ getCellFromPosition(posGeo, cells) {
73
+ //compute candidate cell position
74
+ /** @type {number} */
75
+ //const r = this.getResolution()
76
+ /** @type {number} */
77
+ //const cellX = r * Math.floor(posGeo.x / r)
78
+ /** @type {number} */
79
+ //const cellY = r * Math.floor(posGeo.y / r)
80
+
81
+ /*/get cell
82
+ for (const cell of cells) {
83
+ if (cell.x != cellX) continue
84
+ if (cell.y != cellY) continue
85
+ return cell
86
+ }
87
+ return undefined*/
88
+
89
+ /** @type {number} */
90
+ const r = this.getResolution()
91
+ for (const cell of cells) {
92
+ if (posGeo.x < cell.x) continue
93
+ else if (cell.x + r < posGeo.x) continue
94
+ else if (posGeo.y < cell.y) continue
95
+ else if (cell.y + r < posGeo.y) continue
96
+ else return cell
97
+ }
98
+ return undefined
99
+
100
+ }
101
+
102
+ //getters and setters
103
+
104
+ /** @returns {number} */
105
+ getResolution() {
106
+ return this.resolution
107
+ }
108
+
109
+ /** @returns {Array.<import("./Dataset").Cell>} */
110
+ getViewCache() {
111
+ return this.cellsViewCache
112
+ }
113
+ }