@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.
Files changed (81) hide show
  1. package/dist/catchUtil.min.esm.js +67927 -14001
  2. package/dist/catchUtil.min.js +2695 -55
  3. package/package.json +22 -3
  4. package/src/constants/annotation_color.js +7 -0
  5. package/src/constants/annotation_draw_style.js +228 -0
  6. package/src/constants/annotation_label_style.js +76 -0
  7. package/src/constants/annotation_style.js +118 -0
  8. package/src/constants/cameras.js +1 -1
  9. package/src/constants/crs.js +31473 -31473
  10. package/src/constants/error_codes.js +44 -0
  11. package/src/constants/height_colors.js +1 -0
  12. package/src/constants/index.js +9 -2
  13. package/src/constants/map_style.js +11 -0
  14. package/src/constants/measurement_fields.js +3 -3
  15. package/src/{event.js → event/event.js} +1 -14
  16. package/src/event/event_bus.js +5 -0
  17. package/src/event/index.js +2 -0
  18. package/src/gl-operations/constants.js +9 -11
  19. package/src/gl-operations/default_options.js +5 -5
  20. package/src/gl-operations/index.js +166 -239
  21. package/src/gl-operations/reglCommands/contours.js +20 -20
  22. package/src/gl-operations/reglCommands/default.js +34 -34
  23. package/src/gl-operations/reglCommands/hillshading.js +116 -116
  24. package/src/gl-operations/reglCommands/index.js +6 -6
  25. package/src/gl-operations/reglCommands/multiLayers.js +55 -55
  26. package/src/gl-operations/reglCommands/transitions.js +24 -24
  27. package/src/gl-operations/reglCommands/util.js +54 -54
  28. package/src/gl-operations/renderer.js +69 -69
  29. package/src/gl-operations/shaders/transform.js +2 -2
  30. package/src/gl-operations/shaders/util/rgbaToFloat.glsl +11 -11
  31. package/src/gl-operations/texture_manager.js +58 -58
  32. package/src/gl-operations/util.js +154 -154
  33. package/src/index.js +14 -2
  34. package/src/measure/index.js +198 -0
  35. package/src/measure/tile_cache.js +88 -0
  36. package/src/mvs/index.js +26 -0
  37. package/src/mvs/protos/index.js +12 -0
  38. package/src/mvs/protos/proto_10.js +155 -0
  39. package/src/observation_pretict.js +168 -0
  40. package/src/photo-parser/exif/gps_tags.js +33 -0
  41. package/src/photo-parser/exif/ifd1_tags.js +22 -0
  42. package/src/photo-parser/exif/index.js +130 -0
  43. package/src/photo-parser/exif/parse_image.js +290 -0
  44. package/src/photo-parser/exif/string_values.js +137 -0
  45. package/src/photo-parser/exif/tags.js +75 -0
  46. package/src/photo-parser/exif/tiff_tags.js +35 -0
  47. package/src/photo-parser/exif/util.js +103 -0
  48. package/src/photo-parser/image-size/detector.js +24 -0
  49. package/src/photo-parser/image-size/fromFile.js +55 -0
  50. package/src/photo-parser/image-size/index.js +2 -0
  51. package/src/photo-parser/image-size/lookup.js +37 -0
  52. package/src/photo-parser/image-size/types/bmp.js +10 -0
  53. package/src/photo-parser/image-size/types/cur.js +16 -0
  54. package/src/photo-parser/image-size/types/dds.js +10 -0
  55. package/src/photo-parser/image-size/types/gif.js +11 -0
  56. package/src/photo-parser/image-size/types/heif.js +35 -0
  57. package/src/photo-parser/image-size/types/icns.js +112 -0
  58. package/src/photo-parser/image-size/types/ico.js +74 -0
  59. package/src/photo-parser/image-size/types/index.js +43 -0
  60. package/src/photo-parser/image-size/types/j2c.js +11 -0
  61. package/src/photo-parser/image-size/types/jp2.js +22 -0
  62. package/src/photo-parser/image-size/types/jpg.js +157 -0
  63. package/src/photo-parser/image-size/types/ktx.js +18 -0
  64. package/src/photo-parser/image-size/types/png.js +36 -0
  65. package/src/photo-parser/image-size/types/pnm.js +74 -0
  66. package/src/photo-parser/image-size/types/psd.js +10 -0
  67. package/src/photo-parser/image-size/types/svg.js +100 -0
  68. package/src/photo-parser/image-size/types/tga.js +14 -0
  69. package/src/photo-parser/image-size/types/tiff.js +92 -0
  70. package/src/photo-parser/image-size/types/utils.js +83 -0
  71. package/src/photo-parser/image-size/types/webp.js +67 -0
  72. package/src/photo-parser/index.js +181 -0
  73. package/src/report/annotations_report.js +446 -0
  74. package/src/report/index.js +2 -0
  75. package/src/report/map_util.js +81 -0
  76. package/src/report/pdf_creator.js +247 -0
  77. package/src/report/report.js +583 -0
  78. package/src/transform.js +204 -0
  79. package/src/util.js +371 -75
  80. package/CHANGELOG.md +0 -60
  81. /package/src/constants/{colors.js → dsm_colors.js} +0 -0
