@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.
- package/dist/catchUtil.min.esm.js +67927 -14001
- package/dist/catchUtil.min.js +2695 -55
- package/package.json +22 -3
- package/src/constants/annotation_color.js +7 -0
- package/src/constants/annotation_draw_style.js +228 -0
- package/src/constants/annotation_label_style.js +76 -0
- package/src/constants/annotation_style.js +118 -0
- package/src/constants/cameras.js +1 -1
- package/src/constants/crs.js +31473 -31473
- package/src/constants/error_codes.js +44 -0
- package/src/constants/height_colors.js +1 -0
- package/src/constants/index.js +9 -2
- package/src/constants/map_style.js +11 -0
- package/src/constants/measurement_fields.js +3 -3
- package/src/{event.js → event/event.js} +1 -14
- package/src/event/event_bus.js +5 -0
- package/src/event/index.js +2 -0
- package/src/gl-operations/constants.js +9 -11
- package/src/gl-operations/default_options.js +5 -5
- package/src/gl-operations/index.js +166 -239
- package/src/gl-operations/reglCommands/contours.js +20 -20
- package/src/gl-operations/reglCommands/default.js +34 -34
- package/src/gl-operations/reglCommands/hillshading.js +116 -116
- package/src/gl-operations/reglCommands/index.js +6 -6
- package/src/gl-operations/reglCommands/multiLayers.js +55 -55
- package/src/gl-operations/reglCommands/transitions.js +24 -24
- package/src/gl-operations/reglCommands/util.js +54 -54
- package/src/gl-operations/renderer.js +69 -69
- package/src/gl-operations/shaders/transform.js +2 -2
- package/src/gl-operations/shaders/util/rgbaToFloat.glsl +11 -11
- package/src/gl-operations/texture_manager.js +58 -58
- package/src/gl-operations/util.js +154 -154
- package/src/index.js +14 -2
- package/src/measure/index.js +198 -0
- package/src/measure/tile_cache.js +88 -0
- package/src/mvs/index.js +26 -0
- package/src/mvs/protos/index.js +12 -0
- package/src/mvs/protos/proto_10.js +155 -0
- package/src/observation_pretict.js +168 -0
- package/src/photo-parser/exif/gps_tags.js +33 -0
- package/src/photo-parser/exif/ifd1_tags.js +22 -0
- package/src/photo-parser/exif/index.js +130 -0
- package/src/photo-parser/exif/parse_image.js +290 -0
- package/src/photo-parser/exif/string_values.js +137 -0
- package/src/photo-parser/exif/tags.js +75 -0
- package/src/photo-parser/exif/tiff_tags.js +35 -0
- package/src/photo-parser/exif/util.js +103 -0
- package/src/photo-parser/image-size/detector.js +24 -0
- package/src/photo-parser/image-size/fromFile.js +55 -0
- package/src/photo-parser/image-size/index.js +2 -0
- package/src/photo-parser/image-size/lookup.js +37 -0
- package/src/photo-parser/image-size/types/bmp.js +10 -0
- package/src/photo-parser/image-size/types/cur.js +16 -0
- package/src/photo-parser/image-size/types/dds.js +10 -0
- package/src/photo-parser/image-size/types/gif.js +11 -0
- package/src/photo-parser/image-size/types/heif.js +35 -0
- package/src/photo-parser/image-size/types/icns.js +112 -0
- package/src/photo-parser/image-size/types/ico.js +74 -0
- package/src/photo-parser/image-size/types/index.js +43 -0
- package/src/photo-parser/image-size/types/j2c.js +11 -0
- package/src/photo-parser/image-size/types/jp2.js +22 -0
- package/src/photo-parser/image-size/types/jpg.js +157 -0
- package/src/photo-parser/image-size/types/ktx.js +18 -0
- package/src/photo-parser/image-size/types/png.js +36 -0
- package/src/photo-parser/image-size/types/pnm.js +74 -0
- package/src/photo-parser/image-size/types/psd.js +10 -0
- package/src/photo-parser/image-size/types/svg.js +100 -0
- package/src/photo-parser/image-size/types/tga.js +14 -0
- package/src/photo-parser/image-size/types/tiff.js +92 -0
- package/src/photo-parser/image-size/types/utils.js +83 -0
- package/src/photo-parser/image-size/types/webp.js +67 -0
- package/src/photo-parser/index.js +181 -0
- package/src/report/annotations_report.js +446 -0
- package/src/report/index.js +2 -0
- package/src/report/map_util.js +81 -0
- package/src/report/pdf_creator.js +247 -0
- package/src/report/report.js +583 -0
- package/src/transform.js +204 -0
- package/src/util.js +371 -75
- package/CHANGELOG.md +0 -60
- /package/src/constants/{colors.js → dsm_colors.js} +0 -0
package/src/transform.js
ADDED
|
@@ -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
|
+
|