From 2227d367fdb5acf45cbd0d4fa9aca90225c370b5 Mon Sep 17 00:00:00 2001 From: sd <1504629600@qq.com> Date: Wed, 11 Feb 2026 15:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=90=E6=A0=87=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/cesiumMap/LocateDialog.vue | 95 ++++++++++++++++++++++----- ruoyi-ui/src/views/cesiumMap/index.vue | 49 ++++++++++++-- ruoyi-ui/src/views/childRoom/index.vue | 8 ++- 3 files changed, 128 insertions(+), 24 deletions(-) diff --git a/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue b/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue index 750db97..9a9861e 100644 --- a/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue +++ b/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue @@ -61,7 +61,7 @@ @@ -70,7 +70,7 @@ @@ -78,7 +78,7 @@ @@ -107,6 +107,10 @@ export default { visible: { type: Boolean, default: false + }, + coordinateFormat: { + type: String, + default: 'dms' // 'decimal' 或 'dms' } }, data() { @@ -137,9 +141,44 @@ export default { this.loadScenarios() } this.$emit('update:visible', newVal) + }, + coordinateFormat: { + handler(newVal) { + this.updateCoordinateFormat(newVal) + } } - }, + }, methods: { + updateCoordinateFormat(newFormat) { + if (!this.formData.lng || !this.formData.lat) return + + let lngDegrees, latDegrees + + if (this.coordinateFormat === 'dms') { + lngDegrees = this.dmsToDegrees(this.formData.lng) + latDegrees = this.dmsToDegrees(this.formData.lat) + } else { + lngDegrees = parseFloat(this.formData.lng) + latDegrees = parseFloat(this.formData.lat) + } + + if (lngDegrees !== null && latDegrees !== null && !isNaN(lngDegrees) && !isNaN(latDegrees)) { + if (newFormat === 'dms') { + this.formData.lng = this.degreesToDMS(lngDegrees) + this.formData.lat = this.degreesToDMS(latDegrees) + } else { + this.formData.lng = lngDegrees.toFixed(6) + this.formData.lat = latDegrees.toFixed(6) + } + } + }, + formatCoordinate(value) { + if (this.coordinateFormat === 'dms') { + return this.degreesToDMS(value) + } else { + return value.toFixed(6) + } + }, degreesToDMS(decimalDegrees) { const degrees = Math.floor(decimalDegrees) const minutesDecimal = (decimalDegrees - degrees) * 60 @@ -157,12 +196,22 @@ export default { return sign * (Math.abs(degrees) + minutes / 60 + seconds / 3600) }, resetForm() { - this.formData = { - scenarioId: null, - routeId: null, - waypointId: null, - lng: '116°23\'48.64"', - lat: '39°54\'33.48"' + if (this.coordinateFormat === 'dms') { + this.formData = { + scenarioId: null, + routeId: null, + waypointId: null, + lng: '116°23\'48.64"', + lat: '39°54\'33.48"' + } + } else { + this.formData = { + scenarioId: null, + routeId: null, + waypointId: null, + lng: '116.396844', + lat: '39.909289' + } } this.routeList = [] this.waypointList = [] @@ -214,8 +263,8 @@ export default { if (value) { const waypoint = this.waypointList.find(w => w.id === value) if (waypoint) { - this.formData.lng = this.degreesToDMS(waypoint.lng) - this.formData.lat = this.degreesToDMS(waypoint.lat) + this.formData.lng = this.formatCoordinate(waypoint.lng) + this.formData.lat = this.formatCoordinate(waypoint.lat) } } }, @@ -233,12 +282,24 @@ export default { return } - const lngDegrees = this.dmsToDegrees(lng) - const latDegrees = this.dmsToDegrees(lat) + let lngDegrees, latDegrees - if (lngDegrees === null || latDegrees === null || isNaN(lngDegrees) || isNaN(latDegrees)) { - this.$message.error('请输入有效的度分秒格式!格式:116°23\'48.64"') - return + if (this.coordinateFormat === 'dms') { + lngDegrees = this.dmsToDegrees(lng) + latDegrees = this.dmsToDegrees(lat) + + if (lngDegrees === null || latDegrees === null || isNaN(lngDegrees) || isNaN(latDegrees)) { + this.$message.error('请输入有效的度分秒格式!格式:116°23\'48.64"') + return + } + } else { + lngDegrees = parseFloat(lng) + latDegrees = parseFloat(lat) + + if (isNaN(lngDegrees) || isNaN(latDegrees)) { + this.$message.error('请输入有效的十进制格式!') + return + } } if (lngDegrees < -180 || lngDegrees > 180 || latDegrees < -90 || latDegrees > 90) { diff --git a/ruoyi-ui/src/views/cesiumMap/index.vue b/ruoyi-ui/src/views/cesiumMap/index.vue index 5802ace..6c8c1df 100644 --- a/ruoyi-ui/src/views/cesiumMap/index.vue +++ b/ruoyi-ui/src/views/cesiumMap/index.vue @@ -43,6 +43,7 @@