From 8941f352da352efd1d1f01181b5b7ce7aa453d19 Mon Sep 17 00:00:00 2001 From: suixy <2277317060@qq.com> Date: Fri, 10 Oct 2025 18:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/index.vue | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index 1f4bdb2..ed3b85d 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -757,11 +757,25 @@ const setItemsId = (e) => { const locationData = ref({}) const currentPosition = ref({}) +const getDistanceInMeters = (lon1, lat1, lon2, lat2) => { + const R = 6371000; // 地球半径(米) + const toRad = deg => deg * Math.PI / 180; + + const dLat = toRad(lat2 - lat1); + const dLon = toRad(lon2 - lon1); + + const a = + Math.sin(dLat / 2) ** 2 + + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLon / 2) ** 2; + + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + return R * c; +} const processData = (data) => { // console.log('data',data.ty) - console.log('FodName', data.FodName) + // console.log('FodName', data.FodName) if (data.FodName === '雷达信息') { - console.log('雷达信息', data.radar_work_state) + // console.log('雷达信息', data.radar_work_state) radarWorkState.value = data.radar_work_state } if (data.FodName === '图像数据') { @@ -776,13 +790,11 @@ const processData = (data) => { lon: data.Longitude, lat: data.Latitude, } - console.log(area) - console.log(data) // console.log(data.Longitude > area.LonMin, data.Longitude < area.LonMax, data.Latitude > area.LatMin, data.Latitude < area.LatMax) if (data.Longitude > area.LonMin && data.Longitude < area.LonMax && data.Latitude > area.LatMin && data.Latitude < area.LatMax) { let location = { - x: data.Longitude, - y: data.Latitude, + x: getDistanceInMeters(data.Longitude, area.LonMin), + y: getDistanceInMeters(data.Latitude, area.LatMin), rotate: data.HeadingAngle // rotate: 0 }