gridviz 3.0.15 → 3.0.17

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 (55) hide show
  1. package/README.md +127 -128
  2. package/dist/gridviz.js +7958 -7861
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +74 -74
  5. package/src/button/ZoomButtons.js +101 -96
  6. package/src/core/Dataset.js +154 -157
  7. package/src/core/Drawable.js +60 -61
  8. package/src/core/GeoCanvas.js +409 -370
  9. package/src/core/Layer.js +23 -25
  10. package/src/core/Legend.js +108 -110
  11. package/src/core/Map.js +494 -495
  12. package/src/core/MultiResolutionDataset.js +93 -97
  13. package/src/core/Style.js +98 -99
  14. package/src/dataset/CSVGrid.js +112 -112
  15. package/src/dataset/GeoTIFF.js +122 -123
  16. package/src/dataset/JSGrid.js +55 -54
  17. package/src/dataset/TiledGrid.js +289 -288
  18. package/src/dataset/worker.js +18 -0
  19. package/src/index.js +77 -71
  20. package/src/layer/BackgroundLayer.js +162 -158
  21. package/src/layer/BackgroundLayerImage.js +81 -84
  22. package/src/layer/BackgroundLayerWMS.js +104 -108
  23. package/src/layer/GeoJSONLayer.js +214 -220
  24. package/src/layer/GridLayer.js +148 -157
  25. package/src/layer/LabelLayer.js +194 -193
  26. package/src/legend/ColorCategoryLegend.js +109 -110
  27. package/src/legend/ColorDiscreteLegend.js +100 -102
  28. package/src/legend/ColorLegend.js +115 -118
  29. package/src/legend/OrientationLegend.js +89 -91
  30. package/src/legend/SizeLegend.js +224 -224
  31. package/src/legend/TernaryLegend.js +302 -210
  32. package/src/style/CompositionStyle.js +291 -288
  33. package/src/style/DotDensityStyle.js +133 -134
  34. package/src/style/ImageStyle.js +100 -102
  35. package/src/style/IsoFenceStyle.js +217 -203
  36. package/src/style/JoyPlotStyle.js +127 -128
  37. package/src/style/LegoStyle.js +110 -110
  38. package/src/style/MosaicStyle.js +99 -99
  39. package/src/style/NinjaStarStyle.js +102 -102
  40. package/src/style/PillarStyle.js +207 -208
  41. package/src/style/SegmentStyle.js +105 -105
  42. package/src/style/ShapeColorSizeStyle.js +147 -132
  43. package/src/style/SideCategoryStyle.js +112 -114
  44. package/src/style/SideStyle.js +212 -205
  45. package/src/style/SquareColorCategoryWebGLStyle.js +107 -108
  46. package/src/style/SquareColorWebGLStyle.js +126 -126
  47. package/src/style/StrokeStyle.js +135 -136
  48. package/src/style/TanakaStyle.js +69 -68
  49. package/src/style/TextStyle.js +110 -111
  50. package/src/style/TimeSeriesStyle.js +222 -229
  51. package/src/utils/scale.js +218 -228
  52. package/src/utils/stretching.js +120 -133
  53. package/src/utils/ternary.js +203 -204
  54. package/src/utils/utils.js +58 -63
  55. package/src/utils/webGLUtils.js +72 -70
