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. // debugger
  309. }
  310. });
  311. break;
  312. case "activate":
  313. jt3d.DrawTools.draw('polygon', {
  314. isEdit: false,
  315. onComplete(cartesian3d, points) {
  316. //清除绘制
  317. // jt3d.DrawTools._entities.remove(jt3d.DrawTools._drawEntity.polygon);
  318. jt3d.DrawTools.Clear();
  319. let pointsArray = [];
  320. points.forEach((coordinate, index) => {
  321. pointsArray.push([
  322. coordinate.lng,
  323. coordinate.lat,
  324. coordinate.height
  325. ]);
  326. });
  327. jt3d.SpatialAnalysis.HeightLimit.addPrimitive(pointsArray, {
  328. height: _self.heightLimit.height,
  329. baseHeight: _self.heightLimit.baseHeight,
  330. });
  331. }
  332. });
  333. break;
  334. case "deactivate":
  335. jt3d.SpatialAnalysis.HeightLimit.removePrimitive();
  336. jt3d.CommonTools._sketchViewModel.sketchClear();
  337. //还原左键单击事件
  338. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  339. break;
  340. }
  341. },
  342. changeHeight(val) {
  343. jt3d.SpatialAnalysis.HeightLimit.changeHeight(val);
  344. },
  345. /**
  346. * 通视分析
  347. * @param {Object} type
  348. */
  349. SightLine(type) {
  350. let _self = this;
  351. //功能初始化
  352. _self.init();
  353. switch (type) {
  354. case "activate":
  355. jt3d.SpatialAnalysis.SightLine.startSightLine();
  356. break;
  357. case "deactivate":
  358. jt3d.SpatialAnalysis.SightLine.clearAll();
  359. //还原左键单击事件
  360. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  361. break;
  362. }
  363. },
  364. /**
  365. * 视域分析
  366. */
  367. ViewShed(type) {
  368. let _self = this;
  369. //功能初始化
  370. _self.init();
  371. switch (type) {
  372. case "activate":
  373. jt3d.SpatialAnalysis.ViewShed.createViewshed(10);
  374. break;
  375. case "deactivate":
  376. jt3d.SpatialAnalysis.ViewShed.clearAll();
  377. //还原左键单击事件
  378. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  379. break;
  380. }
  381. },
  382. /**
  383. * 剖面分析
  384. */
  385. SectionAnalysis() {
  386. let _self = this;
  387. //功能初始化
  388. _self.init();
  389. jt3d.DrawTools.draw('polyline', {
  390. isEdit: false,
  391. onComplete(cartesian3d, points) {
  392. let pointsArray = [];
  393. points.forEach((coordinate, index) => {
  394. pointsArray.push([
  395. coordinate.lng,
  396. coordinate.lat,
  397. coordinate.height
  398. ]);
  399. });
  400. let ProfileAnalysis = jt3d.SpatialAnalysis.Profile.startProfileAnalysis(pointsArray, jt3d.DrawTools._drawEntity.polyline);
  401. ProfileAnalysis.then(function(result) {
  402. _self.$parent.$parent.$refs.refDrawerSectionAnalysis.drawerVisible = true;
  403. _self.$parent.$parent.initEchartsData(result);
  404. });
  405. }
  406. });
  407. },
  408. /**
  409. * 功能初始化
  410. */
  411. init() {
  412. //移除左键单击事件
  413. if (jt3d.handlerLeftClick) {
  414. jt3d.handlerLeftClick.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); //移除事件
  415. }
  416. jt3d.DrawTools.Clear();
  417. jt3d.CommonTools._sketchViewModel.sketchClear();
  418. jt3d.SpatialAnalysis.CutFill.remove(); //清除方量分析
  419. jt3d.SpatialAnalysis.Profile.removeProfileAnalysis(); //移除剖面分析
  420. jt3d.SpatialAnalysis.SightLine.clearAll(); //清除通视分析
  421. jt3d.SpatialAnalysis.ViewShed.clearAll(); //清除视域分析
  422. jt3d.SpatialAnalysis.HeightLimit.removePrimitive(); //清除限高分析
  423. }
  424. },
  425. mounted() {
  426. }
  427. };
  428. </script>
  429. <style lang="scss" scoped>
  430. .jt-analysisSpace {
  431. position: relative;
  432. .iconfont {
  433. padding: 0 10rem;
  434. }
  435. .el-collapse {
  436. --el-collapse-border-color: rgb(0 44 126 / 0%);
  437. --el-collapse-header-text-color: #ffffff;
  438. --el-collapse-header-font-size: 13rem;
  439. --el-collapse-content-bg-color: rgb(0 44 126 / 0%);
  440. --el-collapse-content-font-size: 13rem;
  441. --el-collapse-content-text-color: rgb(216 240 255);
  442. --el-collapse-header-height: 40rem;
  443. --el-collapse-header-bg-color: rgb(30 130 255);
  444. --el-fill-color-blank: rgb(0 44 126 / 68%);
  445. --el-text-color-regular: rgb(216 240 255);
  446. --el-border-color: rgb(35 135 255);
  447. .el-collapse-item__content {
  448. padding: 10rem;
  449. // padding-bottom: 0rem;
  450. }
  451. }
  452. }
  453. ::v-deep .el-collapse-item__content {
  454. padding: 10rem;
  455. // padding-bottom: 0rem;
  456. overflow-y: hidden;
  457. }
  458. ::v-deep .el-collapse-item__header {
  459. background: url(@/assets/images/bg_collapse_title.png) no-repeat;
  460. background-size: 350rem 40rem;
  461. // background-color: rgb(22 90 190);
  462. // background-color: rgb(5 45 100 /60%);
  463. background-color: rgb(30 130 255);
  464. border-bottom: 0;
  465. }
  466. </style>