analysis-terrain.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <script setup>
  2. import {
  3. inject
  4. } from "vue";
  5. const getMapInstance = inject("getMapInstance");
  6. jt3d = getMapInstance();
  7. </script>
  8. <template>
  9. <div class="jt-analysisTerrain">
  10. <el-collapse v-model="activeName" accordion>
  11. <el-collapse-item name="地下模式">
  12. <template #title>
  13. <i class='iconfont icon-svgdixiamoshi' />地下模式
  14. </template>
  15. <div class="el-collapse-item__content">
  16. <div style="line-height: 2em; table-layout: fixed; word-wrap: break-word; word-break: normal; text-align:justify; text-justify: inter-ideograph;color: #ffffff60;">
  17. 提示:可以透明地表,进入地下模式,可以看地下管网数据。
  18. </div>
  19. <el-form label-width="130rem">
  20. <el-form-item label="地下模式开启状态:">
  21. <el-switch v-model="underground.boolUnderground" active-text="已开启" inactive-text="已关闭" @change="handleUndergroundChange">
  22. </el-switch>
  23. </el-form-item>
  24. <el-form-item label="地表透明度:">
  25. <el-slider v-model="underground.alpha" :min="0" :max="1" :step="0.1" :disabled="!underground.boolUnderground" @input="handleAlphaChange">
  26. </el-slider>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. </el-collapse-item>
  31. <el-collapse-item name="地形开挖">
  32. <template #title>
  33. <i class='iconfont icon-svgdixingkaiwa' />地形开挖
  34. </template>
  35. <div class="el-collapse-item__content">
  36. <el-form ref="form" label-width="100rem" label-position="right" size="mini">
  37. <el-form-item label="开挖深度:">
  38. <el-input v-model="terrainExcavation.excavateDepth" />
  39. </el-form-item>
  40. </el-form>
  41. <div class="jt-btn" style="margin-bottom: 10rem;">
  42. <el-button color="rgb(20 136 255)" @click="terrainExcavate('add')">绘制开挖区域</el-button>
  43. <el-button color="rgb(255 100 100)" @click="terrainExcavate('remove')"><span style="color: #fff;">清除开挖分析</span></el-button>
  44. </div>
  45. </div>
  46. </el-collapse-item>
  47. <el-collapse-item name="坡度分析">
  48. <template #title>
  49. <i class='iconfont icon-svgpodufenxi' />坡度分析
  50. </template>
  51. <div class="el-collapse-item__content">
  52. <div class="jt-btn" style="margin-top: 10rem;">
  53. <el-button color="rgb(20 136 255)" @click="SlopeAspect('Num')">坡度等分</el-button>
  54. <el-button color="rgb(20 136 255)" @click="SlopeAspect('Distance')">坡度等距</el-button>
  55. <el-button color="rgb(255 100 100)" @click="removeSlopeAspect"><span style="color: #fff;">移除</span></el-button>
  56. </div>
  57. </div>
  58. </el-collapse-item>
  59. <!-- <el-collapse-item name="深度检测">
  60. <template #title>
  61. <i class='iconfont icon-tianqizitiku43' />深度检测
  62. </template>
  63. <div class="el-collapse-item__content">
  64. 深度检测
  65. </div>
  66. </el-collapse-item>
  67. <el-collapse-item name="等高线">
  68. <template #title>
  69. <i class='iconfont icon-tianqizitiku43' />等高线
  70. </template>
  71. <div class="el-collapse-item__content">
  72. 等高线
  73. </div>
  74. </el-collapse-item> -->
  75. </el-collapse>
  76. </div>
  77. </template>
  78. <script>
  79. let jt3d = undefined;
  80. export default {
  81. props: {
  82. },
  83. watch: {
  84. },
  85. /* 数据 */
  86. data() {
  87. return {
  88. activeName: "地下模式",
  89. //地下模式
  90. underground: {
  91. alpha: 0.5,
  92. boolUnderground: false,
  93. },
  94. //地形开挖
  95. terrainExcavation:{
  96. excavateDepth: 10, //开挖深度
  97. }
  98. }
  99. },
  100. /* 方法 */
  101. methods: {
  102. /**
  103. * 是否开启地下模式
  104. * @param {Object} bool
  105. */
  106. handleUndergroundChange(bool) {
  107. window["viewer"].scene.screenSpaceCameraController.enableCollisionDetection = !bool; //相机与地形的碰撞检测
  108. window["viewer"].scene.globe.translucency.frontFaceAlphaByDistance = new Cesium.NearFarScalar(1.5e2, 0.5, 8.0e6, 1.0);
  109. window["viewer"].scene.globe.translucency.enabled = bool; //是否开启透明
  110. this.handleAlphaChange(this.underground.alpha);
  111. },
  112. /**
  113. * el-slider 值改变时触发
  114. * 设置地表透明度
  115. * @param {Object} alpha
  116. */
  117. handleAlphaChange(alpha) {
  118. const frontFaceAlphaByDistance = window["viewer"].scene.globe.translucency.frontFaceAlphaByDistance;
  119. frontFaceAlphaByDistance.nearValue = alpha;
  120. frontFaceAlphaByDistance.farValue = alpha;
  121. },
  122. /**
  123. * 移除坡度分析
  124. */
  125. removeSlopeAspect() {
  126. jt3d.TerrainAnalysis.SlopeAspect.clearAll();
  127. //还原左键单击事件
  128. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  129. },
  130. /**
  131. * 坡度坡向分析
  132. * @param {Object} type
  133. */
  134. SlopeAspect(type) {
  135. let _self = this;
  136. //功能初始化
  137. _self.init();
  138. switch (type) {
  139. case "Num":
  140. jt3d.DrawTools.draw('polygon', {
  141. isEdit: false,
  142. onComplete(cartesian3d, points) {
  143. let pointsArray = [];
  144. points.forEach((coordinate, index) => {
  145. pointsArray.push([
  146. coordinate.lng,
  147. coordinate.lat,
  148. coordinate.height
  149. ]);
  150. });
  151. jt3d.TerrainAnalysis.SlopeAspect.createNew4Num(pointsArray, jt3d.DrawTools._drawEntity.polygon, {
  152. num: 10
  153. });
  154. //清除绘制
  155. // jt3d.DrawTools._entities.remove(jt3d.DrawTools._drawEntity.polygon);
  156. jt3d.DrawTools.Clear();
  157. }
  158. });
  159. break;
  160. case "Distance":
  161. jt3d.DrawTools.draw('polygon', {
  162. isEdit: false,
  163. onComplete(cartesian3d, points) {
  164. let pointsArray = [];
  165. points.forEach((coordinate, index) => {
  166. pointsArray.push([
  167. coordinate.lng,
  168. coordinate.lat,
  169. coordinate.height
  170. ]);
  171. });
  172. jt3d.TerrainAnalysis.SlopeAspect.createNew4Distance(pointsArray, jt3d.DrawTools._drawEntity.polygon, {
  173. distance: 0.05
  174. });
  175. //清除绘制
  176. // jt3d.DrawTools._entities.remove(jt3d.DrawTools._drawEntity.polygon);
  177. jt3d.DrawTools.Clear();
  178. }
  179. });
  180. break;
  181. }
  182. },
  183. /**
  184. * 移除地形开挖
  185. */
  186. removeTerrainExcavate() {
  187. jt3d.TerrainAnalysis.TerrainExcavation.clear();
  188. //还原左键单击事件
  189. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  190. },
  191. /**
  192. * 地形开挖
  193. */
  194. terrainExcavate(type) {
  195. let _self = this;
  196. //功能初始化
  197. _self.init();
  198. if (type === "add") {
  199. jt3d.DrawTools.draw('polygon', {
  200. onComplete(aa, points) {
  201. jt3d.DrawTools.Clear();
  202. let pointsArray = [];
  203. points.forEach((coordinate, index) => {
  204. pointsArray.push([
  205. coordinate.lng,
  206. coordinate.lat,
  207. coordinate.height
  208. ]);
  209. });
  210. jt3d.TerrainAnalysis.TerrainExcavation.add(pointsArray, {
  211. excavateDepth: _self.terrainExcavation.excavateDepth
  212. });
  213. }
  214. });
  215. } else if (type === "remove") {
  216. _self.removeTerrainExcavate();
  217. }
  218. },
  219. /**
  220. * 功能初始化
  221. */
  222. init() {
  223. //移除左键单击事件
  224. if (jt3d.handlerLeftClick) {
  225. jt3d.handlerLeftClick.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); //移除事件
  226. }
  227. jt3d.DrawTools.Clear();
  228. jt3d.TerrainAnalysis.TerrainExcavation.clear();; //清除地形开挖
  229. jt3d.TerrainAnalysis.SlopeAspect.clearAll(); //移除坡度坡向分析
  230. }
  231. },
  232. mounted() {
  233. }
  234. };
  235. </script>
  236. <style lang="scss" scoped>
  237. .el-switch{
  238. font-size: 14rem !important;
  239. line-height: 20rem !important;
  240. align-items: self-start !important;
  241. }
  242. ::v-deep .is-checked .el-switch__core .el-switch__action{
  243. margin-left: calc(-1rem - 14rem);
  244. }
  245. ::v-deep .el-switch__core .el-switch__action{
  246. top:1rem;
  247. }
  248. ::v-deep .el-switch__core .el-switch__action{
  249. width: 14rem;
  250. height: 14rem;
  251. }
  252. ::v-deep .el-switch__core{
  253. width: 40rem !important;
  254. height: 20rem !important;
  255. }
  256. ::v-deep .el-switch__label{
  257. height: 20rem !important;
  258. font-size: 14rem !important;
  259. }
  260. ::v-deep .el-switch__label *{
  261. font-size: 14rem !important;
  262. }
  263. ::v-deep .el-switch__label--left{
  264. margin-right: 10rem;
  265. }
  266. .jt-analysisTerrain {
  267. position: relative;
  268. .iconfont {
  269. padding: 0 10rem;
  270. }
  271. .el-collapse {
  272. --el-collapse-border-color: rgb(0 44 126 / 0%);
  273. --el-collapse-header-text-color: #ffffff;
  274. --el-collapse-header-font-size: 13rem;
  275. --el-collapse-content-bg-color: rgb(0 44 126 / 0%);
  276. --el-collapse-content-font-size: 13rem;
  277. --el-collapse-content-text-color: rgb(216 240 255);
  278. --el-collapse-header-height: 40rem;
  279. --el-collapse-header-bg-color: rgb(30 130 255);
  280. --el-fill-color-blank: rgb(0 44 126 / 68%);
  281. --el-text-color-regular: rgb(216 240 255);
  282. --el-border-color: rgb(35 135 255);
  283. .el-collapse-item__content {
  284. padding: 10rem;
  285. // padding-bottom: 0rem;
  286. }
  287. }
  288. }
  289. ::v-deep .el-collapse-item__content {
  290. padding: 10rem;
  291. // padding-bottom: 0rem;
  292. overflow-y: hidden;
  293. }
  294. ::v-deep .el-collapse-item__header {
  295. background: url(@/assets/images/bg_collapse_title.png) no-repeat;
  296. background-size: 350rem 40rem;
  297. // background-color: rgb(22 90 190);
  298. // background-color: rgb(5 45 100 /60%);
  299. background-color: rgb(30 130 255);
  300. border-bottom: 0;
  301. }
  302. </style>