analysis-space.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <script setup>
  2. /**
  3. * element-plus组件
  4. */
  5. import {
  6. ElMessage
  7. } from 'element-plus';
  8. import {
  9. inject
  10. } from "vue";
  11. const getMapInstance = inject("getMapInstance");
  12. jt3d = getMapInstance();
  13. </script>
  14. <template>
  15. <div class="jt-analysisSpace">
  16. <el-collapse v-model="activeName" accordion>
  17. <el-collapse-item name="光照分析">
  18. <template #title>
  19. <i class='iconfont icon-svgguangzhaofenxi' />光照分析
  20. </template>
  21. <div class="el-collapse-item__content">
  22. <el-button color="rgb(20 136 255)" @click="SunShine('start')">开启光照分析</el-button>
  23. <el-button color="rgb(255 100 100)" @click="SunShine('remove')"><span style="color: #fff;">移除光照分析</span></el-button>
  24. </div>
  25. </el-collapse-item>
  26. <el-collapse-item name="方量分析">
  27. <template #title>
  28. <i class='iconfont icon-svgfangliangfenxi' />方量分析
  29. </template>
  30. <div class="el-collapse-item__content">
  31. <el-form label-width="100rem">
  32. <el-form-item label="挖方填方高度:">
  33. <el-input v-model="cutFill.height" />
  34. </el-form-item>
  35. <el-form-item label="挖方填方精度:">
  36. <el-input v-model="cutFill.precision" />
  37. </el-form-item>
  38. </el-form>
  39. <div class="jt-btn" style="margin: 10rem;">
  40. <el-button color="rgb(255 100 100)" @click="CutFill('draw')"><span style="color: #fff;">绘制挖方填方区域</span></el-button>
  41. <el-button color="rgb(255 100 100)" @click="CutFill('remove')"><span style="color: #fff;">清除分析结果</span></el-button>
  42. </div>
  43. <el-form label-width="120rem">
  44. <el-form-item label="总分析面积(㎡):">
  45. <el-input v-model="cutFill.result.allArea" />
  46. </el-form-item>
  47. <el-form-item label="填方面积(㎡):">
  48. <el-input v-model="cutFill.result.fillArea" />
  49. </el-form-item>
  50. <el-form-item label="填方体积(m³):">
  51. <el-input v-model="cutFill.result.fillVolume" />
  52. </el-form-item>
  53. <el-form-item label="挖方面积(㎡):">
  54. <el-input v-model="cutFill.result.cutArea" />
  55. </el-form-item>
  56. <el-form-item label="挖方体积(m³):">
  57. <el-input v-model="cutFill.result.cutVolume" />
  58. </el-form-item>
  59. </el-form>
  60. </div>
  61. </el-collapse-item>
  62. <el-collapse-item name="剖面分析">
  63. <template #title>
  64. <i class='iconfont icon-svgpoumianfenxi' />剖面分析
  65. </template>
  66. <div class="el-collapse-item__content">
  67. <div style="line-height: 2em; table-layout: fixed; word-wrap: break-word; word-break: normal; text-align:justify; text-justify: inter-ideograph;color: #ffffff99;">
  68. 提示:单击【剖面分析】按钮触发,然后在实景三维或地形上左键单击开始,左键双击结束
  69. </div>
  70. <el-button color="rgb(20 136 255)" @click="SectionAnalysis">剖面分析</el-button>
  71. </div>
  72. </el-collapse-item>
  73. <el-collapse-item name="通视分析">
  74. <template #title>
  75. <i class='iconfont icon-svgtongshifenxi' />通视分析
  76. </template>
  77. <div class="el-collapse-item__content">
  78. <div style="line-height: 2em; table-layout: fixed; word-wrap: break-word; word-break: normal; text-align:justify; text-justify: inter-ideograph;color: #ffffff99;">
  79. 提示:红色代表不可视,绿色代表可视;
  80. </div>
  81. <el-button color="rgb(20 136 255)" @click="SightLine('activate')">添加通视分析</el-button>
  82. <el-button color="rgb(255 100 100)" @click="SightLine('deactivate')"><span style="color: #fff;">清除通视分析</span></el-button>
  83. </div>
  84. </el-collapse-item>
  85. <el-collapse-item name="视域分析">
  86. <template #title>
  87. <i class='iconfont icon-svgshiyufenxi' />视域分析
  88. </template>
  89. <div class="el-collapse-item__content">
  90. <div style="line-height: 2em; table-layout: fixed; word-wrap: break-word; word-break: normal; text-align:justify; text-justify: inter-ideograph;color: #ffffff99;">
  91. 提示:点击“添加视域”按钮后在场景中点击两个点添加视域,红色代表不可视,绿色代表可视;
  92. </div>
  93. <el-button color="rgb(20 136 255)" @click="ViewShed('activate')">添加视域</el-button>
  94. <el-button color="rgb(255 100 100)" @click="ViewShed('deactivate')"><span style="color: #fff;">清除视域</span></el-button>
  95. </div>
  96. </el-collapse-item>
  97. <el-collapse-item name="限高分析">
  98. <template #title>
  99. <i class='iconfont icon-svgxiangaofenxi' />限高分析
  100. </template>
  101. <div class="el-collapse-item__content">
  102. <el-form ref="form" label-width="100rem" label-position="right" size="mini">
  103. <el-form-item label="地表海拔:">
  104. <span>{{heightLimit.baseHeight}}</span>米&nbsp;&nbsp;<el-button color="rgb(20 136 255)" @click="HeightLimit('pickUp')">图上选点</el-button>
  105. </el-form-item>
  106. <el-form-item label="限制高度:">
  107. <el-slider v-model="heightLimit.height" :min="0" :max="300" :step="1" @input="changeHeight"></el-slider>
  108. </el-form-item>
  109. <el-form-item label="当前高度:">
  110. {{heightLimit.height}}米
  111. </el-form-item>
  112. </el-form>
  113. <div class="jt-btn" style="margin-bottom: 10rem;">
  114. <el-button color="rgb(20 136 255)" @click="HeightLimit('activate')">绘制限高区域</el-button>
  115. <el-button color="rgb(255 100 100)" @click="HeightLimit('deactivate')"><span style="color: #fff;">清除限高分析</span></el-button>
  116. </div>
  117. </div>
  118. </el-collapse-item>
  119. <!-- <el-collapse-item name="剖切展示">
  120. <template #title>
  121. <i class='iconfont icon-svgpouqiezhanshi' />剖切展示
  122. </template>
  123. <div class="el-collapse-item__content">
  124. <div style="line-height: 2em; table-layout: fixed; word-wrap: break-word; word-break: normal; text-align:justify; text-justify: inter-ideograph;color: #ffffff60;">
  125. 目前仅支持凸多边形,如果绘制的是凹多边形,可能裁剪结果不正确
  126. </div>
  127. <el-button color="rgb(20 136 255)" @click="Cutting('activate')">添加剖切多边形</el-button>
  128. </div>
  129. </el-collapse-item> -->
  130. <!-- <el-collapse-item name="视频融合">
  131. <template #title>
  132. <i class='iconfont icon-svgshipinronghe' />视频融合
  133. </template>
  134. <div class="el-collapse-item__content">
  135. <div style="line-height: 2em; table-layout: fixed; word-wrap: break-word; word-break: normal; text-align:justify; text-justify: inter-ideograph;color: #ffffff60;">
  136. 请先打开【牟平中心城实景三维】
  137. </div>
  138. <el-button color="rgb(20 136 255)" @click="PolygonHierarchy">视频融合</el-button>
  139. </div>
  140. </el-collapse-item> -->
  141. </el-collapse>
  142. </div>
  143. </template>
  144. <script>
  145. let jt3d = undefined;
  146. export default {
  147. props: {},
  148. watch: {},
  149. /* 数据 */
  150. data() {
  151. return {
  152. activeName: "光照分析",
  153. // 限高分析
  154. heightLimit: {
  155. height: 20,
  156. baseHeight: 0,
  157. },
  158. //方量分析
  159. cutFill: {
  160. height: 10, //挖方填方高度
  161. precision: 1256, //挖方填方精度
  162. result: { //挖方填方结果
  163. allArea: "",
  164. cutArea: "",
  165. cutVolume: "",
  166. fillArea: "",
  167. fillVolume: "",
  168. },
  169. },
  170. }
  171. },
  172. /* 方法 */
  173. methods: {
  174. /**
  175. * 光照分析
  176. */
  177. SunShine(type) {
  178. let _self = this;
  179. switch (type) {
  180. case "start":
  181. jt3d.statusBar.show = false;
  182. jt3d.SpatialAnalysis.SunshineShadow.start();
  183. break;
  184. case "remove":
  185. jt3d.statusBar.show = true;
  186. jt3d.SpatialAnalysis.SunshineShadow.remove();
  187. break;
  188. }
  189. },
  190. /**
  191. * 方量分析
  192. */
  193. CutFill(type) {
  194. let _self = this;
  195. //功能初始化
  196. _self.init();
  197. switch (type) {
  198. case "draw":
  199. jt3d.DrawTools.draw('polygon', {
  200. isEdit: false,
  201. onComplete(cartesian3d, points) {
  202. //清除绘制
  203. jt3d.DrawTools.Clear();
  204. let pointsArray = [];
  205. points.forEach((coordinate, index) => {
  206. pointsArray.push([
  207. coordinate.lng,
  208. coordinate.lat,
  209. coordinate.height
  210. ]);
  211. });
  212. jt3d.SpatialAnalysis.CutFill.createPolygonGeo(pointsArray, {
  213. height: _self.height,
  214. precision: _self.precision,
  215. }).then(res => {
  216. _self.cutFill.result = res;
  217. });
  218. }
  219. });
  220. break;
  221. case "remove":
  222. jt3d.SpatialAnalysis.CutFill.remove();
  223. this.cutFill.result = {
  224. allArea: "",
  225. cutArea: "",
  226. cutVolume: "",
  227. fillArea: "",
  228. fillVolume: "",
  229. }
  230. //还原左键单击事件
  231. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  232. break;
  233. }
  234. },
  235. /**
  236. * 视频融合
  237. */
  238. PolygonHierarchy() {
  239. let videoElement = document.getElementById('trailer');
  240. var videopolygon = jt3d._viewer.entities.add({
  241. polygon: {
  242. height: 0.1,
  243. hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights([121.600444, 37.398272, 37.95, 121.600443, 37.398272, 33, 121.600443, 37.398341, 33, 121.600444, 37.398341, 37.95])),
  244. material: videoElement,
  245. perPositionHeight: true,
  246. }
  247. });
  248. let flyToEntity = jt3d.LocateUtil.flyToEntity(videopolygon, {
  249. heading: 90, //方向
  250. pitch: -32, //倾斜角度
  251. range: 72
  252. });
  253. flyToEntity.then(function(vehicleEntity) {
  254. jt3d._viewer.trackedEntity = vehicleEntity; //获取或设置摄像机当前正在跟踪的Entity实例。
  255. vehicleEntity.viewFrom = new Cesium.Cartesian3(0, 1, 0.3);
  256. });
  257. },
  258. /**
  259. * 剖切分析
  260. */
  261. Cutting(type) {
  262. let _self = this;
  263. //功能初始化
  264. _self.init();
  265. switch (type) {
  266. case "activate":
  267. if (window["my3dtiles"]) {
  268. jt3d.DrawTools.draw('polygon', {
  269. isEdit: false,
  270. onComplete(cartesian3d, points) {
  271. //清除绘制
  272. jt3d.DrawTools.Clear();
  273. let pointsArray = [];
  274. points.forEach((coordinate, index) => {
  275. pointsArray.push([
  276. coordinate.lng,
  277. coordinate.lat,
  278. coordinate.height
  279. ]);
  280. });
  281. jt3d.SpatialAnalysis.Cutting.addTiles(window["my3dtiles"], pointsArray);
  282. }
  283. });
  284. } else {
  285. ElMessage.error("请先勾选3D模型");
  286. }
  287. break;
  288. case "deactivate":
  289. //还原左键单击事件
  290. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  291. break;
  292. }
  293. },
  294. /**
  295. * 限高分析
  296. */
  297. HeightLimit(type) {
  298. let _self = this;
  299. //功能初始化
  300. _self.init();
  301. switch (type) {
  302. case "pickUp": //图上选点,获取地表高度
  303. jt3d.CommonTools._sketchViewModel.sketchTools('point', {
  304. onComplete(cPoint, gPoint) {
  305. _self.heightLimit.baseHeight = Number(gPoint.height.toFixed(2));
  306. },
  307. onError(message) {
  308. }
  309. });
  310. break;
  311. case "activate":
  312. jt3d.DrawTools.draw('polygon', {
  313. isEdit: false,
  314. onComplete(cartesian3d, points) {
  315. //清除绘制
  316. // jt3d.DrawTools._entities.remove(jt3d.DrawTools._drawEntity.polygon);
  317. jt3d.DrawTools.Clear();
  318. let pointsArray = [];
  319. points.forEach((coordinate, index) => {
  320. pointsArray.push([
  321. coordinate.lng,
  322. coordinate.lat,
  323. coordinate.height
  324. ]);
  325. });
  326. jt3d.SpatialAnalysis.HeightLimit.addPrimitive(pointsArray, {
  327. height: _self.heightLimit.height,
  328. baseHeight: _self.heightLimit.baseHeight,
  329. });
  330. }
  331. });
  332. break;
  333. case "deactivate":
  334. jt3d.SpatialAnalysis.HeightLimit.removePrimitive();
  335. jt3d.CommonTools._sketchViewModel.sketchClear();
  336. //还原左键单击事件
  337. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  338. break;
  339. }
  340. },
  341. changeHeight(val) {
  342. jt3d.SpatialAnalysis.HeightLimit.changeHeight(val);
  343. },
  344. /**
  345. * 通视分析
  346. * @param {Object} type
  347. */
  348. SightLine(type) {
  349. let _self = this;
  350. //功能初始化
  351. _self.init();
  352. switch (type) {
  353. case "activate":
  354. jt3d.SpatialAnalysis.SightLine.startSightLine();
  355. break;
  356. case "deactivate":
  357. jt3d.SpatialAnalysis.SightLine.clearAll();
  358. //还原左键单击事件
  359. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  360. break;
  361. }
  362. },
  363. /**
  364. * 视域分析
  365. */
  366. ViewShed(type) {
  367. let _self = this;
  368. //功能初始化
  369. _self.init();
  370. switch (type) {
  371. case "activate":
  372. jt3d.SpatialAnalysis.ViewShed.createViewshed(10);
  373. break;
  374. case "deactivate":
  375. jt3d.SpatialAnalysis.ViewShed.clearAll();
  376. //还原左键单击事件
  377. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  378. break;
  379. }
  380. },
  381. /**
  382. * 剖面分析
  383. */
  384. SectionAnalysis() {
  385. let _self = this;
  386. //功能初始化
  387. _self.init();
  388. jt3d.DrawTools.draw('polyline', {
  389. isEdit: false,
  390. onComplete(cartesian3d, points) {
  391. let pointsArray = [];
  392. points.forEach((coordinate, index) => {
  393. pointsArray.push([
  394. coordinate.lng,
  395. coordinate.lat,
  396. coordinate.height
  397. ]);
  398. });
  399. let ProfileAnalysis = jt3d.SpatialAnalysis.Profile.startProfileAnalysis(pointsArray, jt3d.DrawTools._drawEntity.polyline);
  400. ProfileAnalysis.then(function(result) {
  401. _self.$parent.$parent.$refs.refDrawerSectionAnalysis.drawerVisible = true;
  402. _self.$parent.$parent.initEchartsData(result);
  403. });
  404. }
  405. });
  406. },
  407. /**
  408. * 功能初始化
  409. */
  410. init() {
  411. //移除左键单击事件
  412. if (jt3d.handlerLeftClick) {
  413. jt3d.handlerLeftClick.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); //移除事件
  414. }
  415. jt3d.DrawTools.Clear();
  416. jt3d.CommonTools._sketchViewModel.sketchClear();
  417. jt3d.SpatialAnalysis.CutFill.remove(); //清除方量分析
  418. jt3d.SpatialAnalysis.Profile.removeProfileAnalysis(); //移除剖面分析
  419. jt3d.SpatialAnalysis.SightLine.clearAll(); //清除通视分析
  420. jt3d.SpatialAnalysis.ViewShed.clearAll(); //清除视域分析
  421. jt3d.SpatialAnalysis.HeightLimit.removePrimitive(); //清除限高分析
  422. }
  423. },
  424. mounted() {
  425. }
  426. };
  427. </script>
  428. <style lang="scss" scoped>
  429. .jt-analysisSpace {
  430. position: relative;
  431. .iconfont {
  432. padding: 0 10rem;
  433. }
  434. .el-collapse {
  435. --el-collapse-border-color: rgb(0 44 126 / 0%);
  436. --el-collapse-header-text-color: #ffffff;
  437. --el-collapse-header-font-size: 13rem;
  438. --el-collapse-content-bg-color: rgb(0 44 126 / 0%);
  439. --el-collapse-content-font-size: 13rem;
  440. --el-collapse-content-text-color: rgb(216 240 255);
  441. --el-collapse-header-height: 40rem;
  442. --el-collapse-header-bg-color: rgb(30 130 255);
  443. --el-fill-color-blank: rgb(0 44 126 / 68%);
  444. --el-text-color-regular: rgb(216 240 255);
  445. --el-border-color: rgb(35 135 255);
  446. .el-collapse-item__content {
  447. padding: 10rem;
  448. // padding-bottom: 0rem;
  449. }
  450. }
  451. }
  452. ::v-deep .el-collapse-item__content {
  453. padding: 10rem;
  454. // padding-bottom: 0rem;
  455. overflow-y: hidden;
  456. }
  457. ::v-deep .el-collapse-item__header {
  458. background: url(@/assets/images/bg_collapse_title.png) no-repeat;
  459. background-size: 350rem 40rem;
  460. // background-color: rgb(22 90 190);
  461. // background-color: rgb(5 45 100 /60%);
  462. background-color: rgb(30 130 255);
  463. border-bottom: 0;
  464. }
  465. </style>