clickQuery.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <template>
  2. <div class="sm-panel sm-function-module-query" v-show="PoinyQueryShow">
  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="activeLayerId &&
  27. queryResults[activeLayerId] &&
  28. queryResults[activeLayerId].length > 0
  29. ">
  30. <el-collapse-item :title="'查询结果' + (index + 1)" :name="'查询结果' + (index + 1)"
  31. v-for="(item, index) in queryResults[activeLayerId]" :key="index">
  32. <template slot="title">
  33. 查询结果{{ index + 1
  34. }}<i title="定位" class="header-icon el-icon-s-promotion flyBtn2" @click.stop="flyTo(index)"></i>
  35. </template>
  36. <el-table :data="item" :show-header="false" border style="width: 100%">
  37. <el-table-column prop="name" label="字段" width="100">
  38. </el-table-column>
  39. <el-table-column prop="value" label="值" width="208">
  40. </el-table-column>
  41. </el-table>
  42. </el-collapse-item>
  43. </el-collapse>
  44. </div>
  45. <!-- <CockpitVector class="cockpit_vector"></CockpitVector> -->
  46. </div>
  47. </template>
  48. <script>
  49. import axios from "axios";
  50. import { GetGDlnfo, GetXzqhTree, GetHouseInfo } from "../../../api/map";
  51. import { keys } from "lodash";
  52. import { handModel, handnew, clearTranslate, keyName } from "./modelLayering";
  53. import CockpitVector from "./CockpitVector.vue";
  54. import * as pick_cockpit_vector from "./pick_cockpit_vector.js";
  55. let gwtype;
  56. export default {
  57. name: "clickQuery",
  58. components: { CockpitVector },
  59. data() {
  60. return {
  61. inited: false,
  62. activeLayerName: "",
  63. columns: [
  64. {
  65. title: "字段",
  66. key: "name",
  67. },
  68. {
  69. title: "值",
  70. key: "value",
  71. },
  72. ],
  73. layersDataUrl: window.layersDataUrl,
  74. layersData: [],
  75. layerList: [],
  76. loading: false,
  77. handler: {},
  78. activeNames: "查询结果1",
  79. activeLayerId: "",
  80. queryResults: {},
  81. queryResultsGeom: {},
  82. queryResultsGeomPart: {},
  83. viewer: null,
  84. dataSourceLayer: null,
  85. actionOptions: [
  86. {
  87. index: 1,
  88. lable: "图层",
  89. iconName: "el-icon-tickets",
  90. isSelect: false,
  91. },
  92. {
  93. index: 2,
  94. lable: "模型",
  95. iconName: "el-icon-office-building",
  96. isSelect: false,
  97. },
  98. {
  99. index: 4,
  100. lable: "矢量",
  101. iconName: "el-icon-picture",
  102. isSelect: false,
  103. }, {
  104. index: 5,
  105. lable: "联级查询",
  106. iconName: "el-icon-c-scale-to-original",
  107. isSelect: false,
  108. },
  109. {
  110. index: 3,
  111. lable: "清除",
  112. iconName: "el-icon-delete",
  113. isSelect: false,
  114. },
  115. ],
  116. };
  117. },
  118. computed: {
  119. PoinyQueryShow: function () {
  120. return store.state.toolBar[9];
  121. },
  122. },
  123. created() { },
  124. watch: {
  125. activeLayerId(val) {
  126. if (val && val != "0") {
  127. for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
  128. let obj = store.state.vectorlayerlist[i];
  129. if (obj.id == val) {
  130. if (obj.type == "S3M") {
  131. this.addGeometrys(true);
  132. } else {
  133. this.addGeometrys();
  134. }
  135. break;
  136. }
  137. }
  138. }
  139. },
  140. PoinyQueryShow(val) {
  141. if (!this.inited) {
  142. this.inited = !this.inited;
  143. this.viewer = viewer;
  144. this.viewer.entities.removeAll();
  145. this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  146. this.dataSourceLayer = new Cesium.CustomDataSource("query");
  147. this.viewer.dataSources.add(this.dataSourceLayer);
  148. }
  149. },
  150. },
  151. mounted() {
  152. this.$nextTick((res) => {
  153. });
  154. },
  155. methods: {
  156. toggleVisibility() {
  157. this.removeMapLayerQuery();
  158. store.setToolBarAction(9);
  159. },
  160. addGeometrys(fill) {
  161. this.viewer.entities.removeAll();
  162. this.dataSourceLayer.entities.removeAll();
  163. let geoms = this.queryResultsGeom[this.activeLayerId];
  164. let parts = this.queryResultsGeomPart[this.activeLayerId];
  165. for (let i = 0; i < geoms.length; i++) {
  166. let cur = geoms[i];
  167. let part = parts[i];
  168. let start = 0;
  169. let end = 0;
  170. for (let k = 0; k < part.length; k++) {
  171. let points = [];
  172. if (k > 0) {
  173. start += part[k - 1];
  174. }
  175. end += part[k];
  176. for (let j = start; j < end; j++) {
  177. let cx = cur[j][0];
  178. let cy = cur[j][1];
  179. points.push(cx);
  180. points.push(cy);
  181. }
  182. if (fill) {
  183. this.viewer.entities.add({
  184. polyline: new Cesium.PolylineGraphics({
  185. positions: Cesium.Cartesian3.fromDegreesArray(points),
  186. width: 3,
  187. material: Cesium.Color.BLUE.withAlpha(0.9),
  188. clampToGround: true,
  189. }),
  190. polygon: {
  191. //高程
  192. hierarchy: new Cesium.PolygonHierarchy(
  193. Cesium.Cartesian3.fromDegreesArray(points)
  194. ),
  195. classificationType: Cesium.ClassificationType.BOTH,
  196. clampToGround: false,
  197. material: Cesium.Color.RED.withAlpha(0.3),
  198. // material: videoElement,
  199. // perPositionHeight: true
  200. },
  201. });
  202. } else {
  203. this.viewer.entities.add({
  204. polyline: new Cesium.PolylineGraphics({
  205. positions: Cesium.Cartesian3.fromDegreesArray(points),
  206. width: 3,
  207. material: Cesium.Color.BLUE.withAlpha(0.9),
  208. clampToGround: true,
  209. }),
  210. });
  211. }
  212. }
  213. // this.viewer.flyTo(this.viewer.entities);
  214. }
  215. },
  216. flyTo(index) {
  217. this.dataSourceLayer.entities.removeAll();
  218. let geoms = this.queryResultsGeom[this.activeLayerId];
  219. let parts = this.queryResultsGeomPart[this.activeLayerId];
  220. let cur = geoms[index];
  221. if (cur) {
  222. let part = parts[index];
  223. let start = 0;
  224. let end = 0;
  225. for (let k = 0; k < part.length; k++) {
  226. let points = [];
  227. if (k > 0) {
  228. start += part[k - 1];
  229. }
  230. end += part[k];
  231. for (let j = start; j < end; j++) {
  232. let cx = cur[j][0];
  233. let cy = cur[j][1];
  234. points.push(cx);
  235. points.push(cy);
  236. }
  237. let e = this.dataSourceLayer.entities.add({
  238. polyline: new Cesium.PolylineGraphics({
  239. positions: Cesium.Cartesian3.fromDegreesArray(points),
  240. width: 3,
  241. material: Cesium.Color.RED.withAlpha(0.9),
  242. clampToGround: true,
  243. }),
  244. });
  245. }
  246. this.viewer.flyTo(this.dataSourceLayer);
  247. } else {
  248. this.$message({
  249. message: "空间范围为空!",
  250. type: "warning",
  251. });
  252. }
  253. },
  254. handleTabClick(item, a) {
  255. this.activeLayerId = item.name;
  256. console.log('this.: ', this.activeLayerId);
  257. },
  258. // 设置数据
  259. setData() {
  260. this.dataSourceLayer = new Cesium.CustomDataSource("query");
  261. this.viewer.dataSources.add(this.dataSourceLayer);
  262. this.activeLayerId = "0";
  263. this.queryResults = {};
  264. this.queryResultsGeom = {};
  265. this.queryResultsGeomPart = {};
  266. },
  267. /**
  268. * 左键点击查询图层
  269. */
  270. async mapLayerQuery(movement) {
  271. let that = this;
  272. that.activeLayerId = "0";
  273. that.layerList = [];
  274. that.layersData = [];
  275. let scene = viewer.scene;
  276. that.viewer.entities.removeAll();
  277. that.dataSourceLayer.entities.removeAll();
  278. //拾取模型
  279. let pickedFeature = scene.pick(movement.position);
  280. if (
  281. scene.pickPositionSupported &&
  282. Cesium.defined(pickedFeature) &&
  283. pickedFeature != null &&
  284. pickedFeature.primitive
  285. ) {
  286. let eneityName = pickedFeature.primitive.name;
  287. let Pid = "";
  288. var tempArr = [];
  289. // "ResultNetWork@管线#1"///"ResultNetWork_Node@管线#1"
  290. if (eneityName.indexOf("雨水") > -1) {
  291. let buildingLayer = scene.layers.find(eneityName);
  292. buildingLayer.indexedDBSetting.isAttributesSave = true; //保存属性
  293. if (buildingLayer.getSelection().length > 0) {
  294. const selectedId = Number(buildingLayer.getSelection()[0]);
  295. buildingLayer.getAttributesById([selectedId]).then(function (atts) {
  296. if (atts) {
  297. Pid = atts["管线段"] || atts["物探点"];
  298. var length = Object.keys(atts).length;
  299. var des;
  300. for (var i = 0; i < length; i++) {
  301. var key = Object.keys(atts)[i];
  302. var value = atts[key];
  303. // console.log(key);
  304. // console.log(value);
  305. if (
  306. key.toLowerCase().indexOf("shape") < 0 &&
  307. key.toLowerCase().indexOf("sm") &&
  308. value != ""
  309. ) {
  310. tempArr.push({
  311. name: key,
  312. value: value,
  313. });
  314. }
  315. }
  316. }
  317. //获取图层id的参数
  318. let substring = pickedFeature.primitive._baseUri.query;
  319. for (let p = 0; p < store.state.vectorlayerlist.length; i++) {
  320. if (store.state.vectorlayerlist[p].id == substring) {
  321. that.layerList.push(store.state.vectorlayerlist[p]);
  322. break;
  323. }
  324. }
  325. that.queryResults[substring] = [tempArr];
  326. that.queryResultsGeom[substring] = [];
  327. that.activeLayerId = substring;
  328. });
  329. }
  330. }
  331. that.loading = true;
  332. that.queryByPickFeature(pickedFeature, function (result, Fields) {
  333. that.loading = false;
  334. if (result != null && result.features[0].fieldNames) {
  335. result.features[0].fieldNames.forEach((fieldName, i) => {
  336. const Field = Fields.find((c) => c.FieldEn == fieldName);
  337. let v = result.features[0].fieldValues[i];
  338. if (!isNaN(parseFloat(v))) {
  339. v = Math.round(parseFloat(v) * 100) / 100;
  340. }
  341. that.layersData.push({
  342. label: Field ? Field.FieldCn : fieldName,
  343. value: v,
  344. });
  345. });
  346. } else {
  347. that.layersData = [];
  348. }
  349. });
  350. } else {
  351. //拾取图层
  352. // let pickRay = viewer.camera.getPickRay(movement.position);
  353. // let artesian3 = viewer.scene.globe.pick(pickRay, viewer.scene);
  354. let artesian3 = viewer.scene.pickPosition(movement.position);
  355. let xy = that.cartesian3ToWGS84(artesian3);
  356. //TODO wanger 分图层查询
  357. for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
  358. let obj = store.state.vectorlayerlist[i];
  359. if (!obj.source) {
  360. continue;
  361. }
  362. let queryByIDParameters = {
  363. getFeatureMode: "BUFFER",
  364. // getFeatureMode: "SPATIAL",
  365. spatialQueryMode: "INTERSECT",
  366. datasetNames: obj.source.split(","),
  367. geometry: {
  368. parts: [1],
  369. points: [{ y: xy.lat, x: xy.lng }],
  370. type: "POINT",
  371. },
  372. bufferDistance: 0.00005,
  373. hasGeometry: true,
  374. };
  375. let e;
  376. if (obj.type == "S3M") {
  377. e = await that.mapQuery(
  378. window.baseModelQueryLayer,
  379. queryByIDParameters
  380. );
  381. } else {
  382. e = await that.mapQuery(
  383. that.calcIserverURI(obj.url),
  384. queryByIDParameters
  385. );
  386. }
  387. if (e && e.totalCount > 0) {
  388. that.layerList.push(store.state.vectorlayerlist[i]);
  389. let queryData = [];
  390. let geoms = [];
  391. let tempTreeData = store.state.tempResourceTree;
  392. //递归查询点击的图层信息
  393. function getTreeId(list, id) {
  394. //判断list是否是数组
  395. if (!list instanceof Array) {
  396. return null;
  397. }
  398. //遍历数组
  399. for (let i in list) {
  400. let item = list[i];
  401. if (item.id === id) {
  402. return item;
  403. } else {
  404. //查不到继续遍历
  405. if (item.children) {
  406. let value = getTreeId(item.children, id);
  407. //查询到直接返回
  408. if (value) {
  409. return value;
  410. }
  411. }
  412. }
  413. }
  414. }
  415. let parts = [];
  416. let legendJson = getTreeId(tempTreeData, obj.id);
  417. for (let u = 0; u < e.features.length; u++) {
  418. let cur = [];
  419. if (legendJson.legend != "") {
  420. //将数据转为json
  421. let parseJson = JSON.parse(legendJson.legend);
  422. //初始化下标
  423. let index = -1;
  424. var linSAr = JSON.parse(JSON.stringify(e.features[u]));
  425. parseJson.forEach((p) => {
  426. //将数据改为大写
  427. p.fieldname = p.fieldname.toUpperCase();
  428. let index1 = linSAr.fieldNames.indexOf(p.fieldname);
  429. if (index1 > -1 && !condition(p)) {
  430. this.$delete(linSAr.fieldNames, index1);
  431. this.$delete(linSAr.fieldValues, index1);
  432. }
  433. //判断数据是否存在
  434. index = linSAr.fieldNames.indexOf(p.fieldname);
  435. if (index > -1 && p.fieldaliasname != p.fieldname) {
  436. //如果数据存在数组中并且进行了修改,找到它对应的下标对数据进行替换
  437. linSAr.fieldNames[index] = p.fieldaliasname;
  438. }
  439. });
  440. } else {
  441. var linSAr = JSON.parse(JSON.stringify(e.features[u]));
  442. }
  443. function condition(ci) {
  444. return ci.status != undefined && ci.status;
  445. }
  446. if (e.features[u].fieldNames) {
  447. linSAr.fieldNames.forEach((fieldName, i) => {
  448. if (linSAr.fieldValues[i] != "") {
  449. let v = linSAr.fieldValues[i];
  450. if (!isNaN(parseFloat(v))) {
  451. v = Math.round(parseFloat(v) * 100) / 100;
  452. }
  453. cur.push({
  454. name: fieldName,
  455. value: v,
  456. });
  457. }
  458. });
  459. // e.features[u].fieldNames.forEach((fieldName, i) => {
  460. // if (
  461. // fieldName.toLowerCase().indexOf("shape") < 0 &&
  462. // fieldName.toLowerCase().indexOf("sm") &&
  463. // e.features[u].fieldValues[i] != ""
  464. // ) {
  465. // let v = e.features[u].fieldValues[i];
  466. // if (!isNaN(parseFloat(v))) {
  467. // v = Math.round(parseFloat(v) * 100) / 100;
  468. // }
  469. // cur.push({
  470. // name: fieldName,
  471. // value: v,
  472. // });
  473. // }
  474. // });
  475. } else {
  476. that.$message({
  477. message: "查询结果为空!",
  478. type: "warning",
  479. customClass: "messageIndex",
  480. });
  481. }
  482. //排序 将value值为空串的数据放到列表最后
  483. // cur.sort((a, b) => {
  484. // if (a === b) {
  485. // return 0;
  486. // } else if (a.value == null || a.value == "") {
  487. // return 1;
  488. // } else if (b.value == null || b.value == "") {
  489. // return -1;
  490. // } else {
  491. // // 降序
  492. // return a.value < b.value ? 1 : -1;
  493. // }
  494. // });
  495. let points = [];
  496. for (let y = 0; y < e.features[u].geometry.points.length; y++) {
  497. let c = that.cartesianToCartographic84(
  498. e.features[u].geometry.points[y].x,
  499. e.features[u].geometry.points[y].y
  500. );
  501. points.push([c.x, c.y]);
  502. }
  503. parts.push(e.features[u].geometry.parts);
  504. geoms.push(points);
  505. queryData.push(cur);
  506. }
  507. that.queryResultsGeomPart[obj.id] = parts;
  508. that.queryResults[obj.id] = queryData;
  509. that.queryResultsGeom[obj.id] = geoms;
  510. }
  511. }
  512. if (that.layerList.length > 0) {
  513. that.activeLayerId = that.layerList[0].id;
  514. } else {
  515. that.$message({
  516. message: "查询结果为空!",
  517. type: "warning",
  518. customClass: "messageIndex",
  519. });
  520. }
  521. }
  522. },
  523. addLayerList(label) {
  524. if (this.layerList.findIndex((a) => a.label == label) >= 0) return;
  525. let layers = store.state.vectorlayerlist.filter(
  526. (element) => element.label === label
  527. );
  528. if (layers.length > 0) {
  529. this.activeLayerId = layers[0].id;
  530. this.layerList.push(layers[0]);
  531. }
  532. },
  533. /**
  534. * 左键点击模型查询
  535. */
  536. mapModelQuery(movement) {
  537. this.activeLayerId = "0";
  538. this.layerList = [];
  539. this.layersData = [];
  540. this.viewer.entities.removeAll();
  541. this.dataSourceLayer.entities.removeAll();
  542. let title;
  543. if (store.state.checkedData) title = store.state.checkedData.title;
  544. // 超图分层分户
  545. if (title == "分层分户") {
  546. let id = handModel(movement);
  547. } else {
  548. handnew(movement);
  549. }
  550. let newArr = [];
  551. GetHouseInfo({ id: "2c01647f-4533-4472-b20b-f5caa4c705b0" }).then(
  552. (res) => {
  553. for (const [key, value] of Object.entries(res.data)) {
  554. newArr.push({ name: keyName[key], value: value });
  555. }
  556. this.addLayerList(title);
  557. this.queryResults[this.activeLayerId] = [newArr];
  558. this.queryResultsGeom[this.activeLayerId] = [];
  559. }
  560. );
  561. },
  562. mapQuerys(queryName) {
  563. this.setData();
  564. let that = this;
  565. this.handler.setInputAction(function (movement) {
  566. that[queryName](movement);
  567. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  568. this.handler.setInputAction(function () {
  569. that.removeMapLayerQuery();
  570. clearTranslate();
  571. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  572. },
  573. /**
  574. * 超图
  575. * 根据返回的三维对象查询数据信息
  576. *
  577. * @param {*} param
  578. */
  579. async queryByPickFeature(param, completed) {
  580. if (param.primitive) {
  581. let dataUrl = "";
  582. let datasourceName = "";
  583. let Fields = [];
  584. for (const layerData of this.layersDataUrl) {
  585. for (const datasource of layerData.datasources) {
  586. if (datasource.Name3D == param.primitive.name) {
  587. dataUrl = layerData.url;
  588. datasourceName = datasource.DataName;
  589. Fields = datasource.Fields;
  590. break;
  591. }
  592. }
  593. }
  594. let queryByIDParameters = {
  595. getFeatureMode: "ID",
  596. datasetNames: [datasourceName],
  597. ids: [param.id],
  598. hasGeometry: "false",
  599. };
  600. if (!dataUrl) {
  601. completed(null);
  602. } else {
  603. let e = await this.mapQuery(dataUrl, queryByIDParameters);
  604. if (completed) {
  605. completed(e, Fields);
  606. }
  607. }
  608. }
  609. },
  610. async mapQuery(url, queryObj) {
  611. let response = await axios.post(url, queryObj);
  612. if (response.data.featureCount > 0) {
  613. return response.data;
  614. } else {
  615. return null;
  616. }
  617. },
  618. // 取消左键点击查询
  619. removeMapLayerQuery() {
  620. this.queryResults = {};
  621. this.queryResultsGeom = {};
  622. this.queryResultsGeomPart = {};
  623. this.layerList = [];
  624. this.viewer.entities.removeAll();
  625. this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  626. this.handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  627. this.dataSourceLayer.entities.removeAll();
  628. this.viewer.dataSources.remove(this.dataSourceLayer);
  629. },
  630. /**
  631. * 笛卡尔坐标系转WGS84坐标系(经纬度)
  632. * @author
  633. * @param {object} point 点,笛卡尔坐标{x:x,y:y,z:z}
  634. * @returns {object} -lat: lat, lng: lng, alt: alt
  635. */
  636. cartesian3ToWGS84(point) {
  637. var cartesian3 = new Cesium.Cartesian3(point.x, point.y, point.z);
  638. var cartographic = Cesium.Cartographic.fromCartesian(cartesian3);
  639. var lat = Cesium.Math.toDegrees(cartographic.latitude);
  640. var lng = Cesium.Math.toDegrees(cartographic.longitude);
  641. var alt = cartographic.height;
  642. return {
  643. lat: lat,
  644. lng: lng,
  645. alt: alt,
  646. };
  647. },
  648. /**
  649. * 墨卡托坐标系转WGS84坐标系(经纬度)
  650. * @author
  651. * @param number x
  652. * @param number y
  653. * @returns {object} x: x, y: y, z: z
  654. */
  655. cartesianToCartographic84(x, y) {
  656. let cartesian3InMercator = new Cesium.Cartesian3(x, y, 0);
  657. let mercator = new Cesium.WebMercatorProjection();
  658. let p = mercator.unproject(cartesian3InMercator);
  659. // 将墨卡托坐标转换为WGS84坐标
  660. // let cartesian3InWGS84 =
  661. // Cesium.Ellipsoid.WGS84.cartesianToCartographic(mercator.unproject(cartesian3InMercator));
  662. return {
  663. x: Cesium.Math.toDegrees(p.longitude),
  664. y: Cesium.Math.toDegrees(p.latitude),
  665. z: p.height,
  666. };
  667. },
  668. calcIserverURI(url) {
  669. let uriArr = url.split("/");
  670. uriArr[5] = uriArr[5].replace("map-", "data-");
  671. uriArr[7] = "data";
  672. uriArr[8] = "featureResults.rjson?returnContent=true";
  673. return uriArr.join("/");
  674. },
  675. //地图数据查询事件
  676. changleQueryItem(item) {
  677. switch (item.index) {
  678. case 1: {
  679. this.mapQuerys("mapLayerQuery"); //图层点击事件
  680. break;
  681. }
  682. case 2: {
  683. this.mapQuerys("mapModelQuery");
  684. break;
  685. }
  686. case 3: {
  687. this.removeMapLayerQuery(); //清除
  688. clearTranslate();
  689. break;
  690. }
  691. case 4: {//驾驶舱矢量数据点选查询
  692. pick_cockpit_vector.init_handler();
  693. break;
  694. } case 5: {//联级查询
  695. pick_cockpit_vector.init_handler();
  696. break;
  697. }
  698. default:
  699. break;
  700. }
  701. },
  702. },
  703. beforeDestroy() {
  704. this.removeMapLayerQuery();
  705. clearTranslate();
  706. },
  707. };
  708. </script>
  709. <style>
  710. .cockpit_vector {
  711. position: absolute;
  712. top: 6rem;
  713. }
  714. .sm-function-module-content-btn {
  715. text-align: center;
  716. padding-top: 5px;
  717. }
  718. .flyBtn2 {
  719. position: absolute;
  720. right: 47px;
  721. }
  722. .el-tabs__item {
  723. color: white !important;
  724. }
  725. .sm-function-module-content-tabs {
  726. height: 45px;
  727. padding: 1px 5px 0px 5px;
  728. }
  729. .sm-function-module-content-table {
  730. height: 564px;
  731. overflow-y: auto;
  732. padding: 1px 5px 0px 5px;
  733. }
  734. .sm-function-module-query {
  735. /* padding: 5px 10px; */
  736. overflow: hidden;
  737. max-height: 700px;
  738. scrollbar-width: none;
  739. /* firefox */
  740. -ms-overflow-style: none;
  741. /* IE 10+ */
  742. @media (max-width: 1000px) {
  743. margin: 0.8rem 0;
  744. padding: 0 15px;
  745. }
  746. @media (max-width: 750px) {
  747. margin: 0.5rem 0;
  748. padding: 0 10px;
  749. max-height: 410px;
  750. }
  751. @media (max-height: 480px) {
  752. margin: 0.5rem 0;
  753. padding: 0 15px;
  754. max-height: 420px;
  755. max-width: 280px;
  756. }
  757. @media (max-height: 300px) {
  758. margin: 0.5rem 0;
  759. padding: 0 10px;
  760. max-height: 280px;
  761. max-width: 250px;
  762. }
  763. @media (max-height: 250px) {
  764. max-height: 240px;
  765. }
  766. }
  767. </style>
  768. <style lang="scss" scoped>
  769. @import "clickQuery";
  770. </style>