clickQuery.vue 30 KB

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