Commit 1034f898 by lyc

init

parent cd3d65b9
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted } from 'vue' import { onMounted } from 'vue'
import * as Cesium from 'cesium' import * as Cesium from 'cesium'
import Viewer from 'cesium/Source/Widgets/Viewer/Viewer';
import { ref } from 'vue' import { ref } from 'vue'
import { configProviderContextKey } from 'element-plus';
...@@ -18,30 +20,94 @@ onMounted(() => { ...@@ -18,30 +20,94 @@ onMounted(() => {
selectionIndicator: false, selectionIndicator: false,
infoBox: false, infoBox: false,
}); });
// const position = Cesium.Cartographic.fromCartesian(120, 20,2000) function draw_sector(point, angleone, angletwo, r) {
// const triangle =[] console.log(angleone, angletwo)
// triangle.push(position) const sector = viewer.entities.add({
// const sector = viewer.entities.add({ name: "Wedge",
// position:position, position: point,
// polygon: { ellipsoid: {
// hierarchy: new Cesium.PolygonHierarchy(arrow), radii: new Cesium.Cartesian3(r, r, 1.0),
// show: true, minimumClock: Cesium.Math.toRadians(angleone),
// fill: true, maximumClock: Cesium.Math.toRadians(angletwo),
// clampToGround: true, material: Cesium.Color.DARKCYAN.withAlpha(0.3),
// material: Cesium.Color.AQUA.withAlpha(0.9) outline: false,
// } },
// }); });
const polyline = viewer.entities.add({ return sector
id: 'polyline',
polyline: { }
positions: Cesium.Cartesian3.fromDegreesArray([120, 20, 121, 20, 121, 20.5, 122, 22, 120, 20]), let count = 0
width:10, let onepoint
material:Cesium.Color.YELLOW 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