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