easy-three-utils 0.0.347 → 0.0.349

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.
@@ -1,10 +1,12 @@
1
1
  import Timeline from './react/Timeline/index.tsx'
2
+ import ProFileEcharts from './react/ProFileEcharts/index.tsx'
2
3
 
3
4
  const components = {
4
5
  vue: {
5
6
  },
6
7
  react: {
7
- Timeline
8
+ Timeline,
9
+ ProFileEcharts
8
10
  }
9
11
  }
10
12
 
@@ -0,0 +1,11 @@
1
+ .profile-echarts-box {
2
+ position: absolute;
3
+ bottom: 30px;
4
+ left: 20vw;
5
+ z-index: 180;
6
+
7
+ .profile-echarts {
8
+ width: 60vw;
9
+ height: 300px;
10
+ }
11
+ }
@@ -0,0 +1,127 @@
1
+ import React, { useEffect, useRef } from "react"
2
+ import echarts from 'echarts'
3
+
4
+ import Styles from './index.module.less'
5
+
6
+ const ProFileEchartCom: React.FC<{
7
+ data: {
8
+ min: number
9
+ value: (number | string)[][]
10
+ }
11
+ display: boolean
12
+ }> = (props) => {
13
+
14
+ const { data, display } = props
15
+
16
+ const chartRef = useRef(null)
17
+ const option = {
18
+ color: ['white'],
19
+ backgroundColor: 'rgba(6, 38, 68, 0.7)',
20
+ title: {
21
+ text: '剖面分析',
22
+ textStyle: {
23
+ color: 'white',
24
+ },
25
+ padding: [15, 15]
26
+ },
27
+ tooltip: {
28
+ trigger: 'axis'
29
+ },
30
+ grid: {
31
+ x: 60,
32
+ x2: 40,
33
+ y2: 30
34
+ },
35
+ calculable: true,
36
+ xAxis: [
37
+ {
38
+ type: 'value',
39
+ max: 'dataMax',
40
+ scale: true,
41
+ axisLabel: {
42
+ textStyle: {
43
+ color: 'white'
44
+ },
45
+ formatter(value) {
46
+ return value + "米"
47
+ }
48
+ },
49
+ axisLine: {
50
+ lineStyle: {
51
+ color: 'white'
52
+ },
53
+ }
54
+ }
55
+ ],
56
+ yAxis: [
57
+ {
58
+ type: 'value',
59
+ min: data.min,
60
+ scale: true,
61
+ axisLabel: {
62
+ textStyle: {
63
+ color: 'white'
64
+ },
65
+ formatter(value) {
66
+ return value + "米"
67
+ }
68
+ },
69
+ axisLine: {
70
+ lineStyle: {
71
+ color: 'white'
72
+ },
73
+ }
74
+ }
75
+ ],
76
+ series: [
77
+ {
78
+ name: '当前高度',
79
+ type: 'line',
80
+ areaStyle: {
81
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
82
+ {
83
+ offset: 0,
84
+ color: 'rgba(58,77,233,0.8)'
85
+ },
86
+ {
87
+ offset: 1,
88
+ color: 'rgba(58,77,233,0.3)'
89
+ }
90
+ ])
91
+ },
92
+ data: data.value
93
+ }
94
+ ]
95
+ }
96
+
97
+ useEffect(() => {
98
+ const chart = echarts.init(chartRef.current)
99
+ chart.setOption(option)
100
+
101
+ return () => {
102
+ chart.dispose()
103
+ }
104
+ }, [data])
105
+
106
+ const echartsResize = () => {
107
+ echarts.init(chartRef.current).resize()
108
+ }
109
+
110
+ window.addEventListener('resize', echartsResize)
111
+
112
+ useEffect(() => {
113
+ return () => {
114
+ window.removeEventListener('resize', echartsResize)
115
+ }
116
+ }, [])
117
+
118
+ return (
119
+ <>
120
+ <div className={Styles['profile-echarts-box']} style={{ display: display ? '' : 'none' }}>
121
+ <div ref={chartRef} className={Styles['profile-echarts']} />
122
+ </div>
123
+ </>
124
+ )
125
+ }
126
+
127
+ export default ProFileEchartCom
package/cesium/index.ts CHANGED
@@ -13,6 +13,8 @@ type TCesiumUtilsType = {
13
13
  clipping: ReturnType<typeof hooks.useClipping>;
14
14
  weather: ReturnType<typeof hooks.useWeather>;
15
15
  measure: ReturnType<typeof hooks.useMeasure>;
16
+ slope: ReturnType<typeof hooks.useSlope>;
17
+ profileAnalysis: ReturnType<typeof hooks.useProfileAnalysis>;
16
18
  }
