Commit 1034f898 by lyc

init

parent cd3d65b9
......@@ -7,8 +7,10 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import * as Cesium from 'cesium'
import Viewer from 'cesium/Source/Widgets/Viewer/Viewer';
import { ref } from 'vue'
import { configProviderContextKey } from 'element-plus';
......@@ -18,30 +20,94 @@ onMounted(() => {
selectionIndicator: false,
infoBox: false,
});
// const position = Cesium.Cartographic.fromCartesian(120, 20,2000)
// const triangle =[]
// triangle.push(position)
// const sector = viewer.entities.add({
// position:position,
// polygon: {
// hierarchy: new Cesium.PolygonHierarchy(arrow),
// show: true,
// fill: true,
// clampToGround: true,
// material: Cesium.Color.AQUA.withAlpha(0.9)
// }
// });
const polyline = viewer.entities.add({
id: 'polyline',
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray([120, 20, 121, 20, 121, 20.5, 122, 22, 120, 20]),
width:10,
material:Cesium.Color.YELLOW
function draw_sector(point, angleone, angletwo, r) {
console.log(angleone, angletwo)
const sector = viewer.entities.add({
name: "Wedge",
position: point,
ellipsoid: {
radii: new Cesium.Cartesian3(r, r, 1.0),
minimumClock: Cesium.Math.toRadians(angleone),
maximumClock: Cesium.Math.toRadians(angletwo),
material: Cesium.Color.DARKCYAN.withAlpha(0.3),
outline: false,
},
});
return sector
}
let count = 0
let onepoint
let twopoint
let threepoint
const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
handler.setInputAction(function (event) {
const ray = viewer.camera.getPickRay(event.position);
const earthPosition = viewer.scene.globe.pick(ray, viewer.scene);
let angleone
let angletwo
let r
if (Cesium.defined(earthPosition)) {
if (count == 0) {
onepoint = earthPosition;
count = count + 1
}
else if (count == 1) {
twopoint = earthPosition;
count = count + 1
}
else if (count == 2) {
threepoint = earthPosition;
count = count + 1
}
if (count == 3) {
angleone = computerJiao(onepoint, twopoint)
angletwo = computerJiao(onepoint, threepoint)
r = computerR(onepoint, twopoint)
draw_sector(onepoint, angleone, angletwo, r)
console.log(r)
count = 0
}
console.log(count)
}
})
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
function computerJiao(point_one, point_two) {
let one = Cesium.Cartographic.fromCartesian(point_one)
let two = Cesium.Cartographic.fromCartesian(point_two)
let onelon = Cesium.Math.toDegrees(one.longitude)
let onelat = Cesium.Math.toDegrees(one.latitude)
let twolon = Cesium.Math.toDegrees(two.longitude)
let twolat = Cesium.Math.toDegrees(two.latitude)
let jiaorad = Math.atan(((twolon) - (onelon)) / ((twolat) - (onelat)))
let jiao = jiaorad * (180 / Math.PI)
return jiao
}
function computerR(point_one, point_two) {
let one = Cesium.Cartographic.fromCartesian(point_one)
let two = Cesium.Cartographic.fromCartesian(point_two)
let onelon = Cesium.Math.toDegrees(one.longitude)
let onelat = Cesium.Math.toDegrees(one.latitude)
let twolon = Cesium.Math.toDegrees(two.longitude)
let twolat = Cesium.Math.toDegrees(two.latitude)
let chang = Math.abs(onelon - twolon)
let kuang = Math.abs(onelat - twolat)
let r = Math.sqrt(chang * chang + kuang * kuang)
return r * 89990
}
// viewer.zoomTo(polygon)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment