@mapcatch/util 1.0.15-a → 2.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/dist/catchUtil.min.esm.js +67981 -14008
- package/dist/catchUtil.min.js +2695 -55
- package/package.json +22 -3
- package/src/constants/annotation_color.js +7 -0
- package/src/constants/annotation_draw_style.js +228 -0
- package/src/constants/annotation_label_style.js +76 -0
- package/src/constants/annotation_style.js +118 -0
- package/src/constants/cameras.js +1 -1
- package/src/constants/crs.js +31473 -31473
- package/src/constants/error_codes.js +44 -0
- package/src/constants/height_colors.js +1 -0
- package/src/constants/index.js +9 -2
- package/src/constants/map_style.js +11 -0
- package/src/{event.js → event/event.js} +1 -14
- package/src/event/event_bus.js +5 -0
- package/src/event/index.js +2 -0
- package/src/gl-operations/constants.js +9 -11
- package/src/gl-operations/default_options.js +5 -5
- package/src/gl-operations/index.js +166 -239
- package/src/gl-operations/reglCommands/contours.js +20 -20
- package/src/gl-operations/reglCommands/default.js +34 -34
- package/src/gl-operations/reglCommands/hillshading.js +116 -116
- package/src/gl-operations/reglCommands/index.js +6 -6
- package/src/gl-operations/reglCommands/multiLayers.js +55 -55
- package/src/gl-operations/reglCommands/transitions.js +24 -24
- package/src/gl-operations/reglCommands/util.js +54 -54
- package/src/gl-operations/renderer.js +69 -69
- package/src/gl-operations/shaders/transform.js +2 -2
- package/src/gl-operations/shaders/util/rgbaToFloat.glsl +11 -11
- package/src/gl-operations/texture_manager.js +58 -58
- package/src/gl-operations/util.js +154 -154
- package/src/index.js +14 -2
- package/src/measure/index.js +198 -0
- package/src/measure/tile_cache.js +88 -0
- package/src/mvs/index.js +26 -0
- package/src/mvs/protos/index.js +12 -0
- package/src/mvs/protos/proto_10.js +155 -0
- package/src/observation_pretict.js +168 -0
- package/src/photo-parser/exif/gps_tags.js +33 -0
- package/src/photo-parser/exif/ifd1_tags.js +22 -0
- package/src/photo-parser/exif/index.js +130 -0
- package/src/photo-parser/exif/parse_image.js +290 -0
- package/src/photo-parser/exif/string_values.js +137 -0
- package/src/photo-parser/exif/tags.js +75 -0
- package/src/photo-parser/exif/tiff_tags.js +35 -0
- package/src/photo-parser/exif/util.js +103 -0
- package/src/photo-parser/image-size/detector.js +24 -0
- package/src/photo-parser/image-size/fromFile.js +55 -0
- package/src/photo-parser/image-size/index.js +2 -0
- package/src/photo-parser/image-size/lookup.js +37 -0
- package/src/photo-parser/image-size/types/bmp.js +10 -0
- package/src/photo-parser/image-size/types/cur.js +16 -0
- package/src/photo-parser/image-size/types/dds.js +10 -0
- package/src/photo-parser/image-size/types/gif.js +11 -0
- package/src/photo-parser/image-size/types/heif.js +35 -0
- package/src/photo-parser/image-size/types/icns.js +112 -0
- package/src/photo-parser/image-size/types/ico.js +74 -0
- package/src/photo-parser/image-size/types/index.js +43 -0
- package/src/photo-parser/image-size/types/j2c.js +11 -0
- package/src/photo-parser/image-size/types/jp2.js +22 -0
- package/src/photo-parser/image-size/types/jpg.js +157 -0
- package/src/photo-parser/image-size/types/ktx.js +18 -0
- package/src/photo-parser/image-size/types/png.js +36 -0
- package/src/photo-parser/image-size/types/pnm.js +74 -0
- package/src/photo-parser/image-size/types/psd.js +10 -0
- package/src/photo-parser/image-size/types/svg.js +100 -0
- package/src/photo-parser/image-size/types/tga.js +14 -0
- package/src/photo-parser/image-size/types/tiff.js +92 -0
- package/src/photo-parser/image-size/types/utils.js +83 -0
- package/src/photo-parser/image-size/types/webp.js +67 -0
- package/src/photo-parser/index.js +181 -0
- package/src/report/annotations_report.js +446 -0
- package/src/report/index.js +2 -0
- package/src/report/map_util.js +81 -0
- package/src/report/pdf_creator.js +247 -0
- package/src/report/report.js +583 -0
- package/src/transform.js +204 -0
- package/src/util.js +371 -75
- package/CHANGELOG.md +0 -60
- /package/src/constants/{colors.js → dsm_colors.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import defaultOptions from
|
|
1
|
+
import defaultOptions from './default_options'
|
|
2
2
|
import * as util from './util'
|
|
3
|
-
import Renderer from
|
|
4
|
-
import { EARTH_CIRCUMFERENCE } from './constants'
|
|
3
|
+
import Renderer from './renderer'
|
|
4
|
+
import { EARTH_CIRCUMFERENCE } from './constants'
|
|
5
5
|
|
|
6
6
|
export default class GLOperations {
|
|
7
|
-
constructor(options) {
|
|
7
|
+
constructor (options) {
|
|
8
8
|
this.options = Object.assign({}, defaultOptions, options)
|
|
9
|
-
this._checkColorScaleAndSentinels()
|
|
10
|
-
this.setHillshadeOptions()
|
|
9
|
+
this._checkColorScaleAndSentinels()
|
|
10
|
+
this.setHillshadeOptions()
|
|
11
11
|
const {
|
|
12
12
|
nodataValue,
|
|
13
13
|
tileSize
|
|
14
|
-
} = this.options
|
|
14
|
+
} = this.options
|
|
15
15
|
|
|
16
16
|
this._renderer = new Renderer(
|
|
17
17
|
this,
|
|
@@ -21,91 +21,36 @@ export default class GLOperations {
|
|
|
21
21
|
this.options.sentinelValues,
|
|
22
22
|
this.options.colorscaleMaxLength,
|
|
23
23
|
this.options.sentinelMaxLength
|
|
24
|
-
)
|
|
24
|
+
)
|
|
25
25
|
|
|
26
|
-
this._renderer.generateAmbientDirections(this.options.hsAdvAmbientIterations)
|
|
26
|
+
this._renderer.generateAmbientDirections(this.options.hsAdvAmbientIterations)
|
|
27
27
|
this._renderer.generateSunDirections(
|
|
28
28
|
this.options.hsAdvSoftIterations,
|
|
29
29
|
this.options.hsAdvSunRadiusMultiplier
|
|
30
|
-
)
|
|
30
|
+
)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
updateOptions(options) {
|
|
33
|
+
updateOptions (options) {
|
|
34
34
|
const {
|
|
35
35
|
url: prevUrl,
|
|
36
|
-
glOperation: prevGlOperation,
|
|
37
36
|
operationUrlA: prevUrlA,
|
|
38
37
|
operationUrlB: prevUrlB,
|
|
39
38
|
operationUrlC: prevUrlC,
|
|
40
39
|
operationUrlD: prevUrlD,
|
|
41
|
-
operationUrlE: prevUrlE,
|
|
42
|
-
operationUrlF: prevUrlF,
|
|
43
40
|
colorScale: prevColorScale,
|
|
44
41
|
sentinelValues: prevSentinelValues,
|
|
45
|
-
filterLowA: prevFilterLowA,
|
|
46
|
-
filterHighA: prevFilterHighA,
|
|
47
|
-
filterLowB: prevFilterLowB,
|
|
48
|
-
filterHighB: prevFilterHighB,
|
|
49
|
-
filterLowC: prevFilterLowC,
|
|
50
|
-
filterHighC: prevFilterHighC,
|
|
51
|
-
filterLowD: prevFilterLowD,
|
|
52
|
-
filterHighD: prevFilterHighD,
|
|
53
|
-
filterLowE: prevFilterLowE,
|
|
54
|
-
filterHighE: prevFilterHighE,
|
|
55
|
-
filterLowF: prevFilterLowF,
|
|
56
|
-
filterHighF: prevFilterHighF,
|
|
57
|
-
multiplierA: prevMultiplierA,
|
|
58
|
-
multiplierB: prevMultiplierB,
|
|
59
|
-
multiplierC: prevMultiplierC,
|
|
60
|
-
multiplierD: prevMultiplierD,
|
|
61
|
-
multiplierE: prevMultiplierE,
|
|
62
|
-
multiplierF: prevMultiplierF,
|
|
63
|
-
multiLayers: prevMultiLayers,
|
|
64
|
-
hsPregenUrl: prevHsPregenUrl,
|
|
65
42
|
hillshadeType: prevHillshadeType,
|
|
66
|
-
hsAdvValueScale: prevHsAdvValueScale,
|
|
67
|
-
hsAdvPixelScale: prevHsAdvPixelScale,
|
|
68
|
-
hsSimpleSlopescale: prevHsSimpleSlopescale,
|
|
69
|
-
hsSimpleAzimuth: prevHsSimpleAzimuth,
|
|
70
|
-
hsSimpleAltitude: prevHsSimpleAltitude,
|
|
71
43
|
hsAdvSoftIterations: prevHsAdvSoftIterations,
|
|
72
44
|
hsAdvAmbientIterations: prevHsAdvAmbientIterations,
|
|
73
45
|
hsAdvSunRadiusMultiplier: prevHsAdvSunRadiusMultiplier,
|
|
74
|
-
hsAdvFinalSoftMultiplier: prevHsAdvFinalSoftMultiplier,
|
|
75
|
-
hsAdvFinalAmbientMultiplier: prevHsAdvFinalAmbientMultiplier,
|
|
76
46
|
hsAdvBaselayerUrl: prevHsAdvBaselayerUrl,
|
|
77
|
-
hsAdvSmoothInput: prevHsAdvSmoothInput,
|
|
78
|
-
hsAdvSmoothInputKernel: prevHsAdvSmoothInputKernel,
|
|
79
|
-
contourInterval: prevContourInterval,
|
|
80
|
-
contourIndexInterval: prevContourIndexInterval,
|
|
81
|
-
contourLineColor: prevContourLineColor,
|
|
82
|
-
contourLineWeight: prevContourLineWeight,
|
|
83
|
-
contourLineIndexWeight: prevContourLineIndexWeight,
|
|
84
|
-
contourType: prevContourType,
|
|
85
|
-
contourSmoothLines: prevContourSmoothLines,
|
|
86
|
-
contourSmoothInput: prevContourSmoothInput,
|
|
87
|
-
contourSmoothInputKernel: prevContourSmoothInputKernel,
|
|
88
|
-
contourIlluminatedHighlightColor: prevContourIlluminatedHighlightColor,
|
|
89
|
-
contourIlluminatedShadowColor: prevContourIlluminatedShadowColor,
|
|
90
|
-
contourIlluminatedShadowSize: prevContourIlluminatedShadowSize,
|
|
91
|
-
contourHypso: prevContourHypso,
|
|
92
|
-
contourHypsoDomain: prevContourHypsoDomain,
|
|
93
|
-
contourHypsoColors: prevContourHypsoColors,
|
|
94
|
-
contourBathy: prevContourBathy,
|
|
95
|
-
contourBathyDomain: prevContourBathyDomain,
|
|
96
|
-
contourBathyColors: prevContourBathyColors,
|
|
97
|
-
contourBathyShadowColor: prevContourBathyShadowColor,
|
|
98
|
-
contourBathyHighlightColor: prevContourBathyHighlightColor,
|
|
99
|
-
contourIndexLabels: prevContourIndexLabels,
|
|
100
|
-
contourLabelFont: prevContourLabelFont,
|
|
101
|
-
contourLabelDistance: prevContourLabelDistance,
|
|
102
47
|
colorscaleMaxLength: prevScaleMaxLength,
|
|
103
|
-
sentinelMaxLength: prevSentinelMaxLength
|
|
104
|
-
} = this.options
|
|
48
|
+
sentinelMaxLength: prevSentinelMaxLength
|
|
49
|
+
} = this.options
|
|
105
50
|
Object.assign(this.options, options)
|
|
106
51
|
// create new renderer if max length of sentinels or colorscale changes
|
|
107
52
|
if (this.options.colorscaleMaxLength !== prevScaleMaxLength || this.options.sentinelMaxLength !== prevSentinelMaxLength) {
|
|
108
|
-
const tileSize = this._tileSizeAsNumber()
|
|
53
|
+
const tileSize = this._tileSizeAsNumber()
|
|
109
54
|
const renderer = new Renderer(
|
|
110
55
|
this,
|
|
111
56
|
tileSize,
|
|
@@ -114,65 +59,64 @@ export default class GLOperations {
|
|
|
114
59
|
this.options.sentinelValues,
|
|
115
60
|
this.options.colorscaleMaxLength,
|
|
116
61
|
this.options.sentinelMaxLength
|
|
117
|
-
)
|
|
62
|
+
)
|
|
118
63
|
|
|
119
|
-
this._renderer.regl.destroy()
|
|
64
|
+
this._renderer.regl.destroy()
|
|
120
65
|
// @ts-ignore
|
|
121
|
-
delete this._renderer
|
|
66
|
+
delete this._renderer
|
|
122
67
|
|
|
123
68
|
Object.assign(this, {
|
|
124
69
|
_renderer: renderer
|
|
125
|
-
})
|
|
70
|
+
})
|
|
126
71
|
}
|
|
127
|
-
this._checkColorScaleAndSentinels()
|
|
72
|
+
this._checkColorScaleAndSentinels()
|
|
128
73
|
if (this.options.colorScale !== prevColorScale) {
|
|
129
|
-
this._renderer.updateColorscale(this.options.colorScale)
|
|
74
|
+
this._renderer.updateColorscale(this.options.colorScale)
|
|
130
75
|
}
|
|
131
76
|
if (this.options.sentinelValues !== prevSentinelValues) {
|
|
132
|
-
this._renderer.updateSentinels(this.options.sentinelValues)
|
|
77
|
+
this._renderer.updateSentinels(this.options.sentinelValues)
|
|
133
78
|
}
|
|
134
79
|
if (this.options.hsAdvAmbientIterations !== prevHsAdvAmbientIterations) {
|
|
135
|
-
this._renderer.generateAmbientDirections(this.options.hsAdvAmbientIterations)
|
|
80
|
+
this._renderer.generateAmbientDirections(this.options.hsAdvAmbientIterations)
|
|
136
81
|
}
|
|
137
82
|
if (
|
|
138
83
|
this.options.hsAdvSoftIterations !== prevHsAdvSoftIterations ||
|
|
139
84
|
this.options.hsAdvSunRadiusMultiplier !== prevHsAdvSunRadiusMultiplier
|
|
140
|
-
|
|
141
|
-
this._renderer.generateSunDirections(this.options.hsAdvSoftIterations, this.options.hsAdvSunRadiusMultiplier)
|
|
85
|
+
) {
|
|
86
|
+
this._renderer.generateSunDirections(this.options.hsAdvSoftIterations, this.options.hsAdvSunRadiusMultiplier)
|
|
142
87
|
}
|
|
143
|
-
this.setHillshadeOptions()
|
|
88
|
+
this.setHillshadeOptions()
|
|
144
89
|
|
|
145
90
|
if (this.options.extraPixelLayers > 0 && this.options.glOperation === 'none') {
|
|
146
|
-
this._maybeLoadExtraLayers(prevUrlA, prevUrlB, prevUrlC, prevUrlD)
|
|
91
|
+
this._maybeLoadExtraLayers(prevUrlA, prevUrlB, prevUrlC, prevUrlD)
|
|
147
92
|
}
|
|
148
93
|
// TODO: Fix shader so simple hillshading works ok with larger texture than tileSize
|
|
149
94
|
if (this.options.hillshadeType !== prevHillshadeType) {
|
|
150
95
|
// reduce textureManager size as simple hillshading type currently gets "edges" around the tiles with larger texture.
|
|
151
96
|
if (this.options.hillshadeType === 'simple') {
|
|
152
|
-
this._renderer.setMaxTextureDimension(this._tileSizeAsNumber())
|
|
97
|
+
this._renderer.setMaxTextureDimension(this._tileSizeAsNumber())
|
|
153
98
|
} else if (prevHillshadeType === 'simple') {
|
|
154
|
-
this._renderer.setMaxTextureDimension(this._renderer.findMaxTextureDimension())
|
|
99
|
+
this._renderer.setMaxTextureDimension(this._renderer.findMaxTextureDimension())
|
|
155
100
|
}
|
|
156
101
|
}
|
|
157
102
|
|
|
158
103
|
if (this.options.url !== prevUrl) {
|
|
159
104
|
// need to clear tiles so they are not reused with adv.hs.
|
|
160
|
-
this._renderer.textureManager.clearTiles()
|
|
105
|
+
this._renderer.textureManager.clearTiles()
|
|
161
106
|
}
|
|
162
107
|
|
|
163
108
|
if (this.options.hsAdvBaselayerUrl !== prevHsAdvBaselayerUrl) {
|
|
164
109
|
// need to clear tiles so they are not reused
|
|
165
110
|
// TODO: Check why necessary
|
|
166
|
-
this._renderer.textureManagerHillshade.clearTiles()
|
|
111
|
+
this._renderer.textureManagerHillshade.clearTiles()
|
|
167
112
|
}
|
|
168
113
|
}
|
|
169
114
|
|
|
170
|
-
createTile(coords) {
|
|
115
|
+
createTile (coords) {
|
|
171
116
|
const {
|
|
172
117
|
extraPixelLayers,
|
|
173
118
|
tileSize,
|
|
174
119
|
url,
|
|
175
|
-
hsPregenUrl,
|
|
176
120
|
operationUrlA,
|
|
177
121
|
operationUrlB,
|
|
178
122
|
operationUrlC,
|
|
@@ -196,95 +140,86 @@ export default class GLOperations {
|
|
|
196
140
|
multiplierC,
|
|
197
141
|
multiplierD,
|
|
198
142
|
multiplierE,
|
|
199
|
-
multiplierF
|
|
200
|
-
} = this.options
|
|
143
|
+
multiplierF
|
|
144
|
+
} = this.options
|
|
201
145
|
|
|
202
146
|
// Create a <canvas> element to contain the rendered image.
|
|
203
|
-
const tileCanvas = document.createElement('canvas')
|
|
147
|
+
const tileCanvas = document.createElement('canvas')
|
|
204
148
|
// Configure the element.
|
|
205
149
|
Object.assign(tileCanvas, {
|
|
206
150
|
className: 'gl-tile',
|
|
207
151
|
width: tileSize,
|
|
208
|
-
height: tileSize
|
|
209
|
-
})
|
|
152
|
+
height: tileSize
|
|
153
|
+
})
|
|
210
154
|
|
|
211
|
-
return new Promise((resolve
|
|
155
|
+
return new Promise((resolve) => {
|
|
212
156
|
if (this.options.glOperation === 'none') {
|
|
213
157
|
// Download an extra layer if required
|
|
214
158
|
if (extraPixelLayers === 1) {
|
|
215
159
|
this._fetchTileData(coords, operationUrlA).then((pixelDataA) => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
160
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
161
|
+
})
|
|
219
162
|
}
|
|
220
163
|
|
|
221
164
|
this._fetchTileData(coords, url).then((pixelData) => {
|
|
222
|
-
// Render in `renderer`'s WebGL context.
|
|
223
|
-
if (this.options.debug) console.log("_fetchTileData with no operation");
|
|
224
165
|
let [sourceX, sourceY] = this._renderer.renderTile(
|
|
225
166
|
{ coords, pixelData },
|
|
226
167
|
this.options._hillshadeOptions,
|
|
227
|
-
coords.z
|
|
228
|
-
)
|
|
168
|
+
coords.z
|
|
169
|
+
)
|
|
229
170
|
|
|
230
171
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
231
|
-
tileCanvas.pixelData = pixelData
|
|
172
|
+
tileCanvas.pixelData = pixelData
|
|
232
173
|
|
|
233
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
174
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
234
175
|
|
|
235
176
|
resolve(tileCanvas)
|
|
236
|
-
})
|
|
177
|
+
})
|
|
237
178
|
} else if (this.options.glOperation === 'diff') {
|
|
238
179
|
Promise.all([
|
|
239
180
|
this._fetchTileData(coords, operationUrlA),
|
|
240
|
-
this._fetchTileData(coords, operationUrlB)
|
|
181
|
+
this._fetchTileData(coords, operationUrlB)
|
|
241
182
|
]).then((pixelDataArray) => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const pixelDataA = pixelDataArray[0];
|
|
245
|
-
const pixelDataB = pixelDataArray[1];
|
|
183
|
+
const pixelDataA = pixelDataArray[0]
|
|
184
|
+
const pixelDataB = pixelDataArray[1]
|
|
246
185
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileDiff(
|
|
247
186
|
{ coords: coords, pixelData: pixelDataA },
|
|
248
|
-
{ coords: coords, pixelData: pixelDataB }
|
|
249
|
-
)
|
|
187
|
+
{ coords: coords, pixelData: pixelDataB }
|
|
188
|
+
)
|
|
250
189
|
|
|
251
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
252
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
253
|
-
tileCanvas.pixelDataB = pixelDataB
|
|
190
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
191
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
192
|
+
tileCanvas.pixelDataB = pixelDataB
|
|
254
193
|
|
|
255
194
|
// Copy contents to tileCanvas.
|
|
256
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
257
|
-
})
|
|
195
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
196
|
+
})
|
|
258
197
|
} else if (this.options.glOperation === 'multi' && this.options.multiLayers === 1) {
|
|
259
198
|
Promise.all([
|
|
260
199
|
this._fetchTileData(coords, operationUrlA)
|
|
261
200
|
]).then((pixelDataArray) => {
|
|
262
|
-
|
|
263
|
-
if (this.options.debug) console.log("_fetchTileData with multi");
|
|
264
|
-
const pixelDataA = pixelDataArray[0];
|
|
201
|
+
const pixelDataA = pixelDataArray[0]
|
|
265
202
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileMulti1(
|
|
266
203
|
{ coords: coords, pixelData: pixelDataA },
|
|
267
204
|
filterLowA,
|
|
268
205
|
filterHighA,
|
|
269
|
-
multiplierA
|
|
270
|
-
)
|
|
206
|
+
multiplierA
|
|
207
|
+
)
|
|
271
208
|
|
|
272
209
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
273
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
274
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
210
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
211
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
275
212
|
|
|
276
213
|
// Copy contents to tileCanvas.
|
|
277
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
278
|
-
})
|
|
214
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
215
|
+
})
|
|
279
216
|
} else if (this.options.glOperation === 'multi' && this.options.multiLayers === 2) {
|
|
280
217
|
Promise.all([
|
|
281
218
|
this._fetchTileData(coords, operationUrlA),
|
|
282
|
-
this._fetchTileData(coords, operationUrlB)
|
|
219
|
+
this._fetchTileData(coords, operationUrlB)
|
|
283
220
|
]).then((pixelDataArray) => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const pixelDataA = pixelDataArray[0];
|
|
287
|
-
const pixelDataB = pixelDataArray[1];
|
|
221
|
+
const pixelDataA = pixelDataArray[0]
|
|
222
|
+
const pixelDataB = pixelDataArray[1]
|
|
288
223
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileMulti2(
|
|
289
224
|
{ coords: coords, pixelData: pixelDataA },
|
|
290
225
|
{ coords: coords, pixelData: pixelDataB },
|
|
@@ -293,28 +228,26 @@ export default class GLOperations {
|
|
|
293
228
|
filterLowB,
|
|
294
229
|
filterHighB,
|
|
295
230
|
multiplierA,
|
|
296
|
-
multiplierB
|
|
297
|
-
)
|
|
231
|
+
multiplierB
|
|
232
|
+
)
|
|
298
233
|
|
|
299
234
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
300
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
301
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
302
|
-
tileCanvas.pixelDataB = pixelDataB
|
|
235
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
236
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
237
|
+
tileCanvas.pixelDataB = pixelDataB
|
|
303
238
|
|
|
304
239
|
// Copy contents to tileCanvas.
|
|
305
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
306
|
-
})
|
|
240
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
241
|
+
})
|
|
307
242
|
} else if (this.options.glOperation === 'multi' && this.options.multiLayers === 3) {
|
|
308
243
|
Promise.all([
|
|
309
244
|
this._fetchTileData(coords, operationUrlA),
|
|
310
245
|
this._fetchTileData(coords, operationUrlB),
|
|
311
|
-
this._fetchTileData(coords, operationUrlC)
|
|
246
|
+
this._fetchTileData(coords, operationUrlC)
|
|
312
247
|
]).then((pixelDataArray) => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
const pixelDataB = pixelDataArray[1];
|
|
317
|
-
const pixelDataC = pixelDataArray[2];
|
|
248
|
+
const pixelDataA = pixelDataArray[0]
|
|
249
|
+
const pixelDataB = pixelDataArray[1]
|
|
250
|
+
const pixelDataC = pixelDataArray[2]
|
|
318
251
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileMulti3(
|
|
319
252
|
{ coords: coords, pixelData: pixelDataA },
|
|
320
253
|
{ coords: coords, pixelData: pixelDataB },
|
|
@@ -327,31 +260,29 @@ export default class GLOperations {
|
|
|
327
260
|
filterHighC,
|
|
328
261
|
multiplierA,
|
|
329
262
|
multiplierB,
|
|
330
|
-
multiplierC
|
|
331
|
-
)
|
|
263
|
+
multiplierC
|
|
264
|
+
)
|
|
332
265
|
|
|
333
266
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
334
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
335
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
336
|
-
tileCanvas.pixelDataB = pixelDataB
|
|
337
|
-
tileCanvas.pixelDataC = pixelDataC
|
|
267
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
268
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
269
|
+
tileCanvas.pixelDataB = pixelDataB
|
|
270
|
+
tileCanvas.pixelDataC = pixelDataC
|
|
338
271
|
|
|
339
272
|
// Copy contents to tileCanvas.
|
|
340
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
341
|
-
})
|
|
273
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
274
|
+
})
|
|
342
275
|
} else if (this.options.glOperation === 'multi' && this.options.multiLayers === 4) {
|
|
343
276
|
Promise.all([
|
|
344
277
|
this._fetchTileData(coords, operationUrlA),
|
|
345
278
|
this._fetchTileData(coords, operationUrlB),
|
|
346
279
|
this._fetchTileData(coords, operationUrlC),
|
|
347
|
-
this._fetchTileData(coords, operationUrlD)
|
|
280
|
+
this._fetchTileData(coords, operationUrlD)
|
|
348
281
|
]).then((pixelDataArray) => {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
const pixelDataC = pixelDataArray[2];
|
|
354
|
-
const pixelDataD = pixelDataArray[3];
|
|
282
|
+
const pixelDataA = pixelDataArray[0]
|
|
283
|
+
const pixelDataB = pixelDataArray[1]
|
|
284
|
+
const pixelDataC = pixelDataArray[2]
|
|
285
|
+
const pixelDataD = pixelDataArray[3]
|
|
355
286
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileMulti4(
|
|
356
287
|
{ coords: coords, pixelData: pixelDataA },
|
|
357
288
|
{ coords: coords, pixelData: pixelDataB },
|
|
@@ -368,34 +299,32 @@ export default class GLOperations {
|
|
|
368
299
|
multiplierA,
|
|
369
300
|
multiplierB,
|
|
370
301
|
multiplierC,
|
|
371
|
-
multiplierD
|
|
372
|
-
)
|
|
302
|
+
multiplierD
|
|
303
|
+
)
|
|
373
304
|
|
|
374
305
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
375
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
376
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
377
|
-
tileCanvas.pixelDataB = pixelDataB
|
|
378
|
-
tileCanvas.pixelDataC = pixelDataC
|
|
379
|
-
tileCanvas.pixelDataD = pixelDataD
|
|
306
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
307
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
308
|
+
tileCanvas.pixelDataB = pixelDataB
|
|
309
|
+
tileCanvas.pixelDataC = pixelDataC
|
|
310
|
+
tileCanvas.pixelDataD = pixelDataD
|
|
380
311
|
|
|
381
312
|
// Copy contents to tileCanvas.
|
|
382
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
383
|
-
})
|
|
313
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
314
|
+
})
|
|
384
315
|
} else if (this.options.glOperation === 'multi' && this.options.multiLayers === 5) {
|
|
385
316
|
Promise.all([
|
|
386
317
|
this._fetchTileData(coords, operationUrlA),
|
|
387
318
|
this._fetchTileData(coords, operationUrlB),
|
|
388
319
|
this._fetchTileData(coords, operationUrlC),
|
|
389
320
|
this._fetchTileData(coords, operationUrlD),
|
|
390
|
-
this._fetchTileData(coords, operationUrlE)
|
|
321
|
+
this._fetchTileData(coords, operationUrlE)
|
|
391
322
|
]).then((pixelDataArray) => {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
const pixelDataD = pixelDataArray[3];
|
|
398
|
-
const pixelDataE = pixelDataArray[4];
|
|
323
|
+
const pixelDataA = pixelDataArray[0]
|
|
324
|
+
const pixelDataB = pixelDataArray[1]
|
|
325
|
+
const pixelDataC = pixelDataArray[2]
|
|
326
|
+
const pixelDataD = pixelDataArray[3]
|
|
327
|
+
const pixelDataE = pixelDataArray[4]
|
|
399
328
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileMulti5(
|
|
400
329
|
{ coords: coords, pixelData: pixelDataA },
|
|
401
330
|
{ coords: coords, pixelData: pixelDataB },
|
|
@@ -416,20 +345,20 @@ export default class GLOperations {
|
|
|
416
345
|
multiplierB,
|
|
417
346
|
multiplierC,
|
|
418
347
|
multiplierD,
|
|
419
|
-
multiplierE
|
|
420
|
-
)
|
|
348
|
+
multiplierE
|
|
349
|
+
)
|
|
421
350
|
|
|
422
351
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
423
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
424
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
425
|
-
tileCanvas.pixelDataB = pixelDataB
|
|
426
|
-
tileCanvas.pixelDataC = pixelDataC
|
|
427
|
-
tileCanvas.pixelDataD = pixelDataD
|
|
428
|
-
tileCanvas.pixelDataE = pixelDataE
|
|
352
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
353
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
354
|
+
tileCanvas.pixelDataB = pixelDataB
|
|
355
|
+
tileCanvas.pixelDataC = pixelDataC
|
|
356
|
+
tileCanvas.pixelDataD = pixelDataD
|
|
357
|
+
tileCanvas.pixelDataE = pixelDataE
|
|
429
358
|
|
|
430
359
|
// Copy contents to tileCanvas.
|
|
431
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
432
|
-
})
|
|
360
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
361
|
+
})
|
|
433
362
|
} else if (this.options.glOperation === 'multi' && this.options.multiLayers === 6) {
|
|
434
363
|
Promise.all([
|
|
435
364
|
this._fetchTileData(coords, operationUrlA),
|
|
@@ -437,16 +366,14 @@ export default class GLOperations {
|
|
|
437
366
|
this._fetchTileData(coords, operationUrlC),
|
|
438
367
|
this._fetchTileData(coords, operationUrlD),
|
|
439
368
|
this._fetchTileData(coords, operationUrlE),
|
|
440
|
-
this._fetchTileData(coords, operationUrlF)
|
|
369
|
+
this._fetchTileData(coords, operationUrlF)
|
|
441
370
|
]).then((pixelDataArray) => {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
const pixelDataE = pixelDataArray[4];
|
|
449
|
-
const pixelDataF = pixelDataArray[5];
|
|
371
|
+
const pixelDataA = pixelDataArray[0]
|
|
372
|
+
const pixelDataB = pixelDataArray[1]
|
|
373
|
+
const pixelDataC = pixelDataArray[2]
|
|
374
|
+
const pixelDataD = pixelDataArray[3]
|
|
375
|
+
const pixelDataE = pixelDataArray[4]
|
|
376
|
+
const pixelDataF = pixelDataArray[5]
|
|
450
377
|
const [sourceX, sourceY, resultEncodedPixels] = this._renderer.renderTileMulti6(
|
|
451
378
|
{ coords: coords, pixelData: pixelDataA },
|
|
452
379
|
{ coords: coords, pixelData: pixelDataB },
|
|
@@ -471,49 +398,49 @@ export default class GLOperations {
|
|
|
471
398
|
multiplierC,
|
|
472
399
|
multiplierD,
|
|
473
400
|
multiplierE,
|
|
474
|
-
multiplierF
|
|
475
|
-
)
|
|
401
|
+
multiplierF
|
|
402
|
+
)
|
|
476
403
|
|
|
477
404
|
// Copy pixel data to a property on tile canvas element (for later retrieval).
|
|
478
|
-
tileCanvas.pixelData = resultEncodedPixels
|
|
479
|
-
tileCanvas.pixelDataA = pixelDataA
|
|
480
|
-
tileCanvas.pixelDataB = pixelDataB
|
|
481
|
-
tileCanvas.pixelDataC = pixelDataC
|
|
482
|
-
tileCanvas.pixelDataD = pixelDataD
|
|
483
|
-
tileCanvas.pixelDataE = pixelDataE
|
|
484
|
-
tileCanvas.pixelDataF = pixelDataF
|
|
405
|
+
tileCanvas.pixelData = resultEncodedPixels
|
|
406
|
+
tileCanvas.pixelDataA = pixelDataA
|
|
407
|
+
tileCanvas.pixelDataB = pixelDataB
|
|
408
|
+
tileCanvas.pixelDataC = pixelDataC
|
|
409
|
+
tileCanvas.pixelDataD = pixelDataD
|
|
410
|
+
tileCanvas.pixelDataE = pixelDataE
|
|
411
|
+
tileCanvas.pixelDataF = pixelDataF
|
|
485
412
|
|
|
486
413
|
// Copy contents to tileCanvas.
|
|
487
|
-
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
488
|
-
})
|
|
414
|
+
this._copyToTileCanvas(tileCanvas, sourceX, sourceY)
|
|
415
|
+
})
|
|
489
416
|
}
|
|
490
417
|
})
|
|
491
418
|
|
|
492
419
|
}
|
|
493
420
|
|
|
494
|
-
_checkColorScaleAndSentinels() {
|
|
421
|
+
_checkColorScaleAndSentinels () {
|
|
495
422
|
const {
|
|
496
423
|
colorScale,
|
|
497
424
|
sentinelValues,
|
|
498
425
|
colorscaleMaxLength,
|
|
499
|
-
sentinelMaxLength
|
|
500
|
-
} = this.options
|
|
426
|
+
sentinelMaxLength
|
|
427
|
+
} = this.options
|
|
501
428
|
if (colorScale.length === 0 && sentinelValues.length === 0) {
|
|
502
|
-
throw new Error('Either `colorScale` or `sentinelValues` must be of non-zero length.')
|
|
429
|
+
throw new Error('Either `colorScale` or `sentinelValues` must be of non-zero length.')
|
|
503
430
|
}
|
|
504
431
|
if (colorScale.length > colorscaleMaxLength) {
|
|
505
432
|
throw new Error(
|
|
506
|
-
`Color scale length ${colorScale.length} exceeds the maximum, ${colorscaleMaxLength}
|
|
507
|
-
)
|
|
433
|
+
`Color scale length ${colorScale.length} exceeds the maximum, ${colorscaleMaxLength}.`
|
|
434
|
+
)
|
|
508
435
|
}
|
|
509
436
|
if (sentinelValues.length > sentinelMaxLength) {
|
|
510
437
|
throw new Error(
|
|
511
|
-
`Sentinel values length ${sentinelValues.length} exceeds the maximum, ${sentinelMaxLength}
|
|
512
|
-
)
|
|
438
|
+
`Sentinel values length ${sentinelValues.length} exceeds the maximum, ${sentinelMaxLength}.`
|
|
439
|
+
)
|
|
513
440
|
}
|
|
514
441
|
}
|
|
515
442
|
|
|
516
|
-
setHillshadeOptions() {
|
|
443
|
+
setHillshadeOptions () {
|
|
517
444
|
this.options._hillshadeOptions = {
|
|
518
445
|
hillshadeType: this.options.hillshadeType,
|
|
519
446
|
hsAdvValueScale: this.options.hsAdvValueScale,
|
|
@@ -530,65 +457,65 @@ export default class GLOperations {
|
|
|
530
457
|
hsAdvBaselayerUrl: this.options.hsAdvBaselayerUrl,
|
|
531
458
|
hsAdvSmoothInput: this.options.hsAdvSmoothInput,
|
|
532
459
|
hsAdvSmoothInputKernel: this.options.hsAdvSmoothInputKernel,
|
|
533
|
-
hsPregenUrl: this.options.hsPregenUrl
|
|
534
|
-
}
|
|
460
|
+
hsPregenUrl: this.options.hsPregenUrl
|
|
461
|
+
}
|
|
535
462
|
}
|
|
536
463
|
|
|
537
|
-
_tileSizeAsNumber() {
|
|
464
|
+
_tileSizeAsNumber () {
|
|
538
465
|
return this.options.tileSize
|
|
539
466
|
}
|
|
540
467
|
|
|
541
|
-
async _fetchTileData(coords, url, tileFormat = this.options.tileFormat) {
|
|
468
|
+
async _fetchTileData (coords, url, tileFormat = this.options.tileFormat) {
|
|
542
469
|
if (tileFormat === 'float32' || tileFormat === 'image') {
|
|
543
|
-
return util.fetchPNGData(this.getTileUrl(coords, url), this.options.nodataValue, this._tileSizeAsNumber())
|
|
470
|
+
return util.fetchPNGData(this.getTileUrl(coords, url), this.options.nodataValue, this._tileSizeAsNumber())
|
|
544
471
|
} else if (tileFormat === 'dem') {
|
|
545
|
-
const nodataTile = util.createNoDataTile(this.options.nodataValue, this._tileSizeAsNumber())
|
|
546
|
-
const imageData = await util.fetchPNGData(this.getTileUrl(coords, url), this.options.nodataValue, this._tileSizeAsNumber())
|
|
472
|
+
const nodataTile = util.createNoDataTile(this.options.nodataValue, this._tileSizeAsNumber())
|
|
473
|
+
const imageData = await util.fetchPNGData(this.getTileUrl(coords, url), this.options.nodataValue, this._tileSizeAsNumber())
|
|
547
474
|
if (util.typedArraysAreEqual(imageData, nodataTile)) {
|
|
548
|
-
return imageData
|
|
475
|
+
return imageData
|
|
549
476
|
} else {
|
|
550
|
-
const rgbaData = this._renderer.renderConvertDem(imageData)
|
|
551
|
-
return rgbaData
|
|
477
|
+
const rgbaData = this._renderer.renderConvertDem(imageData)
|
|
478
|
+
return rgbaData
|
|
552
479
|
}
|
|
553
480
|
}
|
|
554
|
-
return util.createNoDataTile(this.options.nodataValue, this._tileSizeAsNumber())
|
|
481
|
+
return util.createNoDataTile(this.options.nodataValue, this._tileSizeAsNumber())
|
|
555
482
|
}
|
|
556
483
|
|
|
557
|
-
_copyToTileCanvas(tile, sourceX, sourceY) {
|
|
558
|
-
const tileSize = this._tileSizeAsNumber()
|
|
559
|
-
const tileCanvas2DContext = tile.getContext('2d')
|
|
484
|
+
_copyToTileCanvas (tile, sourceX, sourceY) {
|
|
485
|
+
const tileSize = this._tileSizeAsNumber()
|
|
486
|
+
const tileCanvas2DContext = tile.getContext('2d')
|
|
560
487
|
if (tileCanvas2DContext === null) {
|
|
561
|
-
throw new Error('Tile canvas 2D context is null.')
|
|
488
|
+
throw new Error('Tile canvas 2D context is null.')
|
|
562
489
|
}
|
|
563
490
|
// Clear the current contents of the canvas. Otherwise, the new image will be composited with
|
|
564
491
|
// the existing image.
|
|
565
|
-
tileCanvas2DContext.clearRect(0, 0, tileSize, tileSize)
|
|
492
|
+
tileCanvas2DContext.clearRect(0, 0, tileSize, tileSize)
|
|
566
493
|
// Copy the image data from the Renderer's canvas to the tile's canvas.
|
|
567
494
|
tileCanvas2DContext.drawImage(
|
|
568
495
|
this._renderer.canvas,
|
|
569
496
|
sourceX, sourceY, tileSize, tileSize, // source canvas offset (x, y) and size (x, y)
|
|
570
|
-
0, 0, tileSize, tileSize
|
|
571
|
-
)
|
|
497
|
+
0, 0, tileSize, tileSize // destination canvas offset (x, y) and size (x, y)
|
|
498
|
+
)
|
|
572
499
|
}
|
|
573
500
|
|
|
574
|
-
getTileUrl(coords, url) {
|
|
501
|
+
getTileUrl (coords, url) {
|
|
575
502
|
return url
|
|
576
503
|
.replace(/{z}/g, String(coords.z))
|
|
577
504
|
.replace(/{x}/g, String(coords.x))
|
|
578
505
|
.replace(/{y}/g, String(coords.y))
|
|
579
506
|
}
|
|
580
507
|
|
|
581
|
-
_getPixelScale(coords) {
|
|
582
|
-
let {bbox: {
|
|
583
|
-
let pixelScale = 1
|
|
508
|
+
_getPixelScale (coords) {
|
|
509
|
+
let {bbox: {south, north}, z: zoom} = coords
|
|
510
|
+
let pixelScale = 1
|
|
584
511
|
let lat = (south + north) / 2
|
|
585
512
|
if (this.options.hsAdvPixelScale === 'auto') {
|
|
586
513
|
pixelScale = EARTH_CIRCUMFERENCE * Math.abs(
|
|
587
|
-
|
|
588
|
-
)) / Math.pow(2, zoom + 8)
|
|
514
|
+
Math.cos(lat / 180 * Math.PI
|
|
515
|
+
)) / Math.pow(2, zoom + 8)
|
|
589
516
|
} else if (typeof this.options.hsAdvPixelScale === 'number') {
|
|
590
|
-
pixelScale = this.options.hsAdvPixelScale / (this._tileSizeAsNumber() * (2**zoom))
|
|
517
|
+
pixelScale = this.options.hsAdvPixelScale / (this._tileSizeAsNumber() * (2 ** zoom))
|
|
591
518
|
}
|
|
592
|
-
return pixelScale
|
|
519
|
+
return pixelScale
|
|
593
520
|
}
|
|
594
521
|
}
|