| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2023-03-31 10:52:25 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2023-04-18 20:13:04 |
| | | * @LastEditTime: 2023-05-06 10:45:56 |
| | | * @FilePath: \srs-police-affairs\src\utils\turfPolygon.js |
| | | * @Description: |
| | | * |
| | |
| | | return turf.centroid(turf.polygon([arr])).geometry.coordinates |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | export const computerCapacity = (data, type = '') => { |
| | | |
| | |
| | | 3 |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export const getMapBounds = (data, type = '') => { |
| | | let pointArr = [] |
| | | |
| | | data.forEach(item => { |
| | | if (item.lng && item.lat) { |
| | | pointArr.push(turf.point([item.lng, item.lat])) |
| | | return |
| | | } |
| | | }) |
| | | |
| | | const features = turf.featureCollection(pointArr) |
| | | |
| | | console.log(turf.envelope(features)) |
| | | |
| | | const scope = turf.envelope(features).bbox |
| | | |
| | | // const poly = turf.polygon([[[0, 29], [3.5, 29], [2.5, 32], [0, 29]]]) |
| | | |
| | | return scope |
| | | } |