17
19
 
18
20
  let config;
@@ -89,7 +91,14 @@ const useCesium = () => {
89
91
  const measure = hooks.useMeasure(viewer, {
90
92
  distanceCollection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.MEASURE_DISTANCE),
91
93
  heightCollection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.MEASURE_HEIGHT),
92
- areaCollection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.MEASURE_AREA)
94
+ areaCollection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.MEASURE_AREA),
95
+ altitudeCollection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.MEASURE_ALTITUDE),
96
+ })
97
+ const slope = hooks.useSlope(viewer, {
98
+ collection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.SLOPE)
99
+ })
100
+ const profileAnalysis = hooks.useProfileAnalysis(viewer, {
101
+ collection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.PROFILEANALYSIS)
93
102
  })
94
103
 
95
104
  if (config.controllerStyle === cesiumConfigDict.EControllerStyle.THREE) {
@@ -102,7 +111,9 @@ const useCesium = () => {
102
111
  drawPolygon,
103
112
  clipping,
104
113
  weather,
105
- measure
114
+ measure,
115
+ slope,
116
+ profileAnalysis
106
117
  })
107
118
 
108
119
  handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
@@ -3,6 +3,8 @@ import { useDrawPolygon } from './useDrawPolygon'
3
3
  import { useClipping } from './useClipping'
4
4
  import { useWeather, EWeatherType } from './useWeather'
5
5
  import { useMeasure } from './useMeasure'
6
+ import { useSlope } from './useSlope'
7
+ import { useProfileAnalysis } from './useProfileAnalysis'
6
8
 
