clickQuery.vue 25 KB

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