@mapcatch/util 2.0.6 → 2.0.7
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.cjs.js +2928 -0
- package/dist/catchUtil.min.esm.js +44499 -42811
- package/dist/catchUtil.min.js +248 -248
- package/package.json +11 -2
- package/src/constants/annotation_color.js +0 -7
- package/src/constants/annotation_draw_style.js +0 -228
- package/src/constants/annotation_label_style.js +0 -76
- package/src/constants/annotation_style.js +0 -118
- package/src/constants/bmap_types.js +0 -44
- package/src/constants/cameras.js +0 -5
- package/src/constants/crs.js +0 -42099
- package/src/constants/crs_types.js +0 -22
- package/src/constants/default_layers.js +0 -149
- package/src/constants/dsm_colors.js +0 -10
- package/src/constants/error_codes.js +0 -44
- package/src/constants/height_colors.js +0 -1
- package/src/constants/index.js +0 -20
- package/src/constants/layer_folders.js +0 -6
- package/src/constants/layer_groups.js +0 -34
- package/src/constants/layer_groups_multispectral.js +0 -34
- package/src/constants/layer_icons.js +0 -19
- package/src/constants/map_style.js +0 -11
- package/src/constants/measurement_fields.js +0 -208
- package/src/constants/task_params.js +0 -33
- package/src/constants/tools.js +0 -20
- package/src/event/event.js +0 -191
- package/src/event/event_bus.js +0 -5
- package/src/event/index.js +0 -2
- package/src/gl-operations/constants.js +0 -9
- package/src/gl-operations/default_options.js +0 -98
- package/src/gl-operations/index.js +0 -533
- package/src/gl-operations/reglCommands/contours.js +0 -27
- package/src/gl-operations/reglCommands/default.js +0 -46
- package/src/gl-operations/reglCommands/hillshading.js +0 -340
- package/src/gl-operations/reglCommands/index.js +0 -6
- package/src/gl-operations/reglCommands/multiLayers.js +0 -303
- package/src/gl-operations/reglCommands/transitions.js +0 -111
- package/src/gl-operations/reglCommands/util.js +0 -71
- package/src/gl-operations/renderer.js +0 -210
- package/src/gl-operations/shaders/fragment/convertDem.js +0 -26
- package/src/gl-operations/shaders/fragment/convolutionSmooth.js +0 -55
- package/src/gl-operations/shaders/fragment/diffCalc.js +0 -34
- package/src/gl-operations/shaders/fragment/drawResult.js +0 -47
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvAmbientShadows.js +0 -79
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +0 -60
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalBaselayer.js +0 -31
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +0 -61
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js +0 -27
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvNormals.js +0 -26
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvSmooth.js +0 -54
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvSoftShadows.js +0 -81
- package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +0 -55
- package/src/gl-operations/shaders/fragment/interpolateColor.js +0 -66
- package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +0 -50
- package/src/gl-operations/shaders/fragment/interpolateValue.js +0 -137
- package/src/gl-operations/shaders/fragment/multiAnalyze1Calc.js +0 -36
- package/src/gl-operations/shaders/fragment/multiAnalyze2Calc.js +0 -46
- package/src/gl-operations/shaders/fragment/multiAnalyze3Calc.js +0 -54
- package/src/gl-operations/shaders/fragment/multiAnalyze4Calc.js +0 -62
- package/src/gl-operations/shaders/fragment/multiAnalyze5Calc.js +0 -70
- package/src/gl-operations/shaders/fragment/multiAnalyze6Calc.js +0 -78
- package/src/gl-operations/shaders/fragment/single.js +0 -93
- package/src/gl-operations/shaders/transform.js +0 -22
- package/src/gl-operations/shaders/util/computeColor.glsl +0 -85
- package/src/gl-operations/shaders/util/getTexelValue.glsl +0 -10
- package/src/gl-operations/shaders/util/isCloseEnough.glsl +0 -9
- package/src/gl-operations/shaders/util/rgbaToFloat.glsl +0 -18
- package/src/gl-operations/shaders/vertex/double.js +0 -17
- package/src/gl-operations/shaders/vertex/multi3.js +0 -20
- package/src/gl-operations/shaders/vertex/multi4.js +0 -23
- package/src/gl-operations/shaders/vertex/multi5.js +0 -26
- package/src/gl-operations/shaders/vertex/multi6.js +0 -29
- package/src/gl-operations/shaders/vertex/single.js +0 -13
- package/src/gl-operations/shaders/vertex/singleNotTransformed.js +0 -12
- package/src/gl-operations/texture_manager.js +0 -141
- package/src/gl-operations/util.js +0 -336
- package/src/index.js +0 -20
- package/src/measure/index.js +0 -209
- package/src/measure/tile_cache.js +0 -88
- package/src/mvs/index.js +0 -26
- package/src/mvs/protos/index.js +0 -12
- package/src/mvs/protos/proto_10.js +0 -155
- package/src/observation_pretict.js +0 -168
- package/src/photo-parser/exif/gps_tags.js +0 -33
- package/src/photo-parser/exif/ifd1_tags.js +0 -22
- package/src/photo-parser/exif/index.js +0 -143
- package/src/photo-parser/exif/parse_image.js +0 -290
- package/src/photo-parser/exif/string_values.js +0 -137
- package/src/photo-parser/exif/tags.js +0 -75
- package/src/photo-parser/exif/tiff_tags.js +0 -35
- package/src/photo-parser/exif/util.js +0 -103
- package/src/photo-parser/image-size/detector.js +0 -24
- package/src/photo-parser/image-size/fromFile.js +0 -55
- package/src/photo-parser/image-size/index.js +0 -2
- package/src/photo-parser/image-size/lookup.js +0 -37
- package/src/photo-parser/image-size/types/bmp.js +0 -10
- package/src/photo-parser/image-size/types/cur.js +0 -16
- package/src/photo-parser/image-size/types/dds.js +0 -10
- package/src/photo-parser/image-size/types/gif.js +0 -11
- package/src/photo-parser/image-size/types/heif.js +0 -35
- package/src/photo-parser/image-size/types/icns.js +0 -112
- package/src/photo-parser/image-size/types/ico.js +0 -74
- package/src/photo-parser/image-size/types/index.js +0 -43
- package/src/photo-parser/image-size/types/j2c.js +0 -11
- package/src/photo-parser/image-size/types/jp2.js +0 -22
- package/src/photo-parser/image-size/types/jpg.js +0 -157
- package/src/photo-parser/image-size/types/ktx.js +0 -18
- package/src/photo-parser/image-size/types/png.js +0 -36
- package/src/photo-parser/image-size/types/pnm.js +0 -74
- package/src/photo-parser/image-size/types/psd.js +0 -10
- package/src/photo-parser/image-size/types/svg.js +0 -100
- package/src/photo-parser/image-size/types/tga.js +0 -14
- package/src/photo-parser/image-size/types/tiff.js +0 -92
- package/src/photo-parser/image-size/types/utils.js +0 -83
- package/src/photo-parser/image-size/types/webp.js +0 -67
- package/src/photo-parser/index.js +0 -185
- package/src/report/annotations_report.js +0 -446
- package/src/report/index.js +0 -2
- package/src/report/map_util.js +0 -81
- package/src/report/pdf_creator.js +0 -247
- package/src/report/report.js +0 -581
- package/src/transform.js +0 -207
- package/src/util.js +0 -671
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import vertSingle from '../shaders/vertex/single.js'
|
|
2
|
-
import vertDouble from '../shaders/vertex/double.js'
|
|
3
|
-
|
|
4
|
-
import fragInterpolateColor from '../shaders/fragment/interpolateColor.js'
|
|
5
|
-
import fragInterpolateColorOnly from '../shaders/fragment/interpolateColorOnly.js'
|
|
6
|
-
import fragInterpolateValue from '../shaders/fragment/interpolateValue.js'
|
|
7
|
-
|
|
8
|
-
import * as util from '../util'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The DrawCommand output by this function interpolates, for each pixel, between two values, one
|
|
12
|
-
* from `textureA` and one from `textureB`. The same color scale / sentinel values are applied to
|
|
13
|
-
* both.
|
|
14
|
-
*/
|
|
15
|
-
export function createDrawTileInterpolateValueCommand (
|
|
16
|
-
regl,
|
|
17
|
-
commonConfig,
|
|
18
|
-
fragMacros
|
|
19
|
-
) {
|
|
20
|
-
return regl({
|
|
21
|
-
...commonConfig,
|
|
22
|
-
vert: vertDouble,
|
|
23
|
-
frag: util.defineMacros(fragInterpolateValue, fragMacros),
|
|
24
|
-
uniforms: {
|
|
25
|
-
...commonConfig.uniforms,
|
|
26
|
-
scaleLength: regl.prop('scaleLength'),
|
|
27
|
-
sentinelLength: regl.prop('sentinelLength'),
|
|
28
|
-
scaleColormap: regl.prop('scaleColormap'),
|
|
29
|
-
sentinelColormap: regl.prop('sentinelColormap'),
|
|
30
|
-
aboveColor: regl.prop('aboveColor'),
|
|
31
|
-
belowColor: regl.prop('belowColor'),
|
|
32
|
-
textureA: (_, { textureA }) => textureA,
|
|
33
|
-
textureB: (_, { textureB }) => textureB,
|
|
34
|
-
interpolationFraction: (_, { interpolationFraction }) => interpolationFraction
|
|
35
|
-
},
|
|
36
|
-
attributes: {
|
|
37
|
-
...commonConfig.attributes,
|
|
38
|
-
texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
|
|
39
|
-
texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB)
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The behavior of this DrawCommand is similar to the one above, except that pixels from `textureA`
|
|
46
|
-
* are colorized with one color scale / set of sentinel values, while pixels from `textureB` use a
|
|
47
|
-
* different color scale / set of sentinel values.
|
|
48
|
-
*/
|
|
49
|
-
export function createDrawTileInterpolateColorCommand (
|
|
50
|
-
regl,
|
|
51
|
-
commonConfig,
|
|
52
|
-
fragMacros
|
|
53
|
-
) {
|
|
54
|
-
return regl({
|
|
55
|
-
...commonConfig,
|
|
56
|
-
vert: vertDouble,
|
|
57
|
-
frag: util.defineMacros(fragInterpolateColor, fragMacros),
|
|
58
|
-
uniforms: {
|
|
59
|
-
...commonConfig.uniforms,
|
|
60
|
-
scaleLengthA: regl.prop('scaleLengthA'),
|
|
61
|
-
sentinelLengthA: regl.prop('sentinelLengthA'),
|
|
62
|
-
scaleColormapA: regl.prop('scaleColormapA'),
|
|
63
|
-
sentinelColormapA: regl.prop('sentinelColormapA'),
|
|
64
|
-
scaleLengthB: regl.prop('scaleLengthB'),
|
|
65
|
-
sentinelLengthB: regl.prop('sentinelLengthB'),
|
|
66
|
-
scaleColormapB: regl.prop('scaleColormapB'),
|
|
67
|
-
sentinelColormapB: regl.prop('sentinelColormapB'),
|
|
68
|
-
textureA: (_, { textureA }) => textureA,
|
|
69
|
-
textureB: (_, { textureB }) => textureB,
|
|
70
|
-
interpolationFraction: (_, { interpolationFraction }) => interpolationFraction
|
|
71
|
-
},
|
|
72
|
-
attributes: {
|
|
73
|
-
...commonConfig.attributes,
|
|
74
|
-
texCoordA: (_, { textureBoundsA }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsA),
|
|
75
|
-
texCoordB: (_, { textureBoundsB }) => util.getTexCoordVerticesTriangleStripQuad(textureBoundsB)
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The behavior of this DrawCommand is similar to the one above, except that the pixel values
|
|
82
|
-
* are the same. Only the colorscale changes.
|
|
83
|
-
*/
|
|
84
|
-
export function createDrawTileInterpolateColorOnlyCommand (
|
|
85
|
-
regl,
|
|
86
|
-
commonConfig,
|
|
87
|
-
fragMacros
|
|
88
|
-
) {
|
|
89
|
-
return regl({
|
|
90
|
-
...commonConfig,
|
|
91
|
-
vert: vertSingle,
|
|
92
|
-
frag: util.defineMacros(fragInterpolateColorOnly, fragMacros),
|
|
93
|
-
uniforms: {
|
|
94
|
-
...commonConfig.uniforms,
|
|
95
|
-
scaleLengthA: regl.prop('scaleLengthA'),
|
|
96
|
-
sentinelLengthA: regl.prop('sentinelLengthA'),
|
|
97
|
-
scaleColormapA: regl.prop('scaleColormapA'),
|
|
98
|
-
sentinelColormapA: regl.prop('sentinelColormapA'),
|
|
99
|
-
scaleLengthB: regl.prop('scaleLengthB'),
|
|
100
|
-
sentinelLengthB: regl.prop('sentinelLengthB'),
|
|
101
|
-
scaleColormapB: regl.prop('scaleColormapB'),
|
|
102
|
-
sentinelColormapB: regl.prop('sentinelColormapB'),
|
|
103
|
-
texture: (_, { texture }) => texture,
|
|
104
|
-
interpolationFraction: (_, { interpolationFraction }) => interpolationFraction
|
|
105
|
-
},
|
|
106
|
-
attributes: {
|
|
107
|
-
...commonConfig.attributes,
|
|
108
|
-
texCoord: (_, { textureBounds }) => util.getTexCoordVerticesTriangleStripQuad(textureBounds)
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import vertSingle from '../shaders/vertex/single.js'
|
|
2
|
-
|
|
3
|
-
import fragConvertDem from '../shaders/fragment/convertDem.js'
|
|
4
|
-
|
|
5
|
-
import * as util from '../util'
|
|
6
|
-
|
|
7
|
-
const littleEndian = util.machineIsLittleEndian()
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The object generated by this function should be merged into the DrawConfig for each Regl
|
|
11
|
-
* command in the application.
|
|
12
|
-
*/
|
|
13
|
-
export function getCommonDrawConfiguration (
|
|
14
|
-
tileSize,
|
|
15
|
-
nodataValue
|
|
16
|
-
) {
|
|
17
|
-
return {
|
|
18
|
-
uniforms: {
|
|
19
|
-
nodataValue,
|
|
20
|
-
littleEndian,
|
|
21
|
-
transformMatrix: ({ viewportWidth, viewportHeight }) => (
|
|
22
|
-
util.getTransformMatrix(viewportWidth, viewportHeight)
|
|
23
|
-
)
|
|
24
|
-
},
|
|
25
|
-
attributes: {
|
|
26
|
-
position: (_, { canvasCoordinates }) => {
|
|
27
|
-
const [left, top] = canvasCoordinates
|
|
28
|
-
const [right, bottom] = [left + tileSize, top + tileSize]
|
|
29
|
-
return [
|
|
30
|
-
[left, top ],
|
|
31
|
-
[right, top ],
|
|
32
|
-
[left, bottom],
|
|
33
|
-
[right, bottom]
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
// We don't need the depth buffer for 2D drawing. Leaving it enabled (and failing to clear it
|
|
38
|
-
// between draw calls) results in visual artifacts.
|
|
39
|
-
depth: { enable: false },
|
|
40
|
-
primitive: 'triangle strip',
|
|
41
|
-
count: 4,
|
|
42
|
-
viewport: (_, { canvasSize: [width, height] }) => ({ width, height })
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The command output by this function converts a tile in DEM format
|
|
48
|
-
* to float32 packed as rgba.
|
|
49
|
-
*/
|
|
50
|
-
export function createConvertDemCommand (
|
|
51
|
-
regl,
|
|
52
|
-
commonConfig
|
|
53
|
-
) {
|
|
54
|
-
return regl({
|
|
55
|
-
...commonConfig,
|
|
56
|
-
vert: vertSingle,
|
|
57
|
-
frag: fragConvertDem,
|
|
58
|
-
depth: {
|
|
59
|
-
enable: false
|
|
60
|
-
},
|
|
61
|
-
uniforms: {
|
|
62
|
-
...commonConfig.uniforms,
|
|
63
|
-
texture: (_, { texture }) => texture
|
|
64
|
-
},
|
|
65
|
-
attributes: {
|
|
66
|
-
...commonConfig.attributes,
|
|
67
|
-
texCoord: [[0, 1], [1, 1], [0, 0], [1, 0]]
|
|
68
|
-
},
|
|
69
|
-
framebuffer: regl.prop('fbo')
|
|
70
|
-
})
|
|
71
|
-
}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import REGL from 'regl'
|
|
2
|
-
import {
|
|
3
|
-
CLEAR_COLOR,
|
|
4
|
-
MAX_TEXTURE_DIMENSION,
|
|
5
|
-
EARTH_SUN_DISTANCE,
|
|
6
|
-
SUN_RADIUS
|
|
7
|
-
} from './constants'
|
|
8
|
-
|
|
9
|
-
import TextureManager from './texture_manager'
|
|
10
|
-
import * as util from './util'
|
|
11
|
-
import { vec3 } from 'gl-matrix'
|
|
12
|
-
import * as reglCommands from './reglCommands'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export default class Renderer {
|
|
16
|
-
constructor (gloperations, tileSize, nodataValue, scaleInput, sentinelInput, colorscaleMaxLength, sentinelMaxLength, aboveColor, belowColor) {
|
|
17
|
-
const canvas = document.createElement('canvas')
|
|
18
|
-
let maxTextureDimension = MAX_TEXTURE_DIMENSION
|
|
19
|
-
let normalTextureDimension = 1024
|
|
20
|
-
|
|
21
|
-
const regl = REGL({
|
|
22
|
-
canvas: canvas,
|
|
23
|
-
// profile: true,
|
|
24
|
-
// extension only used for advanced hillshading
|
|
25
|
-
// TODO: add fallback to rgba if writing to float fails
|
|
26
|
-
optionalExtensions: ['OES_texture_float', 'WEBGL_color_buffer_float'],
|
|
27
|
-
onDone: function (err, regl) {
|
|
28
|
-
if (err) {
|
|
29
|
-
console.error(err)
|
|
30
|
-
return
|
|
31
|
-
} else {
|
|
32
|
-
// cannot use this directly as it seems to cause some issues
|
|
33
|
-
// maxTextureDimension = regl.limits.maxTextureSize;
|
|
34
|
-
if (regl.limits.maxTextureSize > 2048) {
|
|
35
|
-
maxTextureDimension = 2048
|
|
36
|
-
}
|
|
37
|
-
if (regl.limits.maxTextureSize > 4096) {
|
|
38
|
-
maxTextureDimension = 4096
|
|
39
|
-
}
|
|
40
|
-
if (regl.limits.maxTextureSize > 8192) {
|
|
41
|
-
maxTextureDimension = 8192
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// TODO: use lower normal dimension where relevant
|
|
45
|
-
// Currently set to same due to a bug
|
|
46
|
-
normalTextureDimension = maxTextureDimension
|
|
47
|
-
}
|
|
48
|
-
// TODO: Improve software rendering detection
|
|
49
|
-
if (regl.limits.maxFragmentUniforms === 261) {
|
|
50
|
-
console.warn('Software rendering detected. Many features of this plugin will fail.\
|
|
51
|
-
If you have a GPU, check if drivers are installed ok?')
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const commonDrawConfig = reglCommands.getCommonDrawConfiguration(tileSize, nodataValue)
|
|
57
|
-
const fragMacros = {
|
|
58
|
-
SCALE_MAX_LENGTH: colorscaleMaxLength,
|
|
59
|
-
SENTINEL_MAX_LENGTH: sentinelMaxLength
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Assign object "instance" properties.
|
|
63
|
-
Object.assign(this, {
|
|
64
|
-
gloperations: gloperations,
|
|
65
|
-
canvas: canvas,
|
|
66
|
-
regl: regl,
|
|
67
|
-
tileSize: tileSize,
|
|
68
|
-
nodataValue: nodataValue,
|
|
69
|
-
maxTextureDimension: maxTextureDimension,
|
|
70
|
-
normalTextureDimension: normalTextureDimension,
|
|
71
|
-
scaleInput: scaleInput,
|
|
72
|
-
sentinelInput: sentinelInput,
|
|
73
|
-
scaleColormap: util.createColormapTexture(scaleInput, regl),
|
|
74
|
-
sentinelColormap: util.createColormapTexture(sentinelInput, regl),
|
|
75
|
-
textureManager: new TextureManager(regl, tileSize, normalTextureDimension, false),
|
|
76
|
-
drawTile: reglCommands.createDrawTileCommand(regl, commonDrawConfig, fragMacros),
|
|
77
|
-
aboveColor: util.colorStringToInts(aboveColor || '#00000000').map(i => i / 255.0),
|
|
78
|
-
belowColor: util.colorStringToInts(belowColor || '#00000000').map(i => i / 255.0)
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
destroy () {
|
|
83
|
-
if (this.regl) this.regl.destroy()
|
|
84
|
-
this.regl = null
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
renderTile ({ coords, pixelData }, _hillshadeOptions, zoom) {
|
|
88
|
-
const {
|
|
89
|
-
regl,
|
|
90
|
-
textureManager,
|
|
91
|
-
tileSize
|
|
92
|
-
} = this
|
|
93
|
-
this.setCanvasSize(tileSize, tileSize)
|
|
94
|
-
// Add image to the texture and retrieve its texture coordinates.
|
|
95
|
-
const textureBounds = textureManager.addTile(coords, pixelData)
|
|
96
|
-
|
|
97
|
-
regl.clear({ color: CLEAR_COLOR })
|
|
98
|
-
|
|
99
|
-
const zoomdelta = _hillshadeOptions.hsSimpleZoomdelta || 0
|
|
100
|
-
|
|
101
|
-
const offset_pixels = Math.max(0.5, 2 ** (zoom + zoomdelta) / 2048)
|
|
102
|
-
const offset_texcoords = offset_pixels / textureManager.texture.width
|
|
103
|
-
|
|
104
|
-
if (_hillshadeOptions.hillshadeType === 'none') {
|
|
105
|
-
this.drawTile({
|
|
106
|
-
canvasSize: [tileSize, tileSize],
|
|
107
|
-
canvasCoordinates: [0, 0],
|
|
108
|
-
textureBounds,
|
|
109
|
-
texture: textureManager.texture,
|
|
110
|
-
scaleLength: this.scaleInput.length,
|
|
111
|
-
sentinelLength: this.sentinelInput.length,
|
|
112
|
-
scaleColormap: this.scaleColormap,
|
|
113
|
-
sentinelColormap: this.sentinelColormap,
|
|
114
|
-
enableSimpleHillshade: false,
|
|
115
|
-
aboveColor: this.aboveColor,
|
|
116
|
-
belowColor: this.belowColor
|
|
117
|
-
})
|
|
118
|
-
} else if (_hillshadeOptions.hillshadeType === 'simple') {
|
|
119
|
-
this.drawTileHsSimple({
|
|
120
|
-
scaleLength: this.scaleInput.length,
|
|
121
|
-
sentinelLength: this.sentinelInput.length,
|
|
122
|
-
scaleColormap: this.scaleColormap,
|
|
123
|
-
sentinelColormap: this.sentinelColormap,
|
|
124
|
-
canvasSize: [tileSize, tileSize],
|
|
125
|
-
canvasCoordinates: [0, 0],
|
|
126
|
-
textureBounds: textureBounds,
|
|
127
|
-
texture: textureManager.texture,
|
|
128
|
-
textureSize: textureManager.texture.width,
|
|
129
|
-
tileSize: tileSize,
|
|
130
|
-
offset: offset_texcoords,
|
|
131
|
-
enableSimpleHillshade: true,
|
|
132
|
-
// elevationScale: _hillshadeOptions.hsElevationScale,
|
|
133
|
-
azimuth: _hillshadeOptions.hsSimpleAzimuth,
|
|
134
|
-
altitude: _hillshadeOptions.hsSimpleAltitude,
|
|
135
|
-
slopescale: _hillshadeOptions.hsSimpleSlopescale,
|
|
136
|
-
aboveColor: this.aboveColor,
|
|
137
|
-
belowColor: this.belowColor
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Since the tile will fill the whole canvas, the offset is simply [0, 0].
|
|
142
|
-
return [0, 0]
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
setCanvasSize (width, height) {
|
|
146
|
-
Object.assign(this.canvas, { width, height })
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
generateAmbientDirections (iterations) {
|
|
150
|
-
const ambientDirections = []
|
|
151
|
-
for (let i = 0; i < iterations; i++) {
|
|
152
|
-
const direction = vec3.random(vec3.create(), Math.random())
|
|
153
|
-
ambientDirections.push(direction)
|
|
154
|
-
}
|
|
155
|
-
this.ambientDirections = ambientDirections
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
generateSunDirections (iterations, sunRadiusMultiplier) {
|
|
159
|
-
const sunDirections = []
|
|
160
|
-
for (let i = 0; i < iterations; i++) {
|
|
161
|
-
const direction = vec3.normalize(
|
|
162
|
-
vec3.create(),
|
|
163
|
-
vec3.add(
|
|
164
|
-
vec3.create(),
|
|
165
|
-
vec3.scale(
|
|
166
|
-
vec3.create(),
|
|
167
|
-
vec3.normalize(vec3.create(), [1, 1, 1]),
|
|
168
|
-
EARTH_SUN_DISTANCE
|
|
169
|
-
),
|
|
170
|
-
vec3.random(vec3.create(), SUN_RADIUS * sunRadiusMultiplier)
|
|
171
|
-
)
|
|
172
|
-
)
|
|
173
|
-
sunDirections.push(direction)
|
|
174
|
-
}
|
|
175
|
-
this.sunDirections = sunDirections
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
updateColorscale (scaleInput) {
|
|
179
|
-
this.scaleInputPrevious = this.scaleInput
|
|
180
|
-
this.scaleInput = scaleInput
|
|
181
|
-
this.scaleColormapPrevious = this.scaleColormap
|
|
182
|
-
this.scaleColormap = util.createColormapTexture(scaleInput, this.regl)
|
|
183
|
-
}
|
|
184
|
-
updateOuteRangeColor (aboveColor, belowColor) {
|
|
185
|
-
this.aboveColorPrevious = this.aboveColor
|
|
186
|
-
this.aboveColor = util.colorStringToInts(aboveColor || '#00000000').map(i => i / 255.0)
|
|
187
|
-
this.belowColorPrevious = this.belowColor
|
|
188
|
-
this.belowColor = util.colorStringToInts(belowColor || '#00000000').map(i => i / 255.0)
|
|
189
|
-
}
|
|
190
|
-
updateSentinels (sentinelInput) {
|
|
191
|
-
this.sentinelInputPrevious = this.sentinelInput
|
|
192
|
-
this.sentinelInput = sentinelInput
|
|
193
|
-
this.sentinelColormapPrevious = this.sentinelColormap
|
|
194
|
-
this.sentinelColormap = util.createColormapTexture(sentinelInput, this.regl)
|
|
195
|
-
}
|
|
196
|
-
setMaxTextureDimension (newMaxTextureDimension) {
|
|
197
|
-
const {
|
|
198
|
-
textureManager,
|
|
199
|
-
tileSize,
|
|
200
|
-
regl
|
|
201
|
-
} = this
|
|
202
|
-
|
|
203
|
-
textureManager.destroy()
|
|
204
|
-
|
|
205
|
-
Object.assign(this, {
|
|
206
|
-
maxTextureDimension: newMaxTextureDimension,
|
|
207
|
-
textureManager: new TextureManager(regl, tileSize, newMaxTextureDimension, false)
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import glsl from 'glslify'
|
|
2
|
-
|
|
3
|
-
export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
4
|
-
precision highp float;
|
|
5
|
-
#else
|
|
6
|
-
precision mediump float;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
#pragma glslify: floatToRgba = require(glsl-float-to-rgba)
|
|
10
|
-
|
|
11
|
-
uniform float nodataValue;
|
|
12
|
-
uniform bool littleEndian;
|
|
13
|
-
uniform sampler2D texture;
|
|
14
|
-
varying vec2 vTexCoord;
|
|
15
|
-
|
|
16
|
-
void main() {
|
|
17
|
-
//sample the texture
|
|
18
|
-
vec3 rgb = texture2D(texture, vTexCoord).rgb;
|
|
19
|
-
|
|
20
|
-
// Convert the red, green, and blue channels into a float
|
|
21
|
-
float f = -10000.0 + ((rgb.r * 255.0 * 256.0 * 256.0 + rgb.g * 255.0 * 256.0 + rgb.b * 255.0) * 0.1);
|
|
22
|
-
|
|
23
|
-
// convert to rgba and write to framebuffer
|
|
24
|
-
gl_FragColor = floatToRgba(f, littleEndian);
|
|
25
|
-
}
|
|
26
|
-
`
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import glsl from 'glslify'
|
|
2
|
-
|
|
3
|
-
export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
4
|
-
precision highp float;
|
|
5
|
-
#else
|
|
6
|
-
precision mediump float;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
#pragma glslify: rgbaToFloat = require(glsl-rgba-to-float)
|
|
10
|
-
#pragma glslify: floatToRgba = require(glsl-float-to-rgba)
|
|
11
|
-
#pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
|
|
12
|
-
#pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
|
|
13
|
-
|
|
14
|
-
uniform sampler2D texture;
|
|
15
|
-
uniform float textureSize;
|
|
16
|
-
uniform bool littleEndian;
|
|
17
|
-
uniform float nodataValue;
|
|
18
|
-
varying vec2 vTexCoord;
|
|
19
|
-
uniform int kernelSize;
|
|
20
|
-
|
|
21
|
-
int kernelEnd = int(kernelSize/2);
|
|
22
|
-
int kernelStart = kernelEnd * -1;
|
|
23
|
-
|
|
24
|
-
float runConvKernel(vec2 pos, vec2 onePixel) {
|
|
25
|
-
float convKernelWeight = 0.0;
|
|
26
|
-
float sum = 0.0;
|
|
27
|
-
|
|
28
|
-
for (int i = -20; i < 20; i ++) {
|
|
29
|
-
if (i < kernelStart) continue;
|
|
30
|
-
if (i > kernelEnd) break;
|
|
31
|
-
for (int j = -20; j < 20; j ++) {
|
|
32
|
-
if (j < kernelStart) continue;
|
|
33
|
-
if (j > kernelEnd) break;
|
|
34
|
-
float texelValue = getTexelValue(texture, pos + onePixel * vec2(i, j), littleEndian);
|
|
35
|
-
if (!isCloseEnough(texelValue, nodataValue)) {
|
|
36
|
-
sum = sum + texelValue;
|
|
37
|
-
convKernelWeight = convKernelWeight + 1.0;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return (sum / convKernelWeight);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
void main() {
|
|
46
|
-
float texelFloat = getTexelValue(texture, vTexCoord, littleEndian);
|
|
47
|
-
if (isCloseEnough(texelFloat, nodataValue)) {
|
|
48
|
-
gl_FragColor = floatToRgba(nodataValue, littleEndian);
|
|
49
|
-
} else {
|
|
50
|
-
vec2 onePixel = vec2(1.0, 1.0) / textureSize;
|
|
51
|
-
float texelFloatSmoothed = runConvKernel(vTexCoord, onePixel);
|
|
52
|
-
gl_FragColor = floatToRgba(texelFloatSmoothed, littleEndian);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import glsl from 'glslify'
|
|
2
|
-
|
|
3
|
-
export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
4
|
-
precision highp float;
|
|
5
|
-
#else
|
|
6
|
-
precision mediump float;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
#pragma glslify: floatToRgba = require(glsl-float-to-rgba)
|
|
10
|
-
#pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
|
|
11
|
-
#pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
|
|
12
|
-
|
|
13
|
-
uniform float nodataValue;
|
|
14
|
-
uniform bool littleEndian;
|
|
15
|
-
uniform sampler2D textureA;
|
|
16
|
-
uniform sampler2D textureB;
|
|
17
|
-
|
|
18
|
-
varying vec2 vTexCoordA;
|
|
19
|
-
varying vec2 vTexCoordB;
|
|
20
|
-
|
|
21
|
-
void main() {
|
|
22
|
-
float texelFloatA = getTexelValue(textureA, vTexCoordA, littleEndian);
|
|
23
|
-
float texelFloatB = getTexelValue(textureB, vTexCoordB, littleEndian);
|
|
24
|
-
bool aIsNodata = isCloseEnough(texelFloatA, nodataValue);
|
|
25
|
-
bool bIsNodata = isCloseEnough(texelFloatB, nodataValue);
|
|
26
|
-
|
|
27
|
-
if (aIsNodata || bIsNodata) {
|
|
28
|
-
gl_FragColor = floatToRgba(nodataValue, littleEndian);
|
|
29
|
-
} else {
|
|
30
|
-
float diff = texelFloatB - texelFloatA;
|
|
31
|
-
gl_FragColor = floatToRgba(diff, littleEndian);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import glsl from 'glslify'
|
|
2
|
-
|
|
3
|
-
export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
4
|
-
precision highp float;
|
|
5
|
-
#else
|
|
6
|
-
precision mediump float;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
#define TRANSPARENT vec4(0.0)
|
|
10
|
-
|
|
11
|
-
#pragma glslify: computeColor = require(../util/computeColor.glsl)
|
|
12
|
-
#pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
|
|
13
|
-
#pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
|
|
14
|
-
|
|
15
|
-
uniform int scaleLength;
|
|
16
|
-
uniform int sentinelLength;
|
|
17
|
-
uniform sampler2D scaleColormap;
|
|
18
|
-
uniform sampler2D sentinelColormap;
|
|
19
|
-
|
|
20
|
-
uniform float nodataValue;
|
|
21
|
-
uniform sampler2D texture;
|
|
22
|
-
uniform bool littleEndian;
|
|
23
|
-
|
|
24
|
-
uniform vec4 aboveColor;
|
|
25
|
-
uniform vec4 belowColor;
|
|
26
|
-
|
|
27
|
-
varying vec2 vTexCoord;
|
|
28
|
-
|
|
29
|
-
void main() {
|
|
30
|
-
float f = getTexelValue(texture, vTexCoord, littleEndian);
|
|
31
|
-
|
|
32
|
-
if (isCloseEnough(f, nodataValue)) {
|
|
33
|
-
gl_FragColor = TRANSPARENT;
|
|
34
|
-
} else {
|
|
35
|
-
gl_FragColor = computeColor(
|
|
36
|
-
f,
|
|
37
|
-
scaleColormap,
|
|
38
|
-
sentinelColormap,
|
|
39
|
-
scaleLength,
|
|
40
|
-
sentinelLength,
|
|
41
|
-
littleEndian,
|
|
42
|
-
aboveColor,
|
|
43
|
-
belowColor
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import glsl from 'glslify'
|
|
2
|
-
|
|
3
|
-
export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
4
|
-
precision highp float;
|
|
5
|
-
#else
|
|
6
|
-
precision mediump float;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
uniform sampler2D tInput;
|
|
10
|
-
uniform sampler2D tNormal;
|
|
11
|
-
uniform sampler2D tSrc;
|
|
12
|
-
uniform vec3 direction;
|
|
13
|
-
uniform vec2 resolution;
|
|
14
|
-
uniform float pixelScale;
|
|
15
|
-
uniform float ambientIterations;
|
|
16
|
-
varying vec2 vTexCoord;
|
|
17
|
-
|
|
18
|
-
void main() {
|
|
19
|
-
vec2 ires = 1.0 / resolution;
|
|
20
|
-
vec3 src = texture2D(tSrc, gl_FragCoord.xy * ires).rgb;
|
|
21
|
-
vec4 e0 = texture2D(tInput, vTexCoord);
|
|
22
|
-
vec3 n0 = texture2D(tNormal, vTexCoord).rgb;
|
|
23
|
-
|
|
24
|
-
vec3 sr3d = normalize(n0 + direction); // ray direction
|
|
25
|
-
vec2 sr = normalize(sr3d.xy); // get 2D ray direction
|
|
26
|
-
|
|
27
|
-
// initialize pixel traversal algorithm
|
|
28
|
-
vec2 p0 = vTexCoord * resolution;
|
|
29
|
-
vec2 p = floor(p0); // pixel we are starting in
|
|
30
|
-
vec2 stp = sign(sr);
|
|
31
|
-
|
|
32
|
-
// how far we need to travel in our ray direction to intersect the next pixel
|
|
33
|
-
// in the x- and y- directions
|
|
34
|
-
vec2 tMax = step(0.0, sr) * (1.0 - fract(p0)) + (1.0 - step(0.0, sr)) * fract(p0);
|
|
35
|
-
tMax /= abs(sr);
|
|
36
|
-
// how far must we travel along our ray to cover the width and height of a pixel
|
|
37
|
-
vec2 tDelta = 1.0 / abs(sr);
|
|
38
|
-
|
|
39
|
-
// pixel traversal routine
|
|
40
|
-
for (int i = 0; i < 65536; i++) {
|
|
41
|
-
if (tMax.x < tMax.y) {
|
|
42
|
-
tMax.x += tDelta.x;
|
|
43
|
-
p.x += stp.x;
|
|
44
|
-
} else {
|
|
45
|
-
tMax.y += tDelta.y;
|
|
46
|
-
p.y += stp.y;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// normalized texture coordinate for the center of the current pixel
|
|
50
|
-
vec2 ptex = ires * (p + 0.5);
|
|
51
|
-
|
|
52
|
-
// If we left the tile: add some illumination to the pixel for this iteration and stop traversing
|
|
53
|
-
if (ptex.x < 0.0 || ptex.x > 1.0 || ptex.y < 0.0 || ptex.y > 1.0) {
|
|
54
|
-
// illumination of this single ray
|
|
55
|
-
vec3 illumination = vec3(1.0/ambientIterations);
|
|
56
|
-
// add illumination of this ray to result of previous iteration
|
|
57
|
-
gl_FragColor = vec4(src + illumination, 1.0);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// elevation/value at current pixel
|
|
62
|
-
vec4 e = texture2D(tInput, ptex);
|
|
63
|
-
// time we have traveled along the 2D ray
|
|
64
|
-
float time = distance(p + 0.5, p0);
|
|
65
|
-
// elevation along our original 3D ray at the current point
|
|
66
|
-
float z = e0.r + time * pixelScale * sr3d.z;
|
|
67
|
-
// If we did not exit tile, have we hit the terrain?
|
|
68
|
-
if (e.r > z) {
|
|
69
|
-
// We hit terrain. Do not add illumination for this iteration
|
|
70
|
-
gl_FragColor = vec4(src, 1.0);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Should have hit terrain or left the tile by this point, so should never need this
|
|
76
|
-
// If we finish the loop somehow, let’s pretend it’s been illuminated
|
|
77
|
-
vec3 illumination = vec3(1.0/ambientIterations);
|
|
78
|
-
gl_FragColor = vec4(src + illumination, 1.0);
|
|
79
|
-
}`
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import glsl from 'glslify'
|
|
2
|
-
|
|
3
|
-
export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
4
|
-
precision highp float;
|
|
5
|
-
#else
|
|
6
|
-
precision mediump float;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
#pragma glslify: computeColor = require(../../util/computeColor.glsl)
|
|
10
|
-
#pragma glslify: isCloseEnough = require(../../util/isCloseEnough.glsl)
|
|
11
|
-
|
|
12
|
-
uniform sampler2D tInput;
|
|
13
|
-
uniform sampler2D tNormal;
|
|
14
|
-
uniform float floatScale;
|
|
15
|
-
uniform vec3 sunDirection;
|
|
16
|
-
uniform float nodataValue;
|
|
17
|
-
uniform bool littleEndian;
|
|
18
|
-
varying vec2 vTexCoord;
|
|
19
|
-
|
|
20
|
-
uniform vec4 aboveColor;
|
|
21
|
-
uniform vec4 belowColor;
|
|
22
|
-
|
|
23
|
-
uniform int scaleLength;
|
|
24
|
-
uniform int sentinelLength;
|
|
25
|
-
uniform sampler2D scaleColormap;
|
|
26
|
-
uniform sampler2D sentinelColormap;
|
|
27
|
-
|
|
28
|
-
void main() {
|
|
29
|
-
float f = texture2D(tInput, vTexCoord).r;
|
|
30
|
-
|
|
31
|
-
if (isCloseEnough(f, nodataValue)) {
|
|
32
|
-
// discard;
|
|
33
|
-
gl_FragColor = vec4(0.0);
|
|
34
|
-
} else {
|
|
35
|
-
vec4 clr = computeColor(
|
|
36
|
-
f / floatScale,
|
|
37
|
-
scaleColormap,
|
|
38
|
-
sentinelColormap,
|
|
39
|
-
scaleLength,
|
|
40
|
-
sentinelLength,
|
|
41
|
-
littleEndian,
|
|
42
|
-
aboveColor,
|
|
43
|
-
belowColor
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
vec3 n = texture2D(tNormal, vTexCoord).rgb;
|
|
47
|
-
|
|
48
|
-
// light intensity that varies on the range [−1..1]
|
|
49
|
-
float light = dot(n, sunDirection);
|
|
50
|
-
// transform the light intensity to the range [0..1]
|
|
51
|
-
light = 0.5 * light + 0.5;
|
|
52
|
-
|
|
53
|
-
// gl_FragColor = vec4(l, l, l, 1.0); // to show light
|
|
54
|
-
|
|
55
|
-
vec3 color = light * pow(clr.rgb, vec3(2.0));
|
|
56
|
-
color = pow(color, vec3(1.0/2.2));
|
|
57
|
-
gl_FragColor = vec4(color, 1.0);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
`
|