@mapcatch/util 2.0.4 → 2.0.5-a

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 (68) hide show
  1. package/.eslintrc.js +54 -0
  2. package/.husky/pre-commit +1 -0
  3. package/.prettierrc +4 -0
  4. package/.vscode/settings.json +2 -0
  5. package/README.md +44 -0
  6. package/debug/app.js +26 -0
  7. package/debug/index.html +55 -0
  8. package/debug/libs/vue.global.js +16159 -0
  9. package/debug/my_icon.png +0 -0
  10. package/docs/Catolog.md +24 -0
  11. package/docs/Constant.md +92 -0
  12. package/docs/Event.md +90 -0
  13. package/docs/Util.md +345 -0
  14. package/package.json +21 -1
  15. package/src/constants/crs.js +42098 -42098
  16. package/src/constants/default_layers.js +42 -94
  17. package/src/gl-operations/constants.js +9 -9
  18. package/src/gl-operations/default_options.js +97 -97
  19. package/src/gl-operations/index.js +532 -532
  20. package/src/gl-operations/reglCommands/contours.js +27 -27
  21. package/src/gl-operations/reglCommands/default.js +45 -45
  22. package/src/gl-operations/reglCommands/hillshading.js +340 -340
  23. package/src/gl-operations/reglCommands/index.js +6 -6
  24. package/src/gl-operations/reglCommands/multiLayers.js +303 -303
  25. package/src/gl-operations/reglCommands/transitions.js +111 -111
  26. package/src/gl-operations/reglCommands/util.js +71 -71
  27. package/src/gl-operations/renderer.js +209 -209
  28. package/src/gl-operations/shaders/fragment/convertDem.js +25 -25
  29. package/src/gl-operations/shaders/fragment/convolutionSmooth.js +54 -54
  30. package/src/gl-operations/shaders/fragment/diffCalc.js +33 -33
  31. package/src/gl-operations/shaders/fragment/drawResult.js +46 -46
  32. package/src/gl-operations/shaders/fragment/hillshading/hsAdvAmbientShadows.js +78 -78
  33. package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +59 -59
  34. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalBaselayer.js +30 -30
  35. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +60 -60
  36. package/src/gl-operations/shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js +26 -26
  37. package/src/gl-operations/shaders/fragment/hillshading/hsAdvNormals.js +25 -25
  38. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSmooth.js +53 -53
  39. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSoftShadows.js +80 -80
  40. package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +54 -54
  41. package/src/gl-operations/shaders/fragment/interpolateColor.js +65 -65
  42. package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +49 -49
  43. package/src/gl-operations/shaders/fragment/interpolateValue.js +136 -136
  44. package/src/gl-operations/shaders/fragment/multiAnalyze1Calc.js +35 -35
  45. package/src/gl-operations/shaders/fragment/multiAnalyze2Calc.js +45 -45
  46. package/src/gl-operations/shaders/fragment/multiAnalyze3Calc.js +53 -53
  47. package/src/gl-operations/shaders/fragment/multiAnalyze4Calc.js +61 -61
  48. package/src/gl-operations/shaders/fragment/multiAnalyze5Calc.js +69 -69
  49. package/src/gl-operations/shaders/fragment/multiAnalyze6Calc.js +77 -77
  50. package/src/gl-operations/shaders/fragment/single.js +93 -93
  51. package/src/gl-operations/shaders/transform.js +21 -21
  52. package/src/gl-operations/shaders/util/computeColor.glsl +85 -85
  53. package/src/gl-operations/shaders/util/getTexelValue.glsl +10 -10
  54. package/src/gl-operations/shaders/util/isCloseEnough.glsl +9 -9
  55. package/src/gl-operations/shaders/util/rgbaToFloat.glsl +17 -17
  56. package/src/gl-operations/shaders/vertex/double.js +16 -16
  57. package/src/gl-operations/shaders/vertex/multi3.js +19 -19
  58. package/src/gl-operations/shaders/vertex/multi4.js +22 -22
  59. package/src/gl-operations/shaders/vertex/multi5.js +25 -25
  60. package/src/gl-operations/shaders/vertex/multi6.js +28 -28
  61. package/src/gl-operations/shaders/vertex/single.js +13 -13
  62. package/src/gl-operations/shaders/vertex/singleNotTransformed.js +11 -11
  63. package/src/gl-operations/texture_manager.js +141 -141
  64. package/src/gl-operations/util.js +336 -336
  65. package/src/util.js +14 -6
  66. package/vite.config.js +58 -0
  67. package/dist/catchUtil.min.esm.js +0 -113044
  68. package/dist/catchUtil.min.js +0 -2928
