|
@@ -1,40 +1,64 @@
|
|
|
<template>
|
|
|
- <div
|
|
|
- class="ZTGlobal"
|
|
|
- style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white"
|
|
|
- >
|
|
|
- <el-row :gutter="10">
|
|
|
- 观察者高度(米):
|
|
|
- <el-input-number
|
|
|
- size="small"
|
|
|
- label="观察者高度:"
|
|
|
- min="0"
|
|
|
- max="50"
|
|
|
- :step="0.5"
|
|
|
- precision="1"
|
|
|
- v-model="personH"
|
|
|
- ></el-input-number>
|
|
|
+ <div class="ZTGlobal" style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white">
|
|
|
+
|
|
|
+ <el-row style="border: 1px solid #06c4f3;padding: 0.5rem;color: #ffffff;">
|
|
|
+ 定点分析:
|
|
|
+ <el-row :gutter="10">
|
|
|
+ 观察者高度(米):
|
|
|
+ <el-input-number size="small" label="观察者高度:" min="0" max="50" :step="0.5" precision="1"
|
|
|
+ v-model="personH"></el-input-number>
|
|
|
+
|
|
|
+ <el-col :span="8"><el-button size="mini" type="default" @click="addGCD">添加观察点</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8"><el-button size="mini" type="default" @click="addTagget">添加目标点</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="7">
|
|
|
+ <el-button size="mini" type="default" @click="changeView">切换视角</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+ <el-row style="border: 1px solid #06c4f3; padding: 0.5rem;color: #ffffff;">
|
|
|
+ 环视分析:
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8"><el-button size="mini" type="default" @click="addCirclePoint">添加环视点</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="10">
|
|
|
+ 环视角度(度): </el-col>
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-input-number size="mini" v-model="circlePitch" min="0" max="90"
|
|
|
+ @change="circlePitchChange"></el-input-number></el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="10">
|
|
|
+ 环视高度(米):</el-col>
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-input-number size="mini" v-model="circleH" min="0" max="5000" @change="circleHChange"></el-input-number>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="8"><el-button ref="flyCrile" size="mini" type="default" @click="targetRing()">{{ flyCircleText
|
|
|
+ }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+ <el-row style="border: 1px solid #06c4f3; padding: 0.5rem;color: #ffffff;">
|
|
|
+ 沿线飞行:默认50km/h
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8"><el-button size="mini" type="default" @click="addPolyline">绘制线</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8"><el-button size="mini" type="default" @click="startPolylineFly">飞行</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8"><el-button size="mini" type="default" @click="stopPolylineFly">停止飞行</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ 飞行高度:
|
|
|
+ <el-input-number size="small" label="飞行高度:" min="0" max="2000" v-model="flyH"></el-input-number>
|
|
|
</el-row>
|
|
|
<el-row :gutter="10">
|
|
|
- <el-col :span="6"
|
|
|
- ><el-button size="mini" type="default" @click="addGCD"
|
|
|
- >添加观察点</el-button
|
|
|
- >
|
|
|
- </el-col>
|
|
|
- <el-col :span="6"
|
|
|
- ><el-button size="mini" type="default" @click="addTagget"
|
|
|
- >添加目标点</el-button
|
|
|
- >
|
|
|
- </el-col>
|
|
|
- <el-col :span="5.5">
|
|
|
- <el-button size="mini" type="default" @click="changeView"
|
|
|
- >切换视角</el-button
|
|
|
- >
|
|
|
- </el-col>
|
|
|
- <el-col :span="4">
|
|
|
- <el-button size="mini" type="default" @click="clearScope"
|
|
|
- >清除</el-button
|
|
|
- >
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-button size="mini" type="default" @click="clearScope">清除</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
@@ -50,6 +74,7 @@ import {
|
|
|
// import { point, distance } from "@turf/turf";
|
|
|
let handlerPoint = null; //绘制线
|
|
|
var sightline;
|
|
|
+var flyManager;
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -57,8 +82,19 @@ export default {
|
|
|
points: [],
|
|
|
addViewFlag: false, //当前点击状态是否是 添加观察点
|
|
|
addTargetFlag: false, //当前点击状态是否是 添加目标点,
|
|
|
+
|
|
|
personH: 1.8,
|
|
|
isFrom2To: true,
|
|
|
+ gcPoint: null,
|
|
|
+ targetPoint: null,
|
|
|
+ circlPoint: null,
|
|
|
+ addCircleFlag: false, //环视点标志
|
|
|
+ flyCircleLoop: false,
|
|
|
+ flyCircleText: "环视漫游",
|
|
|
+ circlePitch: 75,
|
|
|
+ circleH: 500,
|
|
|
+ flyH: 20,
|
|
|
+ lineFylPoints: []
|
|
|
};
|
|
|
},
|
|
|
props: {
|
|
@@ -88,7 +124,7 @@ export default {
|
|
|
computed: {},
|
|
|
mounted() {
|
|
|
sightline = new Cesium.Sightline(scene);
|
|
|
- sightline.lin;
|
|
|
+ sightline.build();
|
|
|
handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);
|
|
|
scene.undergroundMode = false;
|
|
|
},
|
|
@@ -101,6 +137,9 @@ export default {
|
|
|
sightline.removeAllTargetPoint();
|
|
|
that.addViewFlag = true;
|
|
|
that.addTargetFlag = false;
|
|
|
+
|
|
|
+ that.addCircleFlag = false
|
|
|
+
|
|
|
that.isFrom2To = true;
|
|
|
if (handlerPoint) handlerPoint.clear();
|
|
|
that.setInput();
|
|
@@ -125,6 +164,16 @@ export default {
|
|
|
that.addViewFlag = false;
|
|
|
that.addTargetFlag = true;
|
|
|
|
|
|
+ that.addCircleFlag = false
|
|
|
+
|
|
|
+ that.setInput();
|
|
|
+ },
|
|
|
+ addCirclePoint() {
|
|
|
+ let that = this;
|
|
|
+ that.addViewFlag = false;
|
|
|
+ that.addTargetFlag = false;
|
|
|
+ that.addCircleFlag = true
|
|
|
+
|
|
|
that.setInput();
|
|
|
},
|
|
|
setInput() {
|
|
@@ -147,8 +196,9 @@ export default {
|
|
|
cartographic[2] += that.personH;
|
|
|
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],
|
|
@@ -186,6 +236,7 @@ export default {
|
|
|
});
|
|
|
// that.points.push(entity)
|
|
|
// viewer.entities.add(entity);
|
|
|
+ that.gcPoint = cartographic;
|
|
|
that.points.push(labelentity);
|
|
|
viewer.entities.add(labelentity);
|
|
|
} else if (that.addTargetFlag) {
|
|
@@ -195,8 +246,9 @@ export default {
|
|
|
position: cartographic,
|
|
|
name: "目标点",
|
|
|
});
|
|
|
-
|
|
|
+ viewer.entities.removeById('targetPoint');
|
|
|
var labelentity = new Cesium.Entity({
|
|
|
+ id: 'targetPoint',
|
|
|
position: position,
|
|
|
point: {
|
|
|
// 点的大小(像素)
|
|
@@ -231,9 +283,51 @@ export default {
|
|
|
that.points.push(labelentity);
|
|
|
viewer.entities.add(labelentity);
|
|
|
that.addTargetFlag = false;
|
|
|
+
|
|
|
+ that.targetPoint = cartographic;
|
|
|
sightline.build();
|
|
|
that.ComputationalPerspective();
|
|
|
}
|
|
|
+ else if (that.addCircleFlag) {
|
|
|
+ viewer.entities.removeById('circlePoint');
|
|
|
+ var labelentity = new Cesium.Entity({
|
|
|
+ id: 'circlePoint',
|
|
|
+ position: position,
|
|
|
+ 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(60, -20), //文字偏移
|
|
|
+ fillColor: Cesium.Color.WHITE,
|
|
|
+ // backgroundColor:new Cesium.Color(0, 0, 0, 1),
|
|
|
+ distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
+ 0,
|
|
|
+ 1500
|
|
|
+ ), //达到一定高度隐藏
|
|
|
+ },
|
|
|
+ });
|
|
|
+ that.points.push(labelentity);
|
|
|
+ viewer.entities.add(labelentity);
|
|
|
+ that.addCircleFlag = false;
|
|
|
+ that.circlPoint = cartographic;
|
|
|
+ }
|
|
|
handlerPoint.deactivate();
|
|
|
handlerPoint.clear();
|
|
|
});
|
|
@@ -245,6 +339,9 @@ export default {
|
|
|
ComputationalPerspective() {
|
|
|
var point1;
|
|
|
var point2;
|
|
|
+ debugger
|
|
|
+ if (sightline.viewPosition[0] == 0 || sightline.viewPosition[1] == 0 || sightline._currentTargetPoint[0] == 0 || sightline._currentTargetPoint[1] == 0)
|
|
|
+ return;
|
|
|
if (this.isFrom2To) {
|
|
|
point1 = [
|
|
|
sightline.viewPosition[0],
|
|
@@ -315,13 +412,174 @@ export default {
|
|
|
handlerPoint.deactivate();
|
|
|
}
|
|
|
this.tooltip.setVisible(false);
|
|
|
+ if (flyManager)
|
|
|
+ flyManager.stop();
|
|
|
+ flyManager = null;
|
|
|
+ this.lineFylPoints = [];
|
|
|
+ scene.camera.stopFlyCircle();
|
|
|
+ this.flyCircleText = '环视漫游'
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 目标点环视
|
|
|
+ */
|
|
|
+ targetRing() {
|
|
|
+
|
|
|
+ var that = this
|
|
|
+ that.flyCircleLoop = !that.flyCircleLoop;
|
|
|
+
|
|
|
+ if (that.circlPoint) {
|
|
|
+ var position = Cesium.Cartesian3.fromDegrees(that.circlPoint[0], that.circlPoint[1], that.circlPoint[2] + 1000)
|
|
|
+ // scene.camera.zoomIn(500)
|
|
|
+ scene.camera.setView({
|
|
|
+ destination: position,
|
|
|
+ orientation: {
|
|
|
+ heading: Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north)
|
|
|
+ pitch: Cesium.Math.toRadians(-75), // default value (looking down)
|
|
|
+ roll: 0.0 // default value
|
|
|
+ }
|
|
|
+ })
|
|
|
+ scene.camera.flyCircle(position)
|
|
|
+ scene.camera.speedRatio = 0.2
|
|
|
+ }
|
|
|
+ // scene.camera.flyCircleLoop = that.flyCircleLoop;
|
|
|
+ if (that.flyCircleLoop == true) {
|
|
|
+ that.flyCircleText = '停止环视'
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ that.flyCircleText = '环视漫游'
|
|
|
+ scene.camera.stopFlyCircle()
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ circleHChange() {
|
|
|
+ scene.camera.setView({
|
|
|
+ destination: Cesium.Cartesian3.fromDegrees(this.circlPoint[0], this.circlPoint[1], this.circlPoint[2] + Number(this.circleH)),
|
|
|
+ orientation: {
|
|
|
+ heading: Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north)
|
|
|
+ pitch: Cesium.Math.toRadians(this.circlePitch * -1), // default value (looking down)
|
|
|
+ roll: 0.0 // default value
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ circlePitchChange() {
|
|
|
+
|
|
|
+ scene.camera.setView({
|
|
|
+ destination: Cesium.Cartesian3.fromDegrees(this.circlPoint[0], this.circlPoint[1], this.circlPoint[2] + Number(this.circleH)),
|
|
|
+ orientation: {
|
|
|
+ heading: Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north)
|
|
|
+ pitch: Cesium.Math.toRadians(this.circlePitch * -1), // default value (looking down)
|
|
|
+ roll: 0.0 // default value
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addPolyline() {
|
|
|
+ var that = this;
|
|
|
+ that.lineFylPoints = []
|
|
|
+ if (handlerPoint)
|
|
|
+ handlerPoint.clear()
|
|
|
+ handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Line);
|
|
|
+ handlerPoint.activate();
|
|
|
+ handlerPoint.drawEvt.addEventListener(function (result) {
|
|
|
+ debugger
|
|
|
+ var positions = result.object.positions;
|
|
|
+ for (var i = 0; i < positions.length; i++) {
|
|
|
+ var cartographic = that.Cartesian2toDegrees(positions[i]);
|
|
|
+ that.lineFylPoints.push(cartographic);
|
|
|
+ }
|
|
|
+ //将获取的点的位置转化成经纬度
|
|
|
+
|
|
|
+ handlerPoint.deactivate();
|
|
|
+ })
|
|
|
},
|
|
|
+ startPolylineFly() {
|
|
|
+ var that = this;
|
|
|
+ if (that.lineFylPoints == null || that.length == 0) {
|
|
|
+ that.$message.warning('请绘制飞行路线!');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ debugger
|
|
|
+
|
|
|
+ var xml = '<?xml version="1.0" encoding="UTF-8"?>' +
|
|
|
+ '<SceneRoute xmlns = "https://www.supermap.com/ugc60" >' +
|
|
|
+ '<route name="飞行路线_1" speed="13.888888888889" lineType="0" showroutestop="False" showrouteline="False" altitudefree="False" headingfree="False" tiltfree="False" flycircle="False" alongline="True">' +
|
|
|
+ '<style>' +
|
|
|
+ '<geostyle3d>' +
|
|
|
+ '<linecolor>RGBA(147,112,219,255)</linecolor>' +
|
|
|
+ '<linewidth>2</linewidth>' +
|
|
|
+ '<altitudeMode>Absolute</altitudeMode>' +
|
|
|
+ '<bottomAltitude>0.00</bottomAltitude>' +
|
|
|
+ '</geostyle3d>' +
|
|
|
+ '</style>'
|
|
|
+ that.lineFylPoints.forEach((point, index) => {
|
|
|
+ xml += '<routestop name="Stop+' + (index + 1) + '" speed="0" excluded="False" viewType="camera">' +
|
|
|
+ '<camera>' +
|
|
|
+ '<longitude>' + point[0] + '</longitude>' +
|
|
|
+ '<latitude>' + point[1] + '</latitude>' +
|
|
|
+ '<altitude>' + (point[2] + that.flyH) + '</altitude>' +
|
|
|
+ '<heading>0</heading>' +
|
|
|
+ '<tilt>78.531727283418646834</tilt>' +
|
|
|
+ '<altitudeMode>Absolute</altitudeMode>' +
|
|
|
+ '</camera>' +
|
|
|
+ '<style>' +
|
|
|
+ '<geostyle3d>' +
|
|
|
+ '<icon />' +
|
|
|
+ '<markersize>4.8</markersize>' +
|
|
|
+ '<markericonscale>1</markericonscale>' +
|
|
|
+ '<markercolor>RGBA(255,255,255,255)</markercolor>' +
|
|
|
+ '</geostyle3d>' +
|
|
|
+ '</style>' +
|
|
|
+ '<setting>' +
|
|
|
+ '<turnTime>1.5</turnTime>' +
|
|
|
+ '<turnSlowly>False</turnSlowly>' +
|
|
|
+ '<stopPlayMode>StopPause</stopPlayMode>' +
|
|
|
+ '<autoPlay>False</autoPlay>' +
|
|
|
+ '<pauseTime>0</pauseTime>' +
|
|
|
+ '<angularSpeed>1</angularSpeed>' +
|
|
|
+ ' </setting>' +
|
|
|
+ '</routestop>';
|
|
|
+ })
|
|
|
+ xml += '</route>'
|
|
|
+ xml += '</SceneRoute >'
|
|
|
+
|
|
|
+ var routes = new Cesium.RouteCollection(viewer.entities);
|
|
|
+ routes.fromXML(xml);
|
|
|
+ //初始化飞行管理
|
|
|
+ flyManager = new Cesium.FlyManager({
|
|
|
+ scene: scene,
|
|
|
+ routes: routes
|
|
|
+ });
|
|
|
+ //注册站点到达事件
|
|
|
+ flyManager.stopArrived.addEventListener(function (routeStop) {
|
|
|
+ routeStop.waitTime = 1; // 在每个站点处停留1s
|
|
|
+ });
|
|
|
+ flyManager.readyPromise.then(function () { // 飞行路线就绪
|
|
|
+ var currentRoute = flyManager.currentRoute;
|
|
|
+ currentRoute.isLineVisible = false;
|
|
|
+ currentRoute.isStopVisible = false;
|
|
|
+ //生成飞行文件中的所有站点列表
|
|
|
+ // var allStops = flyManager.getAllRouteStops();
|
|
|
+ flyManager && flyManager.play();
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ stopPolylineFly() {
|
|
|
+ var allStops = flyManager.getAllRouteStops();
|
|
|
+ flyManager.viewToStop(allStops[allStops.length - 1])
|
|
|
+ flyManager && flyManager.stop();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
beforeDestroy() {
|
|
|
this.clearScope();
|
|
|
},
|
|
|
-};
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="scss">
|
|
|
@import "@/../../zt.scss";
|