@mapcatch/util 2.0.5 → 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 +44507 -42819
- package/dist/catchUtil.min.js +248 -248
- package/package.json +16 -23
- package/CHANGELOG.md +0 -72
- 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 -192
- 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
package/src/util.js
DELETED
|
@@ -1,671 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid'
|
|
2
|
-
import moment from 'moment'
|
|
3
|
-
import _ from 'lodash'
|
|
4
|
-
import cameras from './constants/cameras'
|
|
5
|
-
import {getType, distance as calcDistance, midpoint as getMidpoint} from '@turf/turf'
|
|
6
|
-
import { layerGroups } from './constants'
|
|
7
|
-
import { mat4 } from 'gl-matrix'
|
|
8
|
-
import {transformCoordinateToLngLat, project} from './transform'
|
|
9
|
-
import * as turf from '@turf/turf'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 生成uuid随机字符串
|
|
13
|
-
* @returns uuid字符串
|
|
14
|
-
*/
|
|
15
|
-
export function generateId () { // 生成随机id
|
|
16
|
-
return uuidv4()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 将给定的日期格式化
|
|
21
|
-
* @param {*} date
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
export function formatDate (date) {
|
|
25
|
-
if (!date) {
|
|
26
|
-
return '-'
|
|
27
|
-
}
|
|
28
|
-
return moment(date).format('YYYY-MM-DD HH:mm:ss')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 另一种日期格式化
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
export function formatLocalDate () {
|
|
36
|
-
return moment().format('YYYY/M/D HH:mm:ss')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 将文件大小格式化,自动换算kb\mb\gb
|
|
41
|
-
* @param {*} value 文件大小,单位“字节”
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
export function formatFileSize (value) {
|
|
45
|
-
value = parseInt(value)
|
|
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]
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 根据exif中的经纬度标志判断正负号
|
|
53
|
-
* @param {*} flag
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
export function getGeoCoordOperator (flag) { // 将照片的中的经纬度方位字母换成正负号
|
|
57
|
-
if (flag === 'N' || flag === 'E') {
|
|
58
|
-
return 1
|
|
59
|
-
}
|
|
60
|
-
return -1
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 度分秒转弧度
|
|
65
|
-
* @param {*} arr 度分秒数组
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
export function toRadian (arr) {
|
|
69
|
-
return arr[0] + (arr[1] / 60) + (arr[2] / 3600)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 任务详情中的任务成果树进行差异计算,获取图层更新的操作
|
|
74
|
-
* @param {*} newList
|
|
75
|
-
* @param {*} oldList
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
export function diffLayers (newList, oldList = []) {
|
|
79
|
-
newList = _formatTree(newList)
|
|
80
|
-
oldList = _formatTree(oldList)
|
|
81
|
-
let cmds = []
|
|
82
|
-
for(let group of newList) {
|
|
83
|
-
let {visible: groupVisible} = group
|
|
84
|
-
for(let layer of group.items || []) {
|
|
85
|
-
let {id, type, opacity, visible} = layer
|
|
86
|
-
if (!groupVisible) {
|
|
87
|
-
visible = false
|
|
88
|
-
}
|
|
89
|
-
if (['point', 'line', 'polygon'].includes(type) && cmds.find(d => d[0] === 'updateAnnotations')) {
|
|
90
|
-
continue
|
|
91
|
-
}
|
|
92
|
-
let oldNode = findNodeInTree(id, oldList)
|
|
93
|
-
if (!oldNode && !visible) {
|
|
94
|
-
continue
|
|
95
|
-
}
|
|
96
|
-
if (!oldNode) {
|
|
97
|
-
if (['point', 'line', 'polygon'].includes(type)) {
|
|
98
|
-
cmds.push(['updateAnnotations', layer])
|
|
99
|
-
} else {
|
|
100
|
-
cmds.push(['addLayer', layer])
|
|
101
|
-
}
|
|
102
|
-
continue
|
|
103
|
-
}
|
|
104
|
-
let {opacity: oldOpacity, visible: oldVisible} = oldNode
|
|
105
|
-
if (_.isEqual(layer, oldNode)) {
|
|
106
|
-
continue
|
|
107
|
-
}
|
|
108
|
-
// 有属性更新
|
|
109
|
-
if (['point', 'line', 'polygon'].includes(type)) {
|
|
110
|
-
cmds.push(['updateAnnotations', layer])
|
|
111
|
-
} else if (opacity !== oldOpacity || (!_.isEqual(layer.metadata, oldNode.metadata))) {
|
|
112
|
-
cmds.push(['updateLayer', layer])
|
|
113
|
-
} else if (visible !== oldVisible){
|
|
114
|
-
cmds.push([visible ? 'addLayer' : 'removeLayer', layer])
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
for(let group of oldList) {
|
|
119
|
-
for(let layer of group.items || []) {
|
|
120
|
-
let {id, type} = layer
|
|
121
|
-
let newNode = findNodeInTree(id, newList)
|
|
122
|
-
if (!newNode) {
|
|
123
|
-
if (!['point', 'line', 'polygon'].includes(type)) {
|
|
124
|
-
cmds.push(['removeLayer', layer])
|
|
125
|
-
} else if (!cmds.find(d => d[0] === 'updateAnnotations')){
|
|
126
|
-
cmds.push(['updateAnnotations', layer])
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return cmds
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 从图层树结构中查找指定id的节点
|
|
136
|
-
* @param {*} id 需要查找的节点id
|
|
137
|
-
* @param {*} tree 图层树
|
|
138
|
-
* @returns
|
|
139
|
-
*/
|
|
140
|
-
export function findNodeInTree (id, tree) { // 从图层树中查找指定
|
|
141
|
-
for(let node of tree) {
|
|
142
|
-
if (node.id === id) {
|
|
143
|
-
return node
|
|
144
|
-
}
|
|
145
|
-
if (node.items?.length) {
|
|
146
|
-
let subNode = findNodeInTree(id, node.items)
|
|
147
|
-
if (subNode) {
|
|
148
|
-
return subNode
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return null
|
|
153
|
-
}
|
|
154
|
-
function _formatTree (treeList) {
|
|
155
|
-
let tree = _.cloneDeep(treeList)
|
|
156
|
-
for(let group of tree) {
|
|
157
|
-
for(let layer of group.items || []) {
|
|
158
|
-
if (!group.visible) {
|
|
159
|
-
layer.visible = false
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return tree
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* 在mapbox中获取即将插入图层的位置,根据图层metadata中的图层类型来确定图层顺序
|
|
168
|
-
* @param {*} map 当前地图对象
|
|
169
|
-
* @param {*} layer 即将插入的图层
|
|
170
|
-
* @returns
|
|
171
|
-
*/
|
|
172
|
-
export function getBeforeId (map,layer){
|
|
173
|
-
let layersForFilter = map.style._layers
|
|
174
|
-
let orders = map.style.order
|
|
175
|
-
let {layerType:insertType} = layer.metadata
|
|
176
|
-
// 获取到level比当前大的
|
|
177
|
-
// 如果同级,则添加到最后
|
|
178
|
-
let beforeLayer = orders.find(id=>{
|
|
179
|
-
let targetData = layersForFilter[id].metadata
|
|
180
|
-
if(_.isEmpty(targetData)) {
|
|
181
|
-
targetData = {
|
|
182
|
-
layerType: 'dsm'
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return getLevelByLayerType(insertType,layer.id) < getLevelByLayerType(targetData.layerType,id) ? true : false
|
|
186
|
-
})
|
|
187
|
-
return beforeLayer || ''
|
|
188
|
-
|
|
189
|
-
function getLevelByLayerType (type,id){
|
|
190
|
-
// 此数组维护一个图层类型的先后关系
|
|
191
|
-
// 越在前,则代表此图层层级越低
|
|
192
|
-
const layerTypeLevel = [
|
|
193
|
-
['bmap'],
|
|
194
|
-
['dom'],
|
|
195
|
-
['ndvi'],
|
|
196
|
-
['dsm'],
|
|
197
|
-
['circle'],
|
|
198
|
-
['annotation'],
|
|
199
|
-
['label']
|
|
200
|
-
]
|
|
201
|
-
let level = -1
|
|
202
|
-
if (id.startsWith('gl-draw')) {
|
|
203
|
-
level = 5
|
|
204
|
-
} else {
|
|
205
|
-
level = layerTypeLevel.findIndex(types=>{
|
|
206
|
-
return types.includes(type)
|
|
207
|
-
})
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if(level === -1){
|
|
211
|
-
//console.error(`id为${id}的图层层级未知`)
|
|
212
|
-
return 100
|
|
213
|
-
}
|
|
214
|
-
return level
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* 判断当前响应是否为token过期
|
|
220
|
-
* @param {*} response
|
|
221
|
-
* @returns
|
|
222
|
-
*/
|
|
223
|
-
export function isTokenExpired (response) {
|
|
224
|
-
if (!response) {
|
|
225
|
-
return false
|
|
226
|
-
}
|
|
227
|
-
let {message = '', msg = ''} = response.data
|
|
228
|
-
return response.status == 401 && (msg.toLowerCase().includes('expired') || message.toLowerCase().includes('expired'))
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* 根据相机型号获取照片的类型
|
|
233
|
-
* @param {*} model 相机型号
|
|
234
|
-
* @returns
|
|
235
|
-
*/
|
|
236
|
-
export function getDataType (model) {
|
|
237
|
-
for(let type in cameras) {
|
|
238
|
-
if (cameras[type].includes(model)) {
|
|
239
|
-
return type
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return 'normal'
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* 下载base64格式的图像快照
|
|
247
|
-
* @param {*} base64
|
|
248
|
-
*/
|
|
249
|
-
export function downloadImage (base64) {
|
|
250
|
-
let filename = `快照${moment().format('YYYYMMDD')}${new Date().getTime()}.png`
|
|
251
|
-
let a = document.createElement('a')
|
|
252
|
-
a.href = base64
|
|
253
|
-
a.download = filename
|
|
254
|
-
document.body.appendChild(a)
|
|
255
|
-
a.click()
|
|
256
|
-
document.body.removeChild(a)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* 获取geojon要素的几何类型
|
|
261
|
-
* @param {*} feature
|
|
262
|
-
* @returns point/line/polygon
|
|
263
|
-
*/
|
|
264
|
-
export function getGeometryType (feature) {
|
|
265
|
-
let type = getType(feature)
|
|
266
|
-
if (['Point', 'MultiPoint'].includes(type)) {
|
|
267
|
-
return 'point'
|
|
268
|
-
} else if (['LineString', 'MultiLineString'].includes(type)) {
|
|
269
|
-
return 'line'
|
|
270
|
-
} else {
|
|
271
|
-
return 'polygon'
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* 将png图片中一个像素(四字节的数组)转为float32浮点数
|
|
277
|
-
* @param {*} v
|
|
278
|
-
* @returns
|
|
279
|
-
*/
|
|
280
|
-
export function rgbaToFloat (v) {
|
|
281
|
-
let a = v[3] > 128.0 ? 0 : 1
|
|
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)
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* 将标注的数据库对象转为GeoJSON对象
|
|
290
|
-
* @param {*} annotationItem
|
|
291
|
-
* @returns
|
|
292
|
-
*/
|
|
293
|
-
export function getAnnotationFeature (annotationItem) {
|
|
294
|
-
let {geometry} = annotationItem
|
|
295
|
-
let properties = _.cloneDeep(annotationItem)
|
|
296
|
-
delete properties.geometry
|
|
297
|
-
return {
|
|
298
|
-
id: properties.id,
|
|
299
|
-
type: 'Feature',
|
|
300
|
-
properties,
|
|
301
|
-
geometry: _.cloneDeep(geometry)
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* 根据已有的标注列表计算一个默认的标注名称,确保名称唯一
|
|
307
|
-
* @param {*} annotations 当前已有的标注列表
|
|
308
|
-
* @param {*} type 标注类型
|
|
309
|
-
* @returns
|
|
310
|
-
*/
|
|
311
|
-
export function getAnnotationName (annotations, type) {
|
|
312
|
-
let indexs = []
|
|
313
|
-
let name = type === 'point' ? '点注记' : (type === 'line' ? '线注记' : '面注记')
|
|
314
|
-
annotations.forEach(item => {
|
|
315
|
-
if (item.name === name) {
|
|
316
|
-
indexs.push(0)
|
|
317
|
-
return
|
|
318
|
-
}
|
|
319
|
-
if (item.name.startsWith(`${name} `)) {
|
|
320
|
-
let i = Number(item.name.split(' ').pop())
|
|
321
|
-
if (!Number.isNaN(i)) {
|
|
322
|
-
indexs.push(i)
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
})
|
|
326
|
-
indexs = indexs.sort((a, b) => a - b)
|
|
327
|
-
for(let i = 0;i < indexs.length;i++) {
|
|
328
|
-
if (indexs[i] !== i) {
|
|
329
|
-
return i === 0 ? name : `${name} ${i}`
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return indexs.length === 0 ? name : `${name} ${indexs.length}`
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* 计算线要素标注的文字注记绘制的位置和方向
|
|
337
|
-
* @param {*} lineFeature
|
|
338
|
-
* @returns 返回一个GeoJSON点要素,其集合属性中是文字标注的位置,要素属性中是标注的方向
|
|
339
|
-
*/
|
|
340
|
-
export function getLineLabelFeature (lineFeature) {
|
|
341
|
-
let coordinates = lineFeature.geometry.coordinates
|
|
342
|
-
let temps = []
|
|
343
|
-
for(let i = 1;i < coordinates.length;i++) {
|
|
344
|
-
let distance = calcDistance(coordinates[i - 1], coordinates[i], {units: 'meters'})
|
|
345
|
-
if (distance > 30) {
|
|
346
|
-
temps.push([coordinates[i - 1], coordinates[i]])
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
let labelLine = []
|
|
350
|
-
if (!temps.length) {
|
|
351
|
-
let mid = Math.floor(coordinates.length / 2 - 1)
|
|
352
|
-
labelLine = [coordinates[mid], coordinates[mid + 1]]
|
|
353
|
-
} else {
|
|
354
|
-
let mid = Math.floor(temps.length / 2)
|
|
355
|
-
labelLine = temps[mid]
|
|
356
|
-
}
|
|
357
|
-
let start = project(labelLine[0])
|
|
358
|
-
let end = project(labelLine[1])
|
|
359
|
-
let angle = 360 - (Math.atan((start.y - end.y) / (end.x - start.x)) * 180) / Math.PI
|
|
360
|
-
let midPoint = getMidpoint(labelLine[0], labelLine[1])
|
|
361
|
-
midPoint.properties = lineFeature.properties
|
|
362
|
-
midPoint.properties.angle = angle
|
|
363
|
-
midPoint.geometry.coordinates.push(((labelLine[0][2] || 0) + (labelLine[1][2] || 0)) / 2)
|
|
364
|
-
return midPoint
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* 将图标文件当作mapbox地图的符号添加到地图对象
|
|
369
|
-
* @param {*} map 当前地图对象
|
|
370
|
-
* @param {*} icons 要添加的图标列表,包含图标的url以及是否作为sdf符号
|
|
371
|
-
*/
|
|
372
|
-
export function addIcons2Map (map, icons) {
|
|
373
|
-
return new Promise((resolve, reject) => {
|
|
374
|
-
let cnt = icons.length
|
|
375
|
-
icons.forEach(({url, sdf}) => {
|
|
376
|
-
map.loadImage(url, (error, image) => {
|
|
377
|
-
cnt--
|
|
378
|
-
let iconName = url.split('/').pop().split('.')[0]
|
|
379
|
-
if(map.hasImage(iconName)) return
|
|
380
|
-
if (error) {
|
|
381
|
-
reject(error)
|
|
382
|
-
return
|
|
383
|
-
}
|
|
384
|
-
map.addImage(iconName, image, {sdf})
|
|
385
|
-
if (cnt <= 0) resolve(true)
|
|
386
|
-
})
|
|
387
|
-
})
|
|
388
|
-
})
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* 构造任务成果树的结构
|
|
393
|
-
* @param {*} taskInfo
|
|
394
|
-
* @param {*} annotations
|
|
395
|
-
* @param {*} layers
|
|
396
|
-
* @returns
|
|
397
|
-
*/
|
|
398
|
-
export function getTaskTreeList (taskInfo, annotations, layers) {
|
|
399
|
-
let groups = _.cloneDeep(taskInfo.metadata?.groups || layerGroups)
|
|
400
|
-
groups.forEach(g => g.items = [])
|
|
401
|
-
annotations.forEach(item => {
|
|
402
|
-
let info = _.cloneDeep(item)
|
|
403
|
-
if (!info.group) {
|
|
404
|
-
info.group === 'annotation'
|
|
405
|
-
}
|
|
406
|
-
let groupItem = groups.find(d => d.id === info.group)
|
|
407
|
-
groupItem.items.push(info)
|
|
408
|
-
})
|
|
409
|
-
let lyrs = taskInfo.status === 'complete' ? layers : []
|
|
410
|
-
lyrs.forEach(d => {
|
|
411
|
-
let {group} = d
|
|
412
|
-
let groupItem = groups.find(d => d.id === group)
|
|
413
|
-
if (!groupItem) {
|
|
414
|
-
return
|
|
415
|
-
}
|
|
416
|
-
groupItem.items.push(d)
|
|
417
|
-
})
|
|
418
|
-
return groups
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* 判断当前数组中是否包含非数值要素
|
|
423
|
-
* @param {*} arr
|
|
424
|
-
* @returns
|
|
425
|
-
*/
|
|
426
|
-
export function hasNaN (arr) {
|
|
427
|
-
for (let i = 0; i < arr.length; i++) {
|
|
428
|
-
if (Number.isNaN(arr[i])) {
|
|
429
|
-
return true
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return false
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export function flatObject (obj) {
|
|
436
|
-
let arr = {}
|
|
437
|
-
for(let key in obj) {
|
|
438
|
-
if (key.startsWith('xmlns')) {
|
|
439
|
-
continue
|
|
440
|
-
}
|
|
441
|
-
if (Array.isArray(obj[key])) {
|
|
442
|
-
continue
|
|
443
|
-
}
|
|
444
|
-
if (typeof obj[key] === 'object') {
|
|
445
|
-
Object.assign(arr, flatObject(obj[key]))
|
|
446
|
-
} else {
|
|
447
|
-
arr[key] = obj[key]
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return arr
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* 根据pry参数计算旋转矩阵
|
|
455
|
-
* @param {*} pitch
|
|
456
|
-
* @param {*} roll
|
|
457
|
-
* @param {*} yaw
|
|
458
|
-
* @returns
|
|
459
|
-
*/
|
|
460
|
-
export function getRotationMatrix (pitch, roll, yaw) {
|
|
461
|
-
let orientation = []
|
|
462
|
-
let enu2ned = mat4.fromValues(0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)
|
|
463
|
-
let ned2cam = mat4.fromValues(0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)
|
|
464
|
-
let m1 = mat4.fromZRotation(mat4.create(), yaw * Math.PI / 180)
|
|
465
|
-
let m2 = mat4.fromYRotation(mat4.create(), pitch * Math.PI / 180)
|
|
466
|
-
let m3 = mat4.fromXRotation(mat4.create(), roll * Math.PI / 180)
|
|
467
|
-
let rota = mat4.multiply(mat4.create(), mat4.multiply(mat4.create(), m1, m2), m3)
|
|
468
|
-
let rot = mat4.multiply(mat4.create(), mat4.multiply(mat4.create(), ned2cam, mat4.transpose(mat4.create(), rota)), enu2ned)
|
|
469
|
-
for (let i = 0; i < 3; i++) {
|
|
470
|
-
for (let j = 0; j < 3; j++) {
|
|
471
|
-
orientation[i * 3 + j] = rot[i + j * 4]
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
return orientation
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* 将LocalENU坐标系的ROI转为经纬度
|
|
479
|
-
* @param {*} roi 带转换的roi结构
|
|
480
|
-
* @param {*} crs 目标坐标系,当前仅支持LocalENU
|
|
481
|
-
* @returns
|
|
482
|
-
*/
|
|
483
|
-
export function transformRoi (roi, crs) {
|
|
484
|
-
let {boundary, min_z, max_z} = roi
|
|
485
|
-
let {type, origin_point} = crs
|
|
486
|
-
if (type === 0) { // LocalENU
|
|
487
|
-
let newBoundary = []
|
|
488
|
-
boundary.forEach(coord => {
|
|
489
|
-
let lla = transformCoordinateToLngLat([...coord, 0], crs)
|
|
490
|
-
newBoundary.push(lla)
|
|
491
|
-
})
|
|
492
|
-
min_z += origin_point[2]
|
|
493
|
-
max_z += origin_point[2]
|
|
494
|
-
return {boundary: newBoundary, min_z, max_z}
|
|
495
|
-
}
|
|
496
|
-
return roi // Local系,不做转换
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* 根据当前pos精度描述获得精度的具体数值
|
|
501
|
-
* @param {*} accurency
|
|
502
|
-
* @returns
|
|
503
|
-
*/
|
|
504
|
-
export function getPosSigma (accurency) {
|
|
505
|
-
if (accurency === 'high') {
|
|
506
|
-
return [0.03, 0.03, 0.06]
|
|
507
|
-
} else if (accurency === 'low') {
|
|
508
|
-
return [10, 10, 10]
|
|
509
|
-
} else {
|
|
510
|
-
return [1, 1, 1]
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* 根据照片列表中解析的pos,将照片列表转为GeoJSON
|
|
516
|
-
* @param {*} photoList
|
|
517
|
-
* @returns
|
|
518
|
-
*/
|
|
519
|
-
export function photoPos2Geojson (photoList) {
|
|
520
|
-
let features = []
|
|
521
|
-
let item = photoList.find(d => d.meta_data.pos)
|
|
522
|
-
if (item) {
|
|
523
|
-
let coordinate_system = _.cloneDeep(item.meta_data.coordinate_system)
|
|
524
|
-
photoList.forEach(photo => {
|
|
525
|
-
let {meta_data = {}} = photo
|
|
526
|
-
let {pos} = meta_data
|
|
527
|
-
let position = transformCoordinateToLngLat(pos, coordinate_system)
|
|
528
|
-
if (!position) {
|
|
529
|
-
return
|
|
530
|
-
}
|
|
531
|
-
let properties = _.cloneDeep(photo)
|
|
532
|
-
properties.type = 'photo'
|
|
533
|
-
features.push(turf.point(position, properties))
|
|
534
|
-
})
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
let geojson = turf.featureCollection(features)
|
|
538
|
-
let bbox = null
|
|
539
|
-
if (features.length) {
|
|
540
|
-
bbox = turf.bbox(geojson)
|
|
541
|
-
}
|
|
542
|
-
return {geojson, bbox}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export function getDistance (p1, p2) {
|
|
546
|
-
return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]))
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
export function getMaxValue (arr, field) {
|
|
550
|
-
let value = -Infinity
|
|
551
|
-
arr.forEach(item => {
|
|
552
|
-
value = Math.max(item[field], value)
|
|
553
|
-
})
|
|
554
|
-
return value
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
export function getAverageValue (arr, field) {
|
|
558
|
-
let sum = 0
|
|
559
|
-
arr.forEach(item => {
|
|
560
|
-
sum += item[field]
|
|
561
|
-
})
|
|
562
|
-
return sum / arr.length
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
export function getAppVersion (taskInfo) {
|
|
566
|
-
let {appVersion, environment} = taskInfo.metadata
|
|
567
|
-
if (appVersion) {
|
|
568
|
-
return appVersion
|
|
569
|
-
}
|
|
570
|
-
if (environment) {
|
|
571
|
-
return `${environment.platform}(${environment.appVersion})`
|
|
572
|
-
}
|
|
573
|
-
return '暂无'
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* 将重建质量的数值转为名称
|
|
578
|
-
* @param {*} quality 重建质量-1/2/3
|
|
579
|
-
* @returns
|
|
580
|
-
*/
|
|
581
|
-
export function getResolutionLevelByQuality (quality){
|
|
582
|
-
switch (quality) {
|
|
583
|
-
case 'low':
|
|
584
|
-
return 3
|
|
585
|
-
case 'high':
|
|
586
|
-
return 1
|
|
587
|
-
case 'medium':
|
|
588
|
-
default:
|
|
589
|
-
return 2
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
export function getQualityAliasByLevel (resolutionLevel) {
|
|
594
|
-
let alias = '高'
|
|
595
|
-
if (resolutionLevel === 1) {
|
|
596
|
-
alias = '超高'
|
|
597
|
-
} else if (resolutionLevel === 3) {
|
|
598
|
-
alias = '中'
|
|
599
|
-
}
|
|
600
|
-
return alias
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* 将数据类型的数值转字符串
|
|
605
|
-
* @param {*} dataType
|
|
606
|
-
* @returns
|
|
607
|
-
*/
|
|
608
|
-
export function getImageTypeByDataType (dataType){
|
|
609
|
-
switch (dataType) {
|
|
610
|
-
case 'normal':
|
|
611
|
-
return 1
|
|
612
|
-
case 'multispectral':
|
|
613
|
-
return 2
|
|
614
|
-
case 'infrared':
|
|
615
|
-
default:
|
|
616
|
-
return 3
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
export function getDataTypeAliasByImageType (type) {
|
|
621
|
-
if (type === 'infrared') {
|
|
622
|
-
return '热红外'
|
|
623
|
-
} else if (type === 'multispectral') {
|
|
624
|
-
return '多光谱'
|
|
625
|
-
} else {
|
|
626
|
-
return '可见光'
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
export function getTaskStatusAlias (status) {
|
|
631
|
-
if (status === 'complete') {
|
|
632
|
-
return '建模完成'
|
|
633
|
-
} else if (status === 'error') {
|
|
634
|
-
return '建模出错'
|
|
635
|
-
} else if (status === 'none') {
|
|
636
|
-
return '未开始'
|
|
637
|
-
} else if (status === 'waiting') {
|
|
638
|
-
return '正在排队'
|
|
639
|
-
} else if (status === 'aerotriangulation') {
|
|
640
|
-
return '空三完成'
|
|
641
|
-
} else if (status.startsWith('processing')){
|
|
642
|
-
return '正在处理'
|
|
643
|
-
} else if (status === 'stop'){
|
|
644
|
-
return '任务终止'
|
|
645
|
-
} else {
|
|
646
|
-
return '未知状态'
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* 根据重建参数的输出属性判断是否开启了3d建模
|
|
652
|
-
*/
|
|
653
|
-
export function include3d (output = []) {
|
|
654
|
-
if (output.length && output.includes('mesh3d')) {
|
|
655
|
-
return true
|
|
656
|
-
}
|
|
657
|
-
return false
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
export function extend (dest, ...sources) {
|
|
661
|
-
for (const src of sources) {
|
|
662
|
-
for (const k in src) {
|
|
663
|
-
dest[k] = src[k]
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
return dest
|
|
667
|
-
}
|
|
668
|
-
export function endsWith (string, suffix) {
|
|
669
|
-
return string.indexOf(suffix, string.length - suffix.length) !== -1
|
|
670
|
-
}
|
|
671
|
-
|