|
|
@ -7,6 +7,7 @@
|
|
|
|
import { Angle } from '@/utils/map/angle.ts'
|
|
|
|
import { Angle } from '@/utils/map/angle.ts'
|
|
|
|
import {ScreenSpaceEventHandler, Math, ScreenSpaceEventType} from 'cesium'
|
|
|
|
import {ScreenSpaceEventHandler, Math, ScreenSpaceEventType} from 'cesium'
|
|
|
|
import {onMounted, ref} from "vue";
|
|
|
|
import {onMounted, ref} from "vue";
|
|
|
|
|
|
|
|
import {cartesian2ToCartesian3} from "@/utils/map/coordinate.ts";
|
|
|
|
let nowLatStr: string, nowLonStr: string
|
|
|
|
let nowLatStr: string, nowLonStr: string
|
|
|
|
let lonlatStr = ref('')
|
|
|
|
let lonlatStr = ref('')
|
|
|
|
let isDecimal = ref(true)
|
|
|
|
let isDecimal = ref(true)
|
|
|
@ -17,13 +18,6 @@ onMounted(()=>{
|
|
|
|
let handler = new ScreenSpaceEventHandler(canvas)
|
|
|
|
let handler = new ScreenSpaceEventHandler(canvas)
|
|
|
|
handler.setInputAction((e:any)=> {
|
|
|
|
handler.setInputAction((e:any)=> {
|
|
|
|
//捕获椭球体,将笛卡尔二维平面坐标转为椭球体的笛卡尔三维坐标,返回球体表面的点
|
|
|
|
//捕获椭球体,将笛卡尔二维平面坐标转为椭球体的笛卡尔三维坐标,返回球体表面的点
|
|
|
|
// let position: any = _viewer.scene.pickPosition(e.endPosition)
|
|
|
|
|
|
|
|
// if (!position) {
|
|
|
|
|
|
|
|
// position = _viewer.scene.camera.pickEllipsoid(
|
|
|
|
|
|
|
|
// e.startPosition,
|
|
|
|
|
|
|
|
// _viewer.scene.globe.ellipsoid,
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
let position = cartesian2ToCartesian3(_viewer, e.endPosition)
|
|
|
|
let position = cartesian2ToCartesian3(_viewer, e.endPosition)
|
|
|
|
if (position) {
|
|
|
|
if (position) {
|
|
|
|
//将笛卡尔三维坐标转为地图坐标(弧度)
|
|
|
|
//将笛卡尔三维坐标转为地图坐标(弧度)
|
|
|
@ -35,13 +29,14 @@ onMounted(()=>{
|
|
|
|
let camera_alt = (_viewer.camera.positionCartographic.height / 1000) // 视高
|
|
|
|
let camera_alt = (_viewer.camera.positionCartographic.height / 1000) // 视高
|
|
|
|
// 相机低于250、俯仰角小于-80度时才计算海拔高度(否则误差大)
|
|
|
|
// 相机低于250、俯仰角小于-80度时才计算海拔高度(否则误差大)
|
|
|
|
let needElevation: boolean = camera_alt < 250 && (_viewer.camera.pitch < -(Math.PI/180)*80)
|
|
|
|
let needElevation: boolean = camera_alt < 250 && (_viewer.camera.pitch < -(Math.PI/180)*80)
|
|
|
|
let elevStr = needElevation? _viewer.scene.globe.getHeight(cartographic)?.toFixed(2)?? '' : '' // 海拔
|
|
|
|
let elevStr = needElevation? _viewer.scene.globe.getHeight(cartographic)?.toFixed(2)+'m'?? '' : '高度过高'
|
|
|
|
|
|
|
|
|
|
|
|
if(isDecimal.value) { //如果是十进制度
|
|
|
|
if(isDecimal.value) { //如果是十进制度
|
|
|
|
lonlatStr.value = `经度:${nowLonStr} , 纬度:${nowLatStr} , 海拔(m):${elevStr}`
|
|
|
|
lonlatStr.value = `经度: ${nowLonStr}°, 纬度: ${nowLatStr}°, 高度: ${elevStr}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
lonlatStr.value = `经度:${Angle.DecimalDegree2DMS(nowLonStr)} , 纬度:${Angle.DecimalDegree2DMS(nowLatStr)} , 海拔(m):${elevStr}`
|
|
|
|
lonlatStr.value = `经度: ${Angle.DecimalDegree2DMS(nowLonStr)}, 纬度: ${Angle.DecimalDegree2DMS(nowLatStr)},
|
|
|
|
|
|
|
|
高度: ${elevStr}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -49,12 +44,13 @@ onMounted(()=>{
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
function lonlatClick() {
|
|
|
|
function lonlatClick() {
|
|
|
|
let elevStr = lonlatStr.value.split('海拔')[1]
|
|
|
|
let elevStr = lonlatStr.value.split('高度')[1]
|
|
|
|
|
|
|
|
console.log(elevStr)
|
|
|
|
if(isDecimal.value){
|
|
|
|
if(isDecimal.value){
|
|
|
|
lonlatStr.value = `经度:${Angle.DecimalDegree2DMS(nowLonStr)} , 纬度:${Angle.DecimalDegree2DMS(nowLatStr)} , 海拔(m)` + elevStr
|
|
|
|
lonlatStr.value = `经度: ${Angle.DecimalDegree2DMS(nowLonStr)}, 纬度: ${Angle.DecimalDegree2DMS(nowLatStr)}, 高度` + elevStr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
lonlatStr.value = `经度:${nowLonStr} , 纬度:${nowLatStr} , 海拔(m)` + elevStr
|
|
|
|
lonlatStr.value = `经度: ${nowLonStr}°, 纬度: ${nowLatStr}°, 高度` + elevStr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isDecimal.value = !isDecimal.value
|
|
|
|
isDecimal.value = !isDecimal.value
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -74,7 +70,7 @@ function lonlatClick() {
|
|
|
|
bottom: 1px;
|
|
|
|
bottom: 1px;
|
|
|
|
left: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100vw;
|
|
|
|
width: 100vw;
|
|
|
|
height: 2.3rem;
|
|
|
|
height: 1.7rem;
|
|
|
|
background-color: rgba(47, 53, 60, 0.8);
|
|
|
|
background-color: rgba(47, 53, 60, 0.8);
|
|
|
|
color: #fff;
|
|
|
|
color: #fff;
|
|
|
|
font-size: 0.7rem;
|
|
|
|
font-size: 0.7rem;
|
|
|
@ -83,9 +79,9 @@ function lonlatClick() {
|
|
|
|
padding: 0;
|
|
|
|
padding: 0;
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#lonlatText{
|
|
|
|
#lonlatText{
|
|
|
|
margin-left: 2rem;
|
|
|
|
|
|
|
|
background: none;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
border: none;
|
|
|
|
color: #ffffff;
|
|
|
|
color: #ffffff;
|
|
|
|