7
9
  const dict = {
8
10
  ECollectionWhiteListNames,
@@ -15,6 +17,8 @@ export {
15
17
  useClipping,
16
18
  useWeather,
17
19
  useMeasure,
20
+ useSlope,
21
+ useProfileAnalysis,
18
22
 
19
23
  dict
20
24
  }
@@ -1,16 +1,16 @@
1
- import CreateRemindertip from "./ReminderTip";
1
+ // import CreateRemindertip from "./ReminderTip";
2
2
  import * as Cesium from 'cesium'
3
3
 
4
- const CreatePolygonOnGround = function (viewer, resultList, options, callback, cb) {
4
+ const CreatePolygonOnGround = function ({ viewer, collection }, resultList, options, callback, cb) {
5
5
  if (!viewer) throw new Error("no viewer object!");
6
6
  options = options || {};
7
7
  let id = options.id || setSessionid(); //Polygon的id
8
- if (viewer.entities.getById(id))
8
+ if (collection.entities.getById(id))
9
9
  throw new Error("the id parameter is an unique value");
10
10
  let color = options.color || Cesium.Color.RED; //Polygon的填充色
11
11
  let outlineColor = options.outlineColor || color.withAlpha(1); //Polygon的轮廓线颜色
12
12
  let outlineWidth = options.outlineWidth || 2; //Polygon的轮廓线宽度
13
- const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
13
+ let handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
14
14
  cb && cb(handler)
15
15
  let toolTip = "左键点击开始绘制";
16
16
  let anchorpoints = [];
@@ -29,7 +29,7 @@ const CreatePolygonOnGround = function (viewer, resultList, options, callback, c
29
29
  let dynamicPositions = new Cesium.CallbackProperty(function () {
30
30
  return new Cesium.PolygonHierarchy(anchorpoints);
31
31
  }, false);
32
- polygon = viewer.entities.add({
32
+ polygon = collection.entities.add({
33
33
  name: "Polygon",
34
34
  id: id,
35
35
  polyline: {
@@ -68,7 +68,11 @@ const CreatePolygonOnGround = function (viewer, resultList, options, callback, c
68
68
  anchorpoints.pop();
69
69
  polygon.pottingPoint = anchorpoints;
70
70
  resultList.push(polygon);
71
+ handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_DOWN)
72
+ handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
73
+ handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)
71
74
  handler.destroy();
75
+ handler = null
72
76
  // CreateRemindertip(toolTip, event.position, false);
73
77
  drawStatus = false;
74
78
  if (typeof callback == "function") callback(polygon);
@@ -6,13 +6,26 @@ enum ECollectionWhiteListNames {
6
6
 
7
7
  MEASURE_DISTANCE = 'measure_distance',
8
8
  MEASURE_HEIGHT = 'measure_height',
9
- MEASURE_AREA = 'measure_area'
9
+ MEASURE_AREA = 'measure_area',
10
+ MEASURE_ALTITUDE = 'measure_altitude',
11
+ PROFILEANALYSIS = 'profileAnalysis',
12
+
13
+ SLOPE = 'slope'
10
14
  }
11
15
 
12
16
  const useCustomCollection = (viewer: Cesium.Viewer) => {
13
17
 
14
18
  let collectionNames: string[] = ([])
15
- let whiteList: string[] = ['polygon', 'polygon_node', 'measure_distance', 'measure_height', 'measure_area']
19
+ let whiteList: string[] = [
20
+ 'polygon',
21
+ 'polygon_node',
22
+ 'measure_distance',
23
+ 'measure_height',
24
+ 'measure_area',
25
+ 'measure_altitude',
26
+ 'profileAnalysis',
27
+ 'slope'
28
+ ]
16
29
 
17
30
  const addCollection = (name: string) => {
18
31
  const index = collectionNames.findIndex(item => item === name)
@@ -4,7 +4,8 @@ import * as turf from "@turf/turf"
4
4
  const useMeasure = (viewer: Cesium.Viewer, options: {
5
5
  distanceCollection: Cesium.CustomDataSource,
6
6
  heightCollection: Cesium.CustomDataSource,
7
- areaCollection: Cesium.CustomDataSource
7
+ areaCollection: Cesium.CustomDataSource,
8
+ altitudeCollection: Cesium.CustomDataSource
8
9
  }) => {
9
10
 
10
11
  const angleMeasurement = () => {
@@ -107,7 +108,7 @@ const useMeasure = (viewer: Cesium.Viewer, options: {
107
108
  position: p2,
108
109
  label: {
109
110
  text: angleDeg.toFixed(2) + '°',
110
- font: 'normal 22px MicroSoft YaHei',
111
+ font: 'normal 28px MicroSoft YaHei',
111
112
  style: Cesium.LabelStyle.FILL_AND_OUTLINE,
112
113
  fillColor: Cesium.Color.WHITE,
113
114
  verticalOrigin: Cesium.VerticalOrigin.CENTER,
@@ -611,7 +612,7 @@ const useMeasure = (viewer: Cesium.Viewer, options: {
611
612
  const now = Date.now()
612
613
  if (now - lastClickTime < MIN_INTERVAL) return
613
614
  lastClickTime = now
614
-
615
+
615
616
  let position = viewer.scene.pickPosition(e.position)
616
617
  if (!position) {
617
618
  const ellipsoid = viewer.scene.globe.ellipsoid
@@ -737,16 +738,83 @@ const useMeasure = (viewer: Cesium.Viewer, options: {
737
738
  }
738
739
  }
739
740
 
741
+ const altitudeMeasurement = () => {
742
+ let handler = null
743
+
744
+ const enable = () => {
745
+ disable();
746
+
747
+ (viewer.container as HTMLElement).style.cursor = "crosshair"
748
+
749
+ handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
750
+ handler.setInputAction(async (event) => {
751
+ const cartesian = viewer.scene.pickPosition(event.position)
752
+ if (!cartesian) return
753
+
754
+ const cartographic = Cesium.Cartographic.fromCartesian(cartesian)
755
+ const lon = Cesium.Math.toDegrees(cartographic.longitude)
756
+ const lat = Cesium.Math.toDegrees(cartographic.latitude)
757
+ const height = await getHeightFromLonLat(lon, lat)
758
+
759
+ options.altitudeCollection.entities.add({
760
+ position: Cesium.Cartesian3.fromDegrees(lon, lat, height + 2),
761
+ point: {
762
+ color: Cesium.Color.fromCssColorString("rgb(249, 157, 11)"),
763
+ outlineColor: Cesium.Color.WHITE,
764
+ outlineWidth: 2,
765
+ pixelSize: 10,
766
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
767
+ },
768
+ label: {
769
+ text: `${height.toFixed(2)} m`,
770
+ scale: 0.5,
771
+ font: "normal 28px MicroSoft YaHei",
772
+ style: Cesium.LabelStyle.FILL_AND_OUTLINE,
773
+ pixelOffset: new Cesium.Cartesian2(0, -30),
774
+ outlineWidth: 9,
775
+ outlineColor: Cesium.Color.WHITE
776
+ },
777
+ })
778
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
779
+ }
780
+
781
+ const getHeightFromLonLat = async (lon, lat) => {
782
+ const positions = [Cesium.Cartographic.fromDegrees(lon, lat)]
783
+ const updated = await Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, positions)
784
+ return updated[0].height || 0
785
+ }
786
+
787
+ const disable = () => {
788
+ if (handler) {
789
+ handler.destroy()
790
+ handler = null
791
+ }
792
+ (viewer.container as HTMLElement).style.cursor = "default"
793
+ }
794
+
795
+ const removeAll = () => {
796
+ options.altitudeCollection.entities.removeAll()
797
+ }
798
+
799
+ return {
800
+ enable,
801
+ disable,
802
+ removeAll
803
+ }
804
+ }
805
+
740
806
  const angle = angleMeasurement()
741
807
  const distance = distanceMeasurement()
742
808
  const height = heightMeasurement()
743
809
  const area = areaMeasurement()
810
+ const altitude = altitudeMeasurement()
744
811
 
745
812
  return {
746
813
  angle,
747
814
  distance,
748
815
  height,
749
- area
816
+ area,
817
+ altitude
750
818
  }
751
819
  }
752
820
 
@@ -0,0 +1,270 @@
1
+ import * as Cesium from 'cesium'
2
+
3
+ const useProfileAnalysis = (viewer: Cesium.Viewer, options: {
4
+ collection: Cesium.CustomDataSource
5
+ }) => {
6
+
7
+ let handler = null
8
+ let positions = []
9
+ let positionsCartographic = []
10
+ let positions_Inter = []
11
+ let poly = null
12
+ let distance = null
13
+ let cartesian = null
14
+ let DistanceArray = []
15
+ let profileItem: {
16
+ distance: number
17
+ point: ReturnType<typeof cartesian3ToDegrees>
18
+ }[] = []
19
+
20
+ class PolyLinePrimitive {
21
+ options: Cesium.Entity.ConstructorOptions
22
+ positions: Cesium.Cartesian3[]
23
+
24
+ constructor(positions: Cesium.Cartesian3[]) {
25
+ this.options = {
26
+ polyline: {
27
+ show: true,
28
+ positions: [],
29
+ width: 3,
30
+ material: Cesium.Color.fromCssColorString("rgb(249, 157, 11)"),
31
+ clampToGround: true
32
+ }
33
+ }
34
+ this.positions = positions
35
+ this.init()
36
+ }
37
+
38
+ init = () => {
39
+ const _self = this
40
+ const _update = function () {
41
+ return _self.positions
42
+ }
43
+ this.options.polyline.positions = new Cesium.CallbackProperty(_update, false)
44
+ options.collection.entities.add(this.options)
45
+ }
46
+ }
47
+
48
+ const draw = (cb: (data: {
49
+ min: number;
50
+ value: (number | string)[][]
51
+ }) => void) => {
52
+ if (handler) {
53
+ console.log('请使用右键结束上次测量!')
54
+ return
55
+ }
56
+ options.collection.entities.removeAll()
57
+ handler = new Cesium.ScreenSpaceEventHandler((viewer.scene as any)._imageryLayerCollection)
58
+ leftClickEvent()
59
+ mouseMoveEvent()
60
+ rightClickEvent(cb)
61
+ }
62
+
63
+ const stopDraw = () => {
64
+ if (handler) {
65
+ handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK)
66
+ handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
67
+ handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)
68
+ handler.destroy()
69
+ handler = null
70
+ }
71
+
72
+ positions = []
73
+ positionsCartographic = []
74
+ positions_Inter = []
75
+ poly = null
76
+ distance = null
77
+ cartesian = null
78
+ DistanceArray = []
79
+ profileItem = []
80
+ }
81
+
82
+ const removeAll = () => {
83
+ stopDraw()
84
+ options.collection.entities.removeAll()
85
+ }
86
+
87
+ const leftClickEvent = () => {
88
+ handler.setInputAction(((movement) => {
89
+ cartesian = viewer.scene.pickPosition(movement.position)
90
+ if (positions.length == 0) {
91
+ positions.push(cartesian.clone())
92
+ }
93
+ positions.push(cartesian)
94
+ if (poly) {
95
+ interPoints(poly.positions)
96
+ distance = getSpaceDistance(positions_Inter)
97
+ } else {
98
+ distance = getSpaceDistance(positions)
99
+ }
100
+
101
+ const textDisance = distance + "米"
102
+ DistanceArray.push(distance)
103
+ options.collection.entities.add({
104
+ position: positions[positions.length - 1],
105
+ point: {
106
+ color: Cesium.Color.fromCssColorString("rgb(249, 157, 11)"),
107
+ outlineColor: Cesium.Color.WHITE,
108
+ outlineWidth: 2,
109
+ pixelSize: 10
110
+ },
111
+ label: {
112
+ text: textDisance,
113
+ font: '18px sans-serif',
114
+ fillColor: Cesium.Color.GOLD,
115
+ style: Cesium.LabelStyle.FILL_AND_OUTLINE,
116
+ outlineWidth: 2,
117
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
118
+ pixelOffset: new Cesium.Cartesian2(20, -20),
119
+ heightReference: Cesium.HeightReference.NONE
120
+ }
121
+ })
122
+ }) as Cesium.ScreenSpaceEventHandler.PositionedEventCallback, Cesium.ScreenSpaceEventType.LEFT_CLICK)
123
+ }
124
+
125
+ const mouseMoveEvent = () => {
126
+ handler.setInputAction(((movement) => {
127
+ cartesian = viewer.scene.pickPosition(movement.endPosition)
128
+ if (positions.length >= 2) {
129
+ if (!Cesium.defined(poly)) {
130
+ poly = new PolyLinePrimitive(positions)
131
+ } else {
132
+ positions.pop()
133
+ positions.push(cartesian)
134
+ }
135
+ }
136
+ }) as Cesium.ScreenSpaceEventHandler.MotionEventCallback, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
137
+ }
138
+
139
+ const rightClickEvent = (cb: (data: {
140
+ min: number;
141
+ value: (number | string)[][]
142
+ }) => void) => {
143
+ handler.setInputAction((() => {
144
+ positions.pop()
145
+ createProfileChart(profileItem, cb)
146
+ stopDraw()
147
+ }) as Cesium.ScreenSpaceEventHandler.PositionedEventCallback, Cesium.ScreenSpaceEventType.RIGHT_CLICK)
148
+ }
149
+
150
+ const cartesian3ToDegrees = (pos: Cesium.Cartesian3) => {
151
+ const ellipsoid = viewer.scene.globe.ellipsoid
152
+ const cartographic = ellipsoid.cartesianToCartographic(pos)
153
+ const lat = Cesium.Math.toDegrees(cartographic.latitude)
154
+ const lon = Cesium.Math.toDegrees(cartographic.longitude)
155
+ const height = cartographic.height
156
+
157
+ return {
158
+ lat,
159
+ lon,
160
+ height
161
+ }
162
+ }
163
+
164
+ const getSpaceDistance = (positions: Cesium.Cartesian3[]) => {
165
+ profileItem = [
166
+ {
167
+ point: cartesian3ToDegrees(positions[0]),
168
+ distance: 0
169
+ }
170
+ ]
171
+ let distance = 0
172
+ for (let i = 0; i < positions.length - 1; i++) {
173
+ const point1cartographic = Cesium.Cartographic.fromCartesian(positions[i])
174
+ const point2cartographic = Cesium.Cartographic.fromCartesian(positions[i + 1])
175
+ const geodesic = new Cesium.EllipsoidGeodesic()
176
+ geodesic.setEndPoints(point1cartographic, point2cartographic)
177
+ let s = geodesic.surfaceDistance
178
+ s = Math.sqrt(Math.pow(s, 2) + Math.pow(point2cartographic.height - point1cartographic.height, 2))
179
+ distance = distance + s
180
+
181
+ const m_Item = {
182
+ point: cartesian3ToDegrees(positions[i + 1]),
183
+ distance: distance
184
+ }
185
+ profileItem.push(m_Item)
186
+ }
187
+ return distance.toFixed(2)
188
+ }
189
+
190
+ const interPoints = (positions: Cesium.Cartesian3[]) => {
191
+ positionsCartographic = []
192
+ var terrainSamplePositions = []
193
+ for (let index = 0; index < positions.length - 1; index++) {
194
+ const element = positions[index]
195
+ var ellipsoid = viewer.scene.globe.ellipsoid
196
+ var cartographic = ellipsoid.cartesianToCartographic(element)
197
+ positionsCartographic.push(cartographic)
198
+ }
199
+ for (let i = 0; i < positionsCartographic.length; i++) {
200
+ const m_Cartographic0 = positionsCartographic[i]
201
+ const m_Cartographic1 = positionsCartographic[i + 1]
202
+ if (m_Cartographic1) {
203
+ var a = Math.abs(m_Cartographic0.longitude - m_Cartographic1.longitude) * 10000000
204
+ var b = Math.abs(m_Cartographic0.latitude - m_Cartographic1.latitude) * 10000000
205
+ if (a > b) b = a
206
+ let length = parseInt((b / 2) as any)
207
+ if (length > 1000) length = 1000
208
+ if (length < 2) length = 2
209
+ for (var j = 0; j < length; j++) {
210
+ terrainSamplePositions.push(
211
+ new Cesium.Cartographic(
212
+ Cesium.Math.lerp(m_Cartographic0.longitude, m_Cartographic1.longitude, j / (length - 1)),
213
+ Cesium.Math.lerp(m_Cartographic0.latitude, m_Cartographic1.latitude, j / (length - 1))
214
+ )
215
+ )
216
+ }
217
+ terrainSamplePositions.pop()
218
+ } else {
219
+ terrainSamplePositions.push(m_Cartographic0)
220
+ }
221
+ }
222
+ positions_Inter = []
223
+ for (var n = 0; n < terrainSamplePositions.length; n++) {
224
+ var m_cartographic = terrainSamplePositions[n]
225
+ var height = viewer.scene.globe.getHeight(m_cartographic)
226
+ var point = Cesium.Cartesian3.fromDegrees(m_cartographic.longitude / Math.PI * 180, m_cartographic.latitude / Math.PI * 180, height)
227
+ positions_Inter.push(point)
228
+ }
229
+ }
230
+
231
+ const createProfileChart = (pos: typeof profileItem, cb: (data: {
232
+ min: number;
233
+ value: (number | string)[][]
234
+ }) => void) => {
235
+ const ProfileData = []
236
+ const ProfileData_Lon = []
237
+
238
+ let min = 0
239
+
240
+ for (let index = 0; index < pos.length; index++) {
241
+ const el = pos[index]
242
+ const m_distance = el.distance.toFixed(2)
243
+
244
+ const m_Lon = el.point.lon.toFixed(5)
245
+ const m_Lat = el.point.lat.toFixed(5)
246
+ const m_height = Number(el.point.height.toFixed(2))
247
+
248
+ if (m_height < min) {
249
+ min = m_height
250
+ }
251
+ var m_data = [m_distance, m_height]
252
+ ProfileData.push(m_data)
253
+ ProfileData_Lon.push([m_Lon, m_Lat])
254
+ }
255
+
256
+ cb({
257
+ min,
258
+ value: ProfileData
259
+ })
260
+ }
261
+
262
+ return {
263
+ draw,
264
+ removeAll
265
+ }
266
+ }
267
+
268
+ export {
269
+ useProfileAnalysis
270
+ }