DrawTools.js 242 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841
  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(255,0,255,0.8)', //用于颜色标识
  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,0,255,0.8)', //用于标识描边线颜色
  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+fLlUHJOG9vQ0P4EjfyFIdPZGfqsURampIBIlxsWLLBtL/NltF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BIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAAJCmtXYCutDwWwUr9cEAAAAASUVORK5CYII=';
  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/0Icrt5BaAxb14rAwAA4OsUAC/HPxWAk4i0hSmAF/iT8zMAALCvnN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gT81OI+BZfEeHmBGYZvH3gN96X2YAvAegV7uz0usJAFXaTSwhDYDTtQmIlwdhABZS5CAAAQhAAALbELDIW/Rz4G5DkGYgDcDySXIGwL8H0PsYoN8DMEjXPfUf7wBwp3AVS7dZ6DWlEHsBMg1DgAFYSJGDAAQgAAEIbEMgRvf5PoCSSsLzdEDMAOQnkY5PsQQwGwAdA5TY+6d9y+hfSh5vAfzROcQMwDL693WO/qMuH0EKAQhAAAIQgMAWBNZi77xmA8rav4/x39PxeKePlwCGbtrtjmqT7//3C4CaMvq/19GC7zP/FnwMwBb/Wp4BAQhAAAIQeEzAWu3oWfvMW/zzet0zdPu6DNB1r69HqX+e/S9vANQ97joH9Q3hb9vFBPjmLidAAAIQgAAEILAtAeu1Q+r2oDf1W8QVStn601jEFTR7P1bDMJQfA+r860F++Y83DrhT39feFbju17mTQ9ct4p9lma47kIcABCAAAQhA4GsJpFan4M8a7ofe1XFruPcBKHZV256qp6dWbiDE352fnrQb8NYAlG9goc/oAud9MwIEIAABCEAAAn+GgAbt19H+rOG+9sa+m5D67bRtZQBeX09l5H+5LAbAN/hVA+A9AQQIQAACEIAABP4MgU4H+FKzU7/zev2J1gZAmwE7jfaP89T/YgC8gcAhb+BOS4h8HCWo1H9dt7QiBwEIQAACEIDA1xM4n0OzvYwfYVnC/6jjMZO/28kANM1ZsdZvAoSDyMaR5k2iQ36NtSFY57OeFAIQgAAEIACBbQgcDqnVy8DdT36k4/NMQFd9/352s+rt7Z4BWD78Wugf5ZfW5CAAAQhAAAIQ2IJADtz9rEd516V2Xw3A6WQDUFX7fU4d3N6gVN75M9/g5mF3mlEEAQhAAAIQgMAXErAeW/jX4v/ocWkCVK/f+Z2ena7arvOr4muWNf8rCjIQgAAEIACBv47AL+m4TwlcFH/W+K/7dnwgCEAAAhCAAAQ+T+A/hVJn6rP9qnIAAAAASUVORK5CYII=';
  204. /* 存储的点集合 */
  205. this._sketchTempPoints = []; //临时点集合 主要为了存储鼠标移动事件临时存储点
  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. // this._console(this._drawEntity.position);
  1456. // this._console(this._sketchEllipseRadius);
  1457. },
  1458. /**
  1459. * 绘制墙
  1460. * @ignore 生成方法时不对外公开
  1461. * @param {DrawTools.WallType} wallType 墙的类型
  1462. */
  1463. _createWall: function(wallType) {
  1464. let _self = this;
  1465. /* 初始化一个实体参数变量 */
  1466. let entityParam = DrawTools.initEditPropertyParams();
  1467. /* 颜色墙材质 */
  1468. let wallMaterial = this._materialColorProperty({
  1469. color: _self._param.polygonColor,
  1470. });
  1471. /* 设置实体属性 */
  1472. entityParam.color = _self._param.polygonColor;
  1473. if (wallType !== undefined && wallType === DrawTools.WallType.TextWall) {
  1474. wallMaterial = this._materialTextImageProperty({
  1475. color: _self._param.polygonColor,
  1476. text: _self._param.text,
  1477. });
  1478. /* 设置实体属性 */
  1479. entityParam.text = _self._param.text;
  1480. entityParam.color = _self._param.polygonColor;
  1481. } else if (wallType !== undefined && wallType === DrawTools.WallType.DynamicWall) {
  1482. /* 动态墙材质 */
  1483. wallMaterial = new WallMaterialProperty({
  1484. viewer: _self._viewer,
  1485. trailImage: _self._image_v_t_b,
  1486. duration: _self._param.duration,
  1487. color: Cesium.Color.fromCssColorString(_self._param.polygonColor),
  1488. param: {
  1489. count: _self._param.count,
  1490. direction: _self._param.direction_v,
  1491. order: _self._param.order_minus
  1492. }
  1493. });
  1494. /* 设置实体属性 */
  1495. entityParam.color = _self._param.polygonColor;
  1496. entityParam.duration = _self._param.duration;
  1497. entityParam.direction = _self._param.direction_v;
  1498. entityParam.count = _self._param.count;
  1499. entityParam.order = _self._param.order_minus;
  1500. }
  1501. /* 创建墙 */
  1502. let normalWall = new Cesium.Entity({
  1503. name: _self._sketchEntityName,
  1504. wall: {
  1505. show: true,
  1506. positions: new Cesium.CallbackProperty(function() {
  1507. return _self._sketchTempPoints;
  1508. }, false),
  1509. minimumHeights: new Cesium.CallbackProperty(function() {
  1510. return _self._sketchWallHeights;
  1511. }, false),
  1512. maximumHeights: new Cesium.CallbackProperty(function() {
  1513. _self._sketchWallMaxHeights = [];
  1514. for (let i = 0; i < _self._sketchWallHeights.length; i++) {
  1515. _self._sketchWallMaxHeights.push(_self._sketchWallHeights[i] + _self
  1516. ._param.wallHeight);
  1517. }
  1518. return _self._sketchWallMaxHeights;
  1519. }, false),
  1520. material: wallMaterial,
  1521. }
  1522. });
  1523. /* 渲染墙 */
  1524. this._drawEntity = this._entities.add(normalWall);
  1525. /* 设置实体通用属性 */
  1526. entityParam.height = this._param.wallHeight;
  1527. /* 设置实体类型 */
  1528. if (wallType === undefined || wallType === DrawTools.WallType.ColorWall) {
  1529. this._drawEntity.setEntityType(DrawTools.DrawType.NormalWall);
  1530. /* 设置实体属性 */
  1531. entityParam.id = DrawTools.DrawType.NormalWall;
  1532. } else if (wallType !== undefined && wallType === DrawTools.WallType.DynamicWall) {
  1533. this._drawEntity.setEntityType(DrawTools.DrawType.DynamicWall);
  1534. /* 设置实体属性 */
  1535. entityParam.id = DrawTools.DrawType.DynamicWall;
  1536. } else if (wallType !== undefined && wallType === DrawTools.WallType.TextWall) {
  1537. this._drawEntity.setEntityType(DrawTools.DrawType.TextWall);
  1538. /* 设置实体属性 */
  1539. entityParam.id = DrawTools.DrawType.TextWall;
  1540. }
  1541. /* 挂接实体属性 */
  1542. this._drawEntity.setParams(entityParam);
  1543. },
  1544. /**
  1545. * 更新墙
  1546. * @ignore 生成方法时不对外公开
  1547. * @param {Boolean} isEdit [是否可编辑]可选
  1548. */
  1549. _updateWall: function(isEdit) {
  1550. /* 获取三个数组的长度 */
  1551. let hLength = this._sketchWallHeights.length;
  1552. let mhLength = this._sketchWallMaxHeights.length;
  1553. let pLength = this._sketchPoints.length;
  1554. if (hLength === mhLength && hLength - pLength === 1) {
  1555. /* 移除最后一个高度点 */
  1556. this._sketchWallHeights.pop();
  1557. this._sketchWallMaxHeights.pop();
  1558. /* 设置并停止墙的动态属性 */
  1559. this._drawEntity.wall.positions = this._sketchPoints;
  1560. this._drawEntity.wall.minimumHeights = this._sketchWallHeights;
  1561. this._drawEntity.wall.maximumHeights = this._sketchWallMaxHeights;
  1562. /* 设置是否可编辑 */
  1563. if (isEdit != undefined && isEdit === true) {
  1564. /* 删除所有的临时点 忽略是否保留设置 */
  1565. this._removePointEntitys();
  1566. this._setEntityIsEdit(this._drawEntity);
  1567. }
  1568. } else {
  1569. this._console(hLength, mhLength, pLength);
  1570. }
  1571. },
  1572. /**
  1573. * 创建视频墙
  1574. * @ignore 生成方法时不对外公开
  1575. */
  1576. _createVideoWall: function() {
  1577. let _self = this;
  1578. /* 绘制面 干掉事件 */
  1579. let entityWall = new Cesium.Entity({
  1580. name: _self._sketchEntityName,
  1581. position: _self._sketchOutputPoints[0],
  1582. wall: {
  1583. show: true,
  1584. positions: new Cesium.CallbackProperty(function() {
  1585. let pt0 = _self._sketchOutputPoints[0];
  1586. let pt1 = _self._sketchOutputPoints[1];
  1587. /* 视频墙的位置集合 */
  1588. _self._wallPositions = [];
  1589. _self._wallPositions.push(Cesium.Cartesian3.fromDegrees(pt0.lng, pt0
  1590. .lat,
  1591. pt0.height));
  1592. _self._wallPositions.push(Cesium.Cartesian3.fromDegrees(pt1.lng, pt1
  1593. .lat,
  1594. pt0.height));
  1595. return _self._wallPositions;
  1596. }, false),
  1597. maximumHeights: new Cesium.CallbackProperty(function() {
  1598. _self._sketchWallHeights = [];
  1599. let pt = _self._sketchOutputPoints[0];
  1600. _self._sketchWallHeights.push(pt.height);
  1601. _self._sketchWallHeights.push(pt.height);
  1602. return _self._sketchWallHeights;
  1603. }, false),
  1604. minimumHeights: new Cesium.CallbackProperty(function() {
  1605. _self._sketchWallMaxHeights = [];
  1606. let pt = _self._sketchOutputPoints[1];
  1607. _self._sketchWallMaxHeights.push(pt.height);
  1608. _self._sketchWallMaxHeights.push(pt.height);
  1609. return _self._sketchWallMaxHeights;
  1610. }, false),
  1611. material: Cesium.Color.fromCssColorString(_self._param.polygonColor),
  1612. outline: true,
  1613. outlineColor: Cesium.Color.fromCssColorString(_self._param.outlineColor),
  1614. outlineWidth: _self._param.outlineWidth,
  1615. }
  1616. });
  1617. /* 渲染视频墙 */
  1618. _self._drawEntity = _self._entities.add(entityWall);
  1619. },
  1620. /**
  1621. * 更新视频墙
  1622. * @ignore 生成方法时不对外公开
  1623. */
  1624. _updateVideoWall: function(isEdit) {
  1625. /* 初始化一个实体参数变量 */
  1626. let entityParam = DrawTools.initEditPropertyParams();
  1627. entityParam.id = DrawTools.DrawType.VideoWall;
  1628. /* 查找视频画布 */
  1629. let videoElement = document.getElementById('wallVideo');
  1630. if (videoElement !== null) {
  1631. document.body.removeChild(videoElement);
  1632. }
  1633. videoElement = document.createElement("video");
  1634. videoElement.id = 'wallVideo';
  1635. videoElement.setAttribute('crossorigin', 'anonymous'); //必须设置 为了防止跨域调用网络视频导致播放失败
  1636. videoElement.setAttribute("width", "1024px");
  1637. videoElement.setAttribute("height", "256px");
  1638. videoElement.setAttribute("controls", "controls");
  1639. videoElement.setAttribute("src",
  1640. "https://lf3-cdn-tos.bytescm.com/obj/eden-cn/lmeh7pfuho/campus/campus_intro_20200522.mp4");
  1641. videoElement.setAttribute("loop", "loop");
  1642. videoElement.play();
  1643. document.body.appendChild(videoElement);
  1644. /* 更新数据 */
  1645. this._drawEntity.wall.positions = this._wallPositions;
  1646. this._drawEntity.wall.minimumHeights = this._sketchWallHeights;
  1647. this._drawEntity.wall.maximumHeights = this._sketchWallMaxHeights;
  1648. /* 设置高度参数 */
  1649. entityParam.height = this._sketchWallMaxHeights[0] - this._sketchWallHeights[0];
  1650. this._drawEntity.wall.material = videoElement;
  1651. /* 删除点 */
  1652. this._removePointEntitys();
  1653. /* 设置实体类型 */
  1654. this._drawEntity.setEntityType(DrawTools.DrawType.VideoWall);
  1655. entityParam.videoUrl =
  1656. 'https://lf3-cdn-tos.bytescm.com/obj/eden-cn/lmeh7pfuho/campus/campus_intro_20200522.mp4';
  1657. entityParam.id = DrawTools.DrawType.VideoWall;
  1658. /* 挂接实体属性 */
  1659. this._drawEntity.setParams(entityParam);
  1660. /* 设置是否可编辑 */
  1661. if (isEdit != undefined && isEdit === true) {
  1662. this._setEntityIsEdit(this._drawEntity);
  1663. }
  1664. },
  1665. /**
  1666. * 计算OD线的中间点
  1667. * @ignore 生成方法时不对外公开
  1668. * @param {Cesium.Cartesian3} strPoint 起始点
  1669. * @param {Cesium.Cartesian3} endPoint 终止点
  1670. * @param {Number} height 最大高度
  1671. * @param {Number} count 内插点数
  1672. */
  1673. _calculateOdlinePositios: function(strPoint, endPoint, height, count) {
  1674. let pt1 = this._cartesian3ToGeo(strPoint);
  1675. let pt2 = this._cartesian3ToGeo(endPoint);
  1676. //方程 y=-(4h/L^2)*x^2+h h:顶点高度 L:横纵间距较大者
  1677. var h = height && height < 1000 ? height : 1000;
  1678. var L = Math.abs(pt1.longitude - pt2.longitude) > Math.abs(pt1.latitude - pt2.latitude) ?
  1679. Math.abs(pt1.longitude - pt2.longitude) : Math.abs(pt1.latitude - pt2.latitude);
  1680. var num = count && count > 50 ? count : 50;
  1681. var result = [];
  1682. var tempResult = []; //临时数组
  1683. var dlt = L / num;
  1684. var addHeight = pt1.height > pt2.height ? pt1.height : pt2.height;
  1685. var maxHeight = addHeight + h;
  1686. var minHeight1 = pt1.height;
  1687. var minHeight2 = pt2.height;
  1688. if (Math.abs(pt1.longitude - pt2.longitude) > Math.abs(pt1.latitude - pt2
  1689. .latitude)) { //以lon为基准
  1690. var delLat = (pt2.latitude - pt1.latitude) / num;
  1691. if (pt1.longitude - pt2.longitude > 0) {
  1692. dlt = -dlt;
  1693. }
  1694. for (var i = 1; i < num; i++) {
  1695. var tempH = h - Math.pow((-0.5 * L + Math.abs(dlt) * i), 2) * 4 * h / Math.pow(L, 2);
  1696. var lon = pt1.longitude + dlt * i;
  1697. var lat = pt1.latitude + delLat * i;
  1698. var alt = undefined;
  1699. if (Math.abs(dlt) * i == 0.5 * L) {
  1700. alt = maxHeight;
  1701. } else if (Math.abs(dlt) * i < 0.5 * L) {
  1702. //说明是抛物线左侧
  1703. alt = ((maxHeight - minHeight1) / h) * tempH + minHeight1;
  1704. } else {
  1705. //说明是抛物线右侧
  1706. alt = ((maxHeight - minHeight2) / h) * tempH + minHeight2;
  1707. }
  1708. tempResult.push([lon, lat, alt]);
  1709. }
  1710. } else { //以lat为基准
  1711. var delLon = (pt2.longitude - pt1.longitude) / num;
  1712. if (pt1.latitude - pt2.latitude > 0) {
  1713. dlt = -dlt;
  1714. }
  1715. for (var i = 1; i < num; i++) {
  1716. var tempH = h - Math.pow((-0.5 * L + Math.abs(dlt) * i), 2) * 4 * h / Math.pow(L, 2);
  1717. var lon = pt1.longitude + delLon * i;
  1718. var lat = pt1.latitude + dlt * i;
  1719. var alt = undefined;
  1720. if (Math.abs(dlt) * i == 0.5 * L) {
  1721. alt = maxHeight;
  1722. } else if (Math.abs(dlt) * i < 0.5 * L) {
  1723. //说明是抛物线左侧
  1724. alt = ((maxHeight - minHeight1) / h) * tempH + minHeight1;
  1725. } else {
  1726. //说明是抛物线右侧
  1727. alt = ((maxHeight - minHeight2) / h) * tempH + minHeight2;
  1728. }
  1729. tempResult.push([lon, lat, alt]);
  1730. }
  1731. }
  1732. /* 对结果进行处理 */
  1733. result.push([pt1.longitude, pt1.latitude, pt1.height]);
  1734. for (var i = 0; i < tempResult.length; i++) {
  1735. result.push(tempResult[i]);
  1736. }
  1737. result.push([pt2.longitude, pt2.latitude, pt2.height]);
  1738. /* 对结果进行转换 */
  1739. let results = [];
  1740. for (let i = 0; i < result.length; i++) {
  1741. results.push(Cesium.Cartesian3.fromDegrees(result[i][0], result[i][1], result[i][2]));
  1742. }
  1743. return results;
  1744. },
  1745. /**
  1746. * 创建OD线
  1747. * @ignore 生成方法时不对外公开
  1748. * @param {Boolean} isFirst 是否第一次
  1749. */
  1750. _createOdline: function(isFirst) {
  1751. let _self = this;
  1752. /* 如果初次创建 创建一个父实体*/
  1753. if (isFirst !== undefined && isFirst === true) {
  1754. let fatherEntity = new Cesium.Entity({
  1755. name: this._sketchEntityName,
  1756. });
  1757. this._odlineFatherEntity = this._entities.add(fatherEntity);
  1758. /* 初始化一个实体参数变量 */
  1759. let entityParam = DrawTools.initEditPropertyParams();
  1760. entityParam.id = DrawTools.DrawType.OdLine;
  1761. entityParam.color = _self._param.polygonColor;
  1762. entityParam.duration = _self._param.duration;
  1763. entityParam.direction = _self._param.direction_h;
  1764. entityParam.count = _self._param.count;
  1765. entityParam.order = _self._param.order_add;
  1766. entityParam.odlineHeight = _self._param.odlineHeight;
  1767. entityParam.odlineCount = _self._param.odlineCount;
  1768. entityParam.lineWidth = _self._param.lineWidth * 3;
  1769. /* 为父实体设置参数 保存该OD线集合的必要参数 */
  1770. this._odlineFatherEntity.setParams(entityParam);
  1771. /* 创建一个临时集合 方便回退删除 */
  1772. this._odlineEntitys = [];
  1773. }
  1774. /* 从父节点获取必要参数 */
  1775. let faterParam = this._odlineFatherEntity.getParams();
  1776. /* 创建OD线材质 */
  1777. let odLineMaterial = new WallMaterialProperty({
  1778. viewer: _self._viewer,
  1779. trailImage: _self._image_arrow_reverse,
  1780. duration: faterParam.duration,
  1781. color: Cesium.Color.fromCssColorString(faterParam.color),
  1782. param: {
  1783. direction: faterParam.direction,
  1784. count: faterParam.count,
  1785. order: faterParam.order,
  1786. },
  1787. });
  1788. /* 创建OD线 */
  1789. let entity = new Cesium.Entity({
  1790. name: _self._sketchEntityName,
  1791. parent: this._odlineFatherEntity,
  1792. polyline: {
  1793. show: true,
  1794. positions: new Cesium.CallbackProperty(function() {
  1795. let center = _self._sketchTempPoints[0];
  1796. let endPoint = _self._sketchTempPoints[_self._sketchTempPoints.length -
  1797. 1];
  1798. let results = _self._calculateOdlinePositios(center, endPoint, parseInt(
  1799. faterParam.odlineHeight),
  1800. parseInt(faterParam.odlineCount));
  1801. return results;
  1802. }, false),
  1803. material: odLineMaterial,
  1804. width: faterParam.lineWidth,
  1805. clampToGround: false, //由于是空间线禁止贴地或贴模型
  1806. }
  1807. })
  1808. /* 加入集合 */
  1809. this._drawEntity = this._entities.add(entity);
  1810. },
  1811. /**
  1812. * 更新OD线
  1813. * @ignore 生成方法时不对外公开
  1814. * @param {Boolean} isLast 是否是最后一个
  1815. * @param {Boolean} isEdit 是否为可编辑
  1816. */
  1817. _updateOdline: function(isLast, isEdit) {
  1818. if (isLast !== undefined && isLast === true) {
  1819. if (isEdit !== undefined && isEdit === true) {
  1820. this._drawEntity.setEntityType(DrawTools.DrawType.OdLine);
  1821. this._setEntityIsEdit(this._drawEntity);
  1822. this._drawEntity.parent.setIsEdit(true);
  1823. }
  1824. } else {
  1825. let params = this._drawEntity.parent.getParams();
  1826. let center = this._sketchTempPoints[0];
  1827. let endPoint = this._sketchTempPoints[this._sketchTempPoints.length -
  1828. 1];
  1829. let results = this._calculateOdlinePositios(center, endPoint, parseInt(params.odlineHeight),
  1830. parseInt(params.odlineCount));
  1831. this._drawEntity.polyline.positions = results;
  1832. this._drawEntity.setEntityType(DrawTools.DrawType.OdLine);
  1833. this._odlineEntitys.push(this._drawEntity);
  1834. if (isEdit !== undefined && isEdit === true) {
  1835. this._drawEntity.setIsEdit(true);
  1836. }
  1837. }
  1838. },
  1839. /**
  1840. * 生成GUID随机数
  1841. * @ignore 生成方法时不对外公开
  1842. */
  1843. _guid() {
  1844. function S4() {
  1845. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  1846. }
  1847. return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
  1848. },
  1849. /**
  1850. * 输出消息
  1851. * @ignore 生成方法时不对外公开
  1852. * @param {Object} res
  1853. */
  1854. _console(...rest) {
  1855. console.log('===>>>', rest);
  1856. }
  1857. })
  1858. /**
  1859. * 对外方法
  1860. */
  1861. Object.assign(DrawTools.prototype, {
  1862. /**
  1863. * 鼠标双击结束提示事件
  1864. * @ignore
  1865. * @param {Cesium.Cartesian2} position 位置
  1866. */
  1867. _drawMovingDoubleTooltip(position) {
  1868. this._updateTooltip('左键单击绘制,右键单击撤销<br>左键双击结束绘制', position);
  1869. },
  1870. /**
  1871. * 鼠标单击结束提示事件
  1872. * @ignore
  1873. * @param {Cesium.Cartesian2} position 位置
  1874. */
  1875. _drawMovingSimpleTooltip(position) {
  1876. this._updateTooltip('左键单击结束绘制', position);
  1877. },
  1878. /**
  1879. * 移除最后绘制的一个点元素
  1880. * @ignore
  1881. */
  1882. _removeLastDrawPointEntity() {
  1883. let lastPointEntity = this._pointEntitys.last();
  1884. if (lastPointEntity !== undefined) {
  1885. this._removeEntityByObject(lastPointEntity);
  1886. this._pointEntitys.pop();
  1887. }
  1888. },
  1889. /**
  1890. * 绘制点工具
  1891. * @ignore 生成方法时不对外公开
  1892. * @param {Object} handler 事件句柄
  1893. * @param {JSON} options 配置项
  1894. * @param {Function} [options.onComplete(cPoint, gPoint)] 完成回调 可选
  1895. * @param {Function} [options.onError(message)] 错误回到 可选
  1896. */
  1897. _sketchDrawPoint(handler, options) {
  1898. let _self = this;
  1899. /* 注册鼠标左键点击事件 */
  1900. this._registerLeftClickEvent(handler, function(event) {
  1901. /* 识别屏幕位置 */
  1902. // let loc = _self._transfromFromScreenPoint(event.position);
  1903. // if (!Cesium.defined(loc.sLocation)) return;
  1904. let scene = _self._viewer.scene;
  1905. if (scene.mode !== Cesium.SceneMode.MORPHING) {
  1906. var pickedObject = scene.pick(event.position);
  1907. if (scene.pickPositionSupported && Cesium.defined(pickedObject)) {
  1908. var cartesian = scene.pickPosition(event.position);
  1909. if (Cesium.defined(cartesian)) {
  1910. var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
  1911. var lng = Cesium.Math.toDegrees(cartographic.longitude);
  1912. var lat = Cesium.Math.toDegrees(cartographic.latitude);
  1913. var height = cartographic.height; //模型高度
  1914. _self._sketchOutputPoints.push({
  1915. lng: lng,
  1916. lat: lat,
  1917. height: height
  1918. })
  1919. }
  1920. _self._createPoint(cartesian, '点');
  1921. _self._sketchPoints.push(cartesian.clone());
  1922. if (_self._sketchPoints.length >= 2) {
  1923. _self._createVideoWall();
  1924. /* 干掉事件句柄 释放资源 */
  1925. _self._clearEvent(handler);
  1926. }
  1927. }
  1928. }
  1929. /* 监听输出 */
  1930. if (options.onComplete) options.onComplete(loc.sLocation, loc.gLocation);
  1931. })
  1932. },
  1933. /**
  1934. * 绘制多点
  1935. * @ignore 生成方法时不对外公开
  1936. * @param {Object} handler 事件句柄
  1937. * @param {JSON} options 配置项
  1938. * @param {Function} [options.onAdded(cPoinit,gPoint)] 添加回调 可选
  1939. * @param {Function} [options.onUndo()] 撤销回调 可选
  1940. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  1941. * @param {Function} [options.onError(message)] 错误回调 可选
  1942. */
  1943. _sketchDrawMultiplePoint(handler, options) {
  1944. let _self = this;
  1945. /* 注册鼠标左键点击事件 */
  1946. this._registerLeftClickEvent(handler, function(event) {
  1947. /* 识别屏幕位置 */
  1948. let loc = _self._transfromFromScreenPoint(event.position);
  1949. if (!Cesium.defined(loc.sLocation)) return;
  1950. /* 绘制点 */
  1951. if (_self._isDrawPoint) {
  1952. _self._createPoint(loc.sLocation, _self._lineLabel);
  1953. }
  1954. _self._sketchPoints.push(loc.sLocation);
  1955. _self._sketchOutputPoints.push(loc.gLocation);
  1956. /* 监听输出 */
  1957. if (options.onAdded) options.onAdded(loc.sLocation, loc.gLocation);
  1958. })
  1959. /* 注册鼠标右键事件 */
  1960. this._registerRightClickEvent(handler, function(event) {
  1961. if (_self._sketchPoints.length > 0) {
  1962. _self._sketchPoints.pop();
  1963. _self._sketchOutputPoints.pop();
  1964. if (options.onUndo) options.onUndo();
  1965. }
  1966. })
  1967. /* 注册鼠标左键双击事件 */
  1968. this._registerLeftDoubleClickEvent(handler, function(event) {
  1969. /* 干掉事件句柄 释放资源 */
  1970. _self._clearEvent(handler);
  1971. /* 回调 */
  1972. if (options.onComplete) options.onComplete(_self._sketchPoints, _self._sketchOutputPoints);
  1973. })
  1974. },
  1975. /**
  1976. * 绘制贴地线工具
  1977. * @ignore 生成方法时不对外公开
  1978. * @param {Object} handler 事件句柄
  1979. * @param {JSON} options 配置项
  1980. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  1981. * @param {DrawTools.PolylineType} options.polylineType 线的类型 可选
  1982. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  1983. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  1984. * @param {Function} [options.onUndo()] 撤销回调 可选
  1985. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  1986. * @param {Function} [options.onError(message)] 错误回调 可选
  1987. */
  1988. _sketchDrawPolyline(handler, options) {
  1989. let _self = this;
  1990. /* 注册鼠标左键点击事件 */
  1991. this._registerLeftClickEvent(handler, function(event) {
  1992. /* 识别屏幕位置 */
  1993. let loc = _self._transfromFromScreenPoint(event.position);
  1994. if (!Cesium.defined(loc.sLocation)) return;
  1995. /* 绘制参考点 */
  1996. if (_self._isDrawPoint) {
  1997. _self._createPoint(loc.sLocation, _self._lineLabel);
  1998. }
  1999. /* 第一点击的时候绘制线 */
  2000. if (_self._sketchTempPoints.length === 0) {
  2001. _self._createPolyline(options.polylineType);
  2002. _self._sketchTempPoints.push(loc.sLocation.clone());
  2003. }
  2004. _self._sketchTempPoints.push(loc.sLocation);
  2005. /* 存储正式绘制点集合 */
  2006. _self._sketchPoints.push(loc.sLocation.clone());
  2007. /* 存储输出经纬度点集合 */
  2008. _self._sketchOutputPoints.push(loc.gLocation);
  2009. /* 监听输出 */
  2010. if (options.onAdded) options.onAdded(_self._sketchPoints, _self
  2011. ._sketchOutputPoints);
  2012. /* 添加操作容器 */
  2013. _self._createOperationDom();
  2014. })
  2015. /* 注册鼠标移动事件 */
  2016. this._registerMouseMoveEvent(handler, function(event) {
  2017. /* 如果运行环境是App 则禁止使用移动事件 */
  2018. if (_self._isRuntimeApp()) return;
  2019. /* 识别屏幕位置 */
  2020. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2021. if (!Cesium.defined(loc.sLocation)) return;
  2022. if (_self._sketchTempPoints.length > 1) {
  2023. /* 标签提示 */
  2024. _self._drawMovingDoubleTooltip(event.endPosition);
  2025. _self._sketchTempPoints.pop();
  2026. _self._sketchTempPoints.push(loc.sLocation);
  2027. /* 监听输出 */
  2028. if (options.onMoving) options.onMoving(loc.sLocation);
  2029. }
  2030. });
  2031. /* 注册鼠标右键点击事件 */
  2032. this._registerRightClickEvent(handler, function(event) {
  2033. if (_self._sketchTempPoints.length > 2) {
  2034. _self._drawByUndo();
  2035. if (options.onUndo) options.onUndo();
  2036. }
  2037. });
  2038. /* 注册鼠标左键双击事件 */
  2039. this._registerLeftDoubleClickEvent(handler, function(event) {
  2040. if (_self._sketchPoints.length < 2) {
  2041. if (options.onError) options.onError('点数少于两个,禁止结束绘制!');
  2042. return;
  2043. }
  2044. /* 更新贴地线 */
  2045. _self._updatePolyline(options.isEdit);
  2046. /* 删除标记点 */
  2047. if (!_self._isRetainDrawPoint) _self._removePointEntitys();
  2048. /* 干掉事件句柄 释放资源*/
  2049. _self._clearEvent(handler);
  2050. /* 监听输出 */
  2051. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2052. ._sketchOutputPoints);
  2053. })
  2054. },
  2055. /**
  2056. * 绘制空间线工具
  2057. * @ignore 生成方法时不对外公开
  2058. * @param {Object} handler 事件句柄
  2059. * @param {JSON} options 配置项
  2060. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2061. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  2062. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2063. * @param {Function} [options.onUndo()] 撤销回调 可选
  2064. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  2065. * @param {Function} [options.onError(message)] 错误回到 可选
  2066. */
  2067. _sketchDrawSpatialPolyline(handler, options) {
  2068. let _self = this;
  2069. /* 注册鼠标左键单击事件 */
  2070. this._registerLeftClickEvent(handler, function(event) {
  2071. /* 识别屏幕位置 */
  2072. let loc = _self._transfromFromScreenPoint(event.position);
  2073. if (!Cesium.defined(loc.sLocation)) return;
  2074. /* 绘制点 */
  2075. if (_self._isDrawPoint) {
  2076. _self._createPoint(loc.sLocation, _self._lineLabel);
  2077. }
  2078. /* 第一点击的时候绘制线 */
  2079. if (_self._sketchTempPoints.length === 0) {
  2080. _self._createSpatialPolyline();
  2081. _self._sketchTempPoints.push(loc.sLocation.clone());
  2082. }
  2083. _self._sketchTempPoints.push(loc.sLocation);
  2084. /* 存储正式绘制点集合 */
  2085. _self._sketchPoints.push(loc.sLocation.clone());
  2086. /* 存储输出经纬度点集合 */
  2087. _self._sketchOutputPoints.push(loc.gLocation);
  2088. /* 监听输出 */
  2089. if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
  2090. /* 添加操作容器 */
  2091. _self._createOperationDom();
  2092. })
  2093. /* 注册鼠标移动事件 */
  2094. this._registerMouseMoveEvent(handler, function(event) {
  2095. /* 如果运行环境是App 则禁止使用移动事件 */
  2096. if (_self._isRuntimeApp()) return;
  2097. /* 识别屏幕位置 */
  2098. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2099. if (!Cesium.defined(loc.sLocation)) return;
  2100. if (_self._sketchTempPoints.length > 1) {
  2101. /* 标签提示 */
  2102. _self._drawMovingDoubleTooltip(event.endPosition);
  2103. _self._sketchTempPoints.pop();
  2104. _self._sketchTempPoints.push(loc.sLocation);
  2105. /* 监听输出 */
  2106. if (options.onMoving) options.onMoving(loc.sLocation);
  2107. }
  2108. })
  2109. /* 注册鼠标左键双击事件 */
  2110. this._registerLeftDoubleClickEvent(handler, function(event) {
  2111. if (_self._sketchPoints.length < 2) {
  2112. if (options.onError) options.onError('绘制点少于2个,禁止结束绘制!');
  2113. return;
  2114. }
  2115. /* 绘制正式空间线 */
  2116. _self._updateSpatialPolyline(options.isEdit);
  2117. /* 删除标记点 */
  2118. _self._removePointEntitys();
  2119. /* 干掉事件句柄 释放资源*/
  2120. _self._clearEvent(handler);
  2121. /* 监听输出 */
  2122. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2123. ._sketchOutputPoints);
  2124. })
  2125. /* 注册鼠标右键单击事件 */
  2126. this._registerRightClickEvent(handler, function(event) {
  2127. if (_self._sketchTempPoints.length > 2) {
  2128. _self._drawByUndo();
  2129. if (options.onUndo) options.onUndo();
  2130. }
  2131. });
  2132. },
  2133. /**
  2134. * 绘制OD线工具
  2135. * @ignore 生成方法时不对外公开
  2136. * @param {Object} handler 事件句柄
  2137. * @param {JSON} options 配置项
  2138. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2139. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  2140. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2141. * @param {Function} [options.onUndo()] 撤销回调 可选
  2142. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  2143. * @param {Function} [options.onError(message)] 错误回到 可选
  2144. */
  2145. _sketchDrawOdline(handler, options) {
  2146. let _self = this;
  2147. /* 注册鼠标左键单击事件 */
  2148. this._registerLeftClickEvent(handler, function(event) {
  2149. /* 识别屏幕位置 */
  2150. let loc = _self._transfromFromScreenPoint(event.position);
  2151. if (!Cesium.defined(loc.sLocation)) return;
  2152. /* 绘制点 */
  2153. if (_self._isDrawPoint) {
  2154. _self._createPoint(loc.sLocation, _self._lineLabel);
  2155. }
  2156. if (_self._isRuntimeApp()) {
  2157. _self._showTooltipMessage('再次单击绘制一条OD线!');
  2158. }
  2159. /* 第一点击的时候绘制线 */
  2160. if (_self._sketchTempPoints.length === 0) {
  2161. _self._createOdline(true);
  2162. _self._sketchTempPoints.push(loc.sLocation.clone());
  2163. } else {
  2164. _self._sketchTempPoints.push(loc.sLocation.clone());
  2165. _self._updateOdline(false, options.isEdit);
  2166. _self._createOdline();
  2167. }
  2168. _self._sketchTempPoints.push(loc.sLocation);
  2169. /* 存储正式绘制点集合 */
  2170. _self._sketchPoints.push(loc.sLocation.clone());
  2171. /* 存储输出经纬度点集合 */
  2172. _self._sketchOutputPoints.push(loc.gLocation);
  2173. /* 监听输出 */
  2174. if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
  2175. /* 添加操作容器 */
  2176. _self._createOperationDom();
  2177. })
  2178. /* 注册鼠标移动事件 */
  2179. this._registerMouseMoveEvent(handler, function(event) {
  2180. /* 如果运行环境是App 则禁止使用移动事件 */
  2181. if (_self._isRuntimeApp()) return;
  2182. /* 识别屏幕位置 */
  2183. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2184. if (!Cesium.defined(loc.sLocation)) return;
  2185. if (_self._sketchTempPoints.length > 1) {
  2186. /* 标签提示 */
  2187. _self._drawMovingDoubleTooltip(event.endPosition);
  2188. _self._sketchTempPoints.pop();
  2189. _self._sketchTempPoints.push(loc.sLocation);
  2190. /* 监听输出 */
  2191. if (options.onMoving) options.onMoving(loc.sLocation);
  2192. }
  2193. })
  2194. /* 注册鼠标左键双击事件 */
  2195. this._registerLeftDoubleClickEvent(handler, function(event) {
  2196. /* 绘制正式OD线 */
  2197. _self._removeEntityByObject(_self._drawEntity);
  2198. _self._updateOdline(true, options.isEdit);
  2199. /* 删除标记点 */
  2200. _self._removePointEntitys();
  2201. /* 干掉事件句柄 释放资源*/
  2202. _self._clearEvent(handler);
  2203. /* 监听输出 */
  2204. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2205. ._sketchOutputPoints);
  2206. })
  2207. /* 注册鼠标右键单击事件 */
  2208. this._registerRightClickEvent(handler, function(event) {
  2209. if (_self._odlineEntitys.length > 0) {
  2210. /* 删除最后一个绘制点 */
  2211. if (_self._isDrawPoint) {
  2212. _self._removeLastDrawPointEntity();
  2213. }
  2214. _self._removeEntityByObject(_self._odlineEntitys.last());
  2215. _self._odlineEntitys.pop();
  2216. if (options.onUndo) options.onUndo();
  2217. }
  2218. });
  2219. },
  2220. /**
  2221. * 绘制贴地面工具
  2222. * @ignore 生成方法时不对外公开
  2223. * @param {Object} handler 事件句柄
  2224. * @param {JSON} options 配置项
  2225. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2226. * @param {DrawTools.PolygonType} options.polygonType 绘制面类型 可选
  2227. * @param {Function} [options.onAdded(cPoints,gPoints)] 添加回调 可选
  2228. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2229. * @param {Function} [options.onUndo()] 撤销回调 可选
  2230. * @param {Function} [options.onComplete(cPoints,gPoints)] 完成回调 可选
  2231. * @param {Function} [options.onError(message)] 错误回到 可选
  2232. */
  2233. _sketchDrawPolygon(handler, options) {
  2234. let _self = this;
  2235. /* 注册鼠标左键点击事件 */
  2236. this._registerLeftClickEvent(handler, function(event) {
  2237. /* 识别屏幕位置 */
  2238. let loc = _self._transfromFromScreenPoint(event.position);
  2239. if (!Cesium.defined(loc.sLocation)) return;
  2240. /* 绘制点 */
  2241. if (_self._isDrawPoint) {
  2242. _self._createPoint(loc.sLocation, _self._lineLabel);
  2243. }
  2244. /* 当点数为0时绘制线和面 */
  2245. if (_self._sketchTempPoints.length === 0) {
  2246. _self._createPolygon(options.polygonType);
  2247. _self._sketchTempPoints.push(loc.sLocation.clone());
  2248. }
  2249. _self._sketchTempPoints.push(loc.sLocation);
  2250. /* 存储正式绘制点集合 */
  2251. _self._sketchPoints.push(loc.sLocation.clone());
  2252. /* 存储输出经纬度点集合 */
  2253. _self._sketchOutputPoints.push(loc.gLocation);
  2254. /* 监听输出 */
  2255. if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
  2256. /* 添加操作容器 */
  2257. _self._createOperationDom();
  2258. });
  2259. /* 注册鼠标移动事件 */
  2260. this._registerMouseMoveEvent(handler, function(event) {
  2261. /* 如果运行环境是App 则禁止使用移动事件 */
  2262. if (_self._isRuntimeApp()) return;
  2263. /* 识别屏幕位置 */
  2264. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2265. if (!Cesium.defined(loc.sLocation)) return;
  2266. if (_self._sketchTempPoints.length > 1) {
  2267. /* 标签提示 */
  2268. _self._drawMovingDoubleTooltip(event.endPosition);
  2269. _self._sketchTempPoints.pop();
  2270. _self._sketchTempPoints.push(loc.sLocation);
  2271. /* 监听输出 */
  2272. if (options.onMoving) options.onMoving(loc.sLocation);
  2273. }
  2274. });
  2275. /* 注册鼠标右键单击事件 */
  2276. this._registerRightClickEvent(handler, function(event) {
  2277. if (_self._sketchTempPoints.length > 2) {
  2278. _self._drawByUndo();
  2279. if (options.onUndo) options.onUndo();
  2280. }
  2281. });
  2282. /* 注册鼠标左键双击事件 */
  2283. this._registerLeftDoubleClickEvent(handler, function(event) {
  2284. if (_self._sketchPoints.length < 3) {
  2285. if (options.onError) options.onError('点数少于3个,禁止结束绘制!');
  2286. return;
  2287. }
  2288. /* 更新贴地面 */
  2289. _self._updatePolygon(options.isEdit);
  2290. /* 删除标记点 */
  2291. if (!_self._isRetainDrawPoint) _self._removePointEntitys();
  2292. /* 干掉事件句柄 释放资源*/
  2293. _self._clearEvent(handler);
  2294. /* 监听输出 */
  2295. if (options.onComplete) options.onComplete(_self._sketchPoints, _self
  2296. ._sketchOutputPoints);
  2297. })
  2298. },
  2299. /**
  2300. * 绘制贴地圆工具
  2301. * @ignore 生成方法时不对外公开
  2302. * @param {Object} handler 事件句柄
  2303. * @param {JSON} options 配置项
  2304. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2305. * @param {DrawTools.CircleType} options.circleType 绘制圆的类型 可选
  2306. * @param {Function} [options.onAdded(center)] 添加回调 可选
  2307. * @param {Function} [options.onComplete(center,radius)] 完成回调 可选
  2308. * @param {Function} [options.onError(message)] 错误回到 可选
  2309. */
  2310. _sketchDrawCircle: function(handler, options) {
  2311. let _self = this;
  2312. /* 注册鼠标左键单击事件 */
  2313. this._registerLeftClickEvent(handler, function(event) {
  2314. /* 识别屏幕位置 */
  2315. let loc = _self._transfromFromScreenPoint(event.position);
  2316. if (!Cesium.defined(loc.sLocation)) return;
  2317. if (_self._sketchTempPoints.length === 0) {
  2318. /* 绘制点 */
  2319. if (_self._isDrawPoint) {
  2320. _self._createPoint(loc.sLocation, '起点');
  2321. }
  2322. /* 添加数据 */
  2323. _self._sketchTempPoints.push(loc.sLocation.clone());
  2324. _self._sketchTempPoints.push(loc.sLocation); //凑数的
  2325. /* 存储正式绘制点集合 */
  2326. _self._sketchPoints.push(loc.sLocation.clone());
  2327. /* 存储经纬度 */
  2328. _self._sketchOutputPoints.push(loc.gLocation);
  2329. /* 创建圆 */
  2330. _self._createCircle(loc.sLocation, options.circleType);
  2331. /* App提示信息 */
  2332. if (_self._isRuntimeApp()) {
  2333. _self._showTooltipMessage('再次单击结束绘制!');
  2334. }
  2335. /* 监听输出 */
  2336. if (options.onAdded) options.onAdded(loc.sLocation);
  2337. } else {
  2338. _self._sketchTempPoints.push(loc.sLocation.clone());
  2339. /* 删除标记点 */
  2340. _self._removePointEntitys();
  2341. /* 更新圆 */
  2342. _self._updateCircle(options.isEdit);
  2343. /* 干掉事件句柄 释放资源*/
  2344. _self._clearEvent(handler);
  2345. /* 回调返回 */
  2346. if (options.onComplete) options.onComplete(_self._sketchOutputPoints[0], _self
  2347. ._sketchEllipseRadius);
  2348. }
  2349. });
  2350. /* 注册鼠标移动事件 */
  2351. this._registerMouseMoveEvent(handler, function(event) {
  2352. if (_self._isRuntimeApp()) {
  2353. return;
  2354. }
  2355. /* 如果还未创建圆 则直接返回 */
  2356. if (_self._sketchTempPoints.length <= 0) return;
  2357. /* 标签提示 */
  2358. _self._drawMovingSimpleTooltip(event.endPosition);
  2359. /* 获取空间位置 */
  2360. var cartesian = _self._viewer.scene.pickPosition(event.endPosition);
  2361. /* 如果获取点失败 则直接返回 */
  2362. if (cartesian == undefined) return;
  2363. _self._sketchTempPoints.pop();
  2364. _self._sketchTempPoints.push(cartesian);
  2365. })
  2366. },
  2367. /**
  2368. * 绘制贴地矩形工具
  2369. * @ignore 生成方法时不对外公开
  2370. * @param {Object} handler 事件句柄
  2371. * @param {JSON} options 配置项
  2372. * @param {Boolean} isEdit 是否可编辑 可选 默认可编辑
  2373. * @param {Function} [options.onAdded(cPoint)] 添加回调 可选
  2374. * @param {Function} [options.onComplete(points)] 完成回调 可选
  2375. */
  2376. _sketchDrawRectangle: function(handler, options) {
  2377. let _self = this;
  2378. /* 注册鼠标左键单击事件 */
  2379. this._registerLeftClickEvent(handler, function(event) {
  2380. if (_self._sketchTempPoints.length === 0) {
  2381. /* 识别屏幕位置 */
  2382. let loc = _self._transfromFromScreenPoint(event.position);
  2383. if (!Cesium.defined(loc.sLocation)) return;
  2384. /* 绘制点 */
  2385. if (_self._isDrawPoint) {
  2386. _self._createPoint(loc.sLocation, '起点');
  2387. }
  2388. /* 添加数据 */
  2389. _self._sketchTempPoints.push(loc.sLocation);
  2390. _self._sketchTempPoints.push(loc.sLocation); //凑数的
  2391. /* 存储正式绘制点集合 */
  2392. _self._sketchPoints.push(loc.gLocation);
  2393. /* 创建矩形 */
  2394. _self._createRectangle();
  2395. /* 回调 */
  2396. if (options.onAdded) options.onAdded(loc.sLocation);
  2397. /* App提示信息 */
  2398. if (_self._isRuntimeApp()) {
  2399. _self._showTooltipMessage('再次单击结束绘制!');
  2400. }
  2401. } else {
  2402. /* 删除标记点 */
  2403. _self._removePointEntitys();
  2404. /* 删除临时矩形 */
  2405. _self._removeEntityByObject(_self._sketchTempRectangle);
  2406. /* 创建正式矩形 */
  2407. _self._updateRectangle(options.isEdit);
  2408. /* 干掉事件句柄 释放资源*/
  2409. _self._clearEvent(handler);
  2410. /* 回调返回 */
  2411. if (options.onComplete) options.onComplete(_self._sketchOutputPoints);
  2412. }
  2413. });
  2414. /* 挂接鼠标移动事件 */
  2415. this._registerMouseMoveEvent(handler, function(event) {
  2416. /* 如果还未创矩形 则直接返回 */
  2417. if (_self._sketchTempPoints.length < 1) return;
  2418. /* 标签提示 */
  2419. _self._drawMovingSimpleTooltip(event.endPosition);
  2420. /* 识别屏幕位置 */
  2421. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2422. if (!Cesium.defined(loc.sLocation)) return;
  2423. _self._sketchTempPoints.pop();
  2424. _self._sketchTempPoints.push(loc.sLocation);
  2425. });
  2426. },
  2427. /**
  2428. * 绘制墙
  2429. * @ignore 生成方法时不对外公开
  2430. * @param {Object} handler 事件句柄
  2431. * @param {JSON} options 配置项
  2432. * @param {Boolean} options.isEdit [是否可编辑 可选]
  2433. * @param {DrawTools.WallType} options.wallType [绘制墙的类型 可选]
  2434. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2435. * @param {Function} [options.onComplete(positions)] 完成回调 可选
  2436. * @param {Function} [options.onError(message)] 错误回到 可选
  2437. */
  2438. _sketchDrawWall: function(handler, options) {
  2439. let _self = this;
  2440. /* 注册鼠标左键点击事件 */
  2441. this._registerLeftClickEvent(handler, function(event) {
  2442. /* 识别屏幕位置 */
  2443. let loc = _self._transfromFromScreenPoint(event.position);
  2444. if (!Cesium.defined(loc.sLocation)) return;
  2445. /* 绘制点 */
  2446. if (_self._isDrawPoint) {
  2447. _self._createPoint(loc.sLocation, _self._lineLabel);
  2448. }
  2449. /* 第一点击的时候绘制线 */
  2450. if (_self._sketchTempPoints.length === 0) {
  2451. _self._createWall(options.wallType);
  2452. _self._sketchTempPoints.push(loc.sLocation.clone());
  2453. /* 存储墙的高度点集合 */
  2454. _self._sketchWallHeights.push(loc.gLocation.height);
  2455. }
  2456. _self._sketchTempPoints.push(loc.sLocation);
  2457. _self._sketchWallHeights.push(loc.gLocation.height);
  2458. /* 存储正式绘制点集合 */
  2459. _self._sketchPoints.push(loc.sLocation.clone());
  2460. /* 添加操作容器 */
  2461. _self._createOperationDom();
  2462. })
  2463. /* 注册鼠标移动事件 */
  2464. this._registerMouseMoveEvent(handler, function(event) {
  2465. if (_self._isRuntimeApp()) {
  2466. return;
  2467. }
  2468. /* 识别屏幕位置 */
  2469. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2470. if (!Cesium.defined(loc.sLocation)) return;
  2471. if (_self._sketchTempPoints.length > 1) {
  2472. /* 标签提示 */
  2473. _self._drawMovingDoubleTooltip(event.endPosition);
  2474. _self._sketchTempPoints.pop();
  2475. _self._sketchTempPoints.push(loc.sLocation);
  2476. _self._sketchWallHeights.pop();
  2477. _self._sketchWallHeights.push(loc.gLocation.height);
  2478. }
  2479. });
  2480. /* 注册鼠标右键点击事件 */
  2481. this._registerRightClickEvent(handler, function(event) {
  2482. if (_self._sketchTempPoints.length > 2) {
  2483. /* 移除正式点最有一个元素 */
  2484. _self._sketchPoints.pop();
  2485. if (_self._isRuntimeApp()) {
  2486. /* 移除临时点倒数第二个元素 */
  2487. _self._sketchTempPoints.splice(_self._sketchTempPoints.length - 1, 1);
  2488. /* 移除临时高度点倒数第二个元素 */
  2489. _self._sketchWallHeights.splice(_self._sketchWallHeights.length - 1, 1);
  2490. } else {
  2491. /* 移除临时点倒数第二个元素 */
  2492. _self._sketchTempPoints.splice(_self._sketchTempPoints.length - 2, 1);
  2493. /* 移除临时高度点倒数第二个元素 */
  2494. _self._sketchWallHeights.splice(_self._sketchWallHeights.length - 2, 1);
  2495. }
  2496. /* 如果绘制了点 则删除最后一个 */
  2497. if (_self._isDrawPoint) {
  2498. _self._removeLastDrawPointEntity();
  2499. }
  2500. }
  2501. });
  2502. /* 注册鼠标左键双击事件 */
  2503. this._registerLeftDoubleClickEvent(handler, function(event) {
  2504. if (_self._sketchPoints.length < 2) {
  2505. if (options.onError) options.onError('点数少于两个,禁止结束绘制!');
  2506. return;
  2507. }
  2508. /* 更新墙属性 */
  2509. _self._updateWall(options.isEdit);
  2510. /* 删除标记点 */
  2511. if (!_self._isRetainDrawPoint) _self._removePointEntitys();
  2512. /* 干掉事件句柄 释放资源*/
  2513. _self._clearEvent(handler);
  2514. })
  2515. },
  2516. /**
  2517. * 绘制视频墙工具
  2518. * @ignore 生成方法时不对外公开
  2519. * @param {Object} handler 事件句柄
  2520. * @param {JSON} options 配置项
  2521. * @param {Boolean} options.isEdit [是否可编辑 可选]
  2522. * @param {Function} [options.onMoving(cPoint)] 移动回调 可选
  2523. * @param {Function} [options.onComplete(positions)] 完成回调 可选
  2524. * @param {Function} [options.onError(message)] 错误回到 可选
  2525. */
  2526. _sketchDrawVideoWall: function(handler, options) {
  2527. let _self = this;
  2528. /* 注册鼠标左键点击事件 */
  2529. this._registerLeftClickEvent(handler, function(event) {
  2530. /* 识别屏幕位置 */
  2531. let loc = _self._transfromFromScreenPoint(event.position);
  2532. if (!Cesium.defined(loc.sLocation)) return;
  2533. /* 绘制点 */
  2534. if (_self._isDrawPoint) {
  2535. _self._createPoint(loc.sLocation, _self._lineLabel);
  2536. }
  2537. /* 第一点击的时候绘制 */
  2538. if (_self._sketchOutputPoints.length === 0) {
  2539. _self._sketchOutputPoints.push(loc.gLocation);
  2540. _self._sketchOutputPoints.push(loc.gLocation);
  2541. _self._createVideoWall();
  2542. if (_self._isRuntimeApp()) {
  2543. _self._showTooltipMessage('再次单击结束绘制');
  2544. }
  2545. } else {
  2546. _self._updateVideoWall(options.isEdit);
  2547. _self._clearEvent(handler);
  2548. }
  2549. // _self._removeCoorinateAxis();
  2550. // _self._createCoordinateAxis(loc.sLocation);
  2551. // _self._clearEvent(handler);
  2552. })
  2553. /* 注册鼠标移动事件 */
  2554. this._registerMouseMoveEvent(handler, function(event) {
  2555. if (_self._isRuntimeApp()) return;
  2556. /* 识别屏幕位置 */
  2557. let loc = _self._transfromFromScreenPoint(event.endPosition);
  2558. if (!Cesium.defined(loc.sLocation)) return;
  2559. if (_self._sketchOutputPoints.length > 1) {
  2560. /* 标签提示 */
  2561. _self._drawMovingSimpleTooltip(event.endPosition);
  2562. _self._sketchOutputPoints.pop();
  2563. _self._sketchOutputPoints.push(loc.gLocation);
  2564. }
  2565. });
  2566. },
  2567. /**
  2568. * 撤销上一步的绘制
  2569. */
  2570. _drawByUndo: function() {
  2571. /* 移除正式点最有一个元素 */
  2572. this._sketchPoints.pop();
  2573. if (this._isRuntimeApp()) {
  2574. /* 移除临时点倒数第一个元素 */
  2575. this._sketchTempPoints.splice(this._sketchTempPoints.length - 1, 1);
  2576. } else {
  2577. /* 移除临时点倒数第二个元素 */
  2578. this._sketchTempPoints.splice(this._sketchTempPoints.length - 2, 1);
  2579. }
  2580. /* 如果绘制了点 则删除最后一个 */
  2581. if (this._isDrawPoint) {
  2582. this._removeLastDrawPointEntity();
  2583. }
  2584. },
  2585. /**
  2586. * 启用绘制
  2587. * @param {DrawTools.DrawType} type 绘制类型
  2588. * @param {JSON} options 回调集合
  2589. * @param {Boolean} [isEdit] 是否可编辑 可选 默认不可编辑
  2590. * @param {Function} [options.onAdded] 添加回调 可选 子方法自定义
  2591. * @param {Function} [options.onMoving] 移动回调 可选 子方法自定义
  2592. * @param {Function} [options.onUndo] 撤销回调 可选 子方法自定义
  2593. * @param {Function} [options.onComplete] 完成回调 可选 子方法自定义
  2594. * @param {Function} [options.onError] 错误回调 可选 子方法自定义
  2595. */
  2596. draw: function(type, options) {
  2597. /* 定义自身 */
  2598. let _self = this;
  2599. /* 初始化 */
  2600. this._clear();
  2601. /* 注册事件 */
  2602. this._drawEventHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  2603. if (this._isRuntimeApp()) {
  2604. this._showTooltipMessage("单击绘制");
  2605. } else {
  2606. this._beginTooltip('左键单击绘制', undefined);
  2607. }
  2608. this._drawType = type;
  2609. /* 分类型注册事件 */
  2610. switch (type) {
  2611. case DrawTools.DrawType.Point: //绘制点
  2612. _self._sketchDrawPoint(_self._drawEventHandler, options);
  2613. break;
  2614. case DrawTools.DrawType.Polyline: //绘制贴地线
  2615. options.polylineType = DrawTools.PolylineType.NormalPolyline;
  2616. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2617. break;
  2618. case DrawTools.DrawType.ArrowPolyline: //绘制箭头线
  2619. options.polylineType = DrawTools.PolylineType.ArrowsPolyline;
  2620. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2621. break;
  2622. case DrawTools.DrawType.DynamicPolyline: //绘制流动线
  2623. options.polylineType = DrawTools.PolylineType.DynamicPolyline;
  2624. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2625. break;
  2626. case DrawTools.DrawType.GrowPolyline: //绘制发光线
  2627. options.polylineType = DrawTools.PolylineType.GrowPolyline;
  2628. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2629. break;
  2630. case DrawTools.DrawType.OutlinePolyline: //绘制描边线
  2631. options.polylineType = DrawTools.PolylineType.OutlinePolyline;
  2632. _self._sketchDrawPolyline(_self._drawEventHandler, options);
  2633. break;
  2634. case DrawTools.DrawType.Polygon: //绘制贴地面
  2635. options.polygonType = DrawTools.PolygonType.NormalPolygon;
  2636. _self._sketchDrawPolygon(_self._drawEventHandler, options);
  2637. break;
  2638. case DrawTools.DrawType.SpatialLine: //绘制空���线
  2639. _self._sketchDrawSpatialPolyline(_self._drawEventHandler, options);
  2640. break;
  2641. case DrawTools.DrawType.Circle: //绘�����贴�����圆
  2642. options.circleType = DrawTools.CircleType.ColorCircle;
  2643. _self._sketchDrawCircle(_self._drawEventHandler, options);
  2644. break;
  2645. case DrawTools.DrawType.Rectangle: //绘制矩形
  2646. _self._sketchDrawRectangle(_self._drawEventHandler, options);
  2647. break;
  2648. case DrawTools.DrawType.NormalWall: //������普通墙
  2649. options.wallType = DrawTools.WallType.ColorWall;
  2650. _self._sketchDrawWall(_self._drawEventHandler, options);
  2651. break;
  2652. case DrawTools.DrawType.DynamicWall: //绘制动态墙
  2653. options.wallType = DrawTools.WallType.DynamicWall;
  2654. _self._sketchDrawWall(_self._drawEventHandler, options);
  2655. break;
  2656. case DrawTools.DrawType.TextWall: //绘制文字墙
  2657. options.wallType = DrawTools.WallType.TextWall;
  2658. _self._sketchDrawWall(_self._drawEventHandler, options);
  2659. break;
  2660. case DrawTools.DrawType.DynamicCircle: //���制扩散圆
  2661. options.circleType = DrawTools.CircleType.DynamicCircle;
  2662. _self._sketchDrawCircle(_self._drawEventHandler, options);
  2663. break;
  2664. case DrawTools.DrawType.House: //绘制房屋
  2665. options.polygonType = DrawTools.PolygonType.HousePolygon;
  2666. _self._sketchDrawPolygon(_self._drawEventHandler, options);
  2667. break;
  2668. case DrawTools.DrawType.VideoWall:
  2669. _self._sketchDrawVideoWall(_self._drawEventHandler, options);
  2670. break;
  2671. case DrawTools.DrawType.OdLine:
  2672. _self._sketchDrawOdline(_self._drawEventHandler, options);
  2673. break;
  2674. }
  2675. },
  2676. /**
  2677. * 清理资源
  2678. */
  2679. Clear: function() {
  2680. /* 清理全部绘制内容 */
  2681. this._clear(true);
  2682. /* 结束编辑状态 */
  2683. this._unActivateEdit();
  2684. /* 关闭属性编辑框 */
  2685. this._closePropertyEditDialog();
  2686. /* 移除操作容器 */
  2687. this._removeOperationDom();
  2688. },
  2689. /**
  2690. * 初始化
  2691. */
  2692. sketchInit: function() {
  2693. this._clear(false);
  2694. },
  2695. /**
  2696. * 检测程序运行环境
  2697. * @ignore
  2698. * @return {DrawTools.RuntimeEnvironment}
  2699. */
  2700. _checkAppOrWeb() {
  2701. if (window.navigator.userAgent.match(
  2702. /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
  2703. )) {
  2704. return DrawTools.RuntimeEnvironment.App;
  2705. } else {
  2706. return DrawTools.RuntimeEnvironment.Web;
  2707. }
  2708. },
  2709. /**
  2710. * 是否是运行于App
  2711. * @ignore
  2712. */
  2713. _isRuntimeApp() {
  2714. if (this._checkAppOrWeb() === DrawTools.RuntimeEnvironment.App) {
  2715. return true;
  2716. }
  2717. return false;
  2718. }
  2719. })
  2720. /**
  2721. * 鼠标跟随标签相关
  2722. */
  2723. Object.assign(DrawTools.prototype, {
  2724. /**
  2725. * 提示标签初始化
  2726. * @ignore 生成方法时不对外公开
  2727. * @param {String} text 显示的文本内容
  2728. * @param {JSON} mousePosition 鼠标位置
  2729. */
  2730. _tooltipInit: function(text, mousePosition) {
  2731. let _self = this;
  2732. this._tooltipId = 'tooltipSketchmodel';
  2733. let tooltipObj = document.getElementById(this._tooltipId);
  2734. if (tooltipObj === null) {
  2735. tooltipObj = document.createElement('div');
  2736. tooltipObj.id = this._tooltipId;
  2737. document.body.appendChild(tooltipObj);
  2738. let divStyle = '';
  2739. divStyle += "top: 30px;";
  2740. divStyle += "left: 30px;";
  2741. divStyle += "position: absolute;";
  2742. divStyle += "display: flex;";
  2743. divStyle += "align-items: center;";
  2744. divStyle += "width: 12x0px;";
  2745. divStyle += "height: auto;";
  2746. divStyle += "background-color: rgba(0, 0, 0, 0.65);";
  2747. divStyle += "border-radius: 5px;";
  2748. divStyle += "color: rgb(255, 255, 255);";
  2749. divStyle += "font-size: 12px;";
  2750. divStyle += "font-family: 'Alimama_ShuHeiTi_Bold';";
  2751. divStyle += "padding: 8px;";
  2752. divStyle += "border:solid 1px rgb(255,0,0);";
  2753. tooltipObj.setAttribute('style', divStyle);
  2754. }
  2755. if (text != undefined) tooltipObj.innerHTML = text;
  2756. if (mousePosition === undefined) {
  2757. /* 挂接鼠标移动事件 */
  2758. document.onmousemove = function(event) {
  2759. if (event.clientX < 100 || event.clientX > _self._canvasWidth - 100 || event.clientY <
  2760. 100 ||
  2761. event.clientY > _self._canvasHeight - 100) {
  2762. tooltipObj.style.display = 'none';
  2763. } else {
  2764. tooltipObj.style.display = 'flex';
  2765. tooltipObj.style.left = (event.clientX + 10) + 'px';
  2766. tooltipObj.style.top = (event.clientY - tooltipObj.offsetHeight / 2) + 'px';
  2767. }
  2768. }
  2769. } else {
  2770. if (mousePosition.x < 100 || mousePosition.x > _self._canvasWidth - 100 || mousePosition.y <
  2771. 100 ||
  2772. mousePosition.y > _self._canvasHeight - 100) {
  2773. tooltipObj.style.display = 'none';
  2774. } else {
  2775. tooltipObj.style.display = 'flex';
  2776. tooltipObj.style.left = (mousePosition.x + 10) + 'px';
  2777. tooltipObj.style.top = (mousePosition.y - tooltipObj.offsetHeight / 2) + 'px';
  2778. }
  2779. }
  2780. },
  2781. /**
  2782. * 移除提示标签
  2783. * @ignore 生成方法时不对外公开
  2784. */
  2785. _tooltipRemove: function() {
  2786. let tooltipObj = document.getElementById(this._tooltipId);
  2787. if (tooltipObj != null) {
  2788. document.body.removeChild(tooltipObj);
  2789. }
  2790. },
  2791. /**
  2792. * 设置提示标签文本
  2793. * @ignore 生成方法时不对外公开
  2794. * @param {String} text 文本
  2795. * @param {JSON} mousePosition 鼠标位置
  2796. */
  2797. _tooltipSetText: function(text, mousePosition) {
  2798. let tooltipObj = document.getElementById(this._tooltipId);
  2799. if (tooltipObj != null) {
  2800. if (text != undefined) tooltipObj.innerHTML = text;
  2801. if (mousePosition != undefined) {
  2802. if (mousePosition.x < 100 || mousePosition.x > this._canvasWidth - 100 || mousePosition.y <
  2803. 100 ||
  2804. mousePosition.y > this._canvasHeight - 100) {
  2805. tooltipObj.style.display = 'none';
  2806. } else {
  2807. tooltipObj.style.display = 'flex';
  2808. tooltipObj.style.left = (mousePosition.x + 10) + 'px';
  2809. tooltipObj.style.top = (mousePosition.y - tooltipObj.offsetHeight / 2) + 'px';
  2810. }
  2811. }
  2812. }
  2813. },
  2814. /**
  2815. * 设置鼠标为十字样式
  2816. * @ignore 生成方法时不对外公开
  2817. */
  2818. _setMousePointerStyle: function() {
  2819. document.querySelector('body').style.cursor = 'crosshair';
  2820. },
  2821. /**
  2822. * 恢复鼠标指针为默认样式
  2823. * @ignore 生成方法时不对外公开
  2824. */
  2825. _setMouseDefaultStyle: function() {
  2826. document.querySelector('body').style.cursor = 'default';
  2827. },
  2828. /**
  2829. * 启用标签
  2830. * @ignore 不公开
  2831. * @param {String} text 标签文字
  2832. * @param {Cesium.Cartesian2} position 鼠标位置
  2833. */
  2834. _beginTooltip(text, position) {
  2835. this._tooltipInit(text, position);
  2836. this._setMousePointerStyle();
  2837. },
  2838. /**
  2839. * 更新标签标签
  2840. * @ignore 不公开
  2841. * @param {String} text 标签文字
  2842. * @param {Cesium.Cartesian2} position 鼠标位置
  2843. */
  2844. _updateTooltip(text, position) {
  2845. this._tooltipSetText(text, position);
  2846. },
  2847. /**
  2848. * 结束标签
  2849. * @ignore 不公开
  2850. */
  2851. _endTooltip() {
  2852. this._tooltipRemove();
  2853. this._setMouseDefaultStyle();
  2854. },
  2855. /**
  2856. * 创建顶部弹出提示消息 1秒后自动消失
  2857. * @param {String} message 消息内容
  2858. */
  2859. _showTooltipMessage: function(message) {
  2860. let msgMainDom = document.getElementById('messageMainDom');
  2861. if (msgMainDom !== null && msgMainDom !== undefined) {
  2862. document.body.removeChild(msgMainDom);
  2863. }
  2864. msgMainDom = document.createElement('div');
  2865. msgMainDom.style.width = '30%';
  2866. msgMainDom.style.backgroundColor = 'rgba(237, 248, 230, 1.0)';
  2867. msgMainDom.style.height = '45px';
  2868. msgMainDom.style.border = 'solid 2px rgb(219, 241, 208)';
  2869. msgMainDom.style.borderRadius = '8px';
  2870. msgMainDom.style.display = 'flex';
  2871. msgMainDom.style.alignItems = 'center';
  2872. msgMainDom.style.paddingLeft = '10px';
  2873. msgMainDom.style.color = 'rgb(91, 188, 48)';
  2874. msgMainDom.style.fontSize = '14px';
  2875. msgMainDom.style.fontWeight = '600';
  2876. msgMainDom.style.position = 'absolute';
  2877. msgMainDom.style.left = '35%';
  2878. msgMainDom.style.transition = 'transform 1s';
  2879. msgMainDom.style.transform = 'translateY(-90px)';
  2880. msgMainDom.style.top = '0px';
  2881. msgMainDom.style.zIndex = 1000;
  2882. document.body.appendChild(msgMainDom);
  2883. let strHtml = '';
  2884. strHtml += "<div style='"
  2885. strHtml += "background-color: rgb(88, 185, 45);";
  2886. strHtml += "color: rgb(255, 255, 255);";
  2887. strHtml += "height: 24px;";
  2888. strHtml += "width: 24px;";
  2889. strHtml += "border-radius: 20px;";
  2890. strHtml += "display: flex;";
  2891. strHtml += "justify-content: center;";
  2892. strHtml += "align-items: center;";
  2893. strHtml += "font-size: 14px;";
  2894. strHtml += "margin-right: 18px;";
  2895. strHtml += "'>&#10003</div>";
  2896. strHtml += "<div>" + message + "</div>";
  2897. msgMainDom.innerHTML = strHtml;
  2898. msgMainDom.addEventListener('transitionend', function() {
  2899. setTimeout(function() {
  2900. document.body.removeChild(msgMainDom);
  2901. }, 1000);
  2902. }, false);
  2903. setTimeout(function() {
  2904. msgMainDom.style.transform = 'translateY(50px)';
  2905. }, 100)
  2906. }
  2907. })
  2908. /**
  2909. * 拖拽坐标轴相关
  2910. */
  2911. Object.assign(DrawTools.prototype, {
  2912. /**
  2913. * 创建单个坐标轴
  2914. * @ignore 生成方法时不对外公开
  2915. * @param {Array<Cesium.Cartesian3>} positions 坐标集合
  2916. * @param {String} color 坐标轴颜色 rgba(r,g,b,a)
  2917. * @param {String} axisEntityId 坐标轴实体的Id
  2918. */
  2919. _createSingleCoordinateAxisArrow(positions, color, axisEntityId) {
  2920. let _self = this;
  2921. /* 创建坐标轴 */
  2922. let coordinateAxisEntity = new Cesium.Entity({
  2923. id: axisEntityId,
  2924. name: _self._coordinateAxisEntityName,
  2925. position: positions[0],
  2926. polyline: {
  2927. positions: positions,
  2928. width: 10.0,
  2929. material: _self._materialPolylineArrowProperty({
  2930. color: color,
  2931. })
  2932. }
  2933. })
  2934. /* 设置类型 */
  2935. coordinateAxisEntity.setEditType({
  2936. type: DrawTools.EditPointType.CoordinateAxis,
  2937. });
  2938. /* 渲染坐标轴 */
  2939. return this._entities.add(coordinateAxisEntity);
  2940. },
  2941. /**
  2942. * 平移目标点
  2943. * @ignore 生成方法时不对外公开
  2944. * @param {Cesium.Cartesian3} originPosition 参考点
  2945. * @param {Cesium.Cartesian3} translateCartesian 平移距离
  2946. * @return {Cesium.Cartesian3}
  2947. */
  2948. _getTranslatePostion: function(originPosition, translateCartesian) {
  2949. let transform = Cesium.Transforms.eastNorthUpToFixedFrame(originPosition); //东-北-上参考系构造出4*4的矩阵
  2950. let m = new Cesium.Matrix4();
  2951. Cesium.Matrix4.setTranslation(
  2952. Cesium.Matrix4.IDENTITY,
  2953. translateCartesian,
  2954. m
  2955. ); //构造平移矩阵
  2956. let modelMatrix = Cesium.Matrix4.multiply(transform, m, transform); //将当前位置矩阵乘以平移矩阵得到平移之后的位置矩阵
  2957. let outPosition = new Cesium.Cartesian3(0, 0, 0);
  2958. Cesium.Matrix4.getTranslation(modelMatrix, outPosition); //从位置矩阵中取出坐标信息
  2959. return outPosition;
  2960. },
  2961. /**
  2962. * 创建3个坐标轴
  2963. * @ignore 生成方法时不对外公开
  2964. * @param {Cesium.Cartesian3} position 坐标轴中心点位置
  2965. */
  2966. _createCoordinateAxis: function(position) {
  2967. this._showTooltipMessage('单击右键移除调整轴线!');
  2968. /* 创建坐标轴之前先移除已创建的坐标轴 */
  2969. this._removeCoorinateAxis();
  2970. let _self = this;
  2971. /* 获取相机在世界坐标系中的正确方向 */
  2972. let cameraRight = this._viewer.scene.camera.rightWC;
  2973. this._tx = cameraRight.x > 0 ? 150 : -150;
  2974. this._ty = cameraRight.y > 0 ? 150 : -150;
  2975. this._tz = 150;
  2976. /* 坐标轴的Id */
  2977. this._coordinateAxisEntityId_x = 'coordinateAxisId_x';
  2978. this._coordinateAxisEntityId_y = 'coordinateAxisId_y';
  2979. this._coordinateAxisEntityId_z = 'coordinateAxisId_z';
  2980. /* 坐标轴的名称 */
  2981. this._coordinateAxisEntityName = "coordinateAxisEntity";
  2982. /* 创建X轴 */
  2983. let translateCartesian = new Cesium.Cartesian3(this._tx, 0, 0); //单位为米
  2984. let endPosition = this._getTranslatePostion(position, translateCartesian);
  2985. const xPos = [position, endPosition];
  2986. this._coordinateEntity_x = this._createSingleCoordinateAxisArrow(xPos, 'rgba(0,255,0,1.0)', this
  2987. ._coordinateAxisEntityId_x);
  2988. /* 给坐标轴绑定编辑实体 */
  2989. this._coordinateAxisBindEntity(this._coordinateEntity_x);
  2990. /* 创建Y轴 */
  2991. translateCartesian = new Cesium.Cartesian3(0, this._ty, 0); //单位为
  2992. endPosition = this._getTranslatePostion(position, translateCartesian);
  2993. const yPos = [position, endPosition];
  2994. this._coordinateEntity_y = this._createSingleCoordinateAxisArrow(yPos, 'rgba(0,0,255,1.0)', this
  2995. ._coordinateAxisEntityId_y);
  2996. /* 给坐标轴绑定编辑实体 */
  2997. this._coordinateAxisBindEntity(this._coordinateEntity_y);
  2998. /* 创建Z轴 */
  2999. translateCartesian = new Cesium.Cartesian3(0, 0, this._tz); //单位为
  3000. endPosition = this._getTranslatePostion(position, translateCartesian);
  3001. const zPos = [position, endPosition];
  3002. this._coordinateEntity_z = this._createSingleCoordinateAxisArrow(zPos, 'rgba(255,0,0,1.0)', this
  3003. ._coordinateAxisEntityId_z);
  3004. /* 给坐标轴绑定编辑实体 */
  3005. this._coordinateAxisBindEntity(this._coordinateEntity_z);
  3006. /* 注册坐标轴事件 */
  3007. this._eventCoorinateAxis = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  3008. this._registerLeftDownEvent(this._eventCoorinateAxis, function(event) {
  3009. _self._coorinateAxisMouseDown(event);
  3010. });
  3011. this._registerMouseMoveEvent(this._eventCoorinateAxis, function(event) {
  3012. _self._coorinateAxisMouseMove(event);
  3013. });
  3014. this._registerLeftUpEvent(this._eventCoorinateAxis, function(event) {
  3015. _self._coorinateAxisMouseUp(event);
  3016. });
  3017. this._registerRightClickEvent(this._eventCoorinateAxis, function(event) {
  3018. _self._removeCoorinateAxis();
  3019. });
  3020. },
  3021. /**
  3022. * 给坐标轴绑定编辑的实体
  3023. * @ignore 生成方法时不对外公开
  3024. * @param {Cesium.Entity} axisEntity 轴实体
  3025. */
  3026. _coordinateAxisBindEntity: function(axisEntity) {
  3027. if (this._editEntity === undefined) return;
  3028. /* 获取当前编辑的实体类型 */
  3029. let editEntityType = this._editEntity.getEntityType();
  3030. if (editEntityType === undefined) return;
  3031. if (editEntityType === DrawTools.DrawType.VideoWall) {
  3032. axisEntity.bindEntity(this._editEntity);
  3033. }
  3034. },
  3035. /**
  3036. * 坐标轴鼠标按下事件
  3037. * @ignore 生成方法时不对外公开
  3038. * @param {Cesium.Event} event 事件
  3039. */
  3040. _coorinateAxisMouseDown: function(event) {
  3041. let _self = this;
  3042. let feature = this._viewer.scene.pick(event.position);
  3043. if (feature === undefined) return;
  3044. if (feature.id != undefined && feature.id instanceof Cesium.Entity) {
  3045. this._viewer.scene.screenSpaceCameraController.enableRotate = false;
  3046. if (feature.id.getEditType() === undefined) return;
  3047. let entityType = feature.id.getEditType().type;
  3048. if (entityType !== DrawTools.EditPointType.CoordinateAxis) return;
  3049. this._editCoorinateAxis = feature.id;
  3050. this._editCoorinateAxis.polyline.width = 15;
  3051. /* 设置坐标移动起始点 */
  3052. this._coordinateAxisMoveStartPosition = this._viewer.scene.camera.pickEllipsoid(event.position,
  3053. this._viewer.scene.globe.ellipsoid);
  3054. this._coordinateAxisMoveStartScreen = event.position;
  3055. this._coorinateAxisPosition = this._editCoorinateAxis.position._value;
  3056. /* 设置动态 */
  3057. this._coordinateEntity_x.polyline.positions = new Cesium.CallbackProperty(function() {
  3058. let translateCartesian = new Cesium.Cartesian3(_self._tx, 0, 0); //单位为米
  3059. let endPosition = _self._getTranslatePostion(_self._coorinateAxisPosition,
  3060. translateCartesian);
  3061. return [_self._coorinateAxisPosition, endPosition];
  3062. }, false);
  3063. this._coordinateEntity_y.polyline.positions = new Cesium.CallbackProperty(function() {
  3064. let translateCartesian = new Cesium.Cartesian3(0, _self._ty, 0); //单位为米
  3065. let endPosition = _self._getTranslatePostion(_self._coorinateAxisPosition,
  3066. translateCartesian);
  3067. return [_self._coorinateAxisPosition, endPosition];
  3068. }, false);
  3069. this._coordinateEntity_z.polyline.positions = new Cesium.CallbackProperty(function() {
  3070. let translateCartesian = new Cesium.Cartesian3(0, 0, _self._tz); //单位为米
  3071. let endPosition = _self._getTranslatePostion(_self._coorinateAxisPosition,
  3072. translateCartesian);
  3073. return [_self._coorinateAxisPosition, endPosition];
  3074. }, false);
  3075. /* 激活平移实体 */
  3076. this._coordinateAxisActivateEditEntity(this._editCoorinateAxis);
  3077. }
  3078. },
  3079. /**
  3080. * 坐标轴鼠标移动事件
  3081. * @ignore 生成方法时不对外公开
  3082. * @param {Cesium.Event} event 事件
  3083. */
  3084. _coorinateAxisMouseMove: function(event) {
  3085. if (!Cesium.defined(this._editCoorinateAxis)) return;
  3086. let position = this._viewer.scene.camera.pickEllipsoid(event.endPosition,
  3087. this._viewer.scene.globe.ellipsoid);
  3088. if (!position) return;
  3089. let strGeo = this._cartesian3ToGeo(this._coordinateAxisMoveStartPosition);
  3090. let endGeo = this._cartesian3ToGeo(position);
  3091. let entityId = this._editCoorinateAxis.id;
  3092. let entityPosition = this._editCoorinateAxis.position._value;
  3093. let entityGeo = this._cartesian3ToGeo(entityPosition);
  3094. let heightDifference = 0;
  3095. if (entityId === this._coordinateAxisEntityId_x) {
  3096. let difference = strGeo.longitude - endGeo.longitude;
  3097. entityGeo.longitude = entityGeo.longitude - difference;
  3098. } else if (entityId === this._coordinateAxisEntityId_y) {
  3099. let difference = strGeo.latitude - endGeo.latitude;
  3100. entityGeo.latitude = entityGeo.latitude - difference;
  3101. } else if (entityId === this._coordinateAxisEntityId_z) {
  3102. heightDifference = event.endPosition.y - this._coordinateAxisMoveStartScreen.y;
  3103. heightDifference = heightDifference * 0.5;
  3104. entityGeo.height = entityGeo.height - heightDifference;
  3105. }
  3106. this._coorinateAxisPosition = Cesium.Cartesian3.fromDegrees(entityGeo.longitude, entityGeo
  3107. .latitude, entityGeo.height);
  3108. this._moveEditEntityByCoordinateAxis(entityPosition, this._coorinateAxisPosition, heightDifference);
  3109. },
  3110. /**
  3111. * 坐标轴鼠标抬起事件
  3112. * @ignore 生成方法时不对外公开
  3113. * @param {Cesium.Event} event 事件
  3114. */
  3115. _coorinateAxisMouseUp: function(event) {
  3116. this._viewer.scene.screenSpaceCameraController.enableRotate = true;
  3117. if (this._editCoorinateAxis !== undefined) {
  3118. this._editCoorinateAxis.polyline.width = 10;
  3119. /* 确定最终位置 */
  3120. let translateCartesian = new Cesium.Cartesian3(this._tx, 0, 0); //单位为米
  3121. let endPosition = this._getTranslatePostion(this._coorinateAxisPosition, translateCartesian);
  3122. this._coordinateEntity_x.polyline.positions = [this._coorinateAxisPosition, endPosition];
  3123. translateCartesian = new Cesium.Cartesian3(0, this._ty, 0); //单位为米
  3124. endPosition = this._getTranslatePostion(this._coorinateAxisPosition, translateCartesian);
  3125. this._coordinateEntity_y.polyline.positions = [this._coorinateAxisPosition, endPosition]
  3126. translateCartesian = new Cesium.Cartesian3(0, 0, this._tz); //单位为米
  3127. endPosition = this._getTranslatePostion(this._coorinateAxisPosition, translateCartesian);
  3128. this._coordinateEntity_z.polyline.positions = [this._coorinateAxisPosition, endPosition];
  3129. this._coordinateEntity_x.position = this._coorinateAxisPosition;
  3130. this._coordinateEntity_y.position = this._coorinateAxisPosition;
  3131. this._coordinateEntity_z.position = this._coorinateAxisPosition;
  3132. /* 结束并更新坐标轴绑定的实体 */
  3133. this._coordinateAxisUpdateEditEntity(this._editCoorinateAxis);
  3134. this._editCoorinateAxis = undefined;
  3135. }
  3136. },
  3137. /**
  3138. * 通过移动坐标轴移动编辑实体
  3139. * @ignore 生成方法时不对外公开
  3140. * @param {Cesium.Cartesian3} strPosition 起始位置
  3141. * @param {Cesium.Cartesian3} endPosition 终止位置
  3142. * @param {Number} heightDifference 高度差
  3143. */
  3144. _moveEditEntityByCoordinateAxis: function(strPosition, endPosition, heightDifference) {
  3145. /* 计算平移距离 */
  3146. let movePosition = Cesium.Cartesian3.subtract(endPosition, strPosition, new Cesium.Cartesian3());
  3147. for (let i = 0; i < this._moveInitPositions.length; i++) {
  3148. let moveResult = Cesium.Cartesian3.add(this._moveInitPositions[i], movePosition, new Cesium
  3149. .Cartesian3());
  3150. this._moveUpdatePositions[i] = moveResult.clone();
  3151. }
  3152. for (let i = 0; i < this._moveInitHeights.length; i++) {
  3153. this._moveUpdateHeights[i] = parseFloat(this._moveInitHeights[i]) + heightDifference * (-1);
  3154. }
  3155. },
  3156. /**
  3157. * 激活当前拖拽的坐标轴关联的实体
  3158. * @ignore 生成方法时不对外公开
  3159. * @param {Cesium.Entity} moveAxisEntity 当前拖拽的坐标轴
  3160. */
  3161. _coordinateAxisActivateEditEntity: function(moveAxisEntity) {
  3162. let _self = this;
  3163. /* 获取坐标轴绑定的实体 */
  3164. let bindEntity = moveAxisEntity.getBindEntity();
  3165. if (bindEntity === undefined) return;
  3166. let bindEntityType = bindEntity.getEntityType();
  3167. if (bindEntityType === DrawTools.DrawType.VideoWall) {
  3168. /* 初始数据集合 */
  3169. let wall = bindEntity.wall;
  3170. this._moveInitPositions = wall.positions._value;
  3171. this._moveInitHeights = wall.minimumHeights._value;
  3172. this._moveInitHeight = wall.maximumHeights._value[0] - wall.minimumHeights._value[0];
  3173. /* 平面移动数据点 */
  3174. this._moveUpdatePositions = [];
  3175. for (let i = 0; i < this._moveInitPositions.length; i++) {
  3176. this._moveUpdatePositions.push(this._moveInitPositions[i].clone());
  3177. }
  3178. /* 设置属性回调变更 */
  3179. wall.positions = new Cesium.CallbackProperty(function() {
  3180. return _self._moveUpdatePositions;
  3181. }, false);
  3182. /* 高度移动点 */
  3183. this._moveUpdateHeights = [];
  3184. for (let i = 0; i < this._moveInitHeights.length; i++) {
  3185. this._moveUpdateHeights.push(this._moveInitHeights[i]);
  3186. }
  3187. /* 设置属性回调变更 */
  3188. wall.minimumHeights = new Cesium.CallbackProperty(function() {
  3189. return _self._moveUpdateHeights;
  3190. }, false);
  3191. wall.maximumHeights = new Cesium.CallbackProperty(function() {
  3192. let maxHeights = [];
  3193. for (let i = 0; i < _self._moveUpdateHeights.length; i++) {
  3194. maxHeights.push(parseFloat(_self._moveUpdateHeights[i]) + _self
  3195. ._moveInitHeight);
  3196. }
  3197. return maxHeights;
  3198. }, false);
  3199. }
  3200. },
  3201. /**
  3202. * 更新当前坐标轴绑定的实体
  3203. * @ignore 生成方法时不对外公开
  3204. * @param {Cesium.Entity} moveAxisEntity 当前拖拽的坐标轴
  3205. */
  3206. _coordinateAxisUpdateEditEntity: function(moveAxisEntity) {
  3207. /* 获取坐标轴绑定的实体 */
  3208. let bindEntity = moveAxisEntity.getBindEntity();
  3209. if (bindEntity === undefined) return;
  3210. let bindEntityType = bindEntity.getEntityType();
  3211. if (bindEntityType === DrawTools.DrawType.VideoWall) {
  3212. /* 初始数据机 */
  3213. let wall = bindEntity.wall;
  3214. /* 更新属性 */
  3215. wall.positions = this._moveUpdatePositions;
  3216. wall.minimumHeights = this._moveUpdateHeights;
  3217. let maxHeights = [];
  3218. for (let i = 0; i < this._moveUpdateHeights.length; i++) {
  3219. maxHeights.push(parseFloat(this._moveUpdateHeights[i]) + this._moveInitHeight);
  3220. }
  3221. wall.maximumHeights = maxHeights;
  3222. }
  3223. },
  3224. /**
  3225. * 计算实体转换后的方向
  3226. * @ignore 生成方法时不对外公开
  3227. * @param {Cesium.Entity} entity 实体
  3228. * @param {JSON} options 配置项
  3229. * @param {Number} options.x 绕X轴旋转 度
  3230. * @param {Number} options.y 绕Y轴旋转 度
  3231. * @param {Number} options.z 绕Z轴旋转 度
  3232. */
  3233. _coordinateCalculateEntityOrientation: function(entity, options) {
  3234. /* 获取实体的位置 */
  3235. let position = entity.position._value;
  3236. /* 获取实体的朝向 */
  3237. let orientation = entity.orientation === undefined ? new Cesium.Cartesian3(0, 0, 0) : entity
  3238. .orientation._value;
  3239. /* 根据方向、朝向和缩放计算4*4矩阵 */
  3240. let transform = Cesium.Matrix4.fromTranslationQuaternionRotationScale(position, orientation,
  3241. new Cesium.Cartesian3(1, 1, 1), new Cesium.Matrix4());
  3242. /* 计算3个轴的3*3旋转矩阵 */
  3243. let _rotateX = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.x));
  3244. let _rotateY = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.y));
  3245. let _rotateZ = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.z));
  3246. /* 计算4*4旋转矩阵 */
  3247. transform = Cesium.Matrix4.multiplyByMatrix3(transform, _rotateX, transform);
  3248. transform = Cesium.Matrix4.multiplyByMatrix3(transform, _rotateY, transform);
  3249. transform = Cesium.Matrix4.multiplyByMatrix3(transform, _rotateZ, transform);
  3250. /* 4*4旋转矩阵转换为3*3旋转矩阵 */
  3251. let m3 = Cesium.Matrix4.getRotation(transform, new Cesium.Matrix3());
  3252. /* 转换旋转矩阵转换为齐次坐标 */
  3253. let resOrientation = new Cesium.Quaternion();
  3254. Cesium.Quaternion.fromRotationMatrix(m3, resOrientation);
  3255. return resOrientation;
  3256. },
  3257. /**
  3258. * 移除坐标轴
  3259. * @ignore 生成方法时不对外公开
  3260. */
  3261. _removeCoorinateAxis: function() {
  3262. if (this._coordinateAxisEntityName !== undefined) {
  3263. this._removeEntityByName(this._coordinateAxisEntityName);
  3264. }
  3265. if (this._eventCoorinateAxis !== undefined) {
  3266. this._clearEvent(this._eventCoorinateAxis);
  3267. this._eventCoorinateAxis = undefined;
  3268. }
  3269. }
  3270. });
  3271. /**
  3272. * 实体编辑相关方法
  3273. */
  3274. Object.assign(DrawTools.prototype, {
  3275. /**
  3276. * 设置实体可编辑,编辑的实体必须包含编辑类型
  3277. * @ignore 生成方法时不对外公开
  3278. * @param {Cesium.Entity} entity 编辑的实体
  3279. */
  3280. _setEntityIsEdit(entity) {
  3281. let _self = this;
  3282. /* 设置实体要素可编辑 */
  3283. entity.setIsEdit(true);
  3284. /* 先撤销编辑 */
  3285. this._unActivateEdit();
  3286. /* 激活编辑 并显示属性编辑框 */
  3287. this._sendShowPropertyDialog(entity);
  3288. /* 注册统一事件 用于单击拾取实体 */
  3289. let handler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  3290. this._registerLeftClickEvent(handler, function(event) {
  3291. /* 只要点击 就清除选中状态 */
  3292. _self._unActivateEdit();
  3293. let feature = _self._viewer.scene.pick(event.position);
  3294. if (feature !== undefined && feature.id instanceof Cesium.Entity) {
  3295. _self._sendShowPropertyDialog(feature.id);
  3296. }
  3297. })
  3298. },
  3299. /**
  3300. * 打开实体编辑对话框
  3301. * @ignore 生成方法时不对外公开
  3302. * @param {Cesium.Entity} entity
  3303. */
  3304. _sendShowPropertyDialog(entity) {
  3305. let _self = this;
  3306. /* 获取可编辑实体的类型 */
  3307. let editEntityType = entity.getEntityType();
  3308. if (entity.getIsEdit() === undefined || entity.getIsEdit() === false ||
  3309. editEntityType === undefined) {
  3310. /* 选择的实体不可编辑 */
  3311. this._unActivateEdit();
  3312. return;
  3313. }
  3314. /* 编辑属性 */
  3315. let editProperty = entity.getParams();
  3316. if (editEntityType === DrawTools.DrawType.OdLine) {
  3317. editProperty = entity.parent.getParams();
  3318. }
  3319. this._console('选择实体的属性', editProperty);
  3320. if (editProperty !== undefined && this.onEditProperty !== undefined) {
  3321. /* 改进后不在对外提供监听事件 改为内部流转 */
  3322. // this.onEditProperty(editProperty);
  3323. /* 更改测试 */
  3324. this._openPropertyEditDialog(editProperty, function(params) {
  3325. _self.updateEditEntityProperty(params);
  3326. }, function() {
  3327. _self._removeEditEntity();
  3328. });
  3329. }
  3330. this._activateEdit(entity);
  3331. },
  3332. /**
  3333. * 删除当前编辑实体
  3334. */
  3335. _removeEditEntity() {
  3336. if (this._editEntity !== undefined) {
  3337. this._console('移除实体', this._editEntity);
  3338. let entityType = this._editEntity.getEntityType();
  3339. if (entityType === DrawTools.DrawType.OdLine) {
  3340. let fatherEntityId = this._editEntity.parent.id;
  3341. let removeEntitys = [];
  3342. for (let entity of this._entities.values) {
  3343. if (entity.parent !== undefined && entity.parent.id === fatherEntityId) {
  3344. removeEntitys.push(entity);
  3345. }
  3346. }
  3347. for (let removeEntity of removeEntitys) {
  3348. this._removeEntityByObject(removeEntity);
  3349. }
  3350. } else {
  3351. this._removeEntityByObject(this._editEntity);
  3352. }
  3353. this._unActivateEdit();
  3354. this._editEntity = undefined;
  3355. }
  3356. },
  3357. /**
  3358. * 更新当前编辑的实体属性
  3359. * @param {JSON} params
  3360. */
  3361. updateEditEntityProperty: function(params) {
  3362. let _self = this;
  3363. if (this._editEntity === undefined) return;
  3364. if (this._editEntity.getIsEdit() === undefined || this._editEntity.getIsEdit() === false) return;
  3365. let editEntityType = this._editEntity.getEntityType();
  3366. if (editEntityType === undefined) return;
  3367. if (editEntityType === DrawTools.DrawType.NormalWall || editEntityType === DrawTools.DrawType
  3368. .DynamicWall || editEntityType === DrawTools.DrawType.TextWall) {
  3369. this._updateWallProperty(params);
  3370. } else if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools.DrawType
  3371. .DynamicCircle) {
  3372. this._updateCircleProperty(params);
  3373. } else if (editEntityType === DrawTools.DrawType.House) {
  3374. this._updateHouseProperty(params);
  3375. } else if (editEntityType === DrawTools.DrawType.VideoWall) {
  3376. this._updateVideoWallProperty(params);
  3377. } else if (editEntityType === DrawTools.DrawType.Polyline) {
  3378. this._updatePolylineProperty(params);
  3379. } else if (editEntityType === DrawTools.DrawType.Polygon) {
  3380. this._updatePolygonProperty(params);
  3381. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  3382. this._updateRectangleProperty(params);
  3383. } else if (editEntityType === DrawTools.DrawType.SpatialLine) {
  3384. this._updateSpatialPolylineProperty(params);
  3385. } else if (editEntityType === DrawTools.DrawType.OdLine) {
  3386. this._updateOdlineProperty(params);
  3387. }
  3388. },
  3389. /**
  3390. * 更新OD线属性
  3391. * @ignore 不公开方法
  3392. * @param {Object} params
  3393. */
  3394. _updateOdlineProperty(params) {
  3395. let _self = this;
  3396. /* 获取父实体Id */
  3397. let fatherEntity = this._editEntity.parent;
  3398. /* 当前编辑OD线集合 */
  3399. this._editOdlineEntities = [];
  3400. /* 循环集合寻找符合条件的实体 */
  3401. for (let entity of this._entities.values) {
  3402. if (entity.parent !== undefined && entity.parent.id === fatherEntity.id) {
  3403. this._editOdlineEntities.push(entity);
  3404. }
  3405. }
  3406. let meterialImage = this._image_arrow_reverse;
  3407. if (params.order === this._param.order_add) {
  3408. meterialImage = this._image_arrow_reverse;
  3409. } else if (params.order === this._param.order_minus) {
  3410. meterialImage = this._image_arrow_forward;
  3411. }
  3412. /* 创建OD线材质 */
  3413. let odLineMaterial = new WallMaterialProperty({
  3414. viewer: _self._viewer,
  3415. trailImage: meterialImage,
  3416. duration: params.duration,
  3417. color: Cesium.Color.fromCssColorString(params.color),
  3418. param: {
  3419. direction: params.direction,
  3420. count: params.count,
  3421. order: params.order,
  3422. },
  3423. });
  3424. /* 循环处理需要编辑的实体 */
  3425. for (let entity of this._editOdlineEntities) {
  3426. entity.polyline.material = odLineMaterial;
  3427. /* 获取OD线的位置 */
  3428. let positions = entity.polyline.positions._value;
  3429. let strPoint = positions.first();
  3430. let endPoint = positions.last();
  3431. let newPositios = this._calculateOdlinePositios(strPoint, endPoint, parseInt(params.odlineHeight),
  3432. parseInt(params.odlineCount));
  3433. /* 设置OD线新位置 */
  3434. entity.polyline.positions = newPositios;
  3435. entity.polyline.width = parseInt(params.lineWidth);
  3436. }
  3437. /* 重置材质 */
  3438. fatherEntity.setParams(params);
  3439. },
  3440. /**
  3441. * 更新空间线属性
  3442. * @ignore 不公开方法
  3443. * @param {Object} params
  3444. */
  3445. _updateSpatialPolylineProperty(params) {
  3446. let material = this._editEntity.polyline.material;
  3447. let newMaterial = undefined;
  3448. if (material instanceof Cesium.ColorMaterialProperty) {
  3449. newMaterial = this._materialColorProperty({
  3450. color: params.color,
  3451. });
  3452. }
  3453. /* 设置材质 */
  3454. if (newMaterial !== undefined) this._editEntity.polyline.material = newMaterial;
  3455. this._editEntity.polyline.width = parseFloat(params.lineWidth);
  3456. /* 重新关联墙实体的属性 */
  3457. this._editEntity.setParams(params);
  3458. },
  3459. /**
  3460. * 更新矩形属性
  3461. * @ignore 不公开方法
  3462. * @param {Object} params
  3463. */
  3464. _updateRectangleProperty(params) {
  3465. let material = this._editEntity.rectangle.material;
  3466. if (material instanceof Cesium.ColorMaterialProperty) {
  3467. let newMaterial = this._materialColorProperty({
  3468. color: params.color,
  3469. });
  3470. this._editEntity.rectangle.material = newMaterial;
  3471. }
  3472. if (this._editEntity.polyline !== undefined) {
  3473. let newMaterial = this._materialColorProperty({
  3474. color: params.outlineColor,
  3475. });
  3476. this._editEntity.polyline.material = newMaterial;
  3477. this._editEntity.polyline.width = parseFloat(params.outlineWidth);
  3478. }
  3479. /* 重新关联墙实体的属性 */
  3480. this._editEntity.setParams(params);
  3481. },
  3482. /**
  3483. * 更新面的属性
  3484. * @ignore 不公开方法
  3485. * @param {Object} params
  3486. */
  3487. _updatePolygonProperty(params) {
  3488. let material = this._editEntity.polygon.material;
  3489. if (material instanceof Cesium.ColorMaterialProperty) {
  3490. let newMaterial = this._materialColorProperty({
  3491. color: params.color,
  3492. });
  3493. this._editEntity.polygon.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. _updatePolylineProperty(params) {
  3511. let material = this._editEntity.polyline.material;
  3512. let newMaterial = undefined;
  3513. if (material instanceof Cesium.ColorMaterialProperty) {
  3514. newMaterial = this._materialColorProperty({
  3515. color: params.color,
  3516. });
  3517. } else if (material instanceof Cesium.PolylineArrowMaterialProperty) {
  3518. newMaterial = this._materialPolylineArrowProperty({
  3519. color: params.color,
  3520. });
  3521. } else if (material instanceof WallMaterialProperty) {
  3522. /* 设置方向对应图片 */
  3523. let materialImage = this._image_h_l_r;
  3524. if (params.order === this._param.order_minus) {
  3525. materialImage = this._image_h_r_l;
  3526. } else if (params.order === this._param.order_add) {
  3527. materialImage = this._image_h_l_r;
  3528. }
  3529. newMaterial = new WallMaterialProperty({
  3530. viewer: this._viewer,
  3531. trailImage: materialImage,
  3532. duration: params.duration,
  3533. color: Cesium.Color.fromCssColorString(params.color),
  3534. param: {
  3535. count: parseInt(params.count),
  3536. direction: params.direction,
  3537. order: params.order,
  3538. }
  3539. });
  3540. } else if (material instanceof Cesium.PolylineGlowMaterialProperty) {
  3541. newMaterial = this._materialPolylineGlowProperty({
  3542. color: params.color,
  3543. power: parseFloat(params.power),
  3544. })
  3545. } else if (material instanceof Cesium.PolylineOutlineMaterialProperty) {
  3546. newMaterial = this._materialPolylineOutlineProperty({
  3547. color: params.color,
  3548. outlineWidth: parseFloat(params.outlineWidth),
  3549. outlineColor: params.outlineColor,
  3550. })
  3551. }
  3552. /* 设置材质 */
  3553. if (newMaterial !== undefined) this._editEntity.polyline.material = newMaterial;
  3554. this._editEntity.polyline.width = params.lineWidth;
  3555. /* 重新关联墙实体的属性 */
  3556. this._editEntity.setParams(params);
  3557. },
  3558. /**
  3559. * 更新房屋属性
  3560. * @ignore 不公开方法
  3561. * @param {Object} params
  3562. */
  3563. _updateHouseProperty(params) {
  3564. let entityParams = this._editEntity.getParams();
  3565. let polygonMaterial = this._editEntity.polygon.material;
  3566. if (polygonMaterial instanceof Cesium.ColorMaterialProperty) {
  3567. let material = this._materialColorProperty({
  3568. color: params.color,
  3569. });
  3570. /* 设置材质 */
  3571. this._editEntity.polygon.material = material;
  3572. /* 设置高度 */
  3573. this._editEntity.polygon.extrudedHeight = parseFloat(params.height) + parseFloat(
  3574. entityParams.bottomHeight);
  3575. /* 重新关联墙实体的属性 */
  3576. this._editEntity.setParams(params);
  3577. }
  3578. },
  3579. /**
  3580. * 更新圆的属性
  3581. * @ignore 不公开方法
  3582. * @param {Object} params
  3583. */
  3584. _updateCircleProperty(params) {
  3585. let circleMaterial = this._editEntity.ellipse.material;
  3586. if (circleMaterial instanceof CircleMaterialProperty) {
  3587. let material = new CircleMaterialProperty({
  3588. viewer: this._viewer,
  3589. duration: params.duration,
  3590. color: Cesium.Color.fromCssColorString(params.color),
  3591. count: parseFloat(params.count),
  3592. });
  3593. this._editEntity.ellipse.material = material;
  3594. } else if (circleMaterial instanceof Cesium.ColorMaterialProperty) {
  3595. let material = this._materialColorProperty({
  3596. color: params.color,
  3597. });
  3598. this._editEntity.ellipse.material = material;
  3599. if (this._editEntity.polyline !== undefined) {
  3600. let newMaterial = this._materialColorProperty({
  3601. color: params.outlineColor,
  3602. });
  3603. this._editEntity.polyline.material = newMaterial;
  3604. this._editEntity.polyline.width = parseFloat(params.outlineWidth);
  3605. }
  3606. }
  3607. /* 重新关联墙实体的属性 */
  3608. this._editEntity.setParams(params);
  3609. },
  3610. /**
  3611. * 更新视频墙的属性
  3612. * @ignore 不公开方法
  3613. * @param {Object} params
  3614. */
  3615. _updateVideoWallProperty(params) {
  3616. /* 查找视频画布 */
  3617. let videoElement = document.getElementById('wallVideo');
  3618. if (videoElement !== null) {
  3619. document.body.removeChild(videoElement);
  3620. }
  3621. videoElement = document.createElement("video");
  3622. videoElement.id = 'wallVideo';
  3623. videoElement.setAttribute('crossorigin', 'anonymous'); //必须设置 为了防止跨域调用网络视频导致播放失败
  3624. videoElement.setAttribute("width", "1024px");
  3625. videoElement.setAttribute("height", "256px");
  3626. videoElement.setAttribute("controls", "controls");
  3627. videoElement.setAttribute("src", params.videoUrl);
  3628. videoElement.setAttribute("loop", "loop");
  3629. videoElement.play();
  3630. document.body.appendChild(videoElement);
  3631. /* 更新数据 */
  3632. let minimumHeights = this._editEntity.wall.minimumHeights._value;
  3633. /* 更新最大高度 */
  3634. let maximumHeights = [];
  3635. for (let i = 0; i < minimumHeights.length; i++) {
  3636. maximumHeights.push(minimumHeights[i] + parseFloat(params.height));
  3637. }
  3638. this._editEntity.wall.maximumHeights = maximumHeights;
  3639. this._editEntity.wall.material = videoElement;
  3640. /* 更新平移位置 */
  3641. let wallPositions = this._editEntity.wall.positions._value;
  3642. let newPositions = [];
  3643. for (let wallPosition of wallPositions) {
  3644. /* 获取当前位置的东北上坐标系 */
  3645. let transform = Cesium.Transforms.eastNorthUpToFixedFrame(wallPosition);
  3646. /* 构建平移矩阵 */
  3647. let m = new Cesium.Matrix4();
  3648. Cesium.Matrix4.setTranslation(Cesium.Matrix4.IDENTITY, new Cesium.Cartesian3(parseFloat(params.axisX),
  3649. parseFloat(params.axisY), parseFloat(params.axisZ)), m);
  3650. /* 矩阵相乘 */
  3651. let moveMatrix = Cesium.Matrix4.multiply(transform, m, transform);
  3652. /* 提取位置 */
  3653. let newPosition = new Cesium.Cartesian3();
  3654. Cesium.Matrix4.getTranslation(moveMatrix, newPosition);
  3655. newPositions.push(newPosition);
  3656. }
  3657. this._editEntity.wall.positions = newPositions;
  3658. /* 将平移距离设置为0 */
  3659. params.axisX = params.axisY = params.axisZ = 0
  3660. /* 重新关联墙实体的属性 */
  3661. this._editEntity.setParams(params);
  3662. /* 重置调整坐标轴 已保证坐标轴的位置正确+ */
  3663. this._activateEdit(this._editEntity);
  3664. },
  3665. /**
  3666. * 更新墙的属性
  3667. * @ignore 不公开方法
  3668. * @param {Object} params
  3669. */
  3670. _updateWallProperty(params) {
  3671. let minHeights = this._editEntity.wall.minimumHeights._value;
  3672. let maxHeights = [];
  3673. for (let i = 0; i < minHeights.length; i++) {
  3674. maxHeights.push(minHeights[i] + parseFloat(params.height));
  3675. }
  3676. /* 设置墙的最大高度 */
  3677. this._editEntity.wall.maximumHeights = maxHeights;
  3678. /* 更改存储墙的最大高度的数组 */
  3679. this._sketchWallMaxHeights = maxHeights;
  3680. /* 根据传入的参数id判断需什么材质 */
  3681. let wallMaterial = this._editEntity.wall.material;
  3682. if (wallMaterial instanceof Cesium.ImageMaterialProperty) {
  3683. let material = this._materialTextImageProperty({
  3684. color: params.color,
  3685. text: params.text,
  3686. });
  3687. this._editEntity.wall.material = material;
  3688. } else if (wallMaterial instanceof WallMaterialProperty) {
  3689. /* 判断使用的照片 */
  3690. let materialImage = this._image_h_l_r;
  3691. if (params.direction === this._param.direction_h && params.order === this._param.order_add) {
  3692. materialImage = this._image_h_l_r;
  3693. } else if (params.direction === this._param.direction_h && params.order === this._param.order_add) {
  3694. materialImage = this._image_h_r_l;
  3695. } else if (params.direction === this._param.direction_v && params.order === this._param
  3696. .order_minus) {
  3697. materialImage = this._image_v_t_b;
  3698. } else if (params.direction === this._param.direction_v && params.order === this._param.order_add) {
  3699. materialImage = this._image_v_b_t;
  3700. }
  3701. let material = new WallMaterialProperty({
  3702. viewer: this._viewer,
  3703. trailImage: materialImage,
  3704. duration: params.duration,
  3705. color: Cesium.Color.fromCssColorString(params.color),
  3706. param: {
  3707. count: parseFloat(params.count),
  3708. direction: params.direction,
  3709. order: params.order
  3710. }
  3711. });
  3712. this._editEntity.wall.material = material;
  3713. } else if (wallMaterial instanceof Cesium.ColorMaterialProperty) {
  3714. let material = this._materialColorProperty({
  3715. color: params.color,
  3716. });
  3717. this._editEntity.wall.material = material;
  3718. }
  3719. /* 重新关联墙实体的属性 */
  3720. this._editEntity.setParams(params);
  3721. },
  3722. /**
  3723. * 旋转实体
  3724. * @ignore
  3725. * @param {JSON} options 配置项
  3726. * @param {Number} options.x 绕X轴旋转 度
  3727. * @param {Number} options.y 绕Y轴旋转 度
  3728. * @param {Number} options.z 绕Z轴旋转 度
  3729. */
  3730. rotationEntity(options) {
  3731. if (this._editEntity === undefined) return;
  3732. let orientation = this._coordinateCalculateEntityOrientation(this._editEntity, options);
  3733. },
  3734. /**
  3735. * 获取实体可编辑数据
  3736. * @ignore 生成方法时不对外公开
  3737. * @param {Cesium.Entity} entity 实体
  3738. * @return {Array<Cesium.Cartesian3>} positions
  3739. */
  3740. _getEntityEditData: function(entity) {
  3741. if (entity instanceof Cesium.Entity) {
  3742. /* 获取实体的类型 */
  3743. let editEntityType = entity.getEntityType();
  3744. if (editEntityType === DrawTools.DrawType.Polyline || editEntityType === DrawTools.DrawType
  3745. .SpatialLine) {
  3746. return entity.polyline.positions._value;
  3747. } else if (editEntityType === DrawTools.DrawType.Polygon || editEntityType === DrawTools
  3748. .DrawType.House) {
  3749. let positions = entity.polygon.hierarchy._value.positions;
  3750. /* 判断是否需要加上终点 */
  3751. if (positions[0].x !== positions[positions.length - 1].x) {
  3752. positions.push(positions[0].clone());
  3753. }
  3754. return positions;
  3755. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  3756. let rect = entity.rectangle.coordinates._value;
  3757. /* 计算西北角的位置 */
  3758. let gNw = Cesium.Rectangle.northwest(rect);
  3759. if (gNw.height <= 0) {
  3760. let height = this._queryHeightFromGeo(Cesium.Math.toDegrees(gNw.longitude), Cesium.Math
  3761. .toDegrees(gNw.latitude));
  3762. gNw.height = height;
  3763. }
  3764. let cNw = Cesium.Cartesian3.fromRadians(gNw.longitude, gNw.latitude, gNw.height);
  3765. /* 计算东南角位置 */
  3766. let gSe = Cesium.Rectangle.southeast(rect);
  3767. if (gSe.height <= 0) {
  3768. let height = this._queryHeightFromGeo(Cesium.Math.toDegrees(gSe.longitude), Cesium.Math
  3769. .toDegrees(gSe.latitude));
  3770. gSe.height = height;
  3771. }
  3772. let cSe = Cesium.Cartesian3.fromRadians(gSe.longitude, gSe.latitude, gSe.height);
  3773. /* 组合坐标数组 */
  3774. return [cNw, cSe];
  3775. } else if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools.DrawType
  3776. .DynamicCircle) {
  3777. /* 圆中心点位置 */
  3778. let centerPosition = entity.position._value;
  3779. /* 获取圆的半径 */
  3780. let radius = entity.ellipse.semiMajorAxis._value;
  3781. let cbPoint = this._calculateCircleBoundaryPoint(centerPosition, radius);
  3782. return [centerPosition, cbPoint];
  3783. } else if (editEntityType === DrawTools.DrawType.NormalWall || editEntityType === DrawTools
  3784. .DrawType.DynamicWall || editEntityType === DrawTools.DrawType.TextWall) {
  3785. /* 存储墙的最大高度和最小高度数组 */
  3786. this._sketchWallHeights = [];
  3787. this._sketchWallMaxHeights = [];
  3788. let minHeights = entity.wall.minimumHeights._value;
  3789. let maxHeights = entity.wall.maximumHeights._value;
  3790. for (let i = 0; i < minHeights.length; i++) {
  3791. this._sketchWallHeights.push(minHeights[i]);
  3792. this._sketchWallMaxHeights.push(maxHeights[i]);
  3793. }
  3794. return entity.wall.positions._value;
  3795. } else if (editEntityType === DrawTools.DrawType.VideoWall) {
  3796. let positions = entity.wall.positions._value;
  3797. return [positions[0].clone()];
  3798. } else {
  3799. return [];
  3800. }
  3801. } else {
  3802. return [];
  3803. }
  3804. },
  3805. /**
  3806. * 根据圆的中心点和半径计算边界点坐标位置
  3807. * @ignore 生成方法时不对外公开
  3808. * @param {Cesium.Cartesian3} centerPosition 圆的中心点位置
  3809. * @param {Number} radius 半径
  3810. * @return {Cesium.Cartesian3} boundaryPosition 边界点位置
  3811. */
  3812. _calculateCircleBoundaryPoint: function(centerPosition, radius) {
  3813. let gCenter = Cesium.Ellipsoid.WGS84.cartesianToCartographic(centerPosition);
  3814. /* 计算边界线上的点坐标 */
  3815. let cPoint = turf.point([Cesium.Math.toDegrees(gCenter.longitude), Cesium.Math.toDegrees(
  3816. gCenter.latitude)]);
  3817. let boundaryPoint = turf.destination(cPoint, radius / 1000, 90, {
  3818. units: 'kilometers'
  3819. }).geometry.coordinates;
  3820. /* 查询高度创建边界点 */
  3821. let height = this._queryHeightFromGeo(boundaryPoint[0], boundaryPoint[1]);
  3822. let cbPoint = Cesium.Cartesian3.fromDegrees(boundaryPoint[0], boundaryPoint[1], height);
  3823. return cbPoint;
  3824. },
  3825. /**
  3826. * 根据一组点计算中心点位置
  3827. * @ignore 生成方法时不对外公开
  3828. * @param {Array<Cesium.Cartesian3>} positions 点集合
  3829. */
  3830. _calculateCenterPosition: function(positions) {
  3831. if (positions === undefined || positions.length === 0) return undefined;
  3832. else if (positions.length === 1) {
  3833. return positions[0];
  3834. } else if (positions.length === 2) {
  3835. let pt0 = this._cartesian3ToGeo(positions[0]);
  3836. let pt1 = this._cartesian3ToGeo(positions[1]);
  3837. let point0 = turf.point([pt0.longitude, pt0.latitude]);
  3838. let point1 = turf.point([pt1.longitude, pt1.latitude]);
  3839. let center = turf.midpoint(point0, point1).geometry.coordinates;
  3840. /* 查询高度 */
  3841. let height = this._queryHeightFromGeo(center[0], center[1]);
  3842. /* 返回 */
  3843. return Cesium.Cartesian3.fromDegrees(center[0], center[1], height);
  3844. } else {
  3845. let geoPoints = [
  3846. []
  3847. ];
  3848. for (let i = 0; i < positions.length; i++) {
  3849. /* 将世界坐标转换为经纬度坐标 */
  3850. let geoPoint = this._cartesian3ToGeo(positions[i]);
  3851. geoPoints[0].push([geoPoint.longitude, geoPoint.latitude]);
  3852. }
  3853. geoPoints[0].push(geoPoints[0][0]);
  3854. /* 创建区域 */
  3855. let polygon = turf.polygon(geoPoints);
  3856. /* 计算中心点 */
  3857. let center = turf.centerOfMass(polygon).geometry.coordinates;
  3858. /* 查询高度 */
  3859. let height = this._queryHeightFromGeo(center[0], center[1]);
  3860. /* 返回 */
  3861. return Cesium.Cartesian3.fromDegrees(center[0], center[1], height);
  3862. }
  3863. },
  3864. /**
  3865. * 计算转换后的位置,根据角度和距离计算转换后的位置
  3866. * @ignore 生成方法时不对外公开
  3867. * @param {Cesium.Cartesian3} position 待转换位置
  3868. * @param {Number} distance 距离<距离的表示单位在options中配置>
  3869. * @param {Number} bearing 角度
  3870. * @param {JSON} options 配置项
  3871. * @return {Cesium.Cartesian3} 转换后的位置
  3872. */
  3873. _calculateTransformPosition: function(position, distance, bearing, options) {
  3874. /* 将移动点转换为经纬度格式 */
  3875. let geoPoint = this._cartesian3ToGeo(position);
  3876. /* 根据点的角度度 距离计算移动后的位置 */
  3877. let point = turf.point([geoPoint.longitude, geoPoint.latitude]);
  3878. let resPoint = turf.destination(point, distance, bearing, options).geometry
  3879. .coordinates;
  3880. /* 根据经纬度查询高度 该步骤耗时 且容易出错 */
  3881. let height = geoPoint.height;
  3882. if (options !== undefined && options.calculateHeight !== undefined && options.calculateHeight ===
  3883. true) {
  3884. height = this._queryHeightFromGeo(resPoint[0], resPoint[1]);
  3885. }
  3886. /* 将移动后的点转换为世界坐标系坐标点 */
  3887. let cPosition = Cesium.Cartesian3.fromDegrees(resPoint[0], resPoint[1],
  3888. height);
  3889. /* 返回 */
  3890. return cPosition;
  3891. },
  3892. /**
  3893. * 取消实体编辑激活状态
  3894. * @ignore 生成方法时不对外公开
  3895. */
  3896. _unActivateEdit: function() {
  3897. /* 移除编辑点 */
  3898. this._clearEditPoint();
  3899. /* 删除坐标轴 */
  3900. this._removeCoorinateAxis();
  3901. /* 关闭属性编辑框 */
  3902. this._closePropertyEditDialog();
  3903. },
  3904. /**
  3905. * 激活编辑
  3906. * @ignore 生成方法时不对外公开
  3907. * @param {Cesium.Entity} editEntity 编辑实体
  3908. */
  3909. _activateEdit: function(editEntity) {
  3910. /* 获取编辑类型 */
  3911. let entityType = editEntity.getEntityType();
  3912. /* 获取实体是否可编辑 */
  3913. let entityIsEdit = editEntity.getIsEdit();
  3914. /* 不可编辑对象 直接退出 */
  3915. if (entityIsEdit === undefined || entityType === undefined || entityIsEdit === false) {
  3916. this._console('该实体不可编辑');
  3917. return;
  3918. };
  3919. if (entityType === DrawTools.DrawType.OdLine) {
  3920. this._activeteOdlineEdit(editEntity);
  3921. } else {
  3922. this._activeteNormalEdit(editEntity);
  3923. }
  3924. },
  3925. /**
  3926. * 激活编辑OD线实体
  3927. * @ignore 生成方法时不对外公开
  3928. * @param {Cesium.Entity} editEntity 编辑实体
  3929. */
  3930. _activeteOdlineEdit: function(editEntity) {
  3931. let _self = this;
  3932. let entityType = editEntity.getEntityType();
  3933. /* 不可编辑对象 直接退出 */
  3934. if (entityType === undefined || entityType !== DrawTools.DrawType.OdLine) {
  3935. this._console('该实体不可编辑或该实体不是OD线类型');
  3936. return;
  3937. };
  3938. /* 获取父实体Id */
  3939. let faterEntityId = editEntity.parent.id;
  3940. /* 当前编辑OD线集合 */
  3941. this._editOdlineEntities = [];
  3942. /* 循环集合寻找符合条件的实体 */
  3943. for (let entity of this._entities.values) {
  3944. if (entity.parent !== undefined && entity.parent.id === faterEntityId) {
  3945. this._editOdlineEntities.push(entity);
  3946. }
  3947. }
  3948. /* 不存在可编辑的OD线 */
  3949. if (this._editOdlineEntities.length === 0) return;
  3950. /* 赋值可编辑对象 */
  3951. this._editEntity = this._editOdlineEntities[0];
  3952. for (let i = 0; i < this._editOdlineEntities.length; i++) {
  3953. let entity = this._editOdlineEntities[i];
  3954. let positions = entity.polyline.positions._value;
  3955. if (i === 0) {
  3956. this._createEditOdlineStartPoint(positions.first(), entity);
  3957. this._createEditOdlineEndPoint(positions.last(), entity);
  3958. } else {
  3959. this._createEditOdlineEndPoint(positions.last(), entity);
  3960. }
  3961. }
  3962. /* 创建事件句柄 */
  3963. if (this._sketchEditHandler === undefined) {
  3964. this._sketchEditHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  3965. }
  3966. /* 注册鼠标左键按下事件 */
  3967. this._registerLeftDownEvent(this._sketchEditHandler, function(event) {
  3968. _self._eventEditMouseDown(event);
  3969. });
  3970. /* 注册鼠标左键移动事件 */
  3971. this._registerMouseMoveEvent(this._sketchEditHandler, function(event) {
  3972. _self._eventEditMouseMove(event);
  3973. });
  3974. /* 注册鼠标左键抬起事件 */
  3975. this._registerLeftUpEvent(this._sketchEditHandler, function(event) {
  3976. _self._eventEditMouseUp(event);
  3977. });
  3978. },
  3979. /**
  3980. * 激活编辑单实体
  3981. * @ignore 生成方法时不对外公开
  3982. * @param {Cesium.Entity} editEntity 编辑实体
  3983. */
  3984. _activeteNormalEdit: function(editEntity) {
  3985. let _self = this;
  3986. let positions = this._getEntityEditData(editEntity);
  3987. /* 删除所有临时绘制的点 */
  3988. this._removePointEntitys();
  3989. /* 获取编辑类型 */
  3990. let entityType = editEntity.getEntityType();
  3991. /* 赋值可编辑对象 */
  3992. this._editEntity = editEntity;
  3993. /* 创建节点和中心点 */
  3994. if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools
  3995. .DrawType.DynamicCircle) {
  3996. this._createEditCenterPoint(positions[0]);
  3997. this._createEditNodePoint(positions, 1);
  3998. } else if (entityType === DrawTools.DrawType.VideoWall) {
  3999. if (!this._isRuntimeApp()) {
  4000. /* 如果不是App运行环境,则创建拖动轴 */
  4001. let position = positions[0];
  4002. this._removeCoorinateAxis();
  4003. this._createCoordinateAxis(position);
  4004. }
  4005. } else {
  4006. this._createEditNodePoint(positions);
  4007. let centerPosition = this._calculateCenterPosition(positions);
  4008. if (centerPosition !== undefined) {
  4009. this._createEditCenterPoint(centerPosition);
  4010. }
  4011. }
  4012. /* 创建中点 */
  4013. if (entityType !== DrawTools.DrawType.Rectangle && entityType !== DrawTools
  4014. .DrawType.Circle && entityType !== DrawTools.DrawType.DynamicCircle && entityType !== DrawTools
  4015. .DrawType.VideoWall) {
  4016. if (entityType === DrawTools.DrawType.SpatialLine) {
  4017. this._createEditMiddlePoint(positions, true);
  4018. } else {
  4019. this._createEditMiddlePoint(positions);
  4020. }
  4021. }
  4022. /* 创建事件句柄 */
  4023. if (this._sketchEditHandler === undefined) {
  4024. this._sketchEditHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
  4025. }
  4026. /* 注册鼠标左键按下事件 */
  4027. this._registerLeftDownEvent(this._sketchEditHandler, function(event) {
  4028. _self._eventEditMouseDown(event);
  4029. })
  4030. /* 注册鼠标移动事件 */
  4031. this._registerMouseMoveEvent(this._sketchEditHandler, function(event) {
  4032. _self._eventEditMouseMove(event);
  4033. });
  4034. /* 注册鼠标抬起事件 */
  4035. this._registerLeftUpEvent(this._sketchEditHandler, function(event) {
  4036. _self._eventEditMouseUp(event);
  4037. })
  4038. },
  4039. /**
  4040. * 编辑点鼠标抬起事件
  4041. * @ignore 生成方法时不对外公开
  4042. * @param {Object} event 事件
  4043. */
  4044. _eventEditMouseDown: function(event) {
  4045. let _self = this;
  4046. /* 拾取实体 */
  4047. let feature = _self._viewer.scene.pick(event.position);
  4048. /* 分类处理 */
  4049. if (feature != undefined && feature.id instanceof Cesium.Entity) {
  4050. /* 获取选择实体的样式 */
  4051. let featureType = feature.id.getEditType();
  4052. /* 说明当前选中的实体 不是编辑点 */
  4053. if (featureType === undefined) return;
  4054. /* 禁用场景的旋转移动功能 保留缩放功能 */
  4055. _self._viewer.scene.screenSpaceCameraController.enableRotate = false;
  4056. /* 位置信息 */
  4057. let entityPosition = feature.id.position._value;
  4058. /* 保存当前可编辑的实体 */
  4059. _self._editPointEntity = feature.id;
  4060. /* 设置鼠标样式为十字 */
  4061. _self._setMousePointerStyle();
  4062. /* 判断类型 是节点或中点 进行不同的操作 */
  4063. if (featureType.type === DrawTools.EditPointType.Node || featureType.type ===
  4064. DrawTools.EditPointType.Middle) {
  4065. /* 处理鼠标按下实体的属性变更回调 */
  4066. _self._entityCallbackPropertyByMouseDown();
  4067. /* 移除当前移动的点 */
  4068. _self._removeEntityByObject(_self._editPointEntity);
  4069. /* 删除高空点 */
  4070. if (_self._sketchEditEntitySpatialName != undefined) {
  4071. _self._removeEntityByName(_self._sketchEditEntitySpatialName);
  4072. }
  4073. } else if (featureType.type === DrawTools.EditPointType.Center) {
  4074. _self._entityCenterMouseDownEvent();
  4075. } else if (featureType.type === DrawTools.EditPointType.OdlineEndNode) {
  4076. /* 删除当前移动点 */
  4077. _self._removeEntityByObject(_self._editPointEntity);
  4078. /* 设置当前编辑的实体 */
  4079. _self._editEntity = featureType.joinEntity;
  4080. /* 获取OD线的必要参数 */
  4081. let params = _self._editEntity.parent.getParams();
  4082. _self._sketchEditPoints = [];
  4083. let joinEntityPositions = _self._editEntity.polyline.positions._value;
  4084. _self._sketchEditPoints.push(joinEntityPositions.first());
  4085. _self._sketchEditPoints.push(joinEntityPositions.last());
  4086. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4087. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0], _self
  4088. ._sketchEditPoints[1], parseInt(params.odlineHeight), parseInt(params
  4089. .odlineCount));
  4090. return positions;
  4091. }, false)
  4092. } else if (featureType.type === DrawTools.EditPointType.OdlineStrartNode) {
  4093. /* 删除当前移动点 */
  4094. _self._removeEntityByObject(_self._editPointEntity);
  4095. /* 设置当前编辑的实体 */
  4096. _self._editEntity = featureType.joinEntity;
  4097. /* 获取OD线的必要参数 */
  4098. let params = _self._editEntity.parent.getParams();
  4099. _self._sketchEditPoints = [];
  4100. let joinEntityPositions = _self._editEntity.polyline.positions._value;
  4101. _self._sketchEditPoints.push(joinEntityPositions.first());
  4102. for (let odEntity of _self._editOdlineEntities) {
  4103. let odEntityPositions = odEntity.polyline.positions._value;
  4104. let lastPosition = odEntityPositions.last();
  4105. _self._sketchEditPoints.push(lastPosition.clone());
  4106. odEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4107. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0],
  4108. lastPosition, parseInt(params.odlineHeight), parseInt(params
  4109. .odlineCount));
  4110. return positions;
  4111. }, false);
  4112. }
  4113. }
  4114. /* 根据节点类型不同进行特殊的处理 */
  4115. if (featureType.type === DrawTools.EditPointType.Middle) {
  4116. /* 如果选择的是中点 则插入节点 并记录当前的索引 */
  4117. let index = featureType.index;
  4118. _self._sketchEditPoints.splice(index, 0, entityPosition);
  4119. _self._sketchEditIndex = index;
  4120. /* 如果当前移动的中点为墙的中点,则需要进行特殊处理一下,主要为了修正高度 */
  4121. if (_self._sketchWallHeights != undefined && _self._sketchWallHeights.length >
  4122. 0) {
  4123. /* 查询一下高度 */
  4124. let geoPoint = _self._cartesian3ToGeo(entityPosition);
  4125. let height = _self._queryHeightFromGeo(geoPoint.longitude, geoPoint
  4126. .latitude);
  4127. /* 墙的最小高度加入值 */
  4128. _self._sketchWallHeights.splice(index, 0, height);
  4129. /* 墙的最大高度需要加入值 */
  4130. let heightDifference = _self._sketchWallMaxHeights[0] - _self
  4131. ._sketchWallHeights[0];
  4132. _self._sketchWallMaxHeights.splice(index, 0, height + heightDifference);
  4133. }
  4134. /* 设置提示标签 */
  4135. _self._tooltipInit('拖动中点,改变形状', event.position);
  4136. } else if (featureType.type === DrawTools.EditPointType.Node) {
  4137. /* 如果是节点 则直接记录索引 */
  4138. _self._sketchEditIndex = featureType.index;
  4139. /* 设置提示标签 */
  4140. _self._tooltipInit('拖动节点,改变形状', event.position);
  4141. } else if (featureType.type === DrawTools.EditPointType.Spatial) {
  4142. /* 如果是节点 则直接记录索引 */
  4143. _self._sketchEditIndex = featureType.index;
  4144. /* 设置提示标签 */
  4145. _self._tooltipInit('拖动节点,改变高度', event.position);
  4146. } else if (featureType.type === DrawTools.EditPointType.CoordinateAxis) {
  4147. /* 设置提示标签 */
  4148. _self._tooltipInit('拖动坐标轴,改变位置', event.position);
  4149. } else if (featureType.type === DrawTools.EditPointType.OdlineEndNode || featureType.type ===
  4150. DrawTools.EditPointType.OdlineStrartNode) {
  4151. /* 设置提示标签 */
  4152. _self._tooltipInit('拖动节点,改变OD线位置', event.position);
  4153. }
  4154. }
  4155. },
  4156. /**
  4157. * 编辑点鼠标移动事件
  4158. * @ignore 生成方法时不对外公开
  4159. * @param {Object} event 事件
  4160. */
  4161. _eventEditMouseMove: function(event) {
  4162. let _self = this;
  4163. if (_self._editPointEntity != undefined) {
  4164. let loc = _self._transfromFromScreenPoint(event.endPosition);
  4165. if (!Cesium.defined(loc.sLocation)) return;
  4166. _self._editPosition = loc.sLocation;
  4167. /* 获取当前可编辑点的类型 */
  4168. let editEntityType = _self._editPointEntity.getEditType();
  4169. if (editEntityType.type === DrawTools.EditPointType.Node) {
  4170. _self._sketchEditPoints[_self._sketchEditIndex] = loc.sLocation;
  4171. /* 获取当前编辑的实体的类型 */
  4172. let editEntityType = _self._editEntity.getEntityType();
  4173. if (editEntityType != DrawTools.DrawType.Rectangle &&
  4174. editEntityType != DrawTools.DrawType.Circle && editEntityType != DrawTools
  4175. .DrawType.DynamicCircle) {
  4176. /* 这里对面对象需要进特殊处理 保证第0号点和最后一个点是一致的 */
  4177. if ((editEntityType === DrawTools.DrawType.Polygon || editEntityType ===
  4178. DrawTools.DrawType.House) && _self
  4179. ._sketchEditIndex === 0) {
  4180. _self._sketchEditPoints[_self._sketchEditPoints.length - 1] = loc
  4181. .sLocation;
  4182. } else if (editEntityType === DrawTools.DrawType.NormalWall ||
  4183. editEntityType === DrawTools.DrawType.DynamicWall || editEntityType ===
  4184. DrawTools.DrawType.TextWall) {
  4185. _self._sketchWallHeights[_self._sketchEditIndex] = loc.gLocation.height;
  4186. }
  4187. /* 移除所有中点 */
  4188. _self._removeEntityByName(_self._sketchEditEntityMiddleName);
  4189. /* 创建所有中点 */
  4190. if (editEntityType === DrawTools.DrawType.SpatialLine) {
  4191. _self._createEditMiddlePoint(_self._sketchEditPoints, true);
  4192. } else {
  4193. _self._createEditMiddlePoint(_self._sketchEditPoints);
  4194. }
  4195. }
  4196. } else if (editEntityType.type === DrawTools.EditPointType.Middle) {
  4197. _self._sketchEditPoints[_self._sketchEditIndex] = loc.sLocation;
  4198. } else if (editEntityType.type === DrawTools.EditPointType.Center) {
  4199. _self._entityCenterMouseMoveEvent(event);
  4200. } else if (editEntityType.type === DrawTools.EditPointType.Spatial) {
  4201. /* 当前移动的是空中点 */
  4202. let ellipsoid = _self._viewer.scene.globe.ellipsoid;
  4203. let cartesian = _self._viewer.camera.pickEllipsoid(event.endPosition,
  4204. ellipsoid);
  4205. let bottomPoint = _self._sketchEditPoints[_self._sketchEditIndex];
  4206. /* 计算高差 */
  4207. let heightDifference = cartesian.z - bottomPoint.z;
  4208. if (heightDifference > 0 && heightDifference < 500) {
  4209. for (let i = 0; i < _self._sketchWallHeights.length; i++) {
  4210. _self._sketchWallMaxHeights[i] = _self._sketchWallHeights[i] +
  4211. heightDifference;
  4212. }
  4213. }
  4214. } else if (editEntityType.type === DrawTools.EditPointType.OdlineEndNode) {
  4215. _self._sketchEditPoints[_self._sketchEditPoints.length - 1] = loc.sLocation;
  4216. } else if (editEntityType.type === DrawTools.EditPointType.OdlineStrartNode) {
  4217. _self._sketchEditPoints[0] = loc.sLocation;
  4218. }
  4219. /* 更改标签文字 */
  4220. _self._tooltipInit('抬起鼠标,完成更改', event.endPosition);
  4221. }
  4222. },
  4223. /**
  4224. * 编辑点鼠标抬起事件
  4225. * @ignore 生成方法时不对外公开
  4226. * @param {Object} event 事件
  4227. */
  4228. _eventEditMouseUp: function(event) {
  4229. let _self = this;
  4230. if (_self._editPointEntity != undefined) {
  4231. /* 恢复所有鼠标默认事件 */
  4232. _self._viewer.scene.screenSpaceCameraController.enableRotate = true;
  4233. /* 移除标签 */
  4234. _self._tooltipRemove();
  4235. /* 恢复鼠标默认样式 */
  4236. _self._setMouseDefaultStyle();
  4237. /* 获取当前编辑的点类型 */
  4238. let editEntityPointType = _self._editPointEntity.getEditType().type;
  4239. let entityType = _self._editEntity.getEntityType();
  4240. if (editEntityPointType === DrawTools.EditPointType.CoordinateAxis) {
  4241. } else if (editEntityPointType === DrawTools.EditPointType.OdlineEndNode) {
  4242. /* 获取OD线的必要参数 */
  4243. let params = _self._editEntity.parent.getParams();
  4244. /* 重置编辑实体的位置 */
  4245. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0], _self
  4246. ._sketchEditPoints[1], parseInt(params.odlineHeight), parseInt(params.odlineCount));
  4247. _self._editEntity.polyline.positions = positions;
  4248. /* 创建OD线的终点 */
  4249. _self._createEditOdlineEndPoint(_self._sketchEditPoints[1], _self._editEntity);
  4250. } else if (editEntityPointType === DrawTools.EditPointType.OdlineStrartNode) {
  4251. /* 获取OD线的必要参数 */
  4252. let params = _self._editEntity.parent.getParams();
  4253. let index = 1;
  4254. for (let odEntity of _self._editOdlineEntities) {
  4255. let lastPosition = _self._sketchEditPoints[index++];
  4256. let positions = _self._calculateOdlinePositios(_self._sketchEditPoints[0],
  4257. lastPosition, parseInt(params.odlineHeight), parseInt(params.odlineCount));
  4258. odEntity.polyline.positions = positions;
  4259. }
  4260. _self._createEditOdlineStartPoint(_self._sketchEditPoints[0], _self._editOdlineEntities[0]);
  4261. } else {
  4262. if (editEntityPointType === DrawTools.EditPointType.Node ||
  4263. editEntityPointType === DrawTools.EditPointType.Middle) {
  4264. /* 处理鼠标抬起实体的属性变更回调 */
  4265. _self._entityCallbackPropertyByMouseUp();
  4266. } else if (editEntityPointType === DrawTools.EditPointType.Center) {
  4267. _self._entityCenterMouseUpEvent(event);
  4268. }
  4269. /* 删除节点、中点和中心点 */
  4270. _self._removeEntityByName(_self._sketchEditEntityNodeName);
  4271. _self._removeEntityByName(_self._sketchEditEntityMiddleName);
  4272. _self._removeEntityByName(_self._sketchEditEntityCenterName);
  4273. /* 创建节点、中点和中心点 */
  4274. if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools
  4275. .DrawType
  4276. .DynamicCircle) {
  4277. /* 需要对点进行特殊处理 保证圆边界点始终在统一位置 */
  4278. let centerPosition = _self._editEntity.position._value;
  4279. let boundaryPosition = _self._calculateCircleBoundaryPoint(centerPosition,
  4280. _self
  4281. ._sketchEllipseRadius);
  4282. _self._sketchEditPoints[0] = centerPosition;
  4283. _self._sketchEditPoints[1] = boundaryPosition;
  4284. _self._createEditNodePoint(_self._sketchEditPoints, 1);
  4285. _self._createEditCenterPoint(centerPosition);
  4286. } else {
  4287. /* 创建节点 */
  4288. _self._createEditNodePoint(_self._sketchEditPoints);
  4289. /* 创建中心点 */
  4290. let centerPosition = _self._calculateCenterPosition(_self
  4291. ._sketchEditPoints);
  4292. _self._createEditCenterPoint(centerPosition);
  4293. }
  4294. /* 创建中点 */
  4295. if (entityType != DrawTools.DrawType.Rectangle &&
  4296. entityType != DrawTools.DrawType.Circle && entityType != DrawTools.DrawType
  4297. .DynamicCircle) {
  4298. if (entityType === DrawTools.DrawType.SpatialLine) {
  4299. _self._createEditMiddlePoint(_self._sketchEditPoints, true);
  4300. } else {
  4301. _self._createEditMiddlePoint(_self._sketchEditPoints);
  4302. }
  4303. }
  4304. }
  4305. /* 清除选�����的实体 */
  4306. _self._editPointEntity = undefined;
  4307. }
  4308. },
  4309. /**
  4310. * 实体中心点鼠标按下(拖拽点按下)
  4311. * @ignore 生成方法时不对外公开
  4312. */
  4313. _entityCenterMouseDownEvent: function() {
  4314. let _self = this;
  4315. let entityPosition = this._editEntity.position._value;
  4316. /* 删除节点、中点和中心点 */
  4317. this._removeEntityByName(this._sketchEditEntityNodeName);
  4318. this._removeEntityByName(this._sketchEditEntityMiddleName);
  4319. this._removeEntityByName(this._sketchEditEntityCenterName);
  4320. /* 记录相关位置信息 */
  4321. this._startPoint = entityPosition;
  4322. this._startMovePoints = [];
  4323. this._movePoint = entityPosition;
  4324. /* 获取编辑实体的类型 */
  4325. let editEntityType = this._editEntity.getEntityType();
  4326. /* 操作的如果是圆 */
  4327. if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools
  4328. .DrawType.DynamicCircle) {
  4329. /* 记录移动点为所有的圆边界点 */
  4330. if (this._editEntity.polyline !== undefined) {
  4331. for (let i = 0; i < this._ellipseOutlineCoordinates.length; i++) {
  4332. this._startMovePoints.push(this._ellipseOutlineCoordinates[i]);
  4333. }
  4334. this._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4335. function() {
  4336. return _self._ellipseOutlineCoordinates;
  4337. }, false);
  4338. }
  4339. this._editEntity.position = new Cesium.CallbackProperty(function() {
  4340. return _self._movePoint;
  4341. }, false);
  4342. } else if (editEntityType === DrawTools.DrawType.Polygon || editEntityType === DrawTools.DrawType
  4343. .House) {
  4344. /* 记录移动点为所有边界点 */
  4345. for (let i = 0; i < this._sketchEditPoints.length; i++) {
  4346. this._startMovePoints.push(this._sketchEditPoints[i]);
  4347. }
  4348. /* 设置位置属性更新方式 */
  4349. _self._editEntity.polygon.hierarchy = new Cesium.CallbackProperty(function() {
  4350. return {
  4351. positions: _self._sketchEditPoints,
  4352. };
  4353. }, false);
  4354. if (_self._editEntity.polyline != undefined) {
  4355. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4356. return _self._sketchEditPoints;
  4357. }, false);
  4358. }
  4359. } else if (editEntityType === DrawTools.DrawType.Polyline || editEntityType === DrawTools.DrawType
  4360. .SpatialLine) {
  4361. /* 记录移动点为所有边界点 */
  4362. for (let i = 0; i < this._sketchEditPoints.length; i++) {
  4363. this._startMovePoints.push(this._sketchEditPoints[i]);
  4364. }
  4365. /* 设置属性更新方法回调 */
  4366. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(function() {
  4367. return _self._sketchEditPoints;
  4368. }, false);
  4369. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  4370. /* 记录移动点为所有边界点 */
  4371. for (let i = 0; i < this._sketchEditPoints.length; i++) {
  4372. this._startMovePoints.push(this._sketchEditPoints[i]);
  4373. }
  4374. /* 设置属性变更回调 */
  4375. _self._editEntity.rectangle.coordinates = new Cesium.CallbackProperty(_self
  4376. ._callUpdateRectangleCoordinates(_self
  4377. ._sketchEditPoints), false);
  4378. /* 如果存在边界线 则特殊处理 */
  4379. if (_self._editEntity.polyline != undefined) {
  4380. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(_self
  4381. ._callUpdateRectangleOutlineCoordinates(),
  4382. false);
  4383. }
  4384. }
  4385. },
  4386. /**
  4387. * 实体中心点鼠标移动
  4388. * @ignore
  4389. * @param {Cesium.Event} event 事件
  4390. */
  4391. _entityCenterMouseMoveEvent: function(event) {
  4392. this._calculatePositionsByCenter(event.endPosition, false);
  4393. },
  4394. /* 换个思路试试 移动过程中不计算 待移动完成后计算 以便保���移动速度 要不实时计算高度 导致卡顿 */
  4395. /**
  4396. * 计算中心拖拽点移动后实体点随之移动后的位置数据
  4397. * @ignore 生成方法时不对外公开
  4398. * @param {JSON} screenPosition 移动后的屏幕点
  4399. * @param {Boolean} calculateHeight 是否计算移动点的高度
  4400. */
  4401. _calculatePositionsByCenter: function(screenPosition, calculateHeight) {
  4402. let _self = this;
  4403. /* 起点转换为经纬度 */
  4404. let strLoc = this._cartesian3ToGeo(this._startPoint);
  4405. /* 获取终止点 */
  4406. let endLoc = this._transfromFromScreenPoint(screenPosition);
  4407. /* 计算两点之间的角度 */
  4408. var point1 = turf.point([strLoc.longitude, strLoc.latitude]);
  4409. var point2 = turf.point([endLoc.gLocation.lng, endLoc.gLocation.lat]);
  4410. var bearing = turf.bearing(point1, point2);
  4411. /* 计算亮点���间���距��� 距���单���和���否���算���度*/
  4412. var options = {
  4413. units: 'kilometers',
  4414. calculateHeight: calculateHeight
  4415. };
  4416. var distance = turf.distance(point1, point2, options);
  4417. /* 根据移动的不同类型实体进行不同的操作 */
  4418. let editEntityType = this._editEntity.getEntityType();
  4419. if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools
  4420. .DrawType.DynamicCircle) {
  4421. /* 循环处理所有移动点 */
  4422. for (let i = 0; i < this._startMovePoints.length; i++) {
  4423. /* 计算转换后的位置 */
  4424. let position = this._calculateTransformPosition(this._startMovePoints[i], distance, bearing,
  4425. options);
  4426. /* 更新移动点数组 */
  4427. this._ellipseOutlineCoordinates[i] = position.clone();
  4428. }
  4429. /* �������新中心���置数组 */
  4430. this._movePoint = endLoc.sLocation;
  4431. } else {
  4432. /* 循环处理所有移动点 */
  4433. for (let i = 0; i < this._startMovePoints.length; i++) {
  4434. /* 计算转换后的位置 */
  4435. let position = this._calculateTransformPosition(this._startMovePoints[i], distance, bearing,
  4436. options);
  4437. /* 更新移动点数组 */
  4438. this._sketchEditPoints[i] = position.clone();
  4439. }
  4440. }
  4441. },
  4442. /**
  4443. * 实体中心点鼠标抬起(即拖拽点)
  4444. * @ignore 生成方法时不对外公开
  4445. * @param {Object} event 事件
  4446. */
  4447. _entityCenterMouseUpEvent: function(event) {
  4448. /* 计算最新位置点 */
  4449. this._calculatePositionsByCenter(event.position, true);
  4450. let _self = this;
  4451. /* 根据不同的实体进行不同的操作 */
  4452. let editEntityType = this._editEntity.getEntityType();
  4453. if (editEntityType === DrawTools.DrawType.Circle || editEntityType === DrawTools
  4454. .DrawType.DynamicCircle) {
  4455. this._editEntity.position = this._movePoint;
  4456. if (this._editEntity.polyline !== undefined) {
  4457. this._editEntity.polyline.positions = this._ellipseOutlineCoordinates;
  4458. }
  4459. } else if (editEntityType === DrawTools.DrawType.Polyline || editEntityType === DrawTools.DrawType
  4460. .SpatialLine) {
  4461. this._editEntity.polyline.positions = this._sketchEditPoints;
  4462. } else if (editEntityType === DrawTools.DrawType.Polygon || editEntityType === DrawTools.DrawType
  4463. .House) {
  4464. this._editEntity.polygon.hierarchy = {
  4465. positions: _self._sketchEditPoints,
  4466. };
  4467. if (this._editEntity.polyline != undefined) {
  4468. this._editEntity.polyline.positions = this._sketchEditPoints;
  4469. }
  4470. } else if (editEntityType === DrawTools.DrawType.Rectangle) {
  4471. this._editEntity.rectangle.coordinates = Cesium.Rectangle.fromDegrees(_self
  4472. ._rectangleCoordinates[
  4473. 0], _self
  4474. ._rectangleCoordinates[1], _self._rectangleCoordinates[2], _self
  4475. ._rectangleCoordinates[3]);
  4476. if (this._editEntity.polyline != undefined) {
  4477. this._editEntity.polyline.positions = _self._rectangleOutlineCoordinates;
  4478. }
  4479. }
  4480. },
  4481. /**
  4482. * 处理鼠标抬起实体的属性变更回调
  4483. * @ignore 生成方法时不对外公开
  4484. */
  4485. _entityCallbackPropertyByMouseUp: function() {
  4486. let _self = this;
  4487. let entityType = _self._editEntity.getEntityType();
  4488. if (entityType === DrawTools.DrawType.Polyline) {
  4489. _self._editEntity.polyline.positions = _self._sketchEditPoints;
  4490. } else if (entityType === DrawTools.DrawType.Polygon || entityType === DrawTools.DrawType.House) {
  4491. _self._editEntity.polygon.hierarchy = {
  4492. positions: _self._sketchEditPoints,
  4493. };
  4494. /* 此处���要特殊处理一下 */
  4495. if (_self._editEntity.polyline != undefined) {
  4496. /* 如果创建区域的同时 创建了边界线 则根据区域的边界创建线 */
  4497. let polygonPositions = _self._editEntity.polygon.hierarchy._value.positions;
  4498. let linePositions = [];
  4499. for (let i = 0; i < polygonPositions.length; i++) {
  4500. linePositions.push(polygonPositions[i].clone());
  4501. }
  4502. /* 判断是否需要加入0号点 */
  4503. if (linePositions[0].x !== linePositions[linePositions.length - 1].x) {
  4504. linePositions.push(linePositions[0].clone());
  4505. }
  4506. _self._editEntity.polyline.positions = linePositions;
  4507. }
  4508. } else if (entityType === DrawTools.DrawType.Rectangle) {
  4509. _self._editEntity.rectangle.coordinates = Cesium.Rectangle.fromDegrees(_self
  4510. ._rectangleCoordinates[0], _self
  4511. ._rectangleCoordinates[1], _self._rectangleCoordinates[2], _self
  4512. ._rectangleCoordinates[3]);
  4513. /* 判断矩形有边界线 特殊处理 */
  4514. if (_self._editEntity.polyline != undefined) {
  4515. _self._editEntity.polyline.positions = _self._rectangleOutlineCoordinates;
  4516. }
  4517. } else if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools.DrawType
  4518. .DynamicCircle) {
  4519. /* 移动的是圆的点 需要特殊处理 */
  4520. _self._editEntity.ellipse.semiMajorAxis = _self._sketchEllipseRadius;
  4521. _self._editEntity.ellipse.semiMinorAxis = _self._sketchEllipseRadius;
  4522. /* 如果圆有边界线 则进行特殊处理 */
  4523. if (_self._editEntity.polyline != undefined) {
  4524. _self._editEntity.polyline.positions = _self._ellipseOutlineCoordinates;
  4525. }
  4526. } else if (entityType === DrawTools.DrawType.NormalWall || entityType === DrawTools.DrawType
  4527. .DynamicWall || entityType === DrawTools.DrawType.TextWall) {
  4528. _self._editEntity.wall.positions = _self._sketchEditPoints;
  4529. _self._editEntity.wall.minimumHeights = _self._sketchWallHeights;
  4530. _self._editEntity.wall.maximumHeights = _self._sketchWallMaxHeights;
  4531. }
  4532. },
  4533. /**
  4534. * 处理鼠标按下实体的属性变更回调
  4535. * @ignore 生成方法时不对外公开
  4536. */
  4537. _entityCallbackPropertyByMouseDown: function() {
  4538. let _self = this;
  4539. /* 更改编辑实体的坐标数据获取方式 */
  4540. let entityType = _self._editEntity.getEntityType();
  4541. if (entityType === DrawTools.DrawType.Polyline || entityType === DrawTools.DrawType.SpatialLine) {
  4542. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4543. function() {
  4544. return _self._sketchEditPoints;
  4545. }, false);
  4546. } else if (entityType === DrawTools.DrawType.Polygon || entityType === DrawTools.DrawType.House) {
  4547. _self._editEntity.polygon.hierarchy = new Cesium.CallbackProperty(
  4548. function() {
  4549. return {
  4550. positions: _self._sketchEditPoints,
  4551. };
  4552. }, false);
  4553. /* 此处需要特殊处理 ���断���面实体是否挂接着线 */
  4554. if (_self._editEntity.polyline != undefined) {
  4555. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4556. function() {
  4557. /* 如果创建区域的同时 创建了边界线 则根据区域的边界创建线 */
  4558. let polygonPositions = _self._sketchEditPoints;
  4559. let linePositions = [];
  4560. for (let i = 0; i < polygonPositions.length; i++) {
  4561. linePositions.push(polygonPositions[i].clone());
  4562. }
  4563. /* 判断是否需要加入0号点 */
  4564. if (linePositions[0].x !== linePositions[linePositions.length - 1].x) {
  4565. linePositions.push(linePositions[0].clone());
  4566. }
  4567. return linePositions;
  4568. }, false);
  4569. }
  4570. } else if (entityType === DrawTools.DrawType.Rectangle) {
  4571. _self._editEntity.rectangle.coordinates = new Cesium.CallbackProperty(_self
  4572. ._callUpdateRectangleCoordinates(_self
  4573. ._sketchEditPoints),
  4574. false);
  4575. /* 如果存在边界线则特殊处理 */
  4576. if (_self._editEntity.polyline != undefined) {
  4577. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(_self
  4578. ._callUpdateRectangleOutlineCoordinates(),
  4579. false);
  4580. }
  4581. } else if (entityType === DrawTools.DrawType.Circle || entityType === DrawTools.DrawType
  4582. .DynamicCircle) {
  4583. /* 移动的是圆的点 需要特殊处理 */
  4584. if (_self._editPointEntity.getEditType().index === 1) {
  4585. _self._editEntity.ellipse.semiMajorAxis = new Cesium.CallbackProperty(
  4586. _self
  4587. ._callUpdateEllipseMinorAxis(_self._sketchEditPoints), false);
  4588. _self._editEntity.ellipse.semiMinorAxis = new Cesium.CallbackProperty(
  4589. _self
  4590. ._callUpdateEllipseMinorAxis(_self._sketchEditPoints), false);
  4591. }
  4592. /* 如果圆有边界线 则进行特殊���理 */
  4593. if (_self._editEntity.polyline != undefined) {
  4594. _self._editEntity.polyline.positions = new Cesium.CallbackProperty(
  4595. _self._callEllipseOutlineCoordinate(_self
  4596. ._sketchEditPoints), false);
  4597. }
  4598. } else if (entityType === DrawTools.DrawType.NormalWall || entityType === DrawTools.DrawType
  4599. .DynamicWall || entityType === DrawTools.DrawType.TextWall) {
  4600. /* 位置属性变更 */
  4601. _self._editEntity.wall.positions = new Cesium.CallbackProperty(function() {
  4602. return _self._sketchEditPoints;
  4603. }, false);
  4604. /* 高度属性变更 */
  4605. _self._editEntity.wall.minimumHeights = new Cesium.CallbackProperty(function() {
  4606. return _self._sketchWallHeights;
  4607. }, false);
  4608. _self._editEntity.wall.maximumHeights = new Cesium.CallbackProperty(function() {
  4609. return _self._sketchWallMaxHeights;
  4610. }, false);
  4611. }
  4612. },
  4613. /**
  4614. * 创建编辑点
  4615. * @ignore 生成方法时不对外公开
  4616. * @param {JSON} options 配置项
  4617. * @param {Cesium.Cartesian3} options.position 位置<必须填写>
  4618. * @param {Array<Number>} options.color [颜色] 可选
  4619. * @param {Number} options.size [大小] 可选
  4620. * @param {Number} options.outlineWidth [边框大小] 可选
  4621. * @param {Array<Number>} options.outlineColor [边框颜色] 可选
  4622. * @param {DrawTools.EditPointType} options.editType 编辑点类型<必须填写>
  4623. * @param {String} options.name [实体的名称] 可选
  4624. */
  4625. _createEditPointEntity(options) {
  4626. let _self = this;
  4627. if (options === undefined || options.position === undefined) return;
  4628. if (options === undefined || options.editType === undefined) return;
  4629. /* 初始化参数 */
  4630. let color = options.color != undefined ? options.color : [255, 0, 0, 1.0];
  4631. let size = options.size != undefined && typeof options.size === 'number' ? options.size : 9;
  4632. let outlineWidth = options.outlineWidth != undefined && typeof options.outlineWidth === 'number' ?
  4633. options.outlineWidth : 1;
  4634. let outlineColor = options.outlineColor != undefined ? options.outlineColor : [255, 255, 255, 1.0];
  4635. /* 创建编辑点 */
  4636. let pointEntity = new Cesium.Entity({
  4637. name: options.name != undefined ? options.name : _self._sketchEntityName,
  4638. position: options.position,
  4639. point: {
  4640. show: true,
  4641. pixelSize: size,
  4642. heightReference: Cesium.HeightReference.NONE,
  4643. color: _self._toColorFromArray(color),
  4644. outlineWidth: outlineWidth,
  4645. outlineColor: _self._toColorFromArray(outlineColor),
  4646. disableDepthTestDistance: 1.5e12, //小于该数值后关闭深度检测默认为空
  4647. // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  4648. },
  4649. })
  4650. /* 设置编辑实体类型 */
  4651. pointEntity.setEditType(options.editType);
  4652. /* 追加到集合中 */
  4653. _self._entities.add(pointEntity);
  4654. },
  4655. /**
  4656. * 创建可编辑的节点
  4657. * @ignore 生成方法时不对外公开
  4658. * @param {Array<Cesium.Cartesian3>} positions 坐标集合
  4659. * @param {Number} startIndex [开始索引] 可选 默认为0
  4660. */
  4661. _createEditNodePoint(positions, startIndex) {
  4662. this._sketchEditEntityNodeName = "SketchEditEntityNode";
  4663. let _self = this;
  4664. /* 创建节点 */
  4665. this._sketchEditPoints = [];
  4666. /* 判断开始创建索引 */
  4667. let strIndex = startIndex === undefined ? 0 : startIndex;
  4668. for (let i = 0; i < positions.length; i++) {
  4669. /* 获取当前点 */
  4670. let position = positions[i];
  4671. /* 存储可编辑点 */
  4672. this._sketchEditPoints.push(position.clone());
  4673. /* 小于索引不会创建 */
  4674. if (i < strIndex) continue;
  4675. /* 为了保证不重复创建节点 需要进行特殊过滤处理 */
  4676. if (i !== 0 && position.x === positions[0].x && position.y === positions[0].y && position.z ===
  4677. positions[0]
  4678. .z) {
  4679. continue;
  4680. }
  4681. /* 创建节点前 特殊处理一下 以保证创建的节点 高度是正确的 */
  4682. let geoPoint = this._cartesian3ToGeo(position);
  4683. /* 查询高度 */
  4684. let height = this._queryHeightFromGeo(geoPoint.longitude, geoPoint.latitude);
  4685. /* 创建新位置 */
  4686. let newPosition = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, height);
  4687. /* 创建实体 */
  4688. _self._createEditPointEntity({
  4689. name: _self._sketchEditEntityNodeName,
  4690. position: newPosition,
  4691. size: 12,
  4692. color: [0, 0, 255, 1.0],
  4693. editType: {
  4694. type: DrawTools.EditPointType.Node,
  4695. index: i,
  4696. },
  4697. });
  4698. }
  4699. },
  4700. /**
  4701. * 创建可编辑的空中点
  4702. * @ignore 生成方法时不对外公开
  4703. * @param {Array<Cesium.Cartesian3>} positions 底部坐标集合
  4704. * @param {Array<Number>} heights 高度集合
  4705. * @param {Number} startIndex [开始索引] 可选 默认为0
  4706. */
  4707. _createEditSpatialPoint(positions, heights, startIndex) {
  4708. /* 暂时不创建高空点 */
  4709. return;
  4710. if (positions === undefined || heights === undefined) return;
  4711. if (positions.length === undefined || heights.length === undefined) return;
  4712. if (heights.length < positions.length) return;
  4713. this._sketchEditEntitySpatialName = "SketchEditEntitySpatial";
  4714. let _self = this;
  4715. /* 判断开始创建索引 */
  4716. let strIndex = startIndex === undefined ? 0 : startIndex;
  4717. for (let i = 0; i < positions.length; i++) {
  4718. /* 获取当前点 */
  4719. let p = positions[i];
  4720. /* 当前点转换为经纬度 */
  4721. let geoPoint = this._cartesian3ToGeo(p);
  4722. /* 重新获取新的空间位置 */
  4723. let position = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, heights[i]);
  4724. /* 小于索引不会创建 */
  4725. if (i < strIndex) continue;
  4726. /* 创建实体 */
  4727. this._createEditPointEntity({
  4728. name: _self._sketchEditEntitySpatialName,
  4729. position: position,
  4730. size: 12,
  4731. color: [255, 0, 0, 1.0],
  4732. editType: {
  4733. type: DrawTools.EditPointType.Spatial,
  4734. index: i,
  4735. },
  4736. });
  4737. }
  4738. },
  4739. /**
  4740. * 创建可编辑的中点
  4741. * @ignore 生成方法时不对外公开
  4742. * @param {Array<Cesium.Cartesian3>} positions 坐标集合
  4743. * @param {Boolean} isSpatial 是否是空中点
  4744. */
  4745. _createEditMiddlePoint(positions, isSpatial = false) {
  4746. this._sketchEditEntityMiddleName = "SketchEditEntityMiddle";
  4747. let _self = this;
  4748. if (!isSpatial) {
  4749. /* 创建中点 */
  4750. for (let i = 1; i < positions.length; i++) {
  4751. let p1 = positions[i - 1];
  4752. let p2 = positions[i];
  4753. /* 计算中点 */
  4754. let pCenter = this._calculateMiddlePoint(p1, p2);
  4755. /* 创建中点实体 */
  4756. this._createEditPointEntity({
  4757. name: _self._sketchEditEntityMiddleName,
  4758. position: pCenter,
  4759. size: 9,
  4760. color: [255, 255, 0, 1.0],
  4761. editType: {
  4762. type: DrawTools.EditPointType.Middle,
  4763. index: i
  4764. },
  4765. });
  4766. }
  4767. } else {
  4768. /* 创建中点 */
  4769. for (let i = 1; i < positions.length; i++) {
  4770. let p1 = positions[i - 1];
  4771. let p2 = positions[i];
  4772. /* 计算中点 */
  4773. let pCenter = {
  4774. x: (p1.x + p2.x) / 2,
  4775. y: (p1.y + p2.y) / 2,
  4776. z: (p1.z + p2.z) / 2,
  4777. };
  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. }
  4791. },
  4792. /**
  4793. * 创建可编辑的中心点
  4794. * @ignore 生成方法时不对外公开
  4795. * @param {Cesium.Cartesian3} position 坐标
  4796. */
  4797. _createEditCenterPoint(position) {
  4798. let _self = this;
  4799. this._sketchEditEntityCenterName = "SketchEditEntityCenter";
  4800. /* 创建实体 */
  4801. this._createEditPointEntity({
  4802. name: _self._sketchEditEntityCenterName,
  4803. position: position,
  4804. size: 12,
  4805. color: [0, 255, 0, 0.1],
  4806. outlineWidth: 2.0,
  4807. outlineColor: [255, 255, 255, 1.0],
  4808. editType: {
  4809. type: DrawTools.EditPointType.Center,
  4810. },
  4811. });
  4812. /* 创建中心点的同时将中心点付给当前的编辑实体 */
  4813. if (this._editEntity != undefined) {
  4814. this._editEntity.position = position.clone();
  4815. }
  4816. },
  4817. /**
  4818. * 创建可编辑的OD线编辑终点
  4819. * @ignore 生成方法时不对外公开
  4820. * @param {Cesium.Cartesian3} position 坐标
  4821. * @param {Cesium.Entity} joinEntity 关联的实体
  4822. */
  4823. _createEditOdlineEndPoint(position, joinEntity) {
  4824. this._sketchEditEntityNodeName = "SketchEditEntityNode";
  4825. let _self = this;
  4826. /* 创建节点前 特殊处理一下 以保证创建的节点 高度是正确的 */
  4827. let geoPoint = this._cartesian3ToGeo(position);
  4828. /* 查询高度 */
  4829. let height = this._queryHeightFromGeo(geoPoint.longitude, geoPoint.latitude);
  4830. /* 创建新位置 */
  4831. let newPosition = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, height);
  4832. /* 创建实体 */
  4833. _self._createEditPointEntity({
  4834. name: _self._sketchEditEntityNodeName,
  4835. position: position,
  4836. size: 12,
  4837. color: [0, 0, 255, 1.0],
  4838. editType: {
  4839. type: DrawTools.EditPointType.OdlineEndNode,
  4840. joinEntity: joinEntity,
  4841. },
  4842. });
  4843. },
  4844. /**
  4845. * 创建可编辑的OD线编辑起点
  4846. * @ignore 生成方法时不对外公开
  4847. * @param {Cesium.Cartesian3} position 坐标
  4848. * @param {Cesium.Entity} joinEntity 关联的实体
  4849. */
  4850. _createEditOdlineStartPoint(position, joinEntity) {
  4851. this._sketchEditEntityNodeName = "SketchEditEntityNode";
  4852. let _self = this;
  4853. /* 创建节点前 特殊处理一下 以保证创建的节点 高度是正确的 */
  4854. let geoPoint = this._cartesian3ToGeo(position);
  4855. /* 查询高度 */
  4856. let height = this._queryHeightFromGeo(geoPoint.longitude, geoPoint.latitude);
  4857. /* 创建新位置 */
  4858. let newPosition = Cesium.Cartesian3.fromDegrees(geoPoint.longitude, geoPoint.latitude, height);
  4859. /* 创建实体 */
  4860. _self._createEditPointEntity({
  4861. name: _self._sketchEditEntityNodeName,
  4862. position: position,
  4863. size: 12,
  4864. color: [0, 255, 0, 0.6],
  4865. editType: {
  4866. type: DrawTools.EditPointType.OdlineStrartNode,
  4867. joinEntity: joinEntity,
  4868. },
  4869. });
  4870. },
  4871. /**
  4872. * 计算两个点的中点坐标
  4873. * @ignore 生成方法时不对外公开
  4874. * @param {Cesium.Cartesian3} position1 第一点
  4875. * @param {Cesium.Cartesian3} position2 第二点
  4876. */
  4877. _calculateMiddlePoint(position1, position2) {
  4878. /* 计算经纬度坐标 */
  4879. let g1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position1);
  4880. let g2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position2);
  4881. /* 转换为度格式 */
  4882. let pt1 = [Cesium.Math.toDegrees(g1.longitude), Cesium.Math.toDegrees(g1.latitude)];
  4883. let pt2 = [Cesium.Math.toDegrees(g2.longitude), Cesium.Math.toDegrees(g2.latitude)];
  4884. /* 计算中间点 */
  4885. let tpt1 = turf.point(pt1);
  4886. let tpt2 = turf.point(pt2);
  4887. let midpoint = turf.midpoint(tpt1, tpt2).geometry.coordinates;
  4888. /* 查询高度 */
  4889. let height = this._queryHeightFromGeo(midpoint[0], midpoint[1]);
  4890. /* 转换为世界坐标 */
  4891. let result = Cesium.Cartesian3.fromDegrees(midpoint[0], midpoint[1], height);
  4892. return result;
  4893. },
  4894. /**
  4895. * 世界坐标转换为经纬度坐标
  4896. * @ignore 生成方法时不对外公开
  4897. * @param {Cesium.Cartesian3} position 点
  4898. */
  4899. _cartesian3ToGeo: function(position) {
  4900. let g = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
  4901. return {
  4902. longitude: Cesium.Math.toDegrees(g.longitude),
  4903. latitude: Cesium.Math.toDegrees(g.latitude),
  4904. height: g.height,
  4905. }
  4906. },
  4907. /**
  4908. * 查询指定经纬度位置的高度 有地形则查地形 有模型则查模型 查询错误或未查询到,返回0
  4909. * @ignore 生成方法时不对外公开
  4910. * @param {Number} longitude 经度<度格式>
  4911. * @param {Number} latitude 纬度<度格式>
  4912. * @return {Number} 查询位置的高度值
  4913. */
  4914. _queryHeightFromGeo: function(longitude, latitude) {
  4915. if (longitude === undefined || latitude === undefined || typeof longitude != 'number' ||
  4916. typeof latitude != 'number') return 0;
  4917. let rLng = Cesium.Math.toRadians(longitude);
  4918. let rLat = Cesium.Math.toRadians(latitude);
  4919. let cartographic = new Cesium.Cartographic(rLng, rLat);
  4920. /* 获取不采样的实体数组 */
  4921. let noQueryEntities = [];
  4922. for (let i = 0; i < this._entities.values.length; i++) {
  4923. if (this._entities.values[i].name === this._sketchEntityName) {
  4924. noQueryEntities.push(this._entities.values[i]);
  4925. }
  4926. }
  4927. let height = this._viewer.scene.sampleHeight(cartographic, noQueryEntities);
  4928. if (height === undefined) return 0
  4929. else return height;
  4930. },
  4931. /**
  4932. * 查询指定经纬度位置的高度 有地形则查地形 有模型则查模型 查询错误或未查询到,返回0
  4933. * @ignore 生成方法时不对外公开
  4934. * @param {Number} longitude 经度<度格式>
  4935. * @param {Number} latitude 纬度<度格式>
  4936. * @param {Function} callComplete 查询回调函数callComplete(Number) 查询错误时为undefined
  4937. */
  4938. _queryHeightFromGeoAsync: function(longitude, latitude, callComplete) {
  4939. if (longitude === undefined || latitude === undefined || typeof longitude != 'number' ||
  4940. typeof latitude != 'number') return 0;
  4941. let rLng = Cesium.Math.toRadians(longitude);
  4942. let rLat = Cesium.Math.toRadians(latitude);
  4943. let cartographic = new Cesium.Cartographic(rLng, rLat);
  4944. let promise = this._viewer.scene.sampleHeightMostDetailed([cartographic]);
  4945. promise.then(function(updatedPositions) {
  4946. if (callComplete) callComplete(updatedPositions[0].height);
  4947. })
  4948. },
  4949. /**
  4950. * 清理编辑点
  4951. * @ignore 生成方法时不对外公开
  4952. */
  4953. _clearEditPoint: function() {
  4954. /* 清理事件句柄 */
  4955. if (this._sketchEditHandler != undefined) {
  4956. this._sketchEditHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOWN);
  4957. this._sketchEditHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP);
  4958. this._sketchEditHandler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
  4959. }
  4960. /* 处理理编辑点数据 */
  4961. this._sketchEditPoints = [];
  4962. this._sketchEditIndex = undefined;
  4963. this._editEntity = undefined;
  4964. this._removeEntityByName(this._sketchEditEntityNodeName);
  4965. this._removeEntityByName(this._sketchEditEntityMiddleName);
  4966. this._removeEntityByName(this._sketchEditEntityCenterName);
  4967. this._removeEntityByName(this._sketchEditEntitySpatialName);
  4968. },
  4969. })
  4970. /* 编辑函数相关 */
  4971. Object.assign(DrawTools.prototype, {
  4972. /**
  4973. * 检查颜色值
  4974. * @ignore 生成方法时不对外公开
  4975. * @param {Number} color 颜色值[0~255]
  4976. * @return {Boolean} 是否满足颜色值要求
  4977. */
  4978. _checkColor: function(color) {
  4979. if (color === undefined || color === null) return false;
  4980. if (typeof color != 'number') return false;
  4981. let intColor = parseInt(color);
  4982. if (intColor < 0 || intColor > 255) return false;
  4983. return true;
  4984. },
  4985. /**
  4986. * 检查透明度是否符合要求
  4987. * @ignore 生成方法时不对外公开
  4988. * @param {Object} alpha 透明度[0~1]
  4989. */
  4990. _checkAlpha: function(alpha) {
  4991. if (alpha === undefined || alpha === null) return false;
  4992. if (typeof alpha != 'number') return false;
  4993. let floatAlpha = parseFloat(alpha);
  4994. if (floatAlpha < 0 || floatAlpha > 1) return false;
  4995. return true;
  4996. },
  4997. /**
  4998. * 颜色和透明度检测
  4999. * @ignore 生成方法时不对外公开
  5000. * @param {Array<Number>} colorAndAlpah 颜���和透明度
  5001. * @return {Array<Number>} [0~255,0~255,0~255,0~1] 如果异常 则�����回undefined
  5002. */
  5003. _checkColorAndAlpha: function(colorAndAlpah) {
  5004. let setColor = undefined;
  5005. if (!colorAndAlpah || colorAndAlpah.length === undefined || colorAndAlpah.length === 0)
  5006. return undefined;
  5007. if (colorAndAlpah.length === 1 && this._checkColor(colorAndAlpah[0])) {
  5008. setColor = [colorAndAlpah[0], 0, 0, 1.0];
  5009. } else if (colorAndAlpah.length === 2 && this._checkColor(colorAndAlpah[0]) && this._checkColor(
  5010. colorAndAlpah[1])) {
  5011. setColor = [colorAndAlpah[0], colorAndAlpah[1], 0, 1.0];
  5012. } else if (colorAndAlpah.length === 3 && this._checkColor(colorAndAlpah[0]) && this._checkColor(
  5013. colorAndAlpah[1]) && this._checkColor(colorAndAlpah[2])) {
  5014. setColor = [colorAndAlpah[0], colorAndAlpah[1], colorAndAlpah[2], 1.0];
  5015. } else if (colorAndAlpah.length === 4 && this._checkColor(colorAndAlpah[0]) && this._checkColor(
  5016. colorAndAlpah[1]) && this._checkColor(colorAndAlpah[2]) && this._checkAlpha(
  5017. colorAndAlpah[
  5018. 3])) {
  5019. setColor = [colorAndAlpah[0], colorAndAlpah[1], colorAndAlpah[2], colorAndAlpah[3]];
  5020. }
  5021. return setColor;
  5022. },
  5023. });
  5024. /**
  5025. * 操作容器及按钮相关 主要为了适应App操作
  5026. */
  5027. Object.assign(DrawTools.prototype, {
  5028. /**
  5029. * 初始化操作容器
  5030. * @ignore
  5031. */
  5032. _initOperationDom: function() {
  5033. let _self = this;
  5034. this._operationDomId = 'drawtools_operation_dom'
  5035. this._operationDom = document.getElementById(this._operationDomId);
  5036. /* 移除主容器 */
  5037. this._removeOperationDom()
  5038. /* 创建主容器 */
  5039. this._createOperationMainDom()
  5040. if ([DrawTools.DrawType.Rectangle, DrawTools.DrawType.Circle, DrawTools.DrawType.DynamicCircle,
  5041. DrawTools.DrawType.VideoWall
  5042. ].indexOf(this._drawType) === -1) {
  5043. /* 创建回退按钮 */
  5044. let btnUndo = this._createOperationUndoButtonDom();
  5045. /* 挂接事件 */
  5046. btnUndo.onclick = function() {
  5047. _self._operationExecuteEvent(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  5048. }
  5049. }
  5050. if ([DrawTools.DrawType.Rectangle, DrawTools.DrawType.Circle, DrawTools.DrawType.DynamicCircle,
  5051. DrawTools.DrawType.VideoWall
  5052. ] === -1) {
  5053. /* 创建完成按钮 */
  5054. let btnCompletion = this._crateOperationCompletionButtonDom();
  5055. /* 挂接事件 */
  5056. btnCompletion.onclick = function() {
  5057. _self._operationExecuteEvent(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  5058. }
  5059. } else {
  5060. /* 创建完成按钮 */
  5061. let btnCompletion = this._crateOperationCompletionButtonDom();
  5062. /* 挂接事件 */
  5063. btnCompletion.onclick = function() {
  5064. _self._operationExecuteEvent(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
  5065. }
  5066. }
  5067. },
  5068. /**
  5069. * 执行事件
  5070. * @ignore
  5071. * @param {Cesium.ScreenSpaceEventType} eventType 事件类型
  5072. */
  5073. _operationExecuteEvent(eventType) {
  5074. if (this._drawEventHandler !== undefined && this._drawEventHandler.isDestroyed() ===
  5075. false) {
  5076. let event = {
  5077. position: new Cesium.Cartesian2(300, 300),
  5078. }
  5079. let action = this._drawEventHandler.getInputAction(eventType);
  5080. action(event);
  5081. }
  5082. },
  5083. /**
  5084. * @ignore
  5085. * 创建操作的主容器
  5086. */
  5087. _createOperationMainDom: function() {
  5088. this._operationDom = document.createElement('div');
  5089. this._operationDom.id = this._operationDomId;
  5090. this._operationDom.style.width = '80px';
  5091. this._operationDom.style.backgroundColor = 'rgba(5, 45, 155, 0.7)';
  5092. this._operationDom.style.borderRadius = '5px';
  5093. this._operationDom.style.display = 'flex';
  5094. this._operationDom.style.flexDirection = 'column';
  5095. this._operationDom.style.padding = '8px';
  5096. this._operationDom.style.justifyContent = 'center';
  5097. this._operationDom.style.position = 'absolute';
  5098. this._operationDom.style.bottom = '150px';
  5099. this._operationDom.style.right = '10px';
  5100. document.body.appendChild(this._operationDom);
  5101. },
  5102. /**
  5103. * 创建回退按钮 并返回示例
  5104. * @ignore
  5105. * @return {Element}
  5106. */
  5107. _createOperationUndoButtonDom: function() {
  5108. let btnUndo = document.createElement('button');
  5109. btnUndo.style.height = '30px';
  5110. btnUndo.style.marginBottom = '8px';
  5111. btnUndo.style.backgroundColor = 'rgba(52, 137, 255, 1.0)';
  5112. btnUndo.style.color = 'rgb(255, 255, 255)';
  5113. btnUndo.style.border = '0px solid red';
  5114. btnUndo.style.borderRadius = '5px';
  5115. btnUndo.innerHTML = '回退';
  5116. btnUndo.style.fontSize = '13px';
  5117. btnUndo.style.cursor = 'pointer';
  5118. this._operationDom.appendChild(btnUndo);
  5119. return btnUndo;
  5120. },
  5121. /**
  5122. * 创建完成按钮
  5123. * @ignore
  5124. * @return {Element}
  5125. */
  5126. _crateOperationCompletionButtonDom: function() {
  5127. let btnCompletion = document.createElement('button');
  5128. btnCompletion.style.height = '30px';
  5129. btnCompletion.style.backgroundColor = 'rgba(88, 185, 45, 1.0)';
  5130. btnCompletion.style.color = 'rgb(255, 255, 255)';
  5131. btnCompletion.style.border = '0px solid red';
  5132. btnCompletion.style.borderRadius = '5px';
  5133. btnCompletion.innerHTML = '完成';
  5134. btnCompletion.style.fontSize = '13px';
  5135. btnCompletion.style.cursor = 'pointer';
  5136. this._operationDom.appendChild(btnCompletion);
  5137. return btnCompletion;
  5138. },
  5139. /**
  5140. * 移除操作容器
  5141. * @ignore
  5142. */
  5143. _removeOperationDom: function() {
  5144. if (this._operationDom !== null && this._operationDom !== undefined) {
  5145. document.body.removeChild(this._operationDom);
  5146. this._operationDom = undefined;
  5147. }
  5148. },
  5149. /**
  5150. * 添加操作容器
  5151. * @ignore
  5152. */
  5153. _createOperationDom: function() {
  5154. if (this._isRuntimeApp()) {
  5155. this._initOperationDom();
  5156. }
  5157. }
  5158. })
  5159. /**
  5160. * 属性编辑相关(UI)
  5161. */
  5162. Object.assign(DrawTools.prototype, {
  5163. /**
  5164. * 打开属性编辑窗口
  5165. * @ignore
  5166. * @param {JSON} params 参数
  5167. * @param {Function} callEdit 编辑回调
  5168. * @param {Function} callRemove 移除回调
  5169. */
  5170. _openPropertyEditDialog: function(params, callEdit, callRemove) {
  5171. this._editPropertyDialogDomId = 'dialog-property-dom';
  5172. this._registerDOMPropertyEdit = 'dialog-edit-property'
  5173. /* 获取一个属性编辑组件 */
  5174. let PropertyEditComponent = customElements.get(this._registerDOMPropertyEdit);
  5175. /* 如果组件还未注册 则进行注册 否则不在注册 避免重复注册的BUG */
  5176. if (PropertyEditComponent === undefined) {
  5177. PropertyEditComponent = defineCustomElement(DialogEditProperty);
  5178. customElements.define(this._registerDOMPropertyEdit, PropertyEditComponent);
  5179. }
  5180. /* 先关闭编辑框 */
  5181. this._closePropertyEditDialog();
  5182. /* 创建组件 */
  5183. let dialogPropertyElement = new PropertyEditComponent({
  5184. params: params,
  5185. })
  5186. dialogPropertyElement.id = this._editPropertyDialogDomId;
  5187. dialogPropertyElement.showDialog = true;
  5188. document.body.appendChild(dialogPropertyElement);
  5189. /* 监听修改事件 */
  5190. dialogPropertyElement.addEventListener(
  5191. "submit",
  5192. (e) => {
  5193. if (callEdit) callEdit(e.detail[0]);
  5194. },
  5195. false
  5196. );
  5197. /* 监听移除事件 */
  5198. dialogPropertyElement.addEventListener(
  5199. "remove",
  5200. (e) => {
  5201. if (callRemove) callRemove();
  5202. },
  5203. false
  5204. );
  5205. },
  5206. /**
  5207. * 关闭属性编辑框
  5208. * @ignore
  5209. */
  5210. _closePropertyEditDialog() {
  5211. let dom = document.getElementById(this._editPropertyDialogDomId);
  5212. if (dom !== null && dom !== undefined) {
  5213. document.body.removeChild(dom);
  5214. }
  5215. }
  5216. })
  5217. /**
  5218. * 绘制类型
  5219. */
  5220. DrawTools.DrawType = Object.freeze({
  5221. Point: 'point',
  5222. Polyline: 'polyline', //贴地线
  5223. ArrowPolyline: 'arrowPolyline', //箭头线
  5224. DynamicPolyline: 'dynamicPolyline', //流动线
  5225. GrowPolyline: '发光线',
  5226. OutlinePolyline: 'outlinePolyline', //描边线
  5227. OdLine: 'odLine', //OD线
  5228. Polygon: 'polygon', //贴地面
  5229. SpatialLine: 'spatialLine', //空间线
  5230. Circle: 'circle', //普通圆
  5231. DynamicCircle: 'dynamicCircle', //动态圆
  5232. Rectangle: 'rectangle', //矩形
  5233. NormalWall: 'normalWall', //普通墙
  5234. DynamicWall: 'dynamicWall', //动态墙
  5235. House: 'house', //房屋
  5236. TextWall: 'text', //文字
  5237. VideoWall: 'videoWall', //视频墙
  5238. })
  5239. /**
  5240. * 点图标类型
  5241. */
  5242. DrawTools.IconType = Object.freeze({
  5243. Normal: 'normal',
  5244. Blue: 'blue',
  5245. Green: 'green',
  5246. Violet: 'violter',
  5247. })
  5248. /**
  5249. * 编辑点类型
  5250. */
  5251. DrawTools.EditPointType = Object.freeze({
  5252. Node: 'node', //节点
  5253. Middle: 'middle', //中间点
  5254. Center: 'center', //中心点
  5255. CoordinateAxis: 'coordinateAxis', //坐标轴
  5256. OdlineStrartNode: 'odlineStartNode', //OD线起始点
  5257. OdlineEndNode: 'odlineEndNode', //OD线终点
  5258. })
  5259. /**
  5260. * 绘制墙的类型
  5261. */
  5262. DrawTools.WallType = Object.freeze({
  5263. ColorWall: 'colorWall', //颜色墙
  5264. DynamicWall: 'dynamicWall', //动态墙
  5265. TextWall: 'textWall', //文字墙
  5266. })
  5267. /**
  5268. * 绘制圆类型
  5269. */
  5270. DrawTools.CircleType = Object.freeze({
  5271. ColorCircle: 'colorCircle', //颜色圆
  5272. DynamicCircle: 'dynamicCircle', //动态圆
  5273. })
  5274. /**
  5275. * 绘制线类型
  5276. */
  5277. DrawTools.PolylineType = Object.freeze({
  5278. NormalPolyline: 'normalPolyline', //普通线
  5279. ArrowsPolyline: 'arrowsPolyline', //箭头线
  5280. DynamicPolyline: 'dynamicPolyline', //流动线
  5281. DottedPolyline: 'dottedPolyline', //虚线
  5282. GrowPolyline: 'growPolyline', //发光线
  5283. OutlinePolyline: 'outlinePolyline', //描边线
  5284. })
  5285. /**
  5286. * 绘制面类型
  5287. */
  5288. DrawTools.PolygonType = Object.freeze({
  5289. NormalPolygon: 'normalPolygon', //贴地面
  5290. HousePolygon: 'housePolygon', //拉伸贴地面
  5291. })
  5292. /**
  5293. * 运行环境类型
  5294. */
  5295. DrawTools.RuntimeEnvironment = Object.freeze(({
  5296. App: 'app',
  5297. Web: 'web'
  5298. }))
  5299. class WallMaterialProperty {
  5300. /**
  5301. * 构造方法
  5302. * @ignore 无需公开
  5303. * @param {JSON} options 配置项
  5304. * @param {Cesium.Viewer} options.viewer 着色器运行所需的视图
  5305. * @param {Cesium.Color} options.color [墙的颜色,默认蓝色] 可选
  5306. * @param {Number} options.duration [循环时间 默认1000] 可选
  5307. * @param {String} options.trailImage 墙的贴图
  5308. * @param {JSON} options.param 着色器参数
  5309. * @param {Number} options.param.count [数量 可选 默认为1]
  5310. * @param {String} options.param.direction [方向 可选 默认竖直 ] 取值vertical/horizontal
  5311. * @param {String} options.param.order [顺序 可选 上下/下上/顺时针/逆时针 与方向配合使用 ] 取值+/-
  5312. */
  5313. constructor(options) {
  5314. /* 着色器运行依赖的视图 */
  5315. this._viewer = options.viewer;
  5316. /* 变更事件 */
  5317. this._definitionChanged = new Cesium.Event();
  5318. this._color = undefined;
  5319. /* 墙的颜色 */
  5320. this.color = options.color || Cesium.Color.BLUE;
  5321. /* 动态循环周期 */
  5322. this.duration = options.duration || 1000;
  5323. /* 墙的贴图 */
  5324. this.trailImage = options.trailImage;
  5325. /* 默认时间 */
  5326. this._time = (new Date()).getTime();
  5327. /* 材质类型名称 */
  5328. this._materialTypeName = 'WallMaterial' + this._guid();
  5329. /* 存储相关参数的属性 以便后期进行追踪修改 */
  5330. this._param = {
  5331. color: this.color._value.toCssColorString(),
  5332. image: this.trailImage,
  5333. duration: this.duration,
  5334. count: 0,
  5335. direction: '',
  5336. order: '',
  5337. }
  5338. /* 将材质加入缓存 以便重复利用 */
  5339. Cesium.Material._materialCache.addMaterial(this._materialTypeName, {
  5340. fabric: {
  5341. type: this._materialTypeName,
  5342. uniforms: {
  5343. time: -20,
  5344. color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
  5345. image: options.trailImage,
  5346. },
  5347. source: this._getDirectionWallShader(options.param)
  5348. },
  5349. translucent: function(material) {
  5350. /* 材质是否半透明 */
  5351. return true;
  5352. }
  5353. });
  5354. }
  5355. /**
  5356. * 生成GUID随机数
  5357. * @ignore 无需公开
  5358. */
  5359. _guid() {
  5360. function S4() {
  5361. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  5362. }
  5363. return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
  5364. }
  5365. /**
  5366. * 重新获取类型方法
  5367. * @ignore 无需公开
  5368. * @param {Cesium.JulianDate} time 时间
  5369. */
  5370. getType(time) {
  5371. return this._materialTypeName;
  5372. }
  5373. /**
  5374. * 重写获取值方法
  5375. * @ignore 无需公开
  5376. * @param {Cesium.JulianDate} time
  5377. * @param {JSON} result
  5378. */
  5379. getValue(time, result) {
  5380. if (!Cesium.defined(result)) {
  5381. result = {};
  5382. }
  5383. result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.BLUE, result.color);
  5384. result.image = this.trailImage;
  5385. if (this.duration) {
  5386. result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
  5387. }
  5388. this._viewer.scene.requestRender();
  5389. return result;
  5390. }
  5391. /**
  5392. * 重写对比函数
  5393. * @ignore 无需公开
  5394. * @param {Object} other 传入对比对象
  5395. */
  5396. equals(other) {
  5397. return (this === other || (other instanceof WallMaterialProperty && Cesium.Property.equals(this
  5398. ._color, other._color) && other._param.order === this._param.order && other._param.count ===
  5399. this._param.count && other._param.direction === this._param.direction && other.duration === this
  5400. .duration));
  5401. }
  5402. /**
  5403. * 创建着色器资源
  5404. * @ignore 无需公开
  5405. * @param {JSON} options 配置项
  5406. * @param {Number} options.count [数量 可选 默认为1]
  5407. * @param {String} options.direction [方向 可选 默认竖直 ] 取值vertical/horizontal
  5408. * @param {String} options.order [顺序 可选 上下/下上/顺时针/逆时针 与方向配合使用 ] 取值+/-
  5409. */
  5410. _getDirectionWallShader(options) {
  5411. let op = Cesium.defaultValue(options, {});
  5412. // console.log('>>>op===', op);
  5413. let count = op.count !== undefined && typeof op.count === 'number' && op.count > 0 ? op
  5414. .count : 1;
  5415. let direction = op.direction === 'horizontal' ? 'horizontal' : 'vertical';
  5416. let order = op.order === '+' ? '+' : '-';
  5417. this._param.count = count;
  5418. this._param.direction = direction;
  5419. this._param.order = order;
  5420. let materail = '';
  5421. /* 补充参数 */
  5422. // console.log(this._param);
  5423. materail += 'czm_material czm_getMaterial(czm_materialInput materialInput){\n' +
  5424. ' czm_material material = czm_getDefaultMaterial(materialInput);\n' +
  5425. ' vec2 st = materialInput.st;\n';
  5426. if (direction === 'vertical') {
  5427. materail += ' vec4 colorImage = texture2D(image,vec2(st.s,fract(float(' + count + ')*st.t ' + order +
  5428. ' time)));\n';
  5429. } else if (direction === 'horizontal') {
  5430. materail += ' vec4 colorImage = texture2D(image, vec2(fract(float(' + count + ')*st.s ' + order +
  5431. ' time), st.t));\n'
  5432. }
  5433. materail += ' vec4 fragColor;\n' +
  5434. ' fragColor.rgb = color.rgb / 1.0;\n' +
  5435. ' fragColor = czm_gammaCorrect(fragColor);\n' +
  5436. ' material.alpha = colorImage.a * color.a;\n' +
  5437. ' material.diffuse = color.rgb;\n' +
  5438. ' material.emission = fragColor.rgb;\n' +
  5439. ' return material;\n' +
  5440. '}';
  5441. return materail;
  5442. }
  5443. }
  5444. /**
  5445. * 增加默认属性
  5446. */
  5447. Object.defineProperties(WallMaterialProperty.prototype, {
  5448. /**
  5449. * @ignore 无需公开
  5450. * 判断是否相等,返回false表示属性一直在变化中
  5451. */
  5452. isConstant: {
  5453. get: function() {
  5454. return false;
  5455. }
  5456. },
  5457. /**
  5458. * @ignore 无需公开
  5459. * 事件变更
  5460. */
  5461. definitionChanged: {
  5462. get: function() {
  5463. return this._definitionChanged;
  5464. }
  5465. },
  5466. /* 颜色属性 */
  5467. color: Cesium.createPropertyDescriptor('color')
  5468. })
  5469. /**
  5470. * 创建者:王成
  5471. * 操作系统:MAC
  5472. * 创建日期:2022年12月29日
  5473. * 描述:动态扩散圆材质
  5474. */
  5475. class CircleMaterialProperty {
  5476. /**
  5477. * 构造方法
  5478. * @ignore 无需公开
  5479. * @param {JSON} options 配置项
  5480. * @param {Cesium.Viewer} options.viewer 着色器运行所需的视图
  5481. * @param {Cesium.Color} options.color [圆环的颜色,默认蓝色] 可选
  5482. * @param {Number} options.duration [循环时间 默认1000] 可选
  5483. * @param {Number} options.count [圆环的数量 可选 默认为1]
  5484. */
  5485. constructor(options) {
  5486. /* 着色器运行依赖的视图 */
  5487. this._viewer = options.viewer;
  5488. /* 变更事件 */
  5489. this._definitionChanged = new Cesium.Event();
  5490. this._color = undefined;
  5491. /* 扩算圆环的颜色 */
  5492. this.color = options.color || Cesium.Color.BLUE;
  5493. /* 扩散圆环的数量 */
  5494. this.count = options.count || 1.0;
  5495. /* 动态循环周期 */
  5496. this.duration = options.duration || 1000;
  5497. /* 默认时间 */
  5498. this._time = (new Date()).getTime();
  5499. /* 材质类型名称 */
  5500. this._materialTypeName = 'jtCircleMaterial'
  5501. /* 存储相关参数的属性 以便后期进行追踪修改 */
  5502. this._param = {
  5503. color: this.color._value.toCssColorString(),
  5504. duration: this.duration,
  5505. count: this.count,
  5506. }
  5507. /* 将材质加入缓存 以便重复利用 */
  5508. Cesium.Material._materialCache.addMaterial(this._materialTypeName, {
  5509. fabric: {
  5510. type: this._materialTypeName,
  5511. uniforms: {
  5512. time: 0,
  5513. color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
  5514. count: 1.0,
  5515. },
  5516. source: this._getCircleMaterial(),
  5517. },
  5518. translucent: function(material) {
  5519. /* 材质是否半透明 */
  5520. return true;
  5521. }
  5522. });
  5523. }
  5524. /**
  5525. * @ignore 无需公开
  5526. * 获取材质着色器Shader
  5527. */
  5528. _getCircleMaterial() {
  5529. let circleMaterial = "czm_material czm_getMaterial(czm_materialInput materialInput)\n" +
  5530. "{\n" +
  5531. " czm_material material = czm_getDefaultMaterial(materialInput);\n" +
  5532. " material.diffuse = 1.5 * color.rgb;\n" +
  5533. " vec2 st = materialInput.st;\n" +
  5534. " vec3 str = materialInput.str;\n" +
  5535. " float dis = distance(st, vec2(0.5, 0.5));\n" +
  5536. " float per = fract(time);\n" +
  5537. " if (abs(str.z) > 0.001)\n" +
  5538. " {\n" +
  5539. " //着色器渲染停止,不在绘制内容 \n" +
  5540. " discard;\n" +
  5541. " }\n" +
  5542. " if (dis > 0.5)\n" +
  5543. " {\n" +
  5544. " //超出半径范围时,着色器渲染停止 \n" +
  5545. " discard;\n" +
  5546. " } else {\n" +
  5547. " //把半径分成count份,每两份之间的间隔距离 \n" +
  5548. " float perDis = 0.5 / count;\n" +
  5549. " float disNum;\n" +
  5550. " float bl = 0.0;\n" +
  5551. " //循环,最多999个环 \n" +
  5552. " for (int i = 0; i <= 999; i++)\n" +
  5553. " {\n" +
  5554. " //判断是否属于数量内的环 \n" +
  5555. " if (float(i) <= count)\n" +
  5556. " {\n" +
  5557. " disNum = perDis * float(i) - dis + per / count;\n" +
  5558. " if (disNum > 0.0)\n" +
  5559. " {\n" +
  5560. " if (disNum < perDis)\n" +
  5561. " {\n" +
  5562. " bl = 1.0 - disNum / perDis;\n" +
  5563. " } else if (disNum - perDis < perDis) {\n" +
  5564. " bl = 1.0 - abs(1.0 - disNum / perDis);\n" +
  5565. " }\n" +
  5566. " material.alpha = color.a * pow(bl, 3.0);\n" +
  5567. " }\n" +
  5568. " }\n" +
  5569. " }\n" +
  5570. " }\n" +
  5571. " return material;\n" +
  5572. "}\n";
  5573. return circleMaterial;
  5574. }
  5575. }
  5576. /**
  5577. * @ignore 无需公开
  5578. * 必须重写的方法
  5579. */
  5580. Object.assign(CircleMaterialProperty.prototype, {
  5581. /**
  5582. * 重新获取类型方法
  5583. * @ignore 无需公开
  5584. * @param {Cesium.JulianDate} time 时间
  5585. */
  5586. getType: function(time) {
  5587. return this._materialTypeName;
  5588. },
  5589. /**
  5590. * 重写获取值方法
  5591. * @ignore 无需公开
  5592. * @param {Cesium.JulianDate} time
  5593. * @param {JSON} result
  5594. */
  5595. getValue: function(time, result) {
  5596. if (!Cesium.defined(result)) {
  5597. result = {};
  5598. }
  5599. result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.BLUE, result
  5600. .color);
  5601. result.count = this.count;
  5602. if (this.duration) {
  5603. result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
  5604. }
  5605. this._viewer.scene.requestRender();
  5606. return result;
  5607. },
  5608. /**
  5609. * 重写对比函数
  5610. * @ignore 无需公开
  5611. * @param {Object} other 传入对比对象
  5612. */
  5613. equals: function(other) {
  5614. return (this === other || (other instanceof CircleMaterialProperty && Cesium.Property.equals(this
  5615. ._color, other._color)));
  5616. }
  5617. })
  5618. /**
  5619. * 默认属性
  5620. */
  5621. Object.defineProperties(CircleMaterialProperty.prototype, {
  5622. /**
  5623. * 判断是否相等,返回false表示属性一直在变化中
  5624. * @ignore 无需公开
  5625. */
  5626. isConstant: {
  5627. get: function() {
  5628. return false;
  5629. }
  5630. },
  5631. /**
  5632. * 事件变更
  5633. * @ignore 无需公开
  5634. */
  5635. definitionChanged: {
  5636. get: function() {
  5637. return this._definitionChanged;
  5638. }
  5639. },
  5640. /* 颜色属性 */
  5641. color: Cesium.createPropertyDescriptor('color')
  5642. })
  5643. /* 输出 */
  5644. export {
  5645. DrawTools
  5646. }