DrawTools.js 238 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871
  1. /**
  2. * 创建者:王成
  3. * 操作系统:MAC
  4. * 创建日期:2022年11月10日
  5. * 描述:该类主要是绘制工具 提供各种绘制方法
  6. */
  7. /* 引入Cesium */
  8. // import * as Cesium from 'cesium';
  9. /* 引入地理工具箱 */
  10. import * as turf from '@turf/turf'
  11. /* 引入属性编辑框 */
  12. import DialogEditProperty from './CrEditProperty.ce.vue'
  13. /* 引入组件注册 */
  14. import {
  15. defineCustomElement
  16. } from 'vue'
  17. /* 扩展数组方法 */
  18. /**
  19. * 获取数组最后一个元素
  20. */
  21. Array.prototype.last = function() {
  22. if (this === undefined || this.length === undefined || this.length === 0) return undefined;
  23. return this[this.length - 1];
  24. }
  25. /**
  26. * 获取数组第一个元素
  27. */
  28. Array.prototype.first = function() {
  29. if (this === undefined || this.length === undefined || this.length === 0) return undefined;
  30. return this[0];
  31. }
  32. /**
  33. * 设置编辑点类型
  34. * @ignore 生成方法时不对外公开
  35. * @param {options} options 配置项
  36. * @param {DrawTools.EditPointType} options.type 类型
  37. * @param {Number} options.index 索引
  38. */
  39. Cesium.Entity.prototype.setEditType = function(options) {
  40. this._editType = options;
  41. }
  42. /**
  43. * 获取编辑点类型
  44. * @ignore 生成方法时不对外公开
  45. * @return {DrawTools.EditPointType} 编辑点类型
  46. */
  47. Cesium.Entity.prototype.getEditType = function() {
  48. return this._editType;
  49. }
  50. /**
  51. * 设置实体挂接的数据类型
  52. * @ignore 生成方法时不对外公开
  53. * @param {DrawTools.DrawType} entityType 实体挂接的数据类型
  54. */
  55. Cesium.Entity.prototype.setEntityType = function(entityType) {
  56. this._entityType = entityType;
  57. }
  58. /**
  59. * 获取实体挂接的数据类型
  60. * @ignore 生成方法时不对外公开
  61. * @@return {DrawTools.DrawType} 实体挂接的数据类型
  62. */
  63. Cesium.Entity.prototype.getEntityType = function(entityType) {
  64. return this._entityType;
  65. }
  66. /**
  67. * 设置实体是否可编辑
  68. * @ignore 生成方法时不对外公开
  69. * @param {Boolean} isEdit 是否可编辑
  70. */
  71. Cesium.Entity.prototype.setIsEdit = function(isEdit) {
  72. this._isEdit = isEdit;
  73. }
  74. /**
  75. * 获取实体是否可编辑
  76. * @ignore 生成方法时不对外公开
  77. * @return {Boolean} isEdit
  78. */
  79. Cesium.Entity.prototype.getIsEdit = function() {
  80. return this._isEdit;
  81. }
  82. /**
  83. * 设置附加参数
  84. * @ignore 生成方法时不对外公开
  85. * @param {JSON} params 参数
  86. */
  87. Cesium.Entity.prototype.setParams = function(params) {
  88. this._params = params;
  89. }
  90. /**
  91. * 获取附加参数
  92. * @ignore 生成方法时不对外公开
  93. */
  94. Cesium.Entity.prototype.getParams = function() {
  95. return this._params;
  96. }
  97. /**
  98. * 绑定实体
  99. * @ignore 生成方法时不对外公开
  100. * @param {Cesium.Entity} entity 绑定的实体
  101. */
  102. Cesium.Entity.prototype.bindEntity = function(entity) {
  103. this._bindEntity = entity;
  104. }
  105. /**
  106. * 获取绑定的实体
  107. * @ignore 生成方法时不对外公开
  108. * @return {Cesium.Entity}
  109. */
  110. Cesium.Entity.prototype.getBindEntity = function() {
  111. return this._bindEntity;
  112. }
  113. /**
  114. * 类
  115. */
  116. class DrawTools {
  117. /**
  118. * 默认初始化
  119. * @ignore 生成方法时不对外公开
  120. * @param {Object} viewer 三维场景
  121. * @param {JSON} options [配置项]
  122. * @param {Boolean} options.isDrawPoint 是否绘标记点
  123. * @param {Boolean} options.isRetainDrawPoint 绘制完成,是否保留绘制点
  124. * @param {DrawTools.SketchIconType} options.iconType 点图标类型
  125. */
  126. constructor(viewer, options) {
  127. /* 赋值三维视图 */
  128. this._viewer = viewer;
  129. /* 初始化 */
  130. this._init(options);
  131. }
  132. /**
  133. * 静态方法 初始化并获取属性编辑参数
  134. */
  135. static initEditPropertyParams() {
  136. return {
  137. id: undefined, //用于标识及传递当前编辑的实体类型 内容为DrawTools.DrawType
  138. height: 20, //用于高度标识 如墙、房屋等 或OD线的中间顶点高度
  139. bottomHeight: 0, //用于标识底部高度值 如 墙、房屋等
  140. color: 'rgba(0,255,0,0.75)', //用于颜色标识
  141. direction: 'horizontal', //用于动态方向 取值为horizontal/vertical
  142. order: '-', //用于标识动态流动方向 取值范围为+/-
  143. count: 2, //用于标识动态子元素的数量
  144. text: '', //用于标识文本
  145. lineWidth: 0, //用于标识线宽
  146. power: 0.25, //用于标识发光度[0-1]
  147. outlineWidth: 0, //用于标识描边线宽度
  148. outlineColor: 'rgba(255,255,255,1)', //用于标识描边线颜色
  149. videoUrl: '', //用于标识视频播放地址
  150. duration: 1500, //默认播放速度
  151. odlineHeight: 1000, //OD线的弧顶高度
  152. odlineCount: 50, //OD线的插值数量
  153. axisX: 0, //X坐标轴 平移距离
  154. axisY: 0, //Y坐标轴 平移距离
  155. axisZ: 0, //Z坐标轴 平移距离
  156. }
  157. }
  158. /**
  159. * 初始化
  160. * @ignore 生成方法时不对外公开
  161. * @param {JSON} options [配置项]
  162. * @param {Boolean} options.isDrawPoint 是否绘标记点
  163. * @param {Boolean} options.isRetainDrawPoint 绘制完成,是否保留绘制点
  164. * @param {DrawTools.SketchIconType} options.iconType 点图标类型
  165. */
  166. _init(options) {
  167. /* 开启地形检测 必须开启 否则会导致获取地形高度时异常 导致鼠标移动时位置哆嗦 */
  168. this._viewer.scene.globe.depthTestAgainstTerrain = true;
  169. /* 取消地图右键点击事件 */
  170. this._viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType
  171. .LEFT_DOUBLE_CLICK);
  172. /* 创建的临时实体的名称 该名称通用 为了后期统一删除 */
  173. this._sketchEntityName = this._guid();
  174. /* 用DataSource方式管理绘制的Entity 实现工具分离 */
  175. let dataSource = new Cesium.CustomDataSource(this._sketchEntityName);
  176. this._viewer.dataSources.add(dataSource);
  177. /* 实体数据集 */
  178. this._entities = dataSource.entities;
  179. this._pointEntitys = [];
  180. /* 草图工具绘制的点图片 */
  181. this._sketchPointImage = undefined;
  182. /* 点图标 */
  183. this._iconNormal =
  184. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcEAYAAAAinQPXAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAAASAAAAEgARslrPgAAB2FJREFUWMO9mHtQlNcZxn/nW65GxHtEqTEajUxVoLYRSIyipHG4qG0lajtxVIRFubgqXuOI28ZE7FAvCLKLSNKxg/FSIzdvqNE62kaRitqpYMxovBGigo4I4n6nfwjsCrsLrtjnn53vnPe87/Oc9/2+854VdBhCd6ZP6dMHlAXO/lOngrzMLz/8EEQ0ASNGANNY2aOHxYIdfHr3LuBCwPnzQIKcf/AgiJ8pQV99BfmvR4+orHxZVsLxpZFT0qd07gyP7zqrej3IInF47lwQkTLV3d1xv3KXWPT4MYhLzMzIgHpn10+Sk+Gw74w+jx79HwSGnzUYhg4FED4FBcBq/jtokOOC2oSb0FZUgHpKVoeHQ9GtGM/y8lcgMLxf5juDBwNDlOWnTgGvUdWz5wsQ7c179fUWzz9y0tX1BdZPILeqCpTtil9QEOT9c876K1faWqS07XeMzJFuboCXkpaX1w5hqxl14QJIKYRWCzLV5OXtDQXbon3c3c2/TeMoYvncucAgPrl40Y7fA0zv1QtMydKwb58FL7toRwbDYo3/0utB3OD8qlX2hIkLqalwO0b9+fLlUHJO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cza8XjrusH+oQEAcQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAAJCmtXYCutDwWwUr9cEAAAAASUVORK5CYII=';
  198. this._image_h_r_l =
  199. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAAgCAYAAABkS8DlAAAAAXNSR0IArs4c6QAAAFBlWElmTU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAACAKADAAQAAAABAAAAIAAAAACVLBWUAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgoZXuEHAAAC90lEQVR4Ae3WzVbbMBAG0PzBgcOa93/M7nCj2F8zUUILdDmXjWTNSLauBMz+19vbstvvl139+c5zza39sd7hUNe99mveZ/3dbs3/LF7W3j/IXbZ5hzI/Yzf7TXxux/fPY3n+W+wrOfP3Zs5P26wXk22d/bzenJf8jNf82h/73XLOh7KeS51b++fEw/R8uQfzetvzsubmbtyuPXLmteo6W/9Qv2lZ7te4fde6l6xT52Ysbf22jK3t+o7j8frdt/H1HTWe96RdY+v8OnfrX84u45kznrPm6Cde2/THnPRrW/vjK+e8OT6e61j6OZcaH/ZbfDvXy+/Qsc5Jv55TxtKOWNY/t39+bx/NSV6dk3VGrM4Zu/2fsbFW/Ou69RvGO2rOFlvq2Pwdc2w8Z/0tdpqeL/HTab0/iaWd1xt5iaWd587PyXt6evyOOT939LP8jCcv66d9fn78nsSH2cvLv3OS//p6mzvmJza3Izb+D64/ae/zR/zR3IyN+MfH/fz39+tY9j9yv9//6pw57+45/xvOfzv9ECBAgAABAt0EFADdTtx+CRAgQIDAWUAB4BoQIECAAIGGAgqAhoduywQIECBAQAHgDhAgQIAAgYYCCoCGh27LBAgQIEBAAeAOECBAgACBhgIKgIaHbssECBAgQEAB4A4QIECAAIGGAgqAhoduywQIECBAQAHgDhAgQIAAgYYCCoCGh27LBAgQIEBAAeAOECBAgACBhgIKgIaHbssECBAgQEAB4A4QIECAAIGGAgqAhoduywQIECBAQAHgDhAgQIAAgYYCCoCGh27LBAgQIEBAAeAOECBAgACBhgIKgIaHbssECBAgQEAB4A4QIECAAIGGAgqAhoduywQIECBAQAHgDhAgQIAAgYYCCoCGh27LBAgQIEBAAeAOECBAgACBhgIKgIaHbssECBAgQEAB4A4QIECAAIGGAgqAhoduywQIECBAQAHgDhAgQIAAgYYCCoCGh27LBAgQIEBAAeAOECBAgACBhgK/AX08dE/3SOoSAAAAAElFTkSuQmCC';
  200. this._image_v_b_t =
  201. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAAgCAYAAABkS8DlAAADcklEQVR4nO3di27bMAyFYdpWLuv2/o+aJfFFgxOp5VjKdjDM6rD/A4KkbZyhwIBzTMluE/s+CAAA+J/EIH1/SL9ws/KLR/5rAADwZb2S4zHIMBzVN9YOzh8QN74XAAD8HTmLt2Z3Ns3PId7vR/MB9oPihtcAAGBfOq9Lr3WOR/0Icrt5BaAxb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TempPoints = []; //临时点集合 主要为了存储鼠标移动事件临时存储点
  206. this._sketchPoints = []; //正式点集合 主要为了绘制正式图形
  207. this._sketchOutputPoints = []; //输出点集合 主要为了存储输出的经纬度坐标点集合
  208. this._sketchWallHeights = []; //墙的高度点集合
  209. /* 当前绘制的实体 */
  210. this._drawEntity = undefined;
  211. /* 点线标注 */
  212. this._lineLabel = undefined;
  213. this._polygonLabel = undefined;
  214. /* 配置是否绘制点 */
  215. if (options && options.isDrawPoint) this._isDrawPoint = options.isDrawPoint;
  216. else this._isDrawPoint = false;
  217. /* 配置绘制完成是否保留绘制点 */
  218. if (options && options.isRetainDrawPoint) this._isRetainDrawPoint = options.isRetainDrawPoint;
  219. else this._isRetainDrawPoint = false;
  220. /* 通用参数集合 */
  221. this._param = {
  222. lineWidth: 3, //线宽度
  223. lineColor: 'rgba(0,255,0,0.75)', //线颜色
  224. outlineWidth: 2, //边框宽度
  225. outlineColor: 'rgba(255,255,255,1)', //边框颜色
  226. polygonColor: 'rgba(0,255,0,0.5)', //面填充颜色
  227. wallHeight: 30, //高度 墙、房屋
  228. power: 0.25, //发光强度
  229. odlineHeight: 1000, //OD线弧顶高度
  230. odlineCount: 50, //OD线插值数量
  231. text: '金田产业集团', //立体广告默认文字
  232. duration: 1500, //动画播放速度
  233. count: 1, //动态流动 展示数量
  234. direction_h: 'horizontal', //水平方向
  235. direction_v: 'vertical', //垂直方向
  236. order_add: '+', //正向
  237. order_minus: '-', //反向
  238. houseColor: 'rgba(0,255,0,0.95)' //房屋默认填充颜色
  239. }
  240. /* 设置点符号类型 */
  241. if (options && options.iconType) {
  242. switch (options.iconType) {
  243. case DrawTools.IconType.Normal:
  244. this._sketchPointImage = this._iconNormal;
  245. break;
  246. case DrawTools.IconType.Blue:
  247. this._sketchPointImage = this._iconBlue;
  248. break;
  249. case DrawTools.IconType.Green:
  250. this._sketchPointImage = this._iconGreen;
  251. break;
  252. case DrawTools.IconType.Violet:
  253. this._sketchPointImage = this._iconViolet;
  254. break;
  255. default:
  256. this._sketchPointImage = this._iconNormal;
  257. break;
  258. }
  259. } else {
  260. this._sketchPointImage = this._iconNormal;
  261. }
  262. /* 获取画布的宽度和高度 */
  263. this._canvasWidth = this._viewer.scene.canvas.width;
  264. this._canvasHeight = this._viewer.scene.canvas.height;
  265. /* 根据运行模式调整精细度 如果运行在App上 则调整精细度 使其看起来更加的精细 */
  266. if (this._isRuntimeApp()) {
  267. /* 开启精细渲染 不要太大 否则会导致效率下降 */
  268. this._viewer._cesiumWidget._supportsImageRenderingPixelated = Cesium.FeatureDetection
  269. .supportsImageRenderingPixelated();
  270. this._viewer._cesiumWidget._forceResize = true;
  271. if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
  272. var vtxf_dpr = window.devicePixelRatio;
  273. while (vtxf_dpr >= 2.0) {
  274. vtxf_dpr /= 2.0;
  275. }
  276. this._viewer.resolutionScale = 2.6;
  277. }
  278. }
  279. }
  280. /**
  281. * 弧度转度
  282. * @ignore 生成方法时不对外公开
  283. * @param {Number} arc 弧度
  284. * @return {Number} 角度
  285. */
  286. _arcToDegree(arc) {
  287. return arc / Math.PI * 180;
  288. }
  289. /**
  290. * 普通颜色值转换为Cesium颜色
  291. * @ignore 生成方法时不对外公开
  292. * @param {int} red 红色[0~255]
  293. * @param {int} green 绿色[0~255]
  294. * @param {int} blue 蓝色[0~255]
  295. * @param {int} alpha 透明度[0~1]
  296. * @return {Cesium.Color} Cesium格式的颜色
  297. */
  298. _toColor(red, green, blue, alpha) {
  299. let normalColor = new Cesium.Color(0, 0, 0, 1.0);
  300. if (typeof red != 'number') return normalColor;
  301. if (typeof green != 'number') return normalColor;
  302. if (typeof blue != 'number') return normalColor;
  303. if (typeof alpha != 'number') return normalColor;
  304. if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255 || alpha < 0 || alpha > 1)
  305. return normalColor;
  306. return new Cesium.Color(red / 255.0, green / 255.0, blue / 255.0, alpha);
  307. }
  308. /**
  309. * 通过颜色数组转换为Cesium颜色
  310. * @ignore 生成方法时不对外公开
  311. * @param {Array} array 颜色数组
  312. * @return {Cesium.Color} Cesium格式的颜色
  313. */
  314. _toColorFromArray(array) {
  315. if (!array || array.length === undefined || array.length === 0) return new Cesium.Color(255 / 255.0, 255 /
  316. 255.0, 255 / 255.0, 1.0);
  317. let r = 255,
  318. g = 255,
  319. b = 255,
  320. a = 1.0;
  321. if (array.length === 1) {
  322. r = parseInt(array[0]);
  323. } else if (array.length === 2) {
  324. r = parseInt(array[0]);
  325. g = parseInt(array[1]);
  326. } else if (array.length === 3) {
  327. r = parseInt(array[0]);
  328. g = parseInt(array[1]);
  329. b = parseInt(array[2]);
  330. } else if (array.length >= 4) {
  331. r = parseInt(array[0]);
  332. g = parseInt(array[1]);
  333. b = parseInt(array[2]);
  334. a = parseFloat(array[3]);
  335. }
  336. return new Cesium.Color(r / 255.0, g / 255.0, b / 255.0, a);
  337. }
  338. /**
  339. * 刷新场景 刷新一帧
  340. * @ignore 生成方法时不对外公开
  341. */
  342. _updateScene() {
  343. this._viewer.scene.requestRender();
  344. }
  345. /**
  346. * 根据地形或实景或模型检测当前屏幕位置的世界坐标系位置
  347. * @ignore 生成方法时不对外公开
  348. * @param {JSON} screenPosition 屏幕坐标
  349. * @param {Number} screenPosition.x 屏幕坐标x
  350. * @param {Number} screenPosition.y 屏幕坐标y
  351. * @return {JSON} 位置信息{x,y,z}
  352. */
  353. _getScreenClickPosition(screenPosition) {
  354. let resCartesian = undefined;
  355. let ray = this._viewer.scene.camera.getPickRay(screenPosition);
  356. let position = this._viewer.scene.globe.pick(ray, this._viewer.scene);
  357. let cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
  358. if (Cesium.defined(position)) {
  359. resCartesian = {
  360. x: position.x,
  361. y: position.y,
  362. z: position.z,
  363. }
  364. }
  365. return resCartesian;
  366. }
  367. /**
  368. * 根据地形或实景或模型检测当前屏幕位置的经纬度及高度
  369. * @ignore 生成方法时不对外公开
  370. * @param {JSON} screenPoint 屏幕坐标
  371. * @param {Number} screenPoint.x 屏幕坐标x
  372. * @param {Number} screenPoint.y 屏幕坐标y
  373. * @return {JSON} 位置信息{lng,lat,height}
  374. */
  375. _getScreenClickPositionAndHeight(screenPoint) {
  376. var lng = undefined,
  377. lat = undefined,
  378. height = undefined;
  379. /* 从相机位置到 windowPosition 处的像素创建射线在世界坐标系中 */
  380. var ray = this._viewer.scene.camera.getPickRay(screenPoint);
  381. /* 找到射线与渲染的地球表面之间的交点 */
  382. var position = this._viewer.scene.globe.pick(ray, this._viewer.scene);
  383. /* 获取地理位置的制图表达 */
  384. var cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
  385. cartographic = Cesium.Cartographic.fromCartesian(position);
  386. /* 查询屏幕位置的要素 */
  387. var feature = this._viewer.scene.pick(screenPoint);
  388. if (feature === undefined && Cesium.defined(cartographic)) {
  389. lng = this._arcToDegree(cartographic.longitude);
  390. lat = this._arcToDegree(cartographic.latitude);
  391. height = cartographic.height;
  392. } else {
  393. var cartesian = this._viewer.scene.pickPosition(screenPoint);
  394. if (Cesium.defined(cartesian)) {
  395. var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
  396. if (Cesium.defined(cartographic)) {
  397. lng = this._arcToDegree(cartographic.longitude);
  398. lat = this._arcToDegree(cartographic.latitude);
  399. height = cartographic.height;
  400. }
  401. }
  402. }
  403. /* 返回结果 */
  404. return {
  405. lng: lng,
  406. lat: lat,
  407. height: height,
  408. }
  409. }
  410. /**
  411. * 屏幕位置转换为经纬度位置及空间位置
  412. * @ignore 生成方法时不对外公开
  413. * @param {Cesium.Cartesian2} screenPosition 屏幕位置
  414. * @return {JSON} 经纬度位置及空间位置
  415. */
  416. _transfromFromScreenPoint(screenPosition) {
  417. /* 根据屏幕位置获取经度、纬度和高度信息 */
  418. let location = this._getScreenClickPositionAndHeight(screenPosition);
  419. if (location.lng != undefined) {
  420. /* 经纬度位置转换为三维坐标 */
  421. var cartesian = Cesium.Cartesian3.fromDegrees(location.lng, location.lat, location
  422. .height);
  423. /* 返回 */
  424. return {
  425. gLocation: location,
  426. sLocation: cartesian,
  427. }
  428. } else {
  429. /* 返回 */
  430. return {
  431. gLocation: undefined,
  432. sLocation: undefined,
  433. }
  434. }
  435. }
  436. /**
  437. * 根据Entity的名称批量删除Entity
  438. * @ignore 生成方法时不对外公开
  439. * @param {String} entityName 实体名称
  440. */
  441. _removeEntityByName(entityName) {
  442. /* 获取实体集合 */
  443. var entities = this._entities;
  444. /* 如果不存在实体集合或集合中没有数据 则返回 */
  445. if (!entities || !entities.values) return;
  446. var delEntitys = [];
  447. /* 循环获取当前集合中的所有实体 */
  448. for (var i = 0; i < entities.values.length; i++) {
  449. if (entities.values[i].name == entityName) {
  450. delEntitys.push(entities.values[i]);
  451. }
  452. }
  453. /* 删除符合条件的所有实体 */
  454. for (var i = 0; i < delEntitys.length; i++) {
  455. entities.remove(delEntitys[i]);
  456. }
  457. /* 更新场景 */
  458. this._updateScene();
  459. }
  460. /**
  461. * 移除实体
  462. * @ignore 生成方法时不对外公开
  463. * @param {Cesium.Entity} objEntity 实体
  464. */
  465. _removeEntityByObject(objEntity) {
  466. if (!Cesium.defined(objEntity)) return;
  467. let res = this._entities.remove(objEntity);
  468. }
  469. /**
  470. * 绘制点
  471. * @ignore 生成方法时不对外公开
  472. * @param {Cesium.Cartesian3} coord 坐标
  473. * @param {String} label [点上面显示的文字标注]
  474. */
  475. _createPoint(coord, label) {
  476. let _self = this;
  477. /* 创建点实体 */
  478. let entity = new Cesium.Entity({
  479. name: _self._sketchEntityName + "_Point",
  480. position: coord,
  481. billboard: {
  482. image: _self._sketchPointImage,
  483. horizontalOrigin: Cesium.HorizontalOrigin.center,
  484. verticalOrigin: Cesium.VerticalOrigin.bottom,
  485. scale: 0.5,
  486. pixelOffset: new Cesium.Cartesian2(0, -11),
  487. disableDepthTestDistance: Number.POSITIVE_INFINITY,
  488. }
  489. });
  490. /* 判断是否需要绘制文字 */
  491. if (label) {
  492. entity.label = {
  493. text: label,
  494. font: '12px sans-serif',
  495. fillColor: this._toColor(255, 255, 255, 1.0),
  496. outlineColor: this._toColor(0, 154, 94, 1.0),
  497. style: Cesium.LabelStyle.FILL_AND_OUTLINE,
  498. outlineWidth: 1.0,
  499. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  500. pixelOffset: new Cesium.Cartesian2(0, -28),
  501. showBackground: true,
  502. backgroundColor: this._toColor(0, 0, 0, 0.6),
  503. disableDepthTestDistance: Number.POSITIVE_INFINITY,
  504. }
  505. }
  506. /* 加入集合中 */
  507. this._entities.add(entity);
  508. /* 加入点集合数组中 */
  509. this._pointEntitys.push(entity);
  510. this._updateScene();
  511. }
  512. /**
  513. * 删除全部点
  514. * @ignore 生成方法时不对外公开
  515. */
  516. _removePointEntitys() {
  517. /* 清除所有绘制的点实体 */
  518. this._removeEntityByName(this._sketchEntityName + "_Point");
  519. /* 清除用于临时存储的点实体集合 */
  520. this._pointEntitys = [];
  521. }
  522. /**
  523. * 调用更新椭圆中心点位置信息
  524. * @ignore 生成方法时不对外公开
  525. * @return {Cesium.Cartesian3}
  526. */
  527. _callUpdaeEllipseCenterPosition() {
  528. let _self = this;
  529. return function() {
  530. let point1cartographic = Cesium.Cartographic.fromCartesian(_self
  531. ._sketchTempPoints[0]);
  532. let point2cartographic = Cesium.Cartographic.fromCartesian(_self
  533. ._sketchTempPoints[1]);
  534. _self._sketchEllipseCenterPosition = Cesium.Cartesian3.fromDegrees(Cesium.Math.toDegrees(
  535. point1cartographic
  536. .longitude), Cesium.Math.toDegrees(point1cartographic
  537. .latitude),
  538. point2cartographic.height);
  539. return _self._sketchEllipseCenterPosition;
  540. }
  541. }
  542. /**
  543. * 圆半径变更回调
  544. * @ignore 生成方法时不对外公开
  545. * @param {Array<Cesium.Cartesian3>} positions 位置数据点集合
  546. */
  547. _callUpdateEllipseMinorAxis(positions) {
  548. let _self = this;
  549. return function() {
  550. if (positions === undefined || positions.length === undefined || positions.length < 2) {
  551. _self._sketchEllipseRadius = 0;
  552. } else {
  553. _self._sketchEllipseRadius = _self._calculateEllipseMinorAxis(positions[0], positions[1]);
  554. if (_self._sketchEllipseRadius <= 0) _self._sketchEllipseRadius = 1;
  555. }
  556. return _self._sketchEllipseRadius;
  557. }
  558. }
  559. /**
  560. * 计算两点组成椭圆的半径
  561. * @ignore
  562. * @param {Cesium.Cartesian3} position1 Location center
  563. * @param {Cesium.Cartesian3} position2 Location outline
  564. * @return {Number} radius
  565. */
  566. _calculateEllipseMinorAxis(position1, position2) {
  567. let point1cartographic = Cesium.Cartographic.fromCartesian(position1);
  568. let point2cartographic = Cesium.Cartographic.fromCartesian(position2);
  569. /* 计算距离 */
  570. let geodesic = new Cesium.EllipsoidGeodesic();
  571. geodesic.setEndPoints(point1cartographic, point2cartographic);
  572. return geodesic.surfaceDistance;
  573. }
  574. /**
  575. * 计算两点组成椭圆的边界线坐标集合
  576. * @ignore
  577. * @param {Cesium.Cartesian3} position1 圆心
  578. * @param {Cesium.Cartesian3} position2 外边界点
  579. * @return {Array<Cesium.Cartesian3>}
  580. */
  581. _calculateEllipseOutlineCoordinate(position1, position2) {
  582. let positionCenter = position1;
  583. let positionRotate = position2;
  584. let ellipseOutlineCoordinates = [];
  585. for (let angle = 5; angle < 360;) {
  586. let newPosition = this._rotatedPointByAngle(positionRotate, positionCenter, angle);
  587. ellipseOutlineCoordinates.push(newPosition);
  588. angle = angle + 5;
  589. }
  590. ellipseOutlineCoordinates.push(ellipseOutlineCoordinates[0]);
  591. return ellipseOutlineCoordinates;
  592. }
  593. /**
  594. * 圆的边界变更回调
  595. * @ignore 生成方法时不对外公开
  596. * @param {Array<Cesium.Cartesian3>} positions 圆的点数据集合
  597. */
  598. _callEllipseOutlineCoordinate(positions) {
  599. let _self = this;
  600. return function() {
  601. _self._ellipseOutlineCoordinates = _self._calculateEllipseOutlineCoordinate(positions[0], positions[
  602. 1]);
  603. return _self._ellipseOutlineCoordinates;
  604. }
  605. }
  606. /**
  607. * position_A绕position_B逆时针旋转angle度(角度)得到新点
  608. * @ignore 生成方法时不对外公开
  609. * @param {Cesium.Cartesian3} position_A 动点
  610. * @param {Cesium.Cartesian3} position_B 中心点
  611. * @param {Number} angle 旋转角度
  612. */
  613. _rotatedPointByAngle(position_A, position_B, angle) {
  614. //以B点为原点建立局部坐标系(东方向为x轴,北方向为y轴,垂直于地面为z轴),得到一个局部坐标到世界坐标转换的变换矩阵
  615. var localToWorld_Matrix = Cesium.Transforms.eastNorthUpToFixedFrame(position_B);
  616. //求世界坐标到局部坐标的变换矩阵
  617. var worldToLocal_Matrix = Cesium.Matrix4.inverse(localToWorld_Matrix, new Cesium.Matrix4());
  618. //B点在局部坐标的位置,其实就是局部坐标原点
  619. var localPosition_B = Cesium.Matrix4.multiplyByPoint(worldToLocal_Matrix, position_B, new Cesium
  620. .Cartesian3());
  621. //A点在以B点为原点的局部的坐标位置
  622. var localPosition_A = Cesium.Matrix4.multiplyByPoint(worldToLocal_Matrix, position_A, new Cesium
  623. .Cartesian3());
  624. //根据数学公式A点逆时针旋转angle度后在局部坐标系中的x,y,z位置
  625. var new_x = localPosition_A.x * Math.cos(Cesium.Math.toRadians(angle)) + localPosition_A.y * Math.sin(Cesium
  626. .Math.toRadians(angle));
  627. var new_y = localPosition_A.y * Math.cos(Cesium.Math.toRadians(angle)) - localPosition_A.x * Math.sin(Cesium
  628. .Math.toRadians(angle));
  629. var new_z = localPosition_A.z;
  630. //最后应用局部坐标到世界坐标的转换矩阵求得旋转后的A点世界坐标
  631. return Cesium.Matrix4.multiplyByPoint(localToWorld_Matrix, new Cesium.Cartesian3(new_x, new_y, new_z),
  632. new Cesium.Cartesian3());
  633. }
  634. /**
  635. * 矩形坐标更新回调
  636. * @ignore 生成方法时不对外公开
  637. * @param {Array<Cesium.Cartesian3>} positions 坐标数据集合
  638. */
  639. _callUpdateRectangleCoordinates(positions) {
  640. let _self = this;
  641. return function() {
  642. /* 对坐标进行转换 */
  643. let g0 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(positions[0]);
  644. let g1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(positions[1]);
  645. /* 获取转换 */
  646. let lng0 = Cesium.Math.toDegrees(g0.longitude);
  647. let lat0 = Cesium.Math.toDegrees(g0.latitude);
  648. let lng1 = Cesium.Math.toDegrees(g1.longitude);
  649. let lat1 = Cesium.Math.toDegrees(g1.latitude);
  650. _self._rectangleCoordinates = [0, 0, 1, 1];
  651. if (lng0 < lng1) {
  652. _self._rectangleCoordinates[0] = lng0;
  653. _self._rectangleCoordinates[2] = lng1;
  654. } else {
  655. _self._rectangleCoordinates[0] = lng1;
  656. _self._rectangleCoordinates[2] = lng0;
  657. }
  658. if (lat0 < lat1) {
  659. _self._rectangleCoordinates[1] = lat0;
  660. _self._rectangleCoordinates[3] = lat1;
  661. } else {
  662. _self._rectangleCoordinates[1] = lat1;
  663. _self._rectangleCoordinates[3] = lat0;
  664. }
  665. let rectangle = Cesium.Rectangle.fromDegrees(_self._rectangleCoordinates[0], _self
  666. ._rectangleCoordinates[1],
  667. _self._rectangleCoordinates[2], _self._rectangleCoordinates[3]);
  668. /* 计算并返回矩形的边界线坐标数组 */
  669. let res = _self._calculateRectangleOutlineCoordinates(rectangle);
  670. _self._rectangleOutlineCoordinates = res.cPoints;
  671. _self._sketchOutputPoints = res.gPoints;
  672. return rectangle;
  673. }
  674. }
  675. /**
  676. * 计算矩形的外围坐标串
  677. * @ignore 生成方法时不对外公开
  678. * @param {Cesium.Rectangle} rectangle 矩形
  679. * @return {Array<Cesium.Cartesian3>} 坐标串集合
  680. */
  681. _calculateRectangleOutlineCoordinates(rectangle) {
  682. /* 计算东南角 */
  683. let south_east = Cesium.Rectangle.southeast(rectangle);
  684. let se = Cesium.Cartographic.toCartesian(south_east);
  685. /* 计算西南角 */
  686. let south_west = Cesium.Rectangle.southwest(rectangle);
  687. let sw = Cesium.Cartographic.toCartesian(south_west);
  688. /* 计算东北角 */
  689. let north_east = Cesium.Rectangle.northeast(rectangle);
  690. let ne = Cesium.Cartographic.toCartesian(north_east);
  691. /* 计算西北角 */
  692. let north_west = Cesium.Rectangle.northwest(rectangle);
  693. let nw = Cesium.Cartographic.toCartesian(north_west);
  694. /* 经纬度坐标数组 */
  695. let gPoints = [];
  696. gPoints.push({
  697. lng: Cesium.Math.toDegrees(south_west.longitude),
  698. lat: Cesium.Math.toDegrees(south_west.latitude),
  699. height: south_west.height,
  700. });
  701. gPoints.push({
  702. lng: Cesium.Math.toDegrees(south_east.longitude),
  703. lat: Cesium.Math.toDegrees(south_east.latitude),
  704. height: south_east.height,
  705. });
  706. gPoints.push({
  707. lng: Cesium.Math.toDegrees(north_east.longitude),
  708. lat: Cesium.Math.toDegrees(north_east.latitude),
  709. height: north_east.height,
  710. });
  711. gPoints.push({
  712. lng: Cesium.Math.toDegrees(north_west.longitude),
  713. lat: Cesium.Math.toDegrees(north_west.latitude),
  714. height: north_west.height,
  715. });
  716. gPoints.push({
  717. lng: Cesium.Math.toDegrees(south_west.longitude),
  718. lat: Cesium.Math.toDegrees(south_west.latitude),
  719. height: south_west.height,
  720. });
  721. /* 返回坐标串 */
  722. return {
  723. cPoints: [sw, se, ne, nw, sw],
  724. gPoints: gPoints,
  725. };
  726. }
  727. /**
  728. * 矩形外边框轮廓线回调
  729. * @ignore 生成方法时不对外公开
  730. */
  731. _callUpdateRectangleOutlineCoordinates() {
  732. let _self = this;
  733. return function() {
  734. return _self._rectangleOutlineCoordinates;
  735. }
  736. }
  737. /**
  738. * 文字材质
  739. * @ignore 生成方法时不对外公开
  740. * @param {JSON} options 配置项
  741. * @param {String} options.text 文字内容
  742. * @param {String} options.color 文字颜色 rgba(r,g,b,a)
  743. */
  744. _materialTextImageProperty(options) {
  745. this._canvasId = 'canvasJt';
  746. /* 获取画布 */
  747. let canvasObj = document.getElementById(this._canvasId);
  748. /* 如果画布已经存在则删除 */
  749. if (canvasObj != null) {
  750. document.body.removeChild(canvasObj);
  751. }
  752. /* 创建画布 */
  753. canvasObj = document.createElement('canvas');
  754. canvasObj.id = this._canvasId;
  755. /* 设置画布尺寸 */
  756. canvasObj.setAttribute('width', '1024px');
  757. canvasObj.setAttribute('height', '256px');
  758. /* 加入画布 */
  759. document.body.appendChild(canvasObj);
  760. /* 获取上下文绘制 */
  761. let context = canvasObj.getContext('2d');
  762. context.fillStyle = options.color === undefined ? 'rgba(255,0,0,1)' : options.color;
  763. context.font = 'bold 240px 微软雅黑';
  764. context.textAlign = 'left';
  765. context.textBaseline = 'bottom';
  766. context.fillText(options.text, 12, 250, 1000);
  767. /* 创建材质 */
  768. let textMaterial = new Cesium.ImageMaterialProperty({
  769. image: canvasObj,
  770. transparent: true,
  771. });
  772. textMaterial._param = {
  773. color: context.fillStyle,
  774. text: options.text,
  775. }
  776. /* 返回材质 */
  777. return textMaterial;
  778. }
  779. /**
  780. * 颜色材质
  781. * @ignore 生成方法时不对外公开
  782. * @param {JSON} options 配置项
  783. * @param {String} options.color 文字颜色 rgba(r,g,b,a)
  784. */
  785. _materialColorProperty(options) {
  786. let mColor = 'rgba(0,255,0,1)';
  787. if (options !== undefined && options.color !== undefined) mColor = options.color;
  788. /* 创建材质 */
  789. let colorMaterial = new Cesium.ColorMaterialProperty(Cesium.Color.fromCssColorString(mColor));
  790. colorMaterial._param = {
  791. color: mColor,
  792. }
  793. /* 返回材质 */
  794. return colorMaterial;
  795. }
  796. /**
  797. * 箭头线材质
  798. * @ignore 生成方法时不对外公开
  799. * @param {JSON} options 配置项
  800. * @param {String} options.color 线的颜色 rgba(r,g,b,a)
  801. */
  802. _materialPolylineArrowProperty(options) {
  803. let mColor = 'rgba(0,255,0,1)';
  804. if (options !== undefined && options.color !== undefined) mColor = options.color;
  805. /* 创建材质 */
  806. let colorMaterial = new Cesium.PolylineArrowMaterialProperty(Cesium.Color.fromCssColorString(mColor));
  807. colorMaterial._param = {
  808. color: mColor,
  809. }
  810. /* 返回材质 */
  811. return colorMaterial;
  812. }
  813. /**
  814. * 发光线材质
  815. * @ignore 生成方法时不对外公开
  816. * @param {JSON} options 配置项
  817. * @param {String} options.color 线的颜色 rgba(r,g,b,a)
  818. * @param {Number} options.power 发光强度 0~1
  819. */
  820. _materialPolylineGlowProperty(options) {
  821. let mColor = 'rgba(0,255,0,1)';
  822. if (options !== undefined && options.color !== undefined) mColor = options.color;
  823. let power = 0.25;
  824. if (options !== undefined && options.power !== undefined && typeof(options.power) === 'number') power =
  825. options.power;
  826. /* 创建材质 */
  827. let colorMaterial = new Cesium.PolylineGlowMaterialProperty({
  828. color: Cesium.Color.fromCssColorString(mColor),
  829. glowPower: power,
  830. });
  831. colorMaterial._param = {
  832. color: mColor,
  833. power: power,
  834. }
  835. /* 返回材质 */
  836. return colorMaterial;
  837. }
  838. /**
  839. * 描边线材质
  840. * @ignore 生成方法时不对外公开
  841. * @param {JSON} options 配置项
  842. * @param {String} options.color 线的颜色 rgba(r,g,b,a)
  843. * @param {String} options.outlineColor 描边线的颜色 rgba(r,g,b,a)
  844. * @param {Number} options.outlineWidth 描边线的宽度
  845. */
  846. _materialPolylineOutlineProperty(options) {
  847. let mColor = 'rgba(0,255,0,1)';
  848. let outlineColor = 'rgba(255,255,255,1.0)';
  849. let outlineWidth = 1.2;
  850. if (options !== undefined && options.color !== undefined) mColor = options.color;
  851. if (options !== undefined && options.outlineColor !== undefined) outlineColor = options.outlineColor;
  852. if (options !== undefined && options.outlineWidth !== undefined && typeof(options.outlineWidth) ===
  853. 'number')
  854. outlineWidth = options.outlineWidth;
  855. /* 创建材质 */
  856. let colorMaterial = new Cesium.PolylineOutlineMaterialProperty({
  857. color: Cesium.Color.fromCssColorString(mColor),
  858. outlineColor: Cesium.Color.fromCssColorString(outlineColor),
  859. outlineWidth: outlineWidth,
  860. });
  861. colorMaterial._param = {
  862. color: mColor,
  863. outlineColor: outlineColor,
  864. outlineWidth: outlineWidth,
  865. }
  866. /* 返回材��������������������� */
  867. return colorMaterial;
  868. }
  869. /**
  870. * 清理资源
  871. * @ignore 生成方法时不对外公开
  872. * @param {Boolean} isAll 是否删除已经绘制的全部实体
  873. */
  874. _clear(isAll) {
  875. if (isAll != undefined && isAll === true) {
  876. this._removeEntityByName(this._sketchEntityName);
  877. this._removePointEntitys();
  878. }
  879. /* 重置数组变量 */
  880. this._sketchTempPoints = [];
  881. this._sketchPoints = [];
  882. this._sketchOutputPoints = [];
  883. this._sketchWallHeights = [];
  884. this._drawEntity = undefined;
  885. /* Clear Tooltip */
  886. this._removeOperationDom();
  887. this._tooltipRemove();
  888. /* 释放事件 */
  889. if (this._drawEventHandler !== null && this._drawEventHandler !== undefined && this._drawEventHandler
  890. .isDestroyed() === false) {
  891. this._clearEvent(this._drawEventHandler);
  892. }
  893. }
  894. }
  895. /**
  896. * 设置方法
  897. */
  898. Object.assign(DrawTools.prototype, {
  899. /**
  900. * Set Label
  901. * @param {JSNO} options 配置项
  902. * @param {String} options.lineLabel 线点文字标注
  903. * @param {String} options.polygonLabel 面点文字标注
  904. */
  905. setLabel: function(options) {
  906. if (!options) {
  907. options = {
  908. lineLabel: undefined,
  909. polygonLabel: undefined,
  910. }
  911. }
  912. if (options.lineLabel) this._lineLabel = options.lineLabel;
  913. if (options.polygonLabel) this._lineLabel = options.polygonLabel;
  914. }
  915. })
  916. /**
  917. * 事件相关
  918. */
  919. Object.assign(DrawTools.prototype, {
  920. /**
  921. * 注册鼠标左键点击事件
  922. * @ignore 生成方法时不对外公开
  923. * @param {Cesium.ScreenSpaceEventHandler} handler 事件句柄
  924. * @param {Function} callChange 回调callChange(event)
  925. */
  926. _registerLeftClickEvent: function(handler, callChange) {
  927. let _self = this;
  928. if (!handler) return;
  929. handler.setInputAction(function(event) {
  930. /* 锁定点击事件 以免和移动事件冲突 */
  931. _self._lock = true;
  932. clearTimeout(_self._timer);
  933. _self._timer = setTimeout(function() {
  934. if (callChange) callChange(event);
  935. /* 解除锁定 */
  936. _self._lock = false;
  937. }, 200);
  938. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  939. },
  940. /**
  941. * 注册鼠标左键双击事件
  942. * @ignore 生成方法时不对外公开
  943. * @param {Cesium.ScreenSpaceEventHandler} handler 事件句柄
  944. * @param {Function} callChange 回调callChange(event)
  945. */
  946. _registerLeftDoubleClickEvent: function(handler, callChange) {
  947. let _self = this;
  948. if (!handler) return;
  949. handler.setInputAction(function(event) {
  950. clearTimeout(_self._timer);
  951. /* 解除锁定 */
  952. _self._lock = false;
  953. if (callChange) callChange(event);
  954. }, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
  955. },
  956. /**
  957. * 注册鼠标移动事件
  958. * @ignore 生成方法时不对外公开
  959. * @param {Cesium.ScreenSpaceEventHandler} handler 事件句柄
  960. * @param {Function} callChange 回调callChange(event)
  961. */
  962. _registerMouseMoveEvent: function(handler, callChange) {
  963. let _self = this;
  964. if (!handler) return;
  965. handler.setInputAction(function(event) {
  966. if (_self._lock === undefined || _self._lock === false) {
  967. if (callChange) callChange(event);
  968. }
  969. }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
  970. },
  971. /**
  972. * 注册鼠标右键点击事件
  973. * @ignore 生成方法时不对外公开
  974. * @param {Cesium.ScreenSpaceEventHandler} handler 事件句柄
  975. * @param {Function} callChange ���调callChange(event)
  976. */
  977. _registerRightClickEvent: function(handler, callChange) {
  978. if (!handler) return;
  979. handler.setInputAction(function(event) {
  980. if (callChange) callChange(event);
  981. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  982. },
  983. /**
  984. * 注册鼠标左键按下事件
  985. * @ignore 生成方法时不对外公开
  986. * @param {Cesium.ScreenSpaceEventHandler} handler 事件句柄
  987. * @param {Function} callChange 回调callChange(event)
  988. */
  989. _registerLeftDownEvent: function(handler, callChange) {
  990. if (!handler) return;
  991. handler.setInputAction(function(event) {
  992. if (callChange) callChange(event);
  993. }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
  994. },
  995. /**
  996. * 注册鼠标左键抬起事件
  997. * @ignore 生成方法时不对外公开
  998. * @param {Cesium.ScreenSpaceEventHandler} handler 事件句柄
  999. * @param {Function} callChange 回调callChange(event)
  1000. */
  1001. _registerLeftUpEvent: function(handler, callChange) {
  1002. if (!handler) return;
  1003. handler.setInputAction(function(event) {
  1004. if (callChange) callChange(event);
  1005. }, Cesium.ScreenSpaceEventType.LEFT_UP);
  1006. },
  1007. /**
  1008. * 清除事件
  1009. * @ignore 生成方法时不对外公开
  1010. * @param {Cesium.ScreenSpaceEventHandler} handler
  1011. */
  1012. _clearEvent: function(handler) {
  1013. /* 清理事件的同时 彻底清理提示标签 */
  1014. this._endTooltip();
  1015. /* 隐藏操作容器 */
  1016. this._removeOperationDom();
  1017. if (!handler) return;
  1018. /* 干掉事件句柄 释放资源 */
  1019. handler.destroy();
  1020. handler = null;
  1021. },
  1022. })
  1023. /**
  1024. * 绘制的具体实现方法
  1025. */
  1026. Object.assign(DrawTools.prototype, {
  1027. /**
  1028. * 创建贴地线
  1029. * @ignore 生成方法时不对外公开
  1030. * @param {DrawTools.PolylineType} polylineType 线类型
  1031. */
  1032. _createPolyline: function(polylineType) {
  1033. let _self = this;
  1034. /* 初始化一个实体参数变量 */
  1035. let entityParam = DrawTools.initEditPropertyParams();
  1036. let polylineWidth = _self._param.lineWidth;
  1037. /* 创建普通线材质 */
  1038. let polylineMaterial = this._materialColorProperty({
  1039. color: _self._param.lineColor,
  1040. });
  1041. entityParam.id = DrawTools.DrawType.Polyline;
  1042. if (polylineType !== undefined && polylineType === DrawTools.PolylineType.ArrowsPolyline) {
  1043. polylineMaterial = this._materialPolylineArrowProperty({
  1044. color: _self._param.lineColor,
  1045. });
  1046. polylineWidth = _self._param.lineWidth * 3;
  1047. /* 设置实体参数 */
  1048. entityParam.color = _self._param.lineColor;
  1049. entityParam.id = DrawTools.DrawType.ArrowPolyline;
  1050. } else if (polylineType !== undefined && polylineType === DrawTools.PolylineType.GrowPolyline) {
  1051. polylineMaterial = this._materialPolylineGlowProperty({
  1052. color: _self._param.lineColor,
  1053. power: _self._param.power,
  1054. })
  1055. polylineWidth = _self._param.lineWidth * 3;
  1056. /* 设置实体参数 */
  1057. entityParam.color = _self._param.lineColor;
  1058. entityParam.power = _self._param.power;
  1059. entityParam.id = DrawTools.DrawType.GrowPolyline;
  1060. } else if (polylineType !== undefined && polylineType === DrawTools.PolylineType.OutlinePolyline) {
  1061. polylineMaterial = this._materialPolylineOutlineProperty({
  1062. color: _self._param.lineColor,
  1063. outlineColor: _self._param.outlineColor,
  1064. outlineWidth: _self._param.outlineWidth
  1065. });
  1066. polylineWidth = _self._param.lineWidth * 2;
  1067. /* 设置实体参数 */
  1068. entityParam.color = _self._param.lineColor;
  1069. entityParam.outlineColor = _self._param.outlineColor;
  1070. entityParam.outlineWidth = _self._param.outlineWidth;
  1071. entityParam.id = DrawTools.DrawType.OutlinePolyline;
  1072. } else if (polylineType !== undefined && polylineType === DrawTools.PolylineType.DynamicPolyline) {
  1073. polylineMaterial = new WallMaterialProperty({
  1074. viewer: _self._viewer,
  1075. trailImage: _self._image_h_l_r,
  1076. duration: _self._param.duration,
  1077. color: Cesium.Color.fromCssColorString(_self._param.lineColor),
  1078. param: {
  1079. direction: _self._param.direction_h,
  1080. count: _self._param.count,
  1081. order: _self._param.order_minus,
  1082. },
  1083. });
  1084. polylineWidth = _self._param.lineWidth;
  1085. /* 设置实体参数 */
  1086. entityParam.color = _self._param.lineColor;
  1087. entityParam.duration = _self._param.duration;
  1088. entityParam.direction = _self._param.direction_h;
  1089. entityParam.count = _self._param.count;
  1090. entityParam.order = _self._param.order_minus;
  1091. entityParam.id = DrawTools.DrawType.DynamicPolyline;
  1092. }
  1093. /* 设置实体通用参数 */
  1094. entityParam.lineWidth = polylineWidth;
  1095. /* 创建贴地线 */
  1096. let entityPolyline = new Cesium.Entity({
  1097. name: _self._sketchEntityName,
  1098. polyline: {
  1099. show: true,
  1100. positions: new Cesium.CallbackProperty(function() {
  1101. return _self._sketchTempPoints;
  1102. }, false),
  1103. material: polylineMaterial,
  1104. width: polylineWidth,
  1105. clampToGround: true, //开启贴地 如果有模型则贴模型
  1106. }
  1107. })
  1108. /* 渲染贴地线 */
  1109. this._drawEntity = this._entities.add(entityPolyline);
  1110. /* 挂接参数到实体上 */
  1111. this._drawEntity.setParams(entityParam);
  1112. },
  1113. /**
  1114. * 更新贴地线
  1115. * @ignore 生成方法时不对外公开
  1116. * @param {Boolean} isEdit [是否可编辑] 可选
  1117. */
  1118. _updatePolyline: function(isEdit) {
  1119. /* 更新数据 */
  1120. this._drawEntity.polyline.positions = this._sketchPoints;
  1121. /* 设置实体类型 */
  1122. this._drawEntity.setEntityType(DrawTools.DrawType.Polyline);
  1123. /* 设置是否可编辑 */
  1124. if (isEdit != undefined && isEdit === true) {
  1125. /* 删除所有的临时点 忽略是否保留设置 */
  1126. this._removePointEntitys();
  1127. this._setEntityIsEdit(this._drawEntity);
  1128. }
  1129. },
  1130. /**
  1131. * 创建空间线
  1132. * @ignore 生成方法时不对外公开
  1133. */
  1134. _createSpatialPolyline: function() {
  1135. let _self = this;
  1136. /* 初始化一个实体参数变量 */
  1137. let entityParam = DrawTools.initEditPropertyParams();
  1138. /* 创建空间线材质 */
  1139. let lineMaterial = this._materialColorProperty({
  1140. color: _self._param.lineColor,
  1141. })
  1142. /* 设置实体参数 */
  1143. entityParam.id = DrawTools.DrawType.SpatialLine;
  1144. entityParam.color = _self._param.lineColor;
  1145. entityParam.lineWidth = _self._param.lineWidth;
  1146. /* 创建空间线实体 */
  1147. let entity = new Cesium.Entity({
  1148. name: _self._sketchEntityName,
  1149. polyline: {
  1150. show: true,
  1151. positions: new Cesium.CallbackProperty(function() {
  1152. return _self._sketchTempPoints;
  1153. }, false),
  1154. material: lineMaterial,
  1155. width: _self._param.lineWidth,
  1156. clampToGround: false, //由于是空间线禁止贴地或贴模型
  1157. }
  1158. })
  1159. /* 加入集合 */
  1160. this._drawEntity = this._entities.add(entity);
  1161. /* 挂接实体参数 */
  1162. this._drawEntity.setParams(entityParam);
  1163. },
  1164. /**
  1165. * 更新空间线
  1166. * @ignore 生成方法时不对外公开
  1167. * @param {Boolean} isEdit [是否可编辑] 可选
  1168. */
  1169. _updateSpatialPolyline: function(isEdit) {
  1170. this._drawEntity.polyline.positions = this._sketchPoints;
  1171. this._drawEntity.setEntityType(DrawTools.DrawType.SpatialLine);
  1172. /* 设置是否可编辑 */
  1173. if (isEdit != undefined && isEdit === true) {
  1174. /* 删除所有的临时点 忽略是否保留设置 */
  1175. this._removePointEntitys();
  1176. this._setEntityIsEdit(this._drawEntity);
  1177. }
  1178. },
  1179. /**
  1180. * 绘制面
  1181. * @ignore 生成方法时不对外公开
  1182. * @param {DrawTools.PolygonType} polygonType 面类型
  1183. */
  1184. _createPolygon: function(polygonType) {
  1185. let _self = this;
  1186. /* 初始化一个实体参数变量 */
  1187. let entityParam = DrawTools.initEditPropertyParams();
  1188. /* 创建面材质 */
  1189. let polygonMaterial = this._materialColorProperty({
  1190. color: _self._param.polygonColor,
  1191. })
  1192. /* 创建线材质 */
  1193. let lineMaterial = this._materialColorProperty({
  1194. color: _self._param.outlineColor,
  1195. })
  1196. /* 创建贴地面 */
  1197. let entityPolygon = new Cesium.Entity({
  1198. name: _self._sketchEntityName,
  1199. polygon: {
  1200. show: true,
  1201. hierarchy: new Cesium.CallbackProperty(function() {
  1202. return {
  1203. positions: _self._sketchTempPoints,
  1204. };
  1205. }, false),
  1206. material: polygonMaterial,
  1207. classificationType: Cesium.ClassificationType.BOTH,
  1208. },
  1209. polyline: {
  1210. show: true,
  1211. positions: new Cesium.CallbackProperty(function() {
  1212. return _self._sketchTempPoints;
  1213. }, false),
  1214. material: lineMaterial,
  1215. width: _self._param.outlineWidth,
  1216. clampToGround: true, //开启贴地 如果有模型则贴模型
  1217. }
  1218. })
  1219. /* 设置实体参数 */
  1220. entityParam.color = _self._param.polygonColor;
  1221. entityParam.outlineColor = _self._param.outlineColor;
  1222. entityParam.outlineWidth = _self._param.outlineWidth;
  1223. /* 渲染贴地面 */
  1224. this._drawEntity = this._entities.add(entityPolygon);
  1225. if (polygonType !== undefined && polygonType === DrawTools.PolygonType.NormalPolygon) {
  1226. this._drawEntity.setEntityType(DrawTools.DrawType.Polygon);
  1227. entityParam.id = DrawTools.DrawType.Polygon;
  1228. } else if (polygonType !== undefined && polygonType === DrawTools.PolygonType.HousePolygon) {
  1229. this._drawEntity.setEntityType(DrawTools.DrawType.House);
  1230. entityParam.id = DrawTools.DrawType.House;
  1231. }
  1232. /* 设置实体参数 */
  1233. this._drawEntity.setParams(entityParam);
  1234. },
  1235. /**
  1236. * 创建正式面
  1237. * @ignore 生成方法时不对外公开
  1238. * @param {Boolean} isEdit [是否可编辑] 可选
  1239. */
  1240. _updatePolygon: function(isEdit) {
  1241. let _self = this;
  1242. /* 创建房屋材质 */
  1243. let houseMaterial = this._materialColorProperty({
  1244. color: _self._param.houseColor,
  1245. })
  1246. /* 获取实体类型 */
  1247. let entityType = this._drawEntity.getEntityType();
  1248. if (entityType === DrawTools.DrawType.Polygon) {
  1249. /* 更新数据 */
  1250. this._drawEntity.polygon.hierarchy = {
  1251. positions: _self._sketchPoints,
  1252. };
  1253. this._drawEntity.polyline.positions = this._sketchPoints;
  1254. } else if (entityType === DrawTools.DrawType.House) {
  1255. /* 删除底面实体之前获取存储的属性 */
  1256. let entityParam = this._drawEntity.getParams();
  1257. /* 删除原来创建的实体 */
  1258. this._removeEntityByObject(this._drawEntity);
  1259. /* 创建房屋的高度 */
  1260. let height = parseFloat(this._sketchOutputPoints[0].height);
  1261. let houseHeight = height + parseInt(_self._param.wallHeight);
  1262. /* 创建一个房屋实体 */
  1263. let houseEntity = new Cesium.Entity({
  1264. name: _self._sketchEntityName,
  1265. polygon: {
  1266. show: true,
  1267. hierarchy: {
  1268. positions: _self._sketchPoints,
  1269. },
  1270. extrudedHeight: houseHeight,
  1271. material: houseMaterial,
  1272. },
  1273. })
  1274. /* 渲染实体 */
  1275. this._drawEntity = this._entities.add(houseEntity);
  1276. /* 设置实体类型 */
  1277. this._drawEntity.setEntityType(entityType);
  1278. entityParam.height = _self._param.wallHeight;
  1279. entityParam.bottomHeight = height;
  1280. entityParam.color = _self._param.houseColor;
  1281. this._drawEntity.setParams(entityParam);
  1282. }
  1283. /* 设置是否可编辑 */
  1284. if (isEdit != undefined && isEdit === true) {
  1285. /* 删除所有的临时点 忽略是否保留设置 */
  1286. this._removePointEntitys();
  1287. this._setEntityIsEdit(this._drawEntity);
  1288. }
  1289. },
  1290. /**
  1291. * 创建矩形
  1292. * @ignore 生成方法时不对外公开
  1293. */
  1294. _createRectangle: function() {
  1295. let _self = this;
  1296. /* 初始化一个实体参数变量 */
  1297. let entityParam = DrawTools.initEditPropertyParams();
  1298. /* 创建面材质 */
  1299. let rectMaterial = this._materialColorProperty({
  1300. color: _self._param.polygonColor,
  1301. });
  1302. /* 创建线材质 */
  1303. let lineMaterial = this._materialColorProperty({
  1304. color: _self._param.outlineColor,
  1305. })
  1306. /* 创建贴地矩形 */
  1307. let entityRectangle = new Cesium.Entity({
  1308. name: _self._sketchEntityName,
  1309. polyline: {
  1310. show: true,
  1311. positions: new Cesium.CallbackProperty(_self
  1312. ._callUpdateRectangleOutlineCoordinates(),
  1313. false),
  1314. material: lineMaterial,
  1315. width: _self._param.outlineWidth,
  1316. clampToGround: true, //开启贴地 如果有模型则贴模型
  1317. },
  1318. rectangle: {
  1319. show: true,
  1320. coordinates: new Cesium.CallbackProperty(_self._callUpdateRectangleCoordinates(
  1321. _self
  1322. ._sketchTempPoints),
  1323. false),
  1324. material: rectMaterial,
  1325. classificationType: Cesium.ClassificationType.BOTH,
  1326. },
  1327. });
  1328. /* 设置实体属性 */
  1329. entityParam.id = DrawTools.DrawType.Rectangle;
  1330. entityParam.color = _self._param.polygonColor;
  1331. entityParam.outlineColor = _self._param.outlineColor;
  1332. entityParam.outlineWidth = _self._param.outlineWidth;
  1333. /* 贴地矩形渲染 */
  1334. this._drawEntity = this._entities.add(entityRectangle);
  1335. /* 挂接实体属性 */
  1336. this._drawEntity.setParams(entityParam);
  1337. },
  1338. /**
  1339. * 更新矩形
  1340. * @ignore 生成方法时不对外公开
  1341. * @param {Boolean} isEdit [是否可编辑] 可选
  1342. */
  1343. _updateRectangle(isEdit) {
  1344. let _self = this;
  1345. /* 更新贴地矩形数据 */
  1346. this._drawEntity.polyline.positions = this._rectangleOutlineCoordinates;
  1347. let coordinates = this._rectangleCoordinates;
  1348. this._drawEntity.rectangle.coordinates = Cesium.Rectangle.fromDegrees(coordinates[0], coordinates[
  1349. 1], coordinates[2], coordinates[3]);
  1350. /* 设置实体类型 */
  1351. this._drawEntity.setEntityType(DrawTools.DrawType.Rectangle);
  1352. /* 设置是否可编辑 */
  1353. if (isEdit != undefined && isEdit === true) {
  1354. this._setEntityIsEdit(this._drawEntity);
  1355. }
  1356. },
  1357. /**
  1358. * 创建贴地圆
  1359. * @ignore 生成方法时不对外公开
  1360. * @param {Cesium.Cartesian3} centerPosition 圆的中心点位置
  1361. */
  1362. _createCircle: function(centerPosition, circleType) {
  1363. let _self = this;
  1364. /* 初始化一个实体参数变量 */
  1365. let entityParam = DrawTools.initEditPropertyParams();
  1366. /* 创建颜色材质 */
  1367. let circleMaterial = this._materialColorProperty({
  1368. color: _self._param.polygonColor,
  1369. });
  1370. /* 创建线材质 */
  1371. let lineMaterial = this._materialColorProperty({
  1372. color: _self._param.outlineColor,
  1373. })
  1374. /* 如果是动态圆 创建动态圆材质 */
  1375. if (circleType != undefined && circleType === DrawTools.CircleType.DynamicCircle) {
  1376. circleMaterial = new CircleMaterialProperty({
  1377. viewer: _self._viewer,
  1378. duration: _self._param.duration,
  1379. color: Cesium.Color.fromCssColorString(_self._param.polygonColor),
  1380. count: _self._param.count,
  1381. });
  1382. }
  1383. /* 存储椭圆中心点位置 */
  1384. this._sketchEllipseCenterPosition = centerPosition.clone();
  1385. /* 创建贴地圆 */
  1386. let entityCircle = new Cesium.Entity({
  1387. name: _self._sketchEntityName,
  1388. position: centerPosition,
  1389. ellipse: {
  1390. show: true,
  1391. semiMinorAxis: new Cesium.CallbackProperty(_self._callUpdateEllipseMinorAxis(
  1392. _self
  1393. ._sketchTempPoints), false),
  1394. semiMajorAxis: new Cesium.CallbackProperty(_self._callUpdateEllipseMinorAxis(
  1395. _self
  1396. ._sketchTempPoints), false),
  1397. material: circleMaterial,
  1398. classificationType: Cesium.ClassificationType.BOTH,
  1399. },
  1400. });
  1401. if (circleType === undefined || circleType === DrawTools.CircleType.ColorCircle) {
  1402. entityCircle.polyline = {
  1403. show: true,
  1404. positions: new Cesium.CallbackProperty(_self._callEllipseOutlineCoordinate(
  1405. _self._sketchTempPoints), false),
  1406. material: lineMaterial,
  1407. width: _self._param.outlineWidth,
  1408. clampToGround: true, //开启贴地 如果有模型则贴模型
  1409. };
  1410. }
  1411. /* 渲染贴地圆 */
  1412. this._drawEntity = this._entities.add(entityCircle);
  1413. /* 设置实体类型 */
  1414. if (circleType === undefined || circleType === DrawTools.CircleType.ColorCircle) {
  1415. this._drawEntity.setEntityType(DrawTools.DrawType.Circle);
  1416. /* 设置实体属性 */
  1417. entityParam.id = DrawTools.DrawType.Circle;
  1418. entityParam.color = _self._param.polygonColor;
  1419. entityParam.outlineColor = _self._param.outlineColor;
  1420. entityParam.outlineWidth = _self._param.outlineWidth;
  1421. } else if (circleType != undefined && circleType === DrawTools.CircleType.DynamicCircle) {
  1422. this._drawEntity.setEntityType(DrawTools.DrawType.DynamicCircle);
  1423. /* 设置实体属性 */
  1424. entityParam.id = DrawTools.DrawType.DynamicCircle;
  1425. entityParam.color = _self._param.polygonColor;
  1426. entityParam.duration = _self._param.duration;
  1427. entityParam.count = _self._param.count;
  1428. }
  1429. /* 挂接实体属性 */
  1430. this._drawEntity.setParams(entityParam);
  1431. },
  1432. /**
  1433. * 更新贴地圆
  1434. * @ignore 生成方法时不对外公开
  1435. * @param {Boolean} isEdit [是否可编辑] 可选
  1436. */
  1437. _updateCircle(isEdit) {
  1438. let _self = this;
  1439. /* 更新贴地圆数据 */
  1440. this._drawEntity.position = this._sketchEllipseCenterPosition;
  1441. let center = this._sketchTempPoints.first();
  1442. let outpoint = this._sketchTempPoints.last();
  1443. this._ellipseOutlineCoordinates = this._calculateEllipseOutlineCoordinate(center, outpoint);
  1444. this._sketchEllipseRadius = this._calculateEllipseMinorAxis(center, outpoint);
  1445. if (this._drawEntity.polyline != undefined) {
  1446. this._drawEntity.polyline.positions = this._ellipseOutlineCoordinates;
  1447. }
  1448. this._drawEntity.ellipse.semiMajorAxis = this._sketchEllipseRadius;
  1449. this._drawEntity.ellipse.semiMinorAxis = this._sketchEllipseRadius;
  1450. /* 设置是否可编辑 */
  1451. if (isEdit != undefined && isEdit === true) {
  1452. this._setEntityIsEdit(this._drawEntity);
  1453. }
  1454. },
  1455. /**
  1456. * 绘制墙
  1457. * @ignore 生成方法时不对外公开
  1458. * @param {DrawTools.WallType} wallType 墙的类型
  1459. */
  1460. _createWall: function(wallType) {
  1461. let _self = this;
  1462. /* 初始化一个实体参数变量 */
  1463. let entityParam = DrawTools.initEditPropertyParams();
  1464. /* 颜色墙材质 */
  1465. let wallMaterial = this._materialColorProperty({
  1466. color: _self._param.polygonColor,
  1467. });
  1468. /* 设置实体属性 */
  1469. entityParam.color = _self._param.polygonColor;
  1470. if (wallType !== undefined && wallType === DrawTools.WallType.TextWall) {
  1471. wallMaterial = this._materialTextImageProperty({
  1472. color: _self._param.polygonColor,
  1473. text: _self._param.text,
  1474. });
  1475. /* 设置实体属性 */
  1476. entityParam.text = _self._param.text;
  1477. entityParam.color = _self._param.polygonColor;
  1478. } else if (wallType !== undefined && wallType === DrawTools.WallType.DynamicWall) {
  1479. /* 动态墙材质 */
  1480. wallMaterial = new WallMaterialProperty({
  1481. viewer: _self._viewer,
  1482. trailImage: _self._image_v_t_b,
  1483. duration: _self._param.duration,
  1484. color: Cesium.Color.fromCssColorString(_self._param.polygonColor),
  1485. param: {
  1486. count: _self._param.count,
  1487. direction: _self._param.direction_v,
  1488. order: _self._param.order_minus
  1489. }
  1490. });
  1491. /* 设置实体属性 */
  1492. entityParam.color = _self._param.polygonColor;
  1493. entityParam.duration = _self._param.duration;
  1494. entityParam.direction = _self._param.direction_v;
  1495. entityParam.count = _self._param.count;
  1496. entityParam.order = _self._param.order_minus;
  1497. }
  1498. /* 创建墙 */
  1499. let normalWall = new Cesium.Entity({
  1500. name: _self._sketchEntityName,
  1501. wall: {
  1502. show: true,
  1503. positions: new Cesium.CallbackProperty(function() {
  1504. return _self._sketchTempPoints;
  1505. }, false),
  1506. minimumHeights: new Cesium.CallbackProperty(function() {
  1507. return _self._sketchWallHeights;
  1508. }, false),
  1509. maximumHeights: new Cesium.CallbackProperty(function() {
  1510. _self._sketchWallMaxHeights = [];
  1511. for (let i = 0; i < _self._sketchWallHeights.length; i++) {
  1512. _self._sketchWallMaxHeights.push(_self._sketchWallHeights[i] + _self
  1513. ._param.wallHeight);
  1514. }
  1515. return _self._sketchWallMaxHeights;
  1516. }, false),
  1517. material: wallMaterial,
  1518. }
  1519. });
  1520. /* 渲染墙 */
  1521. this._drawEntity = this._entities.add(normalWall);
  1522. /* 设置实体通用属性 */
  1523. entityParam.height = this._param.wallHeight;
  1524. /* 设置实体类型 */
  1525. if (wallType === undefined || wallType === DrawTools.WallType.ColorWall) {
  1526. this._drawEntity.setEntityType(DrawTools.DrawType.NormalWall);
  1527. /* 设置实体属性 */
  1528. entityParam.id = DrawTools.DrawType.NormalWall;
  1529. } else if (wallType !== undefined && wallType === DrawTools.WallType.DynamicWall) {
  1530. this._drawEntity.setEntityType(DrawTools.DrawType.DynamicWall);
  1531. /* 设置实体属性 */
  1532. entityParam.id = DrawTools.DrawType.DynamicWall;
  1533. } else if (wallType !== undefined && wallType === DrawTools.WallType.TextWall) {
  1534. this._drawEntity.setEntityType(DrawTools.DrawType.TextWall);
  1535. /* 设置实体属性 */
  1536. entityParam.id = DrawTools.DrawType.TextWall;
  1537. }
  1538. /* 挂接实体属性 */
  1539. this._drawEntity.setParams(entityParam);
  1540. },
  1541. /**
  1542. * 更新墙
  1543. * @ignore 生成方法时不对外公开
  1544. * @param {Boolean} isEdit [是否可编辑]可选
  1545. */
  1546. _updateWall: function(isEdit) {
  1547. /* 获取三个数组的长度 */
  1548. let hLength = this._sketchWallHeights.length;
  1549. let mhLength = this._sketchWallMaxHeights.length;
  1550. let pLength = this._sketchPoints.length;
  1551. if (hLength === mhLength && hLength - pLength === 1) {
  1552. /* 移除最后一个高度点 */
  1553. this._sketchWallHeights.pop();
  1554. this._sketchWallMaxHeights.pop();
  1555. /* 设置并停止墙的动态属性 */
  1556. this._drawEntity.wall.positions = this._sketchPoints;
  1557. this._drawEntity.wall.minimumHeights = this._sketchWallHeights;
  1558. this._drawEntity.wall.maximumHeights = this._sketchWallMaxHeights;
  1559. /* 设置是否可编辑 */
  1560. if (isEdit != undefined && isEdit === true) {
  1561. /* 删除所有的临时点 忽略是否保留设置 */
  1562. this._removePointEntitys();
  1563. this._setEntityIsEdit(this._drawEntity);
  1564. }
  1565. } else {
  1566. this._console(hLength, mhLength, pLength);
  1567. }
  1568. },
  1569. /**
  1570. * 创建视频墙
  1571. * @ignore 生成方法时不对外公开
  1572. */
  1573. _createVideoWall: function() {
  1574. let _self = this;
  1575. /* 绘制面 干掉事件 */
  1576. let entityWall = new Cesium.Entity({
  1577. name: _self._sketchEntityName,
  1578. position: _self._sketchOutputPoints[0],
  1579. wall: {
  1580. show: true,
  1581. positions: new Cesium.CallbackProperty(function() {
  1582. let pt0 = _self._sketchOutputPoints[0];
  1583. let pt1 = _self._sketchOutputPoints[1];
  1584. /* 视频墙的位置集合 */
  1585. _self._wallPositions = [];
  1586. _self._wallPositions.push(Cesium.Cartesian3.fromDegrees(pt0.lng, pt0
  1587. .lat,
  1588. pt0.height));
  1589. _self._wallPositions.push(Cesium.Cartesian3.fromDegrees(pt1.lng, pt1
  1590. .lat,
  1591. pt0.height));
  1592. return _self._wallPositions;
  1593. }, false),
  1594. maximumHeights: new Cesium.CallbackProperty(function() {
  1595. _self._sketchWallHeights = [];
  1596. let pt = _self._sketchOutputPoints[0];
  1597. _self._sketchWallHeights.push(pt.height);
  1598. _self._sketchWallHeights.push(pt.height);
  1599. return _self._sketchWallHeights;
  1600. }, false),
  1601. minimumHeights: new Cesium.CallbackProperty(function() {
  1602. _self._sketchWallMaxHeights = [];
  1603. let pt = _self._sketchOutputPoints[1];
  1604. _self._sketchWallMaxHeights.push(pt.height);
  1605. _self._sketchWallMaxHeights.push(pt.height);
  1606. return _self._sketchWallMaxHeights;
  1607. }, false),
  1608. material: Cesium.Color.fromCssColorString(_self._param.polygonColor),
  1609. outline: true,
  1610. outlineColor: Cesium.Color.fromCssColorString(_self._param.outlineColor),
  1611. outlineWidth: _self._param.outlineWidth,
  1612. }
  1613. });
  1614. /* 渲染视频墙 */
  1615. _self._drawEntity = _self._entities.add(entityWall);
  1616. },
  1617. /**
  1618. * 更新视频墙
  1619. * @ignore 生成方法时不对外公开
  1620. */
  1621. _updateVideoWall: function(isEdit) {
  1622. /* 初始化一个实体参数变量 */
  1623. let entityParam = DrawTools.initEditPropertyParams();
  1624. entityParam.id = DrawTools.DrawType.VideoWall;
  1625. /* 查找视频画布 */
  1626. let videoElement = document.getElementById('wallVideo');
  1627. if (videoElement !== null) {
  1628. document.body.removeChild(videoElement);
  1629. }
  1630. videoElement = document.createElement("video");
  1631. videoElement.id = 'wallVideo';
  1632. videoElement.setAttribute('crossorigin', 'anonymous'); //必须设置 为了防止跨域调用网络视频导致播放失败
  1633. videoElement.setAttribute("width", "1024px");
  1634. videoElement.setAttribute("height", "256px");
  1635. videoElement.setAttribute("controls", "controls");
  1636. videoElement.setAttribute("src",
  1637. "https://lf3-cdn-tos.bytescm.com/obj/eden-cn/lmeh7pfuho/campus/campus_intro_20200522.mp4");
  1638. videoElement.setAttribute("loop", "loop");
  1639. videoElement.play();
  1640. document.body.appendChild(videoElement);
  1641. /* 更新数据 */
  1642. this._drawEntity.wall.positions = this._wallPositions;
  1643. this._drawEntity.wall.minimumHeights = this._sketchWallHeights;
  1644. this._drawEntity.wall.maximumHeights = this._sketchWallMaxHeights;
  1645. /* 设置高度参数 */
  1646. entityParam.height = this._sketchWallMaxHeights[0] - this._sketchWallHeights[0];
  1647. this._drawEntity.wall.material = videoElement;
  1648. /* 删除点 */
  1649. this._removePointEntitys();
  1650. /* 设置实体类型 */
  1651. this._drawEntity.setEntityType(DrawTools.DrawType.VideoWall);
  1652. entityParam.videoUrl =
  1653. 'https://lf3-cdn-tos.bytescm.com/obj/eden-cn/lmeh7pfuho/campus/campus_intro_20200522.mp4';
  1654. entityParam.id = DrawTools.DrawType.VideoWall;
  1655. /* 挂接实体属性 */
  1656. this._drawEntity.setParams(entityParam);
  1657. /* 设置是否可编辑 */
  1658. if (isEdit != undefined && isEdit === true) {
  1659. this._setEntityIsEdit(this._drawEntity);
  1660. }
  1661. },
  1662. /**
  1663. * 计算OD线的中间点
  1664. * @ignore 生成方法时不对外公开
  1665. * @param {Cesium.Cartesian3} strPoint 起始点
  1666. * @param {Cesium.Cartesian3} endPoint 终止点
  1667. * @param {Number} height 最大高度
  1668. * @param {Number} count 内插点数
  1669. */
  1670. _calculateOdlinePositios: function(strPoint, endPoint, height, count) {
  1671. let pt1 = this._cartesian3ToGeo(strPoint);
  1672. let pt2 = this._cartesian3ToGeo(endPoint);
  1673. //方程 y=-(4h/L^2)*x^2+h h:顶点高度 L:横纵间距较大者
  1674. var h = height && height < 1000 ? height : 1000;
  1675. var L = Math.abs(pt1.longitude - pt2.longitude) > Math.abs(pt1.latitude - pt2.latitude) ?
  1676. Math.abs(pt1.longitude - pt2.longitude) : Math.abs(pt1.latitude - pt2.latitude);
  1677. var num = count && count > 50 ? count : 50;
  1678. var result = [];
  1679. var tempResult = []; //临时数组
  1680. var dlt = L / num;
  1681. var addHeight = pt1.height > pt2.height ? pt1.height : pt2.height;
  1682. var maxHeight = addHeight + h;
  1683. var minHeight1 = pt1.height;
  1684. var minHeight2 = pt2.height;
  1685. if (Math.abs(pt1.longitude - pt2.longitude) > Math.abs(pt1.latitude - pt2
  1686. .latitude)) { //以lon为基准
  1687. var delLat = (pt2.latitude - pt1.latitude) / num;
  1688. if (pt1.longitude - pt2.longitude > 0) {
  1689. dlt = -dlt;
  1690. }
  1691. for (var i = 1; i < num; i++) {
  1692. var tempH = h - Math.pow((-0.5 * L + Math.abs(dlt) * i), 2) * 4 * h / Math.pow(L, 2);
  1693. var lon = pt1.longitude + dlt * i;
  1694. var lat = pt1.latitude + delLat * i;
  1695. var alt = undefined;
  1696. if (Math.abs(dlt) * i == 0.5 * L) {
  1697. alt = maxHeight;
  1698. } else if (Math.abs(dlt) * i < 0.5 * L) {
  1699. //说明是抛物线左侧
  1700. alt = ((maxHeight - minHeight1) / h) * tempH + minHeight1;
  1701. } else {
  1702. //说明是抛物线右侧
  1703. alt = ((maxHeight - minHeight2) / h) * tempH + minHeight2;
  1704. }
  1705. tempResult.push([lon, lat, alt]);
  1706. }
  1707. } else { //以lat为基准
  1708. var delLon = (pt2.longitude - pt1.longitude) / num;
  1709. if (pt1.latitude - pt2.latitude > 0) {
  1710. dlt = -dlt;
  1711. }
  1712. for (var i = 1; i < num; i++) {
  1713. var tempH = h - Math.pow((-0.5 * L + Math.abs(dlt) * i), 2) * 4 * h / Math.pow(L, 2);
  1714. var lon = pt1.longitude + delLon * i;
  1715. var lat = pt1.latitude + dlt * i;
  1716. var alt = undefined;
  1717. if (Math.abs(dlt) * i == 0.5 * L) {
  1718. alt = maxHeight;
  1719. } else if (Math.abs(dlt) * i < 0.5 * L) {
  1720. //说明是抛物线左侧
  1721. alt = ((maxHeight - minHeight1) / h) * tempH + minHeight1;
  1722. } else {
  1723. //说明是抛物线右侧
  1724. alt = ((maxHeight - minHeight2) / h) * tempH + minHeight2;
  1725. }
  1726. tempResult.push([lon, lat, alt]);
  1727. }
  1728. }
  1729. /* 对结果进行处理 */
  1730. result.push([pt1.longitude, pt1.latitude, pt1.height]);
  1731. for (var i = 0; i < tempResult.length; i++) {
  1732. result.push(tempResult[i]);
  1733. }
  1734. result.push([pt2.longitude, pt2.latitude, pt2.height]);
  1735. /* 对结果进行转换 */
  1736. let results = [];
  1737. for (let i = 0; i < result.length; i++) {
  1738. results.push(Cesium.Cartesian3.fromDegrees(result[i][0], result[i][1], result[i][2]));
  1739. }
  1740. return results;
  1741. },
  1742. /**
  1743. * 创建OD线
  1744. * @ignore 生成方法时不对外公开
  1745. * @param {Boolean} isFirst 是否第一次
  1746. */
  1747. _createOdline: function(isFirst) {
  1748. let _self = this;
  1749. /* 如果初次创建 创建一个父实体*/
  1750. if (isFirst !== undefined && isFirst === true) {
  1751. let fatherEntity = new Cesium.Entity({
  1752. name: this._sketchEntityName,
  1753. });
  1754. this._odlineFatherEntity = this._entities.add(fatherEntity);
  1755. /* 初始化一个实体参数变量 */
  1756. let entityParam = DrawTools.initEditPropertyParams();
  1757. entityParam.id = DrawTools.DrawType.OdLine;
  1758. entityParam.color = _self._param.polygonColor;
  1759. entityParam.duration = _self._param.duration;
  1760. entityParam.direction = _self._param.direction_h;
  1761. entityParam.count = _self._param.count;
  1762. entityParam.order = _self._param.order_add;
  1763. entityParam.odlineHeight = _self._param.odlineHeight;
  1764. entityParam.odlineCount = _self._param.odlineCount;
  1765. entityParam.lineWidth = _self._param.lineWidth * 3;
  1766. /* 为父实体设置参数 保存该OD线集合的必要参数 */
  1767. this._odlineFatherEntity.setParams(entityParam);
  1768. /* 创建一个临时集合 方便回退删除 */
  1769. this._odlineEntitys = [];
  1770. }
  1771. /* 从父节点获取必要参数 */
  1772. let faterParam = this._odlineFatherEntity.getParams();
  1773. /* 创建OD线材质 */
  1774. let odLineMaterial = new WallMaterialProperty({
  1775. viewer: _self._viewer,
  1776. trailImage: _self._image_arrow_reverse,
  1777. duration: faterParam.duration,
  1778. color: Cesium.Color.fromCssColorString(faterParam.color),
  1779. param: {
  1780. direction: faterParam.direction,
  1781. count: faterParam.count,
  1782. order: faterParam.order,
  1783. },
  1784. });
  1785. /* 创建OD线 */
  1786. let entity = new Cesium.Entity({
  1787. name: _self._sketchEntityName,
  1788. parent: this._odlineFatherEntity,
  1789. polyline: {
  1790. show: true,
  1791. positions: new Cesium.CallbackProperty(function() {
  1792. let center = _self._sketchTempPoints[0];
  1793. let endPoint = _self._sketchTempPoints[_self._sketchTempPoints.length -
  1794. 1];
  1795. let results = _self._calculateOdlinePositios(center, endPoint, parseInt(
  1796. faterParam.odlineHeight),
  1797. parseInt(faterParam.odlineCount));
  1798. return results;
  1799. }, false),
  1800. material: odLineMaterial,
  1801. width: faterParam.lineWidth,
  1802. clampToGround: false, //由于是空间线禁止贴地或贴模型
  1803. }
  1804. })
  1805. /* 加入集合 */
  1806. this._drawEntity = this._entities.add(entity);
  1807. },
  1808. /**
  1809. * 更新OD线
  1810. * @ignore 生成方法时不对外公开
  1811. * @param {Boolean} isLast 是否是最后一个
  1812. * @param {Boolean} isEdit 是否为可编辑
  1813. */
  1814. _updateOdline: function(isLast, isEdit) {
  1815. if (isLast !== undefined && isLast === true) {
  1816. if (isEdit !== undefined && isEdit === true) {
  1817. this._drawEntity.setEntityType(DrawTools.DrawType.OdLine);
  1818. this._setEntityIsEdit(this._drawEntity);
  1819. this._drawEntity.parent.setIsEdit(true);
  1820. }
  1821. } else {
  1822. let params = this._drawEntity.parent.getParams();
  1823. let center = this._sketchTempPoints[0];
  1824. let endPoint = this._sketchTempPoints[this._sketchTempPoints.length -
  1825. 1];
  1826. let results = this._calculateOdlinePositios(center, endPoint, parseInt(params.odlineHeight),
  1827. parseInt(params.odlineCount));
  1828. this._drawEntity.polyline.positions = results;
  1829. this._drawEntity.setEntityType(DrawTools.DrawType.OdLine);
  1830. this._odlineEntitys.push(this._drawEntity);
  1831. if (isEdit !== undefined && isEdit === true) {
  1832. this._drawEntity.setIsEdit(true);
  1833. }
  1834. }
  1835. },
  1836. /**
  1837. * 生成GUID随机数
  1838. * @ignore 生成方法时不对外公开
  1839. */
  1840. _guid() {
  1841. function S4() {
  1842. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  1843. }
  1844. return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
  1845. },
  1846. /**
  1847. * 输出消息
  1848. * @ignore 生成方法时不对外公开
  1849. * @param {Object} res
  1850. */
  1851. _console(...rest) {
  1852. console.log('===>>>', rest);
  1853. }
  1854. })
  1855. /**
  1856. * 对外方法
  1857. */
  1858. Object.assign(DrawTools.prototype, {
  1859. /**
  1860. * 鼠标双击结束提示事件
  1861. * @ignore
  1862. * @param {Cesium.Cartesian2} position 位置
  1863. */
  1864. _drawMovingDoubleTooltip(position) {
  1865. this._updateTooltip('左键单击绘制,右键单击撤销<br>左键双击结束绘制', position);
  1866. },
  1867. /**
  1868. * 鼠标单击结束提示事件
  1869. * @ignore
  1870. * @param {Cesium.Cartesian2} position 位置
  1871. */
  1872. _drawMovingSimpleTooltip(position) {
  1873. this._updateTooltip('左键单击结束绘制', position);
  1874. },
  1875. /**
  1876. * 移除最后绘制的一个点元素
  1877. * @ignore
  1878. */
  1879. _removeLastDrawPointEntity() {
  1880. let lastPointEntity = this._pointEntitys.last();
  1881. if (lastPointEntity !== undefined) {
  1882. this._removeEntityByObject(lastPointEntity);
  1883. this._pointEntitys.pop();
  1884. }
  1885. },
  1886. /**
  1887. * 绘制点工具
  1888. * @ignore 生成方法时不对外公开
  1889. * @param {Object} handler 事件句柄
  1890. * @param {JSON} options 配置项
  1891. * @param {Function} [options.onComplete(cPoint, gPoint)] 完成回调 可选
  1892. * @param {Function} [options.onError(message)] 错误回到 可选
  1893. */
  1894. _sketchDrawPoint(handler, options) {
  1895. let _self = this;
  1896. /* 注册鼠标左键点击事件 */
  1897. this._registerLeftClickEvent(handler, function(event) {
  1898. /* 识别屏幕位置 */
  1899. // let loc = _self._transfromFromScreenPoint(event.position);
  1900. // if (!Cesium.defined(loc.sLocation)) return;
  1901. let scene = _self._viewer.scene;
  1902. if (scene.mode !== Cesium.SceneMode.MORPHING) {
  1903. var pickedObject = scene.pick(event.position);
  1904. if (scene.pickPositionSupported && Cesium.defined(pickedObject)) {
  1905. var cartesian = scene.pickPosition(event.position);
  1906. if (Cesium.defined(cartesian)) {
  1907. var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
  1908. var lng = Cesium.Math.toDegrees(cartographic.longitude);
  1909. var lat = Cesium.Math.toDegrees(cartographic.latitude);
  1910. var height = cartographic.height; //模型高度
  1911. _self._sketchOutputPoints.push({
  1912. lng: lng,
  1913. lat: lat,
  1914. height: height
  1915. })
  1916. }
  1917. _self._createPoint(cartesian, '点');
  1918. _self._sketchPoints.push(cartesian.clone());
  1919. if (_self._sketchPoints.length >= 2) {
  1920. _self._createVideoWall();
  1921. /* 干掉事件句柄 释放资源 */
  1922. _self._clearEvent(handler);
  1923. }
  1924. }
  1925. }
  1926. /* 监听输出 */
  1927. if (options.onComplete) options.onComplete(loc.sLocation, loc.gLocation);
  1928. })
  1929. },
  1930. /**
  1931. * 绘制多点
  1932. * @ignore 生成方法时不对外公开
  1933. * @param {Object} handler 事件句柄
  1934. * @param {JSON} options 配置项
  1935. * @param {Function} [options.onAdded(cPoinit,gPoint)] 添加回调 可选
  1936. * @param {Function} [options.onUndo()] 撤销回调 可选
  1937. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  1938. * @param {Function} [options.onError(message)] 错误回调 可选
  1939. */
  1940. _sketchDrawMultiplePoint(handler, options) {
  1941. let _self = this;
  1942. /* 注册鼠标左键点击事件 */
  1943. this._registerLeftClickEvent(handler, function(event) {
  1944. /* 识别屏幕位置 */
  1945. let loc = _self._transfromFromScreenPoint(event.position);
  1946. if (!Cesium.defined(loc.sLocation)) return;
  1947. /* 绘制点 */
  1948. if (_self._isDrawPoint) {
  1949. _self._createPoint(loc.sLocation, _self._lineLabel);
  1950. }
  1951. _self._sketchPoints.push(loc.sLocation);
  1952. _self._sketchOutputPoints.push(loc.gLocation);
  1953. /* 监听输出 */
  1954. if (options.onAdded) options.onAdded(loc.sLocation, loc.gLocation);
  1955. })
  1956. /* 注册鼠标右键事件 */
  1957. this._registerRightClickEvent(handler, function(event) {
  1958. if (_self._sketchPoints.length > 0) {
  1959. _self._sketchPoints.pop();
  1960. _self._sketchOutputPoints.pop();
  1961. if (options.onUndo) options.onUndo();
  1962. }
  1963. })
  1964. /* 注册鼠标左键双击事件 */
  1965. this._registerLeftDoubleClickEvent(handler, function(event) {
  1966. /* 干掉事件句柄 释放资源 */
  1967. _self._clearEvent(handler);
  1968. /* 回调 */
  1969. if (options.onComplete) options.onComplete(_self._sketchPoints, _self._sketchOutputPoints);
  1970. })
  1971. },
  1972. /**
  1973. * 绘制贴地线工具
  1974. * @ignore 生成方法时不对外公开
  1975. * @param {Object} handler 事件句柄
  1976. * @param {JSON} options 配置项
  1977. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  1978. * @param {DrawTools.PolylineType} options.polylineType 线的类型 可选
  1979. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  1980. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  1981. * @param {Function} [options.onUndo()] 撤销回调 可选
  1982. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  1983. * @param {Function} [options.onError(message)] 错误回调 可选
  1984. */
  1985. _sketchDrawPolyline(handler, options) {
  1986. let _self = this;
  1987. /* 注册鼠标左键点击事件 */
  1988. this._registerLeftClickEvent(handler, function(event) {
  1989. /* 识别屏幕位置 */
  1990. let loc = _self._transfromFromScreenPoint(event.position);
  1991. if (!Cesium.defined(loc.sLocation)) return;
  1992. /* 绘制参考点 */
  1993. if (_self._isDrawPoint) {
  1994. _self._createPoint(loc.sLocation, _self._lineLabel);
  1995. }
  1996. /* 第一点击的时候绘制线 */
  1997. if (_self._sketchTempPoints.length === 0) {
  1998. _self._createPolyline(options.polylineType);
  1999. _self._sketchTempPoints.push(loc.sLocation.clone());
  2000. }
  2001. _self._sketchTempPoints.push(loc.sLocation);
  2002. /* 存储正式绘制点集合 */
  2003. _self._sketchPoints.push(loc.sLocation.clone());
  2004. /* 存储输出经纬度点集合 */
  2005. _self._sketchOutputPoints.push(loc.gLocation);
  2006. /* 监听输出 */
  2007. if (options.onAdded) options.onAdded(_self._sketchPoints, _self
  2008. ._sketchOutputPoints);
  2009. /* 添加操作容器 */
  2010. _self._createOperationDom();
  2011. })
  2012. /* 注册鼠标移动事件 */
  2013. this._registerMouseMoveEvent(handler, function(event) {
  2014. /* 如果运行环境是App 则禁止使用移动事件 */
  2015. if (_self._isRuntimeApp()) return;
  2016. /* 识别屏幕位置 */
  2017. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2018. if (!Cesium.defined(loc.sLocation)) return;
  2019. if (_self._sketchTempPoints.length > 1) {
  2020. /* 标签提示 */
  2021. _self._drawMovingDoubleTooltip(event.endPosition);
  2022. _self._sketchTempPoints.pop();
  2023. _self._sketchTempPoints.push(loc.sLocation);
  2024. /* 监听输出 */
  2025. if (options.onMoving) options.onMoving(loc.sLocation);
  2026. }
  2027. });
  2028. /* 注册鼠标右键点击事件 */
  2029. this._registerRightClickEvent(handler, function(event) {
  2030. if (_self._sketchTempPoints.length > 2) {
  2031. _self._drawByUndo();
  2032. if (options.onUndo) options.onUndo();
  2033. }
  2034. });
  2035. /* 注册鼠标左键双击事件 */
  2036. this._registerLeftDoubleClickEvent(handler, function(event) {
  2037. if (_self._sketchPoints.length < 2) {
  2038. if (options.onError) options.onError('点数少于两个,禁止结束绘制!');
  2039. return;
  2040. }
  2041. /* 更新贴地线 */
  2042. _self._updatePolyline(options.isEdit);
  2043. /* 删除标记点 */
  2044. if (!_self._isRetainDrawPoint) _self._removePointEntitys();
  2045. /* 干掉事件句柄 释放资源*/
  2046. _self._clearEvent(handler);
  2047. /* 监听输出 */
  2048. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2049. ._sketchOutputPoints);
  2050. })
  2051. },
  2052. /**
  2053. * 绘制空间线工具
  2054. * @ignore 生成方法时不对外公开
  2055. * @param {Object} handler 事件句柄
  2056. * @param {JSON} options 配置项
  2057. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2058. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  2059. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2060. * @param {Function} [options.onUndo()] 撤销回调 可选
  2061. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  2062. * @param {Function} [options.onError(message)] 错误回到 可选
  2063. */
  2064. _sketchDrawSpatialPolyline(handler, options) {
  2065. let _self = this;
  2066. /* 注册鼠标左键单击事件 */
  2067. this._registerLeftClickEvent(handler, function(event) {
  2068. /* 识别屏幕位置 */
  2069. let loc = _self._transfromFromScreenPoint(event.position);
  2070. if (!Cesium.defined(loc.sLocation)) return;
  2071. /* 绘制点 */
  2072. if (_self._isDrawPoint) {
  2073. _self._createPoint(loc.sLocation, _self._lineLabel);
  2074. }
  2075. /* 第一点击的时候绘制线 */
  2076. if (_self._sketchTempPoints.length === 0) {
  2077. _self._createSpatialPolyline();
  2078. _self._sketchTempPoints.push(loc.sLocation.clone());
  2079. }
  2080. _self._sketchTempPoints.push(loc.sLocation);
  2081. /* 存储正式绘制点集合 */
  2082. _self._sketchPoints.push(loc.sLocation.clone());
  2083. /* 存储输出经纬度点集合 */
  2084. _self._sketchOutputPoints.push(loc.gLocation);
  2085. /* 监听输出 */
  2086. if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
  2087. /* 添加操作容器 */
  2088. _self._createOperationDom();
  2089. })
  2090. /* 注册鼠标移动事件 */
  2091. this._registerMouseMoveEvent(handler, function(event) {
  2092. /* 如果运行环境是App 则禁止使用移动事件 */
  2093. if (_self._isRuntimeApp()) return;
  2094. /* 识别屏幕位置 */
  2095. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2096. if (!Cesium.defined(loc.sLocation)) return;
  2097. if (_self._sketchTempPoints.length > 1) {
  2098. /* 标签提示 */
  2099. _self._drawMovingDoubleTooltip(event.endPosition);
  2100. _self._sketchTempPoints.pop();
  2101. _self._sketchTempPoints.push(loc.sLocation);
  2102. /* 监听输出 */
  2103. if (options.onMoving) options.onMoving(loc.sLocation);
  2104. }
  2105. })
  2106. /* 注册鼠标左键双击事件 */
  2107. this._registerLeftDoubleClickEvent(handler, function(event) {
  2108. if (_self._sketchPoints.length < 2) {
  2109. if (options.onError) options.onError('绘制点少于2个,禁止结束绘制!');
  2110. return;
  2111. }
  2112. /* 绘制正式空间线 */
  2113. _self._updateSpatialPolyline(options.isEdit);
  2114. /* 删除标记点 */
  2115. _self._removePointEntitys();
  2116. /* 干掉事件句柄 释放资源*/
  2117. _self._clearEvent(handler);
  2118. /* 监听输出 */
  2119. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2120. ._sketchOutputPoints);
  2121. })
  2122. /* 注册鼠标右键单击事件 */
  2123. this._registerRightClickEvent(handler, function(event) {
  2124. if (_self._sketchTempPoints.length > 2) {
  2125. _self._drawByUndo();
  2126. if (options.onUndo) options.onUndo();
  2127. }
  2128. });
  2129. },
  2130. /**
  2131. * 绘制OD线工具
  2132. * @ignore 生成方法时不对外公开
  2133. * @param {Object} handler 事件句柄
  2134. * @param {JSON} options 配置项
  2135. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2136. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  2137. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2138. * @param {Function} [options.onUndo()] 撤销回调 可选
  2139. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  2140. * @param {Function} [options.onError(message)] 错误回到 可选
  2141. */
  2142. _sketchDrawOdline(handler, options) {
  2143. let _self = this;
  2144. /* 注册鼠标左键单击事件 */
  2145. this._registerLeftClickEvent(handler, function(event) {
  2146. /* 识别屏幕位置 */
  2147. let loc = _self._transfromFromScreenPoint(event.position);
  2148. if (!Cesium.defined(loc.sLocation)) return;
  2149. /* 绘制点 */
  2150. if (_self._isDrawPoint) {
  2151. _self._createPoint(loc.sLocation, _self._lineLabel);
  2152. }
  2153. if (_self._isRuntimeApp()) {
  2154. _self._showTooltipMessage('再次单击绘制一条OD线!');
  2155. }
  2156. /* 第一点击的时候绘制线 */
  2157. if (_self._sketchTempPoints.length === 0) {
  2158. _self._createOdline(true);
  2159. _self._sketchTempPoints.push(loc.sLocation.clone());
  2160. } else {
  2161. _self._sketchTempPoints.push(loc.sLocation.clone());
  2162. _self._updateOdline(false, options.isEdit);
  2163. _self._createOdline();
  2164. }
  2165. _self._sketchTempPoints.push(loc.sLocation);
  2166. /* 存储正式绘制点集合 */
  2167. _self._sketchPoints.push(loc.sLocation.clone());
  2168. /* 存储输出经纬度点集合 */
  2169. _self._sketchOutputPoints.push(loc.gLocation);
  2170. /* 监听输出 */
  2171. if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
  2172. /* 添加操作容器 */
  2173. _self._createOperationDom();
  2174. })
  2175. /* 注册鼠标移动事件 */
  2176. this._registerMouseMoveEvent(handler, function(event) {
  2177. /* 如果运行环境是App 则禁止使用移动事件 */
  2178. if (_self._isRuntimeApp()) return;
  2179. /* 识别屏幕位置 */
  2180. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2181. if (!Cesium.defined(loc.sLocation)) return;
  2182. if (_self._sketchTempPoints.length > 1) {
  2183. /* 标签提示 */
  2184. _self._drawMovingDoubleTooltip(event.endPosition);
  2185. _self._sketchTempPoints.pop();
  2186. _self._sketchTempPoints.push(loc.sLocation);
  2187. /* 监听输出 */
  2188. if (options.onMoving) options.onMoving(loc.sLocation);
  2189. }
  2190. })
  2191. /* 注册鼠标左键双击事件 */
  2192. this._registerLeftDoubleClickEvent(handler, function(event) {
  2193. /* 绘制正式OD线 */
  2194. _self._removeEntityByObject(_self._drawEntity);
  2195. _self._updateOdline(true, options.isEdit);
  2196. /* 删除标记点 */
  2197. _self._removePointEntitys();
  2198. /* 干掉事件句柄 释放资源*/
  2199. _self._clearEvent(handler);
  2200. /* 监听输出 */
  2201. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2202. ._sketchOutputPoints);
  2203. })
  2204. /* 注册鼠标右键单击事件 */
  2205. this._registerRightClickEvent(handler, function(event) {
  2206. if (_self._odlineEntitys.length > 0) {
  2207. /* 删除最后一个绘制点 */
  2208. if (_self._isDrawPoint) {
  2209. _self._removeLastDrawPointEntity();
  2210. }
  2211. _self._removeEntityByObject(_self._odlineEntitys.last());
  2212. _self._odlineEntitys.pop();
  2213. if (options.onUndo) options.onUndo();
  2214. }
  2215. });
  2216. },
  2217. /**
  2218. * 绘制贴地面工具
  2219. * @ignore 生成方法时不对外公开
  2220. * @param {Object} handler 事件句柄
  2221. * @param {JSON} options 配置项
  2222. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2223. * @param {DrawTools.PolygonType} options.polygonType 绘制面类型 可选
  2224. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  2225. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2226. * @param {Function} [options.onUndo()] 撤销回调 可选
  2227. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  2228. * @param {Function} [options.onError(message)] 错误回到 可选
  2229. */
  2230. _sketchDrawPolygon(handler, options) {
  2231. let _self = this;
  2232. /* 注册鼠标左键点击事件 */
  2233. this._registerLeftClickEvent(handler, function(event) {
  2234. /* 识别屏幕位置 */
  2235. let loc = _self._transfromFromScreenPoint(event.position);
  2236. if (!Cesium.defined(loc.sLocation)) return;
  2237. /* 绘制点 */
  2238. if (_self._isDrawPoint) {
  2239. _self._createPoint(loc.sLocation, _self._lineLabel);
  2240. }
  2241. /* 当点数为0时绘制线和面 */
  2242. if (_self._sketchTempPoints.length === 0) {
  2243. _self._createPolygon(options.polygonType);
  2244. _self._sketchTempPoints.push(loc.sLocation.clone());
  2245. }
  2246. _self._sketchTempPoints.push(loc.sLocation);
  2247. /* 存储正式绘制点集合 */
  2248. _self._sketchPoints.push(loc.sLocation.clone());
  2249. /* 存储输出经纬度点集合 */
  2250. _self._sketchOutputPoints.push(loc.gLocation);
  2251. /* 监听输出 */
  2252. if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
  2253. /* 添加操作容器 */
  2254. _self._createOperationDom();
  2255. });
  2256. /* 注册鼠标移动事件 */
  2257. this._registerMouseMoveEvent(handler, function(event) {
  2258. /* 如果运行环境是App 则禁止使用移动事件 */
  2259. if (_self._isRuntimeApp()) return;
  2260. /* 识别屏幕位置 */
  2261. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2262. if (!Cesium.defined(loc.sLocation)) return;
  2263. if (_self._sketchTempPoints.length > 1) {
  2264. /* 标签提示 */
  2265. _self._drawMovingDoubleTooltip(event.endPosition);
  2266. _self._sketchTempPoints.pop();
  2267. _self._sketchTempPoints.push(loc.sLocation);
  2268. /* 监听输出 */
  2269. if (options.onMoving) options.onMoving(loc.sLocation);
  2270. }
  2271. });
  2272. /* 注册鼠标右键单击事件 */
  2273. this._registerRightClickEvent(handler, function(event) {
  2274. if (_self._sketchTempPoints.length > 2) {
  2275. _self._drawByUndo();
  2276. if (options.onUndo) options.onUndo();
  2277. }
  2278. });
  2279. /* 注册鼠标左键双击事件 */
  2280. this._registerLeftDoubleClickEvent(handler, function(event) {
  2281. if (_self._sketchPoints.length < 3) {
  2282. if (options.onError) options.onError('点数少于3个,禁止结束绘制!');
  2283. return;
  2284. }
  2285. /* 更新贴地面 */
  2286. _self._updatePolygon(options.isEdit);
  2287. /* 删除标记点 */
  2288. if (!_self._isRetainDrawPoint) _self._removePointEntitys();
  2289. /* 干掉事件句柄 释放资源*/
  2290. _self._clearEvent(handler);
  2291. /* 监听输出 */
  2292. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2293. ._sketchOutputPoints);
  2294. })
  2295. },
  2296. /**
  2297. * 绘制贴地圆工具
  2298. * @ignore 生成方法时不对外公开
  2299. * @param {Object} handler 事件句柄
  2300. * @param {JSON} options 配置项
  2301. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2302. * @param {DrawTools.CircleType} options.circleType 绘制圆的类型 可选
  2303. * @param {Function} [options.onAdded(center)] 添加回调 可选
  2304. * @param {Function} [options.onComplete(center,radius)] 完成回调 可选
  2305. * @param {Function} [options.onError(message)] 错误回到 可选
  2306. */
  2307. _sketchDrawCircle: function(handler, options) {
  2308. let _self = this;
  2309. /* 注册鼠标左键单击事件 */
  2310. this._registerLeftClickEvent(handler, function(event) {
  2311. /* 识别屏幕位置 */
  2312. let loc = _self._transfromFromScreenPoint(event.position);
  2313. if (!Cesium.defined(loc.sLocation)) return;
  2314. if (_self._sketchTempPoints.length === 0) {
  2315. /* 绘制点 */
  2316. if (_self._isDrawPoint) {
  2317. _self._createPoint(loc.sLocation, '起点');
  2318. }
  2319. /* 添加数据 */
  2320. _self._sketchTempPoints.push(loc.sLocation.clone());
  2321. _self._sketchTempPoints.push(loc.sLocation); //凑数的
  2322. /* 存储正式绘制点集合 */
  2323. _self._sketchPoints.push(loc.sLocation.clone());
  2324. /* 存储经纬度 */
  2325. _self._sketchOutputPoints.push(loc.gLocation);
  2326. /* 创建圆 */
  2327. _self._createCircle(loc.sLocation, options.circleType);
  2328. /* App提示信息 */
  2329. if (_self._isRuntimeApp()) {
  2330. _self._showTooltipMessage('再次单击结束绘制!');
  2331. }
  2332. /* 监听输出 */
  2333. if (options.onAdded) options.onAdded(loc.sLocation);
  2334. } else {
  2335. _self._sketchTempPoints.push(loc.sLocation.clone());
  2336. /* 删除标记点 */
  2337. _self._removePointEntitys();
  2338. /* 更新圆 */
  2339. _self._updateCircle(options.isEdit);
  2340. /* 干掉事件句柄 释放资源*/
  2341. _self._clearEvent(handler);
  2342. /* 回调返回 */
  2343. if (options.onComplete) options.onComplete(_self._sketchOutputPoints[0], _self
  2344. ._sketchEllipseRadius);
  2345. }
  2346. });
  2347. /* 注册鼠标移动事件 */
  2348. this._registerMouseMoveEvent(handler, function(event) {
  2349. if (_self._isRuntimeApp()) {
  2350. return;
  2351. }
  2352. /* 如果还未创建圆 则直接返回 */
  2353. if (_self._sketchTempPoints.length <= 0) return;
  2354. /* 标签提示 */
  2355. _self._drawMovingSimpleTooltip(event.endPosition);
  2356. /* 获取空间位置 */
  2357. var cartesian = _self._viewer.scene.pickPosition(event.endPosition);
  2358. /* 如果获取点失败 则直接返回 */
  2359. if (cartesian == undefined) return;
  2360. _self._sketchTempPoints.pop();
  2361. _self._sketchTempPoints.push(cartesian);
  2362. })
  2363. },
  2364. /**
  2365. * 绘制贴地矩形工具
  2366. * @ignore 生成方法时不对外公开
  2367. * @param {Object} handler 事件句柄
  2368. * @param {JSON} options 配置项
  2369. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2370. * @param {Function} [options.onAdded(cPoint)] 添加回调 可选
  2371. * @param {Function} [options.onComplete(points)] 完成回调 可选
  2372. */
  2373. _sketchDrawRectangle: function(handler, options) {
  2374. let _self = this;
  2375. /* 注册鼠标左键单击事件 */
  2376. this._registerLeftClickEvent(handler, function(event) {
  2377. if (_self._sketchTempPoints.length === 0) {
  2378. /* 识别屏幕位置 */
  2379. let loc = _self._transfromFromScreenPoint(event.position);
  2380. if (!Cesium.defined(loc.sLocation)) return;
  2381. /* 绘制点 */
  2382. if (_self._isDrawPoint) {
  2383. _self._createPoint(loc.sLocation, '起点');
  2384. }
  2385. /* 添加数据 */
  2386. _self._sketchTempPoints.push(loc.sLocation);
  2387. _self._sketchTempPoints.push(loc.sLocation); //凑数的
  2388. /* 存储正式绘制点集合 */
  2389. _self._sketchPoints.push(loc.gLocation);
  2390. /* 创建矩形 */
  2391. _self._createRectangle();
  2392. /* 回调 */
  2393. if (options.onAdded) options.onAdded(loc.sLocation);
  2394. /* App提示信息 */
  2395. if (_self._isRuntimeApp()) {
  2396. _self._showTooltipMessage('再次单击结束绘制!');
  2397. }
  2398. } else {
  2399. /* 删除标记点 */
  2400. _self._removePointEntitys();
  2401. /* 删除临时矩形 */
  2402. _self._removeEntityByObject(_self._sketchTempRectangle);
  2403. /* 创建正式矩形 */
  2404. _self._updateRectangle(options.isEdit);
  2405. /* 干掉事件句柄 释放资源*/
  2406. _self._clearEvent(handler);
  2407. /* 回调返回 */
  2408. if (options.onComplete) options.onComplete(_self._sketchOutputPoints);
  2409. }
  2410. });
  2411. /* 挂接鼠标移动事件 */
  2412. this._registerMouseMoveEvent(handler, function(event) {
  2413. /* 如果还未创矩形 则直接返回 */
  2414. if (_self._sketchTempPoints.length < 1) return;
  2415. /* 标签提示 */
  2416. _self._drawMovingSimpleTooltip(event.endPosition);
  2417. /* 识别屏幕位置 */
  2418. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2419. if (!Cesium.defined(loc.sLocation)) return;
  2420. _self._sketchTempPoints.pop();
  2421. _self._sketchTempPoints.push(loc.sLocation);
  2422. });
  2423. },
  2424. /**
  2425. * 绘制墙
  2426. * @ignore 生成方法时不对外公开
  2427. * @param {Object} handler 事件句柄
  2428. * @param {JSON} options 配置项
  2429. * @param {Boolean} options.isEdit [是否可编辑 可选]
  2430. * @param {DrawTools.WallType} options.wallType [绘制墙的类型 可选]
  2431. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2432. * @param {Function} [options.onComplete(positions)] 完成回调 可选
  2433. * @param {Function} [options.onError(message)] 错误回到 可选
  2434. */
  2435. _sketchDrawWall: function(handler, options) {
  2436. let _self = this;
  2437. /* 注册鼠标左键点击事件 */
  2438. this._registerLeftClickEvent(handler, function(event) {
  2439. /* 识别屏幕位置 */
  2440. let loc = _self._transfromFromScreenPoint(event.position);
  2441. if (!Cesium.defined(loc.sLocation)) return;
  2442. /* 绘制点 */
  2443. if (_self._isDrawPoint) {
  2444. _self._createPoint(loc.sLocation, _self._lineLabel);
  2445. }
  2446. /* 第一点击的时候绘制线 */
  2447. if (_self._sketchTempPoints.length === 0) {
  2448. _self._createWall(options.wallType);
  2449. _self._sketchTempPoints.push(loc.sLocation.clone());
  2450. /* 存储墙的高度点集合 */
  2451. _self._sketchWallHeights.push(loc.gLocation.height);
  2452. }
  2453. _self._sketchTempPoints.push(loc.sLocation);
  2454. _self._sketchWallHeights.push(loc.gLocation.height);
  2455. /* 存储正式绘制点集合 */
  2456. _self._sketchPoints.push(loc.sLocation.clone());
  2457. /* 添加操作容器 */
  2458. _self._createOperationDom();
  2459. })
  2460. /* 注册鼠标移动事件 */
  2461. this._registerMouseMoveEvent(handler, function(event) {
  2462. if (_self._isRuntimeApp()) {
  2463. return;
  2464. }
  2465. /* 识别屏幕位置 */
  2466. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2467. if (!Cesium.defined(loc.sLocation)) return;
  2468. if (_self._sketchTempPoints.length > 1) {
  2469. /* 标签提示 */
  2470. _self._drawMovingDoubleTooltip(event.endPosition);
  2471. _self._sketchTempPoints.pop();
  2472. _self._sketchTempPoints.push(loc.sLocation);
  2473. _self._sketchWallHeights.pop();
  2474. _self._sketchWallHeights.push(loc.gLocation.height);
  2475. }
  2476. });
  2477. /* 注册鼠标右键点击事件 */
  2478. this._registerRightClickEvent(handler, function(event) {
  2479. if (_self._sketchTempPoints.length > 2) {
  2480. /* 移除正式点最有一个元素 */
  2481. _self._sketchPoints.pop();
  2482. if (_self._isRuntimeApp()) {
  2483. /* 移除临时点倒数第二个元素 */
  2484. _self._sketchTempPoints.splice(_self._sketchTempPoints.length - 1, 1);
  2485. /* 移除临时高度点倒数第二个元素 */
  2486. _self._sketchWallHeights.splice(_self._sketchWallHeights.length - 1, 1);
  2487. } else {
  2488. /* 移除临时点倒数第二个元素 */
  2489. _self._sketchTempPoints.splice(_self._sketchTempPoints.length - 2, 1);
  2490. /* 移除临时高度点倒数第二个元素 */
  2491. _self._sketchWallHeights.splice(_self._sketchWallHeights.length - 2, 1);
  2492. }
  2493. /* 如果绘制了点 则删除最后一个 */
  2494. if (_self._isDrawPoint) {
  2495. _self._removeLastDrawPointEntity();
  2496. }
  2497. }
  2498. });
  2499. /* 注册鼠标左键双击事件 */
  2500. this._registerLeftDoubleClickEvent(handler, function(event) {
  2501. if (_self._sketchPoints.length < 2) {
  2502. if (options.onError) options.onError('点数少于两个,禁止结束绘制!');
  2503. return;
  2504. }
  2505. /* 更新墙属性 */
  2506. _self._updateWall(options.isEdit);
  2507. /* 删除标记点 */
  2508. if (!_self._isRetainDrawPoint) _self._removePointEntitys();
  2509. /* 干掉事件句柄 释放资源*/
  2510. _self._clearEvent(handler);
  2511. })
  2512. },
  2513. /**
  2514. * 绘制视频墙工具
  2515. * @ignore 生成方法时不对外公开
  2516. * @param {Object} handler 事件句柄
  2517. * @param {JSON} options 配置项
  2518. * @param {Boolean} options.isEdit [是否可编辑 可选]
  2519. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2520. * @param {Function} [options.onComplete(positions)] 完成回调 可选
  2521. * @param {Function} [options.onError(message)] 错误回到 可选
  2522. */
  2523. _sketchDrawVideoWall: function(handler, options) {
  2524. let _self = this;
  2525. /* 注册鼠标左键点击事件 */
  2526. this._registerLeftClickEvent(handler, function(event) {
  2527. /* 识别屏幕位置 */
  2528. let loc = _self._transfromFromScreenPoint(event.position);
  2529. if (!Cesium.defined(loc.sLocation)) return;
  2530. /* 绘制点 */
  2531. if (_self._isDrawPoint) {
  2532. _self._createPoint(loc.sLocation, _self._lineLabel);
  2533. }
  2534. /* 第一点击的时候绘制 */
  2535. if (_self._sketchOutputPoints.length === 0) {
  2536. _self._sketchOutputPoints.push(loc.gLocation);
  2537. _self._sketchOutputPoints.push(loc.gLocation);
  2538. _self._createVideoWall();
  2539. if (_self._isRuntimeApp()) {
  2540. _self._showTooltipMessage('再次单击结束绘制');
  2541. }
  2542. } else {
  2543. _self._updateVideoWall(options.isEdit);
  2544. _self._clearEvent(handler);
  2545. }
  2546. // _self._removeCoorinateAxis();
  2547. // _self._createCoordinateAxis(loc.sLocation);
  2548. // _self._clearEvent(handler);
  2549. })
  2550. /* 注册鼠标移动事件 */
  2551. this._registerMouseMoveEvent(handler, function(event) {
  2552. if (_self._isRuntimeApp()) return;
  2553. /* 识别屏幕位置 */
  2554. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2555. if (!Cesium.defined(loc.sLocation)) return;
  2556. if (_self._sketchOutputPoints.length > 1) {
  2557. /* 标签提示 */
  2558. _self._drawMovingSimpleTooltip(event.endPosition);
  2559. _self._sketchOutputPoints.pop();
  2560. _self._sketchOutputPoints.push(loc.gLocation);
  2561. }
  2562. });
  2563. },
  2564. /**
  2565. * 撤销上一步的绘制
  2566. */
  2567. _drawByUndo: function() {
  2568. /* 移除正式点最有一个元素 */
  2569. this._sketchPoints.pop();
  2570. if (this._isRuntimeApp()) {
  2571. /* 移除临时点倒数第一个元素 */
  2572. this._sketchTempPoints.splice(this._sketchTempPoints.length - 1, 1);
  2573. } else {
  2574. /* 移除临时点倒数第二个元素 */
  2575. this._sketchTempPoints.splice(this._sketchTempPoints.length - 2, 1);
  2576. }
  2577. /* 如果绘制了点 则删除最后一个 */
  2578. if (this._isDrawPoint) {
  2579. this._removeLastDrawPointEntity();
  2580. }
  2581. },
  2582. /**
  2583. * 启用绘制
  2584. * @param {DrawTools.DrawType} type 绘制类型
  2585. * @param {JSON} options 回调集合
  2586. * @param {Boolean} [isEdit] 是否可编辑 可选 默认不可编辑
  2587. * @param {Function} [options.onAdded] 添加回调 可选 子方法自定义
  2588. * @param {Function} [options.onMoving] 移动回调 可选 子方法自定义
  2589. * @param {Function} [options.onUndo] 撤销回调 可选 子方法自定义
  2590. * @param {Function} [options.onComplete] 完成回调 可选 子方法自定义
  2591. * @param {Function} [options.onError] 错误回调 可选 子方法自定义
  2592. */
  2593. draw: function(type, options) {
  2594. /* 定义自身 */
  2595. let _self = this;
  2596. /* 初始化 */
  2597. this._clear();
  2598. /* 注册事件 */
  2599. this._drawEventHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  2600. if (this._isRuntimeApp()) {
  2601. this._showTooltipMessage("单击绘制");
  2602. } else {
  2603. this._beginTooltip('左键单击绘制', undefined);
  2604. }
  2605. this._drawType = type;
  2606. /* 分类型注册事件 */
  2607. switch (type) {
  2608. case DrawTools.DrawType.Point: //绘制点
  2609. _self._sketchDrawPoint(_self._drawEventHandler, options);
  2610. break;
  2611. case DrawTools.DrawType.Polyline: //绘制贴地线
  2612. options.polylineType = DrawTools.PolylineType.NormalPolyline;
  2613. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2614. break;
  2615. case DrawTools.DrawType.ArrowPolyline: //绘制箭头线
  2616. options.polylineType = DrawTools.PolylineType.ArrowsPolyline;
  2617. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2618. break;
  2619. case DrawTools.DrawType.DynamicPolyline: //绘制流动线
  2620. options.polylineType = DrawTools.PolylineType.DynamicPolyline;
  2621. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2622. break;
  2623. case DrawTools.DrawType.GrowPolyline: //绘制发光线
  2624. options.polylineType = DrawTools.PolylineType.GrowPolyline;
  2625. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2626. break;
  2627. case DrawTools.DrawType.OutlinePolyline: //绘制描边线
  2628. options.polylineType = DrawTools.PolylineType.OutlinePolyline;
  2629. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2630. break;
  2631. case DrawTools.DrawType.Polygon: //绘制贴地面
  2632. options.polygonType = DrawTools.PolygonType.NormalPolygon;
  2633. _self._sketchDrawPolygon(_self._drawEventHandler, options);
  2634. break;
  2635. case DrawTools.DrawType.SpatialLine: //绘制空���线
  2636. _self._sketchDrawSpatialPolyline(_self._drawEventHandler, options);
  2637. break;
  2638. case DrawTools.DrawType.Circle: //绘�����贴�����圆
  2639. options.circleType = DrawTools.CircleType.ColorCircle;
  2640. _self._sketchDrawCircle(_self._drawEventHandler, options);
  2641. break;
  2642. case DrawTools.DrawType.Rectangle: //绘制矩形
  2643. _self._sketchDrawRectangle(_self._drawEventHandler, options);
  2644. break;
  2645. case DrawTools.DrawType.NormalWall: //������普通墙
  2646. options.wallType = DrawTools.WallType.ColorWall;
  2647. _self._sketchDrawWall(_self._drawEventHandler, options);
  2648. break;
  2649. case DrawTools.DrawType.DynamicWall: //绘制动态墙
  2650. options.wallType = DrawTools.WallType.DynamicWall;
  2651. _self._sketchDrawWall(_self._drawEventHandler, options);
  2652. break;
  2653. case DrawTools.DrawType.TextWall: //绘制文字墙
  2654. options.wallType = DrawTools.WallType.TextWall;
  2655. _self._sketchDrawWall(_self._drawEventHandler, options);
  2656. break;
  2657. case DrawTools.DrawType.DynamicCircle: //���制扩散圆
  2658. options.circleType = DrawTools.CircleType.DynamicCircle;
  2659. _self._sketchDrawCircle(_self._drawEventHandler, options);
  2660. break;
  2661. case DrawTools.DrawType.House: //绘制房屋
  2662. options.polygonType = DrawTools.PolygonType.HousePolygon;
  2663. _self._sketchDrawPolygon(_self._drawEventHandler, options);
  2664. break;
  2665. case DrawTools.DrawType.VideoWall:
  2666. _self._sketchDrawVideoWall(_self._drawEventHandler, options);
  2667. break;
  2668. case DrawTools.DrawType.OdLine:
  2669. _self._sketchDrawOdline(_self._drawEventHandler, options);
  2670. break;
  2671. }
  2672. },
  2673. /**
  2674. * 清理资源
  2675. */
  2676. Clear: function() {
  2677. /* 清理全部绘制内容 */
  2678. this._clear(true);
  2679. /* 结束编辑状态 */
  2680. this._unActivateEdit();
  2681. /* 关闭属性编辑框 */
  2682. this._closePropertyEditDialog();
  2683. /* 移除操作容器 */
  2684. this._removeOperationDom();
  2685. },
  2686. /**
  2687. * 初始化
  2688. */
  2689. sketchInit: function() {
  2690. this._clear(false);
  2691. },
  2692. /**
  2693. * 检测程序运行环境
  2694. * @ignore
  2695. * @return {DrawTools.RuntimeEnvironment}
  2696. */
  2697. _checkAppOrWeb() {
  2698. if (window.navigator.userAgent.match(
  2699. /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
  2700. )) {
  2701. return DrawTools.RuntimeEnvironment.App;
  2702. } else {
  2703. return DrawTools.RuntimeEnvironment.Web;
  2704. }
  2705. },
  2706. /**
  2707. * 是否是运行于App
  2708. * @ignore
  2709. */
  2710. _isRuntimeApp() {
  2711. if (this._checkAppOrWeb() === DrawTools.RuntimeEnvironment.App) {
  2712. return true;
  2713. }
  2714. return false;
  2715. }
  2716. })
  2717. /**
  2718. * 鼠标跟随标签相关
  2719. */
  2720. Object.assign(DrawTools.prototype, {
  2721. /**
  2722. * 提示标签初始化
  2723. * @ignore 生成方法时不对外公开
  2724. * @param {String} text 显示的文本内容
  2725. * @param {JSON} mousePosition 鼠标位置
  2726. */
  2727. _tooltipInit: function(text, mousePosition) {
  2728. let _self = this;
  2729. this._tooltipId = 'tooltipSketchmodel';
  2730. let tooltipObj = document.getElementById(this._tooltipId);
  2731. if (tooltipObj === null) {
  2732. tooltipObj = document.createElement('div');
  2733. tooltipObj.id = this._tooltipId;
  2734. document.body.appendChild(tooltipObj);
  2735. let divStyle = '';
  2736. divStyle += "top: 30px;";
  2737. divStyle += "left: 30px;";
  2738. divStyle += "position: absolute;";
  2739. divStyle += "display: flex;";
  2740. divStyle += "align-items: center;";
  2741. divStyle += "width: 12x0px;";
  2742. divStyle += "height: auto;";
  2743. divStyle += "background-color: rgba(0, 0, 0, 0.65);";
  2744. divStyle += "border-radius: 5px;";
  2745. divStyle += "color: rgb(255, 255, 255);";
  2746. divStyle += "font-size: 12px;";
  2747. divStyle += "font-family: 'Alimama_ShuHeiTi_Bold';";
  2748. divStyle += "padding: 8px;";
  2749. divStyle += "border:solid 1px rgb(255,0,0);";
  2750. tooltipObj.setAttribute('style', divStyle);
  2751. }
  2752. if (text != undefined) tooltipObj.innerHTML = text;
  2753. if (mousePosition === undefined) {
  2754. /* 挂接鼠标移动事件 */
  2755. document.onmousemove = function(event) {
  2756. if (event.clientX < 100 || event.clientX > _self._canvasWidth - 100 || event.clientY <
  2757. 100 ||
  2758. event.clientY > _self._canvasHeight - 100) {
  2759. tooltipObj.style.display = 'none';
  2760. } else {
  2761. tooltipObj.style.display = 'flex';
  2762. tooltipObj.style.left = (event.clientX + 10) + 'px';
  2763. tooltipObj.style.top = (event.clientY - tooltipObj.offsetHeight / 2) + 'px';
  2764. }
  2765. }
  2766. } else {
  2767. if (mousePosition.x < 100 || mousePosition.x > _self._canvasWidth - 100 || mousePosition.y <
  2768. 100 ||
  2769. mousePosition.y > _self._canvasHeight - 100) {
  2770. tooltipObj.style.display = 'none';
  2771. } else {
  2772. tooltipObj.style.display = 'flex';
  2773. tooltipObj.style.left = (mousePosition.x + 10) + 'px';
  2774. tooltipObj.style.top = (mousePosition.y - tooltipObj.offsetHeight / 2) + 'px';
  2775. }
  2776. }
  2777. },
  2778. /**
  2779. * 移除提示标签
  2780. * @ignore 生成方法时不对外公开
  2781. */
  2782. _tooltipRemove: function() {
  2783. let tooltipObj = document.getElementById(this._tooltipId);
  2784. if (tooltipObj != null) {
  2785. document.body.removeChild(tooltipObj);
  2786. }
  2787. },
  2788. /**
  2789. * 设置提示标签文本
  2790. * @ignore 生成方法时不对外公开
  2791. * @param {String} text 文本
  2792. * @param {JSON} mousePosition 鼠标位置
  2793. */
  2794. _tooltipSetText: function(text, mousePosition) {
  2795. let tooltipObj = document.getElementById(this._tooltipId);
  2796. if (tooltipObj != null) {
  2797. if (text != undefined) tooltipObj.innerHTML = text;
  2798. if (mousePosition != undefined) {
  2799. if (mousePosition.x < 100 || mousePosition.x > this._canvasWidth - 100 || mousePosition.y <
  2800. 100 ||
  2801. mousePosition.y > this._canvasHeight - 100) {
  2802. tooltipObj.style.display = 'none';
  2803. } else {
  2804. tooltipObj.style.display = 'flex';
  2805. tooltipObj.style.left = (mousePosition.x + 10) + 'px';
  2806. tooltipObj.style.top = (mousePosition.y - tooltipObj.offsetHeight / 2) + 'px';
  2807. }
  2808. }
  2809. }
  2810. },
  2811. /**
  2812. * 设置鼠标为十字样式
  2813. * @ignore 生成方法时不对外公开
  2814. */
  2815. _setMousePointerStyle: function() {
  2816. document.querySelector('body').style.cursor = 'crosshair';
  2817. },
  2818. /**
  2819. * 恢复鼠标指针为默认样式
  2820. * @ignore 生成方法时不对外公开
  2821. */
  2822. _setMouseDefaultStyle: function() {
  2823. document.querySelector('body').style.cursor = 'default';
  2824. },
  2825. /**
  2826. * 启用标签
  2827. * @ignore 不公开
  2828. * @param {String} text 标签文字
  2829. * @param {Cesium.Cartesian2} position 鼠标位置
  2830. */
  2831. _beginTooltip(text, position) {
  2832. this._tooltipInit(text, position);
  2833. this._setMousePointerStyle();
  2834. },
  2835. /**
  2836. * 更新标签标签
  2837. * @ignore 不公开
  2838. * @param {String} text 标签文字
  2839. * @param {Cesium.Cartesian2} position 鼠标位置
  2840. */
  2841. _updateTooltip(text, position) {
  2842. this._tooltipSetText(text, position);
  2843. },
  2844. /**
  2845. * 结束标签
  2846. * @ignore 不公开
  2847. */
  2848. _endTooltip() {
  2849. this._tooltipRemove();
  2850. this._setMouseDefaultStyle();
  2851. },
  2852. /**
  2853. * 创建顶部弹出提示消息 1秒后自动消失
  2854. * @param {String} message 消息内容
  2855. */
  2856. _showTooltipMessage: function(message) {
  2857. let msgMainDom = document.getElementById('messageMainDom');
  2858. if (msgMainDom !== null && msgMainDom !== undefined) {
  2859. document.body.removeChild(msgMainDom);
  2860. }
  2861. msgMainDom = document.createElement('div');
  2862. msgMainDom.style.width = '30%';
  2863. msgMainDom.style.backgroundColor = 'rgba(237, 248, 230, 1.0)';
  2864. msgMainDom.style.height = '45px';
  2865. msgMainDom.style.border = 'solid 2px rgb(219, 241, 208)';
  2866. msgMainDom.style.borderRadius = '8px';
  2867. msgMainDom.style.display = 'flex';
  2868. msgMainDom.style.alignItems = 'center';
  2869. msgMainDom.style.paddingLeft = '10px';
  2870. msgMainDom.style.color = 'rgb(91, 188, 48)';
  2871. msgMainDom.style.fontSize = '14px';
  2872. msgMainDom.style.fontWeight = '600';
  2873. msgMainDom.style.position = 'absolute';
  2874. msgMainDom.style.left = '35%';
  2875. msgMainDom.style.transition = 'transform 1s';
  2876. msgMainDom.style.transform = 'translateY(-90px)';
  2877. msgMainDom.style.top = '0px';
  2878. msgMainDom.style.zIndex = 1000;
  2879. document.body.appendChild(msgMainDom);
  2880. let strHtml = '';
  2881. strHtml += "<div style='"
  2882. strHtml += "background-color: rgb(88, 185, 45);";
  2883. strHtml += "color: rgb(255, 255, 255);";
  2884. strHtml += "height: 24px;";
  2885. strHtml += "width: 24px;";
  2886. strHtml += "border-radius: 20px;";
  2887. strHtml += "display: flex;";
  2888. strHtml += "justify-content: center;";
  2889. strHtml += "align-items: center;";
  2890. strHtml += "font-size: 14px;";
  2891. strHtml += "margin-right: 18px;";
  2892. strHtml += "'>&#10003</div>";
  2893. strHtml += "<div>" + message + "</div>";
  2894. msgMainDom.innerHTML = strHtml;
  2895. msgMainDom.addEventListener('transitionend', function() {
  2896. setTimeout(function() {
  2897. document.body.removeChild(msgMainDom);
  2898. }, 1000);
  2899. }, false);
  2900. setTimeout(function() {
  2901. msgMainDom.style.transform = 'translateY(50px)';
  2902. }, 100)
  2903. }
  2904. })
  2905. /**
  2906. * 拖拽坐标轴相关
  2907. */
  2908. Object.assign(DrawTools.prototype, {
  2909. /**
  2910. * 创建单个坐标轴
  2911. * @ignore 生成方法时不对外公开
  2912. * @param {Array<Cesium.Cartesian3>} positions 坐标集合
  2913. * @param {String} color 坐标轴颜色 rgba(r,g,b,a)
  2914. * @param {String} axisEntityId 坐标轴实体的Id
  2915. */
  2916. _createSingleCoordinateAxisArrow(positions, color, axisEntityId) {
  2917. let _self = this;
  2918. /* 创建坐标轴 */
  2919. let coordinateAxisEntity = new Cesium.Entity({
  2920. id: axisEntityId,
  2921. name: _self._coordinateAxisEntityName,
  2922. position: positions[0],
  2923. polyline: {
  2924. positions: positions,
  2925. width: 10.0,
  2926. material: _self._materialPolylineArrowProperty({
  2927. color: color,
  2928. })
  2929. }
  2930. })
  2931. /* 设置类型 */
  2932. coordinateAxisEntity.setEditType({
  2933. type: DrawTools.EditPointType.CoordinateAxis,
  2934. });
  2935. /* 渲染坐标轴 */
  2936. return this._entities.add(coordinateAxisEntity);
  2937. },
  2938. /**
  2939. * 平移目标点
  2940. * @ignore 生成方法时不对外公开
  2941. * @param {Cesium.Cartesian3} originPosition 参考点
  2942. * @param {Cesium.Cartesian3} translateCartesian 平移距离
  2943. * @return {Cesium.Cartesian3}
  2944. */
  2945. _getTranslatePostion: function(originPosition, translateCartesian) {
  2946. let transform = Cesium.Transforms.eastNorthUpToFixedFrame(originPosition); //东-北-上参考系构造出4*4的矩阵
  2947. let m = new Cesium.Matrix4();
  2948. Cesium.Matrix4.setTranslation(
  2949. Cesium.Matrix4.IDENTITY,
  2950. translateCartesian,
  2951. m
  2952. ); //构造平移矩阵
  2953. let modelMatrix = Cesium.Matrix4.multiply(transform, m, transform); //将当前位置矩阵乘以平移矩阵得到平移之后的位置矩阵
  2954. let outPosition = new Cesium.Cartesian3(0, 0, 0);
  2955. Cesium.Matrix4.getTranslation(modelMatrix, outPosition); //从位置矩阵中取出坐标信息
  2956. return outPosition;
  2957. },
  2958. /**
  2959. * 创建3个坐标轴
  2960. * @ignore 生成方法时不对外公开
  2961. * @param {Cesium.Cartesian3} position 坐标轴中心点位置
  2962. */
  2963. _createCoordinateAxis: function(position) {
  2964. this._showTooltipMessage('单击右键移除调整轴线!');
  2965. /* 创建坐标轴之前先移除已创建的坐标轴 */
  2966. this._removeCoorinateAxis();
  2967. let _self = this;
  2968. /* 获取相机在世界坐标系中的正确方向 */
  2969. let cameraRight = this._viewer.scene.camera.rightWC;
  2970. this._tx = cameraRight.x > 0 ? 150 : -150;
  2971. this._ty = cameraRight.y > 0 ? 150 : -150;
  2972. this._tz = 150;
  2973. /* 坐标轴的Id */
  2974. this._coordinateAxisEntityId_x = 'coordinateAxisId_x';
  2975. this._coordinateAxisEntityId_y = 'coordinateAxisId_y';
  2976. this._coordinateAxisEntityId_z = 'coordinateAxisId_z';
  2977. /* 坐标轴的名称 */
  2978. this._coordinateAxisEntityName = "coordinateAxisEntity";
  2979. /* 创建X轴 */
  2980. let translateCartesian = new Cesium.Cartesian3(this._tx, 0, 0); //单位为米
  2981. let endPosition = this._getTranslatePostion(position, translateCartesian);
  2982. const xPos = [position, endPosition];
  2983. this._coordinateEntity_x = this._createSingleCoordinateAxisArrow(xPos, 'rgba(0,255,0,1.0)', this
  2984. ._coordinateAxisEntityId_x);
  2985. /* 给坐标轴绑定编辑实体 */
  2986. this._coordinateAxisBindEntity(this._coordinateEntity_x);
  2987. /* 创建Y轴 */
  2988. translateCartesian = new Cesium.Cartesian3(0, this._ty, 0); //单位为
  2989. endPosition = this._getTranslatePostion(position, translateCartesian);
  2990. const yPos = [position, endPosition];
  2991. this._coordinateEntity_y = this._createSingleCoordinateAxisArrow(yPos, 'rgba(0,0,255,1.0)', this
  2992. ._coordinateAxisEntityId_y);
  2993. /* 给坐标轴绑定编辑实体 */
  2994. this._coordinateAxisBindEntity(this._coordinateEntity_y);
  2995. /* 创建Z轴 */
  2996. translateCartesian = new Cesium.Cartesian3(0, 0, this._tz); //单位为
  2997. endPosition = this._getTranslatePostion(position, translateCartesian);
  2998. const zPos = [position, endPosition];
  2999. this._coordinateEntity_z = this._createSingleCoordinateAxisArrow(zPos, 'rgba(255,0,0,1.0)', this
  3000. ._coordinateAxisEntityId_z);
  3001. /* 给坐标轴绑定编辑实体 */
  3002. this._coordinateAxisBindEntity(this._coordinateEntity_z);
  3003. /* 注册坐标轴事件 */
  3004. this._eventCoorinateAxis = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  3005. this._registerLeftDownEvent(this._eventCoorinateAxis, function(event) {
  3006. _self._coorinateAxisMouseDown(event);
  3007. });
  3008. this._registerMouseMoveEvent(this._eventCoorinateAxis, function(event) {
  3009. _self._coorinateAxisMouseMove(event);
  3010. });
  3011. this._registerLeftUpEvent(this._eventCoorinateAxis, function(event) {
  3012. _self._coorinateAxisMouseUp(event);
  3013. });
  3014. this._registerRightClickEvent(this._eventCoorinateAxis, function(event) {
  3015. _self._removeCoorinateAxis();
  3016. });
  3017. },
  3018. /**
  3019. * 给坐标轴绑定编辑的实体
  3020. * @ignore 生成方法时不对外公开
  3021. * @param {Cesium.Entity} axisEntity 轴实体
  3022. */
  3023. _coordinateAxisBindEntity: function(axisEntity) {
  3024. if (this._editEntity === undefined) return;
  3025. /* 获取当前编辑的实体类型 */
  3026. let editEntityType = this._editEntity.getEntityType();
  3027. if (editEntityType === undefined) return;
  3028. if (editEntityType === DrawTools.DrawType.VideoWall) {
  3029. axisEntity.bindEntity(this._editEntity);
  3030. }
  3031. },
  3032. /**
  3033. * 坐标轴鼠标按下事件
  3034. * @ignore 生成方法时不对外公开
  3035. * @param {Cesium.Event} event 事件
  3036. */
  3037. _coorinateAxisMouseDown: function(event) {
  3038. let _self = this;
  3039. let feature = this._viewer.scene.pick(event.position);
  3040. if (feature === undefined) return;
  3041. if (feature.id != undefined && feature.id instanceof Cesium.Entity) {
  3042. this._viewer.scene.screenSpaceCameraController.enableRotate = false;
  3043. if (feature.id.getEditType() === undefined) return;
  3044. let entityType = feature.id.getEditType().type;
  3045. if (entityType !== DrawTools.EditPointType.CoordinateAxis) return;
  3046. this._editCoorinateAxis = feature.id;
  3047. this._editCoorinateAxis.polyline.width = 15;
  3048. /* 设置坐标移动起始点 */
  3049. this._coordinateAxisMoveStartPosition = this._viewer.scene.camera.pickEllipsoid(event.position,
  3050. this._viewer.scene.globe.ellipsoid);
  3051. this._coordinateAxisMoveStartScreen = event.position;
  3052. this._coorinateAxisPosition = this._editCoorinateAxis.position._value;
  3053. /* 设置动态 */
  3054. this._coordinateEntity_x.polyline.positions = new Cesium.CallbackProperty(function() {
  3055. let translateCartesian = new Cesium.Cartesian3(_self._tx, 0, 0); //单位为米
  3056. let endPosition = _self._getTranslatePostion(_self._coorinateAxisPosition,
  3057. translateCartesian);
  3058. return [_self._coorinateAxisPosition, endPosition];
  3059. }, false);
  3060. this._coordinateEntity_y.polyline.positions = new Cesium.CallbackProperty(function() {
  3061. let translateCartesian = new Cesium.Cartesian3(0, _self._ty, 0); //单位为米
  3062. let endPosition = _self._getTranslatePostion(_self._coorinateAxisPosition,
  3063. translateCartesian);
  3064. return [_self._coorinateAxisPosition, endPosition];
  3065. }, false);
  3066. this._coordinateEntity_z.polyline.positions = new Cesium.CallbackProperty(function() {
  3067. let translateCartesian = new Cesium.Cartesian3(0, 0, _self._tz); //单位为米
  3068. let endPosition = _self._getTranslatePostion(_self._coorinateAxisPosition,
  3069. translateCartesian);
  3070. return [_self._coorinateAxisPosition, endPosition];
  3071. }, false);
  3072. /* 激活平移实体 */
  3073. this._coordinateAxisActivateEditEntity(this._editCoorinateAxis);
  3074. }
  3075. },
  3076. /**
  3077. * 坐标轴鼠标移动事件
  3078. * @ignore 生成方法时不对外公开
  3079. * @param {Cesium.Event} event 事件
  3080. */
  3081. _coorinateAxisMouseMove: function(event) {
  3082. if (!Cesium.defined(this._editCoorinateAxis)) return;
  3083. let position = this._viewer.scene.camera.pickEllipsoid(event.endPosition,
  3084. this._viewer.scene.globe.ellipsoid);
  3085. if (!position) return;
  3086. let strGeo = this._cartesian3ToGeo(this._coordinateAxisMoveStartPosition);
  3087. let endGeo = this._cartesian3ToGeo(position);
  3088. let entityId = this._editCoorinateAxis.id;
  3089. let entityPosition = this._editCoorinateAxis.position._value;
  3090. let entityGeo = this._cartesian3ToGeo(entityPosition);
  3091. let heightDifference = 0;
  3092. if (entityId === this._coordinateAxisEntityId_x) {
  3093. let difference = strGeo.longitude - endGeo.longitude;
  3094. entityGeo.longitude = entityGeo.longitude - difference;
  3095. } else if (entityId === this._coordinateAxisEntityId_y) {
  3096. let difference = strGeo.latitude - endGeo.latitude;
  3097. entityGeo.latitude = entityGeo.latitude - difference;
  3098. } else if (entityId === this._coordinateAxisEntityId_z) {
  3099. heightDifference = event.endPosition.y - this._coordinateAxisMoveStartScreen.y;
  3100. heightDifference = heightDifference * 0.5;
  3101. entityGeo.height = entityGeo.height - heightDifference;
  3102. }
  3103. this._coorinateAxisPosition = Cesium.Cartesian3.fromDegrees(entityGeo.longitude, entityGeo
  3104. .latitude, entityGeo.height);
  3105. this._moveEditEntityByCoordinateAxis(entityPosition, this._coorinateAxisPosition, heightDifference);
  3106. },
  3107. /**
  3108. * 坐标轴鼠标抬起事件
  3109. * @ignore 生成方法时不对外公开
  3110. * @param {Cesium.Event} event 事件
  3111. */
  3112. _coorinateAxisMouseUp: function(event) {
  3113. this._viewer.scene.screenSpaceCameraController.enableRotate = true;
  3114. if (this._editCoorinateAxis !== undefined) {
  3115. this._editCoorinateAxis.polyline.width = 10;
  3116. /* 确定最终位置 */
  3117. let translateCartesian = new Cesium.Cartesian3(this._tx, 0, 0); //单位为米
  3118. let endPosition = this._getTranslatePostion(this._coorinateAxisPosition, translateCartesian);
  3119. this._coordinateEntity_x.polyline.positions = [this._coorinateAxisPosition, endPosition];
  3120. translateCartesian = new Cesium.Cartesian3(0, this._ty, 0); //单位为米
  3121. endPosition = this._getTranslatePostion(this._coorinateAxisPosition, translateCartesian);
  3122. this._coordinateEntity_y.polyline.positions = [this._coorinateAxisPosition, endPosition]
  3123. translateCartesian = new Cesium.Cartesian3(0, 0, this._tz); //单位为米
  3124. endPosition = this._getTranslatePostion(this._coorinateAxisPosition, translateCartesian);
  3125. this._coordinateEntity_z.polyline.positions = [this._coorinateAxisPosition, endPosition];
  3126. this._coordinateEntity_x.position = this._coorinateAxisPosition;
  3127. this._coordinateEntity_y.position = this._coorinateAxisPosition;
  3128. this._coordinateEntity_z.position = this._coorinateAxisPosition;
  3129. /* 结束并更新坐标轴绑定的实体 */
  3130. this._coordinateAxisUpdateEditEntity(this._editCoorinateAxis);
  3131. this._editCoorinateAxis = undefined;
  3132. }
  3133. },
  3134. /**
  3135. * 通过移动坐标轴移动编辑实体
  3136. * @ignore 生成方法时不对外公开
  3137. * @param {Cesium.Cartesian3} strPosition 起始位置
  3138. * @param {Cesium.Cartesian3} endPosition 终止位置
  3139. * @param {Number} heightDifference 高度差
  3140. */
  3141. _moveEditEntityByCoordinateAxis: function(strPosition, endPosition, heightDifference) {
  3142. /* 计算平移距离 */
  3143. let movePosition = Cesium.Cartesian3.subtract(endPosition, strPosition, new Cesium.Cartesian3());
  3144. for (let i = 0; i < this._moveInitPositions.length; i++) {
  3145. let moveResult = Cesium.Cartesian3.add(this._moveInitPositions[i], movePosition, new Cesium
  3146. .Cartesian3());
  3147. this._moveUpdatePositions[i] = moveResult.clone();
  3148. }
  3149. for (let i = 0; i < this._moveInitHeights.length; i++) {
  3150. this._moveUpdateHeights[i] = parseFloat(this._moveInitHeights[i]) + heightDifference * (-1);
  3151. }
  3152. },
  3153. /**
  3154. * 激活当前拖拽的坐标轴关联的实体
  3155. * @ignore 生成方法时不对外公开
  3156. * @param {Cesium.Entity} moveAxisEntity 当前拖拽的坐标轴
  3157. */
  3158. _coordinateAxisActivateEditEntity: function(moveAxisEntity) {
  3159. let _self = this;
  3160. /* 获取坐标轴绑定的实体 */
  3161. let bindEntity = moveAxisEntity.getBindEntity();
  3162. if (bindEntity === undefined) return;
  3163. let bindEntityType = bindEntity.getEntityType();
  3164. if (bindEntityType === DrawTools.DrawType.VideoWall) {
  3165. /* 初始数据集合 */
  3166. let wall = bindEntity.wall;
  3167. this._moveInitPositions = wall.positions._value;
  3168. this._moveInitHeights = wall.minimumHeights._value;
  3169. this._moveInitHeight = wall.maximumHeights._value[0] - wall.minimumHeights._value[0];
  3170. /* 平面移动数据点 */
  3171. this._moveUpdatePositions = [];
  3172. for (let i = 0; i < this._moveInitPositions.length; i++) {
  3173. this._moveUpdatePositions.push(this._moveInitPositions[i].clone());
  3174. }
  3175. /* 设置属性回调变更 */
  3176. wall.positions = new Cesium.CallbackProperty(function() {
  3177. return _self._moveUpdatePositions;
  3178. }, false);
  3179. /* 高度移动点 */
  3180. this._moveUpdateHeights = [];
  3181. for (let i = 0; i < this._moveInitHeights.length; i++) {
  3182. this._moveUpdateHeights.push(this._moveInitHeights[i]);
  3183. }
  3184. /* 设置属性回调变更 */
  3185. wall.minimumHeights = new Cesium.CallbackProperty(function() {
  3186. return _self._moveUpdateHeights;
  3187. }, false);
  3188. wall.maximumHeights = new Cesium.CallbackProperty(function() {
  3189. let maxHeights = [];
  3190. for (let i = 0; i < _self._moveUpdateHeights.length; i++) {
  3191. maxHeights.push(parseFloat(_self._moveUpdateHeights[i]) + _self
  3192. ._moveInitHeight);
  3193. }
  3194. return maxHeights;
  3195. }, false);
  3196. }
  3197. },
  3198. /**
  3199. * 更新当前坐标轴绑定的实体
  3200. * @ignore 生成方法时不对外公开
  3201. * @param {Cesium.Entity} moveAxisEntity 当前拖拽的坐标轴
  3202. */
  3203. _coordinateAxisUpdateEditEntity: function(moveAxisEntity) {
  3204. /* 获取坐标轴绑定的实体 */
  3205. let bindEntity = moveAxisEntity.getBindEntity();
  3206. if (bindEntity === undefined) return;
  3207. let bindEntityType = bindEntity.getEntityType();
  3208. if (bindEntityType === DrawTools.DrawType.VideoWall) {
  3209. /* 初始数据机 */
  3210. let wall = bindEntity.wall;
  3211. /* 更新属性 */
  3212. wall.positions = this._moveUpdatePositions;
  3213. wall.minimumHeights = this._moveUpdateHeights;
  3214. let maxHeights = [];
  3215. for (let i = 0; i < this._moveUpdateHeights.length; i++) {
  3216. maxHeights.push(parseFloat(this._moveUpdateHeights[i]) + this._moveInitHeight);
  3217. }
  3218. wall.maximumHeights = maxHeights;
  3219. }
  3220. },
  3221. /**
  3222. * 计算实体转换后的方向
  3223. * @ignore 生成方法时不对外公开
  3224. * @param {Cesium.Entity} entity 实体
  3225. * @param {JSON} options 配置项
  3226. * @param {Number} options.x 绕X轴旋转 度
  3227. * @param {Number} options.y 绕Y轴旋转 度
  3228. * @param {Number} options.z 绕Z轴旋转 度
  3229. */
  3230. _coordinateCalculateEntityOrientation: function(entity, options) {
  3231. /* 获取实体的位置 */
  3232. let position = entity.position._value;
  3233. /* 获取实体的朝向 */
  3234. let orientation = entity.orientation === undefined ? new Cesium.Cartesian3(0, 0, 0) : entity
  3235. .orientation._value;
  3236. /* 根据方向、朝向和缩放计算4*4矩阵 */
  3237. let transform = Cesium.Matrix4.fromTranslationQuaternionRotationScale(position, orientation,
  3238. new Cesium.Cartesian3(1, 1, 1), new Cesium.Matrix4());
  3239. /* 计算3个轴的3*3旋转矩阵 */
  3240. let _rotateX = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.x));
  3241. let _rotateY = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.y));
  3242. let _rotateZ = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.z));
  3243. /* 计算4*4旋转矩阵 */
  3244. transform = Cesium.Matrix4.multiplyByMatrix3(transform, _rotateX, transform);
  3245. transform = Cesium.Matrix4.multiplyByMatrix3(transform, _rotateY, transform);
  3246. transform = Cesium.Matrix4.multiplyByMatrix3(transform, _rotateZ, transform);
  3247. /* 4*4旋转矩阵转换为3*3旋转矩阵 */
  3248. let m3 = Cesium.Matrix4.getRotation(transform, new Cesium.Matrix3());
  3249. /* 转换旋转矩阵转换为齐次坐标 */
  3250. let resOrientation = new Cesium.Quaternion();
  3251. Cesium.Quaternion.fromRotationMatrix(m3, resOrientation);
  3252. return resOrientation;
  3253. },
  3254. /**
  3255. * 移除坐标轴
  3256. * @ignore 生成方法时不对外公开
  3257. */
  3258. _removeCoorinateAxis: function() {
  3259. if (this._coordinateAxisEntityName !== undefined) {
  3260. this._removeEntityByName(this._coordinateAxisEntityName);
  3261. }
  3262. if (this._eventCoorinateAxis !== undefined) {
  3263. this._clearEvent(this._eventCoorinateAxis);
  3264. this._eventCoorinateAxis = undefined;
  3265. }
  3266. }
  3267. });
  3268. /**
  3269. * 实体编辑相关方法
  3270. */
  3271. Object.assign(DrawTools.prototype, {
  3272. /**
  3273. * 设置实体可编辑,编辑的实体必须包含编辑类型
  3274. * @ignore 生成方法时不对外公开
  3275. * @param {Cesium.Entity} entity 编辑的实体
  3276. */
  3277. _setEntityIsEdit(entity) {
  3278. let _self = this;
  3279. /* 设置实体要素可编辑 */
  3280. entity.setIsEdit(true);
  3281. /* 先撤销编辑 */
  3282. this._unActivateEdit();
  3283. /* 激活编辑 并显示属性编辑框 */
  3284. this._sendShowPropertyDialog(entity);
  3285. /* 注册统一事件 用于单击拾取实体 */
  3286. let handler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  3287. this._registerLeftClickEvent(handler, function(event) {
  3288. /* 只要点击 就清除选中状态 */
  3289. _self._unActivateEdit();
  3290. let feature = _self._viewer.scene.pick(event.position);
  3291. if (feature !== undefined && feature.id instanceof Cesium.Entity) {
  3292. let featureType = feature.id.getEditType();
  3293. let entityType = feature.id.getEntityType();
  3294. if (featureType === DrawTools.EditPointType.Node ||
  3295. featureType === DrawTools.EditPointType.Middle ||
  3296. featureType === DrawTools.EditPointType.Center ||
  3297. featureType === DrawTools.EditPointType.CoordinateAxis ||
  3298. featureType === DrawTools.EditPointType.OdlineStrartNode ||
  3299. featureType === DrawTools.EditPointType.OdlineEndNode ||
  3300. entityType === DrawTools.DrawType.Polyline ||
  3301. entityType === DrawTools.DrawType.ArrowPolyline ||
  3302. entityType === DrawTools.DrawType.DynamicPolyline ||
  3303. entityType === DrawTools.DrawType.GrowPolyline ||
  3304. entityType === DrawTools.DrawType.OutlinePolyline ||
  3305. entityType === DrawTools.DrawType.OdLine ||
  3306. entityType === DrawTools.DrawType.Polygon ||
  3307. entityType === DrawTools.DrawType.SpatialLine ||
  3308. entityType === DrawTools.DrawType.Circle ||
  3309. entityType === DrawTools.DrawType.DynamicCircle ||
  3310. entityType === DrawTools.DrawType.Rectangle ||
  3311. entityType === DrawTools.DrawType.NormalWall ||
  3312. entityType === DrawTools.DrawType.DynamicWall ||
  3313. entityType === DrawTools.DrawType.House ||
  3314. entityType === DrawTools.DrawType.TextWall ||
  3315. entityType === DrawTools.DrawType.VideoWall
  3316. ) {
  3317. _self._sendShowPropertyDialog(feature.id);
  3318. }
  3319. }
  3320. })
  3321. },
  3322. /**
  3323. * 打开实体编辑对话框
  3324. * @ignore 生成方法时不对外公开
  3325. * @param {Cesium.Entity} entity
  3326. */
  3327. _sendShowPropertyDialog(entity) {
  3328. let _self = this;
  3329. /* 获取可编辑实体的类型 */
  3330. let editEntityType = entity.getEntityType();
  3331. if (entity.getIsEdit() === undefined || entity.getIsEdit() === false ||
  3332. editEntityType === undefined) {
  3333. /* 选择的实体不可编辑 */
  3334. this._unActivateEdit();
  3335. return;
  3336. }
  3337. /* 编辑属性 */
  3338. let editProperty = entity.getParams();
  3339. if (editEntityType === DrawTools.DrawType.OdLine) {
  3340. editProperty = entity.parent.getParams();
  3341. }
  3342. this._console('选择实体的属性', editProperty);
  3343. if (editProperty !== undefined && this.onEditProperty !== undefined) {
  3344. /* 改进后不在对外提供监听事件 改为内部流转 */
  3345. // this.onEditProperty(editProperty);
  3346. /* 更改测试 */
  3347. this._openPropertyEditDialog(editProperty, function(params) {
  3348. _self.updateEditEntityProperty(params);
  3349. }, function() {
  3350. _self._removeEditEntity();
  3351. });
  3352. }
  3353. this._activateEdit(entity);
  3354. },
  3355. /**
  3356. * 删除当前编辑实体
  3357. */
  3358. _removeEditEntity() {
  3359. if (this._editEntity !== undefined) {
  3360. this._console('移除实体', this._editEntity);
  3361. let entityType = this._editEntity.getEntityType();
  3362. if (entityType === DrawTools.DrawType.OdLine) {
  3363. let fatherEntityId = this._editEntity.parent.id;
  3364. let removeEntitys = [];
  3365. for (let entity of this._entities.values) {
  3366. if (entity.parent !== undefined && entity.parent.id === fatherEntityId) {
  3367. removeEntitys.push(entity);
  3368. }
  3369. }
  3370. for (let removeEntity of removeEntitys) {
  3371. this._removeEntityByObject(removeEntity);
  3372. }
  3373. } else {
  3374. this._removeEntityByObject(this._editEntity);
  3375. }
  3376. this._unActivateEdit();
  3377. this._editEntity = undefined;
  3378. }
  3379. },
  3380. /**
  3381. * 更新当前编辑的实体属性
  3382. * @param {JSON} params
  3383. */
  3384. updateEditEntityProperty: function(params) {
  3385. let _self = this;
  3386. if (this._editEntity === undefined) return;
  3387. if (this._editEntity.getIsEdit() === undefined || this._editEntity.getIsEdit() === false) return;
  3388. let editEntityType = this._editEntity.getEntityType();
  3389. if (editEntityType === undefined) return;
  3390. if (editEntityType === DrawTools.DrawType.NormalWall || editEntityType === DrawTools.DrawType
  3391. .DynamicWall || editEntityType === DrawTools.DrawType.TextWall) {
  3392. this._updateWallProperty(params);
  3393. } else if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools.DrawType
  3394. .DynamicCircle) {
  3395. this._updateCircleProperty(params);
  3396. } else if (editEntityType === DrawTools.DrawType.House) {
  3397. this._updateHouseProperty(params);
  3398. } else if (editEntityType === DrawTools.DrawType.VideoWall) {
  3399. this._updateVideoWallProperty(params);
  3400. } else if (editEntityType === DrawTools.DrawType.Polyline) {
  3401. this._updatePolylineProperty(params);
  3402. } else if (editEntityType === DrawTools.DrawType.Polygon) {
  3403. this._updatePolygonProperty(params);
  3404. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  3405. this._updateRectangleProperty(params);
  3406. } else if (editEntityType === DrawTools.DrawType.SpatialLine) {
  3407. this._updateSpatialPolylineProperty(params);
  3408. } else if (editEntityType === DrawTools.DrawType.OdLine) {
  3409. this._updateOdlineProperty(params);
  3410. }
  3411. },
  3412. /**
  3413. * 更新OD线属性
  3414. * @ignore 不公开方法
  3415. * @param {Object} params
  3416. */
  3417. _updateOdlineProperty(params) {
  3418. let _self = this;
  3419. /* 获取父实体Id */
  3420. let fatherEntity = this._editEntity.parent;
  3421. /* 当前编辑OD线集合 */
  3422. this._editOdlineEntities = [];
  3423. /* 循环集合寻找符合条件的实体 */
  3424. for (let entity of this._entities.values) {
  3425. if (entity.parent !== undefined && entity.parent.id === fatherEntity.id) {
  3426. this._editOdlineEntities.push(entity);
  3427. }
  3428. }
  3429. let meterialImage = this._image_arrow_reverse;
  3430. if (params.order === this._param.order_add) {
  3431. meterialImage = this._image_arrow_reverse;
  3432. } else if (params.order === this._param.order_minus) {
  3433. meterialImage = this._image_arrow_forward;
  3434. }
  3435. /* 创建OD线材质 */
  3436. let odLineMaterial = new WallMaterialProperty({
  3437. viewer: _self._viewer,
  3438. trailImage: meterialImage,
  3439. duration: params.duration,
  3440. color: Cesium.Color.fromCssColorString(params.color),
  3441. param: {
  3442. direction: params.direction,
  3443. count: params.count,
  3444. order: params.order,
  3445. },
  3446. });
  3447. /* 循环处理需要编辑的实体 */
  3448. for (let entity of this._editOdlineEntities) {
  3449. entity.polyline.material = odLineMaterial;
  3450. /* 获取OD线的位置 */
  3451. let positions = entity.polyline.positions._value;
  3452. let strPoint = positions.first();
  3453. let endPoint = positions.last();
  3454. let newPositios = this._calculateOdlinePositios(strPoint, endPoint, parseInt(params.odlineHeight),
  3455. parseInt(params.odlineCount));
  3456. /* 设置OD线新位置 */
  3457. entity.polyline.positions = newPositios;
  3458. entity.polyline.width = parseInt(params.lineWidth);
  3459. }
  3460. /* 重置材质 */
  3461. fatherEntity.setParams(params);
  3462. },
  3463. /**
  3464. * 更新空间线属性
  3465. * @ignore 不公开方法
  3466. * @param {Object} params
  3467. */
  3468. _updateSpatialPolylineProperty(params) {
  3469. let material = this._editEntity.polyline.material;
  3470. let newMaterial = undefined;
  3471. if (material instanceof Cesium.ColorMaterialProperty) {
  3472. newMaterial = this._materialColorProperty({
  3473. color: params.color,
  3474. });
  3475. }
  3476. /* 设置材质 */
  3477. if (newMaterial !== undefined) this._editEntity.polyline.material = newMaterial;
  3478. this._editEntity.polyline.width = parseFloat(params.lineWidth);
  3479. /* 重新关联墙实体的属性 */
  3480. this._editEntity.setParams(params);
  3481. },
  3482. /**
  3483. * 更新矩形属性
  3484. * @ignore 不公开方法
  3485. * @param {Object} params
  3486. */
  3487. _updateRectangleProperty(params) {
  3488. let material = this._editEntity.rectangle.material;
  3489. if (material instanceof Cesium.ColorMaterialProperty) {
  3490. let newMaterial = this._materialColorProperty({
  3491. color: params.color,
  3492. });
  3493. this._editEntity.rectangle.material = newMaterial;
  3494. }
  3495. if (this._editEntity.polyline !== undefined) {
  3496. let newMaterial = this._materialColorProperty({
  3497. color: params.outlineColor,
  3498. });
  3499. this._editEntity.polyline.material = newMaterial;
  3500. this._editEntity.polyline.width = parseFloat(params.outlineWidth);
  3501. }
  3502. /* 重新关联墙实体的属性 */
  3503. this._editEntity.setParams(params);
  3504. },
  3505. /**
  3506. * 更新面的属性
  3507. * @ignore 不公开方法
  3508. * @param {Object} params
  3509. */
  3510. _updatePolygonProperty(params) {
  3511. let material = this._editEntity.polygon.material;
  3512. if (material instanceof Cesium.ColorMaterialProperty) {
  3513. let newMaterial = this._materialColorProperty({
  3514. color: params.color,
  3515. });
  3516. this._editEntity.polygon.material = newMaterial;
  3517. }
  3518. if (this._editEntity.polyline !== undefined) {
  3519. let newMaterial = this._materialColorProperty({
  3520. color: params.outlineColor,
  3521. });
  3522. this._editEntity.polyline.material = newMaterial;
  3523. this._editEntity.polyline.width = parseFloat(params.outlineWidth);
  3524. }
  3525. /* 重新关联墙实体的属性 */
  3526. this._editEntity.setParams(params);
  3527. },
  3528. /**
  3529. * 更新线的属性
  3530. * @ignore 不公开方法
  3531. * @param {Object} params
  3532. */
  3533. _updatePolylineProperty(params) {
  3534. let material = this._editEntity.polyline.material;
  3535. let newMaterial = undefined;
  3536. if (material instanceof Cesium.ColorMaterialProperty) {
  3537. newMaterial = this._materialColorProperty({
  3538. color: params.color,
  3539. });
  3540. } else if (material instanceof Cesium.PolylineArrowMaterialProperty) {
  3541. newMaterial = this._materialPolylineArrowProperty({
  3542. color: params.color,
  3543. });
  3544. } else if (material instanceof WallMaterialProperty) {
  3545. /* 设置方向对应图片 */
  3546. let materialImage = this._image_h_l_r;
  3547. if (params.order === this._param.order_minus) {
  3548. materialImage = this._image_h_r_l;
  3549. } else if (params.order === this._param.order_add) {
  3550. materialImage = this._image_h_l_r;
  3551. }
  3552. newMaterial = new WallMaterialProperty({
  3553. viewer: this._viewer,
  3554. trailImage: materialImage,
  3555. duration: params.duration,
  3556. color: Cesium.Color.fromCssColorString(params.color),
  3557. param: {
  3558. count: parseInt(params.count),
  3559. direction: params.direction,
  3560. order: params.order,
  3561. }
  3562. });
  3563. } else if (material instanceof Cesium.PolylineGlowMaterialProperty) {
  3564. newMaterial = this._materialPolylineGlowProperty({
  3565. color: params.color,
  3566. power: parseFloat(params.power),
  3567. })
  3568. } else if (material instanceof Cesium.PolylineOutlineMaterialProperty) {
  3569. newMaterial = this._materialPolylineOutlineProperty({
  3570. color: params.color,
  3571. outlineWidth: parseFloat(params.outlineWidth),
  3572. outlineColor: params.outlineColor,
  3573. })
  3574. }
  3575. /* 设置材质 */
  3576. if (newMaterial !== undefined) this._editEntity.polyline.material = newMaterial;
  3577. this._editEntity.polyline.width = params.lineWidth;
  3578. /* 重新关联墙实体的属性 */
  3579. this._editEntity.setParams(params);
  3580. },
  3581. /**
  3582. * 更新房屋属性
  3583. * @ignore 不公开方法
  3584. * @param {Object} params
  3585. */
  3586. _updateHouseProperty(params) {
  3587. let entityParams = this._editEntity.getParams();
  3588. let polygonMaterial = this._editEntity.polygon.material;
  3589. if (polygonMaterial instanceof Cesium.ColorMaterialProperty) {
  3590. let material = this._materialColorProperty({
  3591. color: params.color,
  3592. });
  3593. /* 设置材质 */
  3594. this._editEntity.polygon.material = material;
  3595. /* 设置高度 */
  3596. this._editEntity.polygon.extrudedHeight = parseFloat(params.height) + parseFloat(
  3597. entityParams.bottomHeight);
  3598. /* 重新关联墙实体的属性 */
  3599. this._editEntity.setParams(params);
  3600. }
  3601. },
  3602. /**
  3603. * 更新圆的属性
  3604. * @ignore 不公开方法
  3605. * @param {Object} params
  3606. */
  3607. _updateCircleProperty(params) {
  3608. let circleMaterial = this._editEntity.ellipse.material;
  3609. if (circleMaterial instanceof CircleMaterialProperty) {
  3610. let material = new CircleMaterialProperty({
  3611. viewer: this._viewer,
  3612. duration: params.duration,
  3613. color: Cesium.Color.fromCssColorString(params.color),
  3614. count: parseFloat(params.count),
  3615. });
  3616. this._editEntity.ellipse.material = material;
  3617. } else if (circleMaterial instanceof Cesium.ColorMaterialProperty) {
  3618. let material = this._materialColorProperty({
  3619. color: params.color,
  3620. });
  3621. this._editEntity.ellipse.material = material;
  3622. if (this._editEntity.polyline !== undefined) {
  3623. let newMaterial = this._materialColorProperty({
  3624. color: params.outlineColor,
  3625. });
  3626. this._editEntity.polyline.material = newMaterial;
  3627. this._editEntity.polyline.width = parseFloat(params.outlineWidth);
  3628. }
  3629. }
  3630. /* 重新关联墙实体的属性 */
  3631. this._editEntity.setParams(params);
  3632. },
  3633. /**
  3634. * 更新视频墙的属性
  3635. * @ignore 不公开方法
  3636. * @param {Object} params
  3637. */
  3638. _updateVideoWallProperty(params) {
  3639. /* 查找视频画布 */
  3640. let videoElement = document.getElementById('wallVideo');
  3641. if (videoElement !== null) {
  3642. document.body.removeChild(videoElement);
  3643. }
  3644. videoElement = document.createElement("video");
  3645. videoElement.id = 'wallVideo';
  3646. videoElement.setAttribute('crossorigin', 'anonymous'); //必须设置 为了防止跨域调用网络视频导致播放失败
  3647. videoElement.setAttribute("width", "1024px");
  3648. videoElement.setAttribute("height", "256px");
  3649. videoElement.setAttribute("controls", "controls");
  3650. videoElement.setAttribute("src", params.videoUrl);
  3651. videoElement.setAttribute("loop", "loop");
  3652. videoElement.play();
  3653. document.body.appendChild(videoElement);
  3654. /* 更新数据 */
  3655. let minimumHeights = this._editEntity.wall.minimumHeights._value;
  3656. /* 更新最大高度 */
  3657. let maximumHeights = [];
  3658. for (let i = 0; i < minimumHeights.length; i++) {
  3659. maximumHeights.push(minimumHeights[i] + parseFloat(params.height));
  3660. }
  3661. this._editEntity.wall.maximumHeights = maximumHeights;
  3662. this._editEntity.wall.material = videoElement;
  3663. /* 更新平移位置 */
  3664. let wallPositions = this._editEntity.wall.positions._value;
  3665. let newPositions = [];
  3666. for (let wallPosition of wallPositions) {
  3667. /* 获取当前位置的东北上坐标系 */
  3668. let transform = Cesium.Transforms.eastNorthUpToFixedFrame(wallPosition);
  3669. /* 构建平移矩阵 */
  3670. let m = new Cesium.Matrix4();
  3671. Cesium.Matrix4.setTranslation(Cesium.Matrix4.IDENTITY, new Cesium.Cartesian3(parseFloat(params.axisX),
  3672. parseFloat(params.axisY), parseFloat(params.axisZ)), m);
  3673. /* 矩阵相乘 */
  3674. let moveMatrix = Cesium.Matrix4.multiply(transform, m, transform);
  3675. /* 提取位置 */
  3676. let newPosition = new Cesium.Cartesian3();
  3677. Cesium.Matrix4.getTranslation(moveMatrix, newPosition);
  3678. newPositions.push(newPosition);
  3679. }
  3680. this._editEntity.wall.positions = newPositions;
  3681. /* 将平移距离设置为0 */
  3682. params.axisX = params.axisY = params.axisZ = 0
  3683. /* 重新关联墙实体的属性 */
  3684. this._editEntity.setParams(params);
  3685. /* 重置调整坐标轴 已保证坐标轴的位置正确+ */
  3686. this._activateEdit(this._editEntity);
  3687. },
  3688. /**
  3689. * 更新墙的属性
  3690. * @ignore 不公开方法
  3691. * @param {Object} params
  3692. */
  3693. _updateWallProperty(params) {
  3694. let minHeights = this._editEntity.wall.minimumHeights._value;
  3695. let maxHeights = [];
  3696. for (let i = 0; i < minHeights.length; i++) {
  3697. maxHeights.push(minHeights[i] + parseFloat(params.height));
  3698. }
  3699. /* 设置墙的最大高度 */
  3700. this._editEntity.wall.maximumHeights = maxHeights;
  3701. /* 更改存储墙的最大高度的数组 */
  3702. this._sketchWallMaxHeights = maxHeights;
  3703. /* 根据传入的参数id判断需什么材质 */
  3704. let wallMaterial = this._editEntity.wall.material;
  3705. if (wallMaterial instanceof Cesium.ImageMaterialProperty) {
  3706. let material = this._materialTextImageProperty({
  3707. color: params.color,
  3708. text: params.text,
  3709. });
  3710. this._editEntity.wall.material = material;
  3711. } else if (wallMaterial instanceof WallMaterialProperty) {
  3712. /* 判断使用的照片 */
  3713. let materialImage = this._image_h_l_r;
  3714. if (params.direction === this._param.direction_h && params.order === this._param.order_add) {
  3715. materialImage = this._image_h_l_r;
  3716. } else if (params.direction === this._param.direction_h && params.order === this._param.order_add) {
  3717. materialImage = this._image_h_r_l;
  3718. } else if (params.direction === this._param.direction_v && params.order === this._param
  3719. .order_minus) {
  3720. materialImage = this._image_v_t_b;
  3721. } else if (params.direction === this._param.direction_v && params.order === this._param.order_add) {
  3722. materialImage = this._image_v_b_t;
  3723. }
  3724. let material = new WallMaterialProperty({
  3725. viewer: this._viewer,
  3726. trailImage: materialImage,
  3727. duration: params.duration,
  3728. color: Cesium.Color.fromCssColorString(params.color),
  3729. param: {
  3730. count: parseFloat(params.count),
  3731. direction: params.direction,
  3732. order: params.order
  3733. }
  3734. });
  3735. this._editEntity.wall.material = material;
  3736. } else if (wallMaterial instanceof Cesium.ColorMaterialProperty) {
  3737. let material = this._materialColorProperty({
  3738. color: params.color,
  3739. });
  3740. this._editEntity.wall.material = material;
  3741. }
  3742. /* 重新关联墙实体的属性 */
  3743. this._editEntity.setParams(params);
  3744. },
  3745. /**
  3746. * 旋转实体
  3747. * @ignore
  3748. * @param {JSON} options 配置项
  3749. * @param {Number} options.x 绕X轴旋转 度
  3750. * @param {Number} options.y 绕Y轴旋转 度
  3751. * @param {Number} options.z 绕Z轴旋转 度
  3752. */
  3753. rotationEntity(options) {
  3754. if (this._editEntity === undefined) return;
  3755. let orientation = this._coordinateCalculateEntityOrientation(this._editEntity, options);
  3756. },
  3757. /**
  3758. * 获取实体可编辑数据
  3759. * @ignore 生成方法时不对外公开
  3760. * @param {Cesium.Entity} entity 实体
  3761. * @return {Array<Cesium.Cartesian3>} positions
  3762. */
  3763. _getEntityEditData: function(entity) {
  3764. if (entity instanceof Cesium.Entity) {
  3765. /* 获取实体的类型 */
  3766. let editEntityType = entity.getEntityType();
  3767. if (editEntityType === DrawTools.DrawType.Polyline || editEntityType === DrawTools.DrawType
  3768. .SpatialLine) {
  3769. return entity.polyline.positions._value;
  3770. } else if (editEntityType === DrawTools.DrawType.Polygon || editEntityType === DrawTools
  3771. .DrawType.House) {
  3772. let positions = entity.polygon.hierarchy._value.positions;
  3773. /* 判断是否需要加上终点 */
  3774. if (positions[0].x !== positions[positions.length - 1].x) {
  3775. positions.push(positions[0].clone());
  3776. }
  3777. return positions;
  3778. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  3779. let rect = entity.rectangle.coordinates._value;
  3780. /* 计算西北角的位置 */
  3781. let gNw = Cesium.Rectangle.northwest(rect);
  3782. if (gNw.height <= 0) {
  3783. let height = this._queryHeightFromGeo(Cesium.Math.toDegrees(gNw.longitude), Cesium.Math
  3784. .toDegrees(gNw.latitude));
  3785. gNw.height = height;
  3786. }
  3787. let cNw = Cesium.Cartesian3.fromRadians(gNw.longitude, gNw.latitude, gNw.height);
  3788. /* 计算东南角位置 */
  3789. let gSe = Cesium.Rectangle.southeast(rect);
  3790. if (gSe.height <= 0) {
  3791. let height = this._queryHeightFromGeo(Cesium.Math.toDegrees(gSe.longitude), Cesium.Math
  3792. .toDegrees(gSe.latitude));
  3793. gSe.height = height;
  3794. }
  3795. let cSe = Cesium.Cartesian3.fromRadians(gSe.longitude, gSe.latitude, gSe.height);
  3796. /* 组合坐标数组 */
  3797. return [cNw, cSe];
  3798. } else if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools.DrawType
  3799. .DynamicCircle) {
  3800. /* 圆中心点位置 */
  3801. let centerPosition = entity.position._value;
  3802. /* 获取圆的半径 */
  3803. let radius = entity.ellipse.semiMajorAxis._value;
  3804. let cbPoint = this._calculateCircleBoundaryPoint(centerPosition, radius);
  3805. return [centerPosition, cbPoint];
  3806. } else if (editEntityType === DrawTools.DrawType.NormalWall || editEntityType === DrawTools
  3807. .DrawType.DynamicWall || editEntityType === DrawTools.DrawType.TextWall) {
  3808. /* 存储墙的最大高度和最小高度数组 */
  3809. this._sketchWallHeights = [];
  3810. this._sketchWallMaxHeights = [];
  3811. let minHeights = entity.wall.minimumHeights._value;
  3812. let maxHeights = entity.wall.maximumHeights._value;
  3813. for (let i = 0; i < minHeights.length; i++) {
  3814. this._sketchWallHeights.push(minHeights[i]);
  3815. this._sketchWallMaxHeights.push(maxHeights[i]);
  3816. }
  3817. return entity.wall.positions._value;
  3818. } else if (editEntityType === DrawTools.DrawType.VideoWall) {
  3819. let positions = entity.wall.positions._value;
  3820. return [positions[0].clone()];
  3821. } else {
  3822. return [];
  3823. }
  3824. } else {
  3825. return [];
  3826. }
  3827. },
  3828. /**
  3829. * 根据圆的中心点和半径计算边界点坐标位置
  3830. * @ignore 生成方法时不对外公开
  3831. * @param {Cesium.Cartesian3} centerPosition 圆的中心点位置
  3832. * @param {Number} radius 半径
  3833. * @return {Cesium.Cartesian3} boundaryPosition 边界点位置
  3834. */
  3835. _calculateCircleBoundaryPoint: function(centerPosition, radius) {
  3836. let gCenter = Cesium.Ellipsoid.WGS84.cartesianToCartographic(centerPosition);
  3837. /* 计算边界线上的点坐标 */
  3838. let cPoint = turf.point([Cesium.Math.toDegrees(gCenter.longitude), Cesium.Math.toDegrees(
  3839. gCenter.latitude)]);
  3840. let boundaryPoint = turf.destination(cPoint, radius / 1000, 90, {
  3841. units: 'kilometers'
  3842. }).geometry.coordinates;
  3843. /* 查询高度创建边界点 */
  3844. let height = this._queryHeightFromGeo(boundaryPoint[0], boundaryPoint[1]);
  3845. let cbPoint = Cesium.Cartesian3.fromDegrees(boundaryPoint[0], boundaryPoint[1], height);
  3846. return cbPoint;
  3847. },
  3848. /**
  3849. * 根据一组点计算中心点位置
  3850. * @ignore 生成方法时不对外公开
  3851. * @param {Array<Cesium.Cartesian3>} positions 点集合
  3852. */
  3853. _calculateCenterPosition: function(positions) {
  3854. if (positions === undefined || positions.length === 0) return undefined;
  3855. else if (positions.length === 1) {
  3856. return positions[0];
  3857. } else if (positions.length === 2) {
  3858. let pt0 = this._cartesian3ToGeo(positions[0]);
  3859. let pt1 = this._cartesian3ToGeo(positions[1]);
  3860. let point0 = turf.point([pt0.longitude, pt0.latitude]);
  3861. let point1 = turf.point([pt1.longitude, pt1.latitude]);
  3862. let center = turf.midpoint(point0, point1).geometry.coordinates;
  3863. /* 查询高度 */
  3864. let height = this._queryHeightFromGeo(center[0], center[1]);
  3865. /* 返回 */
  3866. return Cesium.Cartesian3.fromDegrees(center[0], center[1], height);
  3867. } else {
  3868. let geoPoints = [
  3869. []
  3870. ];
  3871. for (let i = 0; i < positions.length; i++) {
  3872. /* 将世界坐标转换为经纬度坐标 */
  3873. let geoPoint = this._cartesian3ToGeo(positions[i]);
  3874. geoPoints[0].push([geoPoint.longitude, geoPoint.latitude]);
  3875. }
  3876. geoPoints[0].push(geoPoints[0][0]);
  3877. /* 创建区域 */
  3878. let polygon = turf.polygon(geoPoints);
  3879. /* 计算中心点 */
  3880. let center = turf.centerOfMass(polygon).geometry.coordinates;
  3881. /* 查询高度 */
  3882. let height = this._queryHeightFromGeo(center[0], center[1]);
  3883. /* 返回 */
  3884. return Cesium.Cartesian3.fromDegrees(center[0], center[1], height);
  3885. }
  3886. },
  3887. /**
  3888. * 计算转换后的位置,根据角度和距离计算转换后的位置
  3889. * @ignore 生成方法时不对外公开
  3890. * @param {Cesium.Cartesian3} position 待转换位置
  3891. * @param {Number} distance 距离<距离的表示单位在options中配置>
  3892. * @param {Number} bearing 角度
  3893. * @param {JSON} options 配置项
  3894. * @return {Cesium.Cartesian3} 转换后的位置
  3895. */
  3896. _calculateTransformPosition: function(position, distance, bearing, options) {
  3897. /* 将移动点转换为经纬度格式 */
  3898. let geoPoint = this._cartesian3ToGeo(position);
  3899. /* 根据点的角度度 距离计算移动后的位置 */
  3900. let point = turf.point([geoPoint.longitude, geoPoint.latitude]);
  3901. let resPoint = turf.destination(point, distance, bearing, options).geometry
  3902. .coordinates;
  3903. /* 根据经纬度查询高度 该步骤耗时 且容易出错 */
  3904. let height = geoPoint.height;
  3905. if (options !== undefined && options.calculateHeight !== undefined && options.calculateHeight ===
  3906. true) {
  3907. height = this._queryHeightFromGeo(resPoint[0], resPoint[1]);
  3908. }
  3909. /* 将移动后的点转换为世界坐标系坐标点 */
  3910. let cPosition = Cesium.Cartesian3.fromDegrees(resPoint[0], resPoint[1],
  3911. height);
  3912. /* 返回 */
  3913. return cPosition;
  3914. },
  3915. /**
  3916. * 取消实体编辑激活状态
  3917. * @ignore 生成方法时不对外公开
  3918. */
  3919. _unActivateEdit: function() {
  3920. /* 移除编辑点 */
  3921. this._clearEditPoint();
  3922. /* 删除坐标轴 */
  3923. this._removeCoorinateAxis();
  3924. /* 关闭属性编辑框 */
  3925. this._closePropertyEditDialog();
  3926. },
  3927. /**
  3928. * 激活编辑
  3929. * @ignore 生成方法时不对外公开
  3930. * @param {Cesium.Entity} editEntity 编辑实体
  3931. */
  3932. _activateEdit: function(editEntity) {
  3933. /* 获取编辑类型 */
  3934. let entityType = editEntity.getEntityType();
  3935. /* 获取实体是否可编辑 */
  3936. let entityIsEdit = editEntity.getIsEdit();
  3937. /* 不可编辑对象 直接退出 */
  3938. if (entityIsEdit === undefined || entityType === undefined || entityIsEdit === false) {
  3939. this._console('该实体不可编辑');
  3940. return;
  3941. };
  3942. if (entityType === DrawTools.DrawType.OdLine) {
  3943. this._activeteOdlineEdit(editEntity);
  3944. } else {
  3945. this._activeteNormalEdit(editEntity);
  3946. }
  3947. },
  3948. /**
  3949. * 激活编辑OD线实体
  3950. * @ignore 生成方法时不对外公开
  3951. * @param {Cesium.Entity} editEntity 编辑实体
  3952. */
  3953. _activeteOdlineEdit: function(editEntity) {
  3954. let _self = this;
  3955. let entityType = editEntity.getEntityType();
  3956. /* 不可编辑对象 直接退出 */
  3957. if (entityType === undefined || entityType !== DrawTools.DrawType.OdLine) {
  3958. this._console('该实体不可编辑或该实体不是OD线类型');
  3959. return;
  3960. };
  3961. /* 获取父实体Id */
  3962. let faterEntityId = editEntity.parent.id;
  3963. /* 当前编辑OD线集合 */
  3964. this._editOdlineEntities = [];
  3965. /* 循环集合寻找符合条件的实体 */
  3966. for (let entity of this._entities.values) {
  3967. if (entity.parent !== undefined && entity.parent.id === faterEntityId) {
  3968. this._editOdlineEntities.push(entity);
  3969. }
  3970. }
  3971. /* 不存在可编辑的OD线 */
  3972. if (this._editOdlineEntities.length === 0) return;
  3973. /* 赋值可编辑对象 */
  3974. this._editEntity = this._editOdlineEntities[0];
  3975. for (let i = 0; i < this._editOdlineEntities.length; i++) {
  3976. let entity = this._editOdlineEntities[i];
  3977. let positions = entity.polyline.positions._value;
  3978. if (i === 0) {
  3979. this._createEditOdlineStartPoint(positions.first(), entity);
  3980. this._createEditOdlineEndPoint(positions.last(), entity);
  3981. } else {
  3982. this._createEditOdlineEndPoint(positions.last(), entity);
  3983. }
  3984. }
  3985. /* 创建事件句柄 */
  3986. if (this._sketchEditHandler === undefined) {
  3987. this._sketchEditHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  3988. }
  3989. /* 注册鼠标左键按下事件 */
  3990. this._registerLeftDownEvent(this._sketchEditHandler, function(event) {
  3991. _self._eventEditMouseDown(event);
  3992. });
  3993. /* 注册鼠标左键移动事件 */
  3994. this._registerMouseMoveEvent(this._sketchEditHandler, function(event) {
  3995. _self._eventEditMouseMove(event);
  3996. });
  3997. /* 注册鼠标左键抬起事件 */
  3998. this._registerLeftUpEvent(this._sketchEditHandler, function(event) {
  3999. _self._eventEditMouseUp(event);
  4000. });
  4001. },
  4002. /**
  4003. * 激活编辑单实体
  4004. * @ignore 生成方法时不对外公开
  4005. * @param {Cesium.Entity} editEntity 编辑实体
  4006. */
  4007. _activeteNormalEdit: function(editEntity) {
  4008. let _self = this;
  4009. let positions = this._getEntityEditData(editEntity);
  4010. /* 删除所有临时绘制的点 */
  4011. this._removePointEntitys();
  4012. /* 获取编辑类型 */
  4013. let entityType = editEntity.getEntityType();
  4014. /* 赋值可编辑对象 */
  4015. this._editEntity = editEntity;
  4016. /* 创建节点和中心点 */
  4017. if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools
  4018. .DrawType.DynamicCircle) {
  4019. this._createEditCenterPoint(positions[0]);
  4020. this._createEditNodePoint(positions, 1);
  4021. } else if (entityType === DrawTools.DrawType.VideoWall) {
  4022. if (!this._isRuntimeApp()) {
  4023. /* 如果不是App运行环境,则创建拖动轴 */
  4024. let position = positions[0];
  4025. this._removeCoorinateAxis();
  4026. this._createCoordinateAxis(position);
  4027. }
  4028. } else {
  4029. this._createEditNodePoint(positions);
  4030. let centerPosition = this._calculateCenterPosition(positions);
  4031. if (centerPosition !== undefined) {
  4032. this._createEditCenterPoint(centerPosition);
  4033. }
  4034. }
  4035. /* 创建中点 */
  4036. if (entityType !== DrawTools.DrawType.Rectangle && entityType !== DrawTools
  4037. .DrawType.Circle && entityType !== DrawTools.DrawType.DynamicCircle && entityType !== DrawTools
  4038. .DrawType.VideoWall) {
  4039. if (entityType === DrawTools.DrawType.SpatialLine) {
  4040. this._createEditMiddlePoint(positions, true);
  4041. } else {
  4042. this._createEditMiddlePoint(positions);
  4043. }
  4044. }
  4045. /* 创建事件句柄 */
  4046. if (this._sketchEditHandler === undefined) {
  4047. this._sketchEditHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  4048. }
  4049. /* 注册鼠标左键按下事件 */
  4050. this._registerLeftDownEvent(this._sketchEditHandler, function(event) {
  4051. _self._eventEditMouseDown(event);
  4052. })
  4053. /* 注册鼠标移动事件 */
  4054. this._registerMouseMoveEvent(this._sketchEditHandler, function(event) {
  4055. _self._eventEditMouseMove(event);
  4056. });
  4057. /* 注册鼠标抬起事件 */
  4058. this._registerLeftUpEvent(this._sketchEditHandler, function(event) {
  4059. _self._eventEditMouseUp(event);
  4060. })
  4061. },
  4062. /**
  4063. * 编辑点鼠标抬起事件
  4064. * @ignore 生成方法时不对外公开
  4065. * @param {Object} event 事件
  4066. */
  4067. _eventEditMouseDown: function(event) {
  4068. let _self = this;
  4069. /* 拾取实体 */
  4070. let feature = _self._viewer.scene.pick(event.position);
  4071. /* 分类处理 */
  4072. if (feature != undefined && feature.id instanceof Cesium.Entity) {
  4073. /* 获取选择实体的样式 */
  4074. let featureType = feature.id.getEditType();
  4075. /* 说明当前选中的实体 不是编辑点 */
  4076. if (featureType === undefined) return;
  4077. /* 禁用场景的旋转移动功能 保留缩放功能 */
  4078. _self._viewer.scene.screenSpaceCameraController.enableRotate = false;
  4079. /* 位置信息 */
  4080. let entityPosition = feature.id.position._value;
  4081. /* 保存当前可编辑的实体 */
  4082. _self._editPointEntity = feature.id;
  4083. /* 设置鼠标样式为十字 */
  4084. _self._setMousePointerStyle();
  4085. /* 判断类型 是节点或中点 进行不同的操作 */
  4086. if (featureType.type === DrawTools.EditPointType.Node || featureType.type ===
  4087. DrawTools.EditPointType.Middle) {
  4088. /* 处理鼠标按下实体的属性变更回调 */
  4089. _self._entityCallbackPropertyByMouseDown();
  4090. /* 移除当前移动的点 */
  4091. _self._removeEntityByObject(_self._editPointEntity);
  4092. /* 删除高空点 */
  4093. if (_self._sketchEditEntitySpatialName != undefined) {
  4094. _self._removeEntityByName(_self._sketchEditEntitySpatialName);
  4095. }
  4096. } else if (featureType.type === DrawTools.EditPointType.Center) {
  4097. _self._entityCenterMouseDownEvent();
  4098. } else if (featureType.type === DrawTools.EditPointType.OdlineEndNode) {
  4099. /* 删除当前移动点 */
  4100. _self._removeEntityByObject(_self._editPointEntity);
  4101. /* 设置当前编辑的实体 */
  4102. _self._editEntity = featureType.joinEntity;
  4103. /* 获取OD线的必要参数 */
  4104. let params = _self._editEntity.parent.getParams();
  4105. _self._sketchEditPoints = [];
  4106. let joinEntityPositions = _self._editEntity.polyline.positions._value;
  4107. _self._sketchEditPoints.push(joinEntityPositions.first());
  4108. _self._sketchEditPoints.push(joinEntityPositions.last());
  4109. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4110. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0], _self
  4111. ._sketchEditPoints[1], parseInt(params.odlineHeight), parseInt(params
  4112. .odlineCount));
  4113. return positions;
  4114. }, false)
  4115. } else if (featureType.type === DrawTools.EditPointType.OdlineStrartNode) {
  4116. /* 删除当前移动点 */
  4117. _self._removeEntityByObject(_self._editPointEntity);
  4118. /* 设置当前编辑的实体 */
  4119. _self._editEntity = featureType.joinEntity;
  4120. /* 获取OD线的必要参数 */
  4121. let params = _self._editEntity.parent.getParams();
  4122. _self._sketchEditPoints = [];
  4123. let joinEntityPositions = _self._editEntity.polyline.positions._value;
  4124. _self._sketchEditPoints.push(joinEntityPositions.first());
  4125. for (let odEntity of _self._editOdlineEntities) {
  4126. let odEntityPositions = odEntity.polyline.positions._value;
  4127. let lastPosition = odEntityPositions.last();
  4128. _self._sketchEditPoints.push(lastPosition.clone());
  4129. odEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4130. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0],
  4131. lastPosition, parseInt(params.odlineHeight), parseInt(params
  4132. .odlineCount));
  4133. return positions;
  4134. }, false);
  4135. }
  4136. }
  4137. /* 根据节点类型不同进行特殊的处理 */
  4138. if (featureType.type === DrawTools.EditPointType.Middle) {
  4139. /* 如果选择的是中点 则插入节点 并记录当前的索引 */
  4140. let index = featureType.index;
  4141. _self._sketchEditPoints.splice(index, 0, entityPosition);
  4142. _self._sketchEditIndex = index;
  4143. /* 如果当前移动的中点为墙的中点,则需要进行特殊处理一下,主要为了修正高度 */
  4144. if (_self._sketchWallHeights != undefined && _self._sketchWallHeights.length >
  4145. 0) {
  4146. /* 查询一下高度 */
  4147. let geoPoint = _self._cartesian3ToGeo(entityPosition);
  4148. let height = _self._queryHeightFromGeo(geoPoint.longitude, geoPoint
  4149. .latitude);
  4150. /* 墙的最小高度加入值 */
  4151. _self._sketchWallHeights.splice(index, 0, height);
  4152. /* 墙的最大高度需要加入值 */
  4153. let heightDifference = _self._sketchWallMaxHeights[0] - _self
  4154. ._sketchWallHeights[0];
  4155. _self._sketchWallMaxHeights.splice(index, 0, height + heightDifference);
  4156. }
  4157. /* 设置提示标签 */
  4158. _self._tooltipInit('拖动中点,改变形状', event.position);
  4159. } else if (featureType.type === DrawTools.EditPointType.Node) {
  4160. /* 如果是节点 则直接记录索引 */
  4161. _self._sketchEditIndex = featureType.index;
  4162. /* 设置提示标签 */
  4163. _self._tooltipInit('拖动节点,改变形状', event.position);
  4164. } else if (featureType.type === DrawTools.EditPointType.Spatial) {
  4165. /* 如果是节点 则直接记录索引 */
  4166. _self._sketchEditIndex = featureType.index;
  4167. /* 设置提示标签 */
  4168. _self._tooltipInit('拖动节点,改变高度', event.position);
  4169. } else if (featureType.type === DrawTools.EditPointType.CoordinateAxis) {
  4170. /* 设置提示标签 */
  4171. _self._tooltipInit('拖动坐标轴,改变位置', event.position);
  4172. } else if (featureType.type === DrawTools.EditPointType.OdlineEndNode || featureType.type ===
  4173. DrawTools.EditPointType.OdlineStrartNode) {
  4174. /* 设置提示标签 */
  4175. _self._tooltipInit('拖动节点,改变OD线位置', event.position);
  4176. }
  4177. }
  4178. },
  4179. /**
  4180. * 编辑点鼠标移动事件
  4181. * @ignore 生成方法时不对外公开
  4182. * @param {Object} event 事件
  4183. */
  4184. _eventEditMouseMove: function(event) {
  4185. let _self = this;
  4186. if (_self._editPointEntity != undefined) {
  4187. let loc = _self._transfromFromScreenPoint(event.endPosition);
  4188. if (!Cesium.defined(loc.sLocation)) return;
  4189. _self._editPosition = loc.sLocation;
  4190. /* 获取当前可编辑点的类型 */
  4191. let editEntityType = _self._editPointEntity.getEditType();
  4192. if (editEntityType.type === DrawTools.EditPointType.Node) {
  4193. _self._sketchEditPoints[_self._sketchEditIndex] = loc.sLocation;
  4194. /* 获取当前编辑的实体的类型 */
  4195. let editEntityType = _self._editEntity.getEntityType();
  4196. if (editEntityType != DrawTools.DrawType.Rectangle &&
  4197. editEntityType != DrawTools.DrawType.Circle && editEntityType != DrawTools
  4198. .DrawType.DynamicCircle) {
  4199. /* 这里对面对象需要进特殊处理 保证第0号点和最后一个点是一致的 */
  4200. if ((editEntityType === DrawTools.DrawType.Polygon || editEntityType ===
  4201. DrawTools.DrawType.House) && _self
  4202. ._sketchEditIndex === 0) {
  4203. _self._sketchEditPoints[_self._sketchEditPoints.length - 1] = loc
  4204. .sLocation;
  4205. } else if (editEntityType === DrawTools.DrawType.NormalWall ||
  4206. editEntityType === DrawTools.DrawType.DynamicWall || editEntityType ===
  4207. DrawTools.DrawType.TextWall) {
  4208. _self._sketchWallHeights[_self._sketchEditIndex] = loc.gLocation.height;
  4209. }
  4210. /* 移除所有中点 */
  4211. _self._removeEntityByName(_self._sketchEditEntityMiddleName);
  4212. /* 创建所有中点 */
  4213. if (editEntityType === DrawTools.DrawType.SpatialLine) {
  4214. _self._createEditMiddlePoint(_self._sketchEditPoints, true);
  4215. } else {
  4216. _self._createEditMiddlePoint(_self._sketchEditPoints);
  4217. }
  4218. }
  4219. } else if (editEntityType.type === DrawTools.EditPointType.Middle) {
  4220. _self._sketchEditPoints[_self._sketchEditIndex] = loc.sLocation;
  4221. } else if (editEntityType.type === DrawTools.EditPointType.Center) {
  4222. _self._entityCenterMouseMoveEvent(event);
  4223. } else if (editEntityType.type === DrawTools.EditPointType.Spatial) {
  4224. /* 当前移动的是空中点 */
  4225. let ellipsoid = _self._viewer.scene.globe.ellipsoid;
  4226. let cartesian = _self._viewer.camera.pickEllipsoid(event.endPosition,
  4227. ellipsoid);
  4228. let bottomPoint = _self._sketchEditPoints[_self._sketchEditIndex];
  4229. /* 计算高差 */
  4230. let heightDifference = cartesian.z - bottomPoint.z;
  4231. if (heightDifference > 0 && heightDifference < 500) {
  4232. for (let i = 0; i < _self._sketchWallHeights.length; i++) {
  4233. _self._sketchWallMaxHeights[i] = _self._sketchWallHeights[i] +
  4234. heightDifference;
  4235. }
  4236. }
  4237. } else if (editEntityType.type === DrawTools.EditPointType.OdlineEndNode) {
  4238. _self._sketchEditPoints[_self._sketchEditPoints.length - 1] = loc.sLocation;
  4239. } else if (editEntityType.type === DrawTools.EditPointType.OdlineStrartNode) {
  4240. _self._sketchEditPoints[0] = loc.sLocation;
  4241. }
  4242. /* 更改标签文字 */
  4243. _self._tooltipInit('抬起鼠标,完成更改', event.endPosition);
  4244. }
  4245. },
  4246. /**
  4247. * 编辑点鼠标抬起事件
  4248. * @ignore 生成方法时不对外公开
  4249. * @param {Object} event 事件
  4250. */
  4251. _eventEditMouseUp: function(event) {
  4252. let _self = this;
  4253. if (_self._editPointEntity != undefined) {
  4254. /* 恢复所有鼠标默认事件 */
  4255. _self._viewer.scene.screenSpaceCameraController.enableRotate = true;
  4256. /* 移除标签 */
  4257. _self._tooltipRemove();
  4258. /* 恢复鼠标默认样式 */
  4259. _self._setMouseDefaultStyle();
  4260. /* 获取当前编辑的点类型 */
  4261. let editEntityPointType = _self._editPointEntity.getEditType().type;
  4262. let entityType = _self._editEntity.getEntityType();
  4263. if (editEntityPointType === DrawTools.EditPointType.CoordinateAxis) {
  4264. } else if (editEntityPointType === DrawTools.EditPointType.OdlineEndNode) {
  4265. /* 获取OD线的必要参数 */
  4266. let params = _self._editEntity.parent.getParams();
  4267. /* 重置编辑实体的位置 */
  4268. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0], _self
  4269. ._sketchEditPoints[1], parseInt(params.odlineHeight), parseInt(params.odlineCount));
  4270. _self._editEntity.polyline.positions = positions;
  4271. /* 创建OD线的终点 */
  4272. _self._createEditOdlineEndPoint(_self._sketchEditPoints[1], _self._editEntity);
  4273. } else if (editEntityPointType === DrawTools.EditPointType.OdlineStrartNode) {
  4274. /* 获取OD线的必要参数 */
  4275. let params = _self._editEntity.parent.getParams();
  4276. let index = 1;
  4277. for (let odEntity of _self._editOdlineEntities) {
  4278. let lastPosition = _self._sketchEditPoints[index++];
  4279. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0],
  4280. lastPosition, parseInt(params.odlineHeight), parseInt(params.odlineCount));
  4281. odEntity.polyline.positions = positions;
  4282. }
  4283. _self._createEditOdlineStartPoint(_self._sketchEditPoints[0], _self._editOdlineEntities[0]);
  4284. } else {
  4285. if (editEntityPointType === DrawTools.EditPointType.Node ||
  4286. editEntityPointType === DrawTools.EditPointType.Middle) {
  4287. /* 处理鼠标抬起实体的属性变更回调 */
  4288. _self._entityCallbackPropertyByMouseUp();
  4289. } else if (editEntityPointType === DrawTools.EditPointType.Center) {
  4290. _self._entityCenterMouseUpEvent(event);
  4291. }
  4292. /* 删除节点、中点和中心点 */
  4293. _self._removeEntityByName(_self._sketchEditEntityNodeName);
  4294. _self._removeEntityByName(_self._sketchEditEntityMiddleName);
  4295. _self._removeEntityByName(_self._sketchEditEntityCenterName);
  4296. /* 创建节点、中点和中心点 */
  4297. if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools
  4298. .DrawType
  4299. .DynamicCircle) {
  4300. /* 需要对点进行特殊处理 保证圆边界点始终在统一位置 */
  4301. let centerPosition = _self._editEntity.position._value;
  4302. let boundaryPosition = _self._calculateCircleBoundaryPoint(centerPosition,
  4303. _self
  4304. ._sketchEllipseRadius);
  4305. _self._sketchEditPoints[0] = centerPosition;
  4306. _self._sketchEditPoints[1] = boundaryPosition;
  4307. _self._createEditNodePoint(_self._sketchEditPoints, 1);
  4308. _self._createEditCenterPoint(centerPosition);
  4309. } else {
  4310. /* 创建节点 */
  4311. _self._createEditNodePoint(_self._sketchEditPoints);
  4312. /* 创建中心点 */
  4313. let centerPosition = _self._calculateCenterPosition(_self
  4314. ._sketchEditPoints);
  4315. _self._createEditCenterPoint(centerPosition);
  4316. }
  4317. /* 创建中点 */
  4318. if (entityType != DrawTools.DrawType.Rectangle &&
  4319. entityType != DrawTools.DrawType.Circle && entityType != DrawTools.DrawType
  4320. .DynamicCircle) {
  4321. if (entityType === DrawTools.DrawType.SpatialLine) {
  4322. _self._createEditMiddlePoint(_self._sketchEditPoints, true);
  4323. } else {
  4324. _self._createEditMiddlePoint(_self._sketchEditPoints);
  4325. }
  4326. }
  4327. }
  4328. /* 清除选�����的实体 */
  4329. _self._editPointEntity = undefined;
  4330. }
  4331. },
  4332. /**
  4333. * 实体中心点鼠标按下(拖拽点按下)
  4334. * @ignore 生成方法时不对外公开
  4335. */
  4336. _entityCenterMouseDownEvent: function() {
  4337. let _self = this;
  4338. let entityPosition = this._editEntity.position._value;
  4339. /* 删除节点、中点和中心点 */
  4340. this._removeEntityByName(this._sketchEditEntityNodeName);
  4341. this._removeEntityByName(this._sketchEditEntityMiddleName);
  4342. this._removeEntityByName(this._sketchEditEntityCenterName);
  4343. /* 记录相关位置信息 */
  4344. this._startPoint = entityPosition;
  4345. this._startMovePoints = [];
  4346. this._movePoint = entityPosition;
  4347. /* 获取编辑实体的类型 */
  4348. let editEntityType = this._editEntity.getEntityType();
  4349. /* 操作的如果是圆 */
  4350. if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools
  4351. .DrawType.DynamicCircle) {
  4352. /* 记录移动点为所有的圆边界点 */
  4353. if (this._editEntity.polyline !== undefined) {
  4354. for (let i = 0; i < this._ellipseOutlineCoordinates.length; i++) {
  4355. this._startMovePoints.push(this._ellipseOutlineCoordinates[i]);
  4356. }
  4357. this._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4358. function() {
  4359. return _self._ellipseOutlineCoordinates;
  4360. }, false);
  4361. }
  4362. this._editEntity.position = new Cesium.CallbackProperty(function() {
  4363. return _self._movePoint;
  4364. }, false);
  4365. } else if (editEntityType === DrawTools.DrawType.Polygon || editEntityType === DrawTools.DrawType
  4366. .House) {
  4367. /* 记录移动点为所有边界点 */
  4368. for (let i = 0; i < this._sketchEditPoints.length; i++) {
  4369. this._startMovePoints.push(this._sketchEditPoints[i]);
  4370. }
  4371. /* 设置位置属性更新方式 */
  4372. _self._editEntity.polygon.hierarchy = new Cesium.CallbackProperty(function() {
  4373. return {
  4374. positions: _self._sketchEditPoints,
  4375. };
  4376. }, false);
  4377. if (_self._editEntity.polyline != undefined) {
  4378. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4379. return _self._sketchEditPoints;
  4380. }, false);
  4381. }
  4382. } else if (editEntityType === DrawTools.DrawType.Polyline || editEntityType === DrawTools.DrawType
  4383. .SpatialLine) {
  4384. /* 记录移动点为所有边界点 */
  4385. for (let i = 0; i < this._sketchEditPoints.length; i++) {
  4386. this._startMovePoints.push(this._sketchEditPoints[i]);
  4387. }
  4388. /* 设置属性更新方法回调 */
  4389. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4390. return _self._sketchEditPoints;
  4391. }, false);
  4392. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  4393. /* 记录移动点为所有边界点 */
  4394. for (let i = 0; i < this._sketchEditPoints.length; i++) {
  4395. this._startMovePoints.push(this._sketchEditPoints[i]);
  4396. }
  4397. /* 设置属性变更回调 */
  4398. _self._editEntity.rectangle.coordinates = new Cesium.CallbackProperty(_self
  4399. ._callUpdateRectangleCoordinates(_self
  4400. ._sketchEditPoints), false);
  4401. /* 如果存在边界线 则特殊处理 */
  4402. if (_self._editEntity.polyline != undefined) {
  4403. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(_self
  4404. ._callUpdateRectangleOutlineCoordinates(),
  4405. false);
  4406. }
  4407. }
  4408. },
  4409. /**
  4410. * 实体中心点鼠标移动
  4411. * @ignore
  4412. * @param {Cesium.Event} event 事件
  4413. */
  4414. _entityCenterMouseMoveEvent: function(event) {
  4415. this._calculatePositionsByCenter(event.endPosition, false);
  4416. },
  4417. /* 换个思路试试 移动过程中不计算 待移动完成后计算 以便保���移动速度 要不实时计算高度 导致卡顿 */
  4418. /**
  4419. * 计算中心拖拽点移动后实体点随之移动后的位置数据
  4420. * @ignore 生成方法时不对外公开
  4421. * @param {JSON} screenPosition 移动后的屏幕点
  4422. * @param {Boolean} calculateHeight 是否计算移动点的高度
  4423. */
  4424. _calculatePositionsByCenter: function(screenPosition, calculateHeight) {
  4425. let _self = this;
  4426. /* 起点转换为经纬度 */
  4427. let strLoc = this._cartesian3ToGeo(this._startPoint);
  4428. /* 获取终止点 */
  4429. let endLoc = this._transfromFromScreenPoint(screenPosition);
  4430. /* 计算两点之间的角度 */
  4431. var point1 = turf.point([strLoc.longitude, strLoc.latitude]);
  4432. var point2 = turf.point([endLoc.gLocation.lng, endLoc.gLocation.lat]);
  4433. var bearing = turf.bearing(point1, point2);
  4434. /* 计算亮点���间���距��� 距���单���和���否���算���度*/
  4435. var options = {
  4436. units: 'kilometers',
  4437. calculateHeight: calculateHeight
  4438. };
  4439. var distance = turf.distance(point1, point2, options);
  4440. /* 根据移动的不同类型实体进行不同的操作 */
  4441. let editEntityType = this._editEntity.getEntityType();
  4442. if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools
  4443. .DrawType.DynamicCircle) {
  4444. /* 循环处理所有移动点 */
  4445. for (let i = 0; i < this._startMovePoints.length; i++) {
  4446. /* 计算转换后的位置 */
  4447. let position = this._calculateTransformPosition(this._startMovePoints[i], distance, bearing,
  4448. options);
  4449. /* 更新移动点数组 */
  4450. this._ellipseOutlineCoordinates[i] = position.clone();
  4451. }
  4452. /* �������新中心���置数组 */
  4453. this._movePoint = endLoc.sLocation;
  4454. } else {
  4455. /* 循环处理所有移动点 */
  4456. for (let i = 0; i < this._startMovePoints.length; i++) {
  4457. /* 计算转换后的位置 */
  4458. let position = this._calculateTransformPosition(this._startMovePoints[i], distance, bearing,
  4459. options);
  4460. /* 更新移动点数组 */
  4461. this._sketchEditPoints[i] = position.clone();
  4462. }
  4463. }
  4464. },
  4465. /**
  4466. * 实体中心点鼠标抬起(即拖拽点)
  4467. * @ignore 生成方法时不对外公开
  4468. * @param {Object} event 事件
  4469. */
  4470. _entityCenterMouseUpEvent: function(event) {
  4471. /* 计算最新位置点 */
  4472. this._calculatePositionsByCenter(event.position, true);
  4473. let _self = this;
  4474. /* 根据不同的实体进行不同的操作 */
  4475. let editEntityType = this._editEntity.getEntityType();
  4476. if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools
  4477. .DrawType.DynamicCircle) {
  4478. this._editEntity.position = this._movePoint;
  4479. if (this._editEntity.polyline !== undefined) {
  4480. this._editEntity.polyline.positions = this._ellipseOutlineCoordinates;
  4481. }
  4482. } else if (editEntityType === DrawTools.DrawType.Polyline || editEntityType === DrawTools.DrawType
  4483. .SpatialLine) {
  4484. this._editEntity.polyline.positions = this._sketchEditPoints;
  4485. } else if (editEntityType === DrawTools.DrawType.Polygon || editEntityType === DrawTools.DrawType
  4486. .House) {
  4487. this._editEntity.polygon.hierarchy = {
  4488. positions: _self._sketchEditPoints,
  4489. };
  4490. if (this._editEntity.polyline != undefined) {
  4491. this._editEntity.polyline.positions = this._sketchEditPoints;
  4492. }
  4493. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  4494. this._editEntity.rectangle.coordinates = Cesium.Rectangle.fromDegrees(_self
  4495. ._rectangleCoordinates[
  4496. 0], _self
  4497. ._rectangleCoordinates[1], _self._rectangleCoordinates[2], _self
  4498. ._rectangleCoordinates[3]);
  4499. if (this._editEntity.polyline != undefined) {
  4500. this._editEntity.polyline.positions = _self._rectangleOutlineCoordinates;
  4501. }
  4502. }
  4503. },
  4504. /**
  4505. * 处理鼠标抬起实体的属性变更回调
  4506. * @ignore 生成方法时不对外公开
  4507. */
  4508. _entityCallbackPropertyByMouseUp: function() {
  4509. let _self = this;
  4510. let entityType = _self._editEntity.getEntityType();
  4511. if (entityType === DrawTools.DrawType.Polyline) {
  4512. _self._editEntity.polyline.positions = _self._sketchEditPoints;
  4513. } else if (entityType === DrawTools.DrawType.Polygon || entityType === DrawTools.DrawType.House) {
  4514. _self._editEntity.polygon.hierarchy = {
  4515. positions: _self._sketchEditPoints,
  4516. };
  4517. /* 此处���要特殊处理一下 */
  4518. if (_self._editEntity.polyline != undefined) {
  4519. /* 如果创建区域的同时 创建了边界线 则根据区域的边界创建线 */
  4520. let polygonPositions = _self._editEntity.polygon.hierarchy._value.positions;
  4521. let linePositions = [];
  4522. for (let i = 0; i < polygonPositions.length; i++) {
  4523. linePositions.push(polygonPositions[i].clone());
  4524. }
  4525. /* 判断是否需要加入0号点 */
  4526. if (linePositions[0].x !== linePositions[linePositions.length - 1].x) {
  4527. linePositions.push(linePositions[0].clone());
  4528. }
  4529. _self._editEntity.polyline.positions = linePositions;
  4530. }
  4531. } else if (entityType === DrawTools.DrawType.Rectangle) {
  4532. _self._editEntity.rectangle.coordinates = Cesium.Rectangle.fromDegrees(_self
  4533. ._rectangleCoordinates[0], _self
  4534. ._rectangleCoordinates[1], _self._rectangleCoordinates[2], _self
  4535. ._rectangleCoordinates[3]);
  4536. /* 判断矩形有边界线 特殊处理 */
  4537. if (_self._editEntity.polyline != undefined) {
  4538. _self._editEntity.polyline.positions = _self._rectangleOutlineCoordinates;
  4539. }
  4540. } else if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools.DrawType
  4541. .DynamicCircle) {
  4542. /* 移动的是圆的点 需要特殊处理 */
  4543. _self._editEntity.ellipse.semiMajorAxis = _self._sketchEllipseRadius;
  4544. _self._editEntity.ellipse.semiMinorAxis = _self._sketchEllipseRadius;
  4545. /* 如果圆有边界线 则进行特殊处理 */
  4546. if (_self._editEntity.polyline != undefined) {
  4547. _self._editEntity.polyline.positions = _self._ellipseOutlineCoordinates;
  4548. }
  4549. } else if (entityType === DrawTools.DrawType.NormalWall || entityType === DrawTools.DrawType
  4550. .DynamicWall || entityType === DrawTools.DrawType.TextWall) {
  4551. _self._editEntity.wall.positions = _self._sketchEditPoints;
  4552. _self._editEntity.wall.minimumHeights = _self._sketchWallHeights;
  4553. _self._editEntity.wall.maximumHeights = _self._sketchWallMaxHeights;
  4554. }
  4555. },
  4556. /**
  4557. * 处理鼠标按下实体的属性变更回调
  4558. * @ignore 生成方法时不对外公开
  4559. */
  4560. _entityCallbackPropertyByMouseDown: function() {
  4561. let _self = this;
  4562. /* 更改编辑实体的坐标数据获取方式 */
  4563. let entityType = _self._editEntity.getEntityType();
  4564. if (entityType === DrawTools.DrawType.Polyline || entityType === DrawTools.DrawType.SpatialLine) {
  4565. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4566. function() {
  4567. return _self._sketchEditPoints;
  4568. }, false);
  4569. } else if (entityType === DrawTools.DrawType.Polygon || entityType === DrawTools.DrawType.House) {
  4570. _self._editEntity.polygon.hierarchy = new Cesium.CallbackProperty(
  4571. function() {
  4572. return {
  4573. positions: _self._sketchEditPoints,
  4574. };
  4575. }, false);
  4576. /* 此处需要特殊处理 ���断���面实体是否挂接着线 */
  4577. if (_self._editEntity.polyline != undefined) {
  4578. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4579. function() {
  4580. /* 如果创建区域的同时 创建了边界线 则根据区域的边界创建线 */
  4581. let polygonPositions = _self._sketchEditPoints;
  4582. let linePositions = [];
  4583. for (let i = 0; i < polygonPositions.length; i++) {
  4584. linePositions.push(polygonPositions[i].clone());
  4585. }
  4586. /* 判断是否需要加入0号点 */
  4587. if (linePositions[0].x !== linePositions[linePositions.length - 1].x) {
  4588. linePositions.push(linePositions[0].clone());
  4589. }
  4590. return linePositions;
  4591. }, false);
  4592. }
  4593. } else if (entityType === DrawTools.DrawType.Rectangle) {
  4594. _self._editEntity.rectangle.coordinates = new Cesium.CallbackProperty(_self
  4595. ._callUpdateRectangleCoordinates(_self
  4596. ._sketchEditPoints),
  4597. false);
  4598. /* 如果存在边界线则特殊处理 */
  4599. if (_self._editEntity.polyline != undefined) {
  4600. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(_self
  4601. ._callUpdateRectangleOutlineCoordinates(),
  4602. false);
  4603. }
  4604. } else if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools.DrawType
  4605. .DynamicCircle) {
  4606. /* 移动的是圆的点 需要特殊处理 */
  4607. if (_self._editPointEntity.getEditType().index === 1) {
  4608. _self._editEntity.ellipse.semiMajorAxis = new Cesium.CallbackProperty(
  4609. _self
  4610. ._callUpdateEllipseMinorAxis(_self._sketchEditPoints), false);
  4611. _self._editEntity.ellipse.semiMinorAxis = new Cesium.CallbackProperty(
  4612. _self
  4613. ._callUpdateEllipseMinorAxis(_self._sketchEditPoints), false);
  4614. }
  4615. /* 如果圆有边界线 则进行特殊���理 */
  4616. if (_self._editEntity.polyline != undefined) {
  4617. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4618. _self._callEllipseOutlineCoordinate(_self
  4619. ._sketchEditPoints), false);
  4620. }
  4621. } else if (entityType === DrawTools.DrawType.NormalWall || entityType === DrawTools.DrawType
  4622. .DynamicWall || entityType === DrawTools.DrawType.TextWall) {
  4623. /* 位置属性变更 */
  4624. _self._editEntity.wall.positions = new Cesium.CallbackProperty(function() {
  4625. return _self._sketchEditPoints;
  4626. }, false);
  4627. /* 高度属性变更 */
  4628. _self._editEntity.wall.minimumHeights = new Cesium.CallbackProperty(function() {
  4629. return _self._sketchWallHeights;
  4630. }, false);
  4631. _self._editEntity.wall.maximumHeights = new Cesium.CallbackProperty(function() {
  4632. return _self._sketchWallMaxHeights;
  4633. }, false);
  4634. }
  4635. },
  4636. /**
  4637. * 创建编辑点
  4638. * @ignore 生成方法时不对外公开
  4639. * @param {JSON} options 配置项
  4640. * @param {Cesium.Cartesian3} options.position 位置<必须填写>
  4641. * @param {Array<Number>} options.color [颜色] 可选
  4642. * @param {Number} options.size [大小] 可选
  4643. * @param {Number} options.outlineWidth [边框大小] 可选
  4644. * @param {Array<Number>} options.outlineColor [边框颜色] 可选
  4645. * @param {DrawTools.EditPointType} options.editType 编辑点类型<必须填写>
  4646. * @param {String} options.name [实体的名称] 可选
  4647. */
  4648. _createEditPointEntity(options) {
  4649. let _self = this;
  4650. if (options === undefined || options.position === undefined) return;
  4651. if (options === undefined || options.editType === undefined) return;
  4652. /* 初始化参数 */
  4653. let color = options.color != undefined ? options.color : [255, 0, 0, 1.0];
  4654. let size = options.size != undefined && typeof options.size === 'number' ? options.size : 9;
  4655. let outlineWidth = options.outlineWidth != undefined && typeof options.outlineWidth === 'number' ?
  4656. options.outlineWidth : 1;
  4657. let outlineColor = options.outlineColor != undefined ? options.outlineColor : [255, 255, 255, 1.0];
  4658. /* 创建编辑点 */
  4659. let pointEntity = new Cesium.Entity({
  4660. name: options.name != undefined ? options.name : _self._sketchEntityName,
  4661. position: options.position,
  4662. point: {
  4663. show: true,
  4664. pixelSize: size,
  4665. heightReference: Cesium.HeightReference.NONE,
  4666. color: _self._toColorFromArray(color),
  4667. outlineWidth: outlineWidth,
  4668. outlineColor: _self._toColorFromArray(outlineColor),
  4669. disableDepthTestDistance: 1.5e12, //小于该数值后关闭深度检测默认为空
  4670. // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  4671. },
  4672. })
  4673. /* 设置编辑实体类型 */
  4674. pointEntity.setEditType(options.editType);
  4675. /* 追加到集合中 */
  4676. _self._entities.add(pointEntity);
  4677. },
  4678. /**
  4679. * 创建可编辑的节点
  4680. * @ignore 生成方法时不对外公开
  4681. * @param {Array<Cesium.Cartesian3>} positions 坐标集合
  4682. * @param {Number} startIndex [开始索引] 可选 默认为0
  4683. */
  4684. _createEditNodePoint(positions, startIndex) {
  4685. this._sketchEditEntityNodeName = "SketchEditEntityNode";
  4686. let _self = this;
  4687. /* 创建节点 */
  4688. this._sketchEditPoints = [];
  4689. /* 判断开始创建索引 */
  4690. let strIndex = startIndex === undefined ? 0 : startIndex;
  4691. for (let i = 0; i < positions.length; i++) {
  4692. /* 获取当前点 */
  4693. let position = positions[i];
  4694. /* 存储可编辑点 */
  4695. this._sketchEditPoints.push(position.clone());
  4696. /* 小于索引不会创建 */
  4697. if (i < strIndex) continue;
  4698. /* 为了保证不重复创建节点 需要进行特殊过滤处理 */
  4699. if (i !== 0 && position.x === positions[0].x && position.y === positions[0].y && position.z ===
  4700. positions[0]
  4701. .z) {
  4702. continue;
  4703. }
  4704. /* 创建节点前 特殊处理一下 以保证创建的节点 高度是正确的 */
  4705. let geoPoint = this._cartesian3ToGeo(position);
  4706. /* 查询高度 */
  4707. let height = this._queryHeightFromGeo(geoPoint.longitude, geoPoint.latitude);
  4708. /* 创建新位置 */
  4709. let newPosition = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, height);
  4710. /* 创建实体 */
  4711. _self._createEditPointEntity({
  4712. name: _self._sketchEditEntityNodeName,
  4713. position: newPosition,
  4714. size: 12,
  4715. color: [0, 0, 255, 1.0],
  4716. editType: {
  4717. type: DrawTools.EditPointType.Node,
  4718. index: i,
  4719. },
  4720. });
  4721. }
  4722. },
  4723. /**
  4724. * 创建可编辑的空中点
  4725. * @ignore 生成方法时不对外公开
  4726. * @param {Array<Cesium.Cartesian3>} positions 底部坐标集合
  4727. * @param {Array<Number>} heights 高度集合
  4728. * @param {Number} startIndex [开始索引] 可选 默认为0
  4729. */
  4730. _createEditSpatialPoint(positions, heights, startIndex) {
  4731. /* 暂时不创建高空点 */
  4732. return;
  4733. if (positions === undefined || heights === undefined) return;
  4734. if (positions.length === undefined || heights.length === undefined) return;
  4735. if (heights.length < positions.length) return;
  4736. this._sketchEditEntitySpatialName = "SketchEditEntitySpatial";
  4737. let _self = this;
  4738. /* 判断开始创建索引 */
  4739. let strIndex = startIndex === undefined ? 0 : startIndex;
  4740. for (let i = 0; i < positions.length; i++) {
  4741. /* 获取当前点 */
  4742. let p = positions[i];
  4743. /* 当前点转换为经纬度 */
  4744. let geoPoint = this._cartesian3ToGeo(p);
  4745. /* 重新获取新的空间位置 */
  4746. let position = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, heights[i]);
  4747. /* 小于索引不会创建 */
  4748. if (i < strIndex) continue;
  4749. /* 创建实体 */
  4750. this._createEditPointEntity({
  4751. name: _self._sketchEditEntitySpatialName,
  4752. position: position,
  4753. size: 12,
  4754. color: [255, 0, 0, 1.0],
  4755. editType: {
  4756. type: DrawTools.EditPointType.Spatial,
  4757. index: i,
  4758. },
  4759. });
  4760. }
  4761. },
  4762. /**
  4763. * 创建可编辑的中点
  4764. * @ignore 生成方法时不对外公开
  4765. * @param {Array<Cesium.Cartesian3>} positions 坐标集合
  4766. * @param {Boolean} isSpatial 是否是空中点
  4767. */
  4768. _createEditMiddlePoint(positions, isSpatial = false) {
  4769. this._sketchEditEntityMiddleName = "SketchEditEntityMiddle";
  4770. let _self = this;
  4771. if (!isSpatial) {
  4772. /* 创建中点 */
  4773. for (let i = 1; i < positions.length; i++) {
  4774. let p1 = positions[i - 1];
  4775. let p2 = positions[i];
  4776. /* 计算中点 */
  4777. let pCenter = this._calculateMiddlePoint(p1, p2);
  4778. /* 创建中点实体 */
  4779. this._createEditPointEntity({
  4780. name: _self._sketchEditEntityMiddleName,
  4781. position: pCenter,
  4782. size: 9,
  4783. color: [255, 255, 0, 1.0],
  4784. editType: {
  4785. type: DrawTools.EditPointType.Middle,
  4786. index: i
  4787. },
  4788. });
  4789. }
  4790. } else {
  4791. /* 创建中点 */
  4792. for (let i = 1; i < positions.length; i++) {
  4793. let p1 = positions[i - 1];
  4794. let p2 = positions[i];
  4795. /* 计算中点 */
  4796. let pCenter = {
  4797. x: (p1.x + p2.x) / 2,
  4798. y: (p1.y + p2.y) / 2,
  4799. z: (p1.z + p2.z) / 2,
  4800. };
  4801. /* 创建中点实体 */
  4802. this._createEditPointEntity({
  4803. name: _self._sketchEditEntityMiddleName,
  4804. position: pCenter,
  4805. size: 9,
  4806. color: [255, 255, 0, 1.0],
  4807. editType: {
  4808. type: DrawTools.EditPointType.Middle,
  4809. index: i
  4810. },
  4811. });
  4812. }
  4813. }
  4814. },
  4815. /**
  4816. * 创建可编辑的中心点
  4817. * @ignore 生成方法时不对外公开
  4818. * @param {Cesium.Cartesian3} position 坐标
  4819. */
  4820. _createEditCenterPoint(position) {
  4821. let _self = this;
  4822. this._sketchEditEntityCenterName = "SketchEditEntityCenter";
  4823. /* 创建实体 */
  4824. this._createEditPointEntity({
  4825. name: _self._sketchEditEntityCenterName,
  4826. position: position,
  4827. size: 12,
  4828. color: [0, 255, 0, 0.1],
  4829. outlineWidth: 2.0,
  4830. outlineColor: [255, 255, 255, 1.0],
  4831. editType: {
  4832. type: DrawTools.EditPointType.Center,
  4833. },
  4834. });
  4835. /* 创建中心点的同时将中心点付给当前的编辑实体 */
  4836. if (this._editEntity != undefined) {
  4837. this._editEntity.position = position.clone();
  4838. }
  4839. },
  4840. /**
  4841. * 创建可编辑的OD线编辑终点
  4842. * @ignore 生成方法时不对外公开
  4843. * @param {Cesium.Cartesian3} position 坐标
  4844. * @param {Cesium.Entity} joinEntity 关联的实体
  4845. */
  4846. _createEditOdlineEndPoint(position, joinEntity) {
  4847. this._sketchEditEntityNodeName = "SketchEditEntityNode";
  4848. let _self = this;
  4849. /* 创建节点前 特殊处理一下 以保证创建的节点 高度是正确的 */
  4850. let geoPoint = this._cartesian3ToGeo(position);
  4851. /* 查询高度 */
  4852. let height = this._queryHeightFromGeo(geoPoint.longitude, geoPoint.latitude);
  4853. /* 创建新位置 */
  4854. let newPosition = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, height);
  4855. /* 创建实体 */
  4856. _self._createEditPointEntity({
  4857. name: _self._sketchEditEntityNodeName,
  4858. position: position,
  4859. size: 12,
  4860. color: [0, 0, 255, 1.0],
  4861. editType: {
  4862. type: DrawTools.EditPointType.OdlineEndNode,
  4863. joinEntity: joinEntity,
  4864. },
  4865. });
  4866. },
  4867. /**
  4868. * 创建可编辑的OD线编辑起点
  4869. * @ignore 生成方法时不对外公开
  4870. * @param {Cesium.Cartesian3} position 坐标
  4871. * @param {Cesium.Entity} joinEntity 关联的实体
  4872. */
  4873. _createEditOdlineStartPoint(position, joinEntity) {
  4874. this._sketchEditEntityNodeName = "SketchEditEntityNode";
  4875. let _self = this;
  4876. /* 创建节点前 特殊处理一下 以保证创建的节点 高度是正确的 */
  4877. let geoPoint = this._cartesian3ToGeo(position);
  4878. /* 查询高度 */
  4879. let height = this._queryHeightFromGeo(geoPoint.longitude, geoPoint.latitude);
  4880. /* 创建新位置 */
  4881. let newPosition = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, height);
  4882. /* 创建实体 */
  4883. _self._createEditPointEntity({
  4884. name: _self._sketchEditEntityNodeName,
  4885. position: position,
  4886. size: 12,
  4887. color: [0, 255, 0, 0.6],
  4888. editType: {
  4889. type: DrawTools.EditPointType.OdlineStrartNode,
  4890. joinEntity: joinEntity,
  4891. },
  4892. });
  4893. },
  4894. /**
  4895. * 计算两个点的中点坐标
  4896. * @ignore 生成方法时不对外公开
  4897. * @param {Cesium.Cartesian3} position1 第一点
  4898. * @param {Cesium.Cartesian3} position2 第二点
  4899. */
  4900. _calculateMiddlePoint(position1, position2) {
  4901. /* 计算经纬度坐标 */
  4902. let g1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position1);
  4903. let g2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position2);
  4904. /* 转换为度格式 */
  4905. let pt1 = [Cesium.Math.toDegrees(g1.longitude), Cesium.Math.toDegrees(g1.latitude)];
  4906. let pt2 = [Cesium.Math.toDegrees(g2.longitude), Cesium.Math.toDegrees(g2.latitude)];
  4907. /* 计算中间点 */
  4908. let tpt1 = turf.point(pt1);
  4909. let tpt2 = turf.point(pt2);
  4910. let midpoint = turf.midpoint(tpt1, tpt2).geometry.coordinates;
  4911. /* 查询高度 */
  4912. let height = this._queryHeightFromGeo(midpoint[0], midpoint[1]);
  4913. /* 转换为世界坐标 */
  4914. let result = Cesium.Cartesian3.fromDegrees(midpoint[0], midpoint[1], height);
  4915. return result;
  4916. },
  4917. /**
  4918. * 世界坐标转换为经纬度坐标
  4919. * @ignore 生成方法时不对外公开
  4920. * @param {Cesium.Cartesian3} position 点
  4921. */
  4922. _cartesian3ToGeo: function(position) {
  4923. let g = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
  4924. return {
  4925. longitude: Cesium.Math.toDegrees(g.longitude),
  4926. latitude: Cesium.Math.toDegrees(g.latitude),
  4927. height: g.height,
  4928. }
  4929. },
  4930. /**
  4931. * 查询指定经纬度位置的高度 有地形则查地形 有模型则查模型 查询错误或未查询到,返回0
  4932. * @ignore 生成方法时不对外公开
  4933. * @param {Number} longitude 经度<度格式>
  4934. * @param {Number} latitude 纬度<度格式>
  4935. * @return {Number} 查询位置的高度值
  4936. */
  4937. _queryHeightFromGeo: function(longitude, latitude) {
  4938. if (longitude === undefined || latitude === undefined || typeof longitude != 'number' ||
  4939. typeof latitude != 'number') return 0;
  4940. let rLng = Cesium.Math.toRadians(longitude);
  4941. let rLat = Cesium.Math.toRadians(latitude);
  4942. let cartographic = new Cesium.Cartographic(rLng, rLat);
  4943. /* 获取不采样的实体数组 */
  4944. let noQueryEntities = [];
  4945. for (let i = 0; i < this._entities.values.length; i++) {
  4946. if (this._entities.values[i].name === this._sketchEntityName) {
  4947. noQueryEntities.push(this._entities.values[i]);
  4948. }
  4949. }
  4950. let height = this._viewer.scene.sampleHeight(cartographic, noQueryEntities);
  4951. if (height === undefined) return 0
  4952. else return height;
  4953. },
  4954. /**
  4955. * 查询指定经纬度位置的高度 有地形则查地形 有模型则查模型 查询错误或未查询到,返回0
  4956. * @ignore 生成方法时不对外公开
  4957. * @param {Number} longitude 经度<度格式>
  4958. * @param {Number} latitude 纬度<度格式>
  4959. * @param {Function} callComplete 查询回调函数callComplete(Number) 查询错误时为undefined
  4960. */
  4961. _queryHeightFromGeoAsync: function(longitude, latitude, callComplete) {
  4962. if (longitude === undefined || latitude === undefined || typeof longitude != 'number' ||
  4963. typeof latitude != 'number') return 0;
  4964. let rLng = Cesium.Math.toRadians(longitude);
  4965. let rLat = Cesium.Math.toRadians(latitude);
  4966. let cartographic = new Cesium.Cartographic(rLng, rLat);
  4967. let promise = this._viewer.scene.sampleHeightMostDetailed([cartographic]);
  4968. promise.then(function(updatedPositions) {
  4969. if (callComplete) callComplete(updatedPositions[0].height);
  4970. })
  4971. },
  4972. /**
  4973. * 清理编辑点
  4974. * @ignore 生成方法时不对外公开
  4975. */
  4976. _clearEditPoint: function() {
  4977. /* 清理事件句柄 */
  4978. if (this._sketchEditHandler != undefined) {
  4979. this._sketchEditHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOWN);
  4980. this._sketchEditHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP);
  4981. this._sketchEditHandler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
  4982. }
  4983. /* 处理理编辑点数据 */
  4984. this._sketchEditPoints = [];
  4985. this._sketchEditIndex = undefined;
  4986. this._editEntity = undefined;
  4987. this._removeEntityByName(this._sketchEditEntityNodeName);
  4988. this._removeEntityByName(this._sketchEditEntityMiddleName);
  4989. this._removeEntityByName(this._sketchEditEntityCenterName);
  4990. this._removeEntityByName(this._sketchEditEntitySpatialName);
  4991. },
  4992. })
  4993. /* 编辑函数相关 */
  4994. Object.assign(DrawTools.prototype, {
  4995. /**
  4996. * 检查颜色值
  4997. * @ignore 生成方法时不对外公开
  4998. * @param {Number} color 颜色值[0~255]
  4999. * @return {Boolean} 是否满足颜色值要求
  5000. */
  5001. _checkColor: function(color) {
  5002. if (color === undefined || color === null) return false;
  5003. if (typeof color != 'number') return false;
  5004. let intColor = parseInt(color);
  5005. if (intColor < 0 || intColor > 255) return false;
  5006. return true;
  5007. },
  5008. /**
  5009. * 检查透明度是否符合要求
  5010. * @ignore 生成方法时不对外公开
  5011. * @param {Object} alpha 透明度[0~1]
  5012. */
  5013. _checkAlpha: function(alpha) {
  5014. if (alpha === undefined || alpha === null) return false;
  5015. if (typeof alpha != 'number') return false;
  5016. let floatAlpha = parseFloat(alpha);
  5017. if (floatAlpha < 0 || floatAlpha > 1) return false;
  5018. return true;
  5019. },
  5020. /**
  5021. * 颜色和透明度检测
  5022. * @ignore 生成方法时不对外公开
  5023. * @param {Array<Number>} colorAndAlpah 颜���和透明度
  5024. * @return {Array<Number>} [0~255,0~255,0~255,0~1] 如果异常 则�����回undefined
  5025. */
  5026. _checkColorAndAlpha: function(colorAndAlpah) {
  5027. let setColor = undefined;
  5028. if (!colorAndAlpah || colorAndAlpah.length === undefined || colorAndAlpah.length === 0)
  5029. return undefined;
  5030. if (colorAndAlpah.length === 1 && this._checkColor(colorAndAlpah[0])) {
  5031. setColor = [colorAndAlpah[0], 0, 0, 1.0];
  5032. } else if (colorAndAlpah.length === 2 && this._checkColor(colorAndAlpah[0]) && this._checkColor(
  5033. colorAndAlpah[1])) {
  5034. setColor = [colorAndAlpah[0], colorAndAlpah[1], 0, 1.0];
  5035. } else if (colorAndAlpah.length === 3 && this._checkColor(colorAndAlpah[0]) && this._checkColor(
  5036. colorAndAlpah[1]) && this._checkColor(colorAndAlpah[2])) {
  5037. setColor = [colorAndAlpah[0], colorAndAlpah[1], colorAndAlpah[2], 1.0];
  5038. } else if (colorAndAlpah.length === 4 && this._checkColor(colorAndAlpah[0]) && this._checkColor(
  5039. colorAndAlpah[1]) && this._checkColor(colorAndAlpah[2]) && this._checkAlpha(
  5040. colorAndAlpah[
  5041. 3])) {
  5042. setColor = [colorAndAlpah[0], colorAndAlpah[1], colorAndAlpah[2], colorAndAlpah[3]];
  5043. }
  5044. return setColor;
  5045. },
  5046. });
  5047. /**
  5048. * 操作容器及按钮相关 主要为了适应App操作
  5049. */
  5050. Object.assign(DrawTools.prototype, {
  5051. /**
  5052. * 初始化操作容器
  5053. * @ignore
  5054. */
  5055. _initOperationDom: function() {
  5056. let _self = this;
  5057. this._operationDomId = 'drawButtonDiv'
  5058. this._operationDom = document.getElementById(this._operationDomId);
  5059. /* 移除主容器 */
  5060. this._removeOperationDom()
  5061. /* 创建主容器 */
  5062. this._createOperationMainDom()
  5063. if ([DrawTools.DrawType.Rectangle, DrawTools.DrawType.Circle, DrawTools.DrawType.DynamicCircle,
  5064. DrawTools.DrawType.VideoWall
  5065. ].indexOf(this._drawType) === -1) {
  5066. /* 创建回退按钮 */
  5067. let btnUndo = this._createOperationUndoButtonDom();
  5068. /* 挂接事件 */
  5069. btnUndo.onclick = function() {
  5070. _self._operationExecuteEvent(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  5071. }
  5072. }
  5073. if ([DrawTools.DrawType.Rectangle, DrawTools.DrawType.Circle, DrawTools.DrawType.DynamicCircle,
  5074. DrawTools.DrawType.VideoWall
  5075. ] === -1) {
  5076. /* 创建完成按钮 */
  5077. let btnCompletion = this._crateOperationCompletionButtonDom();
  5078. /* 挂接事件 */
  5079. btnCompletion.onclick = function() {
  5080. _self._operationExecuteEvent(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  5081. }
  5082. } else {
  5083. /* 创建完成按钮 */
  5084. let btnCompletion = this._crateOperationCompletionButtonDom();
  5085. /* 挂接事件 */
  5086. btnCompletion.onclick = function() {
  5087. _self._operationExecuteEvent(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
  5088. }
  5089. }
  5090. },
  5091. /**
  5092. * 执行事件
  5093. * @ignore
  5094. * @param {Cesium.ScreenSpaceEventType} eventType 事件类型
  5095. */
  5096. _operationExecuteEvent(eventType) {
  5097. if (this._drawEventHandler !== undefined && this._drawEventHandler.isDestroyed() ===
  5098. false) {
  5099. let event = {
  5100. position: new Cesium.Cartesian2(300, 300),
  5101. }
  5102. let action = this._drawEventHandler.getInputAction(eventType);
  5103. action(event);
  5104. }
  5105. },
  5106. /**
  5107. * @ignore
  5108. * 创建操作的主容器
  5109. */
  5110. _createOperationMainDom: function() {
  5111. this._operationDom = document.createElement('div');
  5112. this._operationDom.id = this._operationDomId;
  5113. this._operationDom.style.width = '80px';
  5114. this._operationDom.style.backgroundColor = 'rgba(5, 45, 155, 0.7)';
  5115. this._operationDom.style.borderRadius = '5px';
  5116. this._operationDom.style.display = 'flex';
  5117. this._operationDom.style.flexDirection = 'column';
  5118. this._operationDom.style.padding = '8px';
  5119. this._operationDom.style.justifyContent = 'center';
  5120. this._operationDom.style.position = 'absolute';
  5121. this._operationDom.style.bottom = '150px';
  5122. this._operationDom.style.right = '10px';
  5123. document.body.appendChild(this._operationDom);
  5124. },
  5125. /**
  5126. * 创建回退按钮 并返回示例
  5127. * @ignore
  5128. * @return {Element}
  5129. */
  5130. _createOperationUndoButtonDom: function() {
  5131. let btnUndo = document.createElement('button');
  5132. btnUndo.id = "btnDrawBackout";
  5133. btnUndo.style.height = '30px';
  5134. btnUndo.style.marginBottom = '8px';
  5135. btnUndo.style.backgroundColor = 'rgba(52, 137, 255, 1.0)';
  5136. btnUndo.style.color = 'rgb(255, 255, 255)';
  5137. btnUndo.style.border = '0px solid red';
  5138. btnUndo.style.borderRadius = '5px';
  5139. btnUndo.innerHTML = '回退';
  5140. btnUndo.style.fontSize = '13px';
  5141. btnUndo.style.cursor = 'pointer';
  5142. this._operationDom.appendChild(btnUndo);
  5143. return btnUndo;
  5144. },
  5145. /**
  5146. * 创建完成按钮
  5147. * @ignore
  5148. * @return {Element}
  5149. */
  5150. _crateOperationCompletionButtonDom: function() {
  5151. let btnCompletion = document.createElement('button');
  5152. btnCompletion.id = "btnDrawComplete";
  5153. btnCompletion.style.height = '30px';
  5154. btnCompletion.style.backgroundColor = 'rgba(88, 185, 45, 1.0)';
  5155. btnCompletion.style.color = 'rgb(255, 255, 255)';
  5156. btnCompletion.style.border = '0px solid red';
  5157. btnCompletion.style.borderRadius = '5px';
  5158. btnCompletion.innerHTML = '完成';
  5159. btnCompletion.style.fontSize = '13px';
  5160. btnCompletion.style.cursor = 'pointer';
  5161. this._operationDom.appendChild(btnCompletion);
  5162. return btnCompletion;
  5163. },
  5164. /**
  5165. * 移除操作容器
  5166. * @ignore
  5167. */
  5168. _removeOperationDom: function() {
  5169. if (this._operationDom !== null && this._operationDom !== undefined) {
  5170. document.body.removeChild(this._operationDom);
  5171. this._operationDom = undefined;
  5172. }
  5173. },
  5174. /**
  5175. * 添加操作容器
  5176. * @ignore
  5177. */
  5178. _createOperationDom: function() {
  5179. if (this._isRuntimeApp()) {
  5180. this._initOperationDom();
  5181. }
  5182. }
  5183. })
  5184. /**
  5185. * 属性编辑相关(UI)
  5186. */
  5187. Object.assign(DrawTools.prototype, {
  5188. /**
  5189. * 打开属性编辑窗口
  5190. * @ignore
  5191. * @param {JSON} params 参数
  5192. * @param {Function} callEdit 编辑回调
  5193. * @param {Function} callRemove 移除回调
  5194. */
  5195. _openPropertyEditDialog: function(params, callEdit, callRemove) {
  5196. this._editPropertyDialogDomId = 'dialog-property-dom';
  5197. this._registerDOMPropertyEdit = 'dialog-edit-property'
  5198. /* 获取一个属性编辑组件 */
  5199. let PropertyEditComponent = customElements.get(this._registerDOMPropertyEdit);
  5200. /* 如果组件还未注册 则进行注册 否则不在注册 避免重复注册的BUG */
  5201. if (PropertyEditComponent === undefined) {
  5202. PropertyEditComponent = defineCustomElement(DialogEditProperty);
  5203. customElements.define(this._registerDOMPropertyEdit, PropertyEditComponent);
  5204. }
  5205. /* 先关闭编辑框 */
  5206. this._closePropertyEditDialog();
  5207. /* 创建组件 */
  5208. let dialogPropertyElement = new PropertyEditComponent({
  5209. params: params,
  5210. })
  5211. dialogPropertyElement.id = this._editPropertyDialogDomId;
  5212. dialogPropertyElement.showDialog = true;
  5213. document.body.appendChild(dialogPropertyElement);
  5214. /* 监听修改事件 */
  5215. dialogPropertyElement.addEventListener(
  5216. "submit",
  5217. (e) => {
  5218. if (callEdit) callEdit(e.detail[0]);
  5219. },
  5220. false
  5221. );
  5222. /* 监听移除事件 */
  5223. dialogPropertyElement.addEventListener(
  5224. "remove",
  5225. (e) => {
  5226. if (callRemove) callRemove();
  5227. },
  5228. false
  5229. );
  5230. },
  5231. /**
  5232. * 关闭属性编辑框
  5233. * @ignore
  5234. */
  5235. _closePropertyEditDialog() {
  5236. let dom = document.getElementById(this._editPropertyDialogDomId);
  5237. if (dom !== null && dom !== undefined) {
  5238. document.body.removeChild(dom);
  5239. }
  5240. }
  5241. })
  5242. /**
  5243. * 绘制类型
  5244. */
  5245. DrawTools.DrawType = Object.freeze({
  5246. Point: 'point',
  5247. Polyline: 'polyline', //贴地线
  5248. ArrowPolyline: 'arrowPolyline', //箭头线
  5249. DynamicPolyline: 'dynamicPolyline', //流动线
  5250. GrowPolyline: '发光线',
  5251. OutlinePolyline: 'outlinePolyline', //描边线
  5252. OdLine: 'odLine', //OD线
  5253. Polygon: 'polygon', //贴地面
  5254. SpatialLine: 'spatialLine', //空间线
  5255. Circle: 'circle', //普通圆
  5256. DynamicCircle: 'dynamicCircle', //动态圆
  5257. Rectangle: 'rectangle', //矩形
  5258. NormalWall: 'normalWall', //普通墙
  5259. DynamicWall: 'dynamicWall', //动态墙
  5260. House: 'house', //房屋
  5261. TextWall: 'text', //文字
  5262. VideoWall: 'videoWall', //视频墙
  5263. })
  5264. /**
  5265. * 点图标类型
  5266. */
  5267. DrawTools.IconType = Object.freeze({
  5268. Normal: 'normal',
  5269. Blue: 'blue',
  5270. Green: 'green',
  5271. Violet: 'violter',
  5272. })
  5273. /**
  5274. * 编辑点类型
  5275. */
  5276. DrawTools.EditPointType = Object.freeze({
  5277. Node: 'node', //节点
  5278. Middle: 'middle', //中间点
  5279. Center: 'center', //中心点
  5280. CoordinateAxis: 'coordinateAxis', //坐标轴
  5281. OdlineStrartNode: 'odlineStartNode', //OD线起始点
  5282. OdlineEndNode: 'odlineEndNode', //OD线终点
  5283. })
  5284. /**
  5285. * 绘制墙的类型
  5286. */
  5287. DrawTools.WallType = Object.freeze({
  5288. ColorWall: 'colorWall', //颜色墙
  5289. DynamicWall: 'dynamicWall', //动态墙
  5290. TextWall: 'textWall', //文字墙
  5291. })
  5292. /**
  5293. * 绘制圆类型
  5294. */
  5295. DrawTools.CircleType = Object.freeze({
  5296. ColorCircle: 'colorCircle', //颜色圆
  5297. DynamicCircle: 'dynamicCircle', //动态圆
  5298. })
  5299. /**
  5300. * 绘制线类型
  5301. */
  5302. DrawTools.PolylineType = Object.freeze({
  5303. NormalPolyline: 'normalPolyline', //普通线
  5304. ArrowsPolyline: 'arrowsPolyline', //箭头线
  5305. DynamicPolyline: 'dynamicPolyline', //流动线
  5306. DottedPolyline: 'dottedPolyline', //虚线
  5307. GrowPolyline: 'growPolyline', //发光线
  5308. OutlinePolyline: 'outlinePolyline', //描边线
  5309. })
  5310. /**
  5311. * 绘制面类型
  5312. */
  5313. DrawTools.PolygonType = Object.freeze({
  5314. NormalPolygon: 'normalPolygon', //贴地面
  5315. HousePolygon: 'housePolygon', //拉伸贴地面
  5316. })
  5317. /**
  5318. * 运行环境类型
  5319. */
  5320. DrawTools.RuntimeEnvironment = Object.freeze(({
  5321. App: 'app',
  5322. Web: 'web'
  5323. }))
  5324. class WallMaterialProperty {
  5325. /**
  5326. * 构造方法
  5327. * @ignore 无需公开
  5328. * @param {JSON} options 配置项
  5329. * @param {Cesium.Viewer} options.viewer 着色器运行所需的视图
  5330. * @param {Cesium.Color} options.color [墙的颜色,默认蓝色] 可选
  5331. * @param {Number} options.duration [循环时间 默认1000] 可选
  5332. * @param {String} options.trailImage 墙的贴图
  5333. * @param {JSON} options.param 着色器参数
  5334. * @param {Number} options.param.count [数量 可选 默认为1]
  5335. * @param {String} options.param.direction [方向 可选 默认竖直 ] 取值vertical/horizontal
  5336. * @param {String} options.param.order [顺序 可选 上下/下上/顺时针/逆时针 与方向配合使用 ] 取值+/-
  5337. */
  5338. constructor(options) {
  5339. /* 着色器运行依赖的视图 */
  5340. this._viewer = options.viewer;
  5341. /* 变更事件 */
  5342. this._definitionChanged = new Cesium.Event();
  5343. this._color = undefined;
  5344. /* 墙的颜色 */
  5345. this.color = options.color || Cesium.Color.BLUE;
  5346. /* 动态循环周期 */
  5347. this.duration = options.duration || 1000;
  5348. /* 墙的贴图 */
  5349. this.trailImage = options.trailImage;
  5350. /* 默认时间 */
  5351. this._time = (new Date()).getTime();
  5352. /* 材质类型名称 */
  5353. this._materialTypeName = 'WallMaterial' + this._guid();
  5354. /* 存储相关参数的属性 以便后期进行追踪修改 */
  5355. this._param = {
  5356. color: this.color._value.toCssColorString(),
  5357. image: this.trailImage,
  5358. duration: this.duration,
  5359. count: 0,
  5360. direction: '',
  5361. order: '',
  5362. }
  5363. /* 将材质加入缓存 以便重复利用 */
  5364. Cesium.Material._materialCache.addMaterial(this._materialTypeName, {
  5365. fabric: {
  5366. type: this._materialTypeName,
  5367. uniforms: {
  5368. time: -20,
  5369. color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
  5370. image: options.trailImage,
  5371. },
  5372. source: this._getDirectionWallShader(options.param)
  5373. },
  5374. translucent: function(material) {
  5375. /* 材质是否半透明 */
  5376. return true;
  5377. }
  5378. });
  5379. }
  5380. /**
  5381. * 生成GUID随机数
  5382. * @ignore 无需公开
  5383. */
  5384. _guid() {
  5385. function S4() {
  5386. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  5387. }
  5388. return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
  5389. }
  5390. /**
  5391. * 重新获取类型方法
  5392. * @ignore 无需公开
  5393. * @param {Cesium.JulianDate} time 时间
  5394. */
  5395. getType(time) {
  5396. return this._materialTypeName;
  5397. }
  5398. /**
  5399. * 重写获取值方法
  5400. * @ignore 无需公开
  5401. * @param {Cesium.JulianDate} time
  5402. * @param {JSON} result
  5403. */
  5404. getValue(time, result) {
  5405. if (!Cesium.defined(result)) {
  5406. result = {};
  5407. }
  5408. result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.BLUE, result.color);
  5409. result.image = this.trailImage;
  5410. if (this.duration) {
  5411. result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
  5412. }
  5413. this._viewer.scene.requestRender();
  5414. return result;
  5415. }
  5416. /**
  5417. * 重写对比函数
  5418. * @ignore 无需公开
  5419. * @param {Object} other 传入对比对象
  5420. */
  5421. equals(other) {
  5422. return (this === other || (other instanceof WallMaterialProperty && Cesium.Property.equals(this
  5423. ._color, other._color) && other._param.order === this._param.order && other._param.count ===
  5424. this._param.count && other._param.direction === this._param.direction && other.duration === this
  5425. .duration));
  5426. }
  5427. /**
  5428. * 创建着色器资源
  5429. * @ignore 无需公开
  5430. * @param {JSON} options 配置项
  5431. * @param {Number} options.count [数量 可选 默认为1]
  5432. * @param {String} options.direction [方向 可选 默认竖直 ] 取值vertical/horizontal
  5433. * @param {String} options.order [顺序 可选 上下/下上/顺时针/逆时针 与方向配合使用 ] 取值+/-
  5434. */
  5435. _getDirectionWallShader(options) {
  5436. let op = Cesium.defaultValue(options, {});
  5437. // console.log('>>>op===', op);
  5438. let count = op.count !== undefined && typeof op.count === 'number' && op.count > 0 ? op
  5439. .count : 1;
  5440. let direction = op.direction === 'horizontal' ? 'horizontal' : 'vertical';
  5441. let order = op.order === '+' ? '+' : '-';
  5442. this._param.count = count;
  5443. this._param.direction = direction;
  5444. this._param.order = order;
  5445. let materail = '';
  5446. /* 补充参数 */
  5447. // console.log(this._param);
  5448. materail += 'czm_material czm_getMaterial(czm_materialInput materialInput){\n' +
  5449. ' czm_material material = czm_getDefaultMaterial(materialInput);\n' +
  5450. ' vec2 st = materialInput.st;\n';
  5451. if (direction === 'vertical') {
  5452. materail += ' vec4 colorImage = texture2D(image,vec2(st.s,fract(float(' + count + ')*st.t ' + order +
  5453. ' time)));\n';
  5454. } else if (direction === 'horizontal') {
  5455. materail += ' vec4 colorImage = texture2D(image, vec2(fract(float(' + count + ')*st.s ' + order +
  5456. ' time), st.t));\n'
  5457. }
  5458. materail += ' vec4 fragColor;\n' +
  5459. ' fragColor.rgb = color.rgb / 1.0;\n' +
  5460. ' fragColor = czm_gammaCorrect(fragColor);\n' +
  5461. ' material.alpha = colorImage.a * color.a;\n' +
  5462. ' material.diffuse = color.rgb;\n' +
  5463. ' material.emission = fragColor.rgb;\n' +
  5464. ' return material;\n' +
  5465. '}';
  5466. return materail;
  5467. }
  5468. }
  5469. /**
  5470. * 增加默认属性
  5471. */
  5472. Object.defineProperties(WallMaterialProperty.prototype, {
  5473. /**
  5474. * @ignore 无需公开
  5475. * 判断是否相等,返回false表示属性一直在变化中
  5476. */
  5477. isConstant: {
  5478. get: function() {
  5479. return false;
  5480. }
  5481. },
  5482. /**
  5483. * @ignore 无需公开
  5484. * 事件变更
  5485. */
  5486. definitionChanged: {
  5487. get: function() {
  5488. return this._definitionChanged;
  5489. }
  5490. },
  5491. /* 颜色属性 */
  5492. color: Cesium.createPropertyDescriptor('color')
  5493. })
  5494. /**
  5495. * 创建者:王成
  5496. * 操作系统:MAC
  5497. * 创建日期:2022年12月29日
  5498. * 描述:动态扩散圆材质
  5499. */
  5500. class CircleMaterialProperty {
  5501. /**
  5502. * 构造方法
  5503. * @ignore 无需公开
  5504. * @param {JSON} options 配置项
  5505. * @param {Cesium.Viewer} options.viewer 着色器运行所需的视图
  5506. * @param {Cesium.Color} options.color [圆环的颜色,默认蓝色] 可选
  5507. * @param {Number} options.duration [循环时间 默认1000] 可选
  5508. * @param {Number} options.count [圆环的数量 可选 默认为1]
  5509. */
  5510. constructor(options) {
  5511. /* 着色器运行依赖的视图 */
  5512. this._viewer = options.viewer;
  5513. /* 变更事件 */
  5514. this._definitionChanged = new Cesium.Event();
  5515. this._color = undefined;
  5516. /* 扩算圆环的颜色 */
  5517. this.color = options.color || Cesium.Color.BLUE;
  5518. /* 扩散圆环的数量 */
  5519. this.count = options.count || 1.0;
  5520. /* 动态循环周期 */
  5521. this.duration = options.duration || 1000;
  5522. /* 默认时间 */
  5523. this._time = (new Date()).getTime();
  5524. /* 材质类型名称 */
  5525. this._materialTypeName = 'jtCircleMaterial'
  5526. /* 存储相关参数的属性 以便后期进行追踪修改 */
  5527. this._param = {
  5528. color: this.color._value.toCssColorString(),
  5529. duration: this.duration,
  5530. count: this.count,
  5531. }
  5532. /* 将材质加入缓存 以便重复利用 */
  5533. Cesium.Material._materialCache.addMaterial(this._materialTypeName, {
  5534. fabric: {
  5535. type: this._materialTypeName,
  5536. uniforms: {
  5537. time: 0,
  5538. color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
  5539. count: 1.0,
  5540. },
  5541. source: this._getCircleMaterial(),
  5542. },
  5543. translucent: function(material) {
  5544. /* 材质是否半透明 */
  5545. return true;
  5546. }
  5547. });
  5548. }
  5549. /**
  5550. * @ignore 无需公开
  5551. * 获取材质着色器Shader
  5552. */
  5553. _getCircleMaterial() {
  5554. let circleMaterial = "czm_material czm_getMaterial(czm_materialInput materialInput)\n" +
  5555. "{\n" +
  5556. " czm_material material = czm_getDefaultMaterial(materialInput);\n" +
  5557. " material.diffuse = 1.5 * color.rgb;\n" +
  5558. " vec2 st = materialInput.st;\n" +
  5559. " vec3 str = materialInput.str;\n" +
  5560. " float dis = distance(st, vec2(0.5, 0.5));\n" +
  5561. " float per = fract(time);\n" +
  5562. " if (abs(str.z) > 0.001)\n" +
  5563. " {\n" +
  5564. " //着色器渲染停止,不在绘制内容 \n" +
  5565. " discard;\n" +
  5566. " }\n" +
  5567. " if (dis > 0.5)\n" +
  5568. " {\n" +
  5569. " //超出半径范围时,着色器渲染停止 \n" +
  5570. " discard;\n" +
  5571. " } else {\n" +
  5572. " //把半径分成count份,每两份之间的间隔距离 \n" +
  5573. " float perDis = 0.5 / count;\n" +
  5574. " float disNum;\n" +
  5575. " float bl = 0.0;\n" +
  5576. " //循环,最多999个环 \n" +
  5577. " for (int i = 0; i <= 999; i++)\n" +
  5578. " {\n" +
  5579. " //判断是否属于数量内的环 \n" +
  5580. " if (float(i) <= count)\n" +
  5581. " {\n" +
  5582. " disNum = perDis * float(i) - dis + per / count;\n" +
  5583. " if (disNum > 0.0)\n" +
  5584. " {\n" +
  5585. " if (disNum < perDis)\n" +
  5586. " {\n" +
  5587. " bl = 1.0 - disNum / perDis;\n" +
  5588. " } else if (disNum - perDis < perDis) {\n" +
  5589. " bl = 1.0 - abs(1.0 - disNum / perDis);\n" +
  5590. " }\n" +
  5591. " material.alpha = color.a * pow(bl, 3.0);\n" +
  5592. " }\n" +
  5593. " }\n" +
  5594. " }\n" +
  5595. " }\n" +
  5596. " return material;\n" +
  5597. "}\n";
  5598. return circleMaterial;
  5599. }
  5600. }
  5601. /**
  5602. * @ignore 无需公开
  5603. * 必须重写的方法
  5604. */
  5605. Object.assign(CircleMaterialProperty.prototype, {
  5606. /**
  5607. * 重新获取类型方法
  5608. * @ignore 无需公开
  5609. * @param {Cesium.JulianDate} time 时间
  5610. */
  5611. getType: function(time) {
  5612. return this._materialTypeName;
  5613. },
  5614. /**
  5615. * 重写获取值方法
  5616. * @ignore 无需公开
  5617. * @param {Cesium.JulianDate} time
  5618. * @param {JSON} result
  5619. */
  5620. getValue: function(time, result) {
  5621. if (!Cesium.defined(result)) {
  5622. result = {};
  5623. }
  5624. result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.BLUE, result
  5625. .color);
  5626. result.count = this.count;
  5627. if (this.duration) {
  5628. result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
  5629. }
  5630. this._viewer.scene.requestRender();
  5631. return result;
  5632. },
  5633. /**
  5634. * 重写对比函数
  5635. * @ignore 无需公开
  5636. * @param {Object} other 传入对比对象
  5637. */
  5638. equals: function(other) {
  5639. return (this === other || (other instanceof CircleMaterialProperty && Cesium.Property.equals(this
  5640. ._color, other._color)));
  5641. }
  5642. })
  5643. /**
  5644. * 默认属性
  5645. */
  5646. Object.defineProperties(CircleMaterialProperty.prototype, {
  5647. /**
  5648. * 判断是否相等,返回false表示属性一直在变化中
  5649. * @ignore 无需公开
  5650. */
  5651. isConstant: {
  5652. get: function() {
  5653. return false;
  5654. }
  5655. },
  5656. /**
  5657. * 事件变更
  5658. * @ignore 无需公开
  5659. */
  5660. definitionChanged: {
  5661. get: function() {
  5662. return this._definitionChanged;
  5663. }
  5664. },
  5665. /* 颜色属性 */
  5666. color: Cesium.createPropertyDescriptor('color')
  5667. })
  5668. /* 输出 */
  5669. export {
  5670. DrawTools
  5671. }