@@ -1,123 +1,122 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Dataset } from '../core/Dataset.js'
5
- //import { fromUrl } from "geotiff"
6
-
7
- /**
8
- * @todo
9
- * A dataset composed of a single GeoTiff file.
10
- *
11
- * @module dataset
12
- * @author Joseph Davies, Julien Gaffuri
13
- */
14
- export class GeoTIFF extends Dataset {
15
-
16
- constructor(map, url, resolution, opts = {}) {
17
- super(map, url, resolution, opts)
18
-
19
- /**
20
- * @private
21
- * @type {Array.<import("../core/Dataset").Cell>} */
22
- this.cells = []
23
-
24
- /**
25
- * @type {string}
26
- * @private */
27
- this.infoLoadingStatus = 'notLoaded'
28
- }
29
-
30
- /**
31
- * Request data within a geographic envelope.
32
- *
33
- * @param {import("../core/GeoCanvas.js").Envelope|undefined} e
34
- */
35
- getData(e) {
36
- //check if data already loaded
37
- if (this.infoLoadingStatus != 'notLoaded') return this
38
-
39
- //load data
40
- this.infoLoadingStatus = 'loading'
41
-
42
- /*
43
-
44
- fromUrl(this.url)
45
- .then(tiff => {
46
- console.log(tiff);
47
-
48
- (async function () {
49
- const image = await tiff.getImage();
50
- const width = image.getWidth();
51
- const height = image.getHeight();
52
- const tileWidth = image.getTileWidth();
53
- const tileHeight = image.getTileHeight();
54
- const samplesPerPixel = image.getSamplesPerPixel();
55
-
56
- //for geotiff
57
- const origin = image.getOrigin();
58
- const resolution = image.getResolution();
59
- const bbox = image.getBoundingBox();
60
-
61
- console.log(image)
62
- console.log(width, height)
63
- console.log(tileWidth, tileHeight)
64
- console.log(samplesPerPixel)
65
- console.log(origin)
66
- console.log(resolution)
67
- console.log(bbox)
68
-
69
- console.log("-------")
70
-
71
- const data = await image.readRasters();
72
- console.log(data)
73
-
74
- })()
75
-
76
- //convert coordinates in numbers
77
- //for (const c of data) { c.x = +c.x; c.y = +c.y; }
78
-
79
- //this.cells = data;
80
-
81
- //execute preprocess, if any
82
- //if (this.preprocess) for (const c of this.cells) this.preprocess(c);
83
-
84
- //TODO check if redraw is necessary
85
- //that is if the dataset belongs to a layer which is visible at the current zoom level
86
-
87
- //execute the callback, usually a draw function
88
- if (redraw) redraw()
89
-
90
- this.infoLoadingStatus = "loaded";
91
-
92
-
93
- })
94
- .catch(() => {
95
- //mark as failed
96
- this.infoLoadingStatus = "failed";
97
- this.cells = []
98
- });
99
- */
100
-
101
- return this
102
- }
103
-
104
- /**
105
- * Fill the view cache with all cells which are within a geographical envelope.
106
- *
107
- * @param {import("../core/GeoCanvas.js").Envelope} extGeo
108
- * @returns {void}
109
- */
110
- updateViewCache(extGeo) {
111
- //data not loaded yet
112
- if (!this.cells) return
113
-
114
- this.cellsViewCache = []
115
- for (const cell of this.cells) {
116
- if (+cell.x + this.resolution < extGeo.xMin) continue
117
- if (+cell.x - this.resolution > extGeo.xMax) continue
118
- if (+cell.y + this.resolution < extGeo.yMin) continue
119
- if (+cell.y - this.resolution > extGeo.yMax) continue
120
- this.cellsViewCache.push(cell)
121
- }
122
- }
123
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Dataset } from '../core/Dataset.js'
5
+ //import { fromUrl } from "geotiff"
6
+
7
+ /**
8
+ * @todo
9
+ * A dataset composed of a single GeoTiff file.
10
+ *
11
+ * @module dataset
12
+ * @author Joseph Davies, Julien Gaffuri
13
+ */
14
+ export class GeoTIFF extends Dataset {
15
+ constructor(map, url, resolution, opts = {}) {
16
+ super(map, url, resolution, opts)
17
+
18
+ /**
19
+ * @private
20
+ * @type {Array.<import("../core/Dataset").Cell>} */
21
+ this.cells = []
22
+
23
+ /**
24
+ * @type {string}
25
+ * @private */
26
+ this.infoLoadingStatus = 'notLoaded'
27
+ }
28
+
29
+ /**
30
+ * Request data within a geographic envelope.
31
+ *
32
+ * @param {import("../core/GeoCanvas.js").Envelope|undefined} e
33
+ */
34
+ getData(e) {
35
+ //check if data already loaded
36
+ if (this.infoLoadingStatus != 'notLoaded') return this
37
+
38
+ //load data
39
+ this.infoLoadingStatus = 'loading'
40
+
41
+ /*
42
+
43
+ fromUrl(this.url)
44
+ .then(tiff => {
45
+ console.log(tiff);
46
+
47
+ (async function () {
48
+ const image = await tiff.getImage();
49
+ const width = image.getWidth();
50
+ const height = image.getHeight();
51
+ const tileWidth = image.getTileWidth();
52
+ const tileHeight = image.getTileHeight();
53
+ const samplesPerPixel = image.getSamplesPerPixel();
54
+
55
+ //for geotiff
56
+ const origin = image.getOrigin();
57
+ const resolution = image.getResolution();
58
+ const bbox = image.getBoundingBox();
59
+
60
+ console.log(image)
61
+ console.log(width, height)
62
+ console.log(tileWidth, tileHeight)
63
+ console.log(samplesPerPixel)
64
+ console.log(origin)
65
+ console.log(resolution)
66
+ console.log(bbox)
67
+
68
+ console.log("-------")
69
+
70
+ const data = await image.readRasters();
71
+ console.log(data)
72
+
73
+ })()
74
+
75
+ //convert coordinates in numbers
76
+ //for (const c of data) { c.x = +c.x; c.y = +c.y; }
77
+
78
+ //this.cells = data;
79
+
80
+ //execute preprocess, if any
81
+ //if (this.preprocess) for (const c of this.cells) this.preprocess(c);
82
+
83
+ //TODO check if redraw is necessary
84
+ //that is if the dataset belongs to a layer which is visible at the current zoom level
85
+
86
+ //execute the callback, usually a draw function
87
+ if (redraw) redraw()
88
+
89
+ this.infoLoadingStatus = "loaded";
90
+
91
+
92
+ })
93
+ .catch(() => {
94
+ //mark as failed
95
+ this.infoLoadingStatus = "failed";
96
+ this.cells = []
97
+ });
98
+ */
99
+
100
+ return this
101
+ }
102
+
103
+ /**
104
+ * Fill the view cache with all cells which are within a geographical envelope.
105
+ *
106
+ * @param {import("../core/GeoCanvas.js").Envelope} extGeo
107
+ * @returns {void}
108
+ */
109
+ updateViewCache(extGeo) {
110
+ //data not loaded yet
111
+ if (!this.cells) return
112
+
113
+ this.cellsViewCache = []
114
+ for (const cell of this.cells) {
115
+ if (+cell.x + this.resolution < extGeo.xMin) continue
116
+ if (+cell.x - this.resolution > extGeo.xMax) continue
117
+ if (+cell.y + this.resolution < extGeo.yMin) continue
118
+ if (+cell.y - this.resolution > extGeo.yMax) continue
119
+ this.cellsViewCache.push(cell)
120
+ }
121
+ }
122
+ }
@@ -1,54 +1,55 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Dataset } from '../core/Dataset.js'
5
-
6
- /**
7
- * A dataset composed of cells defined in javascript, or loaded outside of gridviz map.
8
- *
9
- * @module dataset
10
- * @author Joseph Davies, Julien Gaffuri
11
- */
12
- export class JSGrid extends Dataset {
13
-
14
- /**
15
- * @param {number} resolution The dataset resolution in geographical unit.
16
- * @param {Array.<Object>} cells The cells.
17
- * @param {} opts
18
- */
19
- constructor(resolution, cells, opts = {}) {
20
- super(undefined, "", resolution, opts)
21
-
22
- /**
23
- * @private
24
- * @type {Array.<import('../core/Dataset.js').Cell>} */
25
- this.cells = cells || []
26
- }
27
-
28
- /**
29
- * Request data within a geographic envelope.
30
- *
31
- * @param {import("../core/GeoCanvas.js").Envelope|undefined} e
32
- */
33
- getData(e) { return this }
34
-
35
- /**
36
- * Fill the view cache with all cells which are within a geographical envelope.
37
- *
38
- * @param {import("../core/GeoCanvas.js").Envelope} extGeo
39
- * @returns {void}
40
- */
41
- updateViewCache(extGeo) {
42
- //data not loaded yet
43
- if (!this.cells) return
44
-
45
- this.cellsViewCache = []
46
- for (const cell of this.cells) {
47
- if (+cell.x + this.resolution < extGeo.xMin) continue
48
- if (+cell.x - this.resolution > extGeo.xMax) continue
49
- if (+cell.y + this.resolution < extGeo.yMin) continue
50
- if (+cell.y - this.resolution > extGeo.yMax) continue
51
- this.cellsViewCache.push(cell)
52
- }
53
- }
54
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Dataset } from '../core/Dataset.js'
5
+
6
+ /**
7
+ * A dataset composed of cells defined in javascript, or loaded outside of gridviz map.
8
+ *
9
+ * @module dataset
10
+ * @author Joseph Davies, Julien Gaffuri
11
+ */
12
+ export class JSGrid extends Dataset {
13
+ /**
14
+ * @param {number} resolution The dataset resolution in geographical unit.
15
+ * @param {Array.<Object>} cells The cells.
16
+ * @param {} opts
17
+ */
18
+ constructor(resolution, cells, opts = {}) {
19
+ super(undefined, '', resolution, opts)
20
+
21
+ /**
22
+ * @private
23
+ * @type {Array.<import('../core/Dataset.js').Cell>} */
24
+ this.cells = cells || []
25
+ }
26
+
27
+ /**
28
+ * Request data within a geographic envelope.
29
+ *
30
+ * @param {import("../core/GeoCanvas.js").Envelope|undefined} e
31
+ */
32
+ getData(e) {
33
+ return this
34
+ }
35
+
36
+ /**
37
+ * Fill the view cache with all cells which are within a geographical envelope.
38
+ *
39
+ * @param {import("../core/GeoCanvas.js").Envelope} extGeo
40
+ * @returns {void}
41
+ */
42
+ updateViewCache(extGeo) {
43
+ //data not loaded yet
44
+ if (!this.cells) return
45
+
46
+ this.cellsViewCache = []
47
+ for (const cell of this.cells) {
48
+ if (+cell.x + this.resolution < extGeo.xMin) continue
49
+ if (+cell.x - this.resolution > extGeo.xMax) continue
50
+ if (+cell.y + this.resolution < extGeo.yMin) continue
51
+ if (+cell.y - this.resolution > extGeo.yMax) continue
52
+ this.cellsViewCache.push(cell)
53
+ }
54
+ }
55
+ }