From a1e33d907d7060768b982cfac48b9c9132a22f62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E5=A4=A7=E8=83=86?= <1101282782@qq.com>
Date: Mon, 25 Aug 2025 11:58:11 +0800
Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=A8=A1=E5=9E=8B=E6=95=B0?=
=?UTF-8?q?=E9=87=8F=E5=88=A4=E6=96=AD=E5=B9=B6=E8=AE=BE=E7=BD=AE=E6=8F=90?=
=?UTF-8?q?=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Obj/Base/BatchModel/index.js | 30 +++++++++++++++++++++++++++++-
src/Tools/index.js | 11 +++++++++--
static/custom/css/index.css | 6 +++++-
3 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/src/Obj/Base/BatchModel/index.js b/src/Obj/Base/BatchModel/index.js
index a42c94e..38b5140 100644
--- a/src/Obj/Base/BatchModel/index.js
+++ b/src/Obj/Base/BatchModel/index.js
@@ -5,6 +5,7 @@ import Dialog from '../../Element/Dialog';
import { html } from "./_element";
import EventBinding from '../../Element/Dialog/eventBinding';
import Base from "../index";
+import Tools from "../../../Tools";
import { syncData } from '../../../Global/MultiViewportMode'
import Model from '../BaseSource/BaseModel/Model'
import { legp } from '../../Element/datalist'
@@ -13,7 +14,7 @@ import DrawPolyline from '../../../Draw/drawPolyline'
import DrawPolygon from '../../../Draw/drawPolygon'
import DrawThreeRect from '../../../Draw/drawThreeRect'
import DrawPoint from '../../../Draw/drawPoint'
-import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
+import { setActiveViewer, closeRotateAround, closeViewFollow, CesiumContainer } from '../../../Global/global'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
@@ -46,6 +47,7 @@ class BatchModel extends Base {
this._elms = {};
this.pointArr = []
this.sdk.addIncetance(this.options.id, this)
+ let tools = new Tools(sdk)
// BatchModel.computeDis(this)
// if (this.options.positions.length > 0 || this.options.positions.lng) {
if ((options.type && options.spacing != undefined) || options.type == '点') {
@@ -67,6 +69,32 @@ class BatchModel extends Base {
}
Draw && Draw.start((a, positions) => {
this.options.positions = positions;
+ //判断范围是否过大
+ if (options.type == '面') {
+ let posi = positions.map(v => {
+ return Cesium.Cartesian3.fromDegrees(v.lng, v.lat)
+ })
+ let dis1 = Cesium.Cartesian3.distance(posi[0], posi[1])
+ let dis2 = Cesium.Cartesian3.distance(posi[1], posi[2])
+ let num1 = dis1 / options.spacing
+ let num2 = dis2 / options.spacing
+ if (num1 * num2 > 100) {
+ tools.message({ type: 'warning', text: '数量大于100,请重新绘制' })
+ return;
+ }
+ } else if (options.type == '线') {
+ let posi = positions.map(v => {
+ return Cesium.Cartesian3.fromDegrees(v.lng, v.lat)
+ })
+ let dis = 0
+ for (let i = 0; i < posi.length - 2; i++) {
+ dis += Cesium.Cartesian3.distance(posi[i], posi[i + 1])
+ }
+ if (dis / options.spacing > 100) {
+ tools.message({ type: 'warning', text: '数量大于100,请重新绘制' })
+ return;
+ }
+ }
// this.callback(this.options);
(this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this)
})
diff --git a/src/Tools/index.js b/src/Tools/index.js
index 7bb0c14..c5b2466 100644
--- a/src/Tools/index.js
+++ b/src/Tools/index.js
@@ -1493,7 +1493,7 @@ class Tools {
}
}
- message(option={}) {
+ message(option = {}) {
let type = option.type || 'success'
let text = option.text || ''
let duration = option.duration || 1500
@@ -1504,9 +1504,16 @@ class Tools {
}
message = document.createElement('div')
message.id = 'YJ-custom-message'
- message.innerHTML = `
+ if (type == 'success') {
+ message.innerHTML = `
${text}
`
+ } else if (type == 'warning') {
+ message.innerHTML = `
+ ${text}
+ `
+ }
+
document.body.appendChild(message)
message.classList.add(type)
}
diff --git a/static/custom/css/index.css b/static/custom/css/index.css
index a8221a2..ddc31cf 100644
--- a/static/custom/css/index.css
+++ b/static/custom/css/index.css
@@ -3799,6 +3799,10 @@
background-color: #f0f9eb;
color: rgb(82, 196, 26);
}
+#YJ-custom-message.warning {
+ background-color: #fdf6ec;
+ color: #e6a23c;
+}
/* 滑入动画 */
@keyframes YJ-custom-message-slideDown {
@@ -3815,4 +3819,4 @@
top: -200px
/* 移回顶部外 */
}
-}
\ No newline at end of file
+}