jxdnsong
2023-04-05 be147d2a99d60a30b20fade742e85b45f06172ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-31 10:52:25
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-03-31 11:36:28
 * @FilePath: \srs-police-affairs\src\utils\turfPolygon.js
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
 */
import * as turf from '@turf/turf'
 
export const computerCapacity = (data) => {
    if (data.length) {
        let pointArr = []
 
        data.forEach(item => {
            if (item.longitude && item.latitude) {
                pointArr.push(turf.point([item.longitude, item.latitude]))
                return
            }
 
            if (item.lng && item.lat) {
                pointArr.push(turf.point([item.lng, item.lat]))
                return
            }
        })
 
        const features = turf.featureCollection(pointArr)
 
        const scope = turf.envelope(features).bbox
 
        global.viewer.flyToBounds(scope,
            { heading: 0, pitch: -90, roll: 0 },
            (e) => { },
            3
        )
    }
}