@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
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { formatDate, getAnnotationFeature } from '../util'
|
|
3
|
-
import {mapStyle, layerFolders} from '../constants'
|
|
4
|
-
import * as turf from '@turf/turf'
|
|
5
|
-
import mapboxgl from 'mapbox-gl'
|
|
6
|
-
mapboxgl.accessToken =
|
|
7
|
-
'pk.eyJ1Ijoid2FueWFueWFuIiwiYSI6Im1uNVZnTncifQ.90XY40_yjpItUHO8HnbbpA'
|
|
8
|
-
|
|
9
|
-
export async function generateReport (params) {
|
|
10
|
-
let {projectInfo, taskInfo, annotations} = params
|
|
11
|
-
return {
|
|
12
|
-
title: '标注报告',
|
|
13
|
-
projectName: projectInfo.name,
|
|
14
|
-
taskName: taskInfo.name,
|
|
15
|
-
user_id: taskInfo.user_id,
|
|
16
|
-
project_id: taskInfo.project_id,
|
|
17
|
-
task_id: taskInfo.task_id,
|
|
18
|
-
data_type: taskInfo.data_type,
|
|
19
|
-
sections: [
|
|
20
|
-
{
|
|
21
|
-
title: '任务概览',
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: 'form',
|
|
25
|
-
items: getTaskPreview(taskInfo)
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: 'image',
|
|
29
|
-
imageType: 'overview'
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
title: '标注列表',
|
|
35
|
-
content: [
|
|
36
|
-
{
|
|
37
|
-
type: 'sub-title',
|
|
38
|
-
label: '点标注'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
type: 'annotation-list',
|
|
42
|
-
colums: getPointColums(taskInfo.data_type),
|
|
43
|
-
data: getAnnoData(annotations, 'point')
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: 'sub-title',
|
|
47
|
-
label: '线标注'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
type: 'annotation-list',
|
|
51
|
-
colums: getLineColums(taskInfo.data_type),
|
|
52
|
-
data: getAnnoData(annotations, 'line')
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
type: 'sub-title',
|
|
56
|
-
label: '面标注'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: 'annotation-list',
|
|
60
|
-
colums: getPolygonColums(taskInfo.data_type),
|
|
61
|
-
data: getAnnoData(annotations, 'polygon')
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
type: 'page-line' // 分页
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
title: '标注详情',
|
|
70
|
-
content: [
|
|
71
|
-
{
|
|
72
|
-
type: 'details',
|
|
73
|
-
data: getAnnotationDetails(annotations, taskInfo)
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function getTaskPreview (taskInfo) {
|
|
82
|
-
return [
|
|
83
|
-
{
|
|
84
|
-
label: '任务名称',
|
|
85
|
-
value: taskInfo.name
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
label: '任务类型',
|
|
89
|
-
value: getDataType(taskInfo.data_type)
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
label: '数据采集时间',
|
|
93
|
-
value: formatDate(taskInfo.captured_at)
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
label: '重建时间',
|
|
97
|
-
value: formatDate(taskInfo.completed_at)
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function getDataType (type) {
|
|
103
|
-
if (type === 'infrared') {
|
|
104
|
-
return '热红外'
|
|
105
|
-
} else if (type === 'multispectral') {
|
|
106
|
-
return '多光谱'
|
|
107
|
-
} else {
|
|
108
|
-
return '可见光'
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function getPointColums (data_type) {
|
|
113
|
-
return [
|
|
114
|
-
{
|
|
115
|
-
title: '',
|
|
116
|
-
slot: 'color',
|
|
117
|
-
key: 'color',
|
|
118
|
-
width: 100
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
title: '名称',
|
|
122
|
-
key: 'name'
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
title: '经度(X)',
|
|
126
|
-
key: 'x'
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
title: '纬度(Y)',
|
|
130
|
-
key: 'y'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
title: data_type === 'infrared' ? '温度(℃)' : '高度(Z)',
|
|
134
|
-
key: data_type === 'infrared' ? 'temprature' : 'height'
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function getLineColums (data_type) {
|
|
140
|
-
if (data_type === 'infrared') {
|
|
141
|
-
return [
|
|
142
|
-
{
|
|
143
|
-
title: '',
|
|
144
|
-
slot: 'color',
|
|
145
|
-
key: 'color',
|
|
146
|
-
width: 100
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
title: '名称',
|
|
150
|
-
key: 'name'
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
title: '长度(m)',
|
|
154
|
-
key: 'distance2d'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
title: '最低温度(℃)',
|
|
158
|
-
key: 'temprature_min'
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
title: '最高温度(℃)',
|
|
162
|
-
key: 'temprature_max'
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
} else {
|
|
166
|
-
return [
|
|
167
|
-
{
|
|
168
|
-
title: '',
|
|
169
|
-
slot: 'color',
|
|
170
|
-
key: 'color',
|
|
171
|
-
width: 100
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
title: '名称',
|
|
175
|
-
key: 'name'
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
title: '2D长度(m)',
|
|
179
|
-
key: 'distance2d'
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
title: '3D长度(m)',
|
|
183
|
-
key: 'distance3d'
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
title: '最小坡度(°)',
|
|
187
|
-
key: 'slope_min'
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
title: '最大坡度(°)',
|
|
191
|
-
key: 'slope_max'
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
title: '最小高度(m)',
|
|
195
|
-
key: 'height_min'
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
title: '最大高度(m)',
|
|
199
|
-
key: 'height_max'
|
|
200
|
-
}
|
|
201
|
-
]
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function getPolygonColums (data_type) {
|
|
206
|
-
if (data_type === 'infrared') {
|
|
207
|
-
return [
|
|
208
|
-
{
|
|
209
|
-
title: '',
|
|
210
|
-
slot: 'color',
|
|
211
|
-
key: 'color',
|
|
212
|
-
width: 100
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
title: '名称',
|
|
216
|
-
key: 'name'
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
title: '面积(㎡)',
|
|
220
|
-
key: 'area2d'
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
title: '周长(m)',
|
|
224
|
-
key: 'distance2d'
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
title: '最低温度(℃)',
|
|
228
|
-
key: 'temprature_min'
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
title: '最高温度(℃)',
|
|
232
|
-
key: 'temprature_max'
|
|
233
|
-
}
|
|
234
|
-
]
|
|
235
|
-
} else {
|
|
236
|
-
return [
|
|
237
|
-
{
|
|
238
|
-
title: '',
|
|
239
|
-
slot: 'color',
|
|
240
|
-
key: 'color',
|
|
241
|
-
width: 100
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
title: '名称',
|
|
245
|
-
key: 'name'
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
title: '2D面积(㎡)',
|
|
249
|
-
key: 'area2d'
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
title: '3D面积(㎡)',
|
|
253
|
-
key: 'area3d'
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
title: '2D周长(m)',
|
|
257
|
-
key: 'distance2d'
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
title: '3D周长(m)',
|
|
261
|
-
key: 'distance3d'
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
title: '最小高度(m)',
|
|
265
|
-
key: 'height_min'
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
title: '最大高度(m)',
|
|
269
|
-
key: 'height_max'
|
|
270
|
-
}
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function getAnnoData (annotations, type) {
|
|
276
|
-
return annotations.filter(d => d.type === type).map(d => {
|
|
277
|
-
let obj = _.cloneDeep(d)
|
|
278
|
-
if (type === 'point') {
|
|
279
|
-
let coord = d.geometry.coordinates
|
|
280
|
-
obj.x = _.round(coord[0], 6)
|
|
281
|
-
obj.y = _.round(coord[1], 6)
|
|
282
|
-
}
|
|
283
|
-
delete obj.geometry
|
|
284
|
-
return obj
|
|
285
|
-
})
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function getAnnotationDetails (annotations, taskInfo) {
|
|
289
|
-
let {data_type} = taskInfo
|
|
290
|
-
let colums = {
|
|
291
|
-
point: getPointColums(data_type),
|
|
292
|
-
line: getLineColums(data_type),
|
|
293
|
-
polygon: getPolygonColums(data_type)
|
|
294
|
-
}
|
|
295
|
-
let sortIndex = {point: 1, line: 2, polygon: 3}
|
|
296
|
-
let sorted = annotations.sort((a, b) => sortIndex[a.type] - sortIndex[b.type])
|
|
297
|
-
let items = []
|
|
298
|
-
let features = []
|
|
299
|
-
sorted.forEach(anno => {
|
|
300
|
-
let {id, type, name, color} = anno
|
|
301
|
-
let data = {}
|
|
302
|
-
colums[type].forEach(col => {
|
|
303
|
-
if (col.key === 'color' || col.key === 'name') {
|
|
304
|
-
return
|
|
305
|
-
}
|
|
306
|
-
if (type === 'point') {
|
|
307
|
-
let coord = anno.geometry.coordinates
|
|
308
|
-
anno.x = _.round(coord[0], 6)
|
|
309
|
-
anno.y = _.round(coord[1], 6)
|
|
310
|
-
}
|
|
311
|
-
data[col.title] = anno[col.key]
|
|
312
|
-
})
|
|
313
|
-
let feature = getAnnotationFeature(anno)
|
|
314
|
-
features.push(feature)
|
|
315
|
-
items.push({
|
|
316
|
-
id,
|
|
317
|
-
name,
|
|
318
|
-
type,
|
|
319
|
-
color,
|
|
320
|
-
data,
|
|
321
|
-
feature,
|
|
322
|
-
image: ''
|
|
323
|
-
})
|
|
324
|
-
})
|
|
325
|
-
return items
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function getStyle (features, report) {
|
|
329
|
-
let style = _.cloneDeep(mapStyle)
|
|
330
|
-
style.layers.push({
|
|
331
|
-
id: 'background',
|
|
332
|
-
type: 'background',
|
|
333
|
-
paint: {
|
|
334
|
-
'background-color': '#000000'
|
|
335
|
-
}
|
|
336
|
-
})
|
|
337
|
-
let {taskName, projectName, user_id, data_type} = report
|
|
338
|
-
let type = data_type === 'infrared' ? 'tmp' : 'dom'
|
|
339
|
-
let tileUrl = `http://127.0.0.1:10024/${user_id}/${projectName}/${taskName}/result/2D/${layerFolders[type]}/{z}/{x}/{y}.webp`
|
|
340
|
-
style.sources.dom_image = {
|
|
341
|
-
'type': 'raster',
|
|
342
|
-
'tiles': [ tileUrl ],
|
|
343
|
-
'tileSize': 512
|
|
344
|
-
}
|
|
345
|
-
style.sources.annotation = {
|
|
346
|
-
type: 'geojson',
|
|
347
|
-
data: {
|
|
348
|
-
type: 'FeatureCollection',
|
|
349
|
-
features
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
style.layers.push({
|
|
353
|
-
'id': 'dom_image',
|
|
354
|
-
'source': 'dom_image',
|
|
355
|
-
'type': 'raster'
|
|
356
|
-
})
|
|
357
|
-
style.layers.push({
|
|
358
|
-
'id': 'annotation-point',
|
|
359
|
-
'type': 'circle',
|
|
360
|
-
filter: ['==', '$type', 'Point'],
|
|
361
|
-
source: 'annotation',
|
|
362
|
-
'paint': {
|
|
363
|
-
'circle-radius': 10,
|
|
364
|
-
'circle-color': ['get', 'color']
|
|
365
|
-
}
|
|
366
|
-
})
|
|
367
|
-
style.layers.push({
|
|
368
|
-
'id': 'annotation-line',
|
|
369
|
-
'type': 'line',
|
|
370
|
-
filter: ['!=', '$type', 'Point'],
|
|
371
|
-
source: 'annotation',
|
|
372
|
-
'layout': {
|
|
373
|
-
'line-cap': 'round',
|
|
374
|
-
'line-join': 'round'
|
|
375
|
-
},
|
|
376
|
-
'paint': {
|
|
377
|
-
'line-color': ['get', 'color'],
|
|
378
|
-
'line-width': 4
|
|
379
|
-
}
|
|
380
|
-
})
|
|
381
|
-
style.layers.push({
|
|
382
|
-
'id': 'annotation-polygon',
|
|
383
|
-
'type': 'fill',
|
|
384
|
-
filter: ['==', '$type', 'Polygon'],
|
|
385
|
-
source: 'annotation',
|
|
386
|
-
'paint': {
|
|
387
|
-
'fill-color': ['get', 'color'],
|
|
388
|
-
'fill-opacity': 0.1
|
|
389
|
-
}
|
|
390
|
-
})
|
|
391
|
-
return style
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
export function initMap (features, report) {
|
|
395
|
-
return new Promise((resolve) => {
|
|
396
|
-
let style = getStyle(features, report)
|
|
397
|
-
let div = document.createElement('div')
|
|
398
|
-
div.style.width = '800px'
|
|
399
|
-
div.style.height = '400px'
|
|
400
|
-
div.style.position = 'absolute'
|
|
401
|
-
div.style.zIndex = '-1'
|
|
402
|
-
document.body.appendChild(div)
|
|
403
|
-
let map = new mapboxgl.Map({
|
|
404
|
-
container: div,
|
|
405
|
-
style: style,
|
|
406
|
-
bearing: 0,
|
|
407
|
-
pitch: 0,
|
|
408
|
-
center: [110.9, 32.79],
|
|
409
|
-
zoom: 4.2,
|
|
410
|
-
interactive: true,
|
|
411
|
-
doubleClickZoom: false,
|
|
412
|
-
dragRotate: false,
|
|
413
|
-
pitchWithRotate: false,
|
|
414
|
-
preserveDrawingBuffer: true,
|
|
415
|
-
localFontFamily: 'sans-serif'
|
|
416
|
-
})
|
|
417
|
-
map.on('load', () => {
|
|
418
|
-
resolve(map)
|
|
419
|
-
})
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
export function removeMap (map) {
|
|
425
|
-
map.remove()
|
|
426
|
-
document.body.removeChild(map.getContainer())
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
export function getImage (map, feature) {
|
|
430
|
-
let extent = turf.bbox(feature)
|
|
431
|
-
let {id} = feature.properties
|
|
432
|
-
map.fitBounds(extent, {
|
|
433
|
-
animate: false,
|
|
434
|
-
padding: 50,
|
|
435
|
-
maxZoom: 19
|
|
436
|
-
})
|
|
437
|
-
map.setFilter('annotation-point', ['all', ['==', '$type', 'Point'], ['==', 'id', id]])
|
|
438
|
-
map.setFilter('annotation-line', ['all', ['!=', '$type', 'Point'], ['==', 'id', id]])
|
|
439
|
-
map.setFilter('annotation-polygon', ['all', ['==', '$type', 'Polygon'], ['==', 'id', id]])
|
|
440
|
-
return new Promise((resolve) => {
|
|
441
|
-
map.once('idle', () => {
|
|
442
|
-
let canvas = map.getCanvas()
|
|
443
|
-
resolve(canvas.toDataURL('image/png'))
|
|
444
|
-
})
|
|
445
|
-
})
|
|
446
|
-
}
|
package/src/report/index.js
DELETED
package/src/report/map_util.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import * as turf from '@turf/turf'
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
import { transformCoordinateToLngLat } from '../transform'
|
|
4
|
-
|
|
5
|
-
const EARTH_RADIUS = 6378137
|
|
6
|
-
|
|
7
|
-
export function getFeatures (photoList, imagePosDiff, zoom) {
|
|
8
|
-
let features = []
|
|
9
|
-
let minDiff_z = Infinity
|
|
10
|
-
let maxDiff_z = -Infinity
|
|
11
|
-
let ratio = getRatio(zoom, imagePosDiff)
|
|
12
|
-
let endPoints = []
|
|
13
|
-
// 先获取坐标系
|
|
14
|
-
let item = photoList.find(d => d.meta_data.pos)
|
|
15
|
-
if (item) {
|
|
16
|
-
let coordinate_system = _.cloneDeep(item.meta_data.coordinate_system)
|
|
17
|
-
photoList.forEach((photo, index) => {
|
|
18
|
-
let {meta_data} = photo
|
|
19
|
-
let startPoint = transformCoordinateToLngLat(meta_data.pos, coordinate_system)
|
|
20
|
-
if (!startPoint) {
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
let id = index + 1
|
|
24
|
-
let diffItem = imagePosDiff.find(d => d.id === id)
|
|
25
|
-
if (!diffItem) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
// 计算z方向的误差最大值,用于给椭圆设置颜色
|
|
29
|
-
let diffs = diffItem.pos_diff
|
|
30
|
-
minDiff_z = Math.min(minDiff_z, diffs[2])
|
|
31
|
-
maxDiff_z = Math.max(maxDiff_z, diffs[2])
|
|
32
|
-
let endPoint = _.cloneDeep(startPoint)
|
|
33
|
-
endPoint[0] += diffs[0] * ratio * getDegreePerMeters()
|
|
34
|
-
endPoint[1] += diffs[1] * ratio * getDegreePerMeters()
|
|
35
|
-
endPoints.push(endPoint)
|
|
36
|
-
features.push(turf.lineString([startPoint, endPoint], {
|
|
37
|
-
diff_x: 100 * diffs[0],
|
|
38
|
-
diff_y: 100 * diffs[1],
|
|
39
|
-
diff_z: 100 * diffs[2]
|
|
40
|
-
}))
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
geojson: turf.featureCollection(features),
|
|
45
|
-
ratio,
|
|
46
|
-
minDiff_z,
|
|
47
|
-
maxDiff_z,
|
|
48
|
-
endPoints
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 获取误差椭圆的缩放系数。要把误差直观反应到地图上需要对误差椭圆进行缩放,其缩放的大小跟误差的大小和当前地图的级别有关
|
|
53
|
-
// 本函数假设要让最大的误差在当前地图层级上显示出30像素的大小,以此来预估缩放系数
|
|
54
|
-
function getRatio (zoom, diffs) {
|
|
55
|
-
// 最大误差值
|
|
56
|
-
let max = diffs.reduce((m, item) => {
|
|
57
|
-
if (!item.pos_diff?.length) {
|
|
58
|
-
return m
|
|
59
|
-
}
|
|
60
|
-
let d = Math.max(Math.abs(item.pos_diff[0]), Math.abs(item.pos_diff[1]))
|
|
61
|
-
return m > d ? m : d
|
|
62
|
-
})
|
|
63
|
-
// 地图上30像素代表的距离
|
|
64
|
-
let distance = 30 * 2 * Math.PI * EARTH_RADIUS / (Math.pow(2, zoom) * 512)
|
|
65
|
-
let ratio = distance / max
|
|
66
|
-
if (ratio < 1) {
|
|
67
|
-
return Number(ratio.toFixed(1))
|
|
68
|
-
}
|
|
69
|
-
if (ratio < 10) {
|
|
70
|
-
return Math.round(ratio)
|
|
71
|
-
}
|
|
72
|
-
if (ratio < 100) {
|
|
73
|
-
return 10 * parseInt(ratio / 10)
|
|
74
|
-
}
|
|
75
|
-
return Math.max(Math.round(ratio / 100) * 100, 100)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 墨卡托坐标系每米对应的经纬度度数
|
|
79
|
-
function getDegreePerMeters () {
|
|
80
|
-
return 180 / (Math.PI * EARTH_RADIUS)
|
|
81
|
-
}
|