clickQuery.vue 30 KB

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