From 89b52af2d6c3c5d855a3a2c9caa73aad90361911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E5=A4=A7=E8=83=86?= <1101282782@qq.com> Date: Wed, 10 Sep 2025 10:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Global/Contour/index.js | 185 +++++++++++++------ src/In/index.js | 6 +- src/Obj/Analysis/ViewShed/index.js | 3 +- src/Tools/index.js | 8 +- src/Tools/projConvert.js | 280 ++++++++++++++--------------- src/Tools/projectionConvert.js | 179 +++++++++--------- 6 files changed, 366 insertions(+), 295 deletions(-) diff --git a/src/Global/Contour/index.js b/src/Global/Contour/index.js index 4bb7c89..babeefc 100644 --- a/src/Global/Contour/index.js +++ b/src/Global/Contour/index.js @@ -30,6 +30,7 @@ let halfIntervalContourColor = '#64b6d9' let supplementaryContourShow = false let supplementaryContourWidth = 1.0 let supplementaryContourColor = '#d084d1' +let paramData = {} activeHeightElm = document.createElement('div') @@ -72,6 +73,55 @@ function accordingToCameraHeight() { // console.log(cameraHeight) } +} + +function startDraw(sdk, showData) { + show = showData + + Object.keys(paramData).forEach(item => { + material.uniforms[item] = paramData[item] + }) + + if (show) { + let height = sdk.viewer.camera.positionCartographic.height + if (height > 16360) { + let cartographic = sdk.viewer.camera.positionCartographic + let options = { + position: { + lng: Cesium.Math.toDegrees(cartographic.longitude), + lat: Cesium.Math.toDegrees(cartographic.latitude), + alt: 16360, + }, + } + flyTo(sdk, options, 0.5) + } + showContour(sdk) + } else { + hideContour(sdk) + } +} +function reset() { + // if (handler) { + // handler.destroy() + // } + secondaryLinesCount = 19 + // show = true + equalHeightDistance = 10 + activeColor = '#ffd000' + indexContourShow = true + indexContourWidth = 2.5 + indexContourColor = '#43cf7c' + intermediateContourShow = true + intermediateContourWidth = 1.8 + intermediateContourColor = '#ff0000' + halfIntervalContourShow = false + halfIntervalContourWidth = 1.0 + halfIntervalContourColor = '#64b6d9' + supplementaryContourShow = false + supplementaryContourWidth = 1.0 + supplementaryContourColor = '#d084d1' + + } async function dialog(sdk) { _sdk = sdk @@ -106,44 +156,44 @@ async function dialog(sdk) { sdk.viewer.scene.postRender.addEventListener(accordingToCameraHeight) // 显示 - let showBtn = contentElm.getElementsByClassName('show')[0] - showBtn.checked = show - if (showBtn.checked) { - let height = sdk.viewer.camera.positionCartographic.height - if (height > 16360) { - let cartographic = sdk.viewer.camera.positionCartographic - let options = { - position: { - lng: Cesium.Math.toDegrees(cartographic.longitude), - lat: Cesium.Math.toDegrees(cartographic.latitude), - alt: 16360, - }, - } - flyTo(sdk, options, 0.5) - } - showContour(sdk) - } - showBtn.addEventListener('change', (e) => { - if (e.target.checked) { - show = true - let height = sdk.viewer.camera.positionCartographic.height - if (height > 16360) { - let cartographic = sdk.viewer.camera.positionCartographic - let options = { - position: { - lng: Cesium.Math.toDegrees(cartographic.longitude), - lat: Cesium.Math.toDegrees(cartographic.latitude), - alt: 16360, - }, - } - flyTo(sdk, options, 0.5) - } - showContour(sdk) - } else { - show = false - hideContour(sdk) - } - }) + // let showBtn = contentElm.getElementsByClassName('show')[0] + // showBtn.checked = show + // if (showBtn.checked) { + // let height = sdk.viewer.camera.positionCartographic.height + // if (height > 16360) { + // let cartographic = sdk.viewer.camera.positionCartographic + // let options = { + // position: { + // lng: Cesium.Math.toDegrees(cartographic.longitude), + // lat: Cesium.Math.toDegrees(cartographic.latitude), + // alt: 16360, + // }, + // } + // flyTo(sdk, options, 0.5) + // } + // showContour(sdk) + // } + // showBtn.addEventListener('change', (e) => { + // if (e.target.checked) { + // show = true + // let height = sdk.viewer.camera.positionCartographic.height + // if (height > 16360) { + // let cartographic = sdk.viewer.camera.positionCartographic + // let options = { + // position: { + // lng: Cesium.Math.toDegrees(cartographic.longitude), + // lat: Cesium.Math.toDegrees(cartographic.latitude), + // alt: 16360, + // }, + // } + // flyTo(sdk, options, 0.5) + // } + // showContour(sdk) + // } else { + // show = false + // hideContour(sdk) + // } + // }) // 等高距 let equalHeightDistanceInput = contentElm.getElementsByClassName('equal-height-distance')[0] equalHeightDistanceInput.value = equalHeightDistance @@ -152,7 +202,8 @@ async function dialog(sdk) { equalHeightDistance = value equalHeightDistanceInput.value = value if (material) { - material.uniforms.spacing = equalHeightDistance * 5 + // material.uniforms.spacing = equalHeightDistance * 5 + paramData.spacing = equalHeightDistance * 5 } }) @@ -188,13 +239,15 @@ async function dialog(sdk) { sure: color => { activeColor = color if (material) { - material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor) + // material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor) + paramData.activeColor = Cesium.Color.fromCssColorString(activeColor) } }, clear: () => { activeColor = 'rgba(255,255,255,1)' if (material) { - material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor) + // material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor) + paramData.activeColor = Cesium.Color.fromCssColorString(activeColor) } } }) @@ -205,7 +258,8 @@ async function dialog(sdk) { indexContourSwitch.addEventListener('change', (e) => { indexContourShow = e.target.checked if (material) { - material.uniforms.indexContourShow = indexContourShow + // material.uniforms.indexContourShow = indexContourShow + paramData.indexContourShow = indexContourShow } }) // 计曲线颜色 @@ -219,13 +273,15 @@ async function dialog(sdk) { sure: color => { indexContourColor = color if (material) { - material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor) + // material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor) + paramData.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor) } }, clear: () => { indexContourColor = 'rgba(255,255,255,1)' if (material) { - material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor) + // material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor) + paramData.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor) } } }) @@ -237,7 +293,8 @@ async function dialog(sdk) { indexContourWidth = value indexContourWidthInput.value = value if (material) { - material.uniforms.indexContourWidth = indexContourWidth + // material.uniforms.indexContourWidth = indexContourWidth + paramData.indexContourWidth = indexContourWidth } }) @@ -247,7 +304,8 @@ async function dialog(sdk) { intermediateContourSwitch.addEventListener('change', (e) => { intermediateContourShow = e.target.checked if (material) { - material.uniforms.intermediateContourShow = intermediateContourShow + // material.uniforms.intermediateContourShow = intermediateContourShow + paramData.intermediateContourShow = intermediateContourShow } }) // 首曲线颜色 @@ -261,13 +319,15 @@ async function dialog(sdk) { sure: color => { intermediateContourColor = color if (material) { - material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor) + // material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor) + paramData.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor) } }, clear: () => { intermediateContourColor = 'rgba(255,255,255,1)' if (material) { - material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor) + // material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor) + paramData.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor) } } }) @@ -279,7 +339,8 @@ async function dialog(sdk) { intermediateContourWidth = value intermediateContourWidthInput.value = value if (material) { - material.uniforms.intermediateContourWidth = intermediateContourWidth + // material.uniforms.intermediateContourWidth = intermediateContourWidth + paramData.intermediateContourWidth = intermediateContourWidth } }) @@ -289,7 +350,8 @@ async function dialog(sdk) { halfIntervalContourSwitch.addEventListener('change', (e) => { halfIntervalContourShow = e.target.checked if (material) { - material.uniforms.halfIntervalContourShow = halfIntervalContourShow + // material.uniforms.halfIntervalContourShow = halfIntervalContourShow + paramData.halfIntervalContourShow = halfIntervalContourShow } }) // 间曲线颜色 @@ -303,13 +365,15 @@ async function dialog(sdk) { sure: color => { halfIntervalContourColor = color if (material) { - material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor) + // material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor) + paramData.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor) } }, clear: () => { halfIntervalContourColor = 'rgba(255,255,255,1)' if (material) { - material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor) + // material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor) + paramData.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor) } } }) @@ -321,7 +385,8 @@ async function dialog(sdk) { halfIntervalContourWidth = value halfIntervalContourWidthInput.value = value if (material) { - material.uniforms.halfIntervalContourWidth = halfIntervalContourWidth + // material.uniforms.halfIntervalContourWidth = halfIntervalContourWidth + paramData.halfIntervalContourWidth = halfIntervalContourWidth } }) @@ -331,7 +396,8 @@ async function dialog(sdk) { supplementaryContourSwitch.addEventListener('change', (e) => { supplementaryContourShow = e.target.checked if (material) { - material.uniforms.supplementaryContourShow = supplementaryContourShow + // material.uniforms.supplementaryContourShow = supplementaryContourShow + paramData.supplementaryContourShow = supplementaryContourShow } }) // 助曲线颜色 @@ -345,13 +411,15 @@ async function dialog(sdk) { sure: color => { supplementaryContourColor = color if (material) { - material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor) + // material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor) + paramData.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor) } }, clear: () => { supplementaryContourColor = 'rgba(255,255,255,1)' if (material) { - material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor) + // material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor) + paramData.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor) } } }) @@ -363,7 +431,8 @@ async function dialog(sdk) { supplementaryContourWidth = value supplementaryContourWidthInput.value = value if (material) { - material.uniforms.supplementaryContourWidth = supplementaryContourWidth + // material.uniforms.supplementaryContourWidth = supplementaryContourWidth + paramData.supplementaryContourWidth = supplementaryContourWidth } }) @@ -638,4 +707,4 @@ czm_material czm_getMaterial(czm_materialInput materialInput) }); } -export { dialog } +export { dialog, startDraw, reset } diff --git a/src/In/index.js b/src/In/index.js index 40f7487..f9a78fa 100644 --- a/src/In/index.js +++ b/src/In/index.js @@ -69,7 +69,7 @@ import { } from '../Global/MultiViewportMode' import { MouseCoordinate } from '../Global/MouseCoordinate' import { MouseRightMenu } from '../Global/mouseRightMenu' -import { dialog as ContourDialog } from '../Global/Contour' +import { dialog as ContourDialog, startDraw as ContourStartDraw, reset as ContourReset } from '../Global/Contour' import { on as SplitScreenOn, off as SplitScreenOff, setActiveId as SplitScreenSetActiveId, getSdk } from '../Global/SplitScreen' import LocateCurrent from '../Obj/Base/LocateCurrent' @@ -346,7 +346,9 @@ if (!window.YJ) { setActiveId: SplitScreenSetActiveId, getSdk }, - Contour: ContourDialog + Contour: ContourDialog, + ContourStartDraw, + ContourReset }, //测量 Measure: { GetMeasureStatus: () => { diff --git a/src/Obj/Analysis/ViewShed/index.js b/src/Obj/Analysis/ViewShed/index.js index 112aaf2..a9f3349 100644 --- a/src/Obj/Analysis/ViewShed/index.js +++ b/src/Obj/Analysis/ViewShed/index.js @@ -434,7 +434,7 @@ class ViewShedStage extends Tools { clear() { YJ.Measure.SetMeasureStatus(false) - this.end() + // this.end() this.tip && this.tip.destroy() this.event && this.event.destroy() this.tip = null @@ -492,6 +492,7 @@ class ViewShedStage extends Tools { text: '上一次测量未结束', type: 'warning', }); + return } else { this.editevent && this.editevent.destroy() diff --git a/src/Tools/index.js b/src/Tools/index.js index f143bf9..dc2d659 100644 --- a/src/Tools/index.js +++ b/src/Tools/index.js @@ -1534,7 +1534,13 @@ class Tools { document.body.appendChild(message) message.classList.add(type) } - + /**两点之间的距离 */ + pointDistance(p1, p2) { + let centerDegress = Cesium.Cartesian3.fromDegrees(p1.lng, p1.lat) + let point = Cesium.Cartesian3.fromDegrees(p2, p2) + let distance = Cesium.Cartesian3.distance(point, centerDegress) + return distance + } } export default Tools diff --git a/src/Tools/projConvert.js b/src/Tools/projConvert.js index 50cb8cf..22a0fbb 100644 --- a/src/Tools/projConvert.js +++ b/src/Tools/projConvert.js @@ -1,138 +1,141 @@ import Dialog from '../BaseDialog' import { Proj } from './proj' import { legp } from '../Obj/Element/datalist'; +import Tools from "../Tools"; let _DialogObject const open = async (sdk, closeCallBack) => { let proj = new Proj() - if (_DialogObject && _DialogObject.close) { - _DialogObject.close() - _DialogObject = null - } - _DialogObject = await new Dialog(sdk.viewer._container, { - title: '度分秒', - left: '180px', - top: '100px', - closeCallBack: () => { - closeCallBack && closeCallBack() - } - }) - await _DialogObject.init() + let tools = new Tools(sdk) + // if (_DialogObject && _DialogObject.close) { + // _DialogObject.close() + // _DialogObject = null + // } + // _DialogObject = await new Dialog(sdk.viewer._container, { + // title: '度分秒', + // left: '180px', + // top: '100px', + // closeCallBack: () => { + // closeCallBack && closeCallBack() + // } + // }) + // await _DialogObject.init() - let html = ` - -
- 度 - 例如116.6°, 39.9° -
-- 度分 - 例如95°10.1702', 49°12.4015' -
-- 度分秒 - 例如11°18'54.37", 39°13'46.57" -
-+ // 度 + // 例如116.6°, 39.9° + //
+ //+ // 度分 + // 例如95°10.1702', 49°12.4015' + //
+ //+ // 度分秒 + // 例如11°18'54.37", 39°13'46.57" + //
+ //