clickQuery.vue 27 KB

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