diff --git a/src/Obj/Analysis/Submerge/index.js b/src/Obj/Analysis/Submerge/index.js index e0a066a..81246dc 100644 --- a/src/Obj/Analysis/Submerge/index.js +++ b/src/Obj/Analysis/Submerge/index.js @@ -384,13 +384,15 @@ class Submerge extends Tools { move() { - if (this.TweenAnimate) { - TWEEN.remove(this.TweenAnimate) + // if (this.TweenAnimate) { + // TWEEN.remove(this.TweenAnimate) + // } + if (!this.TweenAnimate) { + let totalTime = ((this.options.maxWaterLevel - this.options.minWaterLevel) / this.options.risingSpeed) * 1000 + this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => { + this.currentWaterLaver = r.waterLevel + }).start() } - let totalTime = ((this.options.maxWaterLevel - this.options.minWaterLevel) / this.options.risingSpeed) * 1000 - this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => { - this.currentWaterLaver = r.waterLevel - }).start() // let contentElm = this._DialogObject._element.body // let pauseBtn = contentElm.getElementsByClassName('pause')[0]; // let startBtn = contentElm.getElementsByClassName('start')[0]; @@ -409,9 +411,9 @@ class Submerge extends Tools { this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => { this.currentWaterLaver = r.waterLevel }).start() - if (isPaused) { - this.pause() - } + // if (isPaused) { + this.pause() + // } } start() { diff --git a/src/Obj/Analysis/ViewShed/index.js b/src/Obj/Analysis/ViewShed/index.js index a9f3349..8cf11ed 100644 --- a/src/Obj/Analysis/ViewShed/index.js +++ b/src/Obj/Analysis/ViewShed/index.js @@ -43,7 +43,7 @@ class ViewShedStage extends Tools { this.options = {} this.options.viewPosition = options.viewPosition; this.options.viewPositionEnd = options.viewPositionEnd; - this.options.horizontalViewAngle = (options.horizontalViewAngle || options.horizontalViewAngle === 0) ? options.horizontalViewAngle : 90.0; + this.options.horizontalViewAngle = (options.horizontalViewAngle || options.horizontalViewAngle === 0) ? options.horizontalViewAngle : 30.0; this.options.verticalViewAngle = (options.verticalViewAngle || options.verticalViewAngle === 0) ? options.verticalViewAngle : 60.0; this.options.visibleAreaColor = options.visibleAreaColor || '#008000'; this.options.invisibleAreaColor = options.invisibleAreaColor || '#FF0000'; @@ -182,7 +182,7 @@ class ViewShedStage extends Tools { return pitch } - static create(that) { + static create(that, callBack) { that.destroy() let count = 0; if (!YJ.Measure.GetMeasureStatus()) { @@ -201,6 +201,7 @@ class ViewShedStage extends Tools { that.ids.push(ViewShedStage.create_point(that, cartesian)) that.end() that.update() + callBack(true) } }) that.event.mouse_move((movement, cartesian) => { @@ -212,6 +213,7 @@ class ViewShedStage extends Tools { }) that.ids = [] that.end() + callBack(false) }) that.event.gesture_pinck_start((movement, cartesian) => { let startTime = new Date() @@ -223,6 +225,7 @@ class ViewShedStage extends Tools { }) that.ids = [] that.end() + callBack(false) } }) }) @@ -232,6 +235,7 @@ class ViewShedStage extends Tools { text: '上一次测量未结束', type: 'warning', }); + callBack(false) } @@ -247,8 +251,8 @@ class ViewShedStage extends Tools { this.tip = null this.event = null } - draw() { - ViewShedStage.create(this) + draw(callBack) { + ViewShedStage.create(this, callBack) } static create_point(that, cartesian) { diff --git a/src/Tools/index.js b/src/Tools/index.js index aada909..3544176 100644 --- a/src/Tools/index.js +++ b/src/Tools/index.js @@ -1541,10 +1541,111 @@ class Tools { /**两点之间的距离 */ pointDistance(p1, p2) { let centerDegress = Cesium.Cartesian3.fromDegrees(p1.lng, p1.lat) - let point = Cesium.Cartesian3.fromDegrees(p2, p2) + let point = Cesium.Cartesian3.fromDegrees(p2.lng, p2.lat) let distance = Cesium.Cartesian3.distance(point, centerDegress) return distance } + + /** + * Web墨卡托坐标转WGS84经纬度 + * @param {number} x - 墨卡托X坐标 + * @param {number} y - 墨卡托Y坐标 + * @returns {Array} [经度, 纬度] + */ + mercatorToWGS84(x, y) { + // 地球周长的一半 + const earthHalfCircumference = 20037508.34 + + // 计算经度 + const lon = (x / earthHalfCircumference) * 180 + + // 计算纬度(包含反双曲正切变换) + let lat = (y / earthHalfCircumference) * 180 + lat = (180 / Math.PI) * (2 * Math.atan(Math.exp((lat * Math.PI) / 180)) - Math.PI / 2) + + return [lon, lat] + } + /** + * CGCS2000 3度带坐标转WGS84经纬度 + * @param {number} x - CGCS2000 X坐标(不含带号) + * @param {number} y - CGCS2000 Y坐标 + * @param {number} centralMeridian - 中央经线(如120) + * @returns {Array} [经度, 纬度] + */ + convertCGCStoWGS84(x, y, centralMeridian) { + // 定义坐标系参数 + const wgs84 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' + const cgcs2000 = + '+proj=tmerc +lat_0=0 +lon_0=' + + centralMeridian + + ' +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs' + + // 执行坐标转换 + const point = proj4(cgcs2000, wgs84, [x, y]); + return point; + } + /** + * 提取带号并转换CGCS2000坐标到WGS84 + * @param {number} xWithZone - 带代号的X坐标(如40543210) + * @param {number} y - Y坐标 + * @returns {Array} [经度, 纬度] + */ + convertCGCSToWGS84WithZone(xWithZone, y) { + // 将X坐标转为字符串以提取带号 + const xStr = xWithZone.toString(); + + // 提取带号(前2位)和实际X坐标 + const zoneNumber = parseInt(xStr.substring(0, 2)); + const actualX = parseInt(xStr.substring(2)); + + // 计算中央经线:3° × 带号 + const centralMeridian = zoneNumber * 3; + + // 定义坐标系参数 + const wgs84 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'; + const cgcs2000 = `+proj=tmerc +lat_0=0 +lon_0=${centralMeridian} +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs`; + + // 执行坐标转换 + const point = proj4(cgcs2000, wgs84, [actualX, y]); + return point; + } + /** + * CGCS2000六度带坐标转WGS84经纬度 + * @param {number} x - CGCS2000 X坐标(无带号) + * @param {number} y - CGCS2000 Y坐标 + * @param {number} centralMeridian - 中央经线(如117) + * @returns {Array} [经度, 纬度] + */ + convertCGCS2000_6ToWGS84(x, y, centralMeridian) { + // 定义坐标系参数 + const wgs84 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'; + const cgcs2000_6 = '+proj=tmerc +lat_0=0 +lon_0=' + centralMeridian + ' +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs'; + + // 执行坐标转换 + const point = proj4(cgcs2000_6, wgs84, [x, y]); + return point; + } + convertCGCS2000_6ToWGS84WithZone(xWithZone, y) { + // 将X坐标转为字符串以提取带号 + const xStr = xWithZone.toString(); + + // 提取带号(前2位) + const zoneNumber = parseInt(xStr.substring(0, 2)); + + // 计算中央经线:六度带中央经线 = 带号 × 6 - 3 + const centralMeridian = zoneNumber * 6 - 3; + + // 实际X坐标(去除带号) + const actualX = parseInt(xStr.substring(2)); + + // 定义坐标系参数 + const wgs84 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'; + const cgcs2000_6 = '+proj=tmerc +lat_0=0 +lon_0=' + centralMeridian + ' +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs'; + + // 执行坐标转换 + const point = proj4(cgcs2000_6, wgs84, [actualX, y]); + return point; + } } export default Tools