@mapcatch/util 1.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 (71) hide show
  1. package/.eslintrc.js +53 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGELOG.md +0 -0
  4. package/README.md +44 -0
  5. package/docs/Catolog.md +24 -0
  6. package/docs/Util.md +170 -0
  7. package/package.json +30 -0
  8. package/src/constants/cameras.js +5 -0
  9. package/src/constants/index.js +1 -0
  10. package/src/event.js +205 -0
  11. package/src/exif/exif.js +37 -0
  12. package/src/exif/gps_tags.js +33 -0
  13. package/src/exif/ifd1_tags.js +22 -0
  14. package/src/exif/index.js +16 -0
  15. package/src/exif/iptc_field_map.js +12 -0
  16. package/src/exif/parse_image.js +446 -0
  17. package/src/exif/string_values.js +137 -0
  18. package/src/exif/tags.js +75 -0
  19. package/src/exif/tiff_tags.js +35 -0
  20. package/src/exif/util.js +108 -0
  21. package/src/gl-operations/constants.js +11 -0
  22. package/src/gl-operations/default_options.js +98 -0
  23. package/src/gl-operations/index.js +594 -0
  24. package/src/gl-operations/reglCommands/contours.js +27 -0
  25. package/src/gl-operations/reglCommands/default.js +44 -0
  26. package/src/gl-operations/reglCommands/hillshading.js +332 -0
  27. package/src/gl-operations/reglCommands/index.js +6 -0
  28. package/src/gl-operations/reglCommands/multiLayers.js +301 -0
  29. package/src/gl-operations/reglCommands/transitions.js +109 -0
  30. package/src/gl-operations/reglCommands/util.js +71 -0
  31. package/src/gl-operations/renderer.js +193 -0
  32. package/src/gl-operations/shaders/fragment/convertDem.js +26 -0
  33. package/src/gl-operations/shaders/fragment/convolutionSmooth.js +55 -0
  34. package/src/gl-operations/shaders/fragment/diffCalc.js +34 -0
  35. package/src/gl-operations/shaders/fragment/drawResult.js +42 -0
  36. package/src/gl-operations/shaders/fragment/hillshading/hsAdvAmbientShadows.js +79 -0
  37. package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +55 -0
  38. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalBaselayer.js +31 -0
  39. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +56 -0
  40. package/src/gl-operations/shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js +27 -0
  41. package/src/gl-operations/shaders/fragment/hillshading/hsAdvNormals.js +26 -0
  42. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSmooth.js +54 -0
  43. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSoftShadows.js +81 -0
  44. package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +50 -0
  45. package/src/gl-operations/shaders/fragment/interpolateColor.js +63 -0
  46. package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +47 -0
  47. package/src/gl-operations/shaders/fragment/interpolateValue.js +124 -0
  48. package/src/gl-operations/shaders/fragment/multiAnalyze1Calc.js +36 -0
  49. package/src/gl-operations/shaders/fragment/multiAnalyze2Calc.js +46 -0
  50. package/src/gl-operations/shaders/fragment/multiAnalyze3Calc.js +54 -0
  51. package/src/gl-operations/shaders/fragment/multiAnalyze4Calc.js +62 -0
  52. package/src/gl-operations/shaders/fragment/multiAnalyze5Calc.js +70 -0
  53. package/src/gl-operations/shaders/fragment/multiAnalyze6Calc.js +78 -0
  54. package/src/gl-operations/shaders/fragment/single.js +88 -0
  55. package/src/gl-operations/shaders/transform.js +22 -0
  56. package/src/gl-operations/shaders/util/computeColor.glsl +84 -0
  57. package/src/gl-operations/shaders/util/getTexelValue.glsl +10 -0
  58. package/src/gl-operations/shaders/util/isCloseEnough.glsl +9 -0
  59. package/src/gl-operations/shaders/util/rgbaToFloat.glsl +18 -0
  60. package/src/gl-operations/shaders/vertex/double.js +17 -0
  61. package/src/gl-operations/shaders/vertex/multi3.js +20 -0
  62. package/src/gl-operations/shaders/vertex/multi4.js +23 -0
  63. package/src/gl-operations/shaders/vertex/multi5.js +26 -0
  64. package/src/gl-operations/shaders/vertex/multi6.js +29 -0
  65. package/src/gl-operations/shaders/vertex/single.js +13 -0
  66. package/src/gl-operations/shaders/vertex/singleNotTransformed.js +12 -0
  67. package/src/gl-operations/texture_manager.js +141 -0
  68. package/src/gl-operations/util.js +336 -0
  69. package/src/index.js +10 -0
  70. package/src/util.js +332 -0
  71. package/vite.config.js +52 -0