Binary file
@@ -0,0 +1,24 @@
1
+ ## 目录
2
+
3
+ catchUtil主要包括四个部分:
4
+
5
+ - [工具函数](./Util.md)
6
+
7
+ - [事件管理类](./Event.md)
8
+
9
+ - [栅格瓦片自定义样式重渲染](./GlOptions.md)
10
+
11
+ - [常量和配置项](./Constant.md)
12
+
13
+ ### 基本用法
14
+
15
+ ```js
16
+ import {getPhotoTags, generateId} from '@mapcatch/util'
17
+
18
+ // 解析jpg中的exif信息
19
+ getPhotoTags(file).then(info => {
20
+ console.log(info)
21
+ })
22
+ // 生成随机Id
23
+ generateId()
24
+ ```
@@ -0,0 +1,92 @@
1
+ ## 常量和配置项
2
+
3
+ ### cameras
4
+
5
+ 不同数据类型对应的相机型号。
6
+
7
+ ```js
8
+ import {cameras} from '@mapcatch/util'
9
+ ```
10
+ 查看源码:[src/constants/cameras.js](../src/constants/cameras.js)
11
+
12
+ ### layerGroups
13
+
14
+ 成果的默认分组信息
15
+
16
+ ```js
17
+ import {layerGroups} from '@mapcatch/util'
18
+ ```
19
+ 查看源码:[src/constants/layer_groups.js](../src/constants/layer_groups.js)
20
+
21
+ ### bmapTypes
22
+
23
+ 地图底图的图层信息
24
+
25
+ ```js
26
+ import {bmapTypes} from '@mapcatch/util'
27
+ ```
28
+ 查看源码:[src/constants/bmap_types.js](../src/constants/bmap_types.js)
29
+
30
+ ### colors
31
+
32
+ dsm和温度图的色带信息
33
+
34
+ ```js
35
+ import {colors} from '@mapcatch/util'
36
+ ```
37
+ 查看源码:[src/constants/colors.js](../src/constants/colors.js)
38
+
39
+ ### defaultLayers
40
+
41
+ 默认的成果图层属性
42
+
43
+ ```js
44
+ import {defaultLayers} from '@mapcatch/util'
45
+ ```
46
+ 查看源码:[src/constants/default_layers.js](../src/constants/default_layers.js)
47
+
48
+
49
+ ### layerFolders
50
+
51
+ 不同类型图层对应的文件夹名称
52
+
53
+ ```js
54
+ import {layerFolders} from '@mapcatch/util'
55
+ ```
56
+ 查看源码:[src/constants/layer_folders.js](../src/constants/layer_folders.js)
57
+
58
+ ### layerIcons
59
+
60
+ 不同类型图层对应图标
61
+
62
+ ```js
63
+ import {layerIcons} from '@mapcatch/util'
64
+ ```
65
+ 查看源码:[src/constants/layer_icons.js](../src/constants/layer_icons.js)
66
+
67
+ ### mapViewModes
68
+
69
+ 地图的显示模式
70
+
71
+ ```js
72
+ import {mapViewModes} from '@mapcatch/util'
73
+ ```
74
+ 查看源码:[src/constants/map_view_mode.js](../src/constants/map_view_mode.js)
75
+
76
+ ### taskParams
77
+
78
+ 任务的默认参数
79
+
80
+ ```js
81
+ import {taskParams} from '@mapcatch/util'
82
+ ```
83
+ 查看源码:[src/constants/task_params.js](../src/constants/task_params.js)
84
+
85
+ ### tools
86
+
87
+ 地图标绘工具属性
88
+
89
+ ```js
90
+ import {tools} from '@mapcatch/util'
91
+ ```
92
+ 查看源码:[src/constants/tools.js](../src/constants/tools.js)
package/docs/Event.md ADDED
@@ -0,0 +1,90 @@
1
+ ## 事件管理类
2
+
3
+ 主要用来管理自定义事件,包括事件的监听、执行、删除。
4
+
5
+ 基本用法:
6
+
7
+ ```js
8
+ import {Event} from '@mapcatch/util'
9
+
10
+ let event = new Event()
11
+
12
+ event.on('on-change', (e) => {
13
+ console.log(e.data)
14
+ })
15
+
16
+ setTimeout(() => {
17
+ event.fire('on-change')
18
+ }, 3000)
19
+ ```
20
+
21
+ 主要接口:
22
+
23
+ ### on(type, listener)
24
+
25
+ 监听指定类型的事件,事件发生时,自动执行listener。
26
+
27
+ **参数**
28
+
29
+ *type* `String` 事件类型,可以是任意字符串。
30
+
31
+ *listener* `Function` 监听函数,事件发生时执行。
32
+
33
+ **返回值**
34
+
35
+ `Event`: Event实例,用于链式调用
36
+
37
+ ### off(type, listener)
38
+
39
+ 移除指定类型的监听函数,`listener`可以不指定,不指定则会删除该类型所有的监听函数。
40
+
41
+ **参数**
42
+
43
+ *type* `String` 事件类型。
44
+
45
+ *listener* `Function` 需要移除的监听函数,不指定则移除该事件类型的所有监听函数。
46
+
47
+ **返回值**
48
+
49
+ `Event`: Event实例,用于链式调用
50
+
51
+ ### once(type, listener)
52
+
53
+ 一次性监听指定类型的事件,事件发生时,自动执行listener,执行完以后自动移除。
54
+
55
+ **参数**
56
+
57
+ *type* `String` 事件类型,可以是任意字符串。
58
+
59
+ *listener* `Function` 监听函数,事件发生时执行。
60
+
61
+ **返回值**
62
+
63
+ `Event`: Event实例,用于链式调用
64
+
65
+ ### fire(type, data)
66
+
67
+ 触发指定类型的事件。
68
+
69
+ **参数**
70
+
71
+ *type* `String` 事件类型,可以是任意字符串。
72
+
73
+ *data* `Any` 该事件附带的参数信息。
74
+
75
+ **返回值**
76
+
77
+ `Event`: Event实例,用于链式调用
78
+
79
+
80
+ ### listens(type)
81
+
82
+ 判断是否存在该事件类型的监听函数。
83
+
84
+ **参数**
85
+
86
+ *type* `String` 事件类型,可以是任意字符串。
87
+
88
+ **返回值**
89
+
90
+ `boolean`: 是否存在该事件的监听函数。
package/docs/Util.md ADDED
@@ -0,0 +1,345 @@
1
+ ## 工具函数
2
+
3
+ 基本用法:
4
+
5
+ ```js
6
+ // 完整引入
7
+ import * as catchUtil from '@mapcatch/util'
8
+ // 或者按需引入
9
+ import {getPhotoTags} from '@mapcatch/util'
10
+ ```
11
+
12
+ ### getPhotoTags(file)
13
+
14
+ 获取照片文件中的exif信息,例如GPS位置、拍摄的设备型号等。为加快解析速度,可以只截取图片的前64kB进行解析,而不用传整个文件进来解析。
15
+
16
+ **参数**
17
+
18
+ *file* `File` 需要解析的文件,必须是HTML5的File对象
19
+
20
+ **返回值**
21
+
22
+ `Promise`: 一个Promise对象,用来获取解析结果
23
+
24
+ **示例**
25
+
26
+ ```js
27
+ getPhotoTags(file).then(info => {
28
+ console.log(info)
29
+ }).catch(err => {
30
+ throw err
31
+ })
32
+ ```
33
+
34
+ ### generateId()
35
+
36
+ 生成一个随机id字符串
37
+
38
+ **返回值**
39
+
40
+ `uuid`: 使用uuidv4生成一个随机id
41
+
42
+ ### formatDate(date)
43
+
44
+ 将数据库的日期字符串格式化用来前端显示。
45
+
46
+ **参数**
47
+
48
+ *date* `Date String` 日期字符串
49
+
50
+ **返回值**
51
+
52
+ `String` 格式化以后的日期,如`2023-08-01 12:56:32`
53
+
54
+ ### formatLocalDate()
55
+
56
+ 将当前的本地时间转为字符串,这个函数主要是为了解决`.toLocaleDateString()`在不同浏览器结果可能不一致的问题。
57
+
58
+ **返回值**
59
+
60
+ `String` 格式化以后的日期,如`2023/8/1 12:56:32`
61
+
62
+ ### formatFileSize(size)
63
+
64
+ 将以字节为单位的文件大小自动转为`KB`、`MB`等用来显示。
65
+
66
+ **参数**
67
+
68
+ *size* `Number` 文件大小
69
+
70
+ **返回值**
71
+
72
+ `String` 格式化以后文件大小,例如`342KB`
73
+
74
+ ### getPhotoInfo(file)
75
+
76
+ 获取照片文件的拍摄日期、相机型号和GPS位置信息,与`getPhotoTags(file)`不同,该函数只获取这三个属性,并会将位置信息格式化为十进制度。
77
+
78
+ **参数**
79
+
80
+ *file* `File` 需要解析的文件,必须是HTML5的File对象
81
+
82
+ **返回值**
83
+
84
+ `Promise`: 一个Promise对象,用来获取解析结果
85
+
86
+ **示例**
87
+
88
+ ```js
89
+ let info = await getPhotoInfo(file)
90
+
91
+ /*
92
+ {
93
+ date: '2020-04-21',
94
+ Model: 'FC6310R',
95
+ position: {
96
+ lng: 110.3456,
97
+ lat: 32.56434526,
98
+ alt: 78.432
99
+ }
100
+ }
101
+ */
102
+ ```
103
+
104
+ ### getPhotoMeta(file)
105
+
106
+ 获取照片文件的元数据信息,包括md5和原始exif信息。
107
+
108
+ > 注意,为了提高解析性能,该接口只计算文件前64KB的md5,用于确保文件的唯一性,但无法保证文件的完整性。
109
+
110
+ **参数**
111
+
112
+ *file* `File` 需要解析的文件,必须是HTML5的File对象
113
+
114
+ **返回值**
115
+
116
+ `Promise`: 一个Promise对象,用来获取解析结果
117
+
118
+ **示例**
119
+
120
+ ```js
121
+ let info = await getPhotoMeta(file)
122
+
123
+ /*
124
+ {
125
+ md5: '.....',
126
+ exif: {...}
127
+ }
128
+ */
129
+ ```
130
+
131
+ ### getGeoCoordOperator(flag)
132
+
133
+ 一般照片GPS位置中的经纬度用`N`和`E`来表示北纬和东经,但我们程序中通常用带有正负号的十进制度表示,此接口用来根据这些标识来获取正负号。
134
+
135
+ **参数**
136
+
137
+ *flag* `String` 经纬度的标识字符
138
+
139
+ **返回值**
140
+
141
+ `number`: 1或者-1
142
+
143
+ **示例**
144
+
145
+ ```js
146
+ getGeoCoordOperator('N')
147
+ // 1
148
+ getGeoCoordOperator('S')
149
+ // -1
150
+ ```
151
+
152
+ ### toRadian(arr)
153
+
154
+ 将数组表示的度分秒转为带小数的度。
155
+
156
+ **参数**
157
+
158
+ *arr* `Array` 度分秒数组
159
+
160
+ **返回值**
161
+
162
+ `number`: 十进制度
163
+
164
+ **示例**
165
+
166
+ ```js
167
+ let arr = [110, 30, 20]
168
+ toRadian(arr)
169
+ // 110.5055555555
170
+ ```
171
+
172
+ ### diffLayers(newList, oldList)
173
+
174
+ 将新的成果列表与旧的成果列表进行比较,找出其中变化的部分,进行差异化更新。
175
+
176
+ **参数**
177
+
178
+ *newList* `Array` 修改之后的成果树列表
179
+
180
+ *oldList* `Array` 修改之前的成果树列表,默认为`[]`
181
+
182
+ **返回值**
183
+
184
+ `array`: 返回地图更新的命令集合,包含命令的名称(例如`addLayer`)和参数
185
+
186
+ ### findNodeInTree(id, treeList)
187
+
188
+ 从树状列表中找出指定id的节点。
189
+
190
+ **参数**
191
+
192
+ *id* `String` 需要查找的节点id
193
+
194
+ *treeList* `Array` 待查找的树状列表
195
+
196
+ **返回值**
197
+
198
+ `object`: 节点对象,没有则返回`null`
199
+
200
+ ### getBeforeId(map, layer)
201
+
202
+ 根据`layer.metadata.layerType`中指定的图层类型来获取该图层需要插入的位置。这个接口主要用于在mapbox地图中插入一个新的图层时,自动计算新图层应该插入的位置,例如底图图层应该插入到最下面,而标注图层需要插入到最上面。
203
+
204
+ 程序中默认的图层类型的顺序为: `['bmap', 'dom', 'ndvi', 'dsm', 'circle', 'annotation', 'label']`
205
+
206
+ **参数**
207
+
208
+ *map* `Map` mapbox的地图实例。
209
+
210
+ *layer* `object` 等待插入的图层配置项,其中必须指定`layer.metadata.layerType`
211
+
212
+ **返回值**
213
+
214
+ `string`: 图层应该插入到的位置
215
+
216
+ ### isTokenExpired(response)
217
+
218
+ 根据后端的接口响应判断用户的token是否已过期。
219
+
220
+ **返回值**
221
+
222
+ `boolean`: 用户token是否已过期
223
+
224
+ ### getDataType(camera)
225
+
226
+ 根据相机型号判断该数据的类型,主要有三种类型:可见光`normal`、多光谱`multispectral`、热红外`infrared`。
227
+
228
+ **参数**
229
+
230
+ *camera* `String` 相机型号,例如`FC6310`。
231
+
232
+ **返回值**
233
+
234
+ `string`: 数据类型,默认是`normal`
235
+
236
+ ### downloadImage(base64)
237
+
238
+ 在浏览器将base64格式的图片下载到本地。
239
+
240
+ **参数**
241
+
242
+ *base64* `String` 图片文件的base64字符串。
243
+
244
+ ### getGeometryType(feature)
245
+
246
+ 给定geojson要素,获取该要素的几何类型(点、线、面)
247
+
248
+ **参数**
249
+
250
+ *feature* `Object` geojson要素。
251
+
252
+ **返回值**
253
+
254
+ *string*:几何类型,`point`、`line`或者`polygon`
255
+
256
+ ### rgbaToFloat(colorArray)
257
+
258
+ 将rgba格式的颜色数组转为float32浮点数。
259
+
260
+ **参数**
261
+
262
+ *colorArray* `Array` 长度为4的颜色数组,每个值都是0-255。
263
+
264
+ **返回值**
265
+
266
+ *number*: 浮点数
267
+
268
+ **示例**
269
+
270
+ ```js
271
+ let arr = [234, 32, 133, 255];
272
+ let float = rgbaToFloat(arr)
273
+ ```
274
+
275
+ ### getAnnotationName(annotations, type)
276
+
277
+ 根据标注的几何类型获取标注的名称。该接口主要是为了避免名称重复,自动在名称后面加上需要以保证名称的唯一性。
278
+
279
+ **参数**
280
+
281
+ *annotations* `Array` 已经保存的标注列表。
282
+
283
+ *type* `String` 新标注的类型,`point`、`line`或者`polygon`。
284
+
285
+ **返回值**
286
+
287
+ *string*: 新的标注名称
288
+
289
+ **示例**
290
+
291
+ ```js
292
+ let name = getAnnotationName(annotations, 'point')
293
+ console.log(name)
294
+ // 点标注 2
295
+ ```
296
+
297
+ ### getLineLabelFeature(lineFeature)
298
+
299
+ 获取线标注的文字注记点位信息。在地图上标注线要素时需要显示标注的测量信息和名称,而且名称应该沿线排布,该接口根据线标注的长度和走向自动计算文字标注的位置和旋转角度,并返回一个点状的GeoJSON要素。
300
+
301
+ **参数**
302
+
303
+ *lineFeature* `Object` 线标注的geojson要素
304
+
305
+ **返回值**
306
+
307
+ *object*:文字标注的点要素,其中属性信息中包含旋转角度。
308
+
309
+ ### project(lngLat, zoom)
310
+
311
+ 将经纬度转为墨卡托投影的像素坐标,瓦片大小按照512计算。
312
+
313
+ **参数**
314
+
315
+ *lngLat* `Array` 数组格式的经纬度
316
+
317
+ *zoom* `number` 地图级别,可以不指定,默认为12
318
+
319
+ **返回值**
320
+
321
+ *object*:墨卡托投影的像素坐标,包含`x`和`y`。
322
+
323
+ ### addIcons2Map(map, icons)
324
+
325
+ 该接口通过mapbox的`map.addImage`接口批量将给定的图标文件添加到地图中,用于地图中点要素的符号化。
326
+
327
+ **参数**
328
+
329
+ *map* `Map` mapbox地图实例
330
+
331
+ *icons* `Array` 图标数组,每个元素是图标的url
332
+
333
+ ### getTaskTreeList(taskInfo, annotations, layers)
334
+
335
+ 将任务的成果和标注等信息转为成果树列表,用于左边面板展示
336
+
337
+ **参数**
338
+
339
+ *taskInfo* `Object` 任务详细信息
340
+ *annotations* `Array` 标注列表
341
+ *layers* `Array` 任务成果列表
342
+
343
+ **返回值**
344
+
345
+ *array*: 成果树列表
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcatch/util",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-a",
4
4
  "main": "./dist/catchUtil.min.esm.js",
