addLayer.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. import { wait } from '../tools.js'
  2. import { myBridge } from './map.js'
  3. import { getMapToken, getServiceToken } from '@/service/map.js'
  4. import useLayoutStore from '@/store/layout.js'
  5. export function invokeParams(ActionName, params) {
  6. console.log('invokeParams', ActionName, params)
  7. myBridge.bridgeContent.Invoke({
  8. ActionName: ActionName,
  9. Parameters: {
  10. ...params,
  11. },
  12. })
  13. }
  14. async function returnProxyUrl(url) {
  15. let arr = url.split('/')
  16. let username = ''
  17. let password = ''
  18. if (arr.indexOf('MapProxyApi') !== -1) {
  19. //不需要授权服务
  20. for (let i = 0; i < arr.length; i++) {
  21. if (arr[i] === 'getSceneServer') {
  22. username = arr[i + 1]
  23. password = arr[i + 2]
  24. const response = await getServiceToken(username, password)
  25. if (response?.data.length > 0) {
  26. arr.splice(i - 1, 4)
  27. return arr.join('/') + '/MapServiceProxy/' + response.data
  28. }
  29. }
  30. }
  31. } else {
  32. return url
  33. }
  34. }
  35. //重点区域定位
  36. export function importantAreaPosition(x, y, z, heading, tilt, isfly = true) {
  37. invokeParams('SetLocation', {
  38. x: x,
  39. y: y,
  40. z: z,
  41. heading: heading,
  42. tilt: tilt,
  43. isfly: isfly,
  44. })
  45. }
  46. export async function AddBaseMapLayer() {
  47. //let url = await returnProxyUrl('https://192.168.2.140:6443/geoscene/rest/services/JC_dark/MapServer')
  48. invokeParams('AddBaseMapLayer', {
  49. id: 'BaseMap',
  50. title: 'BaseMap',
  51. visible: true,
  52. opacity: 1,
  53. url: 'https://192.168.2.140:6443/geoscene/rest/services/JC_dark/MapServer',
  54. })
  55. }
  56. export async function AddZhenwuMapLayer() {
  57. //let url = await returnProxyUrl('https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/ptgl/37072265')
  58. invokeParams('AddBaseMapLayer', {
  59. id: 'BaseMapZhenwu',
  60. title: 'BaseMapZhenwu',
  61. visible: true,
  62. opacity: 1,
  63. url: 'https://192.168.2.140:6443/geoscene/rest/services/JC_white/MapServer',
  64. })
  65. }
  66. export async function AddYaoganMapLayer() {
  67. //let url = 'https://gisser.china-gis.com/geoserver/rest/services/Hosted/WT_HP/MapServer'
  68. invokeParams('AddBaseMapLayer', {
  69. id: 'BaseMapYaoGan',
  70. title: 'BaseMapYaoGan',
  71. visible: true,
  72. opacity: 1,
  73. type: 'tile',
  74. url: 'https://192.168.2.140:6443/geoscene/rest/services/WT_HP/MapServer',
  75. })
  76. }
  77. export function showLayersWithScaleEvents(params) {
  78. invokeParams('ShowLayersWithScaleEvents', {
  79. status: params.status ? 'show' : 'hide',
  80. scale_handle_id: 'scale_handle_tileLayerChange',
  81. })
  82. }
  83. export async function AddSingleLayer(params) {
  84. // if(params.token){
  85. // params.url = "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/" + params.token;
  86. // }
  87. params.url = await returnProxyUrl(params.url)
  88. let wkid = '0' // 0 代表上海城建 1:代表3857
  89. if (params.wkid) {
  90. if (params.type == '动态地图' && params.wkid == '1') {
  91. params.type = 'dynamic'
  92. }
  93. if (params.type == '切片地图' && params.wkid == '1') {
  94. params.type = 'tile'
  95. }
  96. }
  97. if (params.type == 'scene' || params.type == '3DObject') {
  98. if (params.title == '全市白模') {
  99. invokeParams('AddSingleLayer', {
  100. id: params.id,
  101. title: params.title,
  102. visible: params.visible,
  103. opacity: 1,
  104. url: params.url + '/SceneServer',
  105. where: 'objectid not in (18797)',
  106. type: 'scene',
  107. theme: '高度',
  108. popupEnabled: false,
  109. elevationInfo: {
  110. //下沉高度
  111. mode: 'absolute-height',
  112. offset: -3.5,
  113. },
  114. renderer: {
  115. type: 'simple',
  116. symbol: {
  117. type: 'mesh-3d',
  118. symbolLayers: [
  119. {
  120. type: 'fill',
  121. material: {
  122. //color: [102, 167, 219, 0.9],
  123. color: [255, 255, 255, 1],
  124. colorMixMode: 'replace',
  125. },
  126. },
  127. ],
  128. },
  129. },
  130. mapID: params.mapID,
  131. })
  132. } else if (params.title == '东方明珠') {
  133. invokeParams('AddSingleLayer', {
  134. id: params.id,
  135. title: params.title,
  136. visible: params.visible,
  137. opacity: 1,
  138. url: params.url + '/SceneServer',
  139. type: 'scene',
  140. elevationInfo: {
  141. //下沉高度
  142. mode: 'absolute-height',
  143. offset: -3.5,
  144. },
  145. mapID: params.mapID,
  146. })
  147. } else {
  148. invokeParams('AddSingleLayer', {
  149. id: params.id,
  150. title: params.title,
  151. visible: params.visible,
  152. opacity: params.opacity,
  153. url: params.url + '/SceneServer',
  154. type: 'scene',
  155. popupEnabled: false,
  156. mapID: params.mapID,
  157. })
  158. }
  159. } else if (params.type == 'bim') {
  160. switch (params.title) {
  161. case '朱家角车站':
  162. invokeParams('AddSingleLayer', {
  163. id: params.id,
  164. title: params.title,
  165. visible: params.visible,
  166. opacity: params.opacity === undefined ? 1 : params.opacity,
  167. url: params.url,
  168. elevationInfo: {
  169. //下沉高度
  170. mode: 'absolute-height',
  171. offset: -19.5,
  172. },
  173. type: 'building',
  174. mapID: params.mapID,
  175. })
  176. break
  177. default:
  178. invokeParams('AddSingleLayer', {
  179. id: params.id,
  180. title: params.title,
  181. visible: params.visible,
  182. opacity: params.opacity === undefined ? 1 : params.opacity,
  183. url: params.url,
  184. elevationInfo: {
  185. //下沉高度
  186. mode: 'absolute-height',
  187. offset: -19.5,
  188. },
  189. type: 'building',
  190. mapID: params.mapID,
  191. })
  192. break
  193. }
  194. } else if (params.type == 'mesh') {
  195. invokeParams('AddSingleLayer', {
  196. id: params.id,
  197. title: params.title,
  198. visible: params.visible,
  199. opacity: params.opacity === undefined ? 1 : params.opacity,
  200. url: params.url,
  201. //"renderer":locationRenderer,
  202. type: 'mesh',
  203. mapID: params.mapID,
  204. })
  205. return
  206. } else if (params.type == 'dynamic') {
  207. invokeParams('AddSingleLayer', {
  208. id: params.id,
  209. title: params.title,
  210. visible: params.visible,
  211. opacity: params.opacity === undefined ? 1 : params.opacity,
  212. url: params.url,
  213. // "sublayers": [
  214. // {
  215. // "id": 0
  216. // },{
  217. // "id": 1
  218. // }
  219. // ],
  220. type: 'dynamic',
  221. mapID: params.mapID,
  222. })
  223. } else if (params.type == 'tile') {
  224. invokeParams('AddSingleLayer', {
  225. id: params.id,
  226. title: params.title,
  227. visible: params.visible,
  228. opacity: params.opacity === undefined ? 1 : params.opacity,
  229. url: params.url,
  230. type: 'tile',
  231. mapID: params.mapID,
  232. })
  233. } else if (params.type == '动态地图') {
  234. invokeParams('AddSingleLayer', {
  235. id: params.id,
  236. title: params.title,
  237. visible: params.visible,
  238. opacity: params.opacity === undefined ? 1 : params.opacity,
  239. url: params.url,
  240. type: 'shc_map',
  241. mapID: params.mapID,
  242. })
  243. } else if (params.type == '切片地图') {
  244. let size = [256, 256]
  245. let origin = {
  246. x: -9080400.0,
  247. y: 10002300,
  248. }
  249. invokeParams('AddSingleLayer', {
  250. id: params.id,
  251. title: params.title,
  252. visible: params.visible,
  253. opacity: params.opacity === undefined ? 1 : params.opacity,
  254. url: params.url,
  255. type: 'shc_tile',
  256. mapID: params.mapID,
  257. })
  258. }
  259. }
  260. // 清空绘制
  261. export function clearDraw() {
  262. invokeParams('Draw', {
  263. status: 'hide',
  264. })
  265. }
  266. // 空域展示
  267. export function showShapes({ id, data }) {
  268. invokeParams('GeometryMeshEffect', {
  269. id,
  270. status: data ? 'show' : 'hide',
  271. data,
  272. })
  273. }
  274. // 绘制区域
  275. export function DrawPolygon(params) {
  276. invokeParams('Draw', {
  277. type: 'polygon',
  278. clear: true,
  279. hasZ: params?.hasZ || false,
  280. token: '',
  281. })
  282. }
  283. // 核查网格
  284. export function InspectCube(params) {
  285. const actionMap = {
  286. polygon: 'GetPrismCube',
  287. funnel: 'GetFunnelCube',
  288. 'frustum-cone': 'GetFrustumConeCube',
  289. 'inverted-cone': 'GetInvertedConeCube',
  290. polyline: 'GetPathCube',
  291. }
  292. if (!actionMap[params?.type]) return
  293. invokeParams(actionMap[params.type], {
  294. id: params.id.toString(),
  295. status: params.show ? 'show' : 'hide',
  296. token: '',
  297. ...params.shape,
  298. })
  299. }
  300. // 栅格占用查询、空域剖面查询
  301. export function QueryCube(params) {
  302. invokeParams(params.evaluation ? 'GetPowerCube' : 'GetOccupyCube', {
  303. id: params.id || 'QueryCube',
  304. status: params.show ? 'show' : 'hide',
  305. deepShow: params.deepShow ? params.deepShow : false,
  306. level: params.level,
  307. minZ: params.minZ,
  308. maxZ: params.maxZ,
  309. rings: params.rings,
  310. token: '',
  311. })
  312. }
  313. // 分类核查网格(航线)
  314. export function InspectPathCube(params) {
  315. invokeParams('ShowThreeCubeDetail', {
  316. id: params.id,
  317. status: params.show ? 'show' : 'hide',
  318. points: params.points,
  319. size: params.size,
  320. token: '',
  321. })
  322. }
  323. // 态势航线显隐藏控制
  324. export function toggleMovePath(stauts) {
  325. invokeParams('MovePaths', {
  326. status: stauts ? 'show' : 'hide',
  327. token: '',
  328. })
  329. }
  330. // 态势网格显隐藏控制
  331. export function toggleMoveCube(stauts) {
  332. invokeParams('ShowMovePointCube', {
  333. status: stauts ? 'show' : 'hide',
  334. token: '',
  335. })
  336. }
  337. // 空域点查询
  338. export function toggleFeaturesClickEvent(status) {
  339. invokeParams('AccessFeaturesWithPointEvents', {
  340. status: status ? 'show' : 'hide',
  341. type: 'click',
  342. mouse_time: 500,
  343. popup_title: '悬浮结果',
  344. mouse_handle_id: 'mouse_handle_id',
  345. highlight_handle_id: 'highlight_handle_id',
  346. token: '',
  347. })
  348. }
  349. // 空域栅格修改高度
  350. export function setKysgHeight({ minZ, maxZ }) {
  351. invokeParams('ChangeScaleEventCubeHeight', {
  352. minZ,
  353. maxZ,
  354. token: '',
  355. })
  356. }
  357. // 总体态势
  358. export async function setUavDemo(type, stauts) {
  359. const layoutStore = useLayoutStore()
  360. layoutStore.toggleGlobalLoading(true)
  361. const allTypes = ['SituationAssessment', 'PathConflict', 'UavYawWarning', 'DetectionConflict']
  362. if (stauts) {
  363. allTypes.forEach((t) => {
  364. if (t !== type) {
  365. invokeParams(t, {
  366. status: 'hide',
  367. token: '',
  368. })
  369. }
  370. })
  371. await wait(1000)
  372. invokeParams(type, {
  373. status: 'show',
  374. token: '',
  375. })
  376. } else {
  377. invokeParams(type, {
  378. status: 'hide',
  379. token: '',
  380. })
  381. }
  382. layoutStore.toggleGlobalLoading(false)
  383. }
  384. export function limitHeightAnalysis(params) {
  385. invokeParams('LimitHeightAnalysis', {
  386. status: params.show ? 'show' : 'hide',
  387. layerId: 'D8503010320240901',
  388. limitH: params.minZ,
  389. maxLimitH: params.maxZ,
  390. rings: [
  391. [4929.0513305664, 2427.762878418, 0],
  392. [544.4196777344, 2427.762878418, 0],
  393. [544.4196777344, -1598.4520874023, 0],
  394. [4929.0513305664, -1598.4520874023, 0],
  395. ],
  396. token: '',
  397. })
  398. }