package/src/util.js CHANGED
@@ -5,49 +5,84 @@ import cameras from './constants/cameras'
5
5
  import {getType, distance as calcDistance, midpoint as getMidpoint} from '@turf/turf'
6
6
  import { layerGroups } from './constants'
7
7
  import { mat4 } from 'gl-matrix'
8
- import { crsList, crsTypes } from './constants'
8
+ import {transformCoordinateToLngLat, project} from './transform'
9
+ import * as turf from '@turf/turf'
9
10
 
10
- export function generateId() { // 生成随机id
11
+ /**
12
+ * 生成uuid随机字符串
13
+ * @returns uuid字符串
14
+ */
15
+ export function generateId () { // 生成随机id
11
16
  return uuidv4()
12
17
  }
13
- export function formatDate(date) {
18
+
19
+ /**
20
+ * 将给定的日期格式化
21
+ * @param {*} date
22
+ * @returns
23
+ */
24
+ export function formatDate (date) {
14
25
  if (!date) {
15
26
  return '-'
16
27
  }
17
28
  return moment(date).format('YYYY-MM-DD HH:mm:ss')
18
29
  }
19
- export function formatLocalDate() {
30
+
31
+ /**
32
+ * 另一种日期格式化
33
+ * @returns
34
+ */
35
+ export function formatLocalDate () {
20
36
  return moment().format('YYYY/M/D HH:mm:ss')
21
37
  }
22
- export function formatFileSize (value) { // 文件大小格式化,自动换算kb\mb\gb
38
+
39
+ /**
40
+ * 将文件大小格式化,自动换算kb\mb\gb
41
+ * @param {*} value 文件大小,单位“字节”
42
+ * @returns
43
+ */
44
+ export function formatFileSize (value) {
23
45
  value = parseInt(value)
24
- value = value.toString()
25
- const length = value.length
26
- if (length > 6) {
27
- value = (Number(value) / 1000000).toFixed(2)
28
- return value + ' MB'
29
- } else {
30
- value = (Number(value) / 1000).toFixed(2)
31
- return value + ' KB'
32
- }
46
+ let level = Math.floor(Math.log(value) / Math.log(1024)) // 整数部分
47
+ let units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
48
+ return _.round(value / Math.pow(1024, level), 2) + units[level]
33
49
  }
34
- export function getGeoCoordOperator(flag) { // 将照片的中的经纬度方位字母换成正负号
50
+
51
+ /**
52
+ * 根据exif中的经纬度标志判断正负号
53
+ * @param {*} flag
54
+ * @returns
55
+ */
56
+ export function getGeoCoordOperator (flag) { // 将照片的中的经纬度方位字母换成正负号
35
57
  if (flag === 'N' || flag === 'E') {
36
58
  return 1
37
59
  }
38
60
  return -1
39
61
  }
40
- export function toRadian(arr) { // 度分秒转弧度
62
+
63
+ /**
64
+ * 度分秒转弧度
65
+ * @param {*} arr 度分秒数组
66
+ * @returns
67
+ */
68
+ export function toRadian (arr) {
41
69
  return arr[0] + (arr[1] / 60) + (arr[2] / 3600)
42
70
  }
43
- export function diffLayers(newList, oldList = []) { // 任务详情中的任务成果树进行差异计算,获取图层更新的操作
71
+
72
+ /**
73
+ * 任务详情中的任务成果树进行差异计算,获取图层更新的操作
74
+ * @param {*} newList
75
+ * @param {*} oldList
76
+ * @returns
77
+ */
78
+ export function diffLayers (newList, oldList = []) {
44
79
  newList = _formatTree(newList)
45
80
  oldList = _formatTree(oldList)
46
81
  let cmds = []
47
82
  for(let group of newList) {
48
83
  let {visible: groupVisible} = group
49
84
  for(let layer of group.items || []) {
50
- let {id, type, opacity, visible, color, geometry} = layer
85
+ let {id, type, opacity, visible} = layer
51
86
  if (!groupVisible) {
52
87
  visible = false
53
88
  }
@@ -76,7 +111,7 @@ export function diffLayers(newList, oldList = []) { // 任务详情中的任务
76
111
  } else if (opacity !== oldOpacity || (!_.isEqual(layer.metadata, oldNode.metadata))) {
77
112
  cmds.push(['updateLayer', layer])
78
113
  } else if (visible !== oldVisible){
79
- cmds.push([visible?'addLayer':'removeLayer', layer])
114
+ cmds.push([visible ? 'addLayer' : 'removeLayer', layer])
80
115
  }
81
116
  }
82
117
  }
@@ -95,7 +130,14 @@ export function diffLayers(newList, oldList = []) { // 任务详情中的任务
95
130
  }
96
131
  return cmds
97
132
  }
98
- export function findNodeInTree(id, tree) { // 从图层树中查找指定
133
+
134
+ /**
135
+ * 从图层树结构中查找指定id的节点
136
+ * @param {*} id 需要查找的节点id
137
+ * @param {*} tree 图层树
138
+ * @returns
139
+ */
140
+ export function findNodeInTree (id, tree) { // 从图层树中查找指定
99
141
  for(let node of tree) {
100
142
  if (node.id === id) {
101
143
  return node
@@ -109,7 +151,7 @@ export function findNodeInTree(id, tree) { // 从图层树中查找指定
109
151
  }
110
152
  return null
111
153
  }
112
- function _formatTree(treeList) {
154
+ function _formatTree (treeList) {
113
155
  let tree = _.cloneDeep(treeList)
114
156
  for(let group of tree) {
115
157
  for(let layer of group.items || []) {
@@ -120,7 +162,13 @@ function _formatTree(treeList) {
120
162
  }
121
163
  return tree
122
164
  }
123
- // 获取比当前图层,层级更低的图层id
165
+
166
+ /**
167
+ * 在mapbox中获取即将插入图层的位置,根据图层metadata中的图层类型来确定图层顺序
168
+ * @param {*} map 当前地图对象
169
+ * @param {*} layer 即将插入的图层
170
+ * @returns
171
+ */
124
172
  export function getBeforeId (map,layer){
125
173
  let layersForFilter = map.style._layers
126
174
  let orders = map.style.order
@@ -166,14 +214,26 @@ export function getBeforeId (map,layer){
166
214
  return level
167
215
  }
168
216
  }
169
- export function isTokenExpired(response) {
217
+
218
+ /**
219
+ * 判断当前响应是否为token过期
220
+ * @param {*} response
221
+ * @returns
222
+ */
223
+ export function isTokenExpired (response) {
170
224
  if (!response) {
171
225
  return false
172
226
  }
173
- let {message = '', msg =''} = response.data
227
+ let {message = '', msg = ''} = response.data
174
228
  return response.status == 401 && (msg.toLowerCase().includes('expired') || message.toLowerCase().includes('expired'))
175
229
  }
176
- export function getDataType(model) { // 根据相机型号获取照片的类型
230
+
231
+ /**
232
+ * 根据相机型号获取照片的类型
233
+ * @param {*} model 相机型号
234
+ * @returns
235
+ */
236
+ export function getDataType (model) {
177
237
  for(let type in cameras) {
178
238
  if (cameras[type].includes(model)) {
179
239
  return type
@@ -181,7 +241,12 @@ export function getDataType(model) { // 根据相机型号获取照片的类型
181
241
  }
182
242
  return 'normal'
183
243
  }
184
- export function downloadImage(base64) {
244
+
245
+ /**
246
+ * 下载base64格式的图像快照
247
+ * @param {*} base64
248
+ */
249
+ export function downloadImage (base64) {
185
250
  let filename = `快照${moment().format('YYYYMMDD')}${new Date().getTime()}.png`
186
251
  let a = document.createElement('a')
187
252
  a.href = base64
@@ -190,7 +255,13 @@ export function downloadImage(base64) {
190
255
  a.click()
191
256
  document.body.removeChild(a)
192
257
  }
193
- export function getGeometryType(feature) {
258
+
259
+ /**
260
+ * 获取geojon要素的几何类型
261
+ * @param {*} feature
262
+ * @returns point/line/polygon
263
+ */
264
+ export function getGeometryType (feature) {
194
265
  let type = getType(feature)
195
266
  if (['Point', 'MultiPoint'].includes(type)) {
196
267
  return 'point'
@@ -200,14 +271,26 @@ export function getGeometryType(feature) {
200
271
  return 'polygon'
201
272
  }
202
273
  }
203
- export function rgbaToFloat(v) {
274
+
275
+ /**
276
+ * 将png图片中一个像素(四字节的数组)转为float32浮点数
277
+ * @param {*} v
278
+ * @returns
279
+ */
280
+ export function rgbaToFloat (v) {
204
281
  let a = v[3] > 128.0 ? 0 : 1
205
- let sign = -1 * (1 - a) + a;
206
- let expo = Math.floor((v[3] + 0.1) % 128.0) * 2.0 + Math.floor((v[2] + 0.1) / 128.0) - 127.0;
207
- let sig = v[0] + v[1] * 256.0 + Math.floor((v[2] + 0.1) % 128.0) * 256.0 * 256.0;
208
- return sign * (1.0 + sig / 8388607.0) * Math.pow(2.0, expo);
282
+ let sign = -1 * (1 - a) + a
283
+ let expo = Math.floor((v[3] + 0.1) % 128.0) * 2.0 + Math.floor((v[2] + 0.1) / 128.0) - 127.0
284
+ let sig = v[0] + v[1] * 256.0 + Math.floor((v[2] + 0.1) % 128.0) * 256.0 * 256.0
285
+ return sign * (1.0 + sig / 8388607.0) * Math.pow(2.0, expo)
209
286
  }
210
- export function getAnnotationFeature(annotationItem) {
287
+
288
+ /**
289
+ * 将标注的数据库对象转为GeoJSON对象
290
+ * @param {*} annotationItem
291
+ * @returns
292
+ */
293
+ export function getAnnotationFeature (annotationItem) {
211
294
  let {geometry} = annotationItem
212
295
  let properties = _.cloneDeep(annotationItem)
213
296
  delete properties.geometry
@@ -218,7 +301,14 @@ export function getAnnotationFeature(annotationItem) {
218
301
  geometry: _.cloneDeep(geometry)
219
302
  }
220
303
  }
221
- export function getAnnotationName(annotations, type) {
304
+
305
+ /**
306
+ * 根据已有的标注列表计算一个默认的标注名称,确保名称唯一
307
+ * @param {*} annotations 当前已有的标注列表
308
+ * @param {*} type 标注类型
309
+ * @returns
310
+ */
311
+ export function getAnnotationName (annotations, type) {
222
312
  let indexs = []
223
313
  let name = type === 'point' ? '点注记' : (type === 'line' ? '线注记' : '面注记')
224
314
  annotations.forEach(item => {
@@ -233,7 +323,7 @@ export function getAnnotationName(annotations, type) {
233
323
  }
234
324
  }
235
325
  })
236
- indexs = indexs.sort((a, b) => a-b)
326
+ indexs = indexs.sort((a, b) => a - b)
237
327
  for(let i = 0;i < indexs.length;i++) {
238
328
  if (indexs[i] !== i) {
239
329
  return i === 0 ? name : `${name} ${i}`
@@ -241,19 +331,25 @@ export function getAnnotationName(annotations, type) {
241
331
  }
242
332
  return indexs.length === 0 ? name : `${name} ${indexs.length}`
243
333
  }
244
- export function getLineLabelFeature(lineFeature) {
334
+
335
+ /**
336
+ * 计算线要素标注的文字注记绘制的位置和方向
337
+ * @param {*} lineFeature
338
+ * @returns 返回一个GeoJSON点要素,其集合属性中是文字标注的位置,要素属性中是标注的方向
339
+ */
340
+ export function getLineLabelFeature (lineFeature) {
245
341
  let coordinates = lineFeature.geometry.coordinates
246
342
  let temps = []
247
343
  for(let i = 1;i < coordinates.length;i++) {
248
- let distance = calcDistance(coordinates[i-1], coordinates[i], {units: 'meters'})
344
+ let distance = calcDistance(coordinates[i - 1], coordinates[i], {units: 'meters'})
249
345
  if (distance > 30) {
250
- temps.push([coordinates[i-1], coordinates[i]])
346
+ temps.push([coordinates[i - 1], coordinates[i]])
251
347
  }
252
348
  }
253
349
  let labelLine = []
254
350
  if (!temps.length) {
255
351
  let mid = Math.floor(coordinates.length / 2 - 1)
256
- labelLine = [coordinates[mid], coordinates[mid+1]]
352
+ labelLine = [coordinates[mid], coordinates[mid + 1]]
257
353
  } else {
258
354
  let mid = Math.floor(temps.length / 2)
259
355
  labelLine = temps[mid]
@@ -267,15 +363,12 @@ export function getLineLabelFeature(lineFeature) {
267
363
  midPoint.geometry.coordinates.push(((labelLine[0][2] || 0) + (labelLine[1][2] || 0)) / 2)
268
364
  return midPoint
269
365
  }
270
- export function project(lngLat, zoom=12) { // 经纬度转墨卡托像素坐标
271
- let [lng, lat] = lngLat
272
- let x = (180 + lng) / 360
273
- let y = (180 - (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) / 360
274
- return {
275
- x: x * Math.pow(2, zoom) * 512,
276
- y: y * Math.pow(2, zoom) * 512
277
- }
278
- }
366
+
367
+ /**
368
+ * 将图标文件当作mapbox地图的符号添加到地图对象
369
+ * @param {*} map 当前地图对象
370
+ * @param {*} icons 要添加的图标列表,包含图标的url以及是否作为sdf符号
371
+ */
279
372
  export function addIcons2Map (map, icons) {
280
373
  icons.forEach(({url, sdf}) => {
281
374
  map.loadImage(url, (error, image) => {
@@ -287,7 +380,14 @@ export function addIcons2Map (map, icons) {
287
380
  })
288
381
  }
289
382
 
290
- export function getTaskTreeList(taskInfo, annotations, layers) {
383
+ /**
384
+ * 构造任务成果树的结构
385
+ * @param {*} taskInfo
386
+ * @param {*} annotations
387
+ * @param {*} layers
388
+ * @returns
389
+ */
390
+ export function getTaskTreeList (taskInfo, annotations, layers) {
291
391
  let groups = _.cloneDeep(taskInfo.metadata?.groups || layerGroups)
292
392
  groups.forEach(g => g.items = [])
293
393
  annotations.forEach(item => {
@@ -310,6 +410,11 @@ export function getTaskTreeList(taskInfo, annotations, layers) {
310
410
  return groups
311
411
  }
312
412
 
413
+ /**
414
+ * 判断当前数组中是否包含非数值要素
415
+ * @param {*} arr
416
+ * @returns
417
+ */
313
418
  export function hasNaN (arr) {
314
419
  for (let i = 0; i < arr.length; i++) {
315
420
  if (Number.isNaN(arr[i])) {
@@ -319,6 +424,31 @@ export function hasNaN (arr) {
319
424
  return false
320
425
  }
321
426
 
427
+ export function flatObject (obj) {
428
+ let arr = {}
429
+ for(let key in obj) {
430
+ if (key.startsWith('xmlns')) {
431
+ continue
432
+ }
433
+ if (Array.isArray(obj[key])) {
434
+ continue
435
+ }
436
+ if (typeof obj[key] === 'object') {
437
+ Object.assign(arr, flatObject(obj[key]))
438
+ } else {
439
+ arr[key] = obj[key]
440
+ }
441
+ }
442
+ return arr
443
+ }
444
+
445
+ /**
446
+ * 根据pry参数计算旋转矩阵
447
+ * @param {*} pitch
448
+ * @param {*} roll
449
+ * @param {*} yaw
450
+ * @returns
451
+ */
322
452
  export function getRotationMatrix (pitch, roll, yaw) {
323
453
  let orientation = []
324
454
  let enu2ned = mat4.fromValues(0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)
@@ -336,32 +466,198 @@ export function getRotationMatrix (pitch, roll, yaw) {
336
466
  return orientation
337
467
  }
338
468
 
339
- export function getWKTString(crs) {
340
- let {type, epsg_code} = crs
341
- for(let i = 0;i < crsList.length;i++) {
342
- let typeCode = crsTypes[crsList[i].type].code
343
- if (typeCode !== type) {
344
- continue
345
- }
346
- let {authCode, wkt, children} = crsList[i]
347
- if (authCode == epsg_code) {
348
- return wkt
349
- }
350
- if (children?.length) {
351
- for(let j = 0;j < children.length;j++) {
352
- if (children[j].children) {
353
- for(let n = 0;n < children[j].children.length;n++) {
354
- if (children[j].children[n].authCode == epsg_code) {
355
- return children[j].children[n].wkt
356
- }
357
- }
358
- } else {
359
- if (children[j].authCode == epsg_code) {
360
- return children[j].wkt
361
- }
362
- }
469
+ /**
470
+ * 将LocalENU坐标系的ROI转为经纬度
471
+ * @param {*} roi 带转换的roi结构
472
+ * @param {*} crs 目标坐标系,当前仅支持LocalENU
473
+ * @returns
474
+ */
475
+ export function transformRoi (roi, crs) {
476
+ let {boundary, min_z, max_z} = roi
477
+ let {type, origin_point} = crs
478
+ if (type === 0) { // LocalENU
479
+ let newBoundary = []
480
+ boundary.forEach(coord => {
481
+ let lla = transformCoordinateToLngLat([...coord, 0], crs)
482
+ newBoundary.push(lla)
483
+ })
484
+ min_z += origin_point[2]
485
+ max_z += origin_point[2]
486
+ return {boundary: newBoundary, min_z, max_z}
487
+ }
488
+ return roi // Local系,不做转换
489
+ }
490
+
491
+ /**
492
+ * 根据当前pos精度描述获得精度的具体数值
493
+ * @param {*} accurency
494
+ * @returns
495
+ */
496
+ export function getPosSigma (accurency) {
497
+ if (accurency === 'high') {
498
+ return [0.03, 0.03, 0.06]
499
+ } else if (accurency === 'low') {
500
+ return [10, 10, 10]
501
+ } else {
502
+ return [1, 1, 1]
503
+ }
504
+ }
505
+
506
+ /**
507
+ * 根据照片列表中解析的pos,将照片列表转为GeoJSON
508
+ * @param {*} photoList
509
+ * @returns
510
+ */
511
+ export function photoPos2Geojson (photoList) {
512
+ let features = []
513
+ let item = photoList.find(d => d.meta_data.pos)
514
+ if (item) {
515
+ let coordinate_system = _.cloneDeep(item.meta_data.coordinate_system)
516
+ photoList.forEach(photo => {
517
+ let {meta_data = {}} = photo
518
+ let {pos} = meta_data
519
+ let position = transformCoordinateToLngLat(pos, coordinate_system)
520
+ if (!position) {
521
+ return
363
522
  }
523
+ let properties = _.cloneDeep(photo)
524
+ properties.type = 'photo'
525
+ features.push(turf.point(position, properties))
526
+ })
527
+ }
528
+
529
+ let geojson = turf.featureCollection(features)
530
+ let bbox = null
531
+ if (features.length) {
532
+ bbox = turf.bbox(geojson)
533
+ }
534
+ return {geojson, bbox}
535
+ }
536
+
537
+ export function getDistance (p1, p2) {
538
+ return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]))
539
+ }
540
+
541
+ export function getMaxValue (arr, field) {
542
+ let value = -Infinity
543
+ arr.forEach(item => {
544
+ value = Math.max(item[field], value)
545
+ })
546
+ return value
547
+ }
548
+
549
+ export function getAverageValue (arr, field) {
550
+ let sum = 0
551
+ arr.forEach(item => {
552
+ sum += item[field]
553
+ })
554
+ return sum / arr.length
555
+ }
556
+
557
+ export function getAppVersion (taskInfo) {
558
+ let {appVersion, environment} = taskInfo.metadata
559
+ if (appVersion) {
560
+ return appVersion
561
+ }
562
+ if (environment) {
563
+ return `${environment.platform}(${environment.appVersion})`
564
+ }
565
+ return '暂无'
566
+ }
567
+
568
+ /**
569
+ * 将重建质量的数值转为名称
570
+ * @param {*} quality 重建质量-1/2/3
571
+ * @returns
572
+ */
573
+ export function getResolutionLevelByQuality (quality){
574
+ switch (quality) {
575
+ case 'low':
576
+ return 3
577
+ case 'high':
578
+ return 1
579
+ case 'medium':
580
+ default:
581
+ return 2
582
+ }
583
+ }
584
+
585
+ export function getQualityAliasByLevel (resolutionLevel) {
586
+ let alias = '高'
587
+ if (resolutionLevel === 1) {
588
+ alias = '超高'
589
+ } else if (resolutionLevel === 3) {
590
+ alias = '中'
591
+ }
592
+ return alias
593
+ }
594
+
595
+ /**
596
+ * 将数据类型的数值转字符串
597
+ * @param {*} dataType
598
+ * @returns
599
+ */
600
+ export function getImageTypeByDataType (dataType){
601
+ switch (dataType) {
602
+ case 'normal':
603
+ return 1
604
+ case 'multispectral':
605
+ return 2
606
+ case 'infrared':
607
+ default:
608
+ return 3
609
+ }
610
+ }
611
+
612
+ export function getDataTypeAliasByImageType (type) {
613
+ if (type === 'infrared') {
614
+ return '热红外'
615
+ } else if (type === 'multispectral') {
616
+ return '多光谱'
617
+ } else {
618
+ return '可见光'
619
+ }
620
+ }
621
+
622
+ export function getTaskStatusAlias (status) {
623
+ if (status === 'complete') {
624
+ return '建模完成'
625
+ } else if (status === 'error') {
626
+ return '建模出错'
627
+ } else if (status === 'none') {
628
+ return '未开始'
629
+ } else if (status === 'waiting') {
630
+ return '正在排队'
631
+ } else if (status === 'aerotriangulation') {
632
+ return '空三完成'
633
+ } else if (status.startsWith('processing')){
634
+ return '正在处理'
635
+ } else if (status === 'stop'){
636
+ return '任务终止'
637
+ } else {
638
+ return '未知状态'
639
+ }
640
+ }
641
+
642
+ /**
643
+ * 根据重建参数的输出属性判断是否开启了3d建模
644
+ */
645
+ export function include3d (output = []) {
646
+ if (output.length && output.includes('mesh3d')) {
647
+ return true
648
+ }
649
+ return false
650
+ }
651
+
652
+ export function extend (dest, ...sources) {
653
+ for (const src of sources) {
654
+ for (const k in src) {
655
+ dest[k] = src[k]
364
656
  }
365
657
  }
366
- return null
367
- }
658
+ return dest
659
+ }
660
+ export function endsWith (string, suffix) {
661
+ return string.indexOf(suffix, string.length - suffix.length) !== -1
662
+ }
663
+
package/CHANGELOG.md DELETED
@@ -1,60 +0,0 @@
1
- ## v1.0.2
2
-
3
- - [fix] 修复图片解析报错的问题。
4
-
5
- ## v1.0.3
6
-
7
- - [fix] 修复`util.formatDate(date)`日期一直是当前日期的bug
8
- - [add] 增加`util.getTaskTreeList()`工具函数
9
- - [add] 增加`layerGroups`、`bmapTypes`、`colors`、`defaultLayers`、`layerFolders`、`layerIcons`、`mapViewModes`、`taskParams`、`tools`常量
10
-
11
- ## v1.0.4
12
-
13
- - [add] 常量`layerGroups`增加覆盖物分组
14
- - [add] 常量`layerIcons`增加overlay/geojson/raster/object类型图标
15
-
16
- ## v1.0.5
17
-
18
- - [fix] 地图底图的服务地址修改为https协议
19
- - [fix] 工具函数`diffLayers`增加覆盖物图层更新的比较
20
-
21
- ## v1.0.6
22
-
23
- - [improve] `util.getPhotoInfo`函数返回值增加图像的width和height
24
-
25
- ## v1.0.7
26
-
27
- - [fix] 修复获取exif中可能存在宽高错误的问题
28
- - [improve] 获取照片属性时没有GPS也会返回其他的属性信息
29
-
30
- ## v1.0.8
31
-
32
- - [improve] 支持tiff等其他格式图片获取宽高
33
-
34
- ## v1.0.9
35
-
36
- - [fix] 修复华为相机的照片解析失败的问题
37
-
38
- ## v1.0.10
39
-
40
- - [add] 增加`util.hasNaN()`和`util.getRotationMatrix()`接口
41
- - [add] 增加常量`crsTypes` `measurementFields`
42
- - [improve] 更新常量`defaultLayers`和`layerFolders`
43
- - [delete] 删除`getPhotoTags`接口
44
-
45
- ## v1.0.11
46
-
47
- - [add] 增加`util.getWKTString(epsg_code)`接口
48
- - [add] 增加常量`crsList`
49
-
50
- ## v1.0.12
51
-
52
- - [improve] 点标注的显示字段增加经度(lng)和纬度(lat)
53
-
54
- ## v1.0.13
55
-
56
- - [improve] diffLayers检查所有图层的metadata,有变化则提交更新
57
-
58
- ## v1.0.14
59
-
60
- - [improve] addIcons2Map支持sdf符号
File without changes