From 4850b7bf818d8febdaf9b9f59f09fb4359c03bc4 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 04 Apr 2023 16:10:59 +0800
Subject: [PATCH] 首页及在线离线样式

---
 src/utils/turfPolygon.js |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/utils/turfPolygon.js b/src/utils/turfPolygon.js
index 26f4ce6..8395541 100644
--- a/src/utils/turfPolygon.js
+++ b/src/utils/turfPolygon.js
@@ -2,7 +2,7 @@
  * @Author: shuishen 1109946754@qq.com
  * @Date: 2023-03-31 10:52:25
  * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2023-03-31 11:36:28
+ * @LastEditTime: 2023-04-04 15:55:33
  * @FilePath: \srs-police-affairs\src\utils\turfPolygon.js
  * @Description: 
  * 
@@ -10,8 +10,28 @@
  */
 import * as turf from '@turf/turf'
 
-export const computerCapacity = (data) => {
-    if (data.length) {
+export const computerCapacity = (data, type) => {
+    if (type == 'region') {
+        const pointArr = data.reduce((pre, cur) => {
+            cur.position && JSON.parse(cur.position).coordinates[0][0].forEach(item => {
+                console.log(item, 959)
+                item[0] && item[1] && pre.push(turf.point(item))
+            })
+
+            return pre
+        }, [])
+
+
+        const features = turf.featureCollection(pointArr)
+
+        const scope = turf.envelope(features).bbox
+
+        const poly = turf.polygon([[[scope[0], scope[1]], [scope[0], scope[3]], [scope[2], scope[1]], [scope[2], scope[3]]]])
+
+        const scaledPoly = turf.transformScale(poly, 3)
+
+        console.log(scope, scaledPoly, 5555)
+    } else {
         let pointArr = []
 
         data.forEach(item => {
@@ -30,8 +50,12 @@
 
         const scope = turf.envelope(features).bbox
 
+        console.log(scope, 5555)
+
+        const poly = turf.polygon([[[0, 29], [3.5, 29], [2.5, 32], [0, 29]]])
+
         global.viewer.flyToBounds(scope,
-            { heading: 0, pitch: -90, roll: 0 },
+            { heading: 0, pitch: -45, roll: 0 },
             (e) => { },
             3
         )

--
Gitblit v1.9.3