|
@@ -283,228 +283,3 @@ export function init() {
|
|
|
$("#toolbar").show();
|
|
|
}
|
|
|
|
|
|
-// 观察点,目标点
|
|
|
-import { Cartesian2toDegrees } from "@/utils/MapHelper/help.js"
|
|
|
-export let sightline, handlerPoint, points
|
|
|
-export function initPoint() {
|
|
|
- sightline = new Cesium.Sightline(viewer.scene);
|
|
|
- sightline.build();
|
|
|
- handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);
|
|
|
- viewer.scene.undergroundMode = false;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * 输入点
|
|
|
- */
|
|
|
-export function setInput() {
|
|
|
- var that = this;
|
|
|
- console.log('ssss', sightline)
|
|
|
- // that.changCount = 0;
|
|
|
- handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);
|
|
|
- handlerPoint.activate();
|
|
|
- handlerPoint.drawEvt.addEventListener(function (result) {
|
|
|
- var point = result.object;
|
|
|
- // point.show = false;
|
|
|
- var position = result.object.position;
|
|
|
- debugger;
|
|
|
- //将获取的点的位置转化成经纬度
|
|
|
- var cartographic = Cartesian2toDegrees(position);
|
|
|
- // if (cartographic[2] < 0) cartographic[2] = 0;
|
|
|
- cartographic[2] += that.personH;
|
|
|
- //添加观察点
|
|
|
- if (that.addViewFlag) {
|
|
|
- //设置观察点
|
|
|
-
|
|
|
- sightline.viewPosition = cartographic;
|
|
|
- that.addViewFlag = false;
|
|
|
- viewer.entities.removeById("gcPoint");
|
|
|
- var labelentity = new Cesium.Entity({
|
|
|
- id: "gcPoint",
|
|
|
- position: Cesium.Cartesian3.fromDegrees(
|
|
|
- cartographic[0],
|
|
|
- cartographic[1],
|
|
|
- cartographic[2]
|
|
|
- ),
|
|
|
- point: {
|
|
|
- // 点的大小(像素)
|
|
|
- pixelSize: 10,
|
|
|
- // 点位颜色,fromCssColorString 可以直接使用CSS颜色
|
|
|
- color: Cesium.Color.RED,
|
|
|
- // 边框颜色
|
|
|
- outlineColor: Cesium.Color.fromCssColorString("#fff"),
|
|
|
- // 边框宽度(像素)
|
|
|
- outlineWidth: 2,
|
|
|
- // 显示在距相机的距离处的属性,多少区间内是可以显示的
|
|
|
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- 0,
|
|
|
- 1500
|
|
|
- ),
|
|
|
- // 是否显示
|
|
|
- show: true,
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- text: "观察点",
|
|
|
- font: "15px sans-serif",
|
|
|
- pixelOffset: new Cesium.Cartesian2(0, -20), //文字偏移
|
|
|
- fillColor: Cesium.Color.RED,
|
|
|
- // backgroundColor:new Cesium.Color(0, 0, 0, 1),
|
|
|
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- 0,
|
|
|
- 1500
|
|
|
- ), //达到一定高度隐藏
|
|
|
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
- },
|
|
|
- });
|
|
|
- // that.points.push(entity)
|
|
|
- // viewer.entities.add(entity);
|
|
|
- that.gcPoint = cartographic;
|
|
|
- points.push(labelentity);
|
|
|
- viewer.entities.add(labelentity);
|
|
|
- } else if (that.addTargetFlag) {
|
|
|
- //添加目标点
|
|
|
- //设置目标点
|
|
|
- sightline.addTargetPoint({
|
|
|
- position: cartographic,
|
|
|
- name: "目标点",
|
|
|
- });
|
|
|
- viewer.entities.removeById("targetPoint");
|
|
|
- var labelentity = new Cesium.Entity({
|
|
|
- id: "targetPoint",
|
|
|
- position: Cesium.Cartesian3.fromDegrees(
|
|
|
- cartographic[0],
|
|
|
- cartographic[1],
|
|
|
- cartographic[2]
|
|
|
- ),
|
|
|
- point: {
|
|
|
- // 点的大小(像素)
|
|
|
- pixelSize: 10,
|
|
|
- // 点位颜色,fromCssColorString 可以直接使用CSS颜色
|
|
|
- color: Cesium.Color.RED,
|
|
|
- // 边框颜色
|
|
|
- outlineColor: Cesium.Color.fromCssColorString("#fff"),
|
|
|
- // 边框宽度(像素)
|
|
|
- outlineWidth: 2,
|
|
|
- // 显示在距相机的距离处的属性,多少区间内是可以显示的
|
|
|
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- 0,
|
|
|
- 1500
|
|
|
- ),
|
|
|
- // 是否显示
|
|
|
- show: true,
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- text: "目标点",
|
|
|
- font: "15px sans-serif",
|
|
|
- pixelOffset: new Cesium.Cartesian2(0, -20), //文字偏移
|
|
|
- fillColor: Cesium.Color.RED,
|
|
|
- // backgroundColor:new Cesium.Color(0, 0, 0, 1),
|
|
|
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- 0,
|
|
|
- 1500
|
|
|
- ), //达到一定高度隐藏
|
|
|
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
- },
|
|
|
- });
|
|
|
- points.push(labelentity);
|
|
|
- viewer.entities.add(labelentity);
|
|
|
- that.addTargetFlag = false;
|
|
|
- that.targetPoint = cartographic;
|
|
|
- sightline.build();
|
|
|
- that.ComputationalPerspective();
|
|
|
- }
|
|
|
- handlerPoint.deactivate();
|
|
|
- handlerPoint.clear();
|
|
|
- });
|
|
|
-}
|
|
|
-/**
|
|
|
-* 计算方位角
|
|
|
-* @param {} points
|
|
|
-*/
|
|
|
-export function ComputationalPerspective() {
|
|
|
- // this.changCount++;
|
|
|
- var point1;
|
|
|
- var point2;
|
|
|
- debugger;
|
|
|
- if (
|
|
|
- sightline.viewPosition[0] == 0 ||
|
|
|
- sightline.viewPosition[1] == 0 ||
|
|
|
- sightline._currentTargetPoint[0] == 0 ||
|
|
|
- sightline._currentTargetPoint[1] == 0
|
|
|
- ) {
|
|
|
- this.$message.warning("请添加观察点或目标点");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.isFrom2To) {
|
|
|
- point1 = [
|
|
|
- sightline.viewPosition[0],
|
|
|
- sightline.viewPosition[1],
|
|
|
- sightline.viewPosition[2],
|
|
|
- ];
|
|
|
- point2 = [
|
|
|
- sightline._currentTargetPoint[0],
|
|
|
- sightline._currentTargetPoint[1],
|
|
|
- sightline._currentTargetPoint[2],
|
|
|
- ];
|
|
|
- } else {
|
|
|
- point1 = [
|
|
|
- sightline._currentTargetPoint[0],
|
|
|
- sightline._currentTargetPoint[1],
|
|
|
- sightline._currentTargetPoint[2],
|
|
|
- ];
|
|
|
- point2 = [
|
|
|
- sightline.viewPosition[0],
|
|
|
- sightline.viewPosition[1],
|
|
|
- sightline.viewPosition[2],
|
|
|
- ];
|
|
|
- }
|
|
|
- var positionA = Cesium.Cartesian3.fromDegrees(
|
|
|
- point1[0],
|
|
|
- point1[1],
|
|
|
- point1[2]
|
|
|
- );
|
|
|
- var positionB = Cesium.Cartesian3.fromDegrees(
|
|
|
- point2[0],
|
|
|
- point2[1],
|
|
|
- point2[2]
|
|
|
- );
|
|
|
- let finalPosition = new Cesium.Cartesian3();
|
|
|
- let matrix4 = Cesium.Transforms.eastNorthUpToFixedFrame(positionA);
|
|
|
- Cesium.Matrix4.inverse(matrix4, matrix4);
|
|
|
- Cesium.Matrix4.multiplyByPoint(matrix4, positionB, finalPosition);
|
|
|
- Cesium.Cartesian3.normalize(finalPosition, finalPosition);
|
|
|
- const resultHead = Cesium.Math.toDegrees(
|
|
|
- Math.atan2(finalPosition.x, finalPosition.y)
|
|
|
- );
|
|
|
- const resultPitch = Cesium.Math.toDegrees(Math.asin(finalPosition.z));
|
|
|
- viewer.camera.setView({
|
|
|
- destination: positionA,
|
|
|
- orientation: {
|
|
|
- heading: Cesium.Math.toRadians(resultHead), // east, default value is 0.0 (north)
|
|
|
- pitch: Cesium.Math.toRadians(resultPitch), // default value (looking down)
|
|
|
- roll: 0.0, // default value
|
|
|
- },
|
|
|
- });
|
|
|
-}
|
|
|
-/**
|
|
|
- * 停止飞行、漫游、清除图元
|
|
|
- */
|
|
|
-export function clearScope() {
|
|
|
- viewer.entities.removeAll();
|
|
|
- points = [];
|
|
|
- sightline.removeAllTargetPoint();
|
|
|
- if (handlerPoint) {
|
|
|
- handlerPoint.clear();
|
|
|
- handlerPoint.deactivate();
|
|
|
- }
|
|
|
- // this.tooltip.setVisible(false);
|
|
|
-
|
|
|
- viewer.scene.camera.stopFlyCircle();
|
|
|
-
|
|
|
- // this.changCount = 0;
|
|
|
- viewer.scene.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
|
|
|
-}
|
|
|
-
|
|
|
-
|