5
5
  "repository": "",
6
6
  "author": "wanyanyan",
@@ -17,6 +17,26 @@
17
17
  "src/**/*.js": "yarn lint"
18
18
  },
19
19
  "dependencies": {
20
+ "@turf/turf": "^7.1.0",
21
+ "@xmldom/xmldom": "^0.9.2",
22
+ "cdt2d": "^1.0.0",
23
+ "eslint": "8.22.0",
24
+ "gl-matrix": "^3.4.3",
25
+ "glsl-float-to-rgba": "^1.0.0",
26
+ "glsl-rgba-to-float": "^1.0.0",
27
+ "lodash": "^4.17.21",
28
+ "mapbox-gl": "^3.6.0",
29
+ "mathjs": "12.3.0",
30
+ "moment": "^2.29.4",
31
+ "pbf": "3.2.1",
32
+ "proj4": "^2.12.1",
33
+ "protocol-buffers-schema": "^3.6.0",
34
+ "regl": "^2.1.0",
35
+ "satellite-geo-calc": "^0.0.7",
36
+ "spark-md5": "^3.0.2",
37
+ "svg-path-commander": "2.0.9",
38
+ "upng-js": "^2.1.0",
39
+ "uuid": "^9.0.0"
20
40
  },
21
41
  "devDependencies": {
22
42
  "@babel/core": "^7.25.2",