@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
@@ -0,0 +1,204 @@
1
+ // 坐标转换类
2
+ import satellite_geo_calc from 'satellite-geo-calc'
3
+ import proj4 from 'proj4'
4
+ import { crsList, crsTypes } from './constants'
5
+
6
+ /**
7
+ * 根据坐标系参数获取其WKT字符串
8
+ * @param {*} crs
9
+ * @returns
10
+ */
11
+ export function getWKTString (crs) {
12
+ let {type, epsg_code} = crs
13
+ for(let i = 0;i < crsList.length;i++) {
14
+ let typeCode = crsTypes[crsList[i].type].code
15
+ if (typeCode !== type) {
16
+ continue
17
+ }
18
+ let {authCode, wkt, children} = crsList[i]
19
+ if (authCode == epsg_code) {
20
+ return wkt
21
+ }
22
+ if (children?.length) {
23
+ for(let j = 0;j < children.length;j++) {
24
+ if (children[j].children) {
25
+ for(let n = 0;n < children[j].children.length;n++) {
26
+ if (children[j].children[n].authCode == epsg_code) {
27
+ return children[j].children[n].wkt
28
+ }
29
+ }
30
+ } else {
31
+ if (children[j].authCode == epsg_code) {
32
+ return children[j].wkt
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ return null
39
+ }
40
+
41
+ /**
42
+ * 将经纬度转为指定级别的像素坐标,瓦片大小按照512计算
43
+ * @param {*} lngLat
44
+ * @param {*} zoom
45
+ * @returns
46
+ */
47
+ export function project (lngLat, zoom = 12) { // 经纬度转墨卡托像素坐标
48
+ let [lng, lat] = lngLat
49
+ let x = (180 + lng) / 360
50
+ let y = (180 - (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) / 360
51
+ return {
52
+ x: x * Math.pow(2, zoom) * 512,
53
+ y: y * Math.pow(2, zoom) * 512
54
+ }
55
+ }
56
+
57
+ /**
58
+ * 经纬度转为指定级别的瓦片坐标
59
+ * @param {*} zoom
60
+ * @param {*} lngLat
61
+ * @returns
62
+ */
63
+ export function getTileCoord (zoom, lngLat) {
64
+ let [lng, lat] = lngLat
65
+ let x = (180 + lng) / 360
66
+ let y = (180 - (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) / 360
67
+ return {
68
+ x: Math.floor(x * Math.pow(2, zoom)),
69
+ y: Math.floor(y * Math.pow(2, zoom)),
70
+ z: zoom
71
+ }
72
+ }
73
+
74
+ /**
75
+ * 经纬度转为指定级别的瓦片上的像素坐标
76
+ * @param {*} zoom
77
+ * @param {*} lngLat
78
+ * @returns 返回的坐标是在瓦片坐标系的坐标
79
+ */
80
+ export function getTilePixelCoord (zoom, lngLat) {
81
+ let [lng, lat] = lngLat
82
+ let x = (180 + lng) / 360
83
+ let y = (180 - (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) / 360
84
+ return {
85
+ x: Math.round(x * Math.pow(2, zoom) * 512) % 512,
86
+ y: Math.round(y * Math.pow(2, zoom) * 512) % 512
87
+ }
88
+ }
89
+
90
+ // 根据传入的经度,计算所属UTM投影带
91
+ export function getUTMProjection (lng) {
92
+ let initCode = 32600
93
+ let n = Math.ceil((lng + 180) / 6)
94
+ return {
95
+ type: 3,
96
+ type_name: 'Projected',
97
+ label: `WGS 84 / UTM zone ${n}N`,
98
+ epsg_code: initCode + n
99
+ }
100
+ }
101
+
102
+ /**
103
+ * 通用的坐标转换函数,将一个坐标由源坐标系转到目标坐标系
104
+ * @param {Array} coordinate 带转换的坐标
105
+ * @param {*} sourceCrs 原坐标系
106
+ * @param {*} targetCrs 目标坐标系
107
+ * @returns Array | null
108
+ */
109
+ export function transformCoordinate (coordinate, sourceCrs, targetCrs) {
110
+ if (!coordinate) {
111
+ return null
112
+ }
113
+ coordinate = [...coordinate]
114
+ if (!coordinate[2]) {
115
+ coordinate[2] = 0
116
+ }
117
+ if (!sourceCrs || !targetCrs) {
118
+ return coordinate
119
+ }
120
+ if (targetCrs.type === 1 || sourceCrs.type === 1) { // any => Local 或者 Local => any,无法转换
121
+ return coordinate
122
+ } else if (sourceCrs.type === 0 && targetCrs.type === 0) { // LocalEnu => LocalEnu
123
+ let p = satellite_geo_calc.coordinateTransfer.lla_to_enu({ lon:sourceCrs.origin_point[0], lat:sourceCrs.origin_point[1], alt: sourceCrs.origin_point[2]}, {lon: targetCrs.origin_point[0], lat: targetCrs.origin_point[1], alt: targetCrs.origin_point[2]})
124
+ return [p.x + coordinate[0], p.y + coordinate[1], p.z + coordinate[2]]
125
+ } else if (sourceCrs.type === 0) { // LocalEnu => geo
126
+ let lla = satellite_geo_calc.coordinateTransfer.enu_to_lla({x: coordinate[0], y: coordinate[1], z: coordinate[2]}, { lon: sourceCrs.origin_point[0], lat: sourceCrs.origin_point[1], alt: sourceCrs.origin_point[2] })
127
+ let coord = [lla.lon, lla.lat, lla.alt]
128
+ let {wkt, epsg_code} = targetCrs
129
+ if (epsg_code === 4326 || epsg_code === 4490) {
130
+ return coord
131
+ }
132
+ if (!wkt && epsg_code) {
133
+ wkt = getWKTString(targetCrs)
134
+ }
135
+ if (!wkt) {
136
+ return null
137
+ }
138
+ return proj4('EPSG:4326', wkt, coord)
139
+ } else if (targetCrs.type === 0) { // geo => LocalEnu
140
+ let {wkt, epsg_code} = sourceCrs
141
+ let lla = coordinate
142
+ if (epsg_code !== 4326) {
143
+ if (!wkt && epsg_code) {
144
+ wkt = getWKTString(sourceCrs)
145
+ }
146
+ if (!wkt) {
147
+ return null
148
+ }
149
+ lla = proj4(wkt, 'EPSG:4326', coordinate)
150
+ }
151
+ let p = satellite_geo_calc.coordinateTransfer.lla_to_enu({ lon:lla[0], lat:lla[1], alt: lla[2]}, {lon: targetCrs.origin_point[0], lat: targetCrs.origin_point[1], alt: targetCrs.origin_point[2]})
152
+ return [p.x, p.y, p.z]
153
+ } else { // geo => geo
154
+ let sourceWkt = sourceCrs.wkt
155
+ let targetWkt = targetCrs.wkt
156
+ if (!sourceWkt && sourceCrs.epsg_code) {
157
+ sourceWkt = getWKTString(sourceCrs)
158
+ }
159
+ if (!targetWkt && targetCrs.epsg_code) {
160
+ targetWkt = getWKTString(targetCrs)
161
+ }
162
+ if (!sourceWkt || !targetWkt) {
163
+ return null
164
+ }
165
+ return proj4(sourceWkt, targetWkt, coordinate)
166
+ }
167
+ }
168
+
169
+ /**
170
+ * 将指定坐标系下的某个坐标转到WGS84经纬度
171
+ * @param {*} lngLat
172
+ * @param {*} sourceCrs
173
+ * @returns
174
+ */
175
+ export function transformCoordinateToLngLat (lngLat, sourceCrs) {
176
+ return transformCoordinate(lngLat, sourceCrs, {
177
+ type: 2,
178
+ type_name: 'Geographic',
179
+ epsg_code: 4326
180
+ })
181
+ }
182
+
183
+ /**
184
+ * 将经纬度转为其他坐标系
185
+ */
186
+ export function transformLnglat (lngLat, coordinate_system) {
187
+ return transformCoordinate(lngLat, {
188
+ type: 2,
189
+ type_name: 'Geographic',
190
+ epsg_code: 4326
191
+ }, coordinate_system)
192
+ }
193
+
194
+ /**
195
+ * 将经纬度转为笛卡尔地心坐标系
196
+ * @param {*} coord
197
+ * @returns
198
+ */
199
+ export function geographicToCartesian (coord) {
200
+ let p1 = '+proj=longlat +datum=WGS84'
201
+ let p2 = '+proj=geocent +datum=WGS84'
202
+ return proj4(p1, p2, coord)
203
+ }
204
+