clickQuery.vue 28 KB

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