1
1
/*
2
2
* @Author : zouyaoji@https://github.com/zouyaoji
3
3
* @Date : 2021-10-22 14:09:42
4
- * @LastEditTime : 2023-05-23 10:31:50
4
+ * @LastEditTime : 2024-02-28 17:21:40
5
5
* @LastEditors : zouyaoji 370681295@qq.com
6
6
* @Description :
7
7
* @FilePath : \vue-cesium\packages\composables\use-drawing\use-drawing-segment.ts
@@ -103,6 +103,10 @@ export default function (props, ctx, cmpName: string) {
103
103
const { Cartesian3, Cartographic, Rectangle, createGuid, defined, Math : CesiumMath , Ray } = Cesium
104
104
const { viewer } = $services
105
105
106
+ const angleFormatter = props . angleFormatter || MeasureUnits . angleToString
107
+ const distanceFormatter = props . distanceFormatter || MeasureUnits . distanceToString
108
+ const areaFormatter = props . areaFormatter || MeasureUnits . areaToString
109
+
106
110
renderDatas . value . forEach ( polylineSegment => {
107
111
const startPosition = polylineSegment . positions [ 0 ]
108
112
const endPosition = polylineSegment . positions [ 1 ]
@@ -235,7 +239,7 @@ export default function (props, ctx, cmpName: string) {
235
239
labels . push ( {
236
240
position : labelPosition ,
237
241
id : createGuid ( ) ,
238
- text : MeasureUnits . distanceToString ( distance , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
242
+ text : distanceFormatter ( distance , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
239
243
...labelOpts
240
244
} )
241
245
}
@@ -254,7 +258,7 @@ export default function (props, ctx, cmpName: string) {
254
258
distances . push ( s )
255
259
if ( s > 0 && positions . length > 2 && props . showDistanceLabel ) {
256
260
labels . push ( {
257
- text : MeasureUnits . distanceToString ( s , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
261
+ text : distanceFormatter ( s , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
258
262
position : Cartesian3 . midpoint ( positions [ i ] , positions [ i + 1 ] , { } as any ) ,
259
263
id : createGuid ( ) ,
260
264
...labelsOpts
@@ -273,7 +277,7 @@ export default function (props, ctx, cmpName: string) {
273
277
}
274
278
angles . push ( angle )
275
279
labels . push ( {
276
- text : MeasureUnits . angleToString ( angle , props . measureUnits ?. angleUnits , props . locale , props . decimals ?. angle ) ,
280
+ text : angleFormatter ( angle , props . measureUnits ?. angleUnits , props . locale , props . decimals ?. angle ) ,
277
281
position : point1 ,
278
282
id : createGuid ( ) ,
279
283
...labelsOpts
@@ -285,7 +289,7 @@ export default function (props, ctx, cmpName: string) {
285
289
const area = calculateAreaByPostions ( positions )
286
290
props . showLabel &&
287
291
labels . push ( {
288
- text : MeasureUnits . areaToString ( area , props . measureUnits ?. areaUnits , props . locale , props . decimals ?. area ) ,
292
+ text : areaFormatter ( area , props . measureUnits ?. areaUnits , props . locale , props . decimals ?. area ) ,
289
293
position : polylineSegment . positions [ 0 ] ,
290
294
id : createGuid ( ) ,
291
295
...labelOpts
@@ -306,28 +310,28 @@ export default function (props, ctx, cmpName: string) {
306
310
labels . push ( {
307
311
position : polyline . xLabelPosition ,
308
312
id : createGuid ( ) ,
309
- text : MeasureUnits . distanceToString ( polyline . xDistance || 0 , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
313
+ text : distanceFormatter ( polyline . xDistance || 0 , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
310
314
...props . xLabelOpts
311
315
} )
312
316
313
317
labels . push ( {
314
318
position : polyline . yLabelPosition ,
315
319
id : createGuid ( ) ,
316
- text : MeasureUnits . distanceToString ( polyline . yDistance || 0 , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
320
+ text : distanceFormatter ( polyline . yDistance || 0 , props . measureUnits ?. distanceUnits , props . locale , props . decimals ?. distance ) ,
317
321
...props . yLabelOpts
318
322
} )
319
323
320
324
labels . push ( {
321
325
position : polyline . xAnglePosition ,
322
326
id : createGuid ( ) ,
323
- text : MeasureUnits . angleToString ( polyline . xAngle || 0 , props . measureUnits ?. angleUnits , props . locale , props . decimals ?. angle ) ,
327
+ text : angleFormatter ( polyline . xAngle || 0 , props . measureUnits ?. angleUnits , props . locale , props . decimals ?. angle ) ,
324
328
...props . xAngleLabelOpts
325
329
} )
326
330
327
331
labels . push ( {
328
332
position : polyline . yAnglePosition ,
329
333
id : createGuid ( ) ,
330
- text : MeasureUnits . angleToString ( polyline . yAngle || 0 , props . measureUnits ?. angleUnits , props . locale , props . decimals ?. angle ) ,
334
+ text : angleFormatter ( polyline . yAngle || 0 , props . measureUnits ?. angleUnits , props . locale , props . decimals ?. angle ) ,
331
335
...props . yAngleLabelOpts
332
336
} )
333
337
}
0 commit comments