@mapcatch/util 1.0.15 → 2.0.1
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 +67927 -14001
- 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/constants/measurement_fields.js +3 -3
- 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,63 +1,63 @@
|
|
|
1
|
-
import { memoize } from 'lodash'
|
|
2
|
-
import { decode, toRGBA8 } from 'upng-js'
|
|
1
|
+
import { memoize } from 'lodash'
|
|
2
|
+
import { decode, toRGBA8 } from 'upng-js'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
RGB_REGEX,
|
|
6
|
-
HEX_REGEX
|
|
7
|
-
} from './constants'
|
|
6
|
+
HEX_REGEX
|
|
7
|
+
} from './constants'
|
|
8
8
|
|
|
9
|
-
export function machineIsLittleEndian() {
|
|
10
|
-
const uint8Array = new Uint8Array([0xAA, 0xBB])
|
|
11
|
-
const uint16array = new Uint16Array(uint8Array.buffer)
|
|
12
|
-
return uint16array[0] === 0xBBAA
|
|
9
|
+
export function machineIsLittleEndian () {
|
|
10
|
+
const uint8Array = new Uint8Array([0xAA, 0xBB])
|
|
11
|
+
const uint16array = new Uint16Array(uint8Array.buffer)
|
|
12
|
+
return uint16array[0] === 0xBBAA
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Cribbed from Python's built-in `range` function.
|
|
17
17
|
*/
|
|
18
|
-
export function range(...args) {
|
|
18
|
+
export function range (...args) {
|
|
19
19
|
if (args.length === 1) {
|
|
20
|
-
const [until] = args
|
|
21
|
-
return new Array(until).fill(undefined).map((_, i) => i)
|
|
20
|
+
const [until] = args
|
|
21
|
+
return new Array(until).fill(undefined).map((_, i) => i)
|
|
22
22
|
} else {
|
|
23
|
-
const [from, until, step = 1] = args
|
|
23
|
+
const [from, until, step = 1] = args
|
|
24
24
|
if (step === 0) {
|
|
25
|
-
throw new Error('Argument step must be nonzero.')
|
|
25
|
+
throw new Error('Argument step must be nonzero.')
|
|
26
26
|
}
|
|
27
|
-
const output = []
|
|
27
|
+
const output = []
|
|
28
28
|
for (let val = from; (step > 0) ? val < until : val > until; val += step) {
|
|
29
|
-
output.push(val)
|
|
29
|
+
output.push(val)
|
|
30
30
|
}
|
|
31
|
-
return output
|
|
31
|
+
return output
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Fetch a png and decode data. If png does not exist return an array with nodataValue.
|
|
37
37
|
*/
|
|
38
|
-
export async function fetchPNGData(url, nodataValue, tileDimension) {
|
|
38
|
+
export async function fetchPNGData (url, nodataValue, tileDimension) {
|
|
39
39
|
return new Promise((resolve, reject) => {
|
|
40
|
-
const xhr = new XMLHttpRequest()
|
|
41
|
-
xhr.open(
|
|
42
|
-
xhr.responseType =
|
|
40
|
+
const xhr = new XMLHttpRequest()
|
|
41
|
+
xhr.open('GET', url, true)
|
|
42
|
+
xhr.responseType = 'arraybuffer'
|
|
43
43
|
xhr.addEventListener('load', () => {
|
|
44
|
-
resolve(xhr.response)
|
|
45
|
-
})
|
|
46
|
-
xhr.addEventListener('error', reject)
|
|
47
|
-
xhr.send(null)
|
|
44
|
+
resolve(xhr.response)
|
|
45
|
+
})
|
|
46
|
+
xhr.addEventListener('error', reject)
|
|
47
|
+
xhr.send(null)
|
|
48
48
|
}).then((data) => {
|
|
49
|
-
const img = decode(data)
|
|
50
|
-
const rgba = toRGBA8(img)[0]
|
|
51
|
-
return new Uint8Array(rgba)
|
|
52
|
-
}).catch(() => createNoDataTile(nodataValue, tileDimension))
|
|
49
|
+
const img = decode(data)
|
|
50
|
+
const rgba = toRGBA8(img)[0]
|
|
51
|
+
return new Uint8Array(rgba)
|
|
52
|
+
}).catch(() => createNoDataTile(nodataValue, tileDimension))
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Check if two TypedArrays are equal
|
|
57
57
|
*/
|
|
58
|
-
export function typedArraysAreEqual(a, b) {
|
|
59
|
-
if (a.byteLength !== b.byteLength) return false
|
|
60
|
-
return a.every((val, i) => val === b[i])
|
|
58
|
+
export function typedArraysAreEqual (a, b) {
|
|
59
|
+
if (a.byteLength !== b.byteLength) return false
|
|
60
|
+
return a.every((val, i) => val === b[i])
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -65,115 +65,115 @@ export function typedArraysAreEqual(a, b) {
|
|
|
65
65
|
* buffer (with upper left corner (0, 0) and lower right corner (buffer width, buffer height))
|
|
66
66
|
* to WebGL "clipspace", with upper left corner (-1, 1) and lower right corner (1, -1).
|
|
67
67
|
*/
|
|
68
|
-
export function getTransformMatrix(drawingBufferWidth, drawingBufferHeight) {
|
|
68
|
+
export function getTransformMatrix (drawingBufferWidth, drawingBufferHeight) {
|
|
69
69
|
// To scale horizontally, divide by width (in pixels) and multiply by 2, because width is 2 in clipspace.
|
|
70
|
-
const sx = 2 / drawingBufferWidth
|
|
70
|
+
const sx = 2 / drawingBufferWidth
|
|
71
71
|
// To scale vertically, divide by height (in pixels) and multiply by -2, because height is 2 in clipspace,
|
|
72
72
|
// and the direction is flipped (positive is up, negative is down).
|
|
73
|
-
const sy = -2 / drawingBufferHeight
|
|
73
|
+
const sy = -2 / drawingBufferHeight
|
|
74
74
|
// We translate by -1 horizontally (so the range 0 to 2 maps to the range -1 to 1).
|
|
75
|
-
const tx = -1
|
|
75
|
+
const tx = -1
|
|
76
76
|
// We translate by 1 horizontally (so the range -2 to 0 maps to the range -1 to 1).
|
|
77
|
-
const ty = 1
|
|
77
|
+
const ty = 1
|
|
78
78
|
// Matrix must be in column-major order for WebGL.
|
|
79
79
|
return [
|
|
80
|
-
sx, 0,
|
|
81
|
-
0,
|
|
82
|
-
0,
|
|
83
|
-
tx, ty, 0, 1
|
|
84
|
-
]
|
|
80
|
+
sx, 0, 0, 0,
|
|
81
|
+
0, sy, 0, 0,
|
|
82
|
+
0, 0, 1, 0,
|
|
83
|
+
tx, ty, 0, 1
|
|
84
|
+
]
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* From a TextureBounds object, this function generates the four vertices WebGL needs to draw the
|
|
89
89
|
* corresponding rectangle (as two conjoined triangles generated with the triangle strip primitive).
|
|
90
90
|
*/
|
|
91
|
-
export function getTexCoordVerticesTriangleStripQuad(textureBounds) {
|
|
92
|
-
const [{ x: left, y: top }, { x: right, y: bottom }] = textureBounds
|
|
91
|
+
export function getTexCoordVerticesTriangleStripQuad (textureBounds) {
|
|
92
|
+
const [{ x: left, y: top }, { x: right, y: bottom }] = textureBounds
|
|
93
93
|
return [
|
|
94
|
-
[left,
|
|
95
|
-
[right, top
|
|
96
|
-
[left,
|
|
97
|
-
[right, bottom]
|
|
98
|
-
]
|
|
94
|
+
[left, top ],
|
|
95
|
+
[right, top ],
|
|
96
|
+
[left, bottom],
|
|
97
|
+
[right, bottom]
|
|
98
|
+
]
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* From a TextureBounds object, this function generates the six vertices WebGL needs to draw the
|
|
103
103
|
* corresponding rectangle (as two triangles).
|
|
104
104
|
*/
|
|
105
|
-
export function getTexCoordVerticesTriangleQuad(textureBounds) {
|
|
106
|
-
const [{ x: left, y: top }, { x: right, y: bottom }] = textureBounds
|
|
105
|
+
export function getTexCoordVerticesTriangleQuad (textureBounds) {
|
|
106
|
+
const [{ x: left, y: top }, { x: right, y: bottom }] = textureBounds
|
|
107
107
|
return [
|
|
108
|
-
[left,
|
|
109
|
-
[right, top
|
|
110
|
-
[left,
|
|
108
|
+
[left, top ],
|
|
109
|
+
[right, top ],
|
|
110
|
+
[left, bottom],
|
|
111
111
|
[right, bottom],
|
|
112
|
-
[right, top
|
|
113
|
-
[left,
|
|
114
|
-
]
|
|
112
|
+
[right, top ],
|
|
113
|
+
[left, bottom]
|
|
114
|
+
]
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* Produces a Promise that resolves when the desired `duration` has expired.
|
|
119
119
|
*/
|
|
120
|
-
export function Timer(duration) {
|
|
121
|
-
return new Promise((resolve) => setTimeout(resolve, duration))
|
|
120
|
+
export function Timer (duration) {
|
|
121
|
+
return new Promise((resolve) => setTimeout(resolve, duration))
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Useful for sorting TileCoordinates objects.
|
|
126
126
|
*/
|
|
127
|
-
export function compareTileCoordinates(a, b) {
|
|
128
|
-
const z = a.z - b.z
|
|
129
|
-
const x = a.x - b.x
|
|
130
|
-
const y = a.y - b.y
|
|
127
|
+
export function compareTileCoordinates (a, b) {
|
|
128
|
+
const z = a.z - b.z
|
|
129
|
+
const x = a.x - b.x
|
|
130
|
+
const y = a.y - b.y
|
|
131
131
|
if (z !== 0) {
|
|
132
132
|
// First compare z values.
|
|
133
|
-
return z
|
|
133
|
+
return z
|
|
134
134
|
} else if (x !== 0) {
|
|
135
135
|
// If z values are the same, compare x values.
|
|
136
|
-
return x
|
|
136
|
+
return x
|
|
137
137
|
} else {
|
|
138
138
|
// If x values are the same, compare y values.
|
|
139
|
-
return y
|
|
139
|
+
return y
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Determines whether two arrays of TileCoordinates are the same.
|
|
145
145
|
*/
|
|
146
|
-
export function sameTiles(a, b) {
|
|
146
|
+
export function sameTiles (a, b) {
|
|
147
147
|
return (
|
|
148
148
|
// arrays are of the same length
|
|
149
149
|
a.length === b.length
|
|
150
150
|
// and corresponding elements have the same tile coordinates
|
|
151
151
|
&& a.every((tileA, index) => compareTileCoordinates(tileA, b[index]) === 0)
|
|
152
|
-
)
|
|
152
|
+
)
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
export const createNoDataTile = memoize((nodataValue, tileDimension = 256) => {
|
|
156
156
|
// Create a float 32 array.
|
|
157
|
-
const float32Tile = new Float32Array(tileDimension * tileDimension)
|
|
157
|
+
const float32Tile = new Float32Array(tileDimension * tileDimension)
|
|
158
158
|
// Fill the tile array with the no data value
|
|
159
|
-
float32Tile.fill(nodataValue)
|
|
159
|
+
float32Tile.fill(nodataValue)
|
|
160
160
|
// return the no data tile.
|
|
161
|
-
return new Uint8Array(float32Tile.buffer)
|
|
162
|
-
})
|
|
161
|
+
return new Uint8Array(float32Tile.buffer)
|
|
162
|
+
})
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
165
|
* Force TypeScript to interpret value `val` as type `T`.
|
|
166
166
|
*/
|
|
167
|
-
export function staticCast(val) {
|
|
168
|
-
return val
|
|
167
|
+
export function staticCast (val) {
|
|
168
|
+
return val
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Add one or more macro definitions to a GLSL source string.
|
|
173
173
|
*/
|
|
174
|
-
export function defineMacros(src, macros) {
|
|
175
|
-
const defs = Object.keys(macros).map((key) => `#define ${key} ${macros[key]}\n`).join('')
|
|
176
|
-
return `${defs}\n${src}
|
|
174
|
+
export function defineMacros (src, macros) {
|
|
175
|
+
const defs = Object.keys(macros).map((key) => `#define ${key} ${macros[key]}\n`).join('')
|
|
176
|
+
return `${defs}\n${src}`
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
@@ -181,26 +181,26 @@ export function defineMacros(src, macros) {
|
|
|
181
181
|
* then use it as a source texture in our next iteration.
|
|
182
182
|
* Then swap them and continue. Used for advanced hillshading.
|
|
183
183
|
*/
|
|
184
|
-
export function PingPong(regl, opts) {
|
|
185
|
-
const fbos = [regl.framebuffer(opts), regl.framebuffer(opts)]
|
|
184
|
+
export function PingPong (regl, opts) {
|
|
185
|
+
const fbos = [regl.framebuffer(opts), regl.framebuffer(opts)]
|
|
186
186
|
|
|
187
|
-
let index = 0
|
|
187
|
+
let index = 0
|
|
188
188
|
|
|
189
|
-
function ping() {
|
|
190
|
-
return fbos[index]
|
|
189
|
+
function ping () {
|
|
190
|
+
return fbos[index]
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
function pong() {
|
|
194
|
-
return fbos[1 - index]
|
|
193
|
+
function pong () {
|
|
194
|
+
return fbos[1 - index]
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
function swap() {
|
|
198
|
-
index = 1 - index
|
|
197
|
+
function swap () {
|
|
198
|
+
index = 1 - index
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
function destroy() {
|
|
202
|
-
fbos[0].destroy()
|
|
203
|
-
fbos[1].destroy()
|
|
201
|
+
function destroy () {
|
|
202
|
+
fbos[0].destroy()
|
|
203
|
+
fbos[1].destroy()
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
return {
|
|
@@ -208,7 +208,7 @@ export function PingPong(regl, opts) {
|
|
|
208
208
|
pong,
|
|
209
209
|
swap,
|
|
210
210
|
destroy
|
|
211
|
-
}
|
|
211
|
+
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
@@ -216,33 +216,33 @@ export function PingPong(regl, opts) {
|
|
|
216
216
|
* const [r, g, b, a] = hexToRGB("#ffeeaaff")
|
|
217
217
|
*/
|
|
218
218
|
export const hexToRGB = (hex) => {
|
|
219
|
-
const hasAlpha = hex.length === 9
|
|
220
|
-
const start = hasAlpha ? 24 : 16
|
|
221
|
-
const bigint = parseInt(hex.slice(1), 16)
|
|
222
|
-
const r = (bigint >> start) & 255
|
|
223
|
-
const g = (bigint >> (start - 8)) & 255
|
|
224
|
-
const b = (bigint >> (start - 16)) & 255
|
|
225
|
-
const a = hasAlpha ? (bigint >> (start - 24)) & 255 : 255
|
|
226
|
-
return [r, g, b, a]
|
|
227
|
-
}
|
|
219
|
+
const hasAlpha = hex.length === 9
|
|
220
|
+
const start = hasAlpha ? 24 : 16
|
|
221
|
+
const bigint = parseInt(hex.slice(1), 16)
|
|
222
|
+
const r = (bigint >> start) & 255
|
|
223
|
+
const g = (bigint >> (start - 8)) & 255
|
|
224
|
+
const b = (bigint >> (start - 16)) & 255
|
|
225
|
+
const a = hasAlpha ? (bigint >> (start - 24)) & 255 : 255
|
|
226
|
+
return [r, g, b, a]
|
|
227
|
+
}
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Parses a color string of the form 'rgb({rVal}, {gVal}, {bVal})' and converts the resulting values
|
|
231
231
|
* to an array with ints 0 - 255.
|
|
232
232
|
*/
|
|
233
|
-
export function colorStringToInts(colorstring) {
|
|
233
|
+
export function colorStringToInts (colorstring) {
|
|
234
234
|
if (colorstring === 'transparent') {
|
|
235
|
-
return [0, 0, 0, 0]
|
|
235
|
+
return [0, 0, 0, 0]
|
|
236
236
|
}
|
|
237
|
-
const rgbmatch = colorstring.match(RGB_REGEX)
|
|
238
|
-
const hexmatch = colorstring.match(HEX_REGEX)
|
|
237
|
+
const rgbmatch = colorstring.match(RGB_REGEX)
|
|
238
|
+
const hexmatch = colorstring.match(HEX_REGEX)
|
|
239
239
|
if (rgbmatch !== null) {
|
|
240
|
-
const [, r, g, b] = rgbmatch
|
|
241
|
-
return [+r, +g, +b, 255]
|
|
240
|
+
const [, r, g, b] = rgbmatch
|
|
241
|
+
return [+r, +g, +b, 255]
|
|
242
242
|
} else if (hexmatch !== null) {
|
|
243
|
-
return hexToRGB(colorstring)
|
|
243
|
+
return hexToRGB(colorstring)
|
|
244
244
|
} else {
|
|
245
|
-
throw new Error(`'${colorstring}' is not a valid RGB or hex color expression.`)
|
|
245
|
+
throw new Error(`'${colorstring}' is not a valid RGB or hex color expression.`)
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -252,85 +252,85 @@ export function colorStringToInts(colorstring) {
|
|
|
252
252
|
* The second row contains the encoded offset values.
|
|
253
253
|
*/
|
|
254
254
|
export const colormapToFlatArray = (colormap) => {
|
|
255
|
-
const offsets = []
|
|
256
|
-
let colors = []
|
|
255
|
+
const offsets = []
|
|
256
|
+
let colors = []
|
|
257
257
|
for (let i = 0; i < colormap.length; i++) {
|
|
258
|
-
offsets.push(colormap[i].offset)
|
|
259
|
-
const colorsnew = colorStringToInts(colormap[i].color)
|
|
260
|
-
colors = colors.concat(colorsnew)
|
|
258
|
+
offsets.push(colormap[i].offset)
|
|
259
|
+
const colorsnew = colorStringToInts(colormap[i].color)
|
|
260
|
+
colors = colors.concat(colorsnew)
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
const floatOffsets = new Float32Array(offsets)
|
|
264
|
-
const uintOffsets = new Uint8Array(floatOffsets.buffer)
|
|
265
|
-
const normalOffsets = Array.from(uintOffsets)
|
|
266
|
-
const colormapArray = colors.concat(normalOffsets)
|
|
263
|
+
const floatOffsets = new Float32Array(offsets)
|
|
264
|
+
const uintOffsets = new Uint8Array(floatOffsets.buffer)
|
|
265
|
+
const normalOffsets = Array.from(uintOffsets)
|
|
266
|
+
const colormapArray = colors.concat(normalOffsets)
|
|
267
267
|
|
|
268
|
-
return colormapArray
|
|
269
|
-
}
|
|
268
|
+
return colormapArray
|
|
269
|
+
}
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* Creates a texture with colors on first row and offsets on second row
|
|
273
273
|
*/
|
|
274
|
-
export function createColormapTexture(colormapInput, regl) {
|
|
275
|
-
const colormapFlatArray = colormapToFlatArray(colormapInput)
|
|
276
|
-
let colormapTexture
|
|
274
|
+
export function createColormapTexture (colormapInput, regl) {
|
|
275
|
+
const colormapFlatArray = colormapToFlatArray(colormapInput)
|
|
276
|
+
let colormapTexture
|
|
277
277
|
if (colormapInput.length === 0) {
|
|
278
278
|
// empty texture
|
|
279
279
|
colormapTexture = regl.texture({
|
|
280
280
|
shape: [2, 2]
|
|
281
|
-
})
|
|
281
|
+
})
|
|
282
282
|
} else {
|
|
283
283
|
colormapTexture = regl.texture({
|
|
284
284
|
width: colormapInput.length,
|
|
285
285
|
height: 2,
|
|
286
286
|
data: colormapFlatArray
|
|
287
|
-
})
|
|
287
|
+
})
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
return colormapTexture
|
|
290
|
+
return colormapTexture
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
/**
|
|
294
294
|
* Fetch 8 adjacent tiles, if not already existing in tileManager.
|
|
295
295
|
* Return array with texture coord vertices for all tiles.
|
|
296
296
|
*/
|
|
297
|
-
export async function getAdjacentTilesTexCoords(gloperations, textureManager, coords, url) {
|
|
297
|
+
export async function getAdjacentTilesTexCoords (gloperations, textureManager, coords, url) {
|
|
298
298
|
// Get existing tiles in TextureManager
|
|
299
|
-
const textureContents = textureManager.contents
|
|
299
|
+
const textureContents = textureManager.contents
|
|
300
300
|
|
|
301
301
|
// use 3x3 tiles for adv. hillshading
|
|
302
302
|
// TODO: add as plugin option?
|
|
303
|
-
const adjacentTiles = 3
|
|
304
|
-
let textureCoords = []
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
303
|
+
const adjacentTiles = 3
|
|
304
|
+
let textureCoords = []
|
|
305
|
+
|
|
306
|
+
for (let i = 0; i < adjacentTiles; i++) {
|
|
307
|
+
const _x = coords['x'] + (i - 1)
|
|
308
|
+
for (let j = 0; j < adjacentTiles; j++) {
|
|
309
|
+
const _y = coords['y'] + (j - 1)
|
|
310
|
+
const coordsAdjacent = {
|
|
311
|
+
x: _x,
|
|
312
|
+
y: _y,
|
|
313
|
+
z: coords['z']
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Fetch data for adjacent tile if not already existing in TextureManager
|
|
317
|
+
const hashKey = textureManager.hashTileCoordinates(coordsAdjacent)
|
|
318
|
+
if (!textureContents.has(hashKey)) {
|
|
319
|
+
// Retrieve and add data to TextureManager
|
|
320
|
+
const pixelDataAdjacent = await gloperations._fetchTileData(coordsAdjacent, url)
|
|
321
|
+
const textureBounds = gloperations._renderer.textureManager.addTile(coordsAdjacent, pixelDataAdjacent)
|
|
322
|
+
textureCoords = textureCoords.concat(getTexCoordVerticesTriangleQuad(textureBounds))
|
|
323
|
+
} else {
|
|
324
|
+
const textureBounds = gloperations._renderer.textureManager.getTextureCoordinates(coordsAdjacent)
|
|
325
|
+
textureCoords = textureCoords.concat(getTexCoordVerticesTriangleQuad(textureBounds))
|
|
327
326
|
}
|
|
328
327
|
}
|
|
329
|
-
|
|
328
|
+
}
|
|
329
|
+
return textureCoords
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
export function delay(ms) {
|
|
333
|
-
return new Promise(function(resolve) {
|
|
334
|
-
|
|
335
|
-
})
|
|
332
|
+
export function delay (ms) {
|
|
333
|
+
return new Promise(function (resolve) {
|
|
334
|
+
setTimeout(resolve, ms)
|
|
335
|
+
})
|
|
336
336
|
}
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
// 常用公共函数和工具函数
|
|
2
2
|
export * from './util'
|
|
3
3
|
// 事件处理类
|
|
4
|
-
export
|
|
4
|
+
export * from './event'
|
|
5
5
|
// dsm瓦片渲染类
|
|
6
6
|
export {default as GLOperations} from './gl-operations'
|
|
7
7
|
// 常量
|
|
8
|
-
export * from './constants'
|
|
8
|
+
export * from './constants'
|
|
9
|
+
// 照片解析
|
|
10
|
+
export * from './photo-parser'
|
|
11
|
+
// 刺点预测
|
|
12
|
+
export * from './observation_pretict'
|
|
13
|
+
// 坐标转换
|
|
14
|
+
export * as transform from './transform'
|
|
15
|
+
// 空三解析
|
|
16
|
+
export * from './mvs'
|
|
17
|
+
// 生成报告
|
|
18
|
+
export * from './report'
|
|
19
|
+
// 标注测量
|
|
20
|
+
export {default as Measurement} from './measure'
|