addLayer.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. import { myBridge, previewMapBridge } from "./map.js";
  2. import { getMapToken, getServiceToken } from "@/service/map.js";
  3. // 白膜颜色配置
  4. const locationRenderer = {
  5. type: "simple",
  6. symbol: {
  7. type: "mesh-3d",
  8. symbolLayers: [{
  9. type: "fill",
  10. material: {
  11. color: [255, 255, 255, 1],
  12. colorMixMode: "tint"
  13. },
  14. edges: {
  15. type: 'solid',
  16. color: [0, 0, 0, 0.5],
  17. size: 1
  18. }
  19. }]
  20. }
  21. };
  22. export function invokeParams(ActionName, params) {
  23. console.log('invokeParams', ActionName, params)
  24. getMapToken().then(res => {
  25. let token = res.data.msg[0].Rows[0].token;
  26. myBridge.bridgeContent.Invoke({
  27. 'ActionName': ActionName,
  28. "Parameters": {
  29. token: token,
  30. ...params
  31. }
  32. })
  33. })
  34. }
  35. export function previewInvokeParams(ActionName, params) {
  36. getMapToken().then(res => {
  37. let token = res.data.msg[0].Rows[0].token;
  38. previewMapBridge.bridgeContent.Invoke({
  39. 'ActionName': ActionName,
  40. "Parameters": {
  41. token: token,
  42. ...params
  43. }
  44. })
  45. })
  46. }
  47. async function returnProxyUrl(url) {
  48. let arr = url.split('/');
  49. let username = '';
  50. let password = '';
  51. if (arr.indexOf('MapProxyApi') !== -1) { //不需要授权服务
  52. for (let i = 0; i < arr.length; i++) {
  53. if (arr[i] === 'getSceneServer') {
  54. username = arr[i + 1];
  55. password = arr[i + 2];
  56. const response = await getServiceToken(username, password);
  57. if (response?.data.length > 0) {
  58. arr.splice(i - 1, 4);
  59. return arr.join('/') + '/MapServiceProxy/' + response.data;
  60. }
  61. }
  62. }
  63. } else {
  64. return url
  65. }
  66. }
  67. export function SetBackground() {
  68. invokeParams('SetBackground', {
  69. "opacity": 1,
  70. "color": "transparent",
  71. })
  72. }
  73. export async function AddWhiteMold(visible) { //添加白膜
  74. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/ptgl/05195418");
  75. invokeParams('AddSingleLayer', {
  76. "id": "D8503010320240901",
  77. "title": "全市白模",
  78. "visible": visible,
  79. "opacity": 1,
  80. //"renderer": locationRenderer,
  81. "url": url,
  82. "type": "scene",
  83. })
  84. }
  85. export function addPartWhiteMold(visible) {
  86. invokeParams('AddSingleLayer', {
  87. "id": "whiteMold",
  88. "title": "局部白模",
  89. "visible": visible,
  90. "opacity": 0,
  91. "renderer": locationRenderer,
  92. //"url":"https://serve3d41.gis.cn:6443/geoscene/rest/services/Hosted/jzbm_ljz/SceneServer",
  93. "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9999990120240926",
  94. "type": "scene",
  95. })
  96. }
  97. export function GeometryMeshPrismEffect(params) {
  98. invokeParams('GeometryMeshPrismEffect', {
  99. "status": params.status,
  100. "startHeight": params.startHeight,
  101. "rings": [
  102. [
  103. [
  104. 3764.910326990452,
  105. 8853.749163112263
  106. ],
  107. [
  108. 5715.688477752859,
  109. 8853.749163112263
  110. ],
  111. [
  112. 5715.688477752859,
  113. 6816.1711134560055
  114. ],
  115. [
  116. 3764.910326990452,
  117. 6816.1711134560055
  118. ],
  119. [
  120. 3764.910326990452,
  121. 8853.749163112263
  122. ]
  123. ]
  124. ],
  125. "items": params.items
  126. })
  127. }
  128. export function ThreeGrid(params) {
  129. invokeParams('ThreeGrid', {
  130. "status": params.status,
  131. "size": params.size,
  132. "extent": { minX: 2176, maxX: 6048, minY: -1024, maxY: 1352 },
  133. "height": 1200,
  134. "layerHeight": params.layerHeight,
  135. "animationEnabled": params.animationEnabled
  136. })
  137. }
  138. export function ShowThreeCube(params) {
  139. invokeParams('ShowThreeCube', {
  140. "status": params.status,
  141. "size": params.size,
  142. "points": params.points
  143. })
  144. }
  145. export function ShowThreeCubeDetail(params) {
  146. invokeParams('ShowThreeCubeDetail', {
  147. "id": "paths",
  148. "status": params.status,
  149. "size": params.size,
  150. "points": params.points,
  151. "depthTest": params.depthTest
  152. })
  153. }
  154. export function ShowBuildingThreeCubeByInterface(params) {
  155. invokeParams('ShowBuildingThreeCubeByInterface', {
  156. "status": params.status,
  157. "level": params.level,
  158. "size": params.size
  159. })
  160. }
  161. export function ShowNoFlyThreeCubeByInterface(params) {
  162. invokeParams('ShowNoFlyThreeCubeByInterface', {
  163. "status": params.status,
  164. "level": params.level,
  165. "size": params.size
  166. })
  167. }
  168. export function ShowRoadThreeCubeByInterface(params) {
  169. invokeParams('ShowRoadThreeCubeByInterface', {
  170. "status": params.status,
  171. "level": params.level,
  172. "size": params.size
  173. })
  174. }
  175. export function ShowRiverThreeCubeByInterface(params) {
  176. invokeParams('ShowRiverThreeCubeByInterface', {
  177. "status": params.status,
  178. "level": params.level,
  179. "size": params.size
  180. })
  181. }
  182. export function ShowThreeNet(params) {
  183. invokeParams('ShowThreeNet', {
  184. "status": params.status,
  185. "size": params.size,
  186. "origin": params.origin,
  187. "buffer": params.buffer,
  188. "maxHeight": 120,
  189. "minHeight": 0,
  190. })
  191. }
  192. export function DrawPoint(params) {
  193. invokeParams('Draw', {
  194. "type": "point",
  195. "hasZ": true,
  196. "status": params.status,
  197. "symbol": {
  198. "type": "point-3d",
  199. "symbolLayers": [{
  200. "type": "object",
  201. "width": 20,
  202. "height": 20,
  203. "depth": 20,
  204. "resource": { "primitive": "circle" },
  205. "material": { "color": [0, 255, 0, 0.8] }
  206. }]
  207. }
  208. })
  209. }
  210. export function DrawPath(params) {
  211. invokeParams('Draw', {
  212. "type": "polyline",
  213. "hasZ": true,
  214. "status": params.status,
  215. "path": params.path,
  216. "symbol": {
  217. "type": "line-3d",
  218. "symbolLayers": [
  219. {
  220. "type": "path",
  221. "profile": "circle",
  222. "material": {
  223. "color": [
  224. 0,
  225. 255,
  226. 0,
  227. 0.3
  228. ]
  229. },
  230. "width": 10,
  231. "height": 10
  232. }
  233. ]
  234. }
  235. })
  236. }
  237. export function PathPipe(params) {
  238. invokeParams('PathPipe', {
  239. "status": params.status,
  240. "paths": params.paths,
  241. "color": "#00FF7F",
  242. "pipeRadius": 10
  243. })
  244. }
  245. export function hideFlyGLTF(params) {
  246. invokeParams('FlyGLTF', {
  247. "uavid": params.uavid,
  248. "status": "hide"
  249. })
  250. }
  251. export async function PrismEffectService_sfky(params) {
  252. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9999990220240926") + '/1';
  253. invokeParams('AddSingleLayer', {
  254. "id": "sfky",
  255. "title": "飞行空域",
  256. "visible": params.visible,
  257. "type": "feature",
  258. "opacity": 0.6,
  259. "url": url,
  260. "elevationInfo": {
  261. "mode": "on-the-ground"
  262. },
  263. "renderer": {
  264. "type": "simple",
  265. "symbol": {
  266. "type": "polygon-3d",
  267. "symbolLayers": [{
  268. "type": "extrude",
  269. "size": 120,
  270. "material": {
  271. "color": [
  272. 4, 138, 255,
  273. 1
  274. ],
  275. },
  276. "edges": {
  277. "type": "solid",
  278. "color": [50, 50, 50, 0.5]
  279. }
  280. }]
  281. }
  282. }
  283. })
  284. }
  285. export async function PrismEffectService_jkbhq(params) {
  286. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9999990220240926") + '/0';
  287. invokeParams('AddSingleLayer', {
  288. "id": "jkbhq",
  289. "title": "净空保护区",
  290. "visible": params.visible,
  291. "type": "feature",
  292. "opacity": 0.6,
  293. "url": url,
  294. "elevationInfo": {
  295. "mode": "on-the-ground"
  296. },
  297. "renderer": {
  298. "type": "simple",
  299. "symbol": {
  300. "type": "polygon-3d",
  301. "symbolLayers": [{
  302. "type": "extrude",
  303. "size": 120,
  304. "material": {
  305. "color": [
  306. 255, 0, 0,
  307. 1
  308. ],
  309. },
  310. "edges": {
  311. "type": "solid",
  312. "color": [50, 50, 50, 0.5]
  313. }
  314. }]
  315. }
  316. }
  317. })
  318. }
  319. export async function WaterEffect(params) {
  320. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D0401010120150601") + '/0';
  321. invokeParams('WaterEffect', {
  322. "status": params.status,
  323. "url": url,
  324. "direction": 260,
  325. "strength": "moderate",
  326. "color": "#25427c"
  327. })
  328. }
  329. export function LimitHeightAnalysis(params) {
  330. invokeParams('LimitHeightAnalysis', {
  331. "layerId": "D8503010320240901",
  332. "status": params.status,
  333. "limitH": params.start,
  334. "maxLimitH": params.end,
  335. "rings": [
  336. [
  337. 5734.326828652739,
  338. 8833.735652138346,
  339. 0
  340. ],
  341. [
  342. 3738.5816674344023,
  343. 8812.731486429415,
  344. 0
  345. ],
  346. [
  347. 3783.7974914766223,
  348. 6817.002289960246,
  349. 0
  350. ],
  351. [
  352. 5778.02483719044,
  353. 6840.510219478308,
  354. 0
  355. ]
  356. ]
  357. })
  358. }
  359. //重点区域定位
  360. export function importantAreaPosition(x, y, z, heading, tilt, isfly = true) {
  361. invokeParams('SetLocation', {
  362. "x": x,
  363. "y": y,
  364. "z": z,
  365. "heading": heading,
  366. "tilt": tilt,
  367. "isfly": isfly
  368. })
  369. }
  370. export function FeatureThreeDimension(params) {
  371. if (params.token) {
  372. params.url = "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/" + params.token;
  373. }
  374. invokeParams('FeatureThreeDimension', {
  375. "url": params.url,
  376. "status": params.status
  377. })
  378. }
  379. //区县聚类
  380. export function MapClickByType(status) {
  381. invokeParams('MapClickAll', {
  382. "status": status,
  383. "disableLayerIdList": ["districtArea", "districtStreet", "bgFeaturelayer"]
  384. })
  385. }
  386. //点查询
  387. export function AreaJsonRankShow(params) {
  388. invokeParams('AreaJsonRankShow', {
  389. "type": params.type, //qx、jz
  390. "district": null,
  391. "id": "AreaTextLayer",
  392. "title": "文本标绘",
  393. "status": params.status,
  394. "data": params.data,
  395. "symbol": {
  396. "color": [255, 255, 255, 1],
  397. "backgroundColor": [77, 161, 194, 0.4],
  398. "font": {
  399. "size": 12
  400. }
  401. },
  402. })
  403. }
  404. export function ExtentHeight(height) {
  405. invokeParams('Draw', {
  406. "type": "polygon",
  407. "height": height,
  408. })
  409. }
  410. export async function AddBaseMapLayer() {
  411. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/ptgl/93493321");
  412. invokeParams('AddBaseMapLayer', {
  413. "id": "BaseMap",
  414. "title": "BaseMap",
  415. "visible": true,
  416. "opacity": 1,
  417. url
  418. })
  419. invokeParams('AddSingleLayer', {
  420. "id": "BaseMapCSJYaoGan",
  421. "visible": false,
  422. })
  423. showLayersWithScaleEvents({ status: 'hide' })
  424. }
  425. export async function AddZhenwuMapLayer() {
  426. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/ptgl/37072265");
  427. invokeParams('AddBaseMapLayer', {
  428. "id": "BaseMapZhenwu",
  429. "title": "BaseMapZhenwu",
  430. "visible": true,
  431. "opacity": 1,
  432. url
  433. })
  434. invokeParams('AddSingleLayer', {
  435. "id": "BaseMapCSJYaoGan",
  436. "visible": false,
  437. })
  438. showLayersWithScaleEvents({ status: 'hide' })
  439. }
  440. export async function AddYaoganMapLayer() {
  441. let url = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/ptgl/50115036");
  442. invokeParams('AddBaseMapLayer', {
  443. "id": "BaseMapYaoGan",
  444. "title": "BaseMapYaoGan",
  445. "visible": true,
  446. "opacity": 1,
  447. "type": "tile",
  448. url
  449. });
  450. let CSJUrl = await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9902002720240801");
  451. invokeParams('AddSingleLayer', {
  452. "id": "BaseMapCSJYaoGan",
  453. "title": "BaseMapCSJYaoGan",
  454. "visible": true,
  455. "opacity": 1,
  456. "type": "tile",
  457. url: CSJUrl
  458. })
  459. showLayersWithScaleEvents({ status: 'show' })
  460. }
  461. export function showLayersWithScaleEvents(params) {
  462. invokeParams('ShowLayersWithScaleEvents', {
  463. "status": params.status ? "show" : "hide",
  464. "scale_handle_id": "scale_handle_tileLayerChange",
  465. });
  466. }
  467. //关闭图层
  468. export function clearAllLayer() {
  469. invokeParams('ClearMapLayers', {
  470. })
  471. }
  472. export async function heatMap(params) {
  473. params.url = await returnProxyUrl(params.url) + '/0';
  474. invokeParams('HeatMap', {
  475. id: params.id,
  476. title: params.title,
  477. visible: params.visible,
  478. url: params.url
  479. })
  480. }
  481. export async function AddSingleLayer(params) {
  482. // if(params.token){
  483. // params.url = "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/" + params.token;
  484. // }
  485. params.url = await returnProxyUrl(params.url);
  486. let wkid = "0" // 0 代表上海城建 1:代表3857
  487. if (params.wkid) {
  488. if (params.type == "动态地图" && params.wkid == "1") {
  489. params.type = "dynamic"
  490. }
  491. if (params.type == "切片地图" && params.wkid == "1") {
  492. params.type = "tile"
  493. }
  494. }
  495. if (params.type == "scene" || params.type == '3DObject') {
  496. if (params.title == "全市白模") {
  497. invokeParams('AddSingleLayer', {
  498. "id": params.id,
  499. "title": params.title,
  500. "visible": params.visible,
  501. "opacity": params.opacity,
  502. "url": params.url + '/SceneServer',
  503. "where": 'objectid not in (3941595,3841426)',
  504. "type": "scene",
  505. "theme": "高度",
  506. "popupEnabled": false,
  507. "renderer": {
  508. "type": "class-breaks",
  509. "field": "HEIGHT",
  510. "classBreakInfos": [
  511. {
  512. "minValue": 0,
  513. "maxValue": 10,
  514. "symbol": {
  515. "type": "mesh-3d",
  516. "symbolLayers": [
  517. {
  518. "type": "fill",
  519. "material": {
  520. "color": [55, 135, 192, 0.7],
  521. "colorMixMode": "replace"
  522. },
  523. "edges": {
  524. "type": "solid",
  525. "color": [0, 0, 0, 0.6],
  526. "size": 1
  527. }
  528. }
  529. ]
  530. },
  531. "label": "<10"
  532. }, {
  533. "minValue": 10.1,
  534. "maxValue": 24,
  535. "symbol": {
  536. "type": "mesh-3d",
  537. "symbolLayers": [
  538. {
  539. "type": "fill",
  540. "material": {
  541. "color": [148, 195, 223, 0.7],
  542. "colorMixMode": "replace"
  543. },
  544. "edges": {
  545. "type": "solid",
  546. "color": [0, 0, 0, 0.6],
  547. "size": 1
  548. }
  549. }
  550. ]
  551. },
  552. "label": "10~24"
  553. }, {
  554. "minValue": 24.1,
  555. "maxValue": 100,
  556. "symbol": {
  557. "type": "mesh-3d",
  558. "symbolLayers": [
  559. {
  560. "type": "fill",
  561. "material": {
  562. "color": [230, 238, 251, 0.7],
  563. "colorMixMode": "replace"
  564. },
  565. "edges": {
  566. "type": "solid",
  567. "color": [0, 0, 0, 0.6],
  568. "size": 1
  569. }
  570. }
  571. ]
  572. },
  573. "label": "24~100"
  574. }, {
  575. "minValue": 100.1,
  576. "maxValue": 1000,
  577. "symbol": {
  578. "type": "mesh-3d",
  579. "symbolLayers": [
  580. {
  581. "type": "fill",
  582. "material": {
  583. "color": [235, 240, 249, 0.7],
  584. "colorMixMode": "replace"
  585. },
  586. "edges": {
  587. "type": "solid",
  588. "color": [0, 0, 0, 0.6],
  589. "size": 1
  590. }
  591. }
  592. ]
  593. },
  594. "label": ">100"
  595. }]
  596. },
  597. "mapID": params.mapID
  598. })
  599. } else {
  600. invokeParams('AddSingleLayer', {
  601. "id": params.id,
  602. "title": params.title,
  603. "visible": params.visible,
  604. "opacity": params.opacity,
  605. "url": params.url + '/SceneServer',
  606. "type": "scene",
  607. "popupEnabled": false,
  608. "mapID": params.mapID
  609. })
  610. }
  611. } else if (params.type == "bim") {
  612. switch (params.title) {
  613. case '朱家角车站':
  614. invokeParams('AddSingleLayer',
  615. {
  616. "id": params.id,
  617. "title": params.title,
  618. "visible": params.visible,
  619. "opacity": params.opacity === undefined ? 1 : params.opacity,
  620. "url": params.url,
  621. "elevationInfo": { //下沉高度
  622. mode: "absolute-height",
  623. offset: -19.5
  624. },
  625. "type": "building",
  626. "mapID": params.mapID
  627. })
  628. break;
  629. default:
  630. invokeParams('AddSingleLayer',
  631. {
  632. "id": params.id,
  633. "title": params.title,
  634. "visible": params.visible,
  635. "opacity": params.opacity === undefined ? 1 : params.opacity,
  636. "url": params.url,
  637. "elevationInfo": { //下沉高度
  638. mode: "absolute-height",
  639. offset: -19.5
  640. },
  641. "type": "building",
  642. "mapID": params.mapID
  643. })
  644. break
  645. }
  646. } else if (params.type == 'mesh') {
  647. invokeParams('AddSingleLayer',
  648. {
  649. "id": params.id,
  650. "title": params.title,
  651. "visible": params.visible,
  652. "opacity": params.opacity === undefined ? 1 : params.opacity,
  653. "url": params.url,
  654. //"renderer":locationRenderer,
  655. "type": "mesh",
  656. "mapID": params.mapID
  657. })
  658. return
  659. } else if (params.type == "dynamic") {
  660. invokeParams('AddSingleLayer', {
  661. "id": params.id,
  662. "title": params.title,
  663. "visible": params.visible,
  664. "opacity": params.opacity === undefined ? 1 : params.opacity,
  665. "url": params.url,
  666. // "sublayers": [
  667. // {
  668. // "id": 0
  669. // },{
  670. // "id": 1
  671. // }
  672. // ],
  673. "type": "dynamic",
  674. "mapID": params.mapID
  675. })
  676. } else if (params.type == "tile") {
  677. invokeParams('AddSingleLayer', {
  678. "id": params.id,
  679. "title": params.title,
  680. "visible": params.visible,
  681. "opacity": params.opacity === undefined ? 1 : params.opacity,
  682. "url": params.url,
  683. "type": "tile",
  684. "mapID": params.mapID
  685. })
  686. } else if (params.type == "动态地图") {
  687. invokeParams('AddSingleLayer', {
  688. "id": params.id,
  689. "title": params.title,
  690. "visible": params.visible,
  691. "opacity": params.opacity === undefined ? 1 : params.opacity,
  692. "url": params.url,
  693. "type": "shc_map",
  694. "mapID": params.mapID
  695. })
  696. } else if (params.type == "切片地图") {
  697. let size = [256, 256];
  698. let origin = {
  699. "x": -9080400.0,
  700. "y": 10002300
  701. };
  702. invokeParams('AddSingleLayer',
  703. {
  704. "id": params.id,
  705. "title": params.title,
  706. "visible": params.visible,
  707. "opacity": params.opacity === undefined ? 1 : params.opacity,
  708. "url": params.url,
  709. "type": "shc_tile",
  710. "mapID": params.mapID
  711. })
  712. }
  713. }
  714. export function queryIn2D(params) {
  715. invokeParams('QueryIn2D', params)
  716. }
  717. export function FeaturePolygonPlottingEvent(params) {
  718. invokeParams('FeaturePolygonPlotting', params)
  719. }
  720. export function getRealFlyPoint(params) {
  721. invokeParams('GetRealFlyPoint', params);
  722. }
  723. export function getVirtualFlyPoint(params) {
  724. invokeParams('GetVirtualFlyPoint', params);
  725. }
  726. export function changePointStatus(params) {
  727. invokeParams('ChangePointStatus', params);
  728. }
  729. // 绘制图形:空域划设、起降场划设
  730. export function drawArea(params) {
  731. switch (params.drawType) {
  732. case 'polygon':
  733. case 'rectangle':
  734. case 'circle':
  735. invokeParams('Draw', {
  736. "type": params.drawType,
  737. "hasZ": true,
  738. "status": "show",
  739. "symbol": {
  740. "type": "polygon-3d",
  741. "symbolLayers": [
  742. {
  743. "type": "extrude",
  744. "size": params.height,
  745. "material": {
  746. "color": params.color
  747. }
  748. }
  749. ]
  750. },
  751. "token": "",
  752. })
  753. break;
  754. case 'point': // 圆锥
  755. invokeParams('Draw', {
  756. "type": "point",
  757. "hasZ": true,
  758. "status": "show",
  759. "point": {
  760. "x": 0,
  761. "y": 0,
  762. "z": -10
  763. },
  764. "symbol": {
  765. "type": "point-3d",
  766. "symbolLayers": [
  767. {
  768. "type": "object",
  769. "width": params.topRadius,
  770. "height": params.topRadius,
  771. "depth": params.height,
  772. "anchor": "origin",
  773. "resource": {
  774. "primitive": "inverted-cone"
  775. },
  776. "material": {
  777. "color": params.color
  778. }
  779. }
  780. ]
  781. },
  782. "token": ""
  783. })
  784. break;
  785. case 'mesh': // 圆台
  786. invokeParams('Draw', {
  787. "type": "mesh",
  788. "hasZ": true,
  789. "status": "show",
  790. "symbol": {
  791. "bottomRadius": params.bottomRadius,
  792. "topRadius": params.topRadius,
  793. "height": params.height,
  794. "color": params.color
  795. },
  796. "token": ""
  797. })
  798. break;
  799. case 'funnel': // 漏斗
  800. invokeParams('Draw', {
  801. "type": "funnel",
  802. "hasZ": true,
  803. "status": "show",
  804. "symbol": {
  805. "bottomRadius": params.bottomRadius,
  806. "topRadius": params.topRadius,
  807. "coneHeight": params.topHeight,
  808. "cylinderHeight": params.bottomHeight,
  809. "color": params.color
  810. },
  811. "token": ""
  812. })
  813. break;
  814. }
  815. }
  816. //绘制圆台
  817. export function drawFrustumCone(params) {
  818. invokeParams('GeometryMeshFrustumEffect', {
  819. ...params
  820. })
  821. }
  822. // 航线展示
  823. export function showRoutePath(params) {
  824. invokeParams('PathPipe', {
  825. ...params,
  826. // "id": "1",
  827. // "status": "show",
  828. // "paths": [], //传入路径
  829. "color": params.color,
  830. "intensity": 1.2,
  831. "pipeRadius": 10
  832. })
  833. }
  834. // 航线展示
  835. export function showVritualRoutePath(params) {
  836. invokeParams('PathPipe', {
  837. ...params,
  838. // "id": "1",
  839. // "status": "show",
  840. // "paths": [], //传入路径
  841. "color": params.color,
  842. "intensity": 1.2,
  843. "pipeRadius": 5
  844. })
  845. }
  846. export function symbolPathPipe(params) {
  847. invokeParams('SymbolPathPipe', {
  848. ...params,
  849. // "id": "1",
  850. // "status": "show",
  851. // "paths": [], //传入路径
  852. "color": params.color,
  853. })
  854. }
  855. // 航线展示
  856. export function showRoadPath(params) {
  857. invokeParams('PathPipe', {
  858. ...params,
  859. // "id": "1",
  860. // "status": "show",
  861. // "paths": [], //传入路径
  862. "color": "#438EDB",
  863. "intensity": 1.2,
  864. "pipeRadius": 25
  865. })
  866. }
  867. // 航线规划-自动
  868. export function drawRouteAuto(params) {
  869. invokeParams('Draw', {
  870. "type": "point",
  871. "hasZ": true,
  872. "status": "show",
  873. "clear": false,
  874. "symbol": {
  875. "type": "point-3d",
  876. "symbolLayers": [
  877. {
  878. "type": "object",
  879. "width": 20,
  880. "height": 20,
  881. "depth": 20,
  882. "resource": {
  883. "primitive": "circle"
  884. },
  885. "material": {
  886. "color": params.color
  887. }
  888. }
  889. ]
  890. }
  891. })
  892. }
  893. // 航线规划-手动
  894. export function drawRouteManual(params) {
  895. invokeParams('Draw', {
  896. "type": "polyline",
  897. "hasZ": true,
  898. "status": params.status,
  899. "path": params.path,
  900. "symbol": {
  901. "type": "line-3d",
  902. "symbolLayers": [
  903. {
  904. "type": "path",
  905. "profile": "circle",
  906. "material": {
  907. "color": [
  908. 0,
  909. 149,
  910. 255,
  911. 0.3
  912. ]
  913. },
  914. "width": 10,
  915. "height": 10
  916. }
  917. ]
  918. },
  919. })
  920. }
  921. // 起降场展示
  922. export function showPlot(params) {
  923. invokeParams('FeaturePointsPlotting', {
  924. "status": params.status,
  925. "data": params.data, //传入数据
  926. })
  927. }
  928. // 起降场划设
  929. export function drawPlot(params) {
  930. invokeParams('Draw', {
  931. "type": "circle",
  932. "hasZ": true,
  933. "status": params.status,
  934. "symbol": {
  935. "type": "polygon-3d",
  936. "symbolLayers": [
  937. {
  938. "type": "extrude",
  939. "size": 20,
  940. "material": {
  941. "color": [
  942. 4,
  943. 138,
  944. 255,
  945. 0.3
  946. ]
  947. }
  948. }
  949. ]
  950. }
  951. })
  952. }
  953. //显示网格
  954. export function GetRealPower2(params) {
  955. invokeParams('GetRealPower2', {
  956. id: params.id,
  957. lastId: params.lastId,
  958. status: params.status,
  959. fields: params.fields,
  960. center: params.center,
  961. radius: params.radius,
  962. minZ: params.minZ,
  963. maxZ: params.maxZ,
  964. level: params.level,
  965. size: params.size,
  966. })
  967. }
  968. //碰撞预警
  969. export function pathConflict(params) {
  970. invokeParams('PathConflict', {
  971. status: params.status,
  972. })
  973. }
  974. //避让路线
  975. export function conflict_fly(params) {
  976. invokeParams('Conflict_fly', {
  977. status: params.status,
  978. "uavid": params.uavid,
  979. "skip_route_id": params.skip_route_id,
  980. "distance": params.distance,
  981. })
  982. }
  983. // 态势评估
  984. export function situationAssessment(params) {
  985. invokeParams('SituationAssessment', {
  986. status: params.status
  987. })
  988. }
  989. // 清空绘制
  990. export function clearDraw() {
  991. invokeParams('Draw', {
  992. status: "hide",
  993. })
  994. }
  995. // 空域展示
  996. export function showShapes({ id, data }) {
  997. invokeParams('GeometryMeshEffect', {
  998. id,
  999. status: data ? 'show' : 'hide',
  1000. data
  1001. })
  1002. }
  1003. // 绘制区域
  1004. export function DrawPolygon(params) {
  1005. invokeParams('Draw', {
  1006. type: "polygon",
  1007. clear: true,
  1008. hasZ: params?.hasZ || false,
  1009. token: ""
  1010. })
  1011. }
  1012. // 取消分层
  1013. export function clearLayering(id) {
  1014. invokeParams('FeaturePolygonPlotting', {
  1015. id,
  1016. status: "hide",
  1017. token: ""
  1018. })
  1019. }
  1020. // 绘制分层
  1021. export function drawLayering(params) {
  1022. const heightArr = params.height.split(',').map(h => Number(h))
  1023. invokeParams('FeaturePolygonPlotting', {
  1024. "id": params.id,
  1025. "status": "show",
  1026. "showText": true,
  1027. "data": [
  1028. {
  1029. "attributes": {
  1030. "FID": params.id,
  1031. "id": params.id,
  1032. "name": ""
  1033. },
  1034. "symbol": {
  1035. "height": heightArr[0],
  1036. "size": heightArr[1] - heightArr[0],
  1037. "color": params.color
  1038. },
  1039. "geometry": {
  1040. rings: params.rings.map(s => {
  1041. return s.map(p => {
  1042. return [...p, heightArr[0]]
  1043. })
  1044. })
  1045. }
  1046. }
  1047. ],
  1048. "token": ""
  1049. })
  1050. }
  1051. // 核查网格
  1052. export function InspectCube(params) {
  1053. const actionMap = {
  1054. 'polygon': 'GetPrismCube',
  1055. 'funnel': 'GetFunnelCube',
  1056. 'frustum-cone': 'GetFrustumConeCube',
  1057. 'inverted-cone': 'GetInvertedConeCube',
  1058. 'polyline': 'GetPathCube',
  1059. }
  1060. if (!actionMap[params?.type]) return
  1061. invokeParams(actionMap[params.type], {
  1062. id: params.id.toString(),
  1063. status: params.show ? 'show' : 'hide',
  1064. level: 23,
  1065. token: "",
  1066. ...params.shape
  1067. })
  1068. }
  1069. // 栅格占用查询、空域剖面查询
  1070. export function QueryCube(params) {
  1071. invokeParams(params.evaluation ? 'GetPowerCube' : 'GetOccupyCube', {
  1072. id: params.id || 'QueryCube',
  1073. status: params.show ? 'show' : 'hide',
  1074. level: params.level,
  1075. minZ: params.minZ,
  1076. maxZ: params.maxZ,
  1077. rings: params.rings,
  1078. token: "",
  1079. })
  1080. }
  1081. // 查询行政区划
  1082. export function QueryDistrict(districtArr) {
  1083. const type = districtArr.length === 1 ? "区县" : "街道"
  1084. invokeParams('QueryIn2D', {
  1085. type,
  1086. where: `${type}名称='${districtArr.at(-1)}'`,
  1087. token: ""
  1088. })
  1089. }
  1090. // 比例尺无极切换(空域栅格)
  1091. export function addKysgScale(show) {
  1092. invokeParams('ShowLayersWithScaleEvents', {
  1093. "status": show ? "show" : 'hide',
  1094. "scale_handle_id": "scale_handle_cube",
  1095. "token": ""
  1096. })
  1097. }