@@ -0,0 +1,332 @@
1
+ import vertSingle from '../shaders/vertex/single.js';
2
+ import vertDouble from '../shaders/vertex/double.js';
3
+ import vertSingleNotTransformed from '../shaders/vertex/singleNotTransformed.js';
4
+
5
+ import fragSingle from '../shaders/fragment/single.js';
6
+ import fragHsPregen from '../shaders/fragment/hillshading/hsPregen.js';
7
+ import fragHsAdvMergeAndScaleTiles from '../shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js';
8
+ import fragHsAdvNormals from '../shaders/fragment/hillshading/hsAdvNormals.js';
9
+ import fragHsAdvDirectLight from '../shaders/fragment/hillshading/hsAdvDirect.js';
10
+ import fragHsAdvSoftShadows from '../shaders/fragment/hillshading/hsAdvSoftShadows.js';
11
+ import fragHsAdvAmbientShadows from '../shaders/fragment/hillshading/hsAdvAmbientShadows.js';
12
+ import fragHsAdvFinalColorscale from '../shaders/fragment/hillshading/hsAdvFinalColorscale.js';
13
+ import fragHsAdvFinalBaselayer from '../shaders/fragment/hillshading/hsAdvFinalBaselayer.js';
14
+ import fragHsAdvSmooth from '../shaders/fragment/hillshading/hsAdvSmooth.js';
15
+
16
+ import {
17
+ DEG2RAD,
18
+ SLOPEFACTOR,
19
+ } from '../constants';
20
+
21
+ import * as util from '../util';
22
+
23
+ const littleEndian = util.machineIsLittleEndian();
24
+
25
+ /**
26
+ * The resulting Regl DrawCommand is used to draw a single tile. The fragment shader decodes the
27
+ * Float32 value of a pixel and colorizes it with the given color scale (and/or sentinel values).
28
+ * Hillshading is applied with a simple and fast algorithm
29
+ */
30
+ export function createDrawTileHsSimpleCommand(regl, commonConfig, fragMacros) {
31
+ return regl({
32
+ ...commonConfig,
33
+ vert: vertSingle,
34
+ frag: util.defineMacros(fragSingle, fragMacros),
35
+ uniforms: {
36
+ ...commonConfig.uniforms,
37
+ scaleLength: regl.prop('scaleLength'),
38
+ sentinelLength: regl.prop('sentinelLength'),
39
+ scaleColormap: regl.prop('scaleColormap'),
40
+ sentinelColormap: regl.prop('sentinelColormap'),
41
+ texture: (_, { texture }) => texture,
42
+ enableSimpleHillshade: (_, { enableSimpleHillshade }) => enableSimpleHillshade,
43
+ azimuth: (_, { azimuth }) => azimuth,
44
+ altitude: (_, { altitude }) => altitude,
45
+ slopescale: (_, { slopescale }) => slopescale,
46
+ deg2rad: DEG2RAD,
47
+ slopeFactor: SLOPEFACTOR,
48
+ offset: (_, { offset }) => offset,
49
+ textureBounds: (_, { textureBounds }) => {
50
+ return [
51
+ [textureBounds[0].x],
52
+ [textureBounds[0].y],
53
+ [textureBounds[1].x],
54
+ [textureBounds[1].y]
55
+ ];
56
+ },
57
+ textureSize: (_, { textureSize }) => textureSize,
58
+ tileSize: (_, { tileSize }) => tileSize,
59
+ },
60
+ attributes: {
61
+ ...commonConfig.attributes,
62
+ texCoord: (_, { textureBounds }) => util.getTexCoordVerticesTriangleStripQuad(textureBounds),
63
+ },
64
+ });
65
+ }
66
+
67
+ /**
68
+ * The resulting Regl DrawCommand is used to draw a single tile. The fragment shader decodes the
69
+ * Float32 value of a pixel and colorizes it with the given color scale (and/or sentinel values).
70
+ * Hillshading is applied from a pre-generated texture
71
+ */
72
+ export function createDrawTileHsPregenCommand(regl, commonConfig, fragMacros) {
73
+ return regl({
74
+ ...commonConfig,
75
+ vert: vertDouble,
76
+ frag: util.defineMacros(fragHsPregen, fragMacros),
77
+ uniforms: {
78
+ ...commonConfig.uniforms,
79
+ scaleLength: regl.prop('scaleLength'),
80
+ sentinelLength: regl.prop('sentinelLength'),
81
+ scaleColormap: regl.prop('scaleColormap'),
82
+ sentinelColormap: regl.prop('sentinelColormap'),
83
+ texture: (_, { texture }) => texture,
84
+ hillshadePregenTexture: (_, { hillshadePregenTexture }) => hillshadePregenTexture,
85
+ },
86
+ attributes: {
87
+ ...commonConfig.attributes,
88
+ texCoordA: (_, { textureBounds }) => util.getTexCoordVerticesTriangleStripQuad(textureBounds),
89
+ texCoordB: (_, { textureBoundsHs }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsHs),
90
+ },
91
+ });
92
+ }
93
+
94
+
95
+ /**
96
+ * The resulting Regl DrawCommand is used to get the float values from the 3x3
97
+ * adjacent tiles. The float values can be scaled to adjust the hillshading.
98
+ * It will be saved to a framebuffer and is used as an input to advanced hillshading
99
+ */
100
+ export function createHsAdvMergeAndScaleTiles(regl) {
101
+ return regl({
102
+ vert: vertSingleNotTransformed,
103
+ frag: fragHsAdvMergeAndScaleTiles,
104
+ uniforms: {
105
+ littleEndian: littleEndian,
106
+ nodataValue: regl.prop("nodataValue"),
107
+ texture: regl.prop("texture"),
108
+ floatScale: regl.prop("floatScale"),
109
+ },
110
+ attributes: {
111
+ // 18 triangles = 9 tiles
112
+ position: [
113
+ [-1, 1], [-1/3, 1], [-1, 1/3], [-1/3, 1/3], [-1/3, 1], [-1, 1/3],
114
+ [-1, 1/3], [-1/3, 1/3], [-1, -1/3], [-1/3, -1/3], [-1/3, 1/3], [-1, -1/3],
115
+ [-1, -1/3], [-1/3, -1/3], [-1, -1], [-1/3, -1], [-1/3, -1/3], [-1, -1],
116
+ [-1/3, 1], [1/3, 1], [-1/3, 1/3], [1/3, 1/3], [1/3, 1], [-1/3, 1/3],
117
+ [-1/3, 1/3], [1/3, 1/3], [-1/3, -1/3], [1/3, -1/3], [1/3, 1/3], [-1/3, -1/3],
118
+ [-1/3, -1/3], [1/3, -1/3], [-1/3, -1], [1/3, -1], [1/3, -1/3], [-1/3, -1],
119
+ [1/3, 1], [1, 1], [1/3, 1/3], [1, 1/3], [1, 1], [1/3, 1/3],
120
+ [1/3, 1/3], [1, 1/3], [1/3, -1/3], [1, -1/3], [1, 1/3], [1/3, -1/3],
121
+ [1/3, -1/3], [1, -1/3], [1/3, -1], [1, -1], [1, -1/3], [1/3, -1]
122
+ ],
123
+ texCoord: regl.prop("texCoord"),
124
+ },
125
+ depth: { enable: false },
126
+ primitive: 'triangles',
127
+ count: 54,
128
+ viewport: (_, { canvasSize: [width, height] }) => ({ width, height }),
129
+ framebuffer: regl.prop("fbo"),
130
+ });
131
+ }
132
+
133
+
134
+ /**
135
+ * The resulting Regl DrawCommand is for using a convolution kernel to smooth the input data.
136
+ * Currently hard-coded the kernel and positions in the shader to reduce number of uniforms.
137
+ * TODO: Merge with contours function
138
+ */
139
+ export function createHsAdvSmoothCommand(regl, commonConfig) {
140
+ return regl({
141
+ ...commonConfig,
142
+ vert: vertSingleNotTransformed,
143
+ frag: fragHsAdvSmooth,
144
+ uniforms: {
145
+ ...commonConfig.uniforms,
146
+ tInput: regl.prop("tInput"),
147
+ textureSize: regl.prop("textureSize"),
148
+ kernelSize: regl.prop("kernelSize"),
149
+ },
150
+ attributes: {
151
+ position: [[-1, 1], [1, 1], [-1, -1], [1, -1]],
152
+ texCoord: [[0, 1], [1, 1], [0, 0], [1, 0]],
153
+ },
154
+ framebuffer: regl.prop("fbo"),
155
+ });
156
+ }
157
+
158
+
159
+ /**
160
+ * The resulting Regl DrawCommand is used to calculate the normals.
161
+ * It is used as an input to advanced hillshading
162
+ */
163
+ export function createHsAdvCalcNormals(
164
+ regl,
165
+ commonConfig,
166
+ ) {
167
+ return regl({
168
+ ...commonConfig,
169
+ vert: vertSingleNotTransformed,
170
+ frag: fragHsAdvNormals,
171
+ uniforms: {
172
+ ...commonConfig.uniforms,
173
+ tInput: regl.prop("tInput"),
174
+ pixelScale: regl.prop("pixelScale"),
175
+ onePixel: regl.prop("onePixel"),
176
+ },
177
+ attributes: {
178
+ position: [[-1, 1], [1, 1], [-1, -1], [1, -1]],
179
+ texCoord: [[0, 1], [1, 1], [0, 0], [1, 0]],
180
+ },
181
+ framebuffer: regl.prop("fbo"),
182
+ });
183
+ }
184
+
185
+ /**
186
+ * The resulting Regl DrawCommand is used to show hillshading without shadows.
187
+ * Not currently used
188
+ */
189
+ export function createHsAdvDirectLightning(
190
+ regl,
191
+ commonConfig,
192
+ ) {
193
+ return regl({
194
+ ...commonConfig,
195
+ vert: vertSingleNotTransformed,
196
+ frag: fragHsAdvDirectLight,
197
+ uniforms: {
198
+ ...commonConfig.uniforms,
199
+ scaleLength: regl.prop('scaleLength'),
200
+ sentinelLength: regl.prop('sentinelLength'),
201
+ scaleColormap: regl.prop('scaleColormap'),
202
+ sentinelColormap: regl.prop('sentinelColormap'),
203
+ tInput: regl.prop("tInput"),
204
+ tNormal: regl.prop("tNormal"),
205
+ floatScale: regl.prop("floatScale"),
206
+ sunDirection: regl.prop("sunDirection"),
207
+ },
208
+ attributes: {
209
+ position: [[-1, 1], [1, 1], [-1, -1], [1, -1]],
210
+ texCoord: [[0, 1], [1, 1], [0, 0], [1, 0]],
211
+ },
212
+ });
213
+ }
214
+
215
+ /**
216
+ * The resulting Regl DrawCommand is used to calculate soft shadows.
217
+ */
218
+ export function createHsAdvSoftShadows(
219
+ regl,
220
+ commonConfig,
221
+ ) {
222
+ return regl({
223
+ ...commonConfig,
224
+ vert: vertSingleNotTransformed,
225
+ frag: fragHsAdvSoftShadows,
226
+ uniforms: {
227
+ ...commonConfig.uniforms,
228
+ tInput: regl.prop("tInput"),
229
+ tNormal: regl.prop("tNormal"),
230
+ tSrc: regl.prop("tSrc"),
231
+ softIterations: regl.prop("softIterations"),
232
+ pixelScale: regl.prop("pixelScale"),
233
+ resolution: regl.prop("resolution"),
234
+ sunDirection: regl.prop("sunDirection"),
235
+ },
236
+ attributes: {
237
+ position: [[-1, 1], [1, 1], [-1, -1], [1, -1]],
238
+ texCoord: [[1/3, 2/3], [2/3, 2/3], [1/3, 1/3], [2/3, 1/3]],
239
+ },
240
+ framebuffer: regl.prop("fbo"),
241
+ });
242
+ }
243
+
244
+ /**
245
+ * The resulting Regl DrawCommand is used to calculate ambient lighting.
246
+ */
247
+ export function createHsAdvAmbientShadows(
248
+ regl,
249
+ commonConfig,
250
+ ) {
251
+ return regl({
252
+ ...commonConfig,
253
+ vert: vertSingleNotTransformed,
254
+ frag: fragHsAdvAmbientShadows,
255
+ uniforms: {
256
+ ...commonConfig.uniforms,
257
+ tInput: regl.prop("tInput"),
258
+ tNormal: regl.prop("tNormal"),
259
+ tSrc: regl.prop("tSrc"),
260
+ ambientIterations: regl.prop("ambientIterations"),
261
+ pixelScale: regl.prop("pixelScale"),
262
+ resolution: regl.prop("resolution"),
263
+ direction: regl.prop("direction"),
264
+ },
265
+ attributes: {
266
+ position: [[-1, 1], [1, 1], [-1, -1], [1, -1]],
267
+ texCoord: [[1/3, 2/3], [2/3, 2/3], [1/3, 1/3], [2/3, 1/3]],
268
+ },
269
+ framebuffer: regl.prop("fbo"),
270
+ });
271
+ }
272
+
273
+ /**
274
+ * The resulting Regl DrawCommand is used to combine soft and ambient shading,
275
+ * use the colormap on the input floats and apply the hillshading.
276
+ */
277
+ export function createHsAdvFinalColorscale(
278
+ regl,
279
+ commonConfig,
280
+ ) {
281
+ return regl({
282
+ ...commonConfig,
283
+ vert: vertDouble,
284
+ frag: fragHsAdvFinalColorscale,
285
+ uniforms: {
286
+ ...commonConfig.uniforms,
287
+ scaleLength: regl.prop('scaleLength'),
288
+ sentinelLength: regl.prop('sentinelLength'),
289
+ scaleColormap: regl.prop('scaleColormap'),
290
+ sentinelColormap: regl.prop('sentinelColormap'),
291
+ tInput: regl.prop("tInput"),
292
+ tSoftShadow: regl.prop("tSoftShadow"),
293
+ tAmbient: regl.prop("tAmbient"),
294
+ floatScale: regl.prop("floatScale"),
295
+ finalSoftMultiplier: regl.prop("finalSoftMultiplier"),
296
+ finalAmbientMultiplier: regl.prop("finalAmbientMultiplier"),
297
+ },
298
+ attributes: {
299
+ ...commonConfig.attributes,
300
+ texCoordA: [[1/3, 2/3], [2/3, 2/3], [1/3, 1/3], [2/3, 1/3]],
301
+ texCoordB: [[0, 1], [1, 1], [0, 0], [1, 0]],
302
+ },
303
+ });
304
+ }
305
+
306
+ /**
307
+ * The resulting Regl DrawCommand is used to combine soft and ambient shading,
308
+ * use the baselayer tile and apply the hillshading.
309
+ */
310
+ export function createHsAdvFinalBaselayer(
311
+ regl,
312
+ commonConfig,
313
+ ) {
314
+ return regl({
315
+ ...commonConfig,
316
+ vert: vertDouble,
317
+ frag: fragHsAdvFinalBaselayer,
318
+ uniforms: {
319
+ ...commonConfig.uniforms,
320
+ tBase: regl.prop("tBase"),
321
+ tSoftShadow: regl.prop("tSoftShadow"),
322
+ tAmbient: regl.prop("tAmbient"),
323
+ finalSoftMultiplier: regl.prop("finalSoftMultiplier"),
324
+ finalAmbientMultiplier: regl.prop("finalAmbientMultiplier"),
325
+ },
326
+ attributes: {
327
+ ...commonConfig.attributes,
328
+ texCoordA: regl.prop("baseTexCoords"),
329
+ texCoordB: [[0, 1], [1, 1], [0, 0], [1, 0]],
330
+ },
331
+ });
332
+ }
@@ -0,0 +1,6 @@
1
+ export * from './default';
2
+ export * from './hillshading';
3
+ export * from './transitions';
4
+ export * from './contours';
5
+ export * from './multiLayers';
6
+ export * from './util';
@@ -0,0 +1,301 @@
1
+ import vertSingle from '../shaders/vertex/single.js';
2
+ import vertDouble from '../shaders/vertex/double.js';
3
+ import vertMulti3 from '../shaders/vertex/multi3.js';
4
+ import vertMulti4 from '../shaders/vertex/multi4.js';
5
+ import vertMulti5 from '../shaders/vertex/multi5.js';
6
+ import vertMulti6 from '../shaders/vertex/multi6.js';
7
+
8
+ import fragMulti1Calc from '../shaders/fragment/multiAnalyze1Calc.js';
9
+ import fragMulti2Calc from '../shaders/fragment/multiAnalyze2Calc.js';
10
+ import fragMulti3Calc from '../shaders/fragment/multiAnalyze3Calc.js';
11
+ import fragMulti4Calc from '../shaders/fragment/multiAnalyze4Calc.js';
12
+ import fragMulti5Calc from '../shaders/fragment/multiAnalyze5Calc.js';
13
+ import fragMulti6Calc from '../shaders/fragment/multiAnalyze6Calc.js';
14
+ import fragDiffCalc from '../shaders/fragment/diffCalc.js';
15
+ import fragDrawResult from '../shaders/fragment/drawResult.js';
16
+
17
+ import * as util from '../util';
18
+
19
+
20
+ export function createCalcTileMultiAnalyze1Command(
21
+ regl,
22
+ commonConfig
23
+ ) {
24
+ return regl({
25
+ ...commonConfig,
26
+ vert: vertSingle,
27
+ frag: fragMulti1Calc,
28
+ depth: {
29
+ enable: false
30
+ },
31
+ uniforms: {
32
+ ...commonConfig.uniforms,
33
+ filterLowA: (_, { filterLowA }) => filterLowA,
34
+ filterHighA: (_, { filterHighA }) => filterHighA,
35
+ multiplierA: (_, { multiplierA }) => multiplierA,
36
+ textureA: (_, { textureA }) => textureA,
37
+ },
38
+ attributes: {
39
+ ...commonConfig.attributes,
40
+ texCoord: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
41
+ },
42
+ framebuffer: regl.prop("fbo"),
43
+ });
44
+ }
45
+
46
+ export function createCalcTileMultiAnalyze2Command(
47
+ regl,
48
+ commonConfig
49
+ ) {
50
+ return regl({
51
+ ...commonConfig,
52
+ vert: vertDouble,
53
+ frag: fragMulti2Calc,
54
+ depth: {
55
+ enable: false
56
+ },
57
+ uniforms: {
58
+ ...commonConfig.uniforms,
59
+ filterLowA: (_, { filterLowA }) => filterLowA,
60
+ filterHighA: (_, { filterHighA }) => filterHighA,
61
+ filterLowB: (_, { filterLowB }) => filterLowB,
62
+ filterHighB: (_, { filterHighB }) => filterHighB,
63
+ multiplierA: (_, { multiplierA }) => multiplierA,
64
+ multiplierB: (_, { multiplierB }) => multiplierB,
65
+ textureA: (_, { textureA }) => textureA,
66
+ textureB: (_, { textureB }) => textureB,
67
+ },
68
+ attributes: {
69
+ ...commonConfig.attributes,
70
+ texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
71
+ texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB),
72
+ },
73
+ framebuffer: regl.prop("fbo"),
74
+ });
75
+ }
76
+
77
+ export function createCalcTileMultiAnalyze3Command(
78
+ regl,
79
+ commonConfig
80
+ ) {
81
+ return regl({
82
+ ...commonConfig,
83
+ vert: vertMulti3,
84
+ frag: fragMulti3Calc,
85
+ depth: {
86
+ enable: false
87
+ },
88
+ uniforms: {
89
+ ...commonConfig.uniforms,
90
+ filterLowA: (_, { filterLowA }) => filterLowA,
91
+ filterHighA: (_, { filterHighA }) => filterHighA,
92
+ filterLowB: (_, { filterLowB }) => filterLowB,
93
+ filterHighB: (_, { filterHighB }) => filterHighB,
94
+ filterLowC: (_, { filterLowC }) => filterLowC,
95
+ filterHighC: (_, { filterHighC }) => filterHighC,
96
+ multiplierA: (_, { multiplierA }) => multiplierA,
97
+ multiplierB: (_, { multiplierB }) => multiplierB,
98
+ multiplierC: (_, { multiplierC }) => multiplierC,
99
+ textureA: (_, { textureA }) => textureA,
100
+ textureB: (_, { textureB }) => textureB,
101
+ textureC: (_, { textureC }) => textureC,
102
+ },
103
+ attributes: {
104
+ ...commonConfig.attributes,
105
+ texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
106
+ texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB),
107
+ texCoordC: (_, { textureBoundsC }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsC),
108
+ },
109
+ framebuffer: regl.prop("fbo"),
110
+ });
111
+ }
112
+
113
+ export function createCalcTileMultiAnalyze4Command(
114
+ regl,
115
+ commonConfig
116
+ ) {
117
+ return regl({
118
+ ...commonConfig,
119
+ vert: vertMulti4,
120
+ frag: fragMulti4Calc,
121
+ depth: {
122
+ enable: false
123
+ },
124
+ uniforms: {
125
+ ...commonConfig.uniforms,
126
+ filterLowA: (_, { filterLowA }) => filterLowA,
127
+ filterHighA: (_, { filterHighA }) => filterHighA,
128
+ filterLowB: (_, { filterLowB }) => filterLowB,
129
+ filterHighB: (_, { filterHighB }) => filterHighB,
130
+ filterLowC: (_, { filterLowC }) => filterLowC,
131
+ filterHighC: (_, { filterHighC }) => filterHighC,
132
+ filterLowD: (_, { filterLowD }) => filterLowD,
133
+ filterHighD: (_, { filterHighD }) => filterHighD,
134
+ multiplierA: (_, { multiplierA }) => multiplierA,
135
+ multiplierB: (_, { multiplierB }) => multiplierB,
136
+ multiplierC: (_, { multiplierC }) => multiplierC,
137
+ multiplierD: (_, { multiplierD }) => multiplierD,
138
+ textureA: (_, { textureA }) => textureA,
139
+ textureB: (_, { textureB }) => textureB,
140
+ textureC: (_, { textureC }) => textureC,
141
+ textureD: (_, { textureD }) => textureD,
142
+ },
143
+ attributes: {
144
+ ...commonConfig.attributes,
145
+ texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
146
+ texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB),
147
+ texCoordC: (_, { textureBoundsC }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsC),
148
+ texCoordD: (_, { textureBoundsD }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsD),
149
+ },
150
+ framebuffer: regl.prop("fbo"),
151
+ });
152
+ }
153
+
154
+ export function createCalcTileMultiAnalyze5Command(
155
+ regl,
156
+ commonConfig
157
+ ) {
158
+ return regl({
159
+ ...commonConfig,
160
+ vert: vertMulti5,
161
+ frag: fragMulti5Calc,
162
+ depth: {
163
+ enable: false
164
+ },
165
+ uniforms: {
166
+ ...commonConfig.uniforms,
167
+ filterLowA: (_, { filterLowA }) => filterLowA,
168
+ filterHighA: (_, { filterHighA }) => filterHighA,
169
+ filterLowB: (_, { filterLowB }) => filterLowB,
170
+ filterHighB: (_, { filterHighB }) => filterHighB,
171
+ filterLowC: (_, { filterLowC }) => filterLowC,
172
+ filterHighC: (_, { filterHighC }) => filterHighC,
173
+ filterLowD: (_, { filterLowD }) => filterLowD,
174
+ filterHighD: (_, { filterHighD }) => filterHighD,
175
+ filterLowE: (_, { filterLowE }) => filterLowE,
176
+ filterHighE: (_, { filterHighE }) => filterHighE,
177
+ multiplierA: (_, { multiplierA }) => multiplierA,
178
+ multiplierB: (_, { multiplierB }) => multiplierB,
179
+ multiplierC: (_, { multiplierC }) => multiplierC,
180
+ multiplierD: (_, { multiplierD }) => multiplierD,
181
+ multiplierE: (_, { multiplierE }) => multiplierE,
182
+ textureA: (_, { textureA }) => textureA,
183
+ textureB: (_, { textureB }) => textureB,
184
+ textureC: (_, { textureC }) => textureC,
185
+ textureD: (_, { textureD }) => textureD,
186
+ textureE: (_, { textureE }) => textureE,
187
+ },
188
+ attributes: {
189
+ ...commonConfig.attributes,
190
+ texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
191
+ texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB),
192
+ texCoordC: (_, { textureBoundsC }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsC),
193
+ texCoordD: (_, { textureBoundsD }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsD),
194
+ texCoordE: (_, { textureBoundsE }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsE),
195
+ },
196
+ framebuffer: regl.prop("fbo"),
197
+ });
198
+ }
199
+
200
+ export function createCalcTileMultiAnalyze6Command(
201
+ regl,
202
+ commonConfig
203
+ ) {
204
+ return regl({
205
+ ...commonConfig,
206
+ vert: vertMulti6,
207
+ frag: fragMulti6Calc,
208
+ depth: {
209
+ enable: false
210
+ },
211
+ uniforms: {
212
+ ...commonConfig.uniforms,
213
+ filterLowA: (_, { filterLowA }) => filterLowA,
214
+ filterHighA: (_, { filterHighA }) => filterHighA,
215
+ filterLowB: (_, { filterLowB }) => filterLowB,
216
+ filterHighB: (_, { filterHighB }) => filterHighB,
217
+ filterLowC: (_, { filterLowC }) => filterLowC,
218
+ filterHighC: (_, { filterHighC }) => filterHighC,
219
+ filterLowD: (_, { filterLowD }) => filterLowD,
220
+ filterHighD: (_, { filterHighD }) => filterHighD,
221
+ filterLowE: (_, { filterLowE }) => filterLowE,
222
+ filterHighE: (_, { filterHighE }) => filterHighE,
223
+ filterLowF: (_, { filterLowF }) => filterLowF,
224
+ filterHighF: (_, { filterHighF }) => filterHighF,
225
+ multiplierA: (_, { multiplierA }) => multiplierA,
226
+ multiplierB: (_, { multiplierB }) => multiplierB,
227
+ multiplierC: (_, { multiplierC }) => multiplierC,
228
+ multiplierD: (_, { multiplierD }) => multiplierD,
229
+ multiplierE: (_, { multiplierE }) => multiplierE,
230
+ multiplierF: (_, { multiplierF }) => multiplierF,
231
+ textureA: (_, { textureA }) => textureA,
232
+ textureB: (_, { textureB }) => textureB,
233
+ textureC: (_, { textureC }) => textureC,
234
+ textureD: (_, { textureD }) => textureD,
235
+ textureE: (_, { textureE }) => textureE,
236
+ textureF: (_, { textureF }) => textureF,
237
+ },
238
+ attributes: {
239
+ ...commonConfig.attributes,
240
+ texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
241
+ texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB),
242
+ texCoordC: (_, { textureBoundsC }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsC),
243
+ texCoordD: (_, { textureBoundsD }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsD),
244
+ texCoordE: (_, { textureBoundsE }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsE),
245
+ texCoordF: (_, { textureBoundsF }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsF)
246
+ },
247
+ framebuffer: regl.prop("fbo"),
248
+ });
249
+ }
250
+
251
+ export function createCalcTileDiffCommand(
252
+ regl,
253
+ commonConfig
254
+ ) {
255
+ return regl({
256
+ ...commonConfig,
257
+ vert: vertDouble,
258
+ frag: fragDiffCalc,
259
+ depth: {
260
+ enable: false
261
+ },
262
+ uniforms: {
263
+ ...commonConfig.uniforms,
264
+ textureA: (_, { textureA }) => textureA,
265
+ textureB: (_, { textureB }) => textureB,
266
+ },
267
+ attributes: {
268
+ ...commonConfig.attributes,
269
+ texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
270
+ texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB),
271
+ },
272
+ framebuffer: regl.prop("fbo"),
273
+ });
274
+ }
275
+
276
+ export function createDrawResultCommand(
277
+ regl,
278
+ commonConfig,
279
+ fragMacros,
280
+ ) {
281
+ return regl({
282
+ ...commonConfig,
283
+ vert: vertSingle,
284
+ frag: util.defineMacros(fragDrawResult, fragMacros),
285
+ depth: {
286
+ enable: false
287
+ },
288
+ uniforms: {
289
+ ...commonConfig.uniforms,
290
+ scaleLength: regl.prop('scaleLength'),
291
+ sentinelLength: regl.prop('sentinelLength'),
292
+ scaleColormap: regl.prop('scaleColormap'),
293
+ sentinelColormap: regl.prop('sentinelColormap'),
294
+ texture: regl.prop("texture"),
295
+ },
296
+ attributes: {
297
+ ...commonConfig.attributes,
298
+ texCoord: [[0, 1], [1, 1], [0, 0], [1, 0]],
299
+ },
300
+ });
301
+ }