mapJK.vue 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815
  1. <template>
  2. <div id="map_jk">
  3. <div id="mapDiv" ref="map">
  4. <div id="viewDiv" ref="view">
  5. <div id="menu" class="esri-widget">
  6. </div>
  7. </div>
  8. <div id="viewDiv_2D" ref="view_2D">
  9. <div id="menu" class="esri-widget">
  10. </div>
  11. </div>
  12. <div id = "overviewDiv" ref = "overview" >
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import $ from 'jquery';
  19. import {getCurrentInstance, onMounted} from "vue";
  20. import SetMapConfig from "../units/map/SetMapConfig.js"
  21. import InitMap from "../units/map/InitMap.js";
  22. import AddBaseMapLayer from "../units/map/AddBaseMapLayer.js";
  23. import AddSingleLayer from "../units/map/AddSingleLayer.js";
  24. import WaterEffect from "../units/map/WaterEffect.js";
  25. import Measurement from "../units/map/Measurement.js";
  26. import SunshineAnalysis from "../units/map/SunshineAnalysis.js";
  27. import AddPointEvent from "../units/map/AddPointEvent.js";
  28. import SetPopupOptions from "../units/map/SetPopuopOptions";
  29. import AddScaleEvent from "../units/map/AddScaleEvent";
  30. import ViewShedAnalysisWidget from "../units/map/ViewShedAnalysis.js";
  31. import AddLightBallEvent from "../units/map/AddLightBallEvent.js";
  32. import AddThreeGridEvent from "../units/map/addThreeGridEvent.js";
  33. import LimitHeightAnalysis from "../units/map/LimitHeightAnalysis.js";
  34. import SetLocation from "../units/map/SetLocation.js";
  35. import GeometryMeshPrismEffect from "../units/map/GeometryMeshPrismEffect.js";
  36. import ReRenderingEvent from "../units/map/ReRenderingEvent.js";
  37. import PathPipeEvent from "../units/map/PathPipeEvent.js";
  38. import FlyGLTFEvent from "../units/map/FlyGLTFEvent.js";
  39. import AddDrawEvent from "../units/map/addDrawEvent.js";
  40. import SymbolPathPipeEvent from "../units/map/SymbolPathPipeEvent.js";
  41. import SymbolPointCubeEvent from "../units/map/SymbolPointCubeEvent.js";
  42. import AddThreeCubeEvent from "../units/map/AddThreeCubeEvent.js";
  43. import AddThreeCubeDetailEvent from "../units/map/AddThreeCubeDetailEvent.js";
  44. import AddThreeNetEvent from "../units/map/AddThreeNetEvent.js";
  45. import dojoConfig from '../config/tsconfig.json'
  46. import ws from 'ws';
  47. import Path from '../config/path_wjc.json'
  48. import routeList from '../config/routeList.json'
  49. import MoveCar from '../config/moveCar.json'
  50. import {
  51. getAvoidRoute,
  52. getBuildingPoint,
  53. getNoFlyPointInterface, getOccupyPointByPolygon, getPath,
  54. getPowerInterface,
  55. getPowerPoint, getPowerPointByFrustumCone,
  56. getPowerPointByFunnel, getPowerPointByInvertedCone, getPowerPointByPath,
  57. getPowerPointByPolygon, getPowerPointByPrism, getPrism,
  58. getProxyToken, getQJC,
  59. getRiverPointInterface,
  60. getRoadPointInterface,
  61. gridBaseInfo, queryPathsInfo
  62. } from "../service/http.js";
  63. import FeaturePointsPlottingEvent from "../units/map/FeaturePointsPlottingEvent.js";
  64. import FeaturePolygonPlottingEvent from "../units/map/FeaturePolygonPlottingEvent.js";
  65. import HeatMap from "../units/map/HeatMap.js";
  66. import AddGraphicsEvent from "../units/map/AddGraphicsEvent.js";
  67. import GeometryMeshEffect from "../units/map/GeometryMeshEffect.js";
  68. import QueryIn2D from "../units/map/QueryIn2D.js";
  69. import AddFlowPathEvent from "../units/map/AddFlowPathEvent.js";
  70. import MovePointStreamEvent from "../units/map/MovePointStreamEvent.js";
  71. import AddRadarEffectEvent from "../units/map/AddRadarEffect.js";
  72. export default {
  73. name: "mapJK",
  74. setup(){
  75. let socket = null;
  76. let virtualSocket = null;
  77. let flyPointSocket = null;
  78. let ShowMovePointCube = false;
  79. const ctx = getCurrentInstance();
  80. const bus = ctx?.appContext.config.globalProperties.$bus;
  81. let MapReady = null;
  82. let m_spatialReference = null;
  83. let m_fullExtent = null;
  84. let m_initialExtent = null;
  85. let m_view;
  86. let m_map;
  87. let measureWidget = null;
  88. let sunshineWidget = null;
  89. let m_handles = [];
  90. let viewShedAnalysisWidget = null;
  91. let lightBallInstance = {};
  92. let addThreeGridEvent = null;
  93. let addThreeCubeEvent = null;
  94. //let addThreeCubeDetailEvent = null;
  95. let powerDataList = [];
  96. let addThreeCubeDetailInstance = {};
  97. let addThreeNetEvent = null;
  98. let limitHeightAnalysisEvent = null;
  99. let reRenderingEvent = null;
  100. let pathPipeInstance = {};
  101. let flyGLTFInstances = {};
  102. let radarEffectInstance = {};
  103. let addDrawEvent = null;
  104. let draw_GeometryMeshPrismEffectEvent = null;
  105. let symbolPathPipeEvent = null;
  106. let symbolPointCubeEvent = null;
  107. let addGraphicsEvent = null;
  108. let featurePointsPlottingEvent = null;
  109. let currentShowGridParams = null;
  110. let realFlyPointDataQueue = [];
  111. let addFlowPathEvent = null;
  112. let movePointEvent = null;
  113. let currentRealPowerShow = false; //当前是否显示无极网格
  114. let getFixedFlyInstance = {};
  115. let currentRealPowerIds = {
  116. power_wj_15:[],
  117. power_wj_16:[],
  118. power_wj_17:[],
  119. power_wj_18:[],
  120. power_wj_19:[],
  121. power_wj_20:[],
  122. power_wj_21:[],
  123. power_wj_22:[],
  124. power_wj_23:[]
  125. }; //当前无极网格
  126. let currentRealPowerLevel = null; //当前无极网格层级
  127. let popupEnabled = false;
  128. onMounted(() =>{
  129. bus.on('CreateMap',() =>{
  130. MapReady = $.Deferred();
  131. createMap();
  132. $.when((MapReady).done(()=>{
  133. //发送消息
  134. bus.emit('SendMessage',{
  135. action:"MapIsReady",
  136. data:{
  137. "message":"地图初始化完成"
  138. }
  139. })
  140. }))
  141. })
  142. //调用方法
  143. bus.on('InvokeMethod',(data) =>{
  144. invokeMethod(data);
  145. })
  146. function createMap(){
  147. let setMapConfig = new SetMapConfig({
  148. m_spatialReference,
  149. m_fullExtent,
  150. m_initialExtent,
  151. m_handles
  152. })
  153. m_spatialReference = setMapConfig.m_spatialReference;
  154. m_fullExtent = setMapConfig.m_fullExtent;
  155. m_initialExtent = setMapConfig.m_initialExtent;
  156. m_handles = setMapConfig.m_handles;
  157. let initMap = new InitMap({
  158. m_map,
  159. m_view,
  160. m_spatialReference,
  161. bus
  162. });
  163. m_map = initMap.m_map;
  164. m_view = initMap.m_view;
  165. }
  166. function invokeMethod(data){
  167. //后续设置验证token
  168. runMethod(data);
  169. }
  170. function runMethod(data){
  171. let methodname = data.methodname;
  172. let params = data.params;
  173. if(typeof (params) != "string"&& params)
  174. params = eval(params);
  175. switch (methodname) {
  176. case "SetBackground":
  177. setBackground(params);
  178. break;
  179. case "SetLocation":
  180. setLocation(params);
  181. break;
  182. case "AddBaseMapAnSeLayer":
  183. addBaseMapAnSeLayer(params);
  184. break;
  185. case "AddBaseMapSuSeLayer":
  186. addBaseMapSuSeLayer(params);
  187. break;
  188. case "AddYaoGanLayer":
  189. addYaoGanLayer(params);
  190. break;
  191. case "AddWhiteMoldLayer":
  192. addWhiteMoldLayer(params);
  193. break;
  194. case "AddSingleLayer":
  195. addSingleLayer(params);
  196. break;
  197. case "QueryIn2D":
  198. queryIn2D(params);
  199. break;
  200. case "ReRendering":
  201. reRendering(params);
  202. break;
  203. case "WaterEffect":
  204. waterEffect(params);
  205. break;
  206. case "HeatMap":
  207. heatMap(params);
  208. break;
  209. case "ThreeDimensionalHeatMap":
  210. threeDimensionalHeatMap(params);
  211. break;
  212. case "PathCompletion":
  213. pathCompletion(params);
  214. break;
  215. case "Measurement":
  216. measurement(params);
  217. break;
  218. case "SunshineAnalysis":
  219. sunshineAnalysis(params);
  220. break
  221. case "AccessFeaturesWithPointEvents":
  222. accessFeaturesWithPointEvents(params);
  223. break;
  224. case "ShowLayersWithScaleEvents":
  225. showLayersWithScaleEvents(params);
  226. break;
  227. case "ViewshedAnalysis":
  228. viewshedAnalysis(params);
  229. break;
  230. case "FeatureLayerThreeDimension":
  231. featureLayerThreeDimension(params);
  232. break;
  233. case "AddLightBall":
  234. addLightBall(params);
  235. break;
  236. case "ThreeGrid":
  237. threeGrid(params);
  238. break;
  239. case "ShowThreeCube":
  240. showThreeCube(params);
  241. break;
  242. case "ShowThreeCubeDetail":
  243. showThreeCubeDetail(params);
  244. break;
  245. case "GetAllPowerPoints":
  246. getAllPowerPoints(params);
  247. break;
  248. case "ShowBuildingThreeCubeByInterface":
  249. showBuildingThreeCubeByInterface(params);
  250. break;
  251. case "ShowNoFlyThreeCubeByInterface":
  252. showNoFlyThreeCubeByInterface(params);
  253. break;
  254. case "ShowNoFlyThreeCubeDetailByInterface":
  255. showNoFlyThreeCubeDetailByInterface(params);
  256. break;
  257. case "ShowRoadThreeCubeByInterface":
  258. showRoadThreeCubeByInterface(params);
  259. break;
  260. case "ShowRoadThreeCubeDetailByInterface":
  261. showRoadThreeCubeDetailByInterface(params);
  262. break;
  263. case "ShowRiverThreeCubeByInterface":
  264. showRiverThreeCubeByInterface(params);
  265. break;
  266. case "ShowRiverThreeCubeDetailByInterface":
  267. showRiverThreeCubeDetailByInterface(params);
  268. break;
  269. case "ShowThreeNet":
  270. showThreeNet(params);
  271. break;
  272. case "RealPositionGrid":
  273. realPositionGrid(params);
  274. break;
  275. case "LimitHeightAnalysis":
  276. limitHeightAnalysis(params);
  277. break;
  278. case "GeometryMeshPrismEffect":
  279. geometryMeshPrismEffect(params);
  280. break;
  281. case "GeometryMeshEffect":
  282. geometryMeshEffect(params);
  283. break;
  284. case "PathPipe":
  285. pathPipe(params);
  286. break;
  287. case "FlyGLTF":
  288. flyGLTF(params);
  289. break;
  290. case "Draw":
  291. draw(params);
  292. break;
  293. case "Draw_GeometryMeshPrismEffect":
  294. draw_GeometryMeshPrismEffect(params);
  295. break;
  296. case "SymbolPathPipe":
  297. symbolPathPipe(params);
  298. break;
  299. case "SymbolPointCube":
  300. symbolPointCube(params);
  301. break;
  302. case "FeaturePointsPlotting":
  303. featurePointsPlotting(params);
  304. break;
  305. case "FeaturePolygonPlotting":
  306. featurePolygonPlotting(params);
  307. break;
  308. case "GetRealFlyPoint":
  309. getRealFlyPoint(params);
  310. break;
  311. case "GetVirtualFlyPoint":
  312. getVirtualFlyPoint(params);
  313. break;
  314. case "GetFixedFlyPoint":
  315. getFixedFlyPoint(params);
  316. break;
  317. case "ChangePointStatus":
  318. changePointStatus(params);
  319. break;
  320. case "GetRealPower":
  321. getRealPower(params);
  322. break;
  323. case "GetRealPower2":
  324. getRealPower2(params);
  325. break;
  326. case "PathConflict":
  327. pathConflict(params);
  328. break;
  329. case "UavBatteryWarning":
  330. uavBatteryWarning(params);
  331. break;
  332. case "UavYawWarning":
  333. uavYawWarning(params);
  334. break;
  335. case "Conflict_fly":
  336. conflict_fly(params);
  337. break;
  338. case "SituationAssessment":
  339. situationAssessment(params);
  340. break;
  341. case "FlowPathEffect":
  342. flowPathEffect(params);
  343. break;
  344. case "MovePoint":
  345. movePoint(params);
  346. break;
  347. case "MovePaths":
  348. movePaths(params)
  349. break;
  350. case "ShowMovePointCube":
  351. showMovePointCube(params)
  352. break;
  353. case "GetOccupyCube":
  354. getOccupyCube(params);
  355. break;
  356. case "GetPowerCube":
  357. getPowerCube(params);
  358. break;
  359. case "GetFunnelCube":
  360. getFunnelCube(params);
  361. break;
  362. case "GetFrustumConeCube":
  363. getFrustumConeCube(params);
  364. break;
  365. case "GetInvertedConeCube":
  366. getInvertedConeCube(params);
  367. break;
  368. case "GetCylinderCube":
  369. getCylinderCube(params);
  370. break;
  371. case "GetCuboidCube":
  372. getCuboidCube(params);
  373. break;
  374. case "GetPrismCube":
  375. getPrismCube(params);
  376. break;
  377. case "GetPathCube":
  378. getPathCube(params);
  379. break;
  380. case "GetBasePrism":
  381. getBasePrism(params);
  382. break;
  383. case "GetBasePath":
  384. getBasePath(params);
  385. break;
  386. case "GetBaseQJC":
  387. getBaseQJC(params);
  388. break;
  389. case "RadarEffect":
  390. radarEffect(params);
  391. break;
  392. }
  393. }
  394. function setBackground(params){
  395. }
  396. function setLocation(params){
  397. let setLocation = new SetLocation({
  398. view:m_view,
  399. x:params.x,
  400. y:params.y,
  401. z:params.z,
  402. heading:params.heading,
  403. tilt:params.tilt,
  404. isfly:params.isfly,
  405. });
  406. setLocation.start();
  407. }
  408. function addYaoGanLayer(params){
  409. let addSingleLayer = new AddSingleLayer({
  410. m_map,
  411. type:params.type,
  412. id:params.id,
  413. title:params.title,
  414. visible:params.visible,
  415. opacity:params.opacity,
  416. url:"https://192.168.2.140:6443/geoscene/rest/services/WT_HP/MapServer",
  417. where:params.where,
  418. popupEnabled:params.popupEnabled,
  419. renderer:params.renderer,
  420. elevationInfo:params.elevationInfo
  421. })
  422. let layer = addSingleLayer.layer;
  423. m_map.add(layer);
  424. }
  425. function addBaseMapAnSeLayer(params){
  426. let addBaseMapLayer = new AddBaseMapLayer({
  427. id:params.id,
  428. title:params.title,
  429. visible:params.visible,
  430. opacity:params.opacity,
  431. url:"https://serve2d21.gis.cn:6443/geoscene/rest/services/google_shanghai_black/MapServer",
  432. //url:"https://192.168.2.140:6443/geoscene/rest/services/JC_dark/MapServer",
  433. m_spatialReference,
  434. m_fullExtent,
  435. })
  436. m_view.map.basemap = addBaseMapLayer.basemap;
  437. }
  438. function addBaseMapSuSeLayer(params){
  439. let addBaseMapLayer = new AddBaseMapLayer({
  440. id:params.id,
  441. title:params.title,
  442. visible:params.visible,
  443. opacity:params.opacity,
  444. url:"https://192.168.2.140:6443/geoscene/rest/services/JC_white/MapServer",
  445. m_spatialReference,
  446. m_fullExtent,
  447. })
  448. m_view.map.basemap = addBaseMapLayer.basemap;
  449. }
  450. function addWhiteMoldLayer(params){
  451. let addSingleLayer = new AddSingleLayer({
  452. m_map,
  453. type:params.type,
  454. id:params.id,
  455. title:params.title,
  456. visible:params.visible,
  457. opacity:params.opacity,
  458. url: "https://192.168.2.140:6443/geoscene/rest/services/WT_BM/SceneServer",
  459. where:params.where,
  460. popupEnabled:params.popupEnabled,
  461. renderer:params.renderer,
  462. elevationInfo:params.elevationInfo
  463. })
  464. let layer = addSingleLayer.layer;
  465. m_map.add(layer);
  466. }
  467. function addSingleLayer(params){
  468. let addSingleLayer = new AddSingleLayer({
  469. m_map,
  470. type:params.type,
  471. id:params.id,
  472. title:params.title,
  473. visible:params.visible,
  474. opacity:params.opacity,
  475. url: params.url,
  476. where:params.where,
  477. popupEnabled:params.popupEnabled,
  478. renderer:params.renderer,
  479. elevationInfo:params.elevationInfo
  480. })
  481. let layer = addSingleLayer.layer;
  482. m_map.add(layer);
  483. }
  484. async function queryIn2D(params) {
  485. let type = params.type;
  486. let geometry = params.geometry;
  487. let where = params.where;
  488. let url;
  489. let layerId;
  490. if (type === "区县") {
  491. url = await returnProxyUrl(dojoConfig["queryurl_qx_3857"]) + '/0'
  492. layerId = 0;
  493. } else if (type === "街道") {
  494. url = await returnProxyUrl(dojoConfig["queryurl_jd_3857"]) + '/0'
  495. layerId = 0;
  496. }
  497. let queryIn2DInstance = new QueryIn2D({
  498. view: m_view,
  499. map: m_map,
  500. url: url,
  501. layerId: layerId,
  502. geometry: geometry,
  503. where: where
  504. })
  505. let result = await queryIn2DInstance.search();
  506. if(result.length > 0){
  507. bus.emit('SendMessage',{
  508. action:"ReturnResult",
  509. data:{
  510. "message":result
  511. }
  512. })
  513. }
  514. }
  515. async function returnProxyUrl(url){
  516. if(!url){
  517. return;
  518. }
  519. let arr = url.split('/');
  520. let username = '';
  521. let password = '';
  522. if(arr.indexOf('MapProxyApi') !== -1){ //不需要授权服务
  523. for(let i=0;i<arr.length;i++){
  524. if(arr[i] ==='getSceneServer'){
  525. username = arr[i+1];
  526. password = arr[i+2];
  527. const response = await getProxyToken(username,password);
  528. if(response?.data?.length > 0){
  529. arr.splice(i-1, 4);
  530. return arr.join('/')+'/MapServiceProxy/'+response?.data;
  531. }
  532. }
  533. }
  534. }else{
  535. return url
  536. }
  537. }
  538. function getSymbol(params){
  539. return {
  540. type: "mesh-3d",
  541. symbolLayers: [{
  542. type: "fill",
  543. material: {
  544. color: params.color
  545. },
  546. edges: {
  547. type: "solid",
  548. color:[255, 255, 255],
  549. }
  550. }]
  551. };
  552. }
  553. function reRendering(params){
  554. let ids_1 = [];
  555. for(let i=0;i<10000;i++){
  556. ids_1.push(i);
  557. }
  558. let ids_2 = [];
  559. for(let i=10000;i<20000;i++){
  560. ids_2.push(i);
  561. }
  562. let renderer = {
  563. type:"unique-value",
  564. defaultSymbol: getSymbol({color: [0, 255, 0,0.8]}),
  565. defaultLabel: "Other",
  566. field: "OBJECTID",
  567. uniqueValueInfos: [
  568. ]
  569. };
  570. // 每秒更新一次网格颜色
  571. setInterval(() => {
  572. renderer.uniqueValueInfos = []
  573. // 定义分组和对应的颜色
  574. const groups = {
  575. group1: {
  576. ids: ids_1, // 分组1的 ID 列表
  577. color: [Math.floor(Math.random() * 256), Math.floor(Math.random() * 256), Math.floor(Math.random() * 256), 0.8] // 红色
  578. },
  579. group2: {
  580. ids: ids_2, // 分组3的 ID 列表
  581. color: [Math.floor(Math.random() * 256), Math.floor(Math.random() * 256), Math.floor(Math.random() * 256), 0.8] // 蓝色
  582. }
  583. };
  584. // 遍历分组,动态生成渲染规则
  585. Object.keys(groups).forEach(groupKey => {
  586. const group = groups[groupKey];
  587. group.ids.forEach(id => {
  588. renderer.uniqueValueInfos.push({
  589. value: id, // 对应的 ID
  590. symbol: getSymbol(group)
  591. });
  592. });
  593. });
  594. if(reRenderingEvent == null){
  595. reRenderingEvent = new ReRenderingEvent({
  596. m_map,
  597. type:"scene",
  598. id:"WhiteMold",
  599. renderer:renderer
  600. });
  601. }
  602. reRenderingEvent.ReRendering();
  603. }, 5000);
  604. }
  605. function waterEffect(params){
  606. params.id = "waterLayer";
  607. if(params.status === "hide"){
  608. let layer = m_map.layers.find(item => item.id === params.id);
  609. m_map.remove(layer);
  610. return
  611. }
  612. if(params.status === "show"){
  613. let layer = m_map.layers.find(item => item.id === params.id);
  614. if(typeof layer === "undefined"){
  615. let waterEffect = new WaterEffect({
  616. id:params.id,
  617. url:params.url,
  618. waveDirection:params.waveDirection,
  619. waveStrength:params.waveStrength,
  620. color:params.color
  621. })
  622. layer = waterEffect.layer;
  623. m_map.add(layer);
  624. }else{
  625. m_view.environment.lighting.waterReflectionEnabled = true;
  626. const renderer = layer.renderer.clone();
  627. renderer.symbol.symbolLayers.getItemAt(0).waveDirection = params.waveDirection;
  628. renderer.symbol.symbolLayers.getItemAt(0).waveStrength = params.waveStrength;
  629. renderer.symbol.symbolLayers.getItemAt(0).color = params.color;
  630. layer.renderer = renderer;
  631. }
  632. }
  633. }
  634. function heatMap(params){
  635. params.id = "heatMap";
  636. if(!params.visible){
  637. let layer = m_map.layers.find(item => item.id === params.id);
  638. m_map.remove(layer);
  639. return
  640. }
  641. if(params.visible){
  642. let layer = m_map.layers.find(item => item.id === params.id);
  643. if(typeof layer === "undefined"){
  644. let heatMap = new HeatMap({
  645. id:params.id,
  646. url:params.url,
  647. waveDirection:params.waveDirection,
  648. waveStrength:params.waveStrength,
  649. color:params.color
  650. })
  651. layer = heatMap.layer;
  652. m_map.add(layer);
  653. }
  654. }
  655. }
  656. function threeDimensionalHeatMap(params){
  657. let status = params.status;
  658. if(addFlowPathEvent){
  659. addFlowPathEvent.clear();
  660. addFlowPathEvent = null;
  661. }
  662. if(status === "hide"){
  663. return
  664. }
  665. addFlowPathEvent = new AddFlowPathEvent({
  666. view:m_view,
  667. paths:params.paths,
  668. color:params.color,
  669. pipeRadius:params.pipeRadius
  670. })
  671. addFlowPathEvent.start()
  672. }
  673. function pathCompletion(params){
  674. let points = params.points;
  675. let speed1 = params.speed1;
  676. let speed2 = params.speed2;
  677. const result = [];
  678. // 将第一个点添加到结果中
  679. result.push(points[0]);
  680. for (let i = 1; i < points.length; i++) {
  681. const prevPoint = points[i - 1];
  682. const currPoint = points[i];
  683. const distance = Math.sqrt(
  684. Math.pow(currPoint[0] - prevPoint[0], 2) +
  685. Math.pow(currPoint[1] - prevPoint[1], 2) +
  686. Math.pow(currPoint[2] - prevPoint[2], 2)
  687. );
  688. const velocity = prevPoint[2] === currPoint[2] ? speed1 : speed2; // 判断是否是同一高度
  689. // 计算所需的时间
  690. const time = distance / velocity;
  691. const numPoints = Math.floor(time); // 根据时间间隔生成插值点数
  692. for (let j = 1; j <= numPoints; j++) {
  693. // 线性插值,计算插值点
  694. const t = j / (numPoints + 1);
  695. const x = prevPoint[0] + t * (currPoint[0] - prevPoint[0]);
  696. const y = prevPoint[1] + t * (currPoint[1] - prevPoint[1]);
  697. const z = prevPoint[2] + t * (currPoint[2] - prevPoint[2]);
  698. result.push([x, y, z]);
  699. }
  700. // 最后将当前点添加到结果中
  701. result.push(currPoint);
  702. }
  703. console.log("离散的点",result)
  704. return result;
  705. }
  706. function measurement(params){
  707. let status = params.status;
  708. let type = params.type;
  709. let position = params.position;
  710. if(status === "hide"){
  711. if(measureWidget !== null){
  712. m_view.ui.remove(measureWidget);
  713. measureWidget.destroy();
  714. measureWidget = null;
  715. }
  716. return
  717. }
  718. if(status === "show"){
  719. if(measureWidget === null){
  720. let measurement = new Measurement({
  721. view:m_view,
  722. type
  723. })
  724. measureWidget = measurement.widget;
  725. }
  726. m_view.ui.add(measureWidget,position);
  727. }
  728. }
  729. function sunshineAnalysis(params){
  730. let status = params.status;
  731. let position = params.position;
  732. if(status === "hide"){
  733. if(sunshineWidget !== null){
  734. m_view.ui.remove(sunshineWidget);
  735. sunshineWidget.destroy();
  736. sunshineWidget = null;
  737. }
  738. return
  739. }
  740. if(status === "show"){
  741. if(sunshineWidget === null){
  742. let sunshineAnalysis = new SunshineAnalysis({
  743. view:m_view
  744. })
  745. sunshineWidget = sunshineAnalysis.widget;
  746. }
  747. m_view.ui.add(sunshineWidget,position);
  748. }
  749. }
  750. function accessFeaturesWithPointEvents(params){
  751. let status = params.status;
  752. let mouse_handle_id = params.mouse_handle_id;
  753. let highlight_handle_id = params.highlight_handle_id;
  754. if(status === "hide"){
  755. if(m_handles.has(mouse_handle_id)){
  756. m_handles.remove(mouse_handle_id);
  757. }
  758. if(m_handles.has(highlight_handle_id)){
  759. m_handles.remove(highlight_handle_id);
  760. }
  761. return
  762. }
  763. if(status === "show"){
  764. let type = params.type;
  765. let mouseTime = params.mouse_time;
  766. let popupTitle = params.popup_title;
  767. if(m_handles.has(mouse_handle_id)){
  768. m_handles.remove(mouse_handle_id);
  769. }
  770. if(m_handles.has(highlight_handle_id)){
  771. m_handles.remove(highlight_handle_id);
  772. }
  773. if(params.popupEnabled){
  774. popupEnabled = params.popupEnabled;
  775. }
  776. let addPointEvent = new AddPointEvent({
  777. m_view,
  778. type,
  779. highlightHandleId:highlight_handle_id,
  780. mouseTime,
  781. popupTitle,
  782. callbackFunction:accessFeaturesWithPointEventsReturn
  783. });
  784. m_handles.add(addPointEvent.mouseHandle,mouse_handle_id);
  785. }
  786. }
  787. function accessFeaturesWithPointEventsReturn(screenPoint,handleId,popupTitle){
  788. if(m_handles.has(handleId)){
  789. m_handles.remove(handleId);
  790. }
  791. m_view.hitTest(screenPoint).then((response) =>{
  792. if(response.results.length > 0){
  793. let result = response.results[0];
  794. m_view.whenLayerView(result.graphic.layer).then((lyrView) =>{
  795. let highlightHandle = lyrView.highlight(result.graphic);
  796. m_handles.add(highlightHandle,handleId);
  797. })
  798. if(popupEnabled){
  799. let setPopupOptions = new SetPopupOptions({
  800. title:popupTitle,
  801. location:m_view.toMap(screenPoint),
  802. content:result.graphic.attributes
  803. })
  804. m_view.popup.open(setPopupOptions.popupOptions());
  805. }
  806. bus.emit('SendMessage',{
  807. action:"ClickResult",
  808. data:{
  809. "message":result.graphic.attributes
  810. }
  811. })
  812. }
  813. })
  814. }
  815. function showLayersWithScaleEvents(params){
  816. let status = params.status;
  817. let scale_handle_id = params.scale_handle_id;
  818. if(status === "hide"){
  819. if(scale_handle_id === "scale_handle_cube"){
  820. currentRealPowerShow = false;
  821. currentRealPowerIds = {
  822. power_wj_15:[],
  823. power_wj_16:[],
  824. power_wj_17:[],
  825. power_wj_18:[],
  826. power_wj_19:[],
  827. power_wj_20:[],
  828. power_wj_21:[],
  829. power_wj_22:[],
  830. power_wj_23:[]
  831. };
  832. currentRealPowerLevel = null;
  833. closeOtherThreeCubeDetail("power_wj")
  834. }else if(scale_handle_id === "scale_handle_tileLayerChange"){
  835. //暂无操作
  836. }else if(scale_handle_id === "scale_handle_sceneLayerLayerChange"){
  837. //暂无操作
  838. }
  839. if(m_handles.has(scale_handle_id)){
  840. m_handles.remove(scale_handle_id);
  841. }
  842. return
  843. }
  844. if(status === "show"){
  845. if(m_handles.has(scale_handle_id)){
  846. m_handles.remove(scale_handle_id);
  847. }
  848. let addScaleEvent;
  849. if(scale_handle_id === "scale_handle_cube"){
  850. currentRealPowerShow = true;
  851. showCubeWithScaleEventsReturn(m_view.scale);
  852. addScaleEvent = new AddScaleEvent({
  853. m_view,
  854. callBackFunction:showCubeWithScaleEventsReturn
  855. });
  856. }else if(scale_handle_id === "scale_handle_tileLayerChange"){
  857. showTileLayersWithScaleEventsReturn(m_view.scale)
  858. addScaleEvent = new AddScaleEvent({
  859. m_view,
  860. callBackFunction:showTileLayersWithScaleEventsReturn
  861. });
  862. }else if(scale_handle_id === "scale_handle_sceneLayerLayerChange"){
  863. showSceneLayersWithScaleEventsReturn(m_view.scale)
  864. addScaleEvent = new AddScaleEvent({
  865. m_view,
  866. callBackFunction:showSceneLayersWithScaleEventsReturn
  867. });
  868. }
  869. m_handles.add(addScaleEvent.scaleHandle,scale_handle_id);
  870. }
  871. }
  872. //不同比例尺加载白膜
  873. function showSceneLayersWithScaleEventsReturn(scaleValue){
  874. let layer = m_map.layers.find(item => item.id === "WhiteMold");
  875. if(scaleValue > 50000){
  876. if(layer){
  877. layer.visible = false;
  878. }
  879. }else{
  880. if(layer){
  881. layer.visible = true;
  882. }
  883. }
  884. }
  885. //不同比例尺加载长三角瓦片
  886. function showTileLayersWithScaleEventsReturn(scaleValue){
  887. let layer = m_map.layers.find(item => item.id === "BaseMapCSJYaoGan");
  888. if(scaleValue < 150000){
  889. if(layer){
  890. layer.visible = false;
  891. }
  892. }else{
  893. if(layer){
  894. layer.visible = true;
  895. }
  896. }
  897. }
  898. //不同比例尺加载网格
  899. function showCubeWithScaleEventsReturn(scaleValue){
  900. switch (true) {
  901. case (scaleValue > 1500000): //15级以上隐藏
  902. getCurrentRealPower({
  903. status:'hide'
  904. })
  905. currentRealPowerIds = {
  906. power_wj_15:[],
  907. power_wj_16:[],
  908. power_wj_17:[],
  909. power_wj_18:[],
  910. power_wj_19:[],
  911. power_wj_20:[],
  912. power_wj_21:[],
  913. power_wj_22:[],
  914. power_wj_23:[]
  915. };
  916. currentRealPowerLevel = null;
  917. break;
  918. case (scaleValue <= 1500000 && scaleValue > 300000): //15级
  919. currentRealPowerLevel = 15;
  920. getCurrentRealPower({
  921. status:"show",
  922. id:"power_wj",
  923. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  924. center:m_view.center,
  925. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  926. minZ: 0,
  927. maxZ: 1000,
  928. level: 15,
  929. size:{ x: 1582.2726823222256, y: 1856.6079667204758, z: 1724.5956527210265 }
  930. })
  931. break;
  932. case (scaleValue <= 300000 && scaleValue > 150000): //16级
  933. currentRealPowerLevel = 16;
  934. getCurrentRealPower({
  935. status:"show",
  936. id:"power_wj",
  937. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  938. center:m_view.center,
  939. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  940. minZ: 0,
  941. maxZ: 500,
  942. level: 16,
  943. size:{ x: 844.8477050379952, y: 990.1345935064928, z: 862.239544684298 }
  944. })
  945. break;
  946. case (scaleValue <= 150000 && scaleValue > 100000): //17级
  947. currentRealPowerLevel = 17;
  948. getCurrentRealPower({
  949. status:"show",
  950. id:"power_wj",
  951. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  952. center:m_view.center,
  953. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  954. minZ: 0,
  955. maxZ: 200,
  956. level: 17,
  957. size:{ x: 424.0518521273334, y: 492.09123171765896, z: 431.1052029077298 }
  958. })
  959. break;
  960. case (scaleValue <= 100000 && scaleValue > 40000): //18级
  961. currentRealPowerLevel = 18;
  962. getCurrentRealPower({
  963. status:"show",
  964. id:"power_wj",
  965. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  966. center:m_view.center,
  967. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  968. minZ: 0,
  969. maxZ: 100,
  970. level: 18,
  971. size:{ x: 211.66439868324142, y: 246.49964316944533, z: 215.5489592181181 }
  972. })
  973. break;
  974. case (scaleValue <= 40000 && scaleValue > 15000): //19级
  975. currentRealPowerLevel = 19;
  976. getCurrentRealPower({
  977. status:"show",
  978. id:"power_wj",
  979. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  980. center:m_view.center,
  981. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  982. minZ: 0,
  983. maxZ: 100,
  984. level: 19,
  985. size:{ x: 105.79869494173579, y: 123.19232219036257, z: 107.77356906534683 }
  986. })
  987. break;
  988. case (scaleValue <= 15000 && scaleValue > 6000): //20级
  989. currentRealPowerLevel = 20;
  990. getCurrentRealPower({
  991. status:"show",
  992. id:"power_wj",
  993. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  994. center:m_view.center,
  995. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  996. minZ: 0,
  997. maxZ: 50,
  998. level: 20,
  999. size:{ x: 52.887881893650956, y: 61.627412608112536, z: 53.887012166300096 }
  1000. })
  1001. break;
  1002. case (scaleValue <= 6000 && scaleValue > 3000): //21级
  1003. currentRealPowerLevel = 21;
  1004. getCurrentRealPower({
  1005. status:"show",
  1006. id:"power_wj",
  1007. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  1008. center:m_view.center,
  1009. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  1010. minZ: 0,
  1011. maxZ: 30,
  1012. level: 21,
  1013. size:{ x: 26.44107169853396, y: 30.815525255577086, z: 26.943221541824816 }
  1014. })
  1015. break;
  1016. case (scaleValue <= 3000 && scaleValue > 1500): //22级
  1017. currentRealPowerLevel = 22;
  1018. getCurrentRealPower({
  1019. status:"show",
  1020. id:"power_wj",
  1021. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  1022. center:m_view.center,
  1023. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  1024. minZ: 0,
  1025. maxZ: 30,
  1026. level: 22,
  1027. size:{ x: 13.222978864358083, y: 15.406742669116284, z: 13.471596544164798 }
  1028. })
  1029. break;
  1030. case (scaleValue <= 1500): //23级
  1031. currentRealPowerLevel = 23;
  1032. getCurrentRealPower({
  1033. status:"show",
  1034. id:"power_wj",
  1035. fields:["demographics","green","river","road","collision_buffer","no_fly_zone_buffer","clear_zone_buffer"],
  1036. center:m_view.center,
  1037. radius: (m_view.extent.xmax - m_view.extent.xmin) > (m_view.extent.ymax - m_view.extent.ymin) ? (m_view.extent.xmax - m_view.extent.xmin) : (m_view.extent.ymax - m_view.extent.ymin),
  1038. minZ: 0,
  1039. maxZ: 30,
  1040. level: 23,
  1041. size:{ x: 6.7358, y: 7.7024, z: 6.6111 }
  1042. })
  1043. break;
  1044. }
  1045. //加载二维服务
  1046. //showCurrentCubeTileLayer(currentRealPowerLevel)
  1047. }
  1048. async function showCurrentCubeTileLayer(level) {
  1049. let layerList = [15,16,17,18,19,20,21,22,23];
  1050. layerList.forEach((item)=>{
  1051. if (item !== level) {
  1052. addSingleLayer({
  1053. id: "cubeTile"+item,
  1054. type: "tile",
  1055. visible:false,
  1056. })
  1057. }
  1058. })
  1059. if (level === 15) {
  1060. addSingleLayer({
  1061. id: "cubeTile15",
  1062. type: "tile",
  1063. visible:true,
  1064. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031601")
  1065. })
  1066. } else if (level === 16) {
  1067. addSingleLayer({
  1068. id: "cubeTile16",
  1069. type: "tile",
  1070. visible:true,
  1071. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031602")
  1072. })
  1073. } else if (level === 17) {
  1074. addSingleLayer({
  1075. id: "cubeTile17",
  1076. type: "tile",
  1077. visible:true,
  1078. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031603")
  1079. })
  1080. } else if (level === 18) {
  1081. addSingleLayer({
  1082. id: "cubeTile18",
  1083. type: "tile",
  1084. visible:true,
  1085. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031604")
  1086. })
  1087. } else if (level === 19) {
  1088. addSingleLayer({
  1089. id: "cubeTile19",
  1090. type: "tile",
  1091. visible:true,
  1092. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031605")
  1093. })
  1094. } else if (level === 20) {
  1095. addSingleLayer({
  1096. id: "cubeTile20",
  1097. type: "tile",
  1098. visible:true,
  1099. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031606")
  1100. })
  1101. } else if (level === 21) {
  1102. addSingleLayer({
  1103. id: "cubeTile21",
  1104. type: "tile",
  1105. visible:true,
  1106. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031607")
  1107. })
  1108. } else if (level === 22) {
  1109. addSingleLayer({
  1110. id: "cubeTile22",
  1111. type: "tile",
  1112. visible:true,
  1113. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031608")
  1114. })
  1115. } else if (level === 23) {
  1116. addSingleLayer({
  1117. id: "cubeTile23",
  1118. type: "tile",
  1119. visible:true,
  1120. url: await returnProxyUrl("https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D999999012025031609")
  1121. })
  1122. }
  1123. }
  1124. function showThreeCube(params){
  1125. let status = params.status;
  1126. if(status === "hide"){
  1127. if(addThreeCubeEvent){
  1128. addThreeCubeEvent.clear();
  1129. addThreeCubeEvent = null;
  1130. }
  1131. return
  1132. }
  1133. let size = params.size;
  1134. let points = params.points;
  1135. // 初始化 AddThreeCubeEvent,暂时不启动
  1136. addThreeCubeEvent = new AddThreeCubeEvent({
  1137. view: m_view,
  1138. points:points,
  1139. size,
  1140. });
  1141. addThreeCubeEvent.init();
  1142. }
  1143. function showThreeCubeDetail(params){
  1144. let status = params.status;
  1145. let id = params.id;
  1146. let depthTest = params.depthTest;
  1147. if(depthTest == undefined){
  1148. depthTest = true;
  1149. }
  1150. let deepOpacity = params.deepOpacity;
  1151. if(status === "hide"){
  1152. if(addThreeCubeDetailInstance[id]){
  1153. addThreeCubeDetailInstance[id].clear();
  1154. addThreeCubeDetailInstance[id] = null;
  1155. }
  1156. return
  1157. }
  1158. let size = params.size;
  1159. if(addThreeCubeDetailInstance[id]){
  1160. addThreeCubeDetailInstance[id].add(params.points);
  1161. }else{
  1162. let addThreeCubeDetailEvent = new AddThreeCubeDetailEvent({
  1163. view: m_view,
  1164. points:params.points,
  1165. size,
  1166. bus,
  1167. deepOpacity,
  1168. depthTest
  1169. });
  1170. addThreeCubeDetailEvent.start();
  1171. addThreeCubeDetailInstance[id] = addThreeCubeDetailEvent;
  1172. }
  1173. }
  1174. // 递归获取所有建筑点的辅助函数
  1175. function getAllPowerPoints(level,scrollId = null) {
  1176. getPowerInterface({
  1177. x: m_view.camera.position.x,
  1178. y: m_view.camera.position.y,
  1179. //level: level,
  1180. scrollId: scrollId,
  1181. }).then(res =>{
  1182. if(res.data.data.list?.length >= 10000 && res.data.data.scrollId){
  1183. powerDataList = powerDataList.concat(res.data.data.list);
  1184. getAllPowerPoints(level,res.data.data.scrollId);
  1185. }else{
  1186. powerDataList = powerDataList.concat(res.data.data.list);
  1187. // 初始化 AddThreeCubeEvent,暂时不启动
  1188. powerDataList.forEach((item)=>{
  1189. item.color = getColor(item.averageValue, -100, 0);
  1190. })
  1191. let size = {
  1192. x:13.223015683766334,
  1193. y:15.404125436905815,
  1194. z:13.471596544164798
  1195. }
  1196. let para = {
  1197. id:"1",
  1198. status:"show",
  1199. size,
  1200. points:powerDataList
  1201. }
  1202. //symbolPointCube(para)
  1203. showThreeCubeDetail(para);
  1204. }
  1205. })
  1206. }
  1207. function getColor(value, minValue, maxValue) {
  1208. // 边界处理
  1209. if (value < minValue) value = minValue;
  1210. if (value > maxValue) value = maxValue;
  1211. // 映射到 [0, 1]
  1212. let t = (value - minValue) / (maxValue - minValue);
  1213. // 定义颜色
  1214. let r, g, b;
  1215. if (t <= 0.5) {
  1216. // 从红色到黄色
  1217. r = 1;
  1218. g = t * 2; // 线性插值增加绿色
  1219. b = 0;
  1220. } else {
  1221. // 从黄色到绿色
  1222. r = 2 * (1 - t); // 线性插值减少红色
  1223. g = 1;
  1224. b = 0;
  1225. }
  1226. return [r, g, b];
  1227. }
  1228. function showBuildingThreeCubeByInterface(params){
  1229. let status = params.status;
  1230. let size = params.size;
  1231. if(addThreeCubeEvent){
  1232. addThreeCubeEvent.clear();
  1233. addThreeCubeEvent = null;
  1234. }
  1235. if(status === "hide"){
  1236. return
  1237. }
  1238. let level = params.level;
  1239. // 初始化 AddThreeCubeEvent,暂时不启动
  1240. addThreeCubeEvent = new AddThreeCubeEvent({
  1241. view: m_view,
  1242. size,
  1243. });
  1244. addThreeCubeEvent.start();
  1245. // 获取所有建筑点数据
  1246. getAllBuildingPoints(level);
  1247. }
  1248. function showNoFlyThreeCubeDetailByInterface(params){
  1249. let status = params.status;
  1250. let size = params.size;
  1251. if(addThreeCubeEvent){
  1252. addThreeCubeEvent.clear();
  1253. addThreeCubeEvent = null;
  1254. }
  1255. if(status === "hide"){
  1256. return
  1257. }
  1258. let level = params.level;
  1259. getNoFlyPointInterface({
  1260. x: m_view.camera.position.x,
  1261. y: m_view.camera.position.y,
  1262. level: level,
  1263. scrollId: "",
  1264. }).then(res =>{
  1265. res.data.data.list.forEach(item =>{
  1266. item.color = [1,0,0]
  1267. })
  1268. // 初始化 AddThreeCubeEvent,暂时不启动
  1269. let addThreeCubeDetailEvent = new AddThreeCubeDetailEvent({
  1270. view: m_view,
  1271. points:res.data.data.list,
  1272. size,
  1273. bus
  1274. });
  1275. addThreeCubeDetailEvent.start();
  1276. })
  1277. }
  1278. function showNoFlyThreeCubeByInterface(params){
  1279. let status = params.status;
  1280. let size = params.size;
  1281. if(addThreeCubeEvent){
  1282. addThreeCubeEvent.clear();
  1283. addThreeCubeEvent = null;
  1284. }
  1285. if(status === "hide"){
  1286. return
  1287. }
  1288. let level = params.level;
  1289. // 初始化 AddThreeCubeEvent,暂时不启动
  1290. addThreeCubeEvent = new AddThreeCubeEvent({
  1291. view: m_view,
  1292. size,
  1293. });
  1294. addThreeCubeEvent.start();
  1295. // 获取所有建筑点数据
  1296. getNoFlyPoint(level);
  1297. }
  1298. function showRoadThreeCubeByInterface(params){
  1299. let status = params.status;
  1300. let size = params.size;
  1301. if(addThreeCubeEvent){
  1302. addThreeCubeEvent.clear();
  1303. addThreeCubeEvent = null;
  1304. }
  1305. if(status === "hide"){
  1306. return
  1307. }
  1308. let level = params.level;
  1309. // 初始化 AddThreeCubeEvent,暂时不启动
  1310. addThreeCubeEvent = new AddThreeCubeEvent({
  1311. view: m_view,
  1312. size,
  1313. });
  1314. addThreeCubeEvent.start();
  1315. // 获取所有建筑点数据
  1316. getRoadPoint(level);
  1317. }
  1318. function showRoadThreeCubeDetailByInterface(params){
  1319. let status = params.status;
  1320. let size = params.size;
  1321. if(addThreeCubeEvent){
  1322. addThreeCubeEvent.clear();
  1323. addThreeCubeEvent = null;
  1324. }
  1325. if(status === "hide"){
  1326. return
  1327. }
  1328. let level = params.level;
  1329. getRoadPointInterface({
  1330. x: m_view.camera.position.x,
  1331. y: m_view.camera.position.y,
  1332. level: level,
  1333. scrollId: "",
  1334. }).then(res =>{
  1335. res.data.data.list.forEach(item =>{
  1336. item.color = [0,0,1]
  1337. })
  1338. // 初始化 AddThreeCubeEvent,暂时不启动
  1339. let addThreeCubeDetailEvent = new AddThreeCubeDetailEvent({
  1340. view: m_view,
  1341. points:res.data.data.list,
  1342. size,
  1343. bus
  1344. });
  1345. addThreeCubeDetailEvent.start();
  1346. })
  1347. }
  1348. function showRiverThreeCubeByInterface(params){
  1349. let status = params.status;
  1350. let size = params.size;
  1351. if(addThreeCubeEvent){
  1352. addThreeCubeEvent.clear();
  1353. addThreeCubeEvent = null;
  1354. }
  1355. if(status === "hide"){
  1356. return
  1357. }
  1358. let level = params.level;
  1359. // 初始化 AddThreeCubeEvent,暂时不启动
  1360. addThreeCubeEvent = new AddThreeCubeEvent({
  1361. view: m_view,
  1362. size,
  1363. });
  1364. addThreeCubeEvent.start();
  1365. // 获取所有建筑点数据
  1366. getRiverPoint(level);
  1367. }
  1368. function showRiverThreeCubeDetailByInterface(params){
  1369. let status = params.status;
  1370. let size = params.size;
  1371. if(addThreeCubeEvent){
  1372. addThreeCubeEvent.clear();
  1373. addThreeCubeEvent = null;
  1374. }
  1375. if(status === "hide"){
  1376. return
  1377. }
  1378. let level = params.level;
  1379. getRiverPointInterface({
  1380. x: m_view.camera.position.x,
  1381. y: m_view.camera.position.y,
  1382. level: level,
  1383. scrollId: "",
  1384. }).then(res =>{
  1385. res.data.data.list.forEach(item =>{
  1386. item.color = [1,1,0]
  1387. })
  1388. // 初始化 AddThreeCubeEvent,暂时不启动
  1389. let addThreeCubeDetailEvent = new AddThreeCubeDetailEvent({
  1390. view: m_view,
  1391. points:res.data.data.list,
  1392. size,
  1393. bus
  1394. });
  1395. addThreeCubeDetailEvent.start();
  1396. })
  1397. }
  1398. function showThreeNet(params){
  1399. let status = params.status;
  1400. if(addThreeNetEvent){
  1401. addThreeNetEvent.clear();
  1402. addThreeNetEvent = null;
  1403. }
  1404. if(status === "hide"){
  1405. return
  1406. }
  1407. let size = params.size;
  1408. let origin = params.origin;
  1409. let buffer = params.buffer;
  1410. let maxHeight = params.maxHeight;
  1411. let minHeight = params.minHeight;
  1412. //另一类是网加载(网只根据范围变化)
  1413. addThreeNetEvent = new AddThreeNetEvent({
  1414. view: m_view,
  1415. size,
  1416. origin,
  1417. buffer,
  1418. maxHeight,
  1419. minHeight
  1420. });
  1421. addThreeNetEvent.start();
  1422. }
  1423. // 递归获取所有建筑点的辅助函数
  1424. function getAllBuildingPoints(level,scrollId = null) {
  1425. getBuildingPoint({
  1426. x: m_view.camera.position.x,
  1427. y: m_view.camera.position.y,
  1428. level: level,
  1429. scrollId: scrollId,
  1430. }).then(res =>{
  1431. if(res.data.data.list?.length >= 10000 && res.data.data.scrollId){
  1432. addThreeCubeEvent.addPoints(res.data.data.list);
  1433. getAllBuildingPoints(level,res.data.data.scrollId);
  1434. }else{
  1435. addThreeCubeEvent.addPoints(res.data.data.list);
  1436. }
  1437. })
  1438. }
  1439. // 递归获取所有建筑点的辅助函数
  1440. function getNoFlyPoint(level,scrollId = null) {
  1441. getNoFlyPointInterface({
  1442. x: m_view.camera.position.x,
  1443. y: m_view.camera.position.y,
  1444. level: level,
  1445. scrollId: scrollId,
  1446. }).then(res =>{
  1447. if(res.data.data.list?.length >= 10000 && res.data.data.scrollId){
  1448. addThreeCubeEvent.addPoints(res.data.data.list);
  1449. getNoFlyPoint(level,res.data.data.scrollId);
  1450. }else{
  1451. addThreeCubeEvent.addPoints(res.data.data.list);
  1452. }
  1453. })
  1454. }
  1455. // 递归获取所有道路点的辅助函数
  1456. function getRoadPoint(level,scrollId = null) {
  1457. getRoadPointInterface({
  1458. x: m_view.camera.position.x,
  1459. y: m_view.camera.position.y,
  1460. level: level,
  1461. scrollId: scrollId,
  1462. }).then(res =>{
  1463. if(res.data.data.list?.length >= 10000 && res.data.data.scrollId){
  1464. addThreeCubeEvent.addPoints(res.data.data.list);
  1465. getRoadPoint(level,res.data.data.scrollId);
  1466. }else{
  1467. addThreeCubeEvent.addPoints(res.data.data.list);
  1468. }
  1469. })
  1470. }
  1471. // 递归获取所有河流点的辅助函数
  1472. function getRiverPoint(level,scrollId = null) {
  1473. getRiverPointInterface({
  1474. x: m_view.camera.position.x,
  1475. y: m_view.camera.position.y,
  1476. level: level,
  1477. scrollId: scrollId,
  1478. }).then(res =>{
  1479. if(res.data.data.list?.length >= 10000 && res.data.data.scrollId){
  1480. addThreeCubeEvent.addPoints(res.data.data.list);
  1481. getRiverPoint(level,res.data.data.scrollId);
  1482. }else{
  1483. addThreeCubeEvent.addPoints(res.data.data.list);
  1484. }
  1485. })
  1486. }
  1487. //全市格网自定义分割效果加载
  1488. // function showLayersWithScaleEventsReturn(scaleValue){
  1489. // let eyeExtent = getEyeExtent();
  1490. // if(!eyeExtent){
  1491. // return
  1492. // }
  1493. // let height = m_view.camera.position.z;
  1494. // console.log("height",height,"scale",m_view.scale);
  1495. // let sizeObj = extentGridLimit({
  1496. // eyeExtent,
  1497. // height
  1498. // });
  1499. // let size = sizeObj.size;
  1500. // let opacity = sizeObj.opacity;
  1501. // let layerHeight;
  1502. // if(size > 400){
  1503. // layerHeight = 400;
  1504. // }else{
  1505. // layerHeight = size;
  1506. // }
  1507. // if(addThreeGridEvent){
  1508. // addThreeGridEvent.extent = {minX:eyeExtent.xmin,maxX:eyeExtent.xmax,minY:eyeExtent.ymin,maxY:eyeExtent.ymax};
  1509. // addThreeGridEvent.height = height>1200?1200:height;
  1510. // addThreeGridEvent.size = size;
  1511. // addThreeGridEvent.layerHeight = layerHeight;
  1512. // addThreeGridEvent.gridEnabled = true;
  1513. // addThreeGridEvent.netEnabled = true;
  1514. // addThreeGridEvent.opacity = opacity;
  1515. // addThreeGridEvent.start();
  1516. // }else{
  1517. // addThreeGridEvent = new AddThreeGridEvent({
  1518. // view:m_view,
  1519. // extent: {minX:eyeExtent.xmin,maxX:eyeExtent.xmax,minY:eyeExtent.ymin,maxY:eyeExtent.ymax},
  1520. // height:height>1200?1200:height,
  1521. // size:size,
  1522. // gridEnabled : true,
  1523. // netEnabled : true,
  1524. // opacity:opacity,
  1525. // layerHeight:layerHeight,
  1526. // })
  1527. // addThreeGridEvent.start();
  1528. // }
  1529. //
  1530. // }
  1531. //
  1532. //格网范围限制
  1533. // function extentGridLimit(params){
  1534. // try{
  1535. // //let size = [7.73,61.84,123.69,1850];
  1536. // let size = [
  1537. // {
  1538. // value:7.73,
  1539. // opacity:0.05
  1540. // },
  1541. // {
  1542. // value:61.84,
  1543. // opacity:0.05
  1544. // },
  1545. // {
  1546. // value:123.69,
  1547. // opacity:0.15
  1548. // },
  1549. // {
  1550. // value:1850,
  1551. // opacity:0.3
  1552. // }
  1553. // ]
  1554. // params.eyeExtent = {
  1555. // xmin: params.eyeExtent.xmin < -60000?-60000:params.eyeExtent.xmin,
  1556. // ymin: params.eyeExtent.ymin < -60000?-60000:params.eyeExtent.ymin,
  1557. // xmax: params.eyeExtent.xmax > 60000?60000:params.eyeExtent.xmax,
  1558. // ymax: params.eyeExtent.ymax > 70000?70000:params.eyeExtent.ymax,
  1559. // }
  1560. // params.height = params.height < 1200?params.height:1200;
  1561. // for(let i = 0;i<size.length;i++){
  1562. // let xCount = Math.floor((params.eyeExtent.xmax - params.eyeExtent.xmin) / size[i].value);
  1563. // let yCount = Math.floor((params.eyeExtent.ymax - params.eyeExtent.ymin) / size[i].value);
  1564. // let zCount = Math.floor(params.height / size[i].value);
  1565. // let count = xCount * yCount * zCount;
  1566. // if(count < 200000){
  1567. // return {
  1568. // size: size[i].value,
  1569. // opacity: size[i].opacity
  1570. // }
  1571. // }
  1572. // }
  1573. // }catch(e){
  1574. // console.log("params",params)
  1575. // }
  1576. // }
  1577. // function getEyeExtent() {
  1578. // const screenWidth = m_view.width;
  1579. // const screenHeight = m_view.height;
  1580. //
  1581. // // 四个角的像素坐标
  1582. // const screenCorners = [
  1583. // { x: 0, y: 0 }, // 左上角
  1584. // { x: screenWidth, y: 0 }, // 右上角
  1585. // { x: screenWidth, y: screenHeight }, // 右下角
  1586. // { x: 0, y: screenHeight }, // 左下角
  1587. // ];
  1588. //
  1589. // // 将屏幕角坐标转为地图坐标
  1590. // const mapPoints = screenCorners.map((screenPoint) => m_view.toMap(screenPoint)).filter(p => p);
  1591. //
  1592. // // 添加 camera.position 到 mapPoints
  1593. // const cameraPoint = m_view.camera.position;
  1594. //
  1595. // if (mapPoints.length < 4) {
  1596. // if (cameraPoint) {
  1597. // const bufferDistance = 2000; // 2公里
  1598. // const spatialReference = m_view.spatialReference;
  1599. //
  1600. // const screenExtent = {
  1601. // xmin: cameraPoint.x - bufferDistance,
  1602. // ymin: cameraPoint.y - bufferDistance,
  1603. // xmax: cameraPoint.x + bufferDistance,
  1604. // ymax: cameraPoint.y + bufferDistance,
  1605. // spatialReference: spatialReference,
  1606. // };
  1607. // console.warn("视图范围不足4个有效点,使用摄像机位置生成的2公里范围。");
  1608. // console.log(screenExtent);
  1609. // return screenExtent;
  1610. // } else {
  1611. // console.warn("无法获取摄像机位置,请检查视图状态。");
  1612. // return null;
  1613. // }
  1614. // } else {
  1615. // try {
  1616. // // 获取最小和最大坐标值
  1617. // const xmin = Math.min(...mapPoints.map((p) => p.x));
  1618. // const ymin = Math.min(...mapPoints.map((p) => p.y));
  1619. // const xmax = Math.max(...mapPoints.map((p) => p.x));
  1620. // const ymax = Math.max(...mapPoints.map((p) => p.y));
  1621. //
  1622. // const screenExtent = {
  1623. // xmin: xmin,
  1624. // ymin: ymin,
  1625. // xmax: xmax,
  1626. // ymax: ymax,
  1627. // spatialReference: m_view.spatialReference,
  1628. // };
  1629. // console.log(screenExtent);
  1630. // return screenExtent;
  1631. // } catch (e) {
  1632. // console.error("获取地图范围时出错:", e);
  1633. // return null;
  1634. // }
  1635. // }
  1636. // }
  1637. function viewshedAnalysis(params){
  1638. let status = params.status;
  1639. if(status === "hide"){
  1640. if(viewShedAnalysisWidget !== null){
  1641. viewShedAnalysisWidget.clearAnalysis();
  1642. }
  1643. return
  1644. }
  1645. if(status === "show"){
  1646. if(viewShedAnalysisWidget === null){
  1647. viewShedAnalysisWidget = new ViewShedAnalysisWidget({ view:m_view });
  1648. viewShedAnalysisWidget.startAnalysis();
  1649. }
  1650. }
  1651. }
  1652. function featureLayerThreeDimension(params){
  1653. let status = params.status;
  1654. }
  1655. function addLightBall(params){
  1656. let status = params.status;
  1657. let id = params.id;
  1658. if(lightBallInstance[id]){
  1659. lightBallInstance[id].clear();
  1660. lightBallInstance[id] = null;
  1661. }
  1662. if(status === "hide"){
  1663. return
  1664. }
  1665. let points = params.points;
  1666. let addLightBallEvent = new AddLightBallEvent({
  1667. view:m_view,
  1668. points
  1669. })
  1670. addLightBallEvent.start()
  1671. // 保存实例
  1672. lightBallInstance[id] = addLightBallEvent;
  1673. }
  1674. function threeGrid(params){
  1675. let status = params.status;
  1676. if(status === "hide"){
  1677. if(addThreeGridEvent){
  1678. addThreeGridEvent.clear();
  1679. addThreeGridEvent = null;
  1680. }
  1681. return
  1682. }
  1683. let animationEnabled = false;
  1684. if(params.animationEnabled){
  1685. animationEnabled = params.animationEnabled;
  1686. }
  1687. if(addThreeGridEvent){
  1688. addThreeGridEvent.height = params.height;
  1689. addThreeGridEvent.size = params.size;
  1690. addThreeGridEvent.layerHeight = params.layerHeight;
  1691. addThreeGridEvent.animationEnabled = animationEnabled;
  1692. addThreeGridEvent.gridEnabled = true;
  1693. addThreeGridEvent.netEnabled = true;
  1694. addThreeGridEvent.start();
  1695. }else{
  1696. addThreeGridEvent = new AddThreeGridEvent({
  1697. view:m_view,
  1698. extent : {minX:2176,maxX:6048,minY:-1024,maxY:1352},
  1699. height : params.height,
  1700. size : params.size,
  1701. layerHeight :params.layerHeight,
  1702. gridEnabled:true,
  1703. netEnabled:true,
  1704. animationEnabled
  1705. })
  1706. addThreeGridEvent.start();
  1707. }
  1708. }
  1709. function threeGridDetail(params){
  1710. }
  1711. function realPositionGrid(params){
  1712. let status = params.status;
  1713. }
  1714. function limitHeightAnalysis(params){
  1715. let status = params.status;
  1716. if(limitHeightAnalysisEvent){
  1717. limitHeightAnalysisEvent.clear();
  1718. limitHeightAnalysisEvent =null;
  1719. }
  1720. if(status === "hide"){
  1721. return
  1722. }
  1723. limitHeightAnalysisEvent = new LimitHeightAnalysis({
  1724. view:m_view,
  1725. map:m_map,
  1726. layerId:params.layerId,
  1727. limitH:params.limitH,
  1728. maxLimitH:params.maxLimitH,
  1729. rings:params.rings,
  1730. });
  1731. limitHeightAnalysisEvent.start()
  1732. }
  1733. function geometryMeshPrismEffect(params){
  1734. let status = params.status;
  1735. let f_layer = m_map.layers.find(item => item.id === "geometryMeshPrismEffect");
  1736. if (f_layer) {
  1737. m_map.remove(f_layer);
  1738. }
  1739. if(status === "hide"){
  1740. return
  1741. }
  1742. let geometryMeshPrismEffect = new GeometryMeshPrismEffect({
  1743. view:m_view,
  1744. m_map,
  1745. items:params.items,
  1746. startHeight:params.startHeight,
  1747. rings:params.rings
  1748. });
  1749. m_map.add(geometryMeshPrismEffect.graphicsLayer);
  1750. }
  1751. function geometryMeshEffect(params){
  1752. let status = params.status;
  1753. let id = params.id;
  1754. let f_layer = m_map.layers.find(item => item.id === "geometryMeshEffect" + id);
  1755. if (f_layer) {
  1756. m_map.remove(f_layer);
  1757. }
  1758. if(status === "hide"){
  1759. return
  1760. }
  1761. let geometryMeshEffect = new GeometryMeshEffect({
  1762. view:m_view,
  1763. m_map,
  1764. id:params.id,
  1765. data:params.data,
  1766. });
  1767. m_map.add(geometryMeshEffect.graphicsLayer);
  1768. }
  1769. // 路径冲突
  1770. function pathConflict(params){
  1771. pathPipe({
  1772. "id": "conflict1",
  1773. "status": "show",
  1774. "paths":Path.path_conflict_1,
  1775. "color": "#438EDB",
  1776. "intensity": 1.2,
  1777. "pipeRadius": 5
  1778. });
  1779. pathPipe({
  1780. "id": "conflict2",
  1781. "status": "show",
  1782. "paths":Path.path_conflict_2,
  1783. "color": "#438EDB",
  1784. "intensity": 1.2,
  1785. "pipeRadius": 5
  1786. });
  1787. getRealFlyPoint({
  1788. flyList:[
  1789. {
  1790. "id": "67513a6e-7ce2-4121-9b11-cd6f1d28e02c",
  1791. "speed":40,
  1792. "uavid": "87066700-f12d-4b3e-ac77-a55a409dd30b"
  1793. },
  1794. {
  1795. "id": "fba073d1-def3-4f85-9326-dff8a1ac6ea6",
  1796. "speed":25,
  1797. "uavid": "9556344a-c055-4156-86d4-bc57930275a2"
  1798. }
  1799. ]
  1800. })
  1801. }
  1802. // 无人机电量预警
  1803. function uavBatteryWarning(params){
  1804. pathPipe({
  1805. "id": "conflict1",
  1806. "status": "show",
  1807. "paths":Path.path_conflict_1,
  1808. "color": "#438EDB",
  1809. "intensity": 1.2,
  1810. "pipeRadius": 10
  1811. });
  1812. getRealFlyPoint({
  1813. flyList:[
  1814. {
  1815. "id": "67513a6e-7ce2-4121-9b11-cd6f1d28e02c",
  1816. "speed":40,
  1817. "uavid": "02d47b30-003c-4e7e-89ec-72255c1ebdaf"
  1818. }
  1819. ]
  1820. })
  1821. }
  1822. //无人机偏航
  1823. function uavYawWarning(params){
  1824. pathPipe({
  1825. "id": "yaw",
  1826. "status": "show",
  1827. "paths":Path.yaw_path,
  1828. "color": "#438EDB",
  1829. "intensity": 1.2,
  1830. "pipeRadius": 10
  1831. });
  1832. getRealFlyPoint({
  1833. flyList:[
  1834. {
  1835. "id": "6fd0fa45-de0b-4008-8d4d-afaaa15064f3",
  1836. "speed":40,
  1837. "uavid": "7e080fe7-dbd4-4be2-aa45-72a28da7f26c"
  1838. }
  1839. ]
  1840. })
  1841. }
  1842. function pathPipe(params){
  1843. let id = params.id;
  1844. let status = params.status;
  1845. if(pathPipeInstance[id]){
  1846. pathPipeInstance[id].clear();
  1847. pathPipeInstance[id] = null;
  1848. }
  1849. if(status === "hide"){
  1850. return
  1851. }
  1852. //优化数据
  1853. //params.paths = [MoveCar.paths1];
  1854. let pathPipeEvent = new PathPipeEvent({
  1855. view:m_view,
  1856. paths:params.paths,
  1857. color:params.color,
  1858. pipeRadius:params.pipeRadius,
  1859. intensity:params.intensity
  1860. });
  1861. pathPipeEvent.start();
  1862. // 保存实例
  1863. pathPipeInstance[id] = pathPipeEvent;
  1864. }
  1865. function flyGLTF(params){
  1866. let id = params.id;
  1867. let uavid = params.uavid;
  1868. let status = params.status;
  1869. if(status === "hide"){
  1870. if(flyGLTFInstances[uavid]){
  1871. flyGLTFInstances[uavid].clear();
  1872. delete flyGLTFInstances[uavid];
  1873. }
  1874. return
  1875. }
  1876. let point = params.point;
  1877. let duration = params.duration;
  1878. let uavInfo = params.uavInfo;
  1879. if(flyGLTFInstances[uavid]){
  1880. flyGLTFInstances[uavid].updatePath(point,duration);
  1881. if(uavInfo){
  1882. flyGLTFInstances[uavid].updateUavInfo(uavInfo);
  1883. }
  1884. }else{
  1885. let flyGLTFEvent = new FlyGLTFEvent({
  1886. view:m_view,
  1887. uavid,
  1888. bus,
  1889. })
  1890. flyGLTFEvent.start();
  1891. flyGLTFEvent.updatePath(point,duration);
  1892. if(params.uavInfo){
  1893. flyGLTFEvent.updateUavInfo(uavInfo);
  1894. }
  1895. flyGLTFInstances[uavid] = flyGLTFEvent;
  1896. }
  1897. }
  1898. function getVirtualFlyPoint(params){
  1899. let status = params.status;
  1900. const connectVirtualWebSocket = (status) => {
  1901. if(status === "show"){
  1902. if(virtualSocket){
  1903. virtualSocket.send(JSON.stringify(params.flyList));
  1904. }else{
  1905. virtualSocket = new WebSocket('ws://172.16.8.44:9250/low-altitude/simulate/getRouteInfoWebSocket');
  1906. virtualSocket.onopen = () => {
  1907. console.log('WebSocket 连接成功');
  1908. virtualSocket.send(JSON.stringify(params.flyList));
  1909. };
  1910. virtualSocket.onmessage = (messageEvent) => {
  1911. let messages = JSON.parse(messageEvent.data).data;
  1912. messages.forEach(message => {
  1913. flyGLTF({
  1914. id:message.id,
  1915. uavid:message.uavid,
  1916. status:message.routeInfoVO.status == 3?"hide":"show",
  1917. duration:2100,
  1918. //duration:3000,
  1919. point:message.position_cj,
  1920. uavInfo: {
  1921. type:"safe",
  1922. data:message.routeInfoVO,
  1923. origin:message.routeInfoVO
  1924. }
  1925. });
  1926. })
  1927. };
  1928. virtualSocket.onerror = (error) => {
  1929. console.error('WebSocket 出错:', error);
  1930. };
  1931. virtualSocket.onclose = () => {
  1932. console.log('WebSocket 连接已关闭');
  1933. };
  1934. }
  1935. }else{
  1936. if(virtualSocket){
  1937. virtualSocket.close();
  1938. }
  1939. }
  1940. };
  1941. connectVirtualWebSocket(status);
  1942. }
  1943. function getFixedFlyPoint(params){
  1944. let status = params.status;
  1945. let data = params.paths;
  1946. let id = params.id;
  1947. // let data = params.paths;
  1948. // let id = params.id;
  1949. //设置定时2秒发送data里面下一个点执行flyGltf
  1950. if (status === "show") {
  1951. // 清除已有定时器避免重复
  1952. if (getFixedFlyInstance[id]) {
  1953. clearInterval(getFixedFlyInstance[id].timerId);
  1954. getFixedFlyInstance[id].timerId = null;
  1955. getFixedFlyInstance[id] = null;
  1956. }
  1957. // 重置索引以重新开始
  1958. getFixedFlyInstance[id] = {};
  1959. getFixedFlyInstance[id].currentIndex = 0;
  1960. // 设置新定时器
  1961. getFixedFlyInstance[id].timerId = setInterval(() => {
  1962. if (getFixedFlyInstance[id].currentIndex < data.length) {
  1963. // 获取当前点并发送
  1964. debugger
  1965. let currentPoint = data[getFixedFlyInstance[id].currentIndex];
  1966. flyGLTF({
  1967. uavid:id,
  1968. status:"show",
  1969. duration:2000,
  1970. //duration:3000,
  1971. point:currentPoint
  1972. });
  1973. getFixedFlyInstance[id].currentIndex++;
  1974. } else {
  1975. // 数据发送完毕,清除定时器
  1976. clearInterval(getFixedFlyInstance[id].timerId);
  1977. getFixedFlyInstance[id].timerId = null;
  1978. getFixedFlyInstance[id] = null;
  1979. }
  1980. }, 2000); // 每2秒执行一次
  1981. } else {
  1982. // 状态非show时停止发送
  1983. debugger
  1984. if (getFixedFlyInstance[id]?.timerId !== null && getFixedFlyInstance[id]?.timerId !== undefined) {
  1985. clearInterval(getFixedFlyInstance[id].timerId);
  1986. getFixedFlyInstance[id].timerId = null;
  1987. }
  1988. getFixedFlyInstance[id] = null;
  1989. flyGLTF({
  1990. uavid:id,
  1991. status:"hide"
  1992. });
  1993. }
  1994. }
  1995. function getRealFlyPoint(params){
  1996. const connectWebSocket = () => {
  1997. if(socket){
  1998. socket.send(JSON.stringify(params.flyList));
  1999. }else{
  2000. socket = new WebSocket('ws://172.16.8.44:9250/low-altitude/aircraftRouteSpeedWebSocket');
  2001. socket.onopen = () => {
  2002. console.log('WebSocket 连接成功');
  2003. socket.send(JSON.stringify(params.flyList));
  2004. };
  2005. socket.onmessage = (messageEvent) => {
  2006. let messages = JSON.parse(messageEvent.data).data;
  2007. realFlyPointDataQueue.push(messages);
  2008. };
  2009. socket.onerror = (error) => {
  2010. console.error('WebSocket 出错:', error);
  2011. };
  2012. socket.onclose = () => {
  2013. console.log('WebSocket 连接已关闭');
  2014. };
  2015. }
  2016. };
  2017. connectWebSocket();
  2018. processRealFlyPointData();
  2019. }
  2020. //如果是等待,就要设置另一台无人机继续飞行
  2021. function processRealFlyPointData(){
  2022. setInterval(() => {
  2023. if (realFlyPointDataQueue.length > 0) {
  2024. const messages = realFlyPointDataQueue.shift(); // 从队列中取出数据
  2025. //发送消息
  2026. bus.emit('SendMessage',{
  2027. action:"RealTimeUAVList",
  2028. data:{
  2029. "message":messages
  2030. }
  2031. })
  2032. messages.forEach(message => {
  2033. message.routeInfoVO.speed = message.routeInfoVO.speed * 1 +(Math.random() * 2).toFixed(2) * 1
  2034. if(message.overall === "SAFE"){
  2035. addGraphics({
  2036. "id": message.uavid+'_conflict',
  2037. "status": "hide"
  2038. });
  2039. pathPipe({
  2040. "id": message.uavid+'_conflict',
  2041. "status": "hide"
  2042. });
  2043. flyGLTF({
  2044. id:message.id,
  2045. uavid:message.uavid,
  2046. status:message.routeInfoVO.status == 3?"hide":"show",
  2047. //duration:message.time + 100,
  2048. duration:2500,
  2049. point:message.position_cj,
  2050. uavInfo: {
  2051. type:"safe",
  2052. data:message.routeInfoVO,
  2053. origin:message.routeInfoVO
  2054. }
  2055. });
  2056. }else{
  2057. if(message.nearestAircraft.status !="SAFE"){ //碰撞
  2058. flyGLTF({
  2059. id:message.id,
  2060. uavid:message.uavid,
  2061. status:message.routeInfoVO.status == 3?"hide":"show",
  2062. //duration:message.time + 100,
  2063. duration:2500,
  2064. point:message.position_cj,
  2065. uavInfo: {
  2066. type:"conflict",
  2067. action:message.routeInfoVO.avoidanceType,
  2068. data:message.routeInfoVO.avoidanceType == "wait" ?message.nearestAircraft:message.routeInfoVO,
  2069. origin:{
  2070. ...message.nearestAircraft,
  2071. ...message.routeInfoVO
  2072. }
  2073. }
  2074. });
  2075. addGraphics({
  2076. id: message.uavid+'_conflict',
  2077. status:message.routeInfoVO.status == 3?"hide":"show",
  2078. data: {
  2079. "geometry": { "type": "point", "x": message.nearestAircraft.conflictPoint[0], "y": message.nearestAircraft.conflictPoint[1], "z": message.nearestAircraft.conflictPoint[2] },
  2080. "attributes": { "name": "碰撞点位" }
  2081. }
  2082. });
  2083. pathPipe({
  2084. "id": message.uavid+'_conflict',
  2085. "status": message.routeInfoVO.status == 3?"hide":"show",
  2086. "paths":[message.nearestAircraft.conflictPath],
  2087. "color": "#FF0000",
  2088. "intensity": 1.5,
  2089. "pipeRadius": 10
  2090. });
  2091. }else{
  2092. addGraphics({
  2093. "id": message.uavid+'_conflict',
  2094. "status": "hide"
  2095. });
  2096. pathPipe({
  2097. "id": message.uavid+'_conflict',
  2098. "status": "hide"
  2099. });
  2100. // if(message.noFlyZone.status != "SAFE"){
  2101. // console.log("禁飞区预警",message);
  2102. // flyGLTF({
  2103. // id:message.id,
  2104. // uavid:message.uavid,
  2105. // status:message.routeInfoVO.status == 3?"hide":"show",
  2106. // //duration:message.time + 100,
  2107. // duration:2100,
  2108. // point:message.position_cj,
  2109. // uavInfo: {
  2110. // type:"noFlyZone",
  2111. // data:message.routeInfoVO,
  2112. // origin:message.routeInfoVO
  2113. // }
  2114. // });
  2115. // }else
  2116. if(message.routeDeviate.status != "SAFE" && message.routeDeviate.distance * 1 > 14){
  2117. console.log("偏航异常预警",message);
  2118. flyGLTF({
  2119. id:message.id,
  2120. uavid:message.uavid,
  2121. status:message.routeInfoVO.status == 3?"hide":"show",
  2122. //duration:message.time + 100,
  2123. duration:2500,
  2124. point:message.position_cj,
  2125. uavInfo: {
  2126. type:"routeDeviate",
  2127. data:message.routeDeviate,
  2128. index:message.index,
  2129. origin:{
  2130. ...message.routeDeviate,
  2131. ...message.routeInfoVO
  2132. }
  2133. }
  2134. });
  2135. }
  2136. // else if(message.electricityWarning.status != "SAFE"){
  2137. // console.log("电量异常预警",message);
  2138. // flyGLTF({
  2139. // id:message.id,
  2140. // uavid:message.uavid,
  2141. // status:message.routeInfoVO.status == 3?"hide":"show",
  2142. // //duration:message.time + 100,
  2143. // duration:2100,
  2144. // point:message.position_cj,
  2145. // uavInfo: {
  2146. // type:"electricityWarning",
  2147. // data:message.electricityWarning,
  2148. // origin:message.routeInfoVO
  2149. // }
  2150. // });
  2151. // }
  2152. // else if(message.collision.status != "SAFE"){
  2153. // console.log("建筑物过近异常信息",message);
  2154. // flyGLTF({
  2155. // id:message.id,
  2156. // uavid:message.uavid,
  2157. // status:message.routeInfoVO.status == 3?"hide":"show",
  2158. // //duration:message.time + 100,
  2159. // duration:2100,
  2160. // point:message.position_cj,
  2161. // uavInfo: {
  2162. // type:"collision",
  2163. // data:message.collision,
  2164. // origin:message.routeInfoVO
  2165. // }
  2166. // });
  2167. // }
  2168. // else if(message.clearZone.status != "SAFE"){
  2169. // console.log("净空区异常预警",message);
  2170. // flyGLTF({
  2171. // id:message.id,
  2172. // uavid:message.uavid,
  2173. // status:message.routeInfoVO.status == 3?"hide":"show",
  2174. // //duration:message.time + 100,
  2175. // duration:2100,
  2176. // point:message.position_cj,
  2177. // uavInfo: {
  2178. // type:"clearZone",
  2179. // data:message.clearZone,
  2180. // origin:message.routeInfoVO
  2181. // }
  2182. // });
  2183. // }
  2184. else{
  2185. flyGLTF({
  2186. id:message.id,
  2187. uavid:message.uavid,
  2188. status:message.routeInfoVO.status == 3?"hide":"show",
  2189. //duration:message.time + 100,
  2190. duration:2500,
  2191. point:message.position_cj,
  2192. uavInfo: {
  2193. type:"safe",
  2194. data:message.routeInfoVO,
  2195. origin:message.routeInfoVO
  2196. }
  2197. });
  2198. }
  2199. }
  2200. }
  2201. })
  2202. } else {
  2203. console.log("No data to process.");
  2204. }
  2205. }, 2500); // 每3秒处理一次数据
  2206. }
  2207. function conflict_fly(params){
  2208. let uavid = params.uavid;
  2209. let skip_route_id = params.skip_route_id;
  2210. let distance = params.distance;
  2211. getAvoidRoute({
  2212. uavid:uavid,
  2213. skip_route_id:skip_route_id,
  2214. distance:distance
  2215. }).then(res =>{
  2216. console.log("临时路线",res);
  2217. pathPipe({
  2218. "id": uavid+'_change',
  2219. "status": "show",
  2220. "paths":[res.data.data.pathAll],
  2221. "color": "#438EDB",
  2222. "intensity": 1.2,
  2223. "pipeRadius": 5
  2224. });
  2225. getRealFlyPoint({
  2226. flyList:{
  2227. "path": res.data.data.pathAll,
  2228. "avoidanceType":"avoid",
  2229. "uavid": uavid
  2230. }
  2231. })
  2232. })
  2233. }
  2234. function changePointStatus(params){
  2235. flyGLTFInstances[params.uavid].followPath(params.isFollow);
  2236. }
  2237. //ws 推送方法
  2238. function getRealPower(params){
  2239. const connectWebSocket = () => {
  2240. socket = new WebSocket('ws://172.16.8.44:9250/low-altitude/gridSearchWebSocket');
  2241. socket.onopen = () => {
  2242. console.log('WebSocket 连接成功');
  2243. socket.send(JSON.stringify({
  2244. "locationPoint": {
  2245. "mapX": 6454.080981250964,
  2246. "mapY": 5487.978352845347
  2247. },
  2248. "radiusInMeters": 5000,
  2249. "minZ": 1,
  2250. "maxZ": 120,
  2251. "routes": [
  2252. ],
  2253. "fields":["gridCode","x","y","z"],
  2254. "scrollPage": {
  2255. "pageIndex": 1,
  2256. "pageSize": 10000,
  2257. "scrollId": ""
  2258. },
  2259. "level":20,
  2260. "className":"LowAltitudeGrid"
  2261. }));
  2262. };
  2263. socket.onmessage = (messageEvent) => {
  2264. let messages = JSON.parse(messageEvent.data);
  2265. messages.data.list.forEach((point) =>{
  2266. point.color = [0, 1, 1];
  2267. });
  2268. console.log("messages.data.list",messages.data.list)
  2269. let para = {
  2270. "id":"1",
  2271. "status":"show",
  2272. "size":{
  2273. x:46,
  2274. y:54,
  2275. z:53
  2276. },
  2277. "points":messages.data.list,
  2278. }
  2279. showThreeCubeDetail(para);
  2280. };
  2281. socket.onerror = (error) => {
  2282. console.error('WebSocket 出错:', error);
  2283. };
  2284. socket.onclose = () => {
  2285. console.log('WebSocket 连接已关闭');
  2286. };
  2287. };
  2288. connectWebSocket();
  2289. }
  2290. //无极变换
  2291. function getCurrentRealPower(params){
  2292. let id = params.id;
  2293. let status = params.status;
  2294. let level = params.level;
  2295. let center = params.center;
  2296. let radius = params.radius;
  2297. let minZ = params.minZ;
  2298. let maxZ = params.maxZ;
  2299. let size = params.size;
  2300. let fields = params.fields;
  2301. if(status === "hide"){
  2302. showThreeCubeDetail({
  2303. id:params.id,
  2304. status:"hide"
  2305. });
  2306. currentRealPowerIds = {
  2307. power_wj_15:[],
  2308. power_wj_16:[],
  2309. power_wj_17:[],
  2310. power_wj_18:[],
  2311. power_wj_19:[],
  2312. power_wj_20:[],
  2313. power_wj_21:[],
  2314. power_wj_22:[],
  2315. power_wj_23:[]
  2316. };
  2317. currentRealPowerLevel = null;
  2318. return
  2319. }
  2320. getCurrentPowerPoints({
  2321. id,
  2322. "x": center.x,
  2323. "y": center.y,
  2324. status,
  2325. radius,
  2326. size,
  2327. minZ,
  2328. maxZ,
  2329. level,
  2330. fields,
  2331. scrollId:""
  2332. });
  2333. }
  2334. // 无极变化-获取权重数据
  2335. function getCurrentPowerPoints(params) {
  2336. getPowerPoint({
  2337. x: params.x,
  2338. y: params.y,
  2339. radius:params.radius,
  2340. minZ:params.minZ,
  2341. maxZ:params.maxZ,
  2342. level: params.level,
  2343. fields: params.fields,
  2344. scrollId: params.scrollId,
  2345. }).then(res =>{
  2346. if (currentRealPowerShow) {
  2347. if (res.data.data.list?.length > 0) {
  2348. let data = res.data.data.list;
  2349. let responseLevel = res.data.data.list[0].level;
  2350. console.log("当前执行的level-需要的level",responseLevel,currentRealPowerLevel)
  2351. let newData = [];
  2352. if(responseLevel === currentRealPowerLevel){
  2353. if (currentRealPowerIds[params.id +'_'+ currentRealPowerLevel].length > 0) {
  2354. //将data对象数组中girdCode与currentRealPowerIds数组中的元素进行对比,如果相同则不添加到newData数组中
  2355. newData = data.filter(item => !currentRealPowerIds[params.id +'_'+ currentRealPowerLevel].includes(item.gridCode));
  2356. let newDataIds = newData.map(item => item.gridCode);
  2357. currentRealPowerIds[params.id +'_'+ currentRealPowerLevel]= [...currentRealPowerIds[params.id +'_'+ currentRealPowerLevel], ...newDataIds];
  2358. } else {
  2359. //将data对象数组中girdCode取出来,组成一个数组
  2360. let gridCodes = data.map(item => item.gridCode);
  2361. currentRealPowerIds[params.id +'_'+ currentRealPowerLevel] = gridCodes;
  2362. newData = data;
  2363. }
  2364. }
  2365. showThreeCubeDetail({
  2366. "id": params.id + currentRealPowerLevel,
  2367. "status": params.status,
  2368. "size": {
  2369. x:newData[0].boxSize.latLength,
  2370. y:newData[0].boxSize.lonLength,
  2371. z:newData[0].boxSize.height
  2372. },
  2373. "points": newData,
  2374. })
  2375. bus.emit('SendMessage',{
  2376. action:"CurrentCubeLevel",
  2377. data:{
  2378. "level":currentRealPowerLevel
  2379. }
  2380. })
  2381. closeOtherThreeCubeDetail(params.id,currentRealPowerLevel)
  2382. }
  2383. }
  2384. })
  2385. }
  2386. function closeOtherThreeCubeDetail(paramsId,index){
  2387. let levels = [15,16,17,18,19,20,21,22,23];
  2388. let newLevels = levels.filter(item => item != index);
  2389. newLevels.forEach((level) =>{
  2390. showThreeCubeDetail({
  2391. "id":paramsId + level,
  2392. "status":"hide"
  2393. })
  2394. currentRealPowerIds[paramsId +'_'+ level] = [];
  2395. })
  2396. }
  2397. //获取当前场景
  2398. function getRealPower2(params){
  2399. let id = params.id;
  2400. let lastId = params.lastId;
  2401. let status = params.status;
  2402. let level = params.level;
  2403. let center = params.center;
  2404. let radius = params.radius;
  2405. let minZ = params.minZ;
  2406. let maxZ = params.maxZ;
  2407. let size = params.size;
  2408. let fields = params.fields;
  2409. if(status === "hide"){
  2410. showThreeCubeDetail({
  2411. id:params.id,
  2412. status:"hide"
  2413. });
  2414. currentShowGridParams = null;
  2415. return
  2416. }
  2417. showThreeCubeDetail({
  2418. id:params.lastId,
  2419. status:"hide"
  2420. });
  2421. currentShowGridParams = id;
  2422. getSixPowerPoints({
  2423. id,
  2424. lastId,
  2425. "x": center.x,
  2426. "y": center.y,
  2427. status,
  2428. radius,
  2429. size,
  2430. minZ,
  2431. maxZ,
  2432. level,
  2433. fields,
  2434. scrollId:""
  2435. });
  2436. }
  2437. // 获取当前场景-递归获取权重数据
  2438. function getSixPowerPoints(params) {
  2439. getPowerPoint({
  2440. x: params.x,
  2441. y: params.y,
  2442. radius:params.radius,
  2443. minZ:params.minZ,
  2444. maxZ:params.maxZ,
  2445. level: params.level,
  2446. fields: params.fields,
  2447. scrollId: params.scrollId,
  2448. }).then(res =>{
  2449. if(currentShowGridParams === params.id){
  2450. if(res.data.data.list?.length >= 100000 && res.data.data.scrollId){
  2451. // res.data.data.list.forEach((point) =>{
  2452. // point.color = [0, 1, 1];
  2453. // });
  2454. // res.data.data.list.forEach((item)=>{
  2455. // item.color = getColor(item.averageValue, -50, 50);
  2456. // })
  2457. showThreeCubeDetail({
  2458. "id":params.id,
  2459. "status":params.status,
  2460. "size":params.size,
  2461. "points":res.data.data.list,
  2462. })
  2463. params.scrollId = res.data.data.scrollId;
  2464. getSixPowerPoints(params);
  2465. }else{
  2466. if(res.data.data.list?.length > 0){
  2467. showThreeCubeDetail({
  2468. "id":params.id,
  2469. "status":params.status,
  2470. "size":params.size,
  2471. "points":res.data.data.list,
  2472. })
  2473. }
  2474. }
  2475. }
  2476. })
  2477. }
  2478. //需要添加初始路径(手动绘制和自动绘制)结果
  2479. function draw(params){
  2480. let id = params.id;
  2481. let geometryType = params.type;
  2482. let status = params.status;
  2483. let path = params.path;
  2484. let hasZ = params.hasZ;
  2485. let symbol = params.symbol;
  2486. let clear = true;
  2487. if(params.clear !== undefined){
  2488. clear = params.clear;
  2489. }
  2490. if(clear){
  2491. if(addDrawEvent){
  2492. addDrawEvent.clear();
  2493. addDrawEvent = null;
  2494. }
  2495. }
  2496. if(status === "hide"){
  2497. return
  2498. }
  2499. if(!addDrawEvent){
  2500. addDrawEvent = new AddDrawEvent({
  2501. view:m_view,
  2502. type:geometryType,
  2503. symbol,
  2504. path:path,
  2505. hasZ,
  2506. once:true
  2507. });
  2508. }
  2509. if(path){
  2510. addDrawEvent.update();
  2511. bus.emit('SendMessage',{
  2512. action:"DrawComplete",
  2513. data:{
  2514. "geometry":{
  2515. type: "polyline",
  2516. paths: [path], // 示例路径坐标
  2517. spatialReference: m_view.spatialReference,
  2518. }
  2519. }
  2520. })
  2521. }else{
  2522. addDrawEvent.start(symbol,geometryType);
  2523. }
  2524. addDrawEvent.createListenerEvent((geometry) =>{
  2525. bus.emit('SendMessage',{
  2526. action:"DrawComplete",
  2527. data:{
  2528. "geometry":geometry
  2529. }
  2530. })
  2531. });
  2532. addDrawEvent.updateListenerEvent((geometry) =>{
  2533. bus.emit('SendMessage',{
  2534. action:"DrawComplete",
  2535. data:{
  2536. "geometry":geometry
  2537. }
  2538. })
  2539. });
  2540. }
  2541. //态势评估
  2542. function situationAssessment(params){
  2543. routeList.list.forEach((item) =>{
  2544. pathPipe({
  2545. id: item.id,
  2546. paths: [item.path],
  2547. color:item.color,
  2548. status: params.status,
  2549. "intensity": 1.2,
  2550. "pipeRadius": 10
  2551. })
  2552. })
  2553. featurePointsPlotting({
  2554. status: params.status,
  2555. data:routeList.points
  2556. });
  2557. routeList.conflictList.forEach((item) =>{
  2558. item.status = params.status =="show"?1:3
  2559. })
  2560. //先加载所有的无人机和航线
  2561. getRealFlyPoint({
  2562. status: params.status,
  2563. flyList:params.status=="show"?routeList.conflictList:routeList.conflictList
  2564. })
  2565. }
  2566. function draw_GeometryMeshPrismEffect(params){
  2567. let geometryType = params.type;
  2568. let status = params.status;
  2569. let startHeight = params.startHeight;
  2570. let items = params.items;
  2571. if(addDrawEvent){
  2572. addDrawEvent.clear();
  2573. addDrawEvent = null;
  2574. }
  2575. if(draw_GeometryMeshPrismEffectEvent){
  2576. draw_GeometryMeshPrismEffectEvent.clear();
  2577. draw_GeometryMeshPrismEffectEvent = null;
  2578. }
  2579. let f_layer = m_map.layers.find(item => item.id === "geometryMeshPrismEffect");
  2580. if (f_layer) {
  2581. m_map.remove(f_layer);
  2582. }
  2583. if(status == "hide"){
  2584. return
  2585. }
  2586. addDrawEvent = new AddDrawEvent({
  2587. view:m_view,
  2588. type:geometryType
  2589. })
  2590. addDrawEvent.start();
  2591. addDrawEvent.createListenerEvent((geometry)=>{
  2592. if(draw_GeometryMeshPrismEffectEvent){
  2593. draw_GeometryMeshPrismEffectEvent.clear();
  2594. draw_GeometryMeshPrismEffectEvent = null;
  2595. }
  2596. draw_GeometryMeshPrismEffectEvent = new GeometryMeshPrismEffect({
  2597. view:m_view,
  2598. m_map,
  2599. items:items,
  2600. startHeight:startHeight,
  2601. rings:geometry.rings
  2602. });
  2603. m_map.add(draw_GeometryMeshPrismEffectEvent.graphicsLayer);
  2604. })
  2605. addDrawEvent.updateListenerEvent((geometry)=>{
  2606. if(draw_GeometryMeshPrismEffectEvent){
  2607. draw_GeometryMeshPrismEffectEvent.clear();
  2608. draw_GeometryMeshPrismEffectEvent = null;
  2609. }
  2610. draw_GeometryMeshPrismEffectEvent = new GeometryMeshPrismEffect({
  2611. view:m_view,
  2612. m_map,
  2613. items:items,
  2614. startHeight:startHeight,
  2615. rings:geometry.rings
  2616. });
  2617. m_map.add(draw_GeometryMeshPrismEffectEvent.graphicsLayer);
  2618. })
  2619. }
  2620. function symbolPathPipe(params){
  2621. let status = params.status;
  2622. let f_layer = m_map.layers.find(item => item.id === "symbolPathPipeEvent");
  2623. if (f_layer) {
  2624. m_map.remove(f_layer);
  2625. }
  2626. if(status === "hide"){
  2627. return
  2628. }
  2629. // params.paths = Path.paths
  2630. symbolPathPipeEvent = new SymbolPathPipeEvent({
  2631. view:m_view,
  2632. paths:params.paths,
  2633. })
  2634. m_map.add(symbolPathPipeEvent.graphicsLayer);
  2635. }
  2636. function symbolPointCube(params){
  2637. let status = params.status;
  2638. let f_layer = m_map.layers.find(item => item.id === "symbolPointCubeEvent");
  2639. if (f_layer) {
  2640. m_map.remove(f_layer);
  2641. }
  2642. if(status === "hide"){
  2643. return
  2644. }
  2645. symbolPointCubeEvent = new SymbolPointCubeEvent({
  2646. view:m_view,
  2647. points:params.points,
  2648. size:params.size,
  2649. })
  2650. m_map.add(symbolPointCubeEvent.graphicsLayer);
  2651. }
  2652. function addGraphics(params){
  2653. let status = params.status;
  2654. let id = params.id;
  2655. if(status === "hide"){
  2656. let idGraphic = m_view.graphics.find(item => item.id === id);
  2657. if(idGraphic){
  2658. m_view.graphics.remove(idGraphic);
  2659. }
  2660. return
  2661. }
  2662. let idGraphic = m_view.graphics.find(item => item.id === id);
  2663. if(idGraphic && JSON.stringify(params.data.geometry) == JSON.stringify(idGraphic.geometry)){
  2664. return
  2665. }else{
  2666. m_view.graphics.remove(idGraphic);
  2667. addGraphicsEvent = new AddGraphicsEvent({
  2668. id,
  2669. view:m_view,
  2670. data:params.data,
  2671. imgType:params.imgType
  2672. })
  2673. }
  2674. }
  2675. function featurePointsPlotting(params){
  2676. let status = params.status;
  2677. let f_layer = m_map.layers.find(item => item.id === "featurePointsPlottingEvent");
  2678. if (f_layer) {
  2679. m_map.remove(f_layer);
  2680. }
  2681. if(status === "hide"){
  2682. return
  2683. }
  2684. //params.data = Path.paths_point;
  2685. featurePointsPlottingEvent = new FeaturePointsPlottingEvent({
  2686. view:m_view,
  2687. data:params.data,
  2688. imgType:params.imgType
  2689. })
  2690. m_map.add(featurePointsPlottingEvent.featureLayer);
  2691. }
  2692. function featurePolygonPlotting(params){
  2693. let status = params.status;
  2694. let id = params.id;
  2695. let p_layer = m_map.layers.find(item => item.id === id+"_polygon");
  2696. if (p_layer) {
  2697. m_map.remove(p_layer);
  2698. }
  2699. let t_layer = m_map.layers.find(item => item.id === id+"_text");
  2700. if (t_layer) {
  2701. m_map.remove(t_layer);
  2702. }
  2703. if(status === "hide"){
  2704. return
  2705. }
  2706. let showText = false;
  2707. if(params.showText){
  2708. showText = params.showText;
  2709. }
  2710. featurePointsPlottingEvent = new FeaturePolygonPlottingEvent({
  2711. id,
  2712. view:m_view,
  2713. data:params.data,
  2714. showText:showText
  2715. });
  2716. }
  2717. function flowPathEffect(params){
  2718. let status = params.status;
  2719. if(addFlowPathEvent){
  2720. addFlowPathEvent.clear();
  2721. addFlowPathEvent = null;
  2722. }
  2723. if(status === "hide"){
  2724. return
  2725. }
  2726. addFlowPathEvent = new AddFlowPathEvent({
  2727. view:m_view,
  2728. paths:params.paths,
  2729. color:params.color,
  2730. pipeRadius:params.pipeRadius
  2731. })
  2732. addFlowPathEvent.start()
  2733. }
  2734. function movePoint(params){
  2735. let status = params.status;
  2736. const connectFlyPointWebSocket = (status) => {
  2737. if(status === "show"){
  2738. if(flyPointSocket){
  2739. flyPointSocket.send(JSON.stringify({
  2740. "flightIdS": ["EFF7AE7B8B044436997F93F327819C20","18207414-c19e-4233-87e2-e6e4743fdea0"],
  2741. "messageCode": 1,
  2742. "isShow": true
  2743. }));
  2744. }else{
  2745. flyPointSocket = new WebSocket('ws://172.16.8.44:9250/low-altitude/flight/data/websocket');
  2746. flyPointSocket.onopen = () => {
  2747. console.log('WebSocket 连接成功');
  2748. };
  2749. flyPointSocket.onmessage = (messageEvent) => {
  2750. showThreeCubeDetail({
  2751. "id":"movePointCube",
  2752. "status":"hide"
  2753. })
  2754. let messages = JSON.parse(messageEvent.data);
  2755. if(movePointEvent){
  2756. movePointEvent.update(messages)
  2757. }else{
  2758. movePointEvent = new MovePointStreamEvent({
  2759. view:m_view,
  2760. map:m_map,
  2761. data:messages
  2762. });
  2763. }
  2764. let data = [];
  2765. let points = []
  2766. if(messages.length > 0){
  2767. messages.forEach((item)=>{
  2768. if(item.surroundGrid != null&&item.surroundGrid.length > 0){
  2769. if(ShowMovePointCube) {
  2770. data = data.concat(item.surroundGrid);
  2771. }else {
  2772. item.surroundGrid.forEach((index)=>{
  2773. if(index.color[0] =1 && index.color[1] == 0 && index.color[2] == 0){
  2774. data.push(index)
  2775. }
  2776. })
  2777. }
  2778. }
  2779. points.push([item.x,item.y,item.z])
  2780. })
  2781. if(data.length > 0){
  2782. showThreeCubeDetail({
  2783. "id":"movePointCube",
  2784. "status":"show",
  2785. "size": {
  2786. x:data[0].boxSize.latLength,
  2787. y:data[0].boxSize.lonLength,
  2788. z:data[0].boxSize.height
  2789. },
  2790. "deepOpacity":true,
  2791. "points":data,
  2792. "depthTest":false
  2793. })
  2794. }
  2795. if(points.length > 0){
  2796. addLightBall({
  2797. id:"ball",
  2798. status:"show",
  2799. points:points,
  2800. })
  2801. }
  2802. }
  2803. };
  2804. flyPointSocket.onerror = (error) => {
  2805. console.error('WebSocket 出错:', error);
  2806. };
  2807. flyPointSocket.onclose = () => {
  2808. console.log('WebSocket 连接已关闭');
  2809. };
  2810. }
  2811. }else{
  2812. if(flyPointSocket){
  2813. if(movePointEvent){
  2814. movePointEvent.clear();
  2815. movePointEvent = null;
  2816. }
  2817. showThreeCubeDetail({
  2818. "id":"movePointCube",
  2819. "status":"hide"
  2820. });
  2821. addLightBall({
  2822. id:"ball",
  2823. status:"hide"
  2824. })
  2825. flyPointSocket.close();
  2826. flyPointSocket = null
  2827. }
  2828. }
  2829. };
  2830. connectFlyPointWebSocket(status);
  2831. }
  2832. function movePaths(params){
  2833. let status = params.status;
  2834. if(status === "show"){
  2835. queryPathsInfo().then(res=>{
  2836. if(res.data.code === 200){
  2837. let data = res.data.data;
  2838. data.forEach((item)=>{
  2839. pathPipe({
  2840. id:item.id,
  2841. status:"show",
  2842. paths:JSON.parse(item.shape).paths,
  2843. color: "#438EDB",
  2844. intensity: 1.2,
  2845. pipeRadius: 5
  2846. })
  2847. })
  2848. }
  2849. })
  2850. }else{
  2851. queryPathsInfo().then(res=>{
  2852. if(res.data.code === 200){
  2853. let data = res.data.data;
  2854. data.forEach((item)=>{
  2855. pathPipe({
  2856. id:item.id,
  2857. status:"hide"
  2858. })
  2859. })
  2860. }
  2861. })
  2862. }
  2863. }
  2864. function showMovePointCube(params){
  2865. let status = params.status;
  2866. if(status == "show"){
  2867. ShowMovePointCube = true;
  2868. }else{
  2869. ShowMovePointCube = false;
  2870. }
  2871. }
  2872. //获取当前场景
  2873. function getOccupyCube(params){
  2874. let id = params.id;
  2875. let status = params.status;
  2876. let level = params.level;
  2877. let minZ = params.minZ;
  2878. let maxZ = params.maxZ;
  2879. let rings = params.rings;
  2880. let fields = params.fields;
  2881. let deepShow = params.deepShow;
  2882. // if(status === "hide"){
  2883. // showThreeCubeDetail({
  2884. // id:"test",
  2885. // status:"hide"
  2886. // });
  2887. // currentShowGridParams = null;
  2888. // return
  2889. // }
  2890. // //备用方案:根据rings四至范围生成矩形面,获取左下角的点为原点,距离分别为长、宽
  2891. //
  2892. // let { origin,length,width } = createBoundingBoxFromRings(rings);
  2893. //
  2894. // debugger
  2895. // const cubeGrid = generateGrid({
  2896. // x:origin[0],
  2897. // y:origin[1],
  2898. // z:minZ,
  2899. // }, length, width, maxZ-minZ,32);
  2900. // showThreeCubeDetail({
  2901. // "id":"test",
  2902. // "status":"show",
  2903. // "size": {
  2904. // x:32,
  2905. // y:32,
  2906. // z:32
  2907. // },
  2908. // "points":cubeGrid,
  2909. // "depthTest":false
  2910. // })
  2911. if(status === "hide"){
  2912. showThreeCubeDetail({
  2913. id:params.id,
  2914. status:"hide"
  2915. });
  2916. currentShowGridParams = null;
  2917. return
  2918. }
  2919. showThreeCubeDetail({
  2920. id:params.lastId,
  2921. status:"hide"
  2922. });
  2923. currentShowGridParams = {
  2924. id,
  2925. level,
  2926. minZ,
  2927. maxZ,
  2928. rings,
  2929. fields
  2930. };
  2931. getOccupyByPolygon({
  2932. id,
  2933. status,
  2934. minZ,
  2935. maxZ,
  2936. level,
  2937. fields,
  2938. rings,
  2939. deepShow,
  2940. scrollId:""
  2941. });
  2942. }
  2943. // 获取当前场景-递归获取权重数据
  2944. function getOccupyByPolygon(params) {
  2945. debugger
  2946. getOccupyPointByPolygon({
  2947. minZ:params.minZ,
  2948. maxZ:params.maxZ,
  2949. level: params.level,
  2950. rings: params.rings,
  2951. fields: params.fields,
  2952. scrollId: params.scrollId,
  2953. }).then(res =>{
  2954. if(JSON.stringify(currentShowGridParams) === JSON.stringify({
  2955. id:params.id,
  2956. level:params.level,
  2957. minZ:params.minZ,
  2958. maxZ:params.maxZ,
  2959. rings:params.rings,
  2960. fields:params.fields,
  2961. })){
  2962. if(res.data.data.list?.length >= 100000 && res.data.data.scrollId){
  2963. let length = 8;
  2964. for(let i=0;i<15-params.level;i++){
  2965. length = length * 2;
  2966. }
  2967. let size = {
  2968. x:length,
  2969. y:length,
  2970. z:length
  2971. }
  2972. showThreeCubeDetail({
  2973. "id":params.id,
  2974. "status":params.status,
  2975. "size":size,
  2976. "points":res.data.data.list,
  2977. "depthTest":params.deepShow?params.deepShow:false
  2978. })
  2979. params.scrollId = res.data.data.scrollId;
  2980. getOccupyByPolygon(params);
  2981. }else{
  2982. if(res.data.data.list?.length > 0){
  2983. let length = 8;
  2984. for(let i=0;i<15-params.level;i++){
  2985. length = length * 2;
  2986. }
  2987. let size = {
  2988. x:length,
  2989. y:length,
  2990. z:length
  2991. }
  2992. showThreeCubeDetail({
  2993. "id":params.id,
  2994. "status":params.status,
  2995. "size":size,
  2996. "points":res.data.data.list,
  2997. "depthTest":params.deepShow?params.deepShow:false
  2998. })
  2999. }
  3000. }
  3001. }
  3002. })
  3003. }
  3004. function generateGrid(startPoint,xRange, yRange, zRange, size) {
  3005. const grid = [];
  3006. // 计算每个方向的立方体数量
  3007. const xCount = Math.ceil(xRange / size);
  3008. const yCount = Math.ceil(yRange / size);
  3009. const zCount = Math.ceil(zRange / size);
  3010. // 生成网格点
  3011. for (let x = 0; x < xCount; x++) {
  3012. for (let y = 0; y < yCount; y++) {
  3013. for (let z = 0; z < zCount; z++) {
  3014. grid.push({
  3015. x: startPoint.x* 1 + x * size,
  3016. y: startPoint.y * 1 + y * size,
  3017. z: startPoint.z * 1 + z * size,
  3018. color: [0,1,1]
  3019. });
  3020. }
  3021. }
  3022. }
  3023. return grid;
  3024. }
  3025. function createBoundingBoxFromRings(rings) {
  3026. // 初始化四至范围
  3027. let xmin = Infinity, ymin = Infinity;
  3028. let xmax = -Infinity, ymax = -Infinity;
  3029. // 遍历所有点找到四至范围
  3030. rings.forEach(ring => {
  3031. ring.forEach(point => {
  3032. const [x, y] = point;
  3033. xmin = Math.min(xmin, x);
  3034. ymin = Math.min(ymin, y);
  3035. xmax = Math.max(xmax, x);
  3036. ymax = Math.max(ymax, y);
  3037. });
  3038. });
  3039. // 创建矩形面坐标
  3040. const rectangle = [
  3041. [xmin, ymin], // 左下
  3042. [xmax, ymin], // 右下
  3043. [xmax, ymax], // 右上
  3044. [xmin, ymax], // 左上
  3045. [xmin, ymin] // 闭合
  3046. ];
  3047. return {
  3048. origin: [xmin, ymin], // 原点
  3049. length: xmax - xmin, // 长度
  3050. width: ymax - ymin
  3051. };
  3052. }
  3053. //获取当前场景
  3054. function getPowerCube(params){
  3055. let id = params.id;
  3056. let status = params.status;
  3057. let level = params.level;
  3058. let minZ = params.minZ;
  3059. let maxZ = params.maxZ;
  3060. let deepShow = params.deepShow;
  3061. let rings = params.rings;
  3062. let fields = params.fields;
  3063. // if(status === "hide"){
  3064. // showThreeCubeDetail({
  3065. // id:"test",
  3066. // status:"hide"
  3067. // });
  3068. // currentShowGridParams = null;
  3069. // return
  3070. // }
  3071. // //备用方案:根据rings四至范围生成矩形面,获取左下角的点为原点,距离分别为长、宽
  3072. //
  3073. // let { origin,length,width } = createBoundingBoxFromRings(rings);
  3074. //
  3075. // debugger
  3076. // const cubeGrid = generateGrid({
  3077. // x:origin[0],
  3078. // y:origin[1],
  3079. // z:minZ,
  3080. // }, length, width, maxZ-minZ,32);
  3081. // showThreeCubeDetail({
  3082. // "id":"test",
  3083. // "status":"show",
  3084. // "size": {
  3085. // x:32,
  3086. // y:32,
  3087. // z:32
  3088. // },
  3089. // "points":cubeGrid,
  3090. // "depthTest":false
  3091. // })
  3092. //
  3093. if(status === "hide"){
  3094. showThreeCubeDetail({
  3095. id:params.id,
  3096. status:"hide"
  3097. });
  3098. currentShowGridParams = null;
  3099. return
  3100. }
  3101. currentShowGridParams = {
  3102. id,
  3103. level,
  3104. minZ,
  3105. maxZ,
  3106. rings,
  3107. fields
  3108. };
  3109. getSixPowerByPolygon({
  3110. id,
  3111. status,
  3112. minZ,
  3113. maxZ,
  3114. level,
  3115. fields,
  3116. rings,
  3117. deepShow,
  3118. scrollId:"",
  3119. });
  3120. }
  3121. // 获取当前场景-递归获取权重数据
  3122. function getSixPowerByPolygon(params) {
  3123. getPowerPointByPolygon({
  3124. minZ:params.minZ,
  3125. maxZ:params.maxZ,
  3126. level: params.level,
  3127. rings: params.rings,
  3128. fields: params.fields,
  3129. scrollId: params.scrollId,
  3130. }).then(res =>{
  3131. if(JSON.stringify(currentShowGridParams) === JSON.stringify({
  3132. id:params.id,
  3133. level:params.level,
  3134. minZ:params.minZ,
  3135. maxZ:params.maxZ,
  3136. rings:params.rings,
  3137. fields:params.fields,
  3138. })){
  3139. if(res.data.data.list?.length >= 100000 && res.data.data.scrollId){
  3140. let length = 8;
  3141. for(let i=0;i<15-params.level;i++){
  3142. length = length * 2;
  3143. }
  3144. let size = {
  3145. x:length,
  3146. y:length,
  3147. z:length
  3148. }
  3149. showThreeCubeDetail({
  3150. "id":params.id,
  3151. "status":params.status,
  3152. "size":size,
  3153. "points":res.data.data.list,
  3154. "depthTest":params.deepShow?params.deepShow:false
  3155. })
  3156. params.scrollId = res.data.data.scrollId;
  3157. getSixPowerByPolygon(params);
  3158. }else{
  3159. if(res.data.data.list?.length > 0){
  3160. let length = 8;
  3161. for(let i=0;i<15-params.level;i++){
  3162. length = length * 2;
  3163. }
  3164. let size = {
  3165. x:length,
  3166. y:length,
  3167. z:length
  3168. }
  3169. showThreeCubeDetail({
  3170. "id":params.id,
  3171. "status":params.status,
  3172. "size":size,
  3173. "points":res.data.data.list,
  3174. "depthTest":params.deepShow?params.deepShow:false
  3175. })
  3176. }
  3177. }
  3178. }
  3179. })
  3180. }
  3181. function getFunnelCube(params){
  3182. let id = params.id;
  3183. let status = params.status;
  3184. let level = params.level;
  3185. let coneHeight = params.coneHeight;
  3186. let cylinderHeight = params.cylinderHeight;
  3187. let topRadius = params.topRadius;
  3188. let bottomRadius = params.bottomRadius;
  3189. let point = params.point;
  3190. if(status === "hide"){
  3191. showThreeCubeDetail({
  3192. id:params.id+ "23",
  3193. status:"hide"
  3194. });
  3195. showThreeCubeDetail({
  3196. id:params.id+ "24",
  3197. status:"hide"
  3198. });
  3199. currentShowGridParams = null;
  3200. return
  3201. }
  3202. currentShowGridParams = id;
  3203. getSixPowerByFunnel({
  3204. id,
  3205. status,
  3206. coneHeight,
  3207. cylinderHeight,
  3208. level,
  3209. topRadius,
  3210. bottomRadius,
  3211. point
  3212. });
  3213. }
  3214. function getSixPowerByFunnel(params){
  3215. getPowerPointByFunnel({
  3216. point:params.point,
  3217. coneHeight:params.coneHeight,
  3218. cylinderHeight:params.cylinderHeight,
  3219. level: params.level,
  3220. topRadius: params.topRadius,
  3221. bottomRadius: params.bottomRadius,
  3222. }).then(res =>{
  3223. //处理返回网格结果
  3224. feedbackCubeResult(params,res)
  3225. }).catch(()=>{
  3226. feedbackErrorResult()
  3227. })
  3228. }
  3229. function getFrustumConeCube(params){
  3230. let id = params.id;
  3231. let lastId = params.lastId;
  3232. let status = params.status;
  3233. let level = params.level;
  3234. let height = params.height;
  3235. let topRadius = params.topRadius;
  3236. let bottomRadius = params.bottomRadius;
  3237. let point = params.point;
  3238. if(status === "hide"){
  3239. showThreeCubeDetail({
  3240. id:params.id+ "23",
  3241. status:"hide"
  3242. });
  3243. showThreeCubeDetail({
  3244. id:params.id+ "24",
  3245. status:"hide"
  3246. });
  3247. currentShowGridParams = null;
  3248. return
  3249. }
  3250. currentShowGridParams = id;
  3251. getSixPowerByFrustumCone({
  3252. id,
  3253. status,
  3254. height,
  3255. level,
  3256. topRadius,
  3257. bottomRadius,
  3258. point
  3259. });
  3260. }
  3261. function getSixPowerByFrustumCone(params){
  3262. getPowerPointByFrustumCone({
  3263. point:params.point,
  3264. height:params.height,
  3265. level: params.level,
  3266. topRadius: params.topRadius,
  3267. bottomRadius: params.bottomRadius,
  3268. }).then(res =>{
  3269. //处理返回网格结果
  3270. feedbackCubeResult(params,res)
  3271. }).catch(()=>{
  3272. feedbackErrorResult()
  3273. })
  3274. }
  3275. function getInvertedConeCube(params){
  3276. let id = params.id;
  3277. let status = params.status;
  3278. let level = params.level;
  3279. let height = params.height;
  3280. let radius = params.radius;
  3281. let point = params.point;
  3282. if(status === "hide"){
  3283. showThreeCubeDetail({
  3284. id:params.id+ "23",
  3285. status:"hide"
  3286. });
  3287. showThreeCubeDetail({
  3288. id:params.id+ "24",
  3289. status:"hide"
  3290. });
  3291. currentShowGridParams = null;
  3292. return
  3293. }
  3294. currentShowGridParams = id;
  3295. getSixPowerByInvertedCone({
  3296. id,
  3297. status,
  3298. height,
  3299. level,
  3300. radius,
  3301. point
  3302. });
  3303. }
  3304. function getSixPowerByInvertedCone(params){
  3305. getPowerPointByInvertedCone({
  3306. point:params.point,
  3307. height:params.height,
  3308. level: params.level,
  3309. radius: params.radius,
  3310. }).then(res =>{
  3311. //处理返回网格结果
  3312. feedbackCubeResult(params,res)
  3313. }).catch(()=>{
  3314. feedbackErrorResult()
  3315. })
  3316. }
  3317. //查询圆柱体
  3318. function getCylinderCube(params){
  3319. let id = params.id;
  3320. let status = params.status;
  3321. let level = params.level;
  3322. let height = params.height;
  3323. let rings = params.rings;
  3324. if(status === "hide"){
  3325. showThreeCubeDetail({
  3326. id:params.id+ "23",
  3327. status:"hide"
  3328. });
  3329. showThreeCubeDetail({
  3330. id:params.id+ "24",
  3331. status:"hide"
  3332. });
  3333. currentShowGridParams = null;
  3334. return
  3335. }
  3336. currentShowGridParams = id;
  3337. getSixPowerByPrism({
  3338. id,
  3339. status,
  3340. height,
  3341. level,
  3342. rings
  3343. });
  3344. }
  3345. //查询长方体
  3346. function getCuboidCube(params){
  3347. let id = params.id;
  3348. let lastId = params.lastId;
  3349. let status = params.status;
  3350. let level = params.level;
  3351. let height = params.height;
  3352. let rings = params.rings;
  3353. if(status === "hide"){
  3354. showThreeCubeDetail({
  3355. id:params.id+ "23",
  3356. status:"hide"
  3357. });
  3358. showThreeCubeDetail({
  3359. id:params.id+ "24",
  3360. status:"hide"
  3361. });
  3362. currentShowGridParams = null;
  3363. return
  3364. }
  3365. currentShowGridParams = id;
  3366. getSixPowerByPrism({
  3367. id,
  3368. status,
  3369. height,
  3370. level,
  3371. rings
  3372. });
  3373. }
  3374. //查询棱柱体
  3375. function getPrismCube(params){
  3376. let id = params.id;
  3377. let status = params.status;
  3378. let level = params.level;
  3379. let height = params.height;
  3380. let rings = params.rings;
  3381. if(status === "hide"){
  3382. showThreeCubeDetail({
  3383. id:params.id+ "23",
  3384. status:"hide"
  3385. });
  3386. showThreeCubeDetail({
  3387. id:params.id+ "24",
  3388. status:"hide"
  3389. });
  3390. currentShowGridParams = null;
  3391. return
  3392. }
  3393. currentShowGridParams = id;
  3394. getSixPowerByPrism({
  3395. id,
  3396. status,
  3397. height,
  3398. level,
  3399. rings
  3400. });
  3401. }
  3402. function getSixPowerByPrism(params){
  3403. getPowerPointByPrism({
  3404. rings:params.rings,
  3405. height:params.height,
  3406. level: params.level
  3407. }).then(res =>{
  3408. //处理返回网格结果
  3409. feedbackCubeResult(params,res)
  3410. }).catch(()=>{
  3411. feedbackErrorResult()
  3412. })
  3413. }
  3414. //查询航线
  3415. function getPathCube(params){
  3416. let id = params.id;
  3417. let status = params.status;
  3418. let level = params.level;
  3419. let radius = params.radius;
  3420. let originPaths = params.paths;
  3421. if(status === "hide"){
  3422. showThreeCubeDetail({
  3423. id:params.id+ "23",
  3424. status:"hide"
  3425. });
  3426. showThreeCubeDetail({
  3427. id:params.id+ "24",
  3428. status:"hide"
  3429. });
  3430. currentShowGridParams = null;
  3431. return
  3432. }
  3433. let paths = [];
  3434. originPaths[0].forEach((item)=>{
  3435. paths.push({
  3436. x:item[0],
  3437. y:item[1],
  3438. z:item[2]
  3439. })
  3440. })
  3441. currentShowGridParams = id;
  3442. getSixPowerByPath({
  3443. id,
  3444. status,
  3445. radius,
  3446. level,
  3447. paths
  3448. });
  3449. }
  3450. function getSixPowerByPath(params){
  3451. getPowerPointByPath({
  3452. paths:params.paths,
  3453. radius:params.radius,
  3454. level: params.level
  3455. }).then(res =>{
  3456. //处理返回网格结果
  3457. feedbackCubeResult(params,res);
  3458. }).catch(()=>{
  3459. feedbackErrorResult()
  3460. })
  3461. }
  3462. function feedbackCubeResult(params,res){
  3463. bus.emit('SendMessage',{
  3464. action:"CubeResult",
  3465. data:{
  3466. "message":{
  3467. "time":new Date().getTime(),
  3468. "data":"success"
  3469. }
  3470. }
  3471. })
  3472. if(res.data.data?.list?.length>0){
  3473. showThreeCubeDetail({
  3474. "id":params.id+ "23",
  3475. "status":params.status,
  3476. "size": {
  3477. x:res.data.data.list[0].boxSize.latLength,
  3478. y:res.data.data.list[0].boxSize.lonLength,
  3479. z:res.data.data.list[0].boxSize.height
  3480. },
  3481. "points":res.data.data.list,
  3482. "depthTest":false
  3483. })
  3484. }
  3485. if(res.data.data?.listInfo?.length>0){
  3486. showThreeCubeDetail({
  3487. "id":params.id+ "24",
  3488. "status":params.status,
  3489. "size": {
  3490. x:res.data.data.listInfo[0].boxSize.latLength,
  3491. y:res.data.data.listInfo[0].boxSize.lonLength,
  3492. z:res.data.data.listInfo[0].boxSize.height
  3493. },
  3494. "points":res.data.data.listInfo,
  3495. "depthTest":false
  3496. })
  3497. }
  3498. }
  3499. function feedbackErrorResult(){
  3500. bus.emit('SendMessage',{
  3501. action:"CubeResult",
  3502. data:{
  3503. "message":{
  3504. "time":new Date().getTime(),
  3505. "data":"error"
  3506. }
  3507. }
  3508. })
  3509. }
  3510. function getBasePrism(params){
  3511. getPrism({
  3512. paths:params.paths,
  3513. radius:params.radius,
  3514. level: params.level
  3515. }).then(res =>{
  3516. let data = res.data.data;
  3517. let showData = [];
  3518. data.forEach((item)=>{
  3519. let newShape = JSON.parse(item.shape);
  3520. newShape.color = "red"
  3521. showData.push({
  3522. attributes:{
  3523. id:item.id,
  3524. name:item.name,
  3525. height:newShape.height,
  3526. },
  3527. type:item.geoType,
  3528. shape: newShape
  3529. })
  3530. })
  3531. geometryMeshEffect({
  3532. "status": "show",
  3533. "id": "drawOne",
  3534. "data": showData
  3535. })
  3536. })
  3537. }
  3538. function getBasePath(params){
  3539. getPath({
  3540. paths:params.paths,
  3541. radius:params.radius,
  3542. level: params.level
  3543. }).then(res =>{
  3544. let data = res.data.data;
  3545. let showData = [];
  3546. data.forEach((item)=>{
  3547. let newShape = JSON.parse(item.shape);
  3548. newShape.color = "green"
  3549. showData.push({
  3550. type:"polyline",
  3551. shape: newShape
  3552. })
  3553. })
  3554. geometryMeshEffect({
  3555. "status": "show",
  3556. "id": "drawOne",
  3557. "data": showData
  3558. })
  3559. })
  3560. }
  3561. function getBaseQJC(params){
  3562. getQJC({
  3563. paths:params.paths,
  3564. radius:params.radius,
  3565. level: params.level
  3566. }).then(res =>{
  3567. let data = res.data.data;
  3568. let showData = [];
  3569. data.forEach((item)=>{
  3570. let newShape = JSON.parse(item.shape);
  3571. newShape.color = "green"
  3572. showData.push({
  3573. type:item.geoType,
  3574. shape: newShape
  3575. })
  3576. })
  3577. geometryMeshEffect({
  3578. "status": "show",
  3579. "id": "drawOne",
  3580. "data": showData
  3581. })
  3582. })
  3583. }
  3584. function radarEffect(params){
  3585. let status = params.status;
  3586. let id = params.id;
  3587. if(radarEffectInstance[id]){
  3588. radarEffectInstance[id].clear();
  3589. radarEffectInstance[id] = null;
  3590. }
  3591. if(status === "hide"){
  3592. return
  3593. }
  3594. let points = params.points;
  3595. let radarEffectInstance = new AddRadarEffectEvent({
  3596. view:m_view,
  3597. points
  3598. })
  3599. radarEffectInstance.start()
  3600. // 保存实例
  3601. lightBallInstance[id] = radarEffectInstance;
  3602. }
  3603. })
  3604. }
  3605. }
  3606. </script>
  3607. <style scoped lang="scss">
  3608. #map_jk,#mapDiv,#viewDiv{
  3609. height: 100%;
  3610. }
  3611. :deep(.esri-view-surface--touch-none::after){
  3612. outline: none !important;
  3613. }
  3614. </style>