clickQuery.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. <template>
  2. <div
  3. class="sm-panel sm-function-module-query"
  4. v-show="PoinyQueryShow && vectorShow"
  5. v-drag
  6. >
  7. <div class="sm-panel-header">
  8. <span>{{ Resource.PoinyQuery }}</span>
  9. <span class="closeBtn" @click="toggleVisibility">&times;</span>
  10. </div>
  11. <!-- <div class="sm-function-module-content-btn"> -->
  12. <div class="btnList">
  13. <span
  14. v-for="(item, index) in actionOptions"
  15. :key="index"
  16. class="icon-span"
  17. :title="item.lable"
  18. :class="item.isSelect ? 'selected-icon' : ''"
  19. @click="changleQueryItem(item)"
  20. >
  21. <i
  22. class="iconfont iconSize"
  23. :class="item.iconName"
  24. style="margin-top: 0px"
  25. ></i>
  26. </span>
  27. <!-- <el-button type="primary" size="small" @click.stop="mapLayerQuery"
  28. >点击</el-button
  29. >
  30. <el-button type="primary" size="small" @click.stop="removeMapLayerQuery"
  31. >清除</el-button
  32. > -->
  33. </div>
  34. <div class="sm-function-module-content-tabs">
  35. <el-tabs @tab-click="handleTabClick" v-model="activeLayerId">
  36. <el-tab-pane
  37. :label="item.label"
  38. :name="item.id"
  39. v-for="(item, index) in layerList"
  40. :key="index"
  41. ></el-tab-pane>
  42. </el-tabs>
  43. </div>
  44. <div class="sm-function-module-content-table">
  45. <el-collapse
  46. :value="activeNames"
  47. @change="handleCollapseChange"
  48. v-if="
  49. activeLayerId &&
  50. queryResults[activeLayerId] &&
  51. queryResults[activeLayerId].length > 0
  52. "
  53. >
  54. <el-collapse-item
  55. :title="'查询结果' + (index + 1)"
  56. :name="'查询结果' + (index + 1)"
  57. v-for="(item, index) in queryResults[activeLayerId]"
  58. :key="index"
  59. >
  60. <template slot="title">
  61. 查询结果{{ index + 1
  62. }}<i
  63. title="定位"
  64. class="header-icon el-icon-s-promotion flyBtn2"
  65. @click.stop="flyTo(index)"
  66. ></i>
  67. </template>
  68. <el-table
  69. :data="item"
  70. :show-header="false"
  71. border
  72. style="width: 100%"
  73. :header-cell-style="{
  74. background: 'rgba(10, 25, 38, 0.6)',
  75. color: '#66b1ff',
  76. fontSize: '14px',
  77. fontFamily: 'Microsoft YaHei',
  78. fontWeight: '400',
  79. }"
  80. >
  81. <el-table-column prop="name" label="字段" width="100">
  82. </el-table-column>
  83. <el-table-column prop="value" label="值" width="208">
  84. </el-table-column>
  85. </el-table>
  86. </el-collapse-item>
  87. </el-collapse>
  88. </div>
  89. <CockpitVector v-if="store.state.vectorData.length > 0"></CockpitVector>
  90. <MultiLevelQuery ref="MultiLevelQuery" />
  91. </div>
  92. </template>
  93. <script>
  94. import axios from "axios";
  95. import { GetGDlnfo, GetXzqhTree, GetHouseInfo } from "../../../api/map";
  96. import { keys } from "lodash";
  97. import { handModel, handnew, clearTranslate, keyName } from "./modelLayering";
  98. import CockpitVector from "./CockpitVector.vue";
  99. import MultiLevelQuery from "./MultiLevelQuery.vue";
  100. import * as pick_cockpit_vector from "./pick_cockpit_vector.js";
  101. import * as tdsy from "@/views/cockpit/js/tdsy";
  102. import * as turf from "@turf/turf";
  103. let gwtype;
  104. let query_click = null;
  105. let manager_layer_png = null;
  106. let dataSourceLayer =null
  107. export default {
  108. name: "clickQuery",
  109. components: { CockpitVector, MultiLevelQuery },
  110. data() {
  111. return {
  112. inited: false,
  113. activeLayerName: "",
  114. columns: [
  115. {
  116. title: "字段",
  117. key: "name",
  118. },
  119. {
  120. title: "值",
  121. key: "value",
  122. },
  123. ],
  124. layersDataUrl: window.layersDataUrl,
  125. layersData: [],
  126. layerList: [],
  127. loading: false,
  128. handler: {},
  129. activeNames: "查询结果1",
  130. activeLayerId: "",
  131. queryResults: {},
  132. queryResultsGeom: {},
  133. queryResultsGeomPart: {},
  134. viewer: null,
  135. // dataSourceLayer: null,
  136. actionOptions: [
  137. {
  138. index: 1,
  139. lable: "图层",
  140. iconName: "el-icon-tickets",
  141. isSelect: false,
  142. },
  143. {
  144. index: 2,
  145. lable: "模型",
  146. iconName: "el-icon-office-building",
  147. isSelect: false,
  148. },
  149. // {
  150. // index: 4,
  151. // lable: "矢量",
  152. // iconName: "el-icon-picture",
  153. // isSelect: false,
  154. // },
  155. {
  156. index: 5,
  157. lable: "联级查询",
  158. iconName: "el-icon-c-scale-to-original",
  159. isSelect: false,
  160. },
  161. {
  162. index: 3,
  163. lable: "清除",
  164. iconName: "el-icon-delete",
  165. isSelect: false,
  166. },
  167. ],
  168. };
  169. },
  170. computed: {
  171. PoinyQueryShow: function () {
  172. return store.state.toolBar[9];
  173. },
  174. vectorShow: function () {
  175. return store.state.cockpit_vector.title ||
  176. store.state.cockpit_vector.goitem
  177. ? !store.state.viewer_flag
  178. : true;
  179. },
  180. },
  181. created() {},
  182. watch: {
  183. activeLayerId(val) {
  184. if (val && val != "0") {
  185. for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
  186. let obj = store.state.vectorlayerlist[i];
  187. if (obj.id == val) {
  188. if (obj.type == "S3M") {
  189. this.addGeometrys(true);
  190. } else {
  191. this.addGeometrys();
  192. }
  193. break;
  194. }
  195. }
  196. }
  197. },
  198. PoinyQueryShow(val) {
  199. if (!this.inited) {
  200. this.inited = !this.inited;
  201. // viewer = viewer;
  202. viewer.entities.removeAll();
  203. this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  204. dataSourceLayer = new Cesium.CustomDataSource("query");
  205. viewer.dataSources.add(dataSourceLayer);
  206. }
  207. },
  208. },
  209. mounted() {
  210. this.$nextTick((res) => {
  211. query_click = new Cesium.CustomDataSource("query_click");
  212. viewer.dataSources.add(query_click);
  213. manager_layer_png = new Cesium.CustomDataSource("manager_layer_png");
  214. viewer.dataSources.add(manager_layer_png);
  215. });
  216. },
  217. methods: {
  218. isArray2D(arr) {
  219. // 首先检查arr是否是数组
  220. if (!Array.isArray(arr)) {
  221. return false;
  222. }
  223. // 检查数组中的每个元素是否也是数组
  224. for (let i = 0; i < arr.length; i++) {
  225. if (!Array.isArray(arr[i])) {
  226. return false;
  227. }
  228. }
  229. // 如果所有元素都是数组,那么arr是二维数组
  230. return true;
  231. },
  232. toggleVisibility() {
  233. this.removeMapLayerQuery();
  234. this.remove_query_click()
  235. store.setToolBarAction(9);
  236. tdsy.remove(false);
  237. store.state.vectorData = [];
  238. },
  239. addGeometrys(fill) {
  240. viewer.entities.removeAll();
  241. dataSourceLayer.entities.removeAll();
  242. let geoms = this.queryResultsGeom[this.activeLayerId];
  243. let parts = this.queryResultsGeomPart[this.activeLayerId];
  244. for (let i = 0; i < geoms.length; i++) {
  245. let cur = geoms[i];
  246. let part = parts[i];
  247. let start = 0;
  248. let end = 0;
  249. for (let k = 0; k < part.length; k++) {
  250. let points = [];
  251. if (k > 0) {
  252. start += part[k - 1];
  253. }
  254. end += part[k];
  255. for (let j = start; j < end; j++) {
  256. let cx = cur[j][0];
  257. let cy = cur[j][1];
  258. points.push(cx);
  259. points.push(cy);
  260. }
  261. if (fill) {
  262. viewer.entities.add({
  263. polyline: new Cesium.PolylineGraphics({
  264. positions: Cesium.Cartesian3.fromDegreesArray(points),
  265. width: 3,
  266. material: Cesium.Color.BLUE.withAlpha(0.9),
  267. clampToGround: true,
  268. }),
  269. polygon: {
  270. //高程
  271. hierarchy: new Cesium.PolygonHierarchy(
  272. Cesium.Cartesian3.fromDegreesArray(points)
  273. ),
  274. classificationType: Cesium.ClassificationType.BOTH,
  275. clampToGround: false,
  276. material: Cesium.Color.RED.withAlpha(0.3),
  277. // material: videoElement,
  278. // perPositionHeight: true
  279. },
  280. });
  281. } else {
  282. viewer.entities.add({
  283. polyline: new Cesium.PolylineGraphics({
  284. positions: Cesium.Cartesian3.fromDegreesArray(points),
  285. width: 3,
  286. material: Cesium.Color.BLUE.withAlpha(0.9),
  287. clampToGround: true,
  288. }),
  289. });
  290. }
  291. }
  292. // viewer.flyTo(viewer.entities);
  293. }
  294. },
  295. flyTo(index) {
  296. dataSourceLayer.entities.removeAll();
  297. let geoms = this.queryResultsGeom[this.activeLayerId];
  298. let parts = this.queryResultsGeomPart[this.activeLayerId];
  299. let cur = geoms[index];
  300. if (cur) {
  301. let part = parts[index];
  302. let start = 0;
  303. let end = 0;
  304. for (let k = 0; k < part.length; k++) {
  305. let points = [];
  306. if (k > 0) {
  307. start += part[k - 1];
  308. }
  309. end += part[k];
  310. for (let j = start; j < end; j++) {
  311. let cx = cur[j][0];
  312. let cy = cur[j][1];
  313. points.push(cx);
  314. points.push(cy);
  315. }
  316. // let e = dataSourceLayer.entities.
  317. let e = viewer.entities.add({
  318. polyline: new Cesium.PolylineGraphics({
  319. positions: Cesium.Cartesian3.fromDegreesArray(points),
  320. width: 3,
  321. material: Cesium.Color.RED.withAlpha(0.9),
  322. clampToGround: true,
  323. }),
  324. });
  325. viewer.flyTo(e);
  326. }
  327. } else {
  328. this.$message({
  329. message: "空间范围为空!",
  330. type: "warning",
  331. });
  332. }
  333. },
  334. handleTabClick(item, a) {
  335. this.activeLayerId = item.name;
  336. },
  337. // 设置数据
  338. setData() {
  339. dataSourceLayer = new Cesium.CustomDataSource("query");
  340. viewer.dataSources.add(dataSourceLayer);
  341. this.activeLayerId = "0";
  342. this.queryResults = {};
  343. this.queryResultsGeom = {};
  344. this.queryResultsGeomPart = {};
  345. },
  346. /**
  347. * 左键点击查询图层
  348. */
  349. async mapLayerQuery(movement) {
  350. let that = this;
  351. that.activeLayerId = "0";
  352. that.layerList = [];
  353. that.layersData = [];
  354. this.remove_query_click();
  355. let scene = viewer.scene;
  356. viewer.entities.removeAll();
  357. dataSourceLayer.entities.removeAll();
  358. //拾取模型
  359. let pickedFeature = scene.pick(movement.position);
  360. if (
  361. scene.pickPositionSupported &&
  362. Cesium.defined(pickedFeature) &&
  363. pickedFeature != null &&
  364. pickedFeature.primitive
  365. ) {
  366. let eneityName = pickedFeature.primitive.name;
  367. let Pid = "";
  368. var tempArr = [];
  369. // "ResultNetWork@管线#1"///"ResultNetWork_Node@管线#1"
  370. if (
  371. eneityName.indexOf("雨水") > -1 ||
  372. eneityName.indexOf("管线") > -1
  373. ) {
  374. let buildingLayer = scene.layers.find(eneityName);
  375. if (buildingLayer.getSelection().length > 0) {
  376. const selectedId = Number(buildingLayer.getSelection()[0]);
  377. buildingLayer.getAttributesById([selectedId]).then(function (atts) {
  378. if (atts) {
  379. Pid = atts["管线段"] || atts["物探点"];
  380. var length = Object.keys(atts).length;
  381. var des;
  382. for (var i = 0; i < length; i++) {
  383. var key = Object.keys(atts)[i];
  384. var value = atts[key];
  385. // console.log(key);
  386. // console.log(value);
  387. if (
  388. key.toLowerCase().indexOf("shape") < 0 &&
  389. key.toLowerCase().indexOf("sm") &&
  390. value != ""
  391. ) {
  392. tempArr.push({
  393. name: key,
  394. value: value,
  395. });
  396. }
  397. }
  398. }
  399. //获取图层id的参数
  400. let substring = pickedFeature.primitive._baseUri.query;
  401. for (let p = 0; p < store.state.vectorlayerlist.length; i++) {
  402. if (store.state.vectorlayerlist[p].id == substring) {
  403. that.layerList.push(store.state.vectorlayerlist[p]);
  404. break;
  405. }
  406. }
  407. that.queryResults[substring] = [tempArr];
  408. that.queryResultsGeom[substring] = [];
  409. that.activeLayerId = substring;
  410. });
  411. }
  412. }
  413. that.loading = true;
  414. that.queryByPickFeature(pickedFeature, function (result, Fields) {
  415. that.loading = false;
  416. if (result != null && result.features[0].fieldNames) {
  417. result.features[0].fieldNames.forEach((fieldName, i) => {
  418. const Field = Fields.find((c) => c.FieldEn == fieldName);
  419. let v = result.features[0].fieldValues[i];
  420. if (!isNaN(parseFloat(v))) {
  421. v = Math.round(parseFloat(v) * 100) / 100;
  422. }
  423. that.layersData.push({
  424. label: Field ? Field.FieldCn : fieldName,
  425. value: v,
  426. });
  427. });
  428. } else {
  429. that.layersData = [];
  430. }
  431. });
  432. } else {
  433. //拾取图层
  434. // let pickRay = viewer.camera.getPickRay(movement.position);
  435. // let artesian3 = viewer.scene.globe.pick(pickRay, viewer.scene);
  436. let artesian3 = viewer.scene.pickPosition(movement.position);
  437. let xy = that.cartesian3ToWGS84(artesian3);
  438. //TODO wanger 分图层查询
  439. for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
  440. let obj = store.state.vectorlayerlist[i];
  441. if (!obj.source) {
  442. continue;
  443. }
  444. let queryByIDParameters = {
  445. getFeatureMode: "BUFFER",
  446. // getFeatureMode: "SPATIAL",
  447. spatialQueryMode: "INTERSECT",
  448. datasetNames: obj.source.split(","),
  449. geometry: {
  450. parts: [1],
  451. points: [{ y: xy.lat, x: xy.lng }],
  452. type: "POINT",
  453. },
  454. bufferDistance: 0.00005,
  455. hasGeometry: true,
  456. };
  457. let e;
  458. if (obj.type == "S3M") {
  459. e = await that.mapQuery(
  460. window.baseModelQueryLayer,
  461. queryByIDParameters
  462. );
  463. } else {
  464. e = await that.mapQuery(
  465. that.calcIserverURI(obj.url),
  466. queryByIDParameters
  467. );
  468. }
  469. // 结果高亮
  470. this.highlightResultsPng(xy.lng, xy.lat);
  471. // const outputCoords = this.convertCoordinates(e.features[0].geometry.points);
  472. // outputCoords.push(outputCoords[0])
  473. // let f = { "type": "Polygon", "coordinates": [outputCoords] };
  474. // let result = turf.buffer(f, 1 / 99999, {
  475. // units: "kilometers",
  476. // });
  477. // let positions = [];
  478. // const twoDArray = result.geometry.coordinates[0];
  479. // const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  480. // positions = oneDArray;
  481. // if (this.isArray2D(oneDArray)) {
  482. // const oneDArray2 = oneDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  483. // positions = oneDArray2;
  484. // } else {
  485. // }
  486. // query_click.entities.add({
  487. // polygon: {
  488. // // 获取指定属性(positions,holes(图形内需要挖空的区域))
  489. // hierarchy: {
  490. // positions: Cesium.Cartesian3.fromDegreesArray(positions)
  491. // },
  492. // // 边框
  493. // outline: false,
  494. // // 边框颜色
  495. // outlineColor: Cesium.Color.RED,
  496. // // 边框尺寸
  497. // outlineWidth: 10,
  498. // // 填充的颜色,withAlpha透明度
  499. // material: Cesium.Color.RED,
  500. // // 是否被提供的材质填充
  501. // fill: true,
  502. // // 恒定高度
  503. // height: 1.1,
  504. // // 显示在距相机的距离处的属性,多少区间内是可以显示的
  505. // // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  506. // // 是否显示
  507. // show: true,
  508. // // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  509. // zIndex: 10
  510. // }
  511. // });
  512. if (e && e.totalCount > 0) {
  513. that.layerList.push(store.state.vectorlayerlist[i]);
  514. let queryData = [];
  515. let geoms = [];
  516. // let tempTreeData = store.state.tempResourceTree;
  517. // //递归查询点击的图层信息
  518. // function getTreeId(list, id) {
  519. // //判断list是否是数组
  520. // if (!list instanceof Array) {
  521. // return null;
  522. // }
  523. // //遍历数组
  524. // for (let i in list) {
  525. // let item = list[i];
  526. // if (item.id === id) {
  527. // return item;
  528. // } else {
  529. // //查不到继续遍历
  530. // if (item.children) {
  531. // let value = getTreeId(item.children, id);
  532. // //查询到直接返回
  533. // if (value) {
  534. // return value;
  535. // }
  536. // }
  537. // }
  538. // }
  539. // }
  540. // let legendJson = getTreeId(tempTreeData, obj.id);
  541. // let parseJson =
  542. // legendJson.legend != "" ? JSON.parse(legendJson.legend) : [];
  543. let parts = [];
  544. let parseJson = JSON.parse(obj.legend);
  545. for (let u = 0; u < e.features.length; u++) {
  546. let cur = [];
  547. var linSAr = JSON.parse(JSON.stringify(e.features[u]));
  548. function condition(ci) {
  549. return ci.status != undefined && ci.status;
  550. }
  551. if (e.features[u].fieldNames) {
  552. linSAr.fieldNames.forEach((fieldName, i) => {
  553. let perjson = parseJson.filter(
  554. (p) => p.fieldname.toUpperCase() == fieldName
  555. );
  556. if (perjson.length > 0) {
  557. var show = condition(perjson[0]);
  558. var order = perjson[0].order || linSAr.fieldNames.length;
  559. if (fieldName != perjson[0].fieldaliasname)
  560. fieldName = perjson[0].fieldaliasname;
  561. }
  562. if (show) {
  563. let v = linSAr.fieldValues[i];
  564. if (v != "" && !isNaN(parseFloat(v))) {
  565. v = Math.round(parseFloat(v) * 100) / 100;
  566. }
  567. cur.push({ name: fieldName, value: v, order });
  568. }
  569. });
  570. } else {
  571. that.$message({
  572. message: "查询结果为空!",
  573. type: "warning",
  574. customClass: "messageIndex",
  575. });
  576. }
  577. //排序
  578. cur.sort((a, b) => a.order - b.order);
  579. let urlNew = obj.url + ".json";
  580. let resNew = await axios.get(urlNew);
  581. let serCode = resNew.data.prjCoordSys.epsgCode;
  582. let points = [];
  583. for (let y = 0; y < e.features[u].geometry.points.length; y++) {
  584. let c = {};
  585. if (serCode == 3857) {
  586. c = that.cartesianToCartographic84(
  587. e.features[u].geometry.points[y].x,
  588. e.features[u].geometry.points[y].y
  589. );
  590. } else {
  591. c = e.features[u].geometry.points[y];
  592. }
  593. points.push([c.x, c.y]);
  594. }
  595. parts.push(e.features[u].geometry.parts);
  596. geoms.push(points);
  597. queryData.push(cur);
  598. }
  599. that.queryResultsGeomPart[obj.id] = parts;
  600. that.queryResults[obj.id] = queryData;
  601. that.queryResultsGeom[obj.id] = geoms;
  602. }
  603. }
  604. if (that.layerList.length > 0) {
  605. that.activeLayerId = that.layerList[0].id;
  606. } else {
  607. that.$message({
  608. message: "查询结果为空!",
  609. type: "warning",
  610. customClass: "messageIndex",
  611. });
  612. }
  613. }
  614. },
  615. highlightResultsPng(longitude, latitude) {
  616. manager_layer_png.entities.add({
  617. name: "manager_layer_png",
  618. position: Cesium.Cartesian3.fromDegrees(longitude, latitude, 40),
  619. billboard: {
  620. // 图像地址,URI或Canvas的属性
  621. image: "./static/images/overview/go.png",
  622. height: 34,
  623. width: 36,
  624. scale: 1.0,
  625. zIndex: 2,
  626. show: true,
  627. },
  628. });
  629. },
  630. addLayerList(label) {
  631. if (this.layerList.findIndex((a) => a.label == label) >= 0) return;
  632. let layers = store.state.vectorlayerlist.filter(
  633. (element) => element.label === label
  634. );
  635. if (layers.length > 0) {
  636. this.activeLayerId = layers[0].id;
  637. this.layerList.push(layers[0]);
  638. }
  639. },
  640. /**
  641. * 左键点击模型查询
  642. */
  643. mapModelQuery(movement) {
  644. this.activeLayerId = "0";
  645. this.layerList = [];
  646. this.layersData = [];
  647. viewer.entities.removeAll();
  648. dataSourceLayer.entities.removeAll();
  649. let title;
  650. if (store.state.checkedData) title = store.state.checkedData.title;
  651. // 超图分层分户
  652. if (title == "分层分户" || title == "8号楼-谷") {
  653. let id = handModel(movement);
  654. } else {
  655. handnew(movement);
  656. }
  657. let newArr = [];
  658. GetHouseInfo({ id: "2c01647f-4533-4472-b20b-f5caa4c705b0" }).then(
  659. (res) => {
  660. for (const [key, value] of Object.entries(res.data)) {
  661. newArr.push({ name: keyName[key], value: value });
  662. }
  663. this.addLayerList(title);
  664. this.queryResults[this.activeLayerId] = [newArr];
  665. this.queryResultsGeom[this.activeLayerId] = [];
  666. }
  667. );
  668. },
  669. mapQuerys(queryName) {
  670. this.setData();
  671. let that = this;
  672. this.handler.setInputAction(function (movement) {
  673. that[queryName](movement);
  674. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  675. this.handler.setInputAction(function () {
  676. that.removeMapLayerQuery();
  677. clearTranslate();
  678. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  679. },
  680. /**
  681. * 超图
  682. * 根据返回的三维对象查询数据信息
  683. *
  684. * @param {*} param
  685. */
  686. async queryByPickFeature(param, completed) {
  687. if (param.primitive) {
  688. let dataUrl = "";
  689. let datasourceName = "";
  690. let Fields = [];
  691. for (const layerData of this.layersDataUrl) {
  692. for (const datasource of layerData.datasources) {
  693. if (datasource.Name3D == param.primitive.name) {
  694. dataUrl = layerData.url;
  695. datasourceName = datasource.DataName;
  696. Fields = datasource.Fields;
  697. break;
  698. }
  699. }
  700. }
  701. let queryByIDParameters = {
  702. getFeatureMode: "ID",
  703. datasetNames: [datasourceName],
  704. ids: [param.id],
  705. hasGeometry: "false",
  706. };
  707. if (!dataUrl) {
  708. completed(null);
  709. } else {
  710. let e = await this.mapQuery(dataUrl, queryByIDParameters);
  711. if (completed) {
  712. completed(e, Fields);
  713. }
  714. }
  715. }
  716. },
  717. async mapQuery(url, queryObj) {
  718. let response = await axios.post(url, queryObj);
  719. if (response.data.featureCount > 0) {
  720. return response.data;
  721. } else {
  722. return null;
  723. }
  724. },
  725. convertCoordinates(coordArray) {
  726. return coordArray.map((coord) => [coord.x, coord.y]);
  727. },
  728. // 取消左键点击查询
  729. removeMapLayerQuery() {
  730. this.queryResults = {};
  731. this.queryResultsGeom = {};
  732. this.queryResultsGeomPart = {};
  733. this.layerList = [];
  734. viewer.entities.removeAll();
  735. this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  736. this.handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  737. dataSourceLayer.entities.removeAll();
  738. viewer.dataSources.remove(dataSourceLayer);
  739. },
  740. /**
  741. * 笛卡尔坐标系转WGS84坐标系(经纬度)
  742. * @author
  743. * @param {object} point 点,笛卡尔坐标{x:x,y:y,z:z}
  744. * @returns {object} -lat: lat, lng: lng, alt: alt
  745. */
  746. cartesian3ToWGS84(point) {
  747. var cartesian3 = new Cesium.Cartesian3(point.x, point.y, point.z);
  748. var cartographic = Cesium.Cartographic.fromCartesian(cartesian3);
  749. var lat = Cesium.Math.toDegrees(cartographic.latitude);
  750. var lng = Cesium.Math.toDegrees(cartographic.longitude);
  751. var alt = cartographic.height;
  752. return {
  753. lat: lat,
  754. lng: lng,
  755. alt: alt,
  756. };
  757. },
  758. /**
  759. * 墨卡托坐标系转WGS84坐标系(经纬度)
  760. * @author
  761. * @param number x
  762. * @param number y
  763. * @returns {object} x: x, y: y, z: z
  764. */
  765. cartesianToCartographic84(x, y) {
  766. let cartesian3InMercator = new Cesium.Cartesian3(x, y, 0);
  767. let mercator = new Cesium.WebMercatorProjection();
  768. let p = mercator.unproject(cartesian3InMercator);
  769. // 将墨卡托坐标转换为WGS84坐标
  770. // let cartesian3InWGS84 =
  771. // Cesium.Ellipsoid.WGS84.cartesianToCartographic(mercator.unproject(cartesian3InMercator));
  772. return {
  773. x: Cesium.Math.toDegrees(p.longitude),
  774. y: Cesium.Math.toDegrees(p.latitude),
  775. z: p.height,
  776. };
  777. },
  778. calcIserverURI(url) {
  779. let uriArr = url.split("/");
  780. uriArr[5] = uriArr[5].replace("map-", "data-");
  781. uriArr[7] = "data";
  782. uriArr[8] = "featureResults.rjson?returnContent=true";
  783. return uriArr.join("/");
  784. },
  785. remove_query_click() {
  786. for (var i = 0; i < 10; i++) {
  787. query_click.entities.values.forEach((res) => {
  788. query_click.entities.remove(res);
  789. });
  790. }
  791. // 图标
  792. var entities = manager_layer_png.entities.values;
  793. for (var i = entities.length - 1; i >= 0; i--) {
  794. manager_layer_png.entities.remove(entities[i]);
  795. }
  796. },
  797. //地图数据查询事件
  798. changleQueryItem(item) {
  799. switch (item.index) {
  800. case 1: {
  801. this.mapQuerys("mapLayerQuery"); //图层点击事件
  802. this.remove_query_click();
  803. viewer.entities.removeAll();
  804. break;
  805. }
  806. case 2: {
  807. this.mapQuerys("mapModelQuery");
  808. break;
  809. }
  810. case 3: {
  811. this.removeMapLayerQuery(); //清除
  812. clearTranslate();
  813. pick_cockpit_vector.clear_data(); //矢量拾取清除
  814. this.$refs.MultiLevelQuery.clear_data(); //多级查询
  815. this.remove_query_click();
  816. break;
  817. }
  818. case 4: {
  819. //驾驶舱矢量数据点选查询
  820. pick_cockpit_vector.init_handler();
  821. break;
  822. }
  823. case 5: {
  824. //联级查询
  825. this.$refs.MultiLevelQuery.init_handler();
  826. break;
  827. }
  828. default:
  829. break;
  830. }
  831. },
  832. },
  833. beforeDestroy() {
  834. this.removeMapLayerQuery();
  835. clearTranslate();
  836. },
  837. };
  838. </script>
  839. <style>
  840. .sm-function-module-content-btn {
  841. text-align: center;
  842. padding-top: 5px;
  843. }
  844. .flyBtn2 {
  845. position: absolute;
  846. right: 47px;
  847. }
  848. .el-tabs__item {
  849. color: white !important;
  850. }
  851. .sm-function-module-content-tabs {
  852. height: 45px;
  853. padding: 1px 5px 0px 5px;
  854. /* margin-top: 4rem; */
  855. }
  856. .sm-function-module-content-table {
  857. height: 564px;
  858. overflow-y: auto;
  859. padding: 1px 5px 0px 5px;
  860. }
  861. .sm-function-module-query {
  862. /* padding: 5px 10px; */
  863. overflow: hidden;
  864. max-height: 700px;
  865. scrollbar-width: none;
  866. /* firefox */
  867. -ms-overflow-style: none;
  868. /* IE 10+ */
  869. @media (max-width: 1000px) {
  870. margin: 0.8rem 0;
  871. padding: 0 15px;
  872. }
  873. @media (max-width: 750px) {
  874. margin: 0.5rem 0;
  875. padding: 0 10px;
  876. max-height: 410px;
  877. }
  878. @media (max-height: 480px) {
  879. margin: 0.5rem 0;
  880. padding: 0 15px;
  881. max-height: 420px;
  882. max-width: 280px;
  883. }
  884. @media (max-height: 300px) {
  885. margin: 0.5rem 0;
  886. padding: 0 10px;
  887. max-height: 280px;
  888. max-width: 250px;
  889. }
  890. @media (max-height: 250px) {
  891. max-height: 240px;
  892. }
  893. }
  894. </style>
  895. <style lang="scss" scoped>
  896. @import "clickQuery";
  897. /deep/ .el-table tr {
  898. background: rgba(10, 25, 38, 0.5) !important;
  899. }
  900. /deep/ .el-table td.el-table__cell,
  901. .el-table th.el-table__cell.is-leaf {
  902. background: rgba(10, 25, 38, 0.5) !important;
  903. border-bottom: 1px solid #ebeef5;
  904. }
  905. .el-table {
  906. color: #fff;
  907. background: rgba(10, 25, 38, 0.5) !important;
  908. }
  909. /deep/ .el-table__fixed-right::before,
  910. .el-table__fixed::before {
  911. background: rgba(10, 25, 38, 0.9) !important;
  912. }
  913. /deep/ .el-table__fixed-right-patch {
  914. background: rgba(10, 25, 38, 0.9) !important;
  915. }
  916. /deep/ .el-table--border::after,
  917. .el-table--group::after,
  918. .el-table::before {
  919. background: rgba(10, 25, 38, 0) !important;
  920. }
  921. /deep/ .el-collapse-item__header {
  922. background-color: transparent !important;
  923. color: rgb(217, 237, 254) !important;
  924. }
  925. /deep/ .el-collapse {
  926. border: none;
  927. /* border-top: 1px solid #EBEEF5; */
  928. /* border-bottom: 1px solid #EBEEF5; */
  929. }
  930. /deep/ .el-collapse-item__content {
  931. padding-bottom: 0px;
  932. }
  933. </style>