OpenLayers.js 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460
  1. /*!
  2. * OpenLayers v6.15.1 (https://openlayers.org/)
  3. * Copyright 2005-present, OpenLayers Contributors All rights reserved.
  4. * Licensed under BSD 2-Clause License (https://github.com/openlayers/openlayers/blob/main/LICENSE.md)
  5. *
  6. * @license BSD-2-Clause
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define([], factory);
  13. else if(typeof exports === 'object')
  14. exports["ol"] = factory();
  15. else
  16. root["ol"] = factory();
  17. })(self, function() {
  18. return /******/ (function() { // webpackBootstrap
  19. /******/ var __webpack_modules__ = ({
  20. /***/ 341:
  21. /***/ (function(module) {
  22. !function(t,i){ true?module.exports=i():0}(this,function(){"use strict";function t(t,r,e,a,h){!function t(n,r,e,a,h){for(;a>e;){if(a-e>600){var o=a-e+1,s=r-e+1,l=Math.log(o),f=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*f*(o-f)/o)*(s-o/2<0?-1:1),m=Math.max(e,Math.floor(r-s*f/o+u)),c=Math.min(a,Math.floor(r+(o-s)*f/o+u));t(n,r,m,c,h)}var p=n[r],d=e,x=a;for(i(n,e,r),h(n[a],p)>0&&i(n,e,a);d<x;){for(i(n,d,x),d++,x--;h(n[d],p)<0;)d++;for(;h(n[x],p)>0;)x--}0===h(n[e],p)?i(n,e,x):i(n,++x,a),x<=r&&(e=x+1),r<=x&&(a=x-1)}}(t,r,e||0,a||t.length-1,h||n)}function i(t,i,n){var r=t[i];t[i]=t[n],t[n]=r}function n(t,i){return t<i?-1:t>i?1:0}var r=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function e(t,i,n){if(!n)return i.indexOf(t);for(var r=0;r<i.length;r++)if(n(t,i[r]))return r;return-1}function a(t,i){h(t,0,t.children.length,i,t)}function h(t,i,n,r,e){e||(e=p(null)),e.minX=1/0,e.minY=1/0,e.maxX=-1/0,e.maxY=-1/0;for(var a=i;a<n;a++){var h=t.children[a];o(e,t.leaf?r(h):h)}return e}function o(t,i){return t.minX=Math.min(t.minX,i.minX),t.minY=Math.min(t.minY,i.minY),t.maxX=Math.max(t.maxX,i.maxX),t.maxY=Math.max(t.maxY,i.maxY),t}function s(t,i){return t.minX-i.minX}function l(t,i){return t.minY-i.minY}function f(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function u(t){return t.maxX-t.minX+(t.maxY-t.minY)}function m(t,i){return t.minX<=i.minX&&t.minY<=i.minY&&i.maxX<=t.maxX&&i.maxY<=t.maxY}function c(t,i){return i.minX<=t.maxX&&i.minY<=t.maxY&&i.maxX>=t.minX&&i.maxY>=t.minY}function p(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function d(i,n,r,e,a){for(var h=[n,r];h.length;)if(!((r=h.pop())-(n=h.pop())<=e)){var o=n+Math.ceil((r-n)/e/2)*e;t(i,o,n,r,a),h.push(n,o,o,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(t){var i=this.data,n=[];if(!c(t,i))return n;for(var r=this.toBBox,e=[];i;){for(var a=0;a<i.children.length;a++){var h=i.children[a],o=i.leaf?r(h):h;c(t,o)&&(i.leaf?n.push(h):m(t,o)?this._all(h,n):e.push(h))}i=e.pop()}return n},r.prototype.collides=function(t){var i=this.data;if(!c(t,i))return!1;for(var n=[];i;){for(var r=0;r<i.children.length;r++){var e=i.children[r],a=i.leaf?this.toBBox(e):e;if(c(t,a)){if(i.leaf||m(t,a))return!0;n.push(e)}}i=n.pop()}return!1},r.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var i=0;i<t.length;i++)this.insert(t[i]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},r.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},r.prototype.clear=function(){return this.data=p([]),this},r.prototype.remove=function(t,i){if(!t)return this;for(var n,r,a,h=this.data,o=this.toBBox(t),s=[],l=[];h||s.length;){if(h||(h=s.pop(),r=s[s.length-1],n=l.pop(),a=!0),h.leaf){var f=e(t,h.children,i);if(-1!==f)return h.children.splice(f,1),s.push(h),this._condense(s),this}a||h.leaf||!m(h,o)?r?(n++,h=r.children[n],a=!1):h=null:(s.push(h),l.push(n),n=0,r=h,h=h.children[0])}return this},r.prototype.toBBox=function(t){return t},r.prototype.compareMinX=function(t,i){return t.minX-i.minX},r.prototype.compareMinY=function(t,i){return t.minY-i.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(t){return this.data=t,this},r.prototype._all=function(t,i){for(var n=[];t;)t.leaf?i.push.apply(i,t.children):n.push.apply(n,t.children),t=n.pop();return i},r.prototype._build=function(t,i,n,r){var e,h=n-i+1,o=this._maxEntries;if(h<=o)return a(e=p(t.slice(i,n+1)),this.toBBox),e;r||(r=Math.ceil(Math.log(h)/Math.log(o)),o=Math.ceil(h/Math.pow(o,r-1))),(e=p([])).leaf=!1,e.height=r;var s=Math.ceil(h/o),l=s*Math.ceil(Math.sqrt(o));d(t,i,n,l,this.compareMinX);for(var f=i;f<=n;f+=l){var u=Math.min(f+l-1,n);d(t,f,u,s,this.compareMinY);for(var m=f;m<=u;m+=s){var c=Math.min(m+s-1,u);e.children.push(this._build(t,m,c,r-1))}}return a(e,this.toBBox),e},r.prototype._chooseSubtree=function(t,i,n,r){for(;r.push(i),!i.leaf&&r.length-1!==n;){for(var e=1/0,a=1/0,h=void 0,o=0;o<i.children.length;o++){var s=i.children[o],l=f(s),u=(m=t,c=s,(Math.max(c.maxX,m.maxX)-Math.min(c.minX,m.minX))*(Math.max(c.maxY,m.maxY)-Math.min(c.minY,m.minY))-l);u<a?(a=u,e=l<e?l:e,h=s):u===a&&l<e&&(e=l,h=s)}i=h||i.children[0]}var m,c;return i},r.prototype._insert=function(t,i,n){var r=n?t:this.toBBox(t),e=[],a=this._chooseSubtree(r,this.data,i,e);for(a.children.push(t),o(a,r);i>=0&&e[i].children.length>this._maxEntries;)this._split(e,i),i--;this._adjustParentBBoxes(r,e,i)},r.prototype._split=function(t,i){var n=t[i],r=n.children.length,e=this._minEntries;this._chooseSplitAxis(n,e,r);var h=this._chooseSplitIndex(n,e,r),o=p(n.children.splice(h,n.children.length-h));o.height=n.height,o.leaf=n.leaf,a(n,this.toBBox),a(o,this.toBBox),i?t[i-1].children.push(o):this._splitRoot(n,o)},r.prototype._splitRoot=function(t,i){this.data=p([t,i]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(t,i,n){for(var r,e,a,o,s,l,u,m=1/0,c=1/0,p=i;p<=n-i;p++){var d=h(t,0,p,this.toBBox),x=h(t,p,n,this.toBBox),v=(e=d,a=x,o=void 0,s=void 0,l=void 0,u=void 0,o=Math.max(e.minX,a.minX),s=Math.max(e.minY,a.minY),l=Math.min(e.maxX,a.maxX),u=Math.min(e.maxY,a.maxY),Math.max(0,l-o)*Math.max(0,u-s)),M=f(d)+f(x);v<m?(m=v,r=p,c=M<c?M:c):v===m&&M<c&&(c=M,r=p)}return r||n-i},r.prototype._chooseSplitAxis=function(t,i,n){var r=t.leaf?this.compareMinX:s,e=t.leaf?this.compareMinY:l;this._allDistMargin(t,i,n,r)<this._allDistMargin(t,i,n,e)&&t.children.sort(r)},r.prototype._allDistMargin=function(t,i,n,r){t.children.sort(r);for(var e=this.toBBox,a=h(t,0,i,e),s=h(t,n-i,n,e),l=u(a)+u(s),f=i;f<n-i;f++){var m=t.children[f];o(a,t.leaf?e(m):m),l+=u(a)}for(var c=n-i-1;c>=i;c--){var p=t.children[c];o(s,t.leaf?e(p):p),l+=u(s)}return l},r.prototype._adjustParentBBoxes=function(t,i,n){for(var r=n;r>=0;r--)o(i[r],t)},r.prototype._condense=function(t){for(var i=t.length-1,n=void 0;i>=0;i--)0===t[i].children.length?i>0?(n=t[i-1].children).splice(n.indexOf(t[i]),1):this.clear():a(t[i],this.toBBox)},r});
  23. /***/ })
  24. /******/ });
  25. /************************************************************************/
  26. /******/ // The module cache
  27. /******/ var __webpack_module_cache__ = {};
  28. /******/
  29. /******/ // The require function
  30. /******/ function __webpack_require__(moduleId) {
  31. /******/ // Check if module is in cache
  32. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  33. /******/ if (cachedModule !== undefined) {
  34. /******/ return cachedModule.exports;
  35. /******/ }
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = __webpack_module_cache__[moduleId] = {
  38. /******/ // no module.id needed
  39. /******/ // no module.loaded needed
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /************************************************************************/
  51. /******/ /* webpack/runtime/define property getters */
  52. /******/ !function() {
  53. /******/ // define getter functions for harmony exports
  54. /******/ __webpack_require__.d = function(exports, definition) {
  55. /******/ for(var key in definition) {
  56. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  57. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  58. /******/ }
  59. /******/ }
  60. /******/ };
  61. /******/ }();
  62. /******/
  63. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  64. /******/ !function() {
  65. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  66. /******/ }();
  67. /******/
  68. /************************************************************************/
  69. var __webpack_exports__ = {};
  70. // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
  71. !function() {
  72. "use strict";
  73. // EXPORTS
  74. __webpack_require__.d(__webpack_exports__, {
  75. "default": function() { return /* binding */ src_ol; }
  76. });
  77. ;// ./node_modules/ol/events/Event.js
  78. /**
  79. * @module ol/events/Event
  80. */
  81. /**
  82. * @classdesc
  83. * Stripped down implementation of the W3C DOM Level 2 Event interface.
  84. * See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.
  85. *
  86. * This implementation only provides `type` and `target` properties, and
  87. * `stopPropagation` and `preventDefault` methods. It is meant as base class
  88. * for higher level events defined in the library, and works with
  89. * {@link module:ol/events/Target~Target}.
  90. */
  91. var BaseEvent = /** @class */ (function () {
  92. /**
  93. * @param {string} type Type.
  94. */
  95. function BaseEvent(type) {
  96. /**
  97. * @type {boolean}
  98. */
  99. this.propagationStopped;
  100. /**
  101. * @type {boolean}
  102. */
  103. this.defaultPrevented;
  104. /**
  105. * The event type.
  106. * @type {string}
  107. * @api
  108. */
  109. this.type = type;
  110. /**
  111. * The event target.
  112. * @type {Object}
  113. * @api
  114. */
  115. this.target = null;
  116. }
  117. /**
  118. * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
  119. * will be fired.
  120. * @api
  121. */
  122. BaseEvent.prototype.preventDefault = function () {
  123. this.defaultPrevented = true;
  124. };
  125. /**
  126. * Stop event propagation.
  127. * @api
  128. */
  129. BaseEvent.prototype.stopPropagation = function () {
  130. this.propagationStopped = true;
  131. };
  132. return BaseEvent;
  133. }());
  134. /**
  135. * @param {Event|import("./Event.js").default} evt Event
  136. */
  137. function stopPropagation(evt) {
  138. evt.stopPropagation();
  139. }
  140. /**
  141. * @param {Event|import("./Event.js").default} evt Event
  142. */
  143. function preventDefault(evt) {
  144. evt.preventDefault();
  145. }
  146. /* harmony default export */ var Event = (BaseEvent);
  147. //# sourceMappingURL=Event.js.map
  148. ;// ./node_modules/ol/ObjectEventType.js
  149. /**
  150. * @module ol/ObjectEventType
  151. */
  152. /**
  153. * @enum {string}
  154. */
  155. /* harmony default export */ var ObjectEventType = ({
  156. /**
  157. * Triggered when a property is changed.
  158. * @event module:ol/Object.ObjectEvent#propertychange
  159. * @api
  160. */
  161. PROPERTYCHANGE: 'propertychange',
  162. });
  163. /**
  164. * @typedef {'propertychange'} Types
  165. */
  166. //# sourceMappingURL=ObjectEventType.js.map
  167. ;// ./node_modules/ol/Disposable.js
  168. /**
  169. * @module ol/Disposable
  170. */
  171. /**
  172. * @classdesc
  173. * Objects that need to clean up after themselves.
  174. */
  175. var Disposable = /** @class */ (function () {
  176. function Disposable() {
  177. /**
  178. * The object has already been disposed.
  179. * @type {boolean}
  180. * @protected
  181. */
  182. this.disposed = false;
  183. }
  184. /**
  185. * Clean up.
  186. */
  187. Disposable.prototype.dispose = function () {
  188. if (!this.disposed) {
  189. this.disposed = true;
  190. this.disposeInternal();
  191. }
  192. };
  193. /**
  194. * Extension point for disposable objects.
  195. * @protected
  196. */
  197. Disposable.prototype.disposeInternal = function () { };
  198. return Disposable;
  199. }());
  200. /* harmony default export */ var ol_Disposable = (Disposable);
  201. //# sourceMappingURL=Disposable.js.map
  202. ;// ./node_modules/ol/array.js
  203. /**
  204. * @module ol/array
  205. */
  206. /**
  207. * Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.
  208. * https://github.com/darkskyapp/binary-search
  209. *
  210. * @param {Array<*>} haystack Items to search through.
  211. * @param {*} needle The item to look for.
  212. * @param {Function} [opt_comparator] Comparator function.
  213. * @return {number} The index of the item if found, -1 if not.
  214. */
  215. function binarySearch(haystack, needle, opt_comparator) {
  216. var mid, cmp;
  217. var comparator = opt_comparator || numberSafeCompareFunction;
  218. var low = 0;
  219. var high = haystack.length;
  220. var found = false;
  221. while (low < high) {
  222. /* Note that "(low + high) >>> 1" may overflow, and results in a typecast
  223. * to double (which gives the wrong results). */
  224. mid = low + ((high - low) >> 1);
  225. cmp = +comparator(haystack[mid], needle);
  226. if (cmp < 0.0) {
  227. /* Too low. */
  228. low = mid + 1;
  229. }
  230. else {
  231. /* Key found or too high */
  232. high = mid;
  233. found = !cmp;
  234. }
  235. }
  236. /* Key not found. */
  237. return found ? low : ~low;
  238. }
  239. /**
  240. * Compare function for array sort that is safe for numbers.
  241. * @param {*} a The first object to be compared.
  242. * @param {*} b The second object to be compared.
  243. * @return {number} A negative number, zero, or a positive number as the first
  244. * argument is less than, equal to, or greater than the second.
  245. */
  246. function numberSafeCompareFunction(a, b) {
  247. return a > b ? 1 : a < b ? -1 : 0;
  248. }
  249. /**
  250. * Whether the array contains the given object.
  251. * @param {Array<*>} arr The array to test for the presence of the element.
  252. * @param {*} obj The object for which to test.
  253. * @return {boolean} The object is in the array.
  254. */
  255. function includes(arr, obj) {
  256. return arr.indexOf(obj) >= 0;
  257. }
  258. /**
  259. * {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution} can use a function
  260. * of this type to determine which nearest resolution to use.
  261. *
  262. * This function takes a `{number}` representing a value between two array entries,
  263. * a `{number}` representing the value of the nearest higher entry and
  264. * a `{number}` representing the value of the nearest lower entry
  265. * as arguments and returns a `{number}`. If a negative number or zero is returned
  266. * the lower value will be used, if a positive number is returned the higher value
  267. * will be used.
  268. * @typedef {function(number, number, number): number} NearestDirectionFunction
  269. * @api
  270. */
  271. /**
  272. * @param {Array<number>} arr Array in descending order.
  273. * @param {number} target Target.
  274. * @param {number|NearestDirectionFunction} direction
  275. * 0 means return the nearest,
  276. * > 0 means return the largest nearest,
  277. * < 0 means return the smallest nearest.
  278. * @return {number} Index.
  279. */
  280. function linearFindNearest(arr, target, direction) {
  281. var n = arr.length;
  282. if (arr[0] <= target) {
  283. return 0;
  284. }
  285. else if (target <= arr[n - 1]) {
  286. return n - 1;
  287. }
  288. else {
  289. var i = void 0;
  290. if (direction > 0) {
  291. for (i = 1; i < n; ++i) {
  292. if (arr[i] < target) {
  293. return i - 1;
  294. }
  295. }
  296. }
  297. else if (direction < 0) {
  298. for (i = 1; i < n; ++i) {
  299. if (arr[i] <= target) {
  300. return i;
  301. }
  302. }
  303. }
  304. else {
  305. for (i = 1; i < n; ++i) {
  306. if (arr[i] == target) {
  307. return i;
  308. }
  309. else if (arr[i] < target) {
  310. if (typeof direction === 'function') {
  311. if (direction(target, arr[i - 1], arr[i]) > 0) {
  312. return i - 1;
  313. }
  314. else {
  315. return i;
  316. }
  317. }
  318. else if (arr[i - 1] - target < target - arr[i]) {
  319. return i - 1;
  320. }
  321. else {
  322. return i;
  323. }
  324. }
  325. }
  326. }
  327. return n - 1;
  328. }
  329. }
  330. /**
  331. * @param {Array<*>} arr Array.
  332. * @param {number} begin Begin index.
  333. * @param {number} end End index.
  334. */
  335. function reverseSubArray(arr, begin, end) {
  336. while (begin < end) {
  337. var tmp = arr[begin];
  338. arr[begin] = arr[end];
  339. arr[end] = tmp;
  340. ++begin;
  341. --end;
  342. }
  343. }
  344. /**
  345. * @param {Array<VALUE>} arr The array to modify.
  346. * @param {!Array<VALUE>|VALUE} data The elements or arrays of elements to add to arr.
  347. * @template VALUE
  348. */
  349. function array_extend(arr, data) {
  350. var extension = Array.isArray(data) ? data : [data];
  351. var length = extension.length;
  352. for (var i = 0; i < length; i++) {
  353. arr[arr.length] = extension[i];
  354. }
  355. }
  356. /**
  357. * @param {Array<VALUE>} arr The array to modify.
  358. * @param {VALUE} obj The element to remove.
  359. * @template VALUE
  360. * @return {boolean} If the element was removed.
  361. */
  362. function remove(arr, obj) {
  363. var i = arr.indexOf(obj);
  364. var found = i > -1;
  365. if (found) {
  366. arr.splice(i, 1);
  367. }
  368. return found;
  369. }
  370. /**
  371. * @param {Array<VALUE>} arr The array to search in.
  372. * @param {function(VALUE, number, ?) : boolean} func The function to compare.
  373. * @template VALUE
  374. * @return {VALUE|null} The element found or null.
  375. */
  376. function find(arr, func) {
  377. var length = arr.length >>> 0;
  378. var value;
  379. for (var i = 0; i < length; i++) {
  380. value = arr[i];
  381. if (func(value, i, arr)) {
  382. return value;
  383. }
  384. }
  385. return null;
  386. }
  387. /**
  388. * @param {Array|Uint8ClampedArray} arr1 The first array to compare.
  389. * @param {Array|Uint8ClampedArray} arr2 The second array to compare.
  390. * @return {boolean} Whether the two arrays are equal.
  391. */
  392. function equals(arr1, arr2) {
  393. var len1 = arr1.length;
  394. if (len1 !== arr2.length) {
  395. return false;
  396. }
  397. for (var i = 0; i < len1; i++) {
  398. if (arr1[i] !== arr2[i]) {
  399. return false;
  400. }
  401. }
  402. return true;
  403. }
  404. /**
  405. * Sort the passed array such that the relative order of equal elements is preserved.
  406. * See https://en.wikipedia.org/wiki/Sorting_algorithm#Stability for details.
  407. * @param {Array<*>} arr The array to sort (modifies original).
  408. * @param {!function(*, *): number} compareFnc Comparison function.
  409. * @api
  410. */
  411. function stableSort(arr, compareFnc) {
  412. var length = arr.length;
  413. var tmp = Array(arr.length);
  414. var i;
  415. for (i = 0; i < length; i++) {
  416. tmp[i] = { index: i, value: arr[i] };
  417. }
  418. tmp.sort(function (a, b) {
  419. return compareFnc(a.value, b.value) || a.index - b.index;
  420. });
  421. for (i = 0; i < arr.length; i++) {
  422. arr[i] = tmp[i].value;
  423. }
  424. }
  425. /**
  426. * @param {Array<*>} arr The array to search in.
  427. * @param {Function} func Comparison function.
  428. * @return {number} Return index.
  429. */
  430. function findIndex(arr, func) {
  431. var index;
  432. var found = !arr.every(function (el, idx) {
  433. index = idx;
  434. return !func(el, idx, arr);
  435. });
  436. return found ? index : -1;
  437. }
  438. /**
  439. * @param {Array<*>} arr The array to test.
  440. * @param {Function} [opt_func] Comparison function.
  441. * @param {boolean} [opt_strict] Strictly sorted (default false).
  442. * @return {boolean} Return index.
  443. */
  444. function isSorted(arr, opt_func, opt_strict) {
  445. var compare = opt_func || numberSafeCompareFunction;
  446. return arr.every(function (currentVal, index) {
  447. if (index === 0) {
  448. return true;
  449. }
  450. var res = compare(arr[index - 1], currentVal);
  451. return !(res > 0 || (opt_strict && res === 0));
  452. });
  453. }
  454. //# sourceMappingURL=array.js.map
  455. ;// ./node_modules/ol/functions.js
  456. /**
  457. * @module ol/functions
  458. */
  459. /**
  460. * Always returns true.
  461. * @return {boolean} true.
  462. */
  463. function TRUE() {
  464. return true;
  465. }
  466. /**
  467. * Always returns false.
  468. * @return {boolean} false.
  469. */
  470. function functions_FALSE() {
  471. return false;
  472. }
  473. /**
  474. * A reusable function, used e.g. as a default for callbacks.
  475. *
  476. * @return {void} Nothing.
  477. */
  478. function VOID() { }
  479. /**
  480. * Wrap a function in another function that remembers the last return. If the
  481. * returned function is called twice in a row with the same arguments and the same
  482. * this object, it will return the value from the first call in the second call.
  483. *
  484. * @param {function(...any): ReturnType} fn The function to memoize.
  485. * @return {function(...any): ReturnType} The memoized function.
  486. * @template ReturnType
  487. */
  488. function memoizeOne(fn) {
  489. var called = false;
  490. /** @type {ReturnType} */
  491. var lastResult;
  492. /** @type {Array<any>} */
  493. var lastArgs;
  494. var lastThis;
  495. return function () {
  496. var nextArgs = Array.prototype.slice.call(arguments);
  497. if (!called || this !== lastThis || !equals(nextArgs, lastArgs)) {
  498. called = true;
  499. lastThis = this;
  500. lastArgs = nextArgs;
  501. lastResult = fn.apply(this, arguments);
  502. }
  503. return lastResult;
  504. };
  505. }
  506. /**
  507. * @template T
  508. * @param {function(): (T | Promise<T>)} getter A function that returns a value or a promise for a value.
  509. * @return {Promise<T>} A promise for the value.
  510. */
  511. function toPromise(getter) {
  512. function promiseGetter() {
  513. var value;
  514. try {
  515. value = getter();
  516. }
  517. catch (err) {
  518. return Promise.reject(err);
  519. }
  520. if (value instanceof Promise) {
  521. return value;
  522. }
  523. return Promise.resolve(value);
  524. }
  525. return promiseGetter();
  526. }
  527. //# sourceMappingURL=functions.js.map
  528. ;// ./node_modules/ol/obj.js
  529. /**
  530. * @module ol/obj
  531. */
  532. /**
  533. * Polyfill for Object.assign(). Assigns enumerable and own properties from
  534. * one or more source objects to a target object.
  535. * See https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign.
  536. *
  537. * @param {!Object} target The target object.
  538. * @param {...Object} var_sources The source object(s).
  539. * @return {!Object} The modified target object.
  540. */
  541. var obj_assign = typeof Object.assign === 'function'
  542. ? Object.assign
  543. : function (target, var_sources) {
  544. if (target === undefined || target === null) {
  545. throw new TypeError('Cannot convert undefined or null to object');
  546. }
  547. var output = Object(target);
  548. for (var i = 1, ii = arguments.length; i < ii; ++i) {
  549. var source = arguments[i];
  550. if (source !== undefined && source !== null) {
  551. for (var key in source) {
  552. if (source.hasOwnProperty(key)) {
  553. output[key] = source[key];
  554. }
  555. }
  556. }
  557. }
  558. return output;
  559. };
  560. /**
  561. * Removes all properties from an object.
  562. * @param {Object} object The object to clear.
  563. */
  564. function clear(object) {
  565. for (var property in object) {
  566. delete object[property];
  567. }
  568. }
  569. /**
  570. * Polyfill for Object.values(). Get an array of property values from an object.
  571. * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
  572. *
  573. * @param {!Object<K,V>} object The object from which to get the values.
  574. * @return {!Array<V>} The property values.
  575. * @template K,V
  576. */
  577. var getValues = typeof Object.values === 'function'
  578. ? Object.values
  579. : function (object) {
  580. var values = [];
  581. for (var property in object) {
  582. values.push(object[property]);
  583. }
  584. return values;
  585. };
  586. /**
  587. * Determine if an object has any properties.
  588. * @param {Object} object The object to check.
  589. * @return {boolean} The object is empty.
  590. */
  591. function obj_isEmpty(object) {
  592. var property;
  593. for (property in object) {
  594. return false;
  595. }
  596. return !property;
  597. }
  598. //# sourceMappingURL=obj.js.map
  599. ;// ./node_modules/ol/events/Target.js
  600. var __extends = (undefined && undefined.__extends) || (function () {
  601. var extendStatics = function (d, b) {
  602. extendStatics = Object.setPrototypeOf ||
  603. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  604. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  605. return extendStatics(d, b);
  606. };
  607. return function (d, b) {
  608. if (typeof b !== "function" && b !== null)
  609. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  610. extendStatics(d, b);
  611. function __() { this.constructor = d; }
  612. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  613. };
  614. })();
  615. /**
  616. * @module ol/events/Target
  617. */
  618. /**
  619. * @typedef {EventTarget|Target} EventTargetLike
  620. */
  621. /**
  622. * @classdesc
  623. * A simplified implementation of the W3C DOM Level 2 EventTarget interface.
  624. * See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.
  625. *
  626. * There are two important simplifications compared to the specification:
  627. *
  628. * 1. The handling of `useCapture` in `addEventListener` and
  629. * `removeEventListener`. There is no real capture model.
  630. * 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.
  631. * There is no event target hierarchy. When a listener calls
  632. * `stopPropagation` or `preventDefault` on an event object, it means that no
  633. * more listeners after this one will be called. Same as when the listener
  634. * returns false.
  635. */
  636. var Target = /** @class */ (function (_super) {
  637. __extends(Target, _super);
  638. /**
  639. * @param {*} [opt_target] Default event target for dispatched events.
  640. */
  641. function Target(opt_target) {
  642. var _this = _super.call(this) || this;
  643. /**
  644. * @private
  645. * @type {*}
  646. */
  647. _this.eventTarget_ = opt_target;
  648. /**
  649. * @private
  650. * @type {Object<string, number>}
  651. */
  652. _this.pendingRemovals_ = null;
  653. /**
  654. * @private
  655. * @type {Object<string, number>}
  656. */
  657. _this.dispatching_ = null;
  658. /**
  659. * @private
  660. * @type {Object<string, Array<import("../events.js").Listener>>}
  661. */
  662. _this.listeners_ = null;
  663. return _this;
  664. }
  665. /**
  666. * @param {string} type Type.
  667. * @param {import("../events.js").Listener} listener Listener.
  668. */
  669. Target.prototype.addEventListener = function (type, listener) {
  670. if (!type || !listener) {
  671. return;
  672. }
  673. var listeners = this.listeners_ || (this.listeners_ = {});
  674. var listenersForType = listeners[type] || (listeners[type] = []);
  675. if (listenersForType.indexOf(listener) === -1) {
  676. listenersForType.push(listener);
  677. }
  678. };
  679. /**
  680. * Dispatches an event and calls all listeners listening for events
  681. * of this type. The event parameter can either be a string or an
  682. * Object with a `type` property.
  683. *
  684. * @param {import("./Event.js").default|string} event Event object.
  685. * @return {boolean|undefined} `false` if anyone called preventDefault on the
  686. * event object or if any of the listeners returned false.
  687. * @api
  688. */
  689. Target.prototype.dispatchEvent = function (event) {
  690. var isString = typeof event === 'string';
  691. var type = isString ? event : event.type;
  692. var listeners = this.listeners_ && this.listeners_[type];
  693. if (!listeners) {
  694. return;
  695. }
  696. var evt = isString ? new Event(event) : /** @type {Event} */ (event);
  697. if (!evt.target) {
  698. evt.target = this.eventTarget_ || this;
  699. }
  700. var dispatching = this.dispatching_ || (this.dispatching_ = {});
  701. var pendingRemovals = this.pendingRemovals_ || (this.pendingRemovals_ = {});
  702. if (!(type in dispatching)) {
  703. dispatching[type] = 0;
  704. pendingRemovals[type] = 0;
  705. }
  706. ++dispatching[type];
  707. var propagate;
  708. for (var i = 0, ii = listeners.length; i < ii; ++i) {
  709. if ('handleEvent' in listeners[i]) {
  710. propagate = /** @type {import("../events.js").ListenerObject} */ (listeners[i]).handleEvent(evt);
  711. }
  712. else {
  713. propagate = /** @type {import("../events.js").ListenerFunction} */ (listeners[i]).call(this, evt);
  714. }
  715. if (propagate === false || evt.propagationStopped) {
  716. propagate = false;
  717. break;
  718. }
  719. }
  720. if (--dispatching[type] === 0) {
  721. var pr = pendingRemovals[type];
  722. delete pendingRemovals[type];
  723. while (pr--) {
  724. this.removeEventListener(type, VOID);
  725. }
  726. delete dispatching[type];
  727. }
  728. return propagate;
  729. };
  730. /**
  731. * Clean up.
  732. */
  733. Target.prototype.disposeInternal = function () {
  734. this.listeners_ && clear(this.listeners_);
  735. };
  736. /**
  737. * Get the listeners for a specified event type. Listeners are returned in the
  738. * order that they will be called in.
  739. *
  740. * @param {string} type Type.
  741. * @return {Array<import("../events.js").Listener>|undefined} Listeners.
  742. */
  743. Target.prototype.getListeners = function (type) {
  744. return (this.listeners_ && this.listeners_[type]) || undefined;
  745. };
  746. /**
  747. * @param {string} [opt_type] Type. If not provided,
  748. * `true` will be returned if this event target has any listeners.
  749. * @return {boolean} Has listeners.
  750. */
  751. Target.prototype.hasListener = function (opt_type) {
  752. if (!this.listeners_) {
  753. return false;
  754. }
  755. return opt_type
  756. ? opt_type in this.listeners_
  757. : Object.keys(this.listeners_).length > 0;
  758. };
  759. /**
  760. * @param {string} type Type.
  761. * @param {import("../events.js").Listener} listener Listener.
  762. */
  763. Target.prototype.removeEventListener = function (type, listener) {
  764. var listeners = this.listeners_ && this.listeners_[type];
  765. if (listeners) {
  766. var index = listeners.indexOf(listener);
  767. if (index !== -1) {
  768. if (this.pendingRemovals_ && type in this.pendingRemovals_) {
  769. // make listener a no-op, and remove later in #dispatchEvent()
  770. listeners[index] = VOID;
  771. ++this.pendingRemovals_[type];
  772. }
  773. else {
  774. listeners.splice(index, 1);
  775. if (listeners.length === 0) {
  776. delete this.listeners_[type];
  777. }
  778. }
  779. }
  780. }
  781. };
  782. return Target;
  783. }(ol_Disposable));
  784. /* harmony default export */ var events_Target = (Target);
  785. //# sourceMappingURL=Target.js.map
  786. ;// ./node_modules/ol/events/EventType.js
  787. /**
  788. * @module ol/events/EventType
  789. */
  790. /**
  791. * @enum {string}
  792. * @const
  793. */
  794. /* harmony default export */ var EventType = ({
  795. /**
  796. * Generic change event. Triggered when the revision counter is increased.
  797. * @event module:ol/events/Event~BaseEvent#change
  798. * @api
  799. */
  800. CHANGE: 'change',
  801. /**
  802. * Generic error event. Triggered when an error occurs.
  803. * @event module:ol/events/Event~BaseEvent#error
  804. * @api
  805. */
  806. ERROR: 'error',
  807. BLUR: 'blur',
  808. CLEAR: 'clear',
  809. CONTEXTMENU: 'contextmenu',
  810. CLICK: 'click',
  811. DBLCLICK: 'dblclick',
  812. DRAGENTER: 'dragenter',
  813. DRAGOVER: 'dragover',
  814. DROP: 'drop',
  815. FOCUS: 'focus',
  816. KEYDOWN: 'keydown',
  817. KEYPRESS: 'keypress',
  818. LOAD: 'load',
  819. RESIZE: 'resize',
  820. TOUCHMOVE: 'touchmove',
  821. WHEEL: 'wheel',
  822. });
  823. //# sourceMappingURL=EventType.js.map
  824. ;// ./node_modules/ol/events.js
  825. /**
  826. * @module ol/events
  827. */
  828. /**
  829. * Key to use with {@link module:ol/Observable.unByKey}.
  830. * @typedef {Object} EventsKey
  831. * @property {ListenerFunction} listener Listener.
  832. * @property {import("./events/Target.js").EventTargetLike} target Target.
  833. * @property {string} type Type.
  834. * @api
  835. */
  836. /**
  837. * Listener function. This function is called with an event object as argument.
  838. * When the function returns `false`, event propagation will stop.
  839. *
  840. * @typedef {function((Event|import("./events/Event.js").default)): (void|boolean)} ListenerFunction
  841. * @api
  842. */
  843. /**
  844. * @typedef {Object} ListenerObject
  845. * @property {ListenerFunction} handleEvent HandleEvent listener function.
  846. */
  847. /**
  848. * @typedef {ListenerFunction|ListenerObject} Listener
  849. */
  850. /**
  851. * Registers an event listener on an event target. Inspired by
  852. * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
  853. *
  854. * This function efficiently binds a `listener` to a `this` object, and returns
  855. * a key for use with {@link module:ol/events.unlistenByKey}.
  856. *
  857. * @param {import("./events/Target.js").EventTargetLike} target Event target.
  858. * @param {string} type Event type.
  859. * @param {ListenerFunction} listener Listener.
  860. * @param {Object} [opt_this] Object referenced by the `this` keyword in the
  861. * listener. Default is the `target`.
  862. * @param {boolean} [opt_once] If true, add the listener as one-off listener.
  863. * @return {EventsKey} Unique key for the listener.
  864. */
  865. function listen(target, type, listener, opt_this, opt_once) {
  866. if (opt_this && opt_this !== target) {
  867. listener = listener.bind(opt_this);
  868. }
  869. if (opt_once) {
  870. var originalListener_1 = listener;
  871. listener = function () {
  872. target.removeEventListener(type, listener);
  873. originalListener_1.apply(this, arguments);
  874. };
  875. }
  876. var eventsKey = {
  877. target: target,
  878. type: type,
  879. listener: listener,
  880. };
  881. target.addEventListener(type, listener);
  882. return eventsKey;
  883. }
  884. /**
  885. * Registers a one-off event listener on an event target. Inspired by
  886. * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
  887. *
  888. * This function efficiently binds a `listener` as self-unregistering listener
  889. * to a `this` object, and returns a key for use with
  890. * {@link module:ol/events.unlistenByKey} in case the listener needs to be
  891. * unregistered before it is called.
  892. *
  893. * When {@link module:ol/events.listen} is called with the same arguments after this
  894. * function, the self-unregistering listener will be turned into a permanent
  895. * listener.
  896. *
  897. * @param {import("./events/Target.js").EventTargetLike} target Event target.
  898. * @param {string} type Event type.
  899. * @param {ListenerFunction} listener Listener.
  900. * @param {Object} [opt_this] Object referenced by the `this` keyword in the
  901. * listener. Default is the `target`.
  902. * @return {EventsKey} Key for unlistenByKey.
  903. */
  904. function listenOnce(target, type, listener, opt_this) {
  905. return listen(target, type, listener, opt_this, true);
  906. }
  907. /**
  908. * Unregisters event listeners on an event target. Inspired by
  909. * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
  910. *
  911. * The argument passed to this function is the key returned from
  912. * {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.
  913. *
  914. * @param {EventsKey} key The key.
  915. */
  916. function unlistenByKey(key) {
  917. if (key && key.target) {
  918. key.target.removeEventListener(key.type, key.listener);
  919. clear(key);
  920. }
  921. }
  922. //# sourceMappingURL=events.js.map
  923. ;// ./node_modules/ol/Observable.js
  924. var Observable_extends = (undefined && undefined.__extends) || (function () {
  925. var extendStatics = function (d, b) {
  926. extendStatics = Object.setPrototypeOf ||
  927. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  928. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  929. return extendStatics(d, b);
  930. };
  931. return function (d, b) {
  932. if (typeof b !== "function" && b !== null)
  933. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  934. extendStatics(d, b);
  935. function __() { this.constructor = d; }
  936. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  937. };
  938. })();
  939. /**
  940. * @module ol/Observable
  941. */
  942. /***
  943. * @template {string} Type
  944. * @template {Event|import("./events/Event.js").default} EventClass
  945. * @template Return
  946. * @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature
  947. */
  948. /***
  949. * @template {string} Type
  950. * @template Return
  951. * @typedef {(type: Type[], listener: (event: Event|import("./events/Event").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature
  952. */
  953. /**
  954. * @typedef {'change'|'error'} EventTypes
  955. */
  956. /***
  957. * @template Return
  958. * @typedef {OnSignature<EventTypes, import("./events/Event.js").default, Return> & CombinedOnSignature<EventTypes, Return>} ObservableOnSignature
  959. */
  960. /**
  961. * @classdesc
  962. * Abstract base class; normally only used for creating subclasses and not
  963. * instantiated in apps.
  964. * An event target providing convenient methods for listener registration
  965. * and unregistration. A generic `change` event is always available through
  966. * {@link module:ol/Observable~Observable#changed}.
  967. *
  968. * @fires import("./events/Event.js").default
  969. * @api
  970. */
  971. var Observable = /** @class */ (function (_super) {
  972. Observable_extends(Observable, _super);
  973. function Observable() {
  974. var _this = _super.call(this) || this;
  975. _this.on =
  976. /** @type {ObservableOnSignature<import("./events").EventsKey>} */ (_this.onInternal);
  977. _this.once =
  978. /** @type {ObservableOnSignature<import("./events").EventsKey>} */ (_this.onceInternal);
  979. _this.un = /** @type {ObservableOnSignature<void>} */ (_this.unInternal);
  980. /**
  981. * @private
  982. * @type {number}
  983. */
  984. _this.revision_ = 0;
  985. return _this;
  986. }
  987. /**
  988. * Increases the revision counter and dispatches a 'change' event.
  989. * @api
  990. */
  991. Observable.prototype.changed = function () {
  992. ++this.revision_;
  993. this.dispatchEvent(EventType.CHANGE);
  994. };
  995. /**
  996. * Get the version number for this object. Each time the object is modified,
  997. * its version number will be incremented.
  998. * @return {number} Revision.
  999. * @api
  1000. */
  1001. Observable.prototype.getRevision = function () {
  1002. return this.revision_;
  1003. };
  1004. /**
  1005. * @param {string|Array<string>} type Type.
  1006. * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
  1007. * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
  1008. * @protected
  1009. */
  1010. Observable.prototype.onInternal = function (type, listener) {
  1011. if (Array.isArray(type)) {
  1012. var len = type.length;
  1013. var keys = new Array(len);
  1014. for (var i = 0; i < len; ++i) {
  1015. keys[i] = listen(this, type[i], listener);
  1016. }
  1017. return keys;
  1018. }
  1019. else {
  1020. return listen(this, /** @type {string} */ (type), listener);
  1021. }
  1022. };
  1023. /**
  1024. * @param {string|Array<string>} type Type.
  1025. * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
  1026. * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
  1027. * @protected
  1028. */
  1029. Observable.prototype.onceInternal = function (type, listener) {
  1030. var key;
  1031. if (Array.isArray(type)) {
  1032. var len = type.length;
  1033. key = new Array(len);
  1034. for (var i = 0; i < len; ++i) {
  1035. key[i] = listenOnce(this, type[i], listener);
  1036. }
  1037. }
  1038. else {
  1039. key = listenOnce(this, /** @type {string} */ (type), listener);
  1040. }
  1041. /** @type {Object} */ (listener).ol_key = key;
  1042. return key;
  1043. };
  1044. /**
  1045. * Unlisten for a certain type of event.
  1046. * @param {string|Array<string>} type Type.
  1047. * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
  1048. * @protected
  1049. */
  1050. Observable.prototype.unInternal = function (type, listener) {
  1051. var key = /** @type {Object} */ (listener).ol_key;
  1052. if (key) {
  1053. unByKey(key);
  1054. }
  1055. else if (Array.isArray(type)) {
  1056. for (var i = 0, ii = type.length; i < ii; ++i) {
  1057. this.removeEventListener(type[i], listener);
  1058. }
  1059. }
  1060. else {
  1061. this.removeEventListener(type, listener);
  1062. }
  1063. };
  1064. return Observable;
  1065. }(events_Target));
  1066. /**
  1067. * Listen for a certain type of event.
  1068. * @function
  1069. * @param {string|Array<string>} type The event type or array of event types.
  1070. * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
  1071. * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
  1072. * called with an array of event types as the first argument, the return
  1073. * will be an array of keys.
  1074. * @api
  1075. */
  1076. Observable.prototype.on;
  1077. /**
  1078. * Listen once for a certain type of event.
  1079. * @function
  1080. * @param {string|Array<string>} type The event type or array of event types.
  1081. * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
  1082. * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
  1083. * called with an array of event types as the first argument, the return
  1084. * will be an array of keys.
  1085. * @api
  1086. */
  1087. Observable.prototype.once;
  1088. /**
  1089. * Unlisten for a certain type of event.
  1090. * @function
  1091. * @param {string|Array<string>} type The event type or array of event types.
  1092. * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
  1093. * @api
  1094. */
  1095. Observable.prototype.un;
  1096. /**
  1097. * Removes an event listener using the key returned by `on()` or `once()`.
  1098. * @param {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} key The key returned by `on()`
  1099. * or `once()` (or an array of keys).
  1100. * @api
  1101. */
  1102. function unByKey(key) {
  1103. if (Array.isArray(key)) {
  1104. for (var i = 0, ii = key.length; i < ii; ++i) {
  1105. unlistenByKey(key[i]);
  1106. }
  1107. }
  1108. else {
  1109. unlistenByKey(/** @type {import("./events.js").EventsKey} */ (key));
  1110. }
  1111. }
  1112. /* harmony default export */ var ol_Observable = (Observable);
  1113. //# sourceMappingURL=Observable.js.map
  1114. ;// ./node_modules/ol/util.js
  1115. /**
  1116. * @module ol/util
  1117. */
  1118. /**
  1119. * @return {?} Any return.
  1120. */
  1121. function util_abstract() {
  1122. return /** @type {?} */ ((function () {
  1123. throw new Error('Unimplemented abstract method.');
  1124. })());
  1125. }
  1126. /**
  1127. * Counter for getUid.
  1128. * @type {number}
  1129. * @private
  1130. */
  1131. var uidCounter_ = 0;
  1132. /**
  1133. * Gets a unique ID for an object. This mutates the object so that further calls
  1134. * with the same object as a parameter returns the same value. Unique IDs are generated
  1135. * as a strictly increasing sequence. Adapted from goog.getUid.
  1136. *
  1137. * @param {Object} obj The object to get the unique ID for.
  1138. * @return {string} The unique ID for the object.
  1139. * @api
  1140. */
  1141. function getUid(obj) {
  1142. return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));
  1143. }
  1144. /**
  1145. * OpenLayers version.
  1146. * @type {string}
  1147. */
  1148. var VERSION = '6.15.1';
  1149. //# sourceMappingURL=util.js.map
  1150. ;// ./node_modules/ol/Object.js
  1151. var Object_extends = (undefined && undefined.__extends) || (function () {
  1152. var extendStatics = function (d, b) {
  1153. extendStatics = Object.setPrototypeOf ||
  1154. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1155. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1156. return extendStatics(d, b);
  1157. };
  1158. return function (d, b) {
  1159. if (typeof b !== "function" && b !== null)
  1160. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1161. extendStatics(d, b);
  1162. function __() { this.constructor = d; }
  1163. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1164. };
  1165. })();
  1166. /**
  1167. * @module ol/Object
  1168. */
  1169. /**
  1170. * @classdesc
  1171. * Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.
  1172. */
  1173. var ObjectEvent = /** @class */ (function (_super) {
  1174. Object_extends(ObjectEvent, _super);
  1175. /**
  1176. * @param {string} type The event type.
  1177. * @param {string} key The property name.
  1178. * @param {*} oldValue The old value for `key`.
  1179. */
  1180. function ObjectEvent(type, key, oldValue) {
  1181. var _this = _super.call(this, type) || this;
  1182. /**
  1183. * The name of the property whose value is changing.
  1184. * @type {string}
  1185. * @api
  1186. */
  1187. _this.key = key;
  1188. /**
  1189. * The old value. To get the new value use `e.target.get(e.key)` where
  1190. * `e` is the event object.
  1191. * @type {*}
  1192. * @api
  1193. */
  1194. _this.oldValue = oldValue;
  1195. return _this;
  1196. }
  1197. return ObjectEvent;
  1198. }(Event));
  1199. /***
  1200. * @template Return
  1201. * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
  1202. * import("./Observable").OnSignature<import("./ObjectEventType").Types, ObjectEvent, Return> &
  1203. * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|import("./ObjectEventType").Types, Return>} ObjectOnSignature
  1204. */
  1205. /**
  1206. * @classdesc
  1207. * Abstract base class; normally only used for creating subclasses and not
  1208. * instantiated in apps.
  1209. * Most non-trivial classes inherit from this.
  1210. *
  1211. * This extends {@link module:ol/Observable~Observable} with observable
  1212. * properties, where each property is observable as well as the object as a
  1213. * whole.
  1214. *
  1215. * Classes that inherit from this have pre-defined properties, to which you can
  1216. * add your owns. The pre-defined properties are listed in this documentation as
  1217. * 'Observable Properties', and have their own accessors; for example,
  1218. * {@link module:ol/Map~Map} has a `target` property, accessed with
  1219. * `getTarget()` and changed with `setTarget()`. Not all properties are however
  1220. * settable. There are also general-purpose accessors `get()` and `set()`. For
  1221. * example, `get('target')` is equivalent to `getTarget()`.
  1222. *
  1223. * The `set` accessors trigger a change event, and you can monitor this by
  1224. * registering a listener. For example, {@link module:ol/View~View} has a
  1225. * `center` property, so `view.on('change:center', function(evt) {...});` would
  1226. * call the function whenever the value of the center property changes. Within
  1227. * the function, `evt.target` would be the view, so `evt.target.getCenter()`
  1228. * would return the new center.
  1229. *
  1230. * You can add your own observable properties with
  1231. * `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.
  1232. * You can listen for changes on that property value with
  1233. * `object.on('change:prop', listener)`. You can get a list of all
  1234. * properties with {@link module:ol/Object~BaseObject#getProperties}.
  1235. *
  1236. * Note that the observable properties are separate from standard JS properties.
  1237. * You can, for example, give your map object a title with
  1238. * `map.title='New title'` and with `map.set('title', 'Another title')`. The
  1239. * first will be a `hasOwnProperty`; the second will appear in
  1240. * `getProperties()`. Only the second is observable.
  1241. *
  1242. * Properties can be deleted by using the unset method. E.g.
  1243. * object.unset('foo').
  1244. *
  1245. * @fires ObjectEvent
  1246. * @api
  1247. */
  1248. var BaseObject = /** @class */ (function (_super) {
  1249. Object_extends(BaseObject, _super);
  1250. /**
  1251. * @param {Object<string, *>} [opt_values] An object with key-value pairs.
  1252. */
  1253. function BaseObject(opt_values) {
  1254. var _this = _super.call(this) || this;
  1255. /***
  1256. * @type {ObjectOnSignature<import("./events").EventsKey>}
  1257. */
  1258. _this.on;
  1259. /***
  1260. * @type {ObjectOnSignature<import("./events").EventsKey>}
  1261. */
  1262. _this.once;
  1263. /***
  1264. * @type {ObjectOnSignature<void>}
  1265. */
  1266. _this.un;
  1267. // Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is
  1268. // the same as the order in which they were created. This also helps to
  1269. // ensure that object properties are always added in the same order, which
  1270. // helps many JavaScript engines generate faster code.
  1271. getUid(_this);
  1272. /**
  1273. * @private
  1274. * @type {Object<string, *>}
  1275. */
  1276. _this.values_ = null;
  1277. if (opt_values !== undefined) {
  1278. _this.setProperties(opt_values);
  1279. }
  1280. return _this;
  1281. }
  1282. /**
  1283. * Gets a value.
  1284. * @param {string} key Key name.
  1285. * @return {*} Value.
  1286. * @api
  1287. */
  1288. BaseObject.prototype.get = function (key) {
  1289. var value;
  1290. if (this.values_ && this.values_.hasOwnProperty(key)) {
  1291. value = this.values_[key];
  1292. }
  1293. return value;
  1294. };
  1295. /**
  1296. * Get a list of object property names.
  1297. * @return {Array<string>} List of property names.
  1298. * @api
  1299. */
  1300. BaseObject.prototype.getKeys = function () {
  1301. return (this.values_ && Object.keys(this.values_)) || [];
  1302. };
  1303. /**
  1304. * Get an object of all property names and values.
  1305. * @return {Object<string, *>} Object.
  1306. * @api
  1307. */
  1308. BaseObject.prototype.getProperties = function () {
  1309. return (this.values_ && obj_assign({}, this.values_)) || {};
  1310. };
  1311. /**
  1312. * @return {boolean} The object has properties.
  1313. */
  1314. BaseObject.prototype.hasProperties = function () {
  1315. return !!this.values_;
  1316. };
  1317. /**
  1318. * @param {string} key Key name.
  1319. * @param {*} oldValue Old value.
  1320. */
  1321. BaseObject.prototype.notify = function (key, oldValue) {
  1322. var eventType;
  1323. eventType = "change:".concat(key);
  1324. if (this.hasListener(eventType)) {
  1325. this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
  1326. }
  1327. eventType = ObjectEventType.PROPERTYCHANGE;
  1328. if (this.hasListener(eventType)) {
  1329. this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
  1330. }
  1331. };
  1332. /**
  1333. * @param {string} key Key name.
  1334. * @param {import("./events.js").Listener} listener Listener.
  1335. */
  1336. BaseObject.prototype.addChangeListener = function (key, listener) {
  1337. this.addEventListener("change:".concat(key), listener);
  1338. };
  1339. /**
  1340. * @param {string} key Key name.
  1341. * @param {import("./events.js").Listener} listener Listener.
  1342. */
  1343. BaseObject.prototype.removeChangeListener = function (key, listener) {
  1344. this.removeEventListener("change:".concat(key), listener);
  1345. };
  1346. /**
  1347. * Sets a value.
  1348. * @param {string} key Key name.
  1349. * @param {*} value Value.
  1350. * @param {boolean} [opt_silent] Update without triggering an event.
  1351. * @api
  1352. */
  1353. BaseObject.prototype.set = function (key, value, opt_silent) {
  1354. var values = this.values_ || (this.values_ = {});
  1355. if (opt_silent) {
  1356. values[key] = value;
  1357. }
  1358. else {
  1359. var oldValue = values[key];
  1360. values[key] = value;
  1361. if (oldValue !== value) {
  1362. this.notify(key, oldValue);
  1363. }
  1364. }
  1365. };
  1366. /**
  1367. * Sets a collection of key-value pairs. Note that this changes any existing
  1368. * properties and adds new ones (it does not remove any existing properties).
  1369. * @param {Object<string, *>} values Values.
  1370. * @param {boolean} [opt_silent] Update without triggering an event.
  1371. * @api
  1372. */
  1373. BaseObject.prototype.setProperties = function (values, opt_silent) {
  1374. for (var key in values) {
  1375. this.set(key, values[key], opt_silent);
  1376. }
  1377. };
  1378. /**
  1379. * Apply any properties from another object without triggering events.
  1380. * @param {BaseObject} source The source object.
  1381. * @protected
  1382. */
  1383. BaseObject.prototype.applyProperties = function (source) {
  1384. if (!source.values_) {
  1385. return;
  1386. }
  1387. obj_assign(this.values_ || (this.values_ = {}), source.values_);
  1388. };
  1389. /**
  1390. * Unsets a property.
  1391. * @param {string} key Key name.
  1392. * @param {boolean} [opt_silent] Unset without triggering an event.
  1393. * @api
  1394. */
  1395. BaseObject.prototype.unset = function (key, opt_silent) {
  1396. if (this.values_ && key in this.values_) {
  1397. var oldValue = this.values_[key];
  1398. delete this.values_[key];
  1399. if (obj_isEmpty(this.values_)) {
  1400. this.values_ = null;
  1401. }
  1402. if (!opt_silent) {
  1403. this.notify(key, oldValue);
  1404. }
  1405. }
  1406. };
  1407. return BaseObject;
  1408. }(ol_Observable));
  1409. /* harmony default export */ var ol_Object = (BaseObject);
  1410. //# sourceMappingURL=Object.js.map
  1411. ;// ./node_modules/ol/MapEventType.js
  1412. /**
  1413. * @module ol/MapEventType
  1414. */
  1415. /**
  1416. * @enum {string}
  1417. */
  1418. /* harmony default export */ var MapEventType = ({
  1419. /**
  1420. * Triggered after a map frame is rendered.
  1421. * @event module:ol/MapEvent~MapEvent#postrender
  1422. * @api
  1423. */
  1424. POSTRENDER: 'postrender',
  1425. /**
  1426. * Triggered when the map starts moving.
  1427. * @event module:ol/MapEvent~MapEvent#movestart
  1428. * @api
  1429. */
  1430. MOVESTART: 'movestart',
  1431. /**
  1432. * Triggered after the map is moved.
  1433. * @event module:ol/MapEvent~MapEvent#moveend
  1434. * @api
  1435. */
  1436. MOVEEND: 'moveend',
  1437. /**
  1438. * Triggered when loading of additional map data (tiles, images, features) starts.
  1439. * @event module:ol/MapEvent~MapEvent#loadstart
  1440. * @api
  1441. */
  1442. LOADSTART: 'loadstart',
  1443. /**
  1444. * Triggered when loading of additional map data has completed.
  1445. * @event module:ol/MapEvent~MapEvent#loadend
  1446. * @api
  1447. */
  1448. LOADEND: 'loadend',
  1449. });
  1450. /***
  1451. * @typedef {'postrender'|'movestart'|'moveend'|'loadstart'|'loadend'} Types
  1452. */
  1453. //# sourceMappingURL=MapEventType.js.map
  1454. ;// ./node_modules/ol/has.js
  1455. /**
  1456. * @module ol/has
  1457. */
  1458. var ua = typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined'
  1459. ? navigator.userAgent.toLowerCase()
  1460. : '';
  1461. /**
  1462. * User agent string says we are dealing with Firefox as browser.
  1463. * @type {boolean}
  1464. */
  1465. var FIREFOX = ua.indexOf('firefox') !== -1;
  1466. /**
  1467. * User agent string says we are dealing with Safari as browser.
  1468. * @type {boolean}
  1469. */
  1470. var SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') == -1;
  1471. /**
  1472. * https://bugs.webkit.org/show_bug.cgi?id=237906
  1473. * @type {boolean}
  1474. */
  1475. var SAFARI_BUG_237906 = SAFARI &&
  1476. !!(ua.indexOf('version/15.4') >= 0 ||
  1477. ua.match(/cpu (os|iphone os) 15_4 like mac os x/));
  1478. /**
  1479. * User agent string says we are dealing with a WebKit engine.
  1480. * @type {boolean}
  1481. */
  1482. var WEBKIT = ua.indexOf('webkit') !== -1 && ua.indexOf('edge') == -1;
  1483. /**
  1484. * User agent string says we are dealing with a Mac as platform.
  1485. * @type {boolean}
  1486. */
  1487. var has_MAC = ua.indexOf('macintosh') !== -1;
  1488. /**
  1489. * The ratio between physical pixels and device-independent pixels
  1490. * (dips) on the device (`window.devicePixelRatio`).
  1491. * @const
  1492. * @type {number}
  1493. * @api
  1494. */
  1495. var DEVICE_PIXEL_RATIO = typeof devicePixelRatio !== 'undefined' ? devicePixelRatio : 1;
  1496. /**
  1497. * The execution context is a worker with OffscreenCanvas available.
  1498. * @const
  1499. * @type {boolean}
  1500. */
  1501. var WORKER_OFFSCREEN_CANVAS = typeof WorkerGlobalScope !== 'undefined' &&
  1502. typeof OffscreenCanvas !== 'undefined' &&
  1503. self instanceof WorkerGlobalScope; //eslint-disable-line
  1504. /**
  1505. * Image.prototype.decode() is supported.
  1506. * @type {boolean}
  1507. */
  1508. var IMAGE_DECODE = typeof Image !== 'undefined' && Image.prototype.decode;
  1509. /**
  1510. * @type {boolean}
  1511. */
  1512. var PASSIVE_EVENT_LISTENERS = (function () {
  1513. var passive = false;
  1514. try {
  1515. var options = Object.defineProperty({}, 'passive', {
  1516. get: function () {
  1517. passive = true;
  1518. },
  1519. });
  1520. window.addEventListener('_', null, options);
  1521. window.removeEventListener('_', null, options);
  1522. }
  1523. catch (error) {
  1524. // passive not supported
  1525. }
  1526. return passive;
  1527. })();
  1528. //# sourceMappingURL=has.js.map
  1529. ;// ./node_modules/ol/dom.js
  1530. /**
  1531. * @module ol/dom
  1532. */
  1533. //FIXME Move this function to the canvas module
  1534. /**
  1535. * Create an html canvas element and returns its 2d context.
  1536. * @param {number} [opt_width] Canvas width.
  1537. * @param {number} [opt_height] Canvas height.
  1538. * @param {Array<HTMLCanvasElement>} [opt_canvasPool] Canvas pool to take existing canvas from.
  1539. * @param {CanvasRenderingContext2DSettings} [opt_Context2DSettings] CanvasRenderingContext2DSettings
  1540. * @return {CanvasRenderingContext2D} The context.
  1541. */
  1542. function createCanvasContext2D(opt_width, opt_height, opt_canvasPool, opt_Context2DSettings) {
  1543. /** @type {HTMLCanvasElement|OffscreenCanvas} */
  1544. var canvas;
  1545. if (opt_canvasPool && opt_canvasPool.length) {
  1546. canvas = opt_canvasPool.shift();
  1547. }
  1548. else if (WORKER_OFFSCREEN_CANVAS) {
  1549. canvas = new OffscreenCanvas(opt_width || 300, opt_height || 300);
  1550. }
  1551. else {
  1552. canvas = document.createElement('canvas');
  1553. }
  1554. if (opt_width) {
  1555. canvas.width = opt_width;
  1556. }
  1557. if (opt_height) {
  1558. canvas.height = opt_height;
  1559. }
  1560. //FIXME Allow OffscreenCanvasRenderingContext2D as return type
  1561. return /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d', opt_Context2DSettings));
  1562. }
  1563. /**
  1564. * Releases canvas memory to avoid exceeding memory limits in Safari.
  1565. * See https://pqina.nl/blog/total-canvas-memory-use-exceeds-the-maximum-limit/
  1566. * @param {CanvasRenderingContext2D} context Context.
  1567. */
  1568. function releaseCanvas(context) {
  1569. var canvas = context.canvas;
  1570. canvas.width = 1;
  1571. canvas.height = 1;
  1572. context.clearRect(0, 0, 1, 1);
  1573. }
  1574. /**
  1575. * Get the current computed width for the given element including margin,
  1576. * padding and border.
  1577. * Equivalent to jQuery's `$(el).outerWidth(true)`.
  1578. * @param {!HTMLElement} element Element.
  1579. * @return {number} The width.
  1580. */
  1581. function dom_outerWidth(element) {
  1582. var width = element.offsetWidth;
  1583. var style = getComputedStyle(element);
  1584. width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
  1585. return width;
  1586. }
  1587. /**
  1588. * Get the current computed height for the given element including margin,
  1589. * padding and border.
  1590. * Equivalent to jQuery's `$(el).outerHeight(true)`.
  1591. * @param {!HTMLElement} element Element.
  1592. * @return {number} The height.
  1593. */
  1594. function dom_outerHeight(element) {
  1595. var height = element.offsetHeight;
  1596. var style = getComputedStyle(element);
  1597. height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
  1598. return height;
  1599. }
  1600. /**
  1601. * @param {Node} newNode Node to replace old node
  1602. * @param {Node} oldNode The node to be replaced
  1603. */
  1604. function replaceNode(newNode, oldNode) {
  1605. var parent = oldNode.parentNode;
  1606. if (parent) {
  1607. parent.replaceChild(newNode, oldNode);
  1608. }
  1609. }
  1610. /**
  1611. * @param {Node} node The node to remove.
  1612. * @return {Node|null} The node that was removed or null.
  1613. */
  1614. function removeNode(node) {
  1615. return node && node.parentNode ? node.parentNode.removeChild(node) : null;
  1616. }
  1617. /**
  1618. * @param {Node} node The node to remove the children from.
  1619. */
  1620. function removeChildren(node) {
  1621. while (node.lastChild) {
  1622. node.removeChild(node.lastChild);
  1623. }
  1624. }
  1625. /**
  1626. * Transform the children of a parent node so they match the
  1627. * provided list of children. This function aims to efficiently
  1628. * remove, add, and reorder child nodes while maintaining a simple
  1629. * implementation (it is not guaranteed to minimize DOM operations).
  1630. * @param {Node} node The parent node whose children need reworking.
  1631. * @param {Array<Node>} children The desired children.
  1632. */
  1633. function replaceChildren(node, children) {
  1634. var oldChildren = node.childNodes;
  1635. for (var i = 0; true; ++i) {
  1636. var oldChild = oldChildren[i];
  1637. var newChild = children[i];
  1638. // check if our work is done
  1639. if (!oldChild && !newChild) {
  1640. break;
  1641. }
  1642. // check if children match
  1643. if (oldChild === newChild) {
  1644. continue;
  1645. }
  1646. // check if a new child needs to be added
  1647. if (!oldChild) {
  1648. node.appendChild(newChild);
  1649. continue;
  1650. }
  1651. // check if an old child needs to be removed
  1652. if (!newChild) {
  1653. node.removeChild(oldChild);
  1654. --i;
  1655. continue;
  1656. }
  1657. // reorder
  1658. node.insertBefore(newChild, oldChild);
  1659. }
  1660. }
  1661. //# sourceMappingURL=dom.js.map
  1662. ;// ./node_modules/ol/control/Control.js
  1663. var Control_extends = (undefined && undefined.__extends) || (function () {
  1664. var extendStatics = function (d, b) {
  1665. extendStatics = Object.setPrototypeOf ||
  1666. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1667. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1668. return extendStatics(d, b);
  1669. };
  1670. return function (d, b) {
  1671. if (typeof b !== "function" && b !== null)
  1672. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1673. extendStatics(d, b);
  1674. function __() { this.constructor = d; }
  1675. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1676. };
  1677. })();
  1678. /**
  1679. * @module ol/control/Control
  1680. */
  1681. /**
  1682. * @typedef {Object} Options
  1683. * @property {HTMLElement} [element] The element is the control's
  1684. * container element. This only needs to be specified if you're developing
  1685. * a custom control.
  1686. * @property {function(import("../MapEvent.js").default):void} [render] Function called when
  1687. * the control should be re-rendered. This is called in a `requestAnimationFrame`
  1688. * callback.
  1689. * @property {HTMLElement|string} [target] Specify a target if you want
  1690. * the control to be rendered outside of the map's viewport.
  1691. */
  1692. /**
  1693. * @classdesc
  1694. * A control is a visible widget with a DOM element in a fixed position on the
  1695. * screen. They can involve user input (buttons), or be informational only;
  1696. * the position is determined using CSS. By default these are placed in the
  1697. * container with CSS class name `ol-overlaycontainer-stopevent`, but can use
  1698. * any outside DOM element.
  1699. *
  1700. * This is the base class for controls. You can use it for simple custom
  1701. * controls by creating the element with listeners, creating an instance:
  1702. * ```js
  1703. * var myControl = new Control({element: myElement});
  1704. * ```
  1705. * and then adding this to the map.
  1706. *
  1707. * The main advantage of having this as a control rather than a simple separate
  1708. * DOM element is that preventing propagation is handled for you. Controls
  1709. * will also be objects in a {@link module:ol/Collection~Collection}, so you can use their methods.
  1710. *
  1711. * You can also extend this base for your own control class. See
  1712. * examples/custom-controls for an example of how to do this.
  1713. *
  1714. * @api
  1715. */
  1716. var Control = /** @class */ (function (_super) {
  1717. Control_extends(Control, _super);
  1718. /**
  1719. * @param {Options} options Control options.
  1720. */
  1721. function Control(options) {
  1722. var _this = _super.call(this) || this;
  1723. var element = options.element;
  1724. if (element && !options.target && !element.style.pointerEvents) {
  1725. element.style.pointerEvents = 'auto';
  1726. }
  1727. /**
  1728. * @protected
  1729. * @type {HTMLElement}
  1730. */
  1731. _this.element = element ? element : null;
  1732. /**
  1733. * @private
  1734. * @type {HTMLElement}
  1735. */
  1736. _this.target_ = null;
  1737. /**
  1738. * @private
  1739. * @type {import("../PluggableMap.js").default|null}
  1740. */
  1741. _this.map_ = null;
  1742. /**
  1743. * @protected
  1744. * @type {!Array<import("../events.js").EventsKey>}
  1745. */
  1746. _this.listenerKeys = [];
  1747. if (options.render) {
  1748. _this.render = options.render;
  1749. }
  1750. if (options.target) {
  1751. _this.setTarget(options.target);
  1752. }
  1753. return _this;
  1754. }
  1755. /**
  1756. * Clean up.
  1757. */
  1758. Control.prototype.disposeInternal = function () {
  1759. removeNode(this.element);
  1760. _super.prototype.disposeInternal.call(this);
  1761. };
  1762. /**
  1763. * Get the map associated with this control.
  1764. * @return {import("../PluggableMap.js").default|null} Map.
  1765. * @api
  1766. */
  1767. Control.prototype.getMap = function () {
  1768. return this.map_;
  1769. };
  1770. /**
  1771. * Remove the control from its current map and attach it to the new map.
  1772. * Pass `null` to just remove the control from the current map.
  1773. * Subclasses may set up event handlers to get notified about changes to
  1774. * the map here.
  1775. * @param {import("../PluggableMap.js").default|null} map Map.
  1776. * @api
  1777. */
  1778. Control.prototype.setMap = function (map) {
  1779. if (this.map_) {
  1780. removeNode(this.element);
  1781. }
  1782. for (var i = 0, ii = this.listenerKeys.length; i < ii; ++i) {
  1783. unlistenByKey(this.listenerKeys[i]);
  1784. }
  1785. this.listenerKeys.length = 0;
  1786. this.map_ = map;
  1787. if (map) {
  1788. var target = this.target_
  1789. ? this.target_
  1790. : map.getOverlayContainerStopEvent();
  1791. target.appendChild(this.element);
  1792. if (this.render !== VOID) {
  1793. this.listenerKeys.push(listen(map, MapEventType.POSTRENDER, this.render, this));
  1794. }
  1795. map.render();
  1796. }
  1797. };
  1798. /**
  1799. * Renders the control.
  1800. * @param {import("../MapEvent.js").default} mapEvent Map event.
  1801. * @api
  1802. */
  1803. Control.prototype.render = function (mapEvent) { };
  1804. /**
  1805. * This function is used to set a target element for the control. It has no
  1806. * effect if it is called after the control has been added to the map (i.e.
  1807. * after `setMap` is called on the control). If no `target` is set in the
  1808. * options passed to the control constructor and if `setTarget` is not called
  1809. * then the control is added to the map's overlay container.
  1810. * @param {HTMLElement|string} target Target.
  1811. * @api
  1812. */
  1813. Control.prototype.setTarget = function (target) {
  1814. this.target_ =
  1815. typeof target === 'string' ? document.getElementById(target) : target;
  1816. };
  1817. return Control;
  1818. }(ol_Object));
  1819. /* harmony default export */ var control_Control = (Control);
  1820. //# sourceMappingURL=Control.js.map
  1821. ;// ./node_modules/ol/css.js
  1822. /**
  1823. * @module ol/css
  1824. */
  1825. /**
  1826. * @typedef {Object} FontParameters
  1827. * @property {string} style Style.
  1828. * @property {string} variant Variant.
  1829. * @property {string} weight Weight.
  1830. * @property {string} size Size.
  1831. * @property {string} lineHeight LineHeight.
  1832. * @property {string} family Family.
  1833. * @property {Array<string>} families Families.
  1834. */
  1835. /**
  1836. * The CSS class for hidden feature.
  1837. *
  1838. * @const
  1839. * @type {string}
  1840. */
  1841. var CLASS_HIDDEN = 'ol-hidden';
  1842. /**
  1843. * The CSS class that we'll give the DOM elements to have them selectable.
  1844. *
  1845. * @const
  1846. * @type {string}
  1847. */
  1848. var CLASS_SELECTABLE = 'ol-selectable';
  1849. /**
  1850. * The CSS class that we'll give the DOM elements to have them unselectable.
  1851. *
  1852. * @const
  1853. * @type {string}
  1854. */
  1855. var CLASS_UNSELECTABLE = 'ol-unselectable';
  1856. /**
  1857. * The CSS class for unsupported feature.
  1858. *
  1859. * @const
  1860. * @type {string}
  1861. */
  1862. var CLASS_UNSUPPORTED = 'ol-unsupported';
  1863. /**
  1864. * The CSS class for controls.
  1865. *
  1866. * @const
  1867. * @type {string}
  1868. */
  1869. var CLASS_CONTROL = 'ol-control';
  1870. /**
  1871. * The CSS class that we'll give the DOM elements that are collapsed, i.e.
  1872. * to those elements which usually can be expanded.
  1873. *
  1874. * @const
  1875. * @type {string}
  1876. */
  1877. var CLASS_COLLAPSED = 'ol-collapsed';
  1878. /**
  1879. * From https://stackoverflow.com/questions/10135697/regex-to-parse-any-css-font
  1880. * @type {RegExp}
  1881. */
  1882. var fontRegEx = new RegExp([
  1883. '^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)',
  1884. '(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)',
  1885. '(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)',
  1886. '(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?',
  1887. '(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))',
  1888. '(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))',
  1889. '?\\s*([-,\\"\\\'\\sa-z]+?)\\s*$',
  1890. ].join(''), 'i');
  1891. var fontRegExMatchIndex = [
  1892. 'style',
  1893. 'variant',
  1894. 'weight',
  1895. 'size',
  1896. 'lineHeight',
  1897. 'family',
  1898. ];
  1899. /**
  1900. * Get the list of font families from a font spec. Note that this doesn't work
  1901. * for font families that have commas in them.
  1902. * @param {string} fontSpec The CSS font property.
  1903. * @return {FontParameters|null} The font parameters (or null if the input spec is invalid).
  1904. */
  1905. var getFontParameters = function (fontSpec) {
  1906. var match = fontSpec.match(fontRegEx);
  1907. if (!match) {
  1908. return null;
  1909. }
  1910. var style = /** @type {FontParameters} */ ({
  1911. lineHeight: 'normal',
  1912. size: '1.2em',
  1913. style: 'normal',
  1914. weight: 'normal',
  1915. variant: 'normal',
  1916. });
  1917. for (var i = 0, ii = fontRegExMatchIndex.length; i < ii; ++i) {
  1918. var value = match[i + 1];
  1919. if (value !== undefined) {
  1920. style[fontRegExMatchIndex[i]] = value;
  1921. }
  1922. }
  1923. style.families = style.family.split(/,\s?/);
  1924. return style;
  1925. };
  1926. //# sourceMappingURL=css.js.map
  1927. ;// ./node_modules/ol/layer/Property.js
  1928. /**
  1929. * @module ol/layer/Property
  1930. */
  1931. /**
  1932. * @enum {string}
  1933. */
  1934. /* harmony default export */ var Property = ({
  1935. OPACITY: 'opacity',
  1936. VISIBLE: 'visible',
  1937. EXTENT: 'extent',
  1938. Z_INDEX: 'zIndex',
  1939. MAX_RESOLUTION: 'maxResolution',
  1940. MIN_RESOLUTION: 'minResolution',
  1941. MAX_ZOOM: 'maxZoom',
  1942. MIN_ZOOM: 'minZoom',
  1943. SOURCE: 'source',
  1944. MAP: 'map',
  1945. });
  1946. //# sourceMappingURL=Property.js.map
  1947. ;// ./node_modules/ol/AssertionError.js
  1948. var AssertionError_extends = (undefined && undefined.__extends) || (function () {
  1949. var extendStatics = function (d, b) {
  1950. extendStatics = Object.setPrototypeOf ||
  1951. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1952. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1953. return extendStatics(d, b);
  1954. };
  1955. return function (d, b) {
  1956. if (typeof b !== "function" && b !== null)
  1957. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1958. extendStatics(d, b);
  1959. function __() { this.constructor = d; }
  1960. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1961. };
  1962. })();
  1963. /**
  1964. * @module ol/AssertionError
  1965. */
  1966. /**
  1967. * Error object thrown when an assertion failed. This is an ECMA-262 Error,
  1968. * extended with a `code` property.
  1969. * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error.
  1970. */
  1971. var AssertionError = /** @class */ (function (_super) {
  1972. AssertionError_extends(AssertionError, _super);
  1973. /**
  1974. * @param {number} code Error code.
  1975. */
  1976. function AssertionError(code) {
  1977. var _this = this;
  1978. var path = VERSION === 'latest' ? VERSION : 'v' + VERSION.split('-')[0];
  1979. var message = 'Assertion failed. See https://openlayers.org/en/' +
  1980. path +
  1981. '/doc/errors/#' +
  1982. code +
  1983. ' for details.';
  1984. _this = _super.call(this, message) || this;
  1985. /**
  1986. * Error code. The meaning of the code can be found on
  1987. * https://openlayers.org/en/latest/doc/errors/ (replace `latest` with
  1988. * the version found in the OpenLayers script's header comment if a version
  1989. * other than the latest is used).
  1990. * @type {number}
  1991. * @api
  1992. */
  1993. _this.code = code;
  1994. /**
  1995. * @type {string}
  1996. */
  1997. _this.name = 'AssertionError';
  1998. // Re-assign message, see https://github.com/Rich-Harris/buble/issues/40
  1999. _this.message = message;
  2000. return _this;
  2001. }
  2002. return AssertionError;
  2003. }(Error));
  2004. /* harmony default export */ var ol_AssertionError = (AssertionError);
  2005. //# sourceMappingURL=AssertionError.js.map
  2006. ;// ./node_modules/ol/asserts.js
  2007. /**
  2008. * @module ol/asserts
  2009. */
  2010. /**
  2011. * @param {*} assertion Assertion we expected to be truthy.
  2012. * @param {number} errorCode Error code.
  2013. */
  2014. function asserts_assert(assertion, errorCode) {
  2015. if (!assertion) {
  2016. throw new ol_AssertionError(errorCode);
  2017. }
  2018. }
  2019. //# sourceMappingURL=asserts.js.map
  2020. ;// ./node_modules/ol/math.js
  2021. /**
  2022. * @module ol/math
  2023. */
  2024. /**
  2025. * Takes a number and clamps it to within the provided bounds.
  2026. * @param {number} value The input number.
  2027. * @param {number} min The minimum value to return.
  2028. * @param {number} max The maximum value to return.
  2029. * @return {number} The input number if it is within bounds, or the nearest
  2030. * number within the bounds.
  2031. */
  2032. function math_clamp(value, min, max) {
  2033. return Math.min(Math.max(value, min), max);
  2034. }
  2035. /**
  2036. * Return the hyperbolic cosine of a given number. The method will use the
  2037. * native `Math.cosh` function if it is available, otherwise the hyperbolic
  2038. * cosine will be calculated via the reference implementation of the Mozilla
  2039. * developer network.
  2040. *
  2041. * @param {number} x X.
  2042. * @return {number} Hyperbolic cosine of x.
  2043. */
  2044. var cosh = (function () {
  2045. // Wrapped in a iife, to save the overhead of checking for the native
  2046. // implementation on every invocation.
  2047. var cosh;
  2048. if ('cosh' in Math) {
  2049. // The environment supports the native Math.cosh function, use it…
  2050. cosh = Math.cosh;
  2051. }
  2052. else {
  2053. // … else, use the reference implementation of MDN:
  2054. cosh = function (x) {
  2055. var y = /** @type {Math} */ (Math).exp(x);
  2056. return (y + 1 / y) / 2;
  2057. };
  2058. }
  2059. return cosh;
  2060. })();
  2061. /**
  2062. * Return the base 2 logarithm of a given number. The method will use the
  2063. * native `Math.log2` function if it is available, otherwise the base 2
  2064. * logarithm will be calculated via the reference implementation of the
  2065. * Mozilla developer network.
  2066. *
  2067. * @param {number} x X.
  2068. * @return {number} Base 2 logarithm of x.
  2069. */
  2070. var log2 = (function () {
  2071. // Wrapped in a iife, to save the overhead of checking for the native
  2072. // implementation on every invocation.
  2073. var log2;
  2074. if ('log2' in Math) {
  2075. // The environment supports the native Math.log2 function, use it…
  2076. log2 = Math.log2;
  2077. }
  2078. else {
  2079. // … else, use the reference implementation of MDN:
  2080. log2 = function (x) {
  2081. return Math.log(x) * Math.LOG2E;
  2082. };
  2083. }
  2084. return log2;
  2085. })();
  2086. /**
  2087. * Returns the square of the closest distance between the point (x, y) and the
  2088. * line segment (x1, y1) to (x2, y2).
  2089. * @param {number} x X.
  2090. * @param {number} y Y.
  2091. * @param {number} x1 X1.
  2092. * @param {number} y1 Y1.
  2093. * @param {number} x2 X2.
  2094. * @param {number} y2 Y2.
  2095. * @return {number} Squared distance.
  2096. */
  2097. function squaredSegmentDistance(x, y, x1, y1, x2, y2) {
  2098. var dx = x2 - x1;
  2099. var dy = y2 - y1;
  2100. if (dx !== 0 || dy !== 0) {
  2101. var t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
  2102. if (t > 1) {
  2103. x1 = x2;
  2104. y1 = y2;
  2105. }
  2106. else if (t > 0) {
  2107. x1 += dx * t;
  2108. y1 += dy * t;
  2109. }
  2110. }
  2111. return math_squaredDistance(x, y, x1, y1);
  2112. }
  2113. /**
  2114. * Returns the square of the distance between the points (x1, y1) and (x2, y2).
  2115. * @param {number} x1 X1.
  2116. * @param {number} y1 Y1.
  2117. * @param {number} x2 X2.
  2118. * @param {number} y2 Y2.
  2119. * @return {number} Squared distance.
  2120. */
  2121. function math_squaredDistance(x1, y1, x2, y2) {
  2122. var dx = x2 - x1;
  2123. var dy = y2 - y1;
  2124. return dx * dx + dy * dy;
  2125. }
  2126. /**
  2127. * Solves system of linear equations using Gaussian elimination method.
  2128. *
  2129. * @param {Array<Array<number>>} mat Augmented matrix (n x n + 1 column)
  2130. * in row-major order.
  2131. * @return {Array<number>} The resulting vector.
  2132. */
  2133. function solveLinearSystem(mat) {
  2134. var n = mat.length;
  2135. for (var i = 0; i < n; i++) {
  2136. // Find max in the i-th column (ignoring i - 1 first rows)
  2137. var maxRow = i;
  2138. var maxEl = Math.abs(mat[i][i]);
  2139. for (var r = i + 1; r < n; r++) {
  2140. var absValue = Math.abs(mat[r][i]);
  2141. if (absValue > maxEl) {
  2142. maxEl = absValue;
  2143. maxRow = r;
  2144. }
  2145. }
  2146. if (maxEl === 0) {
  2147. return null; // matrix is singular
  2148. }
  2149. // Swap max row with i-th (current) row
  2150. var tmp = mat[maxRow];
  2151. mat[maxRow] = mat[i];
  2152. mat[i] = tmp;
  2153. // Subtract the i-th row to make all the remaining rows 0 in the i-th column
  2154. for (var j = i + 1; j < n; j++) {
  2155. var coef = -mat[j][i] / mat[i][i];
  2156. for (var k = i; k < n + 1; k++) {
  2157. if (i == k) {
  2158. mat[j][k] = 0;
  2159. }
  2160. else {
  2161. mat[j][k] += coef * mat[i][k];
  2162. }
  2163. }
  2164. }
  2165. }
  2166. // Solve Ax=b for upper triangular matrix A (mat)
  2167. var x = new Array(n);
  2168. for (var l = n - 1; l >= 0; l--) {
  2169. x[l] = mat[l][n] / mat[l][l];
  2170. for (var m = l - 1; m >= 0; m--) {
  2171. mat[m][n] -= mat[m][l] * x[l];
  2172. }
  2173. }
  2174. return x;
  2175. }
  2176. /**
  2177. * Converts radians to to degrees.
  2178. *
  2179. * @param {number} angleInRadians Angle in radians.
  2180. * @return {number} Angle in degrees.
  2181. */
  2182. function math_toDegrees(angleInRadians) {
  2183. return (angleInRadians * 180) / Math.PI;
  2184. }
  2185. /**
  2186. * Converts degrees to radians.
  2187. *
  2188. * @param {number} angleInDegrees Angle in degrees.
  2189. * @return {number} Angle in radians.
  2190. */
  2191. function math_toRadians(angleInDegrees) {
  2192. return (angleInDegrees * Math.PI) / 180;
  2193. }
  2194. /**
  2195. * Returns the modulo of a / b, depending on the sign of b.
  2196. *
  2197. * @param {number} a Dividend.
  2198. * @param {number} b Divisor.
  2199. * @return {number} Modulo.
  2200. */
  2201. function math_modulo(a, b) {
  2202. var r = a % b;
  2203. return r * b < 0 ? r + b : r;
  2204. }
  2205. /**
  2206. * Calculates the linearly interpolated value of x between a and b.
  2207. *
  2208. * @param {number} a Number
  2209. * @param {number} b Number
  2210. * @param {number} x Value to be interpolated.
  2211. * @return {number} Interpolated value.
  2212. */
  2213. function lerp(a, b, x) {
  2214. return a + x * (b - a);
  2215. }
  2216. /**
  2217. * Returns a number with a limited number of decimal digits.
  2218. * @param {number} n The input number.
  2219. * @param {number} decimals The maximum number of decimal digits.
  2220. * @return {number} The input number with a limited number of decimal digits.
  2221. */
  2222. function toFixed(n, decimals) {
  2223. var factor = Math.pow(10, decimals);
  2224. return Math.round(n * factor) / factor;
  2225. }
  2226. /**
  2227. * Rounds a number to the nearest integer value considering only the given number
  2228. * of decimal digits (with rounding on the final digit).
  2229. * @param {number} n The input number.
  2230. * @param {number} decimals The maximum number of decimal digits.
  2231. * @return {number} The nearest integer.
  2232. */
  2233. function round(n, decimals) {
  2234. return Math.round(toFixed(n, decimals));
  2235. }
  2236. /**
  2237. * Rounds a number to the next smaller integer considering only the given number
  2238. * of decimal digits (with rounding on the final digit).
  2239. * @param {number} n The input number.
  2240. * @param {number} decimals The maximum number of decimal digits.
  2241. * @return {number} The next smaller integer.
  2242. */
  2243. function floor(n, decimals) {
  2244. return Math.floor(toFixed(n, decimals));
  2245. }
  2246. /**
  2247. * Rounds a number to the next bigger integer considering only the given number
  2248. * of decimal digits (with rounding on the final digit).
  2249. * @param {number} n The input number.
  2250. * @param {number} decimals The maximum number of decimal digits.
  2251. * @return {number} The next bigger integer.
  2252. */
  2253. function ceil(n, decimals) {
  2254. return Math.ceil(toFixed(n, decimals));
  2255. }
  2256. //# sourceMappingURL=math.js.map
  2257. ;// ./node_modules/ol/layer/Base.js
  2258. var Base_extends = (undefined && undefined.__extends) || (function () {
  2259. var extendStatics = function (d, b) {
  2260. extendStatics = Object.setPrototypeOf ||
  2261. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2262. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  2263. return extendStatics(d, b);
  2264. };
  2265. return function (d, b) {
  2266. if (typeof b !== "function" && b !== null)
  2267. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  2268. extendStatics(d, b);
  2269. function __() { this.constructor = d; }
  2270. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2271. };
  2272. })();
  2273. /**
  2274. * @module ol/layer/Base
  2275. */
  2276. /**
  2277. * A css color, or a function called with a view resolution returning a css color.
  2278. *
  2279. * @typedef {string|function(number):string} BackgroundColor
  2280. * @api
  2281. */
  2282. /**
  2283. * @typedef {import("../ObjectEventType").Types|'change:extent'|'change:maxResolution'|'change:maxZoom'|
  2284. * 'change:minResolution'|'change:minZoom'|'change:opacity'|'change:visible'|'change:zIndex'} BaseLayerObjectEventTypes
  2285. */
  2286. /***
  2287. * @template Return
  2288. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  2289. * import("../Observable").OnSignature<BaseLayerObjectEventTypes, import("../Object").ObjectEvent, Return> &
  2290. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|BaseLayerObjectEventTypes, Return>} BaseLayerOnSignature
  2291. */
  2292. /**
  2293. * @typedef {Object} Options
  2294. * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
  2295. * @property {number} [opacity=1] Opacity (0, 1).
  2296. * @property {boolean} [visible=true] Visibility.
  2297. * @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
  2298. * rendered outside of this extent.
  2299. * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
  2300. * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
  2301. * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
  2302. * method was used.
  2303. * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
  2304. * visible.
  2305. * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
  2306. * be visible.
  2307. * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
  2308. * visible.
  2309. * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
  2310. * be visible.
  2311. * @property {BackgroundColor} [background] Background color for the layer. If not specified, no background
  2312. * will be rendered.
  2313. * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
  2314. */
  2315. /**
  2316. * @classdesc
  2317. * Abstract base class; normally only used for creating subclasses and not
  2318. * instantiated in apps.
  2319. * Note that with {@link module:ol/layer/Base~BaseLayer} and all its subclasses, any property set in
  2320. * the options is set as a {@link module:ol/Object~BaseObject} property on the layer object, so
  2321. * is observable, and has get/set accessors.
  2322. *
  2323. * @api
  2324. */
  2325. var BaseLayer = /** @class */ (function (_super) {
  2326. Base_extends(BaseLayer, _super);
  2327. /**
  2328. * @param {Options} options Layer options.
  2329. */
  2330. function BaseLayer(options) {
  2331. var _this = _super.call(this) || this;
  2332. /***
  2333. * @type {BaseLayerOnSignature<import("../events").EventsKey>}
  2334. */
  2335. _this.on;
  2336. /***
  2337. * @type {BaseLayerOnSignature<import("../events").EventsKey>}
  2338. */
  2339. _this.once;
  2340. /***
  2341. * @type {BaseLayerOnSignature<void>}
  2342. */
  2343. _this.un;
  2344. /**
  2345. * @type {BackgroundColor|false}
  2346. * @private
  2347. */
  2348. _this.background_ = options.background;
  2349. /**
  2350. * @type {Object<string, *>}
  2351. */
  2352. var properties = obj_assign({}, options);
  2353. if (typeof options.properties === 'object') {
  2354. delete properties.properties;
  2355. obj_assign(properties, options.properties);
  2356. }
  2357. properties[Property.OPACITY] =
  2358. options.opacity !== undefined ? options.opacity : 1;
  2359. asserts_assert(typeof properties[Property.OPACITY] === 'number', 64); // Layer opacity must be a number
  2360. properties[Property.VISIBLE] =
  2361. options.visible !== undefined ? options.visible : true;
  2362. properties[Property.Z_INDEX] = options.zIndex;
  2363. properties[Property.MAX_RESOLUTION] =
  2364. options.maxResolution !== undefined ? options.maxResolution : Infinity;
  2365. properties[Property.MIN_RESOLUTION] =
  2366. options.minResolution !== undefined ? options.minResolution : 0;
  2367. properties[Property.MIN_ZOOM] =
  2368. options.minZoom !== undefined ? options.minZoom : -Infinity;
  2369. properties[Property.MAX_ZOOM] =
  2370. options.maxZoom !== undefined ? options.maxZoom : Infinity;
  2371. /**
  2372. * @type {string}
  2373. * @private
  2374. */
  2375. _this.className_ =
  2376. properties.className !== undefined ? properties.className : 'ol-layer';
  2377. delete properties.className;
  2378. _this.setProperties(properties);
  2379. /**
  2380. * @type {import("./Layer.js").State}
  2381. * @private
  2382. */
  2383. _this.state_ = null;
  2384. return _this;
  2385. }
  2386. /**
  2387. * Get the background for this layer.
  2388. * @return {BackgroundColor|false} Layer background.
  2389. */
  2390. BaseLayer.prototype.getBackground = function () {
  2391. return this.background_;
  2392. };
  2393. /**
  2394. * @return {string} CSS class name.
  2395. */
  2396. BaseLayer.prototype.getClassName = function () {
  2397. return this.className_;
  2398. };
  2399. /**
  2400. * This method is not meant to be called by layers or layer renderers because the state
  2401. * is incorrect if the layer is included in a layer group.
  2402. *
  2403. * @param {boolean} [opt_managed] Layer is managed.
  2404. * @return {import("./Layer.js").State} Layer state.
  2405. */
  2406. BaseLayer.prototype.getLayerState = function (opt_managed) {
  2407. /** @type {import("./Layer.js").State} */
  2408. var state = this.state_ ||
  2409. /** @type {?} */ ({
  2410. layer: this,
  2411. managed: opt_managed === undefined ? true : opt_managed,
  2412. });
  2413. var zIndex = this.getZIndex();
  2414. state.opacity = math_clamp(Math.round(this.getOpacity() * 100) / 100, 0, 1);
  2415. state.visible = this.getVisible();
  2416. state.extent = this.getExtent();
  2417. state.zIndex = zIndex === undefined && !state.managed ? Infinity : zIndex;
  2418. state.maxResolution = this.getMaxResolution();
  2419. state.minResolution = Math.max(this.getMinResolution(), 0);
  2420. state.minZoom = this.getMinZoom();
  2421. state.maxZoom = this.getMaxZoom();
  2422. this.state_ = state;
  2423. return state;
  2424. };
  2425. /**
  2426. * @abstract
  2427. * @param {Array<import("./Layer.js").default>} [opt_array] Array of layers (to be
  2428. * modified in place).
  2429. * @return {Array<import("./Layer.js").default>} Array of layers.
  2430. */
  2431. BaseLayer.prototype.getLayersArray = function (opt_array) {
  2432. return util_abstract();
  2433. };
  2434. /**
  2435. * @abstract
  2436. * @param {Array<import("./Layer.js").State>} [opt_states] Optional list of layer
  2437. * states (to be modified in place).
  2438. * @return {Array<import("./Layer.js").State>} List of layer states.
  2439. */
  2440. BaseLayer.prototype.getLayerStatesArray = function (opt_states) {
  2441. return util_abstract();
  2442. };
  2443. /**
  2444. * Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it
  2445. * will be visible regardless of extent.
  2446. * @return {import("../extent.js").Extent|undefined} The layer extent.
  2447. * @observable
  2448. * @api
  2449. */
  2450. BaseLayer.prototype.getExtent = function () {
  2451. return /** @type {import("../extent.js").Extent|undefined} */ (this.get(Property.EXTENT));
  2452. };
  2453. /**
  2454. * Return the maximum resolution of the layer.
  2455. * @return {number} The maximum resolution of the layer.
  2456. * @observable
  2457. * @api
  2458. */
  2459. BaseLayer.prototype.getMaxResolution = function () {
  2460. return /** @type {number} */ (this.get(Property.MAX_RESOLUTION));
  2461. };
  2462. /**
  2463. * Return the minimum resolution of the layer.
  2464. * @return {number} The minimum resolution of the layer.
  2465. * @observable
  2466. * @api
  2467. */
  2468. BaseLayer.prototype.getMinResolution = function () {
  2469. return /** @type {number} */ (this.get(Property.MIN_RESOLUTION));
  2470. };
  2471. /**
  2472. * Return the minimum zoom level of the layer.
  2473. * @return {number} The minimum zoom level of the layer.
  2474. * @observable
  2475. * @api
  2476. */
  2477. BaseLayer.prototype.getMinZoom = function () {
  2478. return /** @type {number} */ (this.get(Property.MIN_ZOOM));
  2479. };
  2480. /**
  2481. * Return the maximum zoom level of the layer.
  2482. * @return {number} The maximum zoom level of the layer.
  2483. * @observable
  2484. * @api
  2485. */
  2486. BaseLayer.prototype.getMaxZoom = function () {
  2487. return /** @type {number} */ (this.get(Property.MAX_ZOOM));
  2488. };
  2489. /**
  2490. * Return the opacity of the layer (between 0 and 1).
  2491. * @return {number} The opacity of the layer.
  2492. * @observable
  2493. * @api
  2494. */
  2495. BaseLayer.prototype.getOpacity = function () {
  2496. return /** @type {number} */ (this.get(Property.OPACITY));
  2497. };
  2498. /**
  2499. * @abstract
  2500. * @return {import("../source/Source.js").State} Source state.
  2501. */
  2502. BaseLayer.prototype.getSourceState = function () {
  2503. return util_abstract();
  2504. };
  2505. /**
  2506. * Return the visibility of the layer (`true` or `false`).
  2507. * @return {boolean} The visibility of the layer.
  2508. * @observable
  2509. * @api
  2510. */
  2511. BaseLayer.prototype.getVisible = function () {
  2512. return /** @type {boolean} */ (this.get(Property.VISIBLE));
  2513. };
  2514. /**
  2515. * Return the Z-index of the layer, which is used to order layers before
  2516. * rendering. The default Z-index is 0.
  2517. * @return {number} The Z-index of the layer.
  2518. * @observable
  2519. * @api
  2520. */
  2521. BaseLayer.prototype.getZIndex = function () {
  2522. return /** @type {number} */ (this.get(Property.Z_INDEX));
  2523. };
  2524. /**
  2525. * Sets the background color.
  2526. * @param {BackgroundColor} [opt_background] Background color.
  2527. */
  2528. BaseLayer.prototype.setBackground = function (opt_background) {
  2529. this.background_ = opt_background;
  2530. this.changed();
  2531. };
  2532. /**
  2533. * Set the extent at which the layer is visible. If `undefined`, the layer
  2534. * will be visible at all extents.
  2535. * @param {import("../extent.js").Extent|undefined} extent The extent of the layer.
  2536. * @observable
  2537. * @api
  2538. */
  2539. BaseLayer.prototype.setExtent = function (extent) {
  2540. this.set(Property.EXTENT, extent);
  2541. };
  2542. /**
  2543. * Set the maximum resolution at which the layer is visible.
  2544. * @param {number} maxResolution The maximum resolution of the layer.
  2545. * @observable
  2546. * @api
  2547. */
  2548. BaseLayer.prototype.setMaxResolution = function (maxResolution) {
  2549. this.set(Property.MAX_RESOLUTION, maxResolution);
  2550. };
  2551. /**
  2552. * Set the minimum resolution at which the layer is visible.
  2553. * @param {number} minResolution The minimum resolution of the layer.
  2554. * @observable
  2555. * @api
  2556. */
  2557. BaseLayer.prototype.setMinResolution = function (minResolution) {
  2558. this.set(Property.MIN_RESOLUTION, minResolution);
  2559. };
  2560. /**
  2561. * Set the maximum zoom (exclusive) at which the layer is visible.
  2562. * Note that the zoom levels for layer visibility are based on the
  2563. * view zoom level, which may be different from a tile source zoom level.
  2564. * @param {number} maxZoom The maximum zoom of the layer.
  2565. * @observable
  2566. * @api
  2567. */
  2568. BaseLayer.prototype.setMaxZoom = function (maxZoom) {
  2569. this.set(Property.MAX_ZOOM, maxZoom);
  2570. };
  2571. /**
  2572. * Set the minimum zoom (inclusive) at which the layer is visible.
  2573. * Note that the zoom levels for layer visibility are based on the
  2574. * view zoom level, which may be different from a tile source zoom level.
  2575. * @param {number} minZoom The minimum zoom of the layer.
  2576. * @observable
  2577. * @api
  2578. */
  2579. BaseLayer.prototype.setMinZoom = function (minZoom) {
  2580. this.set(Property.MIN_ZOOM, minZoom);
  2581. };
  2582. /**
  2583. * Set the opacity of the layer, allowed values range from 0 to 1.
  2584. * @param {number} opacity The opacity of the layer.
  2585. * @observable
  2586. * @api
  2587. */
  2588. BaseLayer.prototype.setOpacity = function (opacity) {
  2589. asserts_assert(typeof opacity === 'number', 64); // Layer opacity must be a number
  2590. this.set(Property.OPACITY, opacity);
  2591. };
  2592. /**
  2593. * Set the visibility of the layer (`true` or `false`).
  2594. * @param {boolean} visible The visibility of the layer.
  2595. * @observable
  2596. * @api
  2597. */
  2598. BaseLayer.prototype.setVisible = function (visible) {
  2599. this.set(Property.VISIBLE, visible);
  2600. };
  2601. /**
  2602. * Set Z-index of the layer, which is used to order layers before rendering.
  2603. * The default Z-index is 0.
  2604. * @param {number} zindex The z-index of the layer.
  2605. * @observable
  2606. * @api
  2607. */
  2608. BaseLayer.prototype.setZIndex = function (zindex) {
  2609. this.set(Property.Z_INDEX, zindex);
  2610. };
  2611. /**
  2612. * Clean up.
  2613. */
  2614. BaseLayer.prototype.disposeInternal = function () {
  2615. if (this.state_) {
  2616. this.state_.layer = null;
  2617. this.state_ = null;
  2618. }
  2619. _super.prototype.disposeInternal.call(this);
  2620. };
  2621. return BaseLayer;
  2622. }(ol_Object));
  2623. /* harmony default export */ var Base = (BaseLayer);
  2624. //# sourceMappingURL=Base.js.map
  2625. ;// ./node_modules/ol/render/EventType.js
  2626. /**
  2627. * @module ol/render/EventType
  2628. */
  2629. /**
  2630. * @enum {string}
  2631. */
  2632. /* harmony default export */ var render_EventType = ({
  2633. /**
  2634. * Triggered before a layer is rendered.
  2635. * @event module:ol/render/Event~RenderEvent#prerender
  2636. * @api
  2637. */
  2638. PRERENDER: 'prerender',
  2639. /**
  2640. * Triggered after a layer is rendered.
  2641. * @event module:ol/render/Event~RenderEvent#postrender
  2642. * @api
  2643. */
  2644. POSTRENDER: 'postrender',
  2645. /**
  2646. * Triggered before layers are composed. When dispatched by the map, the event object will not have
  2647. * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only
  2648. * WebGL layers currently dispatch this event.
  2649. * @event module:ol/render/Event~RenderEvent#precompose
  2650. * @api
  2651. */
  2652. PRECOMPOSE: 'precompose',
  2653. /**
  2654. * Triggered after layers are composed. When dispatched by the map, the event object will not have
  2655. * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only
  2656. * WebGL layers currently dispatch this event.
  2657. * @event module:ol/render/Event~RenderEvent#postcompose
  2658. * @api
  2659. */
  2660. POSTCOMPOSE: 'postcompose',
  2661. /**
  2662. * Triggered when rendering is complete, i.e. all sources and tiles have
  2663. * finished loading for the current viewport, and all tiles are faded in.
  2664. * The event object will not have a `context` set.
  2665. * @event module:ol/render/Event~RenderEvent#rendercomplete
  2666. * @api
  2667. */
  2668. RENDERCOMPLETE: 'rendercomplete',
  2669. });
  2670. /**
  2671. * @typedef {'postrender'|'precompose'|'postcompose'|'rendercomplete'} MapRenderEventTypes
  2672. */
  2673. /**
  2674. * @typedef {'postrender'|'prerender'} LayerRenderEventTypes
  2675. */
  2676. //# sourceMappingURL=EventType.js.map
  2677. ;// ./node_modules/ol/layer/Layer.js
  2678. var Layer_extends = (undefined && undefined.__extends) || (function () {
  2679. var extendStatics = function (d, b) {
  2680. extendStatics = Object.setPrototypeOf ||
  2681. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2682. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  2683. return extendStatics(d, b);
  2684. };
  2685. return function (d, b) {
  2686. if (typeof b !== "function" && b !== null)
  2687. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  2688. extendStatics(d, b);
  2689. function __() { this.constructor = d; }
  2690. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2691. };
  2692. })();
  2693. /**
  2694. * @module ol/layer/Layer
  2695. */
  2696. /**
  2697. * @typedef {function(import("../PluggableMap.js").FrameState):HTMLElement} RenderFunction
  2698. */
  2699. /***
  2700. * @template Return
  2701. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  2702. * import("../Observable").OnSignature<import("./Base").BaseLayerObjectEventTypes|
  2703. * 'change:source', import("../Object").ObjectEvent, Return> &
  2704. * import("../Observable").OnSignature<import("../render/EventType").LayerRenderEventTypes, import("../render/Event").default, Return> &
  2705. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("./Base").BaseLayerObjectEventTypes|'change:source'|
  2706. * import("../render/EventType").LayerRenderEventTypes, Return>} LayerOnSignature
  2707. */
  2708. /**
  2709. * @template {import("../source/Source.js").default} [SourceType=import("../source/Source.js").default]
  2710. * @typedef {Object} Options
  2711. * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
  2712. * @property {number} [opacity=1] Opacity (0, 1).
  2713. * @property {boolean} [visible=true] Visibility.
  2714. * @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
  2715. * rendered outside of this extent.
  2716. * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
  2717. * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
  2718. * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
  2719. * method was used.
  2720. * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
  2721. * visible.
  2722. * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
  2723. * be visible.
  2724. * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
  2725. * visible.
  2726. * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
  2727. * be visible.
  2728. * @property {SourceType} [source] Source for this layer. If not provided to the constructor,
  2729. * the source can be set by calling {@link module:ol/layer/Layer~Layer#setSource layer.setSource(source)} after
  2730. * construction.
  2731. * @property {import("../PluggableMap.js").default|null} [map] Map.
  2732. * @property {RenderFunction} [render] Render function. Takes the frame state as input and is expected to return an
  2733. * HTML element. Will overwrite the default rendering for the layer.
  2734. * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
  2735. */
  2736. /**
  2737. * @typedef {Object} State
  2738. * @property {import("./Layer.js").default} layer Layer.
  2739. * @property {number} opacity Opacity, the value is rounded to two digits to appear after the decimal point.
  2740. * @property {boolean} visible Visible.
  2741. * @property {boolean} managed Managed.
  2742. * @property {import("../extent.js").Extent} [extent] Extent.
  2743. * @property {number} zIndex ZIndex.
  2744. * @property {number} maxResolution Maximum resolution.
  2745. * @property {number} minResolution Minimum resolution.
  2746. * @property {number} minZoom Minimum zoom.
  2747. * @property {number} maxZoom Maximum zoom.
  2748. */
  2749. /**
  2750. * @classdesc
  2751. * Base class from which all layer types are derived. This should only be instantiated
  2752. * in the case where a custom layer is added to the map with a custom `render` function.
  2753. * Such a function can be specified in the `options` object, and is expected to return an HTML element.
  2754. *
  2755. * A visual representation of raster or vector map data.
  2756. * Layers group together those properties that pertain to how the data is to be
  2757. * displayed, irrespective of the source of that data.
  2758. *
  2759. * Layers are usually added to a map with {@link import("../PluggableMap.js").default#addLayer map.addLayer()}. Components
  2760. * like {@link module:ol/interaction/Draw~Draw} use unmanaged layers
  2761. * internally. These unmanaged layers are associated with the map using
  2762. * {@link module:ol/layer/Layer~Layer#setMap} instead.
  2763. *
  2764. * A generic `change` event is fired when the state of the source changes.
  2765. *
  2766. * Please note that for performance reasons several layers might get rendered to
  2767. * the same HTML element, which will cause {@link import("../PluggableMap.js").default#forEachLayerAtPixel map.forEachLayerAtPixel()} to
  2768. * give false positives. To avoid this, apply different `className` properties to the
  2769. * layers at creation time.
  2770. *
  2771. * @fires import("../render/Event.js").RenderEvent#prerender
  2772. * @fires import("../render/Event.js").RenderEvent#postrender
  2773. *
  2774. * @template {import("../source/Source.js").default} [SourceType=import("../source/Source.js").default]
  2775. * @template {import("../renderer/Layer.js").default} [RendererType=import("../renderer/Layer.js").default]
  2776. * @api
  2777. */
  2778. var Layer = /** @class */ (function (_super) {
  2779. Layer_extends(Layer, _super);
  2780. /**
  2781. * @param {Options<SourceType>} options Layer options.
  2782. */
  2783. function Layer(options) {
  2784. var _this = this;
  2785. var baseOptions = obj_assign({}, options);
  2786. delete baseOptions.source;
  2787. _this = _super.call(this, baseOptions) || this;
  2788. /***
  2789. * @type {LayerOnSignature<import("../events").EventsKey>}
  2790. */
  2791. _this.on;
  2792. /***
  2793. * @type {LayerOnSignature<import("../events").EventsKey>}
  2794. */
  2795. _this.once;
  2796. /***
  2797. * @type {LayerOnSignature<void>}
  2798. */
  2799. _this.un;
  2800. /**
  2801. * @private
  2802. * @type {?import("../events.js").EventsKey}
  2803. */
  2804. _this.mapPrecomposeKey_ = null;
  2805. /**
  2806. * @private
  2807. * @type {?import("../events.js").EventsKey}
  2808. */
  2809. _this.mapRenderKey_ = null;
  2810. /**
  2811. * @private
  2812. * @type {?import("../events.js").EventsKey}
  2813. */
  2814. _this.sourceChangeKey_ = null;
  2815. /**
  2816. * @private
  2817. * @type {RendererType}
  2818. */
  2819. _this.renderer_ = null;
  2820. /**
  2821. * @protected
  2822. * @type {boolean}
  2823. */
  2824. _this.rendered = false;
  2825. // Overwrite default render method with a custom one
  2826. if (options.render) {
  2827. _this.render = options.render;
  2828. }
  2829. if (options.map) {
  2830. _this.setMap(options.map);
  2831. }
  2832. _this.addChangeListener(Property.SOURCE, _this.handleSourcePropertyChange_);
  2833. var source = options.source
  2834. ? /** @type {SourceType} */ (options.source)
  2835. : null;
  2836. _this.setSource(source);
  2837. return _this;
  2838. }
  2839. /**
  2840. * @param {Array<import("./Layer.js").default>} [opt_array] Array of layers (to be modified in place).
  2841. * @return {Array<import("./Layer.js").default>} Array of layers.
  2842. */
  2843. Layer.prototype.getLayersArray = function (opt_array) {
  2844. var array = opt_array ? opt_array : [];
  2845. array.push(this);
  2846. return array;
  2847. };
  2848. /**
  2849. * @param {Array<import("./Layer.js").State>} [opt_states] Optional list of layer states (to be modified in place).
  2850. * @return {Array<import("./Layer.js").State>} List of layer states.
  2851. */
  2852. Layer.prototype.getLayerStatesArray = function (opt_states) {
  2853. var states = opt_states ? opt_states : [];
  2854. states.push(this.getLayerState());
  2855. return states;
  2856. };
  2857. /**
  2858. * Get the layer source.
  2859. * @return {SourceType|null} The layer source (or `null` if not yet set).
  2860. * @observable
  2861. * @api
  2862. */
  2863. Layer.prototype.getSource = function () {
  2864. return /** @type {SourceType} */ (this.get(Property.SOURCE)) || null;
  2865. };
  2866. /**
  2867. * @return {SourceType|null} The source being rendered.
  2868. */
  2869. Layer.prototype.getRenderSource = function () {
  2870. return this.getSource();
  2871. };
  2872. /**
  2873. * @return {import("../source/Source.js").State} Source state.
  2874. */
  2875. Layer.prototype.getSourceState = function () {
  2876. var source = this.getSource();
  2877. return !source ? 'undefined' : source.getState();
  2878. };
  2879. /**
  2880. * @private
  2881. */
  2882. Layer.prototype.handleSourceChange_ = function () {
  2883. this.changed();
  2884. };
  2885. /**
  2886. * @private
  2887. */
  2888. Layer.prototype.handleSourcePropertyChange_ = function () {
  2889. if (this.sourceChangeKey_) {
  2890. unlistenByKey(this.sourceChangeKey_);
  2891. this.sourceChangeKey_ = null;
  2892. }
  2893. var source = this.getSource();
  2894. if (source) {
  2895. this.sourceChangeKey_ = listen(source, EventType.CHANGE, this.handleSourceChange_, this);
  2896. }
  2897. this.changed();
  2898. };
  2899. /**
  2900. * @param {import("../pixel").Pixel} pixel Pixel.
  2901. * @return {Promise<Array<import("../Feature").default>>} Promise that resolves with
  2902. * an array of features.
  2903. */
  2904. Layer.prototype.getFeatures = function (pixel) {
  2905. if (!this.renderer_) {
  2906. return new Promise(function (resolve) { return resolve([]); });
  2907. }
  2908. return this.renderer_.getFeatures(pixel);
  2909. };
  2910. /**
  2911. * @param {import("../pixel").Pixel} pixel Pixel.
  2912. * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
  2913. */
  2914. Layer.prototype.getData = function (pixel) {
  2915. if (!this.renderer_ || !this.rendered) {
  2916. return null;
  2917. }
  2918. return this.renderer_.getData(pixel);
  2919. };
  2920. /**
  2921. * In charge to manage the rendering of the layer. One layer type is
  2922. * bounded with one layer renderer.
  2923. * @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
  2924. * @param {HTMLElement} target Target which the renderer may (but need not) use
  2925. * for rendering its content.
  2926. * @return {HTMLElement} The rendered element.
  2927. */
  2928. Layer.prototype.render = function (frameState, target) {
  2929. var layerRenderer = this.getRenderer();
  2930. if (layerRenderer.prepareFrame(frameState)) {
  2931. this.rendered = true;
  2932. return layerRenderer.renderFrame(frameState, target);
  2933. }
  2934. };
  2935. /**
  2936. * Called when a layer is not visible during a map render.
  2937. */
  2938. Layer.prototype.unrender = function () {
  2939. this.rendered = false;
  2940. };
  2941. /**
  2942. * For use inside the library only.
  2943. * @param {import("../PluggableMap.js").default|null} map Map.
  2944. */
  2945. Layer.prototype.setMapInternal = function (map) {
  2946. if (!map) {
  2947. this.unrender();
  2948. }
  2949. this.set(Property.MAP, map);
  2950. };
  2951. /**
  2952. * For use inside the library only.
  2953. * @return {import("../PluggableMap.js").default|null} Map.
  2954. */
  2955. Layer.prototype.getMapInternal = function () {
  2956. return this.get(Property.MAP);
  2957. };
  2958. /**
  2959. * Sets the layer to be rendered on top of other layers on a map. The map will
  2960. * not manage this layer in its layers collection, and the callback in
  2961. * {@link module:ol/Map~Map#forEachLayerAtPixel} will receive `null` as layer. This
  2962. * is useful for temporary layers. To remove an unmanaged layer from the map,
  2963. * use `#setMap(null)`.
  2964. *
  2965. * To add the layer to a map and have it managed by the map, use
  2966. * {@link module:ol/Map~Map#addLayer} instead.
  2967. * @param {import("../PluggableMap.js").default|null} map Map.
  2968. * @api
  2969. */
  2970. Layer.prototype.setMap = function (map) {
  2971. if (this.mapPrecomposeKey_) {
  2972. unlistenByKey(this.mapPrecomposeKey_);
  2973. this.mapPrecomposeKey_ = null;
  2974. }
  2975. if (!map) {
  2976. this.changed();
  2977. }
  2978. if (this.mapRenderKey_) {
  2979. unlistenByKey(this.mapRenderKey_);
  2980. this.mapRenderKey_ = null;
  2981. }
  2982. if (map) {
  2983. this.mapPrecomposeKey_ = listen(map, render_EventType.PRECOMPOSE, function (evt) {
  2984. var renderEvent =
  2985. /** @type {import("../render/Event.js").default} */ (evt);
  2986. var layerStatesArray = renderEvent.frameState.layerStatesArray;
  2987. var layerState = this.getLayerState(false);
  2988. // A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both.
  2989. asserts_assert(!layerStatesArray.some(function (arrayLayerState) {
  2990. return arrayLayerState.layer === layerState.layer;
  2991. }), 67);
  2992. layerStatesArray.push(layerState);
  2993. }, this);
  2994. this.mapRenderKey_ = listen(this, EventType.CHANGE, map.render, map);
  2995. this.changed();
  2996. }
  2997. };
  2998. /**
  2999. * Set the layer source.
  3000. * @param {SourceType|null} source The layer source.
  3001. * @observable
  3002. * @api
  3003. */
  3004. Layer.prototype.setSource = function (source) {
  3005. this.set(Property.SOURCE, source);
  3006. };
  3007. /**
  3008. * Get the renderer for this layer.
  3009. * @return {RendererType|null} The layer renderer.
  3010. */
  3011. Layer.prototype.getRenderer = function () {
  3012. if (!this.renderer_) {
  3013. this.renderer_ = this.createRenderer();
  3014. }
  3015. return this.renderer_;
  3016. };
  3017. /**
  3018. * @return {boolean} The layer has a renderer.
  3019. */
  3020. Layer.prototype.hasRenderer = function () {
  3021. return !!this.renderer_;
  3022. };
  3023. /**
  3024. * Create a renderer for this layer.
  3025. * @return {RendererType} A layer renderer.
  3026. * @protected
  3027. */
  3028. Layer.prototype.createRenderer = function () {
  3029. return null;
  3030. };
  3031. /**
  3032. * Clean up.
  3033. */
  3034. Layer.prototype.disposeInternal = function () {
  3035. if (this.renderer_) {
  3036. this.renderer_.dispose();
  3037. delete this.renderer_;
  3038. }
  3039. this.setSource(null);
  3040. _super.prototype.disposeInternal.call(this);
  3041. };
  3042. return Layer;
  3043. }(Base));
  3044. /**
  3045. * Return `true` if the layer is visible and if the provided view state
  3046. * has resolution and zoom levels that are in range of the layer's min/max.
  3047. * @param {State} layerState Layer state.
  3048. * @param {import("../View.js").State} viewState View state.
  3049. * @return {boolean} The layer is visible at the given view state.
  3050. */
  3051. function inView(layerState, viewState) {
  3052. if (!layerState.visible) {
  3053. return false;
  3054. }
  3055. var resolution = viewState.resolution;
  3056. if (resolution < layerState.minResolution ||
  3057. resolution >= layerState.maxResolution) {
  3058. return false;
  3059. }
  3060. var zoom = viewState.zoom;
  3061. return zoom > layerState.minZoom && zoom <= layerState.maxZoom;
  3062. }
  3063. /* harmony default export */ var layer_Layer = (Layer);
  3064. //# sourceMappingURL=Layer.js.map
  3065. ;// ./node_modules/ol/control/Attribution.js
  3066. var Attribution_extends = (undefined && undefined.__extends) || (function () {
  3067. var extendStatics = function (d, b) {
  3068. extendStatics = Object.setPrototypeOf ||
  3069. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3070. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3071. return extendStatics(d, b);
  3072. };
  3073. return function (d, b) {
  3074. if (typeof b !== "function" && b !== null)
  3075. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3076. extendStatics(d, b);
  3077. function __() { this.constructor = d; }
  3078. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3079. };
  3080. })();
  3081. /**
  3082. * @module ol/control/Attribution
  3083. */
  3084. /**
  3085. * @typedef {Object} Options
  3086. * @property {string} [className='ol-attribution'] CSS class name.
  3087. * @property {HTMLElement|string} [target] Specify a target if you
  3088. * want the control to be rendered outside of the map's
  3089. * viewport.
  3090. * @property {boolean} [collapsible] Specify if attributions can
  3091. * be collapsed. If not specified, sources control this behavior with their
  3092. * `attributionsCollapsible` setting.
  3093. * @property {boolean} [collapsed=true] Specify if attributions should
  3094. * be collapsed at startup.
  3095. * @property {string} [tipLabel='Attributions'] Text label to use for the button tip.
  3096. * @property {string|HTMLElement} [label='i'] Text label to use for the
  3097. * collapsed attributions button.
  3098. * Instead of text, also an element (e.g. a `span` element) can be used.
  3099. * @property {string} [expandClassName=className + '-expand'] CSS class name for the
  3100. * collapsed attributions button.
  3101. * @property {string|HTMLElement} [collapseLabel='›'] Text label to use
  3102. * for the expanded attributions button.
  3103. * Instead of text, also an element (e.g. a `span` element) can be used.
  3104. * @property {string} [collapseClassName=className + '-collapse'] CSS class name for the
  3105. * expanded attributions button.
  3106. * @property {function(import("../MapEvent.js").default):void} [render] Function called when
  3107. * the control should be re-rendered. This is called in a `requestAnimationFrame`
  3108. * callback.
  3109. */
  3110. /**
  3111. * @classdesc
  3112. * Control to show all the attributions associated with the layer sources
  3113. * in the map. This control is one of the default controls included in maps.
  3114. * By default it will show in the bottom right portion of the map, but this can
  3115. * be changed by using a css selector for `.ol-attribution`.
  3116. *
  3117. * @api
  3118. */
  3119. var Attribution = /** @class */ (function (_super) {
  3120. Attribution_extends(Attribution, _super);
  3121. /**
  3122. * @param {Options} [opt_options] Attribution options.
  3123. */
  3124. function Attribution(opt_options) {
  3125. var _this = this;
  3126. var options = opt_options ? opt_options : {};
  3127. _this = _super.call(this, {
  3128. element: document.createElement('div'),
  3129. render: options.render,
  3130. target: options.target,
  3131. }) || this;
  3132. /**
  3133. * @private
  3134. * @type {HTMLElement}
  3135. */
  3136. _this.ulElement_ = document.createElement('ul');
  3137. /**
  3138. * @private
  3139. * @type {boolean}
  3140. */
  3141. _this.collapsed_ =
  3142. options.collapsed !== undefined ? options.collapsed : true;
  3143. /**
  3144. * @private
  3145. * @type {boolean}
  3146. */
  3147. _this.userCollapsed_ = _this.collapsed_;
  3148. /**
  3149. * @private
  3150. * @type {boolean}
  3151. */
  3152. _this.overrideCollapsible_ = options.collapsible !== undefined;
  3153. /**
  3154. * @private
  3155. * @type {boolean}
  3156. */
  3157. _this.collapsible_ =
  3158. options.collapsible !== undefined ? options.collapsible : true;
  3159. if (!_this.collapsible_) {
  3160. _this.collapsed_ = false;
  3161. }
  3162. var className = options.className !== undefined ? options.className : 'ol-attribution';
  3163. var tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
  3164. var expandClassName = options.expandClassName !== undefined
  3165. ? options.expandClassName
  3166. : className + '-expand';
  3167. var collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u203A';
  3168. var collapseClassName = options.collapseClassName !== undefined
  3169. ? options.collapseClassName
  3170. : className + '-collapse';
  3171. if (typeof collapseLabel === 'string') {
  3172. /**
  3173. * @private
  3174. * @type {HTMLElement}
  3175. */
  3176. _this.collapseLabel_ = document.createElement('span');
  3177. _this.collapseLabel_.textContent = collapseLabel;
  3178. _this.collapseLabel_.className = collapseClassName;
  3179. }
  3180. else {
  3181. _this.collapseLabel_ = collapseLabel;
  3182. }
  3183. var label = options.label !== undefined ? options.label : 'i';
  3184. if (typeof label === 'string') {
  3185. /**
  3186. * @private
  3187. * @type {HTMLElement}
  3188. */
  3189. _this.label_ = document.createElement('span');
  3190. _this.label_.textContent = label;
  3191. _this.label_.className = expandClassName;
  3192. }
  3193. else {
  3194. _this.label_ = label;
  3195. }
  3196. var activeLabel = _this.collapsible_ && !_this.collapsed_ ? _this.collapseLabel_ : _this.label_;
  3197. /**
  3198. * @private
  3199. * @type {HTMLElement}
  3200. */
  3201. _this.toggleButton_ = document.createElement('button');
  3202. _this.toggleButton_.setAttribute('type', 'button');
  3203. _this.toggleButton_.setAttribute('aria-expanded', String(!_this.collapsed_));
  3204. _this.toggleButton_.title = tipLabel;
  3205. _this.toggleButton_.appendChild(activeLabel);
  3206. _this.toggleButton_.addEventListener(EventType.CLICK, _this.handleClick_.bind(_this), false);
  3207. var cssClasses = className +
  3208. ' ' +
  3209. CLASS_UNSELECTABLE +
  3210. ' ' +
  3211. CLASS_CONTROL +
  3212. (_this.collapsed_ && _this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
  3213. (_this.collapsible_ ? '' : ' ol-uncollapsible');
  3214. var element = _this.element;
  3215. element.className = cssClasses;
  3216. element.appendChild(_this.toggleButton_);
  3217. element.appendChild(_this.ulElement_);
  3218. /**
  3219. * A list of currently rendered resolutions.
  3220. * @type {Array<string>}
  3221. * @private
  3222. */
  3223. _this.renderedAttributions_ = [];
  3224. /**
  3225. * @private
  3226. * @type {boolean}
  3227. */
  3228. _this.renderedVisible_ = true;
  3229. return _this;
  3230. }
  3231. /**
  3232. * Collect a list of visible attributions and set the collapsible state.
  3233. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  3234. * @return {Array<string>} Attributions.
  3235. * @private
  3236. */
  3237. Attribution.prototype.collectSourceAttributions_ = function (frameState) {
  3238. /**
  3239. * Used to determine if an attribution already exists.
  3240. * @type {!Object<string, boolean>}
  3241. */
  3242. var lookup = {};
  3243. /**
  3244. * A list of visible attributions.
  3245. * @type {Array<string>}
  3246. */
  3247. var visibleAttributions = [];
  3248. var collapsible = true;
  3249. var layerStatesArray = frameState.layerStatesArray;
  3250. for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
  3251. var layerState = layerStatesArray[i];
  3252. if (!inView(layerState, frameState.viewState)) {
  3253. continue;
  3254. }
  3255. var source = /** @type {import("../layer/Layer.js").default} */ (layerState.layer).getSource();
  3256. if (!source) {
  3257. continue;
  3258. }
  3259. var attributionGetter = source.getAttributions();
  3260. if (!attributionGetter) {
  3261. continue;
  3262. }
  3263. var attributions = attributionGetter(frameState);
  3264. if (!attributions) {
  3265. continue;
  3266. }
  3267. collapsible =
  3268. collapsible && source.getAttributionsCollapsible() !== false;
  3269. if (Array.isArray(attributions)) {
  3270. for (var j = 0, jj = attributions.length; j < jj; ++j) {
  3271. if (!(attributions[j] in lookup)) {
  3272. visibleAttributions.push(attributions[j]);
  3273. lookup[attributions[j]] = true;
  3274. }
  3275. }
  3276. }
  3277. else {
  3278. if (!(attributions in lookup)) {
  3279. visibleAttributions.push(attributions);
  3280. lookup[attributions] = true;
  3281. }
  3282. }
  3283. }
  3284. if (!this.overrideCollapsible_) {
  3285. this.setCollapsible(collapsible);
  3286. }
  3287. return visibleAttributions;
  3288. };
  3289. /**
  3290. * @private
  3291. * @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
  3292. */
  3293. Attribution.prototype.updateElement_ = function (frameState) {
  3294. if (!frameState) {
  3295. if (this.renderedVisible_) {
  3296. this.element.style.display = 'none';
  3297. this.renderedVisible_ = false;
  3298. }
  3299. return;
  3300. }
  3301. var attributions = this.collectSourceAttributions_(frameState);
  3302. var visible = attributions.length > 0;
  3303. if (this.renderedVisible_ != visible) {
  3304. this.element.style.display = visible ? '' : 'none';
  3305. this.renderedVisible_ = visible;
  3306. }
  3307. if (equals(attributions, this.renderedAttributions_)) {
  3308. return;
  3309. }
  3310. removeChildren(this.ulElement_);
  3311. // append the attributions
  3312. for (var i = 0, ii = attributions.length; i < ii; ++i) {
  3313. var element = document.createElement('li');
  3314. element.innerHTML = attributions[i];
  3315. this.ulElement_.appendChild(element);
  3316. }
  3317. this.renderedAttributions_ = attributions;
  3318. };
  3319. /**
  3320. * @param {MouseEvent} event The event to handle
  3321. * @private
  3322. */
  3323. Attribution.prototype.handleClick_ = function (event) {
  3324. event.preventDefault();
  3325. this.handleToggle_();
  3326. this.userCollapsed_ = this.collapsed_;
  3327. };
  3328. /**
  3329. * @private
  3330. */
  3331. Attribution.prototype.handleToggle_ = function () {
  3332. this.element.classList.toggle(CLASS_COLLAPSED);
  3333. if (this.collapsed_) {
  3334. replaceNode(this.collapseLabel_, this.label_);
  3335. }
  3336. else {
  3337. replaceNode(this.label_, this.collapseLabel_);
  3338. }
  3339. this.collapsed_ = !this.collapsed_;
  3340. this.toggleButton_.setAttribute('aria-expanded', String(!this.collapsed_));
  3341. };
  3342. /**
  3343. * Return `true` if the attribution is collapsible, `false` otherwise.
  3344. * @return {boolean} True if the widget is collapsible.
  3345. * @api
  3346. */
  3347. Attribution.prototype.getCollapsible = function () {
  3348. return this.collapsible_;
  3349. };
  3350. /**
  3351. * Set whether the attribution should be collapsible.
  3352. * @param {boolean} collapsible True if the widget is collapsible.
  3353. * @api
  3354. */
  3355. Attribution.prototype.setCollapsible = function (collapsible) {
  3356. if (this.collapsible_ === collapsible) {
  3357. return;
  3358. }
  3359. this.collapsible_ = collapsible;
  3360. this.element.classList.toggle('ol-uncollapsible');
  3361. if (this.userCollapsed_) {
  3362. this.handleToggle_();
  3363. }
  3364. };
  3365. /**
  3366. * Collapse or expand the attribution according to the passed parameter. Will
  3367. * not do anything if the attribution isn't collapsible or if the current
  3368. * collapsed state is already the one requested.
  3369. * @param {boolean} collapsed True if the widget is collapsed.
  3370. * @api
  3371. */
  3372. Attribution.prototype.setCollapsed = function (collapsed) {
  3373. this.userCollapsed_ = collapsed;
  3374. if (!this.collapsible_ || this.collapsed_ === collapsed) {
  3375. return;
  3376. }
  3377. this.handleToggle_();
  3378. };
  3379. /**
  3380. * Return `true` when the attribution is currently collapsed or `false`
  3381. * otherwise.
  3382. * @return {boolean} True if the widget is collapsed.
  3383. * @api
  3384. */
  3385. Attribution.prototype.getCollapsed = function () {
  3386. return this.collapsed_;
  3387. };
  3388. /**
  3389. * Update the attribution element.
  3390. * @param {import("../MapEvent.js").default} mapEvent Map event.
  3391. * @override
  3392. */
  3393. Attribution.prototype.render = function (mapEvent) {
  3394. this.updateElement_(mapEvent.frameState);
  3395. };
  3396. return Attribution;
  3397. }(control_Control));
  3398. /* harmony default export */ var control_Attribution = (Attribution);
  3399. //# sourceMappingURL=Attribution.js.map
  3400. ;// ./node_modules/ol/pointer/EventType.js
  3401. /**
  3402. * @module ol/pointer/EventType
  3403. */
  3404. /**
  3405. * Constants for event names.
  3406. * @enum {string}
  3407. */
  3408. /* harmony default export */ var pointer_EventType = ({
  3409. POINTERMOVE: 'pointermove',
  3410. POINTERDOWN: 'pointerdown',
  3411. POINTERUP: 'pointerup',
  3412. POINTEROVER: 'pointerover',
  3413. POINTEROUT: 'pointerout',
  3414. POINTERENTER: 'pointerenter',
  3415. POINTERLEAVE: 'pointerleave',
  3416. POINTERCANCEL: 'pointercancel',
  3417. });
  3418. //# sourceMappingURL=EventType.js.map
  3419. ;// ./node_modules/ol/proj/Units.js
  3420. /**
  3421. * @module ol/proj/Units
  3422. */
  3423. /**
  3424. * Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or
  3425. * `'us-ft'`.
  3426. * @enum {string}
  3427. */
  3428. var Units = {
  3429. /**
  3430. * Radians
  3431. * @api
  3432. */
  3433. RADIANS: 'radians',
  3434. /**
  3435. * Degrees
  3436. * @api
  3437. */
  3438. DEGREES: 'degrees',
  3439. /**
  3440. * Feet
  3441. * @api
  3442. */
  3443. FEET: 'ft',
  3444. /**
  3445. * Meters
  3446. * @api
  3447. */
  3448. METERS: 'm',
  3449. /**
  3450. * Pixels
  3451. * @api
  3452. */
  3453. PIXELS: 'pixels',
  3454. /**
  3455. * Tile Pixels
  3456. * @api
  3457. */
  3458. TILE_PIXELS: 'tile-pixels',
  3459. /**
  3460. * US Feet
  3461. * @api
  3462. */
  3463. USFEET: 'us-ft',
  3464. };
  3465. /**
  3466. * See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt
  3467. * @type {Object<number, Units>}
  3468. */
  3469. var unitByCode = {
  3470. '9001': Units.METERS,
  3471. '9002': Units.FEET,
  3472. '9003': Units.USFEET,
  3473. '9101': Units.RADIANS,
  3474. '9102': Units.DEGREES,
  3475. };
  3476. /**
  3477. * @param {number} code Unit code.
  3478. * @return {Units} Units.
  3479. */
  3480. function fromCode(code) {
  3481. return unitByCode[code];
  3482. }
  3483. /**
  3484. * Meters per unit lookup table.
  3485. * @const
  3486. * @type {Object<Units, number>}
  3487. * @api
  3488. */
  3489. var Units_METERS_PER_UNIT = {};
  3490. // use the radius of the Normal sphere
  3491. Units_METERS_PER_UNIT[Units.RADIANS] = 6370997 / (2 * Math.PI);
  3492. Units_METERS_PER_UNIT[Units.DEGREES] = (2 * Math.PI * 6370997) / 360;
  3493. Units_METERS_PER_UNIT[Units.FEET] = 0.3048;
  3494. Units_METERS_PER_UNIT[Units.METERS] = 1;
  3495. Units_METERS_PER_UNIT[Units.USFEET] = 1200 / 3937;
  3496. /* harmony default export */ var proj_Units = (Units);
  3497. //# sourceMappingURL=Units.js.map
  3498. ;// ./node_modules/ol/proj/Projection.js
  3499. /**
  3500. * @module ol/proj/Projection
  3501. */
  3502. /**
  3503. * @typedef {Object} Options
  3504. * @property {string} code The SRS identifier code, e.g. `EPSG:4326`.
  3505. * @property {import("./Units.js").default|string} [units] Units. Required unless a
  3506. * proj4 projection is defined for `code`.
  3507. * @property {import("../extent.js").Extent} [extent] The validity extent for the SRS.
  3508. * @property {string} [axisOrientation='enu'] The axis orientation as specified in Proj4.
  3509. * @property {boolean} [global=false] Whether the projection is valid for the whole globe.
  3510. * @property {number} [metersPerUnit] The meters per unit for the SRS.
  3511. * If not provided, the `units` are used to get the meters per unit from the {@link module:ol/proj/Units~METERS_PER_UNIT}
  3512. * lookup table.
  3513. * @property {import("../extent.js").Extent} [worldExtent] The world extent for the SRS.
  3514. * @property {function(number, import("../coordinate.js").Coordinate):number} [getPointResolution]
  3515. * Function to determine resolution at a point. The function is called with a
  3516. * `number` view resolution and a {@link module:ol/coordinate~Coordinate Coordinate} as arguments, and returns
  3517. * the `number` resolution in projection units at the passed coordinate. If this is `undefined`,
  3518. * the default {@link module:ol/proj.getPointResolution getPointResolution()} function will be used.
  3519. */
  3520. /**
  3521. * @classdesc
  3522. * Projection definition class. One of these is created for each projection
  3523. * supported in the application and stored in the {@link module:ol/proj} namespace.
  3524. * You can use these in applications, but this is not required, as API params
  3525. * and options use {@link module:ol/proj~ProjectionLike} which means the simple string
  3526. * code will suffice.
  3527. *
  3528. * You can use {@link module:ol/proj.get} to retrieve the object for a particular
  3529. * projection.
  3530. *
  3531. * The library includes definitions for `EPSG:4326` and `EPSG:3857`, together
  3532. * with the following aliases:
  3533. * * `EPSG:4326`: CRS:84, urn:ogc:def:crs:EPSG:6.6:4326,
  3534. * urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84,
  3535. * http://www.opengis.net/gml/srs/epsg.xml#4326,
  3536. * urn:x-ogc:def:crs:EPSG:4326
  3537. * * `EPSG:3857`: EPSG:102100, EPSG:102113, EPSG:900913,
  3538. * urn:ogc:def:crs:EPSG:6.18:3:3857,
  3539. * http://www.opengis.net/gml/srs/epsg.xml#3857
  3540. *
  3541. * If you use [proj4js](https://github.com/proj4js/proj4js), aliases can
  3542. * be added using `proj4.defs()`. After all required projection definitions are
  3543. * added, call the {@link module:ol/proj/proj4.register} function.
  3544. *
  3545. * @api
  3546. */
  3547. var Projection = /** @class */ (function () {
  3548. /**
  3549. * @param {Options} options Projection options.
  3550. */
  3551. function Projection(options) {
  3552. /**
  3553. * @private
  3554. * @type {string}
  3555. */
  3556. this.code_ = options.code;
  3557. /**
  3558. * Units of projected coordinates. When set to `TILE_PIXELS`, a
  3559. * `this.extent_` and `this.worldExtent_` must be configured properly for each
  3560. * tile.
  3561. * @private
  3562. * @type {import("./Units.js").default}
  3563. */
  3564. this.units_ = /** @type {import("./Units.js").default} */ (options.units);
  3565. /**
  3566. * Validity extent of the projection in projected coordinates. For projections
  3567. * with `TILE_PIXELS` units, this is the extent of the tile in
  3568. * tile pixel space.
  3569. * @private
  3570. * @type {import("../extent.js").Extent}
  3571. */
  3572. this.extent_ = options.extent !== undefined ? options.extent : null;
  3573. /**
  3574. * Extent of the world in EPSG:4326. For projections with
  3575. * `TILE_PIXELS` units, this is the extent of the tile in
  3576. * projected coordinate space.
  3577. * @private
  3578. * @type {import("../extent.js").Extent}
  3579. */
  3580. this.worldExtent_ =
  3581. options.worldExtent !== undefined ? options.worldExtent : null;
  3582. /**
  3583. * @private
  3584. * @type {string}
  3585. */
  3586. this.axisOrientation_ =
  3587. options.axisOrientation !== undefined ? options.axisOrientation : 'enu';
  3588. /**
  3589. * @private
  3590. * @type {boolean}
  3591. */
  3592. this.global_ = options.global !== undefined ? options.global : false;
  3593. /**
  3594. * @private
  3595. * @type {boolean}
  3596. */
  3597. this.canWrapX_ = !!(this.global_ && this.extent_);
  3598. /**
  3599. * @private
  3600. * @type {function(number, import("../coordinate.js").Coordinate):number|undefined}
  3601. */
  3602. this.getPointResolutionFunc_ = options.getPointResolution;
  3603. /**
  3604. * @private
  3605. * @type {import("../tilegrid/TileGrid.js").default}
  3606. */
  3607. this.defaultTileGrid_ = null;
  3608. /**
  3609. * @private
  3610. * @type {number|undefined}
  3611. */
  3612. this.metersPerUnit_ = options.metersPerUnit;
  3613. }
  3614. /**
  3615. * @return {boolean} The projection is suitable for wrapping the x-axis
  3616. */
  3617. Projection.prototype.canWrapX = function () {
  3618. return this.canWrapX_;
  3619. };
  3620. /**
  3621. * Get the code for this projection, e.g. 'EPSG:4326'.
  3622. * @return {string} Code.
  3623. * @api
  3624. */
  3625. Projection.prototype.getCode = function () {
  3626. return this.code_;
  3627. };
  3628. /**
  3629. * Get the validity extent for this projection.
  3630. * @return {import("../extent.js").Extent} Extent.
  3631. * @api
  3632. */
  3633. Projection.prototype.getExtent = function () {
  3634. return this.extent_;
  3635. };
  3636. /**
  3637. * Get the units of this projection.
  3638. * @return {import("./Units.js").default} Units.
  3639. * @api
  3640. */
  3641. Projection.prototype.getUnits = function () {
  3642. return this.units_;
  3643. };
  3644. /**
  3645. * Get the amount of meters per unit of this projection. If the projection is
  3646. * not configured with `metersPerUnit` or a units identifier, the return is
  3647. * `undefined`.
  3648. * @return {number|undefined} Meters.
  3649. * @api
  3650. */
  3651. Projection.prototype.getMetersPerUnit = function () {
  3652. return this.metersPerUnit_ || Units_METERS_PER_UNIT[this.units_];
  3653. };
  3654. /**
  3655. * Get the world extent for this projection.
  3656. * @return {import("../extent.js").Extent} Extent.
  3657. * @api
  3658. */
  3659. Projection.prototype.getWorldExtent = function () {
  3660. return this.worldExtent_;
  3661. };
  3662. /**
  3663. * Get the axis orientation of this projection.
  3664. * Example values are:
  3665. * enu - the default easting, northing, elevation.
  3666. * neu - northing, easting, up - useful for "lat/long" geographic coordinates,
  3667. * or south orientated transverse mercator.
  3668. * wnu - westing, northing, up - some planetary coordinate systems have
  3669. * "west positive" coordinate systems
  3670. * @return {string} Axis orientation.
  3671. * @api
  3672. */
  3673. Projection.prototype.getAxisOrientation = function () {
  3674. return this.axisOrientation_;
  3675. };
  3676. /**
  3677. * Is this projection a global projection which spans the whole world?
  3678. * @return {boolean} Whether the projection is global.
  3679. * @api
  3680. */
  3681. Projection.prototype.isGlobal = function () {
  3682. return this.global_;
  3683. };
  3684. /**
  3685. * Set if the projection is a global projection which spans the whole world
  3686. * @param {boolean} global Whether the projection is global.
  3687. * @api
  3688. */
  3689. Projection.prototype.setGlobal = function (global) {
  3690. this.global_ = global;
  3691. this.canWrapX_ = !!(global && this.extent_);
  3692. };
  3693. /**
  3694. * @return {import("../tilegrid/TileGrid.js").default} The default tile grid.
  3695. */
  3696. Projection.prototype.getDefaultTileGrid = function () {
  3697. return this.defaultTileGrid_;
  3698. };
  3699. /**
  3700. * @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid.
  3701. */
  3702. Projection.prototype.setDefaultTileGrid = function (tileGrid) {
  3703. this.defaultTileGrid_ = tileGrid;
  3704. };
  3705. /**
  3706. * Set the validity extent for this projection.
  3707. * @param {import("../extent.js").Extent} extent Extent.
  3708. * @api
  3709. */
  3710. Projection.prototype.setExtent = function (extent) {
  3711. this.extent_ = extent;
  3712. this.canWrapX_ = !!(this.global_ && extent);
  3713. };
  3714. /**
  3715. * Set the world extent for this projection.
  3716. * @param {import("../extent.js").Extent} worldExtent World extent
  3717. * [minlon, minlat, maxlon, maxlat].
  3718. * @api
  3719. */
  3720. Projection.prototype.setWorldExtent = function (worldExtent) {
  3721. this.worldExtent_ = worldExtent;
  3722. };
  3723. /**
  3724. * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}
  3725. * for this projection.
  3726. * @param {function(number, import("../coordinate.js").Coordinate):number} func Function
  3727. * @api
  3728. */
  3729. Projection.prototype.setGetPointResolution = function (func) {
  3730. this.getPointResolutionFunc_ = func;
  3731. };
  3732. /**
  3733. * Get the custom point resolution function for this projection (if set).
  3734. * @return {function(number, import("../coordinate.js").Coordinate):number|undefined} The custom point
  3735. * resolution function (if set).
  3736. */
  3737. Projection.prototype.getPointResolutionFunc = function () {
  3738. return this.getPointResolutionFunc_;
  3739. };
  3740. return Projection;
  3741. }());
  3742. /* harmony default export */ var proj_Projection = (Projection);
  3743. //# sourceMappingURL=Projection.js.map
  3744. ;// ./node_modules/ol/proj/epsg3857.js
  3745. var epsg3857_extends = (undefined && undefined.__extends) || (function () {
  3746. var extendStatics = function (d, b) {
  3747. extendStatics = Object.setPrototypeOf ||
  3748. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3749. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3750. return extendStatics(d, b);
  3751. };
  3752. return function (d, b) {
  3753. if (typeof b !== "function" && b !== null)
  3754. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3755. extendStatics(d, b);
  3756. function __() { this.constructor = d; }
  3757. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3758. };
  3759. })();
  3760. /**
  3761. * @module ol/proj/epsg3857
  3762. */
  3763. /**
  3764. * Radius of WGS84 sphere
  3765. *
  3766. * @const
  3767. * @type {number}
  3768. */
  3769. var RADIUS = 6378137;
  3770. /**
  3771. * @const
  3772. * @type {number}
  3773. */
  3774. var HALF_SIZE = Math.PI * RADIUS;
  3775. /**
  3776. * @const
  3777. * @type {import("../extent.js").Extent}
  3778. */
  3779. var EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];
  3780. /**
  3781. * @const
  3782. * @type {import("../extent.js").Extent}
  3783. */
  3784. var WORLD_EXTENT = [-180, -85, 180, 85];
  3785. /**
  3786. * Maximum safe value in y direction
  3787. * @const
  3788. * @type {number}
  3789. */
  3790. var MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));
  3791. /**
  3792. * @classdesc
  3793. * Projection object for web/spherical Mercator (EPSG:3857).
  3794. */
  3795. var EPSG3857Projection = /** @class */ (function (_super) {
  3796. epsg3857_extends(EPSG3857Projection, _super);
  3797. /**
  3798. * @param {string} code Code.
  3799. */
  3800. function EPSG3857Projection(code) {
  3801. return _super.call(this, {
  3802. code: code,
  3803. units: proj_Units.METERS,
  3804. extent: EXTENT,
  3805. global: true,
  3806. worldExtent: WORLD_EXTENT,
  3807. getPointResolution: function (resolution, point) {
  3808. return resolution / cosh(point[1] / RADIUS);
  3809. },
  3810. }) || this;
  3811. }
  3812. return EPSG3857Projection;
  3813. }(proj_Projection));
  3814. /**
  3815. * Projections equal to EPSG:3857.
  3816. *
  3817. * @const
  3818. * @type {Array<import("./Projection.js").default>}
  3819. */
  3820. var PROJECTIONS = [
  3821. new EPSG3857Projection('EPSG:3857'),
  3822. new EPSG3857Projection('EPSG:102100'),
  3823. new EPSG3857Projection('EPSG:102113'),
  3824. new EPSG3857Projection('EPSG:900913'),
  3825. new EPSG3857Projection('http://www.opengis.net/def/crs/EPSG/0/3857'),
  3826. new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),
  3827. ];
  3828. /**
  3829. * Transformation from EPSG:4326 to EPSG:3857.
  3830. *
  3831. * @param {Array<number>} input Input array of coordinate values.
  3832. * @param {Array<number>} [opt_output] Output array of coordinate values.
  3833. * @param {number} [opt_dimension] Dimension (default is `2`).
  3834. * @return {Array<number>} Output array of coordinate values.
  3835. */
  3836. function fromEPSG4326(input, opt_output, opt_dimension) {
  3837. var length = input.length;
  3838. var dimension = opt_dimension > 1 ? opt_dimension : 2;
  3839. var output = opt_output;
  3840. if (output === undefined) {
  3841. if (dimension > 2) {
  3842. // preserve values beyond second dimension
  3843. output = input.slice();
  3844. }
  3845. else {
  3846. output = new Array(length);
  3847. }
  3848. }
  3849. for (var i = 0; i < length; i += dimension) {
  3850. output[i] = (HALF_SIZE * input[i]) / 180;
  3851. var y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));
  3852. if (y > MAX_SAFE_Y) {
  3853. y = MAX_SAFE_Y;
  3854. }
  3855. else if (y < -MAX_SAFE_Y) {
  3856. y = -MAX_SAFE_Y;
  3857. }
  3858. output[i + 1] = y;
  3859. }
  3860. return output;
  3861. }
  3862. /**
  3863. * Transformation from EPSG:3857 to EPSG:4326.
  3864. *
  3865. * @param {Array<number>} input Input array of coordinate values.
  3866. * @param {Array<number>} [opt_output] Output array of coordinate values.
  3867. * @param {number} [opt_dimension] Dimension (default is `2`).
  3868. * @return {Array<number>} Output array of coordinate values.
  3869. */
  3870. function toEPSG4326(input, opt_output, opt_dimension) {
  3871. var length = input.length;
  3872. var dimension = opt_dimension > 1 ? opt_dimension : 2;
  3873. var output = opt_output;
  3874. if (output === undefined) {
  3875. if (dimension > 2) {
  3876. // preserve values beyond second dimension
  3877. output = input.slice();
  3878. }
  3879. else {
  3880. output = new Array(length);
  3881. }
  3882. }
  3883. for (var i = 0; i < length; i += dimension) {
  3884. output[i] = (180 * input[i]) / HALF_SIZE;
  3885. output[i + 1] =
  3886. (360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;
  3887. }
  3888. return output;
  3889. }
  3890. //# sourceMappingURL=epsg3857.js.map
  3891. ;// ./node_modules/ol/proj/epsg4326.js
  3892. var epsg4326_extends = (undefined && undefined.__extends) || (function () {
  3893. var extendStatics = function (d, b) {
  3894. extendStatics = Object.setPrototypeOf ||
  3895. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3896. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3897. return extendStatics(d, b);
  3898. };
  3899. return function (d, b) {
  3900. if (typeof b !== "function" && b !== null)
  3901. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3902. extendStatics(d, b);
  3903. function __() { this.constructor = d; }
  3904. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3905. };
  3906. })();
  3907. /**
  3908. * @module ol/proj/epsg4326
  3909. */
  3910. /**
  3911. * Semi-major radius of the WGS84 ellipsoid.
  3912. *
  3913. * @const
  3914. * @type {number}
  3915. */
  3916. var epsg4326_RADIUS = 6378137;
  3917. /**
  3918. * Extent of the EPSG:4326 projection which is the whole world.
  3919. *
  3920. * @const
  3921. * @type {import("../extent.js").Extent}
  3922. */
  3923. var epsg4326_EXTENT = [-180, -90, 180, 90];
  3924. /**
  3925. * @const
  3926. * @type {number}
  3927. */
  3928. var epsg4326_METERS_PER_UNIT = (Math.PI * epsg4326_RADIUS) / 180;
  3929. /**
  3930. * @classdesc
  3931. * Projection object for WGS84 geographic coordinates (EPSG:4326).
  3932. *
  3933. * Note that OpenLayers does not strictly comply with the EPSG definition.
  3934. * The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).
  3935. * OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.
  3936. */
  3937. var EPSG4326Projection = /** @class */ (function (_super) {
  3938. epsg4326_extends(EPSG4326Projection, _super);
  3939. /**
  3940. * @param {string} code Code.
  3941. * @param {string} [opt_axisOrientation] Axis orientation.
  3942. */
  3943. function EPSG4326Projection(code, opt_axisOrientation) {
  3944. return _super.call(this, {
  3945. code: code,
  3946. units: proj_Units.DEGREES,
  3947. extent: epsg4326_EXTENT,
  3948. axisOrientation: opt_axisOrientation,
  3949. global: true,
  3950. metersPerUnit: epsg4326_METERS_PER_UNIT,
  3951. worldExtent: epsg4326_EXTENT,
  3952. }) || this;
  3953. }
  3954. return EPSG4326Projection;
  3955. }(proj_Projection));
  3956. /**
  3957. * Projections equal to EPSG:4326.
  3958. *
  3959. * @const
  3960. * @type {Array<import("./Projection.js").default>}
  3961. */
  3962. var epsg4326_PROJECTIONS = [
  3963. new EPSG4326Projection('CRS:84'),
  3964. new EPSG4326Projection('EPSG:4326', 'neu'),
  3965. new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),
  3966. new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),
  3967. new EPSG4326Projection('http://www.opengis.net/def/crs/OGC/1.3/CRS84'),
  3968. new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
  3969. new EPSG4326Projection('http://www.opengis.net/def/crs/EPSG/0/4326', 'neu'),
  3970. ];
  3971. //# sourceMappingURL=epsg4326.js.map
  3972. ;// ./node_modules/ol/proj/projections.js
  3973. /**
  3974. * @module ol/proj/projections
  3975. */
  3976. /**
  3977. * @type {Object<string, import("./Projection.js").default>}
  3978. */
  3979. var cache = {};
  3980. /**
  3981. * Clear the projections cache.
  3982. */
  3983. function projections_clear() {
  3984. cache = {};
  3985. }
  3986. /**
  3987. * Get a cached projection by code.
  3988. * @param {string} code The code for the projection.
  3989. * @return {import("./Projection.js").default} The projection (if cached).
  3990. */
  3991. function get(code) {
  3992. return (cache[code] ||
  3993. cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, 'EPSG:$3')] ||
  3994. null);
  3995. }
  3996. /**
  3997. * Add a projection to the cache.
  3998. * @param {string} code The projection code.
  3999. * @param {import("./Projection.js").default} projection The projection to cache.
  4000. */
  4001. function add(code, projection) {
  4002. cache[code] = projection;
  4003. }
  4004. //# sourceMappingURL=projections.js.map
  4005. ;// ./node_modules/ol/proj/transforms.js
  4006. /**
  4007. * @module ol/proj/transforms
  4008. */
  4009. /**
  4010. * @private
  4011. * @type {!Object<string, Object<string, import("../proj.js").TransformFunction>>}
  4012. */
  4013. var transforms = {};
  4014. /**
  4015. * Clear the transform cache.
  4016. */
  4017. function transforms_clear() {
  4018. transforms = {};
  4019. }
  4020. /**
  4021. * Registers a conversion function to convert coordinates from the source
  4022. * projection to the destination projection.
  4023. *
  4024. * @param {import("./Projection.js").default} source Source.
  4025. * @param {import("./Projection.js").default} destination Destination.
  4026. * @param {import("../proj.js").TransformFunction} transformFn Transform.
  4027. */
  4028. function transforms_add(source, destination, transformFn) {
  4029. var sourceCode = source.getCode();
  4030. var destinationCode = destination.getCode();
  4031. if (!(sourceCode in transforms)) {
  4032. transforms[sourceCode] = {};
  4033. }
  4034. transforms[sourceCode][destinationCode] = transformFn;
  4035. }
  4036. /**
  4037. * Unregisters the conversion function to convert coordinates from the source
  4038. * projection to the destination projection. This method is used to clean up
  4039. * cached transforms during testing.
  4040. *
  4041. * @param {import("./Projection.js").default} source Source projection.
  4042. * @param {import("./Projection.js").default} destination Destination projection.
  4043. * @return {import("../proj.js").TransformFunction} transformFn The unregistered transform.
  4044. */
  4045. function transforms_remove(source, destination) {
  4046. var sourceCode = source.getCode();
  4047. var destinationCode = destination.getCode();
  4048. var transform = transforms[sourceCode][destinationCode];
  4049. delete transforms[sourceCode][destinationCode];
  4050. if (isEmpty(transforms[sourceCode])) {
  4051. delete transforms[sourceCode];
  4052. }
  4053. return transform;
  4054. }
  4055. /**
  4056. * Get a transform given a source code and a destination code.
  4057. * @param {string} sourceCode The code for the source projection.
  4058. * @param {string} destinationCode The code for the destination projection.
  4059. * @return {import("../proj.js").TransformFunction|undefined} The transform function (if found).
  4060. */
  4061. function transforms_get(sourceCode, destinationCode) {
  4062. var transform;
  4063. if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
  4064. transform = transforms[sourceCode][destinationCode];
  4065. }
  4066. return transform;
  4067. }
  4068. //# sourceMappingURL=transforms.js.map
  4069. ;// ./node_modules/ol/extent/Relationship.js
  4070. /**
  4071. * @module ol/extent/Relationship
  4072. */
  4073. /**
  4074. * Relationship to an extent.
  4075. * @enum {number}
  4076. */
  4077. /* harmony default export */ var Relationship = ({
  4078. UNKNOWN: 0,
  4079. INTERSECTING: 1,
  4080. ABOVE: 2,
  4081. RIGHT: 4,
  4082. BELOW: 8,
  4083. LEFT: 16,
  4084. });
  4085. //# sourceMappingURL=Relationship.js.map
  4086. ;// ./node_modules/ol/extent.js
  4087. /**
  4088. * @module ol/extent
  4089. */
  4090. /**
  4091. * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`.
  4092. * @typedef {Array<number>} Extent
  4093. * @api
  4094. */
  4095. /**
  4096. * Extent corner.
  4097. * @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner
  4098. */
  4099. /**
  4100. * Build an extent that includes all given coordinates.
  4101. *
  4102. * @param {Array<import("./coordinate.js").Coordinate>} coordinates Coordinates.
  4103. * @return {Extent} Bounding extent.
  4104. * @api
  4105. */
  4106. function boundingExtent(coordinates) {
  4107. var extent = createEmpty();
  4108. for (var i = 0, ii = coordinates.length; i < ii; ++i) {
  4109. extendCoordinate(extent, coordinates[i]);
  4110. }
  4111. return extent;
  4112. }
  4113. /**
  4114. * @param {Array<number>} xs Xs.
  4115. * @param {Array<number>} ys Ys.
  4116. * @param {Extent} [opt_extent] Destination extent.
  4117. * @private
  4118. * @return {Extent} Extent.
  4119. */
  4120. function _boundingExtentXYs(xs, ys, opt_extent) {
  4121. var minX = Math.min.apply(null, xs);
  4122. var minY = Math.min.apply(null, ys);
  4123. var maxX = Math.max.apply(null, xs);
  4124. var maxY = Math.max.apply(null, ys);
  4125. return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
  4126. }
  4127. /**
  4128. * Return extent increased by the provided value.
  4129. * @param {Extent} extent Extent.
  4130. * @param {number} value The amount by which the extent should be buffered.
  4131. * @param {Extent} [opt_extent] Extent.
  4132. * @return {Extent} Extent.
  4133. * @api
  4134. */
  4135. function buffer(extent, value, opt_extent) {
  4136. if (opt_extent) {
  4137. opt_extent[0] = extent[0] - value;
  4138. opt_extent[1] = extent[1] - value;
  4139. opt_extent[2] = extent[2] + value;
  4140. opt_extent[3] = extent[3] + value;
  4141. return opt_extent;
  4142. }
  4143. else {
  4144. return [
  4145. extent[0] - value,
  4146. extent[1] - value,
  4147. extent[2] + value,
  4148. extent[3] + value,
  4149. ];
  4150. }
  4151. }
  4152. /**
  4153. * Creates a clone of an extent.
  4154. *
  4155. * @param {Extent} extent Extent to clone.
  4156. * @param {Extent} [opt_extent] Extent.
  4157. * @return {Extent} The clone.
  4158. */
  4159. function clone(extent, opt_extent) {
  4160. if (opt_extent) {
  4161. opt_extent[0] = extent[0];
  4162. opt_extent[1] = extent[1];
  4163. opt_extent[2] = extent[2];
  4164. opt_extent[3] = extent[3];
  4165. return opt_extent;
  4166. }
  4167. else {
  4168. return extent.slice();
  4169. }
  4170. }
  4171. /**
  4172. * @param {Extent} extent Extent.
  4173. * @param {number} x X.
  4174. * @param {number} y Y.
  4175. * @return {number} Closest squared distance.
  4176. */
  4177. function closestSquaredDistanceXY(extent, x, y) {
  4178. var dx, dy;
  4179. if (x < extent[0]) {
  4180. dx = extent[0] - x;
  4181. }
  4182. else if (extent[2] < x) {
  4183. dx = x - extent[2];
  4184. }
  4185. else {
  4186. dx = 0;
  4187. }
  4188. if (y < extent[1]) {
  4189. dy = extent[1] - y;
  4190. }
  4191. else if (extent[3] < y) {
  4192. dy = y - extent[3];
  4193. }
  4194. else {
  4195. dy = 0;
  4196. }
  4197. return dx * dx + dy * dy;
  4198. }
  4199. /**
  4200. * Check if the passed coordinate is contained or on the edge of the extent.
  4201. *
  4202. * @param {Extent} extent Extent.
  4203. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  4204. * @return {boolean} The coordinate is contained in the extent.
  4205. * @api
  4206. */
  4207. function containsCoordinate(extent, coordinate) {
  4208. return containsXY(extent, coordinate[0], coordinate[1]);
  4209. }
  4210. /**
  4211. * Check if one extent contains another.
  4212. *
  4213. * An extent is deemed contained if it lies completely within the other extent,
  4214. * including if they share one or more edges.
  4215. *
  4216. * @param {Extent} extent1 Extent 1.
  4217. * @param {Extent} extent2 Extent 2.
  4218. * @return {boolean} The second extent is contained by or on the edge of the
  4219. * first.
  4220. * @api
  4221. */
  4222. function containsExtent(extent1, extent2) {
  4223. return (extent1[0] <= extent2[0] &&
  4224. extent2[2] <= extent1[2] &&
  4225. extent1[1] <= extent2[1] &&
  4226. extent2[3] <= extent1[3]);
  4227. }
  4228. /**
  4229. * Check if the passed coordinate is contained or on the edge of the extent.
  4230. *
  4231. * @param {Extent} extent Extent.
  4232. * @param {number} x X coordinate.
  4233. * @param {number} y Y coordinate.
  4234. * @return {boolean} The x, y values are contained in the extent.
  4235. * @api
  4236. */
  4237. function containsXY(extent, x, y) {
  4238. return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];
  4239. }
  4240. /**
  4241. * Get the relationship between a coordinate and extent.
  4242. * @param {Extent} extent The extent.
  4243. * @param {import("./coordinate.js").Coordinate} coordinate The coordinate.
  4244. * @return {import("./extent/Relationship.js").default} The relationship (bitwise compare with
  4245. * import("./extent/Relationship.js").Relationship).
  4246. */
  4247. function coordinateRelationship(extent, coordinate) {
  4248. var minX = extent[0];
  4249. var minY = extent[1];
  4250. var maxX = extent[2];
  4251. var maxY = extent[3];
  4252. var x = coordinate[0];
  4253. var y = coordinate[1];
  4254. var relationship = Relationship.UNKNOWN;
  4255. if (x < minX) {
  4256. relationship = relationship | Relationship.LEFT;
  4257. }
  4258. else if (x > maxX) {
  4259. relationship = relationship | Relationship.RIGHT;
  4260. }
  4261. if (y < minY) {
  4262. relationship = relationship | Relationship.BELOW;
  4263. }
  4264. else if (y > maxY) {
  4265. relationship = relationship | Relationship.ABOVE;
  4266. }
  4267. if (relationship === Relationship.UNKNOWN) {
  4268. relationship = Relationship.INTERSECTING;
  4269. }
  4270. return relationship;
  4271. }
  4272. /**
  4273. * Create an empty extent.
  4274. * @return {Extent} Empty extent.
  4275. * @api
  4276. */
  4277. function createEmpty() {
  4278. return [Infinity, Infinity, -Infinity, -Infinity];
  4279. }
  4280. /**
  4281. * Create a new extent or update the provided extent.
  4282. * @param {number} minX Minimum X.
  4283. * @param {number} minY Minimum Y.
  4284. * @param {number} maxX Maximum X.
  4285. * @param {number} maxY Maximum Y.
  4286. * @param {Extent} [opt_extent] Destination extent.
  4287. * @return {Extent} Extent.
  4288. */
  4289. function createOrUpdate(minX, minY, maxX, maxY, opt_extent) {
  4290. if (opt_extent) {
  4291. opt_extent[0] = minX;
  4292. opt_extent[1] = minY;
  4293. opt_extent[2] = maxX;
  4294. opt_extent[3] = maxY;
  4295. return opt_extent;
  4296. }
  4297. else {
  4298. return [minX, minY, maxX, maxY];
  4299. }
  4300. }
  4301. /**
  4302. * Create a new empty extent or make the provided one empty.
  4303. * @param {Extent} [opt_extent] Extent.
  4304. * @return {Extent} Extent.
  4305. */
  4306. function createOrUpdateEmpty(opt_extent) {
  4307. return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, opt_extent);
  4308. }
  4309. /**
  4310. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  4311. * @param {Extent} [opt_extent] Extent.
  4312. * @return {Extent} Extent.
  4313. */
  4314. function createOrUpdateFromCoordinate(coordinate, opt_extent) {
  4315. var x = coordinate[0];
  4316. var y = coordinate[1];
  4317. return createOrUpdate(x, y, x, y, opt_extent);
  4318. }
  4319. /**
  4320. * @param {Array<import("./coordinate.js").Coordinate>} coordinates Coordinates.
  4321. * @param {Extent} [opt_extent] Extent.
  4322. * @return {Extent} Extent.
  4323. */
  4324. function createOrUpdateFromCoordinates(coordinates, opt_extent) {
  4325. var extent = createOrUpdateEmpty(opt_extent);
  4326. return extendCoordinates(extent, coordinates);
  4327. }
  4328. /**
  4329. * @param {Array<number>} flatCoordinates Flat coordinates.
  4330. * @param {number} offset Offset.
  4331. * @param {number} end End.
  4332. * @param {number} stride Stride.
  4333. * @param {Extent} [opt_extent] Extent.
  4334. * @return {Extent} Extent.
  4335. */
  4336. function createOrUpdateFromFlatCoordinates(flatCoordinates, offset, end, stride, opt_extent) {
  4337. var extent = createOrUpdateEmpty(opt_extent);
  4338. return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);
  4339. }
  4340. /**
  4341. * @param {Array<Array<import("./coordinate.js").Coordinate>>} rings Rings.
  4342. * @param {Extent} [opt_extent] Extent.
  4343. * @return {Extent} Extent.
  4344. */
  4345. function createOrUpdateFromRings(rings, opt_extent) {
  4346. var extent = createOrUpdateEmpty(opt_extent);
  4347. return extendRings(extent, rings);
  4348. }
  4349. /**
  4350. * Determine if two extents are equivalent.
  4351. * @param {Extent} extent1 Extent 1.
  4352. * @param {Extent} extent2 Extent 2.
  4353. * @return {boolean} The two extents are equivalent.
  4354. * @api
  4355. */
  4356. function extent_equals(extent1, extent2) {
  4357. return (extent1[0] == extent2[0] &&
  4358. extent1[2] == extent2[2] &&
  4359. extent1[1] == extent2[1] &&
  4360. extent1[3] == extent2[3]);
  4361. }
  4362. /**
  4363. * Determine if two extents are approximately equivalent.
  4364. * @param {Extent} extent1 Extent 1.
  4365. * @param {Extent} extent2 Extent 2.
  4366. * @param {number} tolerance Tolerance in extent coordinate units.
  4367. * @return {boolean} The two extents differ by less than the tolerance.
  4368. */
  4369. function approximatelyEquals(extent1, extent2, tolerance) {
  4370. return (Math.abs(extent1[0] - extent2[0]) < tolerance &&
  4371. Math.abs(extent1[2] - extent2[2]) < tolerance &&
  4372. Math.abs(extent1[1] - extent2[1]) < tolerance &&
  4373. Math.abs(extent1[3] - extent2[3]) < tolerance);
  4374. }
  4375. /**
  4376. * Modify an extent to include another extent.
  4377. * @param {Extent} extent1 The extent to be modified.
  4378. * @param {Extent} extent2 The extent that will be included in the first.
  4379. * @return {Extent} A reference to the first (extended) extent.
  4380. * @api
  4381. */
  4382. function extent_extend(extent1, extent2) {
  4383. if (extent2[0] < extent1[0]) {
  4384. extent1[0] = extent2[0];
  4385. }
  4386. if (extent2[2] > extent1[2]) {
  4387. extent1[2] = extent2[2];
  4388. }
  4389. if (extent2[1] < extent1[1]) {
  4390. extent1[1] = extent2[1];
  4391. }
  4392. if (extent2[3] > extent1[3]) {
  4393. extent1[3] = extent2[3];
  4394. }
  4395. return extent1;
  4396. }
  4397. /**
  4398. * @param {Extent} extent Extent.
  4399. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  4400. */
  4401. function extendCoordinate(extent, coordinate) {
  4402. if (coordinate[0] < extent[0]) {
  4403. extent[0] = coordinate[0];
  4404. }
  4405. if (coordinate[0] > extent[2]) {
  4406. extent[2] = coordinate[0];
  4407. }
  4408. if (coordinate[1] < extent[1]) {
  4409. extent[1] = coordinate[1];
  4410. }
  4411. if (coordinate[1] > extent[3]) {
  4412. extent[3] = coordinate[1];
  4413. }
  4414. }
  4415. /**
  4416. * @param {Extent} extent Extent.
  4417. * @param {Array<import("./coordinate.js").Coordinate>} coordinates Coordinates.
  4418. * @return {Extent} Extent.
  4419. */
  4420. function extendCoordinates(extent, coordinates) {
  4421. for (var i = 0, ii = coordinates.length; i < ii; ++i) {
  4422. extendCoordinate(extent, coordinates[i]);
  4423. }
  4424. return extent;
  4425. }
  4426. /**
  4427. * @param {Extent} extent Extent.
  4428. * @param {Array<number>} flatCoordinates Flat coordinates.
  4429. * @param {number} offset Offset.
  4430. * @param {number} end End.
  4431. * @param {number} stride Stride.
  4432. * @return {Extent} Extent.
  4433. */
  4434. function extendFlatCoordinates(extent, flatCoordinates, offset, end, stride) {
  4435. for (; offset < end; offset += stride) {
  4436. extendXY(extent, flatCoordinates[offset], flatCoordinates[offset + 1]);
  4437. }
  4438. return extent;
  4439. }
  4440. /**
  4441. * @param {Extent} extent Extent.
  4442. * @param {Array<Array<import("./coordinate.js").Coordinate>>} rings Rings.
  4443. * @return {Extent} Extent.
  4444. */
  4445. function extendRings(extent, rings) {
  4446. for (var i = 0, ii = rings.length; i < ii; ++i) {
  4447. extendCoordinates(extent, rings[i]);
  4448. }
  4449. return extent;
  4450. }
  4451. /**
  4452. * @param {Extent} extent Extent.
  4453. * @param {number} x X.
  4454. * @param {number} y Y.
  4455. */
  4456. function extendXY(extent, x, y) {
  4457. extent[0] = Math.min(extent[0], x);
  4458. extent[1] = Math.min(extent[1], y);
  4459. extent[2] = Math.max(extent[2], x);
  4460. extent[3] = Math.max(extent[3], y);
  4461. }
  4462. /**
  4463. * This function calls `callback` for each corner of the extent. If the
  4464. * callback returns a truthy value the function returns that value
  4465. * immediately. Otherwise the function returns `false`.
  4466. * @param {Extent} extent Extent.
  4467. * @param {function(import("./coordinate.js").Coordinate): S} callback Callback.
  4468. * @return {S|boolean} Value.
  4469. * @template S
  4470. */
  4471. function forEachCorner(extent, callback) {
  4472. var val;
  4473. val = callback(getBottomLeft(extent));
  4474. if (val) {
  4475. return val;
  4476. }
  4477. val = callback(getBottomRight(extent));
  4478. if (val) {
  4479. return val;
  4480. }
  4481. val = callback(getTopRight(extent));
  4482. if (val) {
  4483. return val;
  4484. }
  4485. val = callback(getTopLeft(extent));
  4486. if (val) {
  4487. return val;
  4488. }
  4489. return false;
  4490. }
  4491. /**
  4492. * Get the size of an extent.
  4493. * @param {Extent} extent Extent.
  4494. * @return {number} Area.
  4495. * @api
  4496. */
  4497. function getArea(extent) {
  4498. var area = 0;
  4499. if (!extent_isEmpty(extent)) {
  4500. area = extent_getWidth(extent) * getHeight(extent);
  4501. }
  4502. return area;
  4503. }
  4504. /**
  4505. * Get the bottom left coordinate of an extent.
  4506. * @param {Extent} extent Extent.
  4507. * @return {import("./coordinate.js").Coordinate} Bottom left coordinate.
  4508. * @api
  4509. */
  4510. function getBottomLeft(extent) {
  4511. return [extent[0], extent[1]];
  4512. }
  4513. /**
  4514. * Get the bottom right coordinate of an extent.
  4515. * @param {Extent} extent Extent.
  4516. * @return {import("./coordinate.js").Coordinate} Bottom right coordinate.
  4517. * @api
  4518. */
  4519. function getBottomRight(extent) {
  4520. return [extent[2], extent[1]];
  4521. }
  4522. /**
  4523. * Get the center coordinate of an extent.
  4524. * @param {Extent} extent Extent.
  4525. * @return {import("./coordinate.js").Coordinate} Center.
  4526. * @api
  4527. */
  4528. function getCenter(extent) {
  4529. return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
  4530. }
  4531. /**
  4532. * Get a corner coordinate of an extent.
  4533. * @param {Extent} extent Extent.
  4534. * @param {Corner} corner Corner.
  4535. * @return {import("./coordinate.js").Coordinate} Corner coordinate.
  4536. */
  4537. function getCorner(extent, corner) {
  4538. var coordinate;
  4539. if (corner === 'bottom-left') {
  4540. coordinate = getBottomLeft(extent);
  4541. }
  4542. else if (corner === 'bottom-right') {
  4543. coordinate = getBottomRight(extent);
  4544. }
  4545. else if (corner === 'top-left') {
  4546. coordinate = getTopLeft(extent);
  4547. }
  4548. else if (corner === 'top-right') {
  4549. coordinate = getTopRight(extent);
  4550. }
  4551. else {
  4552. asserts_assert(false, 13); // Invalid corner
  4553. }
  4554. return coordinate;
  4555. }
  4556. /**
  4557. * @param {Extent} extent1 Extent 1.
  4558. * @param {Extent} extent2 Extent 2.
  4559. * @return {number} Enlarged area.
  4560. */
  4561. function getEnlargedArea(extent1, extent2) {
  4562. var minX = Math.min(extent1[0], extent2[0]);
  4563. var minY = Math.min(extent1[1], extent2[1]);
  4564. var maxX = Math.max(extent1[2], extent2[2]);
  4565. var maxY = Math.max(extent1[3], extent2[3]);
  4566. return (maxX - minX) * (maxY - minY);
  4567. }
  4568. /**
  4569. * @param {import("./coordinate.js").Coordinate} center Center.
  4570. * @param {number} resolution Resolution.
  4571. * @param {number} rotation Rotation.
  4572. * @param {import("./size.js").Size} size Size.
  4573. * @param {Extent} [opt_extent] Destination extent.
  4574. * @return {Extent} Extent.
  4575. */
  4576. function getForViewAndSize(center, resolution, rotation, size, opt_extent) {
  4577. var _a = getRotatedViewport(center, resolution, rotation, size), x0 = _a[0], y0 = _a[1], x1 = _a[2], y1 = _a[3], x2 = _a[4], y2 = _a[5], x3 = _a[6], y3 = _a[7];
  4578. return createOrUpdate(Math.min(x0, x1, x2, x3), Math.min(y0, y1, y2, y3), Math.max(x0, x1, x2, x3), Math.max(y0, y1, y2, y3), opt_extent);
  4579. }
  4580. /**
  4581. * @param {import("./coordinate.js").Coordinate} center Center.
  4582. * @param {number} resolution Resolution.
  4583. * @param {number} rotation Rotation.
  4584. * @param {import("./size.js").Size} size Size.
  4585. * @return {Array<number>} Linear ring representing the viewport.
  4586. */
  4587. function getRotatedViewport(center, resolution, rotation, size) {
  4588. var dx = (resolution * size[0]) / 2;
  4589. var dy = (resolution * size[1]) / 2;
  4590. var cosRotation = Math.cos(rotation);
  4591. var sinRotation = Math.sin(rotation);
  4592. var xCos = dx * cosRotation;
  4593. var xSin = dx * sinRotation;
  4594. var yCos = dy * cosRotation;
  4595. var ySin = dy * sinRotation;
  4596. var x = center[0];
  4597. var y = center[1];
  4598. return [
  4599. x - xCos + ySin,
  4600. y - xSin - yCos,
  4601. x - xCos - ySin,
  4602. y - xSin + yCos,
  4603. x + xCos - ySin,
  4604. y + xSin + yCos,
  4605. x + xCos + ySin,
  4606. y + xSin - yCos,
  4607. x - xCos + ySin,
  4608. y - xSin - yCos,
  4609. ];
  4610. }
  4611. /**
  4612. * Get the height of an extent.
  4613. * @param {Extent} extent Extent.
  4614. * @return {number} Height.
  4615. * @api
  4616. */
  4617. function getHeight(extent) {
  4618. return extent[3] - extent[1];
  4619. }
  4620. /**
  4621. * @param {Extent} extent1 Extent 1.
  4622. * @param {Extent} extent2 Extent 2.
  4623. * @return {number} Intersection area.
  4624. */
  4625. function getIntersectionArea(extent1, extent2) {
  4626. var intersection = getIntersection(extent1, extent2);
  4627. return getArea(intersection);
  4628. }
  4629. /**
  4630. * Get the intersection of two extents.
  4631. * @param {Extent} extent1 Extent 1.
  4632. * @param {Extent} extent2 Extent 2.
  4633. * @param {Extent} [opt_extent] Optional extent to populate with intersection.
  4634. * @return {Extent} Intersecting extent.
  4635. * @api
  4636. */
  4637. function getIntersection(extent1, extent2, opt_extent) {
  4638. var intersection = opt_extent ? opt_extent : createEmpty();
  4639. if (intersects(extent1, extent2)) {
  4640. if (extent1[0] > extent2[0]) {
  4641. intersection[0] = extent1[0];
  4642. }
  4643. else {
  4644. intersection[0] = extent2[0];
  4645. }
  4646. if (extent1[1] > extent2[1]) {
  4647. intersection[1] = extent1[1];
  4648. }
  4649. else {
  4650. intersection[1] = extent2[1];
  4651. }
  4652. if (extent1[2] < extent2[2]) {
  4653. intersection[2] = extent1[2];
  4654. }
  4655. else {
  4656. intersection[2] = extent2[2];
  4657. }
  4658. if (extent1[3] < extent2[3]) {
  4659. intersection[3] = extent1[3];
  4660. }
  4661. else {
  4662. intersection[3] = extent2[3];
  4663. }
  4664. }
  4665. else {
  4666. createOrUpdateEmpty(intersection);
  4667. }
  4668. return intersection;
  4669. }
  4670. /**
  4671. * @param {Extent} extent Extent.
  4672. * @return {number} Margin.
  4673. */
  4674. function getMargin(extent) {
  4675. return extent_getWidth(extent) + getHeight(extent);
  4676. }
  4677. /**
  4678. * Get the size (width, height) of an extent.
  4679. * @param {Extent} extent The extent.
  4680. * @return {import("./size.js").Size} The extent size.
  4681. * @api
  4682. */
  4683. function getSize(extent) {
  4684. return [extent[2] - extent[0], extent[3] - extent[1]];
  4685. }
  4686. /**
  4687. * Get the top left coordinate of an extent.
  4688. * @param {Extent} extent Extent.
  4689. * @return {import("./coordinate.js").Coordinate} Top left coordinate.
  4690. * @api
  4691. */
  4692. function getTopLeft(extent) {
  4693. return [extent[0], extent[3]];
  4694. }
  4695. /**
  4696. * Get the top right coordinate of an extent.
  4697. * @param {Extent} extent Extent.
  4698. * @return {import("./coordinate.js").Coordinate} Top right coordinate.
  4699. * @api
  4700. */
  4701. function getTopRight(extent) {
  4702. return [extent[2], extent[3]];
  4703. }
  4704. /**
  4705. * Get the width of an extent.
  4706. * @param {Extent} extent Extent.
  4707. * @return {number} Width.
  4708. * @api
  4709. */
  4710. function extent_getWidth(extent) {
  4711. return extent[2] - extent[0];
  4712. }
  4713. /**
  4714. * Determine if one extent intersects another.
  4715. * @param {Extent} extent1 Extent 1.
  4716. * @param {Extent} extent2 Extent.
  4717. * @return {boolean} The two extents intersect.
  4718. * @api
  4719. */
  4720. function intersects(extent1, extent2) {
  4721. return (extent1[0] <= extent2[2] &&
  4722. extent1[2] >= extent2[0] &&
  4723. extent1[1] <= extent2[3] &&
  4724. extent1[3] >= extent2[1]);
  4725. }
  4726. /**
  4727. * Determine if an extent is empty.
  4728. * @param {Extent} extent Extent.
  4729. * @return {boolean} Is empty.
  4730. * @api
  4731. */
  4732. function extent_isEmpty(extent) {
  4733. return extent[2] < extent[0] || extent[3] < extent[1];
  4734. }
  4735. /**
  4736. * @param {Extent} extent Extent.
  4737. * @param {Extent} [opt_extent] Extent.
  4738. * @return {Extent} Extent.
  4739. */
  4740. function returnOrUpdate(extent, opt_extent) {
  4741. if (opt_extent) {
  4742. opt_extent[0] = extent[0];
  4743. opt_extent[1] = extent[1];
  4744. opt_extent[2] = extent[2];
  4745. opt_extent[3] = extent[3];
  4746. return opt_extent;
  4747. }
  4748. else {
  4749. return extent;
  4750. }
  4751. }
  4752. /**
  4753. * @param {Extent} extent Extent.
  4754. * @param {number} value Value.
  4755. */
  4756. function scaleFromCenter(extent, value) {
  4757. var deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);
  4758. var deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);
  4759. extent[0] -= deltaX;
  4760. extent[2] += deltaX;
  4761. extent[1] -= deltaY;
  4762. extent[3] += deltaY;
  4763. }
  4764. /**
  4765. * Determine if the segment between two coordinates intersects (crosses,
  4766. * touches, or is contained by) the provided extent.
  4767. * @param {Extent} extent The extent.
  4768. * @param {import("./coordinate.js").Coordinate} start Segment start coordinate.
  4769. * @param {import("./coordinate.js").Coordinate} end Segment end coordinate.
  4770. * @return {boolean} The segment intersects the extent.
  4771. */
  4772. function intersectsSegment(extent, start, end) {
  4773. var intersects = false;
  4774. var startRel = coordinateRelationship(extent, start);
  4775. var endRel = coordinateRelationship(extent, end);
  4776. if (startRel === Relationship.INTERSECTING ||
  4777. endRel === Relationship.INTERSECTING) {
  4778. intersects = true;
  4779. }
  4780. else {
  4781. var minX = extent[0];
  4782. var minY = extent[1];
  4783. var maxX = extent[2];
  4784. var maxY = extent[3];
  4785. var startX = start[0];
  4786. var startY = start[1];
  4787. var endX = end[0];
  4788. var endY = end[1];
  4789. var slope = (endY - startY) / (endX - startX);
  4790. var x = void 0, y = void 0;
  4791. if (!!(endRel & Relationship.ABOVE) && !(startRel & Relationship.ABOVE)) {
  4792. // potentially intersects top
  4793. x = endX - (endY - maxY) / slope;
  4794. intersects = x >= minX && x <= maxX;
  4795. }
  4796. if (!intersects &&
  4797. !!(endRel & Relationship.RIGHT) &&
  4798. !(startRel & Relationship.RIGHT)) {
  4799. // potentially intersects right
  4800. y = endY - (endX - maxX) * slope;
  4801. intersects = y >= minY && y <= maxY;
  4802. }
  4803. if (!intersects &&
  4804. !!(endRel & Relationship.BELOW) &&
  4805. !(startRel & Relationship.BELOW)) {
  4806. // potentially intersects bottom
  4807. x = endX - (endY - minY) / slope;
  4808. intersects = x >= minX && x <= maxX;
  4809. }
  4810. if (!intersects &&
  4811. !!(endRel & Relationship.LEFT) &&
  4812. !(startRel & Relationship.LEFT)) {
  4813. // potentially intersects left
  4814. y = endY - (endX - minX) * slope;
  4815. intersects = y >= minY && y <= maxY;
  4816. }
  4817. }
  4818. return intersects;
  4819. }
  4820. /**
  4821. * Apply a transform function to the extent.
  4822. * @param {Extent} extent Extent.
  4823. * @param {import("./proj.js").TransformFunction} transformFn Transform function.
  4824. * Called with `[minX, minY, maxX, maxY]` extent coordinates.
  4825. * @param {Extent} [opt_extent] Destination extent.
  4826. * @param {number} [opt_stops] Number of stops per side used for the transform.
  4827. * By default only the corners are used.
  4828. * @return {Extent} Extent.
  4829. * @api
  4830. */
  4831. function applyTransform(extent, transformFn, opt_extent, opt_stops) {
  4832. var coordinates = [];
  4833. if (opt_stops > 1) {
  4834. var width = extent[2] - extent[0];
  4835. var height = extent[3] - extent[1];
  4836. for (var i = 0; i < opt_stops; ++i) {
  4837. coordinates.push(extent[0] + (width * i) / opt_stops, extent[1], extent[2], extent[1] + (height * i) / opt_stops, extent[2] - (width * i) / opt_stops, extent[3], extent[0], extent[3] - (height * i) / opt_stops);
  4838. }
  4839. }
  4840. else {
  4841. coordinates = [
  4842. extent[0],
  4843. extent[1],
  4844. extent[2],
  4845. extent[1],
  4846. extent[2],
  4847. extent[3],
  4848. extent[0],
  4849. extent[3],
  4850. ];
  4851. }
  4852. transformFn(coordinates, coordinates, 2);
  4853. var xs = [];
  4854. var ys = [];
  4855. for (var i = 0, l = coordinates.length; i < l; i += 2) {
  4856. xs.push(coordinates[i]);
  4857. ys.push(coordinates[i + 1]);
  4858. }
  4859. return _boundingExtentXYs(xs, ys, opt_extent);
  4860. }
  4861. /**
  4862. * Modifies the provided extent in-place to be within the real world
  4863. * extent.
  4864. *
  4865. * @param {Extent} extent Extent.
  4866. * @param {import("./proj/Projection.js").default} projection Projection
  4867. * @return {Extent} The extent within the real world extent.
  4868. */
  4869. function wrapX(extent, projection) {
  4870. var projectionExtent = projection.getExtent();
  4871. var center = getCenter(extent);
  4872. if (projection.canWrapX() &&
  4873. (center[0] < projectionExtent[0] || center[0] >= projectionExtent[2])) {
  4874. var worldWidth = extent_getWidth(projectionExtent);
  4875. var worldsAway = Math.floor((center[0] - projectionExtent[0]) / worldWidth);
  4876. var offset = worldsAway * worldWidth;
  4877. extent[0] -= offset;
  4878. extent[2] -= offset;
  4879. }
  4880. return extent;
  4881. }
  4882. /**
  4883. * Fits the extent to the real world
  4884. *
  4885. * If the extent does not cross the anti meridian, this will return the extent in an array
  4886. * If the extent crosses the anti meridian, the extent will be sliced, so each part fits within the
  4887. * real world
  4888. *
  4889. *
  4890. * @param {Extent} extent Extent.
  4891. * @param {import("./proj/Projection.js").default} projection Projection
  4892. * @return {Array<Extent>} The extent within the real world extent.
  4893. */
  4894. function wrapAndSliceX(extent, projection) {
  4895. if (projection.canWrapX()) {
  4896. var projectionExtent = projection.getExtent();
  4897. if (!isFinite(extent[0]) || !isFinite(extent[2])) {
  4898. return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];
  4899. }
  4900. wrapX(extent, projection);
  4901. var worldWidth = extent_getWidth(projectionExtent);
  4902. if (extent_getWidth(extent) > worldWidth) {
  4903. // the extent wraps around on itself
  4904. return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];
  4905. }
  4906. else if (extent[0] < projectionExtent[0]) {
  4907. // the extent crosses the anti meridian, so it needs to be sliced
  4908. return [
  4909. [extent[0] + worldWidth, extent[1], projectionExtent[2], extent[3]],
  4910. [projectionExtent[0], extent[1], extent[2], extent[3]],
  4911. ];
  4912. }
  4913. else if (extent[2] > projectionExtent[2]) {
  4914. // the extent crosses the anti meridian, so it needs to be sliced
  4915. return [
  4916. [extent[0], extent[1], projectionExtent[2], extent[3]],
  4917. [projectionExtent[0], extent[1], extent[2] - worldWidth, extent[3]],
  4918. ];
  4919. }
  4920. }
  4921. return [extent];
  4922. }
  4923. //# sourceMappingURL=extent.js.map
  4924. ;// ./node_modules/ol/coordinate.js
  4925. /**
  4926. * @module ol/coordinate
  4927. */
  4928. /**
  4929. * An array of numbers representing an xy coordinate. Example: `[16, 48]`.
  4930. * @typedef {Array<number>} Coordinate
  4931. * @api
  4932. */
  4933. /**
  4934. * A function that takes a {@link module:ol/coordinate~Coordinate} and
  4935. * transforms it into a `{string}`.
  4936. *
  4937. * @typedef {function((Coordinate|undefined)): string} CoordinateFormat
  4938. * @api
  4939. */
  4940. /**
  4941. * Add `delta` to `coordinate`. `coordinate` is modified in place and returned
  4942. * by the function.
  4943. *
  4944. * Example:
  4945. *
  4946. * import {add} from 'ol/coordinate';
  4947. *
  4948. * var coord = [7.85, 47.983333];
  4949. * add(coord, [-2, 4]);
  4950. * // coord is now [5.85, 51.983333]
  4951. *
  4952. * @param {Coordinate} coordinate Coordinate.
  4953. * @param {Coordinate} delta Delta.
  4954. * @return {Coordinate} The input coordinate adjusted by
  4955. * the given delta.
  4956. * @api
  4957. */
  4958. function coordinate_add(coordinate, delta) {
  4959. coordinate[0] += +delta[0];
  4960. coordinate[1] += +delta[1];
  4961. return coordinate;
  4962. }
  4963. /**
  4964. * Calculates the point closest to the passed coordinate on the passed circle.
  4965. *
  4966. * @param {Coordinate} coordinate The coordinate.
  4967. * @param {import("./geom/Circle.js").default} circle The circle.
  4968. * @return {Coordinate} Closest point on the circumference.
  4969. */
  4970. function closestOnCircle(coordinate, circle) {
  4971. var r = circle.getRadius();
  4972. var center = circle.getCenter();
  4973. var x0 = center[0];
  4974. var y0 = center[1];
  4975. var x1 = coordinate[0];
  4976. var y1 = coordinate[1];
  4977. var dx = x1 - x0;
  4978. var dy = y1 - y0;
  4979. if (dx === 0 && dy === 0) {
  4980. dx = 1;
  4981. }
  4982. var d = Math.sqrt(dx * dx + dy * dy);
  4983. var x = x0 + (r * dx) / d;
  4984. var y = y0 + (r * dy) / d;
  4985. return [x, y];
  4986. }
  4987. /**
  4988. * Calculates the point closest to the passed coordinate on the passed segment.
  4989. * This is the foot of the perpendicular of the coordinate to the segment when
  4990. * the foot is on the segment, or the closest segment coordinate when the foot
  4991. * is outside the segment.
  4992. *
  4993. * @param {Coordinate} coordinate The coordinate.
  4994. * @param {Array<Coordinate>} segment The two coordinates
  4995. * of the segment.
  4996. * @return {Coordinate} The foot of the perpendicular of
  4997. * the coordinate to the segment.
  4998. */
  4999. function closestOnSegment(coordinate, segment) {
  5000. var x0 = coordinate[0];
  5001. var y0 = coordinate[1];
  5002. var start = segment[0];
  5003. var end = segment[1];
  5004. var x1 = start[0];
  5005. var y1 = start[1];
  5006. var x2 = end[0];
  5007. var y2 = end[1];
  5008. var dx = x2 - x1;
  5009. var dy = y2 - y1;
  5010. var along = dx === 0 && dy === 0
  5011. ? 0
  5012. : (dx * (x0 - x1) + dy * (y0 - y1)) / (dx * dx + dy * dy || 0);
  5013. var x, y;
  5014. if (along <= 0) {
  5015. x = x1;
  5016. y = y1;
  5017. }
  5018. else if (along >= 1) {
  5019. x = x2;
  5020. y = y2;
  5021. }
  5022. else {
  5023. x = x1 + along * dx;
  5024. y = y1 + along * dy;
  5025. }
  5026. return [x, y];
  5027. }
  5028. /**
  5029. * Returns a {@link module:ol/coordinate~CoordinateFormat} function that can be
  5030. * used to format
  5031. * a {Coordinate} to a string.
  5032. *
  5033. * Example without specifying the fractional digits:
  5034. *
  5035. * import {createStringXY} from 'ol/coordinate';
  5036. *
  5037. * var coord = [7.85, 47.983333];
  5038. * var stringifyFunc = createStringXY();
  5039. * var out = stringifyFunc(coord);
  5040. * // out is now '8, 48'
  5041. *
  5042. * Example with explicitly specifying 2 fractional digits:
  5043. *
  5044. * import {createStringXY} from 'ol/coordinate';
  5045. *
  5046. * var coord = [7.85, 47.983333];
  5047. * var stringifyFunc = createStringXY(2);
  5048. * var out = stringifyFunc(coord);
  5049. * // out is now '7.85, 47.98'
  5050. *
  5051. * @param {number} [opt_fractionDigits] The number of digits to include
  5052. * after the decimal point. Default is `0`.
  5053. * @return {CoordinateFormat} Coordinate format.
  5054. * @api
  5055. */
  5056. function createStringXY(opt_fractionDigits) {
  5057. return (
  5058. /**
  5059. * @param {Coordinate} coordinate Coordinate.
  5060. * @return {string} String XY.
  5061. */
  5062. function (coordinate) {
  5063. return toStringXY(coordinate, opt_fractionDigits);
  5064. });
  5065. }
  5066. /**
  5067. * @param {string} hemispheres Hemispheres.
  5068. * @param {number} degrees Degrees.
  5069. * @param {number} [opt_fractionDigits] The number of digits to include
  5070. * after the decimal point. Default is `0`.
  5071. * @return {string} String.
  5072. */
  5073. function degreesToStringHDMS(hemispheres, degrees, opt_fractionDigits) {
  5074. var normalizedDegrees = modulo(degrees + 180, 360) - 180;
  5075. var x = Math.abs(3600 * normalizedDegrees);
  5076. var dflPrecision = opt_fractionDigits || 0;
  5077. var precision = Math.pow(10, dflPrecision);
  5078. var deg = Math.floor(x / 3600);
  5079. var min = Math.floor((x - deg * 3600) / 60);
  5080. var sec = x - deg * 3600 - min * 60;
  5081. sec = Math.ceil(sec * precision) / precision;
  5082. if (sec >= 60) {
  5083. sec = 0;
  5084. min += 1;
  5085. }
  5086. if (min >= 60) {
  5087. min = 0;
  5088. deg += 1;
  5089. }
  5090. return (deg +
  5091. '\u00b0 ' +
  5092. padNumber(min, 2) +
  5093. '\u2032 ' +
  5094. padNumber(sec, 2, dflPrecision) +
  5095. '\u2033' +
  5096. (normalizedDegrees == 0
  5097. ? ''
  5098. : ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0)));
  5099. }
  5100. /**
  5101. * Transforms the given {@link module:ol/coordinate~Coordinate} to a string
  5102. * using the given string template. The strings `{x}` and `{y}` in the template
  5103. * will be replaced with the first and second coordinate values respectively.
  5104. *
  5105. * Example without specifying the fractional digits:
  5106. *
  5107. * import {format} from 'ol/coordinate';
  5108. *
  5109. * var coord = [7.85, 47.983333];
  5110. * var template = 'Coordinate is ({x}|{y}).';
  5111. * var out = format(coord, template);
  5112. * // out is now 'Coordinate is (8|48).'
  5113. *
  5114. * Example explicitly specifying the fractional digits:
  5115. *
  5116. * import {format} from 'ol/coordinate';
  5117. *
  5118. * var coord = [7.85, 47.983333];
  5119. * var template = 'Coordinate is ({x}|{y}).';
  5120. * var out = format(coord, template, 2);
  5121. * // out is now 'Coordinate is (7.85|47.98).'
  5122. *
  5123. * @param {Coordinate} coordinate Coordinate.
  5124. * @param {string} template A template string with `{x}` and `{y}` placeholders
  5125. * that will be replaced by first and second coordinate values.
  5126. * @param {number} [opt_fractionDigits] The number of digits to include
  5127. * after the decimal point. Default is `0`.
  5128. * @return {string} Formatted coordinate.
  5129. * @api
  5130. */
  5131. function format(coordinate, template, opt_fractionDigits) {
  5132. if (coordinate) {
  5133. return template
  5134. .replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
  5135. .replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
  5136. }
  5137. else {
  5138. return '';
  5139. }
  5140. }
  5141. /**
  5142. * @param {Coordinate} coordinate1 First coordinate.
  5143. * @param {Coordinate} coordinate2 Second coordinate.
  5144. * @return {boolean} The two coordinates are equal.
  5145. */
  5146. function coordinate_equals(coordinate1, coordinate2) {
  5147. var equals = true;
  5148. for (var i = coordinate1.length - 1; i >= 0; --i) {
  5149. if (coordinate1[i] != coordinate2[i]) {
  5150. equals = false;
  5151. break;
  5152. }
  5153. }
  5154. return equals;
  5155. }
  5156. /**
  5157. * Rotate `coordinate` by `angle`. `coordinate` is modified in place and
  5158. * returned by the function.
  5159. *
  5160. * Example:
  5161. *
  5162. * import {rotate} from 'ol/coordinate';
  5163. *
  5164. * var coord = [7.85, 47.983333];
  5165. * var rotateRadians = Math.PI / 2; // 90 degrees
  5166. * rotate(coord, rotateRadians);
  5167. * // coord is now [-47.983333, 7.85]
  5168. *
  5169. * @param {Coordinate} coordinate Coordinate.
  5170. * @param {number} angle Angle in radian.
  5171. * @return {Coordinate} Coordinate.
  5172. * @api
  5173. */
  5174. function rotate(coordinate, angle) {
  5175. var cosAngle = Math.cos(angle);
  5176. var sinAngle = Math.sin(angle);
  5177. var x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
  5178. var y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
  5179. coordinate[0] = x;
  5180. coordinate[1] = y;
  5181. return coordinate;
  5182. }
  5183. /**
  5184. * Scale `coordinate` by `scale`. `coordinate` is modified in place and returned
  5185. * by the function.
  5186. *
  5187. * Example:
  5188. *
  5189. * import {scale as scaleCoordinate} from 'ol/coordinate';
  5190. *
  5191. * var coord = [7.85, 47.983333];
  5192. * var scale = 1.2;
  5193. * scaleCoordinate(coord, scale);
  5194. * // coord is now [9.42, 57.5799996]
  5195. *
  5196. * @param {Coordinate} coordinate Coordinate.
  5197. * @param {number} scale Scale factor.
  5198. * @return {Coordinate} Coordinate.
  5199. */
  5200. function scale(coordinate, scale) {
  5201. coordinate[0] *= scale;
  5202. coordinate[1] *= scale;
  5203. return coordinate;
  5204. }
  5205. /**
  5206. * @param {Coordinate} coord1 First coordinate.
  5207. * @param {Coordinate} coord2 Second coordinate.
  5208. * @return {number} Squared distance between coord1 and coord2.
  5209. */
  5210. function coordinate_squaredDistance(coord1, coord2) {
  5211. var dx = coord1[0] - coord2[0];
  5212. var dy = coord1[1] - coord2[1];
  5213. return dx * dx + dy * dy;
  5214. }
  5215. /**
  5216. * @param {Coordinate} coord1 First coordinate.
  5217. * @param {Coordinate} coord2 Second coordinate.
  5218. * @return {number} Distance between coord1 and coord2.
  5219. */
  5220. function distance(coord1, coord2) {
  5221. return Math.sqrt(coordinate_squaredDistance(coord1, coord2));
  5222. }
  5223. /**
  5224. * Calculate the squared distance from a coordinate to a line segment.
  5225. *
  5226. * @param {Coordinate} coordinate Coordinate of the point.
  5227. * @param {Array<Coordinate>} segment Line segment (2
  5228. * coordinates).
  5229. * @return {number} Squared distance from the point to the line segment.
  5230. */
  5231. function squaredDistanceToSegment(coordinate, segment) {
  5232. return coordinate_squaredDistance(coordinate, closestOnSegment(coordinate, segment));
  5233. }
  5234. /**
  5235. * Format a geographic coordinate with the hemisphere, degrees, minutes, and
  5236. * seconds.
  5237. *
  5238. * Example without specifying fractional digits:
  5239. *
  5240. * import {toStringHDMS} from 'ol/coordinate';
  5241. *
  5242. * var coord = [7.85, 47.983333];
  5243. * var out = toStringHDMS(coord);
  5244. * // out is now '47° 58′ 60″ N 7° 50′ 60″ E'
  5245. *
  5246. * Example explicitly specifying 1 fractional digit:
  5247. *
  5248. * import {toStringHDMS} from 'ol/coordinate';
  5249. *
  5250. * var coord = [7.85, 47.983333];
  5251. * var out = toStringHDMS(coord, 1);
  5252. * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'
  5253. *
  5254. * @param {Coordinate} coordinate Coordinate.
  5255. * @param {number} [opt_fractionDigits] The number of digits to include
  5256. * after the decimal point. Default is `0`.
  5257. * @return {string} Hemisphere, degrees, minutes and seconds.
  5258. * @api
  5259. */
  5260. function toStringHDMS(coordinate, opt_fractionDigits) {
  5261. if (coordinate) {
  5262. return (degreesToStringHDMS('NS', coordinate[1], opt_fractionDigits) +
  5263. ' ' +
  5264. degreesToStringHDMS('EW', coordinate[0], opt_fractionDigits));
  5265. }
  5266. else {
  5267. return '';
  5268. }
  5269. }
  5270. /**
  5271. * Format a coordinate as a comma delimited string.
  5272. *
  5273. * Example without specifying fractional digits:
  5274. *
  5275. * import {toStringXY} from 'ol/coordinate';
  5276. *
  5277. * var coord = [7.85, 47.983333];
  5278. * var out = toStringXY(coord);
  5279. * // out is now '8, 48'
  5280. *
  5281. * Example explicitly specifying 1 fractional digit:
  5282. *
  5283. * import {toStringXY} from 'ol/coordinate';
  5284. *
  5285. * var coord = [7.85, 47.983333];
  5286. * var out = toStringXY(coord, 1);
  5287. * // out is now '7.8, 48.0'
  5288. *
  5289. * @param {Coordinate} coordinate Coordinate.
  5290. * @param {number} [opt_fractionDigits] The number of digits to include
  5291. * after the decimal point. Default is `0`.
  5292. * @return {string} XY.
  5293. * @api
  5294. */
  5295. function toStringXY(coordinate, opt_fractionDigits) {
  5296. return format(coordinate, '{x}, {y}', opt_fractionDigits);
  5297. }
  5298. /**
  5299. * Modifies the provided coordinate in-place to be within the real world
  5300. * extent. The lower projection extent boundary is inclusive, the upper one
  5301. * exclusive.
  5302. *
  5303. * @param {Coordinate} coordinate Coordinate.
  5304. * @param {import("./proj/Projection.js").default} projection Projection.
  5305. * @return {Coordinate} The coordinate within the real world extent.
  5306. */
  5307. function coordinate_wrapX(coordinate, projection) {
  5308. if (projection.canWrapX()) {
  5309. var worldWidth = extent_getWidth(projection.getExtent());
  5310. var worldsAway = coordinate_getWorldsAway(coordinate, projection, worldWidth);
  5311. if (worldsAway) {
  5312. coordinate[0] -= worldsAway * worldWidth;
  5313. }
  5314. }
  5315. return coordinate;
  5316. }
  5317. /**
  5318. * @param {Coordinate} coordinate Coordinate.
  5319. * @param {import("./proj/Projection.js").default} projection Projection.
  5320. * @param {number} [opt_sourceExtentWidth] Width of the source extent.
  5321. * @return {number} Offset in world widths.
  5322. */
  5323. function coordinate_getWorldsAway(coordinate, projection, opt_sourceExtentWidth) {
  5324. var projectionExtent = projection.getExtent();
  5325. var worldsAway = 0;
  5326. if (projection.canWrapX() &&
  5327. (coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])) {
  5328. var sourceExtentWidth = opt_sourceExtentWidth || extent_getWidth(projectionExtent);
  5329. worldsAway = Math.floor((coordinate[0] - projectionExtent[0]) / sourceExtentWidth);
  5330. }
  5331. return worldsAway;
  5332. }
  5333. //# sourceMappingURL=coordinate.js.map
  5334. ;// ./node_modules/ol/sphere.js
  5335. /**
  5336. * @module ol/sphere
  5337. */
  5338. /**
  5339. * Object literal with options for the {@link getLength} or {@link getArea}
  5340. * functions.
  5341. * @typedef {Object} SphereMetricOptions
  5342. * @property {import("./proj.js").ProjectionLike} [projection='EPSG:3857']
  5343. * Projection of the geometry. By default, the geometry is assumed to be in
  5344. * Web Mercator.
  5345. * @property {number} [radius=6371008.8] Sphere radius. By default, the
  5346. * [mean Earth radius](https://en.wikipedia.org/wiki/Earth_radius#Mean_radius)
  5347. * for the WGS84 ellipsoid is used.
  5348. */
  5349. /**
  5350. * The mean Earth radius (1/3 * (2a + b)) for the WGS84 ellipsoid.
  5351. * https://en.wikipedia.org/wiki/Earth_radius#Mean_radius
  5352. * @type {number}
  5353. */
  5354. var DEFAULT_RADIUS = 6371008.8;
  5355. /**
  5356. * Get the great circle distance (in meters) between two geographic coordinates.
  5357. * @param {Array} c1 Starting coordinate.
  5358. * @param {Array} c2 Ending coordinate.
  5359. * @param {number} [opt_radius] The sphere radius to use. Defaults to the Earth's
  5360. * mean radius using the WGS84 ellipsoid.
  5361. * @return {number} The great circle distance between the points (in meters).
  5362. * @api
  5363. */
  5364. function getDistance(c1, c2, opt_radius) {
  5365. var radius = opt_radius || DEFAULT_RADIUS;
  5366. var lat1 = math_toRadians(c1[1]);
  5367. var lat2 = math_toRadians(c2[1]);
  5368. var deltaLatBy2 = (lat2 - lat1) / 2;
  5369. var deltaLonBy2 = math_toRadians(c2[0] - c1[0]) / 2;
  5370. var a = Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +
  5371. Math.sin(deltaLonBy2) *
  5372. Math.sin(deltaLonBy2) *
  5373. Math.cos(lat1) *
  5374. Math.cos(lat2);
  5375. return 2 * radius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  5376. }
  5377. /**
  5378. * Get the cumulative great circle length of linestring coordinates (geographic).
  5379. * @param {Array} coordinates Linestring coordinates.
  5380. * @param {number} radius The sphere radius to use.
  5381. * @return {number} The length (in meters).
  5382. */
  5383. function getLengthInternal(coordinates, radius) {
  5384. var length = 0;
  5385. for (var i = 0, ii = coordinates.length; i < ii - 1; ++i) {
  5386. length += getDistance(coordinates[i], coordinates[i + 1], radius);
  5387. }
  5388. return length;
  5389. }
  5390. /**
  5391. * Get the spherical length of a geometry. This length is the sum of the
  5392. * great circle distances between coordinates. For polygons, the length is
  5393. * the sum of all rings. For points, the length is zero. For multi-part
  5394. * geometries, the length is the sum of the length of each part.
  5395. * @param {import("./geom/Geometry.js").default} geometry A geometry.
  5396. * @param {SphereMetricOptions} [opt_options] Options for the
  5397. * length calculation. By default, geometries are assumed to be in 'EPSG:3857'.
  5398. * You can change this by providing a `projection` option.
  5399. * @return {number} The spherical length (in meters).
  5400. * @api
  5401. */
  5402. function getLength(geometry, opt_options) {
  5403. var options = opt_options || {};
  5404. var radius = options.radius || DEFAULT_RADIUS;
  5405. var projection = options.projection || 'EPSG:3857';
  5406. var type = geometry.getType();
  5407. if (type !== 'GeometryCollection') {
  5408. geometry = geometry.clone().transform(projection, 'EPSG:4326');
  5409. }
  5410. var length = 0;
  5411. var coordinates, coords, i, ii, j, jj;
  5412. switch (type) {
  5413. case 'Point':
  5414. case 'MultiPoint': {
  5415. break;
  5416. }
  5417. case 'LineString':
  5418. case 'LinearRing': {
  5419. coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (geometry).getCoordinates();
  5420. length = getLengthInternal(coordinates, radius);
  5421. break;
  5422. }
  5423. case 'MultiLineString':
  5424. case 'Polygon': {
  5425. coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (geometry).getCoordinates();
  5426. for (i = 0, ii = coordinates.length; i < ii; ++i) {
  5427. length += getLengthInternal(coordinates[i], radius);
  5428. }
  5429. break;
  5430. }
  5431. case 'MultiPolygon': {
  5432. coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (geometry).getCoordinates();
  5433. for (i = 0, ii = coordinates.length; i < ii; ++i) {
  5434. coords = coordinates[i];
  5435. for (j = 0, jj = coords.length; j < jj; ++j) {
  5436. length += getLengthInternal(coords[j], radius);
  5437. }
  5438. }
  5439. break;
  5440. }
  5441. case 'GeometryCollection': {
  5442. var geometries =
  5443. /** @type {import("./geom/GeometryCollection.js").default} */ (geometry).getGeometries();
  5444. for (i = 0, ii = geometries.length; i < ii; ++i) {
  5445. length += getLength(geometries[i], opt_options);
  5446. }
  5447. break;
  5448. }
  5449. default: {
  5450. throw new Error('Unsupported geometry type: ' + type);
  5451. }
  5452. }
  5453. return length;
  5454. }
  5455. /**
  5456. * Returns the spherical area for a list of coordinates.
  5457. *
  5458. * [Reference](https://trs.jpl.nasa.gov/handle/2014/40409)
  5459. * Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for
  5460. * Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion
  5461. * Laboratory, Pasadena, CA, June 2007
  5462. *
  5463. * @param {Array<import("./coordinate.js").Coordinate>} coordinates List of coordinates of a linear
  5464. * ring. If the ring is oriented clockwise, the area will be positive,
  5465. * otherwise it will be negative.
  5466. * @param {number} radius The sphere radius.
  5467. * @return {number} Area (in square meters).
  5468. */
  5469. function getAreaInternal(coordinates, radius) {
  5470. var area = 0;
  5471. var len = coordinates.length;
  5472. var x1 = coordinates[len - 1][0];
  5473. var y1 = coordinates[len - 1][1];
  5474. for (var i = 0; i < len; i++) {
  5475. var x2 = coordinates[i][0];
  5476. var y2 = coordinates[i][1];
  5477. area +=
  5478. toRadians(x2 - x1) *
  5479. (2 + Math.sin(toRadians(y1)) + Math.sin(toRadians(y2)));
  5480. x1 = x2;
  5481. y1 = y2;
  5482. }
  5483. return (area * radius * radius) / 2.0;
  5484. }
  5485. /**
  5486. * Get the spherical area of a geometry. This is the area (in meters) assuming
  5487. * that polygon edges are segments of great circles on a sphere.
  5488. * @param {import("./geom/Geometry.js").default} geometry A geometry.
  5489. * @param {SphereMetricOptions} [opt_options] Options for the area
  5490. * calculation. By default, geometries are assumed to be in 'EPSG:3857'.
  5491. * You can change this by providing a `projection` option.
  5492. * @return {number} The spherical area (in square meters).
  5493. * @api
  5494. */
  5495. function sphere_getArea(geometry, opt_options) {
  5496. var options = opt_options || {};
  5497. var radius = options.radius || DEFAULT_RADIUS;
  5498. var projection = options.projection || 'EPSG:3857';
  5499. var type = geometry.getType();
  5500. if (type !== 'GeometryCollection') {
  5501. geometry = geometry.clone().transform(projection, 'EPSG:4326');
  5502. }
  5503. var area = 0;
  5504. var coordinates, coords, i, ii, j, jj;
  5505. switch (type) {
  5506. case 'Point':
  5507. case 'MultiPoint':
  5508. case 'LineString':
  5509. case 'MultiLineString':
  5510. case 'LinearRing': {
  5511. break;
  5512. }
  5513. case 'Polygon': {
  5514. coordinates = /** @type {import("./geom/Polygon.js").default} */ (geometry).getCoordinates();
  5515. area = Math.abs(getAreaInternal(coordinates[0], radius));
  5516. for (i = 1, ii = coordinates.length; i < ii; ++i) {
  5517. area -= Math.abs(getAreaInternal(coordinates[i], radius));
  5518. }
  5519. break;
  5520. }
  5521. case 'MultiPolygon': {
  5522. coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (geometry).getCoordinates();
  5523. for (i = 0, ii = coordinates.length; i < ii; ++i) {
  5524. coords = coordinates[i];
  5525. area += Math.abs(getAreaInternal(coords[0], radius));
  5526. for (j = 1, jj = coords.length; j < jj; ++j) {
  5527. area -= Math.abs(getAreaInternal(coords[j], radius));
  5528. }
  5529. }
  5530. break;
  5531. }
  5532. case 'GeometryCollection': {
  5533. var geometries =
  5534. /** @type {import("./geom/GeometryCollection.js").default} */ (geometry).getGeometries();
  5535. for (i = 0, ii = geometries.length; i < ii; ++i) {
  5536. area += sphere_getArea(geometries[i], opt_options);
  5537. }
  5538. break;
  5539. }
  5540. default: {
  5541. throw new Error('Unsupported geometry type: ' + type);
  5542. }
  5543. }
  5544. return area;
  5545. }
  5546. /**
  5547. * Returns the coordinate at the given distance and bearing from `c1`.
  5548. *
  5549. * @param {import("./coordinate.js").Coordinate} c1 The origin point (`[lon, lat]` in degrees).
  5550. * @param {number} distance The great-circle distance between the origin
  5551. * point and the target point.
  5552. * @param {number} bearing The bearing (in radians).
  5553. * @param {number} [opt_radius] The sphere radius to use. Defaults to the Earth's
  5554. * mean radius using the WGS84 ellipsoid.
  5555. * @return {import("./coordinate.js").Coordinate} The target point.
  5556. */
  5557. function offset(c1, distance, bearing, opt_radius) {
  5558. var radius = opt_radius || DEFAULT_RADIUS;
  5559. var lat1 = toRadians(c1[1]);
  5560. var lon1 = toRadians(c1[0]);
  5561. var dByR = distance / radius;
  5562. var lat = Math.asin(Math.sin(lat1) * Math.cos(dByR) +
  5563. Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing));
  5564. var lon = lon1 +
  5565. Math.atan2(Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1), Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat));
  5566. return [toDegrees(lon), toDegrees(lat)];
  5567. }
  5568. //# sourceMappingURL=sphere.js.map
  5569. ;// ./node_modules/ol/proj.js
  5570. /**
  5571. * @module ol/proj
  5572. */
  5573. /**
  5574. * The ol/proj module stores:
  5575. * * a list of {@link module:ol/proj/Projection~Projection}
  5576. * objects, one for each projection supported by the application
  5577. * * a list of transform functions needed to convert coordinates in one projection
  5578. * into another.
  5579. *
  5580. * The static functions are the methods used to maintain these.
  5581. * Each transform function can handle not only simple coordinate pairs, but also
  5582. * large arrays of coordinates such as vector geometries.
  5583. *
  5584. * When loaded, the library adds projection objects for EPSG:4326 (WGS84
  5585. * geographic coordinates) and EPSG:3857 (Web or Spherical Mercator, as used
  5586. * for example by Bing Maps or OpenStreetMap), together with the relevant
  5587. * transform functions.
  5588. *
  5589. * Additional transforms may be added by using the http://proj4js.org/
  5590. * library (version 2.2 or later). You can use the full build supplied by
  5591. * Proj4js, or create a custom build to support those projections you need; see
  5592. * the Proj4js website for how to do this. You also need the Proj4js definitions
  5593. * for the required projections. These definitions can be obtained from
  5594. * https://epsg.io/, and are a JS function, so can be loaded in a script
  5595. * tag (as in the examples) or pasted into your application.
  5596. *
  5597. * After all required projection definitions are added to proj4's registry (by
  5598. * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`
  5599. * package. Existing transforms are not changed by this function. See
  5600. * examples/wms-image-custom-proj for an example of this.
  5601. *
  5602. * Additional projection definitions can be registered with `proj4.defs()` any
  5603. * time. Just make sure to call `register(proj4)` again; for example, with user-supplied data where you don't
  5604. * know in advance what projections are needed, you can initially load minimal
  5605. * support and then load whichever are requested.
  5606. *
  5607. * Note that Proj4js does not support projection extents. If you want to add
  5608. * one for creating default tile grids, you can add it after the Projection
  5609. * object has been created with `setExtent`, for example,
  5610. * `get('EPSG:1234').setExtent(extent)`.
  5611. *
  5612. * In addition to Proj4js support, any transform functions can be added with
  5613. * {@link module:ol/proj.addCoordinateTransforms}. To use this, you must first create
  5614. * a {@link module:ol/proj/Projection~Projection} object for the new projection and add it with
  5615. * {@link module:ol/proj.addProjection}. You can then add the forward and inverse
  5616. * functions with {@link module:ol/proj.addCoordinateTransforms}. See
  5617. * examples/wms-custom-proj for an example of this.
  5618. *
  5619. * Note that if no transforms are needed and you only need to define the
  5620. * projection, just add a {@link module:ol/proj/Projection~Projection} with
  5621. * {@link module:ol/proj.addProjection}. See examples/wms-no-proj for an example of
  5622. * this.
  5623. */
  5624. /**
  5625. * A projection as {@link module:ol/proj/Projection~Projection}, SRS identifier
  5626. * string or undefined.
  5627. * @typedef {Projection|string|undefined} ProjectionLike
  5628. * @api
  5629. */
  5630. /**
  5631. * A transform function accepts an array of input coordinate values, an optional
  5632. * output array, and an optional dimension (default should be 2). The function
  5633. * transforms the input coordinate values, populates the output array, and
  5634. * returns the output array.
  5635. *
  5636. * @typedef {function(Array<number>, Array<number>=, number=): Array<number>} TransformFunction
  5637. * @api
  5638. */
  5639. var showCoordinateWarning = true;
  5640. /**
  5641. * @param {boolean} [opt_disable = true] Disable console info about `useGeographic()`
  5642. */
  5643. function disableCoordinateWarning(opt_disable) {
  5644. var hide = opt_disable === undefined ? true : opt_disable;
  5645. showCoordinateWarning = !hide;
  5646. }
  5647. /**
  5648. * @param {Array<number>} input Input coordinate array.
  5649. * @param {Array<number>} [opt_output] Output array of coordinate values.
  5650. * @param {number} [opt_dimension] Dimension.
  5651. * @return {Array<number>} Output coordinate array (new array, same coordinate
  5652. * values).
  5653. */
  5654. function cloneTransform(input, opt_output, opt_dimension) {
  5655. var output;
  5656. if (opt_output !== undefined) {
  5657. for (var i = 0, ii = input.length; i < ii; ++i) {
  5658. opt_output[i] = input[i];
  5659. }
  5660. output = opt_output;
  5661. }
  5662. else {
  5663. output = input.slice();
  5664. }
  5665. return output;
  5666. }
  5667. /**
  5668. * @param {Array<number>} input Input coordinate array.
  5669. * @param {Array<number>} [opt_output] Output array of coordinate values.
  5670. * @param {number} [opt_dimension] Dimension.
  5671. * @return {Array<number>} Input coordinate array (same array as input).
  5672. */
  5673. function identityTransform(input, opt_output, opt_dimension) {
  5674. if (opt_output !== undefined && input !== opt_output) {
  5675. for (var i = 0, ii = input.length; i < ii; ++i) {
  5676. opt_output[i] = input[i];
  5677. }
  5678. input = opt_output;
  5679. }
  5680. return input;
  5681. }
  5682. /**
  5683. * Add a Projection object to the list of supported projections that can be
  5684. * looked up by their code.
  5685. *
  5686. * @param {Projection} projection Projection instance.
  5687. * @api
  5688. */
  5689. function addProjection(projection) {
  5690. add(projection.getCode(), projection);
  5691. transforms_add(projection, projection, cloneTransform);
  5692. }
  5693. /**
  5694. * @param {Array<Projection>} projections Projections.
  5695. */
  5696. function addProjections(projections) {
  5697. projections.forEach(addProjection);
  5698. }
  5699. /**
  5700. * Fetches a Projection object for the code specified.
  5701. *
  5702. * @param {ProjectionLike} projectionLike Either a code string which is
  5703. * a combination of authority and identifier such as "EPSG:4326", or an
  5704. * existing projection object, or undefined.
  5705. * @return {Projection|null} Projection object, or null if not in list.
  5706. * @api
  5707. */
  5708. function proj_get(projectionLike) {
  5709. return typeof projectionLike === 'string'
  5710. ? get(/** @type {string} */ (projectionLike))
  5711. : /** @type {Projection} */ (projectionLike) || null;
  5712. }
  5713. /**
  5714. * Get the resolution of the point in degrees or distance units.
  5715. * For projections with degrees as the unit this will simply return the
  5716. * provided resolution. For other projections the point resolution is
  5717. * by default estimated by transforming the `point` pixel to EPSG:4326,
  5718. * measuring its width and height on the normal sphere,
  5719. * and taking the average of the width and height.
  5720. * A custom function can be provided for a specific projection, either
  5721. * by setting the `getPointResolution` option in the
  5722. * {@link module:ol/proj/Projection~Projection} constructor or by using
  5723. * {@link module:ol/proj/Projection~Projection#setGetPointResolution} to change an existing
  5724. * projection object.
  5725. * @param {ProjectionLike} projection The projection.
  5726. * @param {number} resolution Nominal resolution in projection units.
  5727. * @param {import("./coordinate.js").Coordinate} point Point to find adjusted resolution at.
  5728. * @param {import("./proj/Units.js").default} [opt_units] Units to get the point resolution in.
  5729. * Default is the projection's units.
  5730. * @return {number} Point resolution.
  5731. * @api
  5732. */
  5733. function getPointResolution(projection, resolution, point, opt_units) {
  5734. projection = proj_get(projection);
  5735. var pointResolution;
  5736. var getter = projection.getPointResolutionFunc();
  5737. if (getter) {
  5738. pointResolution = getter(resolution, point);
  5739. if (opt_units && opt_units !== projection.getUnits()) {
  5740. var metersPerUnit = projection.getMetersPerUnit();
  5741. if (metersPerUnit) {
  5742. pointResolution =
  5743. (pointResolution * metersPerUnit) / Units_METERS_PER_UNIT[opt_units];
  5744. }
  5745. }
  5746. }
  5747. else {
  5748. var units = projection.getUnits();
  5749. if ((units == proj_Units.DEGREES && !opt_units) || opt_units == proj_Units.DEGREES) {
  5750. pointResolution = resolution;
  5751. }
  5752. else {
  5753. // Estimate point resolution by transforming the center pixel to EPSG:4326,
  5754. // measuring its width and height on the normal sphere, and taking the
  5755. // average of the width and height.
  5756. var toEPSG4326_1 = getTransformFromProjections(projection, proj_get('EPSG:4326'));
  5757. if (toEPSG4326_1 === identityTransform && units !== proj_Units.DEGREES) {
  5758. // no transform is available
  5759. pointResolution = resolution * projection.getMetersPerUnit();
  5760. }
  5761. else {
  5762. var vertices = [
  5763. point[0] - resolution / 2,
  5764. point[1],
  5765. point[0] + resolution / 2,
  5766. point[1],
  5767. point[0],
  5768. point[1] - resolution / 2,
  5769. point[0],
  5770. point[1] + resolution / 2,
  5771. ];
  5772. vertices = toEPSG4326_1(vertices, vertices, 2);
  5773. var width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));
  5774. var height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));
  5775. pointResolution = (width + height) / 2;
  5776. }
  5777. var metersPerUnit = opt_units
  5778. ? Units_METERS_PER_UNIT[opt_units]
  5779. : projection.getMetersPerUnit();
  5780. if (metersPerUnit !== undefined) {
  5781. pointResolution /= metersPerUnit;
  5782. }
  5783. }
  5784. }
  5785. return pointResolution;
  5786. }
  5787. /**
  5788. * Registers transformation functions that don't alter coordinates. Those allow
  5789. * to transform between projections with equal meaning.
  5790. *
  5791. * @param {Array<Projection>} projections Projections.
  5792. * @api
  5793. */
  5794. function addEquivalentProjections(projections) {
  5795. addProjections(projections);
  5796. projections.forEach(function (source) {
  5797. projections.forEach(function (destination) {
  5798. if (source !== destination) {
  5799. transforms_add(source, destination, cloneTransform);
  5800. }
  5801. });
  5802. });
  5803. }
  5804. /**
  5805. * Registers transformation functions to convert coordinates in any projection
  5806. * in projection1 to any projection in projection2.
  5807. *
  5808. * @param {Array<Projection>} projections1 Projections with equal
  5809. * meaning.
  5810. * @param {Array<Projection>} projections2 Projections with equal
  5811. * meaning.
  5812. * @param {TransformFunction} forwardTransform Transformation from any
  5813. * projection in projection1 to any projection in projection2.
  5814. * @param {TransformFunction} inverseTransform Transform from any projection
  5815. * in projection2 to any projection in projection1..
  5816. */
  5817. function addEquivalentTransforms(projections1, projections2, forwardTransform, inverseTransform) {
  5818. projections1.forEach(function (projection1) {
  5819. projections2.forEach(function (projection2) {
  5820. transforms_add(projection1, projection2, forwardTransform);
  5821. transforms_add(projection2, projection1, inverseTransform);
  5822. });
  5823. });
  5824. }
  5825. /**
  5826. * Clear all cached projections and transforms.
  5827. */
  5828. function clearAllProjections() {
  5829. clearProj();
  5830. clearTransformFuncs();
  5831. }
  5832. /**
  5833. * @param {Projection|string|undefined} projection Projection.
  5834. * @param {string} defaultCode Default code.
  5835. * @return {Projection} Projection.
  5836. */
  5837. function createProjection(projection, defaultCode) {
  5838. if (!projection) {
  5839. return proj_get(defaultCode);
  5840. }
  5841. else if (typeof projection === 'string') {
  5842. return proj_get(projection);
  5843. }
  5844. else {
  5845. return /** @type {Projection} */ (projection);
  5846. }
  5847. }
  5848. /**
  5849. * Creates a {@link module:ol/proj~TransformFunction} from a simple 2D coordinate transform
  5850. * function.
  5851. * @param {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} coordTransform Coordinate
  5852. * transform.
  5853. * @return {TransformFunction} Transform function.
  5854. */
  5855. function createTransformFromCoordinateTransform(coordTransform) {
  5856. return (
  5857. /**
  5858. * @param {Array<number>} input Input.
  5859. * @param {Array<number>} [opt_output] Output.
  5860. * @param {number} [opt_dimension] Dimension.
  5861. * @return {Array<number>} Output.
  5862. */
  5863. function (input, opt_output, opt_dimension) {
  5864. var length = input.length;
  5865. var dimension = opt_dimension !== undefined ? opt_dimension : 2;
  5866. var output = opt_output !== undefined ? opt_output : new Array(length);
  5867. for (var i = 0; i < length; i += dimension) {
  5868. var point = coordTransform(input.slice(i, i + dimension));
  5869. var pointLength = point.length;
  5870. for (var j = 0, jj = dimension; j < jj; ++j) {
  5871. output[i + j] = j >= pointLength ? input[i + j] : point[j];
  5872. }
  5873. }
  5874. return output;
  5875. });
  5876. }
  5877. /**
  5878. * Registers coordinate transform functions to convert coordinates between the
  5879. * source projection and the destination projection.
  5880. * The forward and inverse functions convert coordinate pairs; this function
  5881. * converts these into the functions used internally which also handle
  5882. * extents and coordinate arrays.
  5883. *
  5884. * @param {ProjectionLike} source Source projection.
  5885. * @param {ProjectionLike} destination Destination projection.
  5886. * @param {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} forward The forward transform
  5887. * function (that is, from the source projection to the destination
  5888. * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns
  5889. * the transformed {@link module:ol/coordinate~Coordinate}.
  5890. * @param {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} inverse The inverse transform
  5891. * function (that is, from the destination projection to the source
  5892. * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns
  5893. * the transformed {@link module:ol/coordinate~Coordinate}. If the transform function can only
  5894. * transform less dimensions than the input coordinate, it is supposeed to return a coordinate
  5895. * with only the length it can transform. The other dimensions will be taken unchanged from the
  5896. * source.
  5897. * @api
  5898. */
  5899. function addCoordinateTransforms(source, destination, forward, inverse) {
  5900. var sourceProj = proj_get(source);
  5901. var destProj = proj_get(destination);
  5902. addTransformFunc(sourceProj, destProj, createTransformFromCoordinateTransform(forward));
  5903. addTransformFunc(destProj, sourceProj, createTransformFromCoordinateTransform(inverse));
  5904. }
  5905. /**
  5906. * Transforms a coordinate from longitude/latitude to a different projection.
  5907. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate as longitude and latitude, i.e.
  5908. * an array with longitude as 1st and latitude as 2nd element.
  5909. * @param {ProjectionLike} [opt_projection] Target projection. The
  5910. * default is Web Mercator, i.e. 'EPSG:3857'.
  5911. * @return {import("./coordinate.js").Coordinate} Coordinate projected to the target projection.
  5912. * @api
  5913. */
  5914. function fromLonLat(coordinate, opt_projection) {
  5915. disableCoordinateWarning();
  5916. return transform(coordinate, 'EPSG:4326', opt_projection !== undefined ? opt_projection : 'EPSG:3857');
  5917. }
  5918. /**
  5919. * Transforms a coordinate to longitude/latitude.
  5920. * @param {import("./coordinate.js").Coordinate} coordinate Projected coordinate.
  5921. * @param {ProjectionLike} [opt_projection] Projection of the coordinate.
  5922. * The default is Web Mercator, i.e. 'EPSG:3857'.
  5923. * @return {import("./coordinate.js").Coordinate} Coordinate as longitude and latitude, i.e. an array
  5924. * with longitude as 1st and latitude as 2nd element.
  5925. * @api
  5926. */
  5927. function toLonLat(coordinate, opt_projection) {
  5928. var lonLat = transform(coordinate, opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326');
  5929. var lon = lonLat[0];
  5930. if (lon < -180 || lon > 180) {
  5931. lonLat[0] = modulo(lon + 180, 360) - 180;
  5932. }
  5933. return lonLat;
  5934. }
  5935. /**
  5936. * Checks if two projections are the same, that is every coordinate in one
  5937. * projection does represent the same geographic point as the same coordinate in
  5938. * the other projection.
  5939. *
  5940. * @param {Projection} projection1 Projection 1.
  5941. * @param {Projection} projection2 Projection 2.
  5942. * @return {boolean} Equivalent.
  5943. * @api
  5944. */
  5945. function equivalent(projection1, projection2) {
  5946. if (projection1 === projection2) {
  5947. return true;
  5948. }
  5949. var equalUnits = projection1.getUnits() === projection2.getUnits();
  5950. if (projection1.getCode() === projection2.getCode()) {
  5951. return equalUnits;
  5952. }
  5953. else {
  5954. var transformFunc = getTransformFromProjections(projection1, projection2);
  5955. return transformFunc === cloneTransform && equalUnits;
  5956. }
  5957. }
  5958. /**
  5959. * Searches in the list of transform functions for the function for converting
  5960. * coordinates from the source projection to the destination projection.
  5961. *
  5962. * @param {Projection} sourceProjection Source Projection object.
  5963. * @param {Projection} destinationProjection Destination Projection
  5964. * object.
  5965. * @return {TransformFunction} Transform function.
  5966. */
  5967. function getTransformFromProjections(sourceProjection, destinationProjection) {
  5968. var sourceCode = sourceProjection.getCode();
  5969. var destinationCode = destinationProjection.getCode();
  5970. var transformFunc = transforms_get(sourceCode, destinationCode);
  5971. if (!transformFunc) {
  5972. transformFunc = identityTransform;
  5973. }
  5974. return transformFunc;
  5975. }
  5976. /**
  5977. * Given the projection-like objects, searches for a transformation
  5978. * function to convert a coordinates array from the source projection to the
  5979. * destination projection.
  5980. *
  5981. * @param {ProjectionLike} source Source.
  5982. * @param {ProjectionLike} destination Destination.
  5983. * @return {TransformFunction} Transform function.
  5984. * @api
  5985. */
  5986. function getTransform(source, destination) {
  5987. var sourceProjection = proj_get(source);
  5988. var destinationProjection = proj_get(destination);
  5989. return getTransformFromProjections(sourceProjection, destinationProjection);
  5990. }
  5991. /**
  5992. * Transforms a coordinate from source projection to destination projection.
  5993. * This returns a new coordinate (and does not modify the original).
  5994. *
  5995. * See {@link module:ol/proj.transformExtent} for extent transformation.
  5996. * See the transform method of {@link module:ol/geom/Geometry~Geometry} and its
  5997. * subclasses for geometry transforms.
  5998. *
  5999. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  6000. * @param {ProjectionLike} source Source projection-like.
  6001. * @param {ProjectionLike} destination Destination projection-like.
  6002. * @return {import("./coordinate.js").Coordinate} Coordinate.
  6003. * @api
  6004. */
  6005. function transform(coordinate, source, destination) {
  6006. var transformFunc = getTransform(source, destination);
  6007. return transformFunc(coordinate, undefined, coordinate.length);
  6008. }
  6009. /**
  6010. * Transforms an extent from source projection to destination projection. This
  6011. * returns a new extent (and does not modify the original).
  6012. *
  6013. * @param {import("./extent.js").Extent} extent The extent to transform.
  6014. * @param {ProjectionLike} source Source projection-like.
  6015. * @param {ProjectionLike} destination Destination projection-like.
  6016. * @param {number} [opt_stops] Number of stops per side used for the transform.
  6017. * By default only the corners are used.
  6018. * @return {import("./extent.js").Extent} The transformed extent.
  6019. * @api
  6020. */
  6021. function transformExtent(extent, source, destination, opt_stops) {
  6022. var transformFunc = getTransform(source, destination);
  6023. return applyTransform(extent, transformFunc, undefined, opt_stops);
  6024. }
  6025. /**
  6026. * Transforms the given point to the destination projection.
  6027. *
  6028. * @param {import("./coordinate.js").Coordinate} point Point.
  6029. * @param {Projection} sourceProjection Source projection.
  6030. * @param {Projection} destinationProjection Destination projection.
  6031. * @return {import("./coordinate.js").Coordinate} Point.
  6032. */
  6033. function transformWithProjections(point, sourceProjection, destinationProjection) {
  6034. var transformFunc = getTransformFromProjections(sourceProjection, destinationProjection);
  6035. return transformFunc(point);
  6036. }
  6037. /**
  6038. * @type {Projection|null}
  6039. */
  6040. var userProjection = null;
  6041. /**
  6042. * Set the projection for coordinates supplied from and returned by API methods.
  6043. * This includes all API methods except for those interacting with tile grids.
  6044. * @param {ProjectionLike} projection The user projection.
  6045. * @api
  6046. */
  6047. function setUserProjection(projection) {
  6048. userProjection = proj_get(projection);
  6049. }
  6050. /**
  6051. * Clear the user projection if set.
  6052. * @api
  6053. */
  6054. function clearUserProjection() {
  6055. userProjection = null;
  6056. }
  6057. /**
  6058. * Get the projection for coordinates supplied from and returned by API methods.
  6059. * Note that this method is not yet a part of the stable API. Support for user
  6060. * projections is not yet complete and should be considered experimental.
  6061. * @return {Projection|null} The user projection (or null if not set).
  6062. * @api
  6063. */
  6064. function getUserProjection() {
  6065. return userProjection;
  6066. }
  6067. /**
  6068. * Use geographic coordinates (WGS-84 datum) in API methods. This includes all API
  6069. * methods except for those interacting with tile grids.
  6070. * @api
  6071. */
  6072. function useGeographic() {
  6073. setUserProjection('EPSG:4326');
  6074. }
  6075. /**
  6076. * Return a coordinate transformed into the user projection. If no user projection
  6077. * is set, the original coordinate is returned.
  6078. * @param {Array<number>} coordinate Input coordinate.
  6079. * @param {ProjectionLike} sourceProjection The input coordinate projection.
  6080. * @return {Array<number>} The input coordinate in the user projection.
  6081. */
  6082. function toUserCoordinate(coordinate, sourceProjection) {
  6083. if (!userProjection) {
  6084. return coordinate;
  6085. }
  6086. return transform(coordinate, sourceProjection, userProjection);
  6087. }
  6088. /**
  6089. * Return a coordinate transformed from the user projection. If no user projection
  6090. * is set, the original coordinate is returned.
  6091. * @param {Array<number>} coordinate Input coordinate.
  6092. * @param {ProjectionLike} destProjection The destination projection.
  6093. * @return {Array<number>} The input coordinate transformed.
  6094. */
  6095. function fromUserCoordinate(coordinate, destProjection) {
  6096. if (!userProjection) {
  6097. if (showCoordinateWarning &&
  6098. !coordinate_equals(coordinate, [0, 0]) &&
  6099. coordinate[0] >= -180 &&
  6100. coordinate[0] <= 180 &&
  6101. coordinate[1] >= -90 &&
  6102. coordinate[1] <= 90) {
  6103. showCoordinateWarning = false;
  6104. // eslint-disable-next-line no-console
  6105. console.warn('Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.');
  6106. }
  6107. return coordinate;
  6108. }
  6109. return transform(coordinate, userProjection, destProjection);
  6110. }
  6111. /**
  6112. * Return an extent transformed into the user projection. If no user projection
  6113. * is set, the original extent is returned.
  6114. * @param {import("./extent.js").Extent} extent Input extent.
  6115. * @param {ProjectionLike} sourceProjection The input extent projection.
  6116. * @return {import("./extent.js").Extent} The input extent in the user projection.
  6117. */
  6118. function proj_toUserExtent(extent, sourceProjection) {
  6119. if (!userProjection) {
  6120. return extent;
  6121. }
  6122. return transformExtent(extent, sourceProjection, userProjection);
  6123. }
  6124. /**
  6125. * Return an extent transformed from the user projection. If no user projection
  6126. * is set, the original extent is returned.
  6127. * @param {import("./extent.js").Extent} extent Input extent.
  6128. * @param {ProjectionLike} destProjection The destination projection.
  6129. * @return {import("./extent.js").Extent} The input extent transformed.
  6130. */
  6131. function proj_fromUserExtent(extent, destProjection) {
  6132. if (!userProjection) {
  6133. return extent;
  6134. }
  6135. return transformExtent(extent, userProjection, destProjection);
  6136. }
  6137. /**
  6138. * Return the resolution in user projection units per pixel. If no user projection
  6139. * is set, or source or user projection are missing units, the original resolution
  6140. * is returned.
  6141. * @param {number} resolution Resolution in input projection units per pixel.
  6142. * @param {ProjectionLike} sourceProjection The input projection.
  6143. * @return {number} Resolution in user projection units per pixel.
  6144. */
  6145. function toUserResolution(resolution, sourceProjection) {
  6146. if (!userProjection) {
  6147. return resolution;
  6148. }
  6149. var sourceUnits = proj_get(sourceProjection).getUnits();
  6150. var userUnits = userProjection.getUnits();
  6151. return sourceUnits && userUnits
  6152. ? (resolution * Units_METERS_PER_UNIT[sourceUnits]) / Units_METERS_PER_UNIT[userUnits]
  6153. : resolution;
  6154. }
  6155. /**
  6156. * Return the resolution in user projection units per pixel. If no user projection
  6157. * is set, or source or user projection are missing units, the original resolution
  6158. * is returned.
  6159. * @param {number} resolution Resolution in user projection units per pixel.
  6160. * @param {ProjectionLike} destProjection The destination projection.
  6161. * @return {number} Resolution in destination projection units per pixel.
  6162. */
  6163. function proj_fromUserResolution(resolution, destProjection) {
  6164. if (!userProjection) {
  6165. return resolution;
  6166. }
  6167. var sourceUnits = proj_get(destProjection).getUnits();
  6168. var userUnits = userProjection.getUnits();
  6169. return sourceUnits && userUnits
  6170. ? (resolution * METERS_PER_UNIT[userUnits]) / METERS_PER_UNIT[sourceUnits]
  6171. : resolution;
  6172. }
  6173. /**
  6174. * Creates a safe coordinate transform function from a coordinate transform function.
  6175. * "Safe" means that it can handle wrapping of x-coordinates for global projections,
  6176. * and that coordinates exceeding the source projection validity extent's range will be
  6177. * clamped to the validity range.
  6178. * @param {Projection} sourceProj Source projection.
  6179. * @param {Projection} destProj Destination projection.
  6180. * @param {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} transform Transform function (source to destiation).
  6181. * @return {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} Safe transform function (source to destiation).
  6182. */
  6183. function createSafeCoordinateTransform(sourceProj, destProj, transform) {
  6184. return function (coord) {
  6185. var transformed, worldsAway;
  6186. if (sourceProj.canWrapX()) {
  6187. var sourceExtent = sourceProj.getExtent();
  6188. var sourceExtentWidth = getWidth(sourceExtent);
  6189. coord = coord.slice(0);
  6190. worldsAway = getWorldsAway(coord, sourceProj, sourceExtentWidth);
  6191. if (worldsAway) {
  6192. // Move x to the real world
  6193. coord[0] = coord[0] - worldsAway * sourceExtentWidth;
  6194. }
  6195. coord[0] = clamp(coord[0], sourceExtent[0], sourceExtent[2]);
  6196. coord[1] = clamp(coord[1], sourceExtent[1], sourceExtent[3]);
  6197. transformed = transform(coord);
  6198. }
  6199. else {
  6200. transformed = transform(coord);
  6201. }
  6202. if (worldsAway && destProj.canWrapX()) {
  6203. // Move transformed coordinate back to the offset world
  6204. transformed[0] += worldsAway * getWidth(destProj.getExtent());
  6205. }
  6206. return transformed;
  6207. };
  6208. }
  6209. /**
  6210. * Add transforms to and from EPSG:4326 and EPSG:3857. This function is called
  6211. * by when this module is executed and should only need to be called again after
  6212. * `clearAllProjections()` is called (e.g. in tests).
  6213. */
  6214. function addCommon() {
  6215. // Add transformations that don't alter coordinates to convert within set of
  6216. // projections with equal meaning.
  6217. addEquivalentProjections(PROJECTIONS);
  6218. addEquivalentProjections(epsg4326_PROJECTIONS);
  6219. // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
  6220. // coordinates and back.
  6221. addEquivalentTransforms(epsg4326_PROJECTIONS, PROJECTIONS, fromEPSG4326, toEPSG4326);
  6222. }
  6223. addCommon();
  6224. //# sourceMappingURL=proj.js.map
  6225. ;// ./node_modules/ol/control/MousePosition.js
  6226. /**
  6227. * @module ol/control/MousePosition
  6228. */
  6229. var MousePosition_extends = (undefined && undefined.__extends) || (function () {
  6230. var extendStatics = function (d, b) {
  6231. extendStatics = Object.setPrototypeOf ||
  6232. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6233. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  6234. return extendStatics(d, b);
  6235. };
  6236. return function (d, b) {
  6237. if (typeof b !== "function" && b !== null)
  6238. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  6239. extendStatics(d, b);
  6240. function __() { this.constructor = d; }
  6241. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6242. };
  6243. })();
  6244. /**
  6245. * @type {string}
  6246. */
  6247. var PROJECTION = 'projection';
  6248. /**
  6249. * @type {string}
  6250. */
  6251. var COORDINATE_FORMAT = 'coordinateFormat';
  6252. /***
  6253. * @template Return
  6254. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  6255. * import("../Observable").OnSignature<import("../ObjectEventType").Types|
  6256. * 'change:coordinateFormat'|'change:projection', import("../Object").ObjectEvent, Return> &
  6257. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
  6258. * 'change:coordinateFormat'|'change:projection', Return>} MousePositionOnSignature
  6259. */
  6260. /**
  6261. * @typedef {Object} Options
  6262. * @property {string} [className='ol-mouse-position'] CSS class name.
  6263. * @property {import("../coordinate.js").CoordinateFormat} [coordinateFormat] Coordinate format.
  6264. * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
  6265. * @property {function(import("../MapEvent.js").default):void} [render] Function called when the
  6266. * control should be re-rendered. This is called in a `requestAnimationFrame`
  6267. * callback.
  6268. * @property {HTMLElement|string} [target] Specify a target if you want the
  6269. * control to be rendered outside of the map's viewport.
  6270. * @property {string|boolean} [placeholder] Markup to show when the mouse position is not
  6271. * available (e.g. when the pointer leaves the map viewport). By default, a non-breaking space
  6272. * is rendered when the mouse leaves the viewport. To render something else, provide a string
  6273. * to be used as the text content (e.g. 'no position' or '' for an empty string). Set the placeholder
  6274. * to `false` to retain the last position when the mouse leaves the viewport. In a future release, this
  6275. * will be the default behavior.
  6276. * @property {string} [undefinedHTML='&#160;'] This option is deprecated. Use the `placeholder` option instead.
  6277. */
  6278. /**
  6279. * @classdesc
  6280. * A control to show the 2D coordinates of the mouse cursor. By default, these
  6281. * are in the view projection, but can be in any supported projection.
  6282. * By default the control is shown in the top right corner of the map, but this
  6283. * can be changed by using the css selector `.ol-mouse-position`.
  6284. *
  6285. * On touch devices, which usually do not have a mouse cursor, the coordinates
  6286. * of the currently touched position are shown.
  6287. *
  6288. * @api
  6289. */
  6290. var MousePosition = /** @class */ (function (_super) {
  6291. MousePosition_extends(MousePosition, _super);
  6292. /**
  6293. * @param {Options} [opt_options] Mouse position options.
  6294. */
  6295. function MousePosition(opt_options) {
  6296. var _this = this;
  6297. var options = opt_options ? opt_options : {};
  6298. var element = document.createElement('div');
  6299. element.className =
  6300. options.className !== undefined ? options.className : 'ol-mouse-position';
  6301. _this = _super.call(this, {
  6302. element: element,
  6303. render: options.render,
  6304. target: options.target,
  6305. }) || this;
  6306. /***
  6307. * @type {MousePositionOnSignature<import("../events").EventsKey>}
  6308. */
  6309. _this.on;
  6310. /***
  6311. * @type {MousePositionOnSignature<import("../events").EventsKey>}
  6312. */
  6313. _this.once;
  6314. /***
  6315. * @type {MousePositionOnSignature<void>}
  6316. */
  6317. _this.un;
  6318. _this.addChangeListener(PROJECTION, _this.handleProjectionChanged_);
  6319. if (options.coordinateFormat) {
  6320. _this.setCoordinateFormat(options.coordinateFormat);
  6321. }
  6322. if (options.projection) {
  6323. _this.setProjection(options.projection);
  6324. }
  6325. /**
  6326. * Change this to `false` when removing the deprecated `undefinedHTML` option.
  6327. * @type {boolean}
  6328. */
  6329. var renderOnMouseOut = true;
  6330. /**
  6331. * @type {string}
  6332. */
  6333. var placeholder = '&#160;';
  6334. if ('undefinedHTML' in options) {
  6335. // deprecated behavior
  6336. if (options.undefinedHTML !== undefined) {
  6337. placeholder = options.undefinedHTML;
  6338. }
  6339. renderOnMouseOut = !!placeholder;
  6340. }
  6341. else if ('placeholder' in options) {
  6342. if (options.placeholder === false) {
  6343. renderOnMouseOut = false;
  6344. }
  6345. else {
  6346. placeholder = String(options.placeholder);
  6347. }
  6348. }
  6349. /**
  6350. * @private
  6351. * @type {string}
  6352. */
  6353. _this.placeholder_ = placeholder;
  6354. /**
  6355. * @private
  6356. * @type {boolean}
  6357. */
  6358. _this.renderOnMouseOut_ = renderOnMouseOut;
  6359. /**
  6360. * @private
  6361. * @type {string}
  6362. */
  6363. _this.renderedHTML_ = element.innerHTML;
  6364. /**
  6365. * @private
  6366. * @type {?import("../proj/Projection.js").default}
  6367. */
  6368. _this.mapProjection_ = null;
  6369. /**
  6370. * @private
  6371. * @type {?import("../proj.js").TransformFunction}
  6372. */
  6373. _this.transform_ = null;
  6374. return _this;
  6375. }
  6376. /**
  6377. * @private
  6378. */
  6379. MousePosition.prototype.handleProjectionChanged_ = function () {
  6380. this.transform_ = null;
  6381. };
  6382. /**
  6383. * Return the coordinate format type used to render the current position or
  6384. * undefined.
  6385. * @return {import("../coordinate.js").CoordinateFormat|undefined} The format to render the current
  6386. * position in.
  6387. * @observable
  6388. * @api
  6389. */
  6390. MousePosition.prototype.getCoordinateFormat = function () {
  6391. return /** @type {import("../coordinate.js").CoordinateFormat|undefined} */ (this.get(COORDINATE_FORMAT));
  6392. };
  6393. /**
  6394. * Return the projection that is used to report the mouse position.
  6395. * @return {import("../proj/Projection.js").default|undefined} The projection to report mouse
  6396. * position in.
  6397. * @observable
  6398. * @api
  6399. */
  6400. MousePosition.prototype.getProjection = function () {
  6401. return /** @type {import("../proj/Projection.js").default|undefined} */ (this.get(PROJECTION));
  6402. };
  6403. /**
  6404. * @param {MouseEvent} event Browser event.
  6405. * @protected
  6406. */
  6407. MousePosition.prototype.handleMouseMove = function (event) {
  6408. var map = this.getMap();
  6409. this.updateHTML_(map.getEventPixel(event));
  6410. };
  6411. /**
  6412. * @param {Event} event Browser event.
  6413. * @protected
  6414. */
  6415. MousePosition.prototype.handleMouseOut = function (event) {
  6416. this.updateHTML_(null);
  6417. };
  6418. /**
  6419. * Remove the control from its current map and attach it to the new map.
  6420. * Pass `null` to just remove the control from the current map.
  6421. * Subclasses may set up event handlers to get notified about changes to
  6422. * the map here.
  6423. * @param {import("../PluggableMap.js").default|null} map Map.
  6424. * @api
  6425. */
  6426. MousePosition.prototype.setMap = function (map) {
  6427. _super.prototype.setMap.call(this, map);
  6428. if (map) {
  6429. var viewport = map.getViewport();
  6430. this.listenerKeys.push(listen(viewport, pointer_EventType.POINTERMOVE, this.handleMouseMove, this));
  6431. if (this.renderOnMouseOut_) {
  6432. this.listenerKeys.push(listen(viewport, pointer_EventType.POINTEROUT, this.handleMouseOut, this));
  6433. }
  6434. this.updateHTML_(null);
  6435. }
  6436. };
  6437. /**
  6438. * Set the coordinate format type used to render the current position.
  6439. * @param {import("../coordinate.js").CoordinateFormat} format The format to render the current
  6440. * position in.
  6441. * @observable
  6442. * @api
  6443. */
  6444. MousePosition.prototype.setCoordinateFormat = function (format) {
  6445. this.set(COORDINATE_FORMAT, format);
  6446. };
  6447. /**
  6448. * Set the projection that is used to report the mouse position.
  6449. * @param {import("../proj.js").ProjectionLike} projection The projection to report mouse
  6450. * position in.
  6451. * @observable
  6452. * @api
  6453. */
  6454. MousePosition.prototype.setProjection = function (projection) {
  6455. this.set(PROJECTION, proj_get(projection));
  6456. };
  6457. /**
  6458. * @param {?import("../pixel.js").Pixel} pixel Pixel.
  6459. * @private
  6460. */
  6461. MousePosition.prototype.updateHTML_ = function (pixel) {
  6462. var html = this.placeholder_;
  6463. if (pixel && this.mapProjection_) {
  6464. if (!this.transform_) {
  6465. var projection = this.getProjection();
  6466. if (projection) {
  6467. this.transform_ = getTransformFromProjections(this.mapProjection_, projection);
  6468. }
  6469. else {
  6470. this.transform_ = identityTransform;
  6471. }
  6472. }
  6473. var map = this.getMap();
  6474. var coordinate = map.getCoordinateFromPixelInternal(pixel);
  6475. if (coordinate) {
  6476. var userProjection = getUserProjection();
  6477. if (userProjection) {
  6478. this.transform_ = getTransformFromProjections(this.mapProjection_, userProjection);
  6479. }
  6480. this.transform_(coordinate, coordinate);
  6481. var coordinateFormat = this.getCoordinateFormat();
  6482. if (coordinateFormat) {
  6483. html = coordinateFormat(coordinate);
  6484. }
  6485. else {
  6486. html = coordinate.toString();
  6487. }
  6488. }
  6489. }
  6490. if (!this.renderedHTML_ || html !== this.renderedHTML_) {
  6491. this.element.innerHTML = html;
  6492. this.renderedHTML_ = html;
  6493. }
  6494. };
  6495. /**
  6496. * Update the projection. Rendering of the coordinates is done in
  6497. * `handleMouseMove` and `handleMouseUp`.
  6498. * @param {import("../MapEvent.js").default} mapEvent Map event.
  6499. * @override
  6500. */
  6501. MousePosition.prototype.render = function (mapEvent) {
  6502. var frameState = mapEvent.frameState;
  6503. if (!frameState) {
  6504. this.mapProjection_ = null;
  6505. }
  6506. else {
  6507. if (this.mapProjection_ != frameState.viewState.projection) {
  6508. this.mapProjection_ = frameState.viewState.projection;
  6509. this.transform_ = null;
  6510. }
  6511. }
  6512. };
  6513. return MousePosition;
  6514. }(control_Control));
  6515. /* harmony default export */ var control_MousePosition = (MousePosition);
  6516. //# sourceMappingURL=MousePosition.js.map
  6517. ;// ./node_modules/ol/easing.js
  6518. /**
  6519. * @module ol/easing
  6520. */
  6521. /**
  6522. * Start slow and speed up.
  6523. * @param {number} t Input between 0 and 1.
  6524. * @return {number} Output between 0 and 1.
  6525. * @api
  6526. */
  6527. function easeIn(t) {
  6528. return Math.pow(t, 3);
  6529. }
  6530. /**
  6531. * Start fast and slow down.
  6532. * @param {number} t Input between 0 and 1.
  6533. * @return {number} Output between 0 and 1.
  6534. * @api
  6535. */
  6536. function easeOut(t) {
  6537. return 1 - easeIn(1 - t);
  6538. }
  6539. /**
  6540. * Start slow, speed up, and then slow down again.
  6541. * @param {number} t Input between 0 and 1.
  6542. * @return {number} Output between 0 and 1.
  6543. * @api
  6544. */
  6545. function inAndOut(t) {
  6546. return 3 * t * t - 2 * t * t * t;
  6547. }
  6548. /**
  6549. * Maintain a constant speed over time.
  6550. * @param {number} t Input between 0 and 1.
  6551. * @return {number} Output between 0 and 1.
  6552. * @api
  6553. */
  6554. function linear(t) {
  6555. return t;
  6556. }
  6557. /**
  6558. * Start slow, speed up, and at the very end slow down again. This has the
  6559. * same general behavior as {@link module:ol/easing.inAndOut}, but the final
  6560. * slowdown is delayed.
  6561. * @param {number} t Input between 0 and 1.
  6562. * @return {number} Output between 0 and 1.
  6563. * @api
  6564. */
  6565. function upAndDown(t) {
  6566. if (t < 0.5) {
  6567. return inAndOut(2 * t);
  6568. }
  6569. else {
  6570. return 1 - inAndOut(2 * (t - 0.5));
  6571. }
  6572. }
  6573. //# sourceMappingURL=easing.js.map
  6574. ;// ./node_modules/ol/control/Zoom.js
  6575. var Zoom_extends = (undefined && undefined.__extends) || (function () {
  6576. var extendStatics = function (d, b) {
  6577. extendStatics = Object.setPrototypeOf ||
  6578. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6579. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  6580. return extendStatics(d, b);
  6581. };
  6582. return function (d, b) {
  6583. if (typeof b !== "function" && b !== null)
  6584. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  6585. extendStatics(d, b);
  6586. function __() { this.constructor = d; }
  6587. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6588. };
  6589. })();
  6590. /**
  6591. * @module ol/control/Zoom
  6592. */
  6593. /**
  6594. * @typedef {Object} Options
  6595. * @property {number} [duration=250] Animation duration in milliseconds.
  6596. * @property {string} [className='ol-zoom'] CSS class name.
  6597. * @property {string} [zoomInClassName=className + '-in'] CSS class name for the zoom-in button.
  6598. * @property {string} [zoomOutClassName=className + '-out'] CSS class name for the zoom-out button.
  6599. * @property {string|HTMLElement} [zoomInLabel='+'] Text label to use for the zoom-in
  6600. * button. Instead of text, also an element (e.g. a `span` element) can be used.
  6601. * @property {string|HTMLElement} [zoomOutLabel='–'] Text label to use for the zoom-out button.
  6602. * Instead of text, also an element (e.g. a `span` element) can be used.
  6603. * @property {string} [zoomInTipLabel='Zoom in'] Text label to use for the button tip.
  6604. * @property {string} [zoomOutTipLabel='Zoom out'] Text label to use for the button tip.
  6605. * @property {number} [delta=1] The zoom delta applied on each click.
  6606. * @property {HTMLElement|string} [target] Specify a target if you want the control to be
  6607. * rendered outside of the map's viewport.
  6608. */
  6609. /**
  6610. * @classdesc
  6611. * A control with 2 buttons, one for zoom in and one for zoom out.
  6612. * This control is one of the default controls of a map. To style this control
  6613. * use css selectors `.ol-zoom-in` and `.ol-zoom-out`.
  6614. *
  6615. * @api
  6616. */
  6617. var Zoom = /** @class */ (function (_super) {
  6618. Zoom_extends(Zoom, _super);
  6619. /**
  6620. * @param {Options} [opt_options] Zoom options.
  6621. */
  6622. function Zoom(opt_options) {
  6623. var _this = this;
  6624. var options = opt_options ? opt_options : {};
  6625. _this = _super.call(this, {
  6626. element: document.createElement('div'),
  6627. target: options.target,
  6628. }) || this;
  6629. var className = options.className !== undefined ? options.className : 'ol-zoom';
  6630. var delta = options.delta !== undefined ? options.delta : 1;
  6631. var zoomInClassName = options.zoomInClassName !== undefined
  6632. ? options.zoomInClassName
  6633. : className + '-in';
  6634. var zoomOutClassName = options.zoomOutClassName !== undefined
  6635. ? options.zoomOutClassName
  6636. : className + '-out';
  6637. var zoomInLabel = options.zoomInLabel !== undefined ? options.zoomInLabel : '+';
  6638. var zoomOutLabel = options.zoomOutLabel !== undefined ? options.zoomOutLabel : '\u2013';
  6639. var zoomInTipLabel = options.zoomInTipLabel !== undefined ? options.zoomInTipLabel : 'Zoom in';
  6640. var zoomOutTipLabel = options.zoomOutTipLabel !== undefined
  6641. ? options.zoomOutTipLabel
  6642. : 'Zoom out';
  6643. var inElement = document.createElement('button');
  6644. inElement.className = zoomInClassName;
  6645. inElement.setAttribute('type', 'button');
  6646. inElement.title = zoomInTipLabel;
  6647. inElement.appendChild(typeof zoomInLabel === 'string'
  6648. ? document.createTextNode(zoomInLabel)
  6649. : zoomInLabel);
  6650. inElement.addEventListener(EventType.CLICK, _this.handleClick_.bind(_this, delta), false);
  6651. var outElement = document.createElement('button');
  6652. outElement.className = zoomOutClassName;
  6653. outElement.setAttribute('type', 'button');
  6654. outElement.title = zoomOutTipLabel;
  6655. outElement.appendChild(typeof zoomOutLabel === 'string'
  6656. ? document.createTextNode(zoomOutLabel)
  6657. : zoomOutLabel);
  6658. outElement.addEventListener(EventType.CLICK, _this.handleClick_.bind(_this, -delta), false);
  6659. var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
  6660. var element = _this.element;
  6661. element.className = cssClasses;
  6662. element.appendChild(inElement);
  6663. element.appendChild(outElement);
  6664. /**
  6665. * @type {number}
  6666. * @private
  6667. */
  6668. _this.duration_ = options.duration !== undefined ? options.duration : 250;
  6669. return _this;
  6670. }
  6671. /**
  6672. * @param {number} delta Zoom delta.
  6673. * @param {MouseEvent} event The event to handle
  6674. * @private
  6675. */
  6676. Zoom.prototype.handleClick_ = function (delta, event) {
  6677. event.preventDefault();
  6678. this.zoomByDelta_(delta);
  6679. };
  6680. /**
  6681. * @param {number} delta Zoom delta.
  6682. * @private
  6683. */
  6684. Zoom.prototype.zoomByDelta_ = function (delta) {
  6685. var map = this.getMap();
  6686. var view = map.getView();
  6687. if (!view) {
  6688. // the map does not have a view, so we can't act
  6689. // upon it
  6690. return;
  6691. }
  6692. var currentZoom = view.getZoom();
  6693. if (currentZoom !== undefined) {
  6694. var newZoom = view.getConstrainedZoom(currentZoom + delta);
  6695. if (this.duration_ > 0) {
  6696. if (view.getAnimating()) {
  6697. view.cancelAnimations();
  6698. }
  6699. view.animate({
  6700. zoom: newZoom,
  6701. duration: this.duration_,
  6702. easing: easeOut,
  6703. });
  6704. }
  6705. else {
  6706. view.setZoom(newZoom);
  6707. }
  6708. }
  6709. };
  6710. return Zoom;
  6711. }(control_Control));
  6712. /* harmony default export */ var control_Zoom = (Zoom);
  6713. //# sourceMappingURL=Zoom.js.map
  6714. ;// ./node_modules/ol/geom/GeometryLayout.js
  6715. /**
  6716. * @module ol/geom/GeometryLayout
  6717. */
  6718. /**
  6719. * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')
  6720. * or measure ('M') coordinate is available. Supported values are `'XY'`,
  6721. * `'XYZ'`, `'XYM'`, `'XYZM'`.
  6722. * @enum {string}
  6723. */
  6724. /* harmony default export */ var geom_GeometryLayout = ({
  6725. XY: 'XY',
  6726. XYZ: 'XYZ',
  6727. XYM: 'XYM',
  6728. XYZM: 'XYZM',
  6729. });
  6730. //# sourceMappingURL=GeometryLayout.js.map
  6731. ;// ./node_modules/ol/transform.js
  6732. /**
  6733. * @module ol/transform
  6734. */
  6735. /**
  6736. * An array representing an affine 2d transformation for use with
  6737. * {@link module:ol/transform} functions. The array has 6 elements.
  6738. * @typedef {!Array<number>} Transform
  6739. * @api
  6740. */
  6741. /**
  6742. * Collection of affine 2d transformation functions. The functions work on an
  6743. * array of 6 elements. The element order is compatible with the [SVGMatrix
  6744. * interface](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) and is
  6745. * a subset (elements a to f) of a 3×3 matrix:
  6746. * ```
  6747. * [ a c e ]
  6748. * [ b d f ]
  6749. * [ 0 0 1 ]
  6750. * ```
  6751. */
  6752. /**
  6753. * @private
  6754. * @type {Transform}
  6755. */
  6756. var tmp_ = new Array(6);
  6757. /**
  6758. * Create an identity transform.
  6759. * @return {!Transform} Identity transform.
  6760. */
  6761. function create() {
  6762. return [1, 0, 0, 1, 0, 0];
  6763. }
  6764. /**
  6765. * Resets the given transform to an identity transform.
  6766. * @param {!Transform} transform Transform.
  6767. * @return {!Transform} Transform.
  6768. */
  6769. function transform_reset(transform) {
  6770. return set(transform, 1, 0, 0, 1, 0, 0);
  6771. }
  6772. /**
  6773. * Multiply the underlying matrices of two transforms and return the result in
  6774. * the first transform.
  6775. * @param {!Transform} transform1 Transform parameters of matrix 1.
  6776. * @param {!Transform} transform2 Transform parameters of matrix 2.
  6777. * @return {!Transform} transform1 multiplied with transform2.
  6778. */
  6779. function multiply(transform1, transform2) {
  6780. var a1 = transform1[0];
  6781. var b1 = transform1[1];
  6782. var c1 = transform1[2];
  6783. var d1 = transform1[3];
  6784. var e1 = transform1[4];
  6785. var f1 = transform1[5];
  6786. var a2 = transform2[0];
  6787. var b2 = transform2[1];
  6788. var c2 = transform2[2];
  6789. var d2 = transform2[3];
  6790. var e2 = transform2[4];
  6791. var f2 = transform2[5];
  6792. transform1[0] = a1 * a2 + c1 * b2;
  6793. transform1[1] = b1 * a2 + d1 * b2;
  6794. transform1[2] = a1 * c2 + c1 * d2;
  6795. transform1[3] = b1 * c2 + d1 * d2;
  6796. transform1[4] = a1 * e2 + c1 * f2 + e1;
  6797. transform1[5] = b1 * e2 + d1 * f2 + f1;
  6798. return transform1;
  6799. }
  6800. /**
  6801. * Set the transform components a-f on a given transform.
  6802. * @param {!Transform} transform Transform.
  6803. * @param {number} a The a component of the transform.
  6804. * @param {number} b The b component of the transform.
  6805. * @param {number} c The c component of the transform.
  6806. * @param {number} d The d component of the transform.
  6807. * @param {number} e The e component of the transform.
  6808. * @param {number} f The f component of the transform.
  6809. * @return {!Transform} Matrix with transform applied.
  6810. */
  6811. function set(transform, a, b, c, d, e, f) {
  6812. transform[0] = a;
  6813. transform[1] = b;
  6814. transform[2] = c;
  6815. transform[3] = d;
  6816. transform[4] = e;
  6817. transform[5] = f;
  6818. return transform;
  6819. }
  6820. /**
  6821. * Set transform on one matrix from another matrix.
  6822. * @param {!Transform} transform1 Matrix to set transform to.
  6823. * @param {!Transform} transform2 Matrix to set transform from.
  6824. * @return {!Transform} transform1 with transform from transform2 applied.
  6825. */
  6826. function setFromArray(transform1, transform2) {
  6827. transform1[0] = transform2[0];
  6828. transform1[1] = transform2[1];
  6829. transform1[2] = transform2[2];
  6830. transform1[3] = transform2[3];
  6831. transform1[4] = transform2[4];
  6832. transform1[5] = transform2[5];
  6833. return transform1;
  6834. }
  6835. /**
  6836. * Transforms the given coordinate with the given transform returning the
  6837. * resulting, transformed coordinate. The coordinate will be modified in-place.
  6838. *
  6839. * @param {Transform} transform The transformation.
  6840. * @param {import("./coordinate.js").Coordinate|import("./pixel.js").Pixel} coordinate The coordinate to transform.
  6841. * @return {import("./coordinate.js").Coordinate|import("./pixel.js").Pixel} return coordinate so that operations can be
  6842. * chained together.
  6843. */
  6844. function apply(transform, coordinate) {
  6845. var x = coordinate[0];
  6846. var y = coordinate[1];
  6847. coordinate[0] = transform[0] * x + transform[2] * y + transform[4];
  6848. coordinate[1] = transform[1] * x + transform[3] * y + transform[5];
  6849. return coordinate;
  6850. }
  6851. /**
  6852. * Applies rotation to the given transform.
  6853. * @param {!Transform} transform Transform.
  6854. * @param {number} angle Angle in radians.
  6855. * @return {!Transform} The rotated transform.
  6856. */
  6857. function transform_rotate(transform, angle) {
  6858. var cos = Math.cos(angle);
  6859. var sin = Math.sin(angle);
  6860. return multiply(transform, set(tmp_, cos, sin, -sin, cos, 0, 0));
  6861. }
  6862. /**
  6863. * Applies scale to a given transform.
  6864. * @param {!Transform} transform Transform.
  6865. * @param {number} x Scale factor x.
  6866. * @param {number} y Scale factor y.
  6867. * @return {!Transform} The scaled transform.
  6868. */
  6869. function transform_scale(transform, x, y) {
  6870. return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));
  6871. }
  6872. /**
  6873. * Creates a scale transform.
  6874. * @param {!Transform} target Transform to overwrite.
  6875. * @param {number} x Scale factor x.
  6876. * @param {number} y Scale factor y.
  6877. * @return {!Transform} The scale transform.
  6878. */
  6879. function makeScale(target, x, y) {
  6880. return set(target, x, 0, 0, y, 0, 0);
  6881. }
  6882. /**
  6883. * Applies translation to the given transform.
  6884. * @param {!Transform} transform Transform.
  6885. * @param {number} dx Translation x.
  6886. * @param {number} dy Translation y.
  6887. * @return {!Transform} The translated transform.
  6888. */
  6889. function translate(transform, dx, dy) {
  6890. return multiply(transform, set(tmp_, 1, 0, 0, 1, dx, dy));
  6891. }
  6892. /**
  6893. * Creates a composite transform given an initial translation, scale, rotation, and
  6894. * final translation (in that order only, not commutative).
  6895. * @param {!Transform} transform The transform (will be modified in place).
  6896. * @param {number} dx1 Initial translation x.
  6897. * @param {number} dy1 Initial translation y.
  6898. * @param {number} sx Scale factor x.
  6899. * @param {number} sy Scale factor y.
  6900. * @param {number} angle Rotation (in counter-clockwise radians).
  6901. * @param {number} dx2 Final translation x.
  6902. * @param {number} dy2 Final translation y.
  6903. * @return {!Transform} The composite transform.
  6904. */
  6905. function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {
  6906. var sin = Math.sin(angle);
  6907. var cos = Math.cos(angle);
  6908. transform[0] = sx * cos;
  6909. transform[1] = sy * sin;
  6910. transform[2] = -sx * sin;
  6911. transform[3] = sy * cos;
  6912. transform[4] = dx2 * sx * cos - dy2 * sx * sin + dx1;
  6913. transform[5] = dx2 * sy * sin + dy2 * sy * cos + dy1;
  6914. return transform;
  6915. }
  6916. /**
  6917. * Creates a composite transform given an initial translation, scale, rotation, and
  6918. * final translation (in that order only, not commutative). The resulting transform
  6919. * string can be applied as `transform` property of an HTMLElement's style.
  6920. * @param {number} dx1 Initial translation x.
  6921. * @param {number} dy1 Initial translation y.
  6922. * @param {number} sx Scale factor x.
  6923. * @param {number} sy Scale factor y.
  6924. * @param {number} angle Rotation (in counter-clockwise radians).
  6925. * @param {number} dx2 Final translation x.
  6926. * @param {number} dy2 Final translation y.
  6927. * @return {string} The composite css transform.
  6928. * @api
  6929. */
  6930. function composeCssTransform(dx1, dy1, sx, sy, angle, dx2, dy2) {
  6931. return transform_toString(compose(create(), dx1, dy1, sx, sy, angle, dx2, dy2));
  6932. }
  6933. /**
  6934. * Invert the given transform.
  6935. * @param {!Transform} source The source transform to invert.
  6936. * @return {!Transform} The inverted (source) transform.
  6937. */
  6938. function invert(source) {
  6939. return makeInverse(source, source);
  6940. }
  6941. /**
  6942. * Invert the given transform.
  6943. * @param {!Transform} target Transform to be set as the inverse of
  6944. * the source transform.
  6945. * @param {!Transform} source The source transform to invert.
  6946. * @return {!Transform} The inverted (target) transform.
  6947. */
  6948. function makeInverse(target, source) {
  6949. var det = determinant(source);
  6950. asserts_assert(det !== 0, 32); // Transformation matrix cannot be inverted
  6951. var a = source[0];
  6952. var b = source[1];
  6953. var c = source[2];
  6954. var d = source[3];
  6955. var e = source[4];
  6956. var f = source[5];
  6957. target[0] = d / det;
  6958. target[1] = -b / det;
  6959. target[2] = -c / det;
  6960. target[3] = a / det;
  6961. target[4] = (c * f - d * e) / det;
  6962. target[5] = -(a * f - b * e) / det;
  6963. return target;
  6964. }
  6965. /**
  6966. * Returns the determinant of the given matrix.
  6967. * @param {!Transform} mat Matrix.
  6968. * @return {number} Determinant.
  6969. */
  6970. function determinant(mat) {
  6971. return mat[0] * mat[3] - mat[1] * mat[2];
  6972. }
  6973. /**
  6974. * @type {HTMLElement}
  6975. * @private
  6976. */
  6977. var transformStringDiv;
  6978. /**
  6979. * A rounded string version of the transform. This can be used
  6980. * for CSS transforms.
  6981. * @param {!Transform} mat Matrix.
  6982. * @return {string} The transform as a string.
  6983. */
  6984. function transform_toString(mat) {
  6985. var transformString = 'matrix(' + mat.join(', ') + ')';
  6986. if (WORKER_OFFSCREEN_CANVAS) {
  6987. return transformString;
  6988. }
  6989. var node = transformStringDiv || (transformStringDiv = document.createElement('div'));
  6990. node.style.transform = transformString;
  6991. return node.style.transform;
  6992. }
  6993. //# sourceMappingURL=transform.js.map
  6994. ;// ./node_modules/ol/geom/flat/transform.js
  6995. /**
  6996. * @module ol/geom/flat/transform
  6997. */
  6998. /**
  6999. * @param {Array<number>} flatCoordinates Flat coordinates.
  7000. * @param {number} offset Offset.
  7001. * @param {number} end End.
  7002. * @param {number} stride Stride.
  7003. * @param {import("../../transform.js").Transform} transform Transform.
  7004. * @param {Array<number>} [opt_dest] Destination.
  7005. * @return {Array<number>} Transformed coordinates.
  7006. */
  7007. function transform2D(flatCoordinates, offset, end, stride, transform, opt_dest) {
  7008. var dest = opt_dest ? opt_dest : [];
  7009. var i = 0;
  7010. for (var j = offset; j < end; j += stride) {
  7011. var x = flatCoordinates[j];
  7012. var y = flatCoordinates[j + 1];
  7013. dest[i++] = transform[0] * x + transform[2] * y + transform[4];
  7014. dest[i++] = transform[1] * x + transform[3] * y + transform[5];
  7015. }
  7016. if (opt_dest && dest.length != i) {
  7017. dest.length = i;
  7018. }
  7019. return dest;
  7020. }
  7021. /**
  7022. * @param {Array<number>} flatCoordinates Flat coordinates.
  7023. * @param {number} offset Offset.
  7024. * @param {number} end End.
  7025. * @param {number} stride Stride.
  7026. * @param {number} angle Angle.
  7027. * @param {Array<number>} anchor Rotation anchor point.
  7028. * @param {Array<number>} [opt_dest] Destination.
  7029. * @return {Array<number>} Transformed coordinates.
  7030. */
  7031. function flat_transform_rotate(flatCoordinates, offset, end, stride, angle, anchor, opt_dest) {
  7032. var dest = opt_dest ? opt_dest : [];
  7033. var cos = Math.cos(angle);
  7034. var sin = Math.sin(angle);
  7035. var anchorX = anchor[0];
  7036. var anchorY = anchor[1];
  7037. var i = 0;
  7038. for (var j = offset; j < end; j += stride) {
  7039. var deltaX = flatCoordinates[j] - anchorX;
  7040. var deltaY = flatCoordinates[j + 1] - anchorY;
  7041. dest[i++] = anchorX + deltaX * cos - deltaY * sin;
  7042. dest[i++] = anchorY + deltaX * sin + deltaY * cos;
  7043. for (var k = j + 2; k < j + stride; ++k) {
  7044. dest[i++] = flatCoordinates[k];
  7045. }
  7046. }
  7047. if (opt_dest && dest.length != i) {
  7048. dest.length = i;
  7049. }
  7050. return dest;
  7051. }
  7052. /**
  7053. * Scale the coordinates.
  7054. * @param {Array<number>} flatCoordinates Flat coordinates.
  7055. * @param {number} offset Offset.
  7056. * @param {number} end End.
  7057. * @param {number} stride Stride.
  7058. * @param {number} sx Scale factor in the x-direction.
  7059. * @param {number} sy Scale factor in the y-direction.
  7060. * @param {Array<number>} anchor Scale anchor point.
  7061. * @param {Array<number>} [opt_dest] Destination.
  7062. * @return {Array<number>} Transformed coordinates.
  7063. */
  7064. function flat_transform_scale(flatCoordinates, offset, end, stride, sx, sy, anchor, opt_dest) {
  7065. var dest = opt_dest ? opt_dest : [];
  7066. var anchorX = anchor[0];
  7067. var anchorY = anchor[1];
  7068. var i = 0;
  7069. for (var j = offset; j < end; j += stride) {
  7070. var deltaX = flatCoordinates[j] - anchorX;
  7071. var deltaY = flatCoordinates[j + 1] - anchorY;
  7072. dest[i++] = anchorX + sx * deltaX;
  7073. dest[i++] = anchorY + sy * deltaY;
  7074. for (var k = j + 2; k < j + stride; ++k) {
  7075. dest[i++] = flatCoordinates[k];
  7076. }
  7077. }
  7078. if (opt_dest && dest.length != i) {
  7079. dest.length = i;
  7080. }
  7081. return dest;
  7082. }
  7083. /**
  7084. * @param {Array<number>} flatCoordinates Flat coordinates.
  7085. * @param {number} offset Offset.
  7086. * @param {number} end End.
  7087. * @param {number} stride Stride.
  7088. * @param {number} deltaX Delta X.
  7089. * @param {number} deltaY Delta Y.
  7090. * @param {Array<number>} [opt_dest] Destination.
  7091. * @return {Array<number>} Transformed coordinates.
  7092. */
  7093. function transform_translate(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) {
  7094. var dest = opt_dest ? opt_dest : [];
  7095. var i = 0;
  7096. for (var j = offset; j < end; j += stride) {
  7097. dest[i++] = flatCoordinates[j] + deltaX;
  7098. dest[i++] = flatCoordinates[j + 1] + deltaY;
  7099. for (var k = j + 2; k < j + stride; ++k) {
  7100. dest[i++] = flatCoordinates[k];
  7101. }
  7102. }
  7103. if (opt_dest && dest.length != i) {
  7104. dest.length = i;
  7105. }
  7106. return dest;
  7107. }
  7108. //# sourceMappingURL=transform.js.map
  7109. ;// ./node_modules/ol/geom/Geometry.js
  7110. var Geometry_extends = (undefined && undefined.__extends) || (function () {
  7111. var extendStatics = function (d, b) {
  7112. extendStatics = Object.setPrototypeOf ||
  7113. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  7114. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7115. return extendStatics(d, b);
  7116. };
  7117. return function (d, b) {
  7118. if (typeof b !== "function" && b !== null)
  7119. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  7120. extendStatics(d, b);
  7121. function __() { this.constructor = d; }
  7122. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7123. };
  7124. })();
  7125. /**
  7126. * @module ol/geom/Geometry
  7127. */
  7128. /**
  7129. * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type
  7130. * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,
  7131. * `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,
  7132. * `'GeometryCollection'`, or `'Circle'`.
  7133. */
  7134. /**
  7135. * @type {import("../transform.js").Transform}
  7136. */
  7137. var tmpTransform = create();
  7138. /**
  7139. * @classdesc
  7140. * Abstract base class; normally only used for creating subclasses and not
  7141. * instantiated in apps.
  7142. * Base class for vector geometries.
  7143. *
  7144. * To get notified of changes to the geometry, register a listener for the
  7145. * generic `change` event on your geometry instance.
  7146. *
  7147. * @abstract
  7148. * @api
  7149. */
  7150. var Geometry = /** @class */ (function (_super) {
  7151. Geometry_extends(Geometry, _super);
  7152. function Geometry() {
  7153. var _this = _super.call(this) || this;
  7154. /**
  7155. * @private
  7156. * @type {import("../extent.js").Extent}
  7157. */
  7158. _this.extent_ = createEmpty();
  7159. /**
  7160. * @private
  7161. * @type {number}
  7162. */
  7163. _this.extentRevision_ = -1;
  7164. /**
  7165. * @protected
  7166. * @type {number}
  7167. */
  7168. _this.simplifiedGeometryMaxMinSquaredTolerance = 0;
  7169. /**
  7170. * @protected
  7171. * @type {number}
  7172. */
  7173. _this.simplifiedGeometryRevision = 0;
  7174. /**
  7175. * Get a transformed and simplified version of the geometry.
  7176. * @abstract
  7177. * @param {number} revision The geometry revision.
  7178. * @param {number} squaredTolerance Squared tolerance.
  7179. * @param {import("../proj.js").TransformFunction} [opt_transform] Optional transform function.
  7180. * @return {Geometry} Simplified geometry.
  7181. */
  7182. _this.simplifyTransformedInternal = memoizeOne(function (revision, squaredTolerance, opt_transform) {
  7183. if (!opt_transform) {
  7184. return this.getSimplifiedGeometry(squaredTolerance);
  7185. }
  7186. var clone = this.clone();
  7187. clone.applyTransform(opt_transform);
  7188. return clone.getSimplifiedGeometry(squaredTolerance);
  7189. });
  7190. return _this;
  7191. }
  7192. /**
  7193. * Get a transformed and simplified version of the geometry.
  7194. * @abstract
  7195. * @param {number} squaredTolerance Squared tolerance.
  7196. * @param {import("../proj.js").TransformFunction} [opt_transform] Optional transform function.
  7197. * @return {Geometry} Simplified geometry.
  7198. */
  7199. Geometry.prototype.simplifyTransformed = function (squaredTolerance, opt_transform) {
  7200. return this.simplifyTransformedInternal(this.getRevision(), squaredTolerance, opt_transform);
  7201. };
  7202. /**
  7203. * Make a complete copy of the geometry.
  7204. * @abstract
  7205. * @return {!Geometry} Clone.
  7206. */
  7207. Geometry.prototype.clone = function () {
  7208. return util_abstract();
  7209. };
  7210. /**
  7211. * @abstract
  7212. * @param {number} x X.
  7213. * @param {number} y Y.
  7214. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  7215. * @param {number} minSquaredDistance Minimum squared distance.
  7216. * @return {number} Minimum squared distance.
  7217. */
  7218. Geometry.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  7219. return util_abstract();
  7220. };
  7221. /**
  7222. * @param {number} x X.
  7223. * @param {number} y Y.
  7224. * @return {boolean} Contains (x, y).
  7225. */
  7226. Geometry.prototype.containsXY = function (x, y) {
  7227. var coord = this.getClosestPoint([x, y]);
  7228. return coord[0] === x && coord[1] === y;
  7229. };
  7230. /**
  7231. * Return the closest point of the geometry to the passed point as
  7232. * {@link module:ol/coordinate~Coordinate coordinate}.
  7233. * @param {import("../coordinate.js").Coordinate} point Point.
  7234. * @param {import("../coordinate.js").Coordinate} [opt_closestPoint] Closest point.
  7235. * @return {import("../coordinate.js").Coordinate} Closest point.
  7236. * @api
  7237. */
  7238. Geometry.prototype.getClosestPoint = function (point, opt_closestPoint) {
  7239. var closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
  7240. this.closestPointXY(point[0], point[1], closestPoint, Infinity);
  7241. return closestPoint;
  7242. };
  7243. /**
  7244. * Returns true if this geometry includes the specified coordinate. If the
  7245. * coordinate is on the boundary of the geometry, returns false.
  7246. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  7247. * @return {boolean} Contains coordinate.
  7248. * @api
  7249. */
  7250. Geometry.prototype.intersectsCoordinate = function (coordinate) {
  7251. return this.containsXY(coordinate[0], coordinate[1]);
  7252. };
  7253. /**
  7254. * @abstract
  7255. * @param {import("../extent.js").Extent} extent Extent.
  7256. * @protected
  7257. * @return {import("../extent.js").Extent} extent Extent.
  7258. */
  7259. Geometry.prototype.computeExtent = function (extent) {
  7260. return util_abstract();
  7261. };
  7262. /**
  7263. * Get the extent of the geometry.
  7264. * @param {import("../extent.js").Extent} [opt_extent] Extent.
  7265. * @return {import("../extent.js").Extent} extent Extent.
  7266. * @api
  7267. */
  7268. Geometry.prototype.getExtent = function (opt_extent) {
  7269. if (this.extentRevision_ != this.getRevision()) {
  7270. var extent = this.computeExtent(this.extent_);
  7271. if (isNaN(extent[0]) || isNaN(extent[1])) {
  7272. createOrUpdateEmpty(extent);
  7273. }
  7274. this.extentRevision_ = this.getRevision();
  7275. }
  7276. return returnOrUpdate(this.extent_, opt_extent);
  7277. };
  7278. /**
  7279. * Rotate the geometry around a given coordinate. This modifies the geometry
  7280. * coordinates in place.
  7281. * @abstract
  7282. * @param {number} angle Rotation angle in radians.
  7283. * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
  7284. * @api
  7285. */
  7286. Geometry.prototype.rotate = function (angle, anchor) {
  7287. util_abstract();
  7288. };
  7289. /**
  7290. * Scale the geometry (with an optional origin). This modifies the geometry
  7291. * coordinates in place.
  7292. * @abstract
  7293. * @param {number} sx The scaling factor in the x-direction.
  7294. * @param {number} [opt_sy] The scaling factor in the y-direction (defaults to sx).
  7295. * @param {import("../coordinate.js").Coordinate} [opt_anchor] The scale origin (defaults to the center
  7296. * of the geometry extent).
  7297. * @api
  7298. */
  7299. Geometry.prototype.scale = function (sx, opt_sy, opt_anchor) {
  7300. util_abstract();
  7301. };
  7302. /**
  7303. * Create a simplified version of this geometry. For linestrings, this uses
  7304. * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)
  7305. * algorithm. For polygons, a quantization-based
  7306. * simplification is used to preserve topology.
  7307. * @param {number} tolerance The tolerance distance for simplification.
  7308. * @return {Geometry} A new, simplified version of the original geometry.
  7309. * @api
  7310. */
  7311. Geometry.prototype.simplify = function (tolerance) {
  7312. return this.getSimplifiedGeometry(tolerance * tolerance);
  7313. };
  7314. /**
  7315. * Create a simplified version of this geometry using the Douglas Peucker
  7316. * algorithm.
  7317. * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.
  7318. * @abstract
  7319. * @param {number} squaredTolerance Squared tolerance.
  7320. * @return {Geometry} Simplified geometry.
  7321. */
  7322. Geometry.prototype.getSimplifiedGeometry = function (squaredTolerance) {
  7323. return util_abstract();
  7324. };
  7325. /**
  7326. * Get the type of this geometry.
  7327. * @abstract
  7328. * @return {Type} Geometry type.
  7329. */
  7330. Geometry.prototype.getType = function () {
  7331. return util_abstract();
  7332. };
  7333. /**
  7334. * Apply a transform function to the coordinates of the geometry.
  7335. * The geometry is modified in place.
  7336. * If you do not want the geometry modified in place, first `clone()` it and
  7337. * then use this function on the clone.
  7338. * @abstract
  7339. * @param {import("../proj.js").TransformFunction} transformFn Transform function.
  7340. * Called with a flat array of geometry coordinates.
  7341. */
  7342. Geometry.prototype.applyTransform = function (transformFn) {
  7343. util_abstract();
  7344. };
  7345. /**
  7346. * Test if the geometry and the passed extent intersect.
  7347. * @abstract
  7348. * @param {import("../extent.js").Extent} extent Extent.
  7349. * @return {boolean} `true` if the geometry and the extent intersect.
  7350. */
  7351. Geometry.prototype.intersectsExtent = function (extent) {
  7352. return util_abstract();
  7353. };
  7354. /**
  7355. * Translate the geometry. This modifies the geometry coordinates in place. If
  7356. * instead you want a new geometry, first `clone()` this geometry.
  7357. * @abstract
  7358. * @param {number} deltaX Delta X.
  7359. * @param {number} deltaY Delta Y.
  7360. * @api
  7361. */
  7362. Geometry.prototype.translate = function (deltaX, deltaY) {
  7363. util_abstract();
  7364. };
  7365. /**
  7366. * Transform each coordinate of the geometry from one coordinate reference
  7367. * system to another. The geometry is modified in place.
  7368. * For example, a line will be transformed to a line and a circle to a circle.
  7369. * If you do not want the geometry modified in place, first `clone()` it and
  7370. * then use this function on the clone.
  7371. *
  7372. * @param {import("../proj.js").ProjectionLike} source The current projection. Can be a
  7373. * string identifier or a {@link module:ol/proj/Projection~Projection} object.
  7374. * @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a
  7375. * string identifier or a {@link module:ol/proj/Projection~Projection} object.
  7376. * @return {Geometry} This geometry. Note that original geometry is
  7377. * modified in place.
  7378. * @api
  7379. */
  7380. Geometry.prototype.transform = function (source, destination) {
  7381. /** @type {import("../proj/Projection.js").default} */
  7382. var sourceProj = proj_get(source);
  7383. var transformFn = sourceProj.getUnits() == proj_Units.TILE_PIXELS
  7384. ? function (inCoordinates, outCoordinates, stride) {
  7385. var pixelExtent = sourceProj.getExtent();
  7386. var projectedExtent = sourceProj.getWorldExtent();
  7387. var scale = getHeight(projectedExtent) / getHeight(pixelExtent);
  7388. compose(tmpTransform, projectedExtent[0], projectedExtent[3], scale, -scale, 0, 0, 0);
  7389. transform2D(inCoordinates, 0, inCoordinates.length, stride, tmpTransform, outCoordinates);
  7390. return getTransform(sourceProj, destination)(inCoordinates, outCoordinates, stride);
  7391. }
  7392. : getTransform(sourceProj, destination);
  7393. this.applyTransform(transformFn);
  7394. return this;
  7395. };
  7396. return Geometry;
  7397. }(ol_Object));
  7398. /* harmony default export */ var geom_Geometry = (Geometry);
  7399. //# sourceMappingURL=Geometry.js.map
  7400. ;// ./node_modules/ol/geom/SimpleGeometry.js
  7401. var SimpleGeometry_extends = (undefined && undefined.__extends) || (function () {
  7402. var extendStatics = function (d, b) {
  7403. extendStatics = Object.setPrototypeOf ||
  7404. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  7405. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7406. return extendStatics(d, b);
  7407. };
  7408. return function (d, b) {
  7409. if (typeof b !== "function" && b !== null)
  7410. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  7411. extendStatics(d, b);
  7412. function __() { this.constructor = d; }
  7413. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7414. };
  7415. })();
  7416. /**
  7417. * @module ol/geom/SimpleGeometry
  7418. */
  7419. /**
  7420. * @classdesc
  7421. * Abstract base class; only used for creating subclasses; do not instantiate
  7422. * in apps, as cannot be rendered.
  7423. *
  7424. * @abstract
  7425. * @api
  7426. */
  7427. var SimpleGeometry = /** @class */ (function (_super) {
  7428. SimpleGeometry_extends(SimpleGeometry, _super);
  7429. function SimpleGeometry() {
  7430. var _this = _super.call(this) || this;
  7431. /**
  7432. * @protected
  7433. * @type {import("./GeometryLayout.js").default}
  7434. */
  7435. _this.layout = geom_GeometryLayout.XY;
  7436. /**
  7437. * @protected
  7438. * @type {number}
  7439. */
  7440. _this.stride = 2;
  7441. /**
  7442. * @protected
  7443. * @type {Array<number>}
  7444. */
  7445. _this.flatCoordinates = null;
  7446. return _this;
  7447. }
  7448. /**
  7449. * @param {import("../extent.js").Extent} extent Extent.
  7450. * @protected
  7451. * @return {import("../extent.js").Extent} extent Extent.
  7452. */
  7453. SimpleGeometry.prototype.computeExtent = function (extent) {
  7454. return createOrUpdateFromFlatCoordinates(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, extent);
  7455. };
  7456. /**
  7457. * @abstract
  7458. * @return {Array<*> | null} Coordinates.
  7459. */
  7460. SimpleGeometry.prototype.getCoordinates = function () {
  7461. return util_abstract();
  7462. };
  7463. /**
  7464. * Return the first coordinate of the geometry.
  7465. * @return {import("../coordinate.js").Coordinate} First coordinate.
  7466. * @api
  7467. */
  7468. SimpleGeometry.prototype.getFirstCoordinate = function () {
  7469. return this.flatCoordinates.slice(0, this.stride);
  7470. };
  7471. /**
  7472. * @return {Array<number>} Flat coordinates.
  7473. */
  7474. SimpleGeometry.prototype.getFlatCoordinates = function () {
  7475. return this.flatCoordinates;
  7476. };
  7477. /**
  7478. * Return the last coordinate of the geometry.
  7479. * @return {import("../coordinate.js").Coordinate} Last point.
  7480. * @api
  7481. */
  7482. SimpleGeometry.prototype.getLastCoordinate = function () {
  7483. return this.flatCoordinates.slice(this.flatCoordinates.length - this.stride);
  7484. };
  7485. /**
  7486. * Return the {@link module:ol/geom/GeometryLayout layout} of the geometry.
  7487. * @return {import("./GeometryLayout.js").default} Layout.
  7488. * @api
  7489. */
  7490. SimpleGeometry.prototype.getLayout = function () {
  7491. return this.layout;
  7492. };
  7493. /**
  7494. * Create a simplified version of this geometry using the Douglas Peucker algorithm.
  7495. * @param {number} squaredTolerance Squared tolerance.
  7496. * @return {SimpleGeometry} Simplified geometry.
  7497. */
  7498. SimpleGeometry.prototype.getSimplifiedGeometry = function (squaredTolerance) {
  7499. if (this.simplifiedGeometryRevision !== this.getRevision()) {
  7500. this.simplifiedGeometryMaxMinSquaredTolerance = 0;
  7501. this.simplifiedGeometryRevision = this.getRevision();
  7502. }
  7503. // If squaredTolerance is negative or if we know that simplification will not
  7504. // have any effect then just return this.
  7505. if (squaredTolerance < 0 ||
  7506. (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&
  7507. squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)) {
  7508. return this;
  7509. }
  7510. var simplifiedGeometry = this.getSimplifiedGeometryInternal(squaredTolerance);
  7511. var simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();
  7512. if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {
  7513. return simplifiedGeometry;
  7514. }
  7515. else {
  7516. // Simplification did not actually remove any coordinates. We now know
  7517. // that any calls to getSimplifiedGeometry with a squaredTolerance less
  7518. // than or equal to the current squaredTolerance will also not have any
  7519. // effect. This allows us to short circuit simplification (saving CPU
  7520. // cycles) and prevents the cache of simplified geometries from filling
  7521. // up with useless identical copies of this geometry (saving memory).
  7522. this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;
  7523. return this;
  7524. }
  7525. };
  7526. /**
  7527. * @param {number} squaredTolerance Squared tolerance.
  7528. * @return {SimpleGeometry} Simplified geometry.
  7529. * @protected
  7530. */
  7531. SimpleGeometry.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
  7532. return this;
  7533. };
  7534. /**
  7535. * @return {number} Stride.
  7536. */
  7537. SimpleGeometry.prototype.getStride = function () {
  7538. return this.stride;
  7539. };
  7540. /**
  7541. * @param {import("./GeometryLayout.js").default} layout Layout.
  7542. * @param {Array<number>} flatCoordinates Flat coordinates.
  7543. */
  7544. SimpleGeometry.prototype.setFlatCoordinates = function (layout, flatCoordinates) {
  7545. this.stride = getStrideForLayout(layout);
  7546. this.layout = layout;
  7547. this.flatCoordinates = flatCoordinates;
  7548. };
  7549. /**
  7550. * @abstract
  7551. * @param {!Array<*>} coordinates Coordinates.
  7552. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  7553. */
  7554. SimpleGeometry.prototype.setCoordinates = function (coordinates, opt_layout) {
  7555. util_abstract();
  7556. };
  7557. /**
  7558. * @param {import("./GeometryLayout.js").default|undefined} layout Layout.
  7559. * @param {Array<*>} coordinates Coordinates.
  7560. * @param {number} nesting Nesting.
  7561. * @protected
  7562. */
  7563. SimpleGeometry.prototype.setLayout = function (layout, coordinates, nesting) {
  7564. /** @type {number} */
  7565. var stride;
  7566. if (layout) {
  7567. stride = getStrideForLayout(layout);
  7568. }
  7569. else {
  7570. for (var i = 0; i < nesting; ++i) {
  7571. if (coordinates.length === 0) {
  7572. this.layout = geom_GeometryLayout.XY;
  7573. this.stride = 2;
  7574. return;
  7575. }
  7576. else {
  7577. coordinates = /** @type {Array} */ (coordinates[0]);
  7578. }
  7579. }
  7580. stride = coordinates.length;
  7581. layout = getLayoutForStride(stride);
  7582. }
  7583. this.layout = layout;
  7584. this.stride = stride;
  7585. };
  7586. /**
  7587. * Apply a transform function to the coordinates of the geometry.
  7588. * The geometry is modified in place.
  7589. * If you do not want the geometry modified in place, first `clone()` it and
  7590. * then use this function on the clone.
  7591. * @param {import("../proj.js").TransformFunction} transformFn Transform function.
  7592. * Called with a flat array of geometry coordinates.
  7593. * @api
  7594. */
  7595. SimpleGeometry.prototype.applyTransform = function (transformFn) {
  7596. if (this.flatCoordinates) {
  7597. transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);
  7598. this.changed();
  7599. }
  7600. };
  7601. /**
  7602. * Rotate the geometry around a given coordinate. This modifies the geometry
  7603. * coordinates in place.
  7604. * @param {number} angle Rotation angle in counter-clockwise radians.
  7605. * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
  7606. * @api
  7607. */
  7608. SimpleGeometry.prototype.rotate = function (angle, anchor) {
  7609. var flatCoordinates = this.getFlatCoordinates();
  7610. if (flatCoordinates) {
  7611. var stride = this.getStride();
  7612. flat_transform_rotate(flatCoordinates, 0, flatCoordinates.length, stride, angle, anchor, flatCoordinates);
  7613. this.changed();
  7614. }
  7615. };
  7616. /**
  7617. * Scale the geometry (with an optional origin). This modifies the geometry
  7618. * coordinates in place.
  7619. * @param {number} sx The scaling factor in the x-direction.
  7620. * @param {number} [opt_sy] The scaling factor in the y-direction (defaults to sx).
  7621. * @param {import("../coordinate.js").Coordinate} [opt_anchor] The scale origin (defaults to the center
  7622. * of the geometry extent).
  7623. * @api
  7624. */
  7625. SimpleGeometry.prototype.scale = function (sx, opt_sy, opt_anchor) {
  7626. var sy = opt_sy;
  7627. if (sy === undefined) {
  7628. sy = sx;
  7629. }
  7630. var anchor = opt_anchor;
  7631. if (!anchor) {
  7632. anchor = getCenter(this.getExtent());
  7633. }
  7634. var flatCoordinates = this.getFlatCoordinates();
  7635. if (flatCoordinates) {
  7636. var stride = this.getStride();
  7637. flat_transform_scale(flatCoordinates, 0, flatCoordinates.length, stride, sx, sy, anchor, flatCoordinates);
  7638. this.changed();
  7639. }
  7640. };
  7641. /**
  7642. * Translate the geometry. This modifies the geometry coordinates in place. If
  7643. * instead you want a new geometry, first `clone()` this geometry.
  7644. * @param {number} deltaX Delta X.
  7645. * @param {number} deltaY Delta Y.
  7646. * @api
  7647. */
  7648. SimpleGeometry.prototype.translate = function (deltaX, deltaY) {
  7649. var flatCoordinates = this.getFlatCoordinates();
  7650. if (flatCoordinates) {
  7651. var stride = this.getStride();
  7652. transform_translate(flatCoordinates, 0, flatCoordinates.length, stride, deltaX, deltaY, flatCoordinates);
  7653. this.changed();
  7654. }
  7655. };
  7656. return SimpleGeometry;
  7657. }(geom_Geometry));
  7658. /**
  7659. * @param {number} stride Stride.
  7660. * @return {import("./GeometryLayout.js").default} layout Layout.
  7661. */
  7662. function getLayoutForStride(stride) {
  7663. var layout;
  7664. if (stride == 2) {
  7665. layout = geom_GeometryLayout.XY;
  7666. }
  7667. else if (stride == 3) {
  7668. layout = geom_GeometryLayout.XYZ;
  7669. }
  7670. else if (stride == 4) {
  7671. layout = geom_GeometryLayout.XYZM;
  7672. }
  7673. return /** @type {import("./GeometryLayout.js").default} */ (layout);
  7674. }
  7675. /**
  7676. * @param {import("./GeometryLayout.js").default} layout Layout.
  7677. * @return {number} Stride.
  7678. */
  7679. function getStrideForLayout(layout) {
  7680. var stride;
  7681. if (layout == geom_GeometryLayout.XY) {
  7682. stride = 2;
  7683. }
  7684. else if (layout == geom_GeometryLayout.XYZ || layout == geom_GeometryLayout.XYM) {
  7685. stride = 3;
  7686. }
  7687. else if (layout == geom_GeometryLayout.XYZM) {
  7688. stride = 4;
  7689. }
  7690. return /** @type {number} */ (stride);
  7691. }
  7692. /**
  7693. * @param {SimpleGeometry} simpleGeometry Simple geometry.
  7694. * @param {import("../transform.js").Transform} transform Transform.
  7695. * @param {Array<number>} [opt_dest] Destination.
  7696. * @return {Array<number>} Transformed flat coordinates.
  7697. */
  7698. function transformGeom2D(simpleGeometry, transform, opt_dest) {
  7699. var flatCoordinates = simpleGeometry.getFlatCoordinates();
  7700. if (!flatCoordinates) {
  7701. return null;
  7702. }
  7703. else {
  7704. var stride = simpleGeometry.getStride();
  7705. return transform2D(flatCoordinates, 0, flatCoordinates.length, stride, transform, opt_dest);
  7706. }
  7707. }
  7708. /* harmony default export */ var geom_SimpleGeometry = (SimpleGeometry);
  7709. //# sourceMappingURL=SimpleGeometry.js.map
  7710. ;// ./node_modules/ol/geom/flat/closest.js
  7711. /**
  7712. * @module ol/geom/flat/closest
  7713. */
  7714. /**
  7715. * Returns the point on the 2D line segment flatCoordinates[offset1] to
  7716. * flatCoordinates[offset2] that is closest to the point (x, y). Extra
  7717. * dimensions are linearly interpolated.
  7718. * @param {Array<number>} flatCoordinates Flat coordinates.
  7719. * @param {number} offset1 Offset 1.
  7720. * @param {number} offset2 Offset 2.
  7721. * @param {number} stride Stride.
  7722. * @param {number} x X.
  7723. * @param {number} y Y.
  7724. * @param {Array<number>} closestPoint Closest point.
  7725. */
  7726. function assignClosest(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
  7727. var x1 = flatCoordinates[offset1];
  7728. var y1 = flatCoordinates[offset1 + 1];
  7729. var dx = flatCoordinates[offset2] - x1;
  7730. var dy = flatCoordinates[offset2 + 1] - y1;
  7731. var offset;
  7732. if (dx === 0 && dy === 0) {
  7733. offset = offset1;
  7734. }
  7735. else {
  7736. var t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
  7737. if (t > 1) {
  7738. offset = offset2;
  7739. }
  7740. else if (t > 0) {
  7741. for (var i = 0; i < stride; ++i) {
  7742. closestPoint[i] = lerp(flatCoordinates[offset1 + i], flatCoordinates[offset2 + i], t);
  7743. }
  7744. closestPoint.length = stride;
  7745. return;
  7746. }
  7747. else {
  7748. offset = offset1;
  7749. }
  7750. }
  7751. for (var i = 0; i < stride; ++i) {
  7752. closestPoint[i] = flatCoordinates[offset + i];
  7753. }
  7754. closestPoint.length = stride;
  7755. }
  7756. /**
  7757. * Return the squared of the largest distance between any pair of consecutive
  7758. * coordinates.
  7759. * @param {Array<number>} flatCoordinates Flat coordinates.
  7760. * @param {number} offset Offset.
  7761. * @param {number} end End.
  7762. * @param {number} stride Stride.
  7763. * @param {number} max Max squared delta.
  7764. * @return {number} Max squared delta.
  7765. */
  7766. function maxSquaredDelta(flatCoordinates, offset, end, stride, max) {
  7767. var x1 = flatCoordinates[offset];
  7768. var y1 = flatCoordinates[offset + 1];
  7769. for (offset += stride; offset < end; offset += stride) {
  7770. var x2 = flatCoordinates[offset];
  7771. var y2 = flatCoordinates[offset + 1];
  7772. var squaredDelta = math_squaredDistance(x1, y1, x2, y2);
  7773. if (squaredDelta > max) {
  7774. max = squaredDelta;
  7775. }
  7776. x1 = x2;
  7777. y1 = y2;
  7778. }
  7779. return max;
  7780. }
  7781. /**
  7782. * @param {Array<number>} flatCoordinates Flat coordinates.
  7783. * @param {number} offset Offset.
  7784. * @param {Array<number>} ends Ends.
  7785. * @param {number} stride Stride.
  7786. * @param {number} max Max squared delta.
  7787. * @return {number} Max squared delta.
  7788. */
  7789. function arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max) {
  7790. for (var i = 0, ii = ends.length; i < ii; ++i) {
  7791. var end = ends[i];
  7792. max = maxSquaredDelta(flatCoordinates, offset, end, stride, max);
  7793. offset = end;
  7794. }
  7795. return max;
  7796. }
  7797. /**
  7798. * @param {Array<number>} flatCoordinates Flat coordinates.
  7799. * @param {number} offset Offset.
  7800. * @param {Array<Array<number>>} endss Endss.
  7801. * @param {number} stride Stride.
  7802. * @param {number} max Max squared delta.
  7803. * @return {number} Max squared delta.
  7804. */
  7805. function multiArrayMaxSquaredDelta(flatCoordinates, offset, endss, stride, max) {
  7806. for (var i = 0, ii = endss.length; i < ii; ++i) {
  7807. var ends = endss[i];
  7808. max = arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max);
  7809. offset = ends[ends.length - 1];
  7810. }
  7811. return max;
  7812. }
  7813. /**
  7814. * @param {Array<number>} flatCoordinates Flat coordinates.
  7815. * @param {number} offset Offset.
  7816. * @param {number} end End.
  7817. * @param {number} stride Stride.
  7818. * @param {number} maxDelta Max delta.
  7819. * @param {boolean} isRing Is ring.
  7820. * @param {number} x X.
  7821. * @param {number} y Y.
  7822. * @param {Array<number>} closestPoint Closest point.
  7823. * @param {number} minSquaredDistance Minimum squared distance.
  7824. * @param {Array<number>} [opt_tmpPoint] Temporary point object.
  7825. * @return {number} Minimum squared distance.
  7826. */
  7827. function assignClosestPoint(flatCoordinates, offset, end, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) {
  7828. if (offset == end) {
  7829. return minSquaredDistance;
  7830. }
  7831. var i, squaredDistance;
  7832. if (maxDelta === 0) {
  7833. // All points are identical, so just test the first point.
  7834. squaredDistance = math_squaredDistance(x, y, flatCoordinates[offset], flatCoordinates[offset + 1]);
  7835. if (squaredDistance < minSquaredDistance) {
  7836. for (i = 0; i < stride; ++i) {
  7837. closestPoint[i] = flatCoordinates[offset + i];
  7838. }
  7839. closestPoint.length = stride;
  7840. return squaredDistance;
  7841. }
  7842. else {
  7843. return minSquaredDistance;
  7844. }
  7845. }
  7846. var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
  7847. var index = offset + stride;
  7848. while (index < end) {
  7849. assignClosest(flatCoordinates, index - stride, index, stride, x, y, tmpPoint);
  7850. squaredDistance = math_squaredDistance(x, y, tmpPoint[0], tmpPoint[1]);
  7851. if (squaredDistance < minSquaredDistance) {
  7852. minSquaredDistance = squaredDistance;
  7853. for (i = 0; i < stride; ++i) {
  7854. closestPoint[i] = tmpPoint[i];
  7855. }
  7856. closestPoint.length = stride;
  7857. index += stride;
  7858. }
  7859. else {
  7860. // Skip ahead multiple points, because we know that all the skipped
  7861. // points cannot be any closer than the closest point we have found so
  7862. // far. We know this because we know how close the current point is, how
  7863. // close the closest point we have found so far is, and the maximum
  7864. // distance between consecutive points. For example, if we're currently
  7865. // at distance 10, the best we've found so far is 3, and that the maximum
  7866. // distance between consecutive points is 2, then we'll need to skip at
  7867. // least (10 - 3) / 2 == 3 (rounded down) points to have any chance of
  7868. // finding a closer point. We use Math.max(..., 1) to ensure that we
  7869. // always advance at least one point, to avoid an infinite loop.
  7870. index +=
  7871. stride *
  7872. Math.max(((Math.sqrt(squaredDistance) - Math.sqrt(minSquaredDistance)) /
  7873. maxDelta) |
  7874. 0, 1);
  7875. }
  7876. }
  7877. if (isRing) {
  7878. // Check the closing segment.
  7879. assignClosest(flatCoordinates, end - stride, offset, stride, x, y, tmpPoint);
  7880. squaredDistance = math_squaredDistance(x, y, tmpPoint[0], tmpPoint[1]);
  7881. if (squaredDistance < minSquaredDistance) {
  7882. minSquaredDistance = squaredDistance;
  7883. for (i = 0; i < stride; ++i) {
  7884. closestPoint[i] = tmpPoint[i];
  7885. }
  7886. closestPoint.length = stride;
  7887. }
  7888. }
  7889. return minSquaredDistance;
  7890. }
  7891. /**
  7892. * @param {Array<number>} flatCoordinates Flat coordinates.
  7893. * @param {number} offset Offset.
  7894. * @param {Array<number>} ends Ends.
  7895. * @param {number} stride Stride.
  7896. * @param {number} maxDelta Max delta.
  7897. * @param {boolean} isRing Is ring.
  7898. * @param {number} x X.
  7899. * @param {number} y Y.
  7900. * @param {Array<number>} closestPoint Closest point.
  7901. * @param {number} minSquaredDistance Minimum squared distance.
  7902. * @param {Array<number>} [opt_tmpPoint] Temporary point object.
  7903. * @return {number} Minimum squared distance.
  7904. */
  7905. function assignClosestArrayPoint(flatCoordinates, offset, ends, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) {
  7906. var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
  7907. for (var i = 0, ii = ends.length; i < ii; ++i) {
  7908. var end = ends[i];
  7909. minSquaredDistance = assignClosestPoint(flatCoordinates, offset, end, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
  7910. offset = end;
  7911. }
  7912. return minSquaredDistance;
  7913. }
  7914. /**
  7915. * @param {Array<number>} flatCoordinates Flat coordinates.
  7916. * @param {number} offset Offset.
  7917. * @param {Array<Array<number>>} endss Endss.
  7918. * @param {number} stride Stride.
  7919. * @param {number} maxDelta Max delta.
  7920. * @param {boolean} isRing Is ring.
  7921. * @param {number} x X.
  7922. * @param {number} y Y.
  7923. * @param {Array<number>} closestPoint Closest point.
  7924. * @param {number} minSquaredDistance Minimum squared distance.
  7925. * @param {Array<number>} [opt_tmpPoint] Temporary point object.
  7926. * @return {number} Minimum squared distance.
  7927. */
  7928. function assignClosestMultiArrayPoint(flatCoordinates, offset, endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) {
  7929. var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
  7930. for (var i = 0, ii = endss.length; i < ii; ++i) {
  7931. var ends = endss[i];
  7932. minSquaredDistance = assignClosestArrayPoint(flatCoordinates, offset, ends, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
  7933. offset = ends[ends.length - 1];
  7934. }
  7935. return minSquaredDistance;
  7936. }
  7937. //# sourceMappingURL=closest.js.map
  7938. ;// ./node_modules/ol/geom/flat/deflate.js
  7939. /**
  7940. * @module ol/geom/flat/deflate
  7941. */
  7942. /**
  7943. * @param {Array<number>} flatCoordinates Flat coordinates.
  7944. * @param {number} offset Offset.
  7945. * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
  7946. * @param {number} stride Stride.
  7947. * @return {number} offset Offset.
  7948. */
  7949. function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {
  7950. for (var i = 0, ii = coordinate.length; i < ii; ++i) {
  7951. flatCoordinates[offset++] = coordinate[i];
  7952. }
  7953. return offset;
  7954. }
  7955. /**
  7956. * @param {Array<number>} flatCoordinates Flat coordinates.
  7957. * @param {number} offset Offset.
  7958. * @param {Array<import("../../coordinate.js").Coordinate>} coordinates Coordinates.
  7959. * @param {number} stride Stride.
  7960. * @return {number} offset Offset.
  7961. */
  7962. function deflateCoordinates(flatCoordinates, offset, coordinates, stride) {
  7963. for (var i = 0, ii = coordinates.length; i < ii; ++i) {
  7964. var coordinate = coordinates[i];
  7965. for (var j = 0; j < stride; ++j) {
  7966. flatCoordinates[offset++] = coordinate[j];
  7967. }
  7968. }
  7969. return offset;
  7970. }
  7971. /**
  7972. * @param {Array<number>} flatCoordinates Flat coordinates.
  7973. * @param {number} offset Offset.
  7974. * @param {Array<Array<import("../../coordinate.js").Coordinate>>} coordinatess Coordinatess.
  7975. * @param {number} stride Stride.
  7976. * @param {Array<number>} [opt_ends] Ends.
  7977. * @return {Array<number>} Ends.
  7978. */
  7979. function deflateCoordinatesArray(flatCoordinates, offset, coordinatess, stride, opt_ends) {
  7980. var ends = opt_ends ? opt_ends : [];
  7981. var i = 0;
  7982. for (var j = 0, jj = coordinatess.length; j < jj; ++j) {
  7983. var end = deflateCoordinates(flatCoordinates, offset, coordinatess[j], stride);
  7984. ends[i++] = end;
  7985. offset = end;
  7986. }
  7987. ends.length = i;
  7988. return ends;
  7989. }
  7990. /**
  7991. * @param {Array<number>} flatCoordinates Flat coordinates.
  7992. * @param {number} offset Offset.
  7993. * @param {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} coordinatesss Coordinatesss.
  7994. * @param {number} stride Stride.
  7995. * @param {Array<Array<number>>} [opt_endss] Endss.
  7996. * @return {Array<Array<number>>} Endss.
  7997. */
  7998. function deflateMultiCoordinatesArray(flatCoordinates, offset, coordinatesss, stride, opt_endss) {
  7999. var endss = opt_endss ? opt_endss : [];
  8000. var i = 0;
  8001. for (var j = 0, jj = coordinatesss.length; j < jj; ++j) {
  8002. var ends = deflateCoordinatesArray(flatCoordinates, offset, coordinatesss[j], stride, endss[i]);
  8003. endss[i++] = ends;
  8004. offset = ends[ends.length - 1];
  8005. }
  8006. endss.length = i;
  8007. return endss;
  8008. }
  8009. //# sourceMappingURL=deflate.js.map
  8010. ;// ./node_modules/ol/geom/flat/simplify.js
  8011. /**
  8012. * @module ol/geom/flat/simplify
  8013. */
  8014. // Based on simplify-js https://github.com/mourner/simplify-js
  8015. // Copyright (c) 2012, Vladimir Agafonkin
  8016. // All rights reserved.
  8017. //
  8018. // Redistribution and use in source and binary forms, with or without
  8019. // modification, are permitted provided that the following conditions are met:
  8020. //
  8021. // 1. Redistributions of source code must retain the above copyright notice,
  8022. // this list of conditions and the following disclaimer.
  8023. //
  8024. // 2. Redistributions in binary form must reproduce the above copyright
  8025. // notice, this list of conditions and the following disclaimer in the
  8026. // documentation and/or other materials provided with the distribution.
  8027. //
  8028. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  8029. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8030. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  8031. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  8032. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  8033. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  8034. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  8035. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  8036. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  8037. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  8038. // POSSIBILITY OF SUCH DAMAGE.
  8039. /**
  8040. * @param {Array<number>} flatCoordinates Flat coordinates.
  8041. * @param {number} offset Offset.
  8042. * @param {number} end End.
  8043. * @param {number} stride Stride.
  8044. * @param {number} squaredTolerance Squared tolerance.
  8045. * @param {boolean} highQuality Highest quality.
  8046. * @param {Array<number>} [opt_simplifiedFlatCoordinates] Simplified flat
  8047. * coordinates.
  8048. * @return {Array<number>} Simplified line string.
  8049. */
  8050. function simplifyLineString(flatCoordinates, offset, end, stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
  8051. var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined
  8052. ? opt_simplifiedFlatCoordinates
  8053. : [];
  8054. if (!highQuality) {
  8055. end = radialDistance(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, 0);
  8056. flatCoordinates = simplifiedFlatCoordinates;
  8057. offset = 0;
  8058. stride = 2;
  8059. }
  8060. simplifiedFlatCoordinates.length = douglasPeucker(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, 0);
  8061. return simplifiedFlatCoordinates;
  8062. }
  8063. /**
  8064. * @param {Array<number>} flatCoordinates Flat coordinates.
  8065. * @param {number} offset Offset.
  8066. * @param {number} end End.
  8067. * @param {number} stride Stride.
  8068. * @param {number} squaredTolerance Squared tolerance.
  8069. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8070. * coordinates.
  8071. * @param {number} simplifiedOffset Simplified offset.
  8072. * @return {number} Simplified offset.
  8073. */
  8074. function douglasPeucker(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
  8075. var n = (end - offset) / stride;
  8076. if (n < 3) {
  8077. for (; offset < end; offset += stride) {
  8078. simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];
  8079. simplifiedFlatCoordinates[simplifiedOffset++] =
  8080. flatCoordinates[offset + 1];
  8081. }
  8082. return simplifiedOffset;
  8083. }
  8084. /** @type {Array<number>} */
  8085. var markers = new Array(n);
  8086. markers[0] = 1;
  8087. markers[n - 1] = 1;
  8088. /** @type {Array<number>} */
  8089. var stack = [offset, end - stride];
  8090. var index = 0;
  8091. while (stack.length > 0) {
  8092. var last = stack.pop();
  8093. var first = stack.pop();
  8094. var maxSquaredDistance = 0;
  8095. var x1 = flatCoordinates[first];
  8096. var y1 = flatCoordinates[first + 1];
  8097. var x2 = flatCoordinates[last];
  8098. var y2 = flatCoordinates[last + 1];
  8099. for (var i = first + stride; i < last; i += stride) {
  8100. var x = flatCoordinates[i];
  8101. var y = flatCoordinates[i + 1];
  8102. var squaredDistance_1 = squaredSegmentDistance(x, y, x1, y1, x2, y2);
  8103. if (squaredDistance_1 > maxSquaredDistance) {
  8104. index = i;
  8105. maxSquaredDistance = squaredDistance_1;
  8106. }
  8107. }
  8108. if (maxSquaredDistance > squaredTolerance) {
  8109. markers[(index - offset) / stride] = 1;
  8110. if (first + stride < index) {
  8111. stack.push(first, index);
  8112. }
  8113. if (index + stride < last) {
  8114. stack.push(index, last);
  8115. }
  8116. }
  8117. }
  8118. for (var i = 0; i < n; ++i) {
  8119. if (markers[i]) {
  8120. simplifiedFlatCoordinates[simplifiedOffset++] =
  8121. flatCoordinates[offset + i * stride];
  8122. simplifiedFlatCoordinates[simplifiedOffset++] =
  8123. flatCoordinates[offset + i * stride + 1];
  8124. }
  8125. }
  8126. return simplifiedOffset;
  8127. }
  8128. /**
  8129. * @param {Array<number>} flatCoordinates Flat coordinates.
  8130. * @param {number} offset Offset.
  8131. * @param {Array<number>} ends Ends.
  8132. * @param {number} stride Stride.
  8133. * @param {number} squaredTolerance Squared tolerance.
  8134. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8135. * coordinates.
  8136. * @param {number} simplifiedOffset Simplified offset.
  8137. * @param {Array<number>} simplifiedEnds Simplified ends.
  8138. * @return {number} Simplified offset.
  8139. */
  8140. function douglasPeuckerArray(flatCoordinates, offset, ends, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
  8141. for (var i = 0, ii = ends.length; i < ii; ++i) {
  8142. var end = ends[i];
  8143. simplifiedOffset = douglasPeucker(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset);
  8144. simplifiedEnds.push(simplifiedOffset);
  8145. offset = end;
  8146. }
  8147. return simplifiedOffset;
  8148. }
  8149. /**
  8150. * @param {Array<number>} flatCoordinates Flat coordinates.
  8151. * @param {number} offset Offset.
  8152. * @param {Array<Array<number>>} endss Endss.
  8153. * @param {number} stride Stride.
  8154. * @param {number} squaredTolerance Squared tolerance.
  8155. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8156. * coordinates.
  8157. * @param {number} simplifiedOffset Simplified offset.
  8158. * @param {Array<Array<number>>} simplifiedEndss Simplified endss.
  8159. * @return {number} Simplified offset.
  8160. */
  8161. function douglasPeuckerMultiArray(flatCoordinates, offset, endss, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
  8162. for (var i = 0, ii = endss.length; i < ii; ++i) {
  8163. var ends = endss[i];
  8164. var simplifiedEnds = [];
  8165. simplifiedOffset = douglasPeuckerArray(flatCoordinates, offset, ends, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
  8166. simplifiedEndss.push(simplifiedEnds);
  8167. offset = ends[ends.length - 1];
  8168. }
  8169. return simplifiedOffset;
  8170. }
  8171. /**
  8172. * @param {Array<number>} flatCoordinates Flat coordinates.
  8173. * @param {number} offset Offset.
  8174. * @param {number} end End.
  8175. * @param {number} stride Stride.
  8176. * @param {number} squaredTolerance Squared tolerance.
  8177. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8178. * coordinates.
  8179. * @param {number} simplifiedOffset Simplified offset.
  8180. * @return {number} Simplified offset.
  8181. */
  8182. function radialDistance(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
  8183. if (end <= offset + stride) {
  8184. // zero or one point, no simplification possible, so copy and return
  8185. for (; offset < end; offset += stride) {
  8186. simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];
  8187. simplifiedFlatCoordinates[simplifiedOffset++] =
  8188. flatCoordinates[offset + 1];
  8189. }
  8190. return simplifiedOffset;
  8191. }
  8192. var x1 = flatCoordinates[offset];
  8193. var y1 = flatCoordinates[offset + 1];
  8194. // copy first point
  8195. simplifiedFlatCoordinates[simplifiedOffset++] = x1;
  8196. simplifiedFlatCoordinates[simplifiedOffset++] = y1;
  8197. var x2 = x1;
  8198. var y2 = y1;
  8199. for (offset += stride; offset < end; offset += stride) {
  8200. x2 = flatCoordinates[offset];
  8201. y2 = flatCoordinates[offset + 1];
  8202. if (squaredDistance(x1, y1, x2, y2) > squaredTolerance) {
  8203. // copy point at offset
  8204. simplifiedFlatCoordinates[simplifiedOffset++] = x2;
  8205. simplifiedFlatCoordinates[simplifiedOffset++] = y2;
  8206. x1 = x2;
  8207. y1 = y2;
  8208. }
  8209. }
  8210. if (x2 != x1 || y2 != y1) {
  8211. // copy last point
  8212. simplifiedFlatCoordinates[simplifiedOffset++] = x2;
  8213. simplifiedFlatCoordinates[simplifiedOffset++] = y2;
  8214. }
  8215. return simplifiedOffset;
  8216. }
  8217. /**
  8218. * @param {number} value Value.
  8219. * @param {number} tolerance Tolerance.
  8220. * @return {number} Rounded value.
  8221. */
  8222. function snap(value, tolerance) {
  8223. return tolerance * Math.round(value / tolerance);
  8224. }
  8225. /**
  8226. * Simplifies a line string using an algorithm designed by Tim Schaub.
  8227. * Coordinates are snapped to the nearest value in a virtual grid and
  8228. * consecutive duplicate coordinates are discarded. This effectively preserves
  8229. * topology as the simplification of any subsection of a line string is
  8230. * independent of the rest of the line string. This means that, for examples,
  8231. * the common edge between two polygons will be simplified to the same line
  8232. * string independently in both polygons. This implementation uses a single
  8233. * pass over the coordinates and eliminates intermediate collinear points.
  8234. * @param {Array<number>} flatCoordinates Flat coordinates.
  8235. * @param {number} offset Offset.
  8236. * @param {number} end End.
  8237. * @param {number} stride Stride.
  8238. * @param {number} tolerance Tolerance.
  8239. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8240. * coordinates.
  8241. * @param {number} simplifiedOffset Simplified offset.
  8242. * @return {number} Simplified offset.
  8243. */
  8244. function quantize(flatCoordinates, offset, end, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
  8245. // do nothing if the line is empty
  8246. if (offset == end) {
  8247. return simplifiedOffset;
  8248. }
  8249. // snap the first coordinate (P1)
  8250. var x1 = snap(flatCoordinates[offset], tolerance);
  8251. var y1 = snap(flatCoordinates[offset + 1], tolerance);
  8252. offset += stride;
  8253. // add the first coordinate to the output
  8254. simplifiedFlatCoordinates[simplifiedOffset++] = x1;
  8255. simplifiedFlatCoordinates[simplifiedOffset++] = y1;
  8256. // find the next coordinate that does not snap to the same value as the first
  8257. // coordinate (P2)
  8258. var x2, y2;
  8259. do {
  8260. x2 = snap(flatCoordinates[offset], tolerance);
  8261. y2 = snap(flatCoordinates[offset + 1], tolerance);
  8262. offset += stride;
  8263. if (offset == end) {
  8264. // all coordinates snap to the same value, the line collapses to a point
  8265. // push the last snapped value anyway to ensure that the output contains
  8266. // at least two points
  8267. // FIXME should we really return at least two points anyway?
  8268. simplifiedFlatCoordinates[simplifiedOffset++] = x2;
  8269. simplifiedFlatCoordinates[simplifiedOffset++] = y2;
  8270. return simplifiedOffset;
  8271. }
  8272. } while (x2 == x1 && y2 == y1);
  8273. while (offset < end) {
  8274. // snap the next coordinate (P3)
  8275. var x3 = snap(flatCoordinates[offset], tolerance);
  8276. var y3 = snap(flatCoordinates[offset + 1], tolerance);
  8277. offset += stride;
  8278. // skip P3 if it is equal to P2
  8279. if (x3 == x2 && y3 == y2) {
  8280. continue;
  8281. }
  8282. // calculate the delta between P1 and P2
  8283. var dx1 = x2 - x1;
  8284. var dy1 = y2 - y1;
  8285. // calculate the delta between P3 and P1
  8286. var dx2 = x3 - x1;
  8287. var dy2 = y3 - y1;
  8288. // if P1, P2, and P3 are colinear and P3 is further from P1 than P2 is from
  8289. // P1 in the same direction then P2 is on the straight line between P1 and
  8290. // P3
  8291. if (dx1 * dy2 == dy1 * dx2 &&
  8292. ((dx1 < 0 && dx2 < dx1) || dx1 == dx2 || (dx1 > 0 && dx2 > dx1)) &&
  8293. ((dy1 < 0 && dy2 < dy1) || dy1 == dy2 || (dy1 > 0 && dy2 > dy1))) {
  8294. // discard P2 and set P2 = P3
  8295. x2 = x3;
  8296. y2 = y3;
  8297. continue;
  8298. }
  8299. // either P1, P2, and P3 are not colinear, or they are colinear but P3 is
  8300. // between P3 and P1 or on the opposite half of the line to P2. add P2,
  8301. // and continue with P1 = P2 and P2 = P3
  8302. simplifiedFlatCoordinates[simplifiedOffset++] = x2;
  8303. simplifiedFlatCoordinates[simplifiedOffset++] = y2;
  8304. x1 = x2;
  8305. y1 = y2;
  8306. x2 = x3;
  8307. y2 = y3;
  8308. }
  8309. // add the last point (P2)
  8310. simplifiedFlatCoordinates[simplifiedOffset++] = x2;
  8311. simplifiedFlatCoordinates[simplifiedOffset++] = y2;
  8312. return simplifiedOffset;
  8313. }
  8314. /**
  8315. * @param {Array<number>} flatCoordinates Flat coordinates.
  8316. * @param {number} offset Offset.
  8317. * @param {Array<number>} ends Ends.
  8318. * @param {number} stride Stride.
  8319. * @param {number} tolerance Tolerance.
  8320. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8321. * coordinates.
  8322. * @param {number} simplifiedOffset Simplified offset.
  8323. * @param {Array<number>} simplifiedEnds Simplified ends.
  8324. * @return {number} Simplified offset.
  8325. */
  8326. function quantizeArray(flatCoordinates, offset, ends, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
  8327. for (var i = 0, ii = ends.length; i < ii; ++i) {
  8328. var end = ends[i];
  8329. simplifiedOffset = quantize(flatCoordinates, offset, end, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset);
  8330. simplifiedEnds.push(simplifiedOffset);
  8331. offset = end;
  8332. }
  8333. return simplifiedOffset;
  8334. }
  8335. /**
  8336. * @param {Array<number>} flatCoordinates Flat coordinates.
  8337. * @param {number} offset Offset.
  8338. * @param {Array<Array<number>>} endss Endss.
  8339. * @param {number} stride Stride.
  8340. * @param {number} tolerance Tolerance.
  8341. * @param {Array<number>} simplifiedFlatCoordinates Simplified flat
  8342. * coordinates.
  8343. * @param {number} simplifiedOffset Simplified offset.
  8344. * @param {Array<Array<number>>} simplifiedEndss Simplified endss.
  8345. * @return {number} Simplified offset.
  8346. */
  8347. function quantizeMultiArray(flatCoordinates, offset, endss, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
  8348. for (var i = 0, ii = endss.length; i < ii; ++i) {
  8349. var ends = endss[i];
  8350. var simplifiedEnds = [];
  8351. simplifiedOffset = quantizeArray(flatCoordinates, offset, ends, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
  8352. simplifiedEndss.push(simplifiedEnds);
  8353. offset = ends[ends.length - 1];
  8354. }
  8355. return simplifiedOffset;
  8356. }
  8357. //# sourceMappingURL=simplify.js.map
  8358. ;// ./node_modules/ol/geom/flat/segments.js
  8359. /**
  8360. * @module ol/geom/flat/segments
  8361. */
  8362. /**
  8363. * This function calls `callback` for each segment of the flat coordinates
  8364. * array. If the callback returns a truthy value the function returns that
  8365. * value immediately. Otherwise the function returns `false`.
  8366. * @param {Array<number>} flatCoordinates Flat coordinates.
  8367. * @param {number} offset Offset.
  8368. * @param {number} end End.
  8369. * @param {number} stride Stride.
  8370. * @param {function(import("../../coordinate.js").Coordinate, import("../../coordinate.js").Coordinate): T} callback Function
  8371. * called for each segment.
  8372. * @return {T|boolean} Value.
  8373. * @template T
  8374. */
  8375. function forEach(flatCoordinates, offset, end, stride, callback) {
  8376. var ret;
  8377. offset += stride;
  8378. for (; offset < end; offset += stride) {
  8379. ret = callback(flatCoordinates.slice(offset - stride, offset), flatCoordinates.slice(offset, offset + stride));
  8380. if (ret) {
  8381. return ret;
  8382. }
  8383. }
  8384. return false;
  8385. }
  8386. //# sourceMappingURL=segments.js.map
  8387. ;// ./node_modules/ol/geom/flat/inflate.js
  8388. /**
  8389. * @module ol/geom/flat/inflate
  8390. */
  8391. /**
  8392. * @param {Array<number>} flatCoordinates Flat coordinates.
  8393. * @param {number} offset Offset.
  8394. * @param {number} end End.
  8395. * @param {number} stride Stride.
  8396. * @param {Array<import("../../coordinate.js").Coordinate>} [opt_coordinates] Coordinates.
  8397. * @return {Array<import("../../coordinate.js").Coordinate>} Coordinates.
  8398. */
  8399. function inflateCoordinates(flatCoordinates, offset, end, stride, opt_coordinates) {
  8400. var coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
  8401. var i = 0;
  8402. for (var j = offset; j < end; j += stride) {
  8403. coordinates[i++] = flatCoordinates.slice(j, j + stride);
  8404. }
  8405. coordinates.length = i;
  8406. return coordinates;
  8407. }
  8408. /**
  8409. * @param {Array<number>} flatCoordinates Flat coordinates.
  8410. * @param {number} offset Offset.
  8411. * @param {Array<number>} ends Ends.
  8412. * @param {number} stride Stride.
  8413. * @param {Array<Array<import("../../coordinate.js").Coordinate>>} [opt_coordinatess] Coordinatess.
  8414. * @return {Array<Array<import("../../coordinate.js").Coordinate>>} Coordinatess.
  8415. */
  8416. function inflateCoordinatesArray(flatCoordinates, offset, ends, stride, opt_coordinatess) {
  8417. var coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
  8418. var i = 0;
  8419. for (var j = 0, jj = ends.length; j < jj; ++j) {
  8420. var end = ends[j];
  8421. coordinatess[i++] = inflateCoordinates(flatCoordinates, offset, end, stride, coordinatess[i]);
  8422. offset = end;
  8423. }
  8424. coordinatess.length = i;
  8425. return coordinatess;
  8426. }
  8427. /**
  8428. * @param {Array<number>} flatCoordinates Flat coordinates.
  8429. * @param {number} offset Offset.
  8430. * @param {Array<Array<number>>} endss Endss.
  8431. * @param {number} stride Stride.
  8432. * @param {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} [opt_coordinatesss]
  8433. * Coordinatesss.
  8434. * @return {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} Coordinatesss.
  8435. */
  8436. function inflateMultiCoordinatesArray(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
  8437. var coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
  8438. var i = 0;
  8439. for (var j = 0, jj = endss.length; j < jj; ++j) {
  8440. var ends = endss[j];
  8441. coordinatesss[i++] = inflateCoordinatesArray(flatCoordinates, offset, ends, stride, coordinatesss[i]);
  8442. offset = ends[ends.length - 1];
  8443. }
  8444. coordinatesss.length = i;
  8445. return coordinatesss;
  8446. }
  8447. //# sourceMappingURL=inflate.js.map
  8448. ;// ./node_modules/ol/geom/flat/interpolate.js
  8449. /**
  8450. * @module ol/geom/flat/interpolate
  8451. */
  8452. /**
  8453. * @param {Array<number>} flatCoordinates Flat coordinates.
  8454. * @param {number} offset Offset.
  8455. * @param {number} end End.
  8456. * @param {number} stride Stride.
  8457. * @param {number} fraction Fraction.
  8458. * @param {Array<number>} [opt_dest] Destination.
  8459. * @param {number} [opt_dimension] Destination dimension (default is `2`)
  8460. * @return {Array<number>} Destination.
  8461. */
  8462. function interpolatePoint(flatCoordinates, offset, end, stride, fraction, opt_dest, opt_dimension) {
  8463. var o, t;
  8464. var n = (end - offset) / stride;
  8465. if (n === 1) {
  8466. o = offset;
  8467. }
  8468. else if (n === 2) {
  8469. o = offset;
  8470. t = fraction;
  8471. }
  8472. else if (n !== 0) {
  8473. var x1 = flatCoordinates[offset];
  8474. var y1 = flatCoordinates[offset + 1];
  8475. var length_1 = 0;
  8476. var cumulativeLengths = [0];
  8477. for (var i = offset + stride; i < end; i += stride) {
  8478. var x2 = flatCoordinates[i];
  8479. var y2 = flatCoordinates[i + 1];
  8480. length_1 += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  8481. cumulativeLengths.push(length_1);
  8482. x1 = x2;
  8483. y1 = y2;
  8484. }
  8485. var target = fraction * length_1;
  8486. var index = binarySearch(cumulativeLengths, target);
  8487. if (index < 0) {
  8488. t =
  8489. (target - cumulativeLengths[-index - 2]) /
  8490. (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);
  8491. o = offset + (-index - 2) * stride;
  8492. }
  8493. else {
  8494. o = offset + index * stride;
  8495. }
  8496. }
  8497. var dimension = opt_dimension > 1 ? opt_dimension : 2;
  8498. var dest = opt_dest ? opt_dest : new Array(dimension);
  8499. for (var i = 0; i < dimension; ++i) {
  8500. dest[i] =
  8501. o === undefined
  8502. ? NaN
  8503. : t === undefined
  8504. ? flatCoordinates[o + i]
  8505. : lerp(flatCoordinates[o + i], flatCoordinates[o + stride + i], t);
  8506. }
  8507. return dest;
  8508. }
  8509. /**
  8510. * @param {Array<number>} flatCoordinates Flat coordinates.
  8511. * @param {number} offset Offset.
  8512. * @param {number} end End.
  8513. * @param {number} stride Stride.
  8514. * @param {number} m M.
  8515. * @param {boolean} extrapolate Extrapolate.
  8516. * @return {import("../../coordinate.js").Coordinate|null} Coordinate.
  8517. */
  8518. function lineStringCoordinateAtM(flatCoordinates, offset, end, stride, m, extrapolate) {
  8519. if (end == offset) {
  8520. return null;
  8521. }
  8522. var coordinate;
  8523. if (m < flatCoordinates[offset + stride - 1]) {
  8524. if (extrapolate) {
  8525. coordinate = flatCoordinates.slice(offset, offset + stride);
  8526. coordinate[stride - 1] = m;
  8527. return coordinate;
  8528. }
  8529. else {
  8530. return null;
  8531. }
  8532. }
  8533. else if (flatCoordinates[end - 1] < m) {
  8534. if (extrapolate) {
  8535. coordinate = flatCoordinates.slice(end - stride, end);
  8536. coordinate[stride - 1] = m;
  8537. return coordinate;
  8538. }
  8539. else {
  8540. return null;
  8541. }
  8542. }
  8543. // FIXME use O(1) search
  8544. if (m == flatCoordinates[offset + stride - 1]) {
  8545. return flatCoordinates.slice(offset, offset + stride);
  8546. }
  8547. var lo = offset / stride;
  8548. var hi = end / stride;
  8549. while (lo < hi) {
  8550. var mid = (lo + hi) >> 1;
  8551. if (m < flatCoordinates[(mid + 1) * stride - 1]) {
  8552. hi = mid;
  8553. }
  8554. else {
  8555. lo = mid + 1;
  8556. }
  8557. }
  8558. var m0 = flatCoordinates[lo * stride - 1];
  8559. if (m == m0) {
  8560. return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);
  8561. }
  8562. var m1 = flatCoordinates[(lo + 1) * stride - 1];
  8563. var t = (m - m0) / (m1 - m0);
  8564. coordinate = [];
  8565. for (var i = 0; i < stride - 1; ++i) {
  8566. coordinate.push(lerp(flatCoordinates[(lo - 1) * stride + i], flatCoordinates[lo * stride + i], t));
  8567. }
  8568. coordinate.push(m);
  8569. return coordinate;
  8570. }
  8571. /**
  8572. * @param {Array<number>} flatCoordinates Flat coordinates.
  8573. * @param {number} offset Offset.
  8574. * @param {Array<number>} ends Ends.
  8575. * @param {number} stride Stride.
  8576. * @param {number} m M.
  8577. * @param {boolean} extrapolate Extrapolate.
  8578. * @param {boolean} interpolate Interpolate.
  8579. * @return {import("../../coordinate.js").Coordinate|null} Coordinate.
  8580. */
  8581. function lineStringsCoordinateAtM(flatCoordinates, offset, ends, stride, m, extrapolate, interpolate) {
  8582. if (interpolate) {
  8583. return lineStringCoordinateAtM(flatCoordinates, offset, ends[ends.length - 1], stride, m, extrapolate);
  8584. }
  8585. var coordinate;
  8586. if (m < flatCoordinates[stride - 1]) {
  8587. if (extrapolate) {
  8588. coordinate = flatCoordinates.slice(0, stride);
  8589. coordinate[stride - 1] = m;
  8590. return coordinate;
  8591. }
  8592. else {
  8593. return null;
  8594. }
  8595. }
  8596. if (flatCoordinates[flatCoordinates.length - 1] < m) {
  8597. if (extrapolate) {
  8598. coordinate = flatCoordinates.slice(flatCoordinates.length - stride);
  8599. coordinate[stride - 1] = m;
  8600. return coordinate;
  8601. }
  8602. else {
  8603. return null;
  8604. }
  8605. }
  8606. for (var i = 0, ii = ends.length; i < ii; ++i) {
  8607. var end = ends[i];
  8608. if (offset == end) {
  8609. continue;
  8610. }
  8611. if (m < flatCoordinates[offset + stride - 1]) {
  8612. return null;
  8613. }
  8614. else if (m <= flatCoordinates[end - 1]) {
  8615. return lineStringCoordinateAtM(flatCoordinates, offset, end, stride, m, false);
  8616. }
  8617. offset = end;
  8618. }
  8619. return null;
  8620. }
  8621. //# sourceMappingURL=interpolate.js.map
  8622. ;// ./node_modules/ol/geom/flat/contains.js
  8623. /**
  8624. * @module ol/geom/flat/contains
  8625. */
  8626. /**
  8627. * @param {Array<number>} flatCoordinates Flat coordinates.
  8628. * @param {number} offset Offset.
  8629. * @param {number} end End.
  8630. * @param {number} stride Stride.
  8631. * @param {import("../../extent.js").Extent} extent Extent.
  8632. * @return {boolean} Contains extent.
  8633. */
  8634. function linearRingContainsExtent(flatCoordinates, offset, end, stride, extent) {
  8635. var outside = forEachCorner(extent,
  8636. /**
  8637. * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
  8638. * @return {boolean} Contains (x, y).
  8639. */
  8640. function (coordinate) {
  8641. return !linearRingContainsXY(flatCoordinates, offset, end, stride, coordinate[0], coordinate[1]);
  8642. });
  8643. return !outside;
  8644. }
  8645. /**
  8646. * @param {Array<number>} flatCoordinates Flat coordinates.
  8647. * @param {number} offset Offset.
  8648. * @param {number} end End.
  8649. * @param {number} stride Stride.
  8650. * @param {number} x X.
  8651. * @param {number} y Y.
  8652. * @return {boolean} Contains (x, y).
  8653. */
  8654. function linearRingContainsXY(flatCoordinates, offset, end, stride, x, y) {
  8655. // https://geomalgorithms.com/a03-_inclusion.html
  8656. // Copyright 2000 softSurfer, 2012 Dan Sunday
  8657. // This code may be freely used and modified for any purpose
  8658. // providing that this copyright notice is included with it.
  8659. // SoftSurfer makes no warranty for this code, and cannot be held
  8660. // liable for any real or imagined damage resulting from its use.
  8661. // Users of this code must verify correctness for their application.
  8662. var wn = 0;
  8663. var x1 = flatCoordinates[end - stride];
  8664. var y1 = flatCoordinates[end - stride + 1];
  8665. for (; offset < end; offset += stride) {
  8666. var x2 = flatCoordinates[offset];
  8667. var y2 = flatCoordinates[offset + 1];
  8668. if (y1 <= y) {
  8669. if (y2 > y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) > 0) {
  8670. wn++;
  8671. }
  8672. }
  8673. else if (y2 <= y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) < 0) {
  8674. wn--;
  8675. }
  8676. x1 = x2;
  8677. y1 = y2;
  8678. }
  8679. return wn !== 0;
  8680. }
  8681. /**
  8682. * @param {Array<number>} flatCoordinates Flat coordinates.
  8683. * @param {number} offset Offset.
  8684. * @param {Array<number>} ends Ends.
  8685. * @param {number} stride Stride.
  8686. * @param {number} x X.
  8687. * @param {number} y Y.
  8688. * @return {boolean} Contains (x, y).
  8689. */
  8690. function linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y) {
  8691. if (ends.length === 0) {
  8692. return false;
  8693. }
  8694. if (!linearRingContainsXY(flatCoordinates, offset, ends[0], stride, x, y)) {
  8695. return false;
  8696. }
  8697. for (var i = 1, ii = ends.length; i < ii; ++i) {
  8698. if (linearRingContainsXY(flatCoordinates, ends[i - 1], ends[i], stride, x, y)) {
  8699. return false;
  8700. }
  8701. }
  8702. return true;
  8703. }
  8704. /**
  8705. * @param {Array<number>} flatCoordinates Flat coordinates.
  8706. * @param {number} offset Offset.
  8707. * @param {Array<Array<number>>} endss Endss.
  8708. * @param {number} stride Stride.
  8709. * @param {number} x X.
  8710. * @param {number} y Y.
  8711. * @return {boolean} Contains (x, y).
  8712. */
  8713. function linearRingssContainsXY(flatCoordinates, offset, endss, stride, x, y) {
  8714. if (endss.length === 0) {
  8715. return false;
  8716. }
  8717. for (var i = 0, ii = endss.length; i < ii; ++i) {
  8718. var ends = endss[i];
  8719. if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {
  8720. return true;
  8721. }
  8722. offset = ends[ends.length - 1];
  8723. }
  8724. return false;
  8725. }
  8726. //# sourceMappingURL=contains.js.map
  8727. ;// ./node_modules/ol/geom/flat/intersectsextent.js
  8728. /**
  8729. * @module ol/geom/flat/intersectsextent
  8730. */
  8731. /**
  8732. * @param {Array<number>} flatCoordinates Flat coordinates.
  8733. * @param {number} offset Offset.
  8734. * @param {number} end End.
  8735. * @param {number} stride Stride.
  8736. * @param {import("../../extent.js").Extent} extent Extent.
  8737. * @return {boolean} True if the geometry and the extent intersect.
  8738. */
  8739. function intersectsLineString(flatCoordinates, offset, end, stride, extent) {
  8740. var coordinatesExtent = extendFlatCoordinates(createEmpty(), flatCoordinates, offset, end, stride);
  8741. if (!intersects(extent, coordinatesExtent)) {
  8742. return false;
  8743. }
  8744. if (containsExtent(extent, coordinatesExtent)) {
  8745. return true;
  8746. }
  8747. if (coordinatesExtent[0] >= extent[0] && coordinatesExtent[2] <= extent[2]) {
  8748. return true;
  8749. }
  8750. if (coordinatesExtent[1] >= extent[1] && coordinatesExtent[3] <= extent[3]) {
  8751. return true;
  8752. }
  8753. return forEach(flatCoordinates, offset, end, stride,
  8754. /**
  8755. * @param {import("../../coordinate.js").Coordinate} point1 Start point.
  8756. * @param {import("../../coordinate.js").Coordinate} point2 End point.
  8757. * @return {boolean} `true` if the segment and the extent intersect,
  8758. * `false` otherwise.
  8759. */
  8760. function (point1, point2) {
  8761. return intersectsSegment(extent, point1, point2);
  8762. });
  8763. }
  8764. /**
  8765. * @param {Array<number>} flatCoordinates Flat coordinates.
  8766. * @param {number} offset Offset.
  8767. * @param {Array<number>} ends Ends.
  8768. * @param {number} stride Stride.
  8769. * @param {import("../../extent.js").Extent} extent Extent.
  8770. * @return {boolean} True if the geometry and the extent intersect.
  8771. */
  8772. function intersectsLineStringArray(flatCoordinates, offset, ends, stride, extent) {
  8773. for (var i = 0, ii = ends.length; i < ii; ++i) {
  8774. if (intersectsLineString(flatCoordinates, offset, ends[i], stride, extent)) {
  8775. return true;
  8776. }
  8777. offset = ends[i];
  8778. }
  8779. return false;
  8780. }
  8781. /**
  8782. * @param {Array<number>} flatCoordinates Flat coordinates.
  8783. * @param {number} offset Offset.
  8784. * @param {number} end End.
  8785. * @param {number} stride Stride.
  8786. * @param {import("../../extent.js").Extent} extent Extent.
  8787. * @return {boolean} True if the geometry and the extent intersect.
  8788. */
  8789. function intersectsLinearRing(flatCoordinates, offset, end, stride, extent) {
  8790. if (intersectsLineString(flatCoordinates, offset, end, stride, extent)) {
  8791. return true;
  8792. }
  8793. if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[0], extent[1])) {
  8794. return true;
  8795. }
  8796. if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[0], extent[3])) {
  8797. return true;
  8798. }
  8799. if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[2], extent[1])) {
  8800. return true;
  8801. }
  8802. if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[2], extent[3])) {
  8803. return true;
  8804. }
  8805. return false;
  8806. }
  8807. /**
  8808. * @param {Array<number>} flatCoordinates Flat coordinates.
  8809. * @param {number} offset Offset.
  8810. * @param {Array<number>} ends Ends.
  8811. * @param {number} stride Stride.
  8812. * @param {import("../../extent.js").Extent} extent Extent.
  8813. * @return {boolean} True if the geometry and the extent intersect.
  8814. */
  8815. function intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent) {
  8816. if (!intersectsLinearRing(flatCoordinates, offset, ends[0], stride, extent)) {
  8817. return false;
  8818. }
  8819. if (ends.length === 1) {
  8820. return true;
  8821. }
  8822. for (var i = 1, ii = ends.length; i < ii; ++i) {
  8823. if (linearRingContainsExtent(flatCoordinates, ends[i - 1], ends[i], stride, extent)) {
  8824. if (!intersectsLineString(flatCoordinates, ends[i - 1], ends[i], stride, extent)) {
  8825. return false;
  8826. }
  8827. }
  8828. }
  8829. return true;
  8830. }
  8831. /**
  8832. * @param {Array<number>} flatCoordinates Flat coordinates.
  8833. * @param {number} offset Offset.
  8834. * @param {Array<Array<number>>} endss Endss.
  8835. * @param {number} stride Stride.
  8836. * @param {import("../../extent.js").Extent} extent Extent.
  8837. * @return {boolean} True if the geometry and the extent intersect.
  8838. */
  8839. function intersectsLinearRingMultiArray(flatCoordinates, offset, endss, stride, extent) {
  8840. for (var i = 0, ii = endss.length; i < ii; ++i) {
  8841. var ends = endss[i];
  8842. if (intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent)) {
  8843. return true;
  8844. }
  8845. offset = ends[ends.length - 1];
  8846. }
  8847. return false;
  8848. }
  8849. //# sourceMappingURL=intersectsextent.js.map
  8850. ;// ./node_modules/ol/geom/flat/length.js
  8851. /**
  8852. * @module ol/geom/flat/length
  8853. */
  8854. /**
  8855. * @param {Array<number>} flatCoordinates Flat coordinates.
  8856. * @param {number} offset Offset.
  8857. * @param {number} end End.
  8858. * @param {number} stride Stride.
  8859. * @return {number} Length.
  8860. */
  8861. function lineStringLength(flatCoordinates, offset, end, stride) {
  8862. var x1 = flatCoordinates[offset];
  8863. var y1 = flatCoordinates[offset + 1];
  8864. var length = 0;
  8865. for (var i = offset + stride; i < end; i += stride) {
  8866. var x2 = flatCoordinates[i];
  8867. var y2 = flatCoordinates[i + 1];
  8868. length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  8869. x1 = x2;
  8870. y1 = y2;
  8871. }
  8872. return length;
  8873. }
  8874. /**
  8875. * @param {Array<number>} flatCoordinates Flat coordinates.
  8876. * @param {number} offset Offset.
  8877. * @param {number} end End.
  8878. * @param {number} stride Stride.
  8879. * @return {number} Perimeter.
  8880. */
  8881. function linearRingLength(flatCoordinates, offset, end, stride) {
  8882. var perimeter = lineStringLength(flatCoordinates, offset, end, stride);
  8883. var dx = flatCoordinates[end - stride] - flatCoordinates[offset];
  8884. var dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
  8885. perimeter += Math.sqrt(dx * dx + dy * dy);
  8886. return perimeter;
  8887. }
  8888. //# sourceMappingURL=length.js.map
  8889. ;// ./node_modules/ol/geom/LineString.js
  8890. var LineString_extends = (undefined && undefined.__extends) || (function () {
  8891. var extendStatics = function (d, b) {
  8892. extendStatics = Object.setPrototypeOf ||
  8893. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8894. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  8895. return extendStatics(d, b);
  8896. };
  8897. return function (d, b) {
  8898. if (typeof b !== "function" && b !== null)
  8899. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  8900. extendStatics(d, b);
  8901. function __() { this.constructor = d; }
  8902. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8903. };
  8904. })();
  8905. /**
  8906. * @module ol/geom/LineString
  8907. */
  8908. /**
  8909. * @classdesc
  8910. * Linestring geometry.
  8911. *
  8912. * @api
  8913. */
  8914. var LineString = /** @class */ (function (_super) {
  8915. LineString_extends(LineString, _super);
  8916. /**
  8917. * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
  8918. * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
  8919. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  8920. */
  8921. function LineString(coordinates, opt_layout) {
  8922. var _this = _super.call(this) || this;
  8923. /**
  8924. * @private
  8925. * @type {import("../coordinate.js").Coordinate}
  8926. */
  8927. _this.flatMidpoint_ = null;
  8928. /**
  8929. * @private
  8930. * @type {number}
  8931. */
  8932. _this.flatMidpointRevision_ = -1;
  8933. /**
  8934. * @private
  8935. * @type {number}
  8936. */
  8937. _this.maxDelta_ = -1;
  8938. /**
  8939. * @private
  8940. * @type {number}
  8941. */
  8942. _this.maxDeltaRevision_ = -1;
  8943. if (opt_layout !== undefined && !Array.isArray(coordinates[0])) {
  8944. _this.setFlatCoordinates(opt_layout,
  8945. /** @type {Array<number>} */ (coordinates));
  8946. }
  8947. else {
  8948. _this.setCoordinates(
  8949. /** @type {Array<import("../coordinate.js").Coordinate>} */ (coordinates), opt_layout);
  8950. }
  8951. return _this;
  8952. }
  8953. /**
  8954. * Append the passed coordinate to the coordinates of the linestring.
  8955. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  8956. * @api
  8957. */
  8958. LineString.prototype.appendCoordinate = function (coordinate) {
  8959. if (!this.flatCoordinates) {
  8960. this.flatCoordinates = coordinate.slice();
  8961. }
  8962. else {
  8963. array_extend(this.flatCoordinates, coordinate);
  8964. }
  8965. this.changed();
  8966. };
  8967. /**
  8968. * Make a complete copy of the geometry.
  8969. * @return {!LineString} Clone.
  8970. * @api
  8971. */
  8972. LineString.prototype.clone = function () {
  8973. var lineString = new LineString(this.flatCoordinates.slice(), this.layout);
  8974. lineString.applyProperties(this);
  8975. return lineString;
  8976. };
  8977. /**
  8978. * @param {number} x X.
  8979. * @param {number} y Y.
  8980. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  8981. * @param {number} minSquaredDistance Minimum squared distance.
  8982. * @return {number} Minimum squared distance.
  8983. */
  8984. LineString.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  8985. if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
  8986. return minSquaredDistance;
  8987. }
  8988. if (this.maxDeltaRevision_ != this.getRevision()) {
  8989. this.maxDelta_ = Math.sqrt(maxSquaredDelta(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
  8990. this.maxDeltaRevision_ = this.getRevision();
  8991. }
  8992. return assignClosestPoint(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
  8993. };
  8994. /**
  8995. * Iterate over each segment, calling the provided callback.
  8996. * If the callback returns a truthy value the function returns that
  8997. * value immediately. Otherwise the function returns `false`.
  8998. *
  8999. * @param {function(this: S, import("../coordinate.js").Coordinate, import("../coordinate.js").Coordinate): T} callback Function
  9000. * called for each segment. The function will receive two arguments, the start and end coordinates of the segment.
  9001. * @return {T|boolean} Value.
  9002. * @template T,S
  9003. * @api
  9004. */
  9005. LineString.prototype.forEachSegment = function (callback) {
  9006. return forEach(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, callback);
  9007. };
  9008. /**
  9009. * Returns the coordinate at `m` using linear interpolation, or `null` if no
  9010. * such coordinate exists.
  9011. *
  9012. * `opt_extrapolate` controls extrapolation beyond the range of Ms in the
  9013. * MultiLineString. If `opt_extrapolate` is `true` then Ms less than the first
  9014. * M will return the first coordinate and Ms greater than the last M will
  9015. * return the last coordinate.
  9016. *
  9017. * @param {number} m M.
  9018. * @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
  9019. * @return {import("../coordinate.js").Coordinate|null} Coordinate.
  9020. * @api
  9021. */
  9022. LineString.prototype.getCoordinateAtM = function (m, opt_extrapolate) {
  9023. if (this.layout != geom_GeometryLayout.XYM &&
  9024. this.layout != geom_GeometryLayout.XYZM) {
  9025. return null;
  9026. }
  9027. var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
  9028. return lineStringCoordinateAtM(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, m, extrapolate);
  9029. };
  9030. /**
  9031. * Return the coordinates of the linestring.
  9032. * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
  9033. * @api
  9034. */
  9035. LineString.prototype.getCoordinates = function () {
  9036. return inflateCoordinates(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
  9037. };
  9038. /**
  9039. * Return the coordinate at the provided fraction along the linestring.
  9040. * The `fraction` is a number between 0 and 1, where 0 is the start of the
  9041. * linestring and 1 is the end.
  9042. * @param {number} fraction Fraction.
  9043. * @param {import("../coordinate.js").Coordinate} [opt_dest] Optional coordinate whose values will
  9044. * be modified. If not provided, a new coordinate will be returned.
  9045. * @return {import("../coordinate.js").Coordinate} Coordinate of the interpolated point.
  9046. * @api
  9047. */
  9048. LineString.prototype.getCoordinateAt = function (fraction, opt_dest) {
  9049. return interpolatePoint(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, fraction, opt_dest, this.stride);
  9050. };
  9051. /**
  9052. * Return the length of the linestring on projected plane.
  9053. * @return {number} Length (on projected plane).
  9054. * @api
  9055. */
  9056. LineString.prototype.getLength = function () {
  9057. return lineStringLength(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
  9058. };
  9059. /**
  9060. * @return {Array<number>} Flat midpoint.
  9061. */
  9062. LineString.prototype.getFlatMidpoint = function () {
  9063. if (this.flatMidpointRevision_ != this.getRevision()) {
  9064. this.flatMidpoint_ = this.getCoordinateAt(0.5, this.flatMidpoint_);
  9065. this.flatMidpointRevision_ = this.getRevision();
  9066. }
  9067. return this.flatMidpoint_;
  9068. };
  9069. /**
  9070. * @param {number} squaredTolerance Squared tolerance.
  9071. * @return {LineString} Simplified LineString.
  9072. * @protected
  9073. */
  9074. LineString.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
  9075. var simplifiedFlatCoordinates = [];
  9076. simplifiedFlatCoordinates.length = douglasPeucker(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0);
  9077. return new LineString(simplifiedFlatCoordinates, geom_GeometryLayout.XY);
  9078. };
  9079. /**
  9080. * Get the type of this geometry.
  9081. * @return {import("./Geometry.js").Type} Geometry type.
  9082. * @api
  9083. */
  9084. LineString.prototype.getType = function () {
  9085. return 'LineString';
  9086. };
  9087. /**
  9088. * Test if the geometry and the passed extent intersect.
  9089. * @param {import("../extent.js").Extent} extent Extent.
  9090. * @return {boolean} `true` if the geometry and the extent intersect.
  9091. * @api
  9092. */
  9093. LineString.prototype.intersectsExtent = function (extent) {
  9094. return intersectsLineString(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, extent);
  9095. };
  9096. /**
  9097. * Set the coordinates of the linestring.
  9098. * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
  9099. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9100. * @api
  9101. */
  9102. LineString.prototype.setCoordinates = function (coordinates, opt_layout) {
  9103. this.setLayout(opt_layout, coordinates, 1);
  9104. if (!this.flatCoordinates) {
  9105. this.flatCoordinates = [];
  9106. }
  9107. this.flatCoordinates.length = deflateCoordinates(this.flatCoordinates, 0, coordinates, this.stride);
  9108. this.changed();
  9109. };
  9110. return LineString;
  9111. }(geom_SimpleGeometry));
  9112. /* harmony default export */ var geom_LineString = (LineString);
  9113. //# sourceMappingURL=LineString.js.map
  9114. ;// ./node_modules/ol/geom/flat/area.js
  9115. /**
  9116. * @module ol/geom/flat/area
  9117. */
  9118. /**
  9119. * @param {Array<number>} flatCoordinates Flat coordinates.
  9120. * @param {number} offset Offset.
  9121. * @param {number} end End.
  9122. * @param {number} stride Stride.
  9123. * @return {number} Area.
  9124. */
  9125. function linearRing(flatCoordinates, offset, end, stride) {
  9126. var twiceArea = 0;
  9127. var x1 = flatCoordinates[end - stride];
  9128. var y1 = flatCoordinates[end - stride + 1];
  9129. for (; offset < end; offset += stride) {
  9130. var x2 = flatCoordinates[offset];
  9131. var y2 = flatCoordinates[offset + 1];
  9132. twiceArea += y1 * x2 - x1 * y2;
  9133. x1 = x2;
  9134. y1 = y2;
  9135. }
  9136. return twiceArea / 2;
  9137. }
  9138. /**
  9139. * @param {Array<number>} flatCoordinates Flat coordinates.
  9140. * @param {number} offset Offset.
  9141. * @param {Array<number>} ends Ends.
  9142. * @param {number} stride Stride.
  9143. * @return {number} Area.
  9144. */
  9145. function linearRings(flatCoordinates, offset, ends, stride) {
  9146. var area = 0;
  9147. for (var i = 0, ii = ends.length; i < ii; ++i) {
  9148. var end = ends[i];
  9149. area += linearRing(flatCoordinates, offset, end, stride);
  9150. offset = end;
  9151. }
  9152. return area;
  9153. }
  9154. /**
  9155. * @param {Array<number>} flatCoordinates Flat coordinates.
  9156. * @param {number} offset Offset.
  9157. * @param {Array<Array<number>>} endss Endss.
  9158. * @param {number} stride Stride.
  9159. * @return {number} Area.
  9160. */
  9161. function linearRingss(flatCoordinates, offset, endss, stride) {
  9162. var area = 0;
  9163. for (var i = 0, ii = endss.length; i < ii; ++i) {
  9164. var ends = endss[i];
  9165. area += linearRings(flatCoordinates, offset, ends, stride);
  9166. offset = ends[ends.length - 1];
  9167. }
  9168. return area;
  9169. }
  9170. //# sourceMappingURL=area.js.map
  9171. ;// ./node_modules/ol/geom/LinearRing.js
  9172. var LinearRing_extends = (undefined && undefined.__extends) || (function () {
  9173. var extendStatics = function (d, b) {
  9174. extendStatics = Object.setPrototypeOf ||
  9175. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9176. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  9177. return extendStatics(d, b);
  9178. };
  9179. return function (d, b) {
  9180. if (typeof b !== "function" && b !== null)
  9181. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  9182. extendStatics(d, b);
  9183. function __() { this.constructor = d; }
  9184. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9185. };
  9186. })();
  9187. /**
  9188. * @module ol/geom/LinearRing
  9189. */
  9190. /**
  9191. * @classdesc
  9192. * Linear ring geometry. Only used as part of polygon; cannot be rendered
  9193. * on its own.
  9194. *
  9195. * @api
  9196. */
  9197. var LinearRing = /** @class */ (function (_super) {
  9198. LinearRing_extends(LinearRing, _super);
  9199. /**
  9200. * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
  9201. * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
  9202. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9203. */
  9204. function LinearRing(coordinates, opt_layout) {
  9205. var _this = _super.call(this) || this;
  9206. /**
  9207. * @private
  9208. * @type {number}
  9209. */
  9210. _this.maxDelta_ = -1;
  9211. /**
  9212. * @private
  9213. * @type {number}
  9214. */
  9215. _this.maxDeltaRevision_ = -1;
  9216. if (opt_layout !== undefined && !Array.isArray(coordinates[0])) {
  9217. _this.setFlatCoordinates(opt_layout,
  9218. /** @type {Array<number>} */ (coordinates));
  9219. }
  9220. else {
  9221. _this.setCoordinates(
  9222. /** @type {Array<import("../coordinate.js").Coordinate>} */ (coordinates), opt_layout);
  9223. }
  9224. return _this;
  9225. }
  9226. /**
  9227. * Make a complete copy of the geometry.
  9228. * @return {!LinearRing} Clone.
  9229. * @api
  9230. */
  9231. LinearRing.prototype.clone = function () {
  9232. return new LinearRing(this.flatCoordinates.slice(), this.layout);
  9233. };
  9234. /**
  9235. * @param {number} x X.
  9236. * @param {number} y Y.
  9237. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  9238. * @param {number} minSquaredDistance Minimum squared distance.
  9239. * @return {number} Minimum squared distance.
  9240. */
  9241. LinearRing.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  9242. if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
  9243. return minSquaredDistance;
  9244. }
  9245. if (this.maxDeltaRevision_ != this.getRevision()) {
  9246. this.maxDelta_ = Math.sqrt(maxSquaredDelta(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
  9247. this.maxDeltaRevision_ = this.getRevision();
  9248. }
  9249. return assignClosestPoint(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
  9250. };
  9251. /**
  9252. * Return the area of the linear ring on projected plane.
  9253. * @return {number} Area (on projected plane).
  9254. * @api
  9255. */
  9256. LinearRing.prototype.getArea = function () {
  9257. return linearRing(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
  9258. };
  9259. /**
  9260. * Return the coordinates of the linear ring.
  9261. * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
  9262. * @api
  9263. */
  9264. LinearRing.prototype.getCoordinates = function () {
  9265. return inflateCoordinates(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
  9266. };
  9267. /**
  9268. * @param {number} squaredTolerance Squared tolerance.
  9269. * @return {LinearRing} Simplified LinearRing.
  9270. * @protected
  9271. */
  9272. LinearRing.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
  9273. var simplifiedFlatCoordinates = [];
  9274. simplifiedFlatCoordinates.length = douglasPeucker(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0);
  9275. return new LinearRing(simplifiedFlatCoordinates, geom_GeometryLayout.XY);
  9276. };
  9277. /**
  9278. * Get the type of this geometry.
  9279. * @return {import("./Geometry.js").Type} Geometry type.
  9280. * @api
  9281. */
  9282. LinearRing.prototype.getType = function () {
  9283. return 'LinearRing';
  9284. };
  9285. /**
  9286. * Test if the geometry and the passed extent intersect.
  9287. * @param {import("../extent.js").Extent} extent Extent.
  9288. * @return {boolean} `true` if the geometry and the extent intersect.
  9289. * @api
  9290. */
  9291. LinearRing.prototype.intersectsExtent = function (extent) {
  9292. return false;
  9293. };
  9294. /**
  9295. * Set the coordinates of the linear ring.
  9296. * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
  9297. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9298. * @api
  9299. */
  9300. LinearRing.prototype.setCoordinates = function (coordinates, opt_layout) {
  9301. this.setLayout(opt_layout, coordinates, 1);
  9302. if (!this.flatCoordinates) {
  9303. this.flatCoordinates = [];
  9304. }
  9305. this.flatCoordinates.length = deflateCoordinates(this.flatCoordinates, 0, coordinates, this.stride);
  9306. this.changed();
  9307. };
  9308. return LinearRing;
  9309. }(geom_SimpleGeometry));
  9310. /* harmony default export */ var geom_LinearRing = (LinearRing);
  9311. //# sourceMappingURL=LinearRing.js.map
  9312. ;// ./node_modules/ol/geom/MultiLineString.js
  9313. var MultiLineString_extends = (undefined && undefined.__extends) || (function () {
  9314. var extendStatics = function (d, b) {
  9315. extendStatics = Object.setPrototypeOf ||
  9316. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9317. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  9318. return extendStatics(d, b);
  9319. };
  9320. return function (d, b) {
  9321. if (typeof b !== "function" && b !== null)
  9322. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  9323. extendStatics(d, b);
  9324. function __() { this.constructor = d; }
  9325. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9326. };
  9327. })();
  9328. /**
  9329. * @module ol/geom/MultiLineString
  9330. */
  9331. /**
  9332. * @classdesc
  9333. * Multi-linestring geometry.
  9334. *
  9335. * @api
  9336. */
  9337. var MultiLineString = /** @class */ (function (_super) {
  9338. MultiLineString_extends(MultiLineString, _super);
  9339. /**
  9340. * @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates
  9341. * Coordinates or LineString geometries. (For internal use, flat coordinates in
  9342. * combination with `opt_layout` and `opt_ends` are also accepted.)
  9343. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9344. * @param {Array<number>} [opt_ends] Flat coordinate ends for internal use.
  9345. */
  9346. function MultiLineString(coordinates, opt_layout, opt_ends) {
  9347. var _this = _super.call(this) || this;
  9348. /**
  9349. * @type {Array<number>}
  9350. * @private
  9351. */
  9352. _this.ends_ = [];
  9353. /**
  9354. * @private
  9355. * @type {number}
  9356. */
  9357. _this.maxDelta_ = -1;
  9358. /**
  9359. * @private
  9360. * @type {number}
  9361. */
  9362. _this.maxDeltaRevision_ = -1;
  9363. if (Array.isArray(coordinates[0])) {
  9364. _this.setCoordinates(
  9365. /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */ (coordinates), opt_layout);
  9366. }
  9367. else if (opt_layout !== undefined && opt_ends) {
  9368. _this.setFlatCoordinates(opt_layout,
  9369. /** @type {Array<number>} */ (coordinates));
  9370. _this.ends_ = opt_ends;
  9371. }
  9372. else {
  9373. var layout = _this.getLayout();
  9374. var lineStrings = /** @type {Array<LineString>} */ (coordinates);
  9375. var flatCoordinates = [];
  9376. var ends = [];
  9377. for (var i = 0, ii = lineStrings.length; i < ii; ++i) {
  9378. var lineString = lineStrings[i];
  9379. if (i === 0) {
  9380. layout = lineString.getLayout();
  9381. }
  9382. array_extend(flatCoordinates, lineString.getFlatCoordinates());
  9383. ends.push(flatCoordinates.length);
  9384. }
  9385. _this.setFlatCoordinates(layout, flatCoordinates);
  9386. _this.ends_ = ends;
  9387. }
  9388. return _this;
  9389. }
  9390. /**
  9391. * Append the passed linestring to the multilinestring.
  9392. * @param {LineString} lineString LineString.
  9393. * @api
  9394. */
  9395. MultiLineString.prototype.appendLineString = function (lineString) {
  9396. if (!this.flatCoordinates) {
  9397. this.flatCoordinates = lineString.getFlatCoordinates().slice();
  9398. }
  9399. else {
  9400. array_extend(this.flatCoordinates, lineString.getFlatCoordinates().slice());
  9401. }
  9402. this.ends_.push(this.flatCoordinates.length);
  9403. this.changed();
  9404. };
  9405. /**
  9406. * Make a complete copy of the geometry.
  9407. * @return {!MultiLineString} Clone.
  9408. * @api
  9409. */
  9410. MultiLineString.prototype.clone = function () {
  9411. var multiLineString = new MultiLineString(this.flatCoordinates.slice(), this.layout, this.ends_.slice());
  9412. multiLineString.applyProperties(this);
  9413. return multiLineString;
  9414. };
  9415. /**
  9416. * @param {number} x X.
  9417. * @param {number} y Y.
  9418. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  9419. * @param {number} minSquaredDistance Minimum squared distance.
  9420. * @return {number} Minimum squared distance.
  9421. */
  9422. MultiLineString.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  9423. if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
  9424. return minSquaredDistance;
  9425. }
  9426. if (this.maxDeltaRevision_ != this.getRevision()) {
  9427. this.maxDelta_ = Math.sqrt(arrayMaxSquaredDelta(this.flatCoordinates, 0, this.ends_, this.stride, 0));
  9428. this.maxDeltaRevision_ = this.getRevision();
  9429. }
  9430. return assignClosestArrayPoint(this.flatCoordinates, 0, this.ends_, this.stride, this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
  9431. };
  9432. /**
  9433. * Returns the coordinate at `m` using linear interpolation, or `null` if no
  9434. * such coordinate exists.
  9435. *
  9436. * `opt_extrapolate` controls extrapolation beyond the range of Ms in the
  9437. * MultiLineString. If `opt_extrapolate` is `true` then Ms less than the first
  9438. * M will return the first coordinate and Ms greater than the last M will
  9439. * return the last coordinate.
  9440. *
  9441. * `opt_interpolate` controls interpolation between consecutive LineStrings
  9442. * within the MultiLineString. If `opt_interpolate` is `true` the coordinates
  9443. * will be linearly interpolated between the last coordinate of one LineString
  9444. * and the first coordinate of the next LineString. If `opt_interpolate` is
  9445. * `false` then the function will return `null` for Ms falling between
  9446. * LineStrings.
  9447. *
  9448. * @param {number} m M.
  9449. * @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
  9450. * @param {boolean} [opt_interpolate] Interpolate. Default is `false`.
  9451. * @return {import("../coordinate.js").Coordinate|null} Coordinate.
  9452. * @api
  9453. */
  9454. MultiLineString.prototype.getCoordinateAtM = function (m, opt_extrapolate, opt_interpolate) {
  9455. if ((this.layout != geom_GeometryLayout.XYM &&
  9456. this.layout != geom_GeometryLayout.XYZM) ||
  9457. this.flatCoordinates.length === 0) {
  9458. return null;
  9459. }
  9460. var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
  9461. var interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
  9462. return lineStringsCoordinateAtM(this.flatCoordinates, 0, this.ends_, this.stride, m, extrapolate, interpolate);
  9463. };
  9464. /**
  9465. * Return the coordinates of the multilinestring.
  9466. * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
  9467. * @api
  9468. */
  9469. MultiLineString.prototype.getCoordinates = function () {
  9470. return inflateCoordinatesArray(this.flatCoordinates, 0, this.ends_, this.stride);
  9471. };
  9472. /**
  9473. * @return {Array<number>} Ends.
  9474. */
  9475. MultiLineString.prototype.getEnds = function () {
  9476. return this.ends_;
  9477. };
  9478. /**
  9479. * Return the linestring at the specified index.
  9480. * @param {number} index Index.
  9481. * @return {LineString} LineString.
  9482. * @api
  9483. */
  9484. MultiLineString.prototype.getLineString = function (index) {
  9485. if (index < 0 || this.ends_.length <= index) {
  9486. return null;
  9487. }
  9488. return new geom_LineString(this.flatCoordinates.slice(index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]), this.layout);
  9489. };
  9490. /**
  9491. * Return the linestrings of this multilinestring.
  9492. * @return {Array<LineString>} LineStrings.
  9493. * @api
  9494. */
  9495. MultiLineString.prototype.getLineStrings = function () {
  9496. var flatCoordinates = this.flatCoordinates;
  9497. var ends = this.ends_;
  9498. var layout = this.layout;
  9499. /** @type {Array<LineString>} */
  9500. var lineStrings = [];
  9501. var offset = 0;
  9502. for (var i = 0, ii = ends.length; i < ii; ++i) {
  9503. var end = ends[i];
  9504. var lineString = new geom_LineString(flatCoordinates.slice(offset, end), layout);
  9505. lineStrings.push(lineString);
  9506. offset = end;
  9507. }
  9508. return lineStrings;
  9509. };
  9510. /**
  9511. * @return {Array<number>} Flat midpoints.
  9512. */
  9513. MultiLineString.prototype.getFlatMidpoints = function () {
  9514. var midpoints = [];
  9515. var flatCoordinates = this.flatCoordinates;
  9516. var offset = 0;
  9517. var ends = this.ends_;
  9518. var stride = this.stride;
  9519. for (var i = 0, ii = ends.length; i < ii; ++i) {
  9520. var end = ends[i];
  9521. var midpoint = interpolatePoint(flatCoordinates, offset, end, stride, 0.5);
  9522. array_extend(midpoints, midpoint);
  9523. offset = end;
  9524. }
  9525. return midpoints;
  9526. };
  9527. /**
  9528. * @param {number} squaredTolerance Squared tolerance.
  9529. * @return {MultiLineString} Simplified MultiLineString.
  9530. * @protected
  9531. */
  9532. MultiLineString.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
  9533. var simplifiedFlatCoordinates = [];
  9534. var simplifiedEnds = [];
  9535. simplifiedFlatCoordinates.length = douglasPeuckerArray(this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0, simplifiedEnds);
  9536. return new MultiLineString(simplifiedFlatCoordinates, geom_GeometryLayout.XY, simplifiedEnds);
  9537. };
  9538. /**
  9539. * Get the type of this geometry.
  9540. * @return {import("./Geometry.js").Type} Geometry type.
  9541. * @api
  9542. */
  9543. MultiLineString.prototype.getType = function () {
  9544. return 'MultiLineString';
  9545. };
  9546. /**
  9547. * Test if the geometry and the passed extent intersect.
  9548. * @param {import("../extent.js").Extent} extent Extent.
  9549. * @return {boolean} `true` if the geometry and the extent intersect.
  9550. * @api
  9551. */
  9552. MultiLineString.prototype.intersectsExtent = function (extent) {
  9553. return intersectsLineStringArray(this.flatCoordinates, 0, this.ends_, this.stride, extent);
  9554. };
  9555. /**
  9556. * Set the coordinates of the multilinestring.
  9557. * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
  9558. * @param {GeometryLayout} [opt_layout] Layout.
  9559. * @api
  9560. */
  9561. MultiLineString.prototype.setCoordinates = function (coordinates, opt_layout) {
  9562. this.setLayout(opt_layout, coordinates, 2);
  9563. if (!this.flatCoordinates) {
  9564. this.flatCoordinates = [];
  9565. }
  9566. var ends = deflateCoordinatesArray(this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
  9567. this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
  9568. this.changed();
  9569. };
  9570. return MultiLineString;
  9571. }(geom_SimpleGeometry));
  9572. /* harmony default export */ var geom_MultiLineString = (MultiLineString);
  9573. //# sourceMappingURL=MultiLineString.js.map
  9574. ;// ./node_modules/ol/geom/Point.js
  9575. var Point_extends = (undefined && undefined.__extends) || (function () {
  9576. var extendStatics = function (d, b) {
  9577. extendStatics = Object.setPrototypeOf ||
  9578. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9579. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  9580. return extendStatics(d, b);
  9581. };
  9582. return function (d, b) {
  9583. if (typeof b !== "function" && b !== null)
  9584. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  9585. extendStatics(d, b);
  9586. function __() { this.constructor = d; }
  9587. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9588. };
  9589. })();
  9590. /**
  9591. * @module ol/geom/Point
  9592. */
  9593. /**
  9594. * @classdesc
  9595. * Point geometry.
  9596. *
  9597. * @api
  9598. */
  9599. var Point = /** @class */ (function (_super) {
  9600. Point_extends(Point, _super);
  9601. /**
  9602. * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
  9603. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9604. */
  9605. function Point(coordinates, opt_layout) {
  9606. var _this = _super.call(this) || this;
  9607. _this.setCoordinates(coordinates, opt_layout);
  9608. return _this;
  9609. }
  9610. /**
  9611. * Make a complete copy of the geometry.
  9612. * @return {!Point} Clone.
  9613. * @api
  9614. */
  9615. Point.prototype.clone = function () {
  9616. var point = new Point(this.flatCoordinates.slice(), this.layout);
  9617. point.applyProperties(this);
  9618. return point;
  9619. };
  9620. /**
  9621. * @param {number} x X.
  9622. * @param {number} y Y.
  9623. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  9624. * @param {number} minSquaredDistance Minimum squared distance.
  9625. * @return {number} Minimum squared distance.
  9626. */
  9627. Point.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  9628. var flatCoordinates = this.flatCoordinates;
  9629. var squaredDistance = math_squaredDistance(x, y, flatCoordinates[0], flatCoordinates[1]);
  9630. if (squaredDistance < minSquaredDistance) {
  9631. var stride = this.stride;
  9632. for (var i = 0; i < stride; ++i) {
  9633. closestPoint[i] = flatCoordinates[i];
  9634. }
  9635. closestPoint.length = stride;
  9636. return squaredDistance;
  9637. }
  9638. else {
  9639. return minSquaredDistance;
  9640. }
  9641. };
  9642. /**
  9643. * Return the coordinate of the point.
  9644. * @return {import("../coordinate.js").Coordinate} Coordinates.
  9645. * @api
  9646. */
  9647. Point.prototype.getCoordinates = function () {
  9648. return !this.flatCoordinates ? [] : this.flatCoordinates.slice();
  9649. };
  9650. /**
  9651. * @param {import("../extent.js").Extent} extent Extent.
  9652. * @protected
  9653. * @return {import("../extent.js").Extent} extent Extent.
  9654. */
  9655. Point.prototype.computeExtent = function (extent) {
  9656. return createOrUpdateFromCoordinate(this.flatCoordinates, extent);
  9657. };
  9658. /**
  9659. * Get the type of this geometry.
  9660. * @return {import("./Geometry.js").Type} Geometry type.
  9661. * @api
  9662. */
  9663. Point.prototype.getType = function () {
  9664. return 'Point';
  9665. };
  9666. /**
  9667. * Test if the geometry and the passed extent intersect.
  9668. * @param {import("../extent.js").Extent} extent Extent.
  9669. * @return {boolean} `true` if the geometry and the extent intersect.
  9670. * @api
  9671. */
  9672. Point.prototype.intersectsExtent = function (extent) {
  9673. return containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]);
  9674. };
  9675. /**
  9676. * @param {!Array<*>} coordinates Coordinates.
  9677. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9678. * @api
  9679. */
  9680. Point.prototype.setCoordinates = function (coordinates, opt_layout) {
  9681. this.setLayout(opt_layout, coordinates, 0);
  9682. if (!this.flatCoordinates) {
  9683. this.flatCoordinates = [];
  9684. }
  9685. this.flatCoordinates.length = deflateCoordinate(this.flatCoordinates, 0, coordinates, this.stride);
  9686. this.changed();
  9687. };
  9688. return Point;
  9689. }(geom_SimpleGeometry));
  9690. /* harmony default export */ var geom_Point = (Point);
  9691. //# sourceMappingURL=Point.js.map
  9692. ;// ./node_modules/ol/geom/MultiPoint.js
  9693. var MultiPoint_extends = (undefined && undefined.__extends) || (function () {
  9694. var extendStatics = function (d, b) {
  9695. extendStatics = Object.setPrototypeOf ||
  9696. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9697. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  9698. return extendStatics(d, b);
  9699. };
  9700. return function (d, b) {
  9701. if (typeof b !== "function" && b !== null)
  9702. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  9703. extendStatics(d, b);
  9704. function __() { this.constructor = d; }
  9705. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9706. };
  9707. })();
  9708. /**
  9709. * @module ol/geom/MultiPoint
  9710. */
  9711. /**
  9712. * @classdesc
  9713. * Multi-point geometry.
  9714. *
  9715. * @api
  9716. */
  9717. var MultiPoint = /** @class */ (function (_super) {
  9718. MultiPoint_extends(MultiPoint, _super);
  9719. /**
  9720. * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
  9721. * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
  9722. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9723. */
  9724. function MultiPoint(coordinates, opt_layout) {
  9725. var _this = _super.call(this) || this;
  9726. if (opt_layout && !Array.isArray(coordinates[0])) {
  9727. _this.setFlatCoordinates(opt_layout,
  9728. /** @type {Array<number>} */ (coordinates));
  9729. }
  9730. else {
  9731. _this.setCoordinates(
  9732. /** @type {Array<import("../coordinate.js").Coordinate>} */ (coordinates), opt_layout);
  9733. }
  9734. return _this;
  9735. }
  9736. /**
  9737. * Append the passed point to this multipoint.
  9738. * @param {Point} point Point.
  9739. * @api
  9740. */
  9741. MultiPoint.prototype.appendPoint = function (point) {
  9742. if (!this.flatCoordinates) {
  9743. this.flatCoordinates = point.getFlatCoordinates().slice();
  9744. }
  9745. else {
  9746. array_extend(this.flatCoordinates, point.getFlatCoordinates());
  9747. }
  9748. this.changed();
  9749. };
  9750. /**
  9751. * Make a complete copy of the geometry.
  9752. * @return {!MultiPoint} Clone.
  9753. * @api
  9754. */
  9755. MultiPoint.prototype.clone = function () {
  9756. var multiPoint = new MultiPoint(this.flatCoordinates.slice(), this.layout);
  9757. multiPoint.applyProperties(this);
  9758. return multiPoint;
  9759. };
  9760. /**
  9761. * @param {number} x X.
  9762. * @param {number} y Y.
  9763. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  9764. * @param {number} minSquaredDistance Minimum squared distance.
  9765. * @return {number} Minimum squared distance.
  9766. */
  9767. MultiPoint.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  9768. if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
  9769. return minSquaredDistance;
  9770. }
  9771. var flatCoordinates = this.flatCoordinates;
  9772. var stride = this.stride;
  9773. for (var i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
  9774. var squaredDistance = math_squaredDistance(x, y, flatCoordinates[i], flatCoordinates[i + 1]);
  9775. if (squaredDistance < minSquaredDistance) {
  9776. minSquaredDistance = squaredDistance;
  9777. for (var j = 0; j < stride; ++j) {
  9778. closestPoint[j] = flatCoordinates[i + j];
  9779. }
  9780. closestPoint.length = stride;
  9781. }
  9782. }
  9783. return minSquaredDistance;
  9784. };
  9785. /**
  9786. * Return the coordinates of the multipoint.
  9787. * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
  9788. * @api
  9789. */
  9790. MultiPoint.prototype.getCoordinates = function () {
  9791. return inflateCoordinates(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
  9792. };
  9793. /**
  9794. * Return the point at the specified index.
  9795. * @param {number} index Index.
  9796. * @return {Point} Point.
  9797. * @api
  9798. */
  9799. MultiPoint.prototype.getPoint = function (index) {
  9800. var n = !this.flatCoordinates
  9801. ? 0
  9802. : this.flatCoordinates.length / this.stride;
  9803. if (index < 0 || n <= index) {
  9804. return null;
  9805. }
  9806. return new geom_Point(this.flatCoordinates.slice(index * this.stride, (index + 1) * this.stride), this.layout);
  9807. };
  9808. /**
  9809. * Return the points of this multipoint.
  9810. * @return {Array<Point>} Points.
  9811. * @api
  9812. */
  9813. MultiPoint.prototype.getPoints = function () {
  9814. var flatCoordinates = this.flatCoordinates;
  9815. var layout = this.layout;
  9816. var stride = this.stride;
  9817. /** @type {Array<Point>} */
  9818. var points = [];
  9819. for (var i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
  9820. var point = new geom_Point(flatCoordinates.slice(i, i + stride), layout);
  9821. points.push(point);
  9822. }
  9823. return points;
  9824. };
  9825. /**
  9826. * Get the type of this geometry.
  9827. * @return {import("./Geometry.js").Type} Geometry type.
  9828. * @api
  9829. */
  9830. MultiPoint.prototype.getType = function () {
  9831. return 'MultiPoint';
  9832. };
  9833. /**
  9834. * Test if the geometry and the passed extent intersect.
  9835. * @param {import("../extent.js").Extent} extent Extent.
  9836. * @return {boolean} `true` if the geometry and the extent intersect.
  9837. * @api
  9838. */
  9839. MultiPoint.prototype.intersectsExtent = function (extent) {
  9840. var flatCoordinates = this.flatCoordinates;
  9841. var stride = this.stride;
  9842. for (var i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
  9843. var x = flatCoordinates[i];
  9844. var y = flatCoordinates[i + 1];
  9845. if (containsXY(extent, x, y)) {
  9846. return true;
  9847. }
  9848. }
  9849. return false;
  9850. };
  9851. /**
  9852. * Set the coordinates of the multipoint.
  9853. * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
  9854. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  9855. * @api
  9856. */
  9857. MultiPoint.prototype.setCoordinates = function (coordinates, opt_layout) {
  9858. this.setLayout(opt_layout, coordinates, 1);
  9859. if (!this.flatCoordinates) {
  9860. this.flatCoordinates = [];
  9861. }
  9862. this.flatCoordinates.length = deflateCoordinates(this.flatCoordinates, 0, coordinates, this.stride);
  9863. this.changed();
  9864. };
  9865. return MultiPoint;
  9866. }(geom_SimpleGeometry));
  9867. /* harmony default export */ var geom_MultiPoint = (MultiPoint);
  9868. //# sourceMappingURL=MultiPoint.js.map
  9869. ;// ./node_modules/ol/geom/flat/interiorpoint.js
  9870. /**
  9871. * @module ol/geom/flat/interiorpoint
  9872. */
  9873. /**
  9874. * Calculates a point that is likely to lie in the interior of the linear rings.
  9875. * Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint.
  9876. * @param {Array<number>} flatCoordinates Flat coordinates.
  9877. * @param {number} offset Offset.
  9878. * @param {Array<number>} ends Ends.
  9879. * @param {number} stride Stride.
  9880. * @param {Array<number>} flatCenters Flat centers.
  9881. * @param {number} flatCentersOffset Flat center offset.
  9882. * @param {Array<number>} [opt_dest] Destination.
  9883. * @return {Array<number>} Destination point as XYM coordinate, where M is the
  9884. * length of the horizontal intersection that the point belongs to.
  9885. */
  9886. function getInteriorPointOfArray(flatCoordinates, offset, ends, stride, flatCenters, flatCentersOffset, opt_dest) {
  9887. var i, ii, x, x1, x2, y1, y2;
  9888. var y = flatCenters[flatCentersOffset + 1];
  9889. /** @type {Array<number>} */
  9890. var intersections = [];
  9891. // Calculate intersections with the horizontal line
  9892. for (var r = 0, rr = ends.length; r < rr; ++r) {
  9893. var end = ends[r];
  9894. x1 = flatCoordinates[end - stride];
  9895. y1 = flatCoordinates[end - stride + 1];
  9896. for (i = offset; i < end; i += stride) {
  9897. x2 = flatCoordinates[i];
  9898. y2 = flatCoordinates[i + 1];
  9899. if ((y <= y1 && y2 <= y) || (y1 <= y && y <= y2)) {
  9900. x = ((y - y1) / (y2 - y1)) * (x2 - x1) + x1;
  9901. intersections.push(x);
  9902. }
  9903. x1 = x2;
  9904. y1 = y2;
  9905. }
  9906. }
  9907. // Find the longest segment of the horizontal line that has its center point
  9908. // inside the linear ring.
  9909. var pointX = NaN;
  9910. var maxSegmentLength = -Infinity;
  9911. intersections.sort(numberSafeCompareFunction);
  9912. x1 = intersections[0];
  9913. for (i = 1, ii = intersections.length; i < ii; ++i) {
  9914. x2 = intersections[i];
  9915. var segmentLength = Math.abs(x2 - x1);
  9916. if (segmentLength > maxSegmentLength) {
  9917. x = (x1 + x2) / 2;
  9918. if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {
  9919. pointX = x;
  9920. maxSegmentLength = segmentLength;
  9921. }
  9922. }
  9923. x1 = x2;
  9924. }
  9925. if (isNaN(pointX)) {
  9926. // There is no horizontal line that has its center point inside the linear
  9927. // ring. Use the center of the the linear ring's extent.
  9928. pointX = flatCenters[flatCentersOffset];
  9929. }
  9930. if (opt_dest) {
  9931. opt_dest.push(pointX, y, maxSegmentLength);
  9932. return opt_dest;
  9933. }
  9934. else {
  9935. return [pointX, y, maxSegmentLength];
  9936. }
  9937. }
  9938. /**
  9939. * @param {Array<number>} flatCoordinates Flat coordinates.
  9940. * @param {number} offset Offset.
  9941. * @param {Array<Array<number>>} endss Endss.
  9942. * @param {number} stride Stride.
  9943. * @param {Array<number>} flatCenters Flat centers.
  9944. * @return {Array<number>} Interior points as XYM coordinates, where M is the
  9945. * length of the horizontal intersection that the point belongs to.
  9946. */
  9947. function getInteriorPointsOfMultiArray(flatCoordinates, offset, endss, stride, flatCenters) {
  9948. var interiorPoints = [];
  9949. for (var i = 0, ii = endss.length; i < ii; ++i) {
  9950. var ends = endss[i];
  9951. interiorPoints = getInteriorPointOfArray(flatCoordinates, offset, ends, stride, flatCenters, 2 * i, interiorPoints);
  9952. offset = ends[ends.length - 1];
  9953. }
  9954. return interiorPoints;
  9955. }
  9956. //# sourceMappingURL=interiorpoint.js.map
  9957. ;// ./node_modules/ol/geom/flat/reverse.js
  9958. /**
  9959. * @module ol/geom/flat/reverse
  9960. */
  9961. /**
  9962. * @param {Array<number>} flatCoordinates Flat coordinates.
  9963. * @param {number} offset Offset.
  9964. * @param {number} end End.
  9965. * @param {number} stride Stride.
  9966. */
  9967. function coordinates(flatCoordinates, offset, end, stride) {
  9968. while (offset < end - stride) {
  9969. for (var i = 0; i < stride; ++i) {
  9970. var tmp = flatCoordinates[offset + i];
  9971. flatCoordinates[offset + i] = flatCoordinates[end - stride + i];
  9972. flatCoordinates[end - stride + i] = tmp;
  9973. }
  9974. offset += stride;
  9975. end -= stride;
  9976. }
  9977. }
  9978. //# sourceMappingURL=reverse.js.map
  9979. ;// ./node_modules/ol/geom/flat/orient.js
  9980. /**
  9981. * @module ol/geom/flat/orient
  9982. */
  9983. /**
  9984. * Is the linear ring oriented clockwise in a coordinate system with a bottom-left
  9985. * coordinate origin? For a coordinate system with a top-left coordinate origin,
  9986. * the ring's orientation is clockwise when this function returns false.
  9987. * @param {Array<number>} flatCoordinates Flat coordinates.
  9988. * @param {number} offset Offset.
  9989. * @param {number} end End.
  9990. * @param {number} stride Stride.
  9991. * @return {boolean} Is clockwise.
  9992. */
  9993. function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
  9994. // https://stackoverflow.com/q/1165647/clockwise-method#1165943
  9995. // https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrlinearring.cpp
  9996. var edge = 0;
  9997. var x1 = flatCoordinates[end - stride];
  9998. var y1 = flatCoordinates[end - stride + 1];
  9999. for (; offset < end; offset += stride) {
  10000. var x2 = flatCoordinates[offset];
  10001. var y2 = flatCoordinates[offset + 1];
  10002. edge += (x2 - x1) * (y2 + y1);
  10003. x1 = x2;
  10004. y1 = y2;
  10005. }
  10006. return edge === 0 ? undefined : edge > 0;
  10007. }
  10008. /**
  10009. * Determines if linear rings are oriented. By default, left-hand orientation
  10010. * is tested (first ring must be clockwise, remaining rings counter-clockwise).
  10011. * To test for right-hand orientation, use the `opt_right` argument.
  10012. *
  10013. * @param {Array<number>} flatCoordinates Flat coordinates.
  10014. * @param {number} offset Offset.
  10015. * @param {Array<number>} ends Array of end indexes.
  10016. * @param {number} stride Stride.
  10017. * @param {boolean} [opt_right] Test for right-hand orientation
  10018. * (counter-clockwise exterior ring and clockwise interior rings).
  10019. * @return {boolean} Rings are correctly oriented.
  10020. */
  10021. function linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right) {
  10022. var right = opt_right !== undefined ? opt_right : false;
  10023. for (var i = 0, ii = ends.length; i < ii; ++i) {
  10024. var end = ends[i];
  10025. var isClockwise = linearRingIsClockwise(flatCoordinates, offset, end, stride);
  10026. if (i === 0) {
  10027. if ((right && isClockwise) || (!right && !isClockwise)) {
  10028. return false;
  10029. }
  10030. }
  10031. else {
  10032. if ((right && !isClockwise) || (!right && isClockwise)) {
  10033. return false;
  10034. }
  10035. }
  10036. offset = end;
  10037. }
  10038. return true;
  10039. }
  10040. /**
  10041. * Determines if linear rings are oriented. By default, left-hand orientation
  10042. * is tested (first ring must be clockwise, remaining rings counter-clockwise).
  10043. * To test for right-hand orientation, use the `opt_right` argument.
  10044. *
  10045. * @param {Array<number>} flatCoordinates Flat coordinates.
  10046. * @param {number} offset Offset.
  10047. * @param {Array<Array<number>>} endss Array of array of end indexes.
  10048. * @param {number} stride Stride.
  10049. * @param {boolean} [opt_right] Test for right-hand orientation
  10050. * (counter-clockwise exterior ring and clockwise interior rings).
  10051. * @return {boolean} Rings are correctly oriented.
  10052. */
  10053. function linearRingssAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
  10054. for (var i = 0, ii = endss.length; i < ii; ++i) {
  10055. var ends = endss[i];
  10056. if (!linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right)) {
  10057. return false;
  10058. }
  10059. if (ends.length) {
  10060. offset = ends[ends.length - 1];
  10061. }
  10062. }
  10063. return true;
  10064. }
  10065. /**
  10066. * Orient coordinates in a flat array of linear rings. By default, rings
  10067. * are oriented following the left-hand rule (clockwise for exterior and
  10068. * counter-clockwise for interior rings). To orient according to the
  10069. * right-hand rule, use the `opt_right` argument.
  10070. *
  10071. * @param {Array<number>} flatCoordinates Flat coordinates.
  10072. * @param {number} offset Offset.
  10073. * @param {Array<number>} ends Ends.
  10074. * @param {number} stride Stride.
  10075. * @param {boolean} [opt_right] Follow the right-hand rule for orientation.
  10076. * @return {number} End.
  10077. */
  10078. function orientLinearRings(flatCoordinates, offset, ends, stride, opt_right) {
  10079. var right = opt_right !== undefined ? opt_right : false;
  10080. for (var i = 0, ii = ends.length; i < ii; ++i) {
  10081. var end = ends[i];
  10082. var isClockwise = linearRingIsClockwise(flatCoordinates, offset, end, stride);
  10083. var reverse = i === 0
  10084. ? (right && isClockwise) || (!right && !isClockwise)
  10085. : (right && !isClockwise) || (!right && isClockwise);
  10086. if (reverse) {
  10087. coordinates(flatCoordinates, offset, end, stride);
  10088. }
  10089. offset = end;
  10090. }
  10091. return offset;
  10092. }
  10093. /**
  10094. * Orient coordinates in a flat array of linear rings. By default, rings
  10095. * are oriented following the left-hand rule (clockwise for exterior and
  10096. * counter-clockwise for interior rings). To orient according to the
  10097. * right-hand rule, use the `opt_right` argument.
  10098. *
  10099. * @param {Array<number>} flatCoordinates Flat coordinates.
  10100. * @param {number} offset Offset.
  10101. * @param {Array<Array<number>>} endss Array of array of end indexes.
  10102. * @param {number} stride Stride.
  10103. * @param {boolean} [opt_right] Follow the right-hand rule for orientation.
  10104. * @return {number} End.
  10105. */
  10106. function orientLinearRingsArray(flatCoordinates, offset, endss, stride, opt_right) {
  10107. for (var i = 0, ii = endss.length; i < ii; ++i) {
  10108. offset = orientLinearRings(flatCoordinates, offset, endss[i], stride, opt_right);
  10109. }
  10110. return offset;
  10111. }
  10112. /**
  10113. * Return a two-dimensional endss
  10114. * @param {Array<number>} flatCoordinates Flat coordinates
  10115. * @param {Array<number>} ends Linear ring end indexes
  10116. * @return {Array<Array<number>>} Two dimensional endss array that can
  10117. * be used to contruct a MultiPolygon
  10118. */
  10119. function inflateEnds(flatCoordinates, ends) {
  10120. var endss = [];
  10121. var offset = 0;
  10122. var prevEndIndex = 0;
  10123. for (var i = 0, ii = ends.length; i < ii; ++i) {
  10124. var end = ends[i];
  10125. // classifies an array of rings into polygons with outer rings and holes
  10126. if (!linearRingIsClockwise(flatCoordinates, offset, end, 2)) {
  10127. endss.push(ends.slice(prevEndIndex, i + 1));
  10128. }
  10129. else {
  10130. if (endss.length === 0) {
  10131. continue;
  10132. }
  10133. endss[endss.length - 1].push(ends[prevEndIndex]);
  10134. }
  10135. prevEndIndex = i + 1;
  10136. offset = end;
  10137. }
  10138. return endss;
  10139. }
  10140. //# sourceMappingURL=orient.js.map
  10141. ;// ./node_modules/ol/geom/Polygon.js
  10142. var Polygon_extends = (undefined && undefined.__extends) || (function () {
  10143. var extendStatics = function (d, b) {
  10144. extendStatics = Object.setPrototypeOf ||
  10145. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10146. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10147. return extendStatics(d, b);
  10148. };
  10149. return function (d, b) {
  10150. if (typeof b !== "function" && b !== null)
  10151. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  10152. extendStatics(d, b);
  10153. function __() { this.constructor = d; }
  10154. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10155. };
  10156. })();
  10157. /**
  10158. * @module ol/geom/Polygon
  10159. */
  10160. /**
  10161. * @classdesc
  10162. * Polygon geometry.
  10163. *
  10164. * @api
  10165. */
  10166. var Polygon = /** @class */ (function (_super) {
  10167. Polygon_extends(Polygon, _super);
  10168. /**
  10169. * @param {!Array<Array<import("../coordinate.js").Coordinate>>|!Array<number>} coordinates
  10170. * Array of linear rings that define the polygon. The first linear ring of the
  10171. * array defines the outer-boundary or surface of the polygon. Each subsequent
  10172. * linear ring defines a hole in the surface of the polygon. A linear ring is
  10173. * an array of vertices' coordinates where the first coordinate and the last are
  10174. * equivalent. (For internal use, flat coordinates in combination with
  10175. * `opt_layout` and `opt_ends` are also accepted.)
  10176. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  10177. * @param {Array<number>} [opt_ends] Ends (for internal use with flat coordinates).
  10178. */
  10179. function Polygon(coordinates, opt_layout, opt_ends) {
  10180. var _this = _super.call(this) || this;
  10181. /**
  10182. * @type {Array<number>}
  10183. * @private
  10184. */
  10185. _this.ends_ = [];
  10186. /**
  10187. * @private
  10188. * @type {number}
  10189. */
  10190. _this.flatInteriorPointRevision_ = -1;
  10191. /**
  10192. * @private
  10193. * @type {import("../coordinate.js").Coordinate}
  10194. */
  10195. _this.flatInteriorPoint_ = null;
  10196. /**
  10197. * @private
  10198. * @type {number}
  10199. */
  10200. _this.maxDelta_ = -1;
  10201. /**
  10202. * @private
  10203. * @type {number}
  10204. */
  10205. _this.maxDeltaRevision_ = -1;
  10206. /**
  10207. * @private
  10208. * @type {number}
  10209. */
  10210. _this.orientedRevision_ = -1;
  10211. /**
  10212. * @private
  10213. * @type {Array<number>}
  10214. */
  10215. _this.orientedFlatCoordinates_ = null;
  10216. if (opt_layout !== undefined && opt_ends) {
  10217. _this.setFlatCoordinates(opt_layout,
  10218. /** @type {Array<number>} */ (coordinates));
  10219. _this.ends_ = opt_ends;
  10220. }
  10221. else {
  10222. _this.setCoordinates(
  10223. /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */ (coordinates), opt_layout);
  10224. }
  10225. return _this;
  10226. }
  10227. /**
  10228. * Append the passed linear ring to this polygon.
  10229. * @param {LinearRing} linearRing Linear ring.
  10230. * @api
  10231. */
  10232. Polygon.prototype.appendLinearRing = function (linearRing) {
  10233. if (!this.flatCoordinates) {
  10234. this.flatCoordinates = linearRing.getFlatCoordinates().slice();
  10235. }
  10236. else {
  10237. array_extend(this.flatCoordinates, linearRing.getFlatCoordinates());
  10238. }
  10239. this.ends_.push(this.flatCoordinates.length);
  10240. this.changed();
  10241. };
  10242. /**
  10243. * Make a complete copy of the geometry.
  10244. * @return {!Polygon} Clone.
  10245. * @api
  10246. */
  10247. Polygon.prototype.clone = function () {
  10248. var polygon = new Polygon(this.flatCoordinates.slice(), this.layout, this.ends_.slice());
  10249. polygon.applyProperties(this);
  10250. return polygon;
  10251. };
  10252. /**
  10253. * @param {number} x X.
  10254. * @param {number} y Y.
  10255. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  10256. * @param {number} minSquaredDistance Minimum squared distance.
  10257. * @return {number} Minimum squared distance.
  10258. */
  10259. Polygon.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  10260. if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
  10261. return minSquaredDistance;
  10262. }
  10263. if (this.maxDeltaRevision_ != this.getRevision()) {
  10264. this.maxDelta_ = Math.sqrt(arrayMaxSquaredDelta(this.flatCoordinates, 0, this.ends_, this.stride, 0));
  10265. this.maxDeltaRevision_ = this.getRevision();
  10266. }
  10267. return assignClosestArrayPoint(this.flatCoordinates, 0, this.ends_, this.stride, this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
  10268. };
  10269. /**
  10270. * @param {number} x X.
  10271. * @param {number} y Y.
  10272. * @return {boolean} Contains (x, y).
  10273. */
  10274. Polygon.prototype.containsXY = function (x, y) {
  10275. return linearRingsContainsXY(this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, x, y);
  10276. };
  10277. /**
  10278. * Return the area of the polygon on projected plane.
  10279. * @return {number} Area (on projected plane).
  10280. * @api
  10281. */
  10282. Polygon.prototype.getArea = function () {
  10283. return linearRings(this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride);
  10284. };
  10285. /**
  10286. * Get the coordinate array for this geometry. This array has the structure
  10287. * of a GeoJSON coordinate array for polygons.
  10288. *
  10289. * @param {boolean} [opt_right] Orient coordinates according to the right-hand
  10290. * rule (counter-clockwise for exterior and clockwise for interior rings).
  10291. * If `false`, coordinates will be oriented according to the left-hand rule
  10292. * (clockwise for exterior and counter-clockwise for interior rings).
  10293. * By default, coordinate orientation will depend on how the geometry was
  10294. * constructed.
  10295. * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
  10296. * @api
  10297. */
  10298. Polygon.prototype.getCoordinates = function (opt_right) {
  10299. var flatCoordinates;
  10300. if (opt_right !== undefined) {
  10301. flatCoordinates = this.getOrientedFlatCoordinates().slice();
  10302. orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, opt_right);
  10303. }
  10304. else {
  10305. flatCoordinates = this.flatCoordinates;
  10306. }
  10307. return inflateCoordinatesArray(flatCoordinates, 0, this.ends_, this.stride);
  10308. };
  10309. /**
  10310. * @return {Array<number>} Ends.
  10311. */
  10312. Polygon.prototype.getEnds = function () {
  10313. return this.ends_;
  10314. };
  10315. /**
  10316. * @return {Array<number>} Interior point.
  10317. */
  10318. Polygon.prototype.getFlatInteriorPoint = function () {
  10319. if (this.flatInteriorPointRevision_ != this.getRevision()) {
  10320. var flatCenter = getCenter(this.getExtent());
  10321. this.flatInteriorPoint_ = getInteriorPointOfArray(this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, flatCenter, 0);
  10322. this.flatInteriorPointRevision_ = this.getRevision();
  10323. }
  10324. return this.flatInteriorPoint_;
  10325. };
  10326. /**
  10327. * Return an interior point of the polygon.
  10328. * @return {Point} Interior point as XYM coordinate, where M is the
  10329. * length of the horizontal intersection that the point belongs to.
  10330. * @api
  10331. */
  10332. Polygon.prototype.getInteriorPoint = function () {
  10333. return new geom_Point(this.getFlatInteriorPoint(), geom_GeometryLayout.XYM);
  10334. };
  10335. /**
  10336. * Return the number of rings of the polygon, this includes the exterior
  10337. * ring and any interior rings.
  10338. *
  10339. * @return {number} Number of rings.
  10340. * @api
  10341. */
  10342. Polygon.prototype.getLinearRingCount = function () {
  10343. return this.ends_.length;
  10344. };
  10345. /**
  10346. * Return the Nth linear ring of the polygon geometry. Return `null` if the
  10347. * given index is out of range.
  10348. * The exterior linear ring is available at index `0` and the interior rings
  10349. * at index `1` and beyond.
  10350. *
  10351. * @param {number} index Index.
  10352. * @return {LinearRing|null} Linear ring.
  10353. * @api
  10354. */
  10355. Polygon.prototype.getLinearRing = function (index) {
  10356. if (index < 0 || this.ends_.length <= index) {
  10357. return null;
  10358. }
  10359. return new geom_LinearRing(this.flatCoordinates.slice(index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]), this.layout);
  10360. };
  10361. /**
  10362. * Return the linear rings of the polygon.
  10363. * @return {Array<LinearRing>} Linear rings.
  10364. * @api
  10365. */
  10366. Polygon.prototype.getLinearRings = function () {
  10367. var layout = this.layout;
  10368. var flatCoordinates = this.flatCoordinates;
  10369. var ends = this.ends_;
  10370. var linearRings = [];
  10371. var offset = 0;
  10372. for (var i = 0, ii = ends.length; i < ii; ++i) {
  10373. var end = ends[i];
  10374. var linearRing = new geom_LinearRing(flatCoordinates.slice(offset, end), layout);
  10375. linearRings.push(linearRing);
  10376. offset = end;
  10377. }
  10378. return linearRings;
  10379. };
  10380. /**
  10381. * @return {Array<number>} Oriented flat coordinates.
  10382. */
  10383. Polygon.prototype.getOrientedFlatCoordinates = function () {
  10384. if (this.orientedRevision_ != this.getRevision()) {
  10385. var flatCoordinates = this.flatCoordinates;
  10386. if (linearRingsAreOriented(flatCoordinates, 0, this.ends_, this.stride)) {
  10387. this.orientedFlatCoordinates_ = flatCoordinates;
  10388. }
  10389. else {
  10390. this.orientedFlatCoordinates_ = flatCoordinates.slice();
  10391. this.orientedFlatCoordinates_.length = orientLinearRings(this.orientedFlatCoordinates_, 0, this.ends_, this.stride);
  10392. }
  10393. this.orientedRevision_ = this.getRevision();
  10394. }
  10395. return this.orientedFlatCoordinates_;
  10396. };
  10397. /**
  10398. * @param {number} squaredTolerance Squared tolerance.
  10399. * @return {Polygon} Simplified Polygon.
  10400. * @protected
  10401. */
  10402. Polygon.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
  10403. var simplifiedFlatCoordinates = [];
  10404. var simplifiedEnds = [];
  10405. simplifiedFlatCoordinates.length = quantizeArray(this.flatCoordinates, 0, this.ends_, this.stride, Math.sqrt(squaredTolerance), simplifiedFlatCoordinates, 0, simplifiedEnds);
  10406. return new Polygon(simplifiedFlatCoordinates, geom_GeometryLayout.XY, simplifiedEnds);
  10407. };
  10408. /**
  10409. * Get the type of this geometry.
  10410. * @return {import("./Geometry.js").Type} Geometry type.
  10411. * @api
  10412. */
  10413. Polygon.prototype.getType = function () {
  10414. return 'Polygon';
  10415. };
  10416. /**
  10417. * Test if the geometry and the passed extent intersect.
  10418. * @param {import("../extent.js").Extent} extent Extent.
  10419. * @return {boolean} `true` if the geometry and the extent intersect.
  10420. * @api
  10421. */
  10422. Polygon.prototype.intersectsExtent = function (extent) {
  10423. return intersectsLinearRingArray(this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, extent);
  10424. };
  10425. /**
  10426. * Set the coordinates of the polygon.
  10427. * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
  10428. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  10429. * @api
  10430. */
  10431. Polygon.prototype.setCoordinates = function (coordinates, opt_layout) {
  10432. this.setLayout(opt_layout, coordinates, 2);
  10433. if (!this.flatCoordinates) {
  10434. this.flatCoordinates = [];
  10435. }
  10436. var ends = deflateCoordinatesArray(this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
  10437. this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
  10438. this.changed();
  10439. };
  10440. return Polygon;
  10441. }(geom_SimpleGeometry));
  10442. /* harmony default export */ var geom_Polygon = (Polygon);
  10443. /**
  10444. * Create an approximation of a circle on the surface of a sphere.
  10445. * @param {import("../coordinate.js").Coordinate} center Center (`[lon, lat]` in degrees).
  10446. * @param {number} radius The great-circle distance from the center to
  10447. * the polygon vertices in meters.
  10448. * @param {number} [opt_n] Optional number of vertices for the resulting
  10449. * polygon. Default is `32`.
  10450. * @param {number} [opt_sphereRadius] Optional radius for the sphere (defaults to
  10451. * the Earth's mean radius using the WGS84 ellipsoid).
  10452. * @return {Polygon} The "circular" polygon.
  10453. * @api
  10454. */
  10455. function circular(center, radius, opt_n, opt_sphereRadius) {
  10456. var n = opt_n ? opt_n : 32;
  10457. /** @type {Array<number>} */
  10458. var flatCoordinates = [];
  10459. for (var i = 0; i < n; ++i) {
  10460. extend(flatCoordinates, sphereOffset(center, radius, (2 * Math.PI * i) / n, opt_sphereRadius));
  10461. }
  10462. flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
  10463. return new Polygon(flatCoordinates, GeometryLayout.XY, [
  10464. flatCoordinates.length,
  10465. ]);
  10466. }
  10467. /**
  10468. * Create a polygon from an extent. The layout used is `XY`.
  10469. * @param {import("../extent.js").Extent} extent The extent.
  10470. * @return {Polygon} The polygon.
  10471. * @api
  10472. */
  10473. function fromExtent(extent) {
  10474. var minX = extent[0];
  10475. var minY = extent[1];
  10476. var maxX = extent[2];
  10477. var maxY = extent[3];
  10478. var flatCoordinates = [
  10479. minX,
  10480. minY,
  10481. minX,
  10482. maxY,
  10483. maxX,
  10484. maxY,
  10485. maxX,
  10486. minY,
  10487. minX,
  10488. minY,
  10489. ];
  10490. return new Polygon(flatCoordinates, geom_GeometryLayout.XY, [
  10491. flatCoordinates.length,
  10492. ]);
  10493. }
  10494. /**
  10495. * Create a regular polygon from a circle.
  10496. * @param {import("./Circle.js").default} circle Circle geometry.
  10497. * @param {number} [opt_sides] Number of sides of the polygon. Default is 32.
  10498. * @param {number} [opt_angle] Start angle for the first vertex of the polygon in
  10499. * counter-clockwise radians. 0 means East. Default is 0.
  10500. * @return {Polygon} Polygon geometry.
  10501. * @api
  10502. */
  10503. function fromCircle(circle, opt_sides, opt_angle) {
  10504. var sides = opt_sides ? opt_sides : 32;
  10505. var stride = circle.getStride();
  10506. var layout = circle.getLayout();
  10507. var center = circle.getCenter();
  10508. var arrayLength = stride * (sides + 1);
  10509. var flatCoordinates = new Array(arrayLength);
  10510. for (var i = 0; i < arrayLength; i += stride) {
  10511. flatCoordinates[i] = 0;
  10512. flatCoordinates[i + 1] = 0;
  10513. for (var j = 2; j < stride; j++) {
  10514. flatCoordinates[i + j] = center[j];
  10515. }
  10516. }
  10517. var ends = [flatCoordinates.length];
  10518. var polygon = new Polygon(flatCoordinates, layout, ends);
  10519. makeRegular(polygon, center, circle.getRadius(), opt_angle);
  10520. return polygon;
  10521. }
  10522. /**
  10523. * Modify the coordinates of a polygon to make it a regular polygon.
  10524. * @param {Polygon} polygon Polygon geometry.
  10525. * @param {import("../coordinate.js").Coordinate} center Center of the regular polygon.
  10526. * @param {number} radius Radius of the regular polygon.
  10527. * @param {number} [opt_angle] Start angle for the first vertex of the polygon in
  10528. * counter-clockwise radians. 0 means East. Default is 0.
  10529. */
  10530. function makeRegular(polygon, center, radius, opt_angle) {
  10531. var flatCoordinates = polygon.getFlatCoordinates();
  10532. var stride = polygon.getStride();
  10533. var sides = flatCoordinates.length / stride - 1;
  10534. var startAngle = opt_angle ? opt_angle : 0;
  10535. for (var i = 0; i <= sides; ++i) {
  10536. var offset = i * stride;
  10537. var angle = startAngle + (modulo(i, sides) * 2 * Math.PI) / sides;
  10538. flatCoordinates[offset] = center[0] + radius * Math.cos(angle);
  10539. flatCoordinates[offset + 1] = center[1] + radius * Math.sin(angle);
  10540. }
  10541. polygon.changed();
  10542. }
  10543. //# sourceMappingURL=Polygon.js.map
  10544. ;// ./node_modules/ol/geom/flat/center.js
  10545. /**
  10546. * @module ol/geom/flat/center
  10547. */
  10548. /**
  10549. * @param {Array<number>} flatCoordinates Flat coordinates.
  10550. * @param {number} offset Offset.
  10551. * @param {Array<Array<number>>} endss Endss.
  10552. * @param {number} stride Stride.
  10553. * @return {Array<number>} Flat centers.
  10554. */
  10555. function center_linearRingss(flatCoordinates, offset, endss, stride) {
  10556. var flatCenters = [];
  10557. var extent = createEmpty();
  10558. for (var i = 0, ii = endss.length; i < ii; ++i) {
  10559. var ends = endss[i];
  10560. extent = createOrUpdateFromFlatCoordinates(flatCoordinates, offset, ends[0], stride);
  10561. flatCenters.push((extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2);
  10562. offset = ends[ends.length - 1];
  10563. }
  10564. return flatCenters;
  10565. }
  10566. //# sourceMappingURL=center.js.map
  10567. ;// ./node_modules/ol/geom/MultiPolygon.js
  10568. var MultiPolygon_extends = (undefined && undefined.__extends) || (function () {
  10569. var extendStatics = function (d, b) {
  10570. extendStatics = Object.setPrototypeOf ||
  10571. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10572. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10573. return extendStatics(d, b);
  10574. };
  10575. return function (d, b) {
  10576. if (typeof b !== "function" && b !== null)
  10577. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  10578. extendStatics(d, b);
  10579. function __() { this.constructor = d; }
  10580. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10581. };
  10582. })();
  10583. /**
  10584. * @module ol/geom/MultiPolygon
  10585. */
  10586. /**
  10587. * @classdesc
  10588. * Multi-polygon geometry.
  10589. *
  10590. * @api
  10591. */
  10592. var MultiPolygon = /** @class */ (function (_super) {
  10593. MultiPolygon_extends(MultiPolygon, _super);
  10594. /**
  10595. * @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates.
  10596. * For internal use, flat coordinates in combination with `opt_layout` and `opt_endss` are also accepted.
  10597. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  10598. * @param {Array<Array<number>>} [opt_endss] Array of ends for internal use with flat coordinates.
  10599. */
  10600. function MultiPolygon(coordinates, opt_layout, opt_endss) {
  10601. var _this = _super.call(this) || this;
  10602. /**
  10603. * @type {Array<Array<number>>}
  10604. * @private
  10605. */
  10606. _this.endss_ = [];
  10607. /**
  10608. * @private
  10609. * @type {number}
  10610. */
  10611. _this.flatInteriorPointsRevision_ = -1;
  10612. /**
  10613. * @private
  10614. * @type {Array<number>}
  10615. */
  10616. _this.flatInteriorPoints_ = null;
  10617. /**
  10618. * @private
  10619. * @type {number}
  10620. */
  10621. _this.maxDelta_ = -1;
  10622. /**
  10623. * @private
  10624. * @type {number}
  10625. */
  10626. _this.maxDeltaRevision_ = -1;
  10627. /**
  10628. * @private
  10629. * @type {number}
  10630. */
  10631. _this.orientedRevision_ = -1;
  10632. /**
  10633. * @private
  10634. * @type {Array<number>}
  10635. */
  10636. _this.orientedFlatCoordinates_ = null;
  10637. if (!opt_endss && !Array.isArray(coordinates[0])) {
  10638. var layout = _this.getLayout();
  10639. var polygons = /** @type {Array<Polygon>} */ (coordinates);
  10640. var flatCoordinates = [];
  10641. var endss = [];
  10642. for (var i = 0, ii = polygons.length; i < ii; ++i) {
  10643. var polygon = polygons[i];
  10644. if (i === 0) {
  10645. layout = polygon.getLayout();
  10646. }
  10647. var offset = flatCoordinates.length;
  10648. var ends = polygon.getEnds();
  10649. for (var j = 0, jj = ends.length; j < jj; ++j) {
  10650. ends[j] += offset;
  10651. }
  10652. array_extend(flatCoordinates, polygon.getFlatCoordinates());
  10653. endss.push(ends);
  10654. }
  10655. opt_layout = layout;
  10656. coordinates = flatCoordinates;
  10657. opt_endss = endss;
  10658. }
  10659. if (opt_layout !== undefined && opt_endss) {
  10660. _this.setFlatCoordinates(opt_layout,
  10661. /** @type {Array<number>} */ (coordinates));
  10662. _this.endss_ = opt_endss;
  10663. }
  10664. else {
  10665. _this.setCoordinates(
  10666. /** @type {Array<Array<Array<import("../coordinate.js").Coordinate>>>} */ (coordinates), opt_layout);
  10667. }
  10668. return _this;
  10669. }
  10670. /**
  10671. * Append the passed polygon to this multipolygon.
  10672. * @param {Polygon} polygon Polygon.
  10673. * @api
  10674. */
  10675. MultiPolygon.prototype.appendPolygon = function (polygon) {
  10676. /** @type {Array<number>} */
  10677. var ends;
  10678. if (!this.flatCoordinates) {
  10679. this.flatCoordinates = polygon.getFlatCoordinates().slice();
  10680. ends = polygon.getEnds().slice();
  10681. this.endss_.push();
  10682. }
  10683. else {
  10684. var offset = this.flatCoordinates.length;
  10685. array_extend(this.flatCoordinates, polygon.getFlatCoordinates());
  10686. ends = polygon.getEnds().slice();
  10687. for (var i = 0, ii = ends.length; i < ii; ++i) {
  10688. ends[i] += offset;
  10689. }
  10690. }
  10691. this.endss_.push(ends);
  10692. this.changed();
  10693. };
  10694. /**
  10695. * Make a complete copy of the geometry.
  10696. * @return {!MultiPolygon} Clone.
  10697. * @api
  10698. */
  10699. MultiPolygon.prototype.clone = function () {
  10700. var len = this.endss_.length;
  10701. var newEndss = new Array(len);
  10702. for (var i = 0; i < len; ++i) {
  10703. newEndss[i] = this.endss_[i].slice();
  10704. }
  10705. var multiPolygon = new MultiPolygon(this.flatCoordinates.slice(), this.layout, newEndss);
  10706. multiPolygon.applyProperties(this);
  10707. return multiPolygon;
  10708. };
  10709. /**
  10710. * @param {number} x X.
  10711. * @param {number} y Y.
  10712. * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
  10713. * @param {number} minSquaredDistance Minimum squared distance.
  10714. * @return {number} Minimum squared distance.
  10715. */
  10716. MultiPolygon.prototype.closestPointXY = function (x, y, closestPoint, minSquaredDistance) {
  10717. if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
  10718. return minSquaredDistance;
  10719. }
  10720. if (this.maxDeltaRevision_ != this.getRevision()) {
  10721. this.maxDelta_ = Math.sqrt(multiArrayMaxSquaredDelta(this.flatCoordinates, 0, this.endss_, this.stride, 0));
  10722. this.maxDeltaRevision_ = this.getRevision();
  10723. }
  10724. return assignClosestMultiArrayPoint(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
  10725. };
  10726. /**
  10727. * @param {number} x X.
  10728. * @param {number} y Y.
  10729. * @return {boolean} Contains (x, y).
  10730. */
  10731. MultiPolygon.prototype.containsXY = function (x, y) {
  10732. return linearRingssContainsXY(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, x, y);
  10733. };
  10734. /**
  10735. * Return the area of the multipolygon on projected plane.
  10736. * @return {number} Area (on projected plane).
  10737. * @api
  10738. */
  10739. MultiPolygon.prototype.getArea = function () {
  10740. return linearRingss(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride);
  10741. };
  10742. /**
  10743. * Get the coordinate array for this geometry. This array has the structure
  10744. * of a GeoJSON coordinate array for multi-polygons.
  10745. *
  10746. * @param {boolean} [opt_right] Orient coordinates according to the right-hand
  10747. * rule (counter-clockwise for exterior and clockwise for interior rings).
  10748. * If `false`, coordinates will be oriented according to the left-hand rule
  10749. * (clockwise for exterior and counter-clockwise for interior rings).
  10750. * By default, coordinate orientation will depend on how the geometry was
  10751. * constructed.
  10752. * @return {Array<Array<Array<import("../coordinate.js").Coordinate>>>} Coordinates.
  10753. * @api
  10754. */
  10755. MultiPolygon.prototype.getCoordinates = function (opt_right) {
  10756. var flatCoordinates;
  10757. if (opt_right !== undefined) {
  10758. flatCoordinates = this.getOrientedFlatCoordinates().slice();
  10759. orientLinearRingsArray(flatCoordinates, 0, this.endss_, this.stride, opt_right);
  10760. }
  10761. else {
  10762. flatCoordinates = this.flatCoordinates;
  10763. }
  10764. return inflateMultiCoordinatesArray(flatCoordinates, 0, this.endss_, this.stride);
  10765. };
  10766. /**
  10767. * @return {Array<Array<number>>} Endss.
  10768. */
  10769. MultiPolygon.prototype.getEndss = function () {
  10770. return this.endss_;
  10771. };
  10772. /**
  10773. * @return {Array<number>} Flat interior points.
  10774. */
  10775. MultiPolygon.prototype.getFlatInteriorPoints = function () {
  10776. if (this.flatInteriorPointsRevision_ != this.getRevision()) {
  10777. var flatCenters = center_linearRingss(this.flatCoordinates, 0, this.endss_, this.stride);
  10778. this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, flatCenters);
  10779. this.flatInteriorPointsRevision_ = this.getRevision();
  10780. }
  10781. return this.flatInteriorPoints_;
  10782. };
  10783. /**
  10784. * Return the interior points as {@link module:ol/geom/MultiPoint~MultiPoint multipoint}.
  10785. * @return {MultiPoint} Interior points as XYM coordinates, where M is
  10786. * the length of the horizontal intersection that the point belongs to.
  10787. * @api
  10788. */
  10789. MultiPolygon.prototype.getInteriorPoints = function () {
  10790. return new geom_MultiPoint(this.getFlatInteriorPoints().slice(), geom_GeometryLayout.XYM);
  10791. };
  10792. /**
  10793. * @return {Array<number>} Oriented flat coordinates.
  10794. */
  10795. MultiPolygon.prototype.getOrientedFlatCoordinates = function () {
  10796. if (this.orientedRevision_ != this.getRevision()) {
  10797. var flatCoordinates = this.flatCoordinates;
  10798. if (linearRingssAreOriented(flatCoordinates, 0, this.endss_, this.stride)) {
  10799. this.orientedFlatCoordinates_ = flatCoordinates;
  10800. }
  10801. else {
  10802. this.orientedFlatCoordinates_ = flatCoordinates.slice();
  10803. this.orientedFlatCoordinates_.length = orientLinearRingsArray(this.orientedFlatCoordinates_, 0, this.endss_, this.stride);
  10804. }
  10805. this.orientedRevision_ = this.getRevision();
  10806. }
  10807. return this.orientedFlatCoordinates_;
  10808. };
  10809. /**
  10810. * @param {number} squaredTolerance Squared tolerance.
  10811. * @return {MultiPolygon} Simplified MultiPolygon.
  10812. * @protected
  10813. */
  10814. MultiPolygon.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
  10815. var simplifiedFlatCoordinates = [];
  10816. var simplifiedEndss = [];
  10817. simplifiedFlatCoordinates.length = quantizeMultiArray(this.flatCoordinates, 0, this.endss_, this.stride, Math.sqrt(squaredTolerance), simplifiedFlatCoordinates, 0, simplifiedEndss);
  10818. return new MultiPolygon(simplifiedFlatCoordinates, geom_GeometryLayout.XY, simplifiedEndss);
  10819. };
  10820. /**
  10821. * Return the polygon at the specified index.
  10822. * @param {number} index Index.
  10823. * @return {Polygon} Polygon.
  10824. * @api
  10825. */
  10826. MultiPolygon.prototype.getPolygon = function (index) {
  10827. if (index < 0 || this.endss_.length <= index) {
  10828. return null;
  10829. }
  10830. var offset;
  10831. if (index === 0) {
  10832. offset = 0;
  10833. }
  10834. else {
  10835. var prevEnds = this.endss_[index - 1];
  10836. offset = prevEnds[prevEnds.length - 1];
  10837. }
  10838. var ends = this.endss_[index].slice();
  10839. var end = ends[ends.length - 1];
  10840. if (offset !== 0) {
  10841. for (var i = 0, ii = ends.length; i < ii; ++i) {
  10842. ends[i] -= offset;
  10843. }
  10844. }
  10845. return new geom_Polygon(this.flatCoordinates.slice(offset, end), this.layout, ends);
  10846. };
  10847. /**
  10848. * Return the polygons of this multipolygon.
  10849. * @return {Array<Polygon>} Polygons.
  10850. * @api
  10851. */
  10852. MultiPolygon.prototype.getPolygons = function () {
  10853. var layout = this.layout;
  10854. var flatCoordinates = this.flatCoordinates;
  10855. var endss = this.endss_;
  10856. var polygons = [];
  10857. var offset = 0;
  10858. for (var i = 0, ii = endss.length; i < ii; ++i) {
  10859. var ends = endss[i].slice();
  10860. var end = ends[ends.length - 1];
  10861. if (offset !== 0) {
  10862. for (var j = 0, jj = ends.length; j < jj; ++j) {
  10863. ends[j] -= offset;
  10864. }
  10865. }
  10866. var polygon = new geom_Polygon(flatCoordinates.slice(offset, end), layout, ends);
  10867. polygons.push(polygon);
  10868. offset = end;
  10869. }
  10870. return polygons;
  10871. };
  10872. /**
  10873. * Get the type of this geometry.
  10874. * @return {import("./Geometry.js").Type} Geometry type.
  10875. * @api
  10876. */
  10877. MultiPolygon.prototype.getType = function () {
  10878. return 'MultiPolygon';
  10879. };
  10880. /**
  10881. * Test if the geometry and the passed extent intersect.
  10882. * @param {import("../extent.js").Extent} extent Extent.
  10883. * @return {boolean} `true` if the geometry and the extent intersect.
  10884. * @api
  10885. */
  10886. MultiPolygon.prototype.intersectsExtent = function (extent) {
  10887. return intersectsLinearRingMultiArray(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, extent);
  10888. };
  10889. /**
  10890. * Set the coordinates of the multipolygon.
  10891. * @param {!Array<Array<Array<import("../coordinate.js").Coordinate>>>} coordinates Coordinates.
  10892. * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
  10893. * @api
  10894. */
  10895. MultiPolygon.prototype.setCoordinates = function (coordinates, opt_layout) {
  10896. this.setLayout(opt_layout, coordinates, 3);
  10897. if (!this.flatCoordinates) {
  10898. this.flatCoordinates = [];
  10899. }
  10900. var endss = deflateMultiCoordinatesArray(this.flatCoordinates, 0, coordinates, this.stride, this.endss_);
  10901. if (endss.length === 0) {
  10902. this.flatCoordinates.length = 0;
  10903. }
  10904. else {
  10905. var lastEnds = endss[endss.length - 1];
  10906. this.flatCoordinates.length =
  10907. lastEnds.length === 0 ? 0 : lastEnds[lastEnds.length - 1];
  10908. }
  10909. this.changed();
  10910. };
  10911. return MultiPolygon;
  10912. }(geom_SimpleGeometry));
  10913. /* harmony default export */ var geom_MultiPolygon = (MultiPolygon);
  10914. //# sourceMappingURL=MultiPolygon.js.map
  10915. ;// ./node_modules/ol/layer/TileProperty.js
  10916. /**
  10917. * @module ol/layer/TileProperty
  10918. */
  10919. /**
  10920. * @enum {string}
  10921. */
  10922. /* harmony default export */ var TileProperty = ({
  10923. PRELOAD: 'preload',
  10924. USE_INTERIM_TILES_ON_ERROR: 'useInterimTilesOnError',
  10925. });
  10926. //# sourceMappingURL=TileProperty.js.map
  10927. ;// ./node_modules/ol/layer/BaseTile.js
  10928. var BaseTile_extends = (undefined && undefined.__extends) || (function () {
  10929. var extendStatics = function (d, b) {
  10930. extendStatics = Object.setPrototypeOf ||
  10931. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10932. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10933. return extendStatics(d, b);
  10934. };
  10935. return function (d, b) {
  10936. if (typeof b !== "function" && b !== null)
  10937. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  10938. extendStatics(d, b);
  10939. function __() { this.constructor = d; }
  10940. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10941. };
  10942. })();
  10943. /**
  10944. * @module ol/layer/BaseTile
  10945. */
  10946. /***
  10947. * @template Return
  10948. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  10949. * import("../Observable").OnSignature<import("./Base").BaseLayerObjectEventTypes|
  10950. * 'change:source'|'change:preload'|'change:useInterimTilesOnError', import("../Object").ObjectEvent, Return> &
  10951. * import("../Observable").OnSignature<import("../render/EventType").LayerRenderEventTypes, import("../render/Event").default, Return> &
  10952. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("./Base").BaseLayerObjectEventTypes|
  10953. * 'change:source'|'change:preload'|'change:useInterimTilesOnError'|import("../render/EventType").LayerRenderEventTypes, Return>} BaseTileLayerOnSignature
  10954. */
  10955. /**
  10956. * @template {import("../source/Tile.js").default} TileSourceType
  10957. * @typedef {Object} Options
  10958. * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
  10959. * @property {number} [opacity=1] Opacity (0, 1).
  10960. * @property {boolean} [visible=true] Visibility.
  10961. * @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
  10962. * rendered outside of this extent.
  10963. * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
  10964. * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
  10965. * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
  10966. * method was used.
  10967. * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
  10968. * visible.
  10969. * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
  10970. * be visible.
  10971. * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
  10972. * visible.
  10973. * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
  10974. * be visible.
  10975. * @property {number} [preload=0] Preload. Load low-resolution tiles up to `preload` levels. `0`
  10976. * means no preloading.
  10977. * @property {TileSourceType} [source] Source for this layer.
  10978. * @property {import("../PluggableMap.js").default} [map] Sets the layer as overlay on a map. The map will not manage
  10979. * this layer in its layers collection, and the layer will be rendered on top. This is useful for
  10980. * temporary layers. The standard way to add a layer to a map and have it managed by the map is to
  10981. * use {@link import("../PluggableMap.js").default#addLayer map.addLayer()}.
  10982. * @property {boolean} [useInterimTilesOnError=true] Use interim tiles on error.
  10983. * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
  10984. */
  10985. /**
  10986. * @classdesc
  10987. * For layer sources that provide pre-rendered, tiled images in grids that are
  10988. * organized by zoom levels for specific resolutions.
  10989. * Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
  10990. * property on the layer object; for example, setting `title: 'My Title'` in the
  10991. * options means that `title` is observable, and has get/set accessors.
  10992. *
  10993. * @template {import("../source/Tile.js").default} TileSourceType
  10994. * @template {import("../renderer/Layer.js").default} RendererType
  10995. * @extends {Layer<TileSourceType, RendererType>}
  10996. * @api
  10997. */
  10998. var BaseTileLayer = /** @class */ (function (_super) {
  10999. BaseTile_extends(BaseTileLayer, _super);
  11000. /**
  11001. * @param {Options<TileSourceType>} [opt_options] Tile layer options.
  11002. */
  11003. function BaseTileLayer(opt_options) {
  11004. var _this = this;
  11005. var options = opt_options ? opt_options : {};
  11006. var baseOptions = obj_assign({}, options);
  11007. delete baseOptions.preload;
  11008. delete baseOptions.useInterimTilesOnError;
  11009. _this = _super.call(this, baseOptions) || this;
  11010. /***
  11011. * @type {BaseTileLayerOnSignature<import("../events").EventsKey>}
  11012. */
  11013. _this.on;
  11014. /***
  11015. * @type {BaseTileLayerOnSignature<import("../events").EventsKey>}
  11016. */
  11017. _this.once;
  11018. /***
  11019. * @type {BaseTileLayerOnSignature<void>}
  11020. */
  11021. _this.un;
  11022. _this.setPreload(options.preload !== undefined ? options.preload : 0);
  11023. _this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined
  11024. ? options.useInterimTilesOnError
  11025. : true);
  11026. return _this;
  11027. }
  11028. /**
  11029. * Return the level as number to which we will preload tiles up to.
  11030. * @return {number} The level to preload tiles up to.
  11031. * @observable
  11032. * @api
  11033. */
  11034. BaseTileLayer.prototype.getPreload = function () {
  11035. return /** @type {number} */ (this.get(TileProperty.PRELOAD));
  11036. };
  11037. /**
  11038. * Set the level as number to which we will preload tiles up to.
  11039. * @param {number} preload The level to preload tiles up to.
  11040. * @observable
  11041. * @api
  11042. */
  11043. BaseTileLayer.prototype.setPreload = function (preload) {
  11044. this.set(TileProperty.PRELOAD, preload);
  11045. };
  11046. /**
  11047. * Whether we use interim tiles on error.
  11048. * @return {boolean} Use interim tiles on error.
  11049. * @observable
  11050. * @api
  11051. */
  11052. BaseTileLayer.prototype.getUseInterimTilesOnError = function () {
  11053. return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
  11054. };
  11055. /**
  11056. * Set whether we use interim tiles on error.
  11057. * @param {boolean} useInterimTilesOnError Use interim tiles on error.
  11058. * @observable
  11059. * @api
  11060. */
  11061. BaseTileLayer.prototype.setUseInterimTilesOnError = function (useInterimTilesOnError) {
  11062. this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
  11063. };
  11064. /**
  11065. * Get data for a pixel location. The return type depends on the source data. For image tiles,
  11066. * a four element RGBA array will be returned. For data tiles, the array length will match the
  11067. * number of bands in the dataset. For requests outside the layer extent, `null` will be returned.
  11068. * Data for a image tiles can only be retrieved if the source's `crossOrigin` property is set.
  11069. *
  11070. * ```js
  11071. * // display layer data on every pointer move
  11072. * map.on('pointermove', (event) => {
  11073. * console.log(layer.getData(event.pixel));
  11074. * });
  11075. * ```
  11076. * @param {import("../pixel").Pixel} pixel Pixel.
  11077. * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
  11078. * @api
  11079. */
  11080. BaseTileLayer.prototype.getData = function (pixel) {
  11081. return _super.prototype.getData.call(this, pixel);
  11082. };
  11083. return BaseTileLayer;
  11084. }(layer_Layer));
  11085. /* harmony default export */ var BaseTile = (BaseTileLayer);
  11086. //# sourceMappingURL=BaseTile.js.map
  11087. ;// ./node_modules/ol/ImageState.js
  11088. /**
  11089. * @module ol/ImageState
  11090. */
  11091. /**
  11092. * @enum {number}
  11093. */
  11094. /* harmony default export */ var ImageState = ({
  11095. IDLE: 0,
  11096. LOADING: 1,
  11097. LOADED: 2,
  11098. ERROR: 3,
  11099. EMPTY: 4,
  11100. });
  11101. //# sourceMappingURL=ImageState.js.map
  11102. ;// ./node_modules/ol/renderer/Layer.js
  11103. var renderer_Layer_extends = (undefined && undefined.__extends) || (function () {
  11104. var extendStatics = function (d, b) {
  11105. extendStatics = Object.setPrototypeOf ||
  11106. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11107. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  11108. return extendStatics(d, b);
  11109. };
  11110. return function (d, b) {
  11111. if (typeof b !== "function" && b !== null)
  11112. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11113. extendStatics(d, b);
  11114. function __() { this.constructor = d; }
  11115. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11116. };
  11117. })();
  11118. /**
  11119. * @module ol/renderer/Layer
  11120. */
  11121. /**
  11122. * @template {import("../layer/Layer.js").default} LayerType
  11123. */
  11124. var LayerRenderer = /** @class */ (function (_super) {
  11125. renderer_Layer_extends(LayerRenderer, _super);
  11126. /**
  11127. * @param {LayerType} layer Layer.
  11128. */
  11129. function LayerRenderer(layer) {
  11130. var _this = _super.call(this) || this;
  11131. /**
  11132. * The renderer is initialized and ready to render.
  11133. * @type {boolean}
  11134. */
  11135. _this.ready = true;
  11136. /** @private */
  11137. _this.boundHandleImageChange_ = _this.handleImageChange_.bind(_this);
  11138. /**
  11139. * @protected
  11140. * @type {LayerType}
  11141. */
  11142. _this.layer_ = layer;
  11143. /**
  11144. * @type {import("../render/canvas/ExecutorGroup").default}
  11145. */
  11146. _this.declutterExecutorGroup = null;
  11147. return _this;
  11148. }
  11149. /**
  11150. * Asynchronous layer level hit detection.
  11151. * @param {import("../pixel.js").Pixel} pixel Pixel.
  11152. * @return {Promise<Array<import("../Feature").default>>} Promise that resolves with
  11153. * an array of features.
  11154. */
  11155. LayerRenderer.prototype.getFeatures = function (pixel) {
  11156. return util_abstract();
  11157. };
  11158. /**
  11159. * @param {import("../pixel.js").Pixel} pixel Pixel.
  11160. * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
  11161. */
  11162. LayerRenderer.prototype.getData = function (pixel) {
  11163. return null;
  11164. };
  11165. /**
  11166. * Determine whether render should be called.
  11167. * @abstract
  11168. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  11169. * @return {boolean} Layer is ready to be rendered.
  11170. */
  11171. LayerRenderer.prototype.prepareFrame = function (frameState) {
  11172. return util_abstract();
  11173. };
  11174. /**
  11175. * Render the layer.
  11176. * @abstract
  11177. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  11178. * @param {HTMLElement} target Target that may be used to render content to.
  11179. * @return {HTMLElement} The rendered element.
  11180. */
  11181. LayerRenderer.prototype.renderFrame = function (frameState, target) {
  11182. return util_abstract();
  11183. };
  11184. /**
  11185. * @param {Object<number, Object<string, import("../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level.
  11186. * @param {number} zoom Zoom level.
  11187. * @param {import("../Tile.js").default} tile Tile.
  11188. * @return {boolean|void} If `false`, the tile will not be considered loaded.
  11189. */
  11190. LayerRenderer.prototype.loadedTileCallback = function (tiles, zoom, tile) {
  11191. if (!tiles[zoom]) {
  11192. tiles[zoom] = {};
  11193. }
  11194. tiles[zoom][tile.tileCoord.toString()] = tile;
  11195. return undefined;
  11196. };
  11197. /**
  11198. * Create a function that adds loaded tiles to the tile lookup.
  11199. * @param {import("../source/Tile.js").default} source Tile source.
  11200. * @param {import("../proj/Projection.js").default} projection Projection of the tiles.
  11201. * @param {Object<number, Object<string, import("../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level.
  11202. * @return {function(number, import("../TileRange.js").default):boolean} A function that can be
  11203. * called with a zoom level and a tile range to add loaded tiles to the lookup.
  11204. * @protected
  11205. */
  11206. LayerRenderer.prototype.createLoadedTileFinder = function (source, projection, tiles) {
  11207. return (
  11208. /**
  11209. * @param {number} zoom Zoom level.
  11210. * @param {import("../TileRange.js").default} tileRange Tile range.
  11211. * @return {boolean} The tile range is fully loaded.
  11212. * @this {LayerRenderer}
  11213. */
  11214. function (zoom, tileRange) {
  11215. var callback = this.loadedTileCallback.bind(this, tiles, zoom);
  11216. return source.forEachLoadedTile(projection, zoom, tileRange, callback);
  11217. }.bind(this));
  11218. };
  11219. /**
  11220. * @abstract
  11221. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  11222. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  11223. * @param {number} hitTolerance Hit tolerance in pixels.
  11224. * @param {import("./vector.js").FeatureCallback<T>} callback Feature callback.
  11225. * @param {Array<import("./Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
  11226. * @return {T|undefined} Callback result.
  11227. * @template T
  11228. */
  11229. LayerRenderer.prototype.forEachFeatureAtCoordinate = function (coordinate, frameState, hitTolerance, callback, matches) {
  11230. return undefined;
  11231. };
  11232. /**
  11233. * @abstract
  11234. * @param {import("../pixel.js").Pixel} pixel Pixel.
  11235. * @param {import("../PluggableMap.js").FrameState} frameState FrameState.
  11236. * @param {number} hitTolerance Hit tolerance in pixels.
  11237. * @return {Uint8ClampedArray|Uint8Array} The result. If there is no data at the pixel
  11238. * location, null will be returned. If there is data, but pixel values cannot be
  11239. * returned, and empty array will be returned.
  11240. */
  11241. LayerRenderer.prototype.getDataAtPixel = function (pixel, frameState, hitTolerance) {
  11242. return null;
  11243. };
  11244. /**
  11245. * @return {LayerType} Layer.
  11246. */
  11247. LayerRenderer.prototype.getLayer = function () {
  11248. return this.layer_;
  11249. };
  11250. /**
  11251. * Perform action necessary to get the layer rendered after new fonts have loaded
  11252. * @abstract
  11253. */
  11254. LayerRenderer.prototype.handleFontsChanged = function () { };
  11255. /**
  11256. * Handle changes in image state.
  11257. * @param {import("../events/Event.js").default} event Image change event.
  11258. * @private
  11259. */
  11260. LayerRenderer.prototype.handleImageChange_ = function (event) {
  11261. var image = /** @type {import("../Image.js").default} */ (event.target);
  11262. if (image.getState() === ImageState.LOADED) {
  11263. this.renderIfReadyAndVisible();
  11264. }
  11265. };
  11266. /**
  11267. * Load the image if not already loaded, and register the image change
  11268. * listener if needed.
  11269. * @param {import("../ImageBase.js").default} image Image.
  11270. * @return {boolean} `true` if the image is already loaded, `false` otherwise.
  11271. * @protected
  11272. */
  11273. LayerRenderer.prototype.loadImage = function (image) {
  11274. var imageState = image.getState();
  11275. if (imageState != ImageState.LOADED && imageState != ImageState.ERROR) {
  11276. image.addEventListener(EventType.CHANGE, this.boundHandleImageChange_);
  11277. }
  11278. if (imageState == ImageState.IDLE) {
  11279. image.load();
  11280. imageState = image.getState();
  11281. }
  11282. return imageState == ImageState.LOADED;
  11283. };
  11284. /**
  11285. * @protected
  11286. */
  11287. LayerRenderer.prototype.renderIfReadyAndVisible = function () {
  11288. var layer = this.getLayer();
  11289. if (layer && layer.getVisible() && layer.getSourceState() === 'ready') {
  11290. layer.changed();
  11291. }
  11292. };
  11293. /**
  11294. * Clean up.
  11295. */
  11296. LayerRenderer.prototype.disposeInternal = function () {
  11297. delete this.layer_;
  11298. _super.prototype.disposeInternal.call(this);
  11299. };
  11300. return LayerRenderer;
  11301. }(ol_Observable));
  11302. /* harmony default export */ var renderer_Layer = (LayerRenderer);
  11303. //# sourceMappingURL=Layer.js.map
  11304. ;// ./node_modules/ol/render/Event.js
  11305. /**
  11306. * @module ol/render/Event
  11307. */
  11308. var Event_extends = (undefined && undefined.__extends) || (function () {
  11309. var extendStatics = function (d, b) {
  11310. extendStatics = Object.setPrototypeOf ||
  11311. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11312. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  11313. return extendStatics(d, b);
  11314. };
  11315. return function (d, b) {
  11316. if (typeof b !== "function" && b !== null)
  11317. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11318. extendStatics(d, b);
  11319. function __() { this.constructor = d; }
  11320. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11321. };
  11322. })();
  11323. var RenderEvent = /** @class */ (function (_super) {
  11324. Event_extends(RenderEvent, _super);
  11325. /**
  11326. * @param {import("./EventType.js").default} type Type.
  11327. * @param {import("../transform.js").Transform} [opt_inversePixelTransform] Transform for
  11328. * CSS pixels to rendered pixels.
  11329. * @param {import("../PluggableMap.js").FrameState} [opt_frameState] Frame state.
  11330. * @param {?(CanvasRenderingContext2D|WebGLRenderingContext)} [opt_context] Context.
  11331. */
  11332. function RenderEvent(type, opt_inversePixelTransform, opt_frameState, opt_context) {
  11333. var _this = _super.call(this, type) || this;
  11334. /**
  11335. * Transform from CSS pixels (relative to the top-left corner of the map viewport)
  11336. * to rendered pixels on this event's `context`. Only available when a Canvas renderer is used, null otherwise.
  11337. * @type {import("../transform.js").Transform|undefined}
  11338. * @api
  11339. */
  11340. _this.inversePixelTransform = opt_inversePixelTransform;
  11341. /**
  11342. * An object representing the current render frame state.
  11343. * @type {import("../PluggableMap.js").FrameState|undefined}
  11344. * @api
  11345. */
  11346. _this.frameState = opt_frameState;
  11347. /**
  11348. * Canvas context. Not available when the event is dispatched by the map. For Canvas 2D layers,
  11349. * the context will be the 2D rendering context. For WebGL layers, the context will be the WebGL
  11350. * context.
  11351. * @type {CanvasRenderingContext2D|WebGLRenderingContext|undefined}
  11352. * @api
  11353. */
  11354. _this.context = opt_context;
  11355. return _this;
  11356. }
  11357. return RenderEvent;
  11358. }(Event));
  11359. /* harmony default export */ var render_Event = (RenderEvent);
  11360. //# sourceMappingURL=Event.js.map
  11361. ;// ./node_modules/ol/color.js
  11362. /**
  11363. * @module ol/color
  11364. */
  11365. /**
  11366. * A color represented as a short array [red, green, blue, alpha].
  11367. * red, green, and blue should be integers in the range 0..255 inclusive.
  11368. * alpha should be a float in the range 0..1 inclusive. If no alpha value is
  11369. * given then `1` will be used.
  11370. * @typedef {Array<number>} Color
  11371. * @api
  11372. */
  11373. /**
  11374. * This RegExp matches # followed by 3, 4, 6, or 8 hex digits.
  11375. * @const
  11376. * @type {RegExp}
  11377. * @private
  11378. */
  11379. var HEX_COLOR_RE_ = /^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i;
  11380. /**
  11381. * Regular expression for matching potential named color style strings.
  11382. * @const
  11383. * @type {RegExp}
  11384. * @private
  11385. */
  11386. var NAMED_COLOR_RE_ = /^([a-z]*)$|^hsla?\(.*\)$/i;
  11387. /**
  11388. * Return the color as an rgba string.
  11389. * @param {Color|string} color Color.
  11390. * @return {string} Rgba string.
  11391. * @api
  11392. */
  11393. function asString(color) {
  11394. if (typeof color === 'string') {
  11395. return color;
  11396. }
  11397. else {
  11398. return color_toString(color);
  11399. }
  11400. }
  11401. /**
  11402. * Return named color as an rgba string.
  11403. * @param {string} color Named color.
  11404. * @return {string} Rgb string.
  11405. */
  11406. function fromNamed(color) {
  11407. var el = document.createElement('div');
  11408. el.style.color = color;
  11409. if (el.style.color !== '') {
  11410. document.body.appendChild(el);
  11411. var rgb = getComputedStyle(el).color;
  11412. document.body.removeChild(el);
  11413. return rgb;
  11414. }
  11415. else {
  11416. return '';
  11417. }
  11418. }
  11419. /**
  11420. * @param {string} s String.
  11421. * @return {Color} Color.
  11422. */
  11423. var fromString = (function () {
  11424. // We maintain a small cache of parsed strings. To provide cheap LRU-like
  11425. // semantics, whenever the cache grows too large we simply delete an
  11426. // arbitrary 25% of the entries.
  11427. /**
  11428. * @const
  11429. * @type {number}
  11430. */
  11431. var MAX_CACHE_SIZE = 1024;
  11432. /**
  11433. * @type {Object<string, Color>}
  11434. */
  11435. var cache = {};
  11436. /**
  11437. * @type {number}
  11438. */
  11439. var cacheSize = 0;
  11440. return (
  11441. /**
  11442. * @param {string} s String.
  11443. * @return {Color} Color.
  11444. */
  11445. function (s) {
  11446. var color;
  11447. if (cache.hasOwnProperty(s)) {
  11448. color = cache[s];
  11449. }
  11450. else {
  11451. if (cacheSize >= MAX_CACHE_SIZE) {
  11452. var i = 0;
  11453. for (var key in cache) {
  11454. if ((i++ & 3) === 0) {
  11455. delete cache[key];
  11456. --cacheSize;
  11457. }
  11458. }
  11459. }
  11460. color = fromStringInternal_(s);
  11461. cache[s] = color;
  11462. ++cacheSize;
  11463. }
  11464. return color;
  11465. });
  11466. })();
  11467. /**
  11468. * Return the color as an array. This function maintains a cache of calculated
  11469. * arrays which means the result should not be modified.
  11470. * @param {Color|string} color Color.
  11471. * @return {Color} Color.
  11472. * @api
  11473. */
  11474. function asArray(color) {
  11475. if (Array.isArray(color)) {
  11476. return color;
  11477. }
  11478. else {
  11479. return fromString(color);
  11480. }
  11481. }
  11482. /**
  11483. * @param {string} s String.
  11484. * @private
  11485. * @return {Color} Color.
  11486. */
  11487. function fromStringInternal_(s) {
  11488. var r, g, b, a, color;
  11489. if (NAMED_COLOR_RE_.exec(s)) {
  11490. s = fromNamed(s);
  11491. }
  11492. if (HEX_COLOR_RE_.exec(s)) {
  11493. // hex
  11494. var n = s.length - 1; // number of hex digits
  11495. var d = // number of digits per channel
  11496. void 0; // number of digits per channel
  11497. if (n <= 4) {
  11498. d = 1;
  11499. }
  11500. else {
  11501. d = 2;
  11502. }
  11503. var hasAlpha = n === 4 || n === 8;
  11504. r = parseInt(s.substr(1 + 0 * d, d), 16);
  11505. g = parseInt(s.substr(1 + 1 * d, d), 16);
  11506. b = parseInt(s.substr(1 + 2 * d, d), 16);
  11507. if (hasAlpha) {
  11508. a = parseInt(s.substr(1 + 3 * d, d), 16);
  11509. }
  11510. else {
  11511. a = 255;
  11512. }
  11513. if (d == 1) {
  11514. r = (r << 4) + r;
  11515. g = (g << 4) + g;
  11516. b = (b << 4) + b;
  11517. if (hasAlpha) {
  11518. a = (a << 4) + a;
  11519. }
  11520. }
  11521. color = [r, g, b, a / 255];
  11522. }
  11523. else if (s.indexOf('rgba(') == 0) {
  11524. // rgba()
  11525. color = s.slice(5, -1).split(',').map(Number);
  11526. normalize(color);
  11527. }
  11528. else if (s.indexOf('rgb(') == 0) {
  11529. // rgb()
  11530. color = s.slice(4, -1).split(',').map(Number);
  11531. color.push(1);
  11532. normalize(color);
  11533. }
  11534. else {
  11535. asserts_assert(false, 14); // Invalid color
  11536. }
  11537. return color;
  11538. }
  11539. /**
  11540. * TODO this function is only used in the test, we probably shouldn't export it
  11541. * @param {Color} color Color.
  11542. * @return {Color} Clamped color.
  11543. */
  11544. function normalize(color) {
  11545. color[0] = math_clamp((color[0] + 0.5) | 0, 0, 255);
  11546. color[1] = math_clamp((color[1] + 0.5) | 0, 0, 255);
  11547. color[2] = math_clamp((color[2] + 0.5) | 0, 0, 255);
  11548. color[3] = math_clamp(color[3], 0, 1);
  11549. return color;
  11550. }
  11551. /**
  11552. * @param {Color} color Color.
  11553. * @return {string} String.
  11554. */
  11555. function color_toString(color) {
  11556. var r = color[0];
  11557. if (r != (r | 0)) {
  11558. r = (r + 0.5) | 0;
  11559. }
  11560. var g = color[1];
  11561. if (g != (g | 0)) {
  11562. g = (g + 0.5) | 0;
  11563. }
  11564. var b = color[2];
  11565. if (b != (b | 0)) {
  11566. b = (b + 0.5) | 0;
  11567. }
  11568. var a = color[3] === undefined ? 1 : Math.round(color[3] * 100) / 100;
  11569. return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
  11570. }
  11571. /**
  11572. * @param {string} s String.
  11573. * @return {boolean} Whether the string is actually a valid color
  11574. */
  11575. function isStringColor(s) {
  11576. if (NAMED_COLOR_RE_.test(s)) {
  11577. s = fromNamed(s);
  11578. }
  11579. return (HEX_COLOR_RE_.test(s) || s.indexOf('rgba(') === 0 || s.indexOf('rgb(') === 0);
  11580. }
  11581. //# sourceMappingURL=color.js.map
  11582. ;// ./node_modules/ol/renderer/canvas/Layer.js
  11583. var canvas_Layer_extends = (undefined && undefined.__extends) || (function () {
  11584. var extendStatics = function (d, b) {
  11585. extendStatics = Object.setPrototypeOf ||
  11586. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11587. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  11588. return extendStatics(d, b);
  11589. };
  11590. return function (d, b) {
  11591. if (typeof b !== "function" && b !== null)
  11592. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11593. extendStatics(d, b);
  11594. function __() { this.constructor = d; }
  11595. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11596. };
  11597. })();
  11598. /**
  11599. * @module ol/renderer/canvas/Layer
  11600. */
  11601. /**
  11602. * @type {Array<HTMLCanvasElement>}
  11603. */
  11604. var canvasPool = [];
  11605. /**
  11606. * @type {CanvasRenderingContext2D}
  11607. */
  11608. var pixelContext = null;
  11609. function createPixelContext() {
  11610. var canvas = document.createElement('canvas');
  11611. canvas.width = 1;
  11612. canvas.height = 1;
  11613. pixelContext = canvas.getContext('2d');
  11614. }
  11615. /**
  11616. * @abstract
  11617. * @template {import("../../layer/Layer.js").default} LayerType
  11618. * @extends {LayerRenderer<LayerType>}
  11619. */
  11620. var CanvasLayerRenderer = /** @class */ (function (_super) {
  11621. canvas_Layer_extends(CanvasLayerRenderer, _super);
  11622. /**
  11623. * @param {LayerType} layer Layer.
  11624. */
  11625. function CanvasLayerRenderer(layer) {
  11626. var _this = _super.call(this, layer) || this;
  11627. /**
  11628. * @protected
  11629. * @type {HTMLElement}
  11630. */
  11631. _this.container = null;
  11632. /**
  11633. * @protected
  11634. * @type {number}
  11635. */
  11636. _this.renderedResolution;
  11637. /**
  11638. * A temporary transform. The values in this transform should only be used in a
  11639. * function that sets the values.
  11640. * @protected
  11641. * @type {import("../../transform.js").Transform}
  11642. */
  11643. _this.tempTransform = create();
  11644. /**
  11645. * The transform for rendered pixels to viewport CSS pixels. This transform must
  11646. * be set when rendering a frame and may be used by other functions after rendering.
  11647. * @protected
  11648. * @type {import("../../transform.js").Transform}
  11649. */
  11650. _this.pixelTransform = create();
  11651. /**
  11652. * The transform for viewport CSS pixels to rendered pixels. This transform must
  11653. * be set when rendering a frame and may be used by other functions after rendering.
  11654. * @protected
  11655. * @type {import("../../transform.js").Transform}
  11656. */
  11657. _this.inversePixelTransform = create();
  11658. /**
  11659. * @type {CanvasRenderingContext2D}
  11660. */
  11661. _this.context = null;
  11662. /**
  11663. * @type {boolean}
  11664. */
  11665. _this.containerReused = false;
  11666. /**
  11667. * @private
  11668. * @type {CanvasRenderingContext2D}
  11669. */
  11670. _this.pixelContext_ = null;
  11671. /**
  11672. * @protected
  11673. * @type {import("../../PluggableMap.js").FrameState|null}
  11674. */
  11675. _this.frameState = null;
  11676. return _this;
  11677. }
  11678. /**
  11679. * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
  11680. * @param {number} col The column index.
  11681. * @param {number} row The row index.
  11682. * @return {Uint8ClampedArray|null} The image data.
  11683. */
  11684. CanvasLayerRenderer.prototype.getImageData = function (image, col, row) {
  11685. if (!pixelContext) {
  11686. createPixelContext();
  11687. }
  11688. pixelContext.clearRect(0, 0, 1, 1);
  11689. var data;
  11690. try {
  11691. pixelContext.drawImage(image, col, row, 1, 1, 0, 0, 1, 1);
  11692. data = pixelContext.getImageData(0, 0, 1, 1).data;
  11693. }
  11694. catch (err) {
  11695. pixelContext = null;
  11696. return null;
  11697. }
  11698. return data;
  11699. };
  11700. /**
  11701. * @param {import('../../PluggableMap.js').FrameState} frameState Frame state.
  11702. * @return {string} Background color.
  11703. */
  11704. CanvasLayerRenderer.prototype.getBackground = function (frameState) {
  11705. var layer = this.getLayer();
  11706. var background = layer.getBackground();
  11707. if (typeof background === 'function') {
  11708. background = background(frameState.viewState.resolution);
  11709. }
  11710. return background || undefined;
  11711. };
  11712. /**
  11713. * Get a rendering container from an existing target, if compatible.
  11714. * @param {HTMLElement} target Potential render target.
  11715. * @param {string} transform CSS Transform.
  11716. * @param {string} [opt_backgroundColor] Background color.
  11717. */
  11718. CanvasLayerRenderer.prototype.useContainer = function (target, transform, opt_backgroundColor) {
  11719. var layerClassName = this.getLayer().getClassName();
  11720. var container, context;
  11721. if (target &&
  11722. target.className === layerClassName &&
  11723. (!opt_backgroundColor ||
  11724. (target &&
  11725. target.style.backgroundColor &&
  11726. equals(asArray(target.style.backgroundColor), asArray(opt_backgroundColor))))) {
  11727. var canvas = target.firstElementChild;
  11728. if (canvas instanceof HTMLCanvasElement) {
  11729. context = canvas.getContext('2d');
  11730. }
  11731. }
  11732. if (context && context.canvas.style.transform === transform) {
  11733. // Container of the previous layer renderer can be used.
  11734. this.container = target;
  11735. this.context = context;
  11736. this.containerReused = true;
  11737. }
  11738. else if (this.containerReused) {
  11739. // Previously reused container cannot be used any more.
  11740. this.container = null;
  11741. this.context = null;
  11742. this.containerReused = false;
  11743. }
  11744. if (!this.container) {
  11745. container = document.createElement('div');
  11746. container.className = layerClassName;
  11747. var style = container.style;
  11748. style.position = 'absolute';
  11749. style.width = '100%';
  11750. style.height = '100%';
  11751. context = createCanvasContext2D();
  11752. var canvas = context.canvas;
  11753. container.appendChild(canvas);
  11754. style = canvas.style;
  11755. style.position = 'absolute';
  11756. style.left = '0';
  11757. style.transformOrigin = 'top left';
  11758. this.container = container;
  11759. this.context = context;
  11760. }
  11761. if (!this.containerReused &&
  11762. opt_backgroundColor &&
  11763. !this.container.style.backgroundColor) {
  11764. this.container.style.backgroundColor = opt_backgroundColor;
  11765. }
  11766. };
  11767. /**
  11768. * @param {CanvasRenderingContext2D} context Context.
  11769. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  11770. * @param {import("../../extent.js").Extent} extent Clip extent.
  11771. * @protected
  11772. */
  11773. CanvasLayerRenderer.prototype.clipUnrotated = function (context, frameState, extent) {
  11774. var topLeft = getTopLeft(extent);
  11775. var topRight = getTopRight(extent);
  11776. var bottomRight = getBottomRight(extent);
  11777. var bottomLeft = getBottomLeft(extent);
  11778. apply(frameState.coordinateToPixelTransform, topLeft);
  11779. apply(frameState.coordinateToPixelTransform, topRight);
  11780. apply(frameState.coordinateToPixelTransform, bottomRight);
  11781. apply(frameState.coordinateToPixelTransform, bottomLeft);
  11782. var inverted = this.inversePixelTransform;
  11783. apply(inverted, topLeft);
  11784. apply(inverted, topRight);
  11785. apply(inverted, bottomRight);
  11786. apply(inverted, bottomLeft);
  11787. context.save();
  11788. context.beginPath();
  11789. context.moveTo(Math.round(topLeft[0]), Math.round(topLeft[1]));
  11790. context.lineTo(Math.round(topRight[0]), Math.round(topRight[1]));
  11791. context.lineTo(Math.round(bottomRight[0]), Math.round(bottomRight[1]));
  11792. context.lineTo(Math.round(bottomLeft[0]), Math.round(bottomLeft[1]));
  11793. context.clip();
  11794. };
  11795. /**
  11796. * @param {import("../../render/EventType.js").default} type Event type.
  11797. * @param {CanvasRenderingContext2D} context Context.
  11798. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  11799. * @private
  11800. */
  11801. CanvasLayerRenderer.prototype.dispatchRenderEvent_ = function (type, context, frameState) {
  11802. var layer = this.getLayer();
  11803. if (layer.hasListener(type)) {
  11804. var event_1 = new render_Event(type, this.inversePixelTransform, frameState, context);
  11805. layer.dispatchEvent(event_1);
  11806. }
  11807. };
  11808. /**
  11809. * @param {CanvasRenderingContext2D} context Context.
  11810. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  11811. * @protected
  11812. */
  11813. CanvasLayerRenderer.prototype.preRender = function (context, frameState) {
  11814. this.frameState = frameState;
  11815. this.dispatchRenderEvent_(render_EventType.PRERENDER, context, frameState);
  11816. };
  11817. /**
  11818. * @param {CanvasRenderingContext2D} context Context.
  11819. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  11820. * @protected
  11821. */
  11822. CanvasLayerRenderer.prototype.postRender = function (context, frameState) {
  11823. this.dispatchRenderEvent_(render_EventType.POSTRENDER, context, frameState);
  11824. };
  11825. /**
  11826. * Creates a transform for rendering to an element that will be rotated after rendering.
  11827. * @param {import("../../coordinate.js").Coordinate} center Center.
  11828. * @param {number} resolution Resolution.
  11829. * @param {number} rotation Rotation.
  11830. * @param {number} pixelRatio Pixel ratio.
  11831. * @param {number} width Width of the rendered element (in pixels).
  11832. * @param {number} height Height of the rendered element (in pixels).
  11833. * @param {number} offsetX Offset on the x-axis in view coordinates.
  11834. * @protected
  11835. * @return {!import("../../transform.js").Transform} Transform.
  11836. */
  11837. CanvasLayerRenderer.prototype.getRenderTransform = function (center, resolution, rotation, pixelRatio, width, height, offsetX) {
  11838. var dx1 = width / 2;
  11839. var dy1 = height / 2;
  11840. var sx = pixelRatio / resolution;
  11841. var sy = -sx;
  11842. var dx2 = -center[0] + offsetX;
  11843. var dy2 = -center[1];
  11844. return compose(this.tempTransform, dx1, dy1, sx, sy, -rotation, dx2, dy2);
  11845. };
  11846. /**
  11847. * @param {import("../../pixel.js").Pixel} pixel Pixel.
  11848. * @param {import("../../PluggableMap.js").FrameState} frameState FrameState.
  11849. * @param {number} hitTolerance Hit tolerance in pixels.
  11850. * @return {Uint8ClampedArray|Uint8Array} The result. If there is no data at the pixel
  11851. * location, null will be returned. If there is data, but pixel values cannot be
  11852. * returned, and empty array will be returned.
  11853. */
  11854. CanvasLayerRenderer.prototype.getDataAtPixel = function (pixel, frameState, hitTolerance) {
  11855. var renderPixel = apply(this.inversePixelTransform, pixel.slice());
  11856. var context = this.context;
  11857. var layer = this.getLayer();
  11858. var layerExtent = layer.getExtent();
  11859. if (layerExtent) {
  11860. var renderCoordinate = apply(frameState.pixelToCoordinateTransform, pixel.slice());
  11861. /** get only data inside of the layer extent */
  11862. if (!containsCoordinate(layerExtent, renderCoordinate)) {
  11863. return null;
  11864. }
  11865. }
  11866. var x = Math.round(renderPixel[0]);
  11867. var y = Math.round(renderPixel[1]);
  11868. var pixelContext = this.pixelContext_;
  11869. if (!pixelContext) {
  11870. var pixelCanvas = document.createElement('canvas');
  11871. pixelCanvas.width = 1;
  11872. pixelCanvas.height = 1;
  11873. pixelContext = pixelCanvas.getContext('2d');
  11874. this.pixelContext_ = pixelContext;
  11875. }
  11876. pixelContext.clearRect(0, 0, 1, 1);
  11877. var data;
  11878. try {
  11879. pixelContext.drawImage(context.canvas, x, y, 1, 1, 0, 0, 1, 1);
  11880. data = pixelContext.getImageData(0, 0, 1, 1).data;
  11881. }
  11882. catch (err) {
  11883. if (err.name === 'SecurityError') {
  11884. // tainted canvas, we assume there is data at the given pixel (although there might not be)
  11885. this.pixelContext_ = null;
  11886. return new Uint8Array();
  11887. }
  11888. return data;
  11889. }
  11890. if (data[3] === 0) {
  11891. return null;
  11892. }
  11893. return data;
  11894. };
  11895. /**
  11896. * Clean up.
  11897. */
  11898. CanvasLayerRenderer.prototype.disposeInternal = function () {
  11899. delete this.frameState;
  11900. _super.prototype.disposeInternal.call(this);
  11901. };
  11902. return CanvasLayerRenderer;
  11903. }(renderer_Layer));
  11904. /* harmony default export */ var canvas_Layer = (CanvasLayerRenderer);
  11905. //# sourceMappingURL=Layer.js.map
  11906. ;// ./node_modules/ol/TileState.js
  11907. /**
  11908. * @module ol/TileState
  11909. */
  11910. /**
  11911. * @enum {number}
  11912. */
  11913. /* harmony default export */ var TileState = ({
  11914. IDLE: 0,
  11915. LOADING: 1,
  11916. LOADED: 2,
  11917. /**
  11918. * Indicates that tile loading failed
  11919. * @type {number}
  11920. */
  11921. ERROR: 3,
  11922. EMPTY: 4,
  11923. });
  11924. //# sourceMappingURL=TileState.js.map
  11925. ;// ./node_modules/ol/Tile.js
  11926. var Tile_extends = (undefined && undefined.__extends) || (function () {
  11927. var extendStatics = function (d, b) {
  11928. extendStatics = Object.setPrototypeOf ||
  11929. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11930. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  11931. return extendStatics(d, b);
  11932. };
  11933. return function (d, b) {
  11934. if (typeof b !== "function" && b !== null)
  11935. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11936. extendStatics(d, b);
  11937. function __() { this.constructor = d; }
  11938. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11939. };
  11940. })();
  11941. /**
  11942. * @module ol/Tile
  11943. */
  11944. /**
  11945. * A function that takes an {@link module:ol/Tile~Tile} for the tile and a
  11946. * `{string}` for the url as arguments. The default is
  11947. * ```js
  11948. * source.setTileLoadFunction(function(tile, src) {
  11949. * tile.getImage().src = src;
  11950. * });
  11951. * ```
  11952. * For more fine grained control, the load function can use fetch or XMLHttpRequest and involve
  11953. * error handling:
  11954. *
  11955. * ```js
  11956. * import TileState from 'ol/TileState';
  11957. *
  11958. * source.setTileLoadFunction(function(tile, src) {
  11959. * var xhr = new XMLHttpRequest();
  11960. * xhr.responseType = 'blob';
  11961. * xhr.addEventListener('loadend', function (evt) {
  11962. * var data = this.response;
  11963. * if (data !== undefined) {
  11964. * tile.getImage().src = URL.createObjectURL(data);
  11965. * } else {
  11966. * tile.setState(TileState.ERROR);
  11967. * }
  11968. * });
  11969. * xhr.addEventListener('error', function () {
  11970. * tile.setState(TileState.ERROR);
  11971. * });
  11972. * xhr.open('GET', src);
  11973. * xhr.send();
  11974. * });
  11975. * ```
  11976. *
  11977. * @typedef {function(Tile, string): void} LoadFunction
  11978. * @api
  11979. */
  11980. /**
  11981. * {@link module:ol/source/Tile~TileSource} sources use a function of this type to get
  11982. * the url that provides a tile for a given tile coordinate.
  11983. *
  11984. * This function takes an {@link module:ol/tilecoord~TileCoord} for the tile
  11985. * coordinate, a `{number}` representing the pixel ratio and a
  11986. * {@link module:ol/proj/Projection~Projection} for the projection as arguments
  11987. * and returns a `{string}` representing the tile URL, or undefined if no tile
  11988. * should be requested for the passed tile coordinate.
  11989. *
  11990. * @typedef {function(import("./tilecoord.js").TileCoord, number,
  11991. * import("./proj/Projection.js").default): (string|undefined)} UrlFunction
  11992. * @api
  11993. */
  11994. /**
  11995. * @typedef {Object} Options
  11996. * @property {number} [transition=250] A duration for tile opacity
  11997. * transitions in milliseconds. A duration of 0 disables the opacity transition.
  11998. * @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
  11999. * the nearest neighbor is used when resampling.
  12000. * @api
  12001. */
  12002. /**
  12003. * @classdesc
  12004. * Base class for tiles.
  12005. *
  12006. * @abstract
  12007. */
  12008. var Tile = /** @class */ (function (_super) {
  12009. Tile_extends(Tile, _super);
  12010. /**
  12011. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
  12012. * @param {import("./TileState.js").default} state State.
  12013. * @param {Options} [opt_options] Tile options.
  12014. */
  12015. function Tile(tileCoord, state, opt_options) {
  12016. var _this = _super.call(this) || this;
  12017. var options = opt_options ? opt_options : {};
  12018. /**
  12019. * @type {import("./tilecoord.js").TileCoord}
  12020. */
  12021. _this.tileCoord = tileCoord;
  12022. /**
  12023. * @protected
  12024. * @type {import("./TileState.js").default}
  12025. */
  12026. _this.state = state;
  12027. /**
  12028. * An "interim" tile for this tile. The interim tile may be used while this
  12029. * one is loading, for "smooth" transitions when changing params/dimensions
  12030. * on the source.
  12031. * @type {Tile}
  12032. */
  12033. _this.interimTile = null;
  12034. /**
  12035. * A key assigned to the tile. This is used by the tile source to determine
  12036. * if this tile can effectively be used, or if a new tile should be created
  12037. * and this one be used as an interim tile for this new tile.
  12038. * @type {string}
  12039. */
  12040. _this.key = '';
  12041. /**
  12042. * The duration for the opacity transition.
  12043. * @type {number}
  12044. */
  12045. _this.transition_ =
  12046. options.transition === undefined ? 250 : options.transition;
  12047. /**
  12048. * Lookup of start times for rendering transitions. If the start time is
  12049. * equal to -1, the transition is complete.
  12050. * @type {Object<string, number>}
  12051. */
  12052. _this.transitionStarts_ = {};
  12053. /**
  12054. * @type {boolean}
  12055. */
  12056. _this.interpolate = !!options.interpolate;
  12057. return _this;
  12058. }
  12059. /**
  12060. * @protected
  12061. */
  12062. Tile.prototype.changed = function () {
  12063. this.dispatchEvent(EventType.CHANGE);
  12064. };
  12065. /**
  12066. * Called by the tile cache when the tile is removed from the cache due to expiry
  12067. */
  12068. Tile.prototype.release = function () { };
  12069. /**
  12070. * @return {string} Key.
  12071. */
  12072. Tile.prototype.getKey = function () {
  12073. return this.key + '/' + this.tileCoord;
  12074. };
  12075. /**
  12076. * Get the interim tile most suitable for rendering using the chain of interim
  12077. * tiles. This corresponds to the most recent tile that has been loaded, if no
  12078. * such tile exists, the original tile is returned.
  12079. * @return {!Tile} Best tile for rendering.
  12080. */
  12081. Tile.prototype.getInterimTile = function () {
  12082. if (!this.interimTile) {
  12083. //empty chain
  12084. return this;
  12085. }
  12086. var tile = this.interimTile;
  12087. // find the first loaded tile and return it. Since the chain is sorted in
  12088. // decreasing order of creation time, there is no need to search the remainder
  12089. // of the list (all those tiles correspond to older requests and will be
  12090. // cleaned up by refreshInterimChain)
  12091. do {
  12092. if (tile.getState() == TileState.LOADED) {
  12093. // Show tile immediately instead of fading it in after loading, because
  12094. // the interim tile is in place already
  12095. this.transition_ = 0;
  12096. return tile;
  12097. }
  12098. tile = tile.interimTile;
  12099. } while (tile);
  12100. // we can not find a better tile
  12101. return this;
  12102. };
  12103. /**
  12104. * Goes through the chain of interim tiles and discards sections of the chain
  12105. * that are no longer relevant.
  12106. */
  12107. Tile.prototype.refreshInterimChain = function () {
  12108. if (!this.interimTile) {
  12109. return;
  12110. }
  12111. var tile = this.interimTile;
  12112. /**
  12113. * @type {Tile}
  12114. */
  12115. var prev = this;
  12116. do {
  12117. if (tile.getState() == TileState.LOADED) {
  12118. //we have a loaded tile, we can discard the rest of the list
  12119. //we would could abort any LOADING tile request
  12120. //older than this tile (i.e. any LOADING tile following this entry in the chain)
  12121. tile.interimTile = null;
  12122. break;
  12123. }
  12124. else if (tile.getState() == TileState.LOADING) {
  12125. //keep this LOADING tile any loaded tiles later in the chain are
  12126. //older than this tile, so we're still interested in the request
  12127. prev = tile;
  12128. }
  12129. else if (tile.getState() == TileState.IDLE) {
  12130. //the head of the list is the most current tile, we don't need
  12131. //to start any other requests for this chain
  12132. prev.interimTile = tile.interimTile;
  12133. }
  12134. else {
  12135. prev = tile;
  12136. }
  12137. tile = prev.interimTile;
  12138. } while (tile);
  12139. };
  12140. /**
  12141. * Get the tile coordinate for this tile.
  12142. * @return {import("./tilecoord.js").TileCoord} The tile coordinate.
  12143. * @api
  12144. */
  12145. Tile.prototype.getTileCoord = function () {
  12146. return this.tileCoord;
  12147. };
  12148. /**
  12149. * @return {import("./TileState.js").default} State.
  12150. */
  12151. Tile.prototype.getState = function () {
  12152. return this.state;
  12153. };
  12154. /**
  12155. * Sets the state of this tile. If you write your own {@link module:ol/Tile~LoadFunction tileLoadFunction} ,
  12156. * it is important to set the state correctly to {@link module:ol/TileState~ERROR}
  12157. * when the tile cannot be loaded. Otherwise the tile cannot be removed from
  12158. * the tile queue and will block other requests.
  12159. * @param {import("./TileState.js").default} state State.
  12160. * @api
  12161. */
  12162. Tile.prototype.setState = function (state) {
  12163. if (this.state !== TileState.ERROR && this.state > state) {
  12164. throw new Error('Tile load sequence violation');
  12165. }
  12166. this.state = state;
  12167. this.changed();
  12168. };
  12169. /**
  12170. * Load the image or retry if loading previously failed.
  12171. * Loading is taken care of by the tile queue, and calling this method is
  12172. * only needed for preloading or for reloading in case of an error.
  12173. * @abstract
  12174. * @api
  12175. */
  12176. Tile.prototype.load = function () {
  12177. util_abstract();
  12178. };
  12179. /**
  12180. * Get the alpha value for rendering.
  12181. * @param {string} id An id for the renderer.
  12182. * @param {number} time The render frame time.
  12183. * @return {number} A number between 0 and 1.
  12184. */
  12185. Tile.prototype.getAlpha = function (id, time) {
  12186. if (!this.transition_) {
  12187. return 1;
  12188. }
  12189. var start = this.transitionStarts_[id];
  12190. if (!start) {
  12191. start = time;
  12192. this.transitionStarts_[id] = start;
  12193. }
  12194. else if (start === -1) {
  12195. return 1;
  12196. }
  12197. var delta = time - start + 1000 / 60; // avoid rendering at 0
  12198. if (delta >= this.transition_) {
  12199. return 1;
  12200. }
  12201. return easeIn(delta / this.transition_);
  12202. };
  12203. /**
  12204. * Determine if a tile is in an alpha transition. A tile is considered in
  12205. * transition if tile.getAlpha() has not yet been called or has been called
  12206. * and returned 1.
  12207. * @param {string} id An id for the renderer.
  12208. * @return {boolean} The tile is in transition.
  12209. */
  12210. Tile.prototype.inTransition = function (id) {
  12211. if (!this.transition_) {
  12212. return false;
  12213. }
  12214. return this.transitionStarts_[id] !== -1;
  12215. };
  12216. /**
  12217. * Mark a transition as complete.
  12218. * @param {string} id An id for the renderer.
  12219. */
  12220. Tile.prototype.endTransition = function (id) {
  12221. if (this.transition_) {
  12222. this.transitionStarts_[id] = -1;
  12223. }
  12224. };
  12225. return Tile;
  12226. }(events_Target));
  12227. /* harmony default export */ var ol_Tile = (Tile);
  12228. //# sourceMappingURL=Tile.js.map
  12229. ;// ./node_modules/ol/ImageBase.js
  12230. var ImageBase_extends = (undefined && undefined.__extends) || (function () {
  12231. var extendStatics = function (d, b) {
  12232. extendStatics = Object.setPrototypeOf ||
  12233. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  12234. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  12235. return extendStatics(d, b);
  12236. };
  12237. return function (d, b) {
  12238. if (typeof b !== "function" && b !== null)
  12239. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12240. extendStatics(d, b);
  12241. function __() { this.constructor = d; }
  12242. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12243. };
  12244. })();
  12245. /**
  12246. * @module ol/ImageBase
  12247. */
  12248. /**
  12249. * @abstract
  12250. */
  12251. var ImageBase = /** @class */ (function (_super) {
  12252. ImageBase_extends(ImageBase, _super);
  12253. /**
  12254. * @param {import("./extent.js").Extent} extent Extent.
  12255. * @param {number|undefined} resolution Resolution.
  12256. * @param {number} pixelRatio Pixel ratio.
  12257. * @param {import("./ImageState.js").default} state State.
  12258. */
  12259. function ImageBase(extent, resolution, pixelRatio, state) {
  12260. var _this = _super.call(this) || this;
  12261. /**
  12262. * @protected
  12263. * @type {import("./extent.js").Extent}
  12264. */
  12265. _this.extent = extent;
  12266. /**
  12267. * @private
  12268. * @type {number}
  12269. */
  12270. _this.pixelRatio_ = pixelRatio;
  12271. /**
  12272. * @protected
  12273. * @type {number|undefined}
  12274. */
  12275. _this.resolution = resolution;
  12276. /**
  12277. * @protected
  12278. * @type {import("./ImageState.js").default}
  12279. */
  12280. _this.state = state;
  12281. return _this;
  12282. }
  12283. /**
  12284. * @protected
  12285. */
  12286. ImageBase.prototype.changed = function () {
  12287. this.dispatchEvent(EventType.CHANGE);
  12288. };
  12289. /**
  12290. * @return {import("./extent.js").Extent} Extent.
  12291. */
  12292. ImageBase.prototype.getExtent = function () {
  12293. return this.extent;
  12294. };
  12295. /**
  12296. * @abstract
  12297. * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
  12298. */
  12299. ImageBase.prototype.getImage = function () {
  12300. return util_abstract();
  12301. };
  12302. /**
  12303. * @return {number} PixelRatio.
  12304. */
  12305. ImageBase.prototype.getPixelRatio = function () {
  12306. return this.pixelRatio_;
  12307. };
  12308. /**
  12309. * @return {number} Resolution.
  12310. */
  12311. ImageBase.prototype.getResolution = function () {
  12312. return /** @type {number} */ (this.resolution);
  12313. };
  12314. /**
  12315. * @return {import("./ImageState.js").default} State.
  12316. */
  12317. ImageBase.prototype.getState = function () {
  12318. return this.state;
  12319. };
  12320. /**
  12321. * Load not yet loaded URI.
  12322. * @abstract
  12323. */
  12324. ImageBase.prototype.load = function () {
  12325. util_abstract();
  12326. };
  12327. return ImageBase;
  12328. }(events_Target));
  12329. /* harmony default export */ var ol_ImageBase = (ImageBase);
  12330. //# sourceMappingURL=ImageBase.js.map
  12331. ;// ./node_modules/ol/Image.js
  12332. var Image_extends = (undefined && undefined.__extends) || (function () {
  12333. var extendStatics = function (d, b) {
  12334. extendStatics = Object.setPrototypeOf ||
  12335. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  12336. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  12337. return extendStatics(d, b);
  12338. };
  12339. return function (d, b) {
  12340. if (typeof b !== "function" && b !== null)
  12341. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12342. extendStatics(d, b);
  12343. function __() { this.constructor = d; }
  12344. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12345. };
  12346. })();
  12347. /**
  12348. * @module ol/Image
  12349. */
  12350. /**
  12351. * A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a
  12352. * `{string}` for the src as arguments. It is supposed to make it so the
  12353. * underlying image {@link module:ol/Image~ImageWrapper#getImage} is assigned the
  12354. * content specified by the src. If not specified, the default is
  12355. *
  12356. * function(image, src) {
  12357. * image.getImage().src = src;
  12358. * }
  12359. *
  12360. * Providing a custom `imageLoadFunction` can be useful to load images with
  12361. * post requests or - in general - through XHR requests, where the src of the
  12362. * image element would be set to a data URI when the content is loaded.
  12363. *
  12364. * @typedef {function(ImageWrapper, string): void} LoadFunction
  12365. * @api
  12366. */
  12367. var ImageWrapper = /** @class */ (function (_super) {
  12368. Image_extends(ImageWrapper, _super);
  12369. /**
  12370. * @param {import("./extent.js").Extent} extent Extent.
  12371. * @param {number|undefined} resolution Resolution.
  12372. * @param {number} pixelRatio Pixel ratio.
  12373. * @param {string} src Image source URI.
  12374. * @param {?string} crossOrigin Cross origin.
  12375. * @param {LoadFunction} imageLoadFunction Image load function.
  12376. */
  12377. function ImageWrapper(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
  12378. var _this = _super.call(this, extent, resolution, pixelRatio, ImageState.IDLE) || this;
  12379. /**
  12380. * @private
  12381. * @type {string}
  12382. */
  12383. _this.src_ = src;
  12384. /**
  12385. * @private
  12386. * @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement}
  12387. */
  12388. _this.image_ = new Image();
  12389. if (crossOrigin !== null) {
  12390. _this.image_.crossOrigin = crossOrigin;
  12391. }
  12392. /**
  12393. * @private
  12394. * @type {?function():void}
  12395. */
  12396. _this.unlisten_ = null;
  12397. /**
  12398. * @protected
  12399. * @type {import("./ImageState.js").default}
  12400. */
  12401. _this.state = ImageState.IDLE;
  12402. /**
  12403. * @private
  12404. * @type {LoadFunction}
  12405. */
  12406. _this.imageLoadFunction_ = imageLoadFunction;
  12407. return _this;
  12408. }
  12409. /**
  12410. * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
  12411. * @api
  12412. */
  12413. ImageWrapper.prototype.getImage = function () {
  12414. return this.image_;
  12415. };
  12416. /**
  12417. * Tracks loading or read errors.
  12418. *
  12419. * @private
  12420. */
  12421. ImageWrapper.prototype.handleImageError_ = function () {
  12422. this.state = ImageState.ERROR;
  12423. this.unlistenImage_();
  12424. this.changed();
  12425. };
  12426. /**
  12427. * Tracks successful image load.
  12428. *
  12429. * @private
  12430. */
  12431. ImageWrapper.prototype.handleImageLoad_ = function () {
  12432. if (this.resolution === undefined) {
  12433. this.resolution = getHeight(this.extent) / this.image_.height;
  12434. }
  12435. this.state = ImageState.LOADED;
  12436. this.unlistenImage_();
  12437. this.changed();
  12438. };
  12439. /**
  12440. * Load the image or retry if loading previously failed.
  12441. * Loading is taken care of by the tile queue, and calling this method is
  12442. * only needed for preloading or for reloading in case of an error.
  12443. * @api
  12444. */
  12445. ImageWrapper.prototype.load = function () {
  12446. if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) {
  12447. this.state = ImageState.LOADING;
  12448. this.changed();
  12449. this.imageLoadFunction_(this, this.src_);
  12450. this.unlisten_ = listenImage(this.image_, this.handleImageLoad_.bind(this), this.handleImageError_.bind(this));
  12451. }
  12452. };
  12453. /**
  12454. * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
  12455. */
  12456. ImageWrapper.prototype.setImage = function (image) {
  12457. this.image_ = image;
  12458. this.resolution = getHeight(this.extent) / this.image_.height;
  12459. };
  12460. /**
  12461. * Discards event handlers which listen for load completion or errors.
  12462. *
  12463. * @private
  12464. */
  12465. ImageWrapper.prototype.unlistenImage_ = function () {
  12466. if (this.unlisten_) {
  12467. this.unlisten_();
  12468. this.unlisten_ = null;
  12469. }
  12470. };
  12471. return ImageWrapper;
  12472. }(ol_ImageBase));
  12473. /**
  12474. * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image element.
  12475. * @param {function():any} loadHandler Load callback function.
  12476. * @param {function():any} errorHandler Error callback function.
  12477. * @return {function():void} Callback to stop listening.
  12478. */
  12479. function listenImage(image, loadHandler, errorHandler) {
  12480. var img = /** @type {HTMLImageElement} */ (image);
  12481. var listening = true;
  12482. var decoding = false;
  12483. var loaded = false;
  12484. var listenerKeys = [
  12485. listenOnce(img, EventType.LOAD, function () {
  12486. loaded = true;
  12487. if (!decoding) {
  12488. loadHandler();
  12489. }
  12490. }),
  12491. ];
  12492. if (img.src && IMAGE_DECODE) {
  12493. decoding = true;
  12494. img
  12495. .decode()
  12496. .then(function () {
  12497. if (listening) {
  12498. loadHandler();
  12499. }
  12500. })
  12501. .catch(function (error) {
  12502. if (listening) {
  12503. if (loaded) {
  12504. loadHandler();
  12505. }
  12506. else {
  12507. errorHandler();
  12508. }
  12509. }
  12510. });
  12511. }
  12512. else {
  12513. listenerKeys.push(listenOnce(img, EventType.ERROR, errorHandler));
  12514. }
  12515. return function unlisten() {
  12516. listening = false;
  12517. listenerKeys.forEach(unlistenByKey);
  12518. };
  12519. }
  12520. /* harmony default export */ var ol_Image = ((/* unused pure expression or super */ null && (ImageWrapper)));
  12521. //# sourceMappingURL=Image.js.map
  12522. ;// ./node_modules/ol/ImageTile.js
  12523. var ImageTile_extends = (undefined && undefined.__extends) || (function () {
  12524. var extendStatics = function (d, b) {
  12525. extendStatics = Object.setPrototypeOf ||
  12526. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  12527. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  12528. return extendStatics(d, b);
  12529. };
  12530. return function (d, b) {
  12531. if (typeof b !== "function" && b !== null)
  12532. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12533. extendStatics(d, b);
  12534. function __() { this.constructor = d; }
  12535. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12536. };
  12537. })();
  12538. /**
  12539. * @module ol/ImageTile
  12540. */
  12541. var ImageTile = /** @class */ (function (_super) {
  12542. ImageTile_extends(ImageTile, _super);
  12543. /**
  12544. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
  12545. * @param {import("./TileState.js").default} state State.
  12546. * @param {string} src Image source URI.
  12547. * @param {?string} crossOrigin Cross origin.
  12548. * @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
  12549. * @param {import("./Tile.js").Options} [opt_options] Tile options.
  12550. */
  12551. function ImageTile(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
  12552. var _this = _super.call(this, tileCoord, state, opt_options) || this;
  12553. /**
  12554. * @private
  12555. * @type {?string}
  12556. */
  12557. _this.crossOrigin_ = crossOrigin;
  12558. /**
  12559. * Image URI
  12560. *
  12561. * @private
  12562. * @type {string}
  12563. */
  12564. _this.src_ = src;
  12565. _this.key = src;
  12566. /**
  12567. * @private
  12568. * @type {HTMLImageElement|HTMLCanvasElement}
  12569. */
  12570. _this.image_ = new Image();
  12571. if (crossOrigin !== null) {
  12572. _this.image_.crossOrigin = crossOrigin;
  12573. }
  12574. /**
  12575. * @private
  12576. * @type {?function():void}
  12577. */
  12578. _this.unlisten_ = null;
  12579. /**
  12580. * @private
  12581. * @type {import("./Tile.js").LoadFunction}
  12582. */
  12583. _this.tileLoadFunction_ = tileLoadFunction;
  12584. return _this;
  12585. }
  12586. /**
  12587. * Get the HTML image element for this tile (may be a Canvas, Image, or Video).
  12588. * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
  12589. * @api
  12590. */
  12591. ImageTile.prototype.getImage = function () {
  12592. return this.image_;
  12593. };
  12594. /**
  12595. * Sets an HTML image element for this tile (may be a Canvas or preloaded Image).
  12596. * @param {HTMLCanvasElement|HTMLImageElement} element Element.
  12597. */
  12598. ImageTile.prototype.setImage = function (element) {
  12599. this.image_ = element;
  12600. this.state = TileState.LOADED;
  12601. this.unlistenImage_();
  12602. this.changed();
  12603. };
  12604. /**
  12605. * Tracks loading or read errors.
  12606. *
  12607. * @private
  12608. */
  12609. ImageTile.prototype.handleImageError_ = function () {
  12610. this.state = TileState.ERROR;
  12611. this.unlistenImage_();
  12612. this.image_ = getBlankImage();
  12613. this.changed();
  12614. };
  12615. /**
  12616. * Tracks successful image load.
  12617. *
  12618. * @private
  12619. */
  12620. ImageTile.prototype.handleImageLoad_ = function () {
  12621. var image = /** @type {HTMLImageElement} */ (this.image_);
  12622. if (image.naturalWidth && image.naturalHeight) {
  12623. this.state = TileState.LOADED;
  12624. }
  12625. else {
  12626. this.state = TileState.EMPTY;
  12627. }
  12628. this.unlistenImage_();
  12629. this.changed();
  12630. };
  12631. /**
  12632. * Load not yet loaded URI.
  12633. * @api
  12634. */
  12635. ImageTile.prototype.load = function () {
  12636. if (this.state == TileState.ERROR) {
  12637. this.state = TileState.IDLE;
  12638. this.image_ = new Image();
  12639. if (this.crossOrigin_ !== null) {
  12640. this.image_.crossOrigin = this.crossOrigin_;
  12641. }
  12642. }
  12643. if (this.state == TileState.IDLE) {
  12644. this.state = TileState.LOADING;
  12645. this.changed();
  12646. this.tileLoadFunction_(this, this.src_);
  12647. this.unlisten_ = listenImage(this.image_, this.handleImageLoad_.bind(this), this.handleImageError_.bind(this));
  12648. }
  12649. };
  12650. /**
  12651. * Discards event handlers which listen for load completion or errors.
  12652. *
  12653. * @private
  12654. */
  12655. ImageTile.prototype.unlistenImage_ = function () {
  12656. if (this.unlisten_) {
  12657. this.unlisten_();
  12658. this.unlisten_ = null;
  12659. }
  12660. };
  12661. return ImageTile;
  12662. }(ol_Tile));
  12663. /**
  12664. * Get a 1-pixel blank image.
  12665. * @return {HTMLCanvasElement} Blank image.
  12666. */
  12667. function getBlankImage() {
  12668. var ctx = createCanvasContext2D(1, 1);
  12669. ctx.fillStyle = 'rgba(0,0,0,0)';
  12670. ctx.fillRect(0, 0, 1, 1);
  12671. return ctx.canvas;
  12672. }
  12673. /* harmony default export */ var ol_ImageTile = (ImageTile);
  12674. //# sourceMappingURL=ImageTile.js.map
  12675. ;// ./node_modules/ol/reproj/common.js
  12676. /**
  12677. * @module ol/reproj/common
  12678. */
  12679. /**
  12680. * Default maximum allowed threshold (in pixels) for reprojection
  12681. * triangulation.
  12682. * @type {number}
  12683. */
  12684. var ERROR_THRESHOLD = 0.5;
  12685. /**
  12686. * Enable automatic reprojection of raster sources. Default is `true`.
  12687. * TODO: decide if we want to expose this as a build flag or remove it
  12688. * @type {boolean}
  12689. */
  12690. var ENABLE_RASTER_REPROJECTION = true;
  12691. //# sourceMappingURL=common.js.map
  12692. ;// ./node_modules/ol/reproj/Triangulation.js
  12693. /**
  12694. * @module ol/reproj/Triangulation
  12695. */
  12696. /**
  12697. * Single triangle; consists of 3 source points and 3 target points.
  12698. * @typedef {Object} Triangle
  12699. * @property {Array<import("../coordinate.js").Coordinate>} source Source.
  12700. * @property {Array<import("../coordinate.js").Coordinate>} target Target.
  12701. */
  12702. /**
  12703. * Maximum number of subdivision steps during raster reprojection triangulation.
  12704. * Prevents high memory usage and large number of proj4 calls (for certain
  12705. * transformations and areas). At most `2*(2^this)` triangles are created for
  12706. * each triangulated extent (tile/image).
  12707. * @type {number}
  12708. */
  12709. var MAX_SUBDIVISION = 10;
  12710. /**
  12711. * Maximum allowed size of triangle relative to world width. When transforming
  12712. * corners of world extent between certain projections, the resulting
  12713. * triangulation seems to have zero error and no subdivision is performed. If
  12714. * the triangle width is more than this (relative to world width; 0-1),
  12715. * subdivison is forced (up to `MAX_SUBDIVISION`). Default is `0.25`.
  12716. * @type {number}
  12717. */
  12718. var MAX_TRIANGLE_WIDTH = 0.25;
  12719. /**
  12720. * @classdesc
  12721. * Class containing triangulation of the given target extent.
  12722. * Used for determining source data and the reprojection itself.
  12723. */
  12724. var Triangulation = /** @class */ (function () {
  12725. /**
  12726. * @param {import("../proj/Projection.js").default} sourceProj Source projection.
  12727. * @param {import("../proj/Projection.js").default} targetProj Target projection.
  12728. * @param {import("../extent.js").Extent} targetExtent Target extent to triangulate.
  12729. * @param {import("../extent.js").Extent} maxSourceExtent Maximal source extent that can be used.
  12730. * @param {number} errorThreshold Acceptable error (in source units).
  12731. * @param {?number} opt_destinationResolution The (optional) resolution of the destination.
  12732. */
  12733. function Triangulation(sourceProj, targetProj, targetExtent, maxSourceExtent, errorThreshold, opt_destinationResolution) {
  12734. /**
  12735. * @type {import("../proj/Projection.js").default}
  12736. * @private
  12737. */
  12738. this.sourceProj_ = sourceProj;
  12739. /**
  12740. * @type {import("../proj/Projection.js").default}
  12741. * @private
  12742. */
  12743. this.targetProj_ = targetProj;
  12744. /** @type {!Object<string, import("../coordinate.js").Coordinate>} */
  12745. var transformInvCache = {};
  12746. var transformInv = getTransform(this.targetProj_, this.sourceProj_);
  12747. /**
  12748. * @param {import("../coordinate.js").Coordinate} c A coordinate.
  12749. * @return {import("../coordinate.js").Coordinate} Transformed coordinate.
  12750. * @private
  12751. */
  12752. this.transformInv_ = function (c) {
  12753. var key = c[0] + '/' + c[1];
  12754. if (!transformInvCache[key]) {
  12755. transformInvCache[key] = transformInv(c);
  12756. }
  12757. return transformInvCache[key];
  12758. };
  12759. /**
  12760. * @type {import("../extent.js").Extent}
  12761. * @private
  12762. */
  12763. this.maxSourceExtent_ = maxSourceExtent;
  12764. /**
  12765. * @type {number}
  12766. * @private
  12767. */
  12768. this.errorThresholdSquared_ = errorThreshold * errorThreshold;
  12769. /**
  12770. * @type {Array<Triangle>}
  12771. * @private
  12772. */
  12773. this.triangles_ = [];
  12774. /**
  12775. * Indicates that the triangulation crosses edge of the source projection.
  12776. * @type {boolean}
  12777. * @private
  12778. */
  12779. this.wrapsXInSource_ = false;
  12780. /**
  12781. * @type {boolean}
  12782. * @private
  12783. */
  12784. this.canWrapXInSource_ =
  12785. this.sourceProj_.canWrapX() &&
  12786. !!maxSourceExtent &&
  12787. !!this.sourceProj_.getExtent() &&
  12788. extent_getWidth(maxSourceExtent) == extent_getWidth(this.sourceProj_.getExtent());
  12789. /**
  12790. * @type {?number}
  12791. * @private
  12792. */
  12793. this.sourceWorldWidth_ = this.sourceProj_.getExtent()
  12794. ? extent_getWidth(this.sourceProj_.getExtent())
  12795. : null;
  12796. /**
  12797. * @type {?number}
  12798. * @private
  12799. */
  12800. this.targetWorldWidth_ = this.targetProj_.getExtent()
  12801. ? extent_getWidth(this.targetProj_.getExtent())
  12802. : null;
  12803. var destinationTopLeft = getTopLeft(targetExtent);
  12804. var destinationTopRight = getTopRight(targetExtent);
  12805. var destinationBottomRight = getBottomRight(targetExtent);
  12806. var destinationBottomLeft = getBottomLeft(targetExtent);
  12807. var sourceTopLeft = this.transformInv_(destinationTopLeft);
  12808. var sourceTopRight = this.transformInv_(destinationTopRight);
  12809. var sourceBottomRight = this.transformInv_(destinationBottomRight);
  12810. var sourceBottomLeft = this.transformInv_(destinationBottomLeft);
  12811. /*
  12812. * The maxSubdivision controls how many splittings of the target area can
  12813. * be done. The idea here is to do a linear mapping of the target areas
  12814. * but the actual overal reprojection (can be) extremely non-linear. The
  12815. * default value of MAX_SUBDIVISION was chosen based on mapping a 256x256
  12816. * tile size. However this function is also called to remap canvas rendered
  12817. * layers which can be much larger. This calculation increases the maxSubdivision
  12818. * value by the right factor so that each 256x256 pixel area has
  12819. * MAX_SUBDIVISION divisions.
  12820. */
  12821. var maxSubdivision = MAX_SUBDIVISION +
  12822. (opt_destinationResolution
  12823. ? Math.max(0, Math.ceil(log2(getArea(targetExtent) /
  12824. (opt_destinationResolution *
  12825. opt_destinationResolution *
  12826. 256 *
  12827. 256))))
  12828. : 0);
  12829. this.addQuad_(destinationTopLeft, destinationTopRight, destinationBottomRight, destinationBottomLeft, sourceTopLeft, sourceTopRight, sourceBottomRight, sourceBottomLeft, maxSubdivision);
  12830. if (this.wrapsXInSource_) {
  12831. var leftBound_1 = Infinity;
  12832. this.triangles_.forEach(function (triangle, i, arr) {
  12833. leftBound_1 = Math.min(leftBound_1, triangle.source[0][0], triangle.source[1][0], triangle.source[2][0]);
  12834. });
  12835. // Shift triangles to be as close to `leftBound` as possible
  12836. // (if the distance is more than `worldWidth / 2` it can be closer.
  12837. this.triangles_.forEach(function (triangle) {
  12838. if (Math.max(triangle.source[0][0], triangle.source[1][0], triangle.source[2][0]) -
  12839. leftBound_1 >
  12840. this.sourceWorldWidth_ / 2) {
  12841. var newTriangle = [
  12842. [triangle.source[0][0], triangle.source[0][1]],
  12843. [triangle.source[1][0], triangle.source[1][1]],
  12844. [triangle.source[2][0], triangle.source[2][1]],
  12845. ];
  12846. if (newTriangle[0][0] - leftBound_1 > this.sourceWorldWidth_ / 2) {
  12847. newTriangle[0][0] -= this.sourceWorldWidth_;
  12848. }
  12849. if (newTriangle[1][0] - leftBound_1 > this.sourceWorldWidth_ / 2) {
  12850. newTriangle[1][0] -= this.sourceWorldWidth_;
  12851. }
  12852. if (newTriangle[2][0] - leftBound_1 > this.sourceWorldWidth_ / 2) {
  12853. newTriangle[2][0] -= this.sourceWorldWidth_;
  12854. }
  12855. // Rarely (if the extent contains both the dateline and prime meridian)
  12856. // the shift can in turn break some triangles.
  12857. // Detect this here and don't shift in such cases.
  12858. var minX = Math.min(newTriangle[0][0], newTriangle[1][0], newTriangle[2][0]);
  12859. var maxX = Math.max(newTriangle[0][0], newTriangle[1][0], newTriangle[2][0]);
  12860. if (maxX - minX < this.sourceWorldWidth_ / 2) {
  12861. triangle.source = newTriangle;
  12862. }
  12863. }
  12864. }.bind(this));
  12865. }
  12866. transformInvCache = {};
  12867. }
  12868. /**
  12869. * Adds triangle to the triangulation.
  12870. * @param {import("../coordinate.js").Coordinate} a The target a coordinate.
  12871. * @param {import("../coordinate.js").Coordinate} b The target b coordinate.
  12872. * @param {import("../coordinate.js").Coordinate} c The target c coordinate.
  12873. * @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
  12874. * @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
  12875. * @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
  12876. * @private
  12877. */
  12878. Triangulation.prototype.addTriangle_ = function (a, b, c, aSrc, bSrc, cSrc) {
  12879. this.triangles_.push({
  12880. source: [aSrc, bSrc, cSrc],
  12881. target: [a, b, c],
  12882. });
  12883. };
  12884. /**
  12885. * Adds quad (points in clock-wise order) to the triangulation
  12886. * (and reprojects the vertices) if valid.
  12887. * Performs quad subdivision if needed to increase precision.
  12888. *
  12889. * @param {import("../coordinate.js").Coordinate} a The target a coordinate.
  12890. * @param {import("../coordinate.js").Coordinate} b The target b coordinate.
  12891. * @param {import("../coordinate.js").Coordinate} c The target c coordinate.
  12892. * @param {import("../coordinate.js").Coordinate} d The target d coordinate.
  12893. * @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
  12894. * @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
  12895. * @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
  12896. * @param {import("../coordinate.js").Coordinate} dSrc The source d coordinate.
  12897. * @param {number} maxSubdivision Maximal allowed subdivision of the quad.
  12898. * @private
  12899. */
  12900. Triangulation.prototype.addQuad_ = function (a, b, c, d, aSrc, bSrc, cSrc, dSrc, maxSubdivision) {
  12901. var sourceQuadExtent = boundingExtent([aSrc, bSrc, cSrc, dSrc]);
  12902. var sourceCoverageX = this.sourceWorldWidth_
  12903. ? extent_getWidth(sourceQuadExtent) / this.sourceWorldWidth_
  12904. : null;
  12905. var sourceWorldWidth = /** @type {number} */ (this.sourceWorldWidth_);
  12906. // when the quad is wrapped in the source projection
  12907. // it covers most of the projection extent, but not fully
  12908. var wrapsX = this.sourceProj_.canWrapX() &&
  12909. sourceCoverageX > 0.5 &&
  12910. sourceCoverageX < 1;
  12911. var needsSubdivision = false;
  12912. if (maxSubdivision > 0) {
  12913. if (this.targetProj_.isGlobal() && this.targetWorldWidth_) {
  12914. var targetQuadExtent = boundingExtent([a, b, c, d]);
  12915. var targetCoverageX = extent_getWidth(targetQuadExtent) / this.targetWorldWidth_;
  12916. needsSubdivision =
  12917. targetCoverageX > MAX_TRIANGLE_WIDTH || needsSubdivision;
  12918. }
  12919. if (!wrapsX && this.sourceProj_.isGlobal() && sourceCoverageX) {
  12920. needsSubdivision =
  12921. sourceCoverageX > MAX_TRIANGLE_WIDTH || needsSubdivision;
  12922. }
  12923. }
  12924. if (!needsSubdivision && this.maxSourceExtent_) {
  12925. if (isFinite(sourceQuadExtent[0]) &&
  12926. isFinite(sourceQuadExtent[1]) &&
  12927. isFinite(sourceQuadExtent[2]) &&
  12928. isFinite(sourceQuadExtent[3])) {
  12929. if (!intersects(sourceQuadExtent, this.maxSourceExtent_)) {
  12930. // whole quad outside source projection extent -> ignore
  12931. return;
  12932. }
  12933. }
  12934. }
  12935. var isNotFinite = 0;
  12936. if (!needsSubdivision) {
  12937. if (!isFinite(aSrc[0]) ||
  12938. !isFinite(aSrc[1]) ||
  12939. !isFinite(bSrc[0]) ||
  12940. !isFinite(bSrc[1]) ||
  12941. !isFinite(cSrc[0]) ||
  12942. !isFinite(cSrc[1]) ||
  12943. !isFinite(dSrc[0]) ||
  12944. !isFinite(dSrc[1])) {
  12945. if (maxSubdivision > 0) {
  12946. needsSubdivision = true;
  12947. }
  12948. else {
  12949. // It might be the case that only 1 of the points is infinite. In this case
  12950. // we can draw a single triangle with the other three points
  12951. isNotFinite =
  12952. (!isFinite(aSrc[0]) || !isFinite(aSrc[1]) ? 8 : 0) +
  12953. (!isFinite(bSrc[0]) || !isFinite(bSrc[1]) ? 4 : 0) +
  12954. (!isFinite(cSrc[0]) || !isFinite(cSrc[1]) ? 2 : 0) +
  12955. (!isFinite(dSrc[0]) || !isFinite(dSrc[1]) ? 1 : 0);
  12956. if (isNotFinite != 1 &&
  12957. isNotFinite != 2 &&
  12958. isNotFinite != 4 &&
  12959. isNotFinite != 8) {
  12960. return;
  12961. }
  12962. }
  12963. }
  12964. }
  12965. if (maxSubdivision > 0) {
  12966. if (!needsSubdivision) {
  12967. var center = [(a[0] + c[0]) / 2, (a[1] + c[1]) / 2];
  12968. var centerSrc = this.transformInv_(center);
  12969. var dx = void 0;
  12970. if (wrapsX) {
  12971. var centerSrcEstimX = (math_modulo(aSrc[0], sourceWorldWidth) +
  12972. math_modulo(cSrc[0], sourceWorldWidth)) /
  12973. 2;
  12974. dx = centerSrcEstimX - math_modulo(centerSrc[0], sourceWorldWidth);
  12975. }
  12976. else {
  12977. dx = (aSrc[0] + cSrc[0]) / 2 - centerSrc[0];
  12978. }
  12979. var dy = (aSrc[1] + cSrc[1]) / 2 - centerSrc[1];
  12980. var centerSrcErrorSquared = dx * dx + dy * dy;
  12981. needsSubdivision = centerSrcErrorSquared > this.errorThresholdSquared_;
  12982. }
  12983. if (needsSubdivision) {
  12984. if (Math.abs(a[0] - c[0]) <= Math.abs(a[1] - c[1])) {
  12985. // split horizontally (top & bottom)
  12986. var bc = [(b[0] + c[0]) / 2, (b[1] + c[1]) / 2];
  12987. var bcSrc = this.transformInv_(bc);
  12988. var da = [(d[0] + a[0]) / 2, (d[1] + a[1]) / 2];
  12989. var daSrc = this.transformInv_(da);
  12990. this.addQuad_(a, b, bc, da, aSrc, bSrc, bcSrc, daSrc, maxSubdivision - 1);
  12991. this.addQuad_(da, bc, c, d, daSrc, bcSrc, cSrc, dSrc, maxSubdivision - 1);
  12992. }
  12993. else {
  12994. // split vertically (left & right)
  12995. var ab = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
  12996. var abSrc = this.transformInv_(ab);
  12997. var cd = [(c[0] + d[0]) / 2, (c[1] + d[1]) / 2];
  12998. var cdSrc = this.transformInv_(cd);
  12999. this.addQuad_(a, ab, cd, d, aSrc, abSrc, cdSrc, dSrc, maxSubdivision - 1);
  13000. this.addQuad_(ab, b, c, cd, abSrc, bSrc, cSrc, cdSrc, maxSubdivision - 1);
  13001. }
  13002. return;
  13003. }
  13004. }
  13005. if (wrapsX) {
  13006. if (!this.canWrapXInSource_) {
  13007. return;
  13008. }
  13009. this.wrapsXInSource_ = true;
  13010. }
  13011. // Exactly zero or one of *Src is not finite
  13012. // The triangles must have the diagonal line as the first side
  13013. // This is to allow easy code in reproj.s to make it straight for broken
  13014. // browsers that can't handle diagonal clipping
  13015. if ((isNotFinite & 0xb) == 0) {
  13016. this.addTriangle_(a, c, d, aSrc, cSrc, dSrc);
  13017. }
  13018. if ((isNotFinite & 0xe) == 0) {
  13019. this.addTriangle_(a, c, b, aSrc, cSrc, bSrc);
  13020. }
  13021. if (isNotFinite) {
  13022. // Try the other two triangles
  13023. if ((isNotFinite & 0xd) == 0) {
  13024. this.addTriangle_(b, d, a, bSrc, dSrc, aSrc);
  13025. }
  13026. if ((isNotFinite & 0x7) == 0) {
  13027. this.addTriangle_(b, d, c, bSrc, dSrc, cSrc);
  13028. }
  13029. }
  13030. };
  13031. /**
  13032. * Calculates extent of the `source` coordinates from all the triangles.
  13033. *
  13034. * @return {import("../extent.js").Extent} Calculated extent.
  13035. */
  13036. Triangulation.prototype.calculateSourceExtent = function () {
  13037. var extent = createEmpty();
  13038. this.triangles_.forEach(function (triangle, i, arr) {
  13039. var src = triangle.source;
  13040. extendCoordinate(extent, src[0]);
  13041. extendCoordinate(extent, src[1]);
  13042. extendCoordinate(extent, src[2]);
  13043. });
  13044. return extent;
  13045. };
  13046. /**
  13047. * @return {Array<Triangle>} Array of the calculated triangles.
  13048. */
  13049. Triangulation.prototype.getTriangles = function () {
  13050. return this.triangles_;
  13051. };
  13052. return Triangulation;
  13053. }());
  13054. /* harmony default export */ var reproj_Triangulation = (Triangulation);
  13055. //# sourceMappingURL=Triangulation.js.map
  13056. ;// ./node_modules/ol/renderer/canvas/common.js
  13057. /**
  13058. * @module ol/renderer/canvas/common
  13059. */
  13060. /**
  13061. * Context options to disable image smoothing.
  13062. * @type {Object}
  13063. */
  13064. var IMAGE_SMOOTHING_DISABLED = {
  13065. imageSmoothingEnabled: false,
  13066. msImageSmoothingEnabled: false,
  13067. };
  13068. /**
  13069. * Context options to enable image smoothing.
  13070. * @type {Object}
  13071. */
  13072. var IMAGE_SMOOTHING_ENABLED = {
  13073. imageSmoothingEnabled: true,
  13074. msImageSmoothingEnabled: true,
  13075. };
  13076. //# sourceMappingURL=common.js.map
  13077. ;// ./node_modules/ol/reproj.js
  13078. /**
  13079. * @module ol/reproj
  13080. */
  13081. var brokenDiagonalRendering_;
  13082. /**
  13083. * @type {Array<HTMLCanvasElement>}
  13084. */
  13085. var reproj_canvasPool = [];
  13086. /**
  13087. * This draws a small triangle into a canvas by setting the triangle as the clip region
  13088. * and then drawing a (too large) rectangle
  13089. *
  13090. * @param {CanvasRenderingContext2D} ctx The context in which to draw the triangle
  13091. * @param {number} u1 The x-coordinate of the second point. The first point is 0,0.
  13092. * @param {number} v1 The y-coordinate of the second point.
  13093. * @param {number} u2 The x-coordinate of the third point.
  13094. * @param {number} v2 The y-coordinate of the third point.
  13095. */
  13096. function drawTestTriangle(ctx, u1, v1, u2, v2) {
  13097. ctx.beginPath();
  13098. ctx.moveTo(0, 0);
  13099. ctx.lineTo(u1, v1);
  13100. ctx.lineTo(u2, v2);
  13101. ctx.closePath();
  13102. ctx.save();
  13103. ctx.clip();
  13104. ctx.fillRect(0, 0, Math.max(u1, u2) + 1, Math.max(v1, v2));
  13105. ctx.restore();
  13106. }
  13107. /**
  13108. * Given the data from getImageData, see if the right values appear at the provided offset.
  13109. * Returns true if either the color or transparency is off
  13110. *
  13111. * @param {Uint8ClampedArray} data The data returned from getImageData
  13112. * @param {number} offset The pixel offset from the start of data.
  13113. * @return {boolean} true if the diagonal rendering is broken
  13114. */
  13115. function verifyBrokenDiagonalRendering(data, offset) {
  13116. // the values ought to be close to the rgba(210, 0, 0, 0.75)
  13117. return (Math.abs(data[offset * 4] - 210) > 2 ||
  13118. Math.abs(data[offset * 4 + 3] - 0.75 * 255) > 2);
  13119. }
  13120. /**
  13121. * Determines if the current browser configuration can render triangular clip regions correctly.
  13122. * This value is cached so the function is only expensive the first time called.
  13123. * Firefox on Windows (as of now) does not if HWA is enabled. See https://bugzilla.mozilla.org/show_bug.cgi?id=1606976
  13124. * IE also doesn't. Chrome works, and everything seems to work on OSX and Android. This function caches the
  13125. * result. I suppose that it is conceivably possible that a browser might flip modes while the app is
  13126. * running, but lets hope not.
  13127. *
  13128. * @return {boolean} true if the Diagonal Rendering is broken.
  13129. */
  13130. function isBrokenDiagonalRendering() {
  13131. if (brokenDiagonalRendering_ === undefined) {
  13132. var ctx = document.createElement('canvas').getContext('2d');
  13133. ctx.globalCompositeOperation = 'lighter';
  13134. ctx.fillStyle = 'rgba(210, 0, 0, 0.75)';
  13135. drawTestTriangle(ctx, 4, 5, 4, 0);
  13136. drawTestTriangle(ctx, 4, 5, 0, 5);
  13137. var data = ctx.getImageData(0, 0, 3, 3).data;
  13138. brokenDiagonalRendering_ =
  13139. verifyBrokenDiagonalRendering(data, 0) ||
  13140. verifyBrokenDiagonalRendering(data, 4) ||
  13141. verifyBrokenDiagonalRendering(data, 8);
  13142. }
  13143. return brokenDiagonalRendering_;
  13144. }
  13145. /**
  13146. * Calculates ideal resolution to use from the source in order to achieve
  13147. * pixel mapping as close as possible to 1:1 during reprojection.
  13148. * The resolution is calculated regardless of what resolutions
  13149. * are actually available in the dataset (TileGrid, Image, ...).
  13150. *
  13151. * @param {import("./proj/Projection.js").default} sourceProj Source projection.
  13152. * @param {import("./proj/Projection.js").default} targetProj Target projection.
  13153. * @param {import("./coordinate.js").Coordinate} targetCenter Target center.
  13154. * @param {number} targetResolution Target resolution.
  13155. * @return {number} The best resolution to use. Can be +-Infinity, NaN or 0.
  13156. */
  13157. function calculateSourceResolution(sourceProj, targetProj, targetCenter, targetResolution) {
  13158. var sourceCenter = transform(targetCenter, targetProj, sourceProj);
  13159. // calculate the ideal resolution of the source data
  13160. var sourceResolution = getPointResolution(targetProj, targetResolution, targetCenter);
  13161. var targetMetersPerUnit = targetProj.getMetersPerUnit();
  13162. if (targetMetersPerUnit !== undefined) {
  13163. sourceResolution *= targetMetersPerUnit;
  13164. }
  13165. var sourceMetersPerUnit = sourceProj.getMetersPerUnit();
  13166. if (sourceMetersPerUnit !== undefined) {
  13167. sourceResolution /= sourceMetersPerUnit;
  13168. }
  13169. // Based on the projection properties, the point resolution at the specified
  13170. // coordinates may be slightly different. We need to reverse-compensate this
  13171. // in order to achieve optimal results.
  13172. var sourceExtent = sourceProj.getExtent();
  13173. if (!sourceExtent || containsCoordinate(sourceExtent, sourceCenter)) {
  13174. var compensationFactor = getPointResolution(sourceProj, sourceResolution, sourceCenter) /
  13175. sourceResolution;
  13176. if (isFinite(compensationFactor) && compensationFactor > 0) {
  13177. sourceResolution /= compensationFactor;
  13178. }
  13179. }
  13180. return sourceResolution;
  13181. }
  13182. /**
  13183. * Calculates ideal resolution to use from the source in order to achieve
  13184. * pixel mapping as close as possible to 1:1 during reprojection.
  13185. * The resolution is calculated regardless of what resolutions
  13186. * are actually available in the dataset (TileGrid, Image, ...).
  13187. *
  13188. * @param {import("./proj/Projection.js").default} sourceProj Source projection.
  13189. * @param {import("./proj/Projection.js").default} targetProj Target projection.
  13190. * @param {import("./extent.js").Extent} targetExtent Target extent
  13191. * @param {number} targetResolution Target resolution.
  13192. * @return {number} The best resolution to use. Can be +-Infinity, NaN or 0.
  13193. */
  13194. function calculateSourceExtentResolution(sourceProj, targetProj, targetExtent, targetResolution) {
  13195. var targetCenter = getCenter(targetExtent);
  13196. var sourceResolution = calculateSourceResolution(sourceProj, targetProj, targetCenter, targetResolution);
  13197. if (!isFinite(sourceResolution) || sourceResolution <= 0) {
  13198. forEachCorner(targetExtent, function (corner) {
  13199. sourceResolution = calculateSourceResolution(sourceProj, targetProj, corner, targetResolution);
  13200. return isFinite(sourceResolution) && sourceResolution > 0;
  13201. });
  13202. }
  13203. return sourceResolution;
  13204. }
  13205. /**
  13206. * @typedef {Object} ImageExtent
  13207. * @property {import("./extent.js").Extent} extent Extent.
  13208. * @property {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
  13209. */
  13210. /**
  13211. * Renders the source data into new canvas based on the triangulation.
  13212. *
  13213. * @param {number} width Width of the canvas.
  13214. * @param {number} height Height of the canvas.
  13215. * @param {number} pixelRatio Pixel ratio.
  13216. * @param {number} sourceResolution Source resolution.
  13217. * @param {import("./extent.js").Extent} sourceExtent Extent of the data source.
  13218. * @param {number} targetResolution Target resolution.
  13219. * @param {import("./extent.js").Extent} targetExtent Target extent.
  13220. * @param {import("./reproj/Triangulation.js").default} triangulation Calculated triangulation.
  13221. * @param {Array<ImageExtent>} sources Array of sources.
  13222. * @param {number} gutter Gutter of the sources.
  13223. * @param {boolean} [opt_renderEdges] Render reprojection edges.
  13224. * @param {boolean} [opt_interpolate] Use linear interpolation when resampling.
  13225. * @return {HTMLCanvasElement} Canvas with reprojected data.
  13226. */
  13227. function render(width, height, pixelRatio, sourceResolution, sourceExtent, targetResolution, targetExtent, triangulation, sources, gutter, opt_renderEdges, opt_interpolate) {
  13228. var context = createCanvasContext2D(Math.round(pixelRatio * width), Math.round(pixelRatio * height), reproj_canvasPool);
  13229. if (!opt_interpolate) {
  13230. obj_assign(context, IMAGE_SMOOTHING_DISABLED);
  13231. }
  13232. if (sources.length === 0) {
  13233. return context.canvas;
  13234. }
  13235. context.scale(pixelRatio, pixelRatio);
  13236. function pixelRound(value) {
  13237. return Math.round(value * pixelRatio) / pixelRatio;
  13238. }
  13239. context.globalCompositeOperation = 'lighter';
  13240. var sourceDataExtent = createEmpty();
  13241. sources.forEach(function (src, i, arr) {
  13242. extent_extend(sourceDataExtent, src.extent);
  13243. });
  13244. var canvasWidthInUnits = extent_getWidth(sourceDataExtent);
  13245. var canvasHeightInUnits = getHeight(sourceDataExtent);
  13246. var stitchContext = createCanvasContext2D(Math.round((pixelRatio * canvasWidthInUnits) / sourceResolution), Math.round((pixelRatio * canvasHeightInUnits) / sourceResolution));
  13247. if (!opt_interpolate) {
  13248. obj_assign(stitchContext, IMAGE_SMOOTHING_DISABLED);
  13249. }
  13250. var stitchScale = pixelRatio / sourceResolution;
  13251. sources.forEach(function (src, i, arr) {
  13252. var xPos = src.extent[0] - sourceDataExtent[0];
  13253. var yPos = -(src.extent[3] - sourceDataExtent[3]);
  13254. var srcWidth = extent_getWidth(src.extent);
  13255. var srcHeight = getHeight(src.extent);
  13256. // This test should never fail -- but it does. Need to find a fix the upstream condition
  13257. if (src.image.width > 0 && src.image.height > 0) {
  13258. stitchContext.drawImage(src.image, gutter, gutter, src.image.width - 2 * gutter, src.image.height - 2 * gutter, xPos * stitchScale, yPos * stitchScale, srcWidth * stitchScale, srcHeight * stitchScale);
  13259. }
  13260. });
  13261. var targetTopLeft = getTopLeft(targetExtent);
  13262. triangulation.getTriangles().forEach(function (triangle, i, arr) {
  13263. /* Calculate affine transform (src -> dst)
  13264. * Resulting matrix can be used to transform coordinate
  13265. * from `sourceProjection` to destination pixels.
  13266. *
  13267. * To optimize number of context calls and increase numerical stability,
  13268. * we also do the following operations:
  13269. * trans(-topLeftExtentCorner), scale(1 / targetResolution), scale(1, -1)
  13270. * here before solving the linear system so [ui, vi] are pixel coordinates.
  13271. *
  13272. * Src points: xi, yi
  13273. * Dst points: ui, vi
  13274. * Affine coefficients: aij
  13275. *
  13276. * | x0 y0 1 0 0 0 | |a00| |u0|
  13277. * | x1 y1 1 0 0 0 | |a01| |u1|
  13278. * | x2 y2 1 0 0 0 | x |a02| = |u2|
  13279. * | 0 0 0 x0 y0 1 | |a10| |v0|
  13280. * | 0 0 0 x1 y1 1 | |a11| |v1|
  13281. * | 0 0 0 x2 y2 1 | |a12| |v2|
  13282. */
  13283. var source = triangle.source;
  13284. var target = triangle.target;
  13285. var x0 = source[0][0], y0 = source[0][1];
  13286. var x1 = source[1][0], y1 = source[1][1];
  13287. var x2 = source[2][0], y2 = source[2][1];
  13288. // Make sure that everything is on pixel boundaries
  13289. var u0 = pixelRound((target[0][0] - targetTopLeft[0]) / targetResolution);
  13290. var v0 = pixelRound(-(target[0][1] - targetTopLeft[1]) / targetResolution);
  13291. var u1 = pixelRound((target[1][0] - targetTopLeft[0]) / targetResolution);
  13292. var v1 = pixelRound(-(target[1][1] - targetTopLeft[1]) / targetResolution);
  13293. var u2 = pixelRound((target[2][0] - targetTopLeft[0]) / targetResolution);
  13294. var v2 = pixelRound(-(target[2][1] - targetTopLeft[1]) / targetResolution);
  13295. // Shift all the source points to improve numerical stability
  13296. // of all the subsequent calculations. The [x0, y0] is used here.
  13297. // This is also used to simplify the linear system.
  13298. var sourceNumericalShiftX = x0;
  13299. var sourceNumericalShiftY = y0;
  13300. x0 = 0;
  13301. y0 = 0;
  13302. x1 -= sourceNumericalShiftX;
  13303. y1 -= sourceNumericalShiftY;
  13304. x2 -= sourceNumericalShiftX;
  13305. y2 -= sourceNumericalShiftY;
  13306. var augmentedMatrix = [
  13307. [x1, y1, 0, 0, u1 - u0],
  13308. [x2, y2, 0, 0, u2 - u0],
  13309. [0, 0, x1, y1, v1 - v0],
  13310. [0, 0, x2, y2, v2 - v0],
  13311. ];
  13312. var affineCoefs = solveLinearSystem(augmentedMatrix);
  13313. if (!affineCoefs) {
  13314. return;
  13315. }
  13316. context.save();
  13317. context.beginPath();
  13318. if (isBrokenDiagonalRendering() || !opt_interpolate) {
  13319. // Make sure that all lines are horizontal or vertical
  13320. context.moveTo(u1, v1);
  13321. // This is the diagonal line. Do it in 4 steps
  13322. var steps = 4;
  13323. var ud = u0 - u1;
  13324. var vd = v0 - v1;
  13325. for (var step = 0; step < steps; step++) {
  13326. // Go horizontally
  13327. context.lineTo(u1 + pixelRound(((step + 1) * ud) / steps), v1 + pixelRound((step * vd) / (steps - 1)));
  13328. // Go vertically
  13329. if (step != steps - 1) {
  13330. context.lineTo(u1 + pixelRound(((step + 1) * ud) / steps), v1 + pixelRound(((step + 1) * vd) / (steps - 1)));
  13331. }
  13332. }
  13333. // We are almost at u0r, v0r
  13334. context.lineTo(u2, v2);
  13335. }
  13336. else {
  13337. context.moveTo(u1, v1);
  13338. context.lineTo(u0, v0);
  13339. context.lineTo(u2, v2);
  13340. }
  13341. context.clip();
  13342. context.transform(affineCoefs[0], affineCoefs[2], affineCoefs[1], affineCoefs[3], u0, v0);
  13343. context.translate(sourceDataExtent[0] - sourceNumericalShiftX, sourceDataExtent[3] - sourceNumericalShiftY);
  13344. context.scale(sourceResolution / pixelRatio, -sourceResolution / pixelRatio);
  13345. context.drawImage(stitchContext.canvas, 0, 0);
  13346. context.restore();
  13347. });
  13348. if (opt_renderEdges) {
  13349. context.save();
  13350. context.globalCompositeOperation = 'source-over';
  13351. context.strokeStyle = 'black';
  13352. context.lineWidth = 1;
  13353. triangulation.getTriangles().forEach(function (triangle, i, arr) {
  13354. var target = triangle.target;
  13355. var u0 = (target[0][0] - targetTopLeft[0]) / targetResolution;
  13356. var v0 = -(target[0][1] - targetTopLeft[1]) / targetResolution;
  13357. var u1 = (target[1][0] - targetTopLeft[0]) / targetResolution;
  13358. var v1 = -(target[1][1] - targetTopLeft[1]) / targetResolution;
  13359. var u2 = (target[2][0] - targetTopLeft[0]) / targetResolution;
  13360. var v2 = -(target[2][1] - targetTopLeft[1]) / targetResolution;
  13361. context.beginPath();
  13362. context.moveTo(u1, v1);
  13363. context.lineTo(u0, v0);
  13364. context.lineTo(u2, v2);
  13365. context.closePath();
  13366. context.stroke();
  13367. });
  13368. context.restore();
  13369. }
  13370. return context.canvas;
  13371. }
  13372. //# sourceMappingURL=reproj.js.map
  13373. ;// ./node_modules/ol/reproj/Tile.js
  13374. var reproj_Tile_extends = (undefined && undefined.__extends) || (function () {
  13375. var extendStatics = function (d, b) {
  13376. extendStatics = Object.setPrototypeOf ||
  13377. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13378. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  13379. return extendStatics(d, b);
  13380. };
  13381. return function (d, b) {
  13382. if (typeof b !== "function" && b !== null)
  13383. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  13384. extendStatics(d, b);
  13385. function __() { this.constructor = d; }
  13386. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13387. };
  13388. })();
  13389. /**
  13390. * @module ol/reproj/Tile
  13391. */
  13392. /**
  13393. * @typedef {function(number, number, number, number) : import("../Tile.js").default} FunctionType
  13394. */
  13395. /**
  13396. * @classdesc
  13397. * Class encapsulating single reprojected tile.
  13398. * See {@link module:ol/source/TileImage~TileImage}.
  13399. *
  13400. */
  13401. var ReprojTile = /** @class */ (function (_super) {
  13402. reproj_Tile_extends(ReprojTile, _super);
  13403. /**
  13404. * @param {import("../proj/Projection.js").default} sourceProj Source projection.
  13405. * @param {import("../tilegrid/TileGrid.js").default} sourceTileGrid Source tile grid.
  13406. * @param {import("../proj/Projection.js").default} targetProj Target projection.
  13407. * @param {import("../tilegrid/TileGrid.js").default} targetTileGrid Target tile grid.
  13408. * @param {import("../tilecoord.js").TileCoord} tileCoord Coordinate of the tile.
  13409. * @param {import("../tilecoord.js").TileCoord} wrappedTileCoord Coordinate of the tile wrapped in X.
  13410. * @param {number} pixelRatio Pixel ratio.
  13411. * @param {number} gutter Gutter of the source tiles.
  13412. * @param {FunctionType} getTileFunction
  13413. * Function returning source tiles (z, x, y, pixelRatio).
  13414. * @param {number} [opt_errorThreshold] Acceptable reprojection error (in px).
  13415. * @param {boolean} [opt_renderEdges] Render reprojection edges.
  13416. * @param {boolean} [opt_interpolate] Use linear interpolation when resampling.
  13417. */
  13418. function ReprojTile(sourceProj, sourceTileGrid, targetProj, targetTileGrid, tileCoord, wrappedTileCoord, pixelRatio, gutter, getTileFunction, opt_errorThreshold, opt_renderEdges, opt_interpolate) {
  13419. var _this = _super.call(this, tileCoord, TileState.IDLE, { interpolate: !!opt_interpolate }) || this;
  13420. /**
  13421. * @private
  13422. * @type {boolean}
  13423. */
  13424. _this.renderEdges_ = opt_renderEdges !== undefined ? opt_renderEdges : false;
  13425. /**
  13426. * @private
  13427. * @type {number}
  13428. */
  13429. _this.pixelRatio_ = pixelRatio;
  13430. /**
  13431. * @private
  13432. * @type {number}
  13433. */
  13434. _this.gutter_ = gutter;
  13435. /**
  13436. * @private
  13437. * @type {HTMLCanvasElement}
  13438. */
  13439. _this.canvas_ = null;
  13440. /**
  13441. * @private
  13442. * @type {import("../tilegrid/TileGrid.js").default}
  13443. */
  13444. _this.sourceTileGrid_ = sourceTileGrid;
  13445. /**
  13446. * @private
  13447. * @type {import("../tilegrid/TileGrid.js").default}
  13448. */
  13449. _this.targetTileGrid_ = targetTileGrid;
  13450. /**
  13451. * @private
  13452. * @type {import("../tilecoord.js").TileCoord}
  13453. */
  13454. _this.wrappedTileCoord_ = wrappedTileCoord ? wrappedTileCoord : tileCoord;
  13455. /**
  13456. * @private
  13457. * @type {!Array<import("../Tile.js").default>}
  13458. */
  13459. _this.sourceTiles_ = [];
  13460. /**
  13461. * @private
  13462. * @type {?Array<import("../events.js").EventsKey>}
  13463. */
  13464. _this.sourcesListenerKeys_ = null;
  13465. /**
  13466. * @private
  13467. * @type {number}
  13468. */
  13469. _this.sourceZ_ = 0;
  13470. var targetExtent = targetTileGrid.getTileCoordExtent(_this.wrappedTileCoord_);
  13471. var maxTargetExtent = _this.targetTileGrid_.getExtent();
  13472. var maxSourceExtent = _this.sourceTileGrid_.getExtent();
  13473. var limitedTargetExtent = maxTargetExtent
  13474. ? getIntersection(targetExtent, maxTargetExtent)
  13475. : targetExtent;
  13476. if (getArea(limitedTargetExtent) === 0) {
  13477. // Tile is completely outside range -> EMPTY
  13478. // TODO: is it actually correct that the source even creates the tile ?
  13479. _this.state = TileState.EMPTY;
  13480. return _this;
  13481. }
  13482. var sourceProjExtent = sourceProj.getExtent();
  13483. if (sourceProjExtent) {
  13484. if (!maxSourceExtent) {
  13485. maxSourceExtent = sourceProjExtent;
  13486. }
  13487. else {
  13488. maxSourceExtent = getIntersection(maxSourceExtent, sourceProjExtent);
  13489. }
  13490. }
  13491. var targetResolution = targetTileGrid.getResolution(_this.wrappedTileCoord_[0]);
  13492. var sourceResolution = calculateSourceExtentResolution(sourceProj, targetProj, limitedTargetExtent, targetResolution);
  13493. if (!isFinite(sourceResolution) || sourceResolution <= 0) {
  13494. // invalid sourceResolution -> EMPTY
  13495. // probably edges of the projections when no extent is defined
  13496. _this.state = TileState.EMPTY;
  13497. return _this;
  13498. }
  13499. var errorThresholdInPixels = opt_errorThreshold !== undefined ? opt_errorThreshold : ERROR_THRESHOLD;
  13500. /**
  13501. * @private
  13502. * @type {!import("./Triangulation.js").default}
  13503. */
  13504. _this.triangulation_ = new reproj_Triangulation(sourceProj, targetProj, limitedTargetExtent, maxSourceExtent, sourceResolution * errorThresholdInPixels, targetResolution);
  13505. if (_this.triangulation_.getTriangles().length === 0) {
  13506. // no valid triangles -> EMPTY
  13507. _this.state = TileState.EMPTY;
  13508. return _this;
  13509. }
  13510. _this.sourceZ_ = sourceTileGrid.getZForResolution(sourceResolution);
  13511. var sourceExtent = _this.triangulation_.calculateSourceExtent();
  13512. if (maxSourceExtent) {
  13513. if (sourceProj.canWrapX()) {
  13514. sourceExtent[1] = math_clamp(sourceExtent[1], maxSourceExtent[1], maxSourceExtent[3]);
  13515. sourceExtent[3] = math_clamp(sourceExtent[3], maxSourceExtent[1], maxSourceExtent[3]);
  13516. }
  13517. else {
  13518. sourceExtent = getIntersection(sourceExtent, maxSourceExtent);
  13519. }
  13520. }
  13521. if (!getArea(sourceExtent)) {
  13522. _this.state = TileState.EMPTY;
  13523. }
  13524. else {
  13525. var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ(sourceExtent, _this.sourceZ_);
  13526. for (var srcX = sourceRange.minX; srcX <= sourceRange.maxX; srcX++) {
  13527. for (var srcY = sourceRange.minY; srcY <= sourceRange.maxY; srcY++) {
  13528. var tile = getTileFunction(_this.sourceZ_, srcX, srcY, pixelRatio);
  13529. if (tile) {
  13530. _this.sourceTiles_.push(tile);
  13531. }
  13532. }
  13533. }
  13534. if (_this.sourceTiles_.length === 0) {
  13535. _this.state = TileState.EMPTY;
  13536. }
  13537. }
  13538. return _this;
  13539. }
  13540. /**
  13541. * Get the HTML Canvas element for this tile.
  13542. * @return {HTMLCanvasElement} Canvas.
  13543. */
  13544. ReprojTile.prototype.getImage = function () {
  13545. return this.canvas_;
  13546. };
  13547. /**
  13548. * @private
  13549. */
  13550. ReprojTile.prototype.reproject_ = function () {
  13551. var sources = [];
  13552. this.sourceTiles_.forEach(function (tile, i, arr) {
  13553. if (tile && tile.getState() == TileState.LOADED) {
  13554. sources.push({
  13555. extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
  13556. image: tile.getImage(),
  13557. });
  13558. }
  13559. }.bind(this));
  13560. this.sourceTiles_.length = 0;
  13561. if (sources.length === 0) {
  13562. this.state = TileState.ERROR;
  13563. }
  13564. else {
  13565. var z = this.wrappedTileCoord_[0];
  13566. var size = this.targetTileGrid_.getTileSize(z);
  13567. var width = typeof size === 'number' ? size : size[0];
  13568. var height = typeof size === 'number' ? size : size[1];
  13569. var targetResolution = this.targetTileGrid_.getResolution(z);
  13570. var sourceResolution = this.sourceTileGrid_.getResolution(this.sourceZ_);
  13571. var targetExtent = this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);
  13572. this.canvas_ = render(width, height, this.pixelRatio_, sourceResolution, this.sourceTileGrid_.getExtent(), targetResolution, targetExtent, this.triangulation_, sources, this.gutter_, this.renderEdges_, this.interpolate);
  13573. this.state = TileState.LOADED;
  13574. }
  13575. this.changed();
  13576. };
  13577. /**
  13578. * Load not yet loaded URI.
  13579. */
  13580. ReprojTile.prototype.load = function () {
  13581. if (this.state == TileState.IDLE) {
  13582. this.state = TileState.LOADING;
  13583. this.changed();
  13584. var leftToLoad_1 = 0;
  13585. this.sourcesListenerKeys_ = [];
  13586. this.sourceTiles_.forEach(function (tile, i, arr) {
  13587. var state = tile.getState();
  13588. if (state == TileState.IDLE || state == TileState.LOADING) {
  13589. leftToLoad_1++;
  13590. var sourceListenKey_1 = listen(tile, EventType.CHANGE, function (e) {
  13591. var state = tile.getState();
  13592. if (state == TileState.LOADED ||
  13593. state == TileState.ERROR ||
  13594. state == TileState.EMPTY) {
  13595. unlistenByKey(sourceListenKey_1);
  13596. leftToLoad_1--;
  13597. if (leftToLoad_1 === 0) {
  13598. this.unlistenSources_();
  13599. this.reproject_();
  13600. }
  13601. }
  13602. }, this);
  13603. this.sourcesListenerKeys_.push(sourceListenKey_1);
  13604. }
  13605. }.bind(this));
  13606. if (leftToLoad_1 === 0) {
  13607. setTimeout(this.reproject_.bind(this), 0);
  13608. }
  13609. else {
  13610. this.sourceTiles_.forEach(function (tile, i, arr) {
  13611. var state = tile.getState();
  13612. if (state == TileState.IDLE) {
  13613. tile.load();
  13614. }
  13615. });
  13616. }
  13617. }
  13618. };
  13619. /**
  13620. * @private
  13621. */
  13622. ReprojTile.prototype.unlistenSources_ = function () {
  13623. this.sourcesListenerKeys_.forEach(unlistenByKey);
  13624. this.sourcesListenerKeys_ = null;
  13625. };
  13626. /**
  13627. * Remove from the cache due to expiry
  13628. */
  13629. ReprojTile.prototype.release = function () {
  13630. if (this.canvas_) {
  13631. releaseCanvas(this.canvas_.getContext('2d'));
  13632. reproj_canvasPool.push(this.canvas_);
  13633. this.canvas_ = null;
  13634. }
  13635. _super.prototype.release.call(this);
  13636. };
  13637. return ReprojTile;
  13638. }(ol_Tile));
  13639. /* harmony default export */ var reproj_Tile = (ReprojTile);
  13640. //# sourceMappingURL=Tile.js.map
  13641. ;// ./node_modules/ol/TileRange.js
  13642. /**
  13643. * @module ol/TileRange
  13644. */
  13645. /**
  13646. * A representation of a contiguous block of tiles. A tile range is specified
  13647. * by its min/max tile coordinates and is inclusive of coordinates.
  13648. */
  13649. var TileRange = /** @class */ (function () {
  13650. /**
  13651. * @param {number} minX Minimum X.
  13652. * @param {number} maxX Maximum X.
  13653. * @param {number} minY Minimum Y.
  13654. * @param {number} maxY Maximum Y.
  13655. */
  13656. function TileRange(minX, maxX, minY, maxY) {
  13657. /**
  13658. * @type {number}
  13659. */
  13660. this.minX = minX;
  13661. /**
  13662. * @type {number}
  13663. */
  13664. this.maxX = maxX;
  13665. /**
  13666. * @type {number}
  13667. */
  13668. this.minY = minY;
  13669. /**
  13670. * @type {number}
  13671. */
  13672. this.maxY = maxY;
  13673. }
  13674. /**
  13675. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
  13676. * @return {boolean} Contains tile coordinate.
  13677. */
  13678. TileRange.prototype.contains = function (tileCoord) {
  13679. return this.containsXY(tileCoord[1], tileCoord[2]);
  13680. };
  13681. /**
  13682. * @param {TileRange} tileRange Tile range.
  13683. * @return {boolean} Contains.
  13684. */
  13685. TileRange.prototype.containsTileRange = function (tileRange) {
  13686. return (this.minX <= tileRange.minX &&
  13687. tileRange.maxX <= this.maxX &&
  13688. this.minY <= tileRange.minY &&
  13689. tileRange.maxY <= this.maxY);
  13690. };
  13691. /**
  13692. * @param {number} x Tile coordinate x.
  13693. * @param {number} y Tile coordinate y.
  13694. * @return {boolean} Contains coordinate.
  13695. */
  13696. TileRange.prototype.containsXY = function (x, y) {
  13697. return this.minX <= x && x <= this.maxX && this.minY <= y && y <= this.maxY;
  13698. };
  13699. /**
  13700. * @param {TileRange} tileRange Tile range.
  13701. * @return {boolean} Equals.
  13702. */
  13703. TileRange.prototype.equals = function (tileRange) {
  13704. return (this.minX == tileRange.minX &&
  13705. this.minY == tileRange.minY &&
  13706. this.maxX == tileRange.maxX &&
  13707. this.maxY == tileRange.maxY);
  13708. };
  13709. /**
  13710. * @param {TileRange} tileRange Tile range.
  13711. */
  13712. TileRange.prototype.extend = function (tileRange) {
  13713. if (tileRange.minX < this.minX) {
  13714. this.minX = tileRange.minX;
  13715. }
  13716. if (tileRange.maxX > this.maxX) {
  13717. this.maxX = tileRange.maxX;
  13718. }
  13719. if (tileRange.minY < this.minY) {
  13720. this.minY = tileRange.minY;
  13721. }
  13722. if (tileRange.maxY > this.maxY) {
  13723. this.maxY = tileRange.maxY;
  13724. }
  13725. };
  13726. /**
  13727. * @return {number} Height.
  13728. */
  13729. TileRange.prototype.getHeight = function () {
  13730. return this.maxY - this.minY + 1;
  13731. };
  13732. /**
  13733. * @return {import("./size.js").Size} Size.
  13734. */
  13735. TileRange.prototype.getSize = function () {
  13736. return [this.getWidth(), this.getHeight()];
  13737. };
  13738. /**
  13739. * @return {number} Width.
  13740. */
  13741. TileRange.prototype.getWidth = function () {
  13742. return this.maxX - this.minX + 1;
  13743. };
  13744. /**
  13745. * @param {TileRange} tileRange Tile range.
  13746. * @return {boolean} Intersects.
  13747. */
  13748. TileRange.prototype.intersects = function (tileRange) {
  13749. return (this.minX <= tileRange.maxX &&
  13750. this.maxX >= tileRange.minX &&
  13751. this.minY <= tileRange.maxY &&
  13752. this.maxY >= tileRange.minY);
  13753. };
  13754. return TileRange;
  13755. }());
  13756. /**
  13757. * @param {number} minX Minimum X.
  13758. * @param {number} maxX Maximum X.
  13759. * @param {number} minY Minimum Y.
  13760. * @param {number} maxY Maximum Y.
  13761. * @param {TileRange} [tileRange] TileRange.
  13762. * @return {TileRange} Tile range.
  13763. */
  13764. function TileRange_createOrUpdate(minX, maxX, minY, maxY, tileRange) {
  13765. if (tileRange !== undefined) {
  13766. tileRange.minX = minX;
  13767. tileRange.maxX = maxX;
  13768. tileRange.minY = minY;
  13769. tileRange.maxY = maxY;
  13770. return tileRange;
  13771. }
  13772. else {
  13773. return new TileRange(minX, maxX, minY, maxY);
  13774. }
  13775. }
  13776. /* harmony default export */ var ol_TileRange = (TileRange);
  13777. //# sourceMappingURL=TileRange.js.map
  13778. ;// ./node_modules/ol/size.js
  13779. /**
  13780. * @module ol/size
  13781. */
  13782. /**
  13783. * An array of numbers representing a size: `[width, height]`.
  13784. * @typedef {Array<number>} Size
  13785. * @api
  13786. */
  13787. /**
  13788. * Returns a buffered size.
  13789. * @param {Size} size Size.
  13790. * @param {number} num The amount by which to buffer.
  13791. * @param {Size} [opt_size] Optional reusable size array.
  13792. * @return {Size} The buffered size.
  13793. */
  13794. function size_buffer(size, num, opt_size) {
  13795. if (opt_size === undefined) {
  13796. opt_size = [0, 0];
  13797. }
  13798. opt_size[0] = size[0] + 2 * num;
  13799. opt_size[1] = size[1] + 2 * num;
  13800. return opt_size;
  13801. }
  13802. /**
  13803. * Determines if a size has a positive area.
  13804. * @param {Size} size The size to test.
  13805. * @return {boolean} The size has a positive area.
  13806. */
  13807. function hasArea(size) {
  13808. return size[0] > 0 && size[1] > 0;
  13809. }
  13810. /**
  13811. * Returns a size scaled by a ratio. The result will be an array of integers.
  13812. * @param {Size} size Size.
  13813. * @param {number} ratio Ratio.
  13814. * @param {Size} [opt_size] Optional reusable size array.
  13815. * @return {Size} The scaled size.
  13816. */
  13817. function size_scale(size, ratio, opt_size) {
  13818. if (opt_size === undefined) {
  13819. opt_size = [0, 0];
  13820. }
  13821. opt_size[0] = (size[0] * ratio + 0.5) | 0;
  13822. opt_size[1] = (size[1] * ratio + 0.5) | 0;
  13823. return opt_size;
  13824. }
  13825. /**
  13826. * Returns an `Size` array for the passed in number (meaning: square) or
  13827. * `Size` array.
  13828. * (meaning: non-square),
  13829. * @param {number|Size} size Width and height.
  13830. * @param {Size} [opt_size] Optional reusable size array.
  13831. * @return {Size} Size.
  13832. * @api
  13833. */
  13834. function toSize(size, opt_size) {
  13835. if (Array.isArray(size)) {
  13836. return size;
  13837. }
  13838. else {
  13839. if (opt_size === undefined) {
  13840. opt_size = [size, size];
  13841. }
  13842. else {
  13843. opt_size[0] = size;
  13844. opt_size[1] = size;
  13845. }
  13846. return opt_size;
  13847. }
  13848. }
  13849. //# sourceMappingURL=size.js.map
  13850. ;// ./node_modules/ol/renderer/canvas/TileLayer.js
  13851. var TileLayer_extends = (undefined && undefined.__extends) || (function () {
  13852. var extendStatics = function (d, b) {
  13853. extendStatics = Object.setPrototypeOf ||
  13854. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13855. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  13856. return extendStatics(d, b);
  13857. };
  13858. return function (d, b) {
  13859. if (typeof b !== "function" && b !== null)
  13860. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  13861. extendStatics(d, b);
  13862. function __() { this.constructor = d; }
  13863. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13864. };
  13865. })();
  13866. /**
  13867. * @module ol/renderer/canvas/TileLayer
  13868. */
  13869. /**
  13870. * @classdesc
  13871. * Canvas renderer for tile layers.
  13872. * @api
  13873. * @template {import("../../layer/Tile.js").default<import("../../source/Tile.js").default>|import("../../layer/VectorTile.js").default} [LayerType=import("../../layer/Tile.js").default<import("../../source/Tile.js").default>|import("../../layer/VectorTile.js").default]
  13874. * @extends {CanvasLayerRenderer<LayerType>}
  13875. */
  13876. var CanvasTileLayerRenderer = /** @class */ (function (_super) {
  13877. TileLayer_extends(CanvasTileLayerRenderer, _super);
  13878. /**
  13879. * @param {LayerType} tileLayer Tile layer.
  13880. */
  13881. function CanvasTileLayerRenderer(tileLayer) {
  13882. var _this = _super.call(this, tileLayer) || this;
  13883. /**
  13884. * Rendered extent has changed since the previous `renderFrame()` call
  13885. * @type {boolean}
  13886. */
  13887. _this.extentChanged = true;
  13888. /**
  13889. * @private
  13890. * @type {?import("../../extent.js").Extent}
  13891. */
  13892. _this.renderedExtent_ = null;
  13893. /**
  13894. * @protected
  13895. * @type {number}
  13896. */
  13897. _this.renderedPixelRatio;
  13898. /**
  13899. * @protected
  13900. * @type {import("../../proj/Projection.js").default}
  13901. */
  13902. _this.renderedProjection = null;
  13903. /**
  13904. * @protected
  13905. * @type {number}
  13906. */
  13907. _this.renderedRevision;
  13908. /**
  13909. * @protected
  13910. * @type {!Array<import("../../Tile.js").default>}
  13911. */
  13912. _this.renderedTiles = [];
  13913. /**
  13914. * @private
  13915. * @type {boolean}
  13916. */
  13917. _this.newTiles_ = false;
  13918. /**
  13919. * @protected
  13920. * @type {import("../../extent.js").Extent}
  13921. */
  13922. _this.tmpExtent = createEmpty();
  13923. /**
  13924. * @private
  13925. * @type {import("../../TileRange.js").default}
  13926. */
  13927. _this.tmpTileRange_ = new ol_TileRange(0, 0, 0, 0);
  13928. return _this;
  13929. }
  13930. /**
  13931. * @protected
  13932. * @param {import("../../Tile.js").default} tile Tile.
  13933. * @return {boolean} Tile is drawable.
  13934. */
  13935. CanvasTileLayerRenderer.prototype.isDrawableTile = function (tile) {
  13936. var tileLayer = this.getLayer();
  13937. var tileState = tile.getState();
  13938. var useInterimTilesOnError = tileLayer.getUseInterimTilesOnError();
  13939. return (tileState == TileState.LOADED ||
  13940. tileState == TileState.EMPTY ||
  13941. (tileState == TileState.ERROR && !useInterimTilesOnError));
  13942. };
  13943. /**
  13944. * @param {number} z Tile coordinate z.
  13945. * @param {number} x Tile coordinate x.
  13946. * @param {number} y Tile coordinate y.
  13947. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  13948. * @return {!import("../../Tile.js").default} Tile.
  13949. */
  13950. CanvasTileLayerRenderer.prototype.getTile = function (z, x, y, frameState) {
  13951. var pixelRatio = frameState.pixelRatio;
  13952. var projection = frameState.viewState.projection;
  13953. var tileLayer = this.getLayer();
  13954. var tileSource = tileLayer.getSource();
  13955. var tile = tileSource.getTile(z, x, y, pixelRatio, projection);
  13956. if (tile.getState() == TileState.ERROR) {
  13957. if (!tileLayer.getUseInterimTilesOnError()) {
  13958. // When useInterimTilesOnError is false, we consider the error tile as loaded.
  13959. tile.setState(TileState.LOADED);
  13960. }
  13961. else if (tileLayer.getPreload() > 0) {
  13962. // Preloaded tiles for lower resolutions might have finished loading.
  13963. this.newTiles_ = true;
  13964. }
  13965. }
  13966. if (!this.isDrawableTile(tile)) {
  13967. tile = tile.getInterimTile();
  13968. }
  13969. return tile;
  13970. };
  13971. /**
  13972. * @param {import("../../pixel.js").Pixel} pixel Pixel.
  13973. * @return {Uint8ClampedArray} Data at the pixel location.
  13974. */
  13975. CanvasTileLayerRenderer.prototype.getData = function (pixel) {
  13976. var frameState = this.frameState;
  13977. if (!frameState) {
  13978. return null;
  13979. }
  13980. var layer = this.getLayer();
  13981. var coordinate = apply(frameState.pixelToCoordinateTransform, pixel.slice());
  13982. var layerExtent = layer.getExtent();
  13983. if (layerExtent) {
  13984. if (!containsCoordinate(layerExtent, coordinate)) {
  13985. return null;
  13986. }
  13987. }
  13988. var pixelRatio = frameState.pixelRatio;
  13989. var projection = frameState.viewState.projection;
  13990. var viewState = frameState.viewState;
  13991. var source = layer.getRenderSource();
  13992. var tileGrid = source.getTileGridForProjection(viewState.projection);
  13993. var tilePixelRatio = source.getTilePixelRatio(frameState.pixelRatio);
  13994. for (var z = tileGrid.getZForResolution(viewState.resolution); z >= tileGrid.getMinZoom(); --z) {
  13995. var tileCoord = tileGrid.getTileCoordForCoordAndZ(coordinate, z);
  13996. var tile = source.getTile(z, tileCoord[1], tileCoord[2], pixelRatio, projection);
  13997. if (!(tile instanceof ol_ImageTile || tile instanceof reproj_Tile)) {
  13998. return null;
  13999. }
  14000. if (tile.getState() !== TileState.LOADED) {
  14001. continue;
  14002. }
  14003. var tileOrigin = tileGrid.getOrigin(z);
  14004. var tileSize = toSize(tileGrid.getTileSize(z));
  14005. var tileResolution = tileGrid.getResolution(z);
  14006. var col = Math.floor(tilePixelRatio *
  14007. ((coordinate[0] - tileOrigin[0]) / tileResolution -
  14008. tileCoord[1] * tileSize[0]));
  14009. var row = Math.floor(tilePixelRatio *
  14010. ((tileOrigin[1] - coordinate[1]) / tileResolution -
  14011. tileCoord[2] * tileSize[1]));
  14012. var gutter = Math.round(tilePixelRatio * source.getGutterForProjection(viewState.projection));
  14013. return this.getImageData(tile.getImage(), col + gutter, row + gutter);
  14014. }
  14015. return null;
  14016. };
  14017. /**
  14018. * @param {Object<number, Object<string, import("../../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level.
  14019. * @param {number} zoom Zoom level.
  14020. * @param {import("../../Tile.js").default} tile Tile.
  14021. * @return {boolean|void} If `false`, the tile will not be considered loaded.
  14022. */
  14023. CanvasTileLayerRenderer.prototype.loadedTileCallback = function (tiles, zoom, tile) {
  14024. if (this.isDrawableTile(tile)) {
  14025. return _super.prototype.loadedTileCallback.call(this, tiles, zoom, tile);
  14026. }
  14027. return false;
  14028. };
  14029. /**
  14030. * Determine whether render should be called.
  14031. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  14032. * @return {boolean} Layer is ready to be rendered.
  14033. */
  14034. CanvasTileLayerRenderer.prototype.prepareFrame = function (frameState) {
  14035. return !!this.getLayer().getSource();
  14036. };
  14037. /**
  14038. * Render the layer.
  14039. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  14040. * @param {HTMLElement} target Target that may be used to render content to.
  14041. * @return {HTMLElement} The rendered element.
  14042. */
  14043. CanvasTileLayerRenderer.prototype.renderFrame = function (frameState, target) {
  14044. var layerState = frameState.layerStatesArray[frameState.layerIndex];
  14045. var viewState = frameState.viewState;
  14046. var projection = viewState.projection;
  14047. var viewResolution = viewState.resolution;
  14048. var viewCenter = viewState.center;
  14049. var rotation = viewState.rotation;
  14050. var pixelRatio = frameState.pixelRatio;
  14051. var tileLayer = this.getLayer();
  14052. var tileSource = tileLayer.getSource();
  14053. var sourceRevision = tileSource.getRevision();
  14054. var tileGrid = tileSource.getTileGridForProjection(projection);
  14055. var z = tileGrid.getZForResolution(viewResolution, tileSource.zDirection);
  14056. var tileResolution = tileGrid.getResolution(z);
  14057. var extent = frameState.extent;
  14058. var resolution = frameState.viewState.resolution;
  14059. var tilePixelRatio = tileSource.getTilePixelRatio(pixelRatio);
  14060. // desired dimensions of the canvas in pixels
  14061. var width = Math.round((extent_getWidth(extent) / resolution) * pixelRatio);
  14062. var height = Math.round((getHeight(extent) / resolution) * pixelRatio);
  14063. var layerExtent = layerState.extent && proj_fromUserExtent(layerState.extent, projection);
  14064. if (layerExtent) {
  14065. extent = getIntersection(extent, proj_fromUserExtent(layerState.extent, projection));
  14066. }
  14067. var dx = (tileResolution * width) / 2 / tilePixelRatio;
  14068. var dy = (tileResolution * height) / 2 / tilePixelRatio;
  14069. var canvasExtent = [
  14070. viewCenter[0] - dx,
  14071. viewCenter[1] - dy,
  14072. viewCenter[0] + dx,
  14073. viewCenter[1] + dy,
  14074. ];
  14075. var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
  14076. /**
  14077. * @type {Object<number, Object<string, import("../../Tile.js").default>>}
  14078. */
  14079. var tilesToDrawByZ = {};
  14080. tilesToDrawByZ[z] = {};
  14081. var findLoadedTiles = this.createLoadedTileFinder(tileSource, projection, tilesToDrawByZ);
  14082. var tmpExtent = this.tmpExtent;
  14083. var tmpTileRange = this.tmpTileRange_;
  14084. this.newTiles_ = false;
  14085. var viewport = rotation
  14086. ? getRotatedViewport(viewState.center, resolution, rotation, frameState.size)
  14087. : undefined;
  14088. for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
  14089. for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
  14090. if (rotation &&
  14091. !tileGrid.tileCoordIntersectsViewport([z, x, y], viewport)) {
  14092. continue;
  14093. }
  14094. var tile = this.getTile(z, x, y, frameState);
  14095. if (this.isDrawableTile(tile)) {
  14096. var uid = getUid(this);
  14097. if (tile.getState() == TileState.LOADED) {
  14098. tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
  14099. var inTransition = tile.inTransition(uid);
  14100. if (inTransition && layerState.opacity !== 1) {
  14101. // Skipping transition when layer is not fully opaque avoids visual artifacts.
  14102. tile.endTransition(uid);
  14103. inTransition = false;
  14104. }
  14105. if (!this.newTiles_ &&
  14106. (inTransition || this.renderedTiles.indexOf(tile) === -1)) {
  14107. this.newTiles_ = true;
  14108. }
  14109. }
  14110. if (tile.getAlpha(uid, frameState.time) === 1) {
  14111. // don't look for alt tiles if alpha is 1
  14112. continue;
  14113. }
  14114. }
  14115. var childTileRange = tileGrid.getTileCoordChildTileRange(tile.tileCoord, tmpTileRange, tmpExtent);
  14116. var covered = false;
  14117. if (childTileRange) {
  14118. covered = findLoadedTiles(z + 1, childTileRange);
  14119. }
  14120. if (!covered) {
  14121. tileGrid.forEachTileCoordParentTileRange(tile.tileCoord, findLoadedTiles, tmpTileRange, tmpExtent);
  14122. }
  14123. }
  14124. }
  14125. var canvasScale = ((tileResolution / viewResolution) * pixelRatio) / tilePixelRatio;
  14126. // set forward and inverse pixel transforms
  14127. compose(this.pixelTransform, frameState.size[0] / 2, frameState.size[1] / 2, 1 / pixelRatio, 1 / pixelRatio, rotation, -width / 2, -height / 2);
  14128. var canvasTransform = transform_toString(this.pixelTransform);
  14129. this.useContainer(target, canvasTransform, this.getBackground(frameState));
  14130. var context = this.context;
  14131. var canvas = context.canvas;
  14132. makeInverse(this.inversePixelTransform, this.pixelTransform);
  14133. // set scale transform for calculating tile positions on the canvas
  14134. compose(this.tempTransform, width / 2, height / 2, canvasScale, canvasScale, 0, -width / 2, -height / 2);
  14135. if (canvas.width != width || canvas.height != height) {
  14136. canvas.width = width;
  14137. canvas.height = height;
  14138. }
  14139. else if (!this.containerReused) {
  14140. context.clearRect(0, 0, width, height);
  14141. }
  14142. if (layerExtent) {
  14143. this.clipUnrotated(context, frameState, layerExtent);
  14144. }
  14145. if (!tileSource.getInterpolate()) {
  14146. obj_assign(context, IMAGE_SMOOTHING_DISABLED);
  14147. }
  14148. this.preRender(context, frameState);
  14149. this.renderedTiles.length = 0;
  14150. /** @type {Array<number>} */
  14151. var zs = Object.keys(tilesToDrawByZ).map(Number);
  14152. zs.sort(numberSafeCompareFunction);
  14153. var clips, clipZs, currentClip;
  14154. if (layerState.opacity === 1 &&
  14155. (!this.containerReused ||
  14156. tileSource.getOpaque(frameState.viewState.projection))) {
  14157. zs = zs.reverse();
  14158. }
  14159. else {
  14160. clips = [];
  14161. clipZs = [];
  14162. }
  14163. for (var i = zs.length - 1; i >= 0; --i) {
  14164. var currentZ = zs[i];
  14165. var currentTilePixelSize = tileSource.getTilePixelSize(currentZ, pixelRatio, projection);
  14166. var currentResolution = tileGrid.getResolution(currentZ);
  14167. var currentScale = currentResolution / tileResolution;
  14168. var dx_1 = currentTilePixelSize[0] * currentScale * canvasScale;
  14169. var dy_1 = currentTilePixelSize[1] * currentScale * canvasScale;
  14170. var originTileCoord = tileGrid.getTileCoordForCoordAndZ(getTopLeft(canvasExtent), currentZ);
  14171. var originTileExtent = tileGrid.getTileCoordExtent(originTileCoord);
  14172. var origin_1 = apply(this.tempTransform, [
  14173. (tilePixelRatio * (originTileExtent[0] - canvasExtent[0])) /
  14174. tileResolution,
  14175. (tilePixelRatio * (canvasExtent[3] - originTileExtent[3])) /
  14176. tileResolution,
  14177. ]);
  14178. var tileGutter = tilePixelRatio * tileSource.getGutterForProjection(projection);
  14179. var tilesToDraw = tilesToDrawByZ[currentZ];
  14180. for (var tileCoordKey in tilesToDraw) {
  14181. var tile = /** @type {import("../../ImageTile.js").default} */ (tilesToDraw[tileCoordKey]);
  14182. var tileCoord = tile.tileCoord;
  14183. // Calculate integer positions and sizes so that tiles align
  14184. var xIndex = originTileCoord[1] - tileCoord[1];
  14185. var nextX = Math.round(origin_1[0] - (xIndex - 1) * dx_1);
  14186. var yIndex = originTileCoord[2] - tileCoord[2];
  14187. var nextY = Math.round(origin_1[1] - (yIndex - 1) * dy_1);
  14188. var x = Math.round(origin_1[0] - xIndex * dx_1);
  14189. var y = Math.round(origin_1[1] - yIndex * dy_1);
  14190. var w = nextX - x;
  14191. var h = nextY - y;
  14192. var transition = z === currentZ;
  14193. var inTransition = transition && tile.getAlpha(getUid(this), frameState.time) !== 1;
  14194. var contextSaved = false;
  14195. if (!inTransition) {
  14196. if (clips) {
  14197. // Clip mask for regions in this tile that already filled by a higher z tile
  14198. currentClip = [x, y, x + w, y, x + w, y + h, x, y + h];
  14199. for (var i_1 = 0, ii = clips.length; i_1 < ii; ++i_1) {
  14200. if (z !== currentZ && currentZ < clipZs[i_1]) {
  14201. var clip = clips[i_1];
  14202. if (intersects([x, y, x + w, y + h], [clip[0], clip[3], clip[4], clip[7]])) {
  14203. if (!contextSaved) {
  14204. context.save();
  14205. contextSaved = true;
  14206. }
  14207. context.beginPath();
  14208. // counter-clockwise (outer ring) for current tile
  14209. context.moveTo(currentClip[0], currentClip[1]);
  14210. context.lineTo(currentClip[2], currentClip[3]);
  14211. context.lineTo(currentClip[4], currentClip[5]);
  14212. context.lineTo(currentClip[6], currentClip[7]);
  14213. // clockwise (inner ring) for higher z tile
  14214. context.moveTo(clip[6], clip[7]);
  14215. context.lineTo(clip[4], clip[5]);
  14216. context.lineTo(clip[2], clip[3]);
  14217. context.lineTo(clip[0], clip[1]);
  14218. context.clip();
  14219. }
  14220. }
  14221. }
  14222. clips.push(currentClip);
  14223. clipZs.push(currentZ);
  14224. }
  14225. else {
  14226. context.clearRect(x, y, w, h);
  14227. }
  14228. }
  14229. this.drawTileImage(tile, frameState, x, y, w, h, tileGutter, transition);
  14230. if (clips && !inTransition) {
  14231. if (contextSaved) {
  14232. context.restore();
  14233. }
  14234. this.renderedTiles.unshift(tile);
  14235. }
  14236. else {
  14237. this.renderedTiles.push(tile);
  14238. }
  14239. this.updateUsedTiles(frameState.usedTiles, tileSource, tile);
  14240. }
  14241. }
  14242. this.renderedRevision = sourceRevision;
  14243. this.renderedResolution = tileResolution;
  14244. this.extentChanged =
  14245. !this.renderedExtent_ || !extent_equals(this.renderedExtent_, canvasExtent);
  14246. this.renderedExtent_ = canvasExtent;
  14247. this.renderedPixelRatio = pixelRatio;
  14248. this.renderedProjection = projection;
  14249. this.manageTilePyramid(frameState, tileSource, tileGrid, pixelRatio, projection, extent, z, tileLayer.getPreload());
  14250. this.scheduleExpireCache(frameState, tileSource);
  14251. this.postRender(context, frameState);
  14252. if (layerState.extent) {
  14253. context.restore();
  14254. }
  14255. obj_assign(context, IMAGE_SMOOTHING_ENABLED);
  14256. if (canvasTransform !== canvas.style.transform) {
  14257. canvas.style.transform = canvasTransform;
  14258. }
  14259. return this.container;
  14260. };
  14261. /**
  14262. * @param {import("../../ImageTile.js").default} tile Tile.
  14263. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  14264. * @param {number} x Left of the tile.
  14265. * @param {number} y Top of the tile.
  14266. * @param {number} w Width of the tile.
  14267. * @param {number} h Height of the tile.
  14268. * @param {number} gutter Tile gutter.
  14269. * @param {boolean} transition Apply an alpha transition.
  14270. */
  14271. CanvasTileLayerRenderer.prototype.drawTileImage = function (tile, frameState, x, y, w, h, gutter, transition) {
  14272. var image = this.getTileImage(tile);
  14273. if (!image) {
  14274. return;
  14275. }
  14276. var uid = getUid(this);
  14277. var layerState = frameState.layerStatesArray[frameState.layerIndex];
  14278. var alpha = layerState.opacity *
  14279. (transition ? tile.getAlpha(uid, frameState.time) : 1);
  14280. var alphaChanged = alpha !== this.context.globalAlpha;
  14281. if (alphaChanged) {
  14282. this.context.save();
  14283. this.context.globalAlpha = alpha;
  14284. }
  14285. this.context.drawImage(image, gutter, gutter, image.width - 2 * gutter, image.height - 2 * gutter, x, y, w, h);
  14286. if (alphaChanged) {
  14287. this.context.restore();
  14288. }
  14289. if (alpha !== layerState.opacity) {
  14290. frameState.animate = true;
  14291. }
  14292. else if (transition) {
  14293. tile.endTransition(uid);
  14294. }
  14295. };
  14296. /**
  14297. * @return {HTMLCanvasElement} Image
  14298. */
  14299. CanvasTileLayerRenderer.prototype.getImage = function () {
  14300. var context = this.context;
  14301. return context ? context.canvas : null;
  14302. };
  14303. /**
  14304. * Get the image from a tile.
  14305. * @param {import("../../ImageTile.js").default} tile Tile.
  14306. * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
  14307. * @protected
  14308. */
  14309. CanvasTileLayerRenderer.prototype.getTileImage = function (tile) {
  14310. return tile.getImage();
  14311. };
  14312. /**
  14313. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  14314. * @param {import("../../source/Tile.js").default} tileSource Tile source.
  14315. * @protected
  14316. */
  14317. CanvasTileLayerRenderer.prototype.scheduleExpireCache = function (frameState, tileSource) {
  14318. if (tileSource.canExpireCache()) {
  14319. /**
  14320. * @param {import("../../source/Tile.js").default} tileSource Tile source.
  14321. * @param {import("../../PluggableMap.js").default} map Map.
  14322. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  14323. */
  14324. var postRenderFunction = function (tileSource, map, frameState) {
  14325. var tileSourceKey = getUid(tileSource);
  14326. if (tileSourceKey in frameState.usedTiles) {
  14327. tileSource.expireCache(frameState.viewState.projection, frameState.usedTiles[tileSourceKey]);
  14328. }
  14329. }.bind(null, tileSource);
  14330. frameState.postRenderFunctions.push(
  14331. /** @type {import("../../PluggableMap.js").PostRenderFunction} */ (postRenderFunction));
  14332. }
  14333. };
  14334. /**
  14335. * @param {!Object<string, !Object<string, boolean>>} usedTiles Used tiles.
  14336. * @param {import("../../source/Tile.js").default} tileSource Tile source.
  14337. * @param {import('../../Tile.js').default} tile Tile.
  14338. * @protected
  14339. */
  14340. CanvasTileLayerRenderer.prototype.updateUsedTiles = function (usedTiles, tileSource, tile) {
  14341. // FIXME should we use tilesToDrawByZ instead?
  14342. var tileSourceKey = getUid(tileSource);
  14343. if (!(tileSourceKey in usedTiles)) {
  14344. usedTiles[tileSourceKey] = {};
  14345. }
  14346. usedTiles[tileSourceKey][tile.getKey()] = true;
  14347. };
  14348. /**
  14349. * Manage tile pyramid.
  14350. * This function performs a number of functions related to the tiles at the
  14351. * current zoom and lower zoom levels:
  14352. * - registers idle tiles in frameState.wantedTiles so that they are not
  14353. * discarded by the tile queue
  14354. * - enqueues missing tiles
  14355. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  14356. * @param {import("../../source/Tile.js").default} tileSource Tile source.
  14357. * @param {import("../../tilegrid/TileGrid.js").default} tileGrid Tile grid.
  14358. * @param {number} pixelRatio Pixel ratio.
  14359. * @param {import("../../proj/Projection.js").default} projection Projection.
  14360. * @param {import("../../extent.js").Extent} extent Extent.
  14361. * @param {number} currentZ Current Z.
  14362. * @param {number} preload Load low resolution tiles up to `preload` levels.
  14363. * @param {function(import("../../Tile.js").default):void} [opt_tileCallback] Tile callback.
  14364. * @protected
  14365. */
  14366. CanvasTileLayerRenderer.prototype.manageTilePyramid = function (frameState, tileSource, tileGrid, pixelRatio, projection, extent, currentZ, preload, opt_tileCallback) {
  14367. var tileSourceKey = getUid(tileSource);
  14368. if (!(tileSourceKey in frameState.wantedTiles)) {
  14369. frameState.wantedTiles[tileSourceKey] = {};
  14370. }
  14371. var wantedTiles = frameState.wantedTiles[tileSourceKey];
  14372. var tileQueue = frameState.tileQueue;
  14373. var minZoom = tileGrid.getMinZoom();
  14374. var rotation = frameState.viewState.rotation;
  14375. var viewport = rotation
  14376. ? getRotatedViewport(frameState.viewState.center, frameState.viewState.resolution, rotation, frameState.size)
  14377. : undefined;
  14378. var tileCount = 0;
  14379. var tile, tileRange, tileResolution, x, y, z;
  14380. for (z = minZoom; z <= currentZ; ++z) {
  14381. tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z, tileRange);
  14382. tileResolution = tileGrid.getResolution(z);
  14383. for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
  14384. for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
  14385. if (rotation &&
  14386. !tileGrid.tileCoordIntersectsViewport([z, x, y], viewport)) {
  14387. continue;
  14388. }
  14389. if (currentZ - z <= preload) {
  14390. ++tileCount;
  14391. tile = tileSource.getTile(z, x, y, pixelRatio, projection);
  14392. if (tile.getState() == TileState.IDLE) {
  14393. wantedTiles[tile.getKey()] = true;
  14394. if (!tileQueue.isKeyQueued(tile.getKey())) {
  14395. tileQueue.enqueue([
  14396. tile,
  14397. tileSourceKey,
  14398. tileGrid.getTileCoordCenter(tile.tileCoord),
  14399. tileResolution,
  14400. ]);
  14401. }
  14402. }
  14403. if (opt_tileCallback !== undefined) {
  14404. opt_tileCallback(tile);
  14405. }
  14406. }
  14407. else {
  14408. tileSource.useTile(z, x, y, projection);
  14409. }
  14410. }
  14411. }
  14412. }
  14413. tileSource.updateCacheSize(tileCount, projection);
  14414. };
  14415. return CanvasTileLayerRenderer;
  14416. }(canvas_Layer));
  14417. /* harmony default export */ var canvas_TileLayer = (CanvasTileLayerRenderer);
  14418. //# sourceMappingURL=TileLayer.js.map
  14419. ;// ./node_modules/ol/layer/Tile.js
  14420. var layer_Tile_extends = (undefined && undefined.__extends) || (function () {
  14421. var extendStatics = function (d, b) {
  14422. extendStatics = Object.setPrototypeOf ||
  14423. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14424. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  14425. return extendStatics(d, b);
  14426. };
  14427. return function (d, b) {
  14428. if (typeof b !== "function" && b !== null)
  14429. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  14430. extendStatics(d, b);
  14431. function __() { this.constructor = d; }
  14432. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14433. };
  14434. })();
  14435. /**
  14436. * @module ol/layer/Tile
  14437. */
  14438. /**
  14439. * @classdesc
  14440. * For layer sources that provide pre-rendered, tiled images in grids that are
  14441. * organized by zoom levels for specific resolutions.
  14442. * Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
  14443. * property on the layer object; for example, setting `title: 'My Title'` in the
  14444. * options means that `title` is observable, and has get/set accessors.
  14445. *
  14446. * @template {import("../source/Tile.js").default} TileSourceType
  14447. * @extends BaseTileLayer<TileSourceType, CanvasTileLayerRenderer>
  14448. * @api
  14449. */
  14450. var TileLayer = /** @class */ (function (_super) {
  14451. layer_Tile_extends(TileLayer, _super);
  14452. /**
  14453. * @param {import("./BaseTile.js").Options<TileSourceType>} [opt_options] Tile layer options.
  14454. */
  14455. function TileLayer(opt_options) {
  14456. return _super.call(this, opt_options) || this;
  14457. }
  14458. TileLayer.prototype.createRenderer = function () {
  14459. return new canvas_TileLayer(this);
  14460. };
  14461. return TileLayer;
  14462. }(BaseTile));
  14463. /* harmony default export */ var layer_Tile = (TileLayer);
  14464. //# sourceMappingURL=Tile.js.map
  14465. // EXTERNAL MODULE: ./node_modules/rbush/rbush.min.js
  14466. var rbush_min = __webpack_require__(341);
  14467. ;// ./node_modules/ol/style/Image.js
  14468. /**
  14469. * @module ol/style/Image
  14470. */
  14471. /**
  14472. * @typedef {Object} Options
  14473. * @property {number} opacity Opacity.
  14474. * @property {boolean} rotateWithView If the image should get rotated with the view.
  14475. * @property {number} rotation Rotation.
  14476. * @property {number|import("../size.js").Size} scale Scale.
  14477. * @property {Array<number>} displacement Displacement.
  14478. * @property {"declutter"|"obstacle"|"none"|undefined} declutterMode Declutter mode: `declutter`, `obstacle`, 'none */
  14479. /**
  14480. * @classdesc
  14481. * A base class used for creating subclasses and not instantiated in
  14482. * apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and
  14483. * {@link module:ol/style/RegularShape~RegularShape}.
  14484. * @abstract
  14485. * @api
  14486. */
  14487. var ImageStyle = /** @class */ (function () {
  14488. /**
  14489. * @param {Options} options Options.
  14490. */
  14491. function ImageStyle(options) {
  14492. /**
  14493. * @private
  14494. * @type {number}
  14495. */
  14496. this.opacity_ = options.opacity;
  14497. /**
  14498. * @private
  14499. * @type {boolean}
  14500. */
  14501. this.rotateWithView_ = options.rotateWithView;
  14502. /**
  14503. * @private
  14504. * @type {number}
  14505. */
  14506. this.rotation_ = options.rotation;
  14507. /**
  14508. * @private
  14509. * @type {number|import("../size.js").Size}
  14510. */
  14511. this.scale_ = options.scale;
  14512. /**
  14513. * @private
  14514. * @type {import("../size.js").Size}
  14515. */
  14516. this.scaleArray_ = toSize(options.scale);
  14517. /**
  14518. * @private
  14519. * @type {Array<number>}
  14520. */
  14521. this.displacement_ = options.displacement;
  14522. /**
  14523. * @private
  14524. * @type {"declutter"|"obstacle"|"none"|undefined}
  14525. */
  14526. this.declutterMode_ = options.declutterMode;
  14527. }
  14528. /**
  14529. * Clones the style.
  14530. * @return {ImageStyle} The cloned style.
  14531. * @api
  14532. */
  14533. ImageStyle.prototype.clone = function () {
  14534. var scale = this.getScale();
  14535. return new ImageStyle({
  14536. opacity: this.getOpacity(),
  14537. scale: Array.isArray(scale) ? scale.slice() : scale,
  14538. rotation: this.getRotation(),
  14539. rotateWithView: this.getRotateWithView(),
  14540. displacement: this.getDisplacement().slice(),
  14541. declutterMode: this.getDeclutterMode(),
  14542. });
  14543. };
  14544. /**
  14545. * Get the symbolizer opacity.
  14546. * @return {number} Opacity.
  14547. * @api
  14548. */
  14549. ImageStyle.prototype.getOpacity = function () {
  14550. return this.opacity_;
  14551. };
  14552. /**
  14553. * Determine whether the symbolizer rotates with the map.
  14554. * @return {boolean} Rotate with map.
  14555. * @api
  14556. */
  14557. ImageStyle.prototype.getRotateWithView = function () {
  14558. return this.rotateWithView_;
  14559. };
  14560. /**
  14561. * Get the symoblizer rotation.
  14562. * @return {number} Rotation.
  14563. * @api
  14564. */
  14565. ImageStyle.prototype.getRotation = function () {
  14566. return this.rotation_;
  14567. };
  14568. /**
  14569. * Get the symbolizer scale.
  14570. * @return {number|import("../size.js").Size} Scale.
  14571. * @api
  14572. */
  14573. ImageStyle.prototype.getScale = function () {
  14574. return this.scale_;
  14575. };
  14576. /**
  14577. * Get the symbolizer scale array.
  14578. * @return {import("../size.js").Size} Scale array.
  14579. */
  14580. ImageStyle.prototype.getScaleArray = function () {
  14581. return this.scaleArray_;
  14582. };
  14583. /**
  14584. * Get the displacement of the shape
  14585. * @return {Array<number>} Shape's center displacement
  14586. * @api
  14587. */
  14588. ImageStyle.prototype.getDisplacement = function () {
  14589. return this.displacement_;
  14590. };
  14591. /**
  14592. * Get the declutter mode of the shape
  14593. * @return {"declutter"|"obstacle"|"none"|undefined} Shape's declutter mode
  14594. * @api
  14595. */
  14596. ImageStyle.prototype.getDeclutterMode = function () {
  14597. return this.declutterMode_;
  14598. };
  14599. /**
  14600. * Get the anchor point in pixels. The anchor determines the center point for the
  14601. * symbolizer.
  14602. * @abstract
  14603. * @return {Array<number>} Anchor.
  14604. */
  14605. ImageStyle.prototype.getAnchor = function () {
  14606. return util_abstract();
  14607. };
  14608. /**
  14609. * Get the image element for the symbolizer.
  14610. * @abstract
  14611. * @param {number} pixelRatio Pixel ratio.
  14612. * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
  14613. */
  14614. ImageStyle.prototype.getImage = function (pixelRatio) {
  14615. return util_abstract();
  14616. };
  14617. /**
  14618. * @abstract
  14619. * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
  14620. */
  14621. ImageStyle.prototype.getHitDetectionImage = function () {
  14622. return util_abstract();
  14623. };
  14624. /**
  14625. * Get the image pixel ratio.
  14626. * @param {number} pixelRatio Pixel ratio.
  14627. * @return {number} Pixel ratio.
  14628. */
  14629. ImageStyle.prototype.getPixelRatio = function (pixelRatio) {
  14630. return 1;
  14631. };
  14632. /**
  14633. * @abstract
  14634. * @return {import("../ImageState.js").default} Image state.
  14635. */
  14636. ImageStyle.prototype.getImageState = function () {
  14637. return util_abstract();
  14638. };
  14639. /**
  14640. * @abstract
  14641. * @return {import("../size.js").Size} Image size.
  14642. */
  14643. ImageStyle.prototype.getImageSize = function () {
  14644. return util_abstract();
  14645. };
  14646. /**
  14647. * Get the origin of the symbolizer.
  14648. * @abstract
  14649. * @return {Array<number>} Origin.
  14650. */
  14651. ImageStyle.prototype.getOrigin = function () {
  14652. return util_abstract();
  14653. };
  14654. /**
  14655. * Get the size of the symbolizer (in pixels).
  14656. * @abstract
  14657. * @return {import("../size.js").Size} Size.
  14658. */
  14659. ImageStyle.prototype.getSize = function () {
  14660. return util_abstract();
  14661. };
  14662. /**
  14663. * Set the displacement.
  14664. *
  14665. * @param {Array<number>} displacement Displacement.
  14666. * @api
  14667. */
  14668. ImageStyle.prototype.setDisplacement = function (displacement) {
  14669. this.displacement_ = displacement;
  14670. };
  14671. /**
  14672. * Set the opacity.
  14673. *
  14674. * @param {number} opacity Opacity.
  14675. * @api
  14676. */
  14677. ImageStyle.prototype.setOpacity = function (opacity) {
  14678. this.opacity_ = opacity;
  14679. };
  14680. /**
  14681. * Set whether to rotate the style with the view.
  14682. *
  14683. * @param {boolean} rotateWithView Rotate with map.
  14684. * @api
  14685. */
  14686. ImageStyle.prototype.setRotateWithView = function (rotateWithView) {
  14687. this.rotateWithView_ = rotateWithView;
  14688. };
  14689. /**
  14690. * Set the rotation.
  14691. *
  14692. * @param {number} rotation Rotation.
  14693. * @api
  14694. */
  14695. ImageStyle.prototype.setRotation = function (rotation) {
  14696. this.rotation_ = rotation;
  14697. };
  14698. /**
  14699. * Set the scale.
  14700. *
  14701. * @param {number|import("../size.js").Size} scale Scale.
  14702. * @api
  14703. */
  14704. ImageStyle.prototype.setScale = function (scale) {
  14705. this.scale_ = scale;
  14706. this.scaleArray_ = toSize(scale);
  14707. };
  14708. /**
  14709. * @abstract
  14710. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  14711. */
  14712. ImageStyle.prototype.listenImageChange = function (listener) {
  14713. util_abstract();
  14714. };
  14715. /**
  14716. * Load not yet loaded URI.
  14717. * @abstract
  14718. */
  14719. ImageStyle.prototype.load = function () {
  14720. util_abstract();
  14721. };
  14722. /**
  14723. * @abstract
  14724. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  14725. */
  14726. ImageStyle.prototype.unlistenImageChange = function (listener) {
  14727. util_abstract();
  14728. };
  14729. return ImageStyle;
  14730. }());
  14731. /* harmony default export */ var style_Image = (ImageStyle);
  14732. //# sourceMappingURL=Image.js.map
  14733. ;// ./node_modules/ol/colorlike.js
  14734. /**
  14735. * @module ol/colorlike
  14736. */
  14737. /**
  14738. * A type accepted by CanvasRenderingContext2D.fillStyle
  14739. * or CanvasRenderingContext2D.strokeStyle.
  14740. * Represents a color, pattern, or gradient. The origin for patterns and
  14741. * gradients as fill style is an increment of 512 css pixels from map coordinate
  14742. * `[0, 0]`. For seamless repeat patterns, width and height of the pattern image
  14743. * must be a factor of two (2, 4, 8, ..., 512).
  14744. *
  14745. * @typedef {string|CanvasPattern|CanvasGradient} ColorLike
  14746. * @api
  14747. */
  14748. /**
  14749. * @param {import("./color.js").Color|ColorLike} color Color.
  14750. * @return {ColorLike} The color as an {@link ol/colorlike~ColorLike}.
  14751. * @api
  14752. */
  14753. function asColorLike(color) {
  14754. if (Array.isArray(color)) {
  14755. return color_toString(color);
  14756. }
  14757. else {
  14758. return color;
  14759. }
  14760. }
  14761. //# sourceMappingURL=colorlike.js.map
  14762. ;// ./node_modules/ol/render/canvas.js
  14763. /**
  14764. * @module ol/render/canvas
  14765. */
  14766. /**
  14767. * @typedef {'Circle' | 'Image' | 'LineString' | 'Polygon' | 'Text' | 'Default'} BuilderType
  14768. */
  14769. /**
  14770. * @typedef {Object} FillState
  14771. * @property {import("../colorlike.js").ColorLike} fillStyle FillStyle.
  14772. */
  14773. /**
  14774. * @typedef Label
  14775. * @property {number} width Width.
  14776. * @property {number} height Height.
  14777. * @property {Array<string|number>} contextInstructions ContextInstructions.
  14778. */
  14779. /**
  14780. * @typedef {Object} FillStrokeState
  14781. * @property {import("../colorlike.js").ColorLike} [currentFillStyle] Current FillStyle.
  14782. * @property {import("../colorlike.js").ColorLike} [currentStrokeStyle] Current StrokeStyle.
  14783. * @property {CanvasLineCap} [currentLineCap] Current LineCap.
  14784. * @property {Array<number>} currentLineDash Current LineDash.
  14785. * @property {number} [currentLineDashOffset] Current LineDashOffset.
  14786. * @property {CanvasLineJoin} [currentLineJoin] Current LineJoin.
  14787. * @property {number} [currentLineWidth] Current LineWidth.
  14788. * @property {number} [currentMiterLimit] Current MiterLimit.
  14789. * @property {number} [lastStroke] Last stroke.
  14790. * @property {import("../colorlike.js").ColorLike} [fillStyle] FillStyle.
  14791. * @property {import("../colorlike.js").ColorLike} [strokeStyle] StrokeStyle.
  14792. * @property {CanvasLineCap} [lineCap] LineCap.
  14793. * @property {Array<number>} lineDash LineDash.
  14794. * @property {number} [lineDashOffset] LineDashOffset.
  14795. * @property {CanvasLineJoin} [lineJoin] LineJoin.
  14796. * @property {number} [lineWidth] LineWidth.
  14797. * @property {number} [miterLimit] MiterLimit.
  14798. */
  14799. /**
  14800. * @typedef {Object} StrokeState
  14801. * @property {CanvasLineCap} lineCap LineCap.
  14802. * @property {Array<number>} lineDash LineDash.
  14803. * @property {number} lineDashOffset LineDashOffset.
  14804. * @property {CanvasLineJoin} lineJoin LineJoin.
  14805. * @property {number} lineWidth LineWidth.
  14806. * @property {number} miterLimit MiterLimit.
  14807. * @property {import("../colorlike.js").ColorLike} strokeStyle StrokeStyle.
  14808. */
  14809. /**
  14810. * @typedef {Object} TextState
  14811. * @property {string} font Font.
  14812. * @property {string} [textAlign] TextAlign.
  14813. * @property {string} [justify] Justify.
  14814. * @property {string} textBaseline TextBaseline.
  14815. * @property {string} [placement] Placement.
  14816. * @property {number} [maxAngle] MaxAngle.
  14817. * @property {boolean} [overflow] Overflow.
  14818. * @property {import("../style/Fill.js").default} [backgroundFill] BackgroundFill.
  14819. * @property {import("../style/Stroke.js").default} [backgroundStroke] BackgroundStroke.
  14820. * @property {import("../size.js").Size} [scale] Scale.
  14821. * @property {Array<number>} [padding] Padding.
  14822. */
  14823. /**
  14824. * @typedef {Object} SerializableInstructions
  14825. * @property {Array<*>} instructions The rendering instructions.
  14826. * @property {Array<*>} hitDetectionInstructions The rendering hit detection instructions.
  14827. * @property {Array<number>} coordinates The array of all coordinates.
  14828. * @property {!Object<string, TextState>} [textStates] The text states (decluttering).
  14829. * @property {!Object<string, FillState>} [fillStates] The fill states (decluttering).
  14830. * @property {!Object<string, StrokeState>} [strokeStates] The stroke states (decluttering).
  14831. */
  14832. /**
  14833. * @typedef {Object<number, import("./canvas/Executor.js").ReplayImageOrLabelArgs>} DeclutterImageWithText
  14834. */
  14835. /**
  14836. * @const
  14837. * @type {string}
  14838. */
  14839. var defaultFont = '10px sans-serif';
  14840. /**
  14841. * @const
  14842. * @type {import("../colorlike.js").ColorLike}
  14843. */
  14844. var defaultFillStyle = '#000';
  14845. /**
  14846. * @const
  14847. * @type {CanvasLineCap}
  14848. */
  14849. var defaultLineCap = 'round';
  14850. /**
  14851. * @const
  14852. * @type {Array<number>}
  14853. */
  14854. var defaultLineDash = [];
  14855. /**
  14856. * @const
  14857. * @type {number}
  14858. */
  14859. var defaultLineDashOffset = 0;
  14860. /**
  14861. * @const
  14862. * @type {CanvasLineJoin}
  14863. */
  14864. var defaultLineJoin = 'round';
  14865. /**
  14866. * @const
  14867. * @type {number}
  14868. */
  14869. var defaultMiterLimit = 10;
  14870. /**
  14871. * @const
  14872. * @type {import("../colorlike.js").ColorLike}
  14873. */
  14874. var defaultStrokeStyle = '#000';
  14875. /**
  14876. * @const
  14877. * @type {string}
  14878. */
  14879. var defaultTextAlign = 'center';
  14880. /**
  14881. * @const
  14882. * @type {string}
  14883. */
  14884. var defaultTextBaseline = 'middle';
  14885. /**
  14886. * @const
  14887. * @type {Array<number>}
  14888. */
  14889. var defaultPadding = [0, 0, 0, 0];
  14890. /**
  14891. * @const
  14892. * @type {number}
  14893. */
  14894. var defaultLineWidth = 1;
  14895. /**
  14896. * @type {BaseObject}
  14897. */
  14898. var checkedFonts = new ol_Object();
  14899. /**
  14900. * The label cache for text rendering. To change the default cache size of 2048
  14901. * entries, use {@link module:ol/structs/LRUCache~LRUCache#setSize cache.setSize()}.
  14902. * Deprecated - there is no label cache any more.
  14903. * @type {?}
  14904. * @api
  14905. * @deprecated
  14906. */
  14907. var labelCache = new events_Target();
  14908. labelCache.setSize = function () {
  14909. console.warn('labelCache is deprecated.'); //eslint-disable-line
  14910. };
  14911. /**
  14912. * @type {CanvasRenderingContext2D}
  14913. */
  14914. var measureContext = null;
  14915. /**
  14916. * @type {string}
  14917. */
  14918. var measureFont;
  14919. /**
  14920. * @type {!Object<string, number>}
  14921. */
  14922. var textHeights = {};
  14923. /**
  14924. * Clears the label cache when a font becomes available.
  14925. * @param {string} fontSpec CSS font spec.
  14926. */
  14927. var registerFont = (function () {
  14928. var retries = 100;
  14929. var size = '32px ';
  14930. var referenceFonts = ['monospace', 'serif'];
  14931. var len = referenceFonts.length;
  14932. var text = 'wmytzilWMYTZIL@#/&?$%10\uF013';
  14933. var interval, referenceWidth;
  14934. /**
  14935. * @param {string} fontStyle Css font-style
  14936. * @param {string} fontWeight Css font-weight
  14937. * @param {*} fontFamily Css font-family
  14938. * @return {boolean} Font with style and weight is available
  14939. */
  14940. function isAvailable(fontStyle, fontWeight, fontFamily) {
  14941. var available = true;
  14942. for (var i = 0; i < len; ++i) {
  14943. var referenceFont = referenceFonts[i];
  14944. referenceWidth = measureTextWidth(fontStyle + ' ' + fontWeight + ' ' + size + referenceFont, text);
  14945. if (fontFamily != referenceFont) {
  14946. var width = measureTextWidth(fontStyle +
  14947. ' ' +
  14948. fontWeight +
  14949. ' ' +
  14950. size +
  14951. fontFamily +
  14952. ',' +
  14953. referenceFont, text);
  14954. // If width and referenceWidth are the same, then the fallback was used
  14955. // instead of the font we wanted, so the font is not available.
  14956. available = available && width != referenceWidth;
  14957. }
  14958. }
  14959. if (available) {
  14960. return true;
  14961. }
  14962. return false;
  14963. }
  14964. function check() {
  14965. var done = true;
  14966. var fonts = checkedFonts.getKeys();
  14967. for (var i = 0, ii = fonts.length; i < ii; ++i) {
  14968. var font = fonts[i];
  14969. if (checkedFonts.get(font) < retries) {
  14970. if (isAvailable.apply(this, font.split('\n'))) {
  14971. clear(textHeights);
  14972. // Make sure that loaded fonts are picked up by Safari
  14973. measureContext = null;
  14974. measureFont = undefined;
  14975. checkedFonts.set(font, retries);
  14976. }
  14977. else {
  14978. checkedFonts.set(font, checkedFonts.get(font) + 1, true);
  14979. done = false;
  14980. }
  14981. }
  14982. }
  14983. if (done) {
  14984. clearInterval(interval);
  14985. interval = undefined;
  14986. }
  14987. }
  14988. return function (fontSpec) {
  14989. var font = getFontParameters(fontSpec);
  14990. if (!font) {
  14991. return;
  14992. }
  14993. var families = font.families;
  14994. for (var i = 0, ii = families.length; i < ii; ++i) {
  14995. var family = families[i];
  14996. var key = font.style + '\n' + font.weight + '\n' + family;
  14997. if (checkedFonts.get(key) === undefined) {
  14998. checkedFonts.set(key, retries, true);
  14999. if (!isAvailable(font.style, font.weight, family)) {
  15000. checkedFonts.set(key, 0, true);
  15001. if (interval === undefined) {
  15002. interval = setInterval(check, 32);
  15003. }
  15004. }
  15005. }
  15006. }
  15007. };
  15008. })();
  15009. /**
  15010. * @param {string} font Font to use for measuring.
  15011. * @return {import("../size.js").Size} Measurement.
  15012. */
  15013. var measureTextHeight = (function () {
  15014. /**
  15015. * @type {HTMLDivElement}
  15016. */
  15017. var measureElement;
  15018. return function (fontSpec) {
  15019. var height = textHeights[fontSpec];
  15020. if (height == undefined) {
  15021. if (WORKER_OFFSCREEN_CANVAS) {
  15022. var font = getFontParameters(fontSpec);
  15023. var metrics = measureText(fontSpec, 'Žg');
  15024. var lineHeight = isNaN(Number(font.lineHeight))
  15025. ? 1.2
  15026. : Number(font.lineHeight);
  15027. height =
  15028. lineHeight *
  15029. (metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);
  15030. }
  15031. else {
  15032. if (!measureElement) {
  15033. measureElement = document.createElement('div');
  15034. measureElement.innerHTML = 'M';
  15035. measureElement.style.minHeight = '0';
  15036. measureElement.style.maxHeight = 'none';
  15037. measureElement.style.height = 'auto';
  15038. measureElement.style.padding = '0';
  15039. measureElement.style.border = 'none';
  15040. measureElement.style.position = 'absolute';
  15041. measureElement.style.display = 'block';
  15042. measureElement.style.left = '-99999px';
  15043. }
  15044. measureElement.style.font = fontSpec;
  15045. document.body.appendChild(measureElement);
  15046. height = measureElement.offsetHeight;
  15047. document.body.removeChild(measureElement);
  15048. }
  15049. textHeights[fontSpec] = height;
  15050. }
  15051. return height;
  15052. };
  15053. })();
  15054. /**
  15055. * @param {string} font Font.
  15056. * @param {string} text Text.
  15057. * @return {TextMetrics} Text metrics.
  15058. */
  15059. function measureText(font, text) {
  15060. if (!measureContext) {
  15061. measureContext = createCanvasContext2D(1, 1);
  15062. }
  15063. if (font != measureFont) {
  15064. measureContext.font = font;
  15065. measureFont = measureContext.font;
  15066. }
  15067. return measureContext.measureText(text);
  15068. }
  15069. /**
  15070. * @param {string} font Font.
  15071. * @param {string} text Text.
  15072. * @return {number} Width.
  15073. */
  15074. function measureTextWidth(font, text) {
  15075. return measureText(font, text).width;
  15076. }
  15077. /**
  15078. * Measure text width using a cache.
  15079. * @param {string} font The font.
  15080. * @param {string} text The text to measure.
  15081. * @param {Object<string, number>} cache A lookup of cached widths by text.
  15082. * @return {number} The text width.
  15083. */
  15084. function measureAndCacheTextWidth(font, text, cache) {
  15085. if (text in cache) {
  15086. return cache[text];
  15087. }
  15088. var width = text
  15089. .split('\n')
  15090. .reduce(function (prev, curr) { return Math.max(prev, measureTextWidth(font, curr)); }, 0);
  15091. cache[text] = width;
  15092. return width;
  15093. }
  15094. /**
  15095. * @param {TextState} baseStyle Base style.
  15096. * @param {Array<string>} chunks Text chunks to measure.
  15097. * @return {{width: number, height: number, widths: Array<number>, heights: Array<number>, lineWidths: Array<number>}}} Text metrics.
  15098. */
  15099. function getTextDimensions(baseStyle, chunks) {
  15100. var widths = [];
  15101. var heights = [];
  15102. var lineWidths = [];
  15103. var width = 0;
  15104. var lineWidth = 0;
  15105. var height = 0;
  15106. var lineHeight = 0;
  15107. for (var i = 0, ii = chunks.length; i <= ii; i += 2) {
  15108. var text = chunks[i];
  15109. if (text === '\n' || i === ii) {
  15110. width = Math.max(width, lineWidth);
  15111. lineWidths.push(lineWidth);
  15112. lineWidth = 0;
  15113. height += lineHeight;
  15114. continue;
  15115. }
  15116. var font = chunks[i + 1] || baseStyle.font;
  15117. var currentWidth = measureTextWidth(font, text);
  15118. widths.push(currentWidth);
  15119. lineWidth += currentWidth;
  15120. var currentHeight = measureTextHeight(font);
  15121. heights.push(currentHeight);
  15122. lineHeight = Math.max(lineHeight, currentHeight);
  15123. }
  15124. return { width: width, height: height, widths: widths, heights: heights, lineWidths: lineWidths };
  15125. }
  15126. /**
  15127. * @param {CanvasRenderingContext2D} context Context.
  15128. * @param {number} rotation Rotation.
  15129. * @param {number} offsetX X offset.
  15130. * @param {number} offsetY Y offset.
  15131. */
  15132. function rotateAtOffset(context, rotation, offsetX, offsetY) {
  15133. if (rotation !== 0) {
  15134. context.translate(offsetX, offsetY);
  15135. context.rotate(rotation);
  15136. context.translate(-offsetX, -offsetY);
  15137. }
  15138. }
  15139. /**
  15140. * @param {CanvasRenderingContext2D} context Context.
  15141. * @param {import("../transform.js").Transform|null} transform Transform.
  15142. * @param {number} opacity Opacity.
  15143. * @param {Label|HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} labelOrImage Label.
  15144. * @param {number} originX Origin X.
  15145. * @param {number} originY Origin Y.
  15146. * @param {number} w Width.
  15147. * @param {number} h Height.
  15148. * @param {number} x X.
  15149. * @param {number} y Y.
  15150. * @param {import("../size.js").Size} scale Scale.
  15151. */
  15152. function drawImageOrLabel(context, transform, opacity, labelOrImage, originX, originY, w, h, x, y, scale) {
  15153. context.save();
  15154. if (opacity !== 1) {
  15155. context.globalAlpha *= opacity;
  15156. }
  15157. if (transform) {
  15158. context.setTransform.apply(context, transform);
  15159. }
  15160. if ( /** @type {*} */(labelOrImage).contextInstructions) {
  15161. // label
  15162. context.translate(x, y);
  15163. context.scale(scale[0], scale[1]);
  15164. executeLabelInstructions(/** @type {Label} */ (labelOrImage), context);
  15165. }
  15166. else if (scale[0] < 0 || scale[1] < 0) {
  15167. // flipped image
  15168. context.translate(x, y);
  15169. context.scale(scale[0], scale[1]);
  15170. context.drawImage(
  15171. /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (labelOrImage), originX, originY, w, h, 0, 0, w, h);
  15172. }
  15173. else {
  15174. // if image not flipped translate and scale can be avoided
  15175. context.drawImage(
  15176. /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (labelOrImage), originX, originY, w, h, x, y, w * scale[0], h * scale[1]);
  15177. }
  15178. context.restore();
  15179. }
  15180. /**
  15181. * @param {Label} label Label.
  15182. * @param {CanvasRenderingContext2D} context Context.
  15183. */
  15184. function executeLabelInstructions(label, context) {
  15185. var contextInstructions = label.contextInstructions;
  15186. for (var i = 0, ii = contextInstructions.length; i < ii; i += 2) {
  15187. if (Array.isArray(contextInstructions[i + 1])) {
  15188. context[contextInstructions[i]].apply(context, contextInstructions[i + 1]);
  15189. }
  15190. else {
  15191. context[contextInstructions[i]] = contextInstructions[i + 1];
  15192. }
  15193. }
  15194. }
  15195. //# sourceMappingURL=canvas.js.map
  15196. ;// ./node_modules/ol/style/RegularShape.js
  15197. /**
  15198. * @module ol/style/RegularShape
  15199. */
  15200. var RegularShape_extends = (undefined && undefined.__extends) || (function () {
  15201. var extendStatics = function (d, b) {
  15202. extendStatics = Object.setPrototypeOf ||
  15203. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15204. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  15205. return extendStatics(d, b);
  15206. };
  15207. return function (d, b) {
  15208. if (typeof b !== "function" && b !== null)
  15209. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  15210. extendStatics(d, b);
  15211. function __() { this.constructor = d; }
  15212. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15213. };
  15214. })();
  15215. /**
  15216. * Specify radius for regular polygons, or radius1 and radius2 for stars.
  15217. * @typedef {Object} Options
  15218. * @property {import("./Fill.js").default} [fill] Fill style.
  15219. * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the number of points
  15220. * is the number of sides.
  15221. * @property {number} [radius] Radius of a regular polygon.
  15222. * @property {number} [radius1] First radius of a star. Ignored if radius is set.
  15223. * @property {number} [radius2] Second radius of a star.
  15224. * @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's point facing up.
  15225. * @property {Array<number>} [displacement=[0,0]] Displacement of the shape
  15226. * @property {import("./Stroke.js").default} [stroke] Stroke style.
  15227. * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
  15228. * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.
  15229. * @property {number|import("../size.js").Size} [scale=1] Scale. Unless two dimensional scaling is required a better
  15230. * result may be obtained with appropriate settings for `radius`, `radius1` and `radius2`.
  15231. * @property {"declutter"|"obstacle"|"none"|undefined} [declutterMode] Declutter mode
  15232. */
  15233. /**
  15234. * @typedef {Object} RenderOptions
  15235. * @property {import("../colorlike.js").ColorLike} [strokeStyle] StrokeStyle.
  15236. * @property {number} strokeWidth StrokeWidth.
  15237. * @property {number} size Size.
  15238. * @property {Array<number>} lineDash LineDash.
  15239. * @property {number} lineDashOffset LineDashOffset.
  15240. * @property {CanvasLineJoin} lineJoin LineJoin.
  15241. * @property {number} miterLimit MiterLimit.
  15242. */
  15243. /**
  15244. * @classdesc
  15245. * Set regular shape style for vector features. The resulting shape will be
  15246. * a regular polygon when `radius` is provided, or a star when `radius1` and
  15247. * `radius2` are provided.
  15248. * @api
  15249. */
  15250. var RegularShape = /** @class */ (function (_super) {
  15251. RegularShape_extends(RegularShape, _super);
  15252. /**
  15253. * @param {Options} options Options.
  15254. */
  15255. function RegularShape(options) {
  15256. var _this = this;
  15257. /**
  15258. * @type {boolean}
  15259. */
  15260. var rotateWithView = options.rotateWithView !== undefined ? options.rotateWithView : false;
  15261. _this = _super.call(this, {
  15262. opacity: 1,
  15263. rotateWithView: rotateWithView,
  15264. rotation: options.rotation !== undefined ? options.rotation : 0,
  15265. scale: options.scale !== undefined ? options.scale : 1,
  15266. displacement: options.displacement !== undefined ? options.displacement : [0, 0],
  15267. declutterMode: options.declutterMode,
  15268. }) || this;
  15269. /**
  15270. * @private
  15271. * @type {Object<number, HTMLCanvasElement>}
  15272. */
  15273. _this.canvas_ = undefined;
  15274. /**
  15275. * @private
  15276. * @type {HTMLCanvasElement}
  15277. */
  15278. _this.hitDetectionCanvas_ = null;
  15279. /**
  15280. * @private
  15281. * @type {import("./Fill.js").default}
  15282. */
  15283. _this.fill_ = options.fill !== undefined ? options.fill : null;
  15284. /**
  15285. * @private
  15286. * @type {Array<number>}
  15287. */
  15288. _this.origin_ = [0, 0];
  15289. /**
  15290. * @private
  15291. * @type {number}
  15292. */
  15293. _this.points_ = options.points;
  15294. /**
  15295. * @protected
  15296. * @type {number}
  15297. */
  15298. _this.radius_ =
  15299. options.radius !== undefined ? options.radius : options.radius1;
  15300. /**
  15301. * @private
  15302. * @type {number|undefined}
  15303. */
  15304. _this.radius2_ = options.radius2;
  15305. /**
  15306. * @private
  15307. * @type {number}
  15308. */
  15309. _this.angle_ = options.angle !== undefined ? options.angle : 0;
  15310. /**
  15311. * @private
  15312. * @type {import("./Stroke.js").default}
  15313. */
  15314. _this.stroke_ = options.stroke !== undefined ? options.stroke : null;
  15315. /**
  15316. * @private
  15317. * @type {import("../size.js").Size}
  15318. */
  15319. _this.size_ = null;
  15320. /**
  15321. * @private
  15322. * @type {RenderOptions}
  15323. */
  15324. _this.renderOptions_ = null;
  15325. _this.render();
  15326. return _this;
  15327. }
  15328. /**
  15329. * Clones the style.
  15330. * @return {RegularShape} The cloned style.
  15331. * @api
  15332. */
  15333. RegularShape.prototype.clone = function () {
  15334. var scale = this.getScale();
  15335. var style = new RegularShape({
  15336. fill: this.getFill() ? this.getFill().clone() : undefined,
  15337. points: this.getPoints(),
  15338. radius: this.getRadius(),
  15339. radius2: this.getRadius2(),
  15340. angle: this.getAngle(),
  15341. stroke: this.getStroke() ? this.getStroke().clone() : undefined,
  15342. rotation: this.getRotation(),
  15343. rotateWithView: this.getRotateWithView(),
  15344. scale: Array.isArray(scale) ? scale.slice() : scale,
  15345. displacement: this.getDisplacement().slice(),
  15346. declutterMode: this.getDeclutterMode(),
  15347. });
  15348. style.setOpacity(this.getOpacity());
  15349. return style;
  15350. };
  15351. /**
  15352. * Get the anchor point in pixels. The anchor determines the center point for the
  15353. * symbolizer.
  15354. * @return {Array<number>} Anchor.
  15355. * @api
  15356. */
  15357. RegularShape.prototype.getAnchor = function () {
  15358. var size = this.size_;
  15359. if (!size) {
  15360. return null;
  15361. }
  15362. var displacement = this.getDisplacement();
  15363. return [size[0] / 2 - displacement[0], size[1] / 2 + displacement[1]];
  15364. };
  15365. /**
  15366. * Get the angle used in generating the shape.
  15367. * @return {number} Shape's rotation in radians.
  15368. * @api
  15369. */
  15370. RegularShape.prototype.getAngle = function () {
  15371. return this.angle_;
  15372. };
  15373. /**
  15374. * Get the fill style for the shape.
  15375. * @return {import("./Fill.js").default} Fill style.
  15376. * @api
  15377. */
  15378. RegularShape.prototype.getFill = function () {
  15379. return this.fill_;
  15380. };
  15381. /**
  15382. * Set the fill style.
  15383. * @param {import("./Fill.js").default} fill Fill style.
  15384. * @api
  15385. */
  15386. RegularShape.prototype.setFill = function (fill) {
  15387. this.fill_ = fill;
  15388. this.render();
  15389. };
  15390. /**
  15391. * @return {HTMLCanvasElement} Image element.
  15392. */
  15393. RegularShape.prototype.getHitDetectionImage = function () {
  15394. if (!this.hitDetectionCanvas_) {
  15395. this.createHitDetectionCanvas_(this.renderOptions_);
  15396. }
  15397. return this.hitDetectionCanvas_;
  15398. };
  15399. /**
  15400. * Get the image icon.
  15401. * @param {number} pixelRatio Pixel ratio.
  15402. * @return {HTMLCanvasElement} Image or Canvas element.
  15403. * @api
  15404. */
  15405. RegularShape.prototype.getImage = function (pixelRatio) {
  15406. var image = this.canvas_[pixelRatio];
  15407. if (!image) {
  15408. var renderOptions = this.renderOptions_;
  15409. var context = createCanvasContext2D(renderOptions.size * pixelRatio, renderOptions.size * pixelRatio);
  15410. this.draw_(renderOptions, context, pixelRatio);
  15411. image = context.canvas;
  15412. this.canvas_[pixelRatio] = image;
  15413. }
  15414. return image;
  15415. };
  15416. /**
  15417. * Get the image pixel ratio.
  15418. * @param {number} pixelRatio Pixel ratio.
  15419. * @return {number} Pixel ratio.
  15420. */
  15421. RegularShape.prototype.getPixelRatio = function (pixelRatio) {
  15422. return pixelRatio;
  15423. };
  15424. /**
  15425. * @return {import("../size.js").Size} Image size.
  15426. */
  15427. RegularShape.prototype.getImageSize = function () {
  15428. return this.size_;
  15429. };
  15430. /**
  15431. * @return {import("../ImageState.js").default} Image state.
  15432. */
  15433. RegularShape.prototype.getImageState = function () {
  15434. return ImageState.LOADED;
  15435. };
  15436. /**
  15437. * Get the origin of the symbolizer.
  15438. * @return {Array<number>} Origin.
  15439. * @api
  15440. */
  15441. RegularShape.prototype.getOrigin = function () {
  15442. return this.origin_;
  15443. };
  15444. /**
  15445. * Get the number of points for generating the shape.
  15446. * @return {number} Number of points for stars and regular polygons.
  15447. * @api
  15448. */
  15449. RegularShape.prototype.getPoints = function () {
  15450. return this.points_;
  15451. };
  15452. /**
  15453. * Get the (primary) radius for the shape.
  15454. * @return {number} Radius.
  15455. * @api
  15456. */
  15457. RegularShape.prototype.getRadius = function () {
  15458. return this.radius_;
  15459. };
  15460. /**
  15461. * Get the secondary radius for the shape.
  15462. * @return {number|undefined} Radius2.
  15463. * @api
  15464. */
  15465. RegularShape.prototype.getRadius2 = function () {
  15466. return this.radius2_;
  15467. };
  15468. /**
  15469. * Get the size of the symbolizer (in pixels).
  15470. * @return {import("../size.js").Size} Size.
  15471. * @api
  15472. */
  15473. RegularShape.prototype.getSize = function () {
  15474. return this.size_;
  15475. };
  15476. /**
  15477. * Get the stroke style for the shape.
  15478. * @return {import("./Stroke.js").default} Stroke style.
  15479. * @api
  15480. */
  15481. RegularShape.prototype.getStroke = function () {
  15482. return this.stroke_;
  15483. };
  15484. /**
  15485. * Set the stroke style.
  15486. * @param {import("./Stroke.js").default} stroke Stroke style.
  15487. * @api
  15488. */
  15489. RegularShape.prototype.setStroke = function (stroke) {
  15490. this.stroke_ = stroke;
  15491. this.render();
  15492. };
  15493. /**
  15494. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  15495. */
  15496. RegularShape.prototype.listenImageChange = function (listener) { };
  15497. /**
  15498. * Load not yet loaded URI.
  15499. */
  15500. RegularShape.prototype.load = function () { };
  15501. /**
  15502. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  15503. */
  15504. RegularShape.prototype.unlistenImageChange = function (listener) { };
  15505. /**
  15506. * Calculate additional canvas size needed for the miter.
  15507. * @param {string} lineJoin Line join
  15508. * @param {number} strokeWidth Stroke width
  15509. * @param {number} miterLimit Miter limit
  15510. * @return {number} Additional canvas size needed
  15511. * @private
  15512. */
  15513. RegularShape.prototype.calculateLineJoinSize_ = function (lineJoin, strokeWidth, miterLimit) {
  15514. if (strokeWidth === 0 ||
  15515. this.points_ === Infinity ||
  15516. (lineJoin !== 'bevel' && lineJoin !== 'miter')) {
  15517. return strokeWidth;
  15518. }
  15519. // m | ^
  15520. // i | |\ .
  15521. // t >| #\
  15522. // e | |\ \ .
  15523. // r \s\
  15524. // | \t\ . .
  15525. // \r\ . .
  15526. // | \o\ . . . . .
  15527. // e \k\ . . . .
  15528. // | \e\ . . . . .
  15529. // d \ \ . . . .
  15530. // | _ _a_ _\# . . .
  15531. // r1 / ` . .
  15532. // | . .
  15533. // b / . .
  15534. // | . .
  15535. // / r2 . .
  15536. // | . .
  15537. // / . .
  15538. // |α . .
  15539. // / . .
  15540. // ° center
  15541. var r1 = this.radius_;
  15542. var r2 = this.radius2_ === undefined ? r1 : this.radius2_;
  15543. if (r1 < r2) {
  15544. var tmp = r1;
  15545. r1 = r2;
  15546. r2 = tmp;
  15547. }
  15548. var points = this.radius2_ === undefined ? this.points_ : this.points_ * 2;
  15549. var alpha = (2 * Math.PI) / points;
  15550. var a = r2 * Math.sin(alpha);
  15551. var b = Math.sqrt(r2 * r2 - a * a);
  15552. var d = r1 - b;
  15553. var e = Math.sqrt(a * a + d * d);
  15554. var miterRatio = e / a;
  15555. if (lineJoin === 'miter' && miterRatio <= miterLimit) {
  15556. return miterRatio * strokeWidth;
  15557. }
  15558. // Calculate the distnce from center to the stroke corner where
  15559. // it was cut short because of the miter limit.
  15560. // l
  15561. // ----+---- <= distance from center to here is maxr
  15562. // /####|k ##\
  15563. // /#####^#####\
  15564. // /#### /+\# s #\
  15565. // /### h/+++\# t #\
  15566. // /### t/+++++\# r #\
  15567. // /### a/+++++++\# o #\
  15568. // /### p/++ fill +\# k #\
  15569. ///#### /+++++^+++++\# e #\
  15570. //#####/+++++/+\+++++\#####\
  15571. var k = strokeWidth / 2 / miterRatio;
  15572. var l = (strokeWidth / 2) * (d / e);
  15573. var maxr = Math.sqrt((r1 + k) * (r1 + k) + l * l);
  15574. var bevelAdd = maxr - r1;
  15575. if (this.radius2_ === undefined || lineJoin === 'bevel') {
  15576. return bevelAdd * 2;
  15577. }
  15578. // If outer miter is over the miter limit the inner miter may reach through the
  15579. // center and be longer than the bevel, same calculation as above but swap r1 / r2.
  15580. var aa = r1 * Math.sin(alpha);
  15581. var bb = Math.sqrt(r1 * r1 - aa * aa);
  15582. var dd = r2 - bb;
  15583. var ee = Math.sqrt(aa * aa + dd * dd);
  15584. var innerMiterRatio = ee / aa;
  15585. if (innerMiterRatio <= miterLimit) {
  15586. var innerLength = (innerMiterRatio * strokeWidth) / 2 - r2 - r1;
  15587. return 2 * Math.max(bevelAdd, innerLength);
  15588. }
  15589. return bevelAdd * 2;
  15590. };
  15591. /**
  15592. * @return {RenderOptions} The render options
  15593. * @protected
  15594. */
  15595. RegularShape.prototype.createRenderOptions = function () {
  15596. var lineJoin = defaultLineJoin;
  15597. var miterLimit = 0;
  15598. var lineDash = null;
  15599. var lineDashOffset = 0;
  15600. var strokeStyle;
  15601. var strokeWidth = 0;
  15602. if (this.stroke_) {
  15603. strokeStyle = this.stroke_.getColor();
  15604. if (strokeStyle === null) {
  15605. strokeStyle = defaultStrokeStyle;
  15606. }
  15607. strokeStyle = asColorLike(strokeStyle);
  15608. strokeWidth = this.stroke_.getWidth();
  15609. if (strokeWidth === undefined) {
  15610. strokeWidth = defaultLineWidth;
  15611. }
  15612. lineDash = this.stroke_.getLineDash();
  15613. lineDashOffset = this.stroke_.getLineDashOffset();
  15614. lineJoin = this.stroke_.getLineJoin();
  15615. if (lineJoin === undefined) {
  15616. lineJoin = defaultLineJoin;
  15617. }
  15618. miterLimit = this.stroke_.getMiterLimit();
  15619. if (miterLimit === undefined) {
  15620. miterLimit = defaultMiterLimit;
  15621. }
  15622. }
  15623. var add = this.calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit);
  15624. var maxRadius = Math.max(this.radius_, this.radius2_ || 0);
  15625. var size = Math.ceil(2 * maxRadius + add);
  15626. return {
  15627. strokeStyle: strokeStyle,
  15628. strokeWidth: strokeWidth,
  15629. size: size,
  15630. lineDash: lineDash,
  15631. lineDashOffset: lineDashOffset,
  15632. lineJoin: lineJoin,
  15633. miterLimit: miterLimit,
  15634. };
  15635. };
  15636. /**
  15637. * @protected
  15638. */
  15639. RegularShape.prototype.render = function () {
  15640. this.renderOptions_ = this.createRenderOptions();
  15641. var size = this.renderOptions_.size;
  15642. this.canvas_ = {};
  15643. this.size_ = [size, size];
  15644. };
  15645. /**
  15646. * @private
  15647. * @param {RenderOptions} renderOptions Render options.
  15648. * @param {CanvasRenderingContext2D} context The rendering context.
  15649. * @param {number} pixelRatio The pixel ratio.
  15650. */
  15651. RegularShape.prototype.draw_ = function (renderOptions, context, pixelRatio) {
  15652. context.scale(pixelRatio, pixelRatio);
  15653. // set origin to canvas center
  15654. context.translate(renderOptions.size / 2, renderOptions.size / 2);
  15655. this.createPath_(context);
  15656. if (this.fill_) {
  15657. var color = this.fill_.getColor();
  15658. if (color === null) {
  15659. color = defaultFillStyle;
  15660. }
  15661. context.fillStyle = asColorLike(color);
  15662. context.fill();
  15663. }
  15664. if (this.stroke_) {
  15665. context.strokeStyle = renderOptions.strokeStyle;
  15666. context.lineWidth = renderOptions.strokeWidth;
  15667. if (context.setLineDash && renderOptions.lineDash) {
  15668. context.setLineDash(renderOptions.lineDash);
  15669. context.lineDashOffset = renderOptions.lineDashOffset;
  15670. }
  15671. context.lineJoin = renderOptions.lineJoin;
  15672. context.miterLimit = renderOptions.miterLimit;
  15673. context.stroke();
  15674. }
  15675. };
  15676. /**
  15677. * @private
  15678. * @param {RenderOptions} renderOptions Render options.
  15679. */
  15680. RegularShape.prototype.createHitDetectionCanvas_ = function (renderOptions) {
  15681. if (this.fill_) {
  15682. var color = this.fill_.getColor();
  15683. // determine if fill is transparent (or pattern or gradient)
  15684. var opacity = 0;
  15685. if (typeof color === 'string') {
  15686. color = asArray(color);
  15687. }
  15688. if (color === null) {
  15689. opacity = 1;
  15690. }
  15691. else if (Array.isArray(color)) {
  15692. opacity = color.length === 4 ? color[3] : 1;
  15693. }
  15694. if (opacity === 0) {
  15695. // if a transparent fill style is set, create an extra hit-detection image
  15696. // with a default fill style
  15697. var context = createCanvasContext2D(renderOptions.size, renderOptions.size);
  15698. this.hitDetectionCanvas_ = context.canvas;
  15699. this.drawHitDetectionCanvas_(renderOptions, context);
  15700. }
  15701. }
  15702. if (!this.hitDetectionCanvas_) {
  15703. this.hitDetectionCanvas_ = this.getImage(1);
  15704. }
  15705. };
  15706. /**
  15707. * @private
  15708. * @param {CanvasRenderingContext2D} context The context to draw in.
  15709. */
  15710. RegularShape.prototype.createPath_ = function (context) {
  15711. var points = this.points_;
  15712. var radius = this.radius_;
  15713. if (points === Infinity) {
  15714. context.arc(0, 0, radius, 0, 2 * Math.PI);
  15715. }
  15716. else {
  15717. var radius2 = this.radius2_ === undefined ? radius : this.radius2_;
  15718. if (this.radius2_ !== undefined) {
  15719. points *= 2;
  15720. }
  15721. var startAngle = this.angle_ - Math.PI / 2;
  15722. var step = (2 * Math.PI) / points;
  15723. for (var i = 0; i < points; i++) {
  15724. var angle0 = startAngle + i * step;
  15725. var radiusC = i % 2 === 0 ? radius : radius2;
  15726. context.lineTo(radiusC * Math.cos(angle0), radiusC * Math.sin(angle0));
  15727. }
  15728. context.closePath();
  15729. }
  15730. };
  15731. /**
  15732. * @private
  15733. * @param {RenderOptions} renderOptions Render options.
  15734. * @param {CanvasRenderingContext2D} context The context.
  15735. */
  15736. RegularShape.prototype.drawHitDetectionCanvas_ = function (renderOptions, context) {
  15737. // set origin to canvas center
  15738. context.translate(renderOptions.size / 2, renderOptions.size / 2);
  15739. this.createPath_(context);
  15740. context.fillStyle = defaultFillStyle;
  15741. context.fill();
  15742. if (this.stroke_) {
  15743. context.strokeStyle = renderOptions.strokeStyle;
  15744. context.lineWidth = renderOptions.strokeWidth;
  15745. if (renderOptions.lineDash) {
  15746. context.setLineDash(renderOptions.lineDash);
  15747. context.lineDashOffset = renderOptions.lineDashOffset;
  15748. }
  15749. context.lineJoin = renderOptions.lineJoin;
  15750. context.miterLimit = renderOptions.miterLimit;
  15751. context.stroke();
  15752. }
  15753. };
  15754. return RegularShape;
  15755. }(style_Image));
  15756. /* harmony default export */ var style_RegularShape = (RegularShape);
  15757. //# sourceMappingURL=RegularShape.js.map
  15758. ;// ./node_modules/ol/style/Circle.js
  15759. /**
  15760. * @module ol/style/Circle
  15761. */
  15762. var Circle_extends = (undefined && undefined.__extends) || (function () {
  15763. var extendStatics = function (d, b) {
  15764. extendStatics = Object.setPrototypeOf ||
  15765. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15766. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  15767. return extendStatics(d, b);
  15768. };
  15769. return function (d, b) {
  15770. if (typeof b !== "function" && b !== null)
  15771. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  15772. extendStatics(d, b);
  15773. function __() { this.constructor = d; }
  15774. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15775. };
  15776. })();
  15777. /**
  15778. * @typedef {Object} Options
  15779. * @property {import("./Fill.js").default} [fill] Fill style.
  15780. * @property {number} radius Circle radius.
  15781. * @property {import("./Stroke.js").default} [stroke] Stroke style.
  15782. * @property {Array<number>} [displacement=[0,0]] displacement
  15783. * @property {number|import("../size.js").Size} [scale=1] Scale. A two dimensional scale will produce an ellipse.
  15784. * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `radius`.
  15785. * @property {number} [rotation=0] Rotation in radians
  15786. * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).
  15787. * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view
  15788. * (meaningful only when used in conjunction with a two dimensional scale).
  15789. * @property {"declutter"|"obstacle"|"none"|undefined} [declutterMode] Declutter mode
  15790. */
  15791. /**
  15792. * @classdesc
  15793. * Set circle style for vector features.
  15794. * @api
  15795. */
  15796. var Circle_CircleStyle = /** @class */ (function (_super) {
  15797. Circle_extends(CircleStyle, _super);
  15798. /**
  15799. * @param {Options} [opt_options] Options.
  15800. */
  15801. function CircleStyle(opt_options) {
  15802. var options = opt_options ? opt_options : {};
  15803. return _super.call(this, {
  15804. points: Infinity,
  15805. fill: options.fill,
  15806. radius: options.radius,
  15807. stroke: options.stroke,
  15808. scale: options.scale !== undefined ? options.scale : 1,
  15809. rotation: options.rotation !== undefined ? options.rotation : 0,
  15810. rotateWithView: options.rotateWithView !== undefined ? options.rotateWithView : false,
  15811. displacement: options.displacement !== undefined ? options.displacement : [0, 0],
  15812. declutterMode: options.declutterMode,
  15813. }) || this;
  15814. }
  15815. /**
  15816. * Clones the style.
  15817. * @return {CircleStyle} The cloned style.
  15818. * @api
  15819. */
  15820. CircleStyle.prototype.clone = function () {
  15821. var scale = this.getScale();
  15822. var style = new CircleStyle({
  15823. fill: this.getFill() ? this.getFill().clone() : undefined,
  15824. stroke: this.getStroke() ? this.getStroke().clone() : undefined,
  15825. radius: this.getRadius(),
  15826. scale: Array.isArray(scale) ? scale.slice() : scale,
  15827. rotation: this.getRotation(),
  15828. rotateWithView: this.getRotateWithView(),
  15829. displacement: this.getDisplacement().slice(),
  15830. declutterMode: this.getDeclutterMode(),
  15831. });
  15832. style.setOpacity(this.getOpacity());
  15833. return style;
  15834. };
  15835. /**
  15836. * Set the circle radius.
  15837. *
  15838. * @param {number} radius Circle radius.
  15839. * @api
  15840. */
  15841. CircleStyle.prototype.setRadius = function (radius) {
  15842. this.radius_ = radius;
  15843. this.render();
  15844. };
  15845. return CircleStyle;
  15846. }(style_RegularShape));
  15847. /* harmony default export */ var Circle = (Circle_CircleStyle);
  15848. //# sourceMappingURL=Circle.js.map
  15849. ;// ./node_modules/ol/style/Fill.js
  15850. /**
  15851. * @module ol/style/Fill
  15852. */
  15853. /**
  15854. * @typedef {Object} Options
  15855. * @property {import("../color.js").Color|import("../colorlike.js").ColorLike|null} [color=null] A color, gradient or pattern.
  15856. * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.
  15857. * Default null; if null, the Canvas/renderer default black will be used.
  15858. */
  15859. /**
  15860. * @classdesc
  15861. * Set fill style for vector features.
  15862. * @api
  15863. */
  15864. var Fill_Fill = /** @class */ (function () {
  15865. /**
  15866. * @param {Options} [opt_options] Options.
  15867. */
  15868. function Fill(opt_options) {
  15869. var options = opt_options || {};
  15870. /**
  15871. * @private
  15872. * @type {import("../color.js").Color|import("../colorlike.js").ColorLike|null}
  15873. */
  15874. this.color_ = options.color !== undefined ? options.color : null;
  15875. }
  15876. /**
  15877. * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.
  15878. * @return {Fill} The cloned style.
  15879. * @api
  15880. */
  15881. Fill.prototype.clone = function () {
  15882. var color = this.getColor();
  15883. return new Fill({
  15884. color: Array.isArray(color) ? color.slice() : color || undefined,
  15885. });
  15886. };
  15887. /**
  15888. * Get the fill color.
  15889. * @return {import("../color.js").Color|import("../colorlike.js").ColorLike|null} Color.
  15890. * @api
  15891. */
  15892. Fill.prototype.getColor = function () {
  15893. return this.color_;
  15894. };
  15895. /**
  15896. * Set the color.
  15897. *
  15898. * @param {import("../color.js").Color|import("../colorlike.js").ColorLike|null} color Color.
  15899. * @api
  15900. */
  15901. Fill.prototype.setColor = function (color) {
  15902. this.color_ = color;
  15903. };
  15904. return Fill;
  15905. }());
  15906. /* harmony default export */ var style_Fill = (Fill_Fill);
  15907. //# sourceMappingURL=Fill.js.map
  15908. ;// ./node_modules/ol/style/Stroke.js
  15909. /**
  15910. * @module ol/style/Stroke
  15911. */
  15912. /**
  15913. * @typedef {Object} Options
  15914. * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [color] A color, gradient or pattern.
  15915. * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.
  15916. * Default null; if null, the Canvas/renderer default black will be used.
  15917. * @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.
  15918. * @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.
  15919. * @property {Array<number>} [lineDash] Line dash pattern. Default is `null` (no dash).
  15920. * Please note that Internet Explorer 10 and lower do not support the `setLineDash` method on
  15921. * the `CanvasRenderingContext2D` and therefore this option will have no visual effect in these browsers.
  15922. * @property {number} [lineDashOffset=0] Line dash offset.
  15923. * @property {number} [miterLimit=10] Miter limit.
  15924. * @property {number} [width] Width.
  15925. */
  15926. /**
  15927. * @classdesc
  15928. * Set stroke style for vector features.
  15929. * Note that the defaults given are the Canvas defaults, which will be used if
  15930. * option is not defined. The `get` functions return whatever was entered in
  15931. * the options; they will not return the default.
  15932. * @api
  15933. */
  15934. var Stroke_Stroke = /** @class */ (function () {
  15935. /**
  15936. * @param {Options} [opt_options] Options.
  15937. */
  15938. function Stroke(opt_options) {
  15939. var options = opt_options || {};
  15940. /**
  15941. * @private
  15942. * @type {import("../color.js").Color|import("../colorlike.js").ColorLike}
  15943. */
  15944. this.color_ = options.color !== undefined ? options.color : null;
  15945. /**
  15946. * @private
  15947. * @type {CanvasLineCap|undefined}
  15948. */
  15949. this.lineCap_ = options.lineCap;
  15950. /**
  15951. * @private
  15952. * @type {Array<number>}
  15953. */
  15954. this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null;
  15955. /**
  15956. * @private
  15957. * @type {number|undefined}
  15958. */
  15959. this.lineDashOffset_ = options.lineDashOffset;
  15960. /**
  15961. * @private
  15962. * @type {CanvasLineJoin|undefined}
  15963. */
  15964. this.lineJoin_ = options.lineJoin;
  15965. /**
  15966. * @private
  15967. * @type {number|undefined}
  15968. */
  15969. this.miterLimit_ = options.miterLimit;
  15970. /**
  15971. * @private
  15972. * @type {number|undefined}
  15973. */
  15974. this.width_ = options.width;
  15975. }
  15976. /**
  15977. * Clones the style.
  15978. * @return {Stroke} The cloned style.
  15979. * @api
  15980. */
  15981. Stroke.prototype.clone = function () {
  15982. var color = this.getColor();
  15983. return new Stroke({
  15984. color: Array.isArray(color) ? color.slice() : color || undefined,
  15985. lineCap: this.getLineCap(),
  15986. lineDash: this.getLineDash() ? this.getLineDash().slice() : undefined,
  15987. lineDashOffset: this.getLineDashOffset(),
  15988. lineJoin: this.getLineJoin(),
  15989. miterLimit: this.getMiterLimit(),
  15990. width: this.getWidth(),
  15991. });
  15992. };
  15993. /**
  15994. * Get the stroke color.
  15995. * @return {import("../color.js").Color|import("../colorlike.js").ColorLike} Color.
  15996. * @api
  15997. */
  15998. Stroke.prototype.getColor = function () {
  15999. return this.color_;
  16000. };
  16001. /**
  16002. * Get the line cap type for the stroke.
  16003. * @return {CanvasLineCap|undefined} Line cap.
  16004. * @api
  16005. */
  16006. Stroke.prototype.getLineCap = function () {
  16007. return this.lineCap_;
  16008. };
  16009. /**
  16010. * Get the line dash style for the stroke.
  16011. * @return {Array<number>} Line dash.
  16012. * @api
  16013. */
  16014. Stroke.prototype.getLineDash = function () {
  16015. return this.lineDash_;
  16016. };
  16017. /**
  16018. * Get the line dash offset for the stroke.
  16019. * @return {number|undefined} Line dash offset.
  16020. * @api
  16021. */
  16022. Stroke.prototype.getLineDashOffset = function () {
  16023. return this.lineDashOffset_;
  16024. };
  16025. /**
  16026. * Get the line join type for the stroke.
  16027. * @return {CanvasLineJoin|undefined} Line join.
  16028. * @api
  16029. */
  16030. Stroke.prototype.getLineJoin = function () {
  16031. return this.lineJoin_;
  16032. };
  16033. /**
  16034. * Get the miter limit for the stroke.
  16035. * @return {number|undefined} Miter limit.
  16036. * @api
  16037. */
  16038. Stroke.prototype.getMiterLimit = function () {
  16039. return this.miterLimit_;
  16040. };
  16041. /**
  16042. * Get the stroke width.
  16043. * @return {number|undefined} Width.
  16044. * @api
  16045. */
  16046. Stroke.prototype.getWidth = function () {
  16047. return this.width_;
  16048. };
  16049. /**
  16050. * Set the color.
  16051. *
  16052. * @param {import("../color.js").Color|import("../colorlike.js").ColorLike} color Color.
  16053. * @api
  16054. */
  16055. Stroke.prototype.setColor = function (color) {
  16056. this.color_ = color;
  16057. };
  16058. /**
  16059. * Set the line cap.
  16060. *
  16061. * @param {CanvasLineCap|undefined} lineCap Line cap.
  16062. * @api
  16063. */
  16064. Stroke.prototype.setLineCap = function (lineCap) {
  16065. this.lineCap_ = lineCap;
  16066. };
  16067. /**
  16068. * Set the line dash.
  16069. *
  16070. * Please note that Internet Explorer 10 and lower [do not support][mdn] the
  16071. * `setLineDash` method on the `CanvasRenderingContext2D` and therefore this
  16072. * property will have no visual effect in these browsers.
  16073. *
  16074. * [mdn]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility
  16075. *
  16076. * @param {Array<number>} lineDash Line dash.
  16077. * @api
  16078. */
  16079. Stroke.prototype.setLineDash = function (lineDash) {
  16080. this.lineDash_ = lineDash;
  16081. };
  16082. /**
  16083. * Set the line dash offset.
  16084. *
  16085. * @param {number|undefined} lineDashOffset Line dash offset.
  16086. * @api
  16087. */
  16088. Stroke.prototype.setLineDashOffset = function (lineDashOffset) {
  16089. this.lineDashOffset_ = lineDashOffset;
  16090. };
  16091. /**
  16092. * Set the line join.
  16093. *
  16094. * @param {CanvasLineJoin|undefined} lineJoin Line join.
  16095. * @api
  16096. */
  16097. Stroke.prototype.setLineJoin = function (lineJoin) {
  16098. this.lineJoin_ = lineJoin;
  16099. };
  16100. /**
  16101. * Set the miter limit.
  16102. *
  16103. * @param {number|undefined} miterLimit Miter limit.
  16104. * @api
  16105. */
  16106. Stroke.prototype.setMiterLimit = function (miterLimit) {
  16107. this.miterLimit_ = miterLimit;
  16108. };
  16109. /**
  16110. * Set the width.
  16111. *
  16112. * @param {number|undefined} width Width.
  16113. * @api
  16114. */
  16115. Stroke.prototype.setWidth = function (width) {
  16116. this.width_ = width;
  16117. };
  16118. return Stroke;
  16119. }());
  16120. /* harmony default export */ var style_Stroke = (Stroke_Stroke);
  16121. //# sourceMappingURL=Stroke.js.map
  16122. ;// ./node_modules/ol/style/Style.js
  16123. /**
  16124. * @module ol/style/Style
  16125. */
  16126. /**
  16127. * A function that takes an {@link module:ol/Feature~Feature} and a `{number}`
  16128. * representing the view's resolution. The function should return a
  16129. * {@link module:ol/style/Style~Style} or an array of them. This way e.g. a
  16130. * vector layer can be styled. If the function returns `undefined`, the
  16131. * feature will not be rendered.
  16132. *
  16133. * @typedef {function(import("../Feature.js").FeatureLike, number):(Style|Array<Style>|void)} StyleFunction
  16134. */
  16135. /**
  16136. * A {@link Style}, an array of {@link Style}, or a {@link StyleFunction}.
  16137. * @typedef {Style|Array<Style>|StyleFunction} StyleLike
  16138. */
  16139. /**
  16140. * A function that takes an {@link module:ol/Feature~Feature} as argument and returns an
  16141. * {@link module:ol/geom/Geometry~Geometry} that will be rendered and styled for the feature.
  16142. *
  16143. * @typedef {function(import("../Feature.js").FeatureLike):
  16144. * (import("../geom/Geometry.js").default|import("../render/Feature.js").default|undefined)} GeometryFunction
  16145. */
  16146. /**
  16147. * Custom renderer function. Takes two arguments:
  16148. *
  16149. * 1. The pixel coordinates of the geometry in GeoJSON notation.
  16150. * 2. The {@link module:ol/render~State} of the layer renderer.
  16151. *
  16152. * @typedef {function((import("../coordinate.js").Coordinate|Array<import("../coordinate.js").Coordinate>|Array<Array<import("../coordinate.js").Coordinate>>),import("../render.js").State): void} RenderFunction
  16153. */
  16154. /**
  16155. * @typedef {Object} Options
  16156. * @property {string|import("../geom/Geometry.js").default|GeometryFunction} [geometry] Feature property or geometry
  16157. * or function returning a geometry to render for this style.
  16158. * @property {import("./Fill.js").default} [fill] Fill style.
  16159. * @property {import("./Image.js").default} [image] Image style.
  16160. * @property {RenderFunction} [renderer] Custom renderer. When configured, `fill`, `stroke` and `image` will be
  16161. * ignored, and the provided function will be called with each render frame for each geometry.
  16162. * @property {RenderFunction} [hitDetectionRenderer] Custom renderer for hit detection. If provided will be used
  16163. * in hit detection rendering.
  16164. * @property {import("./Stroke.js").default} [stroke] Stroke style.
  16165. * @property {import("./Text.js").default} [text] Text style.
  16166. * @property {number} [zIndex] Z index.
  16167. */
  16168. /**
  16169. * @classdesc
  16170. * Container for vector feature rendering styles. Any changes made to the style
  16171. * or its children through `set*()` methods will not take effect until the
  16172. * feature or layer that uses the style is re-rendered.
  16173. *
  16174. * ## Feature styles
  16175. *
  16176. * If no style is defined, the following default style is used:
  16177. * ```js
  16178. * import {Circle, Fill, Stroke, Style} from 'ol/style';
  16179. *
  16180. * const fill = new Fill({
  16181. * color: 'rgba(255,255,255,0.4)',
  16182. * });
  16183. * const stroke = new Stroke({
  16184. * color: '#3399CC',
  16185. * width: 1.25,
  16186. * });
  16187. * const styles = [
  16188. * new Style({
  16189. * image: new Circle({
  16190. * fill: fill,
  16191. * stroke: stroke,
  16192. * radius: 5,
  16193. * }),
  16194. * fill: fill,
  16195. * stroke: stroke,
  16196. * }),
  16197. * ];
  16198. * ```
  16199. *
  16200. * A separate editing style has the following defaults:
  16201. * ```js
  16202. * import {Circle, Fill, Stroke, Style} from 'ol/style';
  16203. *
  16204. * const styles = {};
  16205. * const white = [255, 255, 255, 1];
  16206. * const blue = [0, 153, 255, 1];
  16207. * const width = 3;
  16208. * styles['Polygon'] = [
  16209. * new Style({
  16210. * fill: new Fill({
  16211. * color: [255, 255, 255, 0.5],
  16212. * }),
  16213. * }),
  16214. * ];
  16215. * styles['MultiPolygon'] =
  16216. * styles['Polygon'];
  16217. * styles['LineString'] = [
  16218. * new Style({
  16219. * stroke: new Stroke({
  16220. * color: white,
  16221. * width: width + 2,
  16222. * }),
  16223. * }),
  16224. * new Style({
  16225. * stroke: new Stroke({
  16226. * color: blue,
  16227. * width: width,
  16228. * }),
  16229. * }),
  16230. * ];
  16231. * styles['MultiLineString'] = styles['LineString'];
  16232. *
  16233. * styles['Circle'] = styles['Polygon'].concat(
  16234. * styles['LineString']
  16235. * );
  16236. *
  16237. * styles['Point'] = [
  16238. * new Style({
  16239. * image: new Circle({
  16240. * radius: width * 2,
  16241. * fill: new Fill({
  16242. * color: blue,
  16243. * }),
  16244. * stroke: new Stroke({
  16245. * color: white,
  16246. * width: width / 2,
  16247. * }),
  16248. * }),
  16249. * zIndex: Infinity,
  16250. * }),
  16251. * ];
  16252. * styles['MultiPoint'] =
  16253. * styles['Point'];
  16254. * styles['GeometryCollection'] =
  16255. * styles['Polygon'].concat(
  16256. * styles['LineString'],
  16257. * styles['Point']
  16258. * );
  16259. * ```
  16260. *
  16261. * @api
  16262. */
  16263. var Style = /** @class */ (function () {
  16264. /**
  16265. * @param {Options} [opt_options] Style options.
  16266. */
  16267. function Style(opt_options) {
  16268. var options = opt_options || {};
  16269. /**
  16270. * @private
  16271. * @type {string|import("../geom/Geometry.js").default|GeometryFunction}
  16272. */
  16273. this.geometry_ = null;
  16274. /**
  16275. * @private
  16276. * @type {!GeometryFunction}
  16277. */
  16278. this.geometryFunction_ = defaultGeometryFunction;
  16279. if (options.geometry !== undefined) {
  16280. this.setGeometry(options.geometry);
  16281. }
  16282. /**
  16283. * @private
  16284. * @type {import("./Fill.js").default}
  16285. */
  16286. this.fill_ = options.fill !== undefined ? options.fill : null;
  16287. /**
  16288. * @private
  16289. * @type {import("./Image.js").default}
  16290. */
  16291. this.image_ = options.image !== undefined ? options.image : null;
  16292. /**
  16293. * @private
  16294. * @type {RenderFunction|null}
  16295. */
  16296. this.renderer_ = options.renderer !== undefined ? options.renderer : null;
  16297. /**
  16298. * @private
  16299. * @type {RenderFunction|null}
  16300. */
  16301. this.hitDetectionRenderer_ =
  16302. options.hitDetectionRenderer !== undefined
  16303. ? options.hitDetectionRenderer
  16304. : null;
  16305. /**
  16306. * @private
  16307. * @type {import("./Stroke.js").default}
  16308. */
  16309. this.stroke_ = options.stroke !== undefined ? options.stroke : null;
  16310. /**
  16311. * @private
  16312. * @type {import("./Text.js").default}
  16313. */
  16314. this.text_ = options.text !== undefined ? options.text : null;
  16315. /**
  16316. * @private
  16317. * @type {number|undefined}
  16318. */
  16319. this.zIndex_ = options.zIndex;
  16320. }
  16321. /**
  16322. * Clones the style.
  16323. * @return {Style} The cloned style.
  16324. * @api
  16325. */
  16326. Style.prototype.clone = function () {
  16327. var geometry = this.getGeometry();
  16328. if (geometry && typeof geometry === 'object') {
  16329. geometry = /** @type {import("../geom/Geometry.js").default} */ (geometry).clone();
  16330. }
  16331. return new Style({
  16332. geometry: geometry,
  16333. fill: this.getFill() ? this.getFill().clone() : undefined,
  16334. image: this.getImage() ? this.getImage().clone() : undefined,
  16335. renderer: this.getRenderer(),
  16336. stroke: this.getStroke() ? this.getStroke().clone() : undefined,
  16337. text: this.getText() ? this.getText().clone() : undefined,
  16338. zIndex: this.getZIndex(),
  16339. });
  16340. };
  16341. /**
  16342. * Get the custom renderer function that was configured with
  16343. * {@link #setRenderer} or the `renderer` constructor option.
  16344. * @return {RenderFunction|null} Custom renderer function.
  16345. * @api
  16346. */
  16347. Style.prototype.getRenderer = function () {
  16348. return this.renderer_;
  16349. };
  16350. /**
  16351. * Sets a custom renderer function for this style. When set, `fill`, `stroke`
  16352. * and `image` options of the style will be ignored.
  16353. * @param {RenderFunction|null} renderer Custom renderer function.
  16354. * @api
  16355. */
  16356. Style.prototype.setRenderer = function (renderer) {
  16357. this.renderer_ = renderer;
  16358. };
  16359. /**
  16360. * Sets a custom renderer function for this style used
  16361. * in hit detection.
  16362. * @param {RenderFunction|null} renderer Custom renderer function.
  16363. * @api
  16364. */
  16365. Style.prototype.setHitDetectionRenderer = function (renderer) {
  16366. this.hitDetectionRenderer_ = renderer;
  16367. };
  16368. /**
  16369. * Get the custom renderer function that was configured with
  16370. * {@link #setHitDetectionRenderer} or the `hitDetectionRenderer` constructor option.
  16371. * @return {RenderFunction|null} Custom renderer function.
  16372. * @api
  16373. */
  16374. Style.prototype.getHitDetectionRenderer = function () {
  16375. return this.hitDetectionRenderer_;
  16376. };
  16377. /**
  16378. * Get the geometry to be rendered.
  16379. * @return {string|import("../geom/Geometry.js").default|GeometryFunction}
  16380. * Feature property or geometry or function that returns the geometry that will
  16381. * be rendered with this style.
  16382. * @api
  16383. */
  16384. Style.prototype.getGeometry = function () {
  16385. return this.geometry_;
  16386. };
  16387. /**
  16388. * Get the function used to generate a geometry for rendering.
  16389. * @return {!GeometryFunction} Function that is called with a feature
  16390. * and returns the geometry to render instead of the feature's geometry.
  16391. * @api
  16392. */
  16393. Style.prototype.getGeometryFunction = function () {
  16394. return this.geometryFunction_;
  16395. };
  16396. /**
  16397. * Get the fill style.
  16398. * @return {import("./Fill.js").default} Fill style.
  16399. * @api
  16400. */
  16401. Style.prototype.getFill = function () {
  16402. return this.fill_;
  16403. };
  16404. /**
  16405. * Set the fill style.
  16406. * @param {import("./Fill.js").default} fill Fill style.
  16407. * @api
  16408. */
  16409. Style.prototype.setFill = function (fill) {
  16410. this.fill_ = fill;
  16411. };
  16412. /**
  16413. * Get the image style.
  16414. * @return {import("./Image.js").default} Image style.
  16415. * @api
  16416. */
  16417. Style.prototype.getImage = function () {
  16418. return this.image_;
  16419. };
  16420. /**
  16421. * Set the image style.
  16422. * @param {import("./Image.js").default} image Image style.
  16423. * @api
  16424. */
  16425. Style.prototype.setImage = function (image) {
  16426. this.image_ = image;
  16427. };
  16428. /**
  16429. * Get the stroke style.
  16430. * @return {import("./Stroke.js").default} Stroke style.
  16431. * @api
  16432. */
  16433. Style.prototype.getStroke = function () {
  16434. return this.stroke_;
  16435. };
  16436. /**
  16437. * Set the stroke style.
  16438. * @param {import("./Stroke.js").default} stroke Stroke style.
  16439. * @api
  16440. */
  16441. Style.prototype.setStroke = function (stroke) {
  16442. this.stroke_ = stroke;
  16443. };
  16444. /**
  16445. * Get the text style.
  16446. * @return {import("./Text.js").default} Text style.
  16447. * @api
  16448. */
  16449. Style.prototype.getText = function () {
  16450. return this.text_;
  16451. };
  16452. /**
  16453. * Set the text style.
  16454. * @param {import("./Text.js").default} text Text style.
  16455. * @api
  16456. */
  16457. Style.prototype.setText = function (text) {
  16458. this.text_ = text;
  16459. };
  16460. /**
  16461. * Get the z-index for the style.
  16462. * @return {number|undefined} ZIndex.
  16463. * @api
  16464. */
  16465. Style.prototype.getZIndex = function () {
  16466. return this.zIndex_;
  16467. };
  16468. /**
  16469. * Set a geometry that is rendered instead of the feature's geometry.
  16470. *
  16471. * @param {string|import("../geom/Geometry.js").default|GeometryFunction} geometry
  16472. * Feature property or geometry or function returning a geometry to render
  16473. * for this style.
  16474. * @api
  16475. */
  16476. Style.prototype.setGeometry = function (geometry) {
  16477. if (typeof geometry === 'function') {
  16478. this.geometryFunction_ = geometry;
  16479. }
  16480. else if (typeof geometry === 'string') {
  16481. this.geometryFunction_ = function (feature) {
  16482. return /** @type {import("../geom/Geometry.js").default} */ (feature.get(geometry));
  16483. };
  16484. }
  16485. else if (!geometry) {
  16486. this.geometryFunction_ = defaultGeometryFunction;
  16487. }
  16488. else if (geometry !== undefined) {
  16489. this.geometryFunction_ = function () {
  16490. return /** @type {import("../geom/Geometry.js").default} */ (geometry);
  16491. };
  16492. }
  16493. this.geometry_ = geometry;
  16494. };
  16495. /**
  16496. * Set the z-index.
  16497. *
  16498. * @param {number|undefined} zIndex ZIndex.
  16499. * @api
  16500. */
  16501. Style.prototype.setZIndex = function (zIndex) {
  16502. this.zIndex_ = zIndex;
  16503. };
  16504. return Style;
  16505. }());
  16506. /**
  16507. * Convert the provided object into a style function. Functions passed through
  16508. * unchanged. Arrays of Style or single style objects wrapped in a
  16509. * new style function.
  16510. * @param {StyleFunction|Array<Style>|Style} obj
  16511. * A style function, a single style, or an array of styles.
  16512. * @return {StyleFunction} A style function.
  16513. */
  16514. function toFunction(obj) {
  16515. var styleFunction;
  16516. if (typeof obj === 'function') {
  16517. styleFunction = obj;
  16518. }
  16519. else {
  16520. /**
  16521. * @type {Array<Style>}
  16522. */
  16523. var styles_1;
  16524. if (Array.isArray(obj)) {
  16525. styles_1 = obj;
  16526. }
  16527. else {
  16528. asserts_assert(typeof ( /** @type {?} */(obj).getZIndex) === 'function', 41); // Expected an `Style` or an array of `Style`
  16529. var style = /** @type {Style} */ (obj);
  16530. styles_1 = [style];
  16531. }
  16532. styleFunction = function () {
  16533. return styles_1;
  16534. };
  16535. }
  16536. return styleFunction;
  16537. }
  16538. /**
  16539. * @type {Array<Style>|null}
  16540. */
  16541. var defaultStyles = null;
  16542. /**
  16543. * @param {import("../Feature.js").FeatureLike} feature Feature.
  16544. * @param {number} resolution Resolution.
  16545. * @return {Array<Style>} Style.
  16546. */
  16547. function createDefaultStyle(feature, resolution) {
  16548. // We don't use an immediately-invoked function
  16549. // and a closure so we don't get an error at script evaluation time in
  16550. // browsers that do not support Canvas. (import("./Circle.js").CircleStyle does
  16551. // canvas.getContext('2d') at construction time, which will cause an.error
  16552. // in such browsers.)
  16553. if (!defaultStyles) {
  16554. var fill = new style_Fill({
  16555. color: 'rgba(255,255,255,0.4)',
  16556. });
  16557. var stroke = new style_Stroke({
  16558. color: '#3399CC',
  16559. width: 1.25,
  16560. });
  16561. defaultStyles = [
  16562. new Style({
  16563. image: new Circle({
  16564. fill: fill,
  16565. stroke: stroke,
  16566. radius: 5,
  16567. }),
  16568. fill: fill,
  16569. stroke: stroke,
  16570. }),
  16571. ];
  16572. }
  16573. return defaultStyles;
  16574. }
  16575. /**
  16576. * Default styles for editing features.
  16577. * @return {Object<import("../geom/Geometry.js").Type, Array<Style>>} Styles
  16578. */
  16579. function createEditingStyle() {
  16580. /** @type {Object<import("../geom/Geometry.js").Type, Array<Style>>} */
  16581. var styles = {};
  16582. var white = [255, 255, 255, 1];
  16583. var blue = [0, 153, 255, 1];
  16584. var width = 3;
  16585. styles['Polygon'] = [
  16586. new Style({
  16587. fill: new Fill({
  16588. color: [255, 255, 255, 0.5],
  16589. }),
  16590. }),
  16591. ];
  16592. styles['MultiPolygon'] = styles['Polygon'];
  16593. styles['LineString'] = [
  16594. new Style({
  16595. stroke: new Stroke({
  16596. color: white,
  16597. width: width + 2,
  16598. }),
  16599. }),
  16600. new Style({
  16601. stroke: new Stroke({
  16602. color: blue,
  16603. width: width,
  16604. }),
  16605. }),
  16606. ];
  16607. styles['MultiLineString'] = styles['LineString'];
  16608. styles['Circle'] = styles['Polygon'].concat(styles['LineString']);
  16609. styles['Point'] = [
  16610. new Style({
  16611. image: new CircleStyle({
  16612. radius: width * 2,
  16613. fill: new Fill({
  16614. color: blue,
  16615. }),
  16616. stroke: new Stroke({
  16617. color: white,
  16618. width: width / 2,
  16619. }),
  16620. }),
  16621. zIndex: Infinity,
  16622. }),
  16623. ];
  16624. styles['MultiPoint'] = styles['Point'];
  16625. styles['GeometryCollection'] = styles['Polygon'].concat(styles['LineString'], styles['Point']);
  16626. return styles;
  16627. }
  16628. /**
  16629. * Function that is called with a feature and returns its default geometry.
  16630. * @param {import("../Feature.js").FeatureLike} feature Feature to get the geometry for.
  16631. * @return {import("../geom/Geometry.js").default|import("../render/Feature.js").default|undefined} Geometry to render.
  16632. */
  16633. function defaultGeometryFunction(feature) {
  16634. return feature.getGeometry();
  16635. }
  16636. /* harmony default export */ var style_Style = (Style);
  16637. //# sourceMappingURL=Style.js.map
  16638. ;// ./node_modules/ol/layer/BaseVector.js
  16639. var BaseVector_extends = (undefined && undefined.__extends) || (function () {
  16640. var extendStatics = function (d, b) {
  16641. extendStatics = Object.setPrototypeOf ||
  16642. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  16643. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  16644. return extendStatics(d, b);
  16645. };
  16646. return function (d, b) {
  16647. if (typeof b !== "function" && b !== null)
  16648. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  16649. extendStatics(d, b);
  16650. function __() { this.constructor = d; }
  16651. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16652. };
  16653. })();
  16654. /**
  16655. * @module ol/layer/BaseVector
  16656. */
  16657. /**
  16658. * @template {import("../source/Vector.js").default|import("../source/VectorTile.js").default} VectorSourceType
  16659. * @typedef {Object} Options
  16660. * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
  16661. * @property {number} [opacity=1] Opacity (0, 1).
  16662. * @property {boolean} [visible=true] Visibility.
  16663. * @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
  16664. * rendered outside of this extent.
  16665. * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
  16666. * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
  16667. * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
  16668. * method was used.
  16669. * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
  16670. * visible.
  16671. * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
  16672. * be visible.
  16673. * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
  16674. * visible.
  16675. * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
  16676. * be visible.
  16677. * @property {import("../render.js").OrderFunction} [renderOrder] Render order. Function to be used when sorting
  16678. * features before rendering. By default features are drawn in the order that they are created. Use
  16679. * `null` to avoid the sort, but get an undefined draw order.
  16680. * @property {number} [renderBuffer=100] The buffer in pixels around the viewport extent used by the
  16681. * renderer when getting features from the vector source for the rendering or hit-detection.
  16682. * Recommended value: the size of the largest symbol, line width or label.
  16683. * @property {VectorSourceType} [source] Source.
  16684. * @property {import("../PluggableMap.js").default} [map] Sets the layer as overlay on a map. The map will not manage
  16685. * this layer in its layers collection, and the layer will be rendered on top. This is useful for
  16686. * temporary layers. The standard way to add a layer to a map and have it managed by the map is to
  16687. * use {@link import("../PluggableMap.js").default#addLayer map.addLayer()}.
  16688. * @property {boolean} [declutter=false] Declutter images and text. Decluttering is applied to all
  16689. * image and text styles of all Vector and VectorTile layers that have set this to `true`. The priority
  16690. * is defined by the z-index of the layer, the `zIndex` of the style and the render order of features.
  16691. * Higher z-index means higher priority. Within the same z-index, a feature rendered before another has
  16692. * higher priority.
  16693. *
  16694. * As an optimization decluttered features from layers with the same `className` are rendered above
  16695. * the fill and stroke styles of all of those layers regardless of z-index. To opt out of this
  16696. * behavior and place declutterd features with their own layer configure the layer with a `className`
  16697. * other than `ol-layer`.
  16698. * @property {import("../style/Style.js").StyleLike|null} [style] Layer style. When set to `null`, only
  16699. * features that have their own style will be rendered. See {@link module:ol/style/Style~Style} for the default style
  16700. * which will be used if this is not set.
  16701. * @property {import("./Base.js").BackgroundColor} [background] Background color for the layer. If not specified, no background
  16702. * will be rendered.
  16703. * @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will
  16704. * be recreated during animations. This means that no vectors will be shown clipped, but the
  16705. * setting will have a performance impact for large amounts of vector data. When set to `false`,
  16706. * batches will be recreated when no animation is active.
  16707. * @property {boolean} [updateWhileInteracting=false] When set to `true`, feature batches will
  16708. * be recreated during interactions. See also `updateWhileAnimating`.
  16709. * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
  16710. */
  16711. /**
  16712. * @enum {string}
  16713. * @private
  16714. */
  16715. var BaseVector_Property = {
  16716. RENDER_ORDER: 'renderOrder',
  16717. };
  16718. /**
  16719. * @classdesc
  16720. * Vector data that is rendered client-side.
  16721. * Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
  16722. * property on the layer object; for example, setting `title: 'My Title'` in the
  16723. * options means that `title` is observable, and has get/set accessors.
  16724. *
  16725. * @template {import("../source/Vector.js").default|import("../source/VectorTile.js").default} VectorSourceType
  16726. * @template {import("../renderer/canvas/VectorLayer.js").default|import("../renderer/canvas/VectorTileLayer.js").default|import("../renderer/canvas/VectorImageLayer.js").default|import("../renderer/webgl/PointsLayer.js").default} RendererType
  16727. * @extends {Layer<VectorSourceType, RendererType>}
  16728. * @api
  16729. */
  16730. var BaseVectorLayer = /** @class */ (function (_super) {
  16731. BaseVector_extends(BaseVectorLayer, _super);
  16732. /**
  16733. * @param {Options<VectorSourceType>} [opt_options] Options.
  16734. */
  16735. function BaseVectorLayer(opt_options) {
  16736. var _this = this;
  16737. var options = opt_options ? opt_options : {};
  16738. var baseOptions = obj_assign({}, options);
  16739. delete baseOptions.style;
  16740. delete baseOptions.renderBuffer;
  16741. delete baseOptions.updateWhileAnimating;
  16742. delete baseOptions.updateWhileInteracting;
  16743. _this = _super.call(this, baseOptions) || this;
  16744. /**
  16745. * @private
  16746. * @type {boolean}
  16747. */
  16748. _this.declutter_ =
  16749. options.declutter !== undefined ? options.declutter : false;
  16750. /**
  16751. * @type {number}
  16752. * @private
  16753. */
  16754. _this.renderBuffer_ =
  16755. options.renderBuffer !== undefined ? options.renderBuffer : 100;
  16756. /**
  16757. * User provided style.
  16758. * @type {import("../style/Style.js").StyleLike}
  16759. * @private
  16760. */
  16761. _this.style_ = null;
  16762. /**
  16763. * Style function for use within the library.
  16764. * @type {import("../style/Style.js").StyleFunction|undefined}
  16765. * @private
  16766. */
  16767. _this.styleFunction_ = undefined;
  16768. _this.setStyle(options.style);
  16769. /**
  16770. * @type {boolean}
  16771. * @private
  16772. */
  16773. _this.updateWhileAnimating_ =
  16774. options.updateWhileAnimating !== undefined
  16775. ? options.updateWhileAnimating
  16776. : false;
  16777. /**
  16778. * @type {boolean}
  16779. * @private
  16780. */
  16781. _this.updateWhileInteracting_ =
  16782. options.updateWhileInteracting !== undefined
  16783. ? options.updateWhileInteracting
  16784. : false;
  16785. return _this;
  16786. }
  16787. /**
  16788. * @return {boolean} Declutter.
  16789. */
  16790. BaseVectorLayer.prototype.getDeclutter = function () {
  16791. return this.declutter_;
  16792. };
  16793. /**
  16794. * Get the topmost feature that intersects the given pixel on the viewport. Returns a promise
  16795. * that resolves with an array of features. The array will either contain the topmost feature
  16796. * when a hit was detected, or it will be empty.
  16797. *
  16798. * The hit detection algorithm used for this method is optimized for performance, but is less
  16799. * accurate than the one used in {@link import("../PluggableMap.js").default#getFeaturesAtPixel}: Text
  16800. * is not considered, and icons are only represented by their bounding box instead of the exact
  16801. * image.
  16802. *
  16803. * @param {import("../pixel.js").Pixel} pixel Pixel.
  16804. * @return {Promise<Array<import("../Feature").default>>} Promise that resolves with an array of features.
  16805. * @api
  16806. */
  16807. BaseVectorLayer.prototype.getFeatures = function (pixel) {
  16808. return _super.prototype.getFeatures.call(this, pixel);
  16809. };
  16810. /**
  16811. * @return {number|undefined} Render buffer.
  16812. */
  16813. BaseVectorLayer.prototype.getRenderBuffer = function () {
  16814. return this.renderBuffer_;
  16815. };
  16816. /**
  16817. * @return {function(import("../Feature.js").default, import("../Feature.js").default): number|null|undefined} Render
  16818. * order.
  16819. */
  16820. BaseVectorLayer.prototype.getRenderOrder = function () {
  16821. return /** @type {import("../render.js").OrderFunction|null|undefined} */ (this.get(BaseVector_Property.RENDER_ORDER));
  16822. };
  16823. /**
  16824. * Get the style for features. This returns whatever was passed to the `style`
  16825. * option at construction or to the `setStyle` method.
  16826. * @return {import("../style/Style.js").StyleLike|null|undefined} Layer style.
  16827. * @api
  16828. */
  16829. BaseVectorLayer.prototype.getStyle = function () {
  16830. return this.style_;
  16831. };
  16832. /**
  16833. * Get the style function.
  16834. * @return {import("../style/Style.js").StyleFunction|undefined} Layer style function.
  16835. * @api
  16836. */
  16837. BaseVectorLayer.prototype.getStyleFunction = function () {
  16838. return this.styleFunction_;
  16839. };
  16840. /**
  16841. * @return {boolean} Whether the rendered layer should be updated while
  16842. * animating.
  16843. */
  16844. BaseVectorLayer.prototype.getUpdateWhileAnimating = function () {
  16845. return this.updateWhileAnimating_;
  16846. };
  16847. /**
  16848. * @return {boolean} Whether the rendered layer should be updated while
  16849. * interacting.
  16850. */
  16851. BaseVectorLayer.prototype.getUpdateWhileInteracting = function () {
  16852. return this.updateWhileInteracting_;
  16853. };
  16854. /**
  16855. * Render declutter items for this layer
  16856. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  16857. */
  16858. BaseVectorLayer.prototype.renderDeclutter = function (frameState) {
  16859. if (!frameState.declutterTree) {
  16860. frameState.declutterTree = new rbush_min(9);
  16861. }
  16862. /** @type {*} */ (this.getRenderer()).renderDeclutter(frameState);
  16863. };
  16864. /**
  16865. * @param {import("../render.js").OrderFunction|null|undefined} renderOrder
  16866. * Render order.
  16867. */
  16868. BaseVectorLayer.prototype.setRenderOrder = function (renderOrder) {
  16869. this.set(BaseVector_Property.RENDER_ORDER, renderOrder);
  16870. };
  16871. /**
  16872. * Set the style for features. This can be a single style object, an array
  16873. * of styles, or a function that takes a feature and resolution and returns
  16874. * an array of styles. If set to `null`, the layer has no style (a `null` style),
  16875. * so only features that have their own styles will be rendered in the layer. Call
  16876. * `setStyle()` without arguments to reset to the default style. See
  16877. * {@link module:ol/style/Style~Style} for information on the default style.
  16878. * @param {import("../style/Style.js").StyleLike|null} [opt_style] Layer style.
  16879. * @api
  16880. */
  16881. BaseVectorLayer.prototype.setStyle = function (opt_style) {
  16882. this.style_ = opt_style !== undefined ? opt_style : createDefaultStyle;
  16883. this.styleFunction_ =
  16884. opt_style === null ? undefined : toFunction(this.style_);
  16885. this.changed();
  16886. };
  16887. return BaseVectorLayer;
  16888. }(layer_Layer));
  16889. /* harmony default export */ var BaseVector = (BaseVectorLayer);
  16890. //# sourceMappingURL=BaseVector.js.map
  16891. ;// ./node_modules/ol/render/canvas/Instruction.js
  16892. /**
  16893. * @module ol/render/canvas/Instruction
  16894. */
  16895. /**
  16896. * @enum {number}
  16897. */
  16898. var Instruction = {
  16899. BEGIN_GEOMETRY: 0,
  16900. BEGIN_PATH: 1,
  16901. CIRCLE: 2,
  16902. CLOSE_PATH: 3,
  16903. CUSTOM: 4,
  16904. DRAW_CHARS: 5,
  16905. DRAW_IMAGE: 6,
  16906. END_GEOMETRY: 7,
  16907. FILL: 8,
  16908. MOVE_TO_LINE_TO: 9,
  16909. SET_FILL_STYLE: 10,
  16910. SET_STROKE_STYLE: 11,
  16911. STROKE: 12,
  16912. };
  16913. /**
  16914. * @type {Array<Instruction>}
  16915. */
  16916. var fillInstruction = [Instruction.FILL];
  16917. /**
  16918. * @type {Array<Instruction>}
  16919. */
  16920. var strokeInstruction = [Instruction.STROKE];
  16921. /**
  16922. * @type {Array<Instruction>}
  16923. */
  16924. var beginPathInstruction = [Instruction.BEGIN_PATH];
  16925. /**
  16926. * @type {Array<Instruction>}
  16927. */
  16928. var closePathInstruction = [Instruction.CLOSE_PATH];
  16929. /* harmony default export */ var canvas_Instruction = (Instruction);
  16930. //# sourceMappingURL=Instruction.js.map
  16931. ;// ./node_modules/ol/render/VectorContext.js
  16932. /**
  16933. * @module ol/render/VectorContext
  16934. */
  16935. /**
  16936. * @classdesc
  16937. * Context for drawing geometries. A vector context is available on render
  16938. * events and does not need to be constructed directly.
  16939. * @api
  16940. */
  16941. var VectorContext = /** @class */ (function () {
  16942. function VectorContext() {
  16943. }
  16944. /**
  16945. * Render a geometry with a custom renderer.
  16946. *
  16947. * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
  16948. * @param {import("../Feature.js").FeatureLike} feature Feature.
  16949. * @param {Function} renderer Renderer.
  16950. * @param {Function} hitDetectionRenderer Renderer.
  16951. */
  16952. VectorContext.prototype.drawCustom = function (geometry, feature, renderer, hitDetectionRenderer) { };
  16953. /**
  16954. * Render a geometry.
  16955. *
  16956. * @param {import("../geom/Geometry.js").default} geometry The geometry to render.
  16957. */
  16958. VectorContext.prototype.drawGeometry = function (geometry) { };
  16959. /**
  16960. * Set the rendering style.
  16961. *
  16962. * @param {import("../style/Style.js").default} style The rendering style.
  16963. */
  16964. VectorContext.prototype.setStyle = function (style) { };
  16965. /**
  16966. * @param {import("../geom/Circle.js").default} circleGeometry Circle geometry.
  16967. * @param {import("../Feature.js").default} feature Feature.
  16968. */
  16969. VectorContext.prototype.drawCircle = function (circleGeometry, feature) { };
  16970. /**
  16971. * @param {import("../Feature.js").default} feature Feature.
  16972. * @param {import("../style/Style.js").default} style Style.
  16973. */
  16974. VectorContext.prototype.drawFeature = function (feature, style) { };
  16975. /**
  16976. * @param {import("../geom/GeometryCollection.js").default} geometryCollectionGeometry Geometry collection.
  16977. * @param {import("../Feature.js").default} feature Feature.
  16978. */
  16979. VectorContext.prototype.drawGeometryCollection = function (geometryCollectionGeometry, feature) { };
  16980. /**
  16981. * @param {import("../geom/LineString.js").default|import("./Feature.js").default} lineStringGeometry Line string geometry.
  16982. * @param {import("../Feature.js").FeatureLike} feature Feature.
  16983. */
  16984. VectorContext.prototype.drawLineString = function (lineStringGeometry, feature) { };
  16985. /**
  16986. * @param {import("../geom/MultiLineString.js").default|import("./Feature.js").default} multiLineStringGeometry MultiLineString geometry.
  16987. * @param {import("../Feature.js").FeatureLike} feature Feature.
  16988. */
  16989. VectorContext.prototype.drawMultiLineString = function (multiLineStringGeometry, feature) { };
  16990. /**
  16991. * @param {import("../geom/MultiPoint.js").default|import("./Feature.js").default} multiPointGeometry MultiPoint geometry.
  16992. * @param {import("../Feature.js").FeatureLike} feature Feature.
  16993. */
  16994. VectorContext.prototype.drawMultiPoint = function (multiPointGeometry, feature) { };
  16995. /**
  16996. * @param {import("../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry.
  16997. * @param {import("../Feature.js").FeatureLike} feature Feature.
  16998. */
  16999. VectorContext.prototype.drawMultiPolygon = function (multiPolygonGeometry, feature) { };
  17000. /**
  17001. * @param {import("../geom/Point.js").default|import("./Feature.js").default} pointGeometry Point geometry.
  17002. * @param {import("../Feature.js").FeatureLike} feature Feature.
  17003. */
  17004. VectorContext.prototype.drawPoint = function (pointGeometry, feature) { };
  17005. /**
  17006. * @param {import("../geom/Polygon.js").default|import("./Feature.js").default} polygonGeometry Polygon geometry.
  17007. * @param {import("../Feature.js").FeatureLike} feature Feature.
  17008. */
  17009. VectorContext.prototype.drawPolygon = function (polygonGeometry, feature) { };
  17010. /**
  17011. * @param {import("../geom/SimpleGeometry.js").default|import("./Feature.js").default} geometry Geometry.
  17012. * @param {import("../Feature.js").FeatureLike} feature Feature.
  17013. */
  17014. VectorContext.prototype.drawText = function (geometry, feature) { };
  17015. /**
  17016. * @param {import("../style/Fill.js").default} fillStyle Fill style.
  17017. * @param {import("../style/Stroke.js").default} strokeStyle Stroke style.
  17018. */
  17019. VectorContext.prototype.setFillStrokeStyle = function (fillStyle, strokeStyle) { };
  17020. /**
  17021. * @param {import("../style/Image.js").default} imageStyle Image style.
  17022. * @param {import("../render/canvas.js").DeclutterImageWithText} [opt_declutterImageWithText] Shared data for combined decluttering with a text style.
  17023. */
  17024. VectorContext.prototype.setImageStyle = function (imageStyle, opt_declutterImageWithText) { };
  17025. /**
  17026. * @param {import("../style/Text.js").default} textStyle Text style.
  17027. * @param {import("../render/canvas.js").DeclutterImageWithText} [opt_declutterImageWithText] Shared data for combined decluttering with an image style.
  17028. */
  17029. VectorContext.prototype.setTextStyle = function (textStyle, opt_declutterImageWithText) { };
  17030. return VectorContext;
  17031. }());
  17032. /* harmony default export */ var render_VectorContext = (VectorContext);
  17033. //# sourceMappingURL=VectorContext.js.map
  17034. ;// ./node_modules/ol/render/canvas/Builder.js
  17035. var Builder_extends = (undefined && undefined.__extends) || (function () {
  17036. var extendStatics = function (d, b) {
  17037. extendStatics = Object.setPrototypeOf ||
  17038. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17039. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  17040. return extendStatics(d, b);
  17041. };
  17042. return function (d, b) {
  17043. if (typeof b !== "function" && b !== null)
  17044. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  17045. extendStatics(d, b);
  17046. function __() { this.constructor = d; }
  17047. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17048. };
  17049. })();
  17050. /**
  17051. * @module ol/render/canvas/Builder
  17052. */
  17053. var CanvasBuilder = /** @class */ (function (_super) {
  17054. Builder_extends(CanvasBuilder, _super);
  17055. /**
  17056. * @param {number} tolerance Tolerance.
  17057. * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
  17058. * @param {number} resolution Resolution.
  17059. * @param {number} pixelRatio Pixel ratio.
  17060. */
  17061. function CanvasBuilder(tolerance, maxExtent, resolution, pixelRatio) {
  17062. var _this = _super.call(this) || this;
  17063. /**
  17064. * @protected
  17065. * @type {number}
  17066. */
  17067. _this.tolerance = tolerance;
  17068. /**
  17069. * @protected
  17070. * @const
  17071. * @type {import("../../extent.js").Extent}
  17072. */
  17073. _this.maxExtent = maxExtent;
  17074. /**
  17075. * @protected
  17076. * @type {number}
  17077. */
  17078. _this.pixelRatio = pixelRatio;
  17079. /**
  17080. * @protected
  17081. * @type {number}
  17082. */
  17083. _this.maxLineWidth = 0;
  17084. /**
  17085. * @protected
  17086. * @const
  17087. * @type {number}
  17088. */
  17089. _this.resolution = resolution;
  17090. /**
  17091. * @private
  17092. * @type {Array<*>}
  17093. */
  17094. _this.beginGeometryInstruction1_ = null;
  17095. /**
  17096. * @private
  17097. * @type {Array<*>}
  17098. */
  17099. _this.beginGeometryInstruction2_ = null;
  17100. /**
  17101. * @private
  17102. * @type {import("../../extent.js").Extent}
  17103. */
  17104. _this.bufferedMaxExtent_ = null;
  17105. /**
  17106. * @protected
  17107. * @type {Array<*>}
  17108. */
  17109. _this.instructions = [];
  17110. /**
  17111. * @protected
  17112. * @type {Array<number>}
  17113. */
  17114. _this.coordinates = [];
  17115. /**
  17116. * @private
  17117. * @type {import("../../coordinate.js").Coordinate}
  17118. */
  17119. _this.tmpCoordinate_ = [];
  17120. /**
  17121. * @protected
  17122. * @type {Array<*>}
  17123. */
  17124. _this.hitDetectionInstructions = [];
  17125. /**
  17126. * @protected
  17127. * @type {import("../canvas.js").FillStrokeState}
  17128. */
  17129. _this.state = /** @type {import("../canvas.js").FillStrokeState} */ ({});
  17130. return _this;
  17131. }
  17132. /**
  17133. * @protected
  17134. * @param {Array<number>} dashArray Dash array.
  17135. * @return {Array<number>} Dash array with pixel ratio applied
  17136. */
  17137. CanvasBuilder.prototype.applyPixelRatio = function (dashArray) {
  17138. var pixelRatio = this.pixelRatio;
  17139. return pixelRatio == 1
  17140. ? dashArray
  17141. : dashArray.map(function (dash) {
  17142. return dash * pixelRatio;
  17143. });
  17144. };
  17145. /**
  17146. * @param {Array<number>} flatCoordinates Flat coordinates.
  17147. * @param {number} stride Stride.
  17148. * @protected
  17149. * @return {number} My end
  17150. */
  17151. CanvasBuilder.prototype.appendFlatPointCoordinates = function (flatCoordinates, stride) {
  17152. var extent = this.getBufferedMaxExtent();
  17153. var tmpCoord = this.tmpCoordinate_;
  17154. var coordinates = this.coordinates;
  17155. var myEnd = coordinates.length;
  17156. for (var i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
  17157. tmpCoord[0] = flatCoordinates[i];
  17158. tmpCoord[1] = flatCoordinates[i + 1];
  17159. if (containsCoordinate(extent, tmpCoord)) {
  17160. coordinates[myEnd++] = tmpCoord[0];
  17161. coordinates[myEnd++] = tmpCoord[1];
  17162. }
  17163. }
  17164. return myEnd;
  17165. };
  17166. /**
  17167. * @param {Array<number>} flatCoordinates Flat coordinates.
  17168. * @param {number} offset Offset.
  17169. * @param {number} end End.
  17170. * @param {number} stride Stride.
  17171. * @param {boolean} closed Last input coordinate equals first.
  17172. * @param {boolean} skipFirst Skip first coordinate.
  17173. * @protected
  17174. * @return {number} My end.
  17175. */
  17176. CanvasBuilder.prototype.appendFlatLineCoordinates = function (flatCoordinates, offset, end, stride, closed, skipFirst) {
  17177. var coordinates = this.coordinates;
  17178. var myEnd = coordinates.length;
  17179. var extent = this.getBufferedMaxExtent();
  17180. if (skipFirst) {
  17181. offset += stride;
  17182. }
  17183. var lastXCoord = flatCoordinates[offset];
  17184. var lastYCoord = flatCoordinates[offset + 1];
  17185. var nextCoord = this.tmpCoordinate_;
  17186. var skipped = true;
  17187. var i, lastRel, nextRel;
  17188. for (i = offset + stride; i < end; i += stride) {
  17189. nextCoord[0] = flatCoordinates[i];
  17190. nextCoord[1] = flatCoordinates[i + 1];
  17191. nextRel = coordinateRelationship(extent, nextCoord);
  17192. if (nextRel !== lastRel) {
  17193. if (skipped) {
  17194. coordinates[myEnd++] = lastXCoord;
  17195. coordinates[myEnd++] = lastYCoord;
  17196. skipped = false;
  17197. }
  17198. coordinates[myEnd++] = nextCoord[0];
  17199. coordinates[myEnd++] = nextCoord[1];
  17200. }
  17201. else if (nextRel === Relationship.INTERSECTING) {
  17202. coordinates[myEnd++] = nextCoord[0];
  17203. coordinates[myEnd++] = nextCoord[1];
  17204. skipped = false;
  17205. }
  17206. else {
  17207. skipped = true;
  17208. }
  17209. lastXCoord = nextCoord[0];
  17210. lastYCoord = nextCoord[1];
  17211. lastRel = nextRel;
  17212. }
  17213. // Last coordinate equals first or only one point to append:
  17214. if ((closed && skipped) || i === offset + stride) {
  17215. coordinates[myEnd++] = lastXCoord;
  17216. coordinates[myEnd++] = lastYCoord;
  17217. }
  17218. return myEnd;
  17219. };
  17220. /**
  17221. * @param {Array<number>} flatCoordinates Flat coordinates.
  17222. * @param {number} offset Offset.
  17223. * @param {Array<number>} ends Ends.
  17224. * @param {number} stride Stride.
  17225. * @param {Array<number>} builderEnds Builder ends.
  17226. * @return {number} Offset.
  17227. */
  17228. CanvasBuilder.prototype.drawCustomCoordinates_ = function (flatCoordinates, offset, ends, stride, builderEnds) {
  17229. for (var i = 0, ii = ends.length; i < ii; ++i) {
  17230. var end = ends[i];
  17231. var builderEnd = this.appendFlatLineCoordinates(flatCoordinates, offset, end, stride, false, false);
  17232. builderEnds.push(builderEnd);
  17233. offset = end;
  17234. }
  17235. return offset;
  17236. };
  17237. /**
  17238. * @param {import("../../geom/SimpleGeometry.js").default} geometry Geometry.
  17239. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17240. * @param {Function} renderer Renderer.
  17241. * @param {Function} hitDetectionRenderer Renderer.
  17242. */
  17243. CanvasBuilder.prototype.drawCustom = function (geometry, feature, renderer, hitDetectionRenderer) {
  17244. this.beginGeometry(geometry, feature);
  17245. var type = geometry.getType();
  17246. var stride = geometry.getStride();
  17247. var builderBegin = this.coordinates.length;
  17248. var flatCoordinates, builderEnd, builderEnds, builderEndss;
  17249. var offset;
  17250. switch (type) {
  17251. case 'MultiPolygon':
  17252. flatCoordinates =
  17253. /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry).getOrientedFlatCoordinates();
  17254. builderEndss = [];
  17255. var endss =
  17256. /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry).getEndss();
  17257. offset = 0;
  17258. for (var i = 0, ii = endss.length; i < ii; ++i) {
  17259. var myEnds = [];
  17260. offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
  17261. builderEndss.push(myEnds);
  17262. }
  17263. this.instructions.push([
  17264. canvas_Instruction.CUSTOM,
  17265. builderBegin,
  17266. builderEndss,
  17267. geometry,
  17268. renderer,
  17269. inflateMultiCoordinatesArray,
  17270. ]);
  17271. this.hitDetectionInstructions.push([
  17272. canvas_Instruction.CUSTOM,
  17273. builderBegin,
  17274. builderEndss,
  17275. geometry,
  17276. hitDetectionRenderer || renderer,
  17277. inflateMultiCoordinatesArray,
  17278. ]);
  17279. break;
  17280. case 'Polygon':
  17281. case 'MultiLineString':
  17282. builderEnds = [];
  17283. flatCoordinates =
  17284. type == 'Polygon'
  17285. ? /** @type {import("../../geom/Polygon.js").default} */ (geometry).getOrientedFlatCoordinates()
  17286. : geometry.getFlatCoordinates();
  17287. offset = this.drawCustomCoordinates_(flatCoordinates, 0,
  17288. /** @type {import("../../geom/Polygon.js").default|import("../../geom/MultiLineString.js").default} */ (geometry).getEnds(), stride, builderEnds);
  17289. this.instructions.push([
  17290. canvas_Instruction.CUSTOM,
  17291. builderBegin,
  17292. builderEnds,
  17293. geometry,
  17294. renderer,
  17295. inflateCoordinatesArray,
  17296. ]);
  17297. this.hitDetectionInstructions.push([
  17298. canvas_Instruction.CUSTOM,
  17299. builderBegin,
  17300. builderEnds,
  17301. geometry,
  17302. hitDetectionRenderer || renderer,
  17303. inflateCoordinatesArray,
  17304. ]);
  17305. break;
  17306. case 'LineString':
  17307. case 'Circle':
  17308. flatCoordinates = geometry.getFlatCoordinates();
  17309. builderEnd = this.appendFlatLineCoordinates(flatCoordinates, 0, flatCoordinates.length, stride, false, false);
  17310. this.instructions.push([
  17311. canvas_Instruction.CUSTOM,
  17312. builderBegin,
  17313. builderEnd,
  17314. geometry,
  17315. renderer,
  17316. inflateCoordinates,
  17317. ]);
  17318. this.hitDetectionInstructions.push([
  17319. canvas_Instruction.CUSTOM,
  17320. builderBegin,
  17321. builderEnd,
  17322. geometry,
  17323. hitDetectionRenderer || renderer,
  17324. inflateCoordinates,
  17325. ]);
  17326. break;
  17327. case 'MultiPoint':
  17328. flatCoordinates = geometry.getFlatCoordinates();
  17329. builderEnd = this.appendFlatPointCoordinates(flatCoordinates, stride);
  17330. if (builderEnd > builderBegin) {
  17331. this.instructions.push([
  17332. canvas_Instruction.CUSTOM,
  17333. builderBegin,
  17334. builderEnd,
  17335. geometry,
  17336. renderer,
  17337. inflateCoordinates,
  17338. ]);
  17339. this.hitDetectionInstructions.push([
  17340. canvas_Instruction.CUSTOM,
  17341. builderBegin,
  17342. builderEnd,
  17343. geometry,
  17344. hitDetectionRenderer || renderer,
  17345. inflateCoordinates,
  17346. ]);
  17347. }
  17348. break;
  17349. case 'Point':
  17350. flatCoordinates = geometry.getFlatCoordinates();
  17351. this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
  17352. builderEnd = this.coordinates.length;
  17353. this.instructions.push([
  17354. canvas_Instruction.CUSTOM,
  17355. builderBegin,
  17356. builderEnd,
  17357. geometry,
  17358. renderer,
  17359. ]);
  17360. this.hitDetectionInstructions.push([
  17361. canvas_Instruction.CUSTOM,
  17362. builderBegin,
  17363. builderEnd,
  17364. geometry,
  17365. hitDetectionRenderer || renderer,
  17366. ]);
  17367. break;
  17368. default:
  17369. }
  17370. this.endGeometry(feature);
  17371. };
  17372. /**
  17373. * @protected
  17374. * @param {import("../../geom/Geometry").default|import("../Feature.js").default} geometry The geometry.
  17375. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17376. */
  17377. CanvasBuilder.prototype.beginGeometry = function (geometry, feature) {
  17378. this.beginGeometryInstruction1_ = [
  17379. canvas_Instruction.BEGIN_GEOMETRY,
  17380. feature,
  17381. 0,
  17382. geometry,
  17383. ];
  17384. this.instructions.push(this.beginGeometryInstruction1_);
  17385. this.beginGeometryInstruction2_ = [
  17386. canvas_Instruction.BEGIN_GEOMETRY,
  17387. feature,
  17388. 0,
  17389. geometry,
  17390. ];
  17391. this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
  17392. };
  17393. /**
  17394. * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
  17395. */
  17396. CanvasBuilder.prototype.finish = function () {
  17397. return {
  17398. instructions: this.instructions,
  17399. hitDetectionInstructions: this.hitDetectionInstructions,
  17400. coordinates: this.coordinates,
  17401. };
  17402. };
  17403. /**
  17404. * Reverse the hit detection instructions.
  17405. */
  17406. CanvasBuilder.prototype.reverseHitDetectionInstructions = function () {
  17407. var hitDetectionInstructions = this.hitDetectionInstructions;
  17408. // step 1 - reverse array
  17409. hitDetectionInstructions.reverse();
  17410. // step 2 - reverse instructions within geometry blocks
  17411. var i;
  17412. var n = hitDetectionInstructions.length;
  17413. var instruction;
  17414. var type;
  17415. var begin = -1;
  17416. for (i = 0; i < n; ++i) {
  17417. instruction = hitDetectionInstructions[i];
  17418. type = /** @type {import("./Instruction.js").default} */ (instruction[0]);
  17419. if (type == canvas_Instruction.END_GEOMETRY) {
  17420. begin = i;
  17421. }
  17422. else if (type == canvas_Instruction.BEGIN_GEOMETRY) {
  17423. instruction[2] = i;
  17424. reverseSubArray(this.hitDetectionInstructions, begin, i);
  17425. begin = -1;
  17426. }
  17427. }
  17428. };
  17429. /**
  17430. * @param {import("../../style/Fill.js").default} fillStyle Fill style.
  17431. * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style.
  17432. */
  17433. CanvasBuilder.prototype.setFillStrokeStyle = function (fillStyle, strokeStyle) {
  17434. var state = this.state;
  17435. if (fillStyle) {
  17436. var fillStyleColor = fillStyle.getColor();
  17437. state.fillStyle = asColorLike(fillStyleColor ? fillStyleColor : defaultFillStyle);
  17438. }
  17439. else {
  17440. state.fillStyle = undefined;
  17441. }
  17442. if (strokeStyle) {
  17443. var strokeStyleColor = strokeStyle.getColor();
  17444. state.strokeStyle = asColorLike(strokeStyleColor ? strokeStyleColor : defaultStrokeStyle);
  17445. var strokeStyleLineCap = strokeStyle.getLineCap();
  17446. state.lineCap =
  17447. strokeStyleLineCap !== undefined ? strokeStyleLineCap : defaultLineCap;
  17448. var strokeStyleLineDash = strokeStyle.getLineDash();
  17449. state.lineDash = strokeStyleLineDash
  17450. ? strokeStyleLineDash.slice()
  17451. : defaultLineDash;
  17452. var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
  17453. state.lineDashOffset = strokeStyleLineDashOffset
  17454. ? strokeStyleLineDashOffset
  17455. : defaultLineDashOffset;
  17456. var strokeStyleLineJoin = strokeStyle.getLineJoin();
  17457. state.lineJoin =
  17458. strokeStyleLineJoin !== undefined
  17459. ? strokeStyleLineJoin
  17460. : defaultLineJoin;
  17461. var strokeStyleWidth = strokeStyle.getWidth();
  17462. state.lineWidth =
  17463. strokeStyleWidth !== undefined ? strokeStyleWidth : defaultLineWidth;
  17464. var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
  17465. state.miterLimit =
  17466. strokeStyleMiterLimit !== undefined
  17467. ? strokeStyleMiterLimit
  17468. : defaultMiterLimit;
  17469. if (state.lineWidth > this.maxLineWidth) {
  17470. this.maxLineWidth = state.lineWidth;
  17471. // invalidate the buffered max extent cache
  17472. this.bufferedMaxExtent_ = null;
  17473. }
  17474. }
  17475. else {
  17476. state.strokeStyle = undefined;
  17477. state.lineCap = undefined;
  17478. state.lineDash = null;
  17479. state.lineDashOffset = undefined;
  17480. state.lineJoin = undefined;
  17481. state.lineWidth = undefined;
  17482. state.miterLimit = undefined;
  17483. }
  17484. };
  17485. /**
  17486. * @param {import("../canvas.js").FillStrokeState} state State.
  17487. * @return {Array<*>} Fill instruction.
  17488. */
  17489. CanvasBuilder.prototype.createFill = function (state) {
  17490. var fillStyle = state.fillStyle;
  17491. /** @type {Array<*>} */
  17492. var fillInstruction = [canvas_Instruction.SET_FILL_STYLE, fillStyle];
  17493. if (typeof fillStyle !== 'string') {
  17494. // Fill is a pattern or gradient - align it!
  17495. fillInstruction.push(true);
  17496. }
  17497. return fillInstruction;
  17498. };
  17499. /**
  17500. * @param {import("../canvas.js").FillStrokeState} state State.
  17501. */
  17502. CanvasBuilder.prototype.applyStroke = function (state) {
  17503. this.instructions.push(this.createStroke(state));
  17504. };
  17505. /**
  17506. * @param {import("../canvas.js").FillStrokeState} state State.
  17507. * @return {Array<*>} Stroke instruction.
  17508. */
  17509. CanvasBuilder.prototype.createStroke = function (state) {
  17510. return [
  17511. canvas_Instruction.SET_STROKE_STYLE,
  17512. state.strokeStyle,
  17513. state.lineWidth * this.pixelRatio,
  17514. state.lineCap,
  17515. state.lineJoin,
  17516. state.miterLimit,
  17517. this.applyPixelRatio(state.lineDash),
  17518. state.lineDashOffset * this.pixelRatio,
  17519. ];
  17520. };
  17521. /**
  17522. * @param {import("../canvas.js").FillStrokeState} state State.
  17523. * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState):Array<*>} createFill Create fill.
  17524. */
  17525. CanvasBuilder.prototype.updateFillStyle = function (state, createFill) {
  17526. var fillStyle = state.fillStyle;
  17527. if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) {
  17528. if (fillStyle !== undefined) {
  17529. this.instructions.push(createFill.call(this, state));
  17530. }
  17531. state.currentFillStyle = fillStyle;
  17532. }
  17533. };
  17534. /**
  17535. * @param {import("../canvas.js").FillStrokeState} state State.
  17536. * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState): void} applyStroke Apply stroke.
  17537. */
  17538. CanvasBuilder.prototype.updateStrokeStyle = function (state, applyStroke) {
  17539. var strokeStyle = state.strokeStyle;
  17540. var lineCap = state.lineCap;
  17541. var lineDash = state.lineDash;
  17542. var lineDashOffset = state.lineDashOffset;
  17543. var lineJoin = state.lineJoin;
  17544. var lineWidth = state.lineWidth;
  17545. var miterLimit = state.miterLimit;
  17546. if (state.currentStrokeStyle != strokeStyle ||
  17547. state.currentLineCap != lineCap ||
  17548. (lineDash != state.currentLineDash &&
  17549. !equals(state.currentLineDash, lineDash)) ||
  17550. state.currentLineDashOffset != lineDashOffset ||
  17551. state.currentLineJoin != lineJoin ||
  17552. state.currentLineWidth != lineWidth ||
  17553. state.currentMiterLimit != miterLimit) {
  17554. if (strokeStyle !== undefined) {
  17555. applyStroke.call(this, state);
  17556. }
  17557. state.currentStrokeStyle = strokeStyle;
  17558. state.currentLineCap = lineCap;
  17559. state.currentLineDash = lineDash;
  17560. state.currentLineDashOffset = lineDashOffset;
  17561. state.currentLineJoin = lineJoin;
  17562. state.currentLineWidth = lineWidth;
  17563. state.currentMiterLimit = miterLimit;
  17564. }
  17565. };
  17566. /**
  17567. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17568. */
  17569. CanvasBuilder.prototype.endGeometry = function (feature) {
  17570. this.beginGeometryInstruction1_[2] = this.instructions.length;
  17571. this.beginGeometryInstruction1_ = null;
  17572. this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
  17573. this.beginGeometryInstruction2_ = null;
  17574. var endGeometryInstruction = [canvas_Instruction.END_GEOMETRY, feature];
  17575. this.instructions.push(endGeometryInstruction);
  17576. this.hitDetectionInstructions.push(endGeometryInstruction);
  17577. };
  17578. /**
  17579. * Get the buffered rendering extent. Rendering will be clipped to the extent
  17580. * provided to the constructor. To account for symbolizers that may intersect
  17581. * this extent, we calculate a buffered extent (e.g. based on stroke width).
  17582. * @return {import("../../extent.js").Extent} The buffered rendering extent.
  17583. * @protected
  17584. */
  17585. CanvasBuilder.prototype.getBufferedMaxExtent = function () {
  17586. if (!this.bufferedMaxExtent_) {
  17587. this.bufferedMaxExtent_ = clone(this.maxExtent);
  17588. if (this.maxLineWidth > 0) {
  17589. var width = (this.resolution * (this.maxLineWidth + 1)) / 2;
  17590. buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
  17591. }
  17592. }
  17593. return this.bufferedMaxExtent_;
  17594. };
  17595. return CanvasBuilder;
  17596. }(render_VectorContext));
  17597. /* harmony default export */ var Builder = (CanvasBuilder);
  17598. //# sourceMappingURL=Builder.js.map
  17599. ;// ./node_modules/ol/render/canvas/ImageBuilder.js
  17600. var ImageBuilder_extends = (undefined && undefined.__extends) || (function () {
  17601. var extendStatics = function (d, b) {
  17602. extendStatics = Object.setPrototypeOf ||
  17603. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17604. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  17605. return extendStatics(d, b);
  17606. };
  17607. return function (d, b) {
  17608. if (typeof b !== "function" && b !== null)
  17609. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  17610. extendStatics(d, b);
  17611. function __() { this.constructor = d; }
  17612. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17613. };
  17614. })();
  17615. /**
  17616. * @module ol/render/canvas/ImageBuilder
  17617. */
  17618. var CanvasImageBuilder = /** @class */ (function (_super) {
  17619. ImageBuilder_extends(CanvasImageBuilder, _super);
  17620. /**
  17621. * @param {number} tolerance Tolerance.
  17622. * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
  17623. * @param {number} resolution Resolution.
  17624. * @param {number} pixelRatio Pixel ratio.
  17625. */
  17626. function CanvasImageBuilder(tolerance, maxExtent, resolution, pixelRatio) {
  17627. var _this = _super.call(this, tolerance, maxExtent, resolution, pixelRatio) || this;
  17628. /**
  17629. * @private
  17630. * @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement}
  17631. */
  17632. _this.hitDetectionImage_ = null;
  17633. /**
  17634. * @private
  17635. * @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement}
  17636. */
  17637. _this.image_ = null;
  17638. /**
  17639. * @private
  17640. * @type {number|undefined}
  17641. */
  17642. _this.imagePixelRatio_ = undefined;
  17643. /**
  17644. * @private
  17645. * @type {number|undefined}
  17646. */
  17647. _this.anchorX_ = undefined;
  17648. /**
  17649. * @private
  17650. * @type {number|undefined}
  17651. */
  17652. _this.anchorY_ = undefined;
  17653. /**
  17654. * @private
  17655. * @type {number|undefined}
  17656. */
  17657. _this.height_ = undefined;
  17658. /**
  17659. * @private
  17660. * @type {number|undefined}
  17661. */
  17662. _this.opacity_ = undefined;
  17663. /**
  17664. * @private
  17665. * @type {number|undefined}
  17666. */
  17667. _this.originX_ = undefined;
  17668. /**
  17669. * @private
  17670. * @type {number|undefined}
  17671. */
  17672. _this.originY_ = undefined;
  17673. /**
  17674. * @private
  17675. * @type {boolean|undefined}
  17676. */
  17677. _this.rotateWithView_ = undefined;
  17678. /**
  17679. * @private
  17680. * @type {number|undefined}
  17681. */
  17682. _this.rotation_ = undefined;
  17683. /**
  17684. * @private
  17685. * @type {import("../../size.js").Size|undefined}
  17686. */
  17687. _this.scale_ = undefined;
  17688. /**
  17689. * @private
  17690. * @type {number|undefined}
  17691. */
  17692. _this.width_ = undefined;
  17693. /**
  17694. * @private
  17695. * @type {"declutter"|"obstacle"|"none"|undefined}
  17696. */
  17697. _this.declutterMode_ = undefined;
  17698. /**
  17699. * Data shared with a text builder for combined decluttering.
  17700. * @private
  17701. * @type {import("../canvas.js").DeclutterImageWithText}
  17702. */
  17703. _this.declutterImageWithText_ = undefined;
  17704. return _this;
  17705. }
  17706. /**
  17707. * @param {import("../../geom/Point.js").default|import("../Feature.js").default} pointGeometry Point geometry.
  17708. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17709. */
  17710. CanvasImageBuilder.prototype.drawPoint = function (pointGeometry, feature) {
  17711. if (!this.image_) {
  17712. return;
  17713. }
  17714. this.beginGeometry(pointGeometry, feature);
  17715. var flatCoordinates = pointGeometry.getFlatCoordinates();
  17716. var stride = pointGeometry.getStride();
  17717. var myBegin = this.coordinates.length;
  17718. var myEnd = this.appendFlatPointCoordinates(flatCoordinates, stride);
  17719. this.instructions.push([
  17720. canvas_Instruction.DRAW_IMAGE,
  17721. myBegin,
  17722. myEnd,
  17723. this.image_,
  17724. // Remaining arguments to DRAW_IMAGE are in alphabetical order
  17725. this.anchorX_ * this.imagePixelRatio_,
  17726. this.anchorY_ * this.imagePixelRatio_,
  17727. Math.ceil(this.height_ * this.imagePixelRatio_),
  17728. this.opacity_,
  17729. this.originX_ * this.imagePixelRatio_,
  17730. this.originY_ * this.imagePixelRatio_,
  17731. this.rotateWithView_,
  17732. this.rotation_,
  17733. [
  17734. (this.scale_[0] * this.pixelRatio) / this.imagePixelRatio_,
  17735. (this.scale_[1] * this.pixelRatio) / this.imagePixelRatio_,
  17736. ],
  17737. Math.ceil(this.width_ * this.imagePixelRatio_),
  17738. this.declutterMode_,
  17739. this.declutterImageWithText_,
  17740. ]);
  17741. this.hitDetectionInstructions.push([
  17742. canvas_Instruction.DRAW_IMAGE,
  17743. myBegin,
  17744. myEnd,
  17745. this.hitDetectionImage_,
  17746. // Remaining arguments to DRAW_IMAGE are in alphabetical order
  17747. this.anchorX_,
  17748. this.anchorY_,
  17749. this.height_,
  17750. this.opacity_,
  17751. this.originX_,
  17752. this.originY_,
  17753. this.rotateWithView_,
  17754. this.rotation_,
  17755. this.scale_,
  17756. this.width_,
  17757. this.declutterMode_,
  17758. this.declutterImageWithText_,
  17759. ]);
  17760. this.endGeometry(feature);
  17761. };
  17762. /**
  17763. * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} multiPointGeometry MultiPoint geometry.
  17764. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17765. */
  17766. CanvasImageBuilder.prototype.drawMultiPoint = function (multiPointGeometry, feature) {
  17767. if (!this.image_) {
  17768. return;
  17769. }
  17770. this.beginGeometry(multiPointGeometry, feature);
  17771. var flatCoordinates = multiPointGeometry.getFlatCoordinates();
  17772. var stride = multiPointGeometry.getStride();
  17773. var myBegin = this.coordinates.length;
  17774. var myEnd = this.appendFlatPointCoordinates(flatCoordinates, stride);
  17775. this.instructions.push([
  17776. canvas_Instruction.DRAW_IMAGE,
  17777. myBegin,
  17778. myEnd,
  17779. this.image_,
  17780. // Remaining arguments to DRAW_IMAGE are in alphabetical order
  17781. this.anchorX_ * this.imagePixelRatio_,
  17782. this.anchorY_ * this.imagePixelRatio_,
  17783. Math.ceil(this.height_ * this.imagePixelRatio_),
  17784. this.opacity_,
  17785. this.originX_ * this.imagePixelRatio_,
  17786. this.originY_ * this.imagePixelRatio_,
  17787. this.rotateWithView_,
  17788. this.rotation_,
  17789. [
  17790. (this.scale_[0] * this.pixelRatio) / this.imagePixelRatio_,
  17791. (this.scale_[1] * this.pixelRatio) / this.imagePixelRatio_,
  17792. ],
  17793. Math.ceil(this.width_ * this.imagePixelRatio_),
  17794. this.declutterMode_,
  17795. this.declutterImageWithText_,
  17796. ]);
  17797. this.hitDetectionInstructions.push([
  17798. canvas_Instruction.DRAW_IMAGE,
  17799. myBegin,
  17800. myEnd,
  17801. this.hitDetectionImage_,
  17802. // Remaining arguments to DRAW_IMAGE are in alphabetical order
  17803. this.anchorX_,
  17804. this.anchorY_,
  17805. this.height_,
  17806. this.opacity_,
  17807. this.originX_,
  17808. this.originY_,
  17809. this.rotateWithView_,
  17810. this.rotation_,
  17811. this.scale_,
  17812. this.width_,
  17813. this.declutterMode_,
  17814. this.declutterImageWithText_,
  17815. ]);
  17816. this.endGeometry(feature);
  17817. };
  17818. /**
  17819. * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
  17820. */
  17821. CanvasImageBuilder.prototype.finish = function () {
  17822. this.reverseHitDetectionInstructions();
  17823. // FIXME this doesn't really protect us against further calls to draw*Geometry
  17824. this.anchorX_ = undefined;
  17825. this.anchorY_ = undefined;
  17826. this.hitDetectionImage_ = null;
  17827. this.image_ = null;
  17828. this.imagePixelRatio_ = undefined;
  17829. this.height_ = undefined;
  17830. this.scale_ = undefined;
  17831. this.opacity_ = undefined;
  17832. this.originX_ = undefined;
  17833. this.originY_ = undefined;
  17834. this.rotateWithView_ = undefined;
  17835. this.rotation_ = undefined;
  17836. this.width_ = undefined;
  17837. return _super.prototype.finish.call(this);
  17838. };
  17839. /**
  17840. * @param {import("../../style/Image.js").default} imageStyle Image style.
  17841. * @param {Object} [opt_sharedData] Shared data.
  17842. */
  17843. CanvasImageBuilder.prototype.setImageStyle = function (imageStyle, opt_sharedData) {
  17844. var anchor = imageStyle.getAnchor();
  17845. var size = imageStyle.getSize();
  17846. var origin = imageStyle.getOrigin();
  17847. this.imagePixelRatio_ = imageStyle.getPixelRatio(this.pixelRatio);
  17848. this.anchorX_ = anchor[0];
  17849. this.anchorY_ = anchor[1];
  17850. this.hitDetectionImage_ = imageStyle.getHitDetectionImage();
  17851. this.image_ = imageStyle.getImage(this.pixelRatio);
  17852. this.height_ = size[1];
  17853. this.opacity_ = imageStyle.getOpacity();
  17854. this.originX_ = origin[0];
  17855. this.originY_ = origin[1];
  17856. this.rotateWithView_ = imageStyle.getRotateWithView();
  17857. this.rotation_ = imageStyle.getRotation();
  17858. this.scale_ = imageStyle.getScaleArray();
  17859. this.width_ = size[0];
  17860. this.declutterMode_ = imageStyle.getDeclutterMode();
  17861. this.declutterImageWithText_ = opt_sharedData;
  17862. };
  17863. return CanvasImageBuilder;
  17864. }(Builder));
  17865. /* harmony default export */ var ImageBuilder = (CanvasImageBuilder);
  17866. //# sourceMappingURL=ImageBuilder.js.map
  17867. ;// ./node_modules/ol/render/canvas/LineStringBuilder.js
  17868. var LineStringBuilder_extends = (undefined && undefined.__extends) || (function () {
  17869. var extendStatics = function (d, b) {
  17870. extendStatics = Object.setPrototypeOf ||
  17871. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17872. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  17873. return extendStatics(d, b);
  17874. };
  17875. return function (d, b) {
  17876. if (typeof b !== "function" && b !== null)
  17877. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  17878. extendStatics(d, b);
  17879. function __() { this.constructor = d; }
  17880. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17881. };
  17882. })();
  17883. /**
  17884. * @module ol/render/canvas/LineStringBuilder
  17885. */
  17886. var CanvasLineStringBuilder = /** @class */ (function (_super) {
  17887. LineStringBuilder_extends(CanvasLineStringBuilder, _super);
  17888. /**
  17889. * @param {number} tolerance Tolerance.
  17890. * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
  17891. * @param {number} resolution Resolution.
  17892. * @param {number} pixelRatio Pixel ratio.
  17893. */
  17894. function CanvasLineStringBuilder(tolerance, maxExtent, resolution, pixelRatio) {
  17895. return _super.call(this, tolerance, maxExtent, resolution, pixelRatio) || this;
  17896. }
  17897. /**
  17898. * @param {Array<number>} flatCoordinates Flat coordinates.
  17899. * @param {number} offset Offset.
  17900. * @param {number} end End.
  17901. * @param {number} stride Stride.
  17902. * @private
  17903. * @return {number} end.
  17904. */
  17905. CanvasLineStringBuilder.prototype.drawFlatCoordinates_ = function (flatCoordinates, offset, end, stride) {
  17906. var myBegin = this.coordinates.length;
  17907. var myEnd = this.appendFlatLineCoordinates(flatCoordinates, offset, end, stride, false, false);
  17908. var moveToLineToInstruction = [
  17909. canvas_Instruction.MOVE_TO_LINE_TO,
  17910. myBegin,
  17911. myEnd,
  17912. ];
  17913. this.instructions.push(moveToLineToInstruction);
  17914. this.hitDetectionInstructions.push(moveToLineToInstruction);
  17915. return end;
  17916. };
  17917. /**
  17918. * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} lineStringGeometry Line string geometry.
  17919. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17920. */
  17921. CanvasLineStringBuilder.prototype.drawLineString = function (lineStringGeometry, feature) {
  17922. var state = this.state;
  17923. var strokeStyle = state.strokeStyle;
  17924. var lineWidth = state.lineWidth;
  17925. if (strokeStyle === undefined || lineWidth === undefined) {
  17926. return;
  17927. }
  17928. this.updateStrokeStyle(state, this.applyStroke);
  17929. this.beginGeometry(lineStringGeometry, feature);
  17930. this.hitDetectionInstructions.push([
  17931. canvas_Instruction.SET_STROKE_STYLE,
  17932. state.strokeStyle,
  17933. state.lineWidth,
  17934. state.lineCap,
  17935. state.lineJoin,
  17936. state.miterLimit,
  17937. defaultLineDash,
  17938. defaultLineDashOffset,
  17939. ], beginPathInstruction);
  17940. var flatCoordinates = lineStringGeometry.getFlatCoordinates();
  17941. var stride = lineStringGeometry.getStride();
  17942. this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
  17943. this.hitDetectionInstructions.push(strokeInstruction);
  17944. this.endGeometry(feature);
  17945. };
  17946. /**
  17947. * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} multiLineStringGeometry MultiLineString geometry.
  17948. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  17949. */
  17950. CanvasLineStringBuilder.prototype.drawMultiLineString = function (multiLineStringGeometry, feature) {
  17951. var state = this.state;
  17952. var strokeStyle = state.strokeStyle;
  17953. var lineWidth = state.lineWidth;
  17954. if (strokeStyle === undefined || lineWidth === undefined) {
  17955. return;
  17956. }
  17957. this.updateStrokeStyle(state, this.applyStroke);
  17958. this.beginGeometry(multiLineStringGeometry, feature);
  17959. this.hitDetectionInstructions.push([
  17960. canvas_Instruction.SET_STROKE_STYLE,
  17961. state.strokeStyle,
  17962. state.lineWidth,
  17963. state.lineCap,
  17964. state.lineJoin,
  17965. state.miterLimit,
  17966. state.lineDash,
  17967. state.lineDashOffset,
  17968. ], beginPathInstruction);
  17969. var ends = multiLineStringGeometry.getEnds();
  17970. var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
  17971. var stride = multiLineStringGeometry.getStride();
  17972. var offset = 0;
  17973. for (var i = 0, ii = ends.length; i < ii; ++i) {
  17974. offset = this.drawFlatCoordinates_(flatCoordinates, offset,
  17975. /** @type {number} */ (ends[i]), stride);
  17976. }
  17977. this.hitDetectionInstructions.push(strokeInstruction);
  17978. this.endGeometry(feature);
  17979. };
  17980. /**
  17981. * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
  17982. */
  17983. CanvasLineStringBuilder.prototype.finish = function () {
  17984. var state = this.state;
  17985. if (state.lastStroke != undefined &&
  17986. state.lastStroke != this.coordinates.length) {
  17987. this.instructions.push(strokeInstruction);
  17988. }
  17989. this.reverseHitDetectionInstructions();
  17990. this.state = null;
  17991. return _super.prototype.finish.call(this);
  17992. };
  17993. /**
  17994. * @param {import("../canvas.js").FillStrokeState} state State.
  17995. */
  17996. CanvasLineStringBuilder.prototype.applyStroke = function (state) {
  17997. if (state.lastStroke != undefined &&
  17998. state.lastStroke != this.coordinates.length) {
  17999. this.instructions.push(strokeInstruction);
  18000. state.lastStroke = this.coordinates.length;
  18001. }
  18002. state.lastStroke = 0;
  18003. _super.prototype.applyStroke.call(this, state);
  18004. this.instructions.push(beginPathInstruction);
  18005. };
  18006. return CanvasLineStringBuilder;
  18007. }(Builder));
  18008. /* harmony default export */ var LineStringBuilder = (CanvasLineStringBuilder);
  18009. //# sourceMappingURL=LineStringBuilder.js.map
  18010. ;// ./node_modules/ol/render/canvas/PolygonBuilder.js
  18011. var PolygonBuilder_extends = (undefined && undefined.__extends) || (function () {
  18012. var extendStatics = function (d, b) {
  18013. extendStatics = Object.setPrototypeOf ||
  18014. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  18015. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  18016. return extendStatics(d, b);
  18017. };
  18018. return function (d, b) {
  18019. if (typeof b !== "function" && b !== null)
  18020. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  18021. extendStatics(d, b);
  18022. function __() { this.constructor = d; }
  18023. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18024. };
  18025. })();
  18026. /**
  18027. * @module ol/render/canvas/PolygonBuilder
  18028. */
  18029. var CanvasPolygonBuilder = /** @class */ (function (_super) {
  18030. PolygonBuilder_extends(CanvasPolygonBuilder, _super);
  18031. /**
  18032. * @param {number} tolerance Tolerance.
  18033. * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
  18034. * @param {number} resolution Resolution.
  18035. * @param {number} pixelRatio Pixel ratio.
  18036. */
  18037. function CanvasPolygonBuilder(tolerance, maxExtent, resolution, pixelRatio) {
  18038. return _super.call(this, tolerance, maxExtent, resolution, pixelRatio) || this;
  18039. }
  18040. /**
  18041. * @param {Array<number>} flatCoordinates Flat coordinates.
  18042. * @param {number} offset Offset.
  18043. * @param {Array<number>} ends Ends.
  18044. * @param {number} stride Stride.
  18045. * @private
  18046. * @return {number} End.
  18047. */
  18048. CanvasPolygonBuilder.prototype.drawFlatCoordinatess_ = function (flatCoordinates, offset, ends, stride) {
  18049. var state = this.state;
  18050. var fill = state.fillStyle !== undefined;
  18051. var stroke = state.strokeStyle !== undefined;
  18052. var numEnds = ends.length;
  18053. this.instructions.push(beginPathInstruction);
  18054. this.hitDetectionInstructions.push(beginPathInstruction);
  18055. for (var i = 0; i < numEnds; ++i) {
  18056. var end = ends[i];
  18057. var myBegin = this.coordinates.length;
  18058. var myEnd = this.appendFlatLineCoordinates(flatCoordinates, offset, end, stride, true, !stroke);
  18059. var moveToLineToInstruction = [
  18060. canvas_Instruction.MOVE_TO_LINE_TO,
  18061. myBegin,
  18062. myEnd,
  18063. ];
  18064. this.instructions.push(moveToLineToInstruction);
  18065. this.hitDetectionInstructions.push(moveToLineToInstruction);
  18066. if (stroke) {
  18067. // Performance optimization: only call closePath() when we have a stroke.
  18068. // Otherwise the ring is closed already (see appendFlatLineCoordinates above).
  18069. this.instructions.push(closePathInstruction);
  18070. this.hitDetectionInstructions.push(closePathInstruction);
  18071. }
  18072. offset = end;
  18073. }
  18074. if (fill) {
  18075. this.instructions.push(fillInstruction);
  18076. this.hitDetectionInstructions.push(fillInstruction);
  18077. }
  18078. if (stroke) {
  18079. this.instructions.push(strokeInstruction);
  18080. this.hitDetectionInstructions.push(strokeInstruction);
  18081. }
  18082. return offset;
  18083. };
  18084. /**
  18085. * @param {import("../../geom/Circle.js").default} circleGeometry Circle geometry.
  18086. * @param {import("../../Feature.js").default} feature Feature.
  18087. */
  18088. CanvasPolygonBuilder.prototype.drawCircle = function (circleGeometry, feature) {
  18089. var state = this.state;
  18090. var fillStyle = state.fillStyle;
  18091. var strokeStyle = state.strokeStyle;
  18092. if (fillStyle === undefined && strokeStyle === undefined) {
  18093. return;
  18094. }
  18095. this.setFillStrokeStyles_();
  18096. this.beginGeometry(circleGeometry, feature);
  18097. if (state.fillStyle !== undefined) {
  18098. this.hitDetectionInstructions.push([
  18099. canvas_Instruction.SET_FILL_STYLE,
  18100. defaultFillStyle,
  18101. ]);
  18102. }
  18103. if (state.strokeStyle !== undefined) {
  18104. this.hitDetectionInstructions.push([
  18105. canvas_Instruction.SET_STROKE_STYLE,
  18106. state.strokeStyle,
  18107. state.lineWidth,
  18108. state.lineCap,
  18109. state.lineJoin,
  18110. state.miterLimit,
  18111. state.lineDash,
  18112. state.lineDashOffset,
  18113. ]);
  18114. }
  18115. var flatCoordinates = circleGeometry.getFlatCoordinates();
  18116. var stride = circleGeometry.getStride();
  18117. var myBegin = this.coordinates.length;
  18118. this.appendFlatLineCoordinates(flatCoordinates, 0, flatCoordinates.length, stride, false, false);
  18119. var circleInstruction = [canvas_Instruction.CIRCLE, myBegin];
  18120. this.instructions.push(beginPathInstruction, circleInstruction);
  18121. this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
  18122. if (state.fillStyle !== undefined) {
  18123. this.instructions.push(fillInstruction);
  18124. this.hitDetectionInstructions.push(fillInstruction);
  18125. }
  18126. if (state.strokeStyle !== undefined) {
  18127. this.instructions.push(strokeInstruction);
  18128. this.hitDetectionInstructions.push(strokeInstruction);
  18129. }
  18130. this.endGeometry(feature);
  18131. };
  18132. /**
  18133. * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} polygonGeometry Polygon geometry.
  18134. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  18135. */
  18136. CanvasPolygonBuilder.prototype.drawPolygon = function (polygonGeometry, feature) {
  18137. var state = this.state;
  18138. var fillStyle = state.fillStyle;
  18139. var strokeStyle = state.strokeStyle;
  18140. if (fillStyle === undefined && strokeStyle === undefined) {
  18141. return;
  18142. }
  18143. this.setFillStrokeStyles_();
  18144. this.beginGeometry(polygonGeometry, feature);
  18145. if (state.fillStyle !== undefined) {
  18146. this.hitDetectionInstructions.push([
  18147. canvas_Instruction.SET_FILL_STYLE,
  18148. defaultFillStyle,
  18149. ]);
  18150. }
  18151. if (state.strokeStyle !== undefined) {
  18152. this.hitDetectionInstructions.push([
  18153. canvas_Instruction.SET_STROKE_STYLE,
  18154. state.strokeStyle,
  18155. state.lineWidth,
  18156. state.lineCap,
  18157. state.lineJoin,
  18158. state.miterLimit,
  18159. state.lineDash,
  18160. state.lineDashOffset,
  18161. ]);
  18162. }
  18163. var ends = polygonGeometry.getEnds();
  18164. var flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
  18165. var stride = polygonGeometry.getStride();
  18166. this.drawFlatCoordinatess_(flatCoordinates, 0,
  18167. /** @type {Array<number>} */ (ends), stride);
  18168. this.endGeometry(feature);
  18169. };
  18170. /**
  18171. * @param {import("../../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry.
  18172. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  18173. */
  18174. CanvasPolygonBuilder.prototype.drawMultiPolygon = function (multiPolygonGeometry, feature) {
  18175. var state = this.state;
  18176. var fillStyle = state.fillStyle;
  18177. var strokeStyle = state.strokeStyle;
  18178. if (fillStyle === undefined && strokeStyle === undefined) {
  18179. return;
  18180. }
  18181. this.setFillStrokeStyles_();
  18182. this.beginGeometry(multiPolygonGeometry, feature);
  18183. if (state.fillStyle !== undefined) {
  18184. this.hitDetectionInstructions.push([
  18185. canvas_Instruction.SET_FILL_STYLE,
  18186. defaultFillStyle,
  18187. ]);
  18188. }
  18189. if (state.strokeStyle !== undefined) {
  18190. this.hitDetectionInstructions.push([
  18191. canvas_Instruction.SET_STROKE_STYLE,
  18192. state.strokeStyle,
  18193. state.lineWidth,
  18194. state.lineCap,
  18195. state.lineJoin,
  18196. state.miterLimit,
  18197. state.lineDash,
  18198. state.lineDashOffset,
  18199. ]);
  18200. }
  18201. var endss = multiPolygonGeometry.getEndss();
  18202. var flatCoordinates = multiPolygonGeometry.getOrientedFlatCoordinates();
  18203. var stride = multiPolygonGeometry.getStride();
  18204. var offset = 0;
  18205. for (var i = 0, ii = endss.length; i < ii; ++i) {
  18206. offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride);
  18207. }
  18208. this.endGeometry(feature);
  18209. };
  18210. /**
  18211. * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
  18212. */
  18213. CanvasPolygonBuilder.prototype.finish = function () {
  18214. this.reverseHitDetectionInstructions();
  18215. this.state = null;
  18216. // We want to preserve topology when drawing polygons. Polygons are
  18217. // simplified using quantization and point elimination. However, we might
  18218. // have received a mix of quantized and non-quantized geometries, so ensure
  18219. // that all are quantized by quantizing all coordinates in the batch.
  18220. var tolerance = this.tolerance;
  18221. if (tolerance !== 0) {
  18222. var coordinates = this.coordinates;
  18223. for (var i = 0, ii = coordinates.length; i < ii; ++i) {
  18224. coordinates[i] = snap(coordinates[i], tolerance);
  18225. }
  18226. }
  18227. return _super.prototype.finish.call(this);
  18228. };
  18229. /**
  18230. * @private
  18231. */
  18232. CanvasPolygonBuilder.prototype.setFillStrokeStyles_ = function () {
  18233. var state = this.state;
  18234. var fillStyle = state.fillStyle;
  18235. if (fillStyle !== undefined) {
  18236. this.updateFillStyle(state, this.createFill);
  18237. }
  18238. if (state.strokeStyle !== undefined) {
  18239. this.updateStrokeStyle(state, this.applyStroke);
  18240. }
  18241. };
  18242. return CanvasPolygonBuilder;
  18243. }(Builder));
  18244. /* harmony default export */ var PolygonBuilder = (CanvasPolygonBuilder);
  18245. //# sourceMappingURL=PolygonBuilder.js.map
  18246. ;// ./node_modules/ol/style/TextPlacement.js
  18247. /**
  18248. * @module ol/style/TextPlacement
  18249. */
  18250. /**
  18251. * Text placement. One of `'point'`, `'line'`. Default is `'point'`. Note that
  18252. * `'line'` requires the underlying geometry to be a {@link module:ol/geom/LineString~LineString},
  18253. * {@link module:ol/geom/Polygon~Polygon}, {@link module:ol/geom/MultiLineString~MultiLineString} or
  18254. * {@link module:ol/geom/MultiPolygon~MultiPolygon}.
  18255. * @enum {string}
  18256. */
  18257. /* harmony default export */ var TextPlacement = ({
  18258. POINT: 'point',
  18259. LINE: 'line',
  18260. });
  18261. //# sourceMappingURL=TextPlacement.js.map
  18262. ;// ./node_modules/ol/geom/flat/straightchunk.js
  18263. /**
  18264. * @module ol/geom/flat/straightchunk
  18265. */
  18266. /**
  18267. * @param {number} maxAngle Maximum acceptable angle delta between segments.
  18268. * @param {Array<number>} flatCoordinates Flat coordinates.
  18269. * @param {number} offset Offset.
  18270. * @param {number} end End.
  18271. * @param {number} stride Stride.
  18272. * @return {Array<number>} Start and end of the first suitable chunk of the
  18273. * given `flatCoordinates`.
  18274. */
  18275. function matchingChunk(maxAngle, flatCoordinates, offset, end, stride) {
  18276. var chunkStart = offset;
  18277. var chunkEnd = offset;
  18278. var chunkM = 0;
  18279. var m = 0;
  18280. var start = offset;
  18281. var acos, i, m12, m23, x1, y1, x12, y12, x23, y23;
  18282. for (i = offset; i < end; i += stride) {
  18283. var x2 = flatCoordinates[i];
  18284. var y2 = flatCoordinates[i + 1];
  18285. if (x1 !== undefined) {
  18286. x23 = x2 - x1;
  18287. y23 = y2 - y1;
  18288. m23 = Math.sqrt(x23 * x23 + y23 * y23);
  18289. if (x12 !== undefined) {
  18290. m += m12;
  18291. acos = Math.acos((x12 * x23 + y12 * y23) / (m12 * m23));
  18292. if (acos > maxAngle) {
  18293. if (m > chunkM) {
  18294. chunkM = m;
  18295. chunkStart = start;
  18296. chunkEnd = i;
  18297. }
  18298. m = 0;
  18299. start = i - stride;
  18300. }
  18301. }
  18302. m12 = m23;
  18303. x12 = x23;
  18304. y12 = y23;
  18305. }
  18306. x1 = x2;
  18307. y1 = y2;
  18308. }
  18309. m += m23;
  18310. return m > chunkM ? [start, i] : [chunkStart, chunkEnd];
  18311. }
  18312. //# sourceMappingURL=straightchunk.js.map
  18313. ;// ./node_modules/ol/render/canvas/TextBuilder.js
  18314. var TextBuilder_extends = (undefined && undefined.__extends) || (function () {
  18315. var extendStatics = function (d, b) {
  18316. extendStatics = Object.setPrototypeOf ||
  18317. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  18318. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  18319. return extendStatics(d, b);
  18320. };
  18321. return function (d, b) {
  18322. if (typeof b !== "function" && b !== null)
  18323. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  18324. extendStatics(d, b);
  18325. function __() { this.constructor = d; }
  18326. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18327. };
  18328. })();
  18329. /**
  18330. * @module ol/render/canvas/TextBuilder
  18331. */
  18332. /**
  18333. * @const
  18334. * @enum {number}
  18335. */
  18336. var TEXT_ALIGN = {
  18337. 'left': 0,
  18338. 'end': 0,
  18339. 'center': 0.5,
  18340. 'right': 1,
  18341. 'start': 1,
  18342. 'top': 0,
  18343. 'middle': 0.5,
  18344. 'hanging': 0.2,
  18345. 'alphabetic': 0.8,
  18346. 'ideographic': 0.8,
  18347. 'bottom': 1,
  18348. };
  18349. var CanvasTextBuilder = /** @class */ (function (_super) {
  18350. TextBuilder_extends(CanvasTextBuilder, _super);
  18351. /**
  18352. * @param {number} tolerance Tolerance.
  18353. * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
  18354. * @param {number} resolution Resolution.
  18355. * @param {number} pixelRatio Pixel ratio.
  18356. */
  18357. function CanvasTextBuilder(tolerance, maxExtent, resolution, pixelRatio) {
  18358. var _this = _super.call(this, tolerance, maxExtent, resolution, pixelRatio) || this;
  18359. /**
  18360. * @private
  18361. * @type {Array<HTMLCanvasElement>}
  18362. */
  18363. _this.labels_ = null;
  18364. /**
  18365. * @private
  18366. * @type {string|Array<string>}
  18367. */
  18368. _this.text_ = '';
  18369. /**
  18370. * @private
  18371. * @type {number}
  18372. */
  18373. _this.textOffsetX_ = 0;
  18374. /**
  18375. * @private
  18376. * @type {number}
  18377. */
  18378. _this.textOffsetY_ = 0;
  18379. /**
  18380. * @private
  18381. * @type {boolean|undefined}
  18382. */
  18383. _this.textRotateWithView_ = undefined;
  18384. /**
  18385. * @private
  18386. * @type {number}
  18387. */
  18388. _this.textRotation_ = 0;
  18389. /**
  18390. * @private
  18391. * @type {?import("../canvas.js").FillState}
  18392. */
  18393. _this.textFillState_ = null;
  18394. /**
  18395. * @type {!Object<string, import("../canvas.js").FillState>}
  18396. */
  18397. _this.fillStates = {};
  18398. /**
  18399. * @private
  18400. * @type {?import("../canvas.js").StrokeState}
  18401. */
  18402. _this.textStrokeState_ = null;
  18403. /**
  18404. * @type {!Object<string, import("../canvas.js").StrokeState>}
  18405. */
  18406. _this.strokeStates = {};
  18407. /**
  18408. * @private
  18409. * @type {import("../canvas.js").TextState}
  18410. */
  18411. _this.textState_ = /** @type {import("../canvas.js").TextState} */ ({});
  18412. /**
  18413. * @type {!Object<string, import("../canvas.js").TextState>}
  18414. */
  18415. _this.textStates = {};
  18416. /**
  18417. * @private
  18418. * @type {string}
  18419. */
  18420. _this.textKey_ = '';
  18421. /**
  18422. * @private
  18423. * @type {string}
  18424. */
  18425. _this.fillKey_ = '';
  18426. /**
  18427. * @private
  18428. * @type {string}
  18429. */
  18430. _this.strokeKey_ = '';
  18431. /**
  18432. * Data shared with an image builder for combined decluttering.
  18433. * @private
  18434. * @type {import("../canvas.js").DeclutterImageWithText}
  18435. */
  18436. _this.declutterImageWithText_ = undefined;
  18437. return _this;
  18438. }
  18439. /**
  18440. * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
  18441. */
  18442. CanvasTextBuilder.prototype.finish = function () {
  18443. var instructions = _super.prototype.finish.call(this);
  18444. instructions.textStates = this.textStates;
  18445. instructions.fillStates = this.fillStates;
  18446. instructions.strokeStates = this.strokeStates;
  18447. return instructions;
  18448. };
  18449. /**
  18450. * @param {import("../../geom/SimpleGeometry.js").default|import("../Feature.js").default} geometry Geometry.
  18451. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  18452. */
  18453. CanvasTextBuilder.prototype.drawText = function (geometry, feature) {
  18454. var fillState = this.textFillState_;
  18455. var strokeState = this.textStrokeState_;
  18456. var textState = this.textState_;
  18457. if (this.text_ === '' || !textState || (!fillState && !strokeState)) {
  18458. return;
  18459. }
  18460. var coordinates = this.coordinates;
  18461. var begin = coordinates.length;
  18462. var geometryType = geometry.getType();
  18463. var flatCoordinates = null;
  18464. var stride = geometry.getStride();
  18465. if (textState.placement === TextPlacement.LINE &&
  18466. (geometryType == 'LineString' ||
  18467. geometryType == 'MultiLineString' ||
  18468. geometryType == 'Polygon' ||
  18469. geometryType == 'MultiPolygon')) {
  18470. if (!intersects(this.getBufferedMaxExtent(), geometry.getExtent())) {
  18471. return;
  18472. }
  18473. var ends = void 0;
  18474. flatCoordinates = geometry.getFlatCoordinates();
  18475. if (geometryType == 'LineString') {
  18476. ends = [flatCoordinates.length];
  18477. }
  18478. else if (geometryType == 'MultiLineString') {
  18479. ends = /** @type {import("../../geom/MultiLineString.js").default} */ (geometry).getEnds();
  18480. }
  18481. else if (geometryType == 'Polygon') {
  18482. ends = /** @type {import("../../geom/Polygon.js").default} */ (geometry)
  18483. .getEnds()
  18484. .slice(0, 1);
  18485. }
  18486. else if (geometryType == 'MultiPolygon') {
  18487. var endss =
  18488. /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry).getEndss();
  18489. ends = [];
  18490. for (var i = 0, ii = endss.length; i < ii; ++i) {
  18491. ends.push(endss[i][0]);
  18492. }
  18493. }
  18494. this.beginGeometry(geometry, feature);
  18495. var textAlign = textState.textAlign;
  18496. // No `justify` support for line placement.
  18497. var flatOffset = 0;
  18498. var flatEnd = void 0;
  18499. for (var o = 0, oo = ends.length; o < oo; ++o) {
  18500. if (textAlign == undefined) {
  18501. var range = matchingChunk(textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
  18502. flatOffset = range[0];
  18503. flatEnd = range[1];
  18504. }
  18505. else {
  18506. flatEnd = ends[o];
  18507. }
  18508. for (var i = flatOffset; i < flatEnd; i += stride) {
  18509. coordinates.push(flatCoordinates[i], flatCoordinates[i + 1]);
  18510. }
  18511. var end = coordinates.length;
  18512. flatOffset = ends[o];
  18513. this.drawChars_(begin, end);
  18514. begin = end;
  18515. }
  18516. this.endGeometry(feature);
  18517. }
  18518. else {
  18519. var geometryWidths = textState.overflow ? null : [];
  18520. switch (geometryType) {
  18521. case 'Point':
  18522. case 'MultiPoint':
  18523. flatCoordinates =
  18524. /** @type {import("../../geom/MultiPoint.js").default} */ (geometry).getFlatCoordinates();
  18525. break;
  18526. case 'LineString':
  18527. flatCoordinates =
  18528. /** @type {import("../../geom/LineString.js").default} */ (geometry).getFlatMidpoint();
  18529. break;
  18530. case 'Circle':
  18531. flatCoordinates =
  18532. /** @type {import("../../geom/Circle.js").default} */ (geometry).getCenter();
  18533. break;
  18534. case 'MultiLineString':
  18535. flatCoordinates =
  18536. /** @type {import("../../geom/MultiLineString.js").default} */ (geometry).getFlatMidpoints();
  18537. stride = 2;
  18538. break;
  18539. case 'Polygon':
  18540. flatCoordinates =
  18541. /** @type {import("../../geom/Polygon.js").default} */ (geometry).getFlatInteriorPoint();
  18542. if (!textState.overflow) {
  18543. geometryWidths.push(flatCoordinates[2] / this.resolution);
  18544. }
  18545. stride = 3;
  18546. break;
  18547. case 'MultiPolygon':
  18548. var interiorPoints =
  18549. /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry).getFlatInteriorPoints();
  18550. flatCoordinates = [];
  18551. for (var i = 0, ii = interiorPoints.length; i < ii; i += 3) {
  18552. if (!textState.overflow) {
  18553. geometryWidths.push(interiorPoints[i + 2] / this.resolution);
  18554. }
  18555. flatCoordinates.push(interiorPoints[i], interiorPoints[i + 1]);
  18556. }
  18557. if (flatCoordinates.length === 0) {
  18558. return;
  18559. }
  18560. stride = 2;
  18561. break;
  18562. default:
  18563. }
  18564. var end = this.appendFlatPointCoordinates(flatCoordinates, stride);
  18565. if (end === begin) {
  18566. return;
  18567. }
  18568. if (geometryWidths &&
  18569. (end - begin) / 2 !== flatCoordinates.length / stride) {
  18570. var beg_1 = begin / 2;
  18571. geometryWidths = geometryWidths.filter(function (w, i) {
  18572. var keep = coordinates[(beg_1 + i) * 2] === flatCoordinates[i * stride] &&
  18573. coordinates[(beg_1 + i) * 2 + 1] === flatCoordinates[i * stride + 1];
  18574. if (!keep) {
  18575. --beg_1;
  18576. }
  18577. return keep;
  18578. });
  18579. }
  18580. this.saveTextStates_();
  18581. if (textState.backgroundFill || textState.backgroundStroke) {
  18582. this.setFillStrokeStyle(textState.backgroundFill, textState.backgroundStroke);
  18583. if (textState.backgroundFill) {
  18584. this.updateFillStyle(this.state, this.createFill);
  18585. this.hitDetectionInstructions.push(this.createFill(this.state));
  18586. }
  18587. if (textState.backgroundStroke) {
  18588. this.updateStrokeStyle(this.state, this.applyStroke);
  18589. this.hitDetectionInstructions.push(this.createStroke(this.state));
  18590. }
  18591. }
  18592. this.beginGeometry(geometry, feature);
  18593. // adjust padding for negative scale
  18594. var padding = textState.padding;
  18595. if (padding != defaultPadding &&
  18596. (textState.scale[0] < 0 || textState.scale[1] < 0)) {
  18597. var p0 = textState.padding[0];
  18598. var p1 = textState.padding[1];
  18599. var p2 = textState.padding[2];
  18600. var p3 = textState.padding[3];
  18601. if (textState.scale[0] < 0) {
  18602. p1 = -p1;
  18603. p3 = -p3;
  18604. }
  18605. if (textState.scale[1] < 0) {
  18606. p0 = -p0;
  18607. p2 = -p2;
  18608. }
  18609. padding = [p0, p1, p2, p3];
  18610. }
  18611. // The image is unknown at this stage so we pass null; it will be computed at render time.
  18612. // For clarity, we pass NaN for offsetX, offsetY, width and height, which will be computed at
  18613. // render time.
  18614. var pixelRatio_1 = this.pixelRatio;
  18615. this.instructions.push([
  18616. canvas_Instruction.DRAW_IMAGE,
  18617. begin,
  18618. end,
  18619. null,
  18620. NaN,
  18621. NaN,
  18622. NaN,
  18623. 1,
  18624. 0,
  18625. 0,
  18626. this.textRotateWithView_,
  18627. this.textRotation_,
  18628. [1, 1],
  18629. NaN,
  18630. undefined,
  18631. this.declutterImageWithText_,
  18632. padding == defaultPadding
  18633. ? defaultPadding
  18634. : padding.map(function (p) {
  18635. return p * pixelRatio_1;
  18636. }),
  18637. !!textState.backgroundFill,
  18638. !!textState.backgroundStroke,
  18639. this.text_,
  18640. this.textKey_,
  18641. this.strokeKey_,
  18642. this.fillKey_,
  18643. this.textOffsetX_,
  18644. this.textOffsetY_,
  18645. geometryWidths,
  18646. ]);
  18647. var scale = 1 / pixelRatio_1;
  18648. this.hitDetectionInstructions.push([
  18649. canvas_Instruction.DRAW_IMAGE,
  18650. begin,
  18651. end,
  18652. null,
  18653. NaN,
  18654. NaN,
  18655. NaN,
  18656. 1,
  18657. 0,
  18658. 0,
  18659. this.textRotateWithView_,
  18660. this.textRotation_,
  18661. [scale, scale],
  18662. NaN,
  18663. undefined,
  18664. this.declutterImageWithText_,
  18665. padding,
  18666. !!textState.backgroundFill,
  18667. !!textState.backgroundStroke,
  18668. this.text_,
  18669. this.textKey_,
  18670. this.strokeKey_,
  18671. this.fillKey_,
  18672. this.textOffsetX_,
  18673. this.textOffsetY_,
  18674. geometryWidths,
  18675. ]);
  18676. this.endGeometry(feature);
  18677. }
  18678. };
  18679. /**
  18680. * @private
  18681. */
  18682. CanvasTextBuilder.prototype.saveTextStates_ = function () {
  18683. var strokeState = this.textStrokeState_;
  18684. var textState = this.textState_;
  18685. var fillState = this.textFillState_;
  18686. var strokeKey = this.strokeKey_;
  18687. if (strokeState) {
  18688. if (!(strokeKey in this.strokeStates)) {
  18689. this.strokeStates[strokeKey] = {
  18690. strokeStyle: strokeState.strokeStyle,
  18691. lineCap: strokeState.lineCap,
  18692. lineDashOffset: strokeState.lineDashOffset,
  18693. lineWidth: strokeState.lineWidth,
  18694. lineJoin: strokeState.lineJoin,
  18695. miterLimit: strokeState.miterLimit,
  18696. lineDash: strokeState.lineDash,
  18697. };
  18698. }
  18699. }
  18700. var textKey = this.textKey_;
  18701. if (!(textKey in this.textStates)) {
  18702. this.textStates[textKey] = {
  18703. font: textState.font,
  18704. textAlign: textState.textAlign || defaultTextAlign,
  18705. justify: textState.justify,
  18706. textBaseline: textState.textBaseline || defaultTextBaseline,
  18707. scale: textState.scale,
  18708. };
  18709. }
  18710. var fillKey = this.fillKey_;
  18711. if (fillState) {
  18712. if (!(fillKey in this.fillStates)) {
  18713. this.fillStates[fillKey] = {
  18714. fillStyle: fillState.fillStyle,
  18715. };
  18716. }
  18717. }
  18718. };
  18719. /**
  18720. * @private
  18721. * @param {number} begin Begin.
  18722. * @param {number} end End.
  18723. */
  18724. CanvasTextBuilder.prototype.drawChars_ = function (begin, end) {
  18725. var strokeState = this.textStrokeState_;
  18726. var textState = this.textState_;
  18727. var strokeKey = this.strokeKey_;
  18728. var textKey = this.textKey_;
  18729. var fillKey = this.fillKey_;
  18730. this.saveTextStates_();
  18731. var pixelRatio = this.pixelRatio;
  18732. var baseline = TEXT_ALIGN[textState.textBaseline];
  18733. var offsetY = this.textOffsetY_ * pixelRatio;
  18734. var text = this.text_;
  18735. var strokeWidth = strokeState
  18736. ? (strokeState.lineWidth * Math.abs(textState.scale[0])) / 2
  18737. : 0;
  18738. this.instructions.push([
  18739. canvas_Instruction.DRAW_CHARS,
  18740. begin,
  18741. end,
  18742. baseline,
  18743. textState.overflow,
  18744. fillKey,
  18745. textState.maxAngle,
  18746. pixelRatio,
  18747. offsetY,
  18748. strokeKey,
  18749. strokeWidth * pixelRatio,
  18750. text,
  18751. textKey,
  18752. 1,
  18753. ]);
  18754. this.hitDetectionInstructions.push([
  18755. canvas_Instruction.DRAW_CHARS,
  18756. begin,
  18757. end,
  18758. baseline,
  18759. textState.overflow,
  18760. fillKey,
  18761. textState.maxAngle,
  18762. 1,
  18763. offsetY,
  18764. strokeKey,
  18765. strokeWidth,
  18766. text,
  18767. textKey,
  18768. 1 / pixelRatio,
  18769. ]);
  18770. };
  18771. /**
  18772. * @param {import("../../style/Text.js").default} textStyle Text style.
  18773. * @param {Object} [opt_sharedData] Shared data.
  18774. */
  18775. CanvasTextBuilder.prototype.setTextStyle = function (textStyle, opt_sharedData) {
  18776. var textState, fillState, strokeState;
  18777. if (!textStyle) {
  18778. this.text_ = '';
  18779. }
  18780. else {
  18781. var textFillStyle = textStyle.getFill();
  18782. if (!textFillStyle) {
  18783. fillState = null;
  18784. this.textFillState_ = fillState;
  18785. }
  18786. else {
  18787. fillState = this.textFillState_;
  18788. if (!fillState) {
  18789. fillState = /** @type {import("../canvas.js").FillState} */ ({});
  18790. this.textFillState_ = fillState;
  18791. }
  18792. fillState.fillStyle = asColorLike(textFillStyle.getColor() || defaultFillStyle);
  18793. }
  18794. var textStrokeStyle = textStyle.getStroke();
  18795. if (!textStrokeStyle) {
  18796. strokeState = null;
  18797. this.textStrokeState_ = strokeState;
  18798. }
  18799. else {
  18800. strokeState = this.textStrokeState_;
  18801. if (!strokeState) {
  18802. strokeState = /** @type {import("../canvas.js").StrokeState} */ ({});
  18803. this.textStrokeState_ = strokeState;
  18804. }
  18805. var lineDash = textStrokeStyle.getLineDash();
  18806. var lineDashOffset = textStrokeStyle.getLineDashOffset();
  18807. var lineWidth = textStrokeStyle.getWidth();
  18808. var miterLimit = textStrokeStyle.getMiterLimit();
  18809. strokeState.lineCap = textStrokeStyle.getLineCap() || defaultLineCap;
  18810. strokeState.lineDash = lineDash ? lineDash.slice() : defaultLineDash;
  18811. strokeState.lineDashOffset =
  18812. lineDashOffset === undefined ? defaultLineDashOffset : lineDashOffset;
  18813. strokeState.lineJoin = textStrokeStyle.getLineJoin() || defaultLineJoin;
  18814. strokeState.lineWidth =
  18815. lineWidth === undefined ? defaultLineWidth : lineWidth;
  18816. strokeState.miterLimit =
  18817. miterLimit === undefined ? defaultMiterLimit : miterLimit;
  18818. strokeState.strokeStyle = asColorLike(textStrokeStyle.getColor() || defaultStrokeStyle);
  18819. }
  18820. textState = this.textState_;
  18821. var font = textStyle.getFont() || defaultFont;
  18822. registerFont(font);
  18823. var textScale = textStyle.getScaleArray();
  18824. textState.overflow = textStyle.getOverflow();
  18825. textState.font = font;
  18826. textState.maxAngle = textStyle.getMaxAngle();
  18827. textState.placement = textStyle.getPlacement();
  18828. textState.textAlign = textStyle.getTextAlign();
  18829. textState.justify = textStyle.getJustify();
  18830. textState.textBaseline =
  18831. textStyle.getTextBaseline() || defaultTextBaseline;
  18832. textState.backgroundFill = textStyle.getBackgroundFill();
  18833. textState.backgroundStroke = textStyle.getBackgroundStroke();
  18834. textState.padding = textStyle.getPadding() || defaultPadding;
  18835. textState.scale = textScale === undefined ? [1, 1] : textScale;
  18836. var textOffsetX = textStyle.getOffsetX();
  18837. var textOffsetY = textStyle.getOffsetY();
  18838. var textRotateWithView = textStyle.getRotateWithView();
  18839. var textRotation = textStyle.getRotation();
  18840. this.text_ = textStyle.getText() || '';
  18841. this.textOffsetX_ = textOffsetX === undefined ? 0 : textOffsetX;
  18842. this.textOffsetY_ = textOffsetY === undefined ? 0 : textOffsetY;
  18843. this.textRotateWithView_ =
  18844. textRotateWithView === undefined ? false : textRotateWithView;
  18845. this.textRotation_ = textRotation === undefined ? 0 : textRotation;
  18846. this.strokeKey_ = strokeState
  18847. ? (typeof strokeState.strokeStyle == 'string'
  18848. ? strokeState.strokeStyle
  18849. : getUid(strokeState.strokeStyle)) +
  18850. strokeState.lineCap +
  18851. strokeState.lineDashOffset +
  18852. '|' +
  18853. strokeState.lineWidth +
  18854. strokeState.lineJoin +
  18855. strokeState.miterLimit +
  18856. '[' +
  18857. strokeState.lineDash.join() +
  18858. ']'
  18859. : '';
  18860. this.textKey_ =
  18861. textState.font +
  18862. textState.scale +
  18863. (textState.textAlign || '?') +
  18864. (textState.justify || '?') +
  18865. (textState.textBaseline || '?');
  18866. this.fillKey_ = fillState
  18867. ? typeof fillState.fillStyle == 'string'
  18868. ? fillState.fillStyle
  18869. : '|' + getUid(fillState.fillStyle)
  18870. : '';
  18871. }
  18872. this.declutterImageWithText_ = opt_sharedData;
  18873. };
  18874. return CanvasTextBuilder;
  18875. }(Builder));
  18876. /* harmony default export */ var TextBuilder = (CanvasTextBuilder);
  18877. //# sourceMappingURL=TextBuilder.js.map
  18878. ;// ./node_modules/ol/render/canvas/BuilderGroup.js
  18879. /**
  18880. * @module ol/render/canvas/BuilderGroup
  18881. */
  18882. /**
  18883. * @type {Object<import("../canvas.js").BuilderType, typeof Builder>}
  18884. */
  18885. var BATCH_CONSTRUCTORS = {
  18886. 'Circle': PolygonBuilder,
  18887. 'Default': Builder,
  18888. 'Image': ImageBuilder,
  18889. 'LineString': LineStringBuilder,
  18890. 'Polygon': PolygonBuilder,
  18891. 'Text': TextBuilder,
  18892. };
  18893. var BuilderGroup = /** @class */ (function () {
  18894. /**
  18895. * @param {number} tolerance Tolerance.
  18896. * @param {import("../../extent.js").Extent} maxExtent Max extent.
  18897. * @param {number} resolution Resolution.
  18898. * @param {number} pixelRatio Pixel ratio.
  18899. */
  18900. function BuilderGroup(tolerance, maxExtent, resolution, pixelRatio) {
  18901. /**
  18902. * @private
  18903. * @type {number}
  18904. */
  18905. this.tolerance_ = tolerance;
  18906. /**
  18907. * @private
  18908. * @type {import("../../extent.js").Extent}
  18909. */
  18910. this.maxExtent_ = maxExtent;
  18911. /**
  18912. * @private
  18913. * @type {number}
  18914. */
  18915. this.pixelRatio_ = pixelRatio;
  18916. /**
  18917. * @private
  18918. * @type {number}
  18919. */
  18920. this.resolution_ = resolution;
  18921. /**
  18922. * @private
  18923. * @type {!Object<string, !Object<import("../canvas.js").BuilderType, Builder>>}
  18924. */
  18925. this.buildersByZIndex_ = {};
  18926. }
  18927. /**
  18928. * @return {!Object<string, !Object<import("../canvas.js").BuilderType, import("./Builder.js").SerializableInstructions>>} The serializable instructions
  18929. */
  18930. BuilderGroup.prototype.finish = function () {
  18931. var builderInstructions = {};
  18932. for (var zKey in this.buildersByZIndex_) {
  18933. builderInstructions[zKey] = builderInstructions[zKey] || {};
  18934. var builders = this.buildersByZIndex_[zKey];
  18935. for (var builderKey in builders) {
  18936. var builderInstruction = builders[builderKey].finish();
  18937. builderInstructions[zKey][builderKey] = builderInstruction;
  18938. }
  18939. }
  18940. return builderInstructions;
  18941. };
  18942. /**
  18943. * @param {number|undefined} zIndex Z index.
  18944. * @param {import("../canvas.js").BuilderType} builderType Replay type.
  18945. * @return {import("../VectorContext.js").default} Replay.
  18946. */
  18947. BuilderGroup.prototype.getBuilder = function (zIndex, builderType) {
  18948. var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
  18949. var replays = this.buildersByZIndex_[zIndexKey];
  18950. if (replays === undefined) {
  18951. replays = {};
  18952. this.buildersByZIndex_[zIndexKey] = replays;
  18953. }
  18954. var replay = replays[builderType];
  18955. if (replay === undefined) {
  18956. var Constructor = BATCH_CONSTRUCTORS[builderType];
  18957. replay = new Constructor(this.tolerance_, this.maxExtent_, this.resolution_, this.pixelRatio_);
  18958. replays[builderType] = replay;
  18959. }
  18960. return replay;
  18961. };
  18962. return BuilderGroup;
  18963. }());
  18964. /* harmony default export */ var canvas_BuilderGroup = (BuilderGroup);
  18965. //# sourceMappingURL=BuilderGroup.js.map
  18966. ;// ./node_modules/ol/geom/flat/textpath.js
  18967. /**
  18968. * @module ol/geom/flat/textpath
  18969. */
  18970. /**
  18971. * @param {Array<number>} flatCoordinates Path to put text on.
  18972. * @param {number} offset Start offset of the `flatCoordinates`.
  18973. * @param {number} end End offset of the `flatCoordinates`.
  18974. * @param {number} stride Stride.
  18975. * @param {string} text Text to place on the path.
  18976. * @param {number} startM m along the path where the text starts.
  18977. * @param {number} maxAngle Max angle between adjacent chars in radians.
  18978. * @param {number} scale The product of the text scale and the device pixel ratio.
  18979. * @param {function(string, string, Object<string, number>):number} measureAndCacheTextWidth Measure and cache text width.
  18980. * @param {string} font The font.
  18981. * @param {Object<string, number>} cache A cache of measured widths.
  18982. * @param {number} rotation Rotation to apply to the flatCoordinates to determine whether text needs to be reversed.
  18983. * @return {Array<Array<*>>|null} The result array (or null if `maxAngle` was
  18984. * exceeded). Entries of the array are x, y, anchorX, angle, chunk.
  18985. */
  18986. function drawTextOnPath(flatCoordinates, offset, end, stride, text, startM, maxAngle, scale, measureAndCacheTextWidth, font, cache, rotation) {
  18987. var x2 = flatCoordinates[offset];
  18988. var y2 = flatCoordinates[offset + 1];
  18989. var x1 = 0;
  18990. var y1 = 0;
  18991. var segmentLength = 0;
  18992. var segmentM = 0;
  18993. function advance() {
  18994. x1 = x2;
  18995. y1 = y2;
  18996. offset += stride;
  18997. x2 = flatCoordinates[offset];
  18998. y2 = flatCoordinates[offset + 1];
  18999. segmentM += segmentLength;
  19000. segmentLength = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  19001. }
  19002. do {
  19003. advance();
  19004. } while (offset < end - stride && segmentM + segmentLength < startM);
  19005. var interpolate = segmentLength === 0 ? 0 : (startM - segmentM) / segmentLength;
  19006. var beginX = lerp(x1, x2, interpolate);
  19007. var beginY = lerp(y1, y2, interpolate);
  19008. var startOffset = offset - stride;
  19009. var startLength = segmentM;
  19010. var endM = startM + scale * measureAndCacheTextWidth(font, text, cache);
  19011. while (offset < end - stride && segmentM + segmentLength < endM) {
  19012. advance();
  19013. }
  19014. interpolate = segmentLength === 0 ? 0 : (endM - segmentM) / segmentLength;
  19015. var endX = lerp(x1, x2, interpolate);
  19016. var endY = lerp(y1, y2, interpolate);
  19017. // Keep text upright
  19018. var reverse;
  19019. if (rotation) {
  19020. var flat = [beginX, beginY, endX, endY];
  19021. flat_transform_rotate(flat, 0, 4, 2, rotation, flat, flat);
  19022. reverse = flat[0] > flat[2];
  19023. }
  19024. else {
  19025. reverse = beginX > endX;
  19026. }
  19027. var PI = Math.PI;
  19028. var result = [];
  19029. var singleSegment = startOffset + stride === offset;
  19030. offset = startOffset;
  19031. segmentLength = 0;
  19032. segmentM = startLength;
  19033. x2 = flatCoordinates[offset];
  19034. y2 = flatCoordinates[offset + 1];
  19035. var previousAngle;
  19036. // All on the same segment
  19037. if (singleSegment) {
  19038. advance();
  19039. previousAngle = Math.atan2(y2 - y1, x2 - x1);
  19040. if (reverse) {
  19041. previousAngle += previousAngle > 0 ? -PI : PI;
  19042. }
  19043. var x = (endX + beginX) / 2;
  19044. var y = (endY + beginY) / 2;
  19045. result[0] = [x, y, (endM - startM) / 2, previousAngle, text];
  19046. return result;
  19047. }
  19048. // rendering across line segments
  19049. text = text.replace(/\n/g, ' '); // ensure rendering in single-line as all calculations below don't handle multi-lines
  19050. for (var i = 0, ii = text.length; i < ii;) {
  19051. advance();
  19052. var angle = Math.atan2(y2 - y1, x2 - x1);
  19053. if (reverse) {
  19054. angle += angle > 0 ? -PI : PI;
  19055. }
  19056. if (previousAngle !== undefined) {
  19057. var delta = angle - previousAngle;
  19058. delta += delta > PI ? -2 * PI : delta < -PI ? 2 * PI : 0;
  19059. if (Math.abs(delta) > maxAngle) {
  19060. return null;
  19061. }
  19062. }
  19063. previousAngle = angle;
  19064. var iStart = i;
  19065. var charLength = 0;
  19066. for (; i < ii; ++i) {
  19067. var index = reverse ? ii - i - 1 : i;
  19068. var len = scale * measureAndCacheTextWidth(font, text[index], cache);
  19069. if (offset + stride < end &&
  19070. segmentM + segmentLength < startM + charLength + len / 2) {
  19071. break;
  19072. }
  19073. charLength += len;
  19074. }
  19075. if (i === iStart) {
  19076. continue;
  19077. }
  19078. var chars = reverse
  19079. ? text.substring(ii - iStart, ii - i)
  19080. : text.substring(iStart, i);
  19081. interpolate =
  19082. segmentLength === 0
  19083. ? 0
  19084. : (startM + charLength / 2 - segmentM) / segmentLength;
  19085. var x = lerp(x1, x2, interpolate);
  19086. var y = lerp(y1, y2, interpolate);
  19087. result.push([x, y, charLength / 2, angle, chars]);
  19088. startM += charLength;
  19089. }
  19090. return result;
  19091. }
  19092. //# sourceMappingURL=textpath.js.map
  19093. ;// ./node_modules/ol/render/canvas/Executor.js
  19094. /**
  19095. * @module ol/render/canvas/Executor
  19096. */
  19097. /**
  19098. * @typedef {Object} BBox
  19099. * @property {number} minX Minimal x.
  19100. * @property {number} minY Minimal y.
  19101. * @property {number} maxX Maximal x.
  19102. * @property {number} maxY Maximal y
  19103. * @property {*} value Value.
  19104. */
  19105. /**
  19106. * @typedef {Object} ImageOrLabelDimensions
  19107. * @property {number} drawImageX DrawImageX.
  19108. * @property {number} drawImageY DrawImageY.
  19109. * @property {number} drawImageW DrawImageW.
  19110. * @property {number} drawImageH DrawImageH.
  19111. * @property {number} originX OriginX.
  19112. * @property {number} originY OriginY.
  19113. * @property {Array<number>} scale Scale.
  19114. * @property {BBox} declutterBox DeclutterBox.
  19115. * @property {import("../../transform.js").Transform} canvasTransform CanvasTransform.
  19116. */
  19117. /**
  19118. * @typedef {{0: CanvasRenderingContext2D, 1: number, 2: import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement, 3: ImageOrLabelDimensions, 4: number, 5: Array<*>, 6: Array<*>}} ReplayImageOrLabelArgs
  19119. */
  19120. /**
  19121. * @template T
  19122. * @typedef {function(import("../../Feature.js").FeatureLike, import("../../geom/SimpleGeometry.js").default): T} FeatureCallback
  19123. */
  19124. /**
  19125. * @type {import("../../extent.js").Extent}
  19126. */
  19127. var tmpExtent = createEmpty();
  19128. /** @type {import("../../coordinate.js").Coordinate} */
  19129. var p1 = [];
  19130. /** @type {import("../../coordinate.js").Coordinate} */
  19131. var p2 = [];
  19132. /** @type {import("../../coordinate.js").Coordinate} */
  19133. var p3 = [];
  19134. /** @type {import("../../coordinate.js").Coordinate} */
  19135. var p4 = [];
  19136. /**
  19137. * @param {ReplayImageOrLabelArgs} replayImageOrLabelArgs Arguments to replayImageOrLabel
  19138. * @return {BBox} Declutter bbox.
  19139. */
  19140. function getDeclutterBox(replayImageOrLabelArgs) {
  19141. return replayImageOrLabelArgs[3].declutterBox;
  19142. }
  19143. var rtlRegEx = new RegExp(
  19144. /* eslint-disable prettier/prettier */
  19145. '[' +
  19146. String.fromCharCode(0x00591) + '-' + String.fromCharCode(0x008ff) +
  19147. String.fromCharCode(0x0fb1d) + '-' + String.fromCharCode(0x0fdff) +
  19148. String.fromCharCode(0x0fe70) + '-' + String.fromCharCode(0x0fefc) +
  19149. String.fromCharCode(0x10800) + '-' + String.fromCharCode(0x10fff) +
  19150. String.fromCharCode(0x1e800) + '-' + String.fromCharCode(0x1efff) +
  19151. ']'
  19152. /* eslint-enable prettier/prettier */
  19153. );
  19154. /**
  19155. * @param {string} text Text.
  19156. * @param {string} align Alignment.
  19157. * @return {number} Text alignment.
  19158. */
  19159. function horizontalTextAlign(text, align) {
  19160. if ((align === 'start' || align === 'end') && !rtlRegEx.test(text)) {
  19161. align = align === 'start' ? 'left' : 'right';
  19162. }
  19163. return TEXT_ALIGN[align];
  19164. }
  19165. /**
  19166. * @param {Array<string>} acc Accumulator.
  19167. * @param {string} line Line of text.
  19168. * @param {number} i Index
  19169. * @return {Array<string>} Accumulator.
  19170. */
  19171. function createTextChunks(acc, line, i) {
  19172. if (i > 0) {
  19173. acc.push('\n', '');
  19174. }
  19175. acc.push(line, '');
  19176. return acc;
  19177. }
  19178. var Executor = /** @class */ (function () {
  19179. /**
  19180. * @param {number} resolution Resolution.
  19181. * @param {number} pixelRatio Pixel ratio.
  19182. * @param {boolean} overlaps The replay can have overlapping geometries.
  19183. * @param {import("../canvas.js").SerializableInstructions} instructions The serializable instructions
  19184. */
  19185. function Executor(resolution, pixelRatio, overlaps, instructions) {
  19186. /**
  19187. * @protected
  19188. * @type {boolean}
  19189. */
  19190. this.overlaps = overlaps;
  19191. /**
  19192. * @protected
  19193. * @type {number}
  19194. */
  19195. this.pixelRatio = pixelRatio;
  19196. /**
  19197. * @protected
  19198. * @const
  19199. * @type {number}
  19200. */
  19201. this.resolution = resolution;
  19202. /**
  19203. * @private
  19204. * @type {boolean}
  19205. */
  19206. this.alignFill_;
  19207. /**
  19208. * @protected
  19209. * @type {Array<*>}
  19210. */
  19211. this.instructions = instructions.instructions;
  19212. /**
  19213. * @protected
  19214. * @type {Array<number>}
  19215. */
  19216. this.coordinates = instructions.coordinates;
  19217. /**
  19218. * @private
  19219. * @type {!Object<number,import("../../coordinate.js").Coordinate|Array<import("../../coordinate.js").Coordinate>|Array<Array<import("../../coordinate.js").Coordinate>>>}
  19220. */
  19221. this.coordinateCache_ = {};
  19222. /**
  19223. * @private
  19224. * @type {!import("../../transform.js").Transform}
  19225. */
  19226. this.renderedTransform_ = create();
  19227. /**
  19228. * @protected
  19229. * @type {Array<*>}
  19230. */
  19231. this.hitDetectionInstructions = instructions.hitDetectionInstructions;
  19232. /**
  19233. * @private
  19234. * @type {Array<number>}
  19235. */
  19236. this.pixelCoordinates_ = null;
  19237. /**
  19238. * @private
  19239. * @type {number}
  19240. */
  19241. this.viewRotation_ = 0;
  19242. /**
  19243. * @type {!Object<string, import("../canvas.js").FillState>}
  19244. */
  19245. this.fillStates = instructions.fillStates || {};
  19246. /**
  19247. * @type {!Object<string, import("../canvas.js").StrokeState>}
  19248. */
  19249. this.strokeStates = instructions.strokeStates || {};
  19250. /**
  19251. * @type {!Object<string, import("../canvas.js").TextState>}
  19252. */
  19253. this.textStates = instructions.textStates || {};
  19254. /**
  19255. * @private
  19256. * @type {Object<string, Object<string, number>>}
  19257. */
  19258. this.widths_ = {};
  19259. /**
  19260. * @private
  19261. * @type {Object<string, import("../canvas.js").Label>}
  19262. */
  19263. this.labels_ = {};
  19264. }
  19265. /**
  19266. * @param {string|Array<string>} text Text.
  19267. * @param {string} textKey Text style key.
  19268. * @param {string} fillKey Fill style key.
  19269. * @param {string} strokeKey Stroke style key.
  19270. * @return {import("../canvas.js").Label} Label.
  19271. */
  19272. Executor.prototype.createLabel = function (text, textKey, fillKey, strokeKey) {
  19273. var key = text + textKey + fillKey + strokeKey;
  19274. if (this.labels_[key]) {
  19275. return this.labels_[key];
  19276. }
  19277. var strokeState = strokeKey ? this.strokeStates[strokeKey] : null;
  19278. var fillState = fillKey ? this.fillStates[fillKey] : null;
  19279. var textState = this.textStates[textKey];
  19280. var pixelRatio = this.pixelRatio;
  19281. var scale = [
  19282. textState.scale[0] * pixelRatio,
  19283. textState.scale[1] * pixelRatio,
  19284. ];
  19285. var textIsArray = Array.isArray(text);
  19286. var align = textState.justify
  19287. ? TEXT_ALIGN[textState.justify]
  19288. : horizontalTextAlign(Array.isArray(text) ? text[0] : text, textState.textAlign || defaultTextAlign);
  19289. var strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
  19290. var chunks = textIsArray
  19291. ? text
  19292. : text.split('\n').reduce(createTextChunks, []);
  19293. var _a = getTextDimensions(textState, chunks), width = _a.width, height = _a.height, widths = _a.widths, heights = _a.heights, lineWidths = _a.lineWidths;
  19294. var renderWidth = width + strokeWidth;
  19295. var contextInstructions = [];
  19296. // make canvas 2 pixels wider to account for italic text width measurement errors
  19297. var w = (renderWidth + 2) * scale[0];
  19298. var h = (height + strokeWidth) * scale[1];
  19299. /** @type {import("../canvas.js").Label} */
  19300. var label = {
  19301. width: w < 0 ? Math.floor(w) : Math.ceil(w),
  19302. height: h < 0 ? Math.floor(h) : Math.ceil(h),
  19303. contextInstructions: contextInstructions,
  19304. };
  19305. if (scale[0] != 1 || scale[1] != 1) {
  19306. contextInstructions.push('scale', scale);
  19307. }
  19308. if (strokeKey) {
  19309. contextInstructions.push('strokeStyle', strokeState.strokeStyle);
  19310. contextInstructions.push('lineWidth', strokeWidth);
  19311. contextInstructions.push('lineCap', strokeState.lineCap);
  19312. contextInstructions.push('lineJoin', strokeState.lineJoin);
  19313. contextInstructions.push('miterLimit', strokeState.miterLimit);
  19314. // eslint-disable-next-line
  19315. var Context = WORKER_OFFSCREEN_CANVAS ? OffscreenCanvasRenderingContext2D : CanvasRenderingContext2D;
  19316. if (Context.prototype.setLineDash) {
  19317. contextInstructions.push('setLineDash', [strokeState.lineDash]);
  19318. contextInstructions.push('lineDashOffset', strokeState.lineDashOffset);
  19319. }
  19320. }
  19321. if (fillKey) {
  19322. contextInstructions.push('fillStyle', fillState.fillStyle);
  19323. }
  19324. contextInstructions.push('textBaseline', 'middle');
  19325. contextInstructions.push('textAlign', 'center');
  19326. var leftRight = 0.5 - align;
  19327. var x = align * renderWidth + leftRight * strokeWidth;
  19328. var strokeInstructions = [];
  19329. var fillInstructions = [];
  19330. var lineHeight = 0;
  19331. var lineOffset = 0;
  19332. var widthHeightIndex = 0;
  19333. var lineWidthIndex = 0;
  19334. var previousFont;
  19335. for (var i = 0, ii = chunks.length; i < ii; i += 2) {
  19336. var text_1 = chunks[i];
  19337. if (text_1 === '\n') {
  19338. lineOffset += lineHeight;
  19339. lineHeight = 0;
  19340. x = align * renderWidth + leftRight * strokeWidth;
  19341. ++lineWidthIndex;
  19342. continue;
  19343. }
  19344. var font = chunks[i + 1] || textState.font;
  19345. if (font !== previousFont) {
  19346. if (strokeKey) {
  19347. strokeInstructions.push('font', font);
  19348. }
  19349. if (fillKey) {
  19350. fillInstructions.push('font', font);
  19351. }
  19352. previousFont = font;
  19353. }
  19354. lineHeight = Math.max(lineHeight, heights[widthHeightIndex]);
  19355. var fillStrokeArgs = [
  19356. text_1,
  19357. x +
  19358. leftRight * widths[widthHeightIndex] +
  19359. align * (widths[widthHeightIndex] - lineWidths[lineWidthIndex]),
  19360. 0.5 * (strokeWidth + lineHeight) + lineOffset,
  19361. ];
  19362. x += widths[widthHeightIndex];
  19363. if (strokeKey) {
  19364. strokeInstructions.push('strokeText', fillStrokeArgs);
  19365. }
  19366. if (fillKey) {
  19367. fillInstructions.push('fillText', fillStrokeArgs);
  19368. }
  19369. ++widthHeightIndex;
  19370. }
  19371. Array.prototype.push.apply(contextInstructions, strokeInstructions);
  19372. Array.prototype.push.apply(contextInstructions, fillInstructions);
  19373. this.labels_[key] = label;
  19374. return label;
  19375. };
  19376. /**
  19377. * @param {CanvasRenderingContext2D} context Context.
  19378. * @param {import("../../coordinate.js").Coordinate} p1 1st point of the background box.
  19379. * @param {import("../../coordinate.js").Coordinate} p2 2nd point of the background box.
  19380. * @param {import("../../coordinate.js").Coordinate} p3 3rd point of the background box.
  19381. * @param {import("../../coordinate.js").Coordinate} p4 4th point of the background box.
  19382. * @param {Array<*>} fillInstruction Fill instruction.
  19383. * @param {Array<*>} strokeInstruction Stroke instruction.
  19384. */
  19385. Executor.prototype.replayTextBackground_ = function (context, p1, p2, p3, p4, fillInstruction, strokeInstruction) {
  19386. context.beginPath();
  19387. context.moveTo.apply(context, p1);
  19388. context.lineTo.apply(context, p2);
  19389. context.lineTo.apply(context, p3);
  19390. context.lineTo.apply(context, p4);
  19391. context.lineTo.apply(context, p1);
  19392. if (fillInstruction) {
  19393. this.alignFill_ = /** @type {boolean} */ (fillInstruction[2]);
  19394. this.fill_(context);
  19395. }
  19396. if (strokeInstruction) {
  19397. this.setStrokeStyle_(context,
  19398. /** @type {Array<*>} */ (strokeInstruction));
  19399. context.stroke();
  19400. }
  19401. };
  19402. /**
  19403. * @private
  19404. * @param {number} sheetWidth Width of the sprite sheet.
  19405. * @param {number} sheetHeight Height of the sprite sheet.
  19406. * @param {number} centerX X.
  19407. * @param {number} centerY Y.
  19408. * @param {number} width Width.
  19409. * @param {number} height Height.
  19410. * @param {number} anchorX Anchor X.
  19411. * @param {number} anchorY Anchor Y.
  19412. * @param {number} originX Origin X.
  19413. * @param {number} originY Origin Y.
  19414. * @param {number} rotation Rotation.
  19415. * @param {import("../../size.js").Size} scale Scale.
  19416. * @param {boolean} snapToPixel Snap to pixel.
  19417. * @param {Array<number>} padding Padding.
  19418. * @param {boolean} fillStroke Background fill or stroke.
  19419. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  19420. * @return {ImageOrLabelDimensions} Dimensions for positioning and decluttering the image or label.
  19421. */
  19422. Executor.prototype.calculateImageOrLabelDimensions_ = function (sheetWidth, sheetHeight, centerX, centerY, width, height, anchorX, anchorY, originX, originY, rotation, scale, snapToPixel, padding, fillStroke, feature) {
  19423. anchorX *= scale[0];
  19424. anchorY *= scale[1];
  19425. var x = centerX - anchorX;
  19426. var y = centerY - anchorY;
  19427. var w = width + originX > sheetWidth ? sheetWidth - originX : width;
  19428. var h = height + originY > sheetHeight ? sheetHeight - originY : height;
  19429. var boxW = padding[3] + w * scale[0] + padding[1];
  19430. var boxH = padding[0] + h * scale[1] + padding[2];
  19431. var boxX = x - padding[3];
  19432. var boxY = y - padding[0];
  19433. if (fillStroke || rotation !== 0) {
  19434. p1[0] = boxX;
  19435. p4[0] = boxX;
  19436. p1[1] = boxY;
  19437. p2[1] = boxY;
  19438. p2[0] = boxX + boxW;
  19439. p3[0] = p2[0];
  19440. p3[1] = boxY + boxH;
  19441. p4[1] = p3[1];
  19442. }
  19443. var transform;
  19444. if (rotation !== 0) {
  19445. transform = compose(create(), centerX, centerY, 1, 1, rotation, -centerX, -centerY);
  19446. apply(transform, p1);
  19447. apply(transform, p2);
  19448. apply(transform, p3);
  19449. apply(transform, p4);
  19450. createOrUpdate(Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1]), tmpExtent);
  19451. }
  19452. else {
  19453. createOrUpdate(Math.min(boxX, boxX + boxW), Math.min(boxY, boxY + boxH), Math.max(boxX, boxX + boxW), Math.max(boxY, boxY + boxH), tmpExtent);
  19454. }
  19455. if (snapToPixel) {
  19456. x = Math.round(x);
  19457. y = Math.round(y);
  19458. }
  19459. return {
  19460. drawImageX: x,
  19461. drawImageY: y,
  19462. drawImageW: w,
  19463. drawImageH: h,
  19464. originX: originX,
  19465. originY: originY,
  19466. declutterBox: {
  19467. minX: tmpExtent[0],
  19468. minY: tmpExtent[1],
  19469. maxX: tmpExtent[2],
  19470. maxY: tmpExtent[3],
  19471. value: feature,
  19472. },
  19473. canvasTransform: transform,
  19474. scale: scale,
  19475. };
  19476. };
  19477. /**
  19478. * @private
  19479. * @param {CanvasRenderingContext2D} context Context.
  19480. * @param {number} contextScale Scale of the context.
  19481. * @param {import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} imageOrLabel Image.
  19482. * @param {ImageOrLabelDimensions} dimensions Dimensions.
  19483. * @param {number} opacity Opacity.
  19484. * @param {Array<*>} fillInstruction Fill instruction.
  19485. * @param {Array<*>} strokeInstruction Stroke instruction.
  19486. * @return {boolean} The image or label was rendered.
  19487. */
  19488. Executor.prototype.replayImageOrLabel_ = function (context, contextScale, imageOrLabel, dimensions, opacity, fillInstruction, strokeInstruction) {
  19489. var fillStroke = !!(fillInstruction || strokeInstruction);
  19490. var box = dimensions.declutterBox;
  19491. var canvas = context.canvas;
  19492. var strokePadding = strokeInstruction
  19493. ? (strokeInstruction[2] * dimensions.scale[0]) / 2
  19494. : 0;
  19495. var intersects = box.minX - strokePadding <= canvas.width / contextScale &&
  19496. box.maxX + strokePadding >= 0 &&
  19497. box.minY - strokePadding <= canvas.height / contextScale &&
  19498. box.maxY + strokePadding >= 0;
  19499. if (intersects) {
  19500. if (fillStroke) {
  19501. this.replayTextBackground_(context, p1, p2, p3, p4,
  19502. /** @type {Array<*>} */ (fillInstruction),
  19503. /** @type {Array<*>} */ (strokeInstruction));
  19504. }
  19505. drawImageOrLabel(context, dimensions.canvasTransform, opacity, imageOrLabel, dimensions.originX, dimensions.originY, dimensions.drawImageW, dimensions.drawImageH, dimensions.drawImageX, dimensions.drawImageY, dimensions.scale);
  19506. }
  19507. return true;
  19508. };
  19509. /**
  19510. * @private
  19511. * @param {CanvasRenderingContext2D} context Context.
  19512. */
  19513. Executor.prototype.fill_ = function (context) {
  19514. if (this.alignFill_) {
  19515. var origin_1 = apply(this.renderedTransform_, [0, 0]);
  19516. var repeatSize = 512 * this.pixelRatio;
  19517. context.save();
  19518. context.translate(origin_1[0] % repeatSize, origin_1[1] % repeatSize);
  19519. context.rotate(this.viewRotation_);
  19520. }
  19521. context.fill();
  19522. if (this.alignFill_) {
  19523. context.restore();
  19524. }
  19525. };
  19526. /**
  19527. * @private
  19528. * @param {CanvasRenderingContext2D} context Context.
  19529. * @param {Array<*>} instruction Instruction.
  19530. */
  19531. Executor.prototype.setStrokeStyle_ = function (context, instruction) {
  19532. context['strokeStyle'] =
  19533. /** @type {import("../../colorlike.js").ColorLike} */ (instruction[1]);
  19534. context.lineWidth = /** @type {number} */ (instruction[2]);
  19535. context.lineCap = /** @type {CanvasLineCap} */ (instruction[3]);
  19536. context.lineJoin = /** @type {CanvasLineJoin} */ (instruction[4]);
  19537. context.miterLimit = /** @type {number} */ (instruction[5]);
  19538. if (context.setLineDash) {
  19539. context.lineDashOffset = /** @type {number} */ (instruction[7]);
  19540. context.setLineDash(/** @type {Array<number>} */ (instruction[6]));
  19541. }
  19542. };
  19543. /**
  19544. * @private
  19545. * @param {string|Array<string>} text The text to draw.
  19546. * @param {string} textKey The key of the text state.
  19547. * @param {string} strokeKey The key for the stroke state.
  19548. * @param {string} fillKey The key for the fill state.
  19549. * @return {{label: import("../canvas.js").Label, anchorX: number, anchorY: number}} The text image and its anchor.
  19550. */
  19551. Executor.prototype.drawLabelWithPointPlacement_ = function (text, textKey, strokeKey, fillKey) {
  19552. var textState = this.textStates[textKey];
  19553. var label = this.createLabel(text, textKey, fillKey, strokeKey);
  19554. var strokeState = this.strokeStates[strokeKey];
  19555. var pixelRatio = this.pixelRatio;
  19556. var align = horizontalTextAlign(Array.isArray(text) ? text[0] : text, textState.textAlign || defaultTextAlign);
  19557. var baseline = TEXT_ALIGN[textState.textBaseline || defaultTextBaseline];
  19558. var strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
  19559. // Remove the 2 pixels we added in createLabel() for the anchor
  19560. var width = label.width / pixelRatio - 2 * textState.scale[0];
  19561. var anchorX = align * width + 2 * (0.5 - align) * strokeWidth;
  19562. var anchorY = (baseline * label.height) / pixelRatio +
  19563. 2 * (0.5 - baseline) * strokeWidth;
  19564. return {
  19565. label: label,
  19566. anchorX: anchorX,
  19567. anchorY: anchorY,
  19568. };
  19569. };
  19570. /**
  19571. * @private
  19572. * @param {CanvasRenderingContext2D} context Context.
  19573. * @param {number} contextScale Scale of the context.
  19574. * @param {import("../../transform.js").Transform} transform Transform.
  19575. * @param {Array<*>} instructions Instructions array.
  19576. * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
  19577. * @param {FeatureCallback<T>} [opt_featureCallback] Feature callback.
  19578. * @param {import("../../extent.js").Extent} [opt_hitExtent] Only check
  19579. * features that intersect this extent.
  19580. * @param {import("rbush").default} [opt_declutterTree] Declutter tree.
  19581. * @return {T|undefined} Callback result.
  19582. * @template T
  19583. */
  19584. Executor.prototype.execute_ = function (context, contextScale, transform, instructions, snapToPixel, opt_featureCallback, opt_hitExtent, opt_declutterTree) {
  19585. /** @type {Array<number>} */
  19586. var pixelCoordinates;
  19587. if (this.pixelCoordinates_ && equals(transform, this.renderedTransform_)) {
  19588. pixelCoordinates = this.pixelCoordinates_;
  19589. }
  19590. else {
  19591. if (!this.pixelCoordinates_) {
  19592. this.pixelCoordinates_ = [];
  19593. }
  19594. pixelCoordinates = transform2D(this.coordinates, 0, this.coordinates.length, 2, transform, this.pixelCoordinates_);
  19595. setFromArray(this.renderedTransform_, transform);
  19596. }
  19597. var i = 0; // instruction index
  19598. var ii = instructions.length; // end of instructions
  19599. var d = 0; // data index
  19600. var dd; // end of per-instruction data
  19601. var anchorX, anchorY, prevX, prevY, roundX, roundY, image, text, textKey, strokeKey, fillKey;
  19602. var pendingFill = 0;
  19603. var pendingStroke = 0;
  19604. var lastFillInstruction = null;
  19605. var lastStrokeInstruction = null;
  19606. var coordinateCache = this.coordinateCache_;
  19607. var viewRotation = this.viewRotation_;
  19608. var viewRotationFromTransform = Math.round(Math.atan2(-transform[1], transform[0]) * 1e12) / 1e12;
  19609. var state = /** @type {import("../../render.js").State} */ ({
  19610. context: context,
  19611. pixelRatio: this.pixelRatio,
  19612. resolution: this.resolution,
  19613. rotation: viewRotation,
  19614. });
  19615. // When the batch size gets too big, performance decreases. 200 is a good
  19616. // balance between batch size and number of fill/stroke instructions.
  19617. var batchSize = this.instructions != instructions || this.overlaps ? 0 : 200;
  19618. var /** @type {import("../../Feature.js").FeatureLike} */ feature;
  19619. var x, y, currentGeometry;
  19620. while (i < ii) {
  19621. var instruction = instructions[i];
  19622. var type = /** @type {import("./Instruction.js").default} */ (instruction[0]);
  19623. switch (type) {
  19624. case canvas_Instruction.BEGIN_GEOMETRY:
  19625. feature = /** @type {import("../../Feature.js").FeatureLike} */ (instruction[1]);
  19626. currentGeometry = instruction[3];
  19627. if (!feature.getGeometry()) {
  19628. i = /** @type {number} */ (instruction[2]);
  19629. }
  19630. else if (opt_hitExtent !== undefined &&
  19631. !intersects(opt_hitExtent, currentGeometry.getExtent())) {
  19632. i = /** @type {number} */ (instruction[2]) + 1;
  19633. }
  19634. else {
  19635. ++i;
  19636. }
  19637. break;
  19638. case canvas_Instruction.BEGIN_PATH:
  19639. if (pendingFill > batchSize) {
  19640. this.fill_(context);
  19641. pendingFill = 0;
  19642. }
  19643. if (pendingStroke > batchSize) {
  19644. context.stroke();
  19645. pendingStroke = 0;
  19646. }
  19647. if (!pendingFill && !pendingStroke) {
  19648. context.beginPath();
  19649. prevX = NaN;
  19650. prevY = NaN;
  19651. }
  19652. ++i;
  19653. break;
  19654. case canvas_Instruction.CIRCLE:
  19655. d = /** @type {number} */ (instruction[1]);
  19656. var x1 = pixelCoordinates[d];
  19657. var y1 = pixelCoordinates[d + 1];
  19658. var x2 = pixelCoordinates[d + 2];
  19659. var y2 = pixelCoordinates[d + 3];
  19660. var dx = x2 - x1;
  19661. var dy = y2 - y1;
  19662. var r = Math.sqrt(dx * dx + dy * dy);
  19663. context.moveTo(x1 + r, y1);
  19664. context.arc(x1, y1, r, 0, 2 * Math.PI, true);
  19665. ++i;
  19666. break;
  19667. case canvas_Instruction.CLOSE_PATH:
  19668. context.closePath();
  19669. ++i;
  19670. break;
  19671. case canvas_Instruction.CUSTOM:
  19672. d = /** @type {number} */ (instruction[1]);
  19673. dd = instruction[2];
  19674. var geometry =
  19675. /** @type {import("../../geom/SimpleGeometry.js").default} */ (instruction[3]);
  19676. var renderer = instruction[4];
  19677. var fn = instruction.length == 6 ? instruction[5] : undefined;
  19678. state.geometry = geometry;
  19679. state.feature = feature;
  19680. if (!(i in coordinateCache)) {
  19681. coordinateCache[i] = [];
  19682. }
  19683. var coords = coordinateCache[i];
  19684. if (fn) {
  19685. fn(pixelCoordinates, d, dd, 2, coords);
  19686. }
  19687. else {
  19688. coords[0] = pixelCoordinates[d];
  19689. coords[1] = pixelCoordinates[d + 1];
  19690. coords.length = 2;
  19691. }
  19692. renderer(coords, state);
  19693. ++i;
  19694. break;
  19695. case canvas_Instruction.DRAW_IMAGE:
  19696. d = /** @type {number} */ (instruction[1]);
  19697. dd = /** @type {number} */ (instruction[2]);
  19698. image =
  19699. /** @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} */ (instruction[3]);
  19700. // Remaining arguments in DRAW_IMAGE are in alphabetical order
  19701. anchorX = /** @type {number} */ (instruction[4]);
  19702. anchorY = /** @type {number} */ (instruction[5]);
  19703. var height = /** @type {number} */ (instruction[6]);
  19704. var opacity = /** @type {number} */ (instruction[7]);
  19705. var originX = /** @type {number} */ (instruction[8]);
  19706. var originY = /** @type {number} */ (instruction[9]);
  19707. var rotateWithView = /** @type {boolean} */ (instruction[10]);
  19708. var rotation = /** @type {number} */ (instruction[11]);
  19709. var scale = /** @type {import("../../size.js").Size} */ (instruction[12]);
  19710. var width = /** @type {number} */ (instruction[13]);
  19711. var declutterMode =
  19712. /** @type {"declutter"|"obstacle"|"none"|undefined} */ (instruction[14]);
  19713. var declutterImageWithText =
  19714. /** @type {import("../canvas.js").DeclutterImageWithText} */ (instruction[15]);
  19715. if (!image && instruction.length >= 20) {
  19716. // create label images
  19717. text = /** @type {string} */ (instruction[19]);
  19718. textKey = /** @type {string} */ (instruction[20]);
  19719. strokeKey = /** @type {string} */ (instruction[21]);
  19720. fillKey = /** @type {string} */ (instruction[22]);
  19721. var labelWithAnchor = this.drawLabelWithPointPlacement_(text, textKey, strokeKey, fillKey);
  19722. image = labelWithAnchor.label;
  19723. instruction[3] = image;
  19724. var textOffsetX = /** @type {number} */ (instruction[23]);
  19725. anchorX = (labelWithAnchor.anchorX - textOffsetX) * this.pixelRatio;
  19726. instruction[4] = anchorX;
  19727. var textOffsetY = /** @type {number} */ (instruction[24]);
  19728. anchorY = (labelWithAnchor.anchorY - textOffsetY) * this.pixelRatio;
  19729. instruction[5] = anchorY;
  19730. height = image.height;
  19731. instruction[6] = height;
  19732. width = image.width;
  19733. instruction[13] = width;
  19734. }
  19735. var geometryWidths = void 0;
  19736. if (instruction.length > 25) {
  19737. geometryWidths = /** @type {number} */ (instruction[25]);
  19738. }
  19739. var padding = void 0, backgroundFill = void 0, backgroundStroke = void 0;
  19740. if (instruction.length > 17) {
  19741. padding = /** @type {Array<number>} */ (instruction[16]);
  19742. backgroundFill = /** @type {boolean} */ (instruction[17]);
  19743. backgroundStroke = /** @type {boolean} */ (instruction[18]);
  19744. }
  19745. else {
  19746. padding = defaultPadding;
  19747. backgroundFill = false;
  19748. backgroundStroke = false;
  19749. }
  19750. if (rotateWithView && viewRotationFromTransform) {
  19751. // Canvas is expected to be rotated to reverse view rotation.
  19752. rotation += viewRotation;
  19753. }
  19754. else if (!rotateWithView && !viewRotationFromTransform) {
  19755. // Canvas is not rotated, images need to be rotated back to be north-up.
  19756. rotation -= viewRotation;
  19757. }
  19758. var widthIndex = 0;
  19759. for (; d < dd; d += 2) {
  19760. if (geometryWidths &&
  19761. geometryWidths[widthIndex++] < width / this.pixelRatio) {
  19762. continue;
  19763. }
  19764. var dimensions = this.calculateImageOrLabelDimensions_(image.width, image.height, pixelCoordinates[d], pixelCoordinates[d + 1], width, height, anchorX, anchorY, originX, originY, rotation, scale, snapToPixel, padding, backgroundFill || backgroundStroke, feature);
  19765. /** @type {ReplayImageOrLabelArgs} */
  19766. var args = [
  19767. context,
  19768. contextScale,
  19769. image,
  19770. dimensions,
  19771. opacity,
  19772. backgroundFill
  19773. ? /** @type {Array<*>} */ (lastFillInstruction)
  19774. : null,
  19775. backgroundStroke
  19776. ? /** @type {Array<*>} */ (lastStrokeInstruction)
  19777. : null,
  19778. ];
  19779. if (opt_declutterTree) {
  19780. if (declutterMode === 'none') {
  19781. // not rendered in declutter group
  19782. continue;
  19783. }
  19784. else if (declutterMode === 'obstacle') {
  19785. // will always be drawn, thus no collision detection, but insert as obstacle
  19786. opt_declutterTree.insert(dimensions.declutterBox);
  19787. continue;
  19788. }
  19789. else {
  19790. var imageArgs = void 0;
  19791. var imageDeclutterBox = void 0;
  19792. if (declutterImageWithText) {
  19793. var index = dd - d;
  19794. if (!declutterImageWithText[index]) {
  19795. // We now have the image for an image+text combination.
  19796. declutterImageWithText[index] = args;
  19797. // Don't render anything for now, wait for the text.
  19798. continue;
  19799. }
  19800. imageArgs = declutterImageWithText[index];
  19801. delete declutterImageWithText[index];
  19802. imageDeclutterBox = getDeclutterBox(imageArgs);
  19803. if (opt_declutterTree.collides(imageDeclutterBox)) {
  19804. continue;
  19805. }
  19806. }
  19807. if (opt_declutterTree.collides(dimensions.declutterBox)) {
  19808. continue;
  19809. }
  19810. if (imageArgs) {
  19811. // We now have image and text for an image+text combination.
  19812. opt_declutterTree.insert(imageDeclutterBox);
  19813. // Render the image before we render the text.
  19814. this.replayImageOrLabel_.apply(this, imageArgs);
  19815. }
  19816. opt_declutterTree.insert(dimensions.declutterBox);
  19817. }
  19818. }
  19819. this.replayImageOrLabel_.apply(this, args);
  19820. }
  19821. ++i;
  19822. break;
  19823. case canvas_Instruction.DRAW_CHARS:
  19824. var begin = /** @type {number} */ (instruction[1]);
  19825. var end = /** @type {number} */ (instruction[2]);
  19826. var baseline = /** @type {number} */ (instruction[3]);
  19827. var overflow = /** @type {number} */ (instruction[4]);
  19828. fillKey = /** @type {string} */ (instruction[5]);
  19829. var maxAngle = /** @type {number} */ (instruction[6]);
  19830. var measurePixelRatio = /** @type {number} */ (instruction[7]);
  19831. var offsetY = /** @type {number} */ (instruction[8]);
  19832. strokeKey = /** @type {string} */ (instruction[9]);
  19833. var strokeWidth = /** @type {number} */ (instruction[10]);
  19834. text = /** @type {string} */ (instruction[11]);
  19835. textKey = /** @type {string} */ (instruction[12]);
  19836. var pixelRatioScale = [
  19837. /** @type {number} */ (instruction[13]),
  19838. /** @type {number} */ (instruction[13]),
  19839. ];
  19840. var textState = this.textStates[textKey];
  19841. var font = textState.font;
  19842. var textScale = [
  19843. textState.scale[0] * measurePixelRatio,
  19844. textState.scale[1] * measurePixelRatio,
  19845. ];
  19846. var cachedWidths = void 0;
  19847. if (font in this.widths_) {
  19848. cachedWidths = this.widths_[font];
  19849. }
  19850. else {
  19851. cachedWidths = {};
  19852. this.widths_[font] = cachedWidths;
  19853. }
  19854. var pathLength = lineStringLength(pixelCoordinates, begin, end, 2);
  19855. var textLength = Math.abs(textScale[0]) *
  19856. measureAndCacheTextWidth(font, text, cachedWidths);
  19857. if (overflow || textLength <= pathLength) {
  19858. var textAlign = this.textStates[textKey].textAlign;
  19859. var startM = (pathLength - textLength) * TEXT_ALIGN[textAlign];
  19860. var parts = drawTextOnPath(pixelCoordinates, begin, end, 2, text, startM, maxAngle, Math.abs(textScale[0]), measureAndCacheTextWidth, font, cachedWidths, viewRotationFromTransform ? 0 : this.viewRotation_);
  19861. drawChars: if (parts) {
  19862. /** @type {Array<ReplayImageOrLabelArgs>} */
  19863. var replayImageOrLabelArgs = [];
  19864. var c = void 0, cc = void 0, chars = void 0, label = void 0, part = void 0;
  19865. if (strokeKey) {
  19866. for (c = 0, cc = parts.length; c < cc; ++c) {
  19867. part = parts[c]; // x, y, anchorX, rotation, chunk
  19868. chars = /** @type {string} */ (part[4]);
  19869. label = this.createLabel(chars, textKey, '', strokeKey);
  19870. anchorX =
  19871. /** @type {number} */ (part[2]) +
  19872. (textScale[0] < 0 ? -strokeWidth : strokeWidth);
  19873. anchorY =
  19874. baseline * label.height +
  19875. ((0.5 - baseline) * 2 * strokeWidth * textScale[1]) /
  19876. textScale[0] -
  19877. offsetY;
  19878. var dimensions = this.calculateImageOrLabelDimensions_(label.width, label.height, part[0], part[1], label.width, label.height, anchorX, anchorY, 0, 0, part[3], pixelRatioScale, false, defaultPadding, false, feature);
  19879. if (opt_declutterTree &&
  19880. opt_declutterTree.collides(dimensions.declutterBox)) {
  19881. break drawChars;
  19882. }
  19883. replayImageOrLabelArgs.push([
  19884. context,
  19885. contextScale,
  19886. label,
  19887. dimensions,
  19888. 1,
  19889. null,
  19890. null,
  19891. ]);
  19892. }
  19893. }
  19894. if (fillKey) {
  19895. for (c = 0, cc = parts.length; c < cc; ++c) {
  19896. part = parts[c]; // x, y, anchorX, rotation, chunk
  19897. chars = /** @type {string} */ (part[4]);
  19898. label = this.createLabel(chars, textKey, fillKey, '');
  19899. anchorX = /** @type {number} */ (part[2]);
  19900. anchorY = baseline * label.height - offsetY;
  19901. var dimensions = this.calculateImageOrLabelDimensions_(label.width, label.height, part[0], part[1], label.width, label.height, anchorX, anchorY, 0, 0, part[3], pixelRatioScale, false, defaultPadding, false, feature);
  19902. if (opt_declutterTree &&
  19903. opt_declutterTree.collides(dimensions.declutterBox)) {
  19904. break drawChars;
  19905. }
  19906. replayImageOrLabelArgs.push([
  19907. context,
  19908. contextScale,
  19909. label,
  19910. dimensions,
  19911. 1,
  19912. null,
  19913. null,
  19914. ]);
  19915. }
  19916. }
  19917. if (opt_declutterTree) {
  19918. opt_declutterTree.load(replayImageOrLabelArgs.map(getDeclutterBox));
  19919. }
  19920. for (var i_1 = 0, ii_1 = replayImageOrLabelArgs.length; i_1 < ii_1; ++i_1) {
  19921. this.replayImageOrLabel_.apply(this, replayImageOrLabelArgs[i_1]);
  19922. }
  19923. }
  19924. }
  19925. ++i;
  19926. break;
  19927. case canvas_Instruction.END_GEOMETRY:
  19928. if (opt_featureCallback !== undefined) {
  19929. feature = /** @type {import("../../Feature.js").FeatureLike} */ (instruction[1]);
  19930. var result = opt_featureCallback(feature, currentGeometry);
  19931. if (result) {
  19932. return result;
  19933. }
  19934. }
  19935. ++i;
  19936. break;
  19937. case canvas_Instruction.FILL:
  19938. if (batchSize) {
  19939. pendingFill++;
  19940. }
  19941. else {
  19942. this.fill_(context);
  19943. }
  19944. ++i;
  19945. break;
  19946. case canvas_Instruction.MOVE_TO_LINE_TO:
  19947. d = /** @type {number} */ (instruction[1]);
  19948. dd = /** @type {number} */ (instruction[2]);
  19949. x = pixelCoordinates[d];
  19950. y = pixelCoordinates[d + 1];
  19951. roundX = (x + 0.5) | 0;
  19952. roundY = (y + 0.5) | 0;
  19953. if (roundX !== prevX || roundY !== prevY) {
  19954. context.moveTo(x, y);
  19955. prevX = roundX;
  19956. prevY = roundY;
  19957. }
  19958. for (d += 2; d < dd; d += 2) {
  19959. x = pixelCoordinates[d];
  19960. y = pixelCoordinates[d + 1];
  19961. roundX = (x + 0.5) | 0;
  19962. roundY = (y + 0.5) | 0;
  19963. if (d == dd - 2 || roundX !== prevX || roundY !== prevY) {
  19964. context.lineTo(x, y);
  19965. prevX = roundX;
  19966. prevY = roundY;
  19967. }
  19968. }
  19969. ++i;
  19970. break;
  19971. case canvas_Instruction.SET_FILL_STYLE:
  19972. lastFillInstruction = instruction;
  19973. this.alignFill_ = instruction[2];
  19974. if (pendingFill) {
  19975. this.fill_(context);
  19976. pendingFill = 0;
  19977. if (pendingStroke) {
  19978. context.stroke();
  19979. pendingStroke = 0;
  19980. }
  19981. }
  19982. context.fillStyle =
  19983. /** @type {import("../../colorlike.js").ColorLike} */ (instruction[1]);
  19984. ++i;
  19985. break;
  19986. case canvas_Instruction.SET_STROKE_STYLE:
  19987. lastStrokeInstruction = instruction;
  19988. if (pendingStroke) {
  19989. context.stroke();
  19990. pendingStroke = 0;
  19991. }
  19992. this.setStrokeStyle_(context, /** @type {Array<*>} */ (instruction));
  19993. ++i;
  19994. break;
  19995. case canvas_Instruction.STROKE:
  19996. if (batchSize) {
  19997. pendingStroke++;
  19998. }
  19999. else {
  20000. context.stroke();
  20001. }
  20002. ++i;
  20003. break;
  20004. default: // consume the instruction anyway, to avoid an infinite loop
  20005. ++i;
  20006. break;
  20007. }
  20008. }
  20009. if (pendingFill) {
  20010. this.fill_(context);
  20011. }
  20012. if (pendingStroke) {
  20013. context.stroke();
  20014. }
  20015. return undefined;
  20016. };
  20017. /**
  20018. * @param {CanvasRenderingContext2D} context Context.
  20019. * @param {number} contextScale Scale of the context.
  20020. * @param {import("../../transform.js").Transform} transform Transform.
  20021. * @param {number} viewRotation View rotation.
  20022. * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
  20023. * @param {import("rbush").default} [opt_declutterTree] Declutter tree.
  20024. */
  20025. Executor.prototype.execute = function (context, contextScale, transform, viewRotation, snapToPixel, opt_declutterTree) {
  20026. this.viewRotation_ = viewRotation;
  20027. this.execute_(context, contextScale, transform, this.instructions, snapToPixel, undefined, undefined, opt_declutterTree);
  20028. };
  20029. /**
  20030. * @param {CanvasRenderingContext2D} context Context.
  20031. * @param {import("../../transform.js").Transform} transform Transform.
  20032. * @param {number} viewRotation View rotation.
  20033. * @param {FeatureCallback<T>} [opt_featureCallback] Feature callback.
  20034. * @param {import("../../extent.js").Extent} [opt_hitExtent] Only check
  20035. * features that intersect this extent.
  20036. * @return {T|undefined} Callback result.
  20037. * @template T
  20038. */
  20039. Executor.prototype.executeHitDetection = function (context, transform, viewRotation, opt_featureCallback, opt_hitExtent) {
  20040. this.viewRotation_ = viewRotation;
  20041. return this.execute_(context, 1, transform, this.hitDetectionInstructions, true, opt_featureCallback, opt_hitExtent);
  20042. };
  20043. return Executor;
  20044. }());
  20045. /* harmony default export */ var canvas_Executor = (Executor);
  20046. //# sourceMappingURL=Executor.js.map
  20047. ;// ./node_modules/ol/render/canvas/ExecutorGroup.js
  20048. /**
  20049. * @module ol/render/canvas/ExecutorGroup
  20050. */
  20051. /**
  20052. * @const
  20053. * @type {Array<import("../canvas.js").BuilderType>}
  20054. */
  20055. var ORDER = ['Polygon', 'Circle', 'LineString', 'Image', 'Text', 'Default'];
  20056. var ExecutorGroup = /** @class */ (function () {
  20057. /**
  20058. * @param {import("../../extent.js").Extent} maxExtent Max extent for clipping. When a
  20059. * `maxExtent` was set on the Builder for this executor group, the same `maxExtent`
  20060. * should be set here, unless the target context does not exceed that extent (which
  20061. * can be the case when rendering to tiles).
  20062. * @param {number} resolution Resolution.
  20063. * @param {number} pixelRatio Pixel ratio.
  20064. * @param {boolean} overlaps The executor group can have overlapping geometries.
  20065. * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions
  20066. * The serializable instructions.
  20067. * @param {number} [opt_renderBuffer] Optional rendering buffer.
  20068. */
  20069. function ExecutorGroup(maxExtent, resolution, pixelRatio, overlaps, allInstructions, opt_renderBuffer) {
  20070. /**
  20071. * @private
  20072. * @type {import("../../extent.js").Extent}
  20073. */
  20074. this.maxExtent_ = maxExtent;
  20075. /**
  20076. * @private
  20077. * @type {boolean}
  20078. */
  20079. this.overlaps_ = overlaps;
  20080. /**
  20081. * @private
  20082. * @type {number}
  20083. */
  20084. this.pixelRatio_ = pixelRatio;
  20085. /**
  20086. * @private
  20087. * @type {number}
  20088. */
  20089. this.resolution_ = resolution;
  20090. /**
  20091. * @private
  20092. * @type {number|undefined}
  20093. */
  20094. this.renderBuffer_ = opt_renderBuffer;
  20095. /**
  20096. * @private
  20097. * @type {!Object<string, !Object<import("../canvas.js").BuilderType, import("./Executor").default>>}
  20098. */
  20099. this.executorsByZIndex_ = {};
  20100. /**
  20101. * @private
  20102. * @type {CanvasRenderingContext2D}
  20103. */
  20104. this.hitDetectionContext_ = null;
  20105. /**
  20106. * @private
  20107. * @type {import("../../transform.js").Transform}
  20108. */
  20109. this.hitDetectionTransform_ = create();
  20110. this.createExecutors_(allInstructions);
  20111. }
  20112. /**
  20113. * @param {CanvasRenderingContext2D} context Context.
  20114. * @param {import("../../transform.js").Transform} transform Transform.
  20115. */
  20116. ExecutorGroup.prototype.clip = function (context, transform) {
  20117. var flatClipCoords = this.getClipCoords(transform);
  20118. context.beginPath();
  20119. context.moveTo(flatClipCoords[0], flatClipCoords[1]);
  20120. context.lineTo(flatClipCoords[2], flatClipCoords[3]);
  20121. context.lineTo(flatClipCoords[4], flatClipCoords[5]);
  20122. context.lineTo(flatClipCoords[6], flatClipCoords[7]);
  20123. context.clip();
  20124. };
  20125. /**
  20126. * Create executors and populate them using the provided instructions.
  20127. * @private
  20128. * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions The serializable instructions
  20129. */
  20130. ExecutorGroup.prototype.createExecutors_ = function (allInstructions) {
  20131. for (var zIndex in allInstructions) {
  20132. var executors = this.executorsByZIndex_[zIndex];
  20133. if (executors === undefined) {
  20134. executors = {};
  20135. this.executorsByZIndex_[zIndex] = executors;
  20136. }
  20137. var instructionByZindex = allInstructions[zIndex];
  20138. for (var builderType in instructionByZindex) {
  20139. var instructions = instructionByZindex[builderType];
  20140. executors[builderType] = new canvas_Executor(this.resolution_, this.pixelRatio_, this.overlaps_, instructions);
  20141. }
  20142. }
  20143. };
  20144. /**
  20145. * @param {Array<import("../canvas.js").BuilderType>} executors Executors.
  20146. * @return {boolean} Has executors of the provided types.
  20147. */
  20148. ExecutorGroup.prototype.hasExecutors = function (executors) {
  20149. for (var zIndex in this.executorsByZIndex_) {
  20150. var candidates = this.executorsByZIndex_[zIndex];
  20151. for (var i = 0, ii = executors.length; i < ii; ++i) {
  20152. if (executors[i] in candidates) {
  20153. return true;
  20154. }
  20155. }
  20156. }
  20157. return false;
  20158. };
  20159. /**
  20160. * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
  20161. * @param {number} resolution Resolution.
  20162. * @param {number} rotation Rotation.
  20163. * @param {number} hitTolerance Hit tolerance in pixels.
  20164. * @param {function(import("../../Feature.js").FeatureLike, import("../../geom/SimpleGeometry.js").default, number): T} callback Feature callback.
  20165. * @param {Array<import("../../Feature.js").FeatureLike>} declutteredFeatures Decluttered features.
  20166. * @return {T|undefined} Callback result.
  20167. * @template T
  20168. */
  20169. ExecutorGroup.prototype.forEachFeatureAtCoordinate = function (coordinate, resolution, rotation, hitTolerance, callback, declutteredFeatures) {
  20170. hitTolerance = Math.round(hitTolerance);
  20171. var contextSize = hitTolerance * 2 + 1;
  20172. var transform = compose(this.hitDetectionTransform_, hitTolerance + 0.5, hitTolerance + 0.5, 1 / resolution, -1 / resolution, -rotation, -coordinate[0], -coordinate[1]);
  20173. var newContext = !this.hitDetectionContext_;
  20174. if (newContext) {
  20175. this.hitDetectionContext_ = createCanvasContext2D(contextSize, contextSize);
  20176. }
  20177. var context = this.hitDetectionContext_;
  20178. if (context.canvas.width !== contextSize ||
  20179. context.canvas.height !== contextSize) {
  20180. context.canvas.width = contextSize;
  20181. context.canvas.height = contextSize;
  20182. }
  20183. else if (!newContext) {
  20184. context.clearRect(0, 0, contextSize, contextSize);
  20185. }
  20186. /**
  20187. * @type {import("../../extent.js").Extent}
  20188. */
  20189. var hitExtent;
  20190. if (this.renderBuffer_ !== undefined) {
  20191. hitExtent = createEmpty();
  20192. extendCoordinate(hitExtent, coordinate);
  20193. buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
  20194. }
  20195. var indexes = getPixelIndexArray(hitTolerance);
  20196. var builderType;
  20197. /**
  20198. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  20199. * @param {import("../../geom/SimpleGeometry.js").default} geometry Geometry.
  20200. * @return {T|undefined} Callback result.
  20201. */
  20202. function featureCallback(feature, geometry) {
  20203. var imageData = context.getImageData(0, 0, contextSize, contextSize).data;
  20204. for (var i_1 = 0, ii = indexes.length; i_1 < ii; i_1++) {
  20205. if (imageData[indexes[i_1]] > 0) {
  20206. if (!declutteredFeatures ||
  20207. (builderType !== 'Image' && builderType !== 'Text') ||
  20208. declutteredFeatures.indexOf(feature) !== -1) {
  20209. var idx = (indexes[i_1] - 3) / 4;
  20210. var x = hitTolerance - (idx % contextSize);
  20211. var y = hitTolerance - ((idx / contextSize) | 0);
  20212. var result_1 = callback(feature, geometry, x * x + y * y);
  20213. if (result_1) {
  20214. return result_1;
  20215. }
  20216. }
  20217. context.clearRect(0, 0, contextSize, contextSize);
  20218. break;
  20219. }
  20220. }
  20221. return undefined;
  20222. }
  20223. /** @type {Array<number>} */
  20224. var zs = Object.keys(this.executorsByZIndex_).map(Number);
  20225. zs.sort(numberSafeCompareFunction);
  20226. var i, j, executors, executor, result;
  20227. for (i = zs.length - 1; i >= 0; --i) {
  20228. var zIndexKey = zs[i].toString();
  20229. executors = this.executorsByZIndex_[zIndexKey];
  20230. for (j = ORDER.length - 1; j >= 0; --j) {
  20231. builderType = ORDER[j];
  20232. executor = executors[builderType];
  20233. if (executor !== undefined) {
  20234. result = executor.executeHitDetection(context, transform, rotation, featureCallback, hitExtent);
  20235. if (result) {
  20236. return result;
  20237. }
  20238. }
  20239. }
  20240. }
  20241. return undefined;
  20242. };
  20243. /**
  20244. * @param {import("../../transform.js").Transform} transform Transform.
  20245. * @return {Array<number>|null} Clip coordinates.
  20246. */
  20247. ExecutorGroup.prototype.getClipCoords = function (transform) {
  20248. var maxExtent = this.maxExtent_;
  20249. if (!maxExtent) {
  20250. return null;
  20251. }
  20252. var minX = maxExtent[0];
  20253. var minY = maxExtent[1];
  20254. var maxX = maxExtent[2];
  20255. var maxY = maxExtent[3];
  20256. var flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
  20257. transform2D(flatClipCoords, 0, 8, 2, transform, flatClipCoords);
  20258. return flatClipCoords;
  20259. };
  20260. /**
  20261. * @return {boolean} Is empty.
  20262. */
  20263. ExecutorGroup.prototype.isEmpty = function () {
  20264. return obj_isEmpty(this.executorsByZIndex_);
  20265. };
  20266. /**
  20267. * @param {CanvasRenderingContext2D} context Context.
  20268. * @param {number} contextScale Scale of the context.
  20269. * @param {import("../../transform.js").Transform} transform Transform.
  20270. * @param {number} viewRotation View rotation.
  20271. * @param {boolean} snapToPixel Snap point symbols and test to integer pixel.
  20272. * @param {Array<import("../canvas.js").BuilderType>} [opt_builderTypes] Ordered replay types to replay.
  20273. * Default is {@link module:ol/render/replay~ORDER}
  20274. * @param {import("rbush").default} [opt_declutterTree] Declutter tree.
  20275. */
  20276. ExecutorGroup.prototype.execute = function (context, contextScale, transform, viewRotation, snapToPixel, opt_builderTypes, opt_declutterTree) {
  20277. /** @type {Array<number>} */
  20278. var zs = Object.keys(this.executorsByZIndex_).map(Number);
  20279. zs.sort(numberSafeCompareFunction);
  20280. // setup clipping so that the parts of over-simplified geometries are not
  20281. // visible outside the current extent when panning
  20282. if (this.maxExtent_) {
  20283. context.save();
  20284. this.clip(context, transform);
  20285. }
  20286. var builderTypes = opt_builderTypes ? opt_builderTypes : ORDER;
  20287. var i, ii, j, jj, replays, replay;
  20288. if (opt_declutterTree) {
  20289. zs.reverse();
  20290. }
  20291. for (i = 0, ii = zs.length; i < ii; ++i) {
  20292. var zIndexKey = zs[i].toString();
  20293. replays = this.executorsByZIndex_[zIndexKey];
  20294. for (j = 0, jj = builderTypes.length; j < jj; ++j) {
  20295. var builderType = builderTypes[j];
  20296. replay = replays[builderType];
  20297. if (replay !== undefined) {
  20298. replay.execute(context, contextScale, transform, viewRotation, snapToPixel, opt_declutterTree);
  20299. }
  20300. }
  20301. }
  20302. if (this.maxExtent_) {
  20303. context.restore();
  20304. }
  20305. };
  20306. return ExecutorGroup;
  20307. }());
  20308. /**
  20309. * This cache is used to store arrays of indexes for calculated pixel circles
  20310. * to increase performance.
  20311. * It is a static property to allow each Replaygroup to access it.
  20312. * @type {Object<number, Array<number>>}
  20313. */
  20314. var circlePixelIndexArrayCache = {};
  20315. /**
  20316. * This methods creates an array with indexes of all pixels within a circle,
  20317. * ordered by how close they are to the center.
  20318. * A cache is used to increase performance.
  20319. * @param {number} radius Radius.
  20320. * @return {Array<number>} An array with indexes within a circle.
  20321. */
  20322. function getPixelIndexArray(radius) {
  20323. if (circlePixelIndexArrayCache[radius] !== undefined) {
  20324. return circlePixelIndexArrayCache[radius];
  20325. }
  20326. var size = radius * 2 + 1;
  20327. var maxDistanceSq = radius * radius;
  20328. var distances = new Array(maxDistanceSq + 1);
  20329. for (var i = 0; i <= radius; ++i) {
  20330. for (var j = 0; j <= radius; ++j) {
  20331. var distanceSq = i * i + j * j;
  20332. if (distanceSq > maxDistanceSq) {
  20333. break;
  20334. }
  20335. var distance = distances[distanceSq];
  20336. if (!distance) {
  20337. distance = [];
  20338. distances[distanceSq] = distance;
  20339. }
  20340. distance.push(((radius + i) * size + (radius + j)) * 4 + 3);
  20341. if (i > 0) {
  20342. distance.push(((radius - i) * size + (radius + j)) * 4 + 3);
  20343. }
  20344. if (j > 0) {
  20345. distance.push(((radius + i) * size + (radius - j)) * 4 + 3);
  20346. if (i > 0) {
  20347. distance.push(((radius - i) * size + (radius - j)) * 4 + 3);
  20348. }
  20349. }
  20350. }
  20351. }
  20352. var pixelIndex = [];
  20353. for (var i = 0, ii = distances.length; i < ii; ++i) {
  20354. if (distances[i]) {
  20355. pixelIndex.push.apply(pixelIndex, distances[i]);
  20356. }
  20357. }
  20358. circlePixelIndexArrayCache[radius] = pixelIndex;
  20359. return pixelIndex;
  20360. }
  20361. /* harmony default export */ var canvas_ExecutorGroup = (ExecutorGroup);
  20362. //# sourceMappingURL=ExecutorGroup.js.map
  20363. ;// ./node_modules/ol/ViewHint.js
  20364. /**
  20365. * @module ol/ViewHint
  20366. */
  20367. /**
  20368. * @enum {number}
  20369. */
  20370. /* harmony default export */ var ViewHint = ({
  20371. ANIMATING: 0,
  20372. INTERACTING: 1,
  20373. });
  20374. //# sourceMappingURL=ViewHint.js.map
  20375. ;// ./node_modules/ol/render/canvas/Immediate.js
  20376. /**
  20377. * @module ol/render/canvas/Immediate
  20378. */
  20379. // FIXME test, especially polygons with holes and multipolygons
  20380. // FIXME need to handle large thick features (where pixel size matters)
  20381. // FIXME add offset and end to ol/geom/flat/transform~transform2D?
  20382. var Immediate_extends = (undefined && undefined.__extends) || (function () {
  20383. var extendStatics = function (d, b) {
  20384. extendStatics = Object.setPrototypeOf ||
  20385. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  20386. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  20387. return extendStatics(d, b);
  20388. };
  20389. return function (d, b) {
  20390. if (typeof b !== "function" && b !== null)
  20391. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  20392. extendStatics(d, b);
  20393. function __() { this.constructor = d; }
  20394. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20395. };
  20396. })();
  20397. /**
  20398. * @classdesc
  20399. * A concrete subclass of {@link module:ol/render/VectorContext~VectorContext VectorContext} that implements
  20400. * direct rendering of features and geometries to an HTML5 Canvas context.
  20401. * Instances of this class are created internally by the library and
  20402. * provided to application code as vectorContext member of the
  20403. * {@link module:ol/render/Event~RenderEvent RenderEvent} object associated with postcompose, precompose and
  20404. * render events emitted by layers and maps.
  20405. */
  20406. var CanvasImmediateRenderer = /** @class */ (function (_super) {
  20407. Immediate_extends(CanvasImmediateRenderer, _super);
  20408. /**
  20409. * @param {CanvasRenderingContext2D} context Context.
  20410. * @param {number} pixelRatio Pixel ratio.
  20411. * @param {import("../../extent.js").Extent} extent Extent.
  20412. * @param {import("../../transform.js").Transform} transform Transform.
  20413. * @param {number} viewRotation View rotation.
  20414. * @param {number} [opt_squaredTolerance] Optional squared tolerance for simplification.
  20415. * @param {import("../../proj.js").TransformFunction} [opt_userTransform] Transform from user to view projection.
  20416. */
  20417. function CanvasImmediateRenderer(context, pixelRatio, extent, transform, viewRotation, opt_squaredTolerance, opt_userTransform) {
  20418. var _this = _super.call(this) || this;
  20419. /**
  20420. * @private
  20421. * @type {CanvasRenderingContext2D}
  20422. */
  20423. _this.context_ = context;
  20424. /**
  20425. * @private
  20426. * @type {number}
  20427. */
  20428. _this.pixelRatio_ = pixelRatio;
  20429. /**
  20430. * @private
  20431. * @type {import("../../extent.js").Extent}
  20432. */
  20433. _this.extent_ = extent;
  20434. /**
  20435. * @private
  20436. * @type {import("../../transform.js").Transform}
  20437. */
  20438. _this.transform_ = transform;
  20439. /**
  20440. * @private
  20441. * @type {number}
  20442. */
  20443. _this.viewRotation_ = viewRotation;
  20444. /**
  20445. * @private
  20446. * @type {number}
  20447. */
  20448. _this.squaredTolerance_ = opt_squaredTolerance;
  20449. /**
  20450. * @private
  20451. * @type {import("../../proj.js").TransformFunction}
  20452. */
  20453. _this.userTransform_ = opt_userTransform;
  20454. /**
  20455. * @private
  20456. * @type {?import("../canvas.js").FillState}
  20457. */
  20458. _this.contextFillState_ = null;
  20459. /**
  20460. * @private
  20461. * @type {?import("../canvas.js").StrokeState}
  20462. */
  20463. _this.contextStrokeState_ = null;
  20464. /**
  20465. * @private
  20466. * @type {?import("../canvas.js").TextState}
  20467. */
  20468. _this.contextTextState_ = null;
  20469. /**
  20470. * @private
  20471. * @type {?import("../canvas.js").FillState}
  20472. */
  20473. _this.fillState_ = null;
  20474. /**
  20475. * @private
  20476. * @type {?import("../canvas.js").StrokeState}
  20477. */
  20478. _this.strokeState_ = null;
  20479. /**
  20480. * @private
  20481. * @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement}
  20482. */
  20483. _this.image_ = null;
  20484. /**
  20485. * @private
  20486. * @type {number}
  20487. */
  20488. _this.imageAnchorX_ = 0;
  20489. /**
  20490. * @private
  20491. * @type {number}
  20492. */
  20493. _this.imageAnchorY_ = 0;
  20494. /**
  20495. * @private
  20496. * @type {number}
  20497. */
  20498. _this.imageHeight_ = 0;
  20499. /**
  20500. * @private
  20501. * @type {number}
  20502. */
  20503. _this.imageOpacity_ = 0;
  20504. /**
  20505. * @private
  20506. * @type {number}
  20507. */
  20508. _this.imageOriginX_ = 0;
  20509. /**
  20510. * @private
  20511. * @type {number}
  20512. */
  20513. _this.imageOriginY_ = 0;
  20514. /**
  20515. * @private
  20516. * @type {boolean}
  20517. */
  20518. _this.imageRotateWithView_ = false;
  20519. /**
  20520. * @private
  20521. * @type {number}
  20522. */
  20523. _this.imageRotation_ = 0;
  20524. /**
  20525. * @private
  20526. * @type {import("../../size.js").Size}
  20527. */
  20528. _this.imageScale_ = [0, 0];
  20529. /**
  20530. * @private
  20531. * @type {number}
  20532. */
  20533. _this.imageWidth_ = 0;
  20534. /**
  20535. * @private
  20536. * @type {string}
  20537. */
  20538. _this.text_ = '';
  20539. /**
  20540. * @private
  20541. * @type {number}
  20542. */
  20543. _this.textOffsetX_ = 0;
  20544. /**
  20545. * @private
  20546. * @type {number}
  20547. */
  20548. _this.textOffsetY_ = 0;
  20549. /**
  20550. * @private
  20551. * @type {boolean}
  20552. */
  20553. _this.textRotateWithView_ = false;
  20554. /**
  20555. * @private
  20556. * @type {number}
  20557. */
  20558. _this.textRotation_ = 0;
  20559. /**
  20560. * @private
  20561. * @type {import("../../size.js").Size}
  20562. */
  20563. _this.textScale_ = [0, 0];
  20564. /**
  20565. * @private
  20566. * @type {?import("../canvas.js").FillState}
  20567. */
  20568. _this.textFillState_ = null;
  20569. /**
  20570. * @private
  20571. * @type {?import("../canvas.js").StrokeState}
  20572. */
  20573. _this.textStrokeState_ = null;
  20574. /**
  20575. * @private
  20576. * @type {?import("../canvas.js").TextState}
  20577. */
  20578. _this.textState_ = null;
  20579. /**
  20580. * @private
  20581. * @type {Array<number>}
  20582. */
  20583. _this.pixelCoordinates_ = [];
  20584. /**
  20585. * @private
  20586. * @type {import("../../transform.js").Transform}
  20587. */
  20588. _this.tmpLocalTransform_ = create();
  20589. return _this;
  20590. }
  20591. /**
  20592. * @param {Array<number>} flatCoordinates Flat coordinates.
  20593. * @param {number} offset Offset.
  20594. * @param {number} end End.
  20595. * @param {number} stride Stride.
  20596. * @private
  20597. */
  20598. CanvasImmediateRenderer.prototype.drawImages_ = function (flatCoordinates, offset, end, stride) {
  20599. if (!this.image_) {
  20600. return;
  20601. }
  20602. var pixelCoordinates = transform2D(flatCoordinates, offset, end, stride, this.transform_, this.pixelCoordinates_);
  20603. var context = this.context_;
  20604. var localTransform = this.tmpLocalTransform_;
  20605. var alpha = context.globalAlpha;
  20606. if (this.imageOpacity_ != 1) {
  20607. context.globalAlpha = alpha * this.imageOpacity_;
  20608. }
  20609. var rotation = this.imageRotation_;
  20610. if (this.imageRotateWithView_) {
  20611. rotation += this.viewRotation_;
  20612. }
  20613. for (var i = 0, ii = pixelCoordinates.length; i < ii; i += 2) {
  20614. var x = pixelCoordinates[i] - this.imageAnchorX_;
  20615. var y = pixelCoordinates[i + 1] - this.imageAnchorY_;
  20616. if (rotation !== 0 ||
  20617. this.imageScale_[0] != 1 ||
  20618. this.imageScale_[1] != 1) {
  20619. var centerX = x + this.imageAnchorX_;
  20620. var centerY = y + this.imageAnchorY_;
  20621. compose(localTransform, centerX, centerY, 1, 1, rotation, -centerX, -centerY);
  20622. context.setTransform.apply(context, localTransform);
  20623. context.translate(centerX, centerY);
  20624. context.scale(this.imageScale_[0], this.imageScale_[1]);
  20625. context.drawImage(this.image_, this.imageOriginX_, this.imageOriginY_, this.imageWidth_, this.imageHeight_, -this.imageAnchorX_, -this.imageAnchorY_, this.imageWidth_, this.imageHeight_);
  20626. context.setTransform(1, 0, 0, 1, 0, 0);
  20627. }
  20628. else {
  20629. context.drawImage(this.image_, this.imageOriginX_, this.imageOriginY_, this.imageWidth_, this.imageHeight_, x, y, this.imageWidth_, this.imageHeight_);
  20630. }
  20631. }
  20632. if (this.imageOpacity_ != 1) {
  20633. context.globalAlpha = alpha;
  20634. }
  20635. };
  20636. /**
  20637. * @param {Array<number>} flatCoordinates Flat coordinates.
  20638. * @param {number} offset Offset.
  20639. * @param {number} end End.
  20640. * @param {number} stride Stride.
  20641. * @private
  20642. */
  20643. CanvasImmediateRenderer.prototype.drawText_ = function (flatCoordinates, offset, end, stride) {
  20644. if (!this.textState_ || this.text_ === '') {
  20645. return;
  20646. }
  20647. if (this.textFillState_) {
  20648. this.setContextFillState_(this.textFillState_);
  20649. }
  20650. if (this.textStrokeState_) {
  20651. this.setContextStrokeState_(this.textStrokeState_);
  20652. }
  20653. this.setContextTextState_(this.textState_);
  20654. var pixelCoordinates = transform2D(flatCoordinates, offset, end, stride, this.transform_, this.pixelCoordinates_);
  20655. var context = this.context_;
  20656. var rotation = this.textRotation_;
  20657. if (this.textRotateWithView_) {
  20658. rotation += this.viewRotation_;
  20659. }
  20660. for (; offset < end; offset += stride) {
  20661. var x = pixelCoordinates[offset] + this.textOffsetX_;
  20662. var y = pixelCoordinates[offset + 1] + this.textOffsetY_;
  20663. if (rotation !== 0 ||
  20664. this.textScale_[0] != 1 ||
  20665. this.textScale_[1] != 1) {
  20666. var localTransform = compose(this.tmpLocalTransform_, x, y, 1, 1, rotation, -x, -y);
  20667. context.setTransform.apply(context, localTransform);
  20668. context.translate(x, y);
  20669. context.scale(this.textScale_[0], this.textScale_[1]);
  20670. if (this.textStrokeState_) {
  20671. context.strokeText(this.text_, 0, 0);
  20672. }
  20673. if (this.textFillState_) {
  20674. context.fillText(this.text_, 0, 0);
  20675. }
  20676. context.setTransform(1, 0, 0, 1, 0, 0);
  20677. }
  20678. else {
  20679. if (this.textStrokeState_) {
  20680. context.strokeText(this.text_, x, y);
  20681. }
  20682. if (this.textFillState_) {
  20683. context.fillText(this.text_, x, y);
  20684. }
  20685. }
  20686. }
  20687. };
  20688. /**
  20689. * @param {Array<number>} flatCoordinates Flat coordinates.
  20690. * @param {number} offset Offset.
  20691. * @param {number} end End.
  20692. * @param {number} stride Stride.
  20693. * @param {boolean} close Close.
  20694. * @private
  20695. * @return {number} end End.
  20696. */
  20697. CanvasImmediateRenderer.prototype.moveToLineTo_ = function (flatCoordinates, offset, end, stride, close) {
  20698. var context = this.context_;
  20699. var pixelCoordinates = transform2D(flatCoordinates, offset, end, stride, this.transform_, this.pixelCoordinates_);
  20700. context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
  20701. var length = pixelCoordinates.length;
  20702. if (close) {
  20703. length -= 2;
  20704. }
  20705. for (var i = 2; i < length; i += 2) {
  20706. context.lineTo(pixelCoordinates[i], pixelCoordinates[i + 1]);
  20707. }
  20708. if (close) {
  20709. context.closePath();
  20710. }
  20711. return end;
  20712. };
  20713. /**
  20714. * @param {Array<number>} flatCoordinates Flat coordinates.
  20715. * @param {number} offset Offset.
  20716. * @param {Array<number>} ends Ends.
  20717. * @param {number} stride Stride.
  20718. * @private
  20719. * @return {number} End.
  20720. */
  20721. CanvasImmediateRenderer.prototype.drawRings_ = function (flatCoordinates, offset, ends, stride) {
  20722. for (var i = 0, ii = ends.length; i < ii; ++i) {
  20723. offset = this.moveToLineTo_(flatCoordinates, offset, ends[i], stride, true);
  20724. }
  20725. return offset;
  20726. };
  20727. /**
  20728. * Render a circle geometry into the canvas. Rendering is immediate and uses
  20729. * the current fill and stroke styles.
  20730. *
  20731. * @param {import("../../geom/Circle.js").default} geometry Circle geometry.
  20732. * @api
  20733. */
  20734. CanvasImmediateRenderer.prototype.drawCircle = function (geometry) {
  20735. if (!intersects(this.extent_, geometry.getExtent())) {
  20736. return;
  20737. }
  20738. if (this.fillState_ || this.strokeState_) {
  20739. if (this.fillState_) {
  20740. this.setContextFillState_(this.fillState_);
  20741. }
  20742. if (this.strokeState_) {
  20743. this.setContextStrokeState_(this.strokeState_);
  20744. }
  20745. var pixelCoordinates = transformGeom2D(geometry, this.transform_, this.pixelCoordinates_);
  20746. var dx = pixelCoordinates[2] - pixelCoordinates[0];
  20747. var dy = pixelCoordinates[3] - pixelCoordinates[1];
  20748. var radius = Math.sqrt(dx * dx + dy * dy);
  20749. var context = this.context_;
  20750. context.beginPath();
  20751. context.arc(pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI);
  20752. if (this.fillState_) {
  20753. context.fill();
  20754. }
  20755. if (this.strokeState_) {
  20756. context.stroke();
  20757. }
  20758. }
  20759. if (this.text_ !== '') {
  20760. this.drawText_(geometry.getCenter(), 0, 2, 2);
  20761. }
  20762. };
  20763. /**
  20764. * Set the rendering style. Note that since this is an immediate rendering API,
  20765. * any `zIndex` on the provided style will be ignored.
  20766. *
  20767. * @param {import("../../style/Style.js").default} style The rendering style.
  20768. * @api
  20769. */
  20770. CanvasImmediateRenderer.prototype.setStyle = function (style) {
  20771. this.setFillStrokeStyle(style.getFill(), style.getStroke());
  20772. this.setImageStyle(style.getImage());
  20773. this.setTextStyle(style.getText());
  20774. };
  20775. /**
  20776. * @param {import("../../transform.js").Transform} transform Transform.
  20777. */
  20778. CanvasImmediateRenderer.prototype.setTransform = function (transform) {
  20779. this.transform_ = transform;
  20780. };
  20781. /**
  20782. * Render a geometry into the canvas. Call
  20783. * {@link module:ol/render/canvas/Immediate~CanvasImmediateRenderer#setStyle renderer.setStyle()} first to set the rendering style.
  20784. *
  20785. * @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry The geometry to render.
  20786. * @api
  20787. */
  20788. CanvasImmediateRenderer.prototype.drawGeometry = function (geometry) {
  20789. var type = geometry.getType();
  20790. switch (type) {
  20791. case 'Point':
  20792. this.drawPoint(
  20793. /** @type {import("../../geom/Point.js").default} */ (geometry));
  20794. break;
  20795. case 'LineString':
  20796. this.drawLineString(
  20797. /** @type {import("../../geom/LineString.js").default} */ (geometry));
  20798. break;
  20799. case 'Polygon':
  20800. this.drawPolygon(
  20801. /** @type {import("../../geom/Polygon.js").default} */ (geometry));
  20802. break;
  20803. case 'MultiPoint':
  20804. this.drawMultiPoint(
  20805. /** @type {import("../../geom/MultiPoint.js").default} */ (geometry));
  20806. break;
  20807. case 'MultiLineString':
  20808. this.drawMultiLineString(
  20809. /** @type {import("../../geom/MultiLineString.js").default} */ (geometry));
  20810. break;
  20811. case 'MultiPolygon':
  20812. this.drawMultiPolygon(
  20813. /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry));
  20814. break;
  20815. case 'GeometryCollection':
  20816. this.drawGeometryCollection(
  20817. /** @type {import("../../geom/GeometryCollection.js").default} */ (geometry));
  20818. break;
  20819. case 'Circle':
  20820. this.drawCircle(
  20821. /** @type {import("../../geom/Circle.js").default} */ (geometry));
  20822. break;
  20823. default:
  20824. }
  20825. };
  20826. /**
  20827. * Render a feature into the canvas. Note that any `zIndex` on the provided
  20828. * style will be ignored - features are rendered immediately in the order that
  20829. * this method is called. If you need `zIndex` support, you should be using an
  20830. * {@link module:ol/layer/Vector~VectorLayer VectorLayer} instead.
  20831. *
  20832. * @param {import("../../Feature.js").default} feature Feature.
  20833. * @param {import("../../style/Style.js").default} style Style.
  20834. * @api
  20835. */
  20836. CanvasImmediateRenderer.prototype.drawFeature = function (feature, style) {
  20837. var geometry = style.getGeometryFunction()(feature);
  20838. if (!geometry || !intersects(this.extent_, geometry.getExtent())) {
  20839. return;
  20840. }
  20841. this.setStyle(style);
  20842. this.drawGeometry(geometry);
  20843. };
  20844. /**
  20845. * Render a GeometryCollection to the canvas. Rendering is immediate and
  20846. * uses the current styles appropriate for each geometry in the collection.
  20847. *
  20848. * @param {import("../../geom/GeometryCollection.js").default} geometry Geometry collection.
  20849. */
  20850. CanvasImmediateRenderer.prototype.drawGeometryCollection = function (geometry) {
  20851. var geometries = geometry.getGeometriesArray();
  20852. for (var i = 0, ii = geometries.length; i < ii; ++i) {
  20853. this.drawGeometry(geometries[i]);
  20854. }
  20855. };
  20856. /**
  20857. * Render a Point geometry into the canvas. Rendering is immediate and uses
  20858. * the current style.
  20859. *
  20860. * @param {import("../../geom/Point.js").default|import("../Feature.js").default} geometry Point geometry.
  20861. */
  20862. CanvasImmediateRenderer.prototype.drawPoint = function (geometry) {
  20863. if (this.squaredTolerance_) {
  20864. geometry = /** @type {import("../../geom/Point.js").default} */ (geometry.simplifyTransformed(this.squaredTolerance_, this.userTransform_));
  20865. }
  20866. var flatCoordinates = geometry.getFlatCoordinates();
  20867. var stride = geometry.getStride();
  20868. if (this.image_) {
  20869. this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
  20870. }
  20871. if (this.text_ !== '') {
  20872. this.drawText_(flatCoordinates, 0, flatCoordinates.length, stride);
  20873. }
  20874. };
  20875. /**
  20876. * Render a MultiPoint geometry into the canvas. Rendering is immediate and
  20877. * uses the current style.
  20878. *
  20879. * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} geometry MultiPoint geometry.
  20880. */
  20881. CanvasImmediateRenderer.prototype.drawMultiPoint = function (geometry) {
  20882. if (this.squaredTolerance_) {
  20883. geometry = /** @type {import("../../geom/MultiPoint.js").default} */ (geometry.simplifyTransformed(this.squaredTolerance_, this.userTransform_));
  20884. }
  20885. var flatCoordinates = geometry.getFlatCoordinates();
  20886. var stride = geometry.getStride();
  20887. if (this.image_) {
  20888. this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
  20889. }
  20890. if (this.text_ !== '') {
  20891. this.drawText_(flatCoordinates, 0, flatCoordinates.length, stride);
  20892. }
  20893. };
  20894. /**
  20895. * Render a LineString into the canvas. Rendering is immediate and uses
  20896. * the current style.
  20897. *
  20898. * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} geometry LineString geometry.
  20899. */
  20900. CanvasImmediateRenderer.prototype.drawLineString = function (geometry) {
  20901. if (this.squaredTolerance_) {
  20902. geometry = /** @type {import("../../geom/LineString.js").default} */ (geometry.simplifyTransformed(this.squaredTolerance_, this.userTransform_));
  20903. }
  20904. if (!intersects(this.extent_, geometry.getExtent())) {
  20905. return;
  20906. }
  20907. if (this.strokeState_) {
  20908. this.setContextStrokeState_(this.strokeState_);
  20909. var context = this.context_;
  20910. var flatCoordinates = geometry.getFlatCoordinates();
  20911. context.beginPath();
  20912. this.moveToLineTo_(flatCoordinates, 0, flatCoordinates.length, geometry.getStride(), false);
  20913. context.stroke();
  20914. }
  20915. if (this.text_ !== '') {
  20916. var flatMidpoint = geometry.getFlatMidpoint();
  20917. this.drawText_(flatMidpoint, 0, 2, 2);
  20918. }
  20919. };
  20920. /**
  20921. * Render a MultiLineString geometry into the canvas. Rendering is immediate
  20922. * and uses the current style.
  20923. *
  20924. * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} geometry MultiLineString geometry.
  20925. */
  20926. CanvasImmediateRenderer.prototype.drawMultiLineString = function (geometry) {
  20927. if (this.squaredTolerance_) {
  20928. geometry =
  20929. /** @type {import("../../geom/MultiLineString.js").default} */ (geometry.simplifyTransformed(this.squaredTolerance_, this.userTransform_));
  20930. }
  20931. var geometryExtent = geometry.getExtent();
  20932. if (!intersects(this.extent_, geometryExtent)) {
  20933. return;
  20934. }
  20935. if (this.strokeState_) {
  20936. this.setContextStrokeState_(this.strokeState_);
  20937. var context = this.context_;
  20938. var flatCoordinates = geometry.getFlatCoordinates();
  20939. var offset = 0;
  20940. var ends = /** @type {Array<number>} */ (geometry.getEnds());
  20941. var stride = geometry.getStride();
  20942. context.beginPath();
  20943. for (var i = 0, ii = ends.length; i < ii; ++i) {
  20944. offset = this.moveToLineTo_(flatCoordinates, offset, ends[i], stride, false);
  20945. }
  20946. context.stroke();
  20947. }
  20948. if (this.text_ !== '') {
  20949. var flatMidpoints = geometry.getFlatMidpoints();
  20950. this.drawText_(flatMidpoints, 0, flatMidpoints.length, 2);
  20951. }
  20952. };
  20953. /**
  20954. * Render a Polygon geometry into the canvas. Rendering is immediate and uses
  20955. * the current style.
  20956. *
  20957. * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} geometry Polygon geometry.
  20958. */
  20959. CanvasImmediateRenderer.prototype.drawPolygon = function (geometry) {
  20960. if (this.squaredTolerance_) {
  20961. geometry = /** @type {import("../../geom/Polygon.js").default} */ (geometry.simplifyTransformed(this.squaredTolerance_, this.userTransform_));
  20962. }
  20963. if (!intersects(this.extent_, geometry.getExtent())) {
  20964. return;
  20965. }
  20966. if (this.strokeState_ || this.fillState_) {
  20967. if (this.fillState_) {
  20968. this.setContextFillState_(this.fillState_);
  20969. }
  20970. if (this.strokeState_) {
  20971. this.setContextStrokeState_(this.strokeState_);
  20972. }
  20973. var context = this.context_;
  20974. context.beginPath();
  20975. this.drawRings_(geometry.getOrientedFlatCoordinates(), 0,
  20976. /** @type {Array<number>} */ (geometry.getEnds()), geometry.getStride());
  20977. if (this.fillState_) {
  20978. context.fill();
  20979. }
  20980. if (this.strokeState_) {
  20981. context.stroke();
  20982. }
  20983. }
  20984. if (this.text_ !== '') {
  20985. var flatInteriorPoint = geometry.getFlatInteriorPoint();
  20986. this.drawText_(flatInteriorPoint, 0, 2, 2);
  20987. }
  20988. };
  20989. /**
  20990. * Render MultiPolygon geometry into the canvas. Rendering is immediate and
  20991. * uses the current style.
  20992. * @param {import("../../geom/MultiPolygon.js").default} geometry MultiPolygon geometry.
  20993. */
  20994. CanvasImmediateRenderer.prototype.drawMultiPolygon = function (geometry) {
  20995. if (this.squaredTolerance_) {
  20996. geometry = /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry.simplifyTransformed(this.squaredTolerance_, this.userTransform_));
  20997. }
  20998. if (!intersects(this.extent_, geometry.getExtent())) {
  20999. return;
  21000. }
  21001. if (this.strokeState_ || this.fillState_) {
  21002. if (this.fillState_) {
  21003. this.setContextFillState_(this.fillState_);
  21004. }
  21005. if (this.strokeState_) {
  21006. this.setContextStrokeState_(this.strokeState_);
  21007. }
  21008. var context = this.context_;
  21009. var flatCoordinates = geometry.getOrientedFlatCoordinates();
  21010. var offset = 0;
  21011. var endss = geometry.getEndss();
  21012. var stride = geometry.getStride();
  21013. context.beginPath();
  21014. for (var i = 0, ii = endss.length; i < ii; ++i) {
  21015. var ends = endss[i];
  21016. offset = this.drawRings_(flatCoordinates, offset, ends, stride);
  21017. }
  21018. if (this.fillState_) {
  21019. context.fill();
  21020. }
  21021. if (this.strokeState_) {
  21022. context.stroke();
  21023. }
  21024. }
  21025. if (this.text_ !== '') {
  21026. var flatInteriorPoints = geometry.getFlatInteriorPoints();
  21027. this.drawText_(flatInteriorPoints, 0, flatInteriorPoints.length, 2);
  21028. }
  21029. };
  21030. /**
  21031. * @param {import("../canvas.js").FillState} fillState Fill state.
  21032. * @private
  21033. */
  21034. CanvasImmediateRenderer.prototype.setContextFillState_ = function (fillState) {
  21035. var context = this.context_;
  21036. var contextFillState = this.contextFillState_;
  21037. if (!contextFillState) {
  21038. context.fillStyle = fillState.fillStyle;
  21039. this.contextFillState_ = {
  21040. fillStyle: fillState.fillStyle,
  21041. };
  21042. }
  21043. else {
  21044. if (contextFillState.fillStyle != fillState.fillStyle) {
  21045. contextFillState.fillStyle = fillState.fillStyle;
  21046. context.fillStyle = fillState.fillStyle;
  21047. }
  21048. }
  21049. };
  21050. /**
  21051. * @param {import("../canvas.js").StrokeState} strokeState Stroke state.
  21052. * @private
  21053. */
  21054. CanvasImmediateRenderer.prototype.setContextStrokeState_ = function (strokeState) {
  21055. var context = this.context_;
  21056. var contextStrokeState = this.contextStrokeState_;
  21057. if (!contextStrokeState) {
  21058. context.lineCap = strokeState.lineCap;
  21059. if (context.setLineDash) {
  21060. context.setLineDash(strokeState.lineDash);
  21061. context.lineDashOffset = strokeState.lineDashOffset;
  21062. }
  21063. context.lineJoin = strokeState.lineJoin;
  21064. context.lineWidth = strokeState.lineWidth;
  21065. context.miterLimit = strokeState.miterLimit;
  21066. context.strokeStyle = strokeState.strokeStyle;
  21067. this.contextStrokeState_ = {
  21068. lineCap: strokeState.lineCap,
  21069. lineDash: strokeState.lineDash,
  21070. lineDashOffset: strokeState.lineDashOffset,
  21071. lineJoin: strokeState.lineJoin,
  21072. lineWidth: strokeState.lineWidth,
  21073. miterLimit: strokeState.miterLimit,
  21074. strokeStyle: strokeState.strokeStyle,
  21075. };
  21076. }
  21077. else {
  21078. if (contextStrokeState.lineCap != strokeState.lineCap) {
  21079. contextStrokeState.lineCap = strokeState.lineCap;
  21080. context.lineCap = strokeState.lineCap;
  21081. }
  21082. if (context.setLineDash) {
  21083. if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {
  21084. context.setLineDash((contextStrokeState.lineDash = strokeState.lineDash));
  21085. }
  21086. if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) {
  21087. contextStrokeState.lineDashOffset = strokeState.lineDashOffset;
  21088. context.lineDashOffset = strokeState.lineDashOffset;
  21089. }
  21090. }
  21091. if (contextStrokeState.lineJoin != strokeState.lineJoin) {
  21092. contextStrokeState.lineJoin = strokeState.lineJoin;
  21093. context.lineJoin = strokeState.lineJoin;
  21094. }
  21095. if (contextStrokeState.lineWidth != strokeState.lineWidth) {
  21096. contextStrokeState.lineWidth = strokeState.lineWidth;
  21097. context.lineWidth = strokeState.lineWidth;
  21098. }
  21099. if (contextStrokeState.miterLimit != strokeState.miterLimit) {
  21100. contextStrokeState.miterLimit = strokeState.miterLimit;
  21101. context.miterLimit = strokeState.miterLimit;
  21102. }
  21103. if (contextStrokeState.strokeStyle != strokeState.strokeStyle) {
  21104. contextStrokeState.strokeStyle = strokeState.strokeStyle;
  21105. context.strokeStyle = strokeState.strokeStyle;
  21106. }
  21107. }
  21108. };
  21109. /**
  21110. * @param {import("../canvas.js").TextState} textState Text state.
  21111. * @private
  21112. */
  21113. CanvasImmediateRenderer.prototype.setContextTextState_ = function (textState) {
  21114. var context = this.context_;
  21115. var contextTextState = this.contextTextState_;
  21116. var textAlign = textState.textAlign
  21117. ? textState.textAlign
  21118. : defaultTextAlign;
  21119. if (!contextTextState) {
  21120. context.font = textState.font;
  21121. context.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
  21122. context.textBaseline = /** @type {CanvasTextBaseline} */ (textState.textBaseline);
  21123. this.contextTextState_ = {
  21124. font: textState.font,
  21125. textAlign: textAlign,
  21126. textBaseline: textState.textBaseline,
  21127. };
  21128. }
  21129. else {
  21130. if (contextTextState.font != textState.font) {
  21131. contextTextState.font = textState.font;
  21132. context.font = textState.font;
  21133. }
  21134. if (contextTextState.textAlign != textAlign) {
  21135. contextTextState.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
  21136. context.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
  21137. }
  21138. if (contextTextState.textBaseline != textState.textBaseline) {
  21139. contextTextState.textBaseline = /** @type {CanvasTextBaseline} */ (textState.textBaseline);
  21140. context.textBaseline = /** @type {CanvasTextBaseline} */ (textState.textBaseline);
  21141. }
  21142. }
  21143. };
  21144. /**
  21145. * Set the fill and stroke style for subsequent draw operations. To clear
  21146. * either fill or stroke styles, pass null for the appropriate parameter.
  21147. *
  21148. * @param {import("../../style/Fill.js").default} fillStyle Fill style.
  21149. * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style.
  21150. */
  21151. CanvasImmediateRenderer.prototype.setFillStrokeStyle = function (fillStyle, strokeStyle) {
  21152. var _this = this;
  21153. if (!fillStyle) {
  21154. this.fillState_ = null;
  21155. }
  21156. else {
  21157. var fillStyleColor = fillStyle.getColor();
  21158. this.fillState_ = {
  21159. fillStyle: asColorLike(fillStyleColor ? fillStyleColor : defaultFillStyle),
  21160. };
  21161. }
  21162. if (!strokeStyle) {
  21163. this.strokeState_ = null;
  21164. }
  21165. else {
  21166. var strokeStyleColor = strokeStyle.getColor();
  21167. var strokeStyleLineCap = strokeStyle.getLineCap();
  21168. var strokeStyleLineDash = strokeStyle.getLineDash();
  21169. var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
  21170. var strokeStyleLineJoin = strokeStyle.getLineJoin();
  21171. var strokeStyleWidth = strokeStyle.getWidth();
  21172. var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
  21173. var lineDash = strokeStyleLineDash
  21174. ? strokeStyleLineDash
  21175. : defaultLineDash;
  21176. this.strokeState_ = {
  21177. lineCap: strokeStyleLineCap !== undefined
  21178. ? strokeStyleLineCap
  21179. : defaultLineCap,
  21180. lineDash: this.pixelRatio_ === 1
  21181. ? lineDash
  21182. : lineDash.map(function (n) { return n * _this.pixelRatio_; }),
  21183. lineDashOffset: (strokeStyleLineDashOffset
  21184. ? strokeStyleLineDashOffset
  21185. : defaultLineDashOffset) * this.pixelRatio_,
  21186. lineJoin: strokeStyleLineJoin !== undefined
  21187. ? strokeStyleLineJoin
  21188. : defaultLineJoin,
  21189. lineWidth: (strokeStyleWidth !== undefined
  21190. ? strokeStyleWidth
  21191. : defaultLineWidth) * this.pixelRatio_,
  21192. miterLimit: strokeStyleMiterLimit !== undefined
  21193. ? strokeStyleMiterLimit
  21194. : defaultMiterLimit,
  21195. strokeStyle: asColorLike(strokeStyleColor ? strokeStyleColor : defaultStrokeStyle),
  21196. };
  21197. }
  21198. };
  21199. /**
  21200. * Set the image style for subsequent draw operations. Pass null to remove
  21201. * the image style.
  21202. *
  21203. * @param {import("../../style/Image.js").default} imageStyle Image style.
  21204. */
  21205. CanvasImmediateRenderer.prototype.setImageStyle = function (imageStyle) {
  21206. var imageSize;
  21207. if (!imageStyle || !(imageSize = imageStyle.getSize())) {
  21208. this.image_ = null;
  21209. return;
  21210. }
  21211. var imageAnchor = imageStyle.getAnchor();
  21212. var imageOrigin = imageStyle.getOrigin();
  21213. this.image_ = imageStyle.getImage(this.pixelRatio_);
  21214. this.imageAnchorX_ = imageAnchor[0] * this.pixelRatio_;
  21215. this.imageAnchorY_ = imageAnchor[1] * this.pixelRatio_;
  21216. this.imageHeight_ = imageSize[1] * this.pixelRatio_;
  21217. this.imageOpacity_ = imageStyle.getOpacity();
  21218. this.imageOriginX_ = imageOrigin[0];
  21219. this.imageOriginY_ = imageOrigin[1];
  21220. this.imageRotateWithView_ = imageStyle.getRotateWithView();
  21221. this.imageRotation_ = imageStyle.getRotation();
  21222. this.imageScale_ = imageStyle.getScaleArray();
  21223. this.imageWidth_ = imageSize[0] * this.pixelRatio_;
  21224. };
  21225. /**
  21226. * Set the text style for subsequent draw operations. Pass null to
  21227. * remove the text style.
  21228. *
  21229. * @param {import("../../style/Text.js").default} textStyle Text style.
  21230. */
  21231. CanvasImmediateRenderer.prototype.setTextStyle = function (textStyle) {
  21232. if (!textStyle) {
  21233. this.text_ = '';
  21234. }
  21235. else {
  21236. var textFillStyle = textStyle.getFill();
  21237. if (!textFillStyle) {
  21238. this.textFillState_ = null;
  21239. }
  21240. else {
  21241. var textFillStyleColor = textFillStyle.getColor();
  21242. this.textFillState_ = {
  21243. fillStyle: asColorLike(textFillStyleColor ? textFillStyleColor : defaultFillStyle),
  21244. };
  21245. }
  21246. var textStrokeStyle = textStyle.getStroke();
  21247. if (!textStrokeStyle) {
  21248. this.textStrokeState_ = null;
  21249. }
  21250. else {
  21251. var textStrokeStyleColor = textStrokeStyle.getColor();
  21252. var textStrokeStyleLineCap = textStrokeStyle.getLineCap();
  21253. var textStrokeStyleLineDash = textStrokeStyle.getLineDash();
  21254. var textStrokeStyleLineDashOffset = textStrokeStyle.getLineDashOffset();
  21255. var textStrokeStyleLineJoin = textStrokeStyle.getLineJoin();
  21256. var textStrokeStyleWidth = textStrokeStyle.getWidth();
  21257. var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit();
  21258. this.textStrokeState_ = {
  21259. lineCap: textStrokeStyleLineCap !== undefined
  21260. ? textStrokeStyleLineCap
  21261. : defaultLineCap,
  21262. lineDash: textStrokeStyleLineDash
  21263. ? textStrokeStyleLineDash
  21264. : defaultLineDash,
  21265. lineDashOffset: textStrokeStyleLineDashOffset
  21266. ? textStrokeStyleLineDashOffset
  21267. : defaultLineDashOffset,
  21268. lineJoin: textStrokeStyleLineJoin !== undefined
  21269. ? textStrokeStyleLineJoin
  21270. : defaultLineJoin,
  21271. lineWidth: textStrokeStyleWidth !== undefined
  21272. ? textStrokeStyleWidth
  21273. : defaultLineWidth,
  21274. miterLimit: textStrokeStyleMiterLimit !== undefined
  21275. ? textStrokeStyleMiterLimit
  21276. : defaultMiterLimit,
  21277. strokeStyle: asColorLike(textStrokeStyleColor ? textStrokeStyleColor : defaultStrokeStyle),
  21278. };
  21279. }
  21280. var textFont = textStyle.getFont();
  21281. var textOffsetX = textStyle.getOffsetX();
  21282. var textOffsetY = textStyle.getOffsetY();
  21283. var textRotateWithView = textStyle.getRotateWithView();
  21284. var textRotation = textStyle.getRotation();
  21285. var textScale = textStyle.getScaleArray();
  21286. var textText = textStyle.getText();
  21287. var textTextAlign = textStyle.getTextAlign();
  21288. var textTextBaseline = textStyle.getTextBaseline();
  21289. this.textState_ = {
  21290. font: textFont !== undefined ? textFont : defaultFont,
  21291. textAlign: textTextAlign !== undefined ? textTextAlign : defaultTextAlign,
  21292. textBaseline: textTextBaseline !== undefined
  21293. ? textTextBaseline
  21294. : defaultTextBaseline,
  21295. };
  21296. this.text_ =
  21297. textText !== undefined
  21298. ? Array.isArray(textText)
  21299. ? textText.reduce(function (acc, t, i) { return (acc += i % 2 ? ' ' : t); }, '')
  21300. : textText
  21301. : '';
  21302. this.textOffsetX_ =
  21303. textOffsetX !== undefined ? this.pixelRatio_ * textOffsetX : 0;
  21304. this.textOffsetY_ =
  21305. textOffsetY !== undefined ? this.pixelRatio_ * textOffsetY : 0;
  21306. this.textRotateWithView_ =
  21307. textRotateWithView !== undefined ? textRotateWithView : false;
  21308. this.textRotation_ = textRotation !== undefined ? textRotation : 0;
  21309. this.textScale_ = [
  21310. this.pixelRatio_ * textScale[0],
  21311. this.pixelRatio_ * textScale[1],
  21312. ];
  21313. }
  21314. };
  21315. return CanvasImmediateRenderer;
  21316. }(render_VectorContext));
  21317. /* harmony default export */ var Immediate = (CanvasImmediateRenderer);
  21318. //# sourceMappingURL=Immediate.js.map
  21319. ;// ./node_modules/ol/style/IconAnchorUnits.js
  21320. /**
  21321. * @module ol/style/IconAnchorUnits
  21322. */
  21323. /**
  21324. * Icon anchor units. One of 'fraction', 'pixels'.
  21325. * @enum {string}
  21326. */
  21327. /* harmony default export */ var IconAnchorUnits = ({
  21328. /**
  21329. * Anchor is a fraction
  21330. * @api
  21331. */
  21332. FRACTION: 'fraction',
  21333. /**
  21334. * Anchor is in pixels
  21335. * @api
  21336. */
  21337. PIXELS: 'pixels',
  21338. });
  21339. //# sourceMappingURL=IconAnchorUnits.js.map
  21340. ;// ./node_modules/ol/style/IconOrigin.js
  21341. /**
  21342. * @module ol/style/IconOrigin
  21343. */
  21344. /**
  21345. * Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.
  21346. * @enum {string}
  21347. */
  21348. /* harmony default export */ var IconOrigin = ({
  21349. /**
  21350. * Origin is at bottom left
  21351. * @api
  21352. */
  21353. BOTTOM_LEFT: 'bottom-left',
  21354. /**
  21355. * Origin is at bottom right
  21356. * @api
  21357. */
  21358. BOTTOM_RIGHT: 'bottom-right',
  21359. /**
  21360. * Origin is at top left
  21361. * @api
  21362. */
  21363. TOP_LEFT: 'top-left',
  21364. /**
  21365. * Origin is at top right
  21366. * @api
  21367. */
  21368. TOP_RIGHT: 'top-right',
  21369. });
  21370. //# sourceMappingURL=IconOrigin.js.map
  21371. ;// ./node_modules/ol/style/IconImageCache.js
  21372. /**
  21373. * @module ol/style/IconImageCache
  21374. */
  21375. /**
  21376. * @classdesc
  21377. * Singleton class. Available through {@link module:ol/style/IconImageCache.shared}.
  21378. */
  21379. var IconImageCache = /** @class */ (function () {
  21380. function IconImageCache() {
  21381. /**
  21382. * @type {!Object<string, import("./IconImage.js").default>}
  21383. * @private
  21384. */
  21385. this.cache_ = {};
  21386. /**
  21387. * @type {number}
  21388. * @private
  21389. */
  21390. this.cacheSize_ = 0;
  21391. /**
  21392. * @type {number}
  21393. * @private
  21394. */
  21395. this.maxCacheSize_ = 32;
  21396. }
  21397. /**
  21398. * FIXME empty description for jsdoc
  21399. */
  21400. IconImageCache.prototype.clear = function () {
  21401. this.cache_ = {};
  21402. this.cacheSize_ = 0;
  21403. };
  21404. /**
  21405. * @return {boolean} Can expire cache.
  21406. */
  21407. IconImageCache.prototype.canExpireCache = function () {
  21408. return this.cacheSize_ > this.maxCacheSize_;
  21409. };
  21410. /**
  21411. * FIXME empty description for jsdoc
  21412. */
  21413. IconImageCache.prototype.expire = function () {
  21414. if (this.canExpireCache()) {
  21415. var i = 0;
  21416. for (var key in this.cache_) {
  21417. var iconImage = this.cache_[key];
  21418. if ((i++ & 3) === 0 && !iconImage.hasListener()) {
  21419. delete this.cache_[key];
  21420. --this.cacheSize_;
  21421. }
  21422. }
  21423. }
  21424. };
  21425. /**
  21426. * @param {string} src Src.
  21427. * @param {?string} crossOrigin Cross origin.
  21428. * @param {import("../color.js").Color} color Color.
  21429. * @return {import("./IconImage.js").default} Icon image.
  21430. */
  21431. IconImageCache.prototype.get = function (src, crossOrigin, color) {
  21432. var key = getKey(src, crossOrigin, color);
  21433. return key in this.cache_ ? this.cache_[key] : null;
  21434. };
  21435. /**
  21436. * @param {string} src Src.
  21437. * @param {?string} crossOrigin Cross origin.
  21438. * @param {import("../color.js").Color} color Color.
  21439. * @param {import("./IconImage.js").default} iconImage Icon image.
  21440. */
  21441. IconImageCache.prototype.set = function (src, crossOrigin, color, iconImage) {
  21442. var key = getKey(src, crossOrigin, color);
  21443. this.cache_[key] = iconImage;
  21444. ++this.cacheSize_;
  21445. };
  21446. /**
  21447. * Set the cache size of the icon cache. Default is `32`. Change this value when
  21448. * your map uses more than 32 different icon images and you are not caching icon
  21449. * styles on the application level.
  21450. * @param {number} maxCacheSize Cache max size.
  21451. * @api
  21452. */
  21453. IconImageCache.prototype.setSize = function (maxCacheSize) {
  21454. this.maxCacheSize_ = maxCacheSize;
  21455. this.expire();
  21456. };
  21457. return IconImageCache;
  21458. }());
  21459. /**
  21460. * @param {string} src Src.
  21461. * @param {?string} crossOrigin Cross origin.
  21462. * @param {import("../color.js").Color} color Color.
  21463. * @return {string} Cache key.
  21464. */
  21465. function getKey(src, crossOrigin, color) {
  21466. var colorString = color ? asString(color) : 'null';
  21467. return crossOrigin + ':' + src + ':' + colorString;
  21468. }
  21469. /* harmony default export */ var style_IconImageCache = ((/* unused pure expression or super */ null && (IconImageCache)));
  21470. /**
  21471. * The {@link module:ol/style/IconImageCache~IconImageCache} for
  21472. * {@link module:ol/style/Icon~Icon} images.
  21473. * @api
  21474. */
  21475. var shared = new IconImageCache();
  21476. //# sourceMappingURL=IconImageCache.js.map
  21477. ;// ./node_modules/ol/style/IconImage.js
  21478. /**
  21479. * @module ol/style/IconImage
  21480. */
  21481. var IconImage_extends = (undefined && undefined.__extends) || (function () {
  21482. var extendStatics = function (d, b) {
  21483. extendStatics = Object.setPrototypeOf ||
  21484. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  21485. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  21486. return extendStatics(d, b);
  21487. };
  21488. return function (d, b) {
  21489. if (typeof b !== "function" && b !== null)
  21490. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  21491. extendStatics(d, b);
  21492. function __() { this.constructor = d; }
  21493. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21494. };
  21495. })();
  21496. /**
  21497. * @type {CanvasRenderingContext2D}
  21498. */
  21499. var taintedTestContext = null;
  21500. var IconImage = /** @class */ (function (_super) {
  21501. IconImage_extends(IconImage, _super);
  21502. /**
  21503. * @param {HTMLImageElement|HTMLCanvasElement} image Image.
  21504. * @param {string|undefined} src Src.
  21505. * @param {import("../size.js").Size} size Size.
  21506. * @param {?string} crossOrigin Cross origin.
  21507. * @param {import("../ImageState.js").default} imageState Image state.
  21508. * @param {import("../color.js").Color} color Color.
  21509. */
  21510. function IconImage(image, src, size, crossOrigin, imageState, color) {
  21511. var _this = _super.call(this) || this;
  21512. /**
  21513. * @private
  21514. * @type {HTMLImageElement|HTMLCanvasElement}
  21515. */
  21516. _this.hitDetectionImage_ = null;
  21517. /**
  21518. * @private
  21519. * @type {HTMLImageElement|HTMLCanvasElement}
  21520. */
  21521. _this.image_ = !image ? new Image() : image;
  21522. if (crossOrigin !== null) {
  21523. /** @type {HTMLImageElement} */ (_this.image_).crossOrigin = crossOrigin;
  21524. }
  21525. /**
  21526. * @private
  21527. * @type {Object<number, HTMLCanvasElement>}
  21528. */
  21529. _this.canvas_ = {};
  21530. /**
  21531. * @private
  21532. * @type {import("../color.js").Color}
  21533. */
  21534. _this.color_ = color;
  21535. /**
  21536. * @private
  21537. * @type {?function():void}
  21538. */
  21539. _this.unlisten_ = null;
  21540. /**
  21541. * @private
  21542. * @type {import("../ImageState.js").default}
  21543. */
  21544. _this.imageState_ = imageState;
  21545. /**
  21546. * @private
  21547. * @type {import("../size.js").Size}
  21548. */
  21549. _this.size_ = size;
  21550. /**
  21551. * @private
  21552. * @type {string|undefined}
  21553. */
  21554. _this.src_ = src;
  21555. /**
  21556. * @private
  21557. */
  21558. _this.tainted_;
  21559. return _this;
  21560. }
  21561. /**
  21562. * @private
  21563. * @return {boolean} The image canvas is tainted.
  21564. */
  21565. IconImage.prototype.isTainted_ = function () {
  21566. if (this.tainted_ === undefined && this.imageState_ === ImageState.LOADED) {
  21567. if (!taintedTestContext) {
  21568. taintedTestContext = createCanvasContext2D(1, 1);
  21569. }
  21570. taintedTestContext.drawImage(this.image_, 0, 0);
  21571. try {
  21572. taintedTestContext.getImageData(0, 0, 1, 1);
  21573. this.tainted_ = false;
  21574. }
  21575. catch (e) {
  21576. taintedTestContext = null;
  21577. this.tainted_ = true;
  21578. }
  21579. }
  21580. return this.tainted_ === true;
  21581. };
  21582. /**
  21583. * @private
  21584. */
  21585. IconImage.prototype.dispatchChangeEvent_ = function () {
  21586. this.dispatchEvent(EventType.CHANGE);
  21587. };
  21588. /**
  21589. * @private
  21590. */
  21591. IconImage.prototype.handleImageError_ = function () {
  21592. this.imageState_ = ImageState.ERROR;
  21593. this.unlistenImage_();
  21594. this.dispatchChangeEvent_();
  21595. };
  21596. /**
  21597. * @private
  21598. */
  21599. IconImage.prototype.handleImageLoad_ = function () {
  21600. this.imageState_ = ImageState.LOADED;
  21601. if (this.size_) {
  21602. this.image_.width = this.size_[0];
  21603. this.image_.height = this.size_[1];
  21604. }
  21605. else {
  21606. this.size_ = [this.image_.width, this.image_.height];
  21607. }
  21608. this.unlistenImage_();
  21609. this.dispatchChangeEvent_();
  21610. };
  21611. /**
  21612. * @param {number} pixelRatio Pixel ratio.
  21613. * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
  21614. */
  21615. IconImage.prototype.getImage = function (pixelRatio) {
  21616. this.replaceColor_(pixelRatio);
  21617. return this.canvas_[pixelRatio] ? this.canvas_[pixelRatio] : this.image_;
  21618. };
  21619. /**
  21620. * @param {number} pixelRatio Pixel ratio.
  21621. * @return {number} Image or Canvas element.
  21622. */
  21623. IconImage.prototype.getPixelRatio = function (pixelRatio) {
  21624. this.replaceColor_(pixelRatio);
  21625. return this.canvas_[pixelRatio] ? pixelRatio : 1;
  21626. };
  21627. /**
  21628. * @return {import("../ImageState.js").default} Image state.
  21629. */
  21630. IconImage.prototype.getImageState = function () {
  21631. return this.imageState_;
  21632. };
  21633. /**
  21634. * @return {HTMLImageElement|HTMLCanvasElement} Image element.
  21635. */
  21636. IconImage.prototype.getHitDetectionImage = function () {
  21637. if (!this.hitDetectionImage_) {
  21638. if (this.isTainted_()) {
  21639. var width = this.size_[0];
  21640. var height = this.size_[1];
  21641. var context = createCanvasContext2D(width, height);
  21642. context.fillRect(0, 0, width, height);
  21643. this.hitDetectionImage_ = context.canvas;
  21644. }
  21645. else {
  21646. this.hitDetectionImage_ = this.image_;
  21647. }
  21648. }
  21649. return this.hitDetectionImage_;
  21650. };
  21651. /**
  21652. * Get the size of the icon (in pixels).
  21653. * @return {import("../size.js").Size} Image size.
  21654. */
  21655. IconImage.prototype.getSize = function () {
  21656. return this.size_;
  21657. };
  21658. /**
  21659. * @return {string|undefined} Image src.
  21660. */
  21661. IconImage.prototype.getSrc = function () {
  21662. return this.src_;
  21663. };
  21664. /**
  21665. * Load not yet loaded URI.
  21666. */
  21667. IconImage.prototype.load = function () {
  21668. if (this.imageState_ == ImageState.IDLE) {
  21669. this.imageState_ = ImageState.LOADING;
  21670. try {
  21671. /** @type {HTMLImageElement} */ (this.image_).src = this.src_;
  21672. }
  21673. catch (e) {
  21674. this.handleImageError_();
  21675. }
  21676. this.unlisten_ = listenImage(this.image_, this.handleImageLoad_.bind(this), this.handleImageError_.bind(this));
  21677. }
  21678. };
  21679. /**
  21680. * @param {number} pixelRatio Pixel ratio.
  21681. * @private
  21682. */
  21683. IconImage.prototype.replaceColor_ = function (pixelRatio) {
  21684. if (!this.color_ ||
  21685. this.canvas_[pixelRatio] ||
  21686. this.imageState_ !== ImageState.LOADED) {
  21687. return;
  21688. }
  21689. var canvas = document.createElement('canvas');
  21690. this.canvas_[pixelRatio] = canvas;
  21691. canvas.width = Math.ceil(this.image_.width * pixelRatio);
  21692. canvas.height = Math.ceil(this.image_.height * pixelRatio);
  21693. var ctx = canvas.getContext('2d');
  21694. ctx.scale(pixelRatio, pixelRatio);
  21695. ctx.drawImage(this.image_, 0, 0);
  21696. ctx.globalCompositeOperation = 'multiply';
  21697. // Internet Explorer 11 does not support the multiply operation.
  21698. // If the canvas is tainted in Internet Explorer this still produces
  21699. // a solid color image with the shape of the icon.
  21700. if (ctx.globalCompositeOperation === 'multiply' || this.isTainted_()) {
  21701. ctx.fillStyle = asString(this.color_);
  21702. ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio);
  21703. ctx.globalCompositeOperation = 'destination-in';
  21704. ctx.drawImage(this.image_, 0, 0);
  21705. }
  21706. else {
  21707. var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  21708. var data = imgData.data;
  21709. var r = this.color_[0] / 255.0;
  21710. var g = this.color_[1] / 255.0;
  21711. var b = this.color_[2] / 255.0;
  21712. var a = this.color_[3];
  21713. for (var i = 0, ii = data.length; i < ii; i += 4) {
  21714. data[i] *= r;
  21715. data[i + 1] *= g;
  21716. data[i + 2] *= b;
  21717. data[i + 3] *= a;
  21718. }
  21719. ctx.putImageData(imgData, 0, 0);
  21720. }
  21721. };
  21722. /**
  21723. * Discards event handlers which listen for load completion or errors.
  21724. *
  21725. * @private
  21726. */
  21727. IconImage.prototype.unlistenImage_ = function () {
  21728. if (this.unlisten_) {
  21729. this.unlisten_();
  21730. this.unlisten_ = null;
  21731. }
  21732. };
  21733. return IconImage;
  21734. }(events_Target));
  21735. /**
  21736. * @param {HTMLImageElement|HTMLCanvasElement} image Image.
  21737. * @param {string} src Src.
  21738. * @param {import("../size.js").Size} size Size.
  21739. * @param {?string} crossOrigin Cross origin.
  21740. * @param {import("../ImageState.js").default} imageState Image state.
  21741. * @param {import("../color.js").Color} color Color.
  21742. * @return {IconImage} Icon image.
  21743. */
  21744. function IconImage_get(image, src, size, crossOrigin, imageState, color) {
  21745. var iconImage = shared.get(src, crossOrigin, color);
  21746. if (!iconImage) {
  21747. iconImage = new IconImage(image, src, size, crossOrigin, imageState, color);
  21748. shared.set(src, crossOrigin, color, iconImage);
  21749. }
  21750. return iconImage;
  21751. }
  21752. /* harmony default export */ var style_IconImage = ((/* unused pure expression or super */ null && (IconImage)));
  21753. //# sourceMappingURL=IconImage.js.map
  21754. ;// ./node_modules/ol/style/Icon.js
  21755. var Icon_extends = (undefined && undefined.__extends) || (function () {
  21756. var extendStatics = function (d, b) {
  21757. extendStatics = Object.setPrototypeOf ||
  21758. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  21759. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  21760. return extendStatics(d, b);
  21761. };
  21762. return function (d, b) {
  21763. if (typeof b !== "function" && b !== null)
  21764. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  21765. extendStatics(d, b);
  21766. function __() { this.constructor = d; }
  21767. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21768. };
  21769. })();
  21770. /**
  21771. * @module ol/style/Icon
  21772. */
  21773. /**
  21774. * @typedef {Object} Options
  21775. * @property {Array<number>} [anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
  21776. * @property {import("./IconOrigin.js").default} [anchorOrigin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,
  21777. * `top-left` or `top-right`.
  21778. * @property {import("./IconAnchorUnits.js").default} [anchorXUnits='fraction'] Units in which the anchor x value is
  21779. * specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates
  21780. * the x value in pixels.
  21781. * @property {import("./IconAnchorUnits.js").default} [anchorYUnits='fraction'] Units in which the anchor y value is
  21782. * specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates
  21783. * the y value in pixels.
  21784. * @property {import("../color.js").Color|string} [color] Color to tint the icon. If not specified,
  21785. * the icon will be left as is.
  21786. * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that you must provide a
  21787. * `crossOrigin` value if you want to access pixel data with the Canvas renderer.
  21788. * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
  21789. * @property {HTMLImageElement|HTMLCanvasElement} [img] Image object for the icon. If the `src` option is not provided then the
  21790. * provided image must already be loaded. And in that case, it is required
  21791. * to provide the size of the image, with the `imgSize` option.
  21792. * @property {Array<number>} [offset=[0, 0]] Offset, which, together with the size and the offset origin, define the
  21793. * sub-rectangle to use from the original icon image.
  21794. * @property {Array<number>} [displacement=[0,0]] Displacement of the icon.
  21795. * @property {import("./IconOrigin.js").default} [offsetOrigin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,
  21796. * `top-left` or `top-right`.
  21797. * @property {number} [opacity=1] Opacity of the icon.
  21798. * @property {number|import("../size.js").Size} [scale=1] Scale.
  21799. * @property {boolean} [rotateWithView=false] Whether to rotate the icon with the view.
  21800. * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
  21801. * @property {import("../size.js").Size} [size] Icon size in pixel. Can be used together with `offset` to define the
  21802. * sub-rectangle to use from the origin (sprite) icon image.
  21803. * @property {import("../size.js").Size} [imgSize] Image size in pixels. Only required if `img` is set and `src` is not, and
  21804. * for SVG images in Internet Explorer 11. The provided `imgSize` needs to match the actual size of the image.
  21805. * @property {string} [src] Image source URI.
  21806. * @property {"declutter"|"obstacle"|"none"|undefined} [declutterMode] Declutter mode
  21807. */
  21808. /**
  21809. * @classdesc
  21810. * Set icon style for vector features.
  21811. * @api
  21812. */
  21813. var Icon = /** @class */ (function (_super) {
  21814. Icon_extends(Icon, _super);
  21815. /**
  21816. * @param {Options} [opt_options] Options.
  21817. */
  21818. function Icon(opt_options) {
  21819. var _this = this;
  21820. var options = opt_options || {};
  21821. /**
  21822. * @type {number}
  21823. */
  21824. var opacity = options.opacity !== undefined ? options.opacity : 1;
  21825. /**
  21826. * @type {number}
  21827. */
  21828. var rotation = options.rotation !== undefined ? options.rotation : 0;
  21829. /**
  21830. * @type {number|import("../size.js").Size}
  21831. */
  21832. var scale = options.scale !== undefined ? options.scale : 1;
  21833. /**
  21834. * @type {boolean}
  21835. */
  21836. var rotateWithView = options.rotateWithView !== undefined ? options.rotateWithView : false;
  21837. _this = _super.call(this, {
  21838. opacity: opacity,
  21839. rotation: rotation,
  21840. scale: scale,
  21841. displacement: options.displacement !== undefined ? options.displacement : [0, 0],
  21842. rotateWithView: rotateWithView,
  21843. declutterMode: options.declutterMode,
  21844. }) || this;
  21845. /**
  21846. * @private
  21847. * @type {Array<number>}
  21848. */
  21849. _this.anchor_ = options.anchor !== undefined ? options.anchor : [0.5, 0.5];
  21850. /**
  21851. * @private
  21852. * @type {Array<number>}
  21853. */
  21854. _this.normalizedAnchor_ = null;
  21855. /**
  21856. * @private
  21857. * @type {import("./IconOrigin.js").default}
  21858. */
  21859. _this.anchorOrigin_ =
  21860. options.anchorOrigin !== undefined
  21861. ? options.anchorOrigin
  21862. : IconOrigin.TOP_LEFT;
  21863. /**
  21864. * @private
  21865. * @type {import("./IconAnchorUnits.js").default}
  21866. */
  21867. _this.anchorXUnits_ =
  21868. options.anchorXUnits !== undefined
  21869. ? options.anchorXUnits
  21870. : IconAnchorUnits.FRACTION;
  21871. /**
  21872. * @private
  21873. * @type {import("./IconAnchorUnits.js").default}
  21874. */
  21875. _this.anchorYUnits_ =
  21876. options.anchorYUnits !== undefined
  21877. ? options.anchorYUnits
  21878. : IconAnchorUnits.FRACTION;
  21879. /**
  21880. * @private
  21881. * @type {?string}
  21882. */
  21883. _this.crossOrigin_ =
  21884. options.crossOrigin !== undefined ? options.crossOrigin : null;
  21885. /**
  21886. * @type {HTMLImageElement|HTMLCanvasElement}
  21887. */
  21888. var image = options.img !== undefined ? options.img : null;
  21889. /**
  21890. * @private
  21891. * @type {import("../size.js").Size|undefined}
  21892. */
  21893. _this.imgSize_ = options.imgSize;
  21894. /**
  21895. * @type {string|undefined}
  21896. */
  21897. var src = options.src;
  21898. asserts_assert(!(src !== undefined && image), 4); // `image` and `src` cannot be provided at the same time
  21899. asserts_assert(!image || (image && _this.imgSize_), 5); // `imgSize` must be set when `image` is provided
  21900. if ((src === undefined || src.length === 0) && image) {
  21901. src = /** @type {HTMLImageElement} */ (image).src || getUid(image);
  21902. }
  21903. asserts_assert(src !== undefined && src.length > 0, 6); // A defined and non-empty `src` or `image` must be provided
  21904. /**
  21905. * @type {import("../ImageState.js").default}
  21906. */
  21907. var imageState = options.src !== undefined ? ImageState.IDLE : ImageState.LOADED;
  21908. /**
  21909. * @private
  21910. * @type {import("../color.js").Color}
  21911. */
  21912. _this.color_ = options.color !== undefined ? asArray(options.color) : null;
  21913. /**
  21914. * @private
  21915. * @type {import("./IconImage.js").default}
  21916. */
  21917. _this.iconImage_ = IconImage_get(image,
  21918. /** @type {string} */ (src), _this.imgSize_ !== undefined ? _this.imgSize_ : null, _this.crossOrigin_, imageState, _this.color_);
  21919. /**
  21920. * @private
  21921. * @type {Array<number>}
  21922. */
  21923. _this.offset_ = options.offset !== undefined ? options.offset : [0, 0];
  21924. /**
  21925. * @private
  21926. * @type {import("./IconOrigin.js").default}
  21927. */
  21928. _this.offsetOrigin_ =
  21929. options.offsetOrigin !== undefined
  21930. ? options.offsetOrigin
  21931. : IconOrigin.TOP_LEFT;
  21932. /**
  21933. * @private
  21934. * @type {Array<number>}
  21935. */
  21936. _this.origin_ = null;
  21937. /**
  21938. * @private
  21939. * @type {import("../size.js").Size}
  21940. */
  21941. _this.size_ = options.size !== undefined ? options.size : null;
  21942. return _this;
  21943. }
  21944. /**
  21945. * Clones the style. The underlying Image/HTMLCanvasElement is not cloned.
  21946. * @return {Icon} The cloned style.
  21947. * @api
  21948. */
  21949. Icon.prototype.clone = function () {
  21950. var scale = this.getScale();
  21951. return new Icon({
  21952. anchor: this.anchor_.slice(),
  21953. anchorOrigin: this.anchorOrigin_,
  21954. anchorXUnits: this.anchorXUnits_,
  21955. anchorYUnits: this.anchorYUnits_,
  21956. color: this.color_ && this.color_.slice
  21957. ? this.color_.slice()
  21958. : this.color_ || undefined,
  21959. crossOrigin: this.crossOrigin_,
  21960. imgSize: this.imgSize_,
  21961. offset: this.offset_.slice(),
  21962. offsetOrigin: this.offsetOrigin_,
  21963. opacity: this.getOpacity(),
  21964. rotateWithView: this.getRotateWithView(),
  21965. rotation: this.getRotation(),
  21966. scale: Array.isArray(scale) ? scale.slice() : scale,
  21967. size: this.size_ !== null ? this.size_.slice() : undefined,
  21968. src: this.getSrc(),
  21969. displacement: this.getDisplacement().slice(),
  21970. declutterMode: this.getDeclutterMode(),
  21971. });
  21972. };
  21973. /**
  21974. * Get the anchor point in pixels. The anchor determines the center point for the
  21975. * symbolizer.
  21976. * @return {Array<number>} Anchor.
  21977. * @api
  21978. */
  21979. Icon.prototype.getAnchor = function () {
  21980. var anchor = this.normalizedAnchor_;
  21981. if (!anchor) {
  21982. anchor = this.anchor_;
  21983. var size = this.getSize();
  21984. if (this.anchorXUnits_ == IconAnchorUnits.FRACTION ||
  21985. this.anchorYUnits_ == IconAnchorUnits.FRACTION) {
  21986. if (!size) {
  21987. return null;
  21988. }
  21989. anchor = this.anchor_.slice();
  21990. if (this.anchorXUnits_ == IconAnchorUnits.FRACTION) {
  21991. anchor[0] *= size[0];
  21992. }
  21993. if (this.anchorYUnits_ == IconAnchorUnits.FRACTION) {
  21994. anchor[1] *= size[1];
  21995. }
  21996. }
  21997. if (this.anchorOrigin_ != IconOrigin.TOP_LEFT) {
  21998. if (!size) {
  21999. return null;
  22000. }
  22001. if (anchor === this.anchor_) {
  22002. anchor = this.anchor_.slice();
  22003. }
  22004. if (this.anchorOrigin_ == IconOrigin.TOP_RIGHT ||
  22005. this.anchorOrigin_ == IconOrigin.BOTTOM_RIGHT) {
  22006. anchor[0] = -anchor[0] + size[0];
  22007. }
  22008. if (this.anchorOrigin_ == IconOrigin.BOTTOM_LEFT ||
  22009. this.anchorOrigin_ == IconOrigin.BOTTOM_RIGHT) {
  22010. anchor[1] = -anchor[1] + size[1];
  22011. }
  22012. }
  22013. this.normalizedAnchor_ = anchor;
  22014. }
  22015. var displacement = this.getDisplacement();
  22016. return [anchor[0] - displacement[0], anchor[1] + displacement[1]];
  22017. };
  22018. /**
  22019. * Set the anchor point. The anchor determines the center point for the
  22020. * symbolizer.
  22021. *
  22022. * @param {Array<number>} anchor Anchor.
  22023. * @api
  22024. */
  22025. Icon.prototype.setAnchor = function (anchor) {
  22026. this.anchor_ = anchor;
  22027. this.normalizedAnchor_ = null;
  22028. };
  22029. /**
  22030. * Get the icon color.
  22031. * @return {import("../color.js").Color} Color.
  22032. * @api
  22033. */
  22034. Icon.prototype.getColor = function () {
  22035. return this.color_;
  22036. };
  22037. /**
  22038. * Get the image icon.
  22039. * @param {number} pixelRatio Pixel ratio.
  22040. * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
  22041. * @api
  22042. */
  22043. Icon.prototype.getImage = function (pixelRatio) {
  22044. return this.iconImage_.getImage(pixelRatio);
  22045. };
  22046. /**
  22047. * Get the pixel ratio.
  22048. * @param {number} pixelRatio Pixel ratio.
  22049. * @return {number} The pixel ratio of the image.
  22050. * @api
  22051. */
  22052. Icon.prototype.getPixelRatio = function (pixelRatio) {
  22053. return this.iconImage_.getPixelRatio(pixelRatio);
  22054. };
  22055. /**
  22056. * @return {import("../size.js").Size} Image size.
  22057. */
  22058. Icon.prototype.getImageSize = function () {
  22059. return this.iconImage_.getSize();
  22060. };
  22061. /**
  22062. * @return {import("../ImageState.js").default} Image state.
  22063. */
  22064. Icon.prototype.getImageState = function () {
  22065. return this.iconImage_.getImageState();
  22066. };
  22067. /**
  22068. * @return {HTMLImageElement|HTMLCanvasElement} Image element.
  22069. */
  22070. Icon.prototype.getHitDetectionImage = function () {
  22071. return this.iconImage_.getHitDetectionImage();
  22072. };
  22073. /**
  22074. * Get the origin of the symbolizer.
  22075. * @return {Array<number>} Origin.
  22076. * @api
  22077. */
  22078. Icon.prototype.getOrigin = function () {
  22079. if (this.origin_) {
  22080. return this.origin_;
  22081. }
  22082. var offset = this.offset_;
  22083. if (this.offsetOrigin_ != IconOrigin.TOP_LEFT) {
  22084. var size = this.getSize();
  22085. var iconImageSize = this.iconImage_.getSize();
  22086. if (!size || !iconImageSize) {
  22087. return null;
  22088. }
  22089. offset = offset.slice();
  22090. if (this.offsetOrigin_ == IconOrigin.TOP_RIGHT ||
  22091. this.offsetOrigin_ == IconOrigin.BOTTOM_RIGHT) {
  22092. offset[0] = iconImageSize[0] - size[0] - offset[0];
  22093. }
  22094. if (this.offsetOrigin_ == IconOrigin.BOTTOM_LEFT ||
  22095. this.offsetOrigin_ == IconOrigin.BOTTOM_RIGHT) {
  22096. offset[1] = iconImageSize[1] - size[1] - offset[1];
  22097. }
  22098. }
  22099. this.origin_ = offset;
  22100. return this.origin_;
  22101. };
  22102. /**
  22103. * Get the image URL.
  22104. * @return {string|undefined} Image src.
  22105. * @api
  22106. */
  22107. Icon.prototype.getSrc = function () {
  22108. return this.iconImage_.getSrc();
  22109. };
  22110. /**
  22111. * Get the size of the icon (in pixels).
  22112. * @return {import("../size.js").Size} Image size.
  22113. * @api
  22114. */
  22115. Icon.prototype.getSize = function () {
  22116. return !this.size_ ? this.iconImage_.getSize() : this.size_;
  22117. };
  22118. /**
  22119. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  22120. */
  22121. Icon.prototype.listenImageChange = function (listener) {
  22122. this.iconImage_.addEventListener(EventType.CHANGE, listener);
  22123. };
  22124. /**
  22125. * Load not yet loaded URI.
  22126. * When rendering a feature with an icon style, the vector renderer will
  22127. * automatically call this method. However, you might want to call this
  22128. * method yourself for preloading or other purposes.
  22129. * @api
  22130. */
  22131. Icon.prototype.load = function () {
  22132. this.iconImage_.load();
  22133. };
  22134. /**
  22135. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  22136. */
  22137. Icon.prototype.unlistenImageChange = function (listener) {
  22138. this.iconImage_.removeEventListener(EventType.CHANGE, listener);
  22139. };
  22140. return Icon;
  22141. }(style_Image));
  22142. /* harmony default export */ var style_Icon = (Icon);
  22143. //# sourceMappingURL=Icon.js.map
  22144. ;// ./node_modules/ol/render/canvas/hitdetect.js
  22145. /**
  22146. * @module ol/render/canvas/hitdetect
  22147. */
  22148. var HIT_DETECT_RESOLUTION = 0.5;
  22149. /**
  22150. * @param {import("../../size.js").Size} size Canvas size in css pixels.
  22151. * @param {Array<import("../../transform.js").Transform>} transforms Transforms
  22152. * for rendering features to all worlds of the viewport, from coordinates to css
  22153. * pixels.
  22154. * @param {Array<import("../../Feature.js").FeatureLike>} features
  22155. * Features to consider for hit detection.
  22156. * @param {import("../../style/Style.js").StyleFunction|undefined} styleFunction
  22157. * Layer style function.
  22158. * @param {import("../../extent.js").Extent} extent Extent.
  22159. * @param {number} resolution Resolution.
  22160. * @param {number} rotation Rotation.
  22161. * @return {ImageData} Hit detection image data.
  22162. */
  22163. function createHitDetectionImageData(size, transforms, features, styleFunction, extent, resolution, rotation) {
  22164. var width = size[0] * HIT_DETECT_RESOLUTION;
  22165. var height = size[1] * HIT_DETECT_RESOLUTION;
  22166. var context = createCanvasContext2D(width, height);
  22167. context.imageSmoothingEnabled = false;
  22168. var canvas = context.canvas;
  22169. var renderer = new Immediate(context, HIT_DETECT_RESOLUTION, extent, null, rotation);
  22170. var featureCount = features.length;
  22171. // Stretch hit detection index to use the whole available color range
  22172. var indexFactor = Math.floor((256 * 256 * 256 - 1) / featureCount);
  22173. var featuresByZIndex = {};
  22174. for (var i = 1; i <= featureCount; ++i) {
  22175. var feature = features[i - 1];
  22176. var featureStyleFunction = feature.getStyleFunction() || styleFunction;
  22177. if (!styleFunction) {
  22178. continue;
  22179. }
  22180. var styles = featureStyleFunction(feature, resolution);
  22181. if (!styles) {
  22182. continue;
  22183. }
  22184. if (!Array.isArray(styles)) {
  22185. styles = [styles];
  22186. }
  22187. var index = i * indexFactor;
  22188. var color = '#' + ('000000' + index.toString(16)).slice(-6);
  22189. for (var j = 0, jj = styles.length; j < jj; ++j) {
  22190. var originalStyle = styles[j];
  22191. var geometry = originalStyle.getGeometryFunction()(feature);
  22192. if (!geometry || !intersects(extent, geometry.getExtent())) {
  22193. continue;
  22194. }
  22195. var style = originalStyle.clone();
  22196. var fill = style.getFill();
  22197. if (fill) {
  22198. fill.setColor(color);
  22199. }
  22200. var stroke = style.getStroke();
  22201. if (stroke) {
  22202. stroke.setColor(color);
  22203. stroke.setLineDash(null);
  22204. }
  22205. style.setText(undefined);
  22206. var image = originalStyle.getImage();
  22207. if (image && image.getOpacity() !== 0) {
  22208. var imgSize = image.getImageSize();
  22209. if (!imgSize) {
  22210. continue;
  22211. }
  22212. var imgContext = createCanvasContext2D(imgSize[0], imgSize[1], undefined, { alpha: false });
  22213. var img = imgContext.canvas;
  22214. imgContext.fillStyle = color;
  22215. imgContext.fillRect(0, 0, img.width, img.height);
  22216. style.setImage(new style_Icon({
  22217. img: img,
  22218. imgSize: imgSize,
  22219. anchor: image.getAnchor(),
  22220. anchorXUnits: IconAnchorUnits.PIXELS,
  22221. anchorYUnits: IconAnchorUnits.PIXELS,
  22222. offset: image.getOrigin(),
  22223. opacity: 1,
  22224. size: image.getSize(),
  22225. scale: image.getScale(),
  22226. rotation: image.getRotation(),
  22227. rotateWithView: image.getRotateWithView(),
  22228. }));
  22229. }
  22230. var zIndex = style.getZIndex() || 0;
  22231. var byGeometryType = featuresByZIndex[zIndex];
  22232. if (!byGeometryType) {
  22233. byGeometryType = {};
  22234. featuresByZIndex[zIndex] = byGeometryType;
  22235. byGeometryType['Polygon'] = [];
  22236. byGeometryType['Circle'] = [];
  22237. byGeometryType['LineString'] = [];
  22238. byGeometryType['Point'] = [];
  22239. }
  22240. byGeometryType[geometry.getType().replace('Multi', '')].push(geometry, style);
  22241. }
  22242. }
  22243. var zIndexKeys = Object.keys(featuresByZIndex)
  22244. .map(Number)
  22245. .sort(numberSafeCompareFunction);
  22246. for (var i = 0, ii = zIndexKeys.length; i < ii; ++i) {
  22247. var byGeometryType = featuresByZIndex[zIndexKeys[i]];
  22248. for (var type in byGeometryType) {
  22249. var geomAndStyle = byGeometryType[type];
  22250. for (var j = 0, jj = geomAndStyle.length; j < jj; j += 2) {
  22251. renderer.setStyle(geomAndStyle[j + 1]);
  22252. for (var k = 0, kk = transforms.length; k < kk; ++k) {
  22253. renderer.setTransform(transforms[k]);
  22254. renderer.drawGeometry(geomAndStyle[j]);
  22255. }
  22256. }
  22257. }
  22258. }
  22259. return context.getImageData(0, 0, canvas.width, canvas.height);
  22260. }
  22261. /**
  22262. * @param {import("../../pixel").Pixel} pixel Pixel coordinate on the hit
  22263. * detection canvas in css pixels.
  22264. * @param {Array<import("../../Feature").FeatureLike>} features Features. Has to
  22265. * match the `features` array that was passed to `createHitDetectionImageData()`.
  22266. * @param {ImageData} imageData Hit detection image data generated by
  22267. * `createHitDetectionImageData()`.
  22268. * @return {Array<import("../../Feature").FeatureLike>} features Features.
  22269. */
  22270. function hitDetect(pixel, features, imageData) {
  22271. var resultFeatures = [];
  22272. if (imageData) {
  22273. var x = Math.floor(Math.round(pixel[0]) * HIT_DETECT_RESOLUTION);
  22274. var y = Math.floor(Math.round(pixel[1]) * HIT_DETECT_RESOLUTION);
  22275. // The pixel coordinate is clamped down to the hit-detect canvas' size to account
  22276. // for browsers returning coordinates slightly larger than the actual canvas size
  22277. // due to a non-integer pixel ratio.
  22278. var index = (math_clamp(x, 0, imageData.width - 1) +
  22279. math_clamp(y, 0, imageData.height - 1) * imageData.width) *
  22280. 4;
  22281. var r = imageData.data[index];
  22282. var g = imageData.data[index + 1];
  22283. var b = imageData.data[index + 2];
  22284. var i = b + 256 * (g + 256 * r);
  22285. var indexFactor = Math.floor((256 * 256 * 256 - 1) / features.length);
  22286. if (i && i % indexFactor === 0) {
  22287. resultFeatures.push(features[i / indexFactor - 1]);
  22288. }
  22289. }
  22290. return resultFeatures;
  22291. }
  22292. //# sourceMappingURL=hitdetect.js.map
  22293. ;// ./node_modules/ol/renderer/vector.js
  22294. /**
  22295. * @module ol/renderer/vector
  22296. */
  22297. /**
  22298. * Feature callback. The callback will be called with three arguments. The first
  22299. * argument is one {@link module:ol/Feature~Feature feature} or {@link module:ol/render/Feature~RenderFeature render feature}
  22300. * at the pixel, the second is the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for
  22301. * unmanaged layers. The third is the {@link module:ol/geom/SimpleGeometry~SimpleGeometry} of the feature. For features
  22302. * with a GeometryCollection geometry, it will be the first detected geometry from the collection.
  22303. * @template T
  22304. * @typedef {function(import("../Feature.js").FeatureLike, import("../layer/Layer.js").default<import("../source/Source").default>, import("../geom/SimpleGeometry.js").default): T} FeatureCallback
  22305. */
  22306. /**
  22307. * Tolerance for geometry simplification in device pixels.
  22308. * @type {number}
  22309. */
  22310. var SIMPLIFY_TOLERANCE = 0.5;
  22311. /**
  22312. * @const
  22313. * @type {Object<import("../geom/Geometry.js").Type,
  22314. * function(import("../render/canvas/BuilderGroup.js").default, import("../geom/Geometry.js").default,
  22315. * import("../style/Style.js").default, Object): void>}
  22316. */
  22317. var GEOMETRY_RENDERERS = {
  22318. 'Point': renderPointGeometry,
  22319. 'LineString': renderLineStringGeometry,
  22320. 'Polygon': renderPolygonGeometry,
  22321. 'MultiPoint': renderMultiPointGeometry,
  22322. 'MultiLineString': renderMultiLineStringGeometry,
  22323. 'MultiPolygon': renderMultiPolygonGeometry,
  22324. 'GeometryCollection': renderGeometryCollectionGeometry,
  22325. 'Circle': renderCircleGeometry,
  22326. };
  22327. /**
  22328. * @param {import("../Feature.js").FeatureLike} feature1 Feature 1.
  22329. * @param {import("../Feature.js").FeatureLike} feature2 Feature 2.
  22330. * @return {number} Order.
  22331. */
  22332. function defaultOrder(feature1, feature2) {
  22333. return parseInt(getUid(feature1), 10) - parseInt(getUid(feature2), 10);
  22334. }
  22335. /**
  22336. * @param {number} resolution Resolution.
  22337. * @param {number} pixelRatio Pixel ratio.
  22338. * @return {number} Squared pixel tolerance.
  22339. */
  22340. function getSquaredTolerance(resolution, pixelRatio) {
  22341. var tolerance = getTolerance(resolution, pixelRatio);
  22342. return tolerance * tolerance;
  22343. }
  22344. /**
  22345. * @param {number} resolution Resolution.
  22346. * @param {number} pixelRatio Pixel ratio.
  22347. * @return {number} Pixel tolerance.
  22348. */
  22349. function getTolerance(resolution, pixelRatio) {
  22350. return (SIMPLIFY_TOLERANCE * resolution) / pixelRatio;
  22351. }
  22352. /**
  22353. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Builder group.
  22354. * @param {import("../geom/Circle.js").default} geometry Geometry.
  22355. * @param {import("../style/Style.js").default} style Style.
  22356. * @param {import("../Feature.js").default} feature Feature.
  22357. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22358. */
  22359. function renderCircleGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22360. var fillStyle = style.getFill();
  22361. var strokeStyle = style.getStroke();
  22362. if (fillStyle || strokeStyle) {
  22363. var circleReplay = builderGroup.getBuilder(style.getZIndex(), 'Circle');
  22364. circleReplay.setFillStrokeStyle(fillStyle, strokeStyle);
  22365. circleReplay.drawCircle(geometry, feature);
  22366. }
  22367. var textStyle = style.getText();
  22368. if (textStyle && textStyle.getText()) {
  22369. var textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder(style.getZIndex(), 'Text');
  22370. textReplay.setTextStyle(textStyle);
  22371. textReplay.drawText(geometry, feature);
  22372. }
  22373. }
  22374. /**
  22375. * @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
  22376. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22377. * @param {import("../style/Style.js").default} style Style.
  22378. * @param {number} squaredTolerance Squared tolerance.
  22379. * @param {function(import("../events/Event.js").default): void} listener Listener function.
  22380. * @param {import("../proj.js").TransformFunction} [opt_transform] Transform from user to view projection.
  22381. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22382. * @return {boolean} `true` if style is loading.
  22383. */
  22384. function renderFeature(replayGroup, feature, style, squaredTolerance, listener, opt_transform, opt_declutterBuilderGroup) {
  22385. var loading = false;
  22386. var imageStyle = style.getImage();
  22387. if (imageStyle) {
  22388. var imageState = imageStyle.getImageState();
  22389. if (imageState == ImageState.LOADED || imageState == ImageState.ERROR) {
  22390. imageStyle.unlistenImageChange(listener);
  22391. }
  22392. else {
  22393. if (imageState == ImageState.IDLE) {
  22394. imageStyle.load();
  22395. }
  22396. imageStyle.listenImageChange(listener);
  22397. loading = true;
  22398. }
  22399. }
  22400. renderFeatureInternal(replayGroup, feature, style, squaredTolerance, opt_transform, opt_declutterBuilderGroup);
  22401. return loading;
  22402. }
  22403. /**
  22404. * @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
  22405. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22406. * @param {import("../style/Style.js").default} style Style.
  22407. * @param {number} squaredTolerance Squared tolerance.
  22408. * @param {import("../proj.js").TransformFunction} [opt_transform] Optional transform function.
  22409. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22410. */
  22411. function renderFeatureInternal(replayGroup, feature, style, squaredTolerance, opt_transform, opt_declutterBuilderGroup) {
  22412. var geometry = style.getGeometryFunction()(feature);
  22413. if (!geometry) {
  22414. return;
  22415. }
  22416. var simplifiedGeometry = geometry.simplifyTransformed(squaredTolerance, opt_transform);
  22417. var renderer = style.getRenderer();
  22418. if (renderer) {
  22419. renderGeometry(replayGroup, simplifiedGeometry, style, feature);
  22420. }
  22421. else {
  22422. var geometryRenderer = GEOMETRY_RENDERERS[simplifiedGeometry.getType()];
  22423. geometryRenderer(replayGroup, simplifiedGeometry, style, feature, opt_declutterBuilderGroup);
  22424. }
  22425. }
  22426. /**
  22427. * @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
  22428. * @param {import("../geom/Geometry.js").default|import("../render/Feature.js").default} geometry Geometry.
  22429. * @param {import("../style/Style.js").default} style Style.
  22430. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22431. */
  22432. function renderGeometry(replayGroup, geometry, style, feature) {
  22433. if (geometry.getType() == 'GeometryCollection') {
  22434. var geometries =
  22435. /** @type {import("../geom/GeometryCollection.js").default} */ (geometry).getGeometries();
  22436. for (var i = 0, ii = geometries.length; i < ii; ++i) {
  22437. renderGeometry(replayGroup, geometries[i], style, feature);
  22438. }
  22439. return;
  22440. }
  22441. var replay = replayGroup.getBuilder(style.getZIndex(), 'Default');
  22442. replay.drawCustom(
  22443. /** @type {import("../geom/SimpleGeometry.js").default} */ (geometry), feature, style.getRenderer(), style.getHitDetectionRenderer());
  22444. }
  22445. /**
  22446. * @param {import("../render/canvas/BuilderGroup.js").default} replayGroup Replay group.
  22447. * @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
  22448. * @param {import("../style/Style.js").default} style Style.
  22449. * @param {import("../Feature.js").default} feature Feature.
  22450. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22451. */
  22452. function renderGeometryCollectionGeometry(replayGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22453. var geometries = geometry.getGeometriesArray();
  22454. var i, ii;
  22455. for (i = 0, ii = geometries.length; i < ii; ++i) {
  22456. var geometryRenderer = GEOMETRY_RENDERERS[geometries[i].getType()];
  22457. geometryRenderer(replayGroup, geometries[i], style, feature, opt_declutterBuilderGroup);
  22458. }
  22459. }
  22460. /**
  22461. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
  22462. * @param {import("../geom/LineString.js").default|import("../render/Feature.js").default} geometry Geometry.
  22463. * @param {import("../style/Style.js").default} style Style.
  22464. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22465. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22466. */
  22467. function renderLineStringGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22468. var strokeStyle = style.getStroke();
  22469. if (strokeStyle) {
  22470. var lineStringReplay = builderGroup.getBuilder(style.getZIndex(), 'LineString');
  22471. lineStringReplay.setFillStrokeStyle(null, strokeStyle);
  22472. lineStringReplay.drawLineString(geometry, feature);
  22473. }
  22474. var textStyle = style.getText();
  22475. if (textStyle && textStyle.getText()) {
  22476. var textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder(style.getZIndex(), 'Text');
  22477. textReplay.setTextStyle(textStyle);
  22478. textReplay.drawText(geometry, feature);
  22479. }
  22480. }
  22481. /**
  22482. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
  22483. * @param {import("../geom/MultiLineString.js").default|import("../render/Feature.js").default} geometry Geometry.
  22484. * @param {import("../style/Style.js").default} style Style.
  22485. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22486. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22487. */
  22488. function renderMultiLineStringGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22489. var strokeStyle = style.getStroke();
  22490. if (strokeStyle) {
  22491. var lineStringReplay = builderGroup.getBuilder(style.getZIndex(), 'LineString');
  22492. lineStringReplay.setFillStrokeStyle(null, strokeStyle);
  22493. lineStringReplay.drawMultiLineString(geometry, feature);
  22494. }
  22495. var textStyle = style.getText();
  22496. if (textStyle && textStyle.getText()) {
  22497. var textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder(style.getZIndex(), 'Text');
  22498. textReplay.setTextStyle(textStyle);
  22499. textReplay.drawText(geometry, feature);
  22500. }
  22501. }
  22502. /**
  22503. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
  22504. * @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
  22505. * @param {import("../style/Style.js").default} style Style.
  22506. * @param {import("../Feature.js").default} feature Feature.
  22507. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22508. */
  22509. function renderMultiPolygonGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22510. var fillStyle = style.getFill();
  22511. var strokeStyle = style.getStroke();
  22512. if (strokeStyle || fillStyle) {
  22513. var polygonReplay = builderGroup.getBuilder(style.getZIndex(), 'Polygon');
  22514. polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
  22515. polygonReplay.drawMultiPolygon(geometry, feature);
  22516. }
  22517. var textStyle = style.getText();
  22518. if (textStyle && textStyle.getText()) {
  22519. var textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder(style.getZIndex(), 'Text');
  22520. textReplay.setTextStyle(textStyle);
  22521. textReplay.drawText(geometry, feature);
  22522. }
  22523. }
  22524. /**
  22525. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
  22526. * @param {import("../geom/Point.js").default|import("../render/Feature.js").default} geometry Geometry.
  22527. * @param {import("../style/Style.js").default} style Style.
  22528. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22529. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22530. */
  22531. function renderPointGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22532. var imageStyle = style.getImage();
  22533. var textStyle = style.getText();
  22534. /** @type {import("../render/canvas.js").DeclutterImageWithText} */
  22535. var declutterImageWithText;
  22536. if (imageStyle) {
  22537. if (imageStyle.getImageState() != ImageState.LOADED) {
  22538. return;
  22539. }
  22540. var imageBuilderGroup = builderGroup;
  22541. if (opt_declutterBuilderGroup) {
  22542. var declutterMode = imageStyle.getDeclutterMode();
  22543. if (declutterMode !== 'none') {
  22544. imageBuilderGroup = opt_declutterBuilderGroup;
  22545. if (declutterMode === 'obstacle') {
  22546. // draw in non-declutter group:
  22547. var imageReplay_1 = builderGroup.getBuilder(style.getZIndex(), 'Image');
  22548. imageReplay_1.setImageStyle(imageStyle, declutterImageWithText);
  22549. imageReplay_1.drawPoint(geometry, feature);
  22550. }
  22551. else if (textStyle && textStyle.getText()) {
  22552. declutterImageWithText = {};
  22553. }
  22554. }
  22555. }
  22556. var imageReplay = imageBuilderGroup.getBuilder(style.getZIndex(), 'Image');
  22557. imageReplay.setImageStyle(imageStyle, declutterImageWithText);
  22558. imageReplay.drawPoint(geometry, feature);
  22559. }
  22560. if (textStyle && textStyle.getText()) {
  22561. var textBuilderGroup = builderGroup;
  22562. if (opt_declutterBuilderGroup) {
  22563. textBuilderGroup = opt_declutterBuilderGroup;
  22564. }
  22565. var textReplay = textBuilderGroup.getBuilder(style.getZIndex(), 'Text');
  22566. textReplay.setTextStyle(textStyle, declutterImageWithText);
  22567. textReplay.drawText(geometry, feature);
  22568. }
  22569. }
  22570. /**
  22571. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
  22572. * @param {import("../geom/MultiPoint.js").default|import("../render/Feature.js").default} geometry Geometry.
  22573. * @param {import("../style/Style.js").default} style Style.
  22574. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22575. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22576. */
  22577. function renderMultiPointGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22578. var imageStyle = style.getImage();
  22579. var textStyle = style.getText();
  22580. /** @type {import("../render/canvas.js").DeclutterImageWithText} */
  22581. var declutterImageWithText;
  22582. if (imageStyle) {
  22583. if (imageStyle.getImageState() != ImageState.LOADED) {
  22584. return;
  22585. }
  22586. var imageBuilderGroup = builderGroup;
  22587. if (opt_declutterBuilderGroup) {
  22588. var declutterMode = imageStyle.getDeclutterMode();
  22589. if (declutterMode !== 'none') {
  22590. imageBuilderGroup = opt_declutterBuilderGroup;
  22591. if (declutterMode === 'obstacle') {
  22592. // draw in non-declutter group:
  22593. var imageReplay_2 = builderGroup.getBuilder(style.getZIndex(), 'Image');
  22594. imageReplay_2.setImageStyle(imageStyle, declutterImageWithText);
  22595. imageReplay_2.drawMultiPoint(geometry, feature);
  22596. }
  22597. else if (textStyle && textStyle.getText()) {
  22598. declutterImageWithText = {};
  22599. }
  22600. }
  22601. }
  22602. var imageReplay = imageBuilderGroup.getBuilder(style.getZIndex(), 'Image');
  22603. imageReplay.setImageStyle(imageStyle, declutterImageWithText);
  22604. imageReplay.drawMultiPoint(geometry, feature);
  22605. }
  22606. if (textStyle && textStyle.getText()) {
  22607. var textBuilderGroup = builderGroup;
  22608. if (opt_declutterBuilderGroup) {
  22609. textBuilderGroup = opt_declutterBuilderGroup;
  22610. }
  22611. var textReplay = textBuilderGroup.getBuilder(style.getZIndex(), 'Text');
  22612. textReplay.setTextStyle(textStyle, declutterImageWithText);
  22613. textReplay.drawText(geometry, feature);
  22614. }
  22615. }
  22616. /**
  22617. * @param {import("../render/canvas/BuilderGroup.js").default} builderGroup Replay group.
  22618. * @param {import("../geom/Polygon.js").default|import("../render/Feature.js").default} geometry Geometry.
  22619. * @param {import("../style/Style.js").default} style Style.
  22620. * @param {import("../Feature.js").FeatureLike} feature Feature.
  22621. * @param {import("../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  22622. */
  22623. function renderPolygonGeometry(builderGroup, geometry, style, feature, opt_declutterBuilderGroup) {
  22624. var fillStyle = style.getFill();
  22625. var strokeStyle = style.getStroke();
  22626. if (fillStyle || strokeStyle) {
  22627. var polygonReplay = builderGroup.getBuilder(style.getZIndex(), 'Polygon');
  22628. polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
  22629. polygonReplay.drawPolygon(geometry, feature);
  22630. }
  22631. var textStyle = style.getText();
  22632. if (textStyle && textStyle.getText()) {
  22633. var textReplay = (opt_declutterBuilderGroup || builderGroup).getBuilder(style.getZIndex(), 'Text');
  22634. textReplay.setTextStyle(textStyle);
  22635. textReplay.drawText(geometry, feature);
  22636. }
  22637. }
  22638. //# sourceMappingURL=vector.js.map
  22639. ;// ./node_modules/ol/renderer/canvas/VectorLayer.js
  22640. var VectorLayer_extends = (undefined && undefined.__extends) || (function () {
  22641. var extendStatics = function (d, b) {
  22642. extendStatics = Object.setPrototypeOf ||
  22643. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22644. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  22645. return extendStatics(d, b);
  22646. };
  22647. return function (d, b) {
  22648. if (typeof b !== "function" && b !== null)
  22649. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  22650. extendStatics(d, b);
  22651. function __() { this.constructor = d; }
  22652. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22653. };
  22654. })();
  22655. /**
  22656. * @module ol/renderer/canvas/VectorLayer
  22657. */
  22658. /**
  22659. * @classdesc
  22660. * Canvas renderer for vector layers.
  22661. * @api
  22662. */
  22663. var CanvasVectorLayerRenderer = /** @class */ (function (_super) {
  22664. VectorLayer_extends(CanvasVectorLayerRenderer, _super);
  22665. /**
  22666. * @param {import("../../layer/BaseVector.js").default} vectorLayer Vector layer.
  22667. */
  22668. function CanvasVectorLayerRenderer(vectorLayer) {
  22669. var _this = _super.call(this, vectorLayer) || this;
  22670. /** @private */
  22671. _this.boundHandleStyleImageChange_ = _this.handleStyleImageChange_.bind(_this);
  22672. /**
  22673. * @type {boolean}
  22674. */
  22675. _this.animatingOrInteracting_;
  22676. /**
  22677. * @type {ImageData}
  22678. */
  22679. _this.hitDetectionImageData_ = null;
  22680. /**
  22681. * @type {Array<import("../../Feature.js").default>}
  22682. */
  22683. _this.renderedFeatures_ = null;
  22684. /**
  22685. * @private
  22686. * @type {number}
  22687. */
  22688. _this.renderedRevision_ = -1;
  22689. /**
  22690. * @private
  22691. * @type {number}
  22692. */
  22693. _this.renderedResolution_ = NaN;
  22694. /**
  22695. * @private
  22696. * @type {import("../../extent.js").Extent}
  22697. */
  22698. _this.renderedExtent_ = createEmpty();
  22699. /**
  22700. * @private
  22701. * @type {import("../../extent.js").Extent}
  22702. */
  22703. _this.wrappedRenderedExtent_ = createEmpty();
  22704. /**
  22705. * @private
  22706. * @type {number}
  22707. */
  22708. _this.renderedRotation_;
  22709. /**
  22710. * @private
  22711. * @type {import("../../coordinate").Coordinate}
  22712. */
  22713. _this.renderedCenter_ = null;
  22714. /**
  22715. * @private
  22716. * @type {import("../../proj/Projection").default}
  22717. */
  22718. _this.renderedProjection_ = null;
  22719. /**
  22720. * @private
  22721. * @type {function(import("../../Feature.js").default, import("../../Feature.js").default): number|null}
  22722. */
  22723. _this.renderedRenderOrder_ = null;
  22724. /**
  22725. * @private
  22726. * @type {import("../../render/canvas/ExecutorGroup").default}
  22727. */
  22728. _this.replayGroup_ = null;
  22729. /**
  22730. * A new replay group had to be created by `prepareFrame()`
  22731. * @type {boolean}
  22732. */
  22733. _this.replayGroupChanged = true;
  22734. /**
  22735. * @type {import("../../render/canvas/ExecutorGroup").default}
  22736. */
  22737. _this.declutterExecutorGroup = null;
  22738. /**
  22739. * Clipping to be performed by `renderFrame()`
  22740. * @type {boolean}
  22741. */
  22742. _this.clipping = true;
  22743. /**
  22744. * @private
  22745. * @type {CanvasRenderingContext2D}
  22746. */
  22747. _this.compositionContext_ = null;
  22748. /**
  22749. * @private
  22750. * @type {number}
  22751. */
  22752. _this.opacity_ = 1;
  22753. return _this;
  22754. }
  22755. /**
  22756. * @param {ExecutorGroup} executorGroup Executor group.
  22757. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  22758. * @param {import("rbush").default} [opt_declutterTree] Declutter tree.
  22759. */
  22760. CanvasVectorLayerRenderer.prototype.renderWorlds = function (executorGroup, frameState, opt_declutterTree) {
  22761. var extent = frameState.extent;
  22762. var viewState = frameState.viewState;
  22763. var center = viewState.center;
  22764. var resolution = viewState.resolution;
  22765. var projection = viewState.projection;
  22766. var rotation = viewState.rotation;
  22767. var projectionExtent = projection.getExtent();
  22768. var vectorSource = this.getLayer().getSource();
  22769. var pixelRatio = frameState.pixelRatio;
  22770. var viewHints = frameState.viewHints;
  22771. var snapToPixel = !(viewHints[ViewHint.ANIMATING] || viewHints[ViewHint.INTERACTING]);
  22772. var context = this.compositionContext_;
  22773. var width = Math.round(frameState.size[0] * pixelRatio);
  22774. var height = Math.round(frameState.size[1] * pixelRatio);
  22775. var multiWorld = vectorSource.getWrapX() && projection.canWrapX();
  22776. var worldWidth = multiWorld ? extent_getWidth(projectionExtent) : null;
  22777. var endWorld = multiWorld
  22778. ? Math.ceil((extent[2] - projectionExtent[2]) / worldWidth) + 1
  22779. : 1;
  22780. var world = multiWorld
  22781. ? Math.floor((extent[0] - projectionExtent[0]) / worldWidth)
  22782. : 0;
  22783. do {
  22784. var transform = this.getRenderTransform(center, resolution, rotation, pixelRatio, width, height, world * worldWidth);
  22785. executorGroup.execute(context, 1, transform, rotation, snapToPixel, undefined, opt_declutterTree);
  22786. } while (++world < endWorld);
  22787. };
  22788. CanvasVectorLayerRenderer.prototype.setupCompositionContext_ = function () {
  22789. if (this.opacity_ !== 1) {
  22790. var compositionContext = createCanvasContext2D(this.context.canvas.width, this.context.canvas.height, canvasPool);
  22791. this.compositionContext_ = compositionContext;
  22792. }
  22793. else {
  22794. this.compositionContext_ = this.context;
  22795. }
  22796. };
  22797. CanvasVectorLayerRenderer.prototype.releaseCompositionContext_ = function () {
  22798. if (this.opacity_ !== 1) {
  22799. var alpha = this.context.globalAlpha;
  22800. this.context.globalAlpha = this.opacity_;
  22801. this.context.drawImage(this.compositionContext_.canvas, 0, 0);
  22802. this.context.globalAlpha = alpha;
  22803. releaseCanvas(this.compositionContext_);
  22804. canvasPool.push(this.compositionContext_.canvas);
  22805. this.compositionContext_ = null;
  22806. }
  22807. };
  22808. /**
  22809. * Render declutter items for this layer
  22810. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  22811. */
  22812. CanvasVectorLayerRenderer.prototype.renderDeclutter = function (frameState) {
  22813. if (this.declutterExecutorGroup) {
  22814. this.setupCompositionContext_();
  22815. this.renderWorlds(this.declutterExecutorGroup, frameState, frameState.declutterTree);
  22816. this.releaseCompositionContext_();
  22817. }
  22818. };
  22819. /**
  22820. * Render the layer.
  22821. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  22822. * @param {HTMLElement} target Target that may be used to render content to.
  22823. * @return {HTMLElement} The rendered element.
  22824. */
  22825. CanvasVectorLayerRenderer.prototype.renderFrame = function (frameState, target) {
  22826. var pixelRatio = frameState.pixelRatio;
  22827. var layerState = frameState.layerStatesArray[frameState.layerIndex];
  22828. // set forward and inverse pixel transforms
  22829. makeScale(this.pixelTransform, 1 / pixelRatio, 1 / pixelRatio);
  22830. makeInverse(this.inversePixelTransform, this.pixelTransform);
  22831. var canvasTransform = transform_toString(this.pixelTransform);
  22832. this.useContainer(target, canvasTransform, this.getBackground(frameState));
  22833. var context = this.context;
  22834. var canvas = context.canvas;
  22835. var replayGroup = this.replayGroup_;
  22836. var declutterExecutorGroup = this.declutterExecutorGroup;
  22837. if ((!replayGroup || replayGroup.isEmpty()) &&
  22838. (!declutterExecutorGroup || declutterExecutorGroup.isEmpty())) {
  22839. return null;
  22840. }
  22841. // resize and clear
  22842. var width = Math.round(frameState.size[0] * pixelRatio);
  22843. var height = Math.round(frameState.size[1] * pixelRatio);
  22844. if (canvas.width != width || canvas.height != height) {
  22845. canvas.width = width;
  22846. canvas.height = height;
  22847. if (canvas.style.transform !== canvasTransform) {
  22848. canvas.style.transform = canvasTransform;
  22849. }
  22850. }
  22851. else if (!this.containerReused) {
  22852. context.clearRect(0, 0, width, height);
  22853. }
  22854. this.preRender(context, frameState);
  22855. var viewState = frameState.viewState;
  22856. var projection = viewState.projection;
  22857. this.opacity_ = layerState.opacity;
  22858. this.setupCompositionContext_();
  22859. // clipped rendering if layer extent is set
  22860. var clipped = false;
  22861. var render = true;
  22862. if (layerState.extent && this.clipping) {
  22863. var layerExtent = proj_fromUserExtent(layerState.extent, projection);
  22864. render = intersects(layerExtent, frameState.extent);
  22865. clipped = render && !containsExtent(layerExtent, frameState.extent);
  22866. if (clipped) {
  22867. this.clipUnrotated(this.compositionContext_, frameState, layerExtent);
  22868. }
  22869. }
  22870. if (render) {
  22871. this.renderWorlds(replayGroup, frameState);
  22872. }
  22873. if (clipped) {
  22874. this.compositionContext_.restore();
  22875. }
  22876. this.releaseCompositionContext_();
  22877. this.postRender(context, frameState);
  22878. if (this.renderedRotation_ !== viewState.rotation) {
  22879. this.renderedRotation_ = viewState.rotation;
  22880. this.hitDetectionImageData_ = null;
  22881. }
  22882. return this.container;
  22883. };
  22884. /**
  22885. * Asynchronous layer level hit detection.
  22886. * @param {import("../../pixel.js").Pixel} pixel Pixel.
  22887. * @return {Promise<Array<import("../../Feature").default>>} Promise that resolves with an array of features.
  22888. */
  22889. CanvasVectorLayerRenderer.prototype.getFeatures = function (pixel) {
  22890. return new Promise(
  22891. /**
  22892. * @param {function(Array<import("../../Feature").default|import("../../render/Feature").default>): void} resolve Resolver function.
  22893. * @this {CanvasVectorLayerRenderer}
  22894. */
  22895. function (resolve) {
  22896. if (!this.hitDetectionImageData_ && !this.animatingOrInteracting_) {
  22897. var size = [this.context.canvas.width, this.context.canvas.height];
  22898. apply(this.pixelTransform, size);
  22899. var center = this.renderedCenter_;
  22900. var resolution = this.renderedResolution_;
  22901. var rotation = this.renderedRotation_;
  22902. var projection = this.renderedProjection_;
  22903. var extent = this.wrappedRenderedExtent_;
  22904. var layer = this.getLayer();
  22905. var transforms = [];
  22906. var width = size[0] * HIT_DETECT_RESOLUTION;
  22907. var height = size[1] * HIT_DETECT_RESOLUTION;
  22908. transforms.push(this.getRenderTransform(center, resolution, rotation, HIT_DETECT_RESOLUTION, width, height, 0).slice());
  22909. var source = layer.getSource();
  22910. var projectionExtent = projection.getExtent();
  22911. if (source.getWrapX() &&
  22912. projection.canWrapX() &&
  22913. !containsExtent(projectionExtent, extent)) {
  22914. var startX = extent[0];
  22915. var worldWidth = extent_getWidth(projectionExtent);
  22916. var world = 0;
  22917. var offsetX = void 0;
  22918. while (startX < projectionExtent[0]) {
  22919. --world;
  22920. offsetX = worldWidth * world;
  22921. transforms.push(this.getRenderTransform(center, resolution, rotation, HIT_DETECT_RESOLUTION, width, height, offsetX).slice());
  22922. startX += worldWidth;
  22923. }
  22924. world = 0;
  22925. startX = extent[2];
  22926. while (startX > projectionExtent[2]) {
  22927. ++world;
  22928. offsetX = worldWidth * world;
  22929. transforms.push(this.getRenderTransform(center, resolution, rotation, HIT_DETECT_RESOLUTION, width, height, offsetX).slice());
  22930. startX -= worldWidth;
  22931. }
  22932. }
  22933. this.hitDetectionImageData_ = createHitDetectionImageData(size, transforms, this.renderedFeatures_, layer.getStyleFunction(), extent, resolution, rotation);
  22934. }
  22935. resolve(hitDetect(pixel, this.renderedFeatures_, this.hitDetectionImageData_));
  22936. }.bind(this));
  22937. };
  22938. /**
  22939. * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
  22940. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  22941. * @param {number} hitTolerance Hit tolerance in pixels.
  22942. * @param {import("../vector.js").FeatureCallback<T>} callback Feature callback.
  22943. * @param {Array<import("../Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
  22944. * @return {T|undefined} Callback result.
  22945. * @template T
  22946. */
  22947. CanvasVectorLayerRenderer.prototype.forEachFeatureAtCoordinate = function (coordinate, frameState, hitTolerance, callback, matches) {
  22948. var _this = this;
  22949. if (!this.replayGroup_) {
  22950. return undefined;
  22951. }
  22952. var resolution = frameState.viewState.resolution;
  22953. var rotation = frameState.viewState.rotation;
  22954. var layer = this.getLayer();
  22955. /** @type {!Object<string, import("../Map.js").HitMatch<T>|true>} */
  22956. var features = {};
  22957. /**
  22958. * @param {import("../../Feature.js").FeatureLike} feature Feature.
  22959. * @param {import("../../geom/SimpleGeometry.js").default} geometry Geometry.
  22960. * @param {number} distanceSq The squared distance to the click position
  22961. * @return {T|undefined} Callback result.
  22962. */
  22963. var featureCallback = function (feature, geometry, distanceSq) {
  22964. var key = getUid(feature);
  22965. var match = features[key];
  22966. if (!match) {
  22967. if (distanceSq === 0) {
  22968. features[key] = true;
  22969. return callback(feature, layer, geometry);
  22970. }
  22971. matches.push((features[key] = {
  22972. feature: feature,
  22973. layer: layer,
  22974. geometry: geometry,
  22975. distanceSq: distanceSq,
  22976. callback: callback,
  22977. }));
  22978. }
  22979. else if (match !== true && distanceSq < match.distanceSq) {
  22980. if (distanceSq === 0) {
  22981. features[key] = true;
  22982. matches.splice(matches.lastIndexOf(match), 1);
  22983. return callback(feature, layer, geometry);
  22984. }
  22985. match.geometry = geometry;
  22986. match.distanceSq = distanceSq;
  22987. }
  22988. return undefined;
  22989. };
  22990. var result;
  22991. var executorGroups = [this.replayGroup_];
  22992. if (this.declutterExecutorGroup) {
  22993. executorGroups.push(this.declutterExecutorGroup);
  22994. }
  22995. executorGroups.some(function (executorGroup) {
  22996. return (result = executorGroup.forEachFeatureAtCoordinate(coordinate, resolution, rotation, hitTolerance, featureCallback, executorGroup === _this.declutterExecutorGroup &&
  22997. frameState.declutterTree
  22998. ? frameState.declutterTree.all().map(function (item) { return item.value; })
  22999. : null));
  23000. });
  23001. return result;
  23002. };
  23003. /**
  23004. * Perform action necessary to get the layer rendered after new fonts have loaded
  23005. */
  23006. CanvasVectorLayerRenderer.prototype.handleFontsChanged = function () {
  23007. var layer = this.getLayer();
  23008. if (layer.getVisible() && this.replayGroup_) {
  23009. layer.changed();
  23010. }
  23011. };
  23012. /**
  23013. * Handle changes in image style state.
  23014. * @param {import("../../events/Event.js").default} event Image style change event.
  23015. * @private
  23016. */
  23017. CanvasVectorLayerRenderer.prototype.handleStyleImageChange_ = function (event) {
  23018. this.renderIfReadyAndVisible();
  23019. };
  23020. /**
  23021. * Determine whether render should be called.
  23022. * @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
  23023. * @return {boolean} Layer is ready to be rendered.
  23024. */
  23025. CanvasVectorLayerRenderer.prototype.prepareFrame = function (frameState) {
  23026. var vectorLayer = this.getLayer();
  23027. var vectorSource = vectorLayer.getSource();
  23028. if (!vectorSource) {
  23029. return false;
  23030. }
  23031. var animating = frameState.viewHints[ViewHint.ANIMATING];
  23032. var interacting = frameState.viewHints[ViewHint.INTERACTING];
  23033. var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
  23034. var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
  23035. if ((this.ready && !updateWhileAnimating && animating) ||
  23036. (!updateWhileInteracting && interacting)) {
  23037. this.animatingOrInteracting_ = true;
  23038. return true;
  23039. }
  23040. this.animatingOrInteracting_ = false;
  23041. var frameStateExtent = frameState.extent;
  23042. var viewState = frameState.viewState;
  23043. var projection = viewState.projection;
  23044. var resolution = viewState.resolution;
  23045. var pixelRatio = frameState.pixelRatio;
  23046. var vectorLayerRevision = vectorLayer.getRevision();
  23047. var vectorLayerRenderBuffer = vectorLayer.getRenderBuffer();
  23048. var vectorLayerRenderOrder = vectorLayer.getRenderOrder();
  23049. if (vectorLayerRenderOrder === undefined) {
  23050. vectorLayerRenderOrder = defaultOrder;
  23051. }
  23052. var center = viewState.center.slice();
  23053. var extent = buffer(frameStateExtent, vectorLayerRenderBuffer * resolution);
  23054. var renderedExtent = extent.slice();
  23055. var loadExtents = [extent.slice()];
  23056. var projectionExtent = projection.getExtent();
  23057. if (vectorSource.getWrapX() &&
  23058. projection.canWrapX() &&
  23059. !containsExtent(projectionExtent, frameState.extent)) {
  23060. // For the replay group, we need an extent that intersects the real world
  23061. // (-180° to +180°). To support geometries in a coordinate range from -540°
  23062. // to +540°, we add at least 1 world width on each side of the projection
  23063. // extent. If the viewport is wider than the world, we need to add half of
  23064. // the viewport width to make sure we cover the whole viewport.
  23065. var worldWidth = extent_getWidth(projectionExtent);
  23066. var gutter = Math.max(extent_getWidth(extent) / 2, worldWidth);
  23067. extent[0] = projectionExtent[0] - gutter;
  23068. extent[2] = projectionExtent[2] + gutter;
  23069. coordinate_wrapX(center, projection);
  23070. var loadExtent = wrapX(loadExtents[0], projection);
  23071. // If the extent crosses the date line, we load data for both edges of the worlds
  23072. if (loadExtent[0] < projectionExtent[0] &&
  23073. loadExtent[2] < projectionExtent[2]) {
  23074. loadExtents.push([
  23075. loadExtent[0] + worldWidth,
  23076. loadExtent[1],
  23077. loadExtent[2] + worldWidth,
  23078. loadExtent[3],
  23079. ]);
  23080. }
  23081. else if (loadExtent[0] > projectionExtent[0] &&
  23082. loadExtent[2] > projectionExtent[2]) {
  23083. loadExtents.push([
  23084. loadExtent[0] - worldWidth,
  23085. loadExtent[1],
  23086. loadExtent[2] - worldWidth,
  23087. loadExtent[3],
  23088. ]);
  23089. }
  23090. }
  23091. if (this.ready &&
  23092. this.renderedResolution_ == resolution &&
  23093. this.renderedRevision_ == vectorLayerRevision &&
  23094. this.renderedRenderOrder_ == vectorLayerRenderOrder &&
  23095. containsExtent(this.wrappedRenderedExtent_, extent)) {
  23096. if (!equals(this.renderedExtent_, renderedExtent)) {
  23097. this.hitDetectionImageData_ = null;
  23098. this.renderedExtent_ = renderedExtent;
  23099. }
  23100. this.renderedCenter_ = center;
  23101. this.replayGroupChanged = false;
  23102. return true;
  23103. }
  23104. this.replayGroup_ = null;
  23105. var replayGroup = new canvas_BuilderGroup(getTolerance(resolution, pixelRatio), extent, resolution, pixelRatio);
  23106. var declutterBuilderGroup;
  23107. if (this.getLayer().getDeclutter()) {
  23108. declutterBuilderGroup = new canvas_BuilderGroup(getTolerance(resolution, pixelRatio), extent, resolution, pixelRatio);
  23109. }
  23110. var userProjection = getUserProjection();
  23111. var userTransform;
  23112. if (userProjection) {
  23113. for (var i = 0, ii = loadExtents.length; i < ii; ++i) {
  23114. var extent_1 = loadExtents[i];
  23115. var userExtent_1 = proj_toUserExtent(extent_1, projection);
  23116. vectorSource.loadFeatures(userExtent_1, toUserResolution(resolution, projection), userProjection);
  23117. }
  23118. userTransform = getTransformFromProjections(userProjection, projection);
  23119. }
  23120. else {
  23121. for (var i = 0, ii = loadExtents.length; i < ii; ++i) {
  23122. vectorSource.loadFeatures(loadExtents[i], resolution, projection);
  23123. }
  23124. }
  23125. var squaredTolerance = getSquaredTolerance(resolution, pixelRatio);
  23126. var ready = true;
  23127. var render =
  23128. /**
  23129. * @param {import("../../Feature.js").default} feature Feature.
  23130. * @this {CanvasVectorLayerRenderer}
  23131. */
  23132. function (feature) {
  23133. var styles;
  23134. var styleFunction = feature.getStyleFunction() || vectorLayer.getStyleFunction();
  23135. if (styleFunction) {
  23136. styles = styleFunction(feature, resolution);
  23137. }
  23138. if (styles) {
  23139. var dirty = this.renderFeature(feature, squaredTolerance, styles, replayGroup, userTransform, declutterBuilderGroup);
  23140. ready = ready && !dirty;
  23141. }
  23142. }.bind(this);
  23143. var userExtent = proj_toUserExtent(extent, projection);
  23144. /** @type {Array<import("../../Feature.js").default>} */
  23145. var features = vectorSource.getFeaturesInExtent(userExtent);
  23146. if (vectorLayerRenderOrder) {
  23147. features.sort(vectorLayerRenderOrder);
  23148. }
  23149. for (var i = 0, ii = features.length; i < ii; ++i) {
  23150. render(features[i]);
  23151. }
  23152. this.renderedFeatures_ = features;
  23153. this.ready = ready;
  23154. var replayGroupInstructions = replayGroup.finish();
  23155. var executorGroup = new canvas_ExecutorGroup(extent, resolution, pixelRatio, vectorSource.getOverlaps(), replayGroupInstructions, vectorLayer.getRenderBuffer());
  23156. if (declutterBuilderGroup) {
  23157. this.declutterExecutorGroup = new canvas_ExecutorGroup(extent, resolution, pixelRatio, vectorSource.getOverlaps(), declutterBuilderGroup.finish(), vectorLayer.getRenderBuffer());
  23158. }
  23159. this.renderedResolution_ = resolution;
  23160. this.renderedRevision_ = vectorLayerRevision;
  23161. this.renderedRenderOrder_ = vectorLayerRenderOrder;
  23162. this.renderedExtent_ = renderedExtent;
  23163. this.wrappedRenderedExtent_ = extent;
  23164. this.renderedCenter_ = center;
  23165. this.renderedProjection_ = projection;
  23166. this.replayGroup_ = executorGroup;
  23167. this.hitDetectionImageData_ = null;
  23168. this.replayGroupChanged = true;
  23169. return true;
  23170. };
  23171. /**
  23172. * @param {import("../../Feature.js").default} feature Feature.
  23173. * @param {number} squaredTolerance Squared render tolerance.
  23174. * @param {import("../../style/Style.js").default|Array<import("../../style/Style.js").default>} styles The style or array of styles.
  23175. * @param {import("../../render/canvas/BuilderGroup.js").default} builderGroup Builder group.
  23176. * @param {import("../../proj.js").TransformFunction} [opt_transform] Transform from user to view projection.
  23177. * @param {import("../../render/canvas/BuilderGroup.js").default} [opt_declutterBuilderGroup] Builder for decluttering.
  23178. * @return {boolean} `true` if an image is loading.
  23179. */
  23180. CanvasVectorLayerRenderer.prototype.renderFeature = function (feature, squaredTolerance, styles, builderGroup, opt_transform, opt_declutterBuilderGroup) {
  23181. if (!styles) {
  23182. return false;
  23183. }
  23184. var loading = false;
  23185. if (Array.isArray(styles)) {
  23186. for (var i = 0, ii = styles.length; i < ii; ++i) {
  23187. loading =
  23188. renderFeature(builderGroup, feature, styles[i], squaredTolerance, this.boundHandleStyleImageChange_, opt_transform, opt_declutterBuilderGroup) || loading;
  23189. }
  23190. }
  23191. else {
  23192. loading = renderFeature(builderGroup, feature, styles, squaredTolerance, this.boundHandleStyleImageChange_, opt_transform, opt_declutterBuilderGroup);
  23193. }
  23194. return loading;
  23195. };
  23196. return CanvasVectorLayerRenderer;
  23197. }(canvas_Layer));
  23198. /* harmony default export */ var canvas_VectorLayer = (CanvasVectorLayerRenderer);
  23199. //# sourceMappingURL=VectorLayer.js.map
  23200. ;// ./node_modules/ol/layer/Vector.js
  23201. var Vector_extends = (undefined && undefined.__extends) || (function () {
  23202. var extendStatics = function (d, b) {
  23203. extendStatics = Object.setPrototypeOf ||
  23204. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23205. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  23206. return extendStatics(d, b);
  23207. };
  23208. return function (d, b) {
  23209. if (typeof b !== "function" && b !== null)
  23210. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  23211. extendStatics(d, b);
  23212. function __() { this.constructor = d; }
  23213. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23214. };
  23215. })();
  23216. /**
  23217. * @module ol/layer/Vector
  23218. */
  23219. /**
  23220. * @classdesc
  23221. * Vector data is rendered client-side, as vectors. This layer type provides most accurate rendering
  23222. * even during animations. Points and labels stay upright on rotated views. For very large
  23223. * amounts of vector data, performance may suffer during pan and zoom animations. In this case,
  23224. * try {@link module:ol/layer/VectorImage~VectorImageLayer}.
  23225. *
  23226. * Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
  23227. * property on the layer object; for example, setting `title: 'My Title'` in the
  23228. * options means that `title` is observable, and has get/set accessors.
  23229. *
  23230. * @template {import("../source/Vector.js").default} VectorSourceType
  23231. * @extends {BaseVectorLayer<VectorSourceType, CanvasVectorLayerRenderer>}
  23232. * @api
  23233. */
  23234. var VectorLayer = /** @class */ (function (_super) {
  23235. Vector_extends(VectorLayer, _super);
  23236. /**
  23237. * @param {import("./BaseVector.js").Options<VectorSourceType>} [opt_options] Options.
  23238. */
  23239. function VectorLayer(opt_options) {
  23240. return _super.call(this, opt_options) || this;
  23241. }
  23242. VectorLayer.prototype.createRenderer = function () {
  23243. return new canvas_VectorLayer(this);
  23244. };
  23245. return VectorLayer;
  23246. }(BaseVector));
  23247. /* harmony default export */ var Vector = (VectorLayer);
  23248. //# sourceMappingURL=Vector.js.map
  23249. ;// ./node_modules/ol/structs/LRUCache.js
  23250. /**
  23251. * @module ol/structs/LRUCache
  23252. */
  23253. /**
  23254. * @typedef {Object} Entry
  23255. * @property {string} key_ Key.
  23256. * @property {Object} newer Newer.
  23257. * @property {Object} older Older.
  23258. * @property {*} value_ Value.
  23259. */
  23260. /**
  23261. * @classdesc
  23262. * Implements a Least-Recently-Used cache where the keys do not conflict with
  23263. * Object's properties (e.g. 'hasOwnProperty' is not allowed as a key). Expiring
  23264. * items from the cache is the responsibility of the user.
  23265. *
  23266. * @fires import("../events/Event.js").default
  23267. * @template T
  23268. */
  23269. var LRUCache = /** @class */ (function () {
  23270. /**
  23271. * @param {number} [opt_highWaterMark] High water mark.
  23272. */
  23273. function LRUCache(opt_highWaterMark) {
  23274. /**
  23275. * Desired max cache size after expireCache(). If set to 0, no cache entries
  23276. * will be pruned at all.
  23277. * @type {number}
  23278. */
  23279. this.highWaterMark =
  23280. opt_highWaterMark !== undefined ? opt_highWaterMark : 2048;
  23281. /**
  23282. * @private
  23283. * @type {number}
  23284. */
  23285. this.count_ = 0;
  23286. /**
  23287. * @private
  23288. * @type {!Object<string, Entry>}
  23289. */
  23290. this.entries_ = {};
  23291. /**
  23292. * @private
  23293. * @type {?Entry}
  23294. */
  23295. this.oldest_ = null;
  23296. /**
  23297. * @private
  23298. * @type {?Entry}
  23299. */
  23300. this.newest_ = null;
  23301. }
  23302. /**
  23303. * @return {boolean} Can expire cache.
  23304. */
  23305. LRUCache.prototype.canExpireCache = function () {
  23306. return this.highWaterMark > 0 && this.getCount() > this.highWaterMark;
  23307. };
  23308. /**
  23309. * Expire the cache.
  23310. * @param {!Object<string, boolean>} [keep] Keys to keep. To be implemented by subclasses.
  23311. */
  23312. LRUCache.prototype.expireCache = function (keep) {
  23313. while (this.canExpireCache()) {
  23314. this.pop();
  23315. }
  23316. };
  23317. /**
  23318. * FIXME empty description for jsdoc
  23319. */
  23320. LRUCache.prototype.clear = function () {
  23321. this.count_ = 0;
  23322. this.entries_ = {};
  23323. this.oldest_ = null;
  23324. this.newest_ = null;
  23325. };
  23326. /**
  23327. * @param {string} key Key.
  23328. * @return {boolean} Contains key.
  23329. */
  23330. LRUCache.prototype.containsKey = function (key) {
  23331. return this.entries_.hasOwnProperty(key);
  23332. };
  23333. /**
  23334. * @param {function(T, string, LRUCache<T>): ?} f The function
  23335. * to call for every entry from the oldest to the newer. This function takes
  23336. * 3 arguments (the entry value, the entry key and the LRUCache object).
  23337. * The return value is ignored.
  23338. */
  23339. LRUCache.prototype.forEach = function (f) {
  23340. var entry = this.oldest_;
  23341. while (entry) {
  23342. f(entry.value_, entry.key_, this);
  23343. entry = entry.newer;
  23344. }
  23345. };
  23346. /**
  23347. * @param {string} key Key.
  23348. * @param {*} [opt_options] Options (reserved for subclasses).
  23349. * @return {T} Value.
  23350. */
  23351. LRUCache.prototype.get = function (key, opt_options) {
  23352. var entry = this.entries_[key];
  23353. asserts_assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache
  23354. if (entry === this.newest_) {
  23355. return entry.value_;
  23356. }
  23357. else if (entry === this.oldest_) {
  23358. this.oldest_ = /** @type {Entry} */ (this.oldest_.newer);
  23359. this.oldest_.older = null;
  23360. }
  23361. else {
  23362. entry.newer.older = entry.older;
  23363. entry.older.newer = entry.newer;
  23364. }
  23365. entry.newer = null;
  23366. entry.older = this.newest_;
  23367. this.newest_.newer = entry;
  23368. this.newest_ = entry;
  23369. return entry.value_;
  23370. };
  23371. /**
  23372. * Remove an entry from the cache.
  23373. * @param {string} key The entry key.
  23374. * @return {T} The removed entry.
  23375. */
  23376. LRUCache.prototype.remove = function (key) {
  23377. var entry = this.entries_[key];
  23378. asserts_assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache
  23379. if (entry === this.newest_) {
  23380. this.newest_ = /** @type {Entry} */ (entry.older);
  23381. if (this.newest_) {
  23382. this.newest_.newer = null;
  23383. }
  23384. }
  23385. else if (entry === this.oldest_) {
  23386. this.oldest_ = /** @type {Entry} */ (entry.newer);
  23387. if (this.oldest_) {
  23388. this.oldest_.older = null;
  23389. }
  23390. }
  23391. else {
  23392. entry.newer.older = entry.older;
  23393. entry.older.newer = entry.newer;
  23394. }
  23395. delete this.entries_[key];
  23396. --this.count_;
  23397. return entry.value_;
  23398. };
  23399. /**
  23400. * @return {number} Count.
  23401. */
  23402. LRUCache.prototype.getCount = function () {
  23403. return this.count_;
  23404. };
  23405. /**
  23406. * @return {Array<string>} Keys.
  23407. */
  23408. LRUCache.prototype.getKeys = function () {
  23409. var keys = new Array(this.count_);
  23410. var i = 0;
  23411. var entry;
  23412. for (entry = this.newest_; entry; entry = entry.older) {
  23413. keys[i++] = entry.key_;
  23414. }
  23415. return keys;
  23416. };
  23417. /**
  23418. * @return {Array<T>} Values.
  23419. */
  23420. LRUCache.prototype.getValues = function () {
  23421. var values = new Array(this.count_);
  23422. var i = 0;
  23423. var entry;
  23424. for (entry = this.newest_; entry; entry = entry.older) {
  23425. values[i++] = entry.value_;
  23426. }
  23427. return values;
  23428. };
  23429. /**
  23430. * @return {T} Last value.
  23431. */
  23432. LRUCache.prototype.peekLast = function () {
  23433. return this.oldest_.value_;
  23434. };
  23435. /**
  23436. * @return {string} Last key.
  23437. */
  23438. LRUCache.prototype.peekLastKey = function () {
  23439. return this.oldest_.key_;
  23440. };
  23441. /**
  23442. * Get the key of the newest item in the cache. Throws if the cache is empty.
  23443. * @return {string} The newest key.
  23444. */
  23445. LRUCache.prototype.peekFirstKey = function () {
  23446. return this.newest_.key_;
  23447. };
  23448. /**
  23449. * Return an entry without updating least recently used time.
  23450. * @param {string} key Key.
  23451. * @return {T} Value.
  23452. */
  23453. LRUCache.prototype.peek = function (key) {
  23454. if (!this.containsKey(key)) {
  23455. return undefined;
  23456. }
  23457. return this.entries_[key].value_;
  23458. };
  23459. /**
  23460. * @return {T} value Value.
  23461. */
  23462. LRUCache.prototype.pop = function () {
  23463. var entry = this.oldest_;
  23464. delete this.entries_[entry.key_];
  23465. if (entry.newer) {
  23466. entry.newer.older = null;
  23467. }
  23468. this.oldest_ = /** @type {Entry} */ (entry.newer);
  23469. if (!this.oldest_) {
  23470. this.newest_ = null;
  23471. }
  23472. --this.count_;
  23473. return entry.value_;
  23474. };
  23475. /**
  23476. * @param {string} key Key.
  23477. * @param {T} value Value.
  23478. */
  23479. LRUCache.prototype.replace = function (key, value) {
  23480. this.get(key); // update `newest_`
  23481. this.entries_[key].value_ = value;
  23482. };
  23483. /**
  23484. * @param {string} key Key.
  23485. * @param {T} value Value.
  23486. */
  23487. LRUCache.prototype.set = function (key, value) {
  23488. asserts_assert(!(key in this.entries_), 16); // Tried to set a value for a key that is used already
  23489. var entry = {
  23490. key_: key,
  23491. newer: null,
  23492. older: this.newest_,
  23493. value_: value,
  23494. };
  23495. if (!this.newest_) {
  23496. this.oldest_ = entry;
  23497. }
  23498. else {
  23499. this.newest_.newer = entry;
  23500. }
  23501. this.newest_ = entry;
  23502. this.entries_[key] = entry;
  23503. ++this.count_;
  23504. };
  23505. /**
  23506. * Set a maximum number of entries for the cache.
  23507. * @param {number} size Cache size.
  23508. * @api
  23509. */
  23510. LRUCache.prototype.setSize = function (size) {
  23511. this.highWaterMark = size;
  23512. };
  23513. return LRUCache;
  23514. }());
  23515. /* harmony default export */ var structs_LRUCache = (LRUCache);
  23516. //# sourceMappingURL=LRUCache.js.map
  23517. ;// ./node_modules/ol/tilecoord.js
  23518. /**
  23519. * @module ol/tilecoord
  23520. */
  23521. /**
  23522. * An array of three numbers representing the location of a tile in a tile
  23523. * grid. The order is `z` (zoom level), `x` (column), and `y` (row).
  23524. * @typedef {Array<number>} TileCoord
  23525. * @api
  23526. */
  23527. /**
  23528. * @param {number} z Z.
  23529. * @param {number} x X.
  23530. * @param {number} y Y.
  23531. * @param {TileCoord} [opt_tileCoord] Tile coordinate.
  23532. * @return {TileCoord} Tile coordinate.
  23533. */
  23534. function tilecoord_createOrUpdate(z, x, y, opt_tileCoord) {
  23535. if (opt_tileCoord !== undefined) {
  23536. opt_tileCoord[0] = z;
  23537. opt_tileCoord[1] = x;
  23538. opt_tileCoord[2] = y;
  23539. return opt_tileCoord;
  23540. }
  23541. else {
  23542. return [z, x, y];
  23543. }
  23544. }
  23545. /**
  23546. * @param {number} z Z.
  23547. * @param {number} x X.
  23548. * @param {number} y Y.
  23549. * @return {string} Key.
  23550. */
  23551. function getKeyZXY(z, x, y) {
  23552. return z + '/' + x + '/' + y;
  23553. }
  23554. /**
  23555. * Get the key for a tile coord.
  23556. * @param {TileCoord} tileCoord The tile coord.
  23557. * @return {string} Key.
  23558. */
  23559. function tilecoord_getKey(tileCoord) {
  23560. return getKeyZXY(tileCoord[0], tileCoord[1], tileCoord[2]);
  23561. }
  23562. /**
  23563. * Get the tile cache key for a tile key obtained through `tile.getKey()`.
  23564. * @param {string} tileKey The tile key.
  23565. * @return {string} The cache key.
  23566. */
  23567. function getCacheKeyForTileKey(tileKey) {
  23568. var _a = tileKey
  23569. .substring(tileKey.lastIndexOf('/') + 1, tileKey.length)
  23570. .split(',')
  23571. .map(Number), z = _a[0], x = _a[1], y = _a[2];
  23572. return getKeyZXY(z, x, y);
  23573. }
  23574. /**
  23575. * Get a tile coord given a key.
  23576. * @param {string} key The tile coord key.
  23577. * @return {TileCoord} The tile coord.
  23578. */
  23579. function fromKey(key) {
  23580. return key.split('/').map(Number);
  23581. }
  23582. /**
  23583. * @param {TileCoord} tileCoord Tile coord.
  23584. * @return {number} Hash.
  23585. */
  23586. function hash(tileCoord) {
  23587. return (tileCoord[1] << tileCoord[0]) + tileCoord[2];
  23588. }
  23589. /**
  23590. * @param {TileCoord} tileCoord Tile coordinate.
  23591. * @param {!import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
  23592. * @return {boolean} Tile coordinate is within extent and zoom level range.
  23593. */
  23594. function withinExtentAndZ(tileCoord, tileGrid) {
  23595. var z = tileCoord[0];
  23596. var x = tileCoord[1];
  23597. var y = tileCoord[2];
  23598. if (tileGrid.getMinZoom() > z || z > tileGrid.getMaxZoom()) {
  23599. return false;
  23600. }
  23601. var tileRange = tileGrid.getFullTileRange(z);
  23602. if (!tileRange) {
  23603. return true;
  23604. }
  23605. else {
  23606. return tileRange.containsXY(x, y);
  23607. }
  23608. }
  23609. //# sourceMappingURL=tilecoord.js.map
  23610. ;// ./node_modules/ol/TileCache.js
  23611. var TileCache_extends = (undefined && undefined.__extends) || (function () {
  23612. var extendStatics = function (d, b) {
  23613. extendStatics = Object.setPrototypeOf ||
  23614. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23615. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  23616. return extendStatics(d, b);
  23617. };
  23618. return function (d, b) {
  23619. if (typeof b !== "function" && b !== null)
  23620. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  23621. extendStatics(d, b);
  23622. function __() { this.constructor = d; }
  23623. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23624. };
  23625. })();
  23626. /**
  23627. * @module ol/TileCache
  23628. */
  23629. var TileCache = /** @class */ (function (_super) {
  23630. TileCache_extends(TileCache, _super);
  23631. function TileCache() {
  23632. return _super !== null && _super.apply(this, arguments) || this;
  23633. }
  23634. /**
  23635. * @param {!Object<string, boolean>} usedTiles Used tiles.
  23636. */
  23637. TileCache.prototype.expireCache = function (usedTiles) {
  23638. while (this.canExpireCache()) {
  23639. var tile = this.peekLast();
  23640. if (tile.getKey() in usedTiles) {
  23641. break;
  23642. }
  23643. else {
  23644. this.pop().release();
  23645. }
  23646. }
  23647. };
  23648. /**
  23649. * Prune all tiles from the cache that don't have the same z as the newest tile.
  23650. */
  23651. TileCache.prototype.pruneExceptNewestZ = function () {
  23652. if (this.getCount() === 0) {
  23653. return;
  23654. }
  23655. var key = this.peekFirstKey();
  23656. var tileCoord = fromKey(key);
  23657. var z = tileCoord[0];
  23658. this.forEach(function (tile) {
  23659. if (tile.tileCoord[0] !== z) {
  23660. this.remove(tilecoord_getKey(tile.tileCoord));
  23661. tile.release();
  23662. }
  23663. }.bind(this));
  23664. };
  23665. return TileCache;
  23666. }(structs_LRUCache));
  23667. /* harmony default export */ var ol_TileCache = (TileCache);
  23668. //# sourceMappingURL=TileCache.js.map
  23669. ;// ./node_modules/ol/source/TileEventType.js
  23670. /**
  23671. * @module ol/source/TileEventType
  23672. */
  23673. /**
  23674. * @enum {string}
  23675. */
  23676. /* harmony default export */ var TileEventType = ({
  23677. /**
  23678. * Triggered when a tile starts loading.
  23679. * @event module:ol/source/Tile.TileSourceEvent#tileloadstart
  23680. * @api
  23681. */
  23682. TILELOADSTART: 'tileloadstart',
  23683. /**
  23684. * Triggered when a tile finishes loading, either when its data is loaded,
  23685. * or when loading was aborted because the tile is no longer needed.
  23686. * @event module:ol/source/Tile.TileSourceEvent#tileloadend
  23687. * @api
  23688. */
  23689. TILELOADEND: 'tileloadend',
  23690. /**
  23691. * Triggered if tile loading results in an error.
  23692. * @event module:ol/source/Tile.TileSourceEvent#tileloaderror
  23693. * @api
  23694. */
  23695. TILELOADERROR: 'tileloaderror',
  23696. });
  23697. /**
  23698. * @typedef {'tileloadstart'|'tileloadend'|'tileloaderror'} TileSourceEventTypes
  23699. */
  23700. //# sourceMappingURL=TileEventType.js.map
  23701. ;// ./node_modules/ol/source/Source.js
  23702. var Source_extends = (undefined && undefined.__extends) || (function () {
  23703. var extendStatics = function (d, b) {
  23704. extendStatics = Object.setPrototypeOf ||
  23705. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23706. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  23707. return extendStatics(d, b);
  23708. };
  23709. return function (d, b) {
  23710. if (typeof b !== "function" && b !== null)
  23711. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  23712. extendStatics(d, b);
  23713. function __() { this.constructor = d; }
  23714. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23715. };
  23716. })();
  23717. /**
  23718. * @module ol/source/Source
  23719. */
  23720. /**
  23721. * @typedef {'undefined' | 'loading' | 'ready' | 'error'} State
  23722. * State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
  23723. */
  23724. /**
  23725. * A function that takes a {@link module:ol/PluggableMap~FrameState} and returns a string or
  23726. * an array of strings representing source attributions.
  23727. *
  23728. * @typedef {function(import("../PluggableMap.js").FrameState): (string|Array<string>)} Attribution
  23729. */
  23730. /**
  23731. * A type that can be used to provide attribution information for data sources.
  23732. *
  23733. * It represents either
  23734. * * a simple string (e.g. `'© Acme Inc.'`)
  23735. * * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)
  23736. * * a function that returns a string or array of strings ({@link module:ol/source/Source~Attribution})
  23737. *
  23738. * @typedef {string|Array<string>|Attribution} AttributionLike
  23739. */
  23740. /**
  23741. * @typedef {Object} Options
  23742. * @property {AttributionLike} [attributions] Attributions.
  23743. * @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
  23744. * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
  23745. * @property {import("./Source.js").State} [state='ready'] State.
  23746. * @property {boolean} [wrapX=false] WrapX.
  23747. * @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
  23748. * the nearest neighbor is used when resampling.
  23749. */
  23750. /**
  23751. * @classdesc
  23752. * Abstract base class; normally only used for creating subclasses and not
  23753. * instantiated in apps.
  23754. * Base class for {@link module:ol/layer/Layer~Layer} sources.
  23755. *
  23756. * A generic `change` event is triggered when the state of the source changes.
  23757. * @abstract
  23758. * @api
  23759. */
  23760. var Source = /** @class */ (function (_super) {
  23761. Source_extends(Source, _super);
  23762. /**
  23763. * @param {Options} options Source options.
  23764. */
  23765. function Source(options) {
  23766. var _this = _super.call(this) || this;
  23767. /**
  23768. * @protected
  23769. * @type {import("../proj/Projection.js").default|null}
  23770. */
  23771. _this.projection = proj_get(options.projection);
  23772. /**
  23773. * @private
  23774. * @type {?Attribution}
  23775. */
  23776. _this.attributions_ = adaptAttributions(options.attributions);
  23777. /**
  23778. * @private
  23779. * @type {boolean}
  23780. */
  23781. _this.attributionsCollapsible_ =
  23782. options.attributionsCollapsible !== undefined
  23783. ? options.attributionsCollapsible
  23784. : true;
  23785. /**
  23786. * This source is currently loading data. Sources that defer loading to the
  23787. * map's tile queue never set this to `true`.
  23788. * @type {boolean}
  23789. */
  23790. _this.loading = false;
  23791. /**
  23792. * @private
  23793. * @type {import("./Source.js").State}
  23794. */
  23795. _this.state_ = options.state !== undefined ? options.state : 'ready';
  23796. /**
  23797. * @private
  23798. * @type {boolean}
  23799. */
  23800. _this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
  23801. /**
  23802. * @private
  23803. * @type {boolean}
  23804. */
  23805. _this.interpolate_ = !!options.interpolate;
  23806. /**
  23807. * @protected
  23808. * @type {function(import("../View.js").ViewOptions):void}
  23809. */
  23810. _this.viewResolver = null;
  23811. /**
  23812. * @protected
  23813. * @type {function(Error):void}
  23814. */
  23815. _this.viewRejector = null;
  23816. var self = _this;
  23817. /**
  23818. * @private
  23819. * @type {Promise<import("../View.js").ViewOptions>}
  23820. */
  23821. _this.viewPromise_ = new Promise(function (resolve, reject) {
  23822. self.viewResolver = resolve;
  23823. self.viewRejector = reject;
  23824. });
  23825. return _this;
  23826. }
  23827. /**
  23828. * Get the attribution function for the source.
  23829. * @return {?Attribution} Attribution function.
  23830. * @api
  23831. */
  23832. Source.prototype.getAttributions = function () {
  23833. return this.attributions_;
  23834. };
  23835. /**
  23836. * @return {boolean} Attributions are collapsible.
  23837. * @api
  23838. */
  23839. Source.prototype.getAttributionsCollapsible = function () {
  23840. return this.attributionsCollapsible_;
  23841. };
  23842. /**
  23843. * Get the projection of the source.
  23844. * @return {import("../proj/Projection.js").default|null} Projection.
  23845. * @api
  23846. */
  23847. Source.prototype.getProjection = function () {
  23848. return this.projection;
  23849. };
  23850. /**
  23851. * @abstract
  23852. * @return {Array<number>|null} Resolutions.
  23853. */
  23854. Source.prototype.getResolutions = function () {
  23855. return util_abstract();
  23856. };
  23857. /**
  23858. * @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
  23859. */
  23860. Source.prototype.getView = function () {
  23861. return this.viewPromise_;
  23862. };
  23863. /**
  23864. * Get the state of the source, see {@link import("./Source.js").State} for possible states.
  23865. * @return {import("./Source.js").State} State.
  23866. * @api
  23867. */
  23868. Source.prototype.getState = function () {
  23869. return this.state_;
  23870. };
  23871. /**
  23872. * @return {boolean|undefined} Wrap X.
  23873. */
  23874. Source.prototype.getWrapX = function () {
  23875. return this.wrapX_;
  23876. };
  23877. /**
  23878. * @return {boolean} Use linear interpolation when resampling.
  23879. */
  23880. Source.prototype.getInterpolate = function () {
  23881. return this.interpolate_;
  23882. };
  23883. /**
  23884. * Refreshes the source. The source will be cleared, and data from the server will be reloaded.
  23885. * @api
  23886. */
  23887. Source.prototype.refresh = function () {
  23888. this.changed();
  23889. };
  23890. /**
  23891. * Set the attributions of the source.
  23892. * @param {AttributionLike|undefined} attributions Attributions.
  23893. * Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution},
  23894. * or `undefined`.
  23895. * @api
  23896. */
  23897. Source.prototype.setAttributions = function (attributions) {
  23898. this.attributions_ = adaptAttributions(attributions);
  23899. this.changed();
  23900. };
  23901. /**
  23902. * Set the state of the source.
  23903. * @param {import("./Source.js").State} state State.
  23904. */
  23905. Source.prototype.setState = function (state) {
  23906. this.state_ = state;
  23907. this.changed();
  23908. };
  23909. return Source;
  23910. }(ol_Object));
  23911. /**
  23912. * Turns the attributions option into an attributions function.
  23913. * @param {AttributionLike|undefined} attributionLike The attribution option.
  23914. * @return {Attribution|null} An attribution function (or null).
  23915. */
  23916. function adaptAttributions(attributionLike) {
  23917. if (!attributionLike) {
  23918. return null;
  23919. }
  23920. if (Array.isArray(attributionLike)) {
  23921. return function (frameState) {
  23922. return attributionLike;
  23923. };
  23924. }
  23925. if (typeof attributionLike === 'function') {
  23926. return attributionLike;
  23927. }
  23928. return function (frameState) {
  23929. return [attributionLike];
  23930. };
  23931. }
  23932. /* harmony default export */ var source_Source = (Source);
  23933. //# sourceMappingURL=Source.js.map
  23934. ;// ./node_modules/ol/tilegrid/common.js
  23935. /**
  23936. * @module ol/tilegrid/common
  23937. */
  23938. /**
  23939. * Default maximum zoom for default tile grids.
  23940. * @type {number}
  23941. */
  23942. var DEFAULT_MAX_ZOOM = 42;
  23943. /**
  23944. * Default tile size.
  23945. * @type {number}
  23946. */
  23947. var DEFAULT_TILE_SIZE = 256;
  23948. //# sourceMappingURL=common.js.map
  23949. ;// ./node_modules/ol/tilegrid/TileGrid.js
  23950. /**
  23951. * @module ol/tilegrid/TileGrid
  23952. */
  23953. /**
  23954. * @private
  23955. * @type {import("../tilecoord.js").TileCoord}
  23956. */
  23957. var tmpTileCoord = [0, 0, 0];
  23958. /**
  23959. * Number of decimal digits to consider in integer values when rounding.
  23960. * @type {number}
  23961. */
  23962. var DECIMALS = 5;
  23963. /**
  23964. * @typedef {Object} Options
  23965. * @property {import("../extent.js").Extent} [extent] Extent for the tile grid. No tiles outside this
  23966. * extent will be requested by {@link module:ol/source/Tile~TileSource} sources. When no `origin` or
  23967. * `origins` are configured, the `origin` will be set to the top-left corner of the extent.
  23968. * @property {number} [minZoom=0] Minimum zoom.
  23969. * @property {import("../coordinate.js").Coordinate} [origin] The tile grid origin, i.e. where the `x`
  23970. * and `y` axes meet (`[z, 0, 0]`). Tile coordinates increase left to right and downwards. If not
  23971. * specified, `extent` or `origins` must be provided.
  23972. * @property {Array<import("../coordinate.js").Coordinate>} [origins] Tile grid origins, i.e. where
  23973. * the `x` and `y` axes meet (`[z, 0, 0]`), for each zoom level. If given, the array length
  23974. * should match the length of the `resolutions` array, i.e. each resolution can have a different
  23975. * origin. Tile coordinates increase left to right and downwards. If not specified, `extent` or
  23976. * `origin` must be provided.
  23977. * @property {!Array<number>} resolutions Resolutions. The array index of each resolution needs
  23978. * to match the zoom level. This means that even if a `minZoom` is configured, the resolutions
  23979. * array will have a length of `maxZoom + 1`.
  23980. * @property {Array<import("../size.js").Size>} [sizes] Number of tile rows and columns
  23981. * of the grid for each zoom level. If specified the values
  23982. * define each zoom level's extent together with the `origin` or `origins`.
  23983. * A grid `extent` can be configured in addition, and will further limit the extent
  23984. * for which tile requests are made by sources. If the bottom-left corner of
  23985. * an extent is used as `origin` or `origins`, then the `y` value must be
  23986. * negative because OpenLayers tile coordinates use the top left as the origin.
  23987. * @property {number|import("../size.js").Size} [tileSize] Tile size.
  23988. * Default is `[256, 256]`.
  23989. * @property {Array<number|import("../size.js").Size>} [tileSizes] Tile sizes. If given, the array length
  23990. * should match the length of the `resolutions` array, i.e. each resolution can have a different
  23991. * tile size.
  23992. */
  23993. /**
  23994. * @classdesc
  23995. * Base class for setting the grid pattern for sources accessing tiled-image
  23996. * servers.
  23997. * @api
  23998. */
  23999. var TileGrid = /** @class */ (function () {
  24000. /**
  24001. * @param {Options} options Tile grid options.
  24002. */
  24003. function TileGrid(options) {
  24004. /**
  24005. * @protected
  24006. * @type {number}
  24007. */
  24008. this.minZoom = options.minZoom !== undefined ? options.minZoom : 0;
  24009. /**
  24010. * @private
  24011. * @type {!Array<number>}
  24012. */
  24013. this.resolutions_ = options.resolutions;
  24014. asserts_assert(isSorted(this.resolutions_, function (a, b) {
  24015. return b - a;
  24016. }, true), 17); // `resolutions` must be sorted in descending order
  24017. // check if we've got a consistent zoom factor and origin
  24018. var zoomFactor;
  24019. if (!options.origins) {
  24020. for (var i = 0, ii = this.resolutions_.length - 1; i < ii; ++i) {
  24021. if (!zoomFactor) {
  24022. zoomFactor = this.resolutions_[i] / this.resolutions_[i + 1];
  24023. }
  24024. else {
  24025. if (this.resolutions_[i] / this.resolutions_[i + 1] !== zoomFactor) {
  24026. zoomFactor = undefined;
  24027. break;
  24028. }
  24029. }
  24030. }
  24031. }
  24032. /**
  24033. * @private
  24034. * @type {number|undefined}
  24035. */
  24036. this.zoomFactor_ = zoomFactor;
  24037. /**
  24038. * @protected
  24039. * @type {number}
  24040. */
  24041. this.maxZoom = this.resolutions_.length - 1;
  24042. /**
  24043. * @private
  24044. * @type {import("../coordinate.js").Coordinate|null}
  24045. */
  24046. this.origin_ = options.origin !== undefined ? options.origin : null;
  24047. /**
  24048. * @private
  24049. * @type {Array<import("../coordinate.js").Coordinate>}
  24050. */
  24051. this.origins_ = null;
  24052. if (options.origins !== undefined) {
  24053. this.origins_ = options.origins;
  24054. asserts_assert(this.origins_.length == this.resolutions_.length, 20); // Number of `origins` and `resolutions` must be equal
  24055. }
  24056. var extent = options.extent;
  24057. if (extent !== undefined && !this.origin_ && !this.origins_) {
  24058. this.origin_ = getTopLeft(extent);
  24059. }
  24060. asserts_assert((!this.origin_ && this.origins_) || (this.origin_ && !this.origins_), 18); // Either `origin` or `origins` must be configured, never both
  24061. /**
  24062. * @private
  24063. * @type {Array<number|import("../size.js").Size>}
  24064. */
  24065. this.tileSizes_ = null;
  24066. if (options.tileSizes !== undefined) {
  24067. this.tileSizes_ = options.tileSizes;
  24068. asserts_assert(this.tileSizes_.length == this.resolutions_.length, 19); // Number of `tileSizes` and `resolutions` must be equal
  24069. }
  24070. /**
  24071. * @private
  24072. * @type {number|import("../size.js").Size}
  24073. */
  24074. this.tileSize_ =
  24075. options.tileSize !== undefined
  24076. ? options.tileSize
  24077. : !this.tileSizes_
  24078. ? DEFAULT_TILE_SIZE
  24079. : null;
  24080. asserts_assert((!this.tileSize_ && this.tileSizes_) ||
  24081. (this.tileSize_ && !this.tileSizes_), 22); // Either `tileSize` or `tileSizes` must be configured, never both
  24082. /**
  24083. * @private
  24084. * @type {import("../extent.js").Extent}
  24085. */
  24086. this.extent_ = extent !== undefined ? extent : null;
  24087. /**
  24088. * @private
  24089. * @type {Array<import("../TileRange.js").default>}
  24090. */
  24091. this.fullTileRanges_ = null;
  24092. /**
  24093. * @private
  24094. * @type {import("../size.js").Size}
  24095. */
  24096. this.tmpSize_ = [0, 0];
  24097. /**
  24098. * @private
  24099. * @type {import("../extent.js").Extent}
  24100. */
  24101. this.tmpExtent_ = [0, 0, 0, 0];
  24102. if (options.sizes !== undefined) {
  24103. this.fullTileRanges_ = options.sizes.map(function (size, z) {
  24104. var tileRange = new ol_TileRange(Math.min(0, size[0]), Math.max(size[0] - 1, -1), Math.min(0, size[1]), Math.max(size[1] - 1, -1));
  24105. if (extent) {
  24106. var restrictedTileRange = this.getTileRangeForExtentAndZ(extent, z);
  24107. tileRange.minX = Math.max(restrictedTileRange.minX, tileRange.minX);
  24108. tileRange.maxX = Math.min(restrictedTileRange.maxX, tileRange.maxX);
  24109. tileRange.minY = Math.max(restrictedTileRange.minY, tileRange.minY);
  24110. tileRange.maxY = Math.min(restrictedTileRange.maxY, tileRange.maxY);
  24111. }
  24112. return tileRange;
  24113. }, this);
  24114. }
  24115. else if (extent) {
  24116. this.calculateTileRanges_(extent);
  24117. }
  24118. }
  24119. /**
  24120. * Call a function with each tile coordinate for a given extent and zoom level.
  24121. *
  24122. * @param {import("../extent.js").Extent} extent Extent.
  24123. * @param {number} zoom Integer zoom level.
  24124. * @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
  24125. * @api
  24126. */
  24127. TileGrid.prototype.forEachTileCoord = function (extent, zoom, callback) {
  24128. var tileRange = this.getTileRangeForExtentAndZ(extent, zoom);
  24129. for (var i = tileRange.minX, ii = tileRange.maxX; i <= ii; ++i) {
  24130. for (var j = tileRange.minY, jj = tileRange.maxY; j <= jj; ++j) {
  24131. callback([zoom, i, j]);
  24132. }
  24133. }
  24134. };
  24135. /**
  24136. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24137. * @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
  24138. * @param {import("../TileRange.js").default} [opt_tileRange] Temporary import("../TileRange.js").default object.
  24139. * @param {import("../extent.js").Extent} [opt_extent] Temporary import("../extent.js").Extent object.
  24140. * @return {boolean} Callback succeeded.
  24141. */
  24142. TileGrid.prototype.forEachTileCoordParentTileRange = function (tileCoord, callback, opt_tileRange, opt_extent) {
  24143. var tileRange, x, y;
  24144. var tileCoordExtent = null;
  24145. var z = tileCoord[0] - 1;
  24146. if (this.zoomFactor_ === 2) {
  24147. x = tileCoord[1];
  24148. y = tileCoord[2];
  24149. }
  24150. else {
  24151. tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent);
  24152. }
  24153. while (z >= this.minZoom) {
  24154. if (this.zoomFactor_ === 2) {
  24155. x = Math.floor(x / 2);
  24156. y = Math.floor(y / 2);
  24157. tileRange = TileRange_createOrUpdate(x, x, y, y, opt_tileRange);
  24158. }
  24159. else {
  24160. tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
  24161. }
  24162. if (callback(z, tileRange)) {
  24163. return true;
  24164. }
  24165. --z;
  24166. }
  24167. return false;
  24168. };
  24169. /**
  24170. * Get the extent for this tile grid, if it was configured.
  24171. * @return {import("../extent.js").Extent} Extent.
  24172. * @api
  24173. */
  24174. TileGrid.prototype.getExtent = function () {
  24175. return this.extent_;
  24176. };
  24177. /**
  24178. * Get the maximum zoom level for the grid.
  24179. * @return {number} Max zoom.
  24180. * @api
  24181. */
  24182. TileGrid.prototype.getMaxZoom = function () {
  24183. return this.maxZoom;
  24184. };
  24185. /**
  24186. * Get the minimum zoom level for the grid.
  24187. * @return {number} Min zoom.
  24188. * @api
  24189. */
  24190. TileGrid.prototype.getMinZoom = function () {
  24191. return this.minZoom;
  24192. };
  24193. /**
  24194. * Get the origin for the grid at the given zoom level.
  24195. * @param {number} z Integer zoom level.
  24196. * @return {import("../coordinate.js").Coordinate} Origin.
  24197. * @api
  24198. */
  24199. TileGrid.prototype.getOrigin = function (z) {
  24200. if (this.origin_) {
  24201. return this.origin_;
  24202. }
  24203. else {
  24204. return this.origins_[z];
  24205. }
  24206. };
  24207. /**
  24208. * Get the resolution for the given zoom level.
  24209. * @param {number} z Integer zoom level.
  24210. * @return {number} Resolution.
  24211. * @api
  24212. */
  24213. TileGrid.prototype.getResolution = function (z) {
  24214. return this.resolutions_[z];
  24215. };
  24216. /**
  24217. * Get the list of resolutions for the tile grid.
  24218. * @return {Array<number>} Resolutions.
  24219. * @api
  24220. */
  24221. TileGrid.prototype.getResolutions = function () {
  24222. return this.resolutions_;
  24223. };
  24224. /**
  24225. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24226. * @param {import("../TileRange.js").default} [opt_tileRange] Temporary import("../TileRange.js").default object.
  24227. * @param {import("../extent.js").Extent} [opt_extent] Temporary import("../extent.js").Extent object.
  24228. * @return {import("../TileRange.js").default|null} Tile range.
  24229. */
  24230. TileGrid.prototype.getTileCoordChildTileRange = function (tileCoord, opt_tileRange, opt_extent) {
  24231. if (tileCoord[0] < this.maxZoom) {
  24232. if (this.zoomFactor_ === 2) {
  24233. var minX = tileCoord[1] * 2;
  24234. var minY = tileCoord[2] * 2;
  24235. return TileRange_createOrUpdate(minX, minX + 1, minY, minY + 1, opt_tileRange);
  24236. }
  24237. var tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent || this.tmpExtent_);
  24238. return this.getTileRangeForExtentAndZ(tileCoordExtent, tileCoord[0] + 1, opt_tileRange);
  24239. }
  24240. return null;
  24241. };
  24242. /**
  24243. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24244. * @param {number} z Integer zoom level.
  24245. * @param {import("../TileRange.js").default} [opt_tileRange] Temporary import("../TileRange.js").default object.
  24246. * @return {import("../TileRange.js").default|null} Tile range.
  24247. */
  24248. TileGrid.prototype.getTileRangeForTileCoordAndZ = function (tileCoord, z, opt_tileRange) {
  24249. if (z > this.maxZoom || z < this.minZoom) {
  24250. return null;
  24251. }
  24252. var tileCoordZ = tileCoord[0];
  24253. var tileCoordX = tileCoord[1];
  24254. var tileCoordY = tileCoord[2];
  24255. if (z === tileCoordZ) {
  24256. return TileRange_createOrUpdate(tileCoordX, tileCoordY, tileCoordX, tileCoordY, opt_tileRange);
  24257. }
  24258. if (this.zoomFactor_) {
  24259. var factor = Math.pow(this.zoomFactor_, z - tileCoordZ);
  24260. var minX = Math.floor(tileCoordX * factor);
  24261. var minY = Math.floor(tileCoordY * factor);
  24262. if (z < tileCoordZ) {
  24263. return TileRange_createOrUpdate(minX, minX, minY, minY, opt_tileRange);
  24264. }
  24265. var maxX = Math.floor(factor * (tileCoordX + 1)) - 1;
  24266. var maxY = Math.floor(factor * (tileCoordY + 1)) - 1;
  24267. return TileRange_createOrUpdate(minX, maxX, minY, maxY, opt_tileRange);
  24268. }
  24269. var tileCoordExtent = this.getTileCoordExtent(tileCoord, this.tmpExtent_);
  24270. return this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
  24271. };
  24272. /**
  24273. * Get the extent for a tile range.
  24274. * @param {number} z Integer zoom level.
  24275. * @param {import("../TileRange.js").default} tileRange Tile range.
  24276. * @param {import("../extent.js").Extent} [opt_extent] Temporary import("../extent.js").Extent object.
  24277. * @return {import("../extent.js").Extent} Extent.
  24278. */
  24279. TileGrid.prototype.getTileRangeExtent = function (z, tileRange, opt_extent) {
  24280. var origin = this.getOrigin(z);
  24281. var resolution = this.getResolution(z);
  24282. var tileSize = toSize(this.getTileSize(z), this.tmpSize_);
  24283. var minX = origin[0] + tileRange.minX * tileSize[0] * resolution;
  24284. var maxX = origin[0] + (tileRange.maxX + 1) * tileSize[0] * resolution;
  24285. var minY = origin[1] + tileRange.minY * tileSize[1] * resolution;
  24286. var maxY = origin[1] + (tileRange.maxY + 1) * tileSize[1] * resolution;
  24287. return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
  24288. };
  24289. /**
  24290. * Get a tile range for the given extent and integer zoom level.
  24291. * @param {import("../extent.js").Extent} extent Extent.
  24292. * @param {number} z Integer zoom level.
  24293. * @param {import("../TileRange.js").default} [opt_tileRange] Temporary tile range object.
  24294. * @return {import("../TileRange.js").default} Tile range.
  24295. */
  24296. TileGrid.prototype.getTileRangeForExtentAndZ = function (extent, z, opt_tileRange) {
  24297. var tileCoord = tmpTileCoord;
  24298. this.getTileCoordForXYAndZ_(extent[0], extent[3], z, false, tileCoord);
  24299. var minX = tileCoord[1];
  24300. var minY = tileCoord[2];
  24301. this.getTileCoordForXYAndZ_(extent[2], extent[1], z, true, tileCoord);
  24302. return TileRange_createOrUpdate(minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
  24303. };
  24304. /**
  24305. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24306. * @return {import("../coordinate.js").Coordinate} Tile center.
  24307. */
  24308. TileGrid.prototype.getTileCoordCenter = function (tileCoord) {
  24309. var origin = this.getOrigin(tileCoord[0]);
  24310. var resolution = this.getResolution(tileCoord[0]);
  24311. var tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_);
  24312. return [
  24313. origin[0] + (tileCoord[1] + 0.5) * tileSize[0] * resolution,
  24314. origin[1] - (tileCoord[2] + 0.5) * tileSize[1] * resolution,
  24315. ];
  24316. };
  24317. /**
  24318. * Get the extent of a tile coordinate.
  24319. *
  24320. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24321. * @param {import("../extent.js").Extent} [opt_extent] Temporary extent object.
  24322. * @return {import("../extent.js").Extent} Extent.
  24323. * @api
  24324. */
  24325. TileGrid.prototype.getTileCoordExtent = function (tileCoord, opt_extent) {
  24326. var origin = this.getOrigin(tileCoord[0]);
  24327. var resolution = this.getResolution(tileCoord[0]);
  24328. var tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_);
  24329. var minX = origin[0] + tileCoord[1] * tileSize[0] * resolution;
  24330. var minY = origin[1] - (tileCoord[2] + 1) * tileSize[1] * resolution;
  24331. var maxX = minX + tileSize[0] * resolution;
  24332. var maxY = minY + tileSize[1] * resolution;
  24333. return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
  24334. };
  24335. /**
  24336. * Get the tile coordinate for the given map coordinate and resolution. This
  24337. * method considers that coordinates that intersect tile boundaries should be
  24338. * assigned the higher tile coordinate.
  24339. *
  24340. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  24341. * @param {number} resolution Resolution.
  24342. * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
  24343. * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
  24344. * @api
  24345. */
  24346. TileGrid.prototype.getTileCoordForCoordAndResolution = function (coordinate, resolution, opt_tileCoord) {
  24347. return this.getTileCoordForXYAndResolution_(coordinate[0], coordinate[1], resolution, false, opt_tileCoord);
  24348. };
  24349. /**
  24350. * Note that this method should not be called for resolutions that correspond
  24351. * to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
  24352. * @param {number} x X.
  24353. * @param {number} y Y.
  24354. * @param {number} resolution Resolution (for a non-integer zoom level).
  24355. * @param {boolean} reverseIntersectionPolicy Instead of letting edge
  24356. * intersections go to the higher tile coordinate, let edge intersections
  24357. * go to the lower tile coordinate.
  24358. * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
  24359. * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
  24360. * @private
  24361. */
  24362. TileGrid.prototype.getTileCoordForXYAndResolution_ = function (x, y, resolution, reverseIntersectionPolicy, opt_tileCoord) {
  24363. var z = this.getZForResolution(resolution);
  24364. var scale = resolution / this.getResolution(z);
  24365. var origin = this.getOrigin(z);
  24366. var tileSize = toSize(this.getTileSize(z), this.tmpSize_);
  24367. var tileCoordX = (scale * (x - origin[0])) / resolution / tileSize[0];
  24368. var tileCoordY = (scale * (origin[1] - y)) / resolution / tileSize[1];
  24369. if (reverseIntersectionPolicy) {
  24370. tileCoordX = ceil(tileCoordX, DECIMALS) - 1;
  24371. tileCoordY = ceil(tileCoordY, DECIMALS) - 1;
  24372. }
  24373. else {
  24374. tileCoordX = floor(tileCoordX, DECIMALS);
  24375. tileCoordY = floor(tileCoordY, DECIMALS);
  24376. }
  24377. return tilecoord_createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord);
  24378. };
  24379. /**
  24380. * Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
  24381. * they should have separate implementations. This method is for integer zoom
  24382. * levels. The other method should only be called for resolutions corresponding
  24383. * to non-integer zoom levels.
  24384. * @param {number} x Map x coordinate.
  24385. * @param {number} y Map y coordinate.
  24386. * @param {number} z Integer zoom level.
  24387. * @param {boolean} reverseIntersectionPolicy Instead of letting edge
  24388. * intersections go to the higher tile coordinate, let edge intersections
  24389. * go to the lower tile coordinate.
  24390. * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
  24391. * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
  24392. * @private
  24393. */
  24394. TileGrid.prototype.getTileCoordForXYAndZ_ = function (x, y, z, reverseIntersectionPolicy, opt_tileCoord) {
  24395. var origin = this.getOrigin(z);
  24396. var resolution = this.getResolution(z);
  24397. var tileSize = toSize(this.getTileSize(z), this.tmpSize_);
  24398. var tileCoordX = (x - origin[0]) / resolution / tileSize[0];
  24399. var tileCoordY = (origin[1] - y) / resolution / tileSize[1];
  24400. if (reverseIntersectionPolicy) {
  24401. tileCoordX = ceil(tileCoordX, DECIMALS) - 1;
  24402. tileCoordY = ceil(tileCoordY, DECIMALS) - 1;
  24403. }
  24404. else {
  24405. tileCoordX = floor(tileCoordX, DECIMALS);
  24406. tileCoordY = floor(tileCoordY, DECIMALS);
  24407. }
  24408. return tilecoord_createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord);
  24409. };
  24410. /**
  24411. * Get a tile coordinate given a map coordinate and zoom level.
  24412. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  24413. * @param {number} z Zoom level.
  24414. * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
  24415. * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
  24416. * @api
  24417. */
  24418. TileGrid.prototype.getTileCoordForCoordAndZ = function (coordinate, z, opt_tileCoord) {
  24419. return this.getTileCoordForXYAndZ_(coordinate[0], coordinate[1], z, false, opt_tileCoord);
  24420. };
  24421. /**
  24422. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24423. * @return {number} Tile resolution.
  24424. */
  24425. TileGrid.prototype.getTileCoordResolution = function (tileCoord) {
  24426. return this.resolutions_[tileCoord[0]];
  24427. };
  24428. /**
  24429. * Get the tile size for a zoom level. The type of the return value matches the
  24430. * `tileSize` or `tileSizes` that the tile grid was configured with. To always
  24431. * get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
  24432. * @param {number} z Z.
  24433. * @return {number|import("../size.js").Size} Tile size.
  24434. * @api
  24435. */
  24436. TileGrid.prototype.getTileSize = function (z) {
  24437. if (this.tileSize_) {
  24438. return this.tileSize_;
  24439. }
  24440. else {
  24441. return this.tileSizes_[z];
  24442. }
  24443. };
  24444. /**
  24445. * @param {number} z Zoom level.
  24446. * @return {import("../TileRange.js").default} Extent tile range for the specified zoom level.
  24447. */
  24448. TileGrid.prototype.getFullTileRange = function (z) {
  24449. if (!this.fullTileRanges_) {
  24450. return this.extent_
  24451. ? this.getTileRangeForExtentAndZ(this.extent_, z)
  24452. : null;
  24453. }
  24454. else {
  24455. return this.fullTileRanges_[z];
  24456. }
  24457. };
  24458. /**
  24459. * @param {number} resolution Resolution.
  24460. * @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
  24461. * If 0, the nearest resolution will be used.
  24462. * If 1, the nearest higher resolution (lower Z) will be used. If -1, the
  24463. * nearest lower resolution (higher Z) will be used. Default is 0.
  24464. * Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
  24465. *
  24466. * For example to change tile Z at the midpoint of zoom levels
  24467. * ```js
  24468. * function(value, high, low) {
  24469. * return value - low * Math.sqrt(high / low);
  24470. * }
  24471. * ```
  24472. * @return {number} Z.
  24473. * @api
  24474. */
  24475. TileGrid.prototype.getZForResolution = function (resolution, opt_direction) {
  24476. var z = linearFindNearest(this.resolutions_, resolution, opt_direction || 0);
  24477. return math_clamp(z, this.minZoom, this.maxZoom);
  24478. };
  24479. /**
  24480. * The tile with the provided tile coordinate intersects the given viewport.
  24481. * @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
  24482. * @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
  24483. * @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
  24484. */
  24485. TileGrid.prototype.tileCoordIntersectsViewport = function (tileCoord, viewport) {
  24486. return intersectsLinearRing(viewport, 0, viewport.length, 2, this.getTileCoordExtent(tileCoord));
  24487. };
  24488. /**
  24489. * @param {!import("../extent.js").Extent} extent Extent for this tile grid.
  24490. * @private
  24491. */
  24492. TileGrid.prototype.calculateTileRanges_ = function (extent) {
  24493. var length = this.resolutions_.length;
  24494. var fullTileRanges = new Array(length);
  24495. for (var z = this.minZoom; z < length; ++z) {
  24496. fullTileRanges[z] = this.getTileRangeForExtentAndZ(extent, z);
  24497. }
  24498. this.fullTileRanges_ = fullTileRanges;
  24499. };
  24500. return TileGrid;
  24501. }());
  24502. /* harmony default export */ var tilegrid_TileGrid = (TileGrid);
  24503. //# sourceMappingURL=TileGrid.js.map
  24504. ;// ./node_modules/ol/tilegrid.js
  24505. /**
  24506. * @module ol/tilegrid
  24507. */
  24508. /**
  24509. * @param {import("./proj/Projection.js").default} projection Projection.
  24510. * @return {!TileGrid} Default tile grid for the
  24511. * passed projection.
  24512. */
  24513. function getForProjection(projection) {
  24514. var tileGrid = projection.getDefaultTileGrid();
  24515. if (!tileGrid) {
  24516. tileGrid = createForProjection(projection);
  24517. projection.setDefaultTileGrid(tileGrid);
  24518. }
  24519. return tileGrid;
  24520. }
  24521. /**
  24522. * @param {TileGrid} tileGrid Tile grid.
  24523. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24524. * @param {import("./proj/Projection.js").default} projection Projection.
  24525. * @return {import("./tilecoord.js").TileCoord} Tile coordinate.
  24526. */
  24527. function tilegrid_wrapX(tileGrid, tileCoord, projection) {
  24528. var z = tileCoord[0];
  24529. var center = tileGrid.getTileCoordCenter(tileCoord);
  24530. var projectionExtent = extentFromProjection(projection);
  24531. if (!containsCoordinate(projectionExtent, center)) {
  24532. var worldWidth = extent_getWidth(projectionExtent);
  24533. var worldsAway = Math.ceil((projectionExtent[0] - center[0]) / worldWidth);
  24534. center[0] += worldWidth * worldsAway;
  24535. return tileGrid.getTileCoordForCoordAndZ(center, z);
  24536. }
  24537. else {
  24538. return tileCoord;
  24539. }
  24540. }
  24541. /**
  24542. * @param {import("./extent.js").Extent} extent Extent.
  24543. * @param {number} [opt_maxZoom] Maximum zoom level (default is
  24544. * DEFAULT_MAX_ZOOM).
  24545. * @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
  24546. * DEFAULT_TILE_SIZE).
  24547. * @param {import("./extent.js").Corner} [opt_corner] Extent corner (default is `'top-left'`).
  24548. * @return {!TileGrid} TileGrid instance.
  24549. */
  24550. function createForExtent(extent, opt_maxZoom, opt_tileSize, opt_corner) {
  24551. var corner = opt_corner !== undefined ? opt_corner : 'top-left';
  24552. var resolutions = resolutionsFromExtent(extent, opt_maxZoom, opt_tileSize);
  24553. return new tilegrid_TileGrid({
  24554. extent: extent,
  24555. origin: getCorner(extent, corner),
  24556. resolutions: resolutions,
  24557. tileSize: opt_tileSize,
  24558. });
  24559. }
  24560. /**
  24561. * @typedef {Object} XYZOptions
  24562. * @property {import("./extent.js").Extent} [extent] Extent for the tile grid. The origin for an XYZ tile grid is the
  24563. * top-left corner of the extent. If `maxResolution` is not provided the zero level of the grid is defined by the resolution
  24564. * at which one tile fits in the provided extent. If not provided, the extent of the EPSG:3857 projection is used.
  24565. * @property {number} [maxResolution] Resolution at level zero.
  24566. * @property {number} [maxZoom] Maximum zoom. The default is `42`. This determines the number of levels
  24567. * in the grid set. For example, a `maxZoom` of 21 means there are 22 levels in the grid set.
  24568. * @property {number} [minZoom=0] Minimum zoom.
  24569. * @property {number|import("./size.js").Size} [tileSize=[256, 256]] Tile size in pixels.
  24570. */
  24571. /**
  24572. * Creates a tile grid with a standard XYZ tiling scheme.
  24573. * @param {XYZOptions} [opt_options] Tile grid options.
  24574. * @return {!TileGrid} Tile grid instance.
  24575. * @api
  24576. */
  24577. function createXYZ(opt_options) {
  24578. var xyzOptions = opt_options || {};
  24579. var extent = xyzOptions.extent || proj_get('EPSG:3857').getExtent();
  24580. var gridOptions = {
  24581. extent: extent,
  24582. minZoom: xyzOptions.minZoom,
  24583. tileSize: xyzOptions.tileSize,
  24584. resolutions: resolutionsFromExtent(extent, xyzOptions.maxZoom, xyzOptions.tileSize, xyzOptions.maxResolution),
  24585. };
  24586. return new tilegrid_TileGrid(gridOptions);
  24587. }
  24588. /**
  24589. * Create a resolutions array from an extent. A zoom factor of 2 is assumed.
  24590. * @param {import("./extent.js").Extent} extent Extent.
  24591. * @param {number} [opt_maxZoom] Maximum zoom level (default is
  24592. * DEFAULT_MAX_ZOOM).
  24593. * @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
  24594. * DEFAULT_TILE_SIZE).
  24595. * @param {number} [opt_maxResolution] Resolution at level zero.
  24596. * @return {!Array<number>} Resolutions array.
  24597. */
  24598. function resolutionsFromExtent(extent, opt_maxZoom, opt_tileSize, opt_maxResolution) {
  24599. var maxZoom = opt_maxZoom !== undefined ? opt_maxZoom : DEFAULT_MAX_ZOOM;
  24600. var height = getHeight(extent);
  24601. var width = extent_getWidth(extent);
  24602. var tileSize = toSize(opt_tileSize !== undefined ? opt_tileSize : DEFAULT_TILE_SIZE);
  24603. var maxResolution = opt_maxResolution > 0
  24604. ? opt_maxResolution
  24605. : Math.max(width / tileSize[0], height / tileSize[1]);
  24606. var length = maxZoom + 1;
  24607. var resolutions = new Array(length);
  24608. for (var z = 0; z < length; ++z) {
  24609. resolutions[z] = maxResolution / Math.pow(2, z);
  24610. }
  24611. return resolutions;
  24612. }
  24613. /**
  24614. * @param {import("./proj.js").ProjectionLike} projection Projection.
  24615. * @param {number} [opt_maxZoom] Maximum zoom level (default is
  24616. * DEFAULT_MAX_ZOOM).
  24617. * @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
  24618. * DEFAULT_TILE_SIZE).
  24619. * @param {import("./extent.js").Corner} [opt_corner] Extent corner (default is `'top-left'`).
  24620. * @return {!TileGrid} TileGrid instance.
  24621. */
  24622. function createForProjection(projection, opt_maxZoom, opt_tileSize, opt_corner) {
  24623. var extent = extentFromProjection(projection);
  24624. return createForExtent(extent, opt_maxZoom, opt_tileSize, opt_corner);
  24625. }
  24626. /**
  24627. * Generate a tile grid extent from a projection. If the projection has an
  24628. * extent, it is used. If not, a global extent is assumed.
  24629. * @param {import("./proj.js").ProjectionLike} projection Projection.
  24630. * @return {import("./extent.js").Extent} Extent.
  24631. */
  24632. function extentFromProjection(projection) {
  24633. projection = proj_get(projection);
  24634. var extent = projection.getExtent();
  24635. if (!extent) {
  24636. var half = (180 * Units_METERS_PER_UNIT[proj_Units.DEGREES]) / projection.getMetersPerUnit();
  24637. extent = createOrUpdate(-half, -half, half, half);
  24638. }
  24639. return extent;
  24640. }
  24641. //# sourceMappingURL=tilegrid.js.map
  24642. ;// ./node_modules/ol/source/Tile.js
  24643. var source_Tile_extends = (undefined && undefined.__extends) || (function () {
  24644. var extendStatics = function (d, b) {
  24645. extendStatics = Object.setPrototypeOf ||
  24646. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24647. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  24648. return extendStatics(d, b);
  24649. };
  24650. return function (d, b) {
  24651. if (typeof b !== "function" && b !== null)
  24652. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  24653. extendStatics(d, b);
  24654. function __() { this.constructor = d; }
  24655. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24656. };
  24657. })();
  24658. /**
  24659. * @module ol/source/Tile
  24660. */
  24661. /***
  24662. * @template Return
  24663. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  24664. * import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
  24665. * import("../Observable").OnSignature<import("./TileEventType").TileSourceEventTypes, TileSourceEvent, Return> &
  24666. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
  24667. * import("./TileEventType").TileSourceEventTypes, Return>} TileSourceOnSignature
  24668. */
  24669. /**
  24670. * @typedef {Object} Options
  24671. * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
  24672. * @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
  24673. * @property {number} [cacheSize] CacheSize.
  24674. * @property {boolean} [opaque=false] Whether the layer is opaque.
  24675. * @property {number} [tilePixelRatio] TilePixelRatio.
  24676. * @property {import("../proj.js").ProjectionLike} [projection] Projection.
  24677. * @property {import("./Source.js").State} [state] State.
  24678. * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
  24679. * @property {boolean} [wrapX=false] WrapX.
  24680. * @property {number} [transition] Transition.
  24681. * @property {string} [key] Key.
  24682. * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0] ZDirection.
  24683. * @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
  24684. * the nearest neighbor is used when resampling.
  24685. */
  24686. /**
  24687. * @classdesc
  24688. * Abstract base class; normally only used for creating subclasses and not
  24689. * instantiated in apps.
  24690. * Base class for sources providing images divided into a tile grid.
  24691. * @abstract
  24692. * @api
  24693. */
  24694. var TileSource = /** @class */ (function (_super) {
  24695. source_Tile_extends(TileSource, _super);
  24696. /**
  24697. * @param {Options} options SourceTile source options.
  24698. */
  24699. function TileSource(options) {
  24700. var _this = _super.call(this, {
  24701. attributions: options.attributions,
  24702. attributionsCollapsible: options.attributionsCollapsible,
  24703. projection: options.projection,
  24704. state: options.state,
  24705. wrapX: options.wrapX,
  24706. interpolate: options.interpolate,
  24707. }) || this;
  24708. /***
  24709. * @type {TileSourceOnSignature<import("../events").EventsKey>}
  24710. */
  24711. _this.on;
  24712. /***
  24713. * @type {TileSourceOnSignature<import("../events").EventsKey>}
  24714. */
  24715. _this.once;
  24716. /***
  24717. * @type {TileSourceOnSignature<void>}
  24718. */
  24719. _this.un;
  24720. /**
  24721. * @private
  24722. * @type {boolean}
  24723. */
  24724. _this.opaque_ = options.opaque !== undefined ? options.opaque : false;
  24725. /**
  24726. * @private
  24727. * @type {number}
  24728. */
  24729. _this.tilePixelRatio_ =
  24730. options.tilePixelRatio !== undefined ? options.tilePixelRatio : 1;
  24731. /**
  24732. * @type {import("../tilegrid/TileGrid.js").default|null}
  24733. */
  24734. _this.tileGrid = options.tileGrid !== undefined ? options.tileGrid : null;
  24735. var tileSize = [256, 256];
  24736. if (_this.tileGrid) {
  24737. toSize(_this.tileGrid.getTileSize(_this.tileGrid.getMinZoom()), tileSize);
  24738. }
  24739. /**
  24740. * @protected
  24741. * @type {import("../TileCache.js").default}
  24742. */
  24743. _this.tileCache = new ol_TileCache(options.cacheSize || 0);
  24744. /**
  24745. * @protected
  24746. * @type {import("../size.js").Size}
  24747. */
  24748. _this.tmpSize = [0, 0];
  24749. /**
  24750. * @private
  24751. * @type {string}
  24752. */
  24753. _this.key_ = options.key || '';
  24754. /**
  24755. * @protected
  24756. * @type {import("../Tile.js").Options}
  24757. */
  24758. _this.tileOptions = {
  24759. transition: options.transition,
  24760. interpolate: options.interpolate,
  24761. };
  24762. /**
  24763. * zDirection hint, read by the renderer. Indicates which resolution should be used
  24764. * by a renderer if the views resolution does not match any resolution of the tile source.
  24765. * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
  24766. * will be used. If -1, the nearest higher resolution will be used.
  24767. * @type {number|import("../array.js").NearestDirectionFunction}
  24768. */
  24769. _this.zDirection = options.zDirection ? options.zDirection : 0;
  24770. return _this;
  24771. }
  24772. /**
  24773. * @return {boolean} Can expire cache.
  24774. */
  24775. TileSource.prototype.canExpireCache = function () {
  24776. return this.tileCache.canExpireCache();
  24777. };
  24778. /**
  24779. * @param {import("../proj/Projection.js").default} projection Projection.
  24780. * @param {!Object<string, boolean>} usedTiles Used tiles.
  24781. */
  24782. TileSource.prototype.expireCache = function (projection, usedTiles) {
  24783. var tileCache = this.getTileCacheForProjection(projection);
  24784. if (tileCache) {
  24785. tileCache.expireCache(usedTiles);
  24786. }
  24787. };
  24788. /**
  24789. * @param {import("../proj/Projection.js").default} projection Projection.
  24790. * @param {number} z Zoom level.
  24791. * @param {import("../TileRange.js").default} tileRange Tile range.
  24792. * @param {function(import("../Tile.js").default):(boolean|void)} callback Called with each
  24793. * loaded tile. If the callback returns `false`, the tile will not be
  24794. * considered loaded.
  24795. * @return {boolean} The tile range is fully covered with loaded tiles.
  24796. */
  24797. TileSource.prototype.forEachLoadedTile = function (projection, z, tileRange, callback) {
  24798. var tileCache = this.getTileCacheForProjection(projection);
  24799. if (!tileCache) {
  24800. return false;
  24801. }
  24802. var covered = true;
  24803. var tile, tileCoordKey, loaded;
  24804. for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
  24805. for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
  24806. tileCoordKey = getKeyZXY(z, x, y);
  24807. loaded = false;
  24808. if (tileCache.containsKey(tileCoordKey)) {
  24809. tile = /** @type {!import("../Tile.js").default} */ (tileCache.get(tileCoordKey));
  24810. loaded = tile.getState() === TileState.LOADED;
  24811. if (loaded) {
  24812. loaded = callback(tile) !== false;
  24813. }
  24814. }
  24815. if (!loaded) {
  24816. covered = false;
  24817. }
  24818. }
  24819. }
  24820. return covered;
  24821. };
  24822. /**
  24823. * @param {import("../proj/Projection.js").default} projection Projection.
  24824. * @return {number} Gutter.
  24825. */
  24826. TileSource.prototype.getGutterForProjection = function (projection) {
  24827. return 0;
  24828. };
  24829. /**
  24830. * Return the key to be used for all tiles in the source.
  24831. * @return {string} The key for all tiles.
  24832. */
  24833. TileSource.prototype.getKey = function () {
  24834. return this.key_;
  24835. };
  24836. /**
  24837. * Set the value to be used as the key for all tiles in the source.
  24838. * @param {string} key The key for tiles.
  24839. * @protected
  24840. */
  24841. TileSource.prototype.setKey = function (key) {
  24842. if (this.key_ !== key) {
  24843. this.key_ = key;
  24844. this.changed();
  24845. }
  24846. };
  24847. /**
  24848. * @param {import("../proj/Projection.js").default} projection Projection.
  24849. * @return {boolean} Opaque.
  24850. */
  24851. TileSource.prototype.getOpaque = function (projection) {
  24852. return this.opaque_;
  24853. };
  24854. /**
  24855. * @return {Array<number>|null} Resolutions.
  24856. */
  24857. TileSource.prototype.getResolutions = function () {
  24858. if (!this.tileGrid) {
  24859. return null;
  24860. }
  24861. return this.tileGrid.getResolutions();
  24862. };
  24863. /**
  24864. * @abstract
  24865. * @param {number} z Tile coordinate z.
  24866. * @param {number} x Tile coordinate x.
  24867. * @param {number} y Tile coordinate y.
  24868. * @param {number} pixelRatio Pixel ratio.
  24869. * @param {import("../proj/Projection.js").default} projection Projection.
  24870. * @return {!import("../Tile.js").default} Tile.
  24871. */
  24872. TileSource.prototype.getTile = function (z, x, y, pixelRatio, projection) {
  24873. return util_abstract();
  24874. };
  24875. /**
  24876. * Return the tile grid of the tile source.
  24877. * @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
  24878. * @api
  24879. */
  24880. TileSource.prototype.getTileGrid = function () {
  24881. return this.tileGrid;
  24882. };
  24883. /**
  24884. * @param {import("../proj/Projection.js").default} projection Projection.
  24885. * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
  24886. */
  24887. TileSource.prototype.getTileGridForProjection = function (projection) {
  24888. if (!this.tileGrid) {
  24889. return getForProjection(projection);
  24890. }
  24891. else {
  24892. return this.tileGrid;
  24893. }
  24894. };
  24895. /**
  24896. * @param {import("../proj/Projection.js").default} projection Projection.
  24897. * @return {import("../TileCache.js").default} Tile cache.
  24898. * @protected
  24899. */
  24900. TileSource.prototype.getTileCacheForProjection = function (projection) {
  24901. var sourceProjection = this.getProjection();
  24902. asserts_assert(sourceProjection === null || equivalent(sourceProjection, projection), 68 // A VectorTile source can only be rendered if it has a projection compatible with the view projection.
  24903. );
  24904. return this.tileCache;
  24905. };
  24906. /**
  24907. * Get the tile pixel ratio for this source. Subclasses may override this
  24908. * method, which is meant to return a supported pixel ratio that matches the
  24909. * provided `pixelRatio` as close as possible.
  24910. * @param {number} pixelRatio Pixel ratio.
  24911. * @return {number} Tile pixel ratio.
  24912. */
  24913. TileSource.prototype.getTilePixelRatio = function (pixelRatio) {
  24914. return this.tilePixelRatio_;
  24915. };
  24916. /**
  24917. * @param {number} z Z.
  24918. * @param {number} pixelRatio Pixel ratio.
  24919. * @param {import("../proj/Projection.js").default} projection Projection.
  24920. * @return {import("../size.js").Size} Tile size.
  24921. */
  24922. TileSource.prototype.getTilePixelSize = function (z, pixelRatio, projection) {
  24923. var tileGrid = this.getTileGridForProjection(projection);
  24924. var tilePixelRatio = this.getTilePixelRatio(pixelRatio);
  24925. var tileSize = toSize(tileGrid.getTileSize(z), this.tmpSize);
  24926. if (tilePixelRatio == 1) {
  24927. return tileSize;
  24928. }
  24929. else {
  24930. return size_scale(tileSize, tilePixelRatio, this.tmpSize);
  24931. }
  24932. };
  24933. /**
  24934. * Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
  24935. * is outside the resolution and extent range of the tile grid, `null` will be
  24936. * returned.
  24937. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  24938. * @param {import("../proj/Projection.js").default} [opt_projection] Projection.
  24939. * @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
  24940. * null if no tile URL should be created for the passed `tileCoord`.
  24941. */
  24942. TileSource.prototype.getTileCoordForTileUrlFunction = function (tileCoord, opt_projection) {
  24943. var projection = opt_projection !== undefined ? opt_projection : this.getProjection();
  24944. var tileGrid = this.getTileGridForProjection(projection);
  24945. if (this.getWrapX() && projection.isGlobal()) {
  24946. tileCoord = tilegrid_wrapX(tileGrid, tileCoord, projection);
  24947. }
  24948. return withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
  24949. };
  24950. /**
  24951. * Remove all cached tiles from the source. The next render cycle will fetch new tiles.
  24952. * @api
  24953. */
  24954. TileSource.prototype.clear = function () {
  24955. this.tileCache.clear();
  24956. };
  24957. TileSource.prototype.refresh = function () {
  24958. this.clear();
  24959. _super.prototype.refresh.call(this);
  24960. };
  24961. /**
  24962. * Increases the cache size if needed
  24963. * @param {number} tileCount Minimum number of tiles needed.
  24964. * @param {import("../proj/Projection.js").default} projection Projection.
  24965. */
  24966. TileSource.prototype.updateCacheSize = function (tileCount, projection) {
  24967. var tileCache = this.getTileCacheForProjection(projection);
  24968. if (tileCount > tileCache.highWaterMark) {
  24969. tileCache.highWaterMark = tileCount;
  24970. }
  24971. };
  24972. /**
  24973. * Marks a tile coord as being used, without triggering a load.
  24974. * @abstract
  24975. * @param {number} z Tile coordinate z.
  24976. * @param {number} x Tile coordinate x.
  24977. * @param {number} y Tile coordinate y.
  24978. * @param {import("../proj/Projection.js").default} projection Projection.
  24979. */
  24980. TileSource.prototype.useTile = function (z, x, y, projection) { };
  24981. return TileSource;
  24982. }(source_Source));
  24983. /**
  24984. * @classdesc
  24985. * Events emitted by {@link module:ol/source/Tile~TileSource} instances are instances of this
  24986. * type.
  24987. */
  24988. var TileSourceEvent = /** @class */ (function (_super) {
  24989. source_Tile_extends(TileSourceEvent, _super);
  24990. /**
  24991. * @param {string} type Type.
  24992. * @param {import("../Tile.js").default} tile The tile.
  24993. */
  24994. function TileSourceEvent(type, tile) {
  24995. var _this = _super.call(this, type) || this;
  24996. /**
  24997. * The tile related to the event.
  24998. * @type {import("../Tile.js").default}
  24999. * @api
  25000. */
  25001. _this.tile = tile;
  25002. return _this;
  25003. }
  25004. return TileSourceEvent;
  25005. }(Event));
  25006. /* harmony default export */ var source_Tile = (TileSource);
  25007. //# sourceMappingURL=Tile.js.map
  25008. ;// ./node_modules/ol/tileurlfunction.js
  25009. /**
  25010. * @module ol/tileurlfunction
  25011. */
  25012. /**
  25013. * @param {string} template Template.
  25014. * @param {import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
  25015. * @return {import("./Tile.js").UrlFunction} Tile URL function.
  25016. */
  25017. function createFromTemplate(template, tileGrid) {
  25018. var zRegEx = /\{z\}/g;
  25019. var xRegEx = /\{x\}/g;
  25020. var yRegEx = /\{y\}/g;
  25021. var dashYRegEx = /\{-y\}/g;
  25022. return (
  25023. /**
  25024. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
  25025. * @param {number} pixelRatio Pixel ratio.
  25026. * @param {import("./proj/Projection.js").default} projection Projection.
  25027. * @return {string|undefined} Tile URL.
  25028. */
  25029. function (tileCoord, pixelRatio, projection) {
  25030. if (!tileCoord) {
  25031. return undefined;
  25032. }
  25033. else {
  25034. return template
  25035. .replace(zRegEx, tileCoord[0].toString())
  25036. .replace(xRegEx, tileCoord[1].toString())
  25037. .replace(yRegEx, tileCoord[2].toString())
  25038. .replace(dashYRegEx, function () {
  25039. var z = tileCoord[0];
  25040. var range = tileGrid.getFullTileRange(z);
  25041. asserts_assert(range, 55); // The {-y} placeholder requires a tile grid with extent
  25042. var y = range.getHeight() - tileCoord[2] - 1;
  25043. return y.toString();
  25044. });
  25045. }
  25046. });
  25047. }
  25048. /**
  25049. * @param {Array<string>} templates Templates.
  25050. * @param {import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
  25051. * @return {import("./Tile.js").UrlFunction} Tile URL function.
  25052. */
  25053. function createFromTemplates(templates, tileGrid) {
  25054. var len = templates.length;
  25055. var tileUrlFunctions = new Array(len);
  25056. for (var i = 0; i < len; ++i) {
  25057. tileUrlFunctions[i] = createFromTemplate(templates[i], tileGrid);
  25058. }
  25059. return createFromTileUrlFunctions(tileUrlFunctions);
  25060. }
  25061. /**
  25062. * @param {Array<import("./Tile.js").UrlFunction>} tileUrlFunctions Tile URL Functions.
  25063. * @return {import("./Tile.js").UrlFunction} Tile URL function.
  25064. */
  25065. function createFromTileUrlFunctions(tileUrlFunctions) {
  25066. if (tileUrlFunctions.length === 1) {
  25067. return tileUrlFunctions[0];
  25068. }
  25069. return (
  25070. /**
  25071. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
  25072. * @param {number} pixelRatio Pixel ratio.
  25073. * @param {import("./proj/Projection.js").default} projection Projection.
  25074. * @return {string|undefined} Tile URL.
  25075. */
  25076. function (tileCoord, pixelRatio, projection) {
  25077. if (!tileCoord) {
  25078. return undefined;
  25079. }
  25080. else {
  25081. var h = hash(tileCoord);
  25082. var index = math_modulo(h, tileUrlFunctions.length);
  25083. return tileUrlFunctions[index](tileCoord, pixelRatio, projection);
  25084. }
  25085. });
  25086. }
  25087. /**
  25088. * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
  25089. * @param {number} pixelRatio Pixel ratio.
  25090. * @param {import("./proj/Projection.js").default} projection Projection.
  25091. * @return {string|undefined} Tile URL.
  25092. */
  25093. function nullTileUrlFunction(tileCoord, pixelRatio, projection) {
  25094. return undefined;
  25095. }
  25096. /**
  25097. * @param {string} url URL.
  25098. * @return {Array<string>} Array of urls.
  25099. */
  25100. function expandUrl(url) {
  25101. var urls = [];
  25102. var match = /\{([a-z])-([a-z])\}/.exec(url);
  25103. if (match) {
  25104. // char range
  25105. var startCharCode = match[1].charCodeAt(0);
  25106. var stopCharCode = match[2].charCodeAt(0);
  25107. var charCode = void 0;
  25108. for (charCode = startCharCode; charCode <= stopCharCode; ++charCode) {
  25109. urls.push(url.replace(match[0], String.fromCharCode(charCode)));
  25110. }
  25111. return urls;
  25112. }
  25113. match = /\{(\d+)-(\d+)\}/.exec(url);
  25114. if (match) {
  25115. // number range
  25116. var stop_1 = parseInt(match[2], 10);
  25117. for (var i = parseInt(match[1], 10); i <= stop_1; i++) {
  25118. urls.push(url.replace(match[0], i.toString()));
  25119. }
  25120. return urls;
  25121. }
  25122. urls.push(url);
  25123. return urls;
  25124. }
  25125. //# sourceMappingURL=tileurlfunction.js.map
  25126. ;// ./node_modules/ol/source/UrlTile.js
  25127. var UrlTile_extends = (undefined && undefined.__extends) || (function () {
  25128. var extendStatics = function (d, b) {
  25129. extendStatics = Object.setPrototypeOf ||
  25130. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25131. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25132. return extendStatics(d, b);
  25133. };
  25134. return function (d, b) {
  25135. if (typeof b !== "function" && b !== null)
  25136. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  25137. extendStatics(d, b);
  25138. function __() { this.constructor = d; }
  25139. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25140. };
  25141. })();
  25142. /**
  25143. * @module ol/source/UrlTile
  25144. */
  25145. /**
  25146. * @typedef {Object} Options
  25147. * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
  25148. * @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
  25149. * @property {number} [cacheSize] Cache size.
  25150. * @property {boolean} [opaque=false] Whether the layer is opaque.
  25151. * @property {import("../proj.js").ProjectionLike} [projection] Projection.
  25152. * @property {import("./Source.js").State} [state] State.
  25153. * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
  25154. * @property {import("../Tile.js").LoadFunction} tileLoadFunction TileLoadFunction.
  25155. * @property {number} [tilePixelRatio] TilePixelRatio.
  25156. * @property {import("../Tile.js").UrlFunction} [tileUrlFunction] TileUrlFunction.
  25157. * @property {string} [url] Url.
  25158. * @property {Array<string>} [urls] Urls.
  25159. * @property {boolean} [wrapX=true] WrapX.
  25160. * @property {number} [transition] Transition.
  25161. * @property {string} [key] Key.
  25162. * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0] ZDirection.
  25163. * @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
  25164. * the nearest neighbor is used when resampling.
  25165. */
  25166. /**
  25167. * @classdesc
  25168. * Base class for sources providing tiles divided into a tile grid over http.
  25169. *
  25170. * @fires import("./Tile.js").TileSourceEvent
  25171. */
  25172. var UrlTile = /** @class */ (function (_super) {
  25173. UrlTile_extends(UrlTile, _super);
  25174. /**
  25175. * @param {Options} options Image tile options.
  25176. */
  25177. function UrlTile(options) {
  25178. var _this = _super.call(this, {
  25179. attributions: options.attributions,
  25180. cacheSize: options.cacheSize,
  25181. opaque: options.opaque,
  25182. projection: options.projection,
  25183. state: options.state,
  25184. tileGrid: options.tileGrid,
  25185. tilePixelRatio: options.tilePixelRatio,
  25186. wrapX: options.wrapX,
  25187. transition: options.transition,
  25188. interpolate: options.interpolate,
  25189. key: options.key,
  25190. attributionsCollapsible: options.attributionsCollapsible,
  25191. zDirection: options.zDirection,
  25192. }) || this;
  25193. /**
  25194. * @private
  25195. * @type {boolean}
  25196. */
  25197. _this.generateTileUrlFunction_ =
  25198. _this.tileUrlFunction === UrlTile.prototype.tileUrlFunction;
  25199. /**
  25200. * @protected
  25201. * @type {import("../Tile.js").LoadFunction}
  25202. */
  25203. _this.tileLoadFunction = options.tileLoadFunction;
  25204. if (options.tileUrlFunction) {
  25205. _this.tileUrlFunction = options.tileUrlFunction;
  25206. }
  25207. /**
  25208. * @protected
  25209. * @type {!Array<string>|null}
  25210. */
  25211. _this.urls = null;
  25212. if (options.urls) {
  25213. _this.setUrls(options.urls);
  25214. }
  25215. else if (options.url) {
  25216. _this.setUrl(options.url);
  25217. }
  25218. /**
  25219. * @private
  25220. * @type {!Object<string, boolean>}
  25221. */
  25222. _this.tileLoadingKeys_ = {};
  25223. return _this;
  25224. }
  25225. /**
  25226. * Return the tile load function of the source.
  25227. * @return {import("../Tile.js").LoadFunction} TileLoadFunction
  25228. * @api
  25229. */
  25230. UrlTile.prototype.getTileLoadFunction = function () {
  25231. return this.tileLoadFunction;
  25232. };
  25233. /**
  25234. * Return the tile URL function of the source.
  25235. * @return {import("../Tile.js").UrlFunction} TileUrlFunction
  25236. * @api
  25237. */
  25238. UrlTile.prototype.getTileUrlFunction = function () {
  25239. return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction
  25240. ? this.tileUrlFunction.bind(this)
  25241. : this.tileUrlFunction;
  25242. };
  25243. /**
  25244. * Return the URLs used for this source.
  25245. * When a tileUrlFunction is used instead of url or urls,
  25246. * null will be returned.
  25247. * @return {!Array<string>|null} URLs.
  25248. * @api
  25249. */
  25250. UrlTile.prototype.getUrls = function () {
  25251. return this.urls;
  25252. };
  25253. /**
  25254. * Handle tile change events.
  25255. * @param {import("../events/Event.js").default} event Event.
  25256. * @protected
  25257. */
  25258. UrlTile.prototype.handleTileChange = function (event) {
  25259. var tile = /** @type {import("../Tile.js").default} */ (event.target);
  25260. var uid = getUid(tile);
  25261. var tileState = tile.getState();
  25262. var type;
  25263. if (tileState == TileState.LOADING) {
  25264. this.tileLoadingKeys_[uid] = true;
  25265. type = TileEventType.TILELOADSTART;
  25266. }
  25267. else if (uid in this.tileLoadingKeys_) {
  25268. delete this.tileLoadingKeys_[uid];
  25269. type =
  25270. tileState == TileState.ERROR
  25271. ? TileEventType.TILELOADERROR
  25272. : tileState == TileState.LOADED
  25273. ? TileEventType.TILELOADEND
  25274. : undefined;
  25275. }
  25276. if (type != undefined) {
  25277. this.dispatchEvent(new TileSourceEvent(type, tile));
  25278. }
  25279. };
  25280. /**
  25281. * Set the tile load function of the source.
  25282. * @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
  25283. * @api
  25284. */
  25285. UrlTile.prototype.setTileLoadFunction = function (tileLoadFunction) {
  25286. this.tileCache.clear();
  25287. this.tileLoadFunction = tileLoadFunction;
  25288. this.changed();
  25289. };
  25290. /**
  25291. * Set the tile URL function of the source.
  25292. * @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
  25293. * @param {string} [key] Optional new tile key for the source.
  25294. * @api
  25295. */
  25296. UrlTile.prototype.setTileUrlFunction = function (tileUrlFunction, key) {
  25297. this.tileUrlFunction = tileUrlFunction;
  25298. this.tileCache.pruneExceptNewestZ();
  25299. if (typeof key !== 'undefined') {
  25300. this.setKey(key);
  25301. }
  25302. else {
  25303. this.changed();
  25304. }
  25305. };
  25306. /**
  25307. * Set the URL to use for requests.
  25308. * @param {string} url URL.
  25309. * @api
  25310. */
  25311. UrlTile.prototype.setUrl = function (url) {
  25312. var urls = expandUrl(url);
  25313. this.urls = urls;
  25314. this.setUrls(urls);
  25315. };
  25316. /**
  25317. * Set the URLs to use for requests.
  25318. * @param {Array<string>} urls URLs.
  25319. * @api
  25320. */
  25321. UrlTile.prototype.setUrls = function (urls) {
  25322. this.urls = urls;
  25323. var key = urls.join('\n');
  25324. if (this.generateTileUrlFunction_) {
  25325. this.setTileUrlFunction(createFromTemplates(urls, this.tileGrid), key);
  25326. }
  25327. else {
  25328. this.setKey(key);
  25329. }
  25330. };
  25331. /**
  25332. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
  25333. * @param {number} pixelRatio Pixel ratio.
  25334. * @param {import("../proj/Projection.js").default} projection Projection.
  25335. * @return {string|undefined} Tile URL.
  25336. */
  25337. UrlTile.prototype.tileUrlFunction = function (tileCoord, pixelRatio, projection) {
  25338. return undefined;
  25339. };
  25340. /**
  25341. * Marks a tile coord as being used, without triggering a load.
  25342. * @param {number} z Tile coordinate z.
  25343. * @param {number} x Tile coordinate x.
  25344. * @param {number} y Tile coordinate y.
  25345. */
  25346. UrlTile.prototype.useTile = function (z, x, y) {
  25347. var tileCoordKey = getKeyZXY(z, x, y);
  25348. if (this.tileCache.containsKey(tileCoordKey)) {
  25349. this.tileCache.get(tileCoordKey);
  25350. }
  25351. };
  25352. return UrlTile;
  25353. }(source_Tile));
  25354. /* harmony default export */ var source_UrlTile = (UrlTile);
  25355. //# sourceMappingURL=UrlTile.js.map
  25356. ;// ./node_modules/ol/source/TileImage.js
  25357. var TileImage_extends = (undefined && undefined.__extends) || (function () {
  25358. var extendStatics = function (d, b) {
  25359. extendStatics = Object.setPrototypeOf ||
  25360. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25361. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25362. return extendStatics(d, b);
  25363. };
  25364. return function (d, b) {
  25365. if (typeof b !== "function" && b !== null)
  25366. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  25367. extendStatics(d, b);
  25368. function __() { this.constructor = d; }
  25369. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25370. };
  25371. })();
  25372. /**
  25373. * @module ol/source/TileImage
  25374. */
  25375. /**
  25376. * @typedef {Object} Options
  25377. * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
  25378. * @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
  25379. * @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
  25380. * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
  25381. * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
  25382. * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
  25383. * @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
  25384. * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
  25385. * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
  25386. * @property {boolean} [opaque=false] Whether the layer is opaque.
  25387. * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
  25388. * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
  25389. * Higher values can increase reprojection performance, but decrease precision.
  25390. * @property {import("./Source.js").State} [state] Source state.
  25391. * @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
  25392. * Default is {@link module:ol/ImageTile~ImageTile}.
  25393. * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
  25394. * @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
  25395. * ```js
  25396. * function(imageTile, src) {
  25397. * imageTile.getImage().src = src;
  25398. * };
  25399. * ```
  25400. * @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service. For example, if the tile
  25401. * service advertizes 256px by 256px tiles but actually sends 512px
  25402. * by 512px images (for retina/hidpi devices) then `tilePixelRatio`
  25403. * should be set to `2`.
  25404. * @property {import("../Tile.js").UrlFunction} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection.
  25405. * @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
  25406. * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
  25407. * used instead of defining each one separately in the `urls` option.
  25408. * @property {Array<string>} [urls] An array of URL templates.
  25409. * @property {boolean} [wrapX] Whether to wrap the world horizontally. The default, is to
  25410. * request out-of-bounds tiles from the server. When set to `false`, only one
  25411. * world will be rendered. When set to `true`, tiles will be requested for one
  25412. * world only, but they will be wrapped horizontally to render multiple worlds.
  25413. * @property {number} [transition] Duration of the opacity transition for rendering.
  25414. * To disable the opacity transition, pass `transition: 0`.
  25415. * @property {string} [key] Optional tile key for proper cache fetching
  25416. * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
  25417. * Choose whether to use tiles with a higher or lower zoom level when between integer
  25418. * zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
  25419. */
  25420. /**
  25421. * @classdesc
  25422. * Base class for sources providing images divided into a tile grid.
  25423. *
  25424. * @fires import("./Tile.js").TileSourceEvent
  25425. * @api
  25426. */
  25427. var TileImage = /** @class */ (function (_super) {
  25428. TileImage_extends(TileImage, _super);
  25429. /**
  25430. * @param {!Options} options Image tile options.
  25431. */
  25432. function TileImage(options) {
  25433. var _this = this;
  25434. var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
  25435. if (options.interpolate !== undefined) {
  25436. interpolate = options.interpolate;
  25437. }
  25438. _this = _super.call(this, {
  25439. attributions: options.attributions,
  25440. cacheSize: options.cacheSize,
  25441. opaque: options.opaque,
  25442. projection: options.projection,
  25443. state: options.state,
  25444. tileGrid: options.tileGrid,
  25445. tileLoadFunction: options.tileLoadFunction
  25446. ? options.tileLoadFunction
  25447. : defaultTileLoadFunction,
  25448. tilePixelRatio: options.tilePixelRatio,
  25449. tileUrlFunction: options.tileUrlFunction,
  25450. url: options.url,
  25451. urls: options.urls,
  25452. wrapX: options.wrapX,
  25453. transition: options.transition,
  25454. interpolate: interpolate,
  25455. key: options.key,
  25456. attributionsCollapsible: options.attributionsCollapsible,
  25457. zDirection: options.zDirection,
  25458. }) || this;
  25459. /**
  25460. * @protected
  25461. * @type {?string}
  25462. */
  25463. _this.crossOrigin =
  25464. options.crossOrigin !== undefined ? options.crossOrigin : null;
  25465. /**
  25466. * @protected
  25467. * @type {typeof ImageTile}
  25468. */
  25469. _this.tileClass =
  25470. options.tileClass !== undefined ? options.tileClass : ol_ImageTile;
  25471. /**
  25472. * @protected
  25473. * @type {!Object<string, TileCache>}
  25474. */
  25475. _this.tileCacheForProjection = {};
  25476. /**
  25477. * @protected
  25478. * @type {!Object<string, import("../tilegrid/TileGrid.js").default>}
  25479. */
  25480. _this.tileGridForProjection = {};
  25481. /**
  25482. * @private
  25483. * @type {number|undefined}
  25484. */
  25485. _this.reprojectionErrorThreshold_ = options.reprojectionErrorThreshold;
  25486. /**
  25487. * @private
  25488. * @type {boolean}
  25489. */
  25490. _this.renderReprojectionEdges_ = false;
  25491. return _this;
  25492. }
  25493. /**
  25494. * @return {boolean} Can expire cache.
  25495. */
  25496. TileImage.prototype.canExpireCache = function () {
  25497. if (!ENABLE_RASTER_REPROJECTION) {
  25498. return _super.prototype.canExpireCache.call(this);
  25499. }
  25500. if (this.tileCache.canExpireCache()) {
  25501. return true;
  25502. }
  25503. else {
  25504. for (var key in this.tileCacheForProjection) {
  25505. if (this.tileCacheForProjection[key].canExpireCache()) {
  25506. return true;
  25507. }
  25508. }
  25509. }
  25510. return false;
  25511. };
  25512. /**
  25513. * @param {import("../proj/Projection.js").default} projection Projection.
  25514. * @param {!Object<string, boolean>} usedTiles Used tiles.
  25515. */
  25516. TileImage.prototype.expireCache = function (projection, usedTiles) {
  25517. if (!ENABLE_RASTER_REPROJECTION) {
  25518. _super.prototype.expireCache.call(this, projection, usedTiles);
  25519. return;
  25520. }
  25521. var usedTileCache = this.getTileCacheForProjection(projection);
  25522. this.tileCache.expireCache(this.tileCache == usedTileCache ? usedTiles : {});
  25523. for (var id in this.tileCacheForProjection) {
  25524. var tileCache = this.tileCacheForProjection[id];
  25525. tileCache.expireCache(tileCache == usedTileCache ? usedTiles : {});
  25526. }
  25527. };
  25528. /**
  25529. * @param {import("../proj/Projection.js").default} projection Projection.
  25530. * @return {number} Gutter.
  25531. */
  25532. TileImage.prototype.getGutterForProjection = function (projection) {
  25533. if (ENABLE_RASTER_REPROJECTION &&
  25534. this.getProjection() &&
  25535. projection &&
  25536. !equivalent(this.getProjection(), projection)) {
  25537. return 0;
  25538. }
  25539. else {
  25540. return this.getGutter();
  25541. }
  25542. };
  25543. /**
  25544. * @return {number} Gutter.
  25545. */
  25546. TileImage.prototype.getGutter = function () {
  25547. return 0;
  25548. };
  25549. /**
  25550. * Return the key to be used for all tiles in the source.
  25551. * @return {string} The key for all tiles.
  25552. */
  25553. TileImage.prototype.getKey = function () {
  25554. var key = _super.prototype.getKey.call(this);
  25555. if (!this.getInterpolate()) {
  25556. key += ':disable-interpolation';
  25557. }
  25558. return key;
  25559. };
  25560. /**
  25561. * @param {import("../proj/Projection.js").default} projection Projection.
  25562. * @return {boolean} Opaque.
  25563. */
  25564. TileImage.prototype.getOpaque = function (projection) {
  25565. if (ENABLE_RASTER_REPROJECTION &&
  25566. this.getProjection() &&
  25567. projection &&
  25568. !equivalent(this.getProjection(), projection)) {
  25569. return false;
  25570. }
  25571. else {
  25572. return _super.prototype.getOpaque.call(this, projection);
  25573. }
  25574. };
  25575. /**
  25576. * @param {import("../proj/Projection.js").default} projection Projection.
  25577. * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
  25578. */
  25579. TileImage.prototype.getTileGridForProjection = function (projection) {
  25580. if (!ENABLE_RASTER_REPROJECTION) {
  25581. return _super.prototype.getTileGridForProjection.call(this, projection);
  25582. }
  25583. var thisProj = this.getProjection();
  25584. if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
  25585. return this.tileGrid;
  25586. }
  25587. else {
  25588. var projKey = getUid(projection);
  25589. if (!(projKey in this.tileGridForProjection)) {
  25590. this.tileGridForProjection[projKey] =
  25591. getForProjection(projection);
  25592. }
  25593. return this.tileGridForProjection[projKey];
  25594. }
  25595. };
  25596. /**
  25597. * @param {import("../proj/Projection.js").default} projection Projection.
  25598. * @return {import("../TileCache.js").default} Tile cache.
  25599. */
  25600. TileImage.prototype.getTileCacheForProjection = function (projection) {
  25601. if (!ENABLE_RASTER_REPROJECTION) {
  25602. return _super.prototype.getTileCacheForProjection.call(this, projection);
  25603. }
  25604. var thisProj = this.getProjection();
  25605. if (!thisProj || equivalent(thisProj, projection)) {
  25606. return this.tileCache;
  25607. }
  25608. else {
  25609. var projKey = getUid(projection);
  25610. if (!(projKey in this.tileCacheForProjection)) {
  25611. this.tileCacheForProjection[projKey] = new ol_TileCache(this.tileCache.highWaterMark);
  25612. }
  25613. return this.tileCacheForProjection[projKey];
  25614. }
  25615. };
  25616. /**
  25617. * @param {number} z Tile coordinate z.
  25618. * @param {number} x Tile coordinate x.
  25619. * @param {number} y Tile coordinate y.
  25620. * @param {number} pixelRatio Pixel ratio.
  25621. * @param {import("../proj/Projection.js").default} projection Projection.
  25622. * @param {string} key The key set on the tile.
  25623. * @return {!ImageTile} Tile.
  25624. * @private
  25625. */
  25626. TileImage.prototype.createTile_ = function (z, x, y, pixelRatio, projection, key) {
  25627. var tileCoord = [z, x, y];
  25628. var urlTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection);
  25629. var tileUrl = urlTileCoord
  25630. ? this.tileUrlFunction(urlTileCoord, pixelRatio, projection)
  25631. : undefined;
  25632. var tile = new this.tileClass(tileCoord, tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY, tileUrl !== undefined ? tileUrl : '', this.crossOrigin, this.tileLoadFunction, this.tileOptions);
  25633. tile.key = key;
  25634. tile.addEventListener(EventType.CHANGE, this.handleTileChange.bind(this));
  25635. return tile;
  25636. };
  25637. /**
  25638. * @param {number} z Tile coordinate z.
  25639. * @param {number} x Tile coordinate x.
  25640. * @param {number} y Tile coordinate y.
  25641. * @param {number} pixelRatio Pixel ratio.
  25642. * @param {import("../proj/Projection.js").default} projection Projection.
  25643. * @return {!(ImageTile|ReprojTile)} Tile.
  25644. */
  25645. TileImage.prototype.getTile = function (z, x, y, pixelRatio, projection) {
  25646. var sourceProjection = this.getProjection();
  25647. if (!ENABLE_RASTER_REPROJECTION ||
  25648. !sourceProjection ||
  25649. !projection ||
  25650. equivalent(sourceProjection, projection)) {
  25651. return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection);
  25652. }
  25653. else {
  25654. var cache = this.getTileCacheForProjection(projection);
  25655. var tileCoord = [z, x, y];
  25656. var tile = void 0;
  25657. var tileCoordKey = tilecoord_getKey(tileCoord);
  25658. if (cache.containsKey(tileCoordKey)) {
  25659. tile = cache.get(tileCoordKey);
  25660. }
  25661. var key = this.getKey();
  25662. if (tile && tile.key == key) {
  25663. return tile;
  25664. }
  25665. else {
  25666. var sourceTileGrid = this.getTileGridForProjection(sourceProjection);
  25667. var targetTileGrid = this.getTileGridForProjection(projection);
  25668. var wrappedTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection);
  25669. var newTile = new reproj_Tile(sourceProjection, sourceTileGrid, projection, targetTileGrid, tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio), this.getGutter(), function (z, x, y, pixelRatio) {
  25670. return this.getTileInternal(z, x, y, pixelRatio, sourceProjection);
  25671. }.bind(this), this.reprojectionErrorThreshold_, this.renderReprojectionEdges_, this.getInterpolate());
  25672. newTile.key = key;
  25673. if (tile) {
  25674. newTile.interimTile = tile;
  25675. newTile.refreshInterimChain();
  25676. cache.replace(tileCoordKey, newTile);
  25677. }
  25678. else {
  25679. cache.set(tileCoordKey, newTile);
  25680. }
  25681. return newTile;
  25682. }
  25683. }
  25684. };
  25685. /**
  25686. * @param {number} z Tile coordinate z.
  25687. * @param {number} x Tile coordinate x.
  25688. * @param {number} y Tile coordinate y.
  25689. * @param {number} pixelRatio Pixel ratio.
  25690. * @param {!import("../proj/Projection.js").default} projection Projection.
  25691. * @return {!(ImageTile|ReprojTile)} Tile.
  25692. * @protected
  25693. */
  25694. TileImage.prototype.getTileInternal = function (z, x, y, pixelRatio, projection) {
  25695. var tile = null;
  25696. var tileCoordKey = getKeyZXY(z, x, y);
  25697. var key = this.getKey();
  25698. if (!this.tileCache.containsKey(tileCoordKey)) {
  25699. tile = this.createTile_(z, x, y, pixelRatio, projection, key);
  25700. this.tileCache.set(tileCoordKey, tile);
  25701. }
  25702. else {
  25703. tile = this.tileCache.get(tileCoordKey);
  25704. if (tile.key != key) {
  25705. // The source's params changed. If the tile has an interim tile and if we
  25706. // can use it then we use it. Otherwise we create a new tile. In both
  25707. // cases we attempt to assign an interim tile to the new tile.
  25708. var interimTile = tile;
  25709. tile = this.createTile_(z, x, y, pixelRatio, projection, key);
  25710. //make the new tile the head of the list,
  25711. if (interimTile.getState() == TileState.IDLE) {
  25712. //the old tile hasn't begun loading yet, and is now outdated, so we can simply discard it
  25713. tile.interimTile = interimTile.interimTile;
  25714. }
  25715. else {
  25716. tile.interimTile = interimTile;
  25717. }
  25718. tile.refreshInterimChain();
  25719. this.tileCache.replace(tileCoordKey, tile);
  25720. }
  25721. }
  25722. return tile;
  25723. };
  25724. /**
  25725. * Sets whether to render reprojection edges or not (usually for debugging).
  25726. * @param {boolean} render Render the edges.
  25727. * @api
  25728. */
  25729. TileImage.prototype.setRenderReprojectionEdges = function (render) {
  25730. if (!ENABLE_RASTER_REPROJECTION ||
  25731. this.renderReprojectionEdges_ == render) {
  25732. return;
  25733. }
  25734. this.renderReprojectionEdges_ = render;
  25735. for (var id in this.tileCacheForProjection) {
  25736. this.tileCacheForProjection[id].clear();
  25737. }
  25738. this.changed();
  25739. };
  25740. /**
  25741. * Sets the tile grid to use when reprojecting the tiles to the given
  25742. * projection instead of the default tile grid for the projection.
  25743. *
  25744. * This can be useful when the default tile grid cannot be created
  25745. * (e.g. projection has no extent defined) or
  25746. * for optimization reasons (custom tile size, resolutions, ...).
  25747. *
  25748. * @param {import("../proj.js").ProjectionLike} projection Projection.
  25749. * @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
  25750. * @api
  25751. */
  25752. TileImage.prototype.setTileGridForProjection = function (projection, tilegrid) {
  25753. if (ENABLE_RASTER_REPROJECTION) {
  25754. var proj = proj_get(projection);
  25755. if (proj) {
  25756. var projKey = getUid(proj);
  25757. if (!(projKey in this.tileGridForProjection)) {
  25758. this.tileGridForProjection[projKey] = tilegrid;
  25759. }
  25760. }
  25761. }
  25762. };
  25763. return TileImage;
  25764. }(source_UrlTile));
  25765. /**
  25766. * @param {ImageTile} imageTile Image tile.
  25767. * @param {string} src Source.
  25768. */
  25769. function defaultTileLoadFunction(imageTile, src) {
  25770. /** @type {HTMLImageElement|HTMLVideoElement} */ (imageTile.getImage()).src =
  25771. src;
  25772. }
  25773. /* harmony default export */ var source_TileImage = (TileImage);
  25774. //# sourceMappingURL=TileImage.js.map
  25775. ;// ./node_modules/ol/source/XYZ.js
  25776. /**
  25777. * @module ol/source/XYZ
  25778. */
  25779. var XYZ_extends = (undefined && undefined.__extends) || (function () {
  25780. var extendStatics = function (d, b) {
  25781. extendStatics = Object.setPrototypeOf ||
  25782. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25783. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25784. return extendStatics(d, b);
  25785. };
  25786. return function (d, b) {
  25787. if (typeof b !== "function" && b !== null)
  25788. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  25789. extendStatics(d, b);
  25790. function __() { this.constructor = d; }
  25791. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25792. };
  25793. })();
  25794. /**
  25795. * @typedef {Object} Options
  25796. * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
  25797. * @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
  25798. * @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
  25799. * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
  25800. * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
  25801. * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
  25802. * @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
  25803. * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
  25804. * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
  25805. * @property {boolean} [opaque=false] Whether the layer is opaque.
  25806. * @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection.
  25807. * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
  25808. * Higher values can increase reprojection performance, but decrease precision.
  25809. * @property {number} [maxZoom=42] Optional max zoom level. Not used if `tileGrid` is provided.
  25810. * @property {number} [minZoom=0] Optional min zoom level. Not used if `tileGrid` is provided.
  25811. * @property {number} [maxResolution] Optional tile grid resolution at level zero. Not used if `tileGrid` is provided.
  25812. * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
  25813. * @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
  25814. * ```js
  25815. * function(imageTile, src) {
  25816. * imageTile.getImage().src = src;
  25817. * };
  25818. * ```
  25819. * @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service.
  25820. * For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px
  25821. * by 512px images (for retina/hidpi devices) then `tilePixelRatio`
  25822. * should be set to `2`.
  25823. * @property {number|import("../size.js").Size} [tileSize=[256, 256]] The tile size used by the tile service.
  25824. * Not used if `tileGrid` is provided.
  25825. * @property {number} [gutter=0] The size in pixels of the gutter around image tiles to ignore.
  25826. * This allows artifacts of rendering at tile edges to be ignored.
  25827. * Supported images should be wider and taller than the tile size by a value of `2 x gutter`.
  25828. * @property {import("../Tile.js").UrlFunction} [tileUrlFunction] Optional function to get
  25829. * tile URL given a tile coordinate and the projection.
  25830. * Required if `url` or `urls` are not provided.
  25831. * @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`,
  25832. * and `{z}` placeholders. A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`,
  25833. * may be used instead of defining each one separately in the `urls` option.
  25834. * @property {Array<string>} [urls] An array of URL templates.
  25835. * @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
  25836. * @property {number} [transition=250] Duration of the opacity transition for rendering.
  25837. * To disable the opacity transition, pass `transition: 0`.
  25838. * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
  25839. * Choose whether to use tiles with a higher or lower zoom level when between integer
  25840. * zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
  25841. */
  25842. /**
  25843. * @classdesc
  25844. * Layer source for tile data with URLs in a set XYZ format that are
  25845. * defined in a URL template. By default, this follows the widely-used
  25846. * Google grid where `x` 0 and `y` 0 are in the top left. Grids like
  25847. * TMS where `x` 0 and `y` 0 are in the bottom left can be used by
  25848. * using the `{-y}` placeholder in the URL template, so long as the
  25849. * source does not have a custom tile grid. In this case
  25850. * a `tileUrlFunction` can be used, such as:
  25851. * ```js
  25852. * tileUrlFunction: function(coordinate) {
  25853. * return 'http://mapserver.com/' + coordinate[0] + '/' +
  25854. * coordinate[1] + '/' + (-coordinate[2] - 1) + '.png';
  25855. * }
  25856. * ```
  25857. * @api
  25858. */
  25859. var XYZ = /** @class */ (function (_super) {
  25860. XYZ_extends(XYZ, _super);
  25861. /**
  25862. * @param {Options} [opt_options] XYZ options.
  25863. */
  25864. function XYZ(opt_options) {
  25865. var _this = this;
  25866. var options = opt_options || {};
  25867. var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
  25868. if (options.interpolate !== undefined) {
  25869. interpolate = options.interpolate;
  25870. }
  25871. var projection = options.projection !== undefined ? options.projection : 'EPSG:3857';
  25872. var tileGrid = options.tileGrid !== undefined
  25873. ? options.tileGrid
  25874. : createXYZ({
  25875. extent: extentFromProjection(projection),
  25876. maxResolution: options.maxResolution,
  25877. maxZoom: options.maxZoom,
  25878. minZoom: options.minZoom,
  25879. tileSize: options.tileSize,
  25880. });
  25881. _this = _super.call(this, {
  25882. attributions: options.attributions,
  25883. cacheSize: options.cacheSize,
  25884. crossOrigin: options.crossOrigin,
  25885. interpolate: interpolate,
  25886. opaque: options.opaque,
  25887. projection: projection,
  25888. reprojectionErrorThreshold: options.reprojectionErrorThreshold,
  25889. tileGrid: tileGrid,
  25890. tileLoadFunction: options.tileLoadFunction,
  25891. tilePixelRatio: options.tilePixelRatio,
  25892. tileUrlFunction: options.tileUrlFunction,
  25893. url: options.url,
  25894. urls: options.urls,
  25895. wrapX: options.wrapX !== undefined ? options.wrapX : true,
  25896. transition: options.transition,
  25897. attributionsCollapsible: options.attributionsCollapsible,
  25898. zDirection: options.zDirection,
  25899. }) || this;
  25900. /**
  25901. * @private
  25902. * @type {number}
  25903. */
  25904. _this.gutter_ = options.gutter !== undefined ? options.gutter : 0;
  25905. return _this;
  25906. }
  25907. /**
  25908. * @return {number} Gutter.
  25909. */
  25910. XYZ.prototype.getGutter = function () {
  25911. return this.gutter_;
  25912. };
  25913. return XYZ;
  25914. }(source_TileImage));
  25915. /* harmony default export */ var source_XYZ = (XYZ);
  25916. //# sourceMappingURL=XYZ.js.map
  25917. ;// ./node_modules/ol/source/OSM.js
  25918. /**
  25919. * @module ol/source/OSM
  25920. */
  25921. var OSM_extends = (undefined && undefined.__extends) || (function () {
  25922. var extendStatics = function (d, b) {
  25923. extendStatics = Object.setPrototypeOf ||
  25924. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25925. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25926. return extendStatics(d, b);
  25927. };
  25928. return function (d, b) {
  25929. if (typeof b !== "function" && b !== null)
  25930. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  25931. extendStatics(d, b);
  25932. function __() { this.constructor = d; }
  25933. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25934. };
  25935. })();
  25936. /**
  25937. * The attribution containing a link to the OpenStreetMap Copyright and License
  25938. * page.
  25939. * @const
  25940. * @type {string}
  25941. * @api
  25942. */
  25943. var ATTRIBUTION = '&#169; ' +
  25944. '<a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> ' +
  25945. 'contributors.';
  25946. /**
  25947. * @typedef {Object} Options
  25948. * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
  25949. * @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
  25950. * @property {null|string} [crossOrigin='anonymous'] The `crossOrigin` attribute for loaded images. Note that
  25951. * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
  25952. * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
  25953. * @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
  25954. * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
  25955. * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
  25956. * @property {number} [maxZoom=19] Max zoom.
  25957. * @property {boolean} [opaque=true] Whether the layer is opaque.
  25958. * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
  25959. * Higher values can increase reprojection performance, but decrease precision.
  25960. * @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
  25961. * ```js
  25962. * function(imageTile, src) {
  25963. * imageTile.getImage().src = src;
  25964. * };
  25965. * ```
  25966. * @property {number} [transition=250] Duration of the opacity transition for rendering.
  25967. * To disable the opacity transition, pass `transition: 0`.
  25968. * @property {string} [url='https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'] URL template.
  25969. * Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
  25970. * @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
  25971. * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
  25972. * Choose whether to use tiles with a higher or lower zoom level when between integer
  25973. * zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
  25974. */
  25975. /**
  25976. * @classdesc
  25977. * Layer source for the OpenStreetMap tile server.
  25978. * @api
  25979. */
  25980. var OSM = /** @class */ (function (_super) {
  25981. OSM_extends(OSM, _super);
  25982. /**
  25983. * @param {Options} [opt_options] Open Street Map options.
  25984. */
  25985. function OSM(opt_options) {
  25986. var options = opt_options || {};
  25987. var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
  25988. if (options.interpolate !== undefined) {
  25989. interpolate = options.interpolate;
  25990. }
  25991. var attributions;
  25992. if (options.attributions !== undefined) {
  25993. attributions = options.attributions;
  25994. }
  25995. else {
  25996. attributions = [ATTRIBUTION];
  25997. }
  25998. var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : 'anonymous';
  25999. var url = options.url !== undefined
  26000. ? options.url
  26001. : 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
  26002. return _super.call(this, {
  26003. attributions: attributions,
  26004. attributionsCollapsible: false,
  26005. cacheSize: options.cacheSize,
  26006. crossOrigin: crossOrigin,
  26007. interpolate: interpolate,
  26008. maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,
  26009. opaque: options.opaque !== undefined ? options.opaque : true,
  26010. reprojectionErrorThreshold: options.reprojectionErrorThreshold,
  26011. tileLoadFunction: options.tileLoadFunction,
  26012. transition: options.transition,
  26013. url: url,
  26014. wrapX: options.wrapX,
  26015. zDirection: options.zDirection,
  26016. }) || this;
  26017. }
  26018. return OSM;
  26019. }(source_XYZ));
  26020. /* harmony default export */ var source_OSM = (OSM);
  26021. //# sourceMappingURL=OSM.js.map
  26022. ;// ./node_modules/ol/CollectionEventType.js
  26023. /**
  26024. * @module ol/CollectionEventType
  26025. */
  26026. /**
  26027. * @enum {string}
  26028. */
  26029. /* harmony default export */ var CollectionEventType = ({
  26030. /**
  26031. * Triggered when an item is added to the collection.
  26032. * @event module:ol/Collection.CollectionEvent#add
  26033. * @api
  26034. */
  26035. ADD: 'add',
  26036. /**
  26037. * Triggered when an item is removed from the collection.
  26038. * @event module:ol/Collection.CollectionEvent#remove
  26039. * @api
  26040. */
  26041. REMOVE: 'remove',
  26042. });
  26043. //# sourceMappingURL=CollectionEventType.js.map
  26044. ;// ./node_modules/ol/Collection.js
  26045. var Collection_extends = (undefined && undefined.__extends) || (function () {
  26046. var extendStatics = function (d, b) {
  26047. extendStatics = Object.setPrototypeOf ||
  26048. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26049. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26050. return extendStatics(d, b);
  26051. };
  26052. return function (d, b) {
  26053. if (typeof b !== "function" && b !== null)
  26054. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26055. extendStatics(d, b);
  26056. function __() { this.constructor = d; }
  26057. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26058. };
  26059. })();
  26060. /**
  26061. * @module ol/Collection
  26062. */
  26063. /**
  26064. * @enum {string}
  26065. * @private
  26066. */
  26067. var Collection_Property = {
  26068. LENGTH: 'length',
  26069. };
  26070. /**
  26071. * @classdesc
  26072. * Events emitted by {@link module:ol/Collection~Collection} instances are instances of this
  26073. * type.
  26074. */
  26075. var CollectionEvent = /** @class */ (function (_super) {
  26076. Collection_extends(CollectionEvent, _super);
  26077. /**
  26078. * @param {import("./CollectionEventType.js").default} type Type.
  26079. * @param {*} [opt_element] Element.
  26080. * @param {number} [opt_index] The index of the added or removed element.
  26081. */
  26082. function CollectionEvent(type, opt_element, opt_index) {
  26083. var _this = _super.call(this, type) || this;
  26084. /**
  26085. * The element that is added to or removed from the collection.
  26086. * @type {*}
  26087. * @api
  26088. */
  26089. _this.element = opt_element;
  26090. /**
  26091. * The index of the added or removed element.
  26092. * @type {number}
  26093. * @api
  26094. */
  26095. _this.index = opt_index;
  26096. return _this;
  26097. }
  26098. return CollectionEvent;
  26099. }(Event));
  26100. /***
  26101. * @template Return
  26102. * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
  26103. * import("./Observable").OnSignature<import("./ObjectEventType").Types|'change:length', import("./Object").ObjectEvent, Return> &
  26104. * import("./Observable").OnSignature<'add'|'remove', CollectionEvent, Return> &
  26105. * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|import("./ObjectEventType").Types|
  26106. * 'change:length'|'add'|'remove',Return>} CollectionOnSignature
  26107. */
  26108. /**
  26109. * @typedef {Object} Options
  26110. * @property {boolean} [unique=false] Disallow the same item from being added to
  26111. * the collection twice.
  26112. */
  26113. /**
  26114. * @classdesc
  26115. * An expanded version of standard JS Array, adding convenience methods for
  26116. * manipulation. Add and remove changes to the Collection trigger a Collection
  26117. * event. Note that this does not cover changes to the objects _within_ the
  26118. * Collection; they trigger events on the appropriate object, not on the
  26119. * Collection as a whole.
  26120. *
  26121. * @fires CollectionEvent
  26122. *
  26123. * @template T
  26124. * @api
  26125. */
  26126. var Collection = /** @class */ (function (_super) {
  26127. Collection_extends(Collection, _super);
  26128. /**
  26129. * @param {Array<T>} [opt_array] Array.
  26130. * @param {Options} [opt_options] Collection options.
  26131. */
  26132. function Collection(opt_array, opt_options) {
  26133. var _this = _super.call(this) || this;
  26134. /***
  26135. * @type {CollectionOnSignature<import("./events").EventsKey>}
  26136. */
  26137. _this.on;
  26138. /***
  26139. * @type {CollectionOnSignature<import("./events").EventsKey>}
  26140. */
  26141. _this.once;
  26142. /***
  26143. * @type {CollectionOnSignature<void>}
  26144. */
  26145. _this.un;
  26146. var options = opt_options || {};
  26147. /**
  26148. * @private
  26149. * @type {boolean}
  26150. */
  26151. _this.unique_ = !!options.unique;
  26152. /**
  26153. * @private
  26154. * @type {!Array<T>}
  26155. */
  26156. _this.array_ = opt_array ? opt_array : [];
  26157. if (_this.unique_) {
  26158. for (var i = 0, ii = _this.array_.length; i < ii; ++i) {
  26159. _this.assertUnique_(_this.array_[i], i);
  26160. }
  26161. }
  26162. _this.updateLength_();
  26163. return _this;
  26164. }
  26165. /**
  26166. * Remove all elements from the collection.
  26167. * @api
  26168. */
  26169. Collection.prototype.clear = function () {
  26170. while (this.getLength() > 0) {
  26171. this.pop();
  26172. }
  26173. };
  26174. /**
  26175. * Add elements to the collection. This pushes each item in the provided array
  26176. * to the end of the collection.
  26177. * @param {!Array<T>} arr Array.
  26178. * @return {Collection<T>} This collection.
  26179. * @api
  26180. */
  26181. Collection.prototype.extend = function (arr) {
  26182. for (var i = 0, ii = arr.length; i < ii; ++i) {
  26183. this.push(arr[i]);
  26184. }
  26185. return this;
  26186. };
  26187. /**
  26188. * Iterate over each element, calling the provided callback.
  26189. * @param {function(T, number, Array<T>): *} f The function to call
  26190. * for every element. This function takes 3 arguments (the element, the
  26191. * index and the array). The return value is ignored.
  26192. * @api
  26193. */
  26194. Collection.prototype.forEach = function (f) {
  26195. var array = this.array_;
  26196. for (var i = 0, ii = array.length; i < ii; ++i) {
  26197. f(array[i], i, array);
  26198. }
  26199. };
  26200. /**
  26201. * Get a reference to the underlying Array object. Warning: if the array
  26202. * is mutated, no events will be dispatched by the collection, and the
  26203. * collection's "length" property won't be in sync with the actual length
  26204. * of the array.
  26205. * @return {!Array<T>} Array.
  26206. * @api
  26207. */
  26208. Collection.prototype.getArray = function () {
  26209. return this.array_;
  26210. };
  26211. /**
  26212. * Get the element at the provided index.
  26213. * @param {number} index Index.
  26214. * @return {T} Element.
  26215. * @api
  26216. */
  26217. Collection.prototype.item = function (index) {
  26218. return this.array_[index];
  26219. };
  26220. /**
  26221. * Get the length of this collection.
  26222. * @return {number} The length of the array.
  26223. * @observable
  26224. * @api
  26225. */
  26226. Collection.prototype.getLength = function () {
  26227. return this.get(Collection_Property.LENGTH);
  26228. };
  26229. /**
  26230. * Insert an element at the provided index.
  26231. * @param {number} index Index.
  26232. * @param {T} elem Element.
  26233. * @api
  26234. */
  26235. Collection.prototype.insertAt = function (index, elem) {
  26236. if (this.unique_) {
  26237. this.assertUnique_(elem);
  26238. }
  26239. this.array_.splice(index, 0, elem);
  26240. this.updateLength_();
  26241. this.dispatchEvent(new CollectionEvent(CollectionEventType.ADD, elem, index));
  26242. };
  26243. /**
  26244. * Remove the last element of the collection and return it.
  26245. * Return `undefined` if the collection is empty.
  26246. * @return {T|undefined} Element.
  26247. * @api
  26248. */
  26249. Collection.prototype.pop = function () {
  26250. return this.removeAt(this.getLength() - 1);
  26251. };
  26252. /**
  26253. * Insert the provided element at the end of the collection.
  26254. * @param {T} elem Element.
  26255. * @return {number} New length of the collection.
  26256. * @api
  26257. */
  26258. Collection.prototype.push = function (elem) {
  26259. if (this.unique_) {
  26260. this.assertUnique_(elem);
  26261. }
  26262. var n = this.getLength();
  26263. this.insertAt(n, elem);
  26264. return this.getLength();
  26265. };
  26266. /**
  26267. * Remove the first occurrence of an element from the collection.
  26268. * @param {T} elem Element.
  26269. * @return {T|undefined} The removed element or undefined if none found.
  26270. * @api
  26271. */
  26272. Collection.prototype.remove = function (elem) {
  26273. var arr = this.array_;
  26274. for (var i = 0, ii = arr.length; i < ii; ++i) {
  26275. if (arr[i] === elem) {
  26276. return this.removeAt(i);
  26277. }
  26278. }
  26279. return undefined;
  26280. };
  26281. /**
  26282. * Remove the element at the provided index and return it.
  26283. * Return `undefined` if the collection does not contain this index.
  26284. * @param {number} index Index.
  26285. * @return {T|undefined} Value.
  26286. * @api
  26287. */
  26288. Collection.prototype.removeAt = function (index) {
  26289. var prev = this.array_[index];
  26290. this.array_.splice(index, 1);
  26291. this.updateLength_();
  26292. this.dispatchEvent(new CollectionEvent(CollectionEventType.REMOVE, prev, index));
  26293. return prev;
  26294. };
  26295. /**
  26296. * Set the element at the provided index.
  26297. * @param {number} index Index.
  26298. * @param {T} elem Element.
  26299. * @api
  26300. */
  26301. Collection.prototype.setAt = function (index, elem) {
  26302. var n = this.getLength();
  26303. if (index < n) {
  26304. if (this.unique_) {
  26305. this.assertUnique_(elem, index);
  26306. }
  26307. var prev = this.array_[index];
  26308. this.array_[index] = elem;
  26309. this.dispatchEvent(new CollectionEvent(CollectionEventType.REMOVE, prev, index));
  26310. this.dispatchEvent(new CollectionEvent(CollectionEventType.ADD, elem, index));
  26311. }
  26312. else {
  26313. for (var j = n; j < index; ++j) {
  26314. this.insertAt(j, undefined);
  26315. }
  26316. this.insertAt(index, elem);
  26317. }
  26318. };
  26319. /**
  26320. * @private
  26321. */
  26322. Collection.prototype.updateLength_ = function () {
  26323. this.set(Collection_Property.LENGTH, this.array_.length);
  26324. };
  26325. /**
  26326. * @private
  26327. * @param {T} elem Element.
  26328. * @param {number} [opt_except] Optional index to ignore.
  26329. */
  26330. Collection.prototype.assertUnique_ = function (elem, opt_except) {
  26331. for (var i = 0, ii = this.array_.length; i < ii; ++i) {
  26332. if (this.array_[i] === elem && i !== opt_except) {
  26333. throw new ol_AssertionError(58);
  26334. }
  26335. }
  26336. };
  26337. return Collection;
  26338. }(ol_Object));
  26339. /* harmony default export */ var ol_Collection = (Collection);
  26340. //# sourceMappingURL=Collection.js.map
  26341. ;// ./node_modules/ol/structs/RBush.js
  26342. /**
  26343. * @module ol/structs/RBush
  26344. */
  26345. /**
  26346. * @typedef {Object} Entry
  26347. * @property {number} minX MinX.
  26348. * @property {number} minY MinY.
  26349. * @property {number} maxX MaxX.
  26350. * @property {number} maxY MaxY.
  26351. * @property {Object} [value] Value.
  26352. */
  26353. /**
  26354. * @classdesc
  26355. * Wrapper around the RBush by Vladimir Agafonkin.
  26356. * See https://github.com/mourner/rbush.
  26357. *
  26358. * @template T
  26359. */
  26360. var RBush = /** @class */ (function () {
  26361. /**
  26362. * @param {number} [opt_maxEntries] Max entries.
  26363. */
  26364. function RBush(opt_maxEntries) {
  26365. /**
  26366. * @private
  26367. */
  26368. this.rbush_ = new rbush_min(opt_maxEntries);
  26369. /**
  26370. * A mapping between the objects added to this rbush wrapper
  26371. * and the objects that are actually added to the internal rbush.
  26372. * @private
  26373. * @type {Object<string, Entry>}
  26374. */
  26375. this.items_ = {};
  26376. }
  26377. /**
  26378. * Insert a value into the RBush.
  26379. * @param {import("../extent.js").Extent} extent Extent.
  26380. * @param {T} value Value.
  26381. */
  26382. RBush.prototype.insert = function (extent, value) {
  26383. /** @type {Entry} */
  26384. var item = {
  26385. minX: extent[0],
  26386. minY: extent[1],
  26387. maxX: extent[2],
  26388. maxY: extent[3],
  26389. value: value,
  26390. };
  26391. this.rbush_.insert(item);
  26392. this.items_[getUid(value)] = item;
  26393. };
  26394. /**
  26395. * Bulk-insert values into the RBush.
  26396. * @param {Array<import("../extent.js").Extent>} extents Extents.
  26397. * @param {Array<T>} values Values.
  26398. */
  26399. RBush.prototype.load = function (extents, values) {
  26400. var items = new Array(values.length);
  26401. for (var i = 0, l = values.length; i < l; i++) {
  26402. var extent = extents[i];
  26403. var value = values[i];
  26404. /** @type {Entry} */
  26405. var item = {
  26406. minX: extent[0],
  26407. minY: extent[1],
  26408. maxX: extent[2],
  26409. maxY: extent[3],
  26410. value: value,
  26411. };
  26412. items[i] = item;
  26413. this.items_[getUid(value)] = item;
  26414. }
  26415. this.rbush_.load(items);
  26416. };
  26417. /**
  26418. * Remove a value from the RBush.
  26419. * @param {T} value Value.
  26420. * @return {boolean} Removed.
  26421. */
  26422. RBush.prototype.remove = function (value) {
  26423. var uid = getUid(value);
  26424. // get the object in which the value was wrapped when adding to the
  26425. // internal rbush. then use that object to do the removal.
  26426. var item = this.items_[uid];
  26427. delete this.items_[uid];
  26428. return this.rbush_.remove(item) !== null;
  26429. };
  26430. /**
  26431. * Update the extent of a value in the RBush.
  26432. * @param {import("../extent.js").Extent} extent Extent.
  26433. * @param {T} value Value.
  26434. */
  26435. RBush.prototype.update = function (extent, value) {
  26436. var item = this.items_[getUid(value)];
  26437. var bbox = [item.minX, item.minY, item.maxX, item.maxY];
  26438. if (!extent_equals(bbox, extent)) {
  26439. this.remove(value);
  26440. this.insert(extent, value);
  26441. }
  26442. };
  26443. /**
  26444. * Return all values in the RBush.
  26445. * @return {Array<T>} All.
  26446. */
  26447. RBush.prototype.getAll = function () {
  26448. var items = this.rbush_.all();
  26449. return items.map(function (item) {
  26450. return item.value;
  26451. });
  26452. };
  26453. /**
  26454. * Return all values in the given extent.
  26455. * @param {import("../extent.js").Extent} extent Extent.
  26456. * @return {Array<T>} All in extent.
  26457. */
  26458. RBush.prototype.getInExtent = function (extent) {
  26459. /** @type {Entry} */
  26460. var bbox = {
  26461. minX: extent[0],
  26462. minY: extent[1],
  26463. maxX: extent[2],
  26464. maxY: extent[3],
  26465. };
  26466. var items = this.rbush_.search(bbox);
  26467. return items.map(function (item) {
  26468. return item.value;
  26469. });
  26470. };
  26471. /**
  26472. * Calls a callback function with each value in the tree.
  26473. * If the callback returns a truthy value, this value is returned without
  26474. * checking the rest of the tree.
  26475. * @param {function(T): *} callback Callback.
  26476. * @return {*} Callback return value.
  26477. */
  26478. RBush.prototype.forEach = function (callback) {
  26479. return this.forEach_(this.getAll(), callback);
  26480. };
  26481. /**
  26482. * Calls a callback function with each value in the provided extent.
  26483. * @param {import("../extent.js").Extent} extent Extent.
  26484. * @param {function(T): *} callback Callback.
  26485. * @return {*} Callback return value.
  26486. */
  26487. RBush.prototype.forEachInExtent = function (extent, callback) {
  26488. return this.forEach_(this.getInExtent(extent), callback);
  26489. };
  26490. /**
  26491. * @param {Array<T>} values Values.
  26492. * @param {function(T): *} callback Callback.
  26493. * @private
  26494. * @return {*} Callback return value.
  26495. */
  26496. RBush.prototype.forEach_ = function (values, callback) {
  26497. var result;
  26498. for (var i = 0, l = values.length; i < l; i++) {
  26499. result = callback(values[i]);
  26500. if (result) {
  26501. return result;
  26502. }
  26503. }
  26504. return result;
  26505. };
  26506. /**
  26507. * @return {boolean} Is empty.
  26508. */
  26509. RBush.prototype.isEmpty = function () {
  26510. return obj_isEmpty(this.items_);
  26511. };
  26512. /**
  26513. * Remove all values from the RBush.
  26514. */
  26515. RBush.prototype.clear = function () {
  26516. this.rbush_.clear();
  26517. this.items_ = {};
  26518. };
  26519. /**
  26520. * @param {import("../extent.js").Extent} [opt_extent] Extent.
  26521. * @return {import("../extent.js").Extent} Extent.
  26522. */
  26523. RBush.prototype.getExtent = function (opt_extent) {
  26524. var data = this.rbush_.toJSON();
  26525. return createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
  26526. };
  26527. /**
  26528. * @param {RBush} rbush R-Tree.
  26529. */
  26530. RBush.prototype.concat = function (rbush) {
  26531. this.rbush_.load(rbush.rbush_.all());
  26532. for (var i in rbush.items_) {
  26533. this.items_[i] = rbush.items_[i];
  26534. }
  26535. };
  26536. return RBush;
  26537. }());
  26538. /* harmony default export */ var structs_RBush = (RBush);
  26539. //# sourceMappingURL=RBush.js.map
  26540. ;// ./node_modules/ol/source/VectorEventType.js
  26541. /**
  26542. * @module ol/source/VectorEventType
  26543. */
  26544. /**
  26545. * @enum {string}
  26546. */
  26547. /* harmony default export */ var VectorEventType = ({
  26548. /**
  26549. * Triggered when a feature is added to the source.
  26550. * @event module:ol/source/Vector.VectorSourceEvent#addfeature
  26551. * @api
  26552. */
  26553. ADDFEATURE: 'addfeature',
  26554. /**
  26555. * Triggered when a feature is updated.
  26556. * @event module:ol/source/Vector.VectorSourceEvent#changefeature
  26557. * @api
  26558. */
  26559. CHANGEFEATURE: 'changefeature',
  26560. /**
  26561. * Triggered when the clear method is called on the source.
  26562. * @event module:ol/source/Vector.VectorSourceEvent#clear
  26563. * @api
  26564. */
  26565. CLEAR: 'clear',
  26566. /**
  26567. * Triggered when a feature is removed from the source.
  26568. * See {@link module:ol/source/Vector~VectorSource#clear source.clear()} for exceptions.
  26569. * @event module:ol/source/Vector.VectorSourceEvent#removefeature
  26570. * @api
  26571. */
  26572. REMOVEFEATURE: 'removefeature',
  26573. /**
  26574. * Triggered when features starts loading.
  26575. * @event module:ol/source/Vector.VectorSourceEvent#featuresloadstart
  26576. * @api
  26577. */
  26578. FEATURESLOADSTART: 'featuresloadstart',
  26579. /**
  26580. * Triggered when features finishes loading.
  26581. * @event module:ol/source/Vector.VectorSourceEvent#featuresloadend
  26582. * @api
  26583. */
  26584. FEATURESLOADEND: 'featuresloadend',
  26585. /**
  26586. * Triggered if feature loading results in an error.
  26587. * @event module:ol/source/Vector.VectorSourceEvent#featuresloaderror
  26588. * @api
  26589. */
  26590. FEATURESLOADERROR: 'featuresloaderror',
  26591. });
  26592. /**
  26593. * @typedef {'addfeature'|'changefeature'|'clear'|'removefeature'|'featuresloadstart'|'featuresloadend'|'featuresloaderror'} VectorSourceEventTypes
  26594. */
  26595. //# sourceMappingURL=VectorEventType.js.map
  26596. ;// ./node_modules/ol/loadingstrategy.js
  26597. /**
  26598. * @module ol/loadingstrategy
  26599. */
  26600. /**
  26601. * Strategy function for loading all features with a single request.
  26602. * @param {import("./extent.js").Extent} extent Extent.
  26603. * @param {number} resolution Resolution.
  26604. * @return {Array<import("./extent.js").Extent>} Extents.
  26605. * @api
  26606. */
  26607. function loadingstrategy_all(extent, resolution) {
  26608. return [[-Infinity, -Infinity, Infinity, Infinity]];
  26609. }
  26610. /**
  26611. * Strategy function for loading features based on the view's extent and
  26612. * resolution.
  26613. * @param {import("./extent.js").Extent} extent Extent.
  26614. * @param {number} resolution Resolution.
  26615. * @return {Array<import("./extent.js").Extent>} Extents.
  26616. * @api
  26617. */
  26618. function bbox(extent, resolution) {
  26619. return [extent];
  26620. }
  26621. /**
  26622. * Creates a strategy function for loading features based on a tile grid.
  26623. * @param {import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
  26624. * @return {function(import("./extent.js").Extent, number, import("./proj.js").Projection): Array<import("./extent.js").Extent>} Loading strategy.
  26625. * @api
  26626. */
  26627. function tile(tileGrid) {
  26628. return (
  26629. /**
  26630. * @param {import("./extent.js").Extent} extent Extent.
  26631. * @param {number} resolution Resolution.
  26632. * @param {import("./proj.js").Projection} projection Projection.
  26633. * @return {Array<import("./extent.js").Extent>} Extents.
  26634. */
  26635. function (extent, resolution, projection) {
  26636. var z = tileGrid.getZForResolution(fromUserResolution(resolution, projection));
  26637. var tileRange = tileGrid.getTileRangeForExtentAndZ(fromUserExtent(extent, projection), z);
  26638. /** @type {Array<import("./extent.js").Extent>} */
  26639. var extents = [];
  26640. /** @type {import("./tilecoord.js").TileCoord} */
  26641. var tileCoord = [z, 0, 0];
  26642. for (tileCoord[1] = tileRange.minX; tileCoord[1] <= tileRange.maxX; ++tileCoord[1]) {
  26643. for (tileCoord[2] = tileRange.minY; tileCoord[2] <= tileRange.maxY; ++tileCoord[2]) {
  26644. extents.push(toUserExtent(tileGrid.getTileCoordExtent(tileCoord), projection));
  26645. }
  26646. }
  26647. return extents;
  26648. });
  26649. }
  26650. //# sourceMappingURL=loadingstrategy.js.map
  26651. ;// ./node_modules/ol/featureloader.js
  26652. /**
  26653. * @module ol/featureloader
  26654. */
  26655. /**
  26656. *
  26657. * @type {boolean}
  26658. * @private
  26659. */
  26660. var withCredentials = false;
  26661. /**
  26662. * {@link module:ol/source/Vector~VectorSource} sources use a function of this type to
  26663. * load features.
  26664. *
  26665. * This function takes up to 5 arguments. These are an {@link module:ol/extent~Extent} representing
  26666. * the area to be loaded, a `{number}` representing the resolution (map units per pixel), an
  26667. * {@link module:ol/proj/Projection~Projection} for the projection, an optional success callback that should get
  26668. * the loaded features passed as an argument and an optional failure callback with no arguments. If
  26669. * the callbacks are not used, the corresponding vector source will not fire `'featuresloadend'` and
  26670. * `'featuresloaderror'` events. `this` within the function is bound to the
  26671. * {@link module:ol/source/Vector~VectorSource} it's called from.
  26672. *
  26673. * The function is responsible for loading the features and adding them to the
  26674. * source.
  26675. * @typedef {function(this:(import("./source/Vector").default|import("./VectorTile.js").default),
  26676. * import("./extent.js").Extent,
  26677. * number,
  26678. * import("./proj/Projection.js").default,
  26679. * function(Array<import("./Feature.js").default>): void=,
  26680. * function(): void=): void} FeatureLoader
  26681. * @api
  26682. */
  26683. /**
  26684. * {@link module:ol/source/Vector~VectorSource} sources use a function of this type to
  26685. * get the url to load features from.
  26686. *
  26687. * This function takes an {@link module:ol/extent~Extent} representing the area
  26688. * to be loaded, a `{number}` representing the resolution (map units per pixel)
  26689. * and an {@link module:ol/proj/Projection~Projection} for the projection as
  26690. * arguments and returns a `{string}` representing the URL.
  26691. * @typedef {function(import("./extent.js").Extent, number, import("./proj/Projection.js").default): string} FeatureUrlFunction
  26692. * @api
  26693. */
  26694. /**
  26695. * @param {string|FeatureUrlFunction} url Feature URL service.
  26696. * @param {import("./format/Feature.js").default} format Feature format.
  26697. * @param {import("./extent.js").Extent} extent Extent.
  26698. * @param {number} resolution Resolution.
  26699. * @param {import("./proj/Projection.js").default} projection Projection.
  26700. * @param {function(Array<import("./Feature.js").default>, import("./proj/Projection.js").default): void} success Success
  26701. * Function called with the loaded features and optionally with the data projection.
  26702. * @param {function(): void} failure Failure
  26703. * Function called when loading failed.
  26704. */
  26705. function loadFeaturesXhr(url, format, extent, resolution, projection, success, failure) {
  26706. var xhr = new XMLHttpRequest();
  26707. xhr.open('GET', typeof url === 'function' ? url(extent, resolution, projection) : url, true);
  26708. if (format.getType() == 'arraybuffer') {
  26709. xhr.responseType = 'arraybuffer';
  26710. }
  26711. xhr.withCredentials = withCredentials;
  26712. /**
  26713. * @param {Event} event Event.
  26714. * @private
  26715. */
  26716. xhr.onload = function (event) {
  26717. // status will be 0 for file:// urls
  26718. if (!xhr.status || (xhr.status >= 200 && xhr.status < 300)) {
  26719. var type = format.getType();
  26720. /** @type {Document|Node|Object|string|undefined} */
  26721. var source = void 0;
  26722. if (type == 'json' || type == 'text') {
  26723. source = xhr.responseText;
  26724. }
  26725. else if (type == 'xml') {
  26726. source = xhr.responseXML;
  26727. if (!source) {
  26728. source = new DOMParser().parseFromString(xhr.responseText, 'application/xml');
  26729. }
  26730. }
  26731. else if (type == 'arraybuffer') {
  26732. source = /** @type {ArrayBuffer} */ (xhr.response);
  26733. }
  26734. if (source) {
  26735. success(
  26736. /** @type {Array<import("./Feature.js").default>} */
  26737. (format.readFeatures(source, {
  26738. extent: extent,
  26739. featureProjection: projection,
  26740. })), format.readProjection(source));
  26741. }
  26742. else {
  26743. failure();
  26744. }
  26745. }
  26746. else {
  26747. failure();
  26748. }
  26749. };
  26750. /**
  26751. * @private
  26752. */
  26753. xhr.onerror = failure;
  26754. xhr.send();
  26755. }
  26756. /**
  26757. * Create an XHR feature loader for a `url` and `format`. The feature loader
  26758. * loads features (with XHR), parses the features, and adds them to the
  26759. * vector source.
  26760. * @param {string|FeatureUrlFunction} url Feature URL service.
  26761. * @param {import("./format/Feature.js").default} format Feature format.
  26762. * @return {FeatureLoader} The feature loader.
  26763. * @api
  26764. */
  26765. function xhr(url, format) {
  26766. /**
  26767. * @param {import("./extent.js").Extent} extent Extent.
  26768. * @param {number} resolution Resolution.
  26769. * @param {import("./proj/Projection.js").default} projection Projection.
  26770. * @param {function(Array<import("./Feature.js").default>): void} [success] Success
  26771. * Function called when loading succeeded.
  26772. * @param {function(): void} [failure] Failure
  26773. * Function called when loading failed.
  26774. * @this {import("./source/Vector").default}
  26775. */
  26776. return function (extent, resolution, projection, success, failure) {
  26777. var source = /** @type {import("./source/Vector").default} */ (this);
  26778. loadFeaturesXhr(url, format, extent, resolution, projection,
  26779. /**
  26780. * @param {Array<import("./Feature.js").default>} features The loaded features.
  26781. * @param {import("./proj/Projection.js").default} dataProjection Data
  26782. * projection.
  26783. */
  26784. function (features, dataProjection) {
  26785. source.addFeatures(features);
  26786. if (success !== undefined) {
  26787. success(features);
  26788. }
  26789. },
  26790. /* FIXME handle error */ failure ? failure : VOID);
  26791. };
  26792. }
  26793. /**
  26794. * Setter for the withCredentials configuration for the XHR.
  26795. *
  26796. * @param {boolean} xhrWithCredentials The value of withCredentials to set.
  26797. * Compare https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
  26798. * @api
  26799. */
  26800. function setWithCredentials(xhrWithCredentials) {
  26801. withCredentials = xhrWithCredentials;
  26802. }
  26803. //# sourceMappingURL=featureloader.js.map
  26804. ;// ./node_modules/ol/source/Vector.js
  26805. /**
  26806. * @module ol/source/Vector
  26807. */
  26808. var source_Vector_extends = (undefined && undefined.__extends) || (function () {
  26809. var extendStatics = function (d, b) {
  26810. extendStatics = Object.setPrototypeOf ||
  26811. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26812. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26813. return extendStatics(d, b);
  26814. };
  26815. return function (d, b) {
  26816. if (typeof b !== "function" && b !== null)
  26817. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26818. extendStatics(d, b);
  26819. function __() { this.constructor = d; }
  26820. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26821. };
  26822. })();
  26823. /**
  26824. * A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and
  26825. * returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this
  26826. * is one of the standard {@link module:ol/loadingstrategy} strategies.
  26827. *
  26828. * @typedef {function(import("../extent.js").Extent, number, import("../proj/Projection.js").default): Array<import("../extent.js").Extent>} LoadingStrategy
  26829. * @api
  26830. */
  26831. /**
  26832. * @classdesc
  26833. * Events emitted by {@link module:ol/source/Vector~VectorSource} instances are instances of this
  26834. * type.
  26835. * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
  26836. */
  26837. var VectorSourceEvent = /** @class */ (function (_super) {
  26838. source_Vector_extends(VectorSourceEvent, _super);
  26839. /**
  26840. * @param {string} type Type.
  26841. * @param {import("../Feature.js").default<Geometry>} [opt_feature] Feature.
  26842. * @param {Array<import("../Feature.js").default<Geometry>>} [opt_features] Features.
  26843. */
  26844. function VectorSourceEvent(type, opt_feature, opt_features) {
  26845. var _this = _super.call(this, type) || this;
  26846. /**
  26847. * The added or removed feature for the `ADDFEATURE` and `REMOVEFEATURE` events, `undefined` otherwise.
  26848. * @type {import("../Feature.js").default<Geometry>|undefined}
  26849. * @api
  26850. */
  26851. _this.feature = opt_feature;
  26852. /**
  26853. * The loaded features for the `FEATURESLOADED` event, `undefined` otherwise.
  26854. * @type {Array<import("../Feature.js").default<Geometry>>|undefined}
  26855. * @api
  26856. */
  26857. _this.features = opt_features;
  26858. return _this;
  26859. }
  26860. return VectorSourceEvent;
  26861. }(Event));
  26862. /***
  26863. * @template Return
  26864. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  26865. * import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
  26866. * import("../Observable").OnSignature<import("./VectorEventType").VectorSourceEventTypes, VectorSourceEvent, Return> &
  26867. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
  26868. * import("./VectorEventType").VectorSourceEventTypes, Return>} VectorSourceOnSignature
  26869. */
  26870. /**
  26871. * @typedef {Object} Options
  26872. * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
  26873. * @property {Array<import("../Feature.js").default>|Collection<import("../Feature.js").default>} [features]
  26874. * Features. If provided as {@link module:ol/Collection~Collection}, the features in the source
  26875. * and the collection will stay in sync.
  26876. * @property {import("../format/Feature.js").default} [format] The feature format used by the XHR
  26877. * feature loader when `url` is set. Required if `url` is set, otherwise ignored.
  26878. * @property {import("../featureloader.js").FeatureLoader} [loader]
  26879. * The loader function used to load features, from a remote source for example.
  26880. * If this is not set and `url` is set, the source will create and use an XHR
  26881. * feature loader. The `'featuresloadend'` and `'featuresloaderror'` events
  26882. * will only fire if the `success` and `failure` callbacks are used.
  26883. *
  26884. * Example:
  26885. *
  26886. * ```js
  26887. * import {Vector} from 'ol/source';
  26888. * import {GeoJSON} from 'ol/format';
  26889. * import {bbox} from 'ol/loadingstrategy';
  26890. *
  26891. * var vectorSource = new Vector({
  26892. * format: new GeoJSON(),
  26893. * loader: function(extent, resolution, projection, success, failure) {
  26894. * var proj = projection.getCode();
  26895. * var url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
  26896. * 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
  26897. * 'outputFormat=application/json&srsname=' + proj + '&' +
  26898. * 'bbox=' + extent.join(',') + ',' + proj;
  26899. * var xhr = new XMLHttpRequest();
  26900. * xhr.open('GET', url);
  26901. * var onError = function() {
  26902. * vectorSource.removeLoadedExtent(extent);
  26903. * failure();
  26904. * }
  26905. * xhr.onerror = onError;
  26906. * xhr.onload = function() {
  26907. * if (xhr.status == 200) {
  26908. * var features = vectorSource.getFormat().readFeatures(xhr.responseText);
  26909. * vectorSource.addFeatures(features);
  26910. * success(features);
  26911. * } else {
  26912. * onError();
  26913. * }
  26914. * }
  26915. * xhr.send();
  26916. * },
  26917. * strategy: bbox
  26918. * });
  26919. * ```
  26920. * @property {boolean} [overlaps=true] This source may have overlapping geometries.
  26921. * Setting this to `false` (e.g. for sources with polygons that represent administrative
  26922. * boundaries or TopoJSON sources) allows the renderer to optimise fill and
  26923. * stroke operations.
  26924. * @property {LoadingStrategy} [strategy] The loading strategy to use.
  26925. * By default an {@link module:ol/loadingstrategy.all}
  26926. * strategy is used, a one-off strategy which loads all features at once.
  26927. * @property {string|import("../featureloader.js").FeatureUrlFunction} [url]
  26928. * Setting this option instructs the source to load features using an XHR loader
  26929. * (see {@link module:ol/featureloader.xhr}). Use a `string` and an
  26930. * {@link module:ol/loadingstrategy.all} for a one-off download of all features from
  26931. * the given URL. Use a {@link module:ol/featureloader~FeatureUrlFunction} to generate the url with
  26932. * other loading strategies.
  26933. * Requires `format` to be set as well.
  26934. * When default XHR feature loader is provided, the features will
  26935. * be transformed from the data projection to the view projection
  26936. * during parsing. If your remote data source does not advertise its projection
  26937. * properly, this transformation will be incorrect. For some formats, the
  26938. * default projection (usually EPSG:4326) can be overridden by setting the
  26939. * dataProjection constructor option on the format.
  26940. * Note that if a source contains non-feature data, such as a GeoJSON geometry
  26941. * or a KML NetworkLink, these will be ignored. Use a custom loader to load these.
  26942. * @property {boolean} [useSpatialIndex=true]
  26943. * By default, an RTree is used as spatial index. When features are removed and
  26944. * added frequently, and the total number of features is low, setting this to
  26945. * `false` may improve performance.
  26946. *
  26947. * Note that
  26948. * {@link module:ol/source/Vector~VectorSource#getFeaturesInExtent},
  26949. * {@link module:ol/source/Vector~VectorSource#getClosestFeatureToCoordinate} and
  26950. * {@link module:ol/source/Vector~VectorSource#getExtent} cannot be used when `useSpatialIndex` is
  26951. * set to `false`, and {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent} will loop
  26952. * through all features.
  26953. *
  26954. * When set to `false`, the features will be maintained in an
  26955. * {@link module:ol/Collection~Collection}, which can be retrieved through
  26956. * {@link module:ol/source/Vector~VectorSource#getFeaturesCollection}.
  26957. * @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the
  26958. * -180° and 180° meridians to work properly, this should be set to `false`. The
  26959. * resulting geometry coordinates will then exceed the world bounds.
  26960. */
  26961. /**
  26962. * @classdesc
  26963. * Provides a source of features for vector layers. Vector features provided
  26964. * by this source are suitable for editing. See {@link module:ol/source/VectorTile~VectorTile} for
  26965. * vector data that is optimized for rendering.
  26966. *
  26967. * @fires VectorSourceEvent
  26968. * @api
  26969. * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
  26970. */
  26971. var VectorSource = /** @class */ (function (_super) {
  26972. source_Vector_extends(VectorSource, _super);
  26973. /**
  26974. * @param {Options} [opt_options] Vector source options.
  26975. */
  26976. function VectorSource(opt_options) {
  26977. var _this = this;
  26978. var options = opt_options || {};
  26979. _this = _super.call(this, {
  26980. attributions: options.attributions,
  26981. interpolate: true,
  26982. projection: undefined,
  26983. state: 'ready',
  26984. wrapX: options.wrapX !== undefined ? options.wrapX : true,
  26985. }) || this;
  26986. /***
  26987. * @type {VectorSourceOnSignature<import("../events").EventsKey>}
  26988. */
  26989. _this.on;
  26990. /***
  26991. * @type {VectorSourceOnSignature<import("../events").EventsKey>}
  26992. */
  26993. _this.once;
  26994. /***
  26995. * @type {VectorSourceOnSignature<void>}
  26996. */
  26997. _this.un;
  26998. /**
  26999. * @private
  27000. * @type {import("../featureloader.js").FeatureLoader}
  27001. */
  27002. _this.loader_ = VOID;
  27003. /**
  27004. * @private
  27005. * @type {import("../format/Feature.js").default|undefined}
  27006. */
  27007. _this.format_ = options.format;
  27008. /**
  27009. * @private
  27010. * @type {boolean}
  27011. */
  27012. _this.overlaps_ = options.overlaps === undefined ? true : options.overlaps;
  27013. /**
  27014. * @private
  27015. * @type {string|import("../featureloader.js").FeatureUrlFunction|undefined}
  27016. */
  27017. _this.url_ = options.url;
  27018. if (options.loader !== undefined) {
  27019. _this.loader_ = options.loader;
  27020. }
  27021. else if (_this.url_ !== undefined) {
  27022. asserts_assert(_this.format_, 7); // `format` must be set when `url` is set
  27023. // create a XHR feature loader for "url" and "format"
  27024. _this.loader_ = xhr(_this.url_,
  27025. /** @type {import("../format/Feature.js").default} */ (_this.format_));
  27026. }
  27027. /**
  27028. * @private
  27029. * @type {LoadingStrategy}
  27030. */
  27031. _this.strategy_ =
  27032. options.strategy !== undefined ? options.strategy : loadingstrategy_all;
  27033. var useSpatialIndex = options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;
  27034. /**
  27035. * @private
  27036. * @type {RBush<import("../Feature.js").default<Geometry>>}
  27037. */
  27038. _this.featuresRtree_ = useSpatialIndex ? new structs_RBush() : null;
  27039. /**
  27040. * @private
  27041. * @type {RBush<{extent: import("../extent.js").Extent}>}
  27042. */
  27043. _this.loadedExtentsRtree_ = new structs_RBush();
  27044. /**
  27045. * @type {number}
  27046. * @private
  27047. */
  27048. _this.loadingExtentsCount_ = 0;
  27049. /**
  27050. * @private
  27051. * @type {!Object<string, import("../Feature.js").default<Geometry>>}
  27052. */
  27053. _this.nullGeometryFeatures_ = {};
  27054. /**
  27055. * A lookup of features by id (the return from feature.getId()).
  27056. * @private
  27057. * @type {!Object<string, import("../Feature.js").default<Geometry>>}
  27058. */
  27059. _this.idIndex_ = {};
  27060. /**
  27061. * A lookup of features by uid (using getUid(feature)).
  27062. * @private
  27063. * @type {!Object<string, import("../Feature.js").default<Geometry>>}
  27064. */
  27065. _this.uidIndex_ = {};
  27066. /**
  27067. * @private
  27068. * @type {Object<string, Array<import("../events.js").EventsKey>>}
  27069. */
  27070. _this.featureChangeKeys_ = {};
  27071. /**
  27072. * @private
  27073. * @type {Collection<import("../Feature.js").default<Geometry>>|null}
  27074. */
  27075. _this.featuresCollection_ = null;
  27076. var collection, features;
  27077. if (Array.isArray(options.features)) {
  27078. features =
  27079. /** @type {Array<import("../Feature.js").default<Geometry>>} */ (options.features);
  27080. }
  27081. else if (options.features) {
  27082. collection =
  27083. /** @type {Collection<import("../Feature.js").default<Geometry>>} */ (options.features);
  27084. features = collection.getArray();
  27085. }
  27086. if (!useSpatialIndex && collection === undefined) {
  27087. collection = new ol_Collection(features);
  27088. }
  27089. if (features !== undefined) {
  27090. _this.addFeaturesInternal(features);
  27091. }
  27092. if (collection !== undefined) {
  27093. _this.bindFeaturesCollection_(collection);
  27094. }
  27095. return _this;
  27096. }
  27097. /**
  27098. * Add a single feature to the source. If you want to add a batch of features
  27099. * at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()}
  27100. * instead. A feature will not be added to the source if feature with
  27101. * the same id is already there. The reason for this behavior is to avoid
  27102. * feature duplication when using bbox or tile loading strategies.
  27103. * Note: this also applies if an {@link module:ol/Collection~Collection} is used for features,
  27104. * meaning that if a feature with a duplicate id is added in the collection, it will
  27105. * be removed from it right away.
  27106. * @param {import("../Feature.js").default<Geometry>} feature Feature to add.
  27107. * @api
  27108. */
  27109. VectorSource.prototype.addFeature = function (feature) {
  27110. this.addFeatureInternal(feature);
  27111. this.changed();
  27112. };
  27113. /**
  27114. * Add a feature without firing a `change` event.
  27115. * @param {import("../Feature.js").default<Geometry>} feature Feature.
  27116. * @protected
  27117. */
  27118. VectorSource.prototype.addFeatureInternal = function (feature) {
  27119. var featureKey = getUid(feature);
  27120. if (!this.addToIndex_(featureKey, feature)) {
  27121. if (this.featuresCollection_) {
  27122. this.featuresCollection_.remove(feature);
  27123. }
  27124. return;
  27125. }
  27126. this.setupChangeEvents_(featureKey, feature);
  27127. var geometry = feature.getGeometry();
  27128. if (geometry) {
  27129. var extent = geometry.getExtent();
  27130. if (this.featuresRtree_) {
  27131. this.featuresRtree_.insert(extent, feature);
  27132. }
  27133. }
  27134. else {
  27135. this.nullGeometryFeatures_[featureKey] = feature;
  27136. }
  27137. this.dispatchEvent(new VectorSourceEvent(VectorEventType.ADDFEATURE, feature));
  27138. };
  27139. /**
  27140. * @param {string} featureKey Unique identifier for the feature.
  27141. * @param {import("../Feature.js").default<Geometry>} feature The feature.
  27142. * @private
  27143. */
  27144. VectorSource.prototype.setupChangeEvents_ = function (featureKey, feature) {
  27145. this.featureChangeKeys_[featureKey] = [
  27146. listen(feature, EventType.CHANGE, this.handleFeatureChange_, this),
  27147. listen(feature, ObjectEventType.PROPERTYCHANGE, this.handleFeatureChange_, this),
  27148. ];
  27149. };
  27150. /**
  27151. * @param {string} featureKey Unique identifier for the feature.
  27152. * @param {import("../Feature.js").default<Geometry>} feature The feature.
  27153. * @return {boolean} The feature is "valid", in the sense that it is also a
  27154. * candidate for insertion into the Rtree.
  27155. * @private
  27156. */
  27157. VectorSource.prototype.addToIndex_ = function (featureKey, feature) {
  27158. var valid = true;
  27159. var id = feature.getId();
  27160. if (id !== undefined) {
  27161. if (!(id.toString() in this.idIndex_)) {
  27162. this.idIndex_[id.toString()] = feature;
  27163. }
  27164. else {
  27165. valid = false;
  27166. }
  27167. }
  27168. if (valid) {
  27169. asserts_assert(!(featureKey in this.uidIndex_), 30); // The passed `feature` was already added to the source
  27170. this.uidIndex_[featureKey] = feature;
  27171. }
  27172. return valid;
  27173. };
  27174. /**
  27175. * Add a batch of features to the source.
  27176. * @param {Array<import("../Feature.js").default<Geometry>>} features Features to add.
  27177. * @api
  27178. */
  27179. VectorSource.prototype.addFeatures = function (features) {
  27180. this.addFeaturesInternal(features);
  27181. this.changed();
  27182. };
  27183. /**
  27184. * Add features without firing a `change` event.
  27185. * @param {Array<import("../Feature.js").default<Geometry>>} features Features.
  27186. * @protected
  27187. */
  27188. VectorSource.prototype.addFeaturesInternal = function (features) {
  27189. var extents = [];
  27190. var newFeatures = [];
  27191. var geometryFeatures = [];
  27192. for (var i = 0, length_1 = features.length; i < length_1; i++) {
  27193. var feature = features[i];
  27194. var featureKey = getUid(feature);
  27195. if (this.addToIndex_(featureKey, feature)) {
  27196. newFeatures.push(feature);
  27197. }
  27198. }
  27199. for (var i = 0, length_2 = newFeatures.length; i < length_2; i++) {
  27200. var feature = newFeatures[i];
  27201. var featureKey = getUid(feature);
  27202. this.setupChangeEvents_(featureKey, feature);
  27203. var geometry = feature.getGeometry();
  27204. if (geometry) {
  27205. var extent = geometry.getExtent();
  27206. extents.push(extent);
  27207. geometryFeatures.push(feature);
  27208. }
  27209. else {
  27210. this.nullGeometryFeatures_[featureKey] = feature;
  27211. }
  27212. }
  27213. if (this.featuresRtree_) {
  27214. this.featuresRtree_.load(extents, geometryFeatures);
  27215. }
  27216. if (this.hasListener(VectorEventType.ADDFEATURE)) {
  27217. for (var i = 0, length_3 = newFeatures.length; i < length_3; i++) {
  27218. this.dispatchEvent(new VectorSourceEvent(VectorEventType.ADDFEATURE, newFeatures[i]));
  27219. }
  27220. }
  27221. };
  27222. /**
  27223. * @param {!Collection<import("../Feature.js").default<Geometry>>} collection Collection.
  27224. * @private
  27225. */
  27226. VectorSource.prototype.bindFeaturesCollection_ = function (collection) {
  27227. var modifyingCollection = false;
  27228. this.addEventListener(VectorEventType.ADDFEATURE,
  27229. /**
  27230. * @param {VectorSourceEvent<Geometry>} evt The vector source event
  27231. */
  27232. function (evt) {
  27233. if (!modifyingCollection) {
  27234. modifyingCollection = true;
  27235. collection.push(evt.feature);
  27236. modifyingCollection = false;
  27237. }
  27238. });
  27239. this.addEventListener(VectorEventType.REMOVEFEATURE,
  27240. /**
  27241. * @param {VectorSourceEvent<Geometry>} evt The vector source event
  27242. */
  27243. function (evt) {
  27244. if (!modifyingCollection) {
  27245. modifyingCollection = true;
  27246. collection.remove(evt.feature);
  27247. modifyingCollection = false;
  27248. }
  27249. });
  27250. collection.addEventListener(CollectionEventType.ADD,
  27251. /**
  27252. * @param {import("../Collection.js").CollectionEvent} evt The collection event
  27253. */
  27254. function (evt) {
  27255. if (!modifyingCollection) {
  27256. modifyingCollection = true;
  27257. this.addFeature(
  27258. /** @type {import("../Feature.js").default<Geometry>} */ (evt.element));
  27259. modifyingCollection = false;
  27260. }
  27261. }.bind(this));
  27262. collection.addEventListener(CollectionEventType.REMOVE,
  27263. /**
  27264. * @param {import("../Collection.js").CollectionEvent} evt The collection event
  27265. */
  27266. function (evt) {
  27267. if (!modifyingCollection) {
  27268. modifyingCollection = true;
  27269. this.removeFeature(
  27270. /** @type {import("../Feature.js").default<Geometry>} */ (evt.element));
  27271. modifyingCollection = false;
  27272. }
  27273. }.bind(this));
  27274. this.featuresCollection_ = collection;
  27275. };
  27276. /**
  27277. * Remove all features from the source.
  27278. * @param {boolean} [opt_fast] Skip dispatching of {@link module:ol/source/Vector.VectorSourceEvent#event:removefeature removefeature} events.
  27279. * @api
  27280. */
  27281. VectorSource.prototype.clear = function (opt_fast) {
  27282. if (opt_fast) {
  27283. for (var featureId in this.featureChangeKeys_) {
  27284. var keys = this.featureChangeKeys_[featureId];
  27285. keys.forEach(unlistenByKey);
  27286. }
  27287. if (!this.featuresCollection_) {
  27288. this.featureChangeKeys_ = {};
  27289. this.idIndex_ = {};
  27290. this.uidIndex_ = {};
  27291. }
  27292. }
  27293. else {
  27294. if (this.featuresRtree_) {
  27295. var removeAndIgnoreReturn = function (feature) {
  27296. this.removeFeatureInternal(feature);
  27297. }.bind(this);
  27298. this.featuresRtree_.forEach(removeAndIgnoreReturn);
  27299. for (var id in this.nullGeometryFeatures_) {
  27300. this.removeFeatureInternal(this.nullGeometryFeatures_[id]);
  27301. }
  27302. }
  27303. }
  27304. if (this.featuresCollection_) {
  27305. this.featuresCollection_.clear();
  27306. }
  27307. if (this.featuresRtree_) {
  27308. this.featuresRtree_.clear();
  27309. }
  27310. this.nullGeometryFeatures_ = {};
  27311. var clearEvent = new VectorSourceEvent(VectorEventType.CLEAR);
  27312. this.dispatchEvent(clearEvent);
  27313. this.changed();
  27314. };
  27315. /**
  27316. * Iterate through all features on the source, calling the provided callback
  27317. * with each one. If the callback returns any "truthy" value, iteration will
  27318. * stop and the function will return the same value.
  27319. * Note: this function only iterate through the feature that have a defined geometry.
  27320. *
  27321. * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
  27322. * on the source. Return a truthy value to stop iteration.
  27323. * @return {T|undefined} The return value from the last call to the callback.
  27324. * @template T
  27325. * @api
  27326. */
  27327. VectorSource.prototype.forEachFeature = function (callback) {
  27328. if (this.featuresRtree_) {
  27329. return this.featuresRtree_.forEach(callback);
  27330. }
  27331. else if (this.featuresCollection_) {
  27332. this.featuresCollection_.forEach(callback);
  27333. }
  27334. };
  27335. /**
  27336. * Iterate through all features whose geometries contain the provided
  27337. * coordinate, calling the callback with each feature. If the callback returns
  27338. * a "truthy" value, iteration will stop and the function will return the same
  27339. * value.
  27340. *
  27341. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  27342. * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
  27343. * whose goemetry contains the provided coordinate.
  27344. * @return {T|undefined} The return value from the last call to the callback.
  27345. * @template T
  27346. */
  27347. VectorSource.prototype.forEachFeatureAtCoordinateDirect = function (coordinate, callback) {
  27348. var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
  27349. return this.forEachFeatureInExtent(extent, function (feature) {
  27350. var geometry = feature.getGeometry();
  27351. if (geometry.intersectsCoordinate(coordinate)) {
  27352. return callback(feature);
  27353. }
  27354. else {
  27355. return undefined;
  27356. }
  27357. });
  27358. };
  27359. /**
  27360. * Iterate through all features whose bounding box intersects the provided
  27361. * extent (note that the feature's geometry may not intersect the extent),
  27362. * calling the callback with each feature. If the callback returns a "truthy"
  27363. * value, iteration will stop and the function will return the same value.
  27364. *
  27365. * If you are interested in features whose geometry intersects an extent, call
  27366. * the {@link module:ol/source/Vector~VectorSource#forEachFeatureIntersectingExtent #forEachFeatureIntersectingExtent()} method instead.
  27367. *
  27368. * When `useSpatialIndex` is set to false, this method will loop through all
  27369. * features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}.
  27370. *
  27371. * @param {import("../extent.js").Extent} extent Extent.
  27372. * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
  27373. * whose bounding box intersects the provided extent.
  27374. * @return {T|undefined} The return value from the last call to the callback.
  27375. * @template T
  27376. * @api
  27377. */
  27378. VectorSource.prototype.forEachFeatureInExtent = function (extent, callback) {
  27379. if (this.featuresRtree_) {
  27380. return this.featuresRtree_.forEachInExtent(extent, callback);
  27381. }
  27382. else if (this.featuresCollection_) {
  27383. this.featuresCollection_.forEach(callback);
  27384. }
  27385. };
  27386. /**
  27387. * Iterate through all features whose geometry intersects the provided extent,
  27388. * calling the callback with each feature. If the callback returns a "truthy"
  27389. * value, iteration will stop and the function will return the same value.
  27390. *
  27391. * If you only want to test for bounding box intersection, call the
  27392. * {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead.
  27393. *
  27394. * @param {import("../extent.js").Extent} extent Extent.
  27395. * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
  27396. * whose geometry intersects the provided extent.
  27397. * @return {T|undefined} The return value from the last call to the callback.
  27398. * @template T
  27399. * @api
  27400. */
  27401. VectorSource.prototype.forEachFeatureIntersectingExtent = function (extent, callback) {
  27402. return this.forEachFeatureInExtent(extent,
  27403. /**
  27404. * @param {import("../Feature.js").default<Geometry>} feature Feature.
  27405. * @return {T|undefined} The return value from the last call to the callback.
  27406. */
  27407. function (feature) {
  27408. var geometry = feature.getGeometry();
  27409. if (geometry.intersectsExtent(extent)) {
  27410. var result = callback(feature);
  27411. if (result) {
  27412. return result;
  27413. }
  27414. }
  27415. });
  27416. };
  27417. /**
  27418. * Get the features collection associated with this source. Will be `null`
  27419. * unless the source was configured with `useSpatialIndex` set to `false`, or
  27420. * with an {@link module:ol/Collection~Collection} as `features`.
  27421. * @return {Collection<import("../Feature.js").default<Geometry>>|null} The collection of features.
  27422. * @api
  27423. */
  27424. VectorSource.prototype.getFeaturesCollection = function () {
  27425. return this.featuresCollection_;
  27426. };
  27427. /**
  27428. * Get a snapshot of the features currently on the source in random order. The returned array
  27429. * is a copy, the features are references to the features in the source.
  27430. * @return {Array<import("../Feature.js").default<Geometry>>} Features.
  27431. * @api
  27432. */
  27433. VectorSource.prototype.getFeatures = function () {
  27434. var features;
  27435. if (this.featuresCollection_) {
  27436. features = this.featuresCollection_.getArray().slice(0);
  27437. }
  27438. else if (this.featuresRtree_) {
  27439. features = this.featuresRtree_.getAll();
  27440. if (!obj_isEmpty(this.nullGeometryFeatures_)) {
  27441. array_extend(features, getValues(this.nullGeometryFeatures_));
  27442. }
  27443. }
  27444. return /** @type {Array<import("../Feature.js").default<Geometry>>} */ (features);
  27445. };
  27446. /**
  27447. * Get all features whose geometry intersects the provided coordinate.
  27448. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  27449. * @return {Array<import("../Feature.js").default<Geometry>>} Features.
  27450. * @api
  27451. */
  27452. VectorSource.prototype.getFeaturesAtCoordinate = function (coordinate) {
  27453. var features = [];
  27454. this.forEachFeatureAtCoordinateDirect(coordinate, function (feature) {
  27455. features.push(feature);
  27456. });
  27457. return features;
  27458. };
  27459. /**
  27460. * Get all features whose bounding box intersects the provided extent. Note that this returns an array of
  27461. * all features intersecting the given extent in random order (so it may include
  27462. * features whose geometries do not intersect the extent).
  27463. *
  27464. * When `useSpatialIndex` is set to false, this method will return all
  27465. * features.
  27466. *
  27467. * @param {import("../extent.js").Extent} extent Extent.
  27468. * @param {import("../proj/Projection.js").default} [opt_projection] Include features
  27469. * where `extent` exceeds the x-axis bounds of `projection` and wraps around the world.
  27470. * @return {Array<import("../Feature.js").default<Geometry>>} Features.
  27471. * @api
  27472. */
  27473. VectorSource.prototype.getFeaturesInExtent = function (extent, opt_projection) {
  27474. var _this = this;
  27475. if (this.featuresRtree_) {
  27476. var multiWorld = opt_projection && opt_projection.canWrapX() && this.getWrapX();
  27477. if (!multiWorld) {
  27478. return this.featuresRtree_.getInExtent(extent);
  27479. }
  27480. var extents = wrapAndSliceX(extent, opt_projection);
  27481. return [].concat.apply([], extents.map(function (anExtent) { return _this.featuresRtree_.getInExtent(anExtent); }));
  27482. }
  27483. else if (this.featuresCollection_) {
  27484. return this.featuresCollection_.getArray().slice(0);
  27485. }
  27486. else {
  27487. return [];
  27488. }
  27489. };
  27490. /**
  27491. * Get the closest feature to the provided coordinate.
  27492. *
  27493. * This method is not available when the source is configured with
  27494. * `useSpatialIndex` set to `false`.
  27495. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  27496. * @param {function(import("../Feature.js").default<Geometry>):boolean} [opt_filter] Feature filter function.
  27497. * The filter function will receive one argument, the {@link module:ol/Feature~Feature feature}
  27498. * and it should return a boolean value. By default, no filtering is made.
  27499. * @return {import("../Feature.js").default<Geometry>} Closest feature.
  27500. * @api
  27501. */
  27502. VectorSource.prototype.getClosestFeatureToCoordinate = function (coordinate, opt_filter) {
  27503. // Find the closest feature using branch and bound. We start searching an
  27504. // infinite extent, and find the distance from the first feature found. This
  27505. // becomes the closest feature. We then compute a smaller extent which any
  27506. // closer feature must intersect. We continue searching with this smaller
  27507. // extent, trying to find a closer feature. Every time we find a closer
  27508. // feature, we update the extent being searched so that any even closer
  27509. // feature must intersect it. We continue until we run out of features.
  27510. var x = coordinate[0];
  27511. var y = coordinate[1];
  27512. var closestFeature = null;
  27513. var closestPoint = [NaN, NaN];
  27514. var minSquaredDistance = Infinity;
  27515. var extent = [-Infinity, -Infinity, Infinity, Infinity];
  27516. var filter = opt_filter ? opt_filter : TRUE;
  27517. this.featuresRtree_.forEachInExtent(extent,
  27518. /**
  27519. * @param {import("../Feature.js").default<Geometry>} feature Feature.
  27520. */
  27521. function (feature) {
  27522. if (filter(feature)) {
  27523. var geometry = feature.getGeometry();
  27524. var previousMinSquaredDistance = minSquaredDistance;
  27525. minSquaredDistance = geometry.closestPointXY(x, y, closestPoint, minSquaredDistance);
  27526. if (minSquaredDistance < previousMinSquaredDistance) {
  27527. closestFeature = feature;
  27528. // This is sneaky. Reduce the extent that it is currently being
  27529. // searched while the R-Tree traversal using this same extent object
  27530. // is still in progress. This is safe because the new extent is
  27531. // strictly contained by the old extent.
  27532. var minDistance = Math.sqrt(minSquaredDistance);
  27533. extent[0] = x - minDistance;
  27534. extent[1] = y - minDistance;
  27535. extent[2] = x + minDistance;
  27536. extent[3] = y + minDistance;
  27537. }
  27538. }
  27539. });
  27540. return closestFeature;
  27541. };
  27542. /**
  27543. * Get the extent of the features currently in the source.
  27544. *
  27545. * This method is not available when the source is configured with
  27546. * `useSpatialIndex` set to `false`.
  27547. * @param {import("../extent.js").Extent} [opt_extent] Destination extent. If provided, no new extent
  27548. * will be created. Instead, that extent's coordinates will be overwritten.
  27549. * @return {import("../extent.js").Extent} Extent.
  27550. * @api
  27551. */
  27552. VectorSource.prototype.getExtent = function (opt_extent) {
  27553. return this.featuresRtree_.getExtent(opt_extent);
  27554. };
  27555. /**
  27556. * Get a feature by its identifier (the value returned by feature.getId()).
  27557. * Note that the index treats string and numeric identifiers as the same. So
  27558. * `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.
  27559. *
  27560. * @param {string|number} id Feature identifier.
  27561. * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
  27562. * @api
  27563. */
  27564. VectorSource.prototype.getFeatureById = function (id) {
  27565. var feature = this.idIndex_[id.toString()];
  27566. return feature !== undefined ? feature : null;
  27567. };
  27568. /**
  27569. * Get a feature by its internal unique identifier (using `getUid`).
  27570. *
  27571. * @param {string} uid Feature identifier.
  27572. * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
  27573. */
  27574. VectorSource.prototype.getFeatureByUid = function (uid) {
  27575. var feature = this.uidIndex_[uid];
  27576. return feature !== undefined ? feature : null;
  27577. };
  27578. /**
  27579. * Get the format associated with this source.
  27580. *
  27581. * @return {import("../format/Feature.js").default|undefined} The feature format.
  27582. * @api
  27583. */
  27584. VectorSource.prototype.getFormat = function () {
  27585. return this.format_;
  27586. };
  27587. /**
  27588. * @return {boolean} The source can have overlapping geometries.
  27589. */
  27590. VectorSource.prototype.getOverlaps = function () {
  27591. return this.overlaps_;
  27592. };
  27593. /**
  27594. * Get the url associated with this source.
  27595. *
  27596. * @return {string|import("../featureloader.js").FeatureUrlFunction|undefined} The url.
  27597. * @api
  27598. */
  27599. VectorSource.prototype.getUrl = function () {
  27600. return this.url_;
  27601. };
  27602. /**
  27603. * @param {Event} event Event.
  27604. * @private
  27605. */
  27606. VectorSource.prototype.handleFeatureChange_ = function (event) {
  27607. var feature = /** @type {import("../Feature.js").default<Geometry>} */ (event.target);
  27608. var featureKey = getUid(feature);
  27609. var geometry = feature.getGeometry();
  27610. if (!geometry) {
  27611. if (!(featureKey in this.nullGeometryFeatures_)) {
  27612. if (this.featuresRtree_) {
  27613. this.featuresRtree_.remove(feature);
  27614. }
  27615. this.nullGeometryFeatures_[featureKey] = feature;
  27616. }
  27617. }
  27618. else {
  27619. var extent = geometry.getExtent();
  27620. if (featureKey in this.nullGeometryFeatures_) {
  27621. delete this.nullGeometryFeatures_[featureKey];
  27622. if (this.featuresRtree_) {
  27623. this.featuresRtree_.insert(extent, feature);
  27624. }
  27625. }
  27626. else {
  27627. if (this.featuresRtree_) {
  27628. this.featuresRtree_.update(extent, feature);
  27629. }
  27630. }
  27631. }
  27632. var id = feature.getId();
  27633. if (id !== undefined) {
  27634. var sid = id.toString();
  27635. if (this.idIndex_[sid] !== feature) {
  27636. this.removeFromIdIndex_(feature);
  27637. this.idIndex_[sid] = feature;
  27638. }
  27639. }
  27640. else {
  27641. this.removeFromIdIndex_(feature);
  27642. this.uidIndex_[featureKey] = feature;
  27643. }
  27644. this.changed();
  27645. this.dispatchEvent(new VectorSourceEvent(VectorEventType.CHANGEFEATURE, feature));
  27646. };
  27647. /**
  27648. * Returns true if the feature is contained within the source.
  27649. * @param {import("../Feature.js").default<Geometry>} feature Feature.
  27650. * @return {boolean} Has feature.
  27651. * @api
  27652. */
  27653. VectorSource.prototype.hasFeature = function (feature) {
  27654. var id = feature.getId();
  27655. if (id !== undefined) {
  27656. return id in this.idIndex_;
  27657. }
  27658. else {
  27659. return getUid(feature) in this.uidIndex_;
  27660. }
  27661. };
  27662. /**
  27663. * @return {boolean} Is empty.
  27664. */
  27665. VectorSource.prototype.isEmpty = function () {
  27666. if (this.featuresRtree_) {
  27667. return (this.featuresRtree_.isEmpty() && obj_isEmpty(this.nullGeometryFeatures_));
  27668. }
  27669. if (this.featuresCollection_) {
  27670. return this.featuresCollection_.getLength() === 0;
  27671. }
  27672. return true;
  27673. };
  27674. /**
  27675. * @param {import("../extent.js").Extent} extent Extent.
  27676. * @param {number} resolution Resolution.
  27677. * @param {import("../proj/Projection.js").default} projection Projection.
  27678. */
  27679. VectorSource.prototype.loadFeatures = function (extent, resolution, projection) {
  27680. var loadedExtentsRtree = this.loadedExtentsRtree_;
  27681. var extentsToLoad = this.strategy_(extent, resolution, projection);
  27682. var _loop_1 = function (i, ii) {
  27683. var extentToLoad = extentsToLoad[i];
  27684. var alreadyLoaded = loadedExtentsRtree.forEachInExtent(extentToLoad,
  27685. /**
  27686. * @param {{extent: import("../extent.js").Extent}} object Object.
  27687. * @return {boolean} Contains.
  27688. */
  27689. function (object) {
  27690. return containsExtent(object.extent, extentToLoad);
  27691. });
  27692. if (!alreadyLoaded) {
  27693. ++this_1.loadingExtentsCount_;
  27694. this_1.dispatchEvent(new VectorSourceEvent(VectorEventType.FEATURESLOADSTART));
  27695. this_1.loader_.call(this_1, extentToLoad, resolution, projection, function (features) {
  27696. --this.loadingExtentsCount_;
  27697. this.dispatchEvent(new VectorSourceEvent(VectorEventType.FEATURESLOADEND, undefined, features));
  27698. }.bind(this_1), function () {
  27699. --this.loadingExtentsCount_;
  27700. this.dispatchEvent(new VectorSourceEvent(VectorEventType.FEATURESLOADERROR));
  27701. }.bind(this_1));
  27702. loadedExtentsRtree.insert(extentToLoad, { extent: extentToLoad.slice() });
  27703. }
  27704. };
  27705. var this_1 = this;
  27706. for (var i = 0, ii = extentsToLoad.length; i < ii; ++i) {
  27707. _loop_1(i, ii);
  27708. }
  27709. this.loading =
  27710. this.loader_.length < 4 ? false : this.loadingExtentsCount_ > 0;
  27711. };
  27712. VectorSource.prototype.refresh = function () {
  27713. this.clear(true);
  27714. this.loadedExtentsRtree_.clear();
  27715. _super.prototype.refresh.call(this);
  27716. };
  27717. /**
  27718. * Remove an extent from the list of loaded extents.
  27719. * @param {import("../extent.js").Extent} extent Extent.
  27720. * @api
  27721. */
  27722. VectorSource.prototype.removeLoadedExtent = function (extent) {
  27723. var loadedExtentsRtree = this.loadedExtentsRtree_;
  27724. var obj;
  27725. loadedExtentsRtree.forEachInExtent(extent, function (object) {
  27726. if (extent_equals(object.extent, extent)) {
  27727. obj = object;
  27728. return true;
  27729. }
  27730. });
  27731. if (obj) {
  27732. loadedExtentsRtree.remove(obj);
  27733. }
  27734. };
  27735. /**
  27736. * Remove a single feature from the source. If you want to remove all features
  27737. * at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method
  27738. * instead.
  27739. * @param {import("../Feature.js").default<Geometry>} feature Feature to remove.
  27740. * @api
  27741. */
  27742. VectorSource.prototype.removeFeature = function (feature) {
  27743. if (!feature) {
  27744. return;
  27745. }
  27746. var featureKey = getUid(feature);
  27747. if (featureKey in this.nullGeometryFeatures_) {
  27748. delete this.nullGeometryFeatures_[featureKey];
  27749. }
  27750. else {
  27751. if (this.featuresRtree_) {
  27752. this.featuresRtree_.remove(feature);
  27753. }
  27754. }
  27755. var result = this.removeFeatureInternal(feature);
  27756. if (result) {
  27757. this.changed();
  27758. }
  27759. };
  27760. /**
  27761. * Remove feature without firing a `change` event.
  27762. * @param {import("../Feature.js").default<Geometry>} feature Feature.
  27763. * @return {import("../Feature.js").default<Geometry>|undefined} The removed feature
  27764. * (or undefined if the feature was not found).
  27765. * @protected
  27766. */
  27767. VectorSource.prototype.removeFeatureInternal = function (feature) {
  27768. var featureKey = getUid(feature);
  27769. var featureChangeKeys = this.featureChangeKeys_[featureKey];
  27770. if (!featureChangeKeys) {
  27771. return;
  27772. }
  27773. featureChangeKeys.forEach(unlistenByKey);
  27774. delete this.featureChangeKeys_[featureKey];
  27775. var id = feature.getId();
  27776. if (id !== undefined) {
  27777. delete this.idIndex_[id.toString()];
  27778. }
  27779. delete this.uidIndex_[featureKey];
  27780. this.dispatchEvent(new VectorSourceEvent(VectorEventType.REMOVEFEATURE, feature));
  27781. return feature;
  27782. };
  27783. /**
  27784. * Remove a feature from the id index. Called internally when the feature id
  27785. * may have changed.
  27786. * @param {import("../Feature.js").default<Geometry>} feature The feature.
  27787. * @return {boolean} Removed the feature from the index.
  27788. * @private
  27789. */
  27790. VectorSource.prototype.removeFromIdIndex_ = function (feature) {
  27791. var removed = false;
  27792. for (var id in this.idIndex_) {
  27793. if (this.idIndex_[id] === feature) {
  27794. delete this.idIndex_[id];
  27795. removed = true;
  27796. break;
  27797. }
  27798. }
  27799. return removed;
  27800. };
  27801. /**
  27802. * Set the new loader of the source. The next render cycle will use the
  27803. * new loader.
  27804. * @param {import("../featureloader.js").FeatureLoader} loader The loader to set.
  27805. * @api
  27806. */
  27807. VectorSource.prototype.setLoader = function (loader) {
  27808. this.loader_ = loader;
  27809. };
  27810. /**
  27811. * Points the source to a new url. The next render cycle will use the new url.
  27812. * @param {string|import("../featureloader.js").FeatureUrlFunction} url Url.
  27813. * @api
  27814. */
  27815. VectorSource.prototype.setUrl = function (url) {
  27816. asserts_assert(this.format_, 7); // `format` must be set when `url` is set
  27817. this.url_ = url;
  27818. this.setLoader(xhr(url, this.format_));
  27819. };
  27820. return VectorSource;
  27821. }(source_Source));
  27822. /* harmony default export */ var source_Vector = (VectorSource);
  27823. //# sourceMappingURL=Vector.js.map
  27824. ;// ./node_modules/ol/style/Text.js
  27825. /**
  27826. * @module ol/style/Text
  27827. */
  27828. /**
  27829. * The default fill color to use if no fill was set at construction time; a
  27830. * blackish `#333`.
  27831. *
  27832. * @const {string}
  27833. */
  27834. var DEFAULT_FILL_COLOR = '#333';
  27835. /**
  27836. * @typedef {Object} Options
  27837. * @property {string} [font] Font style as CSS 'font' value, see:
  27838. * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is '10px sans-serif'
  27839. * @property {number} [maxAngle=Math.PI/4] When `placement` is set to `'line'`, allow a maximum angle between adjacent characters.
  27840. * The expected value is in radians, and the default is 45° (`Math.PI / 4`).
  27841. * @property {number} [offsetX=0] Horizontal text offset in pixels. A positive will shift the text right.
  27842. * @property {number} [offsetY=0] Vertical text offset in pixels. A positive will shift the text down.
  27843. * @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
  27844. * the width of the polygon at the label position or the length of the path that it follows.
  27845. * @property {import("./TextPlacement.js").default|string} [placement='point'] Text placement.
  27846. * @property {number|import("../size.js").Size} [scale] Scale.
  27847. * @property {boolean} [rotateWithView=false] Whether to rotate the text with the view.
  27848. * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
  27849. * @property {string|Array<string>} [text] Text content or rich text content. For plain text provide a string, which can
  27850. * contain line breaks (`\n`). For rich text provide an array of text/font tuples. A tuple consists of the text to
  27851. * render and the font to use (or `''` to use the text style's font). A line break has to be a separate tuple (i.e. `'\n', ''`).
  27852. * **Example:** `['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']` will yield "**foo** *bar* baz".
  27853. * **Note:** Rich text is not supported for the immediate rendering API.
  27854. * @property {string} [textAlign] Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'.
  27855. * Default is 'center' for `placement: 'point'`. For `placement: 'line'`, the default is to let the renderer choose a
  27856. * placement where `maxAngle` is not exceeded.
  27857. * @property {string} [justify] Text justification within the text box.
  27858. * If not set, text is justified towards the `textAlign` anchor.
  27859. * Otherwise, use options `'left'`, `'center'`, or `'right'` to justify the text within the text box.
  27860. * **Note:** `justify` is ignored for immediate rendering and also for `placement: 'line'`.
  27861. * @property {string} [textBaseline='middle'] Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic',
  27862. * 'hanging', 'ideographic'.
  27863. * @property {import("./Fill.js").default} [fill] Fill style. If none is provided, we'll use a dark fill-style (#333).
  27864. * @property {import("./Stroke.js").default} [stroke] Stroke style.
  27865. * @property {import("./Fill.js").default} [backgroundFill] Fill style for the text background when `placement` is
  27866. * `'point'`. Default is no fill.
  27867. * @property {import("./Stroke.js").default} [backgroundStroke] Stroke style for the text background when `placement`
  27868. * is `'point'`. Default is no stroke.
  27869. * @property {Array<number>} [padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of
  27870. * values in the array is `[top, right, bottom, left]`.
  27871. */
  27872. /**
  27873. * @classdesc
  27874. * Set text style for vector features.
  27875. * @api
  27876. */
  27877. var Text = /** @class */ (function () {
  27878. /**
  27879. * @param {Options} [opt_options] Options.
  27880. */
  27881. function Text(opt_options) {
  27882. var options = opt_options || {};
  27883. /**
  27884. * @private
  27885. * @type {string|undefined}
  27886. */
  27887. this.font_ = options.font;
  27888. /**
  27889. * @private
  27890. * @type {number|undefined}
  27891. */
  27892. this.rotation_ = options.rotation;
  27893. /**
  27894. * @private
  27895. * @type {boolean|undefined}
  27896. */
  27897. this.rotateWithView_ = options.rotateWithView;
  27898. /**
  27899. * @private
  27900. * @type {number|import("../size.js").Size|undefined}
  27901. */
  27902. this.scale_ = options.scale;
  27903. /**
  27904. * @private
  27905. * @type {import("../size.js").Size}
  27906. */
  27907. this.scaleArray_ = toSize(options.scale !== undefined ? options.scale : 1);
  27908. /**
  27909. * @private
  27910. * @type {string|Array<string>|undefined}
  27911. */
  27912. this.text_ = options.text;
  27913. /**
  27914. * @private
  27915. * @type {string|undefined}
  27916. */
  27917. this.textAlign_ = options.textAlign;
  27918. /**
  27919. * @private
  27920. * @type {string|undefined}
  27921. */
  27922. this.justify_ = options.justify;
  27923. /**
  27924. * @private
  27925. * @type {string|undefined}
  27926. */
  27927. this.textBaseline_ = options.textBaseline;
  27928. /**
  27929. * @private
  27930. * @type {import("./Fill.js").default}
  27931. */
  27932. this.fill_ =
  27933. options.fill !== undefined
  27934. ? options.fill
  27935. : new style_Fill({ color: DEFAULT_FILL_COLOR });
  27936. /**
  27937. * @private
  27938. * @type {number}
  27939. */
  27940. this.maxAngle_ =
  27941. options.maxAngle !== undefined ? options.maxAngle : Math.PI / 4;
  27942. /**
  27943. * @private
  27944. * @type {import("./TextPlacement.js").default|string}
  27945. */
  27946. this.placement_ =
  27947. options.placement !== undefined ? options.placement : TextPlacement.POINT;
  27948. /**
  27949. * @private
  27950. * @type {boolean}
  27951. */
  27952. this.overflow_ = !!options.overflow;
  27953. /**
  27954. * @private
  27955. * @type {import("./Stroke.js").default}
  27956. */
  27957. this.stroke_ = options.stroke !== undefined ? options.stroke : null;
  27958. /**
  27959. * @private
  27960. * @type {number}
  27961. */
  27962. this.offsetX_ = options.offsetX !== undefined ? options.offsetX : 0;
  27963. /**
  27964. * @private
  27965. * @type {number}
  27966. */
  27967. this.offsetY_ = options.offsetY !== undefined ? options.offsetY : 0;
  27968. /**
  27969. * @private
  27970. * @type {import("./Fill.js").default}
  27971. */
  27972. this.backgroundFill_ = options.backgroundFill
  27973. ? options.backgroundFill
  27974. : null;
  27975. /**
  27976. * @private
  27977. * @type {import("./Stroke.js").default}
  27978. */
  27979. this.backgroundStroke_ = options.backgroundStroke
  27980. ? options.backgroundStroke
  27981. : null;
  27982. /**
  27983. * @private
  27984. * @type {Array<number>|null}
  27985. */
  27986. this.padding_ = options.padding === undefined ? null : options.padding;
  27987. }
  27988. /**
  27989. * Clones the style.
  27990. * @return {Text} The cloned style.
  27991. * @api
  27992. */
  27993. Text.prototype.clone = function () {
  27994. var scale = this.getScale();
  27995. return new Text({
  27996. font: this.getFont(),
  27997. placement: this.getPlacement(),
  27998. maxAngle: this.getMaxAngle(),
  27999. overflow: this.getOverflow(),
  28000. rotation: this.getRotation(),
  28001. rotateWithView: this.getRotateWithView(),
  28002. scale: Array.isArray(scale) ? scale.slice() : scale,
  28003. text: this.getText(),
  28004. textAlign: this.getTextAlign(),
  28005. justify: this.getJustify(),
  28006. textBaseline: this.getTextBaseline(),
  28007. fill: this.getFill() ? this.getFill().clone() : undefined,
  28008. stroke: this.getStroke() ? this.getStroke().clone() : undefined,
  28009. offsetX: this.getOffsetX(),
  28010. offsetY: this.getOffsetY(),
  28011. backgroundFill: this.getBackgroundFill()
  28012. ? this.getBackgroundFill().clone()
  28013. : undefined,
  28014. backgroundStroke: this.getBackgroundStroke()
  28015. ? this.getBackgroundStroke().clone()
  28016. : undefined,
  28017. padding: this.getPadding() || undefined,
  28018. });
  28019. };
  28020. /**
  28021. * Get the `overflow` configuration.
  28022. * @return {boolean} Let text overflow the length of the path they follow.
  28023. * @api
  28024. */
  28025. Text.prototype.getOverflow = function () {
  28026. return this.overflow_;
  28027. };
  28028. /**
  28029. * Get the font name.
  28030. * @return {string|undefined} Font.
  28031. * @api
  28032. */
  28033. Text.prototype.getFont = function () {
  28034. return this.font_;
  28035. };
  28036. /**
  28037. * Get the maximum angle between adjacent characters.
  28038. * @return {number} Angle in radians.
  28039. * @api
  28040. */
  28041. Text.prototype.getMaxAngle = function () {
  28042. return this.maxAngle_;
  28043. };
  28044. /**
  28045. * Get the label placement.
  28046. * @return {import("./TextPlacement.js").default|string} Text placement.
  28047. * @api
  28048. */
  28049. Text.prototype.getPlacement = function () {
  28050. return this.placement_;
  28051. };
  28052. /**
  28053. * Get the x-offset for the text.
  28054. * @return {number} Horizontal text offset.
  28055. * @api
  28056. */
  28057. Text.prototype.getOffsetX = function () {
  28058. return this.offsetX_;
  28059. };
  28060. /**
  28061. * Get the y-offset for the text.
  28062. * @return {number} Vertical text offset.
  28063. * @api
  28064. */
  28065. Text.prototype.getOffsetY = function () {
  28066. return this.offsetY_;
  28067. };
  28068. /**
  28069. * Get the fill style for the text.
  28070. * @return {import("./Fill.js").default} Fill style.
  28071. * @api
  28072. */
  28073. Text.prototype.getFill = function () {
  28074. return this.fill_;
  28075. };
  28076. /**
  28077. * Determine whether the text rotates with the map.
  28078. * @return {boolean|undefined} Rotate with map.
  28079. * @api
  28080. */
  28081. Text.prototype.getRotateWithView = function () {
  28082. return this.rotateWithView_;
  28083. };
  28084. /**
  28085. * Get the text rotation.
  28086. * @return {number|undefined} Rotation.
  28087. * @api
  28088. */
  28089. Text.prototype.getRotation = function () {
  28090. return this.rotation_;
  28091. };
  28092. /**
  28093. * Get the text scale.
  28094. * @return {number|import("../size.js").Size|undefined} Scale.
  28095. * @api
  28096. */
  28097. Text.prototype.getScale = function () {
  28098. return this.scale_;
  28099. };
  28100. /**
  28101. * Get the symbolizer scale array.
  28102. * @return {import("../size.js").Size} Scale array.
  28103. */
  28104. Text.prototype.getScaleArray = function () {
  28105. return this.scaleArray_;
  28106. };
  28107. /**
  28108. * Get the stroke style for the text.
  28109. * @return {import("./Stroke.js").default} Stroke style.
  28110. * @api
  28111. */
  28112. Text.prototype.getStroke = function () {
  28113. return this.stroke_;
  28114. };
  28115. /**
  28116. * Get the text to be rendered.
  28117. * @return {string|Array<string>|undefined} Text.
  28118. * @api
  28119. */
  28120. Text.prototype.getText = function () {
  28121. return this.text_;
  28122. };
  28123. /**
  28124. * Get the text alignment.
  28125. * @return {string|undefined} Text align.
  28126. * @api
  28127. */
  28128. Text.prototype.getTextAlign = function () {
  28129. return this.textAlign_;
  28130. };
  28131. /**
  28132. * Get the justification.
  28133. * @return {string|undefined} Justification.
  28134. * @api
  28135. */
  28136. Text.prototype.getJustify = function () {
  28137. return this.justify_;
  28138. };
  28139. /**
  28140. * Get the text baseline.
  28141. * @return {string|undefined} Text baseline.
  28142. * @api
  28143. */
  28144. Text.prototype.getTextBaseline = function () {
  28145. return this.textBaseline_;
  28146. };
  28147. /**
  28148. * Get the background fill style for the text.
  28149. * @return {import("./Fill.js").default} Fill style.
  28150. * @api
  28151. */
  28152. Text.prototype.getBackgroundFill = function () {
  28153. return this.backgroundFill_;
  28154. };
  28155. /**
  28156. * Get the background stroke style for the text.
  28157. * @return {import("./Stroke.js").default} Stroke style.
  28158. * @api
  28159. */
  28160. Text.prototype.getBackgroundStroke = function () {
  28161. return this.backgroundStroke_;
  28162. };
  28163. /**
  28164. * Get the padding for the text.
  28165. * @return {Array<number>|null} Padding.
  28166. * @api
  28167. */
  28168. Text.prototype.getPadding = function () {
  28169. return this.padding_;
  28170. };
  28171. /**
  28172. * Set the `overflow` property.
  28173. *
  28174. * @param {boolean} overflow Let text overflow the path that it follows.
  28175. * @api
  28176. */
  28177. Text.prototype.setOverflow = function (overflow) {
  28178. this.overflow_ = overflow;
  28179. };
  28180. /**
  28181. * Set the font.
  28182. *
  28183. * @param {string|undefined} font Font.
  28184. * @api
  28185. */
  28186. Text.prototype.setFont = function (font) {
  28187. this.font_ = font;
  28188. };
  28189. /**
  28190. * Set the maximum angle between adjacent characters.
  28191. *
  28192. * @param {number} maxAngle Angle in radians.
  28193. * @api
  28194. */
  28195. Text.prototype.setMaxAngle = function (maxAngle) {
  28196. this.maxAngle_ = maxAngle;
  28197. };
  28198. /**
  28199. * Set the x offset.
  28200. *
  28201. * @param {number} offsetX Horizontal text offset.
  28202. * @api
  28203. */
  28204. Text.prototype.setOffsetX = function (offsetX) {
  28205. this.offsetX_ = offsetX;
  28206. };
  28207. /**
  28208. * Set the y offset.
  28209. *
  28210. * @param {number} offsetY Vertical text offset.
  28211. * @api
  28212. */
  28213. Text.prototype.setOffsetY = function (offsetY) {
  28214. this.offsetY_ = offsetY;
  28215. };
  28216. /**
  28217. * Set the text placement.
  28218. *
  28219. * @param {import("./TextPlacement.js").default|string} placement Placement.
  28220. * @api
  28221. */
  28222. Text.prototype.setPlacement = function (placement) {
  28223. this.placement_ = placement;
  28224. };
  28225. /**
  28226. * Set whether to rotate the text with the view.
  28227. *
  28228. * @param {boolean} rotateWithView Rotate with map.
  28229. * @api
  28230. */
  28231. Text.prototype.setRotateWithView = function (rotateWithView) {
  28232. this.rotateWithView_ = rotateWithView;
  28233. };
  28234. /**
  28235. * Set the fill.
  28236. *
  28237. * @param {import("./Fill.js").default} fill Fill style.
  28238. * @api
  28239. */
  28240. Text.prototype.setFill = function (fill) {
  28241. this.fill_ = fill;
  28242. };
  28243. /**
  28244. * Set the rotation.
  28245. *
  28246. * @param {number|undefined} rotation Rotation.
  28247. * @api
  28248. */
  28249. Text.prototype.setRotation = function (rotation) {
  28250. this.rotation_ = rotation;
  28251. };
  28252. /**
  28253. * Set the scale.
  28254. *
  28255. * @param {number|import("../size.js").Size|undefined} scale Scale.
  28256. * @api
  28257. */
  28258. Text.prototype.setScale = function (scale) {
  28259. this.scale_ = scale;
  28260. this.scaleArray_ = toSize(scale !== undefined ? scale : 1);
  28261. };
  28262. /**
  28263. * Set the stroke.
  28264. *
  28265. * @param {import("./Stroke.js").default} stroke Stroke style.
  28266. * @api
  28267. */
  28268. Text.prototype.setStroke = function (stroke) {
  28269. this.stroke_ = stroke;
  28270. };
  28271. /**
  28272. * Set the text.
  28273. *
  28274. * @param {string|Array<string>|undefined} text Text.
  28275. * @api
  28276. */
  28277. Text.prototype.setText = function (text) {
  28278. this.text_ = text;
  28279. };
  28280. /**
  28281. * Set the text alignment.
  28282. *
  28283. * @param {string|undefined} textAlign Text align.
  28284. * @api
  28285. */
  28286. Text.prototype.setTextAlign = function (textAlign) {
  28287. this.textAlign_ = textAlign;
  28288. };
  28289. /**
  28290. * Set the justification.
  28291. *
  28292. * @param {string|undefined} justify Justification.
  28293. * @api
  28294. */
  28295. Text.prototype.setJustify = function (justify) {
  28296. this.justify_ = justify;
  28297. };
  28298. /**
  28299. * Set the text baseline.
  28300. *
  28301. * @param {string|undefined} textBaseline Text baseline.
  28302. * @api
  28303. */
  28304. Text.prototype.setTextBaseline = function (textBaseline) {
  28305. this.textBaseline_ = textBaseline;
  28306. };
  28307. /**
  28308. * Set the background fill.
  28309. *
  28310. * @param {import("./Fill.js").default} fill Fill style.
  28311. * @api
  28312. */
  28313. Text.prototype.setBackgroundFill = function (fill) {
  28314. this.backgroundFill_ = fill;
  28315. };
  28316. /**
  28317. * Set the background stroke.
  28318. *
  28319. * @param {import("./Stroke.js").default} stroke Stroke style.
  28320. * @api
  28321. */
  28322. Text.prototype.setBackgroundStroke = function (stroke) {
  28323. this.backgroundStroke_ = stroke;
  28324. };
  28325. /**
  28326. * Set the padding (`[top, right, bottom, left]`).
  28327. *
  28328. * @param {Array<number>|null} padding Padding.
  28329. * @api
  28330. */
  28331. Text.prototype.setPadding = function (padding) {
  28332. this.padding_ = padding;
  28333. };
  28334. return Text;
  28335. }());
  28336. /* harmony default export */ var style_Text = (Text);
  28337. //# sourceMappingURL=Text.js.map
  28338. ;// ./node_modules/ol/Feature.js
  28339. var Feature_extends = (undefined && undefined.__extends) || (function () {
  28340. var extendStatics = function (d, b) {
  28341. extendStatics = Object.setPrototypeOf ||
  28342. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  28343. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  28344. return extendStatics(d, b);
  28345. };
  28346. return function (d, b) {
  28347. if (typeof b !== "function" && b !== null)
  28348. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  28349. extendStatics(d, b);
  28350. function __() { this.constructor = d; }
  28351. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28352. };
  28353. })();
  28354. /**
  28355. * @module ol/Feature
  28356. */
  28357. /**
  28358. * @typedef {typeof Feature|typeof import("./render/Feature.js").default} FeatureClass
  28359. */
  28360. /**
  28361. * @typedef {Feature|import("./render/Feature.js").default} FeatureLike
  28362. */
  28363. /***
  28364. * @template Return
  28365. * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
  28366. * import("./Observable").OnSignature<import("./ObjectEventType").Types|'change:geometry', import("./Object").ObjectEvent, Return> &
  28367. * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|import("./ObjectEventType").Types
  28368. * |'change:geometry', Return>} FeatureOnSignature
  28369. */
  28370. /***
  28371. * @template Geometry
  28372. * @typedef {Object<string, *> & { geometry?: Geometry }} ObjectWithGeometry
  28373. */
  28374. /**
  28375. * @classdesc
  28376. * A vector object for geographic features with a geometry and other
  28377. * attribute properties, similar to the features in vector file formats like
  28378. * GeoJSON.
  28379. *
  28380. * Features can be styled individually with `setStyle`; otherwise they use the
  28381. * style of their vector layer.
  28382. *
  28383. * Note that attribute properties are set as {@link module:ol/Object~BaseObject} properties on
  28384. * the feature object, so they are observable, and have get/set accessors.
  28385. *
  28386. * Typically, a feature has a single geometry property. You can set the
  28387. * geometry using the `setGeometry` method and get it with `getGeometry`.
  28388. * It is possible to store more than one geometry on a feature using attribute
  28389. * properties. By default, the geometry used for rendering is identified by
  28390. * the property name `geometry`. If you want to use another geometry property
  28391. * for rendering, use the `setGeometryName` method to change the attribute
  28392. * property associated with the geometry for the feature. For example:
  28393. *
  28394. * ```js
  28395. *
  28396. * import Feature from 'ol/Feature';
  28397. * import Polygon from 'ol/geom/Polygon';
  28398. * import Point from 'ol/geom/Point';
  28399. *
  28400. * var feature = new Feature({
  28401. * geometry: new Polygon(polyCoords),
  28402. * labelPoint: new Point(labelCoords),
  28403. * name: 'My Polygon'
  28404. * });
  28405. *
  28406. * // get the polygon geometry
  28407. * var poly = feature.getGeometry();
  28408. *
  28409. * // Render the feature as a point using the coordinates from labelPoint
  28410. * feature.setGeometryName('labelPoint');
  28411. *
  28412. * // get the point geometry
  28413. * var point = feature.getGeometry();
  28414. * ```
  28415. *
  28416. * @api
  28417. * @template {import("./geom/Geometry.js").default} [Geometry=import("./geom/Geometry.js").default]
  28418. */
  28419. var Feature = /** @class */ (function (_super) {
  28420. Feature_extends(Feature, _super);
  28421. /**
  28422. * @param {Geometry|ObjectWithGeometry<Geometry>} [opt_geometryOrProperties]
  28423. * You may pass a Geometry object directly, or an object literal containing
  28424. * properties. If you pass an object literal, you may include a Geometry
  28425. * associated with a `geometry` key.
  28426. */
  28427. function Feature(opt_geometryOrProperties) {
  28428. var _this = _super.call(this) || this;
  28429. /***
  28430. * @type {FeatureOnSignature<import("./events").EventsKey>}
  28431. */
  28432. _this.on;
  28433. /***
  28434. * @type {FeatureOnSignature<import("./events").EventsKey>}
  28435. */
  28436. _this.once;
  28437. /***
  28438. * @type {FeatureOnSignature<void>}
  28439. */
  28440. _this.un;
  28441. /**
  28442. * @private
  28443. * @type {number|string|undefined}
  28444. */
  28445. _this.id_ = undefined;
  28446. /**
  28447. * @type {string}
  28448. * @private
  28449. */
  28450. _this.geometryName_ = 'geometry';
  28451. /**
  28452. * User provided style.
  28453. * @private
  28454. * @type {import("./style/Style.js").StyleLike}
  28455. */
  28456. _this.style_ = null;
  28457. /**
  28458. * @private
  28459. * @type {import("./style/Style.js").StyleFunction|undefined}
  28460. */
  28461. _this.styleFunction_ = undefined;
  28462. /**
  28463. * @private
  28464. * @type {?import("./events.js").EventsKey}
  28465. */
  28466. _this.geometryChangeKey_ = null;
  28467. _this.addChangeListener(_this.geometryName_, _this.handleGeometryChanged_);
  28468. if (opt_geometryOrProperties) {
  28469. if (typeof (
  28470. /** @type {?} */ (opt_geometryOrProperties).getSimplifiedGeometry) === 'function') {
  28471. var geometry = /** @type {Geometry} */ (opt_geometryOrProperties);
  28472. _this.setGeometry(geometry);
  28473. }
  28474. else {
  28475. /** @type {Object<string, *>} */
  28476. var properties = opt_geometryOrProperties;
  28477. _this.setProperties(properties);
  28478. }
  28479. }
  28480. return _this;
  28481. }
  28482. /**
  28483. * Clone this feature. If the original feature has a geometry it
  28484. * is also cloned. The feature id is not set in the clone.
  28485. * @return {Feature<Geometry>} The clone.
  28486. * @api
  28487. */
  28488. Feature.prototype.clone = function () {
  28489. var clone = /** @type {Feature<Geometry>} */ (new Feature(this.hasProperties() ? this.getProperties() : null));
  28490. clone.setGeometryName(this.getGeometryName());
  28491. var geometry = this.getGeometry();
  28492. if (geometry) {
  28493. clone.setGeometry(/** @type {Geometry} */ (geometry.clone()));
  28494. }
  28495. var style = this.getStyle();
  28496. if (style) {
  28497. clone.setStyle(style);
  28498. }
  28499. return clone;
  28500. };
  28501. /**
  28502. * Get the feature's default geometry. A feature may have any number of named
  28503. * geometries. The "default" geometry (the one that is rendered by default) is
  28504. * set when calling {@link module:ol/Feature~Feature#setGeometry}.
  28505. * @return {Geometry|undefined} The default geometry for the feature.
  28506. * @api
  28507. * @observable
  28508. */
  28509. Feature.prototype.getGeometry = function () {
  28510. return /** @type {Geometry|undefined} */ (this.get(this.geometryName_));
  28511. };
  28512. /**
  28513. * Get the feature identifier. This is a stable identifier for the feature and
  28514. * is either set when reading data from a remote source or set explicitly by
  28515. * calling {@link module:ol/Feature~Feature#setId}.
  28516. * @return {number|string|undefined} Id.
  28517. * @api
  28518. */
  28519. Feature.prototype.getId = function () {
  28520. return this.id_;
  28521. };
  28522. /**
  28523. * Get the name of the feature's default geometry. By default, the default
  28524. * geometry is named `geometry`.
  28525. * @return {string} Get the property name associated with the default geometry
  28526. * for this feature.
  28527. * @api
  28528. */
  28529. Feature.prototype.getGeometryName = function () {
  28530. return this.geometryName_;
  28531. };
  28532. /**
  28533. * Get the feature's style. Will return what was provided to the
  28534. * {@link module:ol/Feature~Feature#setStyle} method.
  28535. * @return {import("./style/Style.js").StyleLike|undefined} The feature style.
  28536. * @api
  28537. */
  28538. Feature.prototype.getStyle = function () {
  28539. return this.style_;
  28540. };
  28541. /**
  28542. * Get the feature's style function.
  28543. * @return {import("./style/Style.js").StyleFunction|undefined} Return a function
  28544. * representing the current style of this feature.
  28545. * @api
  28546. */
  28547. Feature.prototype.getStyleFunction = function () {
  28548. return this.styleFunction_;
  28549. };
  28550. /**
  28551. * @private
  28552. */
  28553. Feature.prototype.handleGeometryChange_ = function () {
  28554. this.changed();
  28555. };
  28556. /**
  28557. * @private
  28558. */
  28559. Feature.prototype.handleGeometryChanged_ = function () {
  28560. if (this.geometryChangeKey_) {
  28561. unlistenByKey(this.geometryChangeKey_);
  28562. this.geometryChangeKey_ = null;
  28563. }
  28564. var geometry = this.getGeometry();
  28565. if (geometry) {
  28566. this.geometryChangeKey_ = listen(geometry, EventType.CHANGE, this.handleGeometryChange_, this);
  28567. }
  28568. this.changed();
  28569. };
  28570. /**
  28571. * Set the default geometry for the feature. This will update the property
  28572. * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.
  28573. * @param {Geometry|undefined} geometry The new geometry.
  28574. * @api
  28575. * @observable
  28576. */
  28577. Feature.prototype.setGeometry = function (geometry) {
  28578. this.set(this.geometryName_, geometry);
  28579. };
  28580. /**
  28581. * Set the style for the feature to override the layer style. This can be a
  28582. * single style object, an array of styles, or a function that takes a
  28583. * resolution and returns an array of styles. To unset the feature style, call
  28584. * `setStyle()` without arguments or a falsey value.
  28585. * @param {import("./style/Style.js").StyleLike} [opt_style] Style for this feature.
  28586. * @api
  28587. * @fires module:ol/events/Event~BaseEvent#event:change
  28588. */
  28589. Feature.prototype.setStyle = function (opt_style) {
  28590. this.style_ = opt_style;
  28591. this.styleFunction_ = !opt_style
  28592. ? undefined
  28593. : createStyleFunction(opt_style);
  28594. this.changed();
  28595. };
  28596. /**
  28597. * Set the feature id. The feature id is considered stable and may be used when
  28598. * requesting features or comparing identifiers returned from a remote source.
  28599. * The feature id can be used with the
  28600. * {@link module:ol/source/Vector~VectorSource#getFeatureById} method.
  28601. * @param {number|string|undefined} id The feature id.
  28602. * @api
  28603. * @fires module:ol/events/Event~BaseEvent#event:change
  28604. */
  28605. Feature.prototype.setId = function (id) {
  28606. this.id_ = id;
  28607. this.changed();
  28608. };
  28609. /**
  28610. * Set the property name to be used when getting the feature's default geometry.
  28611. * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with
  28612. * this name will be returned.
  28613. * @param {string} name The property name of the default geometry.
  28614. * @api
  28615. */
  28616. Feature.prototype.setGeometryName = function (name) {
  28617. this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_);
  28618. this.geometryName_ = name;
  28619. this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);
  28620. this.handleGeometryChanged_();
  28621. };
  28622. return Feature;
  28623. }(ol_Object));
  28624. /**
  28625. * Convert the provided object into a feature style function. Functions passed
  28626. * through unchanged. Arrays of Style or single style objects wrapped
  28627. * in a new feature style function.
  28628. * @param {!import("./style/Style.js").StyleFunction|!Array<import("./style/Style.js").default>|!import("./style/Style.js").default} obj
  28629. * A feature style function, a single style, or an array of styles.
  28630. * @return {import("./style/Style.js").StyleFunction} A style function.
  28631. */
  28632. function createStyleFunction(obj) {
  28633. if (typeof obj === 'function') {
  28634. return obj;
  28635. }
  28636. else {
  28637. /**
  28638. * @type {Array<import("./style/Style.js").default>}
  28639. */
  28640. var styles_1;
  28641. if (Array.isArray(obj)) {
  28642. styles_1 = obj;
  28643. }
  28644. else {
  28645. asserts_assert(typeof ( /** @type {?} */(obj).getZIndex) === 'function', 41); // Expected an `import("./style/Style.js").Style` or an array of `import("./style/Style.js").Style`
  28646. var style = /** @type {import("./style/Style.js").default} */ (obj);
  28647. styles_1 = [style];
  28648. }
  28649. return function () {
  28650. return styles_1;
  28651. };
  28652. }
  28653. }
  28654. /* harmony default export */ var ol_Feature = (Feature);
  28655. //# sourceMappingURL=Feature.js.map
  28656. ;// ./node_modules/ol/renderer/Map.js
  28657. var Map_extends = (undefined && undefined.__extends) || (function () {
  28658. var extendStatics = function (d, b) {
  28659. extendStatics = Object.setPrototypeOf ||
  28660. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  28661. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  28662. return extendStatics(d, b);
  28663. };
  28664. return function (d, b) {
  28665. if (typeof b !== "function" && b !== null)
  28666. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  28667. extendStatics(d, b);
  28668. function __() { this.constructor = d; }
  28669. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28670. };
  28671. })();
  28672. /**
  28673. * @module ol/renderer/Map
  28674. */
  28675. /**
  28676. * @typedef HitMatch
  28677. * @property {import("../Feature.js").FeatureLike} feature Feature.
  28678. * @property {import("../layer/Layer.js").default} layer Layer.
  28679. * @property {import("../geom/SimpleGeometry.js").default} geometry Geometry.
  28680. * @property {number} distanceSq Squared distance.
  28681. * @property {import("./vector.js").FeatureCallback<T>} callback Callback.
  28682. * @template T
  28683. */
  28684. /**
  28685. * @abstract
  28686. */
  28687. var MapRenderer = /** @class */ (function (_super) {
  28688. Map_extends(MapRenderer, _super);
  28689. /**
  28690. * @param {import("../PluggableMap.js").default} map Map.
  28691. */
  28692. function MapRenderer(map) {
  28693. var _this = _super.call(this) || this;
  28694. /**
  28695. * @private
  28696. * @type {import("../PluggableMap.js").default}
  28697. */
  28698. _this.map_ = map;
  28699. return _this;
  28700. }
  28701. /**
  28702. * @abstract
  28703. * @param {import("../render/EventType.js").default} type Event type.
  28704. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  28705. */
  28706. MapRenderer.prototype.dispatchRenderEvent = function (type, frameState) {
  28707. util_abstract();
  28708. };
  28709. /**
  28710. * @param {import("../PluggableMap.js").FrameState} frameState FrameState.
  28711. * @protected
  28712. */
  28713. MapRenderer.prototype.calculateMatrices2D = function (frameState) {
  28714. var viewState = frameState.viewState;
  28715. var coordinateToPixelTransform = frameState.coordinateToPixelTransform;
  28716. var pixelToCoordinateTransform = frameState.pixelToCoordinateTransform;
  28717. compose(coordinateToPixelTransform, frameState.size[0] / 2, frameState.size[1] / 2, 1 / viewState.resolution, -1 / viewState.resolution, -viewState.rotation, -viewState.center[0], -viewState.center[1]);
  28718. makeInverse(pixelToCoordinateTransform, coordinateToPixelTransform);
  28719. };
  28720. /**
  28721. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  28722. * @param {import("../PluggableMap.js").FrameState} frameState FrameState.
  28723. * @param {number} hitTolerance Hit tolerance in pixels.
  28724. * @param {boolean} checkWrapped Check for wrapped geometries.
  28725. * @param {import("./vector.js").FeatureCallback<T>} callback Feature callback.
  28726. * @param {S} thisArg Value to use as `this` when executing `callback`.
  28727. * @param {function(this: U, import("../layer/Layer.js").default): boolean} layerFilter Layer filter
  28728. * function, only layers which are visible and for which this function
  28729. * returns `true` will be tested for features. By default, all visible
  28730. * layers will be tested.
  28731. * @param {U} thisArg2 Value to use as `this` when executing `layerFilter`.
  28732. * @return {T|undefined} Callback result.
  28733. * @template S,T,U
  28734. */
  28735. MapRenderer.prototype.forEachFeatureAtCoordinate = function (coordinate, frameState, hitTolerance, checkWrapped, callback, thisArg, layerFilter, thisArg2) {
  28736. var result;
  28737. var viewState = frameState.viewState;
  28738. /**
  28739. * @param {boolean} managed Managed layer.
  28740. * @param {import("../Feature.js").FeatureLike} feature Feature.
  28741. * @param {import("../layer/Layer.js").default} layer Layer.
  28742. * @param {import("../geom/Geometry.js").default} geometry Geometry.
  28743. * @return {T|undefined} Callback result.
  28744. */
  28745. function forEachFeatureAtCoordinate(managed, feature, layer, geometry) {
  28746. return callback.call(thisArg, feature, managed ? layer : null, geometry);
  28747. }
  28748. var projection = viewState.projection;
  28749. var translatedCoordinate = coordinate_wrapX(coordinate.slice(), projection);
  28750. var offsets = [[0, 0]];
  28751. if (projection.canWrapX() && checkWrapped) {
  28752. var projectionExtent = projection.getExtent();
  28753. var worldWidth = extent_getWidth(projectionExtent);
  28754. offsets.push([-worldWidth, 0], [worldWidth, 0]);
  28755. }
  28756. var layerStates = frameState.layerStatesArray;
  28757. var numLayers = layerStates.length;
  28758. var matches = /** @type {Array<HitMatch<T>>} */ ([]);
  28759. var tmpCoord = [];
  28760. for (var i = 0; i < offsets.length; i++) {
  28761. for (var j = numLayers - 1; j >= 0; --j) {
  28762. var layerState = layerStates[j];
  28763. var layer = layerState.layer;
  28764. if (layer.hasRenderer() &&
  28765. inView(layerState, viewState) &&
  28766. layerFilter.call(thisArg2, layer)) {
  28767. var layerRenderer = layer.getRenderer();
  28768. var source = layer.getSource();
  28769. if (layerRenderer && source) {
  28770. var coordinates = source.getWrapX()
  28771. ? translatedCoordinate
  28772. : coordinate;
  28773. var callback_1 = forEachFeatureAtCoordinate.bind(null, layerState.managed);
  28774. tmpCoord[0] = coordinates[0] + offsets[i][0];
  28775. tmpCoord[1] = coordinates[1] + offsets[i][1];
  28776. result = layerRenderer.forEachFeatureAtCoordinate(tmpCoord, frameState, hitTolerance, callback_1, matches);
  28777. }
  28778. if (result) {
  28779. return result;
  28780. }
  28781. }
  28782. }
  28783. }
  28784. if (matches.length === 0) {
  28785. return undefined;
  28786. }
  28787. var order = 1 / matches.length;
  28788. matches.forEach(function (m, i) { return (m.distanceSq += i * order); });
  28789. matches.sort(function (a, b) { return a.distanceSq - b.distanceSq; });
  28790. matches.some(function (m) {
  28791. return (result = m.callback(m.feature, m.layer, m.geometry));
  28792. });
  28793. return result;
  28794. };
  28795. /**
  28796. * @abstract
  28797. * @param {import("../pixel.js").Pixel} pixel Pixel.
  28798. * @param {import("../PluggableMap.js").FrameState} frameState FrameState.
  28799. * @param {number} hitTolerance Hit tolerance in pixels.
  28800. * @param {function(import("../layer/Layer.js").default<import("../source/Source").default>, (Uint8ClampedArray|Uint8Array)): T} callback Layer
  28801. * callback.
  28802. * @param {function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean} layerFilter Layer filter
  28803. * function, only layers which are visible and for which this function
  28804. * returns `true` will be tested for features. By default, all visible
  28805. * layers will be tested.
  28806. * @return {T|undefined} Callback result.
  28807. * @template T
  28808. */
  28809. MapRenderer.prototype.forEachLayerAtPixel = function (pixel, frameState, hitTolerance, callback, layerFilter) {
  28810. return util_abstract();
  28811. };
  28812. /**
  28813. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
  28814. * @param {import("../PluggableMap.js").FrameState} frameState FrameState.
  28815. * @param {number} hitTolerance Hit tolerance in pixels.
  28816. * @param {boolean} checkWrapped Check for wrapped geometries.
  28817. * @param {function(this: U, import("../layer/Layer.js").default): boolean} layerFilter Layer filter
  28818. * function, only layers which are visible and for which this function
  28819. * returns `true` will be tested for features. By default, all visible
  28820. * layers will be tested.
  28821. * @param {U} thisArg Value to use as `this` when executing `layerFilter`.
  28822. * @return {boolean} Is there a feature at the given coordinate?
  28823. * @template U
  28824. */
  28825. MapRenderer.prototype.hasFeatureAtCoordinate = function (coordinate, frameState, hitTolerance, checkWrapped, layerFilter, thisArg) {
  28826. var hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, checkWrapped, TRUE, this, layerFilter, thisArg);
  28827. return hasFeature !== undefined;
  28828. };
  28829. /**
  28830. * @return {import("../PluggableMap.js").default} Map.
  28831. */
  28832. MapRenderer.prototype.getMap = function () {
  28833. return this.map_;
  28834. };
  28835. /**
  28836. * Render.
  28837. * @abstract
  28838. * @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
  28839. */
  28840. MapRenderer.prototype.renderFrame = function (frameState) {
  28841. util_abstract();
  28842. };
  28843. /**
  28844. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  28845. * @protected
  28846. */
  28847. MapRenderer.prototype.scheduleExpireIconCache = function (frameState) {
  28848. if (shared.canExpireCache()) {
  28849. frameState.postRenderFunctions.push(expireIconCache);
  28850. }
  28851. };
  28852. return MapRenderer;
  28853. }(ol_Disposable));
  28854. /**
  28855. * @param {import("../PluggableMap.js").default} map Map.
  28856. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  28857. */
  28858. function expireIconCache(map, frameState) {
  28859. shared.expire();
  28860. }
  28861. /* harmony default export */ var Map = (MapRenderer);
  28862. //# sourceMappingURL=Map.js.map
  28863. ;// ./node_modules/ol/renderer/Composite.js
  28864. var Composite_extends = (undefined && undefined.__extends) || (function () {
  28865. var extendStatics = function (d, b) {
  28866. extendStatics = Object.setPrototypeOf ||
  28867. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  28868. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  28869. return extendStatics(d, b);
  28870. };
  28871. return function (d, b) {
  28872. if (typeof b !== "function" && b !== null)
  28873. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  28874. extendStatics(d, b);
  28875. function __() { this.constructor = d; }
  28876. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28877. };
  28878. })();
  28879. /**
  28880. * @module ol/renderer/Composite
  28881. */
  28882. /**
  28883. * @classdesc
  28884. * Canvas map renderer.
  28885. * @api
  28886. */
  28887. var CompositeMapRenderer = /** @class */ (function (_super) {
  28888. Composite_extends(CompositeMapRenderer, _super);
  28889. /**
  28890. * @param {import("../PluggableMap.js").default} map Map.
  28891. */
  28892. function CompositeMapRenderer(map) {
  28893. var _this = _super.call(this, map) || this;
  28894. /**
  28895. * @type {import("../events.js").EventsKey}
  28896. */
  28897. _this.fontChangeListenerKey_ = listen(checkedFonts, ObjectEventType.PROPERTYCHANGE, map.redrawText.bind(map));
  28898. /**
  28899. * @private
  28900. * @type {HTMLDivElement}
  28901. */
  28902. _this.element_ = document.createElement('div');
  28903. var style = _this.element_.style;
  28904. style.position = 'absolute';
  28905. style.width = '100%';
  28906. style.height = '100%';
  28907. style.zIndex = '0';
  28908. _this.element_.className = CLASS_UNSELECTABLE + ' ol-layers';
  28909. var container = map.getViewport();
  28910. container.insertBefore(_this.element_, container.firstChild || null);
  28911. /**
  28912. * @private
  28913. * @type {Array<HTMLElement>}
  28914. */
  28915. _this.children_ = [];
  28916. /**
  28917. * @private
  28918. * @type {boolean}
  28919. */
  28920. _this.renderedVisible_ = true;
  28921. return _this;
  28922. }
  28923. /**
  28924. * @param {import("../render/EventType.js").default} type Event type.
  28925. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
  28926. */
  28927. CompositeMapRenderer.prototype.dispatchRenderEvent = function (type, frameState) {
  28928. var map = this.getMap();
  28929. if (map.hasListener(type)) {
  28930. var event_1 = new render_Event(type, undefined, frameState);
  28931. map.dispatchEvent(event_1);
  28932. }
  28933. };
  28934. CompositeMapRenderer.prototype.disposeInternal = function () {
  28935. unlistenByKey(this.fontChangeListenerKey_);
  28936. this.element_.parentNode.removeChild(this.element_);
  28937. _super.prototype.disposeInternal.call(this);
  28938. };
  28939. /**
  28940. * Render.
  28941. * @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
  28942. */
  28943. CompositeMapRenderer.prototype.renderFrame = function (frameState) {
  28944. if (!frameState) {
  28945. if (this.renderedVisible_) {
  28946. this.element_.style.display = 'none';
  28947. this.renderedVisible_ = false;
  28948. }
  28949. return;
  28950. }
  28951. this.calculateMatrices2D(frameState);
  28952. this.dispatchRenderEvent(render_EventType.PRECOMPOSE, frameState);
  28953. var layerStatesArray = frameState.layerStatesArray.sort(function (a, b) {
  28954. return a.zIndex - b.zIndex;
  28955. });
  28956. var viewState = frameState.viewState;
  28957. this.children_.length = 0;
  28958. /**
  28959. * @type {Array<import("../layer/BaseVector.js").default>}
  28960. */
  28961. var declutterLayers = [];
  28962. var previousElement = null;
  28963. for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
  28964. var layerState = layerStatesArray[i];
  28965. frameState.layerIndex = i;
  28966. var layer = layerState.layer;
  28967. var sourceState = layer.getSourceState();
  28968. if (!inView(layerState, viewState) ||
  28969. (sourceState != 'ready' && sourceState != 'undefined')) {
  28970. layer.unrender();
  28971. continue;
  28972. }
  28973. var element = layer.render(frameState, previousElement);
  28974. if (!element) {
  28975. continue;
  28976. }
  28977. if (element !== previousElement) {
  28978. this.children_.push(element);
  28979. previousElement = element;
  28980. }
  28981. if ('getDeclutter' in layer) {
  28982. declutterLayers.push(
  28983. /** @type {import("../layer/BaseVector.js").default} */ (layer));
  28984. }
  28985. }
  28986. for (var i = declutterLayers.length - 1; i >= 0; --i) {
  28987. declutterLayers[i].renderDeclutter(frameState);
  28988. }
  28989. replaceChildren(this.element_, this.children_);
  28990. this.dispatchRenderEvent(render_EventType.POSTCOMPOSE, frameState);
  28991. if (!this.renderedVisible_) {
  28992. this.element_.style.display = '';
  28993. this.renderedVisible_ = true;
  28994. }
  28995. this.scheduleExpireIconCache(frameState);
  28996. };
  28997. /**
  28998. * @param {import("../pixel.js").Pixel} pixel Pixel.
  28999. * @param {import("../PluggableMap.js").FrameState} frameState FrameState.
  29000. * @param {number} hitTolerance Hit tolerance in pixels.
  29001. * @param {function(import("../layer/Layer.js").default<import("../source/Source").default>, (Uint8ClampedArray|Uint8Array)): T} callback Layer
  29002. * callback.
  29003. * @param {function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean} layerFilter Layer filter
  29004. * function, only layers which are visible and for which this function
  29005. * returns `true` will be tested for features. By default, all visible
  29006. * layers will be tested.
  29007. * @return {T|undefined} Callback result.
  29008. * @template T
  29009. */
  29010. CompositeMapRenderer.prototype.forEachLayerAtPixel = function (pixel, frameState, hitTolerance, callback, layerFilter) {
  29011. var viewState = frameState.viewState;
  29012. var layerStates = frameState.layerStatesArray;
  29013. var numLayers = layerStates.length;
  29014. for (var i = numLayers - 1; i >= 0; --i) {
  29015. var layerState = layerStates[i];
  29016. var layer = layerState.layer;
  29017. if (layer.hasRenderer() &&
  29018. inView(layerState, viewState) &&
  29019. layerFilter(layer)) {
  29020. var layerRenderer = layer.getRenderer();
  29021. var data = layerRenderer.getDataAtPixel(pixel, frameState, hitTolerance);
  29022. if (data) {
  29023. var result = callback(layer, data);
  29024. if (result) {
  29025. return result;
  29026. }
  29027. }
  29028. }
  29029. }
  29030. return undefined;
  29031. };
  29032. return CompositeMapRenderer;
  29033. }(Map));
  29034. /* harmony default export */ var Composite = (CompositeMapRenderer);
  29035. //# sourceMappingURL=Composite.js.map
  29036. ;// ./node_modules/ol/layer/Group.js
  29037. var Group_extends = (undefined && undefined.__extends) || (function () {
  29038. var extendStatics = function (d, b) {
  29039. extendStatics = Object.setPrototypeOf ||
  29040. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29041. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  29042. return extendStatics(d, b);
  29043. };
  29044. return function (d, b) {
  29045. if (typeof b !== "function" && b !== null)
  29046. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  29047. extendStatics(d, b);
  29048. function __() { this.constructor = d; }
  29049. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29050. };
  29051. })();
  29052. /**
  29053. * @module ol/layer/Group
  29054. */
  29055. /**
  29056. * @typedef {'addlayer'|'removelayer'} EventType
  29057. */
  29058. /**
  29059. * @classdesc
  29060. * A layer group triggers 'addlayer' and 'removelayer' events when layers are added to or removed from
  29061. * the group or one of its child groups. When a layer group is added to or removed from another layer group,
  29062. * a single event will be triggered (instead of one per layer in the group added or removed).
  29063. */
  29064. var GroupEvent = /** @class */ (function (_super) {
  29065. Group_extends(GroupEvent, _super);
  29066. /**
  29067. * @param {EventType} type The event type.
  29068. * @param {BaseLayer} layer The layer.
  29069. */
  29070. function GroupEvent(type, layer) {
  29071. var _this = _super.call(this, type) || this;
  29072. /**
  29073. * The added or removed layer.
  29074. * @type {BaseLayer}
  29075. * @api
  29076. */
  29077. _this.layer = layer;
  29078. return _this;
  29079. }
  29080. return GroupEvent;
  29081. }(Event));
  29082. /***
  29083. * @template Return
  29084. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  29085. * import("../Observable").OnSignature<import("./Base").BaseLayerObjectEventTypes|
  29086. * 'change:layers', import("../Object").ObjectEvent, Return> &
  29087. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("./Base").BaseLayerObjectEventTypes|'change:layers', Return>} GroupOnSignature
  29088. */
  29089. /**
  29090. * @typedef {Object} Options
  29091. * @property {number} [opacity=1] Opacity (0, 1).
  29092. * @property {boolean} [visible=true] Visibility.
  29093. * @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
  29094. * rendered outside of this extent.
  29095. * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
  29096. * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
  29097. * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
  29098. * method was used.
  29099. * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
  29100. * visible.
  29101. * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
  29102. * be visible.
  29103. * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
  29104. * visible.
  29105. * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
  29106. * be visible.
  29107. * @property {Array<import("./Base.js").default>|import("../Collection.js").default<import("./Base.js").default>} [layers] Child layers.
  29108. * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
  29109. */
  29110. /**
  29111. * @enum {string}
  29112. * @private
  29113. */
  29114. var Group_Property = {
  29115. LAYERS: 'layers',
  29116. };
  29117. /**
  29118. * @classdesc
  29119. * A {@link module:ol/Collection~Collection} of layers that are handled together.
  29120. *
  29121. * A generic `change` event is triggered when the group/Collection changes.
  29122. *
  29123. * @api
  29124. */
  29125. var LayerGroup = /** @class */ (function (_super) {
  29126. Group_extends(LayerGroup, _super);
  29127. /**
  29128. * @param {Options} [opt_options] Layer options.
  29129. */
  29130. function LayerGroup(opt_options) {
  29131. var _this = this;
  29132. var options = opt_options || {};
  29133. var baseOptions = /** @type {Options} */ (obj_assign({}, options));
  29134. delete baseOptions.layers;
  29135. var layers = options.layers;
  29136. _this = _super.call(this, baseOptions) || this;
  29137. /***
  29138. * @type {GroupOnSignature<import("../events").EventsKey>}
  29139. */
  29140. _this.on;
  29141. /***
  29142. * @type {GroupOnSignature<import("../events").EventsKey>}
  29143. */
  29144. _this.once;
  29145. /***
  29146. * @type {GroupOnSignature<void>}
  29147. */
  29148. _this.un;
  29149. /**
  29150. * @private
  29151. * @type {Array<import("../events.js").EventsKey>}
  29152. */
  29153. _this.layersListenerKeys_ = [];
  29154. /**
  29155. * @private
  29156. * @type {Object<string, Array<import("../events.js").EventsKey>>}
  29157. */
  29158. _this.listenerKeys_ = {};
  29159. _this.addChangeListener(Group_Property.LAYERS, _this.handleLayersChanged_);
  29160. if (layers) {
  29161. if (Array.isArray(layers)) {
  29162. layers = new ol_Collection(layers.slice(), { unique: true });
  29163. }
  29164. else {
  29165. asserts_assert(typeof ( /** @type {?} */(layers).getArray) === 'function', 43); // Expected `layers` to be an array or a `Collection`
  29166. }
  29167. }
  29168. else {
  29169. layers = new ol_Collection(undefined, { unique: true });
  29170. }
  29171. _this.setLayers(layers);
  29172. return _this;
  29173. }
  29174. /**
  29175. * @private
  29176. */
  29177. LayerGroup.prototype.handleLayerChange_ = function () {
  29178. this.changed();
  29179. };
  29180. /**
  29181. * @private
  29182. */
  29183. LayerGroup.prototype.handleLayersChanged_ = function () {
  29184. this.layersListenerKeys_.forEach(unlistenByKey);
  29185. this.layersListenerKeys_.length = 0;
  29186. var layers = this.getLayers();
  29187. this.layersListenerKeys_.push(listen(layers, CollectionEventType.ADD, this.handleLayersAdd_, this), listen(layers, CollectionEventType.REMOVE, this.handleLayersRemove_, this));
  29188. for (var id in this.listenerKeys_) {
  29189. this.listenerKeys_[id].forEach(unlistenByKey);
  29190. }
  29191. clear(this.listenerKeys_);
  29192. var layersArray = layers.getArray();
  29193. for (var i = 0, ii = layersArray.length; i < ii; i++) {
  29194. var layer = layersArray[i];
  29195. this.registerLayerListeners_(layer);
  29196. this.dispatchEvent(new GroupEvent('addlayer', layer));
  29197. }
  29198. this.changed();
  29199. };
  29200. /**
  29201. * @param {BaseLayer} layer The layer.
  29202. */
  29203. LayerGroup.prototype.registerLayerListeners_ = function (layer) {
  29204. var listenerKeys = [
  29205. listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
  29206. listen(layer, EventType.CHANGE, this.handleLayerChange_, this),
  29207. ];
  29208. if (layer instanceof LayerGroup) {
  29209. listenerKeys.push(listen(layer, 'addlayer', this.handleLayerGroupAdd_, this), listen(layer, 'removelayer', this.handleLayerGroupRemove_, this));
  29210. }
  29211. this.listenerKeys_[getUid(layer)] = listenerKeys;
  29212. };
  29213. /**
  29214. * @param {GroupEvent} event The layer group event.
  29215. */
  29216. LayerGroup.prototype.handleLayerGroupAdd_ = function (event) {
  29217. this.dispatchEvent(new GroupEvent('addlayer', event.layer));
  29218. };
  29219. /**
  29220. * @param {GroupEvent} event The layer group event.
  29221. */
  29222. LayerGroup.prototype.handleLayerGroupRemove_ = function (event) {
  29223. this.dispatchEvent(new GroupEvent('removelayer', event.layer));
  29224. };
  29225. /**
  29226. * @param {import("../Collection.js").CollectionEvent} collectionEvent CollectionEvent.
  29227. * @private
  29228. */
  29229. LayerGroup.prototype.handleLayersAdd_ = function (collectionEvent) {
  29230. var layer = /** @type {import("./Base.js").default} */ (collectionEvent.element);
  29231. this.registerLayerListeners_(layer);
  29232. this.dispatchEvent(new GroupEvent('addlayer', layer));
  29233. this.changed();
  29234. };
  29235. /**
  29236. * @param {import("../Collection.js").CollectionEvent} collectionEvent CollectionEvent.
  29237. * @private
  29238. */
  29239. LayerGroup.prototype.handleLayersRemove_ = function (collectionEvent) {
  29240. var layer = /** @type {import("./Base.js").default} */ (collectionEvent.element);
  29241. var key = getUid(layer);
  29242. this.listenerKeys_[key].forEach(unlistenByKey);
  29243. delete this.listenerKeys_[key];
  29244. this.dispatchEvent(new GroupEvent('removelayer', layer));
  29245. this.changed();
  29246. };
  29247. /**
  29248. * Returns the {@link module:ol/Collection~Collection collection} of {@link module:ol/layer/Layer~Layer layers}
  29249. * in this group.
  29250. * @return {!import("../Collection.js").default<import("./Base.js").default>} Collection of
  29251. * {@link module:ol/layer/Base~BaseLayer layers} that are part of this group.
  29252. * @observable
  29253. * @api
  29254. */
  29255. LayerGroup.prototype.getLayers = function () {
  29256. return /** @type {!import("../Collection.js").default<import("./Base.js").default>} */ (this.get(Group_Property.LAYERS));
  29257. };
  29258. /**
  29259. * Set the {@link module:ol/Collection~Collection collection} of {@link module:ol/layer/Layer~Layer layers}
  29260. * in this group.
  29261. * @param {!import("../Collection.js").default<import("./Base.js").default>} layers Collection of
  29262. * {@link module:ol/layer/Base~BaseLayer layers} that are part of this group.
  29263. * @observable
  29264. * @api
  29265. */
  29266. LayerGroup.prototype.setLayers = function (layers) {
  29267. var collection = this.getLayers();
  29268. if (collection) {
  29269. var currentLayers = collection.getArray();
  29270. for (var i = 0, ii = currentLayers.length; i < ii; ++i) {
  29271. this.dispatchEvent(new GroupEvent('removelayer', currentLayers[i]));
  29272. }
  29273. }
  29274. this.set(Group_Property.LAYERS, layers);
  29275. };
  29276. /**
  29277. * @param {Array<import("./Layer.js").default>} [opt_array] Array of layers (to be modified in place).
  29278. * @return {Array<import("./Layer.js").default>} Array of layers.
  29279. */
  29280. LayerGroup.prototype.getLayersArray = function (opt_array) {
  29281. var array = opt_array !== undefined ? opt_array : [];
  29282. this.getLayers().forEach(function (layer) {
  29283. layer.getLayersArray(array);
  29284. });
  29285. return array;
  29286. };
  29287. /**
  29288. * Get the layer states list and use this groups z-index as the default
  29289. * for all layers in this and nested groups, if it is unset at this point.
  29290. * If opt_states is not provided and this group's z-index is undefined
  29291. * 0 is used a the default z-index.
  29292. * @param {Array<import("./Layer.js").State>} [opt_states] Optional list
  29293. * of layer states (to be modified in place).
  29294. * @return {Array<import("./Layer.js").State>} List of layer states.
  29295. */
  29296. LayerGroup.prototype.getLayerStatesArray = function (opt_states) {
  29297. var states = opt_states !== undefined ? opt_states : [];
  29298. var pos = states.length;
  29299. this.getLayers().forEach(function (layer) {
  29300. layer.getLayerStatesArray(states);
  29301. });
  29302. var ownLayerState = this.getLayerState();
  29303. var defaultZIndex = ownLayerState.zIndex;
  29304. if (!opt_states && ownLayerState.zIndex === undefined) {
  29305. defaultZIndex = 0;
  29306. }
  29307. for (var i = pos, ii = states.length; i < ii; i++) {
  29308. var layerState = states[i];
  29309. layerState.opacity *= ownLayerState.opacity;
  29310. layerState.visible = layerState.visible && ownLayerState.visible;
  29311. layerState.maxResolution = Math.min(layerState.maxResolution, ownLayerState.maxResolution);
  29312. layerState.minResolution = Math.max(layerState.minResolution, ownLayerState.minResolution);
  29313. layerState.minZoom = Math.max(layerState.minZoom, ownLayerState.minZoom);
  29314. layerState.maxZoom = Math.min(layerState.maxZoom, ownLayerState.maxZoom);
  29315. if (ownLayerState.extent !== undefined) {
  29316. if (layerState.extent !== undefined) {
  29317. layerState.extent = getIntersection(layerState.extent, ownLayerState.extent);
  29318. }
  29319. else {
  29320. layerState.extent = ownLayerState.extent;
  29321. }
  29322. }
  29323. if (layerState.zIndex === undefined) {
  29324. layerState.zIndex = defaultZIndex;
  29325. }
  29326. }
  29327. return states;
  29328. };
  29329. /**
  29330. * @return {import("../source/Source.js").State} Source state.
  29331. */
  29332. LayerGroup.prototype.getSourceState = function () {
  29333. return 'ready';
  29334. };
  29335. return LayerGroup;
  29336. }(Base));
  29337. /* harmony default export */ var Group = (LayerGroup);
  29338. //# sourceMappingURL=Group.js.map
  29339. ;// ./node_modules/ol/MapEvent.js
  29340. var MapEvent_extends = (undefined && undefined.__extends) || (function () {
  29341. var extendStatics = function (d, b) {
  29342. extendStatics = Object.setPrototypeOf ||
  29343. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29344. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  29345. return extendStatics(d, b);
  29346. };
  29347. return function (d, b) {
  29348. if (typeof b !== "function" && b !== null)
  29349. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  29350. extendStatics(d, b);
  29351. function __() { this.constructor = d; }
  29352. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29353. };
  29354. })();
  29355. /**
  29356. * @module ol/MapEvent
  29357. */
  29358. /**
  29359. * @classdesc
  29360. * Events emitted as map events are instances of this type.
  29361. * See {@link module:ol/PluggableMap~PluggableMap} for which events trigger a map event.
  29362. */
  29363. var MapEvent = /** @class */ (function (_super) {
  29364. MapEvent_extends(MapEvent, _super);
  29365. /**
  29366. * @param {string} type Event type.
  29367. * @param {import("./PluggableMap.js").default} map Map.
  29368. * @param {?import("./PluggableMap.js").FrameState} [opt_frameState] Frame state.
  29369. */
  29370. function MapEvent(type, map, opt_frameState) {
  29371. var _this = _super.call(this, type) || this;
  29372. /**
  29373. * The map where the event occurred.
  29374. * @type {import("./PluggableMap.js").default}
  29375. * @api
  29376. */
  29377. _this.map = map;
  29378. /**
  29379. * The frame state at the time of the event.
  29380. * @type {?import("./PluggableMap.js").FrameState}
  29381. * @api
  29382. */
  29383. _this.frameState = opt_frameState !== undefined ? opt_frameState : null;
  29384. return _this;
  29385. }
  29386. return MapEvent;
  29387. }(Event));
  29388. /* harmony default export */ var ol_MapEvent = (MapEvent);
  29389. //# sourceMappingURL=MapEvent.js.map
  29390. ;// ./node_modules/ol/MapBrowserEvent.js
  29391. var MapBrowserEvent_extends = (undefined && undefined.__extends) || (function () {
  29392. var extendStatics = function (d, b) {
  29393. extendStatics = Object.setPrototypeOf ||
  29394. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29395. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  29396. return extendStatics(d, b);
  29397. };
  29398. return function (d, b) {
  29399. if (typeof b !== "function" && b !== null)
  29400. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  29401. extendStatics(d, b);
  29402. function __() { this.constructor = d; }
  29403. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29404. };
  29405. })();
  29406. /**
  29407. * @module ol/MapBrowserEvent
  29408. */
  29409. /**
  29410. * @classdesc
  29411. * Events emitted as map browser events are instances of this type.
  29412. * See {@link module:ol/PluggableMap~PluggableMap} for which events trigger a map browser event.
  29413. * @template {UIEvent} EVENT
  29414. */
  29415. var MapBrowserEvent = /** @class */ (function (_super) {
  29416. MapBrowserEvent_extends(MapBrowserEvent, _super);
  29417. /**
  29418. * @param {string} type Event type.
  29419. * @param {import("./PluggableMap.js").default} map Map.
  29420. * @param {EVENT} originalEvent Original event.
  29421. * @param {boolean} [opt_dragging] Is the map currently being dragged?
  29422. * @param {import("./PluggableMap.js").FrameState} [opt_frameState] Frame state.
  29423. * @param {Array<PointerEvent>} [opt_activePointers] Active pointers.
  29424. */
  29425. function MapBrowserEvent(type, map, originalEvent, opt_dragging, opt_frameState, opt_activePointers) {
  29426. var _this = _super.call(this, type, map, opt_frameState) || this;
  29427. /**
  29428. * The original browser event.
  29429. * @const
  29430. * @type {EVENT}
  29431. * @api
  29432. */
  29433. _this.originalEvent = originalEvent;
  29434. /**
  29435. * The map pixel relative to the viewport corresponding to the original browser event.
  29436. * @type {?import("./pixel.js").Pixel}
  29437. */
  29438. _this.pixel_ = null;
  29439. /**
  29440. * The coordinate in the user projection corresponding to the original browser event.
  29441. * @type {?import("./coordinate.js").Coordinate}
  29442. */
  29443. _this.coordinate_ = null;
  29444. /**
  29445. * Indicates if the map is currently being dragged. Only set for
  29446. * `POINTERDRAG` and `POINTERMOVE` events. Default is `false`.
  29447. *
  29448. * @type {boolean}
  29449. * @api
  29450. */
  29451. _this.dragging = opt_dragging !== undefined ? opt_dragging : false;
  29452. /**
  29453. * @type {Array<PointerEvent>|undefined}
  29454. */
  29455. _this.activePointers = opt_activePointers;
  29456. return _this;
  29457. }
  29458. Object.defineProperty(MapBrowserEvent.prototype, "pixel", {
  29459. /**
  29460. * The map pixel relative to the viewport corresponding to the original event.
  29461. * @type {import("./pixel.js").Pixel}
  29462. * @api
  29463. */
  29464. get: function () {
  29465. if (!this.pixel_) {
  29466. this.pixel_ = this.map.getEventPixel(this.originalEvent);
  29467. }
  29468. return this.pixel_;
  29469. },
  29470. set: function (pixel) {
  29471. this.pixel_ = pixel;
  29472. },
  29473. enumerable: false,
  29474. configurable: true
  29475. });
  29476. Object.defineProperty(MapBrowserEvent.prototype, "coordinate", {
  29477. /**
  29478. * The coordinate corresponding to the original browser event. This will be in the user
  29479. * projection if one is set. Otherwise it will be in the view projection.
  29480. * @type {import("./coordinate.js").Coordinate}
  29481. * @api
  29482. */
  29483. get: function () {
  29484. if (!this.coordinate_) {
  29485. this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel);
  29486. }
  29487. return this.coordinate_;
  29488. },
  29489. set: function (coordinate) {
  29490. this.coordinate_ = coordinate;
  29491. },
  29492. enumerable: false,
  29493. configurable: true
  29494. });
  29495. /**
  29496. * Prevents the default browser action.
  29497. * See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault.
  29498. * @api
  29499. */
  29500. MapBrowserEvent.prototype.preventDefault = function () {
  29501. _super.prototype.preventDefault.call(this);
  29502. if ('preventDefault' in this.originalEvent) {
  29503. /** @type {UIEvent} */ (this.originalEvent).preventDefault();
  29504. }
  29505. };
  29506. /**
  29507. * Prevents further propagation of the current event.
  29508. * See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation.
  29509. * @api
  29510. */
  29511. MapBrowserEvent.prototype.stopPropagation = function () {
  29512. _super.prototype.stopPropagation.call(this);
  29513. if ('stopPropagation' in this.originalEvent) {
  29514. /** @type {UIEvent} */ (this.originalEvent).stopPropagation();
  29515. }
  29516. };
  29517. return MapBrowserEvent;
  29518. }(ol_MapEvent));
  29519. /* harmony default export */ var ol_MapBrowserEvent = (MapBrowserEvent);
  29520. //# sourceMappingURL=MapBrowserEvent.js.map
  29521. ;// ./node_modules/ol/MapBrowserEventType.js
  29522. /**
  29523. * @module ol/MapBrowserEventType
  29524. */
  29525. /**
  29526. * Constants for event names.
  29527. * @enum {string}
  29528. */
  29529. /* harmony default export */ var ol_MapBrowserEventType = ({
  29530. /**
  29531. * A true single click with no dragging and no double click. Note that this
  29532. * event is delayed by 250 ms to ensure that it is not a double click.
  29533. * @event module:ol/MapBrowserEvent~MapBrowserEvent#singleclick
  29534. * @api
  29535. */
  29536. SINGLECLICK: 'singleclick',
  29537. /**
  29538. * A click with no dragging. A double click will fire two of this.
  29539. * @event module:ol/MapBrowserEvent~MapBrowserEvent#click
  29540. * @api
  29541. */
  29542. CLICK: EventType.CLICK,
  29543. /**
  29544. * A true double click, with no dragging.
  29545. * @event module:ol/MapBrowserEvent~MapBrowserEvent#dblclick
  29546. * @api
  29547. */
  29548. DBLCLICK: EventType.DBLCLICK,
  29549. /**
  29550. * Triggered when a pointer is dragged.
  29551. * @event module:ol/MapBrowserEvent~MapBrowserEvent#pointerdrag
  29552. * @api
  29553. */
  29554. POINTERDRAG: 'pointerdrag',
  29555. /**
  29556. * Triggered when a pointer is moved. Note that on touch devices this is
  29557. * triggered when the map is panned, so is not the same as mousemove.
  29558. * @event module:ol/MapBrowserEvent~MapBrowserEvent#pointermove
  29559. * @api
  29560. */
  29561. POINTERMOVE: 'pointermove',
  29562. POINTERDOWN: 'pointerdown',
  29563. POINTERUP: 'pointerup',
  29564. POINTEROVER: 'pointerover',
  29565. POINTEROUT: 'pointerout',
  29566. POINTERENTER: 'pointerenter',
  29567. POINTERLEAVE: 'pointerleave',
  29568. POINTERCANCEL: 'pointercancel',
  29569. });
  29570. /***
  29571. * @typedef {'singleclick'|'click'|'dblclick'|'pointerdrag'|'pointermove'} Types
  29572. */
  29573. //# sourceMappingURL=MapBrowserEventType.js.map
  29574. ;// ./node_modules/ol/MapBrowserEventHandler.js
  29575. /**
  29576. * @module ol/MapBrowserEventHandler
  29577. */
  29578. var MapBrowserEventHandler_extends = (undefined && undefined.__extends) || (function () {
  29579. var extendStatics = function (d, b) {
  29580. extendStatics = Object.setPrototypeOf ||
  29581. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29582. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  29583. return extendStatics(d, b);
  29584. };
  29585. return function (d, b) {
  29586. if (typeof b !== "function" && b !== null)
  29587. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  29588. extendStatics(d, b);
  29589. function __() { this.constructor = d; }
  29590. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29591. };
  29592. })();
  29593. var MapBrowserEventHandler = /** @class */ (function (_super) {
  29594. MapBrowserEventHandler_extends(MapBrowserEventHandler, _super);
  29595. /**
  29596. * @param {import("./PluggableMap.js").default} map The map with the viewport to listen to events on.
  29597. * @param {number} [moveTolerance] The minimal distance the pointer must travel to trigger a move.
  29598. */
  29599. function MapBrowserEventHandler(map, moveTolerance) {
  29600. var _this = _super.call(this, map) || this;
  29601. /**
  29602. * This is the element that we will listen to the real events on.
  29603. * @type {import("./PluggableMap.js").default}
  29604. * @private
  29605. */
  29606. _this.map_ = map;
  29607. /**
  29608. * @type {any}
  29609. * @private
  29610. */
  29611. _this.clickTimeoutId_;
  29612. /**
  29613. * Emulate dblclick and singleclick. Will be true when only one pointer is active.
  29614. * @type {boolean}
  29615. */
  29616. _this.emulateClicks_ = false;
  29617. /**
  29618. * @type {boolean}
  29619. * @private
  29620. */
  29621. _this.dragging_ = false;
  29622. /**
  29623. * @type {!Array<import("./events.js").EventsKey>}
  29624. * @private
  29625. */
  29626. _this.dragListenerKeys_ = [];
  29627. /**
  29628. * @type {number}
  29629. * @private
  29630. */
  29631. _this.moveTolerance_ = moveTolerance === undefined ? 1 : moveTolerance;
  29632. /**
  29633. * The most recent "down" type event (or null if none have occurred).
  29634. * Set on pointerdown.
  29635. * @type {PointerEvent|null}
  29636. * @private
  29637. */
  29638. _this.down_ = null;
  29639. var element = _this.map_.getViewport();
  29640. /**
  29641. * @type {Array<PointerEvent>}
  29642. * @private
  29643. */
  29644. _this.activePointers_ = [];
  29645. /**
  29646. * @type {!Object<number, Event>}
  29647. * @private
  29648. */
  29649. _this.trackedTouches_ = {};
  29650. _this.element_ = element;
  29651. /**
  29652. * @type {?import("./events.js").EventsKey}
  29653. * @private
  29654. */
  29655. _this.pointerdownListenerKey_ = listen(element, pointer_EventType.POINTERDOWN, _this.handlePointerDown_, _this);
  29656. /**
  29657. * @type {PointerEvent}
  29658. * @private
  29659. */
  29660. _this.originalPointerMoveEvent_;
  29661. /**
  29662. * @type {?import("./events.js").EventsKey}
  29663. * @private
  29664. */
  29665. _this.relayedListenerKey_ = listen(element, pointer_EventType.POINTERMOVE, _this.relayMoveEvent_, _this);
  29666. /**
  29667. * @private
  29668. */
  29669. _this.boundHandleTouchMove_ = _this.handleTouchMove_.bind(_this);
  29670. _this.element_.addEventListener(EventType.TOUCHMOVE, _this.boundHandleTouchMove_, PASSIVE_EVENT_LISTENERS ? { passive: false } : false);
  29671. return _this;
  29672. }
  29673. /**
  29674. * @param {PointerEvent} pointerEvent Pointer
  29675. * event.
  29676. * @private
  29677. */
  29678. MapBrowserEventHandler.prototype.emulateClick_ = function (pointerEvent) {
  29679. var newEvent = new ol_MapBrowserEvent(ol_MapBrowserEventType.CLICK, this.map_, pointerEvent);
  29680. this.dispatchEvent(newEvent);
  29681. if (this.clickTimeoutId_ !== undefined) {
  29682. // double-click
  29683. clearTimeout(this.clickTimeoutId_);
  29684. this.clickTimeoutId_ = undefined;
  29685. newEvent = new ol_MapBrowserEvent(ol_MapBrowserEventType.DBLCLICK, this.map_, pointerEvent);
  29686. this.dispatchEvent(newEvent);
  29687. }
  29688. else {
  29689. // click
  29690. this.clickTimeoutId_ = setTimeout(
  29691. /** @this {MapBrowserEventHandler} */
  29692. function () {
  29693. this.clickTimeoutId_ = undefined;
  29694. var newEvent = new ol_MapBrowserEvent(ol_MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent);
  29695. this.dispatchEvent(newEvent);
  29696. }.bind(this), 250);
  29697. }
  29698. };
  29699. /**
  29700. * Keeps track on how many pointers are currently active.
  29701. *
  29702. * @param {PointerEvent} pointerEvent Pointer
  29703. * event.
  29704. * @private
  29705. */
  29706. MapBrowserEventHandler.prototype.updateActivePointers_ = function (pointerEvent) {
  29707. var event = pointerEvent;
  29708. var id = event.pointerId;
  29709. if (event.type == ol_MapBrowserEventType.POINTERUP ||
  29710. event.type == ol_MapBrowserEventType.POINTERCANCEL) {
  29711. delete this.trackedTouches_[id];
  29712. for (var pointerId in this.trackedTouches_) {
  29713. if (this.trackedTouches_[pointerId].target !== event.target) {
  29714. // Some platforms assign a new pointerId when the target changes.
  29715. // If this happens, delete one tracked pointer. If there is more
  29716. // than one tracked pointer for the old target, it will be cleared
  29717. // by subsequent POINTERUP events from other pointers.
  29718. delete this.trackedTouches_[pointerId];
  29719. break;
  29720. }
  29721. }
  29722. }
  29723. else if (event.type == ol_MapBrowserEventType.POINTERDOWN ||
  29724. event.type == ol_MapBrowserEventType.POINTERMOVE) {
  29725. this.trackedTouches_[id] = event;
  29726. }
  29727. this.activePointers_ = getValues(this.trackedTouches_);
  29728. };
  29729. /**
  29730. * @param {PointerEvent} pointerEvent Pointer
  29731. * event.
  29732. * @private
  29733. */
  29734. MapBrowserEventHandler.prototype.handlePointerUp_ = function (pointerEvent) {
  29735. this.updateActivePointers_(pointerEvent);
  29736. var newEvent = new ol_MapBrowserEvent(ol_MapBrowserEventType.POINTERUP, this.map_, pointerEvent, undefined, undefined, this.activePointers_);
  29737. this.dispatchEvent(newEvent);
  29738. // We emulate click events on left mouse button click, touch contact, and pen
  29739. // contact. isMouseActionButton returns true in these cases (evt.button is set
  29740. // to 0).
  29741. // See http://www.w3.org/TR/pointerevents/#button-states
  29742. // We only fire click, singleclick, and doubleclick if nobody has called
  29743. // event.preventDefault().
  29744. if (this.emulateClicks_ &&
  29745. !newEvent.defaultPrevented &&
  29746. !this.dragging_ &&
  29747. this.isMouseActionButton_(pointerEvent)) {
  29748. this.emulateClick_(this.down_);
  29749. }
  29750. if (this.activePointers_.length === 0) {
  29751. this.dragListenerKeys_.forEach(unlistenByKey);
  29752. this.dragListenerKeys_.length = 0;
  29753. this.dragging_ = false;
  29754. this.down_ = null;
  29755. }
  29756. };
  29757. /**
  29758. * @param {PointerEvent} pointerEvent Pointer
  29759. * event.
  29760. * @return {boolean} If the left mouse button was pressed.
  29761. * @private
  29762. */
  29763. MapBrowserEventHandler.prototype.isMouseActionButton_ = function (pointerEvent) {
  29764. return pointerEvent.button === 0;
  29765. };
  29766. /**
  29767. * @param {PointerEvent} pointerEvent Pointer
  29768. * event.
  29769. * @private
  29770. */
  29771. MapBrowserEventHandler.prototype.handlePointerDown_ = function (pointerEvent) {
  29772. this.emulateClicks_ = this.activePointers_.length === 0;
  29773. this.updateActivePointers_(pointerEvent);
  29774. var newEvent = new ol_MapBrowserEvent(ol_MapBrowserEventType.POINTERDOWN, this.map_, pointerEvent, undefined, undefined, this.activePointers_);
  29775. this.dispatchEvent(newEvent);
  29776. // Store a copy of the down event
  29777. this.down_ = /** @type {PointerEvent} */ ({});
  29778. for (var property in pointerEvent) {
  29779. var value = pointerEvent[property];
  29780. this.down_[property] = typeof value === 'function' ? VOID : value;
  29781. }
  29782. if (this.dragListenerKeys_.length === 0) {
  29783. var doc = this.map_.getOwnerDocument();
  29784. this.dragListenerKeys_.push(listen(doc, ol_MapBrowserEventType.POINTERMOVE, this.handlePointerMove_, this), listen(doc, ol_MapBrowserEventType.POINTERUP, this.handlePointerUp_, this),
  29785. /* Note that the listener for `pointercancel is set up on
  29786. * `pointerEventHandler_` and not `documentPointerEventHandler_` like
  29787. * the `pointerup` and `pointermove` listeners.
  29788. *
  29789. * The reason for this is the following: `TouchSource.vacuumTouches_()`
  29790. * issues `pointercancel` events, when there was no `touchend` for a
  29791. * `touchstart`. Now, let's say a first `touchstart` is registered on
  29792. * `pointerEventHandler_`. The `documentPointerEventHandler_` is set up.
  29793. * But `documentPointerEventHandler_` doesn't know about the first
  29794. * `touchstart`. If there is no `touchend` for the `touchstart`, we can
  29795. * only receive a `touchcancel` from `pointerEventHandler_`, because it is
  29796. * only registered there.
  29797. */
  29798. listen(this.element_, ol_MapBrowserEventType.POINTERCANCEL, this.handlePointerUp_, this));
  29799. if (this.element_.getRootNode && this.element_.getRootNode() !== doc) {
  29800. this.dragListenerKeys_.push(listen(this.element_.getRootNode(), ol_MapBrowserEventType.POINTERUP, this.handlePointerUp_, this));
  29801. }
  29802. }
  29803. };
  29804. /**
  29805. * @param {PointerEvent} pointerEvent Pointer
  29806. * event.
  29807. * @private
  29808. */
  29809. MapBrowserEventHandler.prototype.handlePointerMove_ = function (pointerEvent) {
  29810. // Between pointerdown and pointerup, pointermove events are triggered.
  29811. // To avoid a 'false' touchmove event to be dispatched, we test if the pointer
  29812. // moved a significant distance.
  29813. if (this.isMoving_(pointerEvent)) {
  29814. this.updateActivePointers_(pointerEvent);
  29815. this.dragging_ = true;
  29816. var newEvent = new ol_MapBrowserEvent(ol_MapBrowserEventType.POINTERDRAG, this.map_, pointerEvent, this.dragging_, undefined, this.activePointers_);
  29817. this.dispatchEvent(newEvent);
  29818. }
  29819. };
  29820. /**
  29821. * Wrap and relay a pointermove event.
  29822. * @param {PointerEvent} pointerEvent Pointer
  29823. * event.
  29824. * @private
  29825. */
  29826. MapBrowserEventHandler.prototype.relayMoveEvent_ = function (pointerEvent) {
  29827. this.originalPointerMoveEvent_ = pointerEvent;
  29828. var dragging = !!(this.down_ && this.isMoving_(pointerEvent));
  29829. this.dispatchEvent(new ol_MapBrowserEvent(ol_MapBrowserEventType.POINTERMOVE, this.map_, pointerEvent, dragging));
  29830. };
  29831. /**
  29832. * Flexible handling of a `touch-action: none` css equivalent: because calling
  29833. * `preventDefault()` on a `pointermove` event does not stop native page scrolling
  29834. * and zooming, we also listen for `touchmove` and call `preventDefault()` on it
  29835. * when an interaction (currently `DragPan` handles the event.
  29836. * @param {TouchEvent} event Event.
  29837. * @private
  29838. */
  29839. MapBrowserEventHandler.prototype.handleTouchMove_ = function (event) {
  29840. // Due to https://github.com/mpizenberg/elm-pep/issues/2, `this.originalPointerMoveEvent_`
  29841. // may not be initialized yet when we get here on a platform without native pointer events.
  29842. var originalEvent = this.originalPointerMoveEvent_;
  29843. if ((!originalEvent || originalEvent.defaultPrevented) &&
  29844. (typeof event.cancelable !== 'boolean' || event.cancelable === true)) {
  29845. event.preventDefault();
  29846. }
  29847. };
  29848. /**
  29849. * @param {PointerEvent} pointerEvent Pointer
  29850. * event.
  29851. * @return {boolean} Is moving.
  29852. * @private
  29853. */
  29854. MapBrowserEventHandler.prototype.isMoving_ = function (pointerEvent) {
  29855. return (this.dragging_ ||
  29856. Math.abs(pointerEvent.clientX - this.down_.clientX) >
  29857. this.moveTolerance_ ||
  29858. Math.abs(pointerEvent.clientY - this.down_.clientY) > this.moveTolerance_);
  29859. };
  29860. /**
  29861. * Clean up.
  29862. */
  29863. MapBrowserEventHandler.prototype.disposeInternal = function () {
  29864. if (this.relayedListenerKey_) {
  29865. unlistenByKey(this.relayedListenerKey_);
  29866. this.relayedListenerKey_ = null;
  29867. }
  29868. this.element_.removeEventListener(EventType.TOUCHMOVE, this.boundHandleTouchMove_);
  29869. if (this.pointerdownListenerKey_) {
  29870. unlistenByKey(this.pointerdownListenerKey_);
  29871. this.pointerdownListenerKey_ = null;
  29872. }
  29873. this.dragListenerKeys_.forEach(unlistenByKey);
  29874. this.dragListenerKeys_.length = 0;
  29875. this.element_ = null;
  29876. _super.prototype.disposeInternal.call(this);
  29877. };
  29878. return MapBrowserEventHandler;
  29879. }(events_Target));
  29880. /* harmony default export */ var ol_MapBrowserEventHandler = (MapBrowserEventHandler);
  29881. //# sourceMappingURL=MapBrowserEventHandler.js.map
  29882. ;// ./node_modules/ol/MapProperty.js
  29883. /**
  29884. * @module ol/MapProperty
  29885. */
  29886. /**
  29887. * @enum {string}
  29888. */
  29889. /* harmony default export */ var MapProperty = ({
  29890. LAYERGROUP: 'layergroup',
  29891. SIZE: 'size',
  29892. TARGET: 'target',
  29893. VIEW: 'view',
  29894. });
  29895. //# sourceMappingURL=MapProperty.js.map
  29896. ;// ./node_modules/ol/structs/PriorityQueue.js
  29897. /**
  29898. * @module ol/structs/PriorityQueue
  29899. */
  29900. /**
  29901. * @type {number}
  29902. */
  29903. var DROP = Infinity;
  29904. /**
  29905. * @classdesc
  29906. * Priority queue.
  29907. *
  29908. * The implementation is inspired from the Closure Library's Heap class and
  29909. * Python's heapq module.
  29910. *
  29911. * See https://github.com/google/closure-library/blob/master/closure/goog/structs/heap.js
  29912. * and https://hg.python.org/cpython/file/2.7/Lib/heapq.py.
  29913. *
  29914. * @template T
  29915. */
  29916. var PriorityQueue = /** @class */ (function () {
  29917. /**
  29918. * @param {function(T): number} priorityFunction Priority function.
  29919. * @param {function(T): string} keyFunction Key function.
  29920. */
  29921. function PriorityQueue(priorityFunction, keyFunction) {
  29922. /**
  29923. * @type {function(T): number}
  29924. * @private
  29925. */
  29926. this.priorityFunction_ = priorityFunction;
  29927. /**
  29928. * @type {function(T): string}
  29929. * @private
  29930. */
  29931. this.keyFunction_ = keyFunction;
  29932. /**
  29933. * @type {Array<T>}
  29934. * @private
  29935. */
  29936. this.elements_ = [];
  29937. /**
  29938. * @type {Array<number>}
  29939. * @private
  29940. */
  29941. this.priorities_ = [];
  29942. /**
  29943. * @type {!Object<string, boolean>}
  29944. * @private
  29945. */
  29946. this.queuedElements_ = {};
  29947. }
  29948. /**
  29949. * FIXME empty description for jsdoc
  29950. */
  29951. PriorityQueue.prototype.clear = function () {
  29952. this.elements_.length = 0;
  29953. this.priorities_.length = 0;
  29954. clear(this.queuedElements_);
  29955. };
  29956. /**
  29957. * Remove and return the highest-priority element. O(log N).
  29958. * @return {T} Element.
  29959. */
  29960. PriorityQueue.prototype.dequeue = function () {
  29961. var elements = this.elements_;
  29962. var priorities = this.priorities_;
  29963. var element = elements[0];
  29964. if (elements.length == 1) {
  29965. elements.length = 0;
  29966. priorities.length = 0;
  29967. }
  29968. else {
  29969. elements[0] = elements.pop();
  29970. priorities[0] = priorities.pop();
  29971. this.siftUp_(0);
  29972. }
  29973. var elementKey = this.keyFunction_(element);
  29974. delete this.queuedElements_[elementKey];
  29975. return element;
  29976. };
  29977. /**
  29978. * Enqueue an element. O(log N).
  29979. * @param {T} element Element.
  29980. * @return {boolean} The element was added to the queue.
  29981. */
  29982. PriorityQueue.prototype.enqueue = function (element) {
  29983. asserts_assert(!(this.keyFunction_(element) in this.queuedElements_), 31); // Tried to enqueue an `element` that was already added to the queue
  29984. var priority = this.priorityFunction_(element);
  29985. if (priority != DROP) {
  29986. this.elements_.push(element);
  29987. this.priorities_.push(priority);
  29988. this.queuedElements_[this.keyFunction_(element)] = true;
  29989. this.siftDown_(0, this.elements_.length - 1);
  29990. return true;
  29991. }
  29992. return false;
  29993. };
  29994. /**
  29995. * @return {number} Count.
  29996. */
  29997. PriorityQueue.prototype.getCount = function () {
  29998. return this.elements_.length;
  29999. };
  30000. /**
  30001. * Gets the index of the left child of the node at the given index.
  30002. * @param {number} index The index of the node to get the left child for.
  30003. * @return {number} The index of the left child.
  30004. * @private
  30005. */
  30006. PriorityQueue.prototype.getLeftChildIndex_ = function (index) {
  30007. return index * 2 + 1;
  30008. };
  30009. /**
  30010. * Gets the index of the right child of the node at the given index.
  30011. * @param {number} index The index of the node to get the right child for.
  30012. * @return {number} The index of the right child.
  30013. * @private
  30014. */
  30015. PriorityQueue.prototype.getRightChildIndex_ = function (index) {
  30016. return index * 2 + 2;
  30017. };
  30018. /**
  30019. * Gets the index of the parent of the node at the given index.
  30020. * @param {number} index The index of the node to get the parent for.
  30021. * @return {number} The index of the parent.
  30022. * @private
  30023. */
  30024. PriorityQueue.prototype.getParentIndex_ = function (index) {
  30025. return (index - 1) >> 1;
  30026. };
  30027. /**
  30028. * Make this a heap. O(N).
  30029. * @private
  30030. */
  30031. PriorityQueue.prototype.heapify_ = function () {
  30032. var i;
  30033. for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) {
  30034. this.siftUp_(i);
  30035. }
  30036. };
  30037. /**
  30038. * @return {boolean} Is empty.
  30039. */
  30040. PriorityQueue.prototype.isEmpty = function () {
  30041. return this.elements_.length === 0;
  30042. };
  30043. /**
  30044. * @param {string} key Key.
  30045. * @return {boolean} Is key queued.
  30046. */
  30047. PriorityQueue.prototype.isKeyQueued = function (key) {
  30048. return key in this.queuedElements_;
  30049. };
  30050. /**
  30051. * @param {T} element Element.
  30052. * @return {boolean} Is queued.
  30053. */
  30054. PriorityQueue.prototype.isQueued = function (element) {
  30055. return this.isKeyQueued(this.keyFunction_(element));
  30056. };
  30057. /**
  30058. * @param {number} index The index of the node to move down.
  30059. * @private
  30060. */
  30061. PriorityQueue.prototype.siftUp_ = function (index) {
  30062. var elements = this.elements_;
  30063. var priorities = this.priorities_;
  30064. var count = elements.length;
  30065. var element = elements[index];
  30066. var priority = priorities[index];
  30067. var startIndex = index;
  30068. while (index < count >> 1) {
  30069. var lIndex = this.getLeftChildIndex_(index);
  30070. var rIndex = this.getRightChildIndex_(index);
  30071. var smallerChildIndex = rIndex < count && priorities[rIndex] < priorities[lIndex]
  30072. ? rIndex
  30073. : lIndex;
  30074. elements[index] = elements[smallerChildIndex];
  30075. priorities[index] = priorities[smallerChildIndex];
  30076. index = smallerChildIndex;
  30077. }
  30078. elements[index] = element;
  30079. priorities[index] = priority;
  30080. this.siftDown_(startIndex, index);
  30081. };
  30082. /**
  30083. * @param {number} startIndex The index of the root.
  30084. * @param {number} index The index of the node to move up.
  30085. * @private
  30086. */
  30087. PriorityQueue.prototype.siftDown_ = function (startIndex, index) {
  30088. var elements = this.elements_;
  30089. var priorities = this.priorities_;
  30090. var element = elements[index];
  30091. var priority = priorities[index];
  30092. while (index > startIndex) {
  30093. var parentIndex = this.getParentIndex_(index);
  30094. if (priorities[parentIndex] > priority) {
  30095. elements[index] = elements[parentIndex];
  30096. priorities[index] = priorities[parentIndex];
  30097. index = parentIndex;
  30098. }
  30099. else {
  30100. break;
  30101. }
  30102. }
  30103. elements[index] = element;
  30104. priorities[index] = priority;
  30105. };
  30106. /**
  30107. * FIXME empty description for jsdoc
  30108. */
  30109. PriorityQueue.prototype.reprioritize = function () {
  30110. var priorityFunction = this.priorityFunction_;
  30111. var elements = this.elements_;
  30112. var priorities = this.priorities_;
  30113. var index = 0;
  30114. var n = elements.length;
  30115. var element, i, priority;
  30116. for (i = 0; i < n; ++i) {
  30117. element = elements[i];
  30118. priority = priorityFunction(element);
  30119. if (priority == DROP) {
  30120. delete this.queuedElements_[this.keyFunction_(element)];
  30121. }
  30122. else {
  30123. priorities[index] = priority;
  30124. elements[index++] = element;
  30125. }
  30126. }
  30127. elements.length = index;
  30128. priorities.length = index;
  30129. this.heapify_();
  30130. };
  30131. return PriorityQueue;
  30132. }());
  30133. /* harmony default export */ var structs_PriorityQueue = (PriorityQueue);
  30134. //# sourceMappingURL=PriorityQueue.js.map
  30135. ;// ./node_modules/ol/TileQueue.js
  30136. var TileQueue_extends = (undefined && undefined.__extends) || (function () {
  30137. var extendStatics = function (d, b) {
  30138. extendStatics = Object.setPrototypeOf ||
  30139. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30140. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  30141. return extendStatics(d, b);
  30142. };
  30143. return function (d, b) {
  30144. if (typeof b !== "function" && b !== null)
  30145. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  30146. extendStatics(d, b);
  30147. function __() { this.constructor = d; }
  30148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30149. };
  30150. })();
  30151. /**
  30152. * @module ol/TileQueue
  30153. */
  30154. /**
  30155. * @typedef {function(import("./Tile.js").default, string, import("./coordinate.js").Coordinate, number): number} PriorityFunction
  30156. */
  30157. var TileQueue = /** @class */ (function (_super) {
  30158. TileQueue_extends(TileQueue, _super);
  30159. /**
  30160. * @param {PriorityFunction} tilePriorityFunction Tile priority function.
  30161. * @param {function(): ?} tileChangeCallback Function called on each tile change event.
  30162. */
  30163. function TileQueue(tilePriorityFunction, tileChangeCallback) {
  30164. var _this = _super.call(this,
  30165. /**
  30166. * @param {Array} element Element.
  30167. * @return {number} Priority.
  30168. */
  30169. function (element) {
  30170. return tilePriorityFunction.apply(null, element);
  30171. },
  30172. /**
  30173. * @param {Array} element Element.
  30174. * @return {string} Key.
  30175. */
  30176. function (element) {
  30177. return /** @type {import("./Tile.js").default} */ (element[0]).getKey();
  30178. }) || this;
  30179. /** @private */
  30180. _this.boundHandleTileChange_ = _this.handleTileChange.bind(_this);
  30181. /**
  30182. * @private
  30183. * @type {function(): ?}
  30184. */
  30185. _this.tileChangeCallback_ = tileChangeCallback;
  30186. /**
  30187. * @private
  30188. * @type {number}
  30189. */
  30190. _this.tilesLoading_ = 0;
  30191. /**
  30192. * @private
  30193. * @type {!Object<string,boolean>}
  30194. */
  30195. _this.tilesLoadingKeys_ = {};
  30196. return _this;
  30197. }
  30198. /**
  30199. * @param {Array} element Element.
  30200. * @return {boolean} The element was added to the queue.
  30201. */
  30202. TileQueue.prototype.enqueue = function (element) {
  30203. var added = _super.prototype.enqueue.call(this, element);
  30204. if (added) {
  30205. var tile = element[0];
  30206. tile.addEventListener(EventType.CHANGE, this.boundHandleTileChange_);
  30207. }
  30208. return added;
  30209. };
  30210. /**
  30211. * @return {number} Number of tiles loading.
  30212. */
  30213. TileQueue.prototype.getTilesLoading = function () {
  30214. return this.tilesLoading_;
  30215. };
  30216. /**
  30217. * @param {import("./events/Event.js").default} event Event.
  30218. * @protected
  30219. */
  30220. TileQueue.prototype.handleTileChange = function (event) {
  30221. var tile = /** @type {import("./Tile.js").default} */ (event.target);
  30222. var state = tile.getState();
  30223. if (state === TileState.LOADED ||
  30224. state === TileState.ERROR ||
  30225. state === TileState.EMPTY) {
  30226. tile.removeEventListener(EventType.CHANGE, this.boundHandleTileChange_);
  30227. var tileKey = tile.getKey();
  30228. if (tileKey in this.tilesLoadingKeys_) {
  30229. delete this.tilesLoadingKeys_[tileKey];
  30230. --this.tilesLoading_;
  30231. }
  30232. this.tileChangeCallback_();
  30233. }
  30234. };
  30235. /**
  30236. * @param {number} maxTotalLoading Maximum number tiles to load simultaneously.
  30237. * @param {number} maxNewLoads Maximum number of new tiles to load.
  30238. */
  30239. TileQueue.prototype.loadMoreTiles = function (maxTotalLoading, maxNewLoads) {
  30240. var newLoads = 0;
  30241. var state, tile, tileKey;
  30242. while (this.tilesLoading_ < maxTotalLoading &&
  30243. newLoads < maxNewLoads &&
  30244. this.getCount() > 0) {
  30245. tile = /** @type {import("./Tile.js").default} */ (this.dequeue()[0]);
  30246. tileKey = tile.getKey();
  30247. state = tile.getState();
  30248. if (state === TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) {
  30249. this.tilesLoadingKeys_[tileKey] = true;
  30250. ++this.tilesLoading_;
  30251. ++newLoads;
  30252. tile.load();
  30253. }
  30254. }
  30255. };
  30256. return TileQueue;
  30257. }(structs_PriorityQueue));
  30258. /* harmony default export */ var ol_TileQueue = (TileQueue);
  30259. /**
  30260. * @param {import('./PluggableMap.js').FrameState} frameState Frame state.
  30261. * @param {import("./Tile.js").default} tile Tile.
  30262. * @param {string} tileSourceKey Tile source key.
  30263. * @param {import("./coordinate.js").Coordinate} tileCenter Tile center.
  30264. * @param {number} tileResolution Tile resolution.
  30265. * @return {number} Tile priority.
  30266. */
  30267. function getTilePriority(frameState, tile, tileSourceKey, tileCenter, tileResolution) {
  30268. // Filter out tiles at higher zoom levels than the current zoom level, or that
  30269. // are outside the visible extent.
  30270. if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
  30271. return DROP;
  30272. }
  30273. if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
  30274. return DROP;
  30275. }
  30276. // Prioritize the highest zoom level tiles closest to the focus.
  30277. // Tiles at higher zoom levels are prioritized using Math.log(tileResolution).
  30278. // Within a zoom level, tiles are prioritized by the distance in pixels between
  30279. // the center of the tile and the center of the viewport. The factor of 65536
  30280. // means that the prioritization should behave as desired for tiles up to
  30281. // 65536 * Math.log(2) = 45426 pixels from the focus.
  30282. var center = frameState.viewState.center;
  30283. var deltaX = tileCenter[0] - center[0];
  30284. var deltaY = tileCenter[1] - center[1];
  30285. return (65536 * Math.log(tileResolution) +
  30286. Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution);
  30287. }
  30288. //# sourceMappingURL=TileQueue.js.map
  30289. ;// ./node_modules/ol/ViewProperty.js
  30290. /**
  30291. * @module ol/ViewProperty
  30292. */
  30293. /**
  30294. * @enum {string}
  30295. */
  30296. /* harmony default export */ var ViewProperty = ({
  30297. CENTER: 'center',
  30298. RESOLUTION: 'resolution',
  30299. ROTATION: 'rotation',
  30300. });
  30301. //# sourceMappingURL=ViewProperty.js.map
  30302. ;// ./node_modules/ol/centerconstraint.js
  30303. /**
  30304. * @module ol/centerconstraint
  30305. */
  30306. /**
  30307. * @typedef {function((import("./coordinate.js").Coordinate|undefined), number, import("./size.js").Size, boolean=, Array<number>=): (import("./coordinate.js").Coordinate|undefined)} Type
  30308. */
  30309. /**
  30310. * @param {import("./extent.js").Extent} extent Extent.
  30311. * @param {boolean} onlyCenter If true, the constraint will only apply to the view center.
  30312. * @param {boolean} smooth If true, the view will be able to go slightly out of the given extent
  30313. * (only during interaction and animation).
  30314. * @return {Type} The constraint.
  30315. */
  30316. function createExtent(extent, onlyCenter, smooth) {
  30317. return (
  30318. /**
  30319. * @param {import("./coordinate.js").Coordinate|undefined} center Center.
  30320. * @param {number|undefined} resolution Resolution.
  30321. * @param {import("./size.js").Size} size Viewport size; unused if `onlyCenter` was specified.
  30322. * @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
  30323. * @param {Array<number>} [opt_centerShift] Shift between map center and viewport center.
  30324. * @return {import("./coordinate.js").Coordinate|undefined} Center.
  30325. */
  30326. function (center, resolution, size, opt_isMoving, opt_centerShift) {
  30327. if (!center) {
  30328. return undefined;
  30329. }
  30330. if (!resolution && !onlyCenter) {
  30331. return center;
  30332. }
  30333. var viewWidth = onlyCenter ? 0 : size[0] * resolution;
  30334. var viewHeight = onlyCenter ? 0 : size[1] * resolution;
  30335. var shiftX = opt_centerShift ? opt_centerShift[0] : 0;
  30336. var shiftY = opt_centerShift ? opt_centerShift[1] : 0;
  30337. var minX = extent[0] + viewWidth / 2 + shiftX;
  30338. var maxX = extent[2] - viewWidth / 2 + shiftX;
  30339. var minY = extent[1] + viewHeight / 2 + shiftY;
  30340. var maxY = extent[3] - viewHeight / 2 + shiftY;
  30341. // note: when zooming out of bounds, min and max values for x and y may
  30342. // end up inverted (min > max); this has to be accounted for
  30343. if (minX > maxX) {
  30344. minX = (maxX + minX) / 2;
  30345. maxX = minX;
  30346. }
  30347. if (minY > maxY) {
  30348. minY = (maxY + minY) / 2;
  30349. maxY = minY;
  30350. }
  30351. var x = math_clamp(center[0], minX, maxX);
  30352. var y = math_clamp(center[1], minY, maxY);
  30353. // during an interaction, allow some overscroll
  30354. if (opt_isMoving && smooth && resolution) {
  30355. var ratio = 30 * resolution;
  30356. x +=
  30357. -ratio * Math.log(1 + Math.max(0, minX - center[0]) / ratio) +
  30358. ratio * Math.log(1 + Math.max(0, center[0] - maxX) / ratio);
  30359. y +=
  30360. -ratio * Math.log(1 + Math.max(0, minY - center[1]) / ratio) +
  30361. ratio * Math.log(1 + Math.max(0, center[1] - maxY) / ratio);
  30362. }
  30363. return [x, y];
  30364. });
  30365. }
  30366. /**
  30367. * @param {import("./coordinate.js").Coordinate} [center] Center.
  30368. * @return {import("./coordinate.js").Coordinate|undefined} Center.
  30369. */
  30370. function none(center) {
  30371. return center;
  30372. }
  30373. //# sourceMappingURL=centerconstraint.js.map
  30374. ;// ./node_modules/ol/resolutionconstraint.js
  30375. /**
  30376. * @module ol/resolutionconstraint
  30377. */
  30378. /**
  30379. * @typedef {function((number|undefined), number, import("./size.js").Size, boolean=): (number|undefined)} Type
  30380. */
  30381. /**
  30382. * Returns a modified resolution taking into account the viewport size and maximum
  30383. * allowed extent.
  30384. * @param {number} resolution Resolution
  30385. * @param {import("./extent.js").Extent} maxExtent Maximum allowed extent.
  30386. * @param {import("./size.js").Size} viewportSize Viewport size.
  30387. * @param {boolean} showFullExtent Whether to show the full extent.
  30388. * @return {number} Capped resolution.
  30389. */
  30390. function getViewportClampedResolution(resolution, maxExtent, viewportSize, showFullExtent) {
  30391. var xResolution = extent_getWidth(maxExtent) / viewportSize[0];
  30392. var yResolution = getHeight(maxExtent) / viewportSize[1];
  30393. if (showFullExtent) {
  30394. return Math.min(resolution, Math.max(xResolution, yResolution));
  30395. }
  30396. return Math.min(resolution, Math.min(xResolution, yResolution));
  30397. }
  30398. /**
  30399. * Returns a modified resolution to be between maxResolution and minResolution while
  30400. * still allowing the value to be slightly out of bounds.
  30401. * Note: the computation is based on the logarithm function (ln):
  30402. * - at 1, ln(x) is 0
  30403. * - above 1, ln(x) keeps increasing but at a much slower pace than x
  30404. * The final result is clamped to prevent getting too far away from bounds.
  30405. * @param {number} resolution Resolution.
  30406. * @param {number} maxResolution Max resolution.
  30407. * @param {number} minResolution Min resolution.
  30408. * @return {number} Smoothed resolution.
  30409. */
  30410. function getSmoothClampedResolution(resolution, maxResolution, minResolution) {
  30411. var result = Math.min(resolution, maxResolution);
  30412. var ratio = 50;
  30413. result *=
  30414. Math.log(1 + ratio * Math.max(0, resolution / maxResolution - 1)) / ratio +
  30415. 1;
  30416. if (minResolution) {
  30417. result = Math.max(result, minResolution);
  30418. result /=
  30419. Math.log(1 + ratio * Math.max(0, minResolution / resolution - 1)) /
  30420. ratio +
  30421. 1;
  30422. }
  30423. return math_clamp(result, minResolution / 2, maxResolution * 2);
  30424. }
  30425. /**
  30426. * @param {Array<number>} resolutions Resolutions.
  30427. * @param {boolean} [opt_smooth] If true, the view will be able to slightly exceed resolution limits. Default: true.
  30428. * @param {import("./extent.js").Extent} [opt_maxExtent] Maximum allowed extent.
  30429. * @param {boolean} [opt_showFullExtent] If true, allows us to show the full extent. Default: false.
  30430. * @return {Type} Zoom function.
  30431. */
  30432. function createSnapToResolutions(resolutions, opt_smooth, opt_maxExtent, opt_showFullExtent) {
  30433. return (
  30434. /**
  30435. * @param {number|undefined} resolution Resolution.
  30436. * @param {number} direction Direction.
  30437. * @param {import("./size.js").Size} size Viewport size.
  30438. * @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
  30439. * @return {number|undefined} Resolution.
  30440. */
  30441. function (resolution, direction, size, opt_isMoving) {
  30442. if (resolution !== undefined) {
  30443. var maxResolution = resolutions[0];
  30444. var minResolution = resolutions[resolutions.length - 1];
  30445. var cappedMaxRes = opt_maxExtent
  30446. ? getViewportClampedResolution(maxResolution, opt_maxExtent, size, opt_showFullExtent)
  30447. : maxResolution;
  30448. // during interacting or animating, allow intermediary values
  30449. if (opt_isMoving) {
  30450. var smooth = opt_smooth !== undefined ? opt_smooth : true;
  30451. if (!smooth) {
  30452. return math_clamp(resolution, minResolution, cappedMaxRes);
  30453. }
  30454. return getSmoothClampedResolution(resolution, cappedMaxRes, minResolution);
  30455. }
  30456. var capped = Math.min(cappedMaxRes, resolution);
  30457. var z = Math.floor(linearFindNearest(resolutions, capped, direction));
  30458. if (resolutions[z] > cappedMaxRes && z < resolutions.length - 1) {
  30459. return resolutions[z + 1];
  30460. }
  30461. return resolutions[z];
  30462. }
  30463. else {
  30464. return undefined;
  30465. }
  30466. });
  30467. }
  30468. /**
  30469. * @param {number} power Power.
  30470. * @param {number} maxResolution Maximum resolution.
  30471. * @param {number} [opt_minResolution] Minimum resolution.
  30472. * @param {boolean} [opt_smooth] If true, the view will be able to slightly exceed resolution limits. Default: true.
  30473. * @param {import("./extent.js").Extent} [opt_maxExtent] Maximum allowed extent.
  30474. * @param {boolean} [opt_showFullExtent] If true, allows us to show the full extent. Default: false.
  30475. * @return {Type} Zoom function.
  30476. */
  30477. function createSnapToPower(power, maxResolution, opt_minResolution, opt_smooth, opt_maxExtent, opt_showFullExtent) {
  30478. return (
  30479. /**
  30480. * @param {number|undefined} resolution Resolution.
  30481. * @param {number} direction Direction.
  30482. * @param {import("./size.js").Size} size Viewport size.
  30483. * @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
  30484. * @return {number|undefined} Resolution.
  30485. */
  30486. function (resolution, direction, size, opt_isMoving) {
  30487. if (resolution !== undefined) {
  30488. var cappedMaxRes = opt_maxExtent
  30489. ? getViewportClampedResolution(maxResolution, opt_maxExtent, size, opt_showFullExtent)
  30490. : maxResolution;
  30491. var minResolution = opt_minResolution !== undefined ? opt_minResolution : 0;
  30492. // during interacting or animating, allow intermediary values
  30493. if (opt_isMoving) {
  30494. var smooth = opt_smooth !== undefined ? opt_smooth : true;
  30495. if (!smooth) {
  30496. return math_clamp(resolution, minResolution, cappedMaxRes);
  30497. }
  30498. return getSmoothClampedResolution(resolution, cappedMaxRes, minResolution);
  30499. }
  30500. var tolerance = 1e-9;
  30501. var minZoomLevel = Math.ceil(Math.log(maxResolution / cappedMaxRes) / Math.log(power) - tolerance);
  30502. var offset = -direction * (0.5 - tolerance) + 0.5;
  30503. var capped = Math.min(cappedMaxRes, resolution);
  30504. var cappedZoomLevel = Math.floor(Math.log(maxResolution / capped) / Math.log(power) + offset);
  30505. var zoomLevel = Math.max(minZoomLevel, cappedZoomLevel);
  30506. var newResolution = maxResolution / Math.pow(power, zoomLevel);
  30507. return math_clamp(newResolution, minResolution, cappedMaxRes);
  30508. }
  30509. else {
  30510. return undefined;
  30511. }
  30512. });
  30513. }
  30514. /**
  30515. * @param {number} maxResolution Max resolution.
  30516. * @param {number} minResolution Min resolution.
  30517. * @param {boolean} [opt_smooth] If true, the view will be able to slightly exceed resolution limits. Default: true.
  30518. * @param {import("./extent.js").Extent} [opt_maxExtent] Maximum allowed extent.
  30519. * @param {boolean} [opt_showFullExtent] If true, allows us to show the full extent. Default: false.
  30520. * @return {Type} Zoom function.
  30521. */
  30522. function createMinMaxResolution(maxResolution, minResolution, opt_smooth, opt_maxExtent, opt_showFullExtent) {
  30523. return (
  30524. /**
  30525. * @param {number|undefined} resolution Resolution.
  30526. * @param {number} direction Direction.
  30527. * @param {import("./size.js").Size} size Viewport size.
  30528. * @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
  30529. * @return {number|undefined} Resolution.
  30530. */
  30531. function (resolution, direction, size, opt_isMoving) {
  30532. if (resolution !== undefined) {
  30533. var cappedMaxRes = opt_maxExtent
  30534. ? getViewportClampedResolution(maxResolution, opt_maxExtent, size, opt_showFullExtent)
  30535. : maxResolution;
  30536. var smooth = opt_smooth !== undefined ? opt_smooth : true;
  30537. if (!smooth || !opt_isMoving) {
  30538. return math_clamp(resolution, minResolution, cappedMaxRes);
  30539. }
  30540. return getSmoothClampedResolution(resolution, cappedMaxRes, minResolution);
  30541. }
  30542. else {
  30543. return undefined;
  30544. }
  30545. });
  30546. }
  30547. //# sourceMappingURL=resolutionconstraint.js.map
  30548. ;// ./node_modules/ol/rotationconstraint.js
  30549. /**
  30550. * @module ol/rotationconstraint
  30551. */
  30552. /**
  30553. * @typedef {function((number|undefined), boolean=): (number|undefined)} Type
  30554. */
  30555. /**
  30556. * @param {number|undefined} rotation Rotation.
  30557. * @return {number|undefined} Rotation.
  30558. */
  30559. function disable(rotation) {
  30560. if (rotation !== undefined) {
  30561. return 0;
  30562. }
  30563. else {
  30564. return undefined;
  30565. }
  30566. }
  30567. /**
  30568. * @param {number|undefined} rotation Rotation.
  30569. * @return {number|undefined} Rotation.
  30570. */
  30571. function rotationconstraint_none(rotation) {
  30572. if (rotation !== undefined) {
  30573. return rotation;
  30574. }
  30575. else {
  30576. return undefined;
  30577. }
  30578. }
  30579. /**
  30580. * @param {number} n N.
  30581. * @return {Type} Rotation constraint.
  30582. */
  30583. function createSnapToN(n) {
  30584. var theta = (2 * Math.PI) / n;
  30585. return (
  30586. /**
  30587. * @param {number|undefined} rotation Rotation.
  30588. * @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
  30589. * @return {number|undefined} Rotation.
  30590. */
  30591. function (rotation, opt_isMoving) {
  30592. if (opt_isMoving) {
  30593. return rotation;
  30594. }
  30595. if (rotation !== undefined) {
  30596. rotation = Math.floor(rotation / theta + 0.5) * theta;
  30597. return rotation;
  30598. }
  30599. else {
  30600. return undefined;
  30601. }
  30602. });
  30603. }
  30604. /**
  30605. * @param {number} [opt_tolerance] Tolerance.
  30606. * @return {Type} Rotation constraint.
  30607. */
  30608. function createSnapToZero(opt_tolerance) {
  30609. var tolerance = opt_tolerance || math_toRadians(5);
  30610. return (
  30611. /**
  30612. * @param {number|undefined} rotation Rotation.
  30613. * @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
  30614. * @return {number|undefined} Rotation.
  30615. */
  30616. function (rotation, opt_isMoving) {
  30617. if (opt_isMoving) {
  30618. return rotation;
  30619. }
  30620. if (rotation !== undefined) {
  30621. if (Math.abs(rotation) <= tolerance) {
  30622. return 0;
  30623. }
  30624. else {
  30625. return rotation;
  30626. }
  30627. }
  30628. else {
  30629. return undefined;
  30630. }
  30631. });
  30632. }
  30633. //# sourceMappingURL=rotationconstraint.js.map
  30634. ;// ./node_modules/ol/View.js
  30635. var View_extends = (undefined && undefined.__extends) || (function () {
  30636. var extendStatics = function (d, b) {
  30637. extendStatics = Object.setPrototypeOf ||
  30638. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30639. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  30640. return extendStatics(d, b);
  30641. };
  30642. return function (d, b) {
  30643. if (typeof b !== "function" && b !== null)
  30644. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  30645. extendStatics(d, b);
  30646. function __() { this.constructor = d; }
  30647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30648. };
  30649. })();
  30650. /**
  30651. * @module ol/View
  30652. */
  30653. /**
  30654. * An animation configuration
  30655. *
  30656. * @typedef {Object} Animation
  30657. * @property {import("./coordinate.js").Coordinate} [sourceCenter] Source center.
  30658. * @property {import("./coordinate.js").Coordinate} [targetCenter] Target center.
  30659. * @property {number} [sourceResolution] Source resolution.
  30660. * @property {number} [targetResolution] Target resolution.
  30661. * @property {number} [sourceRotation] Source rotation.
  30662. * @property {number} [targetRotation] Target rotation.
  30663. * @property {import("./coordinate.js").Coordinate} [anchor] Anchor.
  30664. * @property {number} start Start.
  30665. * @property {number} duration Duration.
  30666. * @property {boolean} complete Complete.
  30667. * @property {function(number):number} easing Easing.
  30668. * @property {function(boolean):void} callback Callback.
  30669. */
  30670. /**
  30671. * @typedef {Object} Constraints
  30672. * @property {import("./centerconstraint.js").Type} center Center.
  30673. * @property {import("./resolutionconstraint.js").Type} resolution Resolution.
  30674. * @property {import("./rotationconstraint.js").Type} rotation Rotation.
  30675. */
  30676. /**
  30677. * @typedef {Object} FitOptions
  30678. * @property {import("./size.js").Size} [size] The size in pixels of the box to fit
  30679. * the extent into. Default is the current size of the first map in the DOM that
  30680. * uses this view, or `[100, 100]` if no such map is found.
  30681. * @property {!Array<number>} [padding=[0, 0, 0, 0]] Padding (in pixels) to be
  30682. * cleared inside the view. Values in the array are top, right, bottom and left
  30683. * padding.
  30684. * @property {boolean} [nearest=false] If the view `constrainResolution` option is `true`,
  30685. * get the nearest extent instead of the closest that actually fits the view.
  30686. * @property {number} [minResolution=0] Minimum resolution that we zoom to.
  30687. * @property {number} [maxZoom] Maximum zoom level that we zoom to. If
  30688. * `minResolution` is given, this property is ignored.
  30689. * @property {number} [duration] The duration of the animation in milliseconds.
  30690. * By default, there is no animation to the target extent.
  30691. * @property {function(number):number} [easing] The easing function used during
  30692. * the animation (defaults to {@link module:ol/easing.inAndOut}).
  30693. * The function will be called for each frame with a number representing a
  30694. * fraction of the animation's duration. The function should return a number
  30695. * between 0 and 1 representing the progress toward the destination state.
  30696. * @property {function(boolean):void} [callback] Function called when the view is in
  30697. * its final position. The callback will be called with `true` if the animation
  30698. * series completed on its own or `false` if it was cancelled.
  30699. */
  30700. /**
  30701. * @typedef {Object} ViewOptions
  30702. * @property {import("./coordinate.js").Coordinate} [center] The initial center for
  30703. * the view. If a user projection is not set, the coordinate system for the center is
  30704. * specified with the `projection` option. Layer sources will not be fetched if this
  30705. * is not set, but the center can be set later with {@link #setCenter}.
  30706. * @property {boolean|number} [constrainRotation=true] Rotation constraint.
  30707. * `false` means no constraint. `true` means no constraint, but snap to zero
  30708. * near zero. A number constrains the rotation to that number of values. For
  30709. * example, `4` will constrain the rotation to 0, 90, 180, and 270 degrees.
  30710. * @property {boolean} [enableRotation=true] Enable rotation.
  30711. * If `false`, a rotation constraint that always sets the rotation to zero is
  30712. * used. The `constrainRotation` option has no effect if `enableRotation` is
  30713. * `false`.
  30714. * @property {import("./extent.js").Extent} [extent] The extent that constrains the
  30715. * view, in other words, nothing outside of this extent can be visible on the map.
  30716. * @property {boolean} [constrainOnlyCenter=false] If true, the extent
  30717. * constraint will only apply to the view center and not the whole extent.
  30718. * @property {boolean} [smoothExtentConstraint=true] If true, the extent
  30719. * constraint will be applied smoothly, i.e. allow the view to go slightly outside
  30720. * of the given `extent`.
  30721. * @property {number} [maxResolution] The maximum resolution used to determine
  30722. * the resolution constraint. It is used together with `minResolution` (or
  30723. * `maxZoom`) and `zoomFactor`. If unspecified it is calculated in such a way
  30724. * that the projection's validity extent fits in a 256x256 px tile. If the
  30725. * projection is Spherical Mercator (the default) then `maxResolution` defaults
  30726. * to `40075016.68557849 / 256 = 156543.03392804097`.
  30727. * @property {number} [minResolution] The minimum resolution used to determine
  30728. * the resolution constraint. It is used together with `maxResolution` (or
  30729. * `minZoom`) and `zoomFactor`. If unspecified it is calculated assuming 29
  30730. * zoom levels (with a factor of 2). If the projection is Spherical Mercator
  30731. * (the default) then `minResolution` defaults to
  30732. * `40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253`.
  30733. * @property {number} [maxZoom=28] The maximum zoom level used to determine the
  30734. * resolution constraint. It is used together with `minZoom` (or
  30735. * `maxResolution`) and `zoomFactor`. Note that if `minResolution` is also
  30736. * provided, it is given precedence over `maxZoom`.
  30737. * @property {number} [minZoom=0] The minimum zoom level used to determine the
  30738. * resolution constraint. It is used together with `maxZoom` (or
  30739. * `minResolution`) and `zoomFactor`. Note that if `maxResolution` is also
  30740. * provided, it is given precedence over `minZoom`.
  30741. * @property {boolean} [multiWorld=false] If `false` the view is constrained so
  30742. * only one world is visible, and you cannot pan off the edge. If `true` the map
  30743. * may show multiple worlds at low zoom levels. Only used if the `projection` is
  30744. * global. Note that if `extent` is also provided it is given precedence.
  30745. * @property {boolean} [constrainResolution=false] If true, the view will always
  30746. * animate to the closest zoom level after an interaction; false means
  30747. * intermediary zoom levels are allowed.
  30748. * @property {boolean} [smoothResolutionConstraint=true] If true, the resolution
  30749. * min/max values will be applied smoothly, i. e. allow the view to exceed slightly
  30750. * the given resolution or zoom bounds.
  30751. * @property {boolean} [showFullExtent=false] Allow the view to be zoomed out to
  30752. * show the full configured extent. By default, when a view is configured with an
  30753. * extent, users will not be able to zoom out so the viewport exceeds the extent in
  30754. * either dimension. This means the full extent may not be visible if the viewport
  30755. * is taller or wider than the aspect ratio of the configured extent. If
  30756. * showFullExtent is true, the user will be able to zoom out so that the viewport
  30757. * exceeds the height or width of the configured extent, but not both, allowing the
  30758. * full extent to be shown.
  30759. * @property {import("./proj.js").ProjectionLike} [projection='EPSG:3857'] The
  30760. * projection. The default is Spherical Mercator.
  30761. * @property {number} [resolution] The initial resolution for the view. The
  30762. * units are `projection` units per pixel (e.g. meters per pixel). An
  30763. * alternative to setting this is to set `zoom`. Layer sources will not be
  30764. * fetched if neither this nor `zoom` are defined, but they can be set later
  30765. * with {@link #setZoom} or {@link #setResolution}.
  30766. * @property {Array<number>} [resolutions] Resolutions that determine the
  30767. * zoom levels if specified. The index in the array corresponds to the zoom level,
  30768. * therefore the resolution values have to be in descending order. It also constrains
  30769. * the resolution by the minimum and maximum value. If set the `maxResolution`,
  30770. * `minResolution`, `minZoom`, `maxZoom`, and `zoomFactor` options are ignored.
  30771. * @property {number} [rotation=0] The initial rotation for the view in radians
  30772. * (positive rotation clockwise, 0 means North).
  30773. * @property {number} [zoom] Only used if `resolution` is not defined. Zoom
  30774. * level used to calculate the initial resolution for the view.
  30775. * @property {number} [zoomFactor=2] The zoom factor used to compute the
  30776. * corresponding resolution.
  30777. * @property {!Array<number>} [padding=[0, 0, 0, 0]] Padding (in css pixels).
  30778. * If the map viewport is partially covered with other content (overlays) along
  30779. * its edges, this setting allows to shift the center of the viewport away from
  30780. * that content. The order of the values is top, right, bottom, left.
  30781. */
  30782. /**
  30783. * @typedef {Object} AnimationOptions
  30784. * @property {import("./coordinate.js").Coordinate} [center] The center of the view at the end of
  30785. * the animation.
  30786. * @property {number} [zoom] The zoom level of the view at the end of the
  30787. * animation. This takes precedence over `resolution`.
  30788. * @property {number} [resolution] The resolution of the view at the end
  30789. * of the animation. If `zoom` is also provided, this option will be ignored.
  30790. * @property {number} [rotation] The rotation of the view at the end of
  30791. * the animation.
  30792. * @property {import("./coordinate.js").Coordinate} [anchor] Optional anchor to remain fixed
  30793. * during a rotation or resolution animation.
  30794. * @property {number} [duration=1000] The duration of the animation in milliseconds.
  30795. * @property {function(number):number} [easing] The easing function used
  30796. * during the animation (defaults to {@link module:ol/easing.inAndOut}).
  30797. * The function will be called for each frame with a number representing a
  30798. * fraction of the animation's duration. The function should return a number
  30799. * between 0 and 1 representing the progress toward the destination state.
  30800. */
  30801. /**
  30802. * @typedef {Object} State
  30803. * @property {import("./coordinate.js").Coordinate} center Center.
  30804. * @property {import("./proj/Projection.js").default} projection Projection.
  30805. * @property {number} resolution Resolution.
  30806. * @property {import("./coordinate.js").Coordinate} [nextCenter] The next center during an animation series.
  30807. * @property {number} [nextResolution] The next resolution during an animation series.
  30808. * @property {number} [nextRotation] The next rotation during an animation series.
  30809. * @property {number} rotation Rotation.
  30810. * @property {number} zoom Zoom.
  30811. */
  30812. /**
  30813. * Default min zoom level for the map view.
  30814. * @type {number}
  30815. */
  30816. var DEFAULT_MIN_ZOOM = 0;
  30817. /**
  30818. * @typedef {import("./ObjectEventType").Types|'change:center'|'change:resolution'|'change:rotation'} ViewObjectEventTypes
  30819. */
  30820. /***
  30821. * @template Return
  30822. * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
  30823. * import("./Observable").OnSignature<ViewObjectEventTypes, import("./Object").ObjectEvent, Return> &
  30824. * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|ViewObjectEventTypes, Return>} ViewOnSignature
  30825. */
  30826. /**
  30827. * @classdesc
  30828. * A View object represents a simple 2D view of the map.
  30829. *
  30830. * This is the object to act upon to change the center, resolution,
  30831. * and rotation of the map.
  30832. *
  30833. * A View has a `projection`. The projection determines the
  30834. * coordinate system of the center, and its units determine the units of the
  30835. * resolution (projection units per pixel). The default projection is
  30836. * Web Mercator (EPSG:3857).
  30837. *
  30838. * ### The view states
  30839. *
  30840. * A View is determined by three states: `center`, `resolution`,
  30841. * and `rotation`. Each state has a corresponding getter and setter, e.g.
  30842. * `getCenter` and `setCenter` for the `center` state.
  30843. *
  30844. * The `zoom` state is actually not saved on the view: all computations
  30845. * internally use the `resolution` state. Still, the `setZoom` and `getZoom`
  30846. * methods are available, as well as `getResolutionForZoom` and
  30847. * `getZoomForResolution` to switch from one system to the other.
  30848. *
  30849. * ### The constraints
  30850. *
  30851. * `setCenter`, `setResolution` and `setRotation` can be used to change the
  30852. * states of the view, but any constraint defined in the constructor will
  30853. * be applied along the way.
  30854. *
  30855. * A View object can have a *resolution constraint*, a *rotation constraint*
  30856. * and a *center constraint*.
  30857. *
  30858. * The *resolution constraint* typically restricts min/max values and
  30859. * snaps to specific resolutions. It is determined by the following
  30860. * options: `resolutions`, `maxResolution`, `maxZoom` and `zoomFactor`.
  30861. * If `resolutions` is set, the other three options are ignored. See
  30862. * documentation for each option for more information. By default, the view
  30863. * only has a min/max restriction and allow intermediary zoom levels when
  30864. * pinch-zooming for example.
  30865. *
  30866. * The *rotation constraint* snaps to specific angles. It is determined
  30867. * by the following options: `enableRotation` and `constrainRotation`.
  30868. * By default rotation is allowed and its value is snapped to zero when approaching the
  30869. * horizontal.
  30870. *
  30871. * The *center constraint* is determined by the `extent` option. By
  30872. * default the view center is not constrained at all.
  30873. *
  30874. * ### Changing the view state
  30875. *
  30876. * It is important to note that `setZoom`, `setResolution`, `setCenter` and
  30877. * `setRotation` are subject to the above mentioned constraints. As such, it
  30878. * may sometimes not be possible to know in advance the resulting state of the
  30879. * View. For example, calling `setResolution(10)` does not guarantee that
  30880. * `getResolution()` will return `10`.
  30881. *
  30882. * A consequence of this is that, when applying a delta on the view state, one
  30883. * should use `adjustCenter`, `adjustRotation`, `adjustZoom` and `adjustResolution`
  30884. * rather than the corresponding setters. This will let view do its internal
  30885. * computations. Besides, the `adjust*` methods also take an `opt_anchor`
  30886. * argument which allows specifying an origin for the transformation.
  30887. *
  30888. * ### Interacting with the view
  30889. *
  30890. * View constraints are usually only applied when the view is *at rest*, meaning that
  30891. * no interaction or animation is ongoing. As such, if the user puts the view in a
  30892. * state that is not equivalent to a constrained one (e.g. rotating the view when
  30893. * the snap angle is 0), an animation will be triggered at the interaction end to
  30894. * put back the view to a stable state;
  30895. *
  30896. * @api
  30897. */
  30898. var View = /** @class */ (function (_super) {
  30899. View_extends(View, _super);
  30900. /**
  30901. * @param {ViewOptions} [opt_options] View options.
  30902. */
  30903. function View(opt_options) {
  30904. var _this = _super.call(this) || this;
  30905. /***
  30906. * @type {ViewOnSignature<import("./events").EventsKey>}
  30907. */
  30908. _this.on;
  30909. /***
  30910. * @type {ViewOnSignature<import("./events").EventsKey>}
  30911. */
  30912. _this.once;
  30913. /***
  30914. * @type {ViewOnSignature<void>}
  30915. */
  30916. _this.un;
  30917. var options = obj_assign({}, opt_options);
  30918. /**
  30919. * @private
  30920. * @type {Array<number>}
  30921. */
  30922. _this.hints_ = [0, 0];
  30923. /**
  30924. * @private
  30925. * @type {Array<Array<Animation>>}
  30926. */
  30927. _this.animations_ = [];
  30928. /**
  30929. * @private
  30930. * @type {number|undefined}
  30931. */
  30932. _this.updateAnimationKey_;
  30933. /**
  30934. * @private
  30935. * @const
  30936. * @type {import("./proj/Projection.js").default}
  30937. */
  30938. _this.projection_ = createProjection(options.projection, 'EPSG:3857');
  30939. /**
  30940. * @private
  30941. * @type {import("./size.js").Size}
  30942. */
  30943. _this.viewportSize_ = [100, 100];
  30944. /**
  30945. * @private
  30946. * @type {import("./coordinate.js").Coordinate|undefined}
  30947. */
  30948. _this.targetCenter_ = null;
  30949. /**
  30950. * @private
  30951. * @type {number|undefined}
  30952. */
  30953. _this.targetResolution_;
  30954. /**
  30955. * @private
  30956. * @type {number|undefined}
  30957. */
  30958. _this.targetRotation_;
  30959. /**
  30960. * @private
  30961. * @type {import("./coordinate.js").Coordinate}
  30962. */
  30963. _this.nextCenter_ = null;
  30964. /**
  30965. * @private
  30966. * @type {number}
  30967. */
  30968. _this.nextResolution_;
  30969. /**
  30970. * @private
  30971. * @type {number}
  30972. */
  30973. _this.nextRotation_;
  30974. /**
  30975. * @private
  30976. * @type {import("./coordinate.js").Coordinate|undefined}
  30977. */
  30978. _this.cancelAnchor_ = undefined;
  30979. if (options.projection) {
  30980. disableCoordinateWarning();
  30981. }
  30982. if (options.center) {
  30983. options.center = fromUserCoordinate(options.center, _this.projection_);
  30984. }
  30985. if (options.extent) {
  30986. options.extent = proj_fromUserExtent(options.extent, _this.projection_);
  30987. }
  30988. _this.applyOptions_(options);
  30989. return _this;
  30990. }
  30991. /**
  30992. * Set up the view with the given options.
  30993. * @param {ViewOptions} options View options.
  30994. */
  30995. View.prototype.applyOptions_ = function (options) {
  30996. var properties = obj_assign({}, options);
  30997. for (var key in ViewProperty) {
  30998. delete properties[key];
  30999. }
  31000. this.setProperties(properties, true);
  31001. var resolutionConstraintInfo = createResolutionConstraint(options);
  31002. /**
  31003. * @private
  31004. * @type {number}
  31005. */
  31006. this.maxResolution_ = resolutionConstraintInfo.maxResolution;
  31007. /**
  31008. * @private
  31009. * @type {number}
  31010. */
  31011. this.minResolution_ = resolutionConstraintInfo.minResolution;
  31012. /**
  31013. * @private
  31014. * @type {number}
  31015. */
  31016. this.zoomFactor_ = resolutionConstraintInfo.zoomFactor;
  31017. /**
  31018. * @private
  31019. * @type {Array<number>|undefined}
  31020. */
  31021. this.resolutions_ = options.resolutions;
  31022. /**
  31023. * @type {Array<number>|undefined}
  31024. * @private
  31025. */
  31026. this.padding_ = options.padding;
  31027. /**
  31028. * @private
  31029. * @type {number}
  31030. */
  31031. this.minZoom_ = resolutionConstraintInfo.minZoom;
  31032. var centerConstraint = createCenterConstraint(options);
  31033. var resolutionConstraint = resolutionConstraintInfo.constraint;
  31034. var rotationConstraint = createRotationConstraint(options);
  31035. /**
  31036. * @private
  31037. * @type {Constraints}
  31038. */
  31039. this.constraints_ = {
  31040. center: centerConstraint,
  31041. resolution: resolutionConstraint,
  31042. rotation: rotationConstraint,
  31043. };
  31044. this.setRotation(options.rotation !== undefined ? options.rotation : 0);
  31045. this.setCenterInternal(options.center !== undefined ? options.center : null);
  31046. if (options.resolution !== undefined) {
  31047. this.setResolution(options.resolution);
  31048. }
  31049. else if (options.zoom !== undefined) {
  31050. this.setZoom(options.zoom);
  31051. }
  31052. };
  31053. Object.defineProperty(View.prototype, "padding", {
  31054. /**
  31055. * Padding (in css pixels).
  31056. * If the map viewport is partially covered with other content (overlays) along
  31057. * its edges, this setting allows to shift the center of the viewport away from that
  31058. * content. The order of the values in the array is top, right, bottom, left.
  31059. * The default is no padding, which is equivalent to `[0, 0, 0, 0]`.
  31060. * @type {Array<number>|undefined}
  31061. * @api
  31062. */
  31063. get: function () {
  31064. return this.padding_;
  31065. },
  31066. set: function (padding) {
  31067. var oldPadding = this.padding_;
  31068. this.padding_ = padding;
  31069. var center = this.getCenter();
  31070. if (center) {
  31071. var newPadding = padding || [0, 0, 0, 0];
  31072. oldPadding = oldPadding || [0, 0, 0, 0];
  31073. var resolution = this.getResolution();
  31074. var offsetX = (resolution / 2) *
  31075. (newPadding[3] - oldPadding[3] + oldPadding[1] - newPadding[1]);
  31076. var offsetY = (resolution / 2) *
  31077. (newPadding[0] - oldPadding[0] + oldPadding[2] - newPadding[2]);
  31078. this.setCenterInternal([center[0] + offsetX, center[1] - offsetY]);
  31079. }
  31080. },
  31081. enumerable: false,
  31082. configurable: true
  31083. });
  31084. /**
  31085. * Get an updated version of the view options used to construct the view. The
  31086. * current resolution (or zoom), center, and rotation are applied to any stored
  31087. * options. The provided options can be used to apply new min/max zoom or
  31088. * resolution limits.
  31089. * @param {ViewOptions} newOptions New options to be applied.
  31090. * @return {ViewOptions} New options updated with the current view state.
  31091. */
  31092. View.prototype.getUpdatedOptions_ = function (newOptions) {
  31093. var options = this.getProperties();
  31094. // preserve resolution (or zoom)
  31095. if (options.resolution !== undefined) {
  31096. options.resolution = this.getResolution();
  31097. }
  31098. else {
  31099. options.zoom = this.getZoom();
  31100. }
  31101. // preserve center
  31102. options.center = this.getCenterInternal();
  31103. // preserve rotation
  31104. options.rotation = this.getRotation();
  31105. return obj_assign({}, options, newOptions);
  31106. };
  31107. /**
  31108. * Animate the view. The view's center, zoom (or resolution), and rotation
  31109. * can be animated for smooth transitions between view states. For example,
  31110. * to animate the view to a new zoom level:
  31111. *
  31112. * view.animate({zoom: view.getZoom() + 1});
  31113. *
  31114. * By default, the animation lasts one second and uses in-and-out easing. You
  31115. * can customize this behavior by including `duration` (in milliseconds) and
  31116. * `easing` options (see {@link module:ol/easing}).
  31117. *
  31118. * To chain together multiple animations, call the method with multiple
  31119. * animation objects. For example, to first zoom and then pan:
  31120. *
  31121. * view.animate({zoom: 10}, {center: [0, 0]});
  31122. *
  31123. * If you provide a function as the last argument to the animate method, it
  31124. * will get called at the end of an animation series. The callback will be
  31125. * called with `true` if the animation series completed on its own or `false`
  31126. * if it was cancelled.
  31127. *
  31128. * Animations are cancelled by user interactions (e.g. dragging the map) or by
  31129. * calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()`
  31130. * (or another method that calls one of these).
  31131. *
  31132. * @param {...(AnimationOptions|function(boolean): void)} var_args Animation
  31133. * options. Multiple animations can be run in series by passing multiple
  31134. * options objects. To run multiple animations in parallel, call the method
  31135. * multiple times. An optional callback can be provided as a final
  31136. * argument. The callback will be called with a boolean indicating whether
  31137. * the animation completed without being cancelled.
  31138. * @api
  31139. */
  31140. View.prototype.animate = function (var_args) {
  31141. if (this.isDef() && !this.getAnimating()) {
  31142. this.resolveConstraints(0);
  31143. }
  31144. var args = new Array(arguments.length);
  31145. for (var i = 0; i < args.length; ++i) {
  31146. var options = arguments[i];
  31147. if (options.center) {
  31148. options = obj_assign({}, options);
  31149. options.center = fromUserCoordinate(options.center, this.getProjection());
  31150. }
  31151. if (options.anchor) {
  31152. options = obj_assign({}, options);
  31153. options.anchor = fromUserCoordinate(options.anchor, this.getProjection());
  31154. }
  31155. args[i] = options;
  31156. }
  31157. this.animateInternal.apply(this, args);
  31158. };
  31159. /**
  31160. * @param {...(AnimationOptions|function(boolean): void)} var_args Animation options.
  31161. */
  31162. View.prototype.animateInternal = function (var_args) {
  31163. var animationCount = arguments.length;
  31164. var callback;
  31165. if (animationCount > 1 &&
  31166. typeof arguments[animationCount - 1] === 'function') {
  31167. callback = arguments[animationCount - 1];
  31168. --animationCount;
  31169. }
  31170. var i = 0;
  31171. for (; i < animationCount && !this.isDef(); ++i) {
  31172. // if view properties are not yet set, shortcut to the final state
  31173. var state = arguments[i];
  31174. if (state.center) {
  31175. this.setCenterInternal(state.center);
  31176. }
  31177. if (state.zoom !== undefined) {
  31178. this.setZoom(state.zoom);
  31179. }
  31180. else if (state.resolution) {
  31181. this.setResolution(state.resolution);
  31182. }
  31183. if (state.rotation !== undefined) {
  31184. this.setRotation(state.rotation);
  31185. }
  31186. }
  31187. if (i === animationCount) {
  31188. if (callback) {
  31189. animationCallback(callback, true);
  31190. }
  31191. return;
  31192. }
  31193. var start = Date.now();
  31194. var center = this.targetCenter_.slice();
  31195. var resolution = this.targetResolution_;
  31196. var rotation = this.targetRotation_;
  31197. var series = [];
  31198. for (; i < animationCount; ++i) {
  31199. var options = /** @type {AnimationOptions} */ (arguments[i]);
  31200. var animation = {
  31201. start: start,
  31202. complete: false,
  31203. anchor: options.anchor,
  31204. duration: options.duration !== undefined ? options.duration : 1000,
  31205. easing: options.easing || inAndOut,
  31206. callback: callback,
  31207. };
  31208. if (options.center) {
  31209. animation.sourceCenter = center;
  31210. animation.targetCenter = options.center.slice();
  31211. center = animation.targetCenter;
  31212. }
  31213. if (options.zoom !== undefined) {
  31214. animation.sourceResolution = resolution;
  31215. animation.targetResolution = this.getResolutionForZoom(options.zoom);
  31216. resolution = animation.targetResolution;
  31217. }
  31218. else if (options.resolution) {
  31219. animation.sourceResolution = resolution;
  31220. animation.targetResolution = options.resolution;
  31221. resolution = animation.targetResolution;
  31222. }
  31223. if (options.rotation !== undefined) {
  31224. animation.sourceRotation = rotation;
  31225. var delta = math_modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI;
  31226. animation.targetRotation = rotation + delta;
  31227. rotation = animation.targetRotation;
  31228. }
  31229. // check if animation is a no-op
  31230. if (isNoopAnimation(animation)) {
  31231. animation.complete = true;
  31232. // we still push it onto the series for callback handling
  31233. }
  31234. else {
  31235. start += animation.duration;
  31236. }
  31237. series.push(animation);
  31238. }
  31239. this.animations_.push(series);
  31240. this.setHint(ViewHint.ANIMATING, 1);
  31241. this.updateAnimations_();
  31242. };
  31243. /**
  31244. * Determine if the view is being animated.
  31245. * @return {boolean} The view is being animated.
  31246. * @api
  31247. */
  31248. View.prototype.getAnimating = function () {
  31249. return this.hints_[ViewHint.ANIMATING] > 0;
  31250. };
  31251. /**
  31252. * Determine if the user is interacting with the view, such as panning or zooming.
  31253. * @return {boolean} The view is being interacted with.
  31254. * @api
  31255. */
  31256. View.prototype.getInteracting = function () {
  31257. return this.hints_[ViewHint.INTERACTING] > 0;
  31258. };
  31259. /**
  31260. * Cancel any ongoing animations.
  31261. * @api
  31262. */
  31263. View.prototype.cancelAnimations = function () {
  31264. this.setHint(ViewHint.ANIMATING, -this.hints_[ViewHint.ANIMATING]);
  31265. var anchor;
  31266. for (var i = 0, ii = this.animations_.length; i < ii; ++i) {
  31267. var series = this.animations_[i];
  31268. if (series[0].callback) {
  31269. animationCallback(series[0].callback, false);
  31270. }
  31271. if (!anchor) {
  31272. for (var j = 0, jj = series.length; j < jj; ++j) {
  31273. var animation = series[j];
  31274. if (!animation.complete) {
  31275. anchor = animation.anchor;
  31276. break;
  31277. }
  31278. }
  31279. }
  31280. }
  31281. this.animations_.length = 0;
  31282. this.cancelAnchor_ = anchor;
  31283. this.nextCenter_ = null;
  31284. this.nextResolution_ = NaN;
  31285. this.nextRotation_ = NaN;
  31286. };
  31287. /**
  31288. * Update all animations.
  31289. */
  31290. View.prototype.updateAnimations_ = function () {
  31291. if (this.updateAnimationKey_ !== undefined) {
  31292. cancelAnimationFrame(this.updateAnimationKey_);
  31293. this.updateAnimationKey_ = undefined;
  31294. }
  31295. if (!this.getAnimating()) {
  31296. return;
  31297. }
  31298. var now = Date.now();
  31299. var more = false;
  31300. for (var i = this.animations_.length - 1; i >= 0; --i) {
  31301. var series = this.animations_[i];
  31302. var seriesComplete = true;
  31303. for (var j = 0, jj = series.length; j < jj; ++j) {
  31304. var animation = series[j];
  31305. if (animation.complete) {
  31306. continue;
  31307. }
  31308. var elapsed = now - animation.start;
  31309. var fraction = animation.duration > 0 ? elapsed / animation.duration : 1;
  31310. if (fraction >= 1) {
  31311. animation.complete = true;
  31312. fraction = 1;
  31313. }
  31314. else {
  31315. seriesComplete = false;
  31316. }
  31317. var progress = animation.easing(fraction);
  31318. if (animation.sourceCenter) {
  31319. var x0 = animation.sourceCenter[0];
  31320. var y0 = animation.sourceCenter[1];
  31321. var x1 = animation.targetCenter[0];
  31322. var y1 = animation.targetCenter[1];
  31323. this.nextCenter_ = animation.targetCenter;
  31324. var x = x0 + progress * (x1 - x0);
  31325. var y = y0 + progress * (y1 - y0);
  31326. this.targetCenter_ = [x, y];
  31327. }
  31328. if (animation.sourceResolution && animation.targetResolution) {
  31329. var resolution = progress === 1
  31330. ? animation.targetResolution
  31331. : animation.sourceResolution +
  31332. progress *
  31333. (animation.targetResolution - animation.sourceResolution);
  31334. if (animation.anchor) {
  31335. var size = this.getViewportSize_(this.getRotation());
  31336. var constrainedResolution = this.constraints_.resolution(resolution, 0, size, true);
  31337. this.targetCenter_ = this.calculateCenterZoom(constrainedResolution, animation.anchor);
  31338. }
  31339. this.nextResolution_ = animation.targetResolution;
  31340. this.targetResolution_ = resolution;
  31341. this.applyTargetState_(true);
  31342. }
  31343. if (animation.sourceRotation !== undefined &&
  31344. animation.targetRotation !== undefined) {
  31345. var rotation = progress === 1
  31346. ? math_modulo(animation.targetRotation + Math.PI, 2 * Math.PI) -
  31347. Math.PI
  31348. : animation.sourceRotation +
  31349. progress *
  31350. (animation.targetRotation - animation.sourceRotation);
  31351. if (animation.anchor) {
  31352. var constrainedRotation = this.constraints_.rotation(rotation, true);
  31353. this.targetCenter_ = this.calculateCenterRotate(constrainedRotation, animation.anchor);
  31354. }
  31355. this.nextRotation_ = animation.targetRotation;
  31356. this.targetRotation_ = rotation;
  31357. }
  31358. this.applyTargetState_(true);
  31359. more = true;
  31360. if (!animation.complete) {
  31361. break;
  31362. }
  31363. }
  31364. if (seriesComplete) {
  31365. this.animations_[i] = null;
  31366. this.setHint(ViewHint.ANIMATING, -1);
  31367. this.nextCenter_ = null;
  31368. this.nextResolution_ = NaN;
  31369. this.nextRotation_ = NaN;
  31370. var callback = series[0].callback;
  31371. if (callback) {
  31372. animationCallback(callback, true);
  31373. }
  31374. }
  31375. }
  31376. // prune completed series
  31377. this.animations_ = this.animations_.filter(Boolean);
  31378. if (more && this.updateAnimationKey_ === undefined) {
  31379. this.updateAnimationKey_ = requestAnimationFrame(this.updateAnimations_.bind(this));
  31380. }
  31381. };
  31382. /**
  31383. * @param {number} rotation Target rotation.
  31384. * @param {import("./coordinate.js").Coordinate} anchor Rotation anchor.
  31385. * @return {import("./coordinate.js").Coordinate|undefined} Center for rotation and anchor.
  31386. */
  31387. View.prototype.calculateCenterRotate = function (rotation, anchor) {
  31388. var center;
  31389. var currentCenter = this.getCenterInternal();
  31390. if (currentCenter !== undefined) {
  31391. center = [currentCenter[0] - anchor[0], currentCenter[1] - anchor[1]];
  31392. rotate(center, rotation - this.getRotation());
  31393. coordinate_add(center, anchor);
  31394. }
  31395. return center;
  31396. };
  31397. /**
  31398. * @param {number} resolution Target resolution.
  31399. * @param {import("./coordinate.js").Coordinate} anchor Zoom anchor.
  31400. * @return {import("./coordinate.js").Coordinate|undefined} Center for resolution and anchor.
  31401. */
  31402. View.prototype.calculateCenterZoom = function (resolution, anchor) {
  31403. var center;
  31404. var currentCenter = this.getCenterInternal();
  31405. var currentResolution = this.getResolution();
  31406. if (currentCenter !== undefined && currentResolution !== undefined) {
  31407. var x = anchor[0] -
  31408. (resolution * (anchor[0] - currentCenter[0])) / currentResolution;
  31409. var y = anchor[1] -
  31410. (resolution * (anchor[1] - currentCenter[1])) / currentResolution;
  31411. center = [x, y];
  31412. }
  31413. return center;
  31414. };
  31415. /**
  31416. * Returns the current viewport size.
  31417. * @private
  31418. * @param {number} [opt_rotation] Take into account the rotation of the viewport when giving the size
  31419. * @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
  31420. */
  31421. View.prototype.getViewportSize_ = function (opt_rotation) {
  31422. var size = this.viewportSize_;
  31423. if (opt_rotation) {
  31424. var w = size[0];
  31425. var h = size[1];
  31426. return [
  31427. Math.abs(w * Math.cos(opt_rotation)) +
  31428. Math.abs(h * Math.sin(opt_rotation)),
  31429. Math.abs(w * Math.sin(opt_rotation)) +
  31430. Math.abs(h * Math.cos(opt_rotation)),
  31431. ];
  31432. }
  31433. else {
  31434. return size;
  31435. }
  31436. };
  31437. /**
  31438. * Stores the viewport size on the view. The viewport size is not read every time from the DOM
  31439. * to avoid performance hit and layout reflow.
  31440. * This should be done on map size change.
  31441. * Note: the constraints are not resolved during an animation to avoid stopping it
  31442. * @param {import("./size.js").Size} [opt_size] Viewport size; if undefined, [100, 100] is assumed
  31443. */
  31444. View.prototype.setViewportSize = function (opt_size) {
  31445. this.viewportSize_ = Array.isArray(opt_size)
  31446. ? opt_size.slice()
  31447. : [100, 100];
  31448. if (!this.getAnimating()) {
  31449. this.resolveConstraints(0);
  31450. }
  31451. };
  31452. /**
  31453. * Get the view center.
  31454. * @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
  31455. * @observable
  31456. * @api
  31457. */
  31458. View.prototype.getCenter = function () {
  31459. var center = this.getCenterInternal();
  31460. if (!center) {
  31461. return center;
  31462. }
  31463. return toUserCoordinate(center, this.getProjection());
  31464. };
  31465. /**
  31466. * Get the view center without transforming to user projection.
  31467. * @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
  31468. */
  31469. View.prototype.getCenterInternal = function () {
  31470. return /** @type {import("./coordinate.js").Coordinate|undefined} */ (this.get(ViewProperty.CENTER));
  31471. };
  31472. /**
  31473. * @return {Constraints} Constraints.
  31474. */
  31475. View.prototype.getConstraints = function () {
  31476. return this.constraints_;
  31477. };
  31478. /**
  31479. * @return {boolean} Resolution constraint is set
  31480. */
  31481. View.prototype.getConstrainResolution = function () {
  31482. return this.get('constrainResolution');
  31483. };
  31484. /**
  31485. * @param {Array<number>} [opt_hints] Destination array.
  31486. * @return {Array<number>} Hint.
  31487. */
  31488. View.prototype.getHints = function (opt_hints) {
  31489. if (opt_hints !== undefined) {
  31490. opt_hints[0] = this.hints_[0];
  31491. opt_hints[1] = this.hints_[1];
  31492. return opt_hints;
  31493. }
  31494. else {
  31495. return this.hints_.slice();
  31496. }
  31497. };
  31498. /**
  31499. * Calculate the extent for the current view state and the passed size.
  31500. * The size is the pixel dimensions of the box into which the calculated extent
  31501. * should fit. In most cases you want to get the extent of the entire map,
  31502. * that is `map.getSize()`.
  31503. * @param {import("./size.js").Size} [opt_size] Box pixel size. If not provided, the size
  31504. * of the map that uses this view will be used.
  31505. * @return {import("./extent.js").Extent} Extent.
  31506. * @api
  31507. */
  31508. View.prototype.calculateExtent = function (opt_size) {
  31509. var extent = this.calculateExtentInternal(opt_size);
  31510. return proj_toUserExtent(extent, this.getProjection());
  31511. };
  31512. /**
  31513. * @param {import("./size.js").Size} [opt_size] Box pixel size. If not provided,
  31514. * the map's last known viewport size will be used.
  31515. * @return {import("./extent.js").Extent} Extent.
  31516. */
  31517. View.prototype.calculateExtentInternal = function (opt_size) {
  31518. var size = opt_size || this.getViewportSizeMinusPadding_();
  31519. var center = /** @type {!import("./coordinate.js").Coordinate} */ (this.getCenterInternal());
  31520. asserts_assert(center, 1); // The view center is not defined
  31521. var resolution = /** @type {!number} */ (this.getResolution());
  31522. asserts_assert(resolution !== undefined, 2); // The view resolution is not defined
  31523. var rotation = /** @type {!number} */ (this.getRotation());
  31524. asserts_assert(rotation !== undefined, 3); // The view rotation is not defined
  31525. return getForViewAndSize(center, resolution, rotation, size);
  31526. };
  31527. /**
  31528. * Get the maximum resolution of the view.
  31529. * @return {number} The maximum resolution of the view.
  31530. * @api
  31531. */
  31532. View.prototype.getMaxResolution = function () {
  31533. return this.maxResolution_;
  31534. };
  31535. /**
  31536. * Get the minimum resolution of the view.
  31537. * @return {number} The minimum resolution of the view.
  31538. * @api
  31539. */
  31540. View.prototype.getMinResolution = function () {
  31541. return this.minResolution_;
  31542. };
  31543. /**
  31544. * Get the maximum zoom level for the view.
  31545. * @return {number} The maximum zoom level.
  31546. * @api
  31547. */
  31548. View.prototype.getMaxZoom = function () {
  31549. return /** @type {number} */ (this.getZoomForResolution(this.minResolution_));
  31550. };
  31551. /**
  31552. * Set a new maximum zoom level for the view.
  31553. * @param {number} zoom The maximum zoom level.
  31554. * @api
  31555. */
  31556. View.prototype.setMaxZoom = function (zoom) {
  31557. this.applyOptions_(this.getUpdatedOptions_({ maxZoom: zoom }));
  31558. };
  31559. /**
  31560. * Get the minimum zoom level for the view.
  31561. * @return {number} The minimum zoom level.
  31562. * @api
  31563. */
  31564. View.prototype.getMinZoom = function () {
  31565. return /** @type {number} */ (this.getZoomForResolution(this.maxResolution_));
  31566. };
  31567. /**
  31568. * Set a new minimum zoom level for the view.
  31569. * @param {number} zoom The minimum zoom level.
  31570. * @api
  31571. */
  31572. View.prototype.setMinZoom = function (zoom) {
  31573. this.applyOptions_(this.getUpdatedOptions_({ minZoom: zoom }));
  31574. };
  31575. /**
  31576. * Set whether the view should allow intermediary zoom levels.
  31577. * @param {boolean} enabled Whether the resolution is constrained.
  31578. * @api
  31579. */
  31580. View.prototype.setConstrainResolution = function (enabled) {
  31581. this.applyOptions_(this.getUpdatedOptions_({ constrainResolution: enabled }));
  31582. };
  31583. /**
  31584. * Get the view projection.
  31585. * @return {import("./proj/Projection.js").default} The projection of the view.
  31586. * @api
  31587. */
  31588. View.prototype.getProjection = function () {
  31589. return this.projection_;
  31590. };
  31591. /**
  31592. * Get the view resolution.
  31593. * @return {number|undefined} The resolution of the view.
  31594. * @observable
  31595. * @api
  31596. */
  31597. View.prototype.getResolution = function () {
  31598. return /** @type {number|undefined} */ (this.get(ViewProperty.RESOLUTION));
  31599. };
  31600. /**
  31601. * Get the resolutions for the view. This returns the array of resolutions
  31602. * passed to the constructor of the View, or undefined if none were given.
  31603. * @return {Array<number>|undefined} The resolutions of the view.
  31604. * @api
  31605. */
  31606. View.prototype.getResolutions = function () {
  31607. return this.resolutions_;
  31608. };
  31609. /**
  31610. * Get the resolution for a provided extent (in map units) and size (in pixels).
  31611. * @param {import("./extent.js").Extent} extent Extent.
  31612. * @param {import("./size.js").Size} [opt_size] Box pixel size.
  31613. * @return {number} The resolution at which the provided extent will render at
  31614. * the given size.
  31615. * @api
  31616. */
  31617. View.prototype.getResolutionForExtent = function (extent, opt_size) {
  31618. return this.getResolutionForExtentInternal(proj_fromUserExtent(extent, this.getProjection()), opt_size);
  31619. };
  31620. /**
  31621. * Get the resolution for a provided extent (in map units) and size (in pixels).
  31622. * @param {import("./extent.js").Extent} extent Extent.
  31623. * @param {import("./size.js").Size} [opt_size] Box pixel size.
  31624. * @return {number} The resolution at which the provided extent will render at
  31625. * the given size.
  31626. */
  31627. View.prototype.getResolutionForExtentInternal = function (extent, opt_size) {
  31628. var size = opt_size || this.getViewportSizeMinusPadding_();
  31629. var xResolution = extent_getWidth(extent) / size[0];
  31630. var yResolution = getHeight(extent) / size[1];
  31631. return Math.max(xResolution, yResolution);
  31632. };
  31633. /**
  31634. * Return a function that returns a value between 0 and 1 for a
  31635. * resolution. Exponential scaling is assumed.
  31636. * @param {number} [opt_power] Power.
  31637. * @return {function(number): number} Resolution for value function.
  31638. */
  31639. View.prototype.getResolutionForValueFunction = function (opt_power) {
  31640. var power = opt_power || 2;
  31641. var maxResolution = this.getConstrainedResolution(this.maxResolution_);
  31642. var minResolution = this.minResolution_;
  31643. var max = Math.log(maxResolution / minResolution) / Math.log(power);
  31644. return (
  31645. /**
  31646. * @param {number} value Value.
  31647. * @return {number} Resolution.
  31648. */
  31649. function (value) {
  31650. var resolution = maxResolution / Math.pow(power, value * max);
  31651. return resolution;
  31652. });
  31653. };
  31654. /**
  31655. * Get the view rotation.
  31656. * @return {number} The rotation of the view in radians.
  31657. * @observable
  31658. * @api
  31659. */
  31660. View.prototype.getRotation = function () {
  31661. return /** @type {number} */ (this.get(ViewProperty.ROTATION));
  31662. };
  31663. /**
  31664. * Return a function that returns a resolution for a value between
  31665. * 0 and 1. Exponential scaling is assumed.
  31666. * @param {number} [opt_power] Power.
  31667. * @return {function(number): number} Value for resolution function.
  31668. */
  31669. View.prototype.getValueForResolutionFunction = function (opt_power) {
  31670. var logPower = Math.log(opt_power || 2);
  31671. var maxResolution = this.getConstrainedResolution(this.maxResolution_);
  31672. var minResolution = this.minResolution_;
  31673. var max = Math.log(maxResolution / minResolution) / logPower;
  31674. return (
  31675. /**
  31676. * @param {number} resolution Resolution.
  31677. * @return {number} Value.
  31678. */
  31679. function (resolution) {
  31680. var value = Math.log(maxResolution / resolution) / logPower / max;
  31681. return value;
  31682. });
  31683. };
  31684. /**
  31685. * Returns the size of the viewport minus padding.
  31686. * @private
  31687. * @param {number} [opt_rotation] Take into account the rotation of the viewport when giving the size
  31688. * @return {import("./size.js").Size} Viewport size reduced by the padding.
  31689. */
  31690. View.prototype.getViewportSizeMinusPadding_ = function (opt_rotation) {
  31691. var size = this.getViewportSize_(opt_rotation);
  31692. var padding = this.padding_;
  31693. if (padding) {
  31694. size = [
  31695. size[0] - padding[1] - padding[3],
  31696. size[1] - padding[0] - padding[2],
  31697. ];
  31698. }
  31699. return size;
  31700. };
  31701. /**
  31702. * @return {State} View state.
  31703. */
  31704. View.prototype.getState = function () {
  31705. var projection = this.getProjection();
  31706. var resolution = this.getResolution();
  31707. var rotation = this.getRotation();
  31708. var center = /** @type {import("./coordinate.js").Coordinate} */ (this.getCenterInternal());
  31709. var padding = this.padding_;
  31710. if (padding) {
  31711. var reducedSize = this.getViewportSizeMinusPadding_();
  31712. center = calculateCenterOn(center, this.getViewportSize_(), [reducedSize[0] / 2 + padding[3], reducedSize[1] / 2 + padding[0]], resolution, rotation);
  31713. }
  31714. return {
  31715. center: center.slice(0),
  31716. projection: projection !== undefined ? projection : null,
  31717. resolution: resolution,
  31718. nextCenter: this.nextCenter_,
  31719. nextResolution: this.nextResolution_,
  31720. nextRotation: this.nextRotation_,
  31721. rotation: rotation,
  31722. zoom: this.getZoom(),
  31723. };
  31724. };
  31725. /**
  31726. * Get the current zoom level. This method may return non-integer zoom levels
  31727. * if the view does not constrain the resolution, or if an interaction or
  31728. * animation is underway.
  31729. * @return {number|undefined} Zoom.
  31730. * @api
  31731. */
  31732. View.prototype.getZoom = function () {
  31733. var zoom;
  31734. var resolution = this.getResolution();
  31735. if (resolution !== undefined) {
  31736. zoom = this.getZoomForResolution(resolution);
  31737. }
  31738. return zoom;
  31739. };
  31740. /**
  31741. * Get the zoom level for a resolution.
  31742. * @param {number} resolution The resolution.
  31743. * @return {number|undefined} The zoom level for the provided resolution.
  31744. * @api
  31745. */
  31746. View.prototype.getZoomForResolution = function (resolution) {
  31747. var offset = this.minZoom_ || 0;
  31748. var max, zoomFactor;
  31749. if (this.resolutions_) {
  31750. var nearest = linearFindNearest(this.resolutions_, resolution, 1);
  31751. offset = nearest;
  31752. max = this.resolutions_[nearest];
  31753. if (nearest == this.resolutions_.length - 1) {
  31754. zoomFactor = 2;
  31755. }
  31756. else {
  31757. zoomFactor = max / this.resolutions_[nearest + 1];
  31758. }
  31759. }
  31760. else {
  31761. max = this.maxResolution_;
  31762. zoomFactor = this.zoomFactor_;
  31763. }
  31764. return offset + Math.log(max / resolution) / Math.log(zoomFactor);
  31765. };
  31766. /**
  31767. * Get the resolution for a zoom level.
  31768. * @param {number} zoom Zoom level.
  31769. * @return {number} The view resolution for the provided zoom level.
  31770. * @api
  31771. */
  31772. View.prototype.getResolutionForZoom = function (zoom) {
  31773. if (this.resolutions_) {
  31774. if (this.resolutions_.length <= 1) {
  31775. return 0;
  31776. }
  31777. var baseLevel = math_clamp(Math.floor(zoom), 0, this.resolutions_.length - 2);
  31778. var zoomFactor = this.resolutions_[baseLevel] / this.resolutions_[baseLevel + 1];
  31779. return (this.resolutions_[baseLevel] /
  31780. Math.pow(zoomFactor, math_clamp(zoom - baseLevel, 0, 1)));
  31781. }
  31782. else {
  31783. return (this.maxResolution_ / Math.pow(this.zoomFactor_, zoom - this.minZoom_));
  31784. }
  31785. };
  31786. /**
  31787. * Fit the given geometry or extent based on the given map size and border.
  31788. * The size is pixel dimensions of the box to fit the extent into.
  31789. * In most cases you will want to use the map size, that is `map.getSize()`.
  31790. * Takes care of the map angle.
  31791. * @param {import("./geom/SimpleGeometry.js").default|import("./extent.js").Extent} geometryOrExtent The geometry or
  31792. * extent to fit the view to.
  31793. * @param {FitOptions} [opt_options] Options.
  31794. * @api
  31795. */
  31796. View.prototype.fit = function (geometryOrExtent, opt_options) {
  31797. /** @type {import("./geom/SimpleGeometry.js").default} */
  31798. var geometry;
  31799. asserts_assert(Array.isArray(geometryOrExtent) ||
  31800. typeof ( /** @type {?} */(geometryOrExtent).getSimplifiedGeometry) ===
  31801. 'function', 24); // Invalid extent or geometry provided as `geometry`
  31802. if (Array.isArray(geometryOrExtent)) {
  31803. asserts_assert(!extent_isEmpty(geometryOrExtent), 25); // Cannot fit empty extent provided as `geometry`
  31804. var extent = proj_fromUserExtent(geometryOrExtent, this.getProjection());
  31805. geometry = fromExtent(extent);
  31806. }
  31807. else if (geometryOrExtent.getType() === 'Circle') {
  31808. var extent = proj_fromUserExtent(geometryOrExtent.getExtent(), this.getProjection());
  31809. geometry = fromExtent(extent);
  31810. geometry.rotate(this.getRotation(), getCenter(extent));
  31811. }
  31812. else {
  31813. var userProjection = getUserProjection();
  31814. if (userProjection) {
  31815. geometry = /** @type {import("./geom/SimpleGeometry.js").default} */ (geometryOrExtent
  31816. .clone()
  31817. .transform(userProjection, this.getProjection()));
  31818. }
  31819. else {
  31820. geometry = geometryOrExtent;
  31821. }
  31822. }
  31823. this.fitInternal(geometry, opt_options);
  31824. };
  31825. /**
  31826. * Calculate rotated extent
  31827. * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
  31828. * @return {import("./extent").Extent} The rotated extent for the geometry.
  31829. */
  31830. View.prototype.rotatedExtentForGeometry = function (geometry) {
  31831. var rotation = this.getRotation();
  31832. var cosAngle = Math.cos(rotation);
  31833. var sinAngle = Math.sin(-rotation);
  31834. var coords = geometry.getFlatCoordinates();
  31835. var stride = geometry.getStride();
  31836. var minRotX = +Infinity;
  31837. var minRotY = +Infinity;
  31838. var maxRotX = -Infinity;
  31839. var maxRotY = -Infinity;
  31840. for (var i = 0, ii = coords.length; i < ii; i += stride) {
  31841. var rotX = coords[i] * cosAngle - coords[i + 1] * sinAngle;
  31842. var rotY = coords[i] * sinAngle + coords[i + 1] * cosAngle;
  31843. minRotX = Math.min(minRotX, rotX);
  31844. minRotY = Math.min(minRotY, rotY);
  31845. maxRotX = Math.max(maxRotX, rotX);
  31846. maxRotY = Math.max(maxRotY, rotY);
  31847. }
  31848. return [minRotX, minRotY, maxRotX, maxRotY];
  31849. };
  31850. /**
  31851. * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
  31852. * @param {FitOptions} [opt_options] Options.
  31853. */
  31854. View.prototype.fitInternal = function (geometry, opt_options) {
  31855. var options = opt_options || {};
  31856. var size = options.size;
  31857. if (!size) {
  31858. size = this.getViewportSizeMinusPadding_();
  31859. }
  31860. var padding = options.padding !== undefined ? options.padding : [0, 0, 0, 0];
  31861. var nearest = options.nearest !== undefined ? options.nearest : false;
  31862. var minResolution;
  31863. if (options.minResolution !== undefined) {
  31864. minResolution = options.minResolution;
  31865. }
  31866. else if (options.maxZoom !== undefined) {
  31867. minResolution = this.getResolutionForZoom(options.maxZoom);
  31868. }
  31869. else {
  31870. minResolution = 0;
  31871. }
  31872. var rotatedExtent = this.rotatedExtentForGeometry(geometry);
  31873. // calculate resolution
  31874. var resolution = this.getResolutionForExtentInternal(rotatedExtent, [
  31875. size[0] - padding[1] - padding[3],
  31876. size[1] - padding[0] - padding[2],
  31877. ]);
  31878. resolution = isNaN(resolution)
  31879. ? minResolution
  31880. : Math.max(resolution, minResolution);
  31881. resolution = this.getConstrainedResolution(resolution, nearest ? 0 : 1);
  31882. // calculate center
  31883. var rotation = this.getRotation();
  31884. var sinAngle = Math.sin(rotation);
  31885. var cosAngle = Math.cos(rotation);
  31886. var centerRot = getCenter(rotatedExtent);
  31887. centerRot[0] += ((padding[1] - padding[3]) / 2) * resolution;
  31888. centerRot[1] += ((padding[0] - padding[2]) / 2) * resolution;
  31889. var centerX = centerRot[0] * cosAngle - centerRot[1] * sinAngle;
  31890. var centerY = centerRot[1] * cosAngle + centerRot[0] * sinAngle;
  31891. var center = this.getConstrainedCenter([centerX, centerY], resolution);
  31892. var callback = options.callback ? options.callback : VOID;
  31893. if (options.duration !== undefined) {
  31894. this.animateInternal({
  31895. resolution: resolution,
  31896. center: center,
  31897. duration: options.duration,
  31898. easing: options.easing,
  31899. }, callback);
  31900. }
  31901. else {
  31902. this.targetResolution_ = resolution;
  31903. this.targetCenter_ = center;
  31904. this.applyTargetState_(false, true);
  31905. animationCallback(callback, true);
  31906. }
  31907. };
  31908. /**
  31909. * Center on coordinate and view position.
  31910. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  31911. * @param {import("./size.js").Size} size Box pixel size.
  31912. * @param {import("./pixel.js").Pixel} position Position on the view to center on.
  31913. * @api
  31914. */
  31915. View.prototype.centerOn = function (coordinate, size, position) {
  31916. this.centerOnInternal(fromUserCoordinate(coordinate, this.getProjection()), size, position);
  31917. };
  31918. /**
  31919. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  31920. * @param {import("./size.js").Size} size Box pixel size.
  31921. * @param {import("./pixel.js").Pixel} position Position on the view to center on.
  31922. */
  31923. View.prototype.centerOnInternal = function (coordinate, size, position) {
  31924. this.setCenterInternal(calculateCenterOn(coordinate, size, position, this.getResolution(), this.getRotation()));
  31925. };
  31926. /**
  31927. * Calculates the shift between map and viewport center.
  31928. * @param {import("./coordinate.js").Coordinate} center Center.
  31929. * @param {number} resolution Resolution.
  31930. * @param {number} rotation Rotation.
  31931. * @param {import("./size.js").Size} size Size.
  31932. * @return {Array<number>|undefined} Center shift.
  31933. */
  31934. View.prototype.calculateCenterShift = function (center, resolution, rotation, size) {
  31935. var centerShift;
  31936. var padding = this.padding_;
  31937. if (padding && center) {
  31938. var reducedSize = this.getViewportSizeMinusPadding_(-rotation);
  31939. var shiftedCenter = calculateCenterOn(center, size, [reducedSize[0] / 2 + padding[3], reducedSize[1] / 2 + padding[0]], resolution, rotation);
  31940. centerShift = [
  31941. center[0] - shiftedCenter[0],
  31942. center[1] - shiftedCenter[1],
  31943. ];
  31944. }
  31945. return centerShift;
  31946. };
  31947. /**
  31948. * @return {boolean} Is defined.
  31949. */
  31950. View.prototype.isDef = function () {
  31951. return !!this.getCenterInternal() && this.getResolution() !== undefined;
  31952. };
  31953. /**
  31954. * Adds relative coordinates to the center of the view. Any extent constraint will apply.
  31955. * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
  31956. * @api
  31957. */
  31958. View.prototype.adjustCenter = function (deltaCoordinates) {
  31959. var center = toUserCoordinate(this.targetCenter_, this.getProjection());
  31960. this.setCenter([
  31961. center[0] + deltaCoordinates[0],
  31962. center[1] + deltaCoordinates[1],
  31963. ]);
  31964. };
  31965. /**
  31966. * Adds relative coordinates to the center of the view. Any extent constraint will apply.
  31967. * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
  31968. */
  31969. View.prototype.adjustCenterInternal = function (deltaCoordinates) {
  31970. var center = this.targetCenter_;
  31971. this.setCenterInternal([
  31972. center[0] + deltaCoordinates[0],
  31973. center[1] + deltaCoordinates[1],
  31974. ]);
  31975. };
  31976. /**
  31977. * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
  31978. * constraint will apply.
  31979. * @param {number} ratio The ratio to apply on the view resolution.
  31980. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
  31981. * @api
  31982. */
  31983. View.prototype.adjustResolution = function (ratio, opt_anchor) {
  31984. var anchor = opt_anchor && fromUserCoordinate(opt_anchor, this.getProjection());
  31985. this.adjustResolutionInternal(ratio, anchor);
  31986. };
  31987. /**
  31988. * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
  31989. * constraint will apply.
  31990. * @param {number} ratio The ratio to apply on the view resolution.
  31991. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
  31992. */
  31993. View.prototype.adjustResolutionInternal = function (ratio, opt_anchor) {
  31994. var isMoving = this.getAnimating() || this.getInteracting();
  31995. var size = this.getViewportSize_(this.getRotation());
  31996. var newResolution = this.constraints_.resolution(this.targetResolution_ * ratio, 0, size, isMoving);
  31997. if (opt_anchor) {
  31998. this.targetCenter_ = this.calculateCenterZoom(newResolution, opt_anchor);
  31999. }
  32000. this.targetResolution_ *= ratio;
  32001. this.applyTargetState_();
  32002. };
  32003. /**
  32004. * Adds a value to the view zoom level, optionally using an anchor. Any resolution
  32005. * constraint will apply.
  32006. * @param {number} delta Relative value to add to the zoom level.
  32007. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
  32008. * @api
  32009. */
  32010. View.prototype.adjustZoom = function (delta, opt_anchor) {
  32011. this.adjustResolution(Math.pow(this.zoomFactor_, -delta), opt_anchor);
  32012. };
  32013. /**
  32014. * Adds a value to the view rotation, optionally using an anchor. Any rotation
  32015. * constraint will apply.
  32016. * @param {number} delta Relative value to add to the zoom rotation, in radians.
  32017. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The rotation center.
  32018. * @api
  32019. */
  32020. View.prototype.adjustRotation = function (delta, opt_anchor) {
  32021. if (opt_anchor) {
  32022. opt_anchor = fromUserCoordinate(opt_anchor, this.getProjection());
  32023. }
  32024. this.adjustRotationInternal(delta, opt_anchor);
  32025. };
  32026. /**
  32027. * @param {number} delta Relative value to add to the zoom rotation, in radians.
  32028. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The rotation center.
  32029. */
  32030. View.prototype.adjustRotationInternal = function (delta, opt_anchor) {
  32031. var isMoving = this.getAnimating() || this.getInteracting();
  32032. var newRotation = this.constraints_.rotation(this.targetRotation_ + delta, isMoving);
  32033. if (opt_anchor) {
  32034. this.targetCenter_ = this.calculateCenterRotate(newRotation, opt_anchor);
  32035. }
  32036. this.targetRotation_ += delta;
  32037. this.applyTargetState_();
  32038. };
  32039. /**
  32040. * Set the center of the current view. Any extent constraint will apply.
  32041. * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
  32042. * @observable
  32043. * @api
  32044. */
  32045. View.prototype.setCenter = function (center) {
  32046. this.setCenterInternal(center ? fromUserCoordinate(center, this.getProjection()) : center);
  32047. };
  32048. /**
  32049. * Set the center using the view projection (not the user projection).
  32050. * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
  32051. */
  32052. View.prototype.setCenterInternal = function (center) {
  32053. this.targetCenter_ = center;
  32054. this.applyTargetState_();
  32055. };
  32056. /**
  32057. * @param {import("./ViewHint.js").default} hint Hint.
  32058. * @param {number} delta Delta.
  32059. * @return {number} New value.
  32060. */
  32061. View.prototype.setHint = function (hint, delta) {
  32062. this.hints_[hint] += delta;
  32063. this.changed();
  32064. return this.hints_[hint];
  32065. };
  32066. /**
  32067. * Set the resolution for this view. Any resolution constraint will apply.
  32068. * @param {number|undefined} resolution The resolution of the view.
  32069. * @observable
  32070. * @api
  32071. */
  32072. View.prototype.setResolution = function (resolution) {
  32073. this.targetResolution_ = resolution;
  32074. this.applyTargetState_();
  32075. };
  32076. /**
  32077. * Set the rotation for this view. Any rotation constraint will apply.
  32078. * @param {number} rotation The rotation of the view in radians.
  32079. * @observable
  32080. * @api
  32081. */
  32082. View.prototype.setRotation = function (rotation) {
  32083. this.targetRotation_ = rotation;
  32084. this.applyTargetState_();
  32085. };
  32086. /**
  32087. * Zoom to a specific zoom level. Any resolution constrain will apply.
  32088. * @param {number} zoom Zoom level.
  32089. * @api
  32090. */
  32091. View.prototype.setZoom = function (zoom) {
  32092. this.setResolution(this.getResolutionForZoom(zoom));
  32093. };
  32094. /**
  32095. * Recompute rotation/resolution/center based on target values.
  32096. * Note: we have to compute rotation first, then resolution and center considering that
  32097. * parameters can influence one another in case a view extent constraint is present.
  32098. * @param {boolean} [opt_doNotCancelAnims] Do not cancel animations.
  32099. * @param {boolean} [opt_forceMoving] Apply constraints as if the view is moving.
  32100. * @private
  32101. */
  32102. View.prototype.applyTargetState_ = function (opt_doNotCancelAnims, opt_forceMoving) {
  32103. var isMoving = this.getAnimating() || this.getInteracting() || opt_forceMoving;
  32104. // compute rotation
  32105. var newRotation = this.constraints_.rotation(this.targetRotation_, isMoving);
  32106. var size = this.getViewportSize_(newRotation);
  32107. var newResolution = this.constraints_.resolution(this.targetResolution_, 0, size, isMoving);
  32108. var newCenter = this.constraints_.center(this.targetCenter_, newResolution, size, isMoving, this.calculateCenterShift(this.targetCenter_, newResolution, newRotation, size));
  32109. if (this.get(ViewProperty.ROTATION) !== newRotation) {
  32110. this.set(ViewProperty.ROTATION, newRotation);
  32111. }
  32112. if (this.get(ViewProperty.RESOLUTION) !== newResolution) {
  32113. this.set(ViewProperty.RESOLUTION, newResolution);
  32114. this.set('zoom', this.getZoom(), true);
  32115. }
  32116. if (!newCenter ||
  32117. !this.get(ViewProperty.CENTER) ||
  32118. !coordinate_equals(this.get(ViewProperty.CENTER), newCenter)) {
  32119. this.set(ViewProperty.CENTER, newCenter);
  32120. }
  32121. if (this.getAnimating() && !opt_doNotCancelAnims) {
  32122. this.cancelAnimations();
  32123. }
  32124. this.cancelAnchor_ = undefined;
  32125. };
  32126. /**
  32127. * If any constraints need to be applied, an animation will be triggered.
  32128. * This is typically done on interaction end.
  32129. * Note: calling this with a duration of 0 will apply the constrained values straight away,
  32130. * without animation.
  32131. * @param {number} [opt_duration] The animation duration in ms.
  32132. * @param {number} [opt_resolutionDirection] Which direction to zoom.
  32133. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
  32134. */
  32135. View.prototype.resolveConstraints = function (opt_duration, opt_resolutionDirection, opt_anchor) {
  32136. var duration = opt_duration !== undefined ? opt_duration : 200;
  32137. var direction = opt_resolutionDirection || 0;
  32138. var newRotation = this.constraints_.rotation(this.targetRotation_);
  32139. var size = this.getViewportSize_(newRotation);
  32140. var newResolution = this.constraints_.resolution(this.targetResolution_, direction, size);
  32141. var newCenter = this.constraints_.center(this.targetCenter_, newResolution, size, false, this.calculateCenterShift(this.targetCenter_, newResolution, newRotation, size));
  32142. if (duration === 0 && !this.cancelAnchor_) {
  32143. this.targetResolution_ = newResolution;
  32144. this.targetRotation_ = newRotation;
  32145. this.targetCenter_ = newCenter;
  32146. this.applyTargetState_();
  32147. return;
  32148. }
  32149. var anchor = opt_anchor || (duration === 0 ? this.cancelAnchor_ : undefined);
  32150. this.cancelAnchor_ = undefined;
  32151. if (this.getResolution() !== newResolution ||
  32152. this.getRotation() !== newRotation ||
  32153. !this.getCenterInternal() ||
  32154. !coordinate_equals(this.getCenterInternal(), newCenter)) {
  32155. if (this.getAnimating()) {
  32156. this.cancelAnimations();
  32157. }
  32158. this.animateInternal({
  32159. rotation: newRotation,
  32160. center: newCenter,
  32161. resolution: newResolution,
  32162. duration: duration,
  32163. easing: easeOut,
  32164. anchor: anchor,
  32165. });
  32166. }
  32167. };
  32168. /**
  32169. * Notify the View that an interaction has started.
  32170. * The view state will be resolved to a stable one if needed
  32171. * (depending on its constraints).
  32172. * @api
  32173. */
  32174. View.prototype.beginInteraction = function () {
  32175. this.resolveConstraints(0);
  32176. this.setHint(ViewHint.INTERACTING, 1);
  32177. };
  32178. /**
  32179. * Notify the View that an interaction has ended. The view state will be resolved
  32180. * to a stable one if needed (depending on its constraints).
  32181. * @param {number} [opt_duration] Animation duration in ms.
  32182. * @param {number} [opt_resolutionDirection] Which direction to zoom.
  32183. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
  32184. * @api
  32185. */
  32186. View.prototype.endInteraction = function (opt_duration, opt_resolutionDirection, opt_anchor) {
  32187. var anchor = opt_anchor && fromUserCoordinate(opt_anchor, this.getProjection());
  32188. this.endInteractionInternal(opt_duration, opt_resolutionDirection, anchor);
  32189. };
  32190. /**
  32191. * Notify the View that an interaction has ended. The view state will be resolved
  32192. * to a stable one if needed (depending on its constraints).
  32193. * @param {number} [opt_duration] Animation duration in ms.
  32194. * @param {number} [opt_resolutionDirection] Which direction to zoom.
  32195. * @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
  32196. */
  32197. View.prototype.endInteractionInternal = function (opt_duration, opt_resolutionDirection, opt_anchor) {
  32198. this.setHint(ViewHint.INTERACTING, -1);
  32199. this.resolveConstraints(opt_duration, opt_resolutionDirection, opt_anchor);
  32200. };
  32201. /**
  32202. * Get a valid position for the view center according to the current constraints.
  32203. * @param {import("./coordinate.js").Coordinate|undefined} targetCenter Target center position.
  32204. * @param {number} [opt_targetResolution] Target resolution. If not supplied, the current one will be used.
  32205. * This is useful to guess a valid center position at a different zoom level.
  32206. * @return {import("./coordinate.js").Coordinate|undefined} Valid center position.
  32207. */
  32208. View.prototype.getConstrainedCenter = function (targetCenter, opt_targetResolution) {
  32209. var size = this.getViewportSize_(this.getRotation());
  32210. return this.constraints_.center(targetCenter, opt_targetResolution || this.getResolution(), size);
  32211. };
  32212. /**
  32213. * Get a valid zoom level according to the current view constraints.
  32214. * @param {number|undefined} targetZoom Target zoom.
  32215. * @param {number} [opt_direction=0] Indicate which resolution should be used
  32216. * by a renderer if the view resolution does not match any resolution of the tile source.
  32217. * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
  32218. * will be used. If -1, the nearest higher resolution will be used.
  32219. * @return {number|undefined} Valid zoom level.
  32220. */
  32221. View.prototype.getConstrainedZoom = function (targetZoom, opt_direction) {
  32222. var targetRes = this.getResolutionForZoom(targetZoom);
  32223. return this.getZoomForResolution(this.getConstrainedResolution(targetRes, opt_direction));
  32224. };
  32225. /**
  32226. * Get a valid resolution according to the current view constraints.
  32227. * @param {number|undefined} targetResolution Target resolution.
  32228. * @param {number} [opt_direction=0] Indicate which resolution should be used
  32229. * by a renderer if the view resolution does not match any resolution of the tile source.
  32230. * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
  32231. * will be used. If -1, the nearest higher resolution will be used.
  32232. * @return {number|undefined} Valid resolution.
  32233. */
  32234. View.prototype.getConstrainedResolution = function (targetResolution, opt_direction) {
  32235. var direction = opt_direction || 0;
  32236. var size = this.getViewportSize_(this.getRotation());
  32237. return this.constraints_.resolution(targetResolution, direction, size);
  32238. };
  32239. return View;
  32240. }(ol_Object));
  32241. /**
  32242. * @param {Function} callback Callback.
  32243. * @param {*} returnValue Return value.
  32244. */
  32245. function animationCallback(callback, returnValue) {
  32246. setTimeout(function () {
  32247. callback(returnValue);
  32248. }, 0);
  32249. }
  32250. /**
  32251. * @param {ViewOptions} options View options.
  32252. * @return {import("./centerconstraint.js").Type} The constraint.
  32253. */
  32254. function createCenterConstraint(options) {
  32255. if (options.extent !== undefined) {
  32256. var smooth = options.smoothExtentConstraint !== undefined
  32257. ? options.smoothExtentConstraint
  32258. : true;
  32259. return createExtent(options.extent, options.constrainOnlyCenter, smooth);
  32260. }
  32261. var projection = createProjection(options.projection, 'EPSG:3857');
  32262. if (options.multiWorld !== true && projection.isGlobal()) {
  32263. var extent = projection.getExtent().slice();
  32264. extent[0] = -Infinity;
  32265. extent[2] = Infinity;
  32266. return createExtent(extent, false, false);
  32267. }
  32268. return none;
  32269. }
  32270. /**
  32271. * @param {ViewOptions} options View options.
  32272. * @return {{constraint: import("./resolutionconstraint.js").Type, maxResolution: number,
  32273. * minResolution: number, minZoom: number, zoomFactor: number}} The constraint.
  32274. */
  32275. function createResolutionConstraint(options) {
  32276. var resolutionConstraint;
  32277. var maxResolution;
  32278. var minResolution;
  32279. // TODO: move these to be ol constants
  32280. // see https://github.com/openlayers/openlayers/issues/2076
  32281. var defaultMaxZoom = 28;
  32282. var defaultZoomFactor = 2;
  32283. var minZoom = options.minZoom !== undefined ? options.minZoom : DEFAULT_MIN_ZOOM;
  32284. var maxZoom = options.maxZoom !== undefined ? options.maxZoom : defaultMaxZoom;
  32285. var zoomFactor = options.zoomFactor !== undefined ? options.zoomFactor : defaultZoomFactor;
  32286. var multiWorld = options.multiWorld !== undefined ? options.multiWorld : false;
  32287. var smooth = options.smoothResolutionConstraint !== undefined
  32288. ? options.smoothResolutionConstraint
  32289. : true;
  32290. var showFullExtent = options.showFullExtent !== undefined ? options.showFullExtent : false;
  32291. var projection = createProjection(options.projection, 'EPSG:3857');
  32292. var projExtent = projection.getExtent();
  32293. var constrainOnlyCenter = options.constrainOnlyCenter;
  32294. var extent = options.extent;
  32295. if (!multiWorld && !extent && projection.isGlobal()) {
  32296. constrainOnlyCenter = false;
  32297. extent = projExtent;
  32298. }
  32299. if (options.resolutions !== undefined) {
  32300. var resolutions = options.resolutions;
  32301. maxResolution = resolutions[minZoom];
  32302. minResolution =
  32303. resolutions[maxZoom] !== undefined
  32304. ? resolutions[maxZoom]
  32305. : resolutions[resolutions.length - 1];
  32306. if (options.constrainResolution) {
  32307. resolutionConstraint = createSnapToResolutions(resolutions, smooth, !constrainOnlyCenter && extent, showFullExtent);
  32308. }
  32309. else {
  32310. resolutionConstraint = createMinMaxResolution(maxResolution, minResolution, smooth, !constrainOnlyCenter && extent, showFullExtent);
  32311. }
  32312. }
  32313. else {
  32314. // calculate the default min and max resolution
  32315. var size = !projExtent
  32316. ? // use an extent that can fit the whole world if need be
  32317. (360 * Units_METERS_PER_UNIT[proj_Units.DEGREES]) / projection.getMetersPerUnit()
  32318. : Math.max(extent_getWidth(projExtent), getHeight(projExtent));
  32319. var defaultMaxResolution = size / DEFAULT_TILE_SIZE / Math.pow(defaultZoomFactor, DEFAULT_MIN_ZOOM);
  32320. var defaultMinResolution = defaultMaxResolution /
  32321. Math.pow(defaultZoomFactor, defaultMaxZoom - DEFAULT_MIN_ZOOM);
  32322. // user provided maxResolution takes precedence
  32323. maxResolution = options.maxResolution;
  32324. if (maxResolution !== undefined) {
  32325. minZoom = 0;
  32326. }
  32327. else {
  32328. maxResolution = defaultMaxResolution / Math.pow(zoomFactor, minZoom);
  32329. }
  32330. // user provided minResolution takes precedence
  32331. minResolution = options.minResolution;
  32332. if (minResolution === undefined) {
  32333. if (options.maxZoom !== undefined) {
  32334. if (options.maxResolution !== undefined) {
  32335. minResolution = maxResolution / Math.pow(zoomFactor, maxZoom);
  32336. }
  32337. else {
  32338. minResolution = defaultMaxResolution / Math.pow(zoomFactor, maxZoom);
  32339. }
  32340. }
  32341. else {
  32342. minResolution = defaultMinResolution;
  32343. }
  32344. }
  32345. // given discrete zoom levels, minResolution may be different than provided
  32346. maxZoom =
  32347. minZoom +
  32348. Math.floor(Math.log(maxResolution / minResolution) / Math.log(zoomFactor));
  32349. minResolution = maxResolution / Math.pow(zoomFactor, maxZoom - minZoom);
  32350. if (options.constrainResolution) {
  32351. resolutionConstraint = createSnapToPower(zoomFactor, maxResolution, minResolution, smooth, !constrainOnlyCenter && extent, showFullExtent);
  32352. }
  32353. else {
  32354. resolutionConstraint = createMinMaxResolution(maxResolution, minResolution, smooth, !constrainOnlyCenter && extent, showFullExtent);
  32355. }
  32356. }
  32357. return {
  32358. constraint: resolutionConstraint,
  32359. maxResolution: maxResolution,
  32360. minResolution: minResolution,
  32361. minZoom: minZoom,
  32362. zoomFactor: zoomFactor,
  32363. };
  32364. }
  32365. /**
  32366. * @param {ViewOptions} options View options.
  32367. * @return {import("./rotationconstraint.js").Type} Rotation constraint.
  32368. */
  32369. function createRotationConstraint(options) {
  32370. var enableRotation = options.enableRotation !== undefined ? options.enableRotation : true;
  32371. if (enableRotation) {
  32372. var constrainRotation = options.constrainRotation;
  32373. if (constrainRotation === undefined || constrainRotation === true) {
  32374. return createSnapToZero();
  32375. }
  32376. else if (constrainRotation === false) {
  32377. return rotationconstraint_none;
  32378. }
  32379. else if (typeof constrainRotation === 'number') {
  32380. return createSnapToN(constrainRotation);
  32381. }
  32382. else {
  32383. return rotationconstraint_none;
  32384. }
  32385. }
  32386. else {
  32387. return disable;
  32388. }
  32389. }
  32390. /**
  32391. * Determine if an animation involves no view change.
  32392. * @param {Animation} animation The animation.
  32393. * @return {boolean} The animation involves no view change.
  32394. */
  32395. function isNoopAnimation(animation) {
  32396. if (animation.sourceCenter && animation.targetCenter) {
  32397. if (!coordinate_equals(animation.sourceCenter, animation.targetCenter)) {
  32398. return false;
  32399. }
  32400. }
  32401. if (animation.sourceResolution !== animation.targetResolution) {
  32402. return false;
  32403. }
  32404. if (animation.sourceRotation !== animation.targetRotation) {
  32405. return false;
  32406. }
  32407. return true;
  32408. }
  32409. /**
  32410. * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
  32411. * @param {import("./size.js").Size} size Box pixel size.
  32412. * @param {import("./pixel.js").Pixel} position Position on the view to center on.
  32413. * @param {number} resolution Resolution.
  32414. * @param {number} rotation Rotation.
  32415. * @return {import("./coordinate.js").Coordinate} Shifted center.
  32416. */
  32417. function calculateCenterOn(coordinate, size, position, resolution, rotation) {
  32418. // calculate rotated position
  32419. var cosAngle = Math.cos(-rotation);
  32420. var sinAngle = Math.sin(-rotation);
  32421. var rotX = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
  32422. var rotY = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
  32423. rotX += (size[0] / 2 - position[0]) * resolution;
  32424. rotY += (position[1] - size[1] / 2) * resolution;
  32425. // go back to original angle
  32426. sinAngle = -sinAngle; // go back to original rotation
  32427. var centerX = rotX * cosAngle - rotY * sinAngle;
  32428. var centerY = rotY * cosAngle + rotX * sinAngle;
  32429. return [centerX, centerY];
  32430. }
  32431. /* harmony default export */ var ol_View = (View);
  32432. //# sourceMappingURL=View.js.map
  32433. ;// ./node_modules/ol/PluggableMap.js
  32434. var PluggableMap_extends = (undefined && undefined.__extends) || (function () {
  32435. var extendStatics = function (d, b) {
  32436. extendStatics = Object.setPrototypeOf ||
  32437. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32438. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  32439. return extendStatics(d, b);
  32440. };
  32441. return function (d, b) {
  32442. if (typeof b !== "function" && b !== null)
  32443. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  32444. extendStatics(d, b);
  32445. function __() { this.constructor = d; }
  32446. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32447. };
  32448. })();
  32449. /**
  32450. * @module ol/PluggableMap
  32451. */
  32452. /**
  32453. * State of the current frame. Only `pixelRatio`, `time` and `viewState` should
  32454. * be used in applications.
  32455. * @typedef {Object} FrameState
  32456. * @property {number} pixelRatio The pixel ratio of the frame.
  32457. * @property {number} time The time when rendering of the frame was requested.
  32458. * @property {import("./View.js").State} viewState The state of the current view.
  32459. * @property {boolean} animate Animate.
  32460. * @property {import("./transform.js").Transform} coordinateToPixelTransform CoordinateToPixelTransform.
  32461. * @property {import("rbush").default} declutterTree DeclutterTree.
  32462. * @property {null|import("./extent.js").Extent} extent Extent.
  32463. * @property {import("./extent.js").Extent} [nextExtent] Next extent during an animation series.
  32464. * @property {number} index Index.
  32465. * @property {Array<import("./layer/Layer.js").State>} layerStatesArray LayerStatesArray.
  32466. * @property {number} layerIndex LayerIndex.
  32467. * @property {import("./transform.js").Transform} pixelToCoordinateTransform PixelToCoordinateTransform.
  32468. * @property {Array<PostRenderFunction>} postRenderFunctions PostRenderFunctions.
  32469. * @property {import("./size.js").Size} size Size.
  32470. * @property {TileQueue} tileQueue TileQueue.
  32471. * @property {!Object<string, Object<string, boolean>>} usedTiles UsedTiles.
  32472. * @property {Array<number>} viewHints ViewHints.
  32473. * @property {!Object<string, Object<string, boolean>>} wantedTiles WantedTiles.
  32474. * @property {string} mapId The id of the map.
  32475. * @property {Object<string, boolean>} renderTargets Identifiers of previously rendered elements.
  32476. */
  32477. /**
  32478. * @typedef {function(PluggableMap, ?FrameState): any} PostRenderFunction
  32479. */
  32480. /**
  32481. * @typedef {Object} AtPixelOptions
  32482. * @property {undefined|function(import("./layer/Layer.js").default<import("./source/Source").default>): boolean} [layerFilter] Layer filter
  32483. * function. The filter function will receive one argument, the
  32484. * {@link module:ol/layer/Layer~Layer layer-candidate} and it should return a boolean value.
  32485. * Only layers which are visible and for which this function returns `true`
  32486. * will be tested for features. By default, all visible layers will be tested.
  32487. * @property {number} [hitTolerance=0] Hit-detection tolerance in css pixels. Pixels
  32488. * inside the radius around the given position will be checked for features.
  32489. * @property {boolean} [checkWrapped=true] Check-Wrapped Will check for for wrapped geometries inside the range of
  32490. * +/- 1 world width. Works only if a projection is used that can be wrapped.
  32491. */
  32492. /**
  32493. * @typedef {Object} MapOptionsInternal
  32494. * @property {Collection<import("./control/Control.js").default>} [controls] Controls.
  32495. * @property {Collection<import("./interaction/Interaction.js").default>} [interactions] Interactions.
  32496. * @property {HTMLElement|Document} keyboardEventTarget KeyboardEventTarget.
  32497. * @property {Collection<import("./Overlay.js").default>} overlays Overlays.
  32498. * @property {Object<string, *>} values Values.
  32499. */
  32500. /**
  32501. * @typedef {import("./ObjectEventType").Types|'change:layergroup'|'change:size'|'change:target'|'change:view'} MapObjectEventTypes
  32502. */
  32503. /***
  32504. * @template Return
  32505. * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
  32506. * import("./Observable").OnSignature<MapObjectEventTypes, import("./Object").ObjectEvent, Return> &
  32507. * import("./Observable").OnSignature<import("./MapBrowserEventType").Types, import("./MapBrowserEvent").default, Return> &
  32508. * import("./Observable").OnSignature<import("./MapEventType").Types, import("./MapEvent").default, Return> &
  32509. * import("./Observable").OnSignature<import("./render/EventType").MapRenderEventTypes, import("./render/Event").default, Return> &
  32510. * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|MapObjectEventTypes|
  32511. * import("./MapBrowserEventType").Types|import("./MapEventType").Types|
  32512. * import("./render/EventType").MapRenderEventTypes, Return>} PluggableMapOnSignature
  32513. */
  32514. /**
  32515. * Object literal with config options for the map.
  32516. * @typedef {Object} MapOptions
  32517. * @property {Collection<import("./control/Control.js").default>|Array<import("./control/Control.js").default>} [controls]
  32518. * Controls initially added to the map. If not specified,
  32519. * {@link module:ol/control.defaults} is used.
  32520. * @property {number} [pixelRatio=window.devicePixelRatio] The ratio between
  32521. * physical pixels and device-independent pixels (dips) on the device.
  32522. * @property {Collection<import("./interaction/Interaction.js").default>|Array<import("./interaction/Interaction.js").default>} [interactions]
  32523. * Interactions that are initially added to the map. If not specified,
  32524. * {@link module:ol/interaction.defaults} is used.
  32525. * @property {HTMLElement|Document|string} [keyboardEventTarget] The element to
  32526. * listen to keyboard events on. This determines when the `KeyboardPan` and
  32527. * `KeyboardZoom` interactions trigger. For example, if this option is set to
  32528. * `document` the keyboard interactions will always trigger. If this option is
  32529. * not specified, the element the library listens to keyboard events on is the
  32530. * map target (i.e. the user-provided div for the map). If this is not
  32531. * `document`, the target element needs to be focused for key events to be
  32532. * emitted, requiring that the target element has a `tabindex` attribute.
  32533. * @property {Array<import("./layer/Base.js").default>|Collection<import("./layer/Base.js").default>|LayerGroup} [layers]
  32534. * Layers. If this is not defined, a map with no layers will be rendered. Note
  32535. * that layers are rendered in the order supplied, so if you want, for example,
  32536. * a vector layer to appear on top of a tile layer, it must come after the tile
  32537. * layer.
  32538. * @property {number} [maxTilesLoading=16] Maximum number tiles to load
  32539. * simultaneously.
  32540. * @property {number} [moveTolerance=1] The minimum distance in pixels the
  32541. * cursor must move to be detected as a map move event instead of a click.
  32542. * Increasing this value can make it easier to click on the map.
  32543. * @property {Collection<import("./Overlay.js").default>|Array<import("./Overlay.js").default>} [overlays]
  32544. * Overlays initially added to the map. By default, no overlays are added.
  32545. * @property {HTMLElement|string} [target] The container for the map, either the
  32546. * element itself or the `id` of the element. If not specified at construction
  32547. * time, {@link module:ol/Map~Map#setTarget} must be called for the map to be
  32548. * rendered. If passed by element, the container can be in a secondary document.
  32549. * @property {View|Promise<import("./View.js").ViewOptions>} [view] The map's view. No layer sources will be
  32550. * fetched unless this is specified at construction time or through
  32551. * {@link module:ol/Map~Map#setView}.
  32552. */
  32553. /**
  32554. * @param {import("./layer/Base.js").default} layer Layer.
  32555. */
  32556. function removeLayerMapProperty(layer) {
  32557. if (layer instanceof layer_Layer) {
  32558. layer.setMapInternal(null);
  32559. return;
  32560. }
  32561. if (layer instanceof Group) {
  32562. layer.getLayers().forEach(removeLayerMapProperty);
  32563. }
  32564. }
  32565. /**
  32566. * @param {import("./layer/Base.js").default} layer Layer.
  32567. * @param {PluggableMap} map Map.
  32568. */
  32569. function setLayerMapProperty(layer, map) {
  32570. if (layer instanceof layer_Layer) {
  32571. layer.setMapInternal(map);
  32572. return;
  32573. }
  32574. if (layer instanceof Group) {
  32575. var layers = layer.getLayers().getArray();
  32576. for (var i = 0, ii = layers.length; i < ii; ++i) {
  32577. setLayerMapProperty(layers[i], map);
  32578. }
  32579. }
  32580. }
  32581. /**
  32582. * @fires import("./MapBrowserEvent.js").MapBrowserEvent
  32583. * @fires import("./MapEvent.js").MapEvent
  32584. * @fires import("./render/Event.js").default#precompose
  32585. * @fires import("./render/Event.js").default#postcompose
  32586. * @fires import("./render/Event.js").default#rendercomplete
  32587. * @api
  32588. */
  32589. var PluggableMap = /** @class */ (function (_super) {
  32590. PluggableMap_extends(PluggableMap, _super);
  32591. /**
  32592. * @param {MapOptions} options Map options.
  32593. */
  32594. function PluggableMap(options) {
  32595. var _this = _super.call(this) || this;
  32596. /***
  32597. * @type {PluggableMapOnSignature<import("./events").EventsKey>}
  32598. */
  32599. _this.on;
  32600. /***
  32601. * @type {PluggableMapOnSignature<import("./events").EventsKey>}
  32602. */
  32603. _this.once;
  32604. /***
  32605. * @type {PluggableMapOnSignature<void>}
  32606. */
  32607. _this.un;
  32608. var optionsInternal = createOptionsInternal(options);
  32609. /**
  32610. * @private
  32611. * @type {boolean|undefined}
  32612. */
  32613. _this.renderComplete_;
  32614. /**
  32615. * @private
  32616. * @type {boolean}
  32617. */
  32618. _this.loaded_ = true;
  32619. /** @private */
  32620. _this.boundHandleBrowserEvent_ = _this.handleBrowserEvent.bind(_this);
  32621. /**
  32622. * @type {number}
  32623. * @private
  32624. */
  32625. _this.maxTilesLoading_ =
  32626. options.maxTilesLoading !== undefined ? options.maxTilesLoading : 16;
  32627. /**
  32628. * @private
  32629. * @type {number}
  32630. */
  32631. _this.pixelRatio_ =
  32632. options.pixelRatio !== undefined
  32633. ? options.pixelRatio
  32634. : DEVICE_PIXEL_RATIO;
  32635. /**
  32636. * @private
  32637. * @type {*}
  32638. */
  32639. _this.postRenderTimeoutHandle_;
  32640. /**
  32641. * @private
  32642. * @type {number|undefined}
  32643. */
  32644. _this.animationDelayKey_;
  32645. /**
  32646. * @private
  32647. */
  32648. _this.animationDelay_ = /** @this {PluggableMap} */ function () {
  32649. this.animationDelayKey_ = undefined;
  32650. this.renderFrame_(Date.now());
  32651. }.bind(_this);
  32652. /**
  32653. * @private
  32654. * @type {import("./transform.js").Transform}
  32655. */
  32656. _this.coordinateToPixelTransform_ = create();
  32657. /**
  32658. * @private
  32659. * @type {import("./transform.js").Transform}
  32660. */
  32661. _this.pixelToCoordinateTransform_ = create();
  32662. /**
  32663. * @private
  32664. * @type {number}
  32665. */
  32666. _this.frameIndex_ = 0;
  32667. /**
  32668. * @private
  32669. * @type {?FrameState}
  32670. */
  32671. _this.frameState_ = null;
  32672. /**
  32673. * The extent at the previous 'moveend' event.
  32674. * @private
  32675. * @type {import("./extent.js").Extent}
  32676. */
  32677. _this.previousExtent_ = null;
  32678. /**
  32679. * @private
  32680. * @type {?import("./events.js").EventsKey}
  32681. */
  32682. _this.viewPropertyListenerKey_ = null;
  32683. /**
  32684. * @private
  32685. * @type {?import("./events.js").EventsKey}
  32686. */
  32687. _this.viewChangeListenerKey_ = null;
  32688. /**
  32689. * @private
  32690. * @type {?Array<import("./events.js").EventsKey>}
  32691. */
  32692. _this.layerGroupPropertyListenerKeys_ = null;
  32693. /**
  32694. * @private
  32695. * @type {!HTMLElement}
  32696. */
  32697. _this.viewport_ = document.createElement('div');
  32698. _this.viewport_.className =
  32699. 'ol-viewport' + ('ontouchstart' in window ? ' ol-touch' : '');
  32700. _this.viewport_.style.position = 'relative';
  32701. _this.viewport_.style.overflow = 'hidden';
  32702. _this.viewport_.style.width = '100%';
  32703. _this.viewport_.style.height = '100%';
  32704. /**
  32705. * @private
  32706. * @type {!HTMLElement}
  32707. */
  32708. _this.overlayContainer_ = document.createElement('div');
  32709. _this.overlayContainer_.style.position = 'absolute';
  32710. _this.overlayContainer_.style.zIndex = '0';
  32711. _this.overlayContainer_.style.width = '100%';
  32712. _this.overlayContainer_.style.height = '100%';
  32713. _this.overlayContainer_.style.pointerEvents = 'none';
  32714. _this.overlayContainer_.className = 'ol-overlaycontainer';
  32715. _this.viewport_.appendChild(_this.overlayContainer_);
  32716. /**
  32717. * @private
  32718. * @type {!HTMLElement}
  32719. */
  32720. _this.overlayContainerStopEvent_ = document.createElement('div');
  32721. _this.overlayContainerStopEvent_.style.position = 'absolute';
  32722. _this.overlayContainerStopEvent_.style.zIndex = '0';
  32723. _this.overlayContainerStopEvent_.style.width = '100%';
  32724. _this.overlayContainerStopEvent_.style.height = '100%';
  32725. _this.overlayContainerStopEvent_.style.pointerEvents = 'none';
  32726. _this.overlayContainerStopEvent_.className = 'ol-overlaycontainer-stopevent';
  32727. _this.viewport_.appendChild(_this.overlayContainerStopEvent_);
  32728. /**
  32729. * @private
  32730. * @type {MapBrowserEventHandler}
  32731. */
  32732. _this.mapBrowserEventHandler_ = null;
  32733. /**
  32734. * @private
  32735. * @type {number}
  32736. */
  32737. _this.moveTolerance_ = options.moveTolerance;
  32738. /**
  32739. * @private
  32740. * @type {HTMLElement|Document}
  32741. */
  32742. _this.keyboardEventTarget_ = optionsInternal.keyboardEventTarget;
  32743. /**
  32744. * @private
  32745. * @type {?Array<import("./events.js").EventsKey>}
  32746. */
  32747. _this.targetChangeHandlerKeys_ = null;
  32748. /**
  32749. * @type {Collection<import("./control/Control.js").default>}
  32750. * @protected
  32751. */
  32752. _this.controls = optionsInternal.controls || new ol_Collection();
  32753. /**
  32754. * @type {Collection<import("./interaction/Interaction.js").default>}
  32755. * @protected
  32756. */
  32757. _this.interactions = optionsInternal.interactions || new ol_Collection();
  32758. /**
  32759. * @type {Collection<import("./Overlay.js").default>}
  32760. * @private
  32761. */
  32762. _this.overlays_ = optionsInternal.overlays;
  32763. /**
  32764. * A lookup of overlays by id.
  32765. * @private
  32766. * @type {Object<string, import("./Overlay.js").default>}
  32767. */
  32768. _this.overlayIdIndex_ = {};
  32769. /**
  32770. * @type {import("./renderer/Map.js").default|null}
  32771. * @private
  32772. */
  32773. _this.renderer_ = null;
  32774. /**
  32775. * @private
  32776. * @type {!Array<PostRenderFunction>}
  32777. */
  32778. _this.postRenderFunctions_ = [];
  32779. /**
  32780. * @private
  32781. * @type {TileQueue}
  32782. */
  32783. _this.tileQueue_ = new ol_TileQueue(_this.getTilePriority.bind(_this), _this.handleTileChange_.bind(_this));
  32784. _this.addChangeListener(MapProperty.LAYERGROUP, _this.handleLayerGroupChanged_);
  32785. _this.addChangeListener(MapProperty.VIEW, _this.handleViewChanged_);
  32786. _this.addChangeListener(MapProperty.SIZE, _this.handleSizeChanged_);
  32787. _this.addChangeListener(MapProperty.TARGET, _this.handleTargetChanged_);
  32788. // setProperties will trigger the rendering of the map if the map
  32789. // is "defined" already.
  32790. _this.setProperties(optionsInternal.values);
  32791. var map = _this;
  32792. if (options.view && !(options.view instanceof ol_View)) {
  32793. options.view.then(function (viewOptions) {
  32794. map.setView(new ol_View(viewOptions));
  32795. });
  32796. }
  32797. _this.controls.addEventListener(CollectionEventType.ADD,
  32798. /**
  32799. * @param {import("./Collection.js").CollectionEvent} event CollectionEvent.
  32800. */
  32801. function (event) {
  32802. event.element.setMap(this);
  32803. }.bind(_this));
  32804. _this.controls.addEventListener(CollectionEventType.REMOVE,
  32805. /**
  32806. * @param {import("./Collection.js").CollectionEvent} event CollectionEvent.
  32807. */
  32808. function (event) {
  32809. event.element.setMap(null);
  32810. }.bind(_this));
  32811. _this.interactions.addEventListener(CollectionEventType.ADD,
  32812. /**
  32813. * @param {import("./Collection.js").CollectionEvent} event CollectionEvent.
  32814. */
  32815. function (event) {
  32816. event.element.setMap(this);
  32817. }.bind(_this));
  32818. _this.interactions.addEventListener(CollectionEventType.REMOVE,
  32819. /**
  32820. * @param {import("./Collection.js").CollectionEvent} event CollectionEvent.
  32821. */
  32822. function (event) {
  32823. event.element.setMap(null);
  32824. }.bind(_this));
  32825. _this.overlays_.addEventListener(CollectionEventType.ADD,
  32826. /**
  32827. * @param {import("./Collection.js").CollectionEvent} event CollectionEvent.
  32828. */
  32829. function (event) {
  32830. this.addOverlayInternal_(
  32831. /** @type {import("./Overlay.js").default} */ (event.element));
  32832. }.bind(_this));
  32833. _this.overlays_.addEventListener(CollectionEventType.REMOVE,
  32834. /**
  32835. * @param {import("./Collection.js").CollectionEvent} event CollectionEvent.
  32836. */
  32837. function (event) {
  32838. var overlay = /** @type {import("./Overlay.js").default} */ (event.element);
  32839. var id = overlay.getId();
  32840. if (id !== undefined) {
  32841. delete this.overlayIdIndex_[id.toString()];
  32842. }
  32843. event.element.setMap(null);
  32844. }.bind(_this));
  32845. _this.controls.forEach(
  32846. /**
  32847. * @param {import("./control/Control.js").default} control Control.
  32848. * @this {PluggableMap}
  32849. */
  32850. function (control) {
  32851. control.setMap(this);
  32852. }.bind(_this));
  32853. _this.interactions.forEach(
  32854. /**
  32855. * @param {import("./interaction/Interaction.js").default} interaction Interaction.
  32856. * @this {PluggableMap}
  32857. */
  32858. function (interaction) {
  32859. interaction.setMap(this);
  32860. }.bind(_this));
  32861. _this.overlays_.forEach(_this.addOverlayInternal_.bind(_this));
  32862. return _this;
  32863. }
  32864. /**
  32865. * @abstract
  32866. * @return {import("./renderer/Map.js").default} The map renderer
  32867. */
  32868. PluggableMap.prototype.createRenderer = function () {
  32869. throw new Error('Use a map type that has a createRenderer method');
  32870. };
  32871. /**
  32872. * Add the given control to the map.
  32873. * @param {import("./control/Control.js").default} control Control.
  32874. * @api
  32875. */
  32876. PluggableMap.prototype.addControl = function (control) {
  32877. this.getControls().push(control);
  32878. };
  32879. /**
  32880. * Add the given interaction to the map. If you want to add an interaction
  32881. * at another point of the collection use `getInteractions()` and the methods
  32882. * available on {@link module:ol/Collection~Collection}. This can be used to
  32883. * stop the event propagation from the handleEvent function. The interactions
  32884. * get to handle the events in the reverse order of this collection.
  32885. * @param {import("./interaction/Interaction.js").default} interaction Interaction to add.
  32886. * @api
  32887. */
  32888. PluggableMap.prototype.addInteraction = function (interaction) {
  32889. this.getInteractions().push(interaction);
  32890. };
  32891. /**
  32892. * Adds the given layer to the top of this map. If you want to add a layer
  32893. * elsewhere in the stack, use `getLayers()` and the methods available on
  32894. * {@link module:ol/Collection~Collection}.
  32895. * @param {import("./layer/Base.js").default} layer Layer.
  32896. * @api
  32897. */
  32898. PluggableMap.prototype.addLayer = function (layer) {
  32899. var layers = this.getLayerGroup().getLayers();
  32900. layers.push(layer);
  32901. };
  32902. /**
  32903. * @param {import("./layer/Group.js").GroupEvent} event The layer add event.
  32904. * @private
  32905. */
  32906. PluggableMap.prototype.handleLayerAdd_ = function (event) {
  32907. setLayerMapProperty(event.layer, this);
  32908. };
  32909. /**
  32910. * Add the given overlay to the map.
  32911. * @param {import("./Overlay.js").default} overlay Overlay.
  32912. * @api
  32913. */
  32914. PluggableMap.prototype.addOverlay = function (overlay) {
  32915. this.getOverlays().push(overlay);
  32916. };
  32917. /**
  32918. * This deals with map's overlay collection changes.
  32919. * @param {import("./Overlay.js").default} overlay Overlay.
  32920. * @private
  32921. */
  32922. PluggableMap.prototype.addOverlayInternal_ = function (overlay) {
  32923. var id = overlay.getId();
  32924. if (id !== undefined) {
  32925. this.overlayIdIndex_[id.toString()] = overlay;
  32926. }
  32927. overlay.setMap(this);
  32928. };
  32929. /**
  32930. *
  32931. * Clean up.
  32932. */
  32933. PluggableMap.prototype.disposeInternal = function () {
  32934. this.controls.clear();
  32935. this.interactions.clear();
  32936. this.overlays_.clear();
  32937. this.setTarget(null);
  32938. _super.prototype.disposeInternal.call(this);
  32939. };
  32940. /**
  32941. * Detect features that intersect a pixel on the viewport, and execute a
  32942. * callback with each intersecting feature. Layers included in the detection can
  32943. * be configured through the `layerFilter` option in `opt_options`.
  32944. * @param {import("./pixel.js").Pixel} pixel Pixel.
  32945. * @param {function(import("./Feature.js").FeatureLike, import("./layer/Layer.js").default<import("./source/Source").default>, import("./geom/SimpleGeometry.js").default): T} callback Feature callback. The callback will be
  32946. * called with two arguments. The first argument is one
  32947. * {@link module:ol/Feature~Feature feature} or
  32948. * {@link module:ol/render/Feature~RenderFeature render feature} at the pixel, the second is
  32949. * the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for
  32950. * unmanaged layers. To stop detection, callback functions can return a
  32951. * truthy value.
  32952. * @param {AtPixelOptions} [opt_options] Optional options.
  32953. * @return {T|undefined} Callback result, i.e. the return value of last
  32954. * callback execution, or the first truthy callback return value.
  32955. * @template T
  32956. * @api
  32957. */
  32958. PluggableMap.prototype.forEachFeatureAtPixel = function (pixel, callback, opt_options) {
  32959. if (!this.frameState_ || !this.renderer_) {
  32960. return;
  32961. }
  32962. var coordinate = this.getCoordinateFromPixelInternal(pixel);
  32963. opt_options = opt_options !== undefined ? opt_options : {};
  32964. var hitTolerance = opt_options.hitTolerance !== undefined ? opt_options.hitTolerance : 0;
  32965. var layerFilter = opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
  32966. var checkWrapped = opt_options.checkWrapped !== false;
  32967. return this.renderer_.forEachFeatureAtCoordinate(coordinate, this.frameState_, hitTolerance, checkWrapped, callback, null, layerFilter, null);
  32968. };
  32969. /**
  32970. * Get all features that intersect a pixel on the viewport.
  32971. * @param {import("./pixel.js").Pixel} pixel Pixel.
  32972. * @param {AtPixelOptions} [opt_options] Optional options.
  32973. * @return {Array<import("./Feature.js").FeatureLike>} The detected features or
  32974. * an empty array if none were found.
  32975. * @api
  32976. */
  32977. PluggableMap.prototype.getFeaturesAtPixel = function (pixel, opt_options) {
  32978. var features = [];
  32979. this.forEachFeatureAtPixel(pixel, function (feature) {
  32980. features.push(feature);
  32981. }, opt_options);
  32982. return features;
  32983. };
  32984. /**
  32985. * Get all layers from all layer groups.
  32986. * @return {Array<import("./layer/Layer.js").default>} Layers.
  32987. * @api
  32988. */
  32989. PluggableMap.prototype.getAllLayers = function () {
  32990. var layers = [];
  32991. function addLayersFrom(layerGroup) {
  32992. layerGroup.forEach(function (layer) {
  32993. if (layer instanceof Group) {
  32994. addLayersFrom(layer.getLayers());
  32995. }
  32996. else {
  32997. layers.push(layer);
  32998. }
  32999. });
  33000. }
  33001. addLayersFrom(this.getLayers());
  33002. return layers;
  33003. };
  33004. /**
  33005. * Please the `layer.getData()` method for {@link module:ol/layer/Tile~TileLayer#getData tile layers} or
  33006. * {@link module:ol/layer/Image~ImageLayer#getData image layers} instead of using this method.
  33007. *
  33008. * Detect layers that have a color value at a pixel on the viewport, and
  33009. * execute a callback with each matching layer. Layers included in the
  33010. * detection can be configured through `opt_layerFilter`.
  33011. *
  33012. * Note: In maps with more than one layer, this method will typically return pixel data
  33013. * representing the composed image of all layers visible at the given pixel – because layers
  33014. * will generally share the same rendering context. To force layers to render separately, and
  33015. * to get pixel data representing only one layer at a time, you can assign each layer a unique
  33016. * `className` in its constructor.
  33017. *
  33018. * @param {import("./pixel.js").Pixel} pixel Pixel.
  33019. * @param {function(this: S, import("./layer/Layer.js").default, (Uint8ClampedArray|Uint8Array)): T} callback
  33020. * Layer callback. This callback will receive two arguments: first is the
  33021. * {@link module:ol/layer/Layer~Layer layer}, second argument is an array representing
  33022. * [R, G, B, A] pixel values (0 - 255) and will be `null` for layer types
  33023. * that do not currently support this argument. To stop detection, callback
  33024. * functions can return a truthy value.
  33025. * @param {AtPixelOptions} [opt_options] Configuration options.
  33026. * @return {T|undefined} Callback result, i.e. the return value of last
  33027. * callback execution, or the first truthy callback return value.
  33028. * @template S,T
  33029. * @api
  33030. * @deprecated
  33031. */
  33032. PluggableMap.prototype.forEachLayerAtPixel = function (pixel, callback, opt_options) {
  33033. if (!this.frameState_ || !this.renderer_) {
  33034. return;
  33035. }
  33036. var options = opt_options || {};
  33037. var hitTolerance = options.hitTolerance !== undefined ? options.hitTolerance : 0;
  33038. var layerFilter = options.layerFilter || TRUE;
  33039. return this.renderer_.forEachLayerAtPixel(pixel, this.frameState_, hitTolerance, callback, layerFilter);
  33040. };
  33041. /**
  33042. * Detect if features intersect a pixel on the viewport. Layers included in the
  33043. * detection can be configured through `opt_layerFilter`.
  33044. * @param {import("./pixel.js").Pixel} pixel Pixel.
  33045. * @param {AtPixelOptions} [opt_options] Optional options.
  33046. * @return {boolean} Is there a feature at the given pixel?
  33047. * @api
  33048. */
  33049. PluggableMap.prototype.hasFeatureAtPixel = function (pixel, opt_options) {
  33050. if (!this.frameState_ || !this.renderer_) {
  33051. return false;
  33052. }
  33053. var coordinate = this.getCoordinateFromPixelInternal(pixel);
  33054. opt_options = opt_options !== undefined ? opt_options : {};
  33055. var layerFilter = opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
  33056. var hitTolerance = opt_options.hitTolerance !== undefined ? opt_options.hitTolerance : 0;
  33057. var checkWrapped = opt_options.checkWrapped !== false;
  33058. return this.renderer_.hasFeatureAtCoordinate(coordinate, this.frameState_, hitTolerance, checkWrapped, layerFilter, null);
  33059. };
  33060. /**
  33061. * Returns the coordinate in user projection for a browser event.
  33062. * @param {MouseEvent} event Event.
  33063. * @return {import("./coordinate.js").Coordinate} Coordinate.
  33064. * @api
  33065. */
  33066. PluggableMap.prototype.getEventCoordinate = function (event) {
  33067. return this.getCoordinateFromPixel(this.getEventPixel(event));
  33068. };
  33069. /**
  33070. * Returns the coordinate in view projection for a browser event.
  33071. * @param {MouseEvent} event Event.
  33072. * @return {import("./coordinate.js").Coordinate} Coordinate.
  33073. */
  33074. PluggableMap.prototype.getEventCoordinateInternal = function (event) {
  33075. return this.getCoordinateFromPixelInternal(this.getEventPixel(event));
  33076. };
  33077. /**
  33078. * Returns the map pixel position for a browser event relative to the viewport.
  33079. * @param {UIEvent} event Event.
  33080. * @return {import("./pixel.js").Pixel} Pixel.
  33081. * @api
  33082. */
  33083. PluggableMap.prototype.getEventPixel = function (event) {
  33084. var viewportPosition = this.viewport_.getBoundingClientRect();
  33085. var eventPosition =
  33086. //FIXME Are we really calling this with a TouchEvent anywhere?
  33087. 'changedTouches' in event
  33088. ? /** @type {TouchEvent} */ (event).changedTouches[0]
  33089. : /** @type {MouseEvent} */ (event);
  33090. return [
  33091. eventPosition.clientX - viewportPosition.left,
  33092. eventPosition.clientY - viewportPosition.top,
  33093. ];
  33094. };
  33095. /**
  33096. * Get the target in which this map is rendered.
  33097. * Note that this returns what is entered as an option or in setTarget:
  33098. * if that was an element, it returns an element; if a string, it returns that.
  33099. * @return {HTMLElement|string|undefined} The Element or id of the Element that the
  33100. * map is rendered in.
  33101. * @observable
  33102. * @api
  33103. */
  33104. PluggableMap.prototype.getTarget = function () {
  33105. return /** @type {HTMLElement|string|undefined} */ (this.get(MapProperty.TARGET));
  33106. };
  33107. /**
  33108. * Get the DOM element into which this map is rendered. In contrast to
  33109. * `getTarget` this method always return an `Element`, or `null` if the
  33110. * map has no target.
  33111. * @return {HTMLElement} The element that the map is rendered in.
  33112. * @api
  33113. */
  33114. PluggableMap.prototype.getTargetElement = function () {
  33115. var target = this.getTarget();
  33116. if (target !== undefined) {
  33117. return typeof target === 'string'
  33118. ? document.getElementById(target)
  33119. : target;
  33120. }
  33121. else {
  33122. return null;
  33123. }
  33124. };
  33125. /**
  33126. * Get the coordinate for a given pixel. This returns a coordinate in the
  33127. * user projection.
  33128. * @param {import("./pixel.js").Pixel} pixel Pixel position in the map viewport.
  33129. * @return {import("./coordinate.js").Coordinate} The coordinate for the pixel position.
  33130. * @api
  33131. */
  33132. PluggableMap.prototype.getCoordinateFromPixel = function (pixel) {
  33133. return toUserCoordinate(this.getCoordinateFromPixelInternal(pixel), this.getView().getProjection());
  33134. };
  33135. /**
  33136. * Get the coordinate for a given pixel. This returns a coordinate in the
  33137. * map view projection.
  33138. * @param {import("./pixel.js").Pixel} pixel Pixel position in the map viewport.
  33139. * @return {import("./coordinate.js").Coordinate} The coordinate for the pixel position.
  33140. */
  33141. PluggableMap.prototype.getCoordinateFromPixelInternal = function (pixel) {
  33142. var frameState = this.frameState_;
  33143. if (!frameState) {
  33144. return null;
  33145. }
  33146. else {
  33147. return apply(frameState.pixelToCoordinateTransform, pixel.slice());
  33148. }
  33149. };
  33150. /**
  33151. * Get the map controls. Modifying this collection changes the controls
  33152. * associated with the map.
  33153. * @return {Collection<import("./control/Control.js").default>} Controls.
  33154. * @api
  33155. */
  33156. PluggableMap.prototype.getControls = function () {
  33157. return this.controls;
  33158. };
  33159. /**
  33160. * Get the map overlays. Modifying this collection changes the overlays
  33161. * associated with the map.
  33162. * @return {Collection<import("./Overlay.js").default>} Overlays.
  33163. * @api
  33164. */
  33165. PluggableMap.prototype.getOverlays = function () {
  33166. return this.overlays_;
  33167. };
  33168. /**
  33169. * Get an overlay by its identifier (the value returned by overlay.getId()).
  33170. * Note that the index treats string and numeric identifiers as the same. So
  33171. * `map.getOverlayById(2)` will return an overlay with id `'2'` or `2`.
  33172. * @param {string|number} id Overlay identifier.
  33173. * @return {import("./Overlay.js").default} Overlay.
  33174. * @api
  33175. */
  33176. PluggableMap.prototype.getOverlayById = function (id) {
  33177. var overlay = this.overlayIdIndex_[id.toString()];
  33178. return overlay !== undefined ? overlay : null;
  33179. };
  33180. /**
  33181. * Get the map interactions. Modifying this collection changes the interactions
  33182. * associated with the map.
  33183. *
  33184. * Interactions are used for e.g. pan, zoom and rotate.
  33185. * @return {Collection<import("./interaction/Interaction.js").default>} Interactions.
  33186. * @api
  33187. */
  33188. PluggableMap.prototype.getInteractions = function () {
  33189. return this.interactions;
  33190. };
  33191. /**
  33192. * Get the layergroup associated with this map.
  33193. * @return {LayerGroup} A layer group containing the layers in this map.
  33194. * @observable
  33195. * @api
  33196. */
  33197. PluggableMap.prototype.getLayerGroup = function () {
  33198. return /** @type {LayerGroup} */ (this.get(MapProperty.LAYERGROUP));
  33199. };
  33200. /**
  33201. * Clear any existing layers and add layers to the map.
  33202. * @param {Array<import("./layer/Base.js").default>|Collection<import("./layer/Base.js").default>} layers The layers to be added to the map.
  33203. * @api
  33204. */
  33205. PluggableMap.prototype.setLayers = function (layers) {
  33206. var group = this.getLayerGroup();
  33207. if (layers instanceof ol_Collection) {
  33208. group.setLayers(layers);
  33209. return;
  33210. }
  33211. var collection = group.getLayers();
  33212. collection.clear();
  33213. collection.extend(layers);
  33214. };
  33215. /**
  33216. * Get the collection of layers associated with this map.
  33217. * @return {!Collection<import("./layer/Base.js").default>} Layers.
  33218. * @api
  33219. */
  33220. PluggableMap.prototype.getLayers = function () {
  33221. var layers = this.getLayerGroup().getLayers();
  33222. return layers;
  33223. };
  33224. /**
  33225. * @return {boolean} Layers have sources that are still loading.
  33226. */
  33227. PluggableMap.prototype.getLoadingOrNotReady = function () {
  33228. var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
  33229. for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
  33230. var state = layerStatesArray[i];
  33231. if (!state.visible) {
  33232. continue;
  33233. }
  33234. var renderer = state.layer.getRenderer();
  33235. if (renderer && !renderer.ready) {
  33236. return true;
  33237. }
  33238. var source = /** @type {import("./layer/Layer.js").default} */ (state.layer).getSource();
  33239. if (source && source.loading) {
  33240. return true;
  33241. }
  33242. }
  33243. return false;
  33244. };
  33245. /**
  33246. * Get the pixel for a coordinate. This takes a coordinate in the user
  33247. * projection and returns the corresponding pixel.
  33248. * @param {import("./coordinate.js").Coordinate} coordinate A map coordinate.
  33249. * @return {import("./pixel.js").Pixel} A pixel position in the map viewport.
  33250. * @api
  33251. */
  33252. PluggableMap.prototype.getPixelFromCoordinate = function (coordinate) {
  33253. var viewCoordinate = fromUserCoordinate(coordinate, this.getView().getProjection());
  33254. return this.getPixelFromCoordinateInternal(viewCoordinate);
  33255. };
  33256. /**
  33257. * Get the pixel for a coordinate. This takes a coordinate in the map view
  33258. * projection and returns the corresponding pixel.
  33259. * @param {import("./coordinate.js").Coordinate} coordinate A map coordinate.
  33260. * @return {import("./pixel.js").Pixel} A pixel position in the map viewport.
  33261. */
  33262. PluggableMap.prototype.getPixelFromCoordinateInternal = function (coordinate) {
  33263. var frameState = this.frameState_;
  33264. if (!frameState) {
  33265. return null;
  33266. }
  33267. else {
  33268. return apply(frameState.coordinateToPixelTransform, coordinate.slice(0, 2));
  33269. }
  33270. };
  33271. /**
  33272. * Get the map renderer.
  33273. * @return {import("./renderer/Map.js").default|null} Renderer
  33274. */
  33275. PluggableMap.prototype.getRenderer = function () {
  33276. return this.renderer_;
  33277. };
  33278. /**
  33279. * Get the size of this map.
  33280. * @return {import("./size.js").Size|undefined} The size in pixels of the map in the DOM.
  33281. * @observable
  33282. * @api
  33283. */
  33284. PluggableMap.prototype.getSize = function () {
  33285. return /** @type {import("./size.js").Size|undefined} */ (this.get(MapProperty.SIZE));
  33286. };
  33287. /**
  33288. * Get the view associated with this map. A view manages properties such as
  33289. * center and resolution.
  33290. * @return {View} The view that controls this map.
  33291. * @observable
  33292. * @api
  33293. */
  33294. PluggableMap.prototype.getView = function () {
  33295. return /** @type {View} */ (this.get(MapProperty.VIEW));
  33296. };
  33297. /**
  33298. * Get the element that serves as the map viewport.
  33299. * @return {HTMLElement} Viewport.
  33300. * @api
  33301. */
  33302. PluggableMap.prototype.getViewport = function () {
  33303. return this.viewport_;
  33304. };
  33305. /**
  33306. * Get the element that serves as the container for overlays. Elements added to
  33307. * this container will let mousedown and touchstart events through to the map,
  33308. * so clicks and gestures on an overlay will trigger {@link module:ol/MapBrowserEvent~MapBrowserEvent}
  33309. * events.
  33310. * @return {!HTMLElement} The map's overlay container.
  33311. */
  33312. PluggableMap.prototype.getOverlayContainer = function () {
  33313. return this.overlayContainer_;
  33314. };
  33315. /**
  33316. * Get the element that serves as a container for overlays that don't allow
  33317. * event propagation. Elements added to this container won't let mousedown and
  33318. * touchstart events through to the map, so clicks and gestures on an overlay
  33319. * don't trigger any {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
  33320. * @return {!HTMLElement} The map's overlay container that stops events.
  33321. */
  33322. PluggableMap.prototype.getOverlayContainerStopEvent = function () {
  33323. return this.overlayContainerStopEvent_;
  33324. };
  33325. /**
  33326. * @return {!Document} The document where the map is displayed.
  33327. */
  33328. PluggableMap.prototype.getOwnerDocument = function () {
  33329. var targetElement = this.getTargetElement();
  33330. return targetElement ? targetElement.ownerDocument : document;
  33331. };
  33332. /**
  33333. * @param {import("./Tile.js").default} tile Tile.
  33334. * @param {string} tileSourceKey Tile source key.
  33335. * @param {import("./coordinate.js").Coordinate} tileCenter Tile center.
  33336. * @param {number} tileResolution Tile resolution.
  33337. * @return {number} Tile priority.
  33338. */
  33339. PluggableMap.prototype.getTilePriority = function (tile, tileSourceKey, tileCenter, tileResolution) {
  33340. return getTilePriority(this.frameState_, tile, tileSourceKey, tileCenter, tileResolution);
  33341. };
  33342. /**
  33343. * @param {UIEvent} browserEvent Browser event.
  33344. * @param {string} [opt_type] Type.
  33345. */
  33346. PluggableMap.prototype.handleBrowserEvent = function (browserEvent, opt_type) {
  33347. var type = opt_type || browserEvent.type;
  33348. var mapBrowserEvent = new ol_MapBrowserEvent(type, this, browserEvent);
  33349. this.handleMapBrowserEvent(mapBrowserEvent);
  33350. };
  33351. /**
  33352. * @param {MapBrowserEvent} mapBrowserEvent The event to handle.
  33353. */
  33354. PluggableMap.prototype.handleMapBrowserEvent = function (mapBrowserEvent) {
  33355. if (!this.frameState_) {
  33356. // With no view defined, we cannot translate pixels into geographical
  33357. // coordinates so interactions cannot be used.
  33358. return;
  33359. }
  33360. var originalEvent = /** @type {PointerEvent} */ (mapBrowserEvent.originalEvent);
  33361. var eventType = originalEvent.type;
  33362. if (eventType === pointer_EventType.POINTERDOWN ||
  33363. eventType === EventType.WHEEL ||
  33364. eventType === EventType.KEYDOWN) {
  33365. var doc = this.getOwnerDocument();
  33366. var rootNode = this.viewport_.getRootNode
  33367. ? this.viewport_.getRootNode()
  33368. : doc;
  33369. var target = /** @type {Node} */ (originalEvent.target);
  33370. if (
  33371. // Abort if the target is a child of the container for elements whose events are not meant
  33372. // to be handled by map interactions.
  33373. this.overlayContainerStopEvent_.contains(target) ||
  33374. // Abort if the event target is a child of the container that is no longer in the page.
  33375. // It's possible for the target to no longer be in the page if it has been removed in an
  33376. // event listener, this might happen in a Control that recreates it's content based on
  33377. // user interaction either manually or via a render in something like https://reactjs.org/
  33378. !(rootNode === doc ? doc.documentElement : rootNode).contains(target)) {
  33379. return;
  33380. }
  33381. }
  33382. mapBrowserEvent.frameState = this.frameState_;
  33383. if (this.dispatchEvent(mapBrowserEvent) !== false) {
  33384. var interactionsArray = this.getInteractions().getArray().slice();
  33385. for (var i = interactionsArray.length - 1; i >= 0; i--) {
  33386. var interaction = interactionsArray[i];
  33387. if (interaction.getMap() !== this ||
  33388. !interaction.getActive() ||
  33389. !this.getTargetElement()) {
  33390. continue;
  33391. }
  33392. var cont = interaction.handleEvent(mapBrowserEvent);
  33393. if (!cont || mapBrowserEvent.propagationStopped) {
  33394. break;
  33395. }
  33396. }
  33397. }
  33398. };
  33399. /**
  33400. * @protected
  33401. */
  33402. PluggableMap.prototype.handlePostRender = function () {
  33403. var frameState = this.frameState_;
  33404. // Manage the tile queue
  33405. // Image loads are expensive and a limited resource, so try to use them
  33406. // efficiently:
  33407. // * When the view is static we allow a large number of parallel tile loads
  33408. // to complete the frame as quickly as possible.
  33409. // * When animating or interacting, image loads can cause janks, so we reduce
  33410. // the maximum number of loads per frame and limit the number of parallel
  33411. // tile loads to remain reactive to view changes and to reduce the chance of
  33412. // loading tiles that will quickly disappear from view.
  33413. var tileQueue = this.tileQueue_;
  33414. if (!tileQueue.isEmpty()) {
  33415. var maxTotalLoading = this.maxTilesLoading_;
  33416. var maxNewLoads = maxTotalLoading;
  33417. if (frameState) {
  33418. var hints = frameState.viewHints;
  33419. if (hints[ViewHint.ANIMATING] || hints[ViewHint.INTERACTING]) {
  33420. var lowOnFrameBudget = Date.now() - frameState.time > 8;
  33421. maxTotalLoading = lowOnFrameBudget ? 0 : 8;
  33422. maxNewLoads = lowOnFrameBudget ? 0 : 2;
  33423. }
  33424. }
  33425. if (tileQueue.getTilesLoading() < maxTotalLoading) {
  33426. tileQueue.reprioritize(); // FIXME only call if view has changed
  33427. tileQueue.loadMoreTiles(maxTotalLoading, maxNewLoads);
  33428. }
  33429. }
  33430. if (frameState && this.renderer_ && !frameState.animate) {
  33431. if (this.renderComplete_ === true) {
  33432. if (this.hasListener(render_EventType.RENDERCOMPLETE)) {
  33433. this.renderer_.dispatchRenderEvent(render_EventType.RENDERCOMPLETE, frameState);
  33434. }
  33435. if (this.loaded_ === false) {
  33436. this.loaded_ = true;
  33437. this.dispatchEvent(new ol_MapEvent(MapEventType.LOADEND, this, frameState));
  33438. }
  33439. }
  33440. else if (this.loaded_ === true) {
  33441. this.loaded_ = false;
  33442. this.dispatchEvent(new ol_MapEvent(MapEventType.LOADSTART, this, frameState));
  33443. }
  33444. }
  33445. var postRenderFunctions = this.postRenderFunctions_;
  33446. for (var i = 0, ii = postRenderFunctions.length; i < ii; ++i) {
  33447. postRenderFunctions[i](this, frameState);
  33448. }
  33449. postRenderFunctions.length = 0;
  33450. };
  33451. /**
  33452. * @private
  33453. */
  33454. PluggableMap.prototype.handleSizeChanged_ = function () {
  33455. if (this.getView() && !this.getView().getAnimating()) {
  33456. this.getView().resolveConstraints(0);
  33457. }
  33458. this.render();
  33459. };
  33460. /**
  33461. * @private
  33462. */
  33463. PluggableMap.prototype.handleTargetChanged_ = function () {
  33464. if (this.mapBrowserEventHandler_) {
  33465. for (var i = 0, ii = this.targetChangeHandlerKeys_.length; i < ii; ++i) {
  33466. unlistenByKey(this.targetChangeHandlerKeys_[i]);
  33467. }
  33468. this.targetChangeHandlerKeys_ = null;
  33469. this.viewport_.removeEventListener(EventType.CONTEXTMENU, this.boundHandleBrowserEvent_);
  33470. this.viewport_.removeEventListener(EventType.WHEEL, this.boundHandleBrowserEvent_);
  33471. this.mapBrowserEventHandler_.dispose();
  33472. this.mapBrowserEventHandler_ = null;
  33473. removeNode(this.viewport_);
  33474. }
  33475. // target may be undefined, null, a string or an Element.
  33476. // If it's a string we convert it to an Element before proceeding.
  33477. // If it's not now an Element we remove the viewport from the DOM.
  33478. // If it's an Element we append the viewport element to it.
  33479. var targetElement = this.getTargetElement();
  33480. if (!targetElement) {
  33481. if (this.renderer_) {
  33482. clearTimeout(this.postRenderTimeoutHandle_);
  33483. this.postRenderTimeoutHandle_ = undefined;
  33484. this.postRenderFunctions_.length = 0;
  33485. this.renderer_.dispose();
  33486. this.renderer_ = null;
  33487. }
  33488. if (this.animationDelayKey_) {
  33489. cancelAnimationFrame(this.animationDelayKey_);
  33490. this.animationDelayKey_ = undefined;
  33491. }
  33492. }
  33493. else {
  33494. targetElement.appendChild(this.viewport_);
  33495. if (!this.renderer_) {
  33496. this.renderer_ = this.createRenderer();
  33497. }
  33498. this.mapBrowserEventHandler_ = new ol_MapBrowserEventHandler(this, this.moveTolerance_);
  33499. for (var key in ol_MapBrowserEventType) {
  33500. this.mapBrowserEventHandler_.addEventListener(ol_MapBrowserEventType[key], this.handleMapBrowserEvent.bind(this));
  33501. }
  33502. this.viewport_.addEventListener(EventType.CONTEXTMENU, this.boundHandleBrowserEvent_, false);
  33503. this.viewport_.addEventListener(EventType.WHEEL, this.boundHandleBrowserEvent_, PASSIVE_EVENT_LISTENERS ? { passive: false } : false);
  33504. var defaultView = this.getOwnerDocument().defaultView;
  33505. var keyboardEventTarget = !this.keyboardEventTarget_
  33506. ? targetElement
  33507. : this.keyboardEventTarget_;
  33508. this.targetChangeHandlerKeys_ = [
  33509. listen(keyboardEventTarget, EventType.KEYDOWN, this.handleBrowserEvent, this),
  33510. listen(keyboardEventTarget, EventType.KEYPRESS, this.handleBrowserEvent, this),
  33511. listen(defaultView, EventType.RESIZE, this.updateSize, this),
  33512. ];
  33513. }
  33514. this.updateSize();
  33515. // updateSize calls setSize, so no need to call this.render
  33516. // ourselves here.
  33517. };
  33518. /**
  33519. * @private
  33520. */
  33521. PluggableMap.prototype.handleTileChange_ = function () {
  33522. this.render();
  33523. };
  33524. /**
  33525. * @private
  33526. */
  33527. PluggableMap.prototype.handleViewPropertyChanged_ = function () {
  33528. this.render();
  33529. };
  33530. /**
  33531. * @private
  33532. */
  33533. PluggableMap.prototype.handleViewChanged_ = function () {
  33534. if (this.viewPropertyListenerKey_) {
  33535. unlistenByKey(this.viewPropertyListenerKey_);
  33536. this.viewPropertyListenerKey_ = null;
  33537. }
  33538. if (this.viewChangeListenerKey_) {
  33539. unlistenByKey(this.viewChangeListenerKey_);
  33540. this.viewChangeListenerKey_ = null;
  33541. }
  33542. var view = this.getView();
  33543. if (view) {
  33544. this.updateViewportSize_();
  33545. this.viewPropertyListenerKey_ = listen(view, ObjectEventType.PROPERTYCHANGE, this.handleViewPropertyChanged_, this);
  33546. this.viewChangeListenerKey_ = listen(view, EventType.CHANGE, this.handleViewPropertyChanged_, this);
  33547. view.resolveConstraints(0);
  33548. }
  33549. this.render();
  33550. };
  33551. /**
  33552. * @private
  33553. */
  33554. PluggableMap.prototype.handleLayerGroupChanged_ = function () {
  33555. if (this.layerGroupPropertyListenerKeys_) {
  33556. this.layerGroupPropertyListenerKeys_.forEach(unlistenByKey);
  33557. this.layerGroupPropertyListenerKeys_ = null;
  33558. }
  33559. var layerGroup = this.getLayerGroup();
  33560. if (layerGroup) {
  33561. this.handleLayerAdd_(new GroupEvent('addlayer', layerGroup));
  33562. this.layerGroupPropertyListenerKeys_ = [
  33563. listen(layerGroup, ObjectEventType.PROPERTYCHANGE, this.render, this),
  33564. listen(layerGroup, EventType.CHANGE, this.render, this),
  33565. listen(layerGroup, 'addlayer', this.handleLayerAdd_, this),
  33566. listen(layerGroup, 'removelayer', this.handleLayerRemove_, this),
  33567. ];
  33568. }
  33569. this.render();
  33570. };
  33571. /**
  33572. * @return {boolean} Is rendered.
  33573. */
  33574. PluggableMap.prototype.isRendered = function () {
  33575. return !!this.frameState_;
  33576. };
  33577. /**
  33578. * Requests an immediate render in a synchronous manner.
  33579. * @api
  33580. */
  33581. PluggableMap.prototype.renderSync = function () {
  33582. if (this.animationDelayKey_) {
  33583. cancelAnimationFrame(this.animationDelayKey_);
  33584. }
  33585. this.animationDelay_();
  33586. };
  33587. /**
  33588. * Redraws all text after new fonts have loaded
  33589. */
  33590. PluggableMap.prototype.redrawText = function () {
  33591. var layerStates = this.getLayerGroup().getLayerStatesArray();
  33592. for (var i = 0, ii = layerStates.length; i < ii; ++i) {
  33593. var layer = layerStates[i].layer;
  33594. if (layer.hasRenderer()) {
  33595. layer.getRenderer().handleFontsChanged();
  33596. }
  33597. }
  33598. };
  33599. /**
  33600. * Request a map rendering (at the next animation frame).
  33601. * @api
  33602. */
  33603. PluggableMap.prototype.render = function () {
  33604. if (this.renderer_ && this.animationDelayKey_ === undefined) {
  33605. this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_);
  33606. }
  33607. };
  33608. /**
  33609. * Remove the given control from the map.
  33610. * @param {import("./control/Control.js").default} control Control.
  33611. * @return {import("./control/Control.js").default|undefined} The removed control (or undefined
  33612. * if the control was not found).
  33613. * @api
  33614. */
  33615. PluggableMap.prototype.removeControl = function (control) {
  33616. return this.getControls().remove(control);
  33617. };
  33618. /**
  33619. * Remove the given interaction from the map.
  33620. * @param {import("./interaction/Interaction.js").default} interaction Interaction to remove.
  33621. * @return {import("./interaction/Interaction.js").default|undefined} The removed interaction (or
  33622. * undefined if the interaction was not found).
  33623. * @api
  33624. */
  33625. PluggableMap.prototype.removeInteraction = function (interaction) {
  33626. return this.getInteractions().remove(interaction);
  33627. };
  33628. /**
  33629. * Removes the given layer from the map.
  33630. * @param {import("./layer/Base.js").default} layer Layer.
  33631. * @return {import("./layer/Base.js").default|undefined} The removed layer (or undefined if the
  33632. * layer was not found).
  33633. * @api
  33634. */
  33635. PluggableMap.prototype.removeLayer = function (layer) {
  33636. var layers = this.getLayerGroup().getLayers();
  33637. return layers.remove(layer);
  33638. };
  33639. /**
  33640. * @param {import("./layer/Group.js").GroupEvent} event The layer remove event.
  33641. * @private
  33642. */
  33643. PluggableMap.prototype.handleLayerRemove_ = function (event) {
  33644. removeLayerMapProperty(event.layer);
  33645. };
  33646. /**
  33647. * Remove the given overlay from the map.
  33648. * @param {import("./Overlay.js").default} overlay Overlay.
  33649. * @return {import("./Overlay.js").default|undefined} The removed overlay (or undefined
  33650. * if the overlay was not found).
  33651. * @api
  33652. */
  33653. PluggableMap.prototype.removeOverlay = function (overlay) {
  33654. return this.getOverlays().remove(overlay);
  33655. };
  33656. /**
  33657. * @param {number} time Time.
  33658. * @private
  33659. */
  33660. PluggableMap.prototype.renderFrame_ = function (time) {
  33661. var _this = this;
  33662. var size = this.getSize();
  33663. var view = this.getView();
  33664. var previousFrameState = this.frameState_;
  33665. /** @type {?FrameState} */
  33666. var frameState = null;
  33667. if (size !== undefined && hasArea(size) && view && view.isDef()) {
  33668. var viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined);
  33669. var viewState = view.getState();
  33670. frameState = {
  33671. animate: false,
  33672. coordinateToPixelTransform: this.coordinateToPixelTransform_,
  33673. declutterTree: null,
  33674. extent: getForViewAndSize(viewState.center, viewState.resolution, viewState.rotation, size),
  33675. index: this.frameIndex_++,
  33676. layerIndex: 0,
  33677. layerStatesArray: this.getLayerGroup().getLayerStatesArray(),
  33678. pixelRatio: this.pixelRatio_,
  33679. pixelToCoordinateTransform: this.pixelToCoordinateTransform_,
  33680. postRenderFunctions: [],
  33681. size: size,
  33682. tileQueue: this.tileQueue_,
  33683. time: time,
  33684. usedTiles: {},
  33685. viewState: viewState,
  33686. viewHints: viewHints,
  33687. wantedTiles: {},
  33688. mapId: getUid(this),
  33689. renderTargets: {},
  33690. };
  33691. if (viewState.nextCenter && viewState.nextResolution) {
  33692. var rotation = isNaN(viewState.nextRotation)
  33693. ? viewState.rotation
  33694. : viewState.nextRotation;
  33695. frameState.nextExtent = getForViewAndSize(viewState.nextCenter, viewState.nextResolution, rotation, size);
  33696. }
  33697. }
  33698. this.frameState_ = frameState;
  33699. /** @type {import("./renderer/Map.js").default} */ (this.renderer_).renderFrame(frameState);
  33700. if (frameState) {
  33701. if (frameState.animate) {
  33702. this.render();
  33703. }
  33704. Array.prototype.push.apply(this.postRenderFunctions_, frameState.postRenderFunctions);
  33705. if (previousFrameState) {
  33706. var moveStart = !this.previousExtent_ ||
  33707. (!extent_isEmpty(this.previousExtent_) &&
  33708. !extent_equals(frameState.extent, this.previousExtent_));
  33709. if (moveStart) {
  33710. this.dispatchEvent(new ol_MapEvent(MapEventType.MOVESTART, this, previousFrameState));
  33711. this.previousExtent_ = createOrUpdateEmpty(this.previousExtent_);
  33712. }
  33713. }
  33714. var idle = this.previousExtent_ &&
  33715. !frameState.viewHints[ViewHint.ANIMATING] &&
  33716. !frameState.viewHints[ViewHint.INTERACTING] &&
  33717. !extent_equals(frameState.extent, this.previousExtent_);
  33718. if (idle) {
  33719. this.dispatchEvent(new ol_MapEvent(MapEventType.MOVEEND, this, frameState));
  33720. clone(frameState.extent, this.previousExtent_);
  33721. }
  33722. }
  33723. this.dispatchEvent(new ol_MapEvent(MapEventType.POSTRENDER, this, frameState));
  33724. this.renderComplete_ =
  33725. this.hasListener(MapEventType.LOADSTART) ||
  33726. this.hasListener(MapEventType.LOADEND) ||
  33727. this.hasListener(render_EventType.RENDERCOMPLETE)
  33728. ? !this.tileQueue_.getTilesLoading() &&
  33729. !this.tileQueue_.getCount() &&
  33730. !this.getLoadingOrNotReady()
  33731. : undefined;
  33732. if (!this.postRenderTimeoutHandle_) {
  33733. this.postRenderTimeoutHandle_ = setTimeout(function () {
  33734. _this.postRenderTimeoutHandle_ = undefined;
  33735. _this.handlePostRender();
  33736. }, 0);
  33737. }
  33738. };
  33739. /**
  33740. * Sets the layergroup of this map.
  33741. * @param {LayerGroup} layerGroup A layer group containing the layers in this map.
  33742. * @observable
  33743. * @api
  33744. */
  33745. PluggableMap.prototype.setLayerGroup = function (layerGroup) {
  33746. var oldLayerGroup = this.getLayerGroup();
  33747. if (oldLayerGroup) {
  33748. this.handleLayerRemove_(new GroupEvent('removelayer', oldLayerGroup));
  33749. }
  33750. this.set(MapProperty.LAYERGROUP, layerGroup);
  33751. };
  33752. /**
  33753. * Set the size of this map.
  33754. * @param {import("./size.js").Size|undefined} size The size in pixels of the map in the DOM.
  33755. * @observable
  33756. * @api
  33757. */
  33758. PluggableMap.prototype.setSize = function (size) {
  33759. this.set(MapProperty.SIZE, size);
  33760. };
  33761. /**
  33762. * Set the target element to render this map into.
  33763. * @param {HTMLElement|string} [target] The Element or id of the Element
  33764. * that the map is rendered in.
  33765. * @observable
  33766. * @api
  33767. */
  33768. PluggableMap.prototype.setTarget = function (target) {
  33769. this.set(MapProperty.TARGET, target);
  33770. };
  33771. /**
  33772. * Set the view for this map.
  33773. * @param {View|Promise<import("./View.js").ViewOptions>} view The view that controls this map.
  33774. * It is also possible to pass a promise that resolves to options for constructing a view. This
  33775. * alternative allows view properties to be resolved by sources or other components that load
  33776. * view-related metadata.
  33777. * @observable
  33778. * @api
  33779. */
  33780. PluggableMap.prototype.setView = function (view) {
  33781. if (!view || view instanceof ol_View) {
  33782. this.set(MapProperty.VIEW, view);
  33783. return;
  33784. }
  33785. this.set(MapProperty.VIEW, new ol_View());
  33786. var map = this;
  33787. view.then(function (viewOptions) {
  33788. map.setView(new ol_View(viewOptions));
  33789. });
  33790. };
  33791. /**
  33792. * Force a recalculation of the map viewport size. This should be called when
  33793. * third-party code changes the size of the map viewport.
  33794. * @api
  33795. */
  33796. PluggableMap.prototype.updateSize = function () {
  33797. var targetElement = this.getTargetElement();
  33798. var size = undefined;
  33799. if (targetElement) {
  33800. var computedStyle = getComputedStyle(targetElement);
  33801. var width = targetElement.offsetWidth -
  33802. parseFloat(computedStyle['borderLeftWidth']) -
  33803. parseFloat(computedStyle['paddingLeft']) -
  33804. parseFloat(computedStyle['paddingRight']) -
  33805. parseFloat(computedStyle['borderRightWidth']);
  33806. var height = targetElement.offsetHeight -
  33807. parseFloat(computedStyle['borderTopWidth']) -
  33808. parseFloat(computedStyle['paddingTop']) -
  33809. parseFloat(computedStyle['paddingBottom']) -
  33810. parseFloat(computedStyle['borderBottomWidth']);
  33811. if (!isNaN(width) && !isNaN(height)) {
  33812. size = [width, height];
  33813. if (!hasArea(size) &&
  33814. !!(targetElement.offsetWidth ||
  33815. targetElement.offsetHeight ||
  33816. targetElement.getClientRects().length)) {
  33817. // eslint-disable-next-line
  33818. console.warn("No map visible because the map container's width or height are 0.");
  33819. }
  33820. }
  33821. }
  33822. this.setSize(size);
  33823. this.updateViewportSize_();
  33824. };
  33825. /**
  33826. * Recomputes the viewport size and save it on the view object (if any)
  33827. * @private
  33828. */
  33829. PluggableMap.prototype.updateViewportSize_ = function () {
  33830. var view = this.getView();
  33831. if (view) {
  33832. var size = undefined;
  33833. var computedStyle = getComputedStyle(this.viewport_);
  33834. if (computedStyle.width && computedStyle.height) {
  33835. size = [
  33836. parseInt(computedStyle.width, 10),
  33837. parseInt(computedStyle.height, 10),
  33838. ];
  33839. }
  33840. view.setViewportSize(size);
  33841. }
  33842. };
  33843. return PluggableMap;
  33844. }(ol_Object));
  33845. /**
  33846. * @param {MapOptions} options Map options.
  33847. * @return {MapOptionsInternal} Internal map options.
  33848. */
  33849. function createOptionsInternal(options) {
  33850. /**
  33851. * @type {HTMLElement|Document}
  33852. */
  33853. var keyboardEventTarget = null;
  33854. if (options.keyboardEventTarget !== undefined) {
  33855. keyboardEventTarget =
  33856. typeof options.keyboardEventTarget === 'string'
  33857. ? document.getElementById(options.keyboardEventTarget)
  33858. : options.keyboardEventTarget;
  33859. }
  33860. /**
  33861. * @type {Object<string, *>}
  33862. */
  33863. var values = {};
  33864. var layerGroup = options.layers &&
  33865. typeof ( /** @type {?} */(options.layers).getLayers) === 'function'
  33866. ? /** @type {LayerGroup} */ (options.layers)
  33867. : new Group({ layers: /** @type {Collection} */ (options.layers) });
  33868. values[MapProperty.LAYERGROUP] = layerGroup;
  33869. values[MapProperty.TARGET] = options.target;
  33870. values[MapProperty.VIEW] =
  33871. options.view instanceof ol_View ? options.view : new ol_View();
  33872. var controls;
  33873. if (options.controls !== undefined) {
  33874. if (Array.isArray(options.controls)) {
  33875. controls = new ol_Collection(options.controls.slice());
  33876. }
  33877. else {
  33878. asserts_assert(typeof ( /** @type {?} */(options.controls).getArray) === 'function', 47); // Expected `controls` to be an array or an `import("./Collection.js").Collection`
  33879. controls = /** @type {Collection} */ (options.controls);
  33880. }
  33881. }
  33882. var interactions;
  33883. if (options.interactions !== undefined) {
  33884. if (Array.isArray(options.interactions)) {
  33885. interactions = new ol_Collection(options.interactions.slice());
  33886. }
  33887. else {
  33888. asserts_assert(typeof ( /** @type {?} */(options.interactions).getArray) ===
  33889. 'function', 48); // Expected `interactions` to be an array or an `import("./Collection.js").Collection`
  33890. interactions = /** @type {Collection} */ (options.interactions);
  33891. }
  33892. }
  33893. var overlays;
  33894. if (options.overlays !== undefined) {
  33895. if (Array.isArray(options.overlays)) {
  33896. overlays = new ol_Collection(options.overlays.slice());
  33897. }
  33898. else {
  33899. asserts_assert(typeof ( /** @type {?} */(options.overlays).getArray) === 'function', 49); // Expected `overlays` to be an array or an `import("./Collection.js").Collection`
  33900. overlays = options.overlays;
  33901. }
  33902. }
  33903. else {
  33904. overlays = new ol_Collection();
  33905. }
  33906. return {
  33907. controls: controls,
  33908. interactions: interactions,
  33909. keyboardEventTarget: keyboardEventTarget,
  33910. overlays: overlays,
  33911. values: values,
  33912. };
  33913. }
  33914. /* harmony default export */ var ol_PluggableMap = (PluggableMap);
  33915. //# sourceMappingURL=PluggableMap.js.map
  33916. ;// ./node_modules/ol/control/Rotate.js
  33917. var Rotate_extends = (undefined && undefined.__extends) || (function () {
  33918. var extendStatics = function (d, b) {
  33919. extendStatics = Object.setPrototypeOf ||
  33920. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33921. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  33922. return extendStatics(d, b);
  33923. };
  33924. return function (d, b) {
  33925. if (typeof b !== "function" && b !== null)
  33926. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  33927. extendStatics(d, b);
  33928. function __() { this.constructor = d; }
  33929. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33930. };
  33931. })();
  33932. /**
  33933. * @module ol/control/Rotate
  33934. */
  33935. /**
  33936. * @typedef {Object} Options
  33937. * @property {string} [className='ol-rotate'] CSS class name.
  33938. * @property {string|HTMLElement} [label='⇧'] Text label to use for the rotate button.
  33939. * Instead of text, also an element (e.g. a `span` element) can be used.
  33940. * @property {string} [tipLabel='Reset rotation'] Text label to use for the rotate tip.
  33941. * @property {string} [compassClassName='ol-compass'] CSS class name for the compass.
  33942. * @property {number} [duration=250] Animation duration in milliseconds.
  33943. * @property {boolean} [autoHide=true] Hide the control when rotation is 0.
  33944. * @property {function(import("../MapEvent.js").default):void} [render] Function called when the control should
  33945. * be re-rendered. This is called in a `requestAnimationFrame` callback.
  33946. * @property {function():void} [resetNorth] Function called when the control is clicked.
  33947. * This will override the default `resetNorth`.
  33948. * @property {HTMLElement|string} [target] Specify a target if you want the control to be
  33949. * rendered outside of the map's viewport.
  33950. */
  33951. /**
  33952. * @classdesc
  33953. * A button control to reset rotation to 0.
  33954. * To style this control use css selector `.ol-rotate`. A `.ol-hidden` css
  33955. * selector is added to the button when the rotation is 0.
  33956. *
  33957. * @api
  33958. */
  33959. var Rotate = /** @class */ (function (_super) {
  33960. Rotate_extends(Rotate, _super);
  33961. /**
  33962. * @param {Options} [opt_options] Rotate options.
  33963. */
  33964. function Rotate(opt_options) {
  33965. var _this = this;
  33966. var options = opt_options ? opt_options : {};
  33967. _this = _super.call(this, {
  33968. element: document.createElement('div'),
  33969. render: options.render,
  33970. target: options.target,
  33971. }) || this;
  33972. var className = options.className !== undefined ? options.className : 'ol-rotate';
  33973. var label = options.label !== undefined ? options.label : '\u21E7';
  33974. var compassClassName = options.compassClassName !== undefined
  33975. ? options.compassClassName
  33976. : 'ol-compass';
  33977. /**
  33978. * @type {HTMLElement}
  33979. * @private
  33980. */
  33981. _this.label_ = null;
  33982. if (typeof label === 'string') {
  33983. _this.label_ = document.createElement('span');
  33984. _this.label_.className = compassClassName;
  33985. _this.label_.textContent = label;
  33986. }
  33987. else {
  33988. _this.label_ = label;
  33989. _this.label_.classList.add(compassClassName);
  33990. }
  33991. var tipLabel = options.tipLabel ? options.tipLabel : 'Reset rotation';
  33992. var button = document.createElement('button');
  33993. button.className = className + '-reset';
  33994. button.setAttribute('type', 'button');
  33995. button.title = tipLabel;
  33996. button.appendChild(_this.label_);
  33997. button.addEventListener(EventType.CLICK, _this.handleClick_.bind(_this), false);
  33998. var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
  33999. var element = _this.element;
  34000. element.className = cssClasses;
  34001. element.appendChild(button);
  34002. _this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
  34003. /**
  34004. * @type {number}
  34005. * @private
  34006. */
  34007. _this.duration_ = options.duration !== undefined ? options.duration : 250;
  34008. /**
  34009. * @type {boolean}
  34010. * @private
  34011. */
  34012. _this.autoHide_ = options.autoHide !== undefined ? options.autoHide : true;
  34013. /**
  34014. * @private
  34015. * @type {number|undefined}
  34016. */
  34017. _this.rotation_ = undefined;
  34018. if (_this.autoHide_) {
  34019. _this.element.classList.add(CLASS_HIDDEN);
  34020. }
  34021. return _this;
  34022. }
  34023. /**
  34024. * @param {MouseEvent} event The event to handle
  34025. * @private
  34026. */
  34027. Rotate.prototype.handleClick_ = function (event) {
  34028. event.preventDefault();
  34029. if (this.callResetNorth_ !== undefined) {
  34030. this.callResetNorth_();
  34031. }
  34032. else {
  34033. this.resetNorth_();
  34034. }
  34035. };
  34036. /**
  34037. * @private
  34038. */
  34039. Rotate.prototype.resetNorth_ = function () {
  34040. var map = this.getMap();
  34041. var view = map.getView();
  34042. if (!view) {
  34043. // the map does not have a view, so we can't act
  34044. // upon it
  34045. return;
  34046. }
  34047. var rotation = view.getRotation();
  34048. if (rotation !== undefined) {
  34049. if (this.duration_ > 0 && rotation % (2 * Math.PI) !== 0) {
  34050. view.animate({
  34051. rotation: 0,
  34052. duration: this.duration_,
  34053. easing: easeOut,
  34054. });
  34055. }
  34056. else {
  34057. view.setRotation(0);
  34058. }
  34059. }
  34060. };
  34061. /**
  34062. * Update the rotate control element.
  34063. * @param {import("../MapEvent.js").default} mapEvent Map event.
  34064. * @override
  34065. */
  34066. Rotate.prototype.render = function (mapEvent) {
  34067. var frameState = mapEvent.frameState;
  34068. if (!frameState) {
  34069. return;
  34070. }
  34071. var rotation = frameState.viewState.rotation;
  34072. if (rotation != this.rotation_) {
  34073. var transform = 'rotate(' + rotation + 'rad)';
  34074. if (this.autoHide_) {
  34075. var contains = this.element.classList.contains(CLASS_HIDDEN);
  34076. if (!contains && rotation === 0) {
  34077. this.element.classList.add(CLASS_HIDDEN);
  34078. }
  34079. else if (contains && rotation !== 0) {
  34080. this.element.classList.remove(CLASS_HIDDEN);
  34081. }
  34082. }
  34083. this.label_.style.transform = transform;
  34084. }
  34085. this.rotation_ = rotation;
  34086. };
  34087. return Rotate;
  34088. }(control_Control));
  34089. /* harmony default export */ var control_Rotate = (Rotate);
  34090. //# sourceMappingURL=Rotate.js.map
  34091. ;// ./node_modules/ol/control.js
  34092. /**
  34093. * @module ol/control
  34094. */
  34095. /**
  34096. * @typedef {Object} DefaultsOptions
  34097. * @property {boolean} [attribution=true] Include
  34098. * {@link module:ol/control/Attribution~Attribution}.
  34099. * @property {import("./control/Attribution.js").Options} [attributionOptions]
  34100. * Options for {@link module:ol/control/Attribution~Attribution}.
  34101. * @property {boolean} [rotate=true] Include
  34102. * {@link module:ol/control/Rotate~Rotate}.
  34103. * @property {import("./control/Rotate.js").Options} [rotateOptions] Options
  34104. * for {@link module:ol/control/Rotate~Rotate}.
  34105. * @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}.
  34106. * @property {import("./control/Zoom.js").Options} [zoomOptions] Options for
  34107. * {@link module:ol/control/Zoom~Zoom}.
  34108. * @api
  34109. */
  34110. /**
  34111. * Set of controls included in maps by default. Unless configured otherwise,
  34112. * this returns a collection containing an instance of each of the following
  34113. * controls:
  34114. * * {@link module:ol/control/Zoom~Zoom}
  34115. * * {@link module:ol/control/Rotate~Rotate}
  34116. * * {@link module:ol/control/Attribution~Attribution}
  34117. *
  34118. * @param {DefaultsOptions} [opt_options]
  34119. * Defaults options.
  34120. * @return {Collection<import("./control/Control.js").default>}
  34121. * Controls.
  34122. * @api
  34123. */
  34124. function defaults(opt_options) {
  34125. var options = opt_options ? opt_options : {};
  34126. var controls = new ol_Collection();
  34127. var zoomControl = options.zoom !== undefined ? options.zoom : true;
  34128. if (zoomControl) {
  34129. controls.push(new control_Zoom(options.zoomOptions));
  34130. }
  34131. var rotateControl = options.rotate !== undefined ? options.rotate : true;
  34132. if (rotateControl) {
  34133. controls.push(new control_Rotate(options.rotateOptions));
  34134. }
  34135. var attributionControl = options.attribution !== undefined ? options.attribution : true;
  34136. if (attributionControl) {
  34137. controls.push(new control_Attribution(options.attributionOptions));
  34138. }
  34139. return controls;
  34140. }
  34141. //# sourceMappingURL=control.js.map
  34142. ;// ./node_modules/ol/interaction/Property.js
  34143. /**
  34144. * @module ol/interaction/Property
  34145. */
  34146. /**
  34147. * @enum {string}
  34148. */
  34149. /* harmony default export */ var interaction_Property = ({
  34150. ACTIVE: 'active',
  34151. });
  34152. //# sourceMappingURL=Property.js.map
  34153. ;// ./node_modules/ol/interaction/Interaction.js
  34154. var Interaction_extends = (undefined && undefined.__extends) || (function () {
  34155. var extendStatics = function (d, b) {
  34156. extendStatics = Object.setPrototypeOf ||
  34157. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34158. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  34159. return extendStatics(d, b);
  34160. };
  34161. return function (d, b) {
  34162. if (typeof b !== "function" && b !== null)
  34163. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  34164. extendStatics(d, b);
  34165. function __() { this.constructor = d; }
  34166. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34167. };
  34168. })();
  34169. /**
  34170. * @module ol/interaction/Interaction
  34171. */
  34172. /***
  34173. * @template Return
  34174. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  34175. * import("../Observable").OnSignature<import("../ObjectEventType").Types|
  34176. * 'change:active', import("../Object").ObjectEvent, Return> &
  34177. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
  34178. * 'change:active', Return>} InteractionOnSignature
  34179. */
  34180. /**
  34181. * Object literal with config options for interactions.
  34182. * @typedef {Object} InteractionOptions
  34183. * @property {function(import("../MapBrowserEvent.js").default):boolean} handleEvent
  34184. * Method called by the map to notify the interaction that a browser event was
  34185. * dispatched to the map. If the function returns a falsy value, propagation of
  34186. * the event to other interactions in the map's interactions chain will be
  34187. * prevented (this includes functions with no explicit return). The interactions
  34188. * are traversed in reverse order of the interactions collection of the map.
  34189. */
  34190. /**
  34191. * @classdesc
  34192. * Abstract base class; normally only used for creating subclasses and not
  34193. * instantiated in apps.
  34194. * User actions that change the state of the map. Some are similar to controls,
  34195. * but are not associated with a DOM element.
  34196. * For example, {@link module:ol/interaction/KeyboardZoom~KeyboardZoom} is
  34197. * functionally the same as {@link module:ol/control/Zoom~Zoom}, but triggered
  34198. * by a keyboard event not a button element event.
  34199. * Although interactions do not have a DOM element, some of them do render
  34200. * vectors and so are visible on the screen.
  34201. * @api
  34202. */
  34203. var Interaction = /** @class */ (function (_super) {
  34204. Interaction_extends(Interaction, _super);
  34205. /**
  34206. * @param {InteractionOptions} [opt_options] Options.
  34207. */
  34208. function Interaction(opt_options) {
  34209. var _this = _super.call(this) || this;
  34210. /***
  34211. * @type {InteractionOnSignature<import("../events").EventsKey>}
  34212. */
  34213. _this.on;
  34214. /***
  34215. * @type {InteractionOnSignature<import("../events").EventsKey>}
  34216. */
  34217. _this.once;
  34218. /***
  34219. * @type {InteractionOnSignature<void>}
  34220. */
  34221. _this.un;
  34222. if (opt_options && opt_options.handleEvent) {
  34223. _this.handleEvent = opt_options.handleEvent;
  34224. }
  34225. /**
  34226. * @private
  34227. * @type {import("../PluggableMap.js").default|null}
  34228. */
  34229. _this.map_ = null;
  34230. _this.setActive(true);
  34231. return _this;
  34232. }
  34233. /**
  34234. * Return whether the interaction is currently active.
  34235. * @return {boolean} `true` if the interaction is active, `false` otherwise.
  34236. * @observable
  34237. * @api
  34238. */
  34239. Interaction.prototype.getActive = function () {
  34240. return /** @type {boolean} */ (this.get(interaction_Property.ACTIVE));
  34241. };
  34242. /**
  34243. * Get the map associated with this interaction.
  34244. * @return {import("../PluggableMap.js").default|null} Map.
  34245. * @api
  34246. */
  34247. Interaction.prototype.getMap = function () {
  34248. return this.map_;
  34249. };
  34250. /**
  34251. * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event}.
  34252. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34253. * @return {boolean} `false` to stop event propagation.
  34254. * @api
  34255. */
  34256. Interaction.prototype.handleEvent = function (mapBrowserEvent) {
  34257. return true;
  34258. };
  34259. /**
  34260. * Activate or deactivate the interaction.
  34261. * @param {boolean} active Active.
  34262. * @observable
  34263. * @api
  34264. */
  34265. Interaction.prototype.setActive = function (active) {
  34266. this.set(interaction_Property.ACTIVE, active);
  34267. };
  34268. /**
  34269. * Remove the interaction from its current map and attach it to the new map.
  34270. * Subclasses may set up event handlers to get notified about changes to
  34271. * the map here.
  34272. * @param {import("../PluggableMap.js").default|null} map Map.
  34273. */
  34274. Interaction.prototype.setMap = function (map) {
  34275. this.map_ = map;
  34276. };
  34277. return Interaction;
  34278. }(ol_Object));
  34279. /**
  34280. * @param {import("../View.js").default} view View.
  34281. * @param {import("../coordinate.js").Coordinate} delta Delta.
  34282. * @param {number} [opt_duration] Duration.
  34283. */
  34284. function pan(view, delta, opt_duration) {
  34285. var currentCenter = view.getCenterInternal();
  34286. if (currentCenter) {
  34287. var center = [currentCenter[0] + delta[0], currentCenter[1] + delta[1]];
  34288. view.animateInternal({
  34289. duration: opt_duration !== undefined ? opt_duration : 250,
  34290. easing: linear,
  34291. center: view.getConstrainedCenter(center),
  34292. });
  34293. }
  34294. }
  34295. /**
  34296. * @param {import("../View.js").default} view View.
  34297. * @param {number} delta Delta from previous zoom level.
  34298. * @param {import("../coordinate.js").Coordinate} [opt_anchor] Anchor coordinate in the user projection.
  34299. * @param {number} [opt_duration] Duration.
  34300. */
  34301. function zoomByDelta(view, delta, opt_anchor, opt_duration) {
  34302. var currentZoom = view.getZoom();
  34303. if (currentZoom === undefined) {
  34304. return;
  34305. }
  34306. var newZoom = view.getConstrainedZoom(currentZoom + delta);
  34307. var newResolution = view.getResolutionForZoom(newZoom);
  34308. if (view.getAnimating()) {
  34309. view.cancelAnimations();
  34310. }
  34311. view.animate({
  34312. resolution: newResolution,
  34313. anchor: opt_anchor,
  34314. duration: opt_duration !== undefined ? opt_duration : 250,
  34315. easing: easeOut,
  34316. });
  34317. }
  34318. /* harmony default export */ var interaction_Interaction = (Interaction);
  34319. //# sourceMappingURL=Interaction.js.map
  34320. ;// ./node_modules/ol/interaction/DoubleClickZoom.js
  34321. var DoubleClickZoom_extends = (undefined && undefined.__extends) || (function () {
  34322. var extendStatics = function (d, b) {
  34323. extendStatics = Object.setPrototypeOf ||
  34324. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34325. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  34326. return extendStatics(d, b);
  34327. };
  34328. return function (d, b) {
  34329. if (typeof b !== "function" && b !== null)
  34330. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  34331. extendStatics(d, b);
  34332. function __() { this.constructor = d; }
  34333. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34334. };
  34335. })();
  34336. /**
  34337. * @module ol/interaction/DoubleClickZoom
  34338. */
  34339. /**
  34340. * @typedef {Object} Options
  34341. * @property {number} [duration=250] Animation duration in milliseconds.
  34342. * @property {number} [delta=1] The zoom delta applied on each double click.
  34343. */
  34344. /**
  34345. * @classdesc
  34346. * Allows the user to zoom by double-clicking on the map.
  34347. * @api
  34348. */
  34349. var DoubleClickZoom = /** @class */ (function (_super) {
  34350. DoubleClickZoom_extends(DoubleClickZoom, _super);
  34351. /**
  34352. * @param {Options} [opt_options] Options.
  34353. */
  34354. function DoubleClickZoom(opt_options) {
  34355. var _this = _super.call(this) || this;
  34356. var options = opt_options ? opt_options : {};
  34357. /**
  34358. * @private
  34359. * @type {number}
  34360. */
  34361. _this.delta_ = options.delta ? options.delta : 1;
  34362. /**
  34363. * @private
  34364. * @type {number}
  34365. */
  34366. _this.duration_ = options.duration !== undefined ? options.duration : 250;
  34367. return _this;
  34368. }
  34369. /**
  34370. * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} (if it was a
  34371. * doubleclick) and eventually zooms the map.
  34372. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34373. * @return {boolean} `false` to stop event propagation.
  34374. */
  34375. DoubleClickZoom.prototype.handleEvent = function (mapBrowserEvent) {
  34376. var stopEvent = false;
  34377. if (mapBrowserEvent.type == ol_MapBrowserEventType.DBLCLICK) {
  34378. var browserEvent = /** @type {MouseEvent} */ (mapBrowserEvent.originalEvent);
  34379. var map = mapBrowserEvent.map;
  34380. var anchor = mapBrowserEvent.coordinate;
  34381. var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
  34382. var view = map.getView();
  34383. zoomByDelta(view, delta, anchor, this.duration_);
  34384. browserEvent.preventDefault();
  34385. stopEvent = true;
  34386. }
  34387. return !stopEvent;
  34388. };
  34389. return DoubleClickZoom;
  34390. }(interaction_Interaction));
  34391. /* harmony default export */ var interaction_DoubleClickZoom = (DoubleClickZoom);
  34392. //# sourceMappingURL=DoubleClickZoom.js.map
  34393. ;// ./node_modules/ol/interaction/Pointer.js
  34394. var Pointer_extends = (undefined && undefined.__extends) || (function () {
  34395. var extendStatics = function (d, b) {
  34396. extendStatics = Object.setPrototypeOf ||
  34397. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34398. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  34399. return extendStatics(d, b);
  34400. };
  34401. return function (d, b) {
  34402. if (typeof b !== "function" && b !== null)
  34403. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  34404. extendStatics(d, b);
  34405. function __() { this.constructor = d; }
  34406. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34407. };
  34408. })();
  34409. /**
  34410. * @module ol/interaction/Pointer
  34411. */
  34412. /**
  34413. * @typedef {Object} Options
  34414. * @property {function(import("../MapBrowserEvent.js").default):boolean} [handleDownEvent]
  34415. * Function handling "down" events. If the function returns `true` then a drag
  34416. * sequence is started.
  34417. * @property {function(import("../MapBrowserEvent.js").default):void} [handleDragEvent]
  34418. * Function handling "drag" events. This function is called on "move" events
  34419. * during a drag sequence.
  34420. * @property {function(import("../MapBrowserEvent.js").default):boolean} [handleEvent]
  34421. * Method called by the map to notify the interaction that a browser event was
  34422. * dispatched to the map. The function may return `false` to prevent the
  34423. * propagation of the event to other interactions in the map's interactions
  34424. * chain.
  34425. * @property {function(import("../MapBrowserEvent.js").default):void} [handleMoveEvent]
  34426. * Function handling "move" events. This function is called on "move" events.
  34427. * This functions is also called during a drag sequence, so during a drag
  34428. * sequence both the `handleDragEvent` function and this function are called.
  34429. * If `handleDownEvent` is defined and it returns true this function will not
  34430. * be called during a drag sequence.
  34431. * @property {function(import("../MapBrowserEvent.js").default):boolean} [handleUpEvent]
  34432. * Function handling "up" events. If the function returns `false` then the
  34433. * current drag sequence is stopped.
  34434. * @property {function(boolean):boolean} [stopDown]
  34435. * Should the down event be propagated to other interactions, or should be
  34436. * stopped?
  34437. */
  34438. /**
  34439. * @classdesc
  34440. * Base class that calls user-defined functions on `down`, `move` and `up`
  34441. * events. This class also manages "drag sequences".
  34442. *
  34443. * When the `handleDownEvent` user function returns `true` a drag sequence is
  34444. * started. During a drag sequence the `handleDragEvent` user function is
  34445. * called on `move` events. The drag sequence ends when the `handleUpEvent`
  34446. * user function is called and returns `false`.
  34447. * @api
  34448. */
  34449. var PointerInteraction = /** @class */ (function (_super) {
  34450. Pointer_extends(PointerInteraction, _super);
  34451. /**
  34452. * @param {Options} [opt_options] Options.
  34453. */
  34454. function PointerInteraction(opt_options) {
  34455. var _this = this;
  34456. var options = opt_options ? opt_options : {};
  34457. _this = _super.call(this,
  34458. /** @type {import("./Interaction.js").InteractionOptions} */ (options)) || this;
  34459. if (options.handleDownEvent) {
  34460. _this.handleDownEvent = options.handleDownEvent;
  34461. }
  34462. if (options.handleDragEvent) {
  34463. _this.handleDragEvent = options.handleDragEvent;
  34464. }
  34465. if (options.handleMoveEvent) {
  34466. _this.handleMoveEvent = options.handleMoveEvent;
  34467. }
  34468. if (options.handleUpEvent) {
  34469. _this.handleUpEvent = options.handleUpEvent;
  34470. }
  34471. if (options.stopDown) {
  34472. _this.stopDown = options.stopDown;
  34473. }
  34474. /**
  34475. * @type {boolean}
  34476. * @protected
  34477. */
  34478. _this.handlingDownUpSequence = false;
  34479. /**
  34480. * @type {Array<PointerEvent>}
  34481. * @protected
  34482. */
  34483. _this.targetPointers = [];
  34484. return _this;
  34485. }
  34486. /**
  34487. * Returns the current number of pointers involved in the interaction,
  34488. * e.g. `2` when two fingers are used.
  34489. * @return {number} The number of pointers.
  34490. * @api
  34491. */
  34492. PointerInteraction.prototype.getPointerCount = function () {
  34493. return this.targetPointers.length;
  34494. };
  34495. /**
  34496. * Handle pointer down events.
  34497. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34498. * @return {boolean} If the event was consumed.
  34499. * @protected
  34500. */
  34501. PointerInteraction.prototype.handleDownEvent = function (mapBrowserEvent) {
  34502. return false;
  34503. };
  34504. /**
  34505. * Handle pointer drag events.
  34506. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34507. * @protected
  34508. */
  34509. PointerInteraction.prototype.handleDragEvent = function (mapBrowserEvent) { };
  34510. /**
  34511. * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may call into
  34512. * other functions, if event sequences like e.g. 'drag' or 'down-up' etc. are
  34513. * detected.
  34514. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34515. * @return {boolean} `false` to stop event propagation.
  34516. * @api
  34517. */
  34518. PointerInteraction.prototype.handleEvent = function (mapBrowserEvent) {
  34519. if (!mapBrowserEvent.originalEvent) {
  34520. return true;
  34521. }
  34522. var stopEvent = false;
  34523. this.updateTrackedPointers_(mapBrowserEvent);
  34524. if (this.handlingDownUpSequence) {
  34525. if (mapBrowserEvent.type == ol_MapBrowserEventType.POINTERDRAG) {
  34526. this.handleDragEvent(mapBrowserEvent);
  34527. // prevent page scrolling during dragging
  34528. mapBrowserEvent.originalEvent.preventDefault();
  34529. }
  34530. else if (mapBrowserEvent.type == ol_MapBrowserEventType.POINTERUP) {
  34531. var handledUp = this.handleUpEvent(mapBrowserEvent);
  34532. this.handlingDownUpSequence =
  34533. handledUp && this.targetPointers.length > 0;
  34534. }
  34535. }
  34536. else {
  34537. if (mapBrowserEvent.type == ol_MapBrowserEventType.POINTERDOWN) {
  34538. var handled = this.handleDownEvent(mapBrowserEvent);
  34539. this.handlingDownUpSequence = handled;
  34540. stopEvent = this.stopDown(handled);
  34541. }
  34542. else if (mapBrowserEvent.type == ol_MapBrowserEventType.POINTERMOVE) {
  34543. this.handleMoveEvent(mapBrowserEvent);
  34544. }
  34545. }
  34546. return !stopEvent;
  34547. };
  34548. /**
  34549. * Handle pointer move events.
  34550. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34551. * @protected
  34552. */
  34553. PointerInteraction.prototype.handleMoveEvent = function (mapBrowserEvent) { };
  34554. /**
  34555. * Handle pointer up events.
  34556. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34557. * @return {boolean} If the event was consumed.
  34558. * @protected
  34559. */
  34560. PointerInteraction.prototype.handleUpEvent = function (mapBrowserEvent) {
  34561. return false;
  34562. };
  34563. /**
  34564. * This function is used to determine if "down" events should be propagated
  34565. * to other interactions or should be stopped.
  34566. * @param {boolean} handled Was the event handled by the interaction?
  34567. * @return {boolean} Should the `down` event be stopped?
  34568. */
  34569. PointerInteraction.prototype.stopDown = function (handled) {
  34570. return handled;
  34571. };
  34572. /**
  34573. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34574. * @private
  34575. */
  34576. PointerInteraction.prototype.updateTrackedPointers_ = function (mapBrowserEvent) {
  34577. if (mapBrowserEvent.activePointers) {
  34578. this.targetPointers = mapBrowserEvent.activePointers;
  34579. }
  34580. };
  34581. return PointerInteraction;
  34582. }(interaction_Interaction));
  34583. /**
  34584. * @param {Array<PointerEvent>} pointerEvents List of events.
  34585. * @return {import("../pixel.js").Pixel} Centroid pixel.
  34586. */
  34587. function Pointer_centroid(pointerEvents) {
  34588. var length = pointerEvents.length;
  34589. var clientX = 0;
  34590. var clientY = 0;
  34591. for (var i = 0; i < length; i++) {
  34592. clientX += pointerEvents[i].clientX;
  34593. clientY += pointerEvents[i].clientY;
  34594. }
  34595. return [clientX / length, clientY / length];
  34596. }
  34597. /* harmony default export */ var Pointer = (PointerInteraction);
  34598. //# sourceMappingURL=Pointer.js.map
  34599. ;// ./node_modules/ol/events/condition.js
  34600. /**
  34601. * @module ol/events/condition
  34602. */
  34603. /**
  34604. * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
  34605. * `{boolean}`. If the condition is met, true should be returned.
  34606. *
  34607. * @typedef {function(this: ?, import("../MapBrowserEvent.js").default): boolean} Condition
  34608. */
  34609. /**
  34610. * Creates a condition function that passes when all provided conditions pass.
  34611. * @param {...Condition} var_args Conditions to check.
  34612. * @return {Condition} Condition function.
  34613. */
  34614. function condition_all(var_args) {
  34615. var conditions = arguments;
  34616. /**
  34617. * @param {import("../MapBrowserEvent.js").default} event Event.
  34618. * @return {boolean} All conditions passed.
  34619. */
  34620. return function (event) {
  34621. var pass = true;
  34622. for (var i = 0, ii = conditions.length; i < ii; ++i) {
  34623. pass = pass && conditions[i](event);
  34624. if (!pass) {
  34625. break;
  34626. }
  34627. }
  34628. return pass;
  34629. };
  34630. }
  34631. /**
  34632. * Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when
  34633. * additionally the shift-key is pressed).
  34634. *
  34635. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34636. * @return {boolean} True if only the alt key is pressed.
  34637. * @api
  34638. */
  34639. var altKeyOnly = function (mapBrowserEvent) {
  34640. var originalEvent = /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ (mapBrowserEvent.originalEvent);
  34641. return (originalEvent.altKey &&
  34642. !(originalEvent.metaKey || originalEvent.ctrlKey) &&
  34643. !originalEvent.shiftKey);
  34644. };
  34645. /**
  34646. * Return `true` if only the alt-key and shift-key is pressed, `false` otherwise
  34647. * (e.g. when additionally the platform-modifier-key is pressed).
  34648. *
  34649. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34650. * @return {boolean} True if only the alt and shift keys are pressed.
  34651. * @api
  34652. */
  34653. var altShiftKeysOnly = function (mapBrowserEvent) {
  34654. var originalEvent = /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ (mapBrowserEvent.originalEvent);
  34655. return (originalEvent.altKey &&
  34656. !(originalEvent.metaKey || originalEvent.ctrlKey) &&
  34657. originalEvent.shiftKey);
  34658. };
  34659. /**
  34660. * Return `true` if the map has the focus. This condition requires a map target
  34661. * element with a `tabindex` attribute, e.g. `<div id="map" tabindex="1">`.
  34662. *
  34663. * @param {import("../MapBrowserEvent.js").default} event Map browser event.
  34664. * @return {boolean} The map has the focus.
  34665. * @api
  34666. */
  34667. var condition_focus = function (event) {
  34668. var targetElement = event.map.getTargetElement();
  34669. var activeElement = event.map.getOwnerDocument().activeElement;
  34670. return targetElement.contains(activeElement);
  34671. };
  34672. /**
  34673. * Return `true` if the map has the focus or no 'tabindex' attribute set.
  34674. *
  34675. * @param {import("../MapBrowserEvent.js").default} event Map browser event.
  34676. * @return {boolean} The map container has the focus or no 'tabindex' attribute.
  34677. */
  34678. var focusWithTabindex = function (event) {
  34679. return event.map.getTargetElement().hasAttribute('tabindex')
  34680. ? condition_focus(event)
  34681. : true;
  34682. };
  34683. /**
  34684. * Return always true.
  34685. *
  34686. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34687. * @return {boolean} True.
  34688. * @api
  34689. */
  34690. var always = TRUE;
  34691. /**
  34692. * Return `true` if the event is a `click` event, `false` otherwise.
  34693. *
  34694. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34695. * @return {boolean} True if the event is a map `click` event.
  34696. * @api
  34697. */
  34698. var click = function (mapBrowserEvent) {
  34699. return mapBrowserEvent.type == MapBrowserEventType.CLICK;
  34700. };
  34701. /**
  34702. * Return `true` if the event has an "action"-producing mouse button.
  34703. *
  34704. * By definition, this includes left-click on windows/linux, and left-click
  34705. * without the ctrl key on Macs.
  34706. *
  34707. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34708. * @return {boolean} The result.
  34709. */
  34710. var mouseActionButton = function (mapBrowserEvent) {
  34711. var originalEvent = /** @type {MouseEvent} */ (mapBrowserEvent.originalEvent);
  34712. return originalEvent.button == 0 && !(WEBKIT && has_MAC && originalEvent.ctrlKey);
  34713. };
  34714. /**
  34715. * Return always false.
  34716. *
  34717. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34718. * @return {boolean} False.
  34719. * @api
  34720. */
  34721. var never = (/* unused pure expression or super */ null && (FALSE));
  34722. /**
  34723. * Return `true` if the browser event is a `pointermove` event, `false`
  34724. * otherwise.
  34725. *
  34726. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34727. * @return {boolean} True if the browser event is a `pointermove` event.
  34728. * @api
  34729. */
  34730. var pointerMove = function (mapBrowserEvent) {
  34731. return mapBrowserEvent.type == 'pointermove';
  34732. };
  34733. /**
  34734. * Return `true` if the event is a map `singleclick` event, `false` otherwise.
  34735. *
  34736. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34737. * @return {boolean} True if the event is a map `singleclick` event.
  34738. * @api
  34739. */
  34740. var singleClick = function (mapBrowserEvent) {
  34741. return mapBrowserEvent.type == MapBrowserEventType.SINGLECLICK;
  34742. };
  34743. /**
  34744. * Return `true` if the event is a map `dblclick` event, `false` otherwise.
  34745. *
  34746. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34747. * @return {boolean} True if the event is a map `dblclick` event.
  34748. * @api
  34749. */
  34750. var doubleClick = function (mapBrowserEvent) {
  34751. return mapBrowserEvent.type == MapBrowserEventType.DBLCLICK;
  34752. };
  34753. /**
  34754. * Return `true` if no modifier key (alt-, shift- or platform-modifier-key) is
  34755. * pressed.
  34756. *
  34757. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34758. * @return {boolean} True only if there no modifier keys are pressed.
  34759. * @api
  34760. */
  34761. var noModifierKeys = function (mapBrowserEvent) {
  34762. var originalEvent = /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ (mapBrowserEvent.originalEvent);
  34763. return (!originalEvent.altKey &&
  34764. !(originalEvent.metaKey || originalEvent.ctrlKey) &&
  34765. !originalEvent.shiftKey);
  34766. };
  34767. /**
  34768. * Return `true` if only the platform-modifier-key (the meta-key on Mac,
  34769. * ctrl-key otherwise) is pressed, `false` otherwise (e.g. when additionally
  34770. * the shift-key is pressed).
  34771. *
  34772. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34773. * @return {boolean} True if only the platform modifier key is pressed.
  34774. * @api
  34775. */
  34776. var platformModifierKeyOnly = function (mapBrowserEvent) {
  34777. var originalEvent = /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ (mapBrowserEvent.originalEvent);
  34778. return (!originalEvent.altKey &&
  34779. (MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
  34780. !originalEvent.shiftKey);
  34781. };
  34782. /**
  34783. * Return `true` if only the shift-key is pressed, `false` otherwise (e.g. when
  34784. * additionally the alt-key is pressed).
  34785. *
  34786. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34787. * @return {boolean} True if only the shift key is pressed.
  34788. * @api
  34789. */
  34790. var shiftKeyOnly = function (mapBrowserEvent) {
  34791. var originalEvent = /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ (mapBrowserEvent.originalEvent);
  34792. return (!originalEvent.altKey &&
  34793. !(originalEvent.metaKey || originalEvent.ctrlKey) &&
  34794. originalEvent.shiftKey);
  34795. };
  34796. /**
  34797. * Return `true` if the target element is not editable, i.e. not an `input`,
  34798. * `select`, or `textarea` element and no `contenteditable` attribute is
  34799. * set or inherited, `false` otherwise.
  34800. *
  34801. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34802. * @return {boolean} True only if the target element is not editable.
  34803. * @api
  34804. */
  34805. var targetNotEditable = function (mapBrowserEvent) {
  34806. var originalEvent = /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ (mapBrowserEvent.originalEvent);
  34807. var tagName = /** @type {Element} */ (originalEvent.target).tagName;
  34808. return (tagName !== 'INPUT' &&
  34809. tagName !== 'SELECT' &&
  34810. tagName !== 'TEXTAREA' &&
  34811. // `isContentEditable` is only available on `HTMLElement`, but it may also be a
  34812. // different type like `SVGElement`.
  34813. // @ts-ignore
  34814. !originalEvent.target.isContentEditable);
  34815. };
  34816. /**
  34817. * Return `true` if the event originates from a mouse device.
  34818. *
  34819. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34820. * @return {boolean} True if the event originates from a mouse device.
  34821. * @api
  34822. */
  34823. var mouseOnly = function (mapBrowserEvent) {
  34824. var pointerEvent = /** @type {import("../MapBrowserEvent").default} */ (mapBrowserEvent).originalEvent;
  34825. asserts_assert(pointerEvent !== undefined, 56); // mapBrowserEvent must originate from a pointer event
  34826. // see https://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
  34827. return pointerEvent.pointerType == 'mouse';
  34828. };
  34829. /**
  34830. * Return `true` if the event originates from a touchable device.
  34831. *
  34832. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34833. * @return {boolean} True if the event originates from a touchable device.
  34834. * @api
  34835. */
  34836. var touchOnly = function (mapBrowserEvent) {
  34837. var pointerEvt = /** @type {import("../MapBrowserEvent").default} */ (mapBrowserEvent).originalEvent;
  34838. assert(pointerEvt !== undefined, 56); // mapBrowserEvent must originate from a pointer event
  34839. // see https://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
  34840. return pointerEvt.pointerType === 'touch';
  34841. };
  34842. /**
  34843. * Return `true` if the event originates from a digital pen.
  34844. *
  34845. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34846. * @return {boolean} True if the event originates from a digital pen.
  34847. * @api
  34848. */
  34849. var penOnly = function (mapBrowserEvent) {
  34850. var pointerEvt = /** @type {import("../MapBrowserEvent").default} */ (mapBrowserEvent).originalEvent;
  34851. assert(pointerEvt !== undefined, 56); // mapBrowserEvent must originate from a pointer event
  34852. // see https://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
  34853. return pointerEvt.pointerType === 'pen';
  34854. };
  34855. /**
  34856. * Return `true` if the event originates from a primary pointer in
  34857. * contact with the surface or if the left mouse button is pressed.
  34858. * See https://www.w3.org/TR/pointerevents/#button-states.
  34859. *
  34860. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  34861. * @return {boolean} True if the event originates from a primary pointer.
  34862. * @api
  34863. */
  34864. var primaryAction = function (mapBrowserEvent) {
  34865. var pointerEvent = /** @type {import("../MapBrowserEvent").default} */ (mapBrowserEvent).originalEvent;
  34866. asserts_assert(pointerEvent !== undefined, 56); // mapBrowserEvent must originate from a pointer event
  34867. return pointerEvent.isPrimary && pointerEvent.button === 0;
  34868. };
  34869. //# sourceMappingURL=condition.js.map
  34870. ;// ./node_modules/ol/interaction/DragPan.js
  34871. var DragPan_extends = (undefined && undefined.__extends) || (function () {
  34872. var extendStatics = function (d, b) {
  34873. extendStatics = Object.setPrototypeOf ||
  34874. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34875. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  34876. return extendStatics(d, b);
  34877. };
  34878. return function (d, b) {
  34879. if (typeof b !== "function" && b !== null)
  34880. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  34881. extendStatics(d, b);
  34882. function __() { this.constructor = d; }
  34883. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34884. };
  34885. })();
  34886. /**
  34887. * @module ol/interaction/DragPan
  34888. */
  34889. /**
  34890. * @typedef {Object} Options
  34891. * @property {import("../events/condition.js").Condition} [condition] A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
  34892. * to indicate whether that event should be handled.
  34893. * Default is {@link module:ol/events/condition.noModifierKeys} and {@link module:ol/events/condition.primaryAction}.
  34894. * @property {boolean} [onFocusOnly=false] When the map's target has a `tabindex` attribute set,
  34895. * the interaction will only handle events when the map has the focus.
  34896. * @property {import("../Kinetic.js").default} [kinetic] Kinetic inertia to apply to the pan.
  34897. */
  34898. /**
  34899. * @classdesc
  34900. * Allows the user to pan the map by dragging the map.
  34901. * @api
  34902. */
  34903. var DragPan = /** @class */ (function (_super) {
  34904. DragPan_extends(DragPan, _super);
  34905. /**
  34906. * @param {Options} [opt_options] Options.
  34907. */
  34908. function DragPan(opt_options) {
  34909. var _this = _super.call(this, {
  34910. stopDown: functions_FALSE,
  34911. }) || this;
  34912. var options = opt_options ? opt_options : {};
  34913. /**
  34914. * @private
  34915. * @type {import("../Kinetic.js").default|undefined}
  34916. */
  34917. _this.kinetic_ = options.kinetic;
  34918. /**
  34919. * @type {import("../pixel.js").Pixel}
  34920. */
  34921. _this.lastCentroid = null;
  34922. /**
  34923. * @type {number}
  34924. */
  34925. _this.lastPointersCount_;
  34926. /**
  34927. * @type {boolean}
  34928. */
  34929. _this.panning_ = false;
  34930. var condition = options.condition
  34931. ? options.condition
  34932. : condition_all(noModifierKeys, primaryAction);
  34933. /**
  34934. * @private
  34935. * @type {import("../events/condition.js").Condition}
  34936. */
  34937. _this.condition_ = options.onFocusOnly
  34938. ? condition_all(focusWithTabindex, condition)
  34939. : condition;
  34940. /**
  34941. * @private
  34942. * @type {boolean}
  34943. */
  34944. _this.noKinetic_ = false;
  34945. return _this;
  34946. }
  34947. /**
  34948. * Handle pointer drag events.
  34949. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34950. */
  34951. DragPan.prototype.handleDragEvent = function (mapBrowserEvent) {
  34952. if (!this.panning_) {
  34953. this.panning_ = true;
  34954. this.getMap().getView().beginInteraction();
  34955. }
  34956. var targetPointers = this.targetPointers;
  34957. var centroid = Pointer_centroid(targetPointers);
  34958. if (targetPointers.length == this.lastPointersCount_) {
  34959. if (this.kinetic_) {
  34960. this.kinetic_.update(centroid[0], centroid[1]);
  34961. }
  34962. if (this.lastCentroid) {
  34963. var delta = [
  34964. this.lastCentroid[0] - centroid[0],
  34965. centroid[1] - this.lastCentroid[1],
  34966. ];
  34967. var map = mapBrowserEvent.map;
  34968. var view = map.getView();
  34969. scale(delta, view.getResolution());
  34970. rotate(delta, view.getRotation());
  34971. view.adjustCenterInternal(delta);
  34972. }
  34973. }
  34974. else if (this.kinetic_) {
  34975. // reset so we don't overestimate the kinetic energy after
  34976. // after one finger down, tiny drag, second finger down
  34977. this.kinetic_.begin();
  34978. }
  34979. this.lastCentroid = centroid;
  34980. this.lastPointersCount_ = targetPointers.length;
  34981. mapBrowserEvent.originalEvent.preventDefault();
  34982. };
  34983. /**
  34984. * Handle pointer up events.
  34985. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  34986. * @return {boolean} If the event was consumed.
  34987. */
  34988. DragPan.prototype.handleUpEvent = function (mapBrowserEvent) {
  34989. var map = mapBrowserEvent.map;
  34990. var view = map.getView();
  34991. if (this.targetPointers.length === 0) {
  34992. if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
  34993. var distance = this.kinetic_.getDistance();
  34994. var angle = this.kinetic_.getAngle();
  34995. var center = view.getCenterInternal();
  34996. var centerpx = map.getPixelFromCoordinateInternal(center);
  34997. var dest = map.getCoordinateFromPixelInternal([
  34998. centerpx[0] - distance * Math.cos(angle),
  34999. centerpx[1] - distance * Math.sin(angle),
  35000. ]);
  35001. view.animateInternal({
  35002. center: view.getConstrainedCenter(dest),
  35003. duration: 500,
  35004. easing: easeOut,
  35005. });
  35006. }
  35007. if (this.panning_) {
  35008. this.panning_ = false;
  35009. view.endInteraction();
  35010. }
  35011. return false;
  35012. }
  35013. else {
  35014. if (this.kinetic_) {
  35015. // reset so we don't overestimate the kinetic energy after
  35016. // after one finger up, tiny drag, second finger up
  35017. this.kinetic_.begin();
  35018. }
  35019. this.lastCentroid = null;
  35020. return true;
  35021. }
  35022. };
  35023. /**
  35024. * Handle pointer down events.
  35025. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35026. * @return {boolean} If the event was consumed.
  35027. */
  35028. DragPan.prototype.handleDownEvent = function (mapBrowserEvent) {
  35029. if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
  35030. var map = mapBrowserEvent.map;
  35031. var view = map.getView();
  35032. this.lastCentroid = null;
  35033. // stop any current animation
  35034. if (view.getAnimating()) {
  35035. view.cancelAnimations();
  35036. }
  35037. if (this.kinetic_) {
  35038. this.kinetic_.begin();
  35039. }
  35040. // No kinetic as soon as more than one pointer on the screen is
  35041. // detected. This is to prevent nasty pans after pinch.
  35042. this.noKinetic_ = this.targetPointers.length > 1;
  35043. return true;
  35044. }
  35045. else {
  35046. return false;
  35047. }
  35048. };
  35049. return DragPan;
  35050. }(Pointer));
  35051. /* harmony default export */ var interaction_DragPan = (DragPan);
  35052. //# sourceMappingURL=DragPan.js.map
  35053. ;// ./node_modules/ol/interaction/DragRotate.js
  35054. var DragRotate_extends = (undefined && undefined.__extends) || (function () {
  35055. var extendStatics = function (d, b) {
  35056. extendStatics = Object.setPrototypeOf ||
  35057. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35058. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35059. return extendStatics(d, b);
  35060. };
  35061. return function (d, b) {
  35062. if (typeof b !== "function" && b !== null)
  35063. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35064. extendStatics(d, b);
  35065. function __() { this.constructor = d; }
  35066. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35067. };
  35068. })();
  35069. /**
  35070. * @module ol/interaction/DragRotate
  35071. */
  35072. /**
  35073. * @typedef {Object} Options
  35074. * @property {import("../events/condition.js").Condition} [condition] A function that takes an
  35075. * {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
  35076. * to indicate whether that event should be handled.
  35077. * Default is {@link module:ol/events/condition.altShiftKeysOnly}.
  35078. * @property {number} [duration=250] Animation duration in milliseconds.
  35079. */
  35080. /**
  35081. * @classdesc
  35082. * Allows the user to rotate the map by clicking and dragging on the map,
  35083. * normally combined with an {@link module:ol/events/condition} that limits
  35084. * it to when the alt and shift keys are held down.
  35085. *
  35086. * This interaction is only supported for mouse devices.
  35087. * @api
  35088. */
  35089. var DragRotate = /** @class */ (function (_super) {
  35090. DragRotate_extends(DragRotate, _super);
  35091. /**
  35092. * @param {Options} [opt_options] Options.
  35093. */
  35094. function DragRotate(opt_options) {
  35095. var _this = this;
  35096. var options = opt_options ? opt_options : {};
  35097. _this = _super.call(this, {
  35098. stopDown: functions_FALSE,
  35099. }) || this;
  35100. /**
  35101. * @private
  35102. * @type {import("../events/condition.js").Condition}
  35103. */
  35104. _this.condition_ = options.condition ? options.condition : altShiftKeysOnly;
  35105. /**
  35106. * @private
  35107. * @type {number|undefined}
  35108. */
  35109. _this.lastAngle_ = undefined;
  35110. /**
  35111. * @private
  35112. * @type {number}
  35113. */
  35114. _this.duration_ = options.duration !== undefined ? options.duration : 250;
  35115. return _this;
  35116. }
  35117. /**
  35118. * Handle pointer drag events.
  35119. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35120. */
  35121. DragRotate.prototype.handleDragEvent = function (mapBrowserEvent) {
  35122. if (!mouseOnly(mapBrowserEvent)) {
  35123. return;
  35124. }
  35125. var map = mapBrowserEvent.map;
  35126. var view = map.getView();
  35127. if (view.getConstraints().rotation === disable) {
  35128. return;
  35129. }
  35130. var size = map.getSize();
  35131. var offset = mapBrowserEvent.pixel;
  35132. var theta = Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2);
  35133. if (this.lastAngle_ !== undefined) {
  35134. var delta = theta - this.lastAngle_;
  35135. view.adjustRotationInternal(-delta);
  35136. }
  35137. this.lastAngle_ = theta;
  35138. };
  35139. /**
  35140. * Handle pointer up events.
  35141. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35142. * @return {boolean} If the event was consumed.
  35143. */
  35144. DragRotate.prototype.handleUpEvent = function (mapBrowserEvent) {
  35145. if (!mouseOnly(mapBrowserEvent)) {
  35146. return true;
  35147. }
  35148. var map = mapBrowserEvent.map;
  35149. var view = map.getView();
  35150. view.endInteraction(this.duration_);
  35151. return false;
  35152. };
  35153. /**
  35154. * Handle pointer down events.
  35155. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35156. * @return {boolean} If the event was consumed.
  35157. */
  35158. DragRotate.prototype.handleDownEvent = function (mapBrowserEvent) {
  35159. if (!mouseOnly(mapBrowserEvent)) {
  35160. return false;
  35161. }
  35162. if (mouseActionButton(mapBrowserEvent) &&
  35163. this.condition_(mapBrowserEvent)) {
  35164. var map = mapBrowserEvent.map;
  35165. map.getView().beginInteraction();
  35166. this.lastAngle_ = undefined;
  35167. return true;
  35168. }
  35169. else {
  35170. return false;
  35171. }
  35172. };
  35173. return DragRotate;
  35174. }(Pointer));
  35175. /* harmony default export */ var interaction_DragRotate = (DragRotate);
  35176. //# sourceMappingURL=DragRotate.js.map
  35177. ;// ./node_modules/ol/render/Box.js
  35178. /**
  35179. * @module ol/render/Box
  35180. */
  35181. var Box_extends = (undefined && undefined.__extends) || (function () {
  35182. var extendStatics = function (d, b) {
  35183. extendStatics = Object.setPrototypeOf ||
  35184. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35185. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35186. return extendStatics(d, b);
  35187. };
  35188. return function (d, b) {
  35189. if (typeof b !== "function" && b !== null)
  35190. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35191. extendStatics(d, b);
  35192. function __() { this.constructor = d; }
  35193. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35194. };
  35195. })();
  35196. var RenderBox = /** @class */ (function (_super) {
  35197. Box_extends(RenderBox, _super);
  35198. /**
  35199. * @param {string} className CSS class name.
  35200. */
  35201. function RenderBox(className) {
  35202. var _this = _super.call(this) || this;
  35203. /**
  35204. * @type {import("../geom/Polygon.js").default}
  35205. * @private
  35206. */
  35207. _this.geometry_ = null;
  35208. /**
  35209. * @type {HTMLDivElement}
  35210. * @private
  35211. */
  35212. _this.element_ = document.createElement('div');
  35213. _this.element_.style.position = 'absolute';
  35214. _this.element_.style.pointerEvents = 'auto';
  35215. _this.element_.className = 'ol-box ' + className;
  35216. /**
  35217. * @private
  35218. * @type {import("../PluggableMap.js").default|null}
  35219. */
  35220. _this.map_ = null;
  35221. /**
  35222. * @private
  35223. * @type {import("../pixel.js").Pixel}
  35224. */
  35225. _this.startPixel_ = null;
  35226. /**
  35227. * @private
  35228. * @type {import("../pixel.js").Pixel}
  35229. */
  35230. _this.endPixel_ = null;
  35231. return _this;
  35232. }
  35233. /**
  35234. * Clean up.
  35235. */
  35236. RenderBox.prototype.disposeInternal = function () {
  35237. this.setMap(null);
  35238. };
  35239. /**
  35240. * @private
  35241. */
  35242. RenderBox.prototype.render_ = function () {
  35243. var startPixel = this.startPixel_;
  35244. var endPixel = this.endPixel_;
  35245. var px = 'px';
  35246. var style = this.element_.style;
  35247. style.left = Math.min(startPixel[0], endPixel[0]) + px;
  35248. style.top = Math.min(startPixel[1], endPixel[1]) + px;
  35249. style.width = Math.abs(endPixel[0] - startPixel[0]) + px;
  35250. style.height = Math.abs(endPixel[1] - startPixel[1]) + px;
  35251. };
  35252. /**
  35253. * @param {import("../PluggableMap.js").default|null} map Map.
  35254. */
  35255. RenderBox.prototype.setMap = function (map) {
  35256. if (this.map_) {
  35257. this.map_.getOverlayContainer().removeChild(this.element_);
  35258. var style = this.element_.style;
  35259. style.left = 'inherit';
  35260. style.top = 'inherit';
  35261. style.width = 'inherit';
  35262. style.height = 'inherit';
  35263. }
  35264. this.map_ = map;
  35265. if (this.map_) {
  35266. this.map_.getOverlayContainer().appendChild(this.element_);
  35267. }
  35268. };
  35269. /**
  35270. * @param {import("../pixel.js").Pixel} startPixel Start pixel.
  35271. * @param {import("../pixel.js").Pixel} endPixel End pixel.
  35272. */
  35273. RenderBox.prototype.setPixels = function (startPixel, endPixel) {
  35274. this.startPixel_ = startPixel;
  35275. this.endPixel_ = endPixel;
  35276. this.createOrUpdateGeometry();
  35277. this.render_();
  35278. };
  35279. /**
  35280. * Creates or updates the cached geometry.
  35281. */
  35282. RenderBox.prototype.createOrUpdateGeometry = function () {
  35283. var startPixel = this.startPixel_;
  35284. var endPixel = this.endPixel_;
  35285. var pixels = [
  35286. startPixel,
  35287. [startPixel[0], endPixel[1]],
  35288. endPixel,
  35289. [endPixel[0], startPixel[1]],
  35290. ];
  35291. var coordinates = pixels.map(this.map_.getCoordinateFromPixelInternal, this.map_);
  35292. // close the polygon
  35293. coordinates[4] = coordinates[0].slice();
  35294. if (!this.geometry_) {
  35295. this.geometry_ = new geom_Polygon([coordinates]);
  35296. }
  35297. else {
  35298. this.geometry_.setCoordinates([coordinates]);
  35299. }
  35300. };
  35301. /**
  35302. * @return {import("../geom/Polygon.js").default} Geometry.
  35303. */
  35304. RenderBox.prototype.getGeometry = function () {
  35305. return this.geometry_;
  35306. };
  35307. return RenderBox;
  35308. }(ol_Disposable));
  35309. /* harmony default export */ var Box = (RenderBox);
  35310. //# sourceMappingURL=Box.js.map
  35311. ;// ./node_modules/ol/interaction/DragBox.js
  35312. var DragBox_extends = (undefined && undefined.__extends) || (function () {
  35313. var extendStatics = function (d, b) {
  35314. extendStatics = Object.setPrototypeOf ||
  35315. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35316. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35317. return extendStatics(d, b);
  35318. };
  35319. return function (d, b) {
  35320. if (typeof b !== "function" && b !== null)
  35321. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35322. extendStatics(d, b);
  35323. function __() { this.constructor = d; }
  35324. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35325. };
  35326. })();
  35327. /**
  35328. * @module ol/interaction/DragBox
  35329. */
  35330. // FIXME draw drag box
  35331. /**
  35332. * A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
  35333. * {@link module:ol/pixel~Pixel}s and returns a `{boolean}`. If the condition is met,
  35334. * true should be returned.
  35335. * @typedef {function(this: ?, import("../MapBrowserEvent.js").default, import("../pixel.js").Pixel, import("../pixel.js").Pixel):boolean} EndCondition
  35336. */
  35337. /**
  35338. * @typedef {Object} Options
  35339. * @property {string} [className='ol-dragbox'] CSS class name for styling the box.
  35340. * @property {import("../events/condition.js").Condition} [condition] A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
  35341. * to indicate whether that event should be handled.
  35342. * Default is {@link ol/events/condition~mouseActionButton}.
  35343. * @property {number} [minArea=64] The minimum area of the box in pixel, this value is used by the default
  35344. * `boxEndCondition` function.
  35345. * @property {EndCondition} [boxEndCondition] A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
  35346. * {@link module:ol/pixel~Pixel}s to indicate whether a `boxend` event should be fired.
  35347. * Default is `true` if the area of the box is bigger than the `minArea` option.
  35348. * @property {function(this:DragBox, import("../MapBrowserEvent.js").default):void} [onBoxEnd] Code to execute just
  35349. * before `boxend` is fired.
  35350. */
  35351. /**
  35352. * @enum {string}
  35353. */
  35354. var DragBoxEventType = {
  35355. /**
  35356. * Triggered upon drag box start.
  35357. * @event DragBoxEvent#boxstart
  35358. * @api
  35359. */
  35360. BOXSTART: 'boxstart',
  35361. /**
  35362. * Triggered on drag when box is active.
  35363. * @event DragBoxEvent#boxdrag
  35364. * @api
  35365. */
  35366. BOXDRAG: 'boxdrag',
  35367. /**
  35368. * Triggered upon drag box end.
  35369. * @event DragBoxEvent#boxend
  35370. * @api
  35371. */
  35372. BOXEND: 'boxend',
  35373. /**
  35374. * Triggered upon drag box canceled.
  35375. * @event DragBoxEvent#boxcancel
  35376. * @api
  35377. */
  35378. BOXCANCEL: 'boxcancel',
  35379. };
  35380. /**
  35381. * @classdesc
  35382. * Events emitted by {@link module:ol/interaction/DragBox~DragBox} instances are instances of
  35383. * this type.
  35384. */
  35385. var DragBoxEvent = /** @class */ (function (_super) {
  35386. DragBox_extends(DragBoxEvent, _super);
  35387. /**
  35388. * @param {string} type The event type.
  35389. * @param {import("../coordinate.js").Coordinate} coordinate The event coordinate.
  35390. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Originating event.
  35391. */
  35392. function DragBoxEvent(type, coordinate, mapBrowserEvent) {
  35393. var _this = _super.call(this, type) || this;
  35394. /**
  35395. * The coordinate of the drag event.
  35396. * @const
  35397. * @type {import("../coordinate.js").Coordinate}
  35398. * @api
  35399. */
  35400. _this.coordinate = coordinate;
  35401. /**
  35402. * @const
  35403. * @type {import("../MapBrowserEvent.js").default}
  35404. * @api
  35405. */
  35406. _this.mapBrowserEvent = mapBrowserEvent;
  35407. return _this;
  35408. }
  35409. return DragBoxEvent;
  35410. }(Event));
  35411. /***
  35412. * @template Return
  35413. * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
  35414. * import("../Observable").OnSignature<import("../ObjectEventType").Types|
  35415. * 'change:active', import("../Object").ObjectEvent, Return> &
  35416. * import("../Observable").OnSignature<'boxcancel'|'boxdrag'|'boxend'|'boxstart', DragBoxEvent, Return> &
  35417. * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
  35418. * 'change:active'|'boxcancel'|'boxdrag'|'boxend', Return>} DragBoxOnSignature
  35419. */
  35420. /**
  35421. * @classdesc
  35422. * Allows the user to draw a vector box by clicking and dragging on the map,
  35423. * normally combined with an {@link module:ol/events/condition} that limits
  35424. * it to when the shift or other key is held down. This is used, for example,
  35425. * for zooming to a specific area of the map
  35426. * (see {@link module:ol/interaction/DragZoom~DragZoom} and
  35427. * {@link module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}).
  35428. *
  35429. * @fires DragBoxEvent
  35430. * @api
  35431. */
  35432. var DragBox = /** @class */ (function (_super) {
  35433. DragBox_extends(DragBox, _super);
  35434. /**
  35435. * @param {Options} [opt_options] Options.
  35436. */
  35437. function DragBox(opt_options) {
  35438. var _this = _super.call(this) || this;
  35439. /***
  35440. * @type {DragBoxOnSignature<import("../events").EventsKey>}
  35441. */
  35442. _this.on;
  35443. /***
  35444. * @type {DragBoxOnSignature<import("../events").EventsKey>}
  35445. */
  35446. _this.once;
  35447. /***
  35448. * @type {DragBoxOnSignature<void>}
  35449. */
  35450. _this.un;
  35451. var options = opt_options ? opt_options : {};
  35452. /**
  35453. * @type {import("../render/Box.js").default}
  35454. * @private
  35455. */
  35456. _this.box_ = new Box(options.className || 'ol-dragbox');
  35457. /**
  35458. * @type {number}
  35459. * @private
  35460. */
  35461. _this.minArea_ = options.minArea !== undefined ? options.minArea : 64;
  35462. if (options.onBoxEnd) {
  35463. _this.onBoxEnd = options.onBoxEnd;
  35464. }
  35465. /**
  35466. * @type {import("../pixel.js").Pixel}
  35467. * @private
  35468. */
  35469. _this.startPixel_ = null;
  35470. /**
  35471. * @private
  35472. * @type {import("../events/condition.js").Condition}
  35473. */
  35474. _this.condition_ = options.condition ? options.condition : mouseActionButton;
  35475. /**
  35476. * @private
  35477. * @type {EndCondition}
  35478. */
  35479. _this.boxEndCondition_ = options.boxEndCondition
  35480. ? options.boxEndCondition
  35481. : _this.defaultBoxEndCondition;
  35482. return _this;
  35483. }
  35484. /**
  35485. * The default condition for determining whether the boxend event
  35486. * should fire.
  35487. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent The originating MapBrowserEvent
  35488. * leading to the box end.
  35489. * @param {import("../pixel.js").Pixel} startPixel The starting pixel of the box.
  35490. * @param {import("../pixel.js").Pixel} endPixel The end pixel of the box.
  35491. * @return {boolean} Whether or not the boxend condition should be fired.
  35492. */
  35493. DragBox.prototype.defaultBoxEndCondition = function (mapBrowserEvent, startPixel, endPixel) {
  35494. var width = endPixel[0] - startPixel[0];
  35495. var height = endPixel[1] - startPixel[1];
  35496. return width * width + height * height >= this.minArea_;
  35497. };
  35498. /**
  35499. * Returns geometry of last drawn box.
  35500. * @return {import("../geom/Polygon.js").default} Geometry.
  35501. * @api
  35502. */
  35503. DragBox.prototype.getGeometry = function () {
  35504. return this.box_.getGeometry();
  35505. };
  35506. /**
  35507. * Handle pointer drag events.
  35508. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35509. */
  35510. DragBox.prototype.handleDragEvent = function (mapBrowserEvent) {
  35511. this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel);
  35512. this.dispatchEvent(new DragBoxEvent(DragBoxEventType.BOXDRAG, mapBrowserEvent.coordinate, mapBrowserEvent));
  35513. };
  35514. /**
  35515. * Handle pointer up events.
  35516. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35517. * @return {boolean} If the event was consumed.
  35518. */
  35519. DragBox.prototype.handleUpEvent = function (mapBrowserEvent) {
  35520. this.box_.setMap(null);
  35521. var completeBox = this.boxEndCondition_(mapBrowserEvent, this.startPixel_, mapBrowserEvent.pixel);
  35522. if (completeBox) {
  35523. this.onBoxEnd(mapBrowserEvent);
  35524. }
  35525. this.dispatchEvent(new DragBoxEvent(completeBox ? DragBoxEventType.BOXEND : DragBoxEventType.BOXCANCEL, mapBrowserEvent.coordinate, mapBrowserEvent));
  35526. return false;
  35527. };
  35528. /**
  35529. * Handle pointer down events.
  35530. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  35531. * @return {boolean} If the event was consumed.
  35532. */
  35533. DragBox.prototype.handleDownEvent = function (mapBrowserEvent) {
  35534. if (this.condition_(mapBrowserEvent)) {
  35535. this.startPixel_ = mapBrowserEvent.pixel;
  35536. this.box_.setMap(mapBrowserEvent.map);
  35537. this.box_.setPixels(this.startPixel_, this.startPixel_);
  35538. this.dispatchEvent(new DragBoxEvent(DragBoxEventType.BOXSTART, mapBrowserEvent.coordinate, mapBrowserEvent));
  35539. return true;
  35540. }
  35541. else {
  35542. return false;
  35543. }
  35544. };
  35545. /**
  35546. * Function to execute just before `onboxend` is fired
  35547. * @param {import("../MapBrowserEvent.js").default} event Event.
  35548. */
  35549. DragBox.prototype.onBoxEnd = function (event) { };
  35550. return DragBox;
  35551. }(Pointer));
  35552. /* harmony default export */ var interaction_DragBox = (DragBox);
  35553. //# sourceMappingURL=DragBox.js.map
  35554. ;// ./node_modules/ol/interaction/DragZoom.js
  35555. var DragZoom_extends = (undefined && undefined.__extends) || (function () {
  35556. var extendStatics = function (d, b) {
  35557. extendStatics = Object.setPrototypeOf ||
  35558. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35559. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35560. return extendStatics(d, b);
  35561. };
  35562. return function (d, b) {
  35563. if (typeof b !== "function" && b !== null)
  35564. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35565. extendStatics(d, b);
  35566. function __() { this.constructor = d; }
  35567. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35568. };
  35569. })();
  35570. /**
  35571. * @module ol/interaction/DragZoom
  35572. */
  35573. /**
  35574. * @typedef {Object} Options
  35575. * @property {string} [className='ol-dragzoom'] CSS class name for styling the
  35576. * box.
  35577. * @property {import("../events/condition.js").Condition} [condition] A function that
  35578. * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
  35579. * boolean to indicate whether that event should be handled.
  35580. * Default is {@link module:ol/events/condition.shiftKeyOnly}.
  35581. * @property {number} [duration=200] Animation duration in milliseconds.
  35582. * @property {boolean} [out=false] Use interaction for zooming out.
  35583. * @property {number} [minArea=64] The minimum area of the box in pixel, this value is used by the parent default
  35584. * `boxEndCondition` function.
  35585. */
  35586. /**
  35587. * @classdesc
  35588. * Allows the user to zoom the map by clicking and dragging on the map,
  35589. * normally combined with an {@link module:ol/events/condition} that limits
  35590. * it to when a key, shift by default, is held down.
  35591. *
  35592. * To change the style of the box, use CSS and the `.ol-dragzoom` selector, or
  35593. * your custom one configured with `className`.
  35594. * @api
  35595. */
  35596. var DragZoom = /** @class */ (function (_super) {
  35597. DragZoom_extends(DragZoom, _super);
  35598. /**
  35599. * @param {Options} [opt_options] Options.
  35600. */
  35601. function DragZoom(opt_options) {
  35602. var _this = this;
  35603. var options = opt_options ? opt_options : {};
  35604. var condition = options.condition ? options.condition : shiftKeyOnly;
  35605. _this = _super.call(this, {
  35606. condition: condition,
  35607. className: options.className || 'ol-dragzoom',
  35608. minArea: options.minArea,
  35609. }) || this;
  35610. /**
  35611. * @private
  35612. * @type {number}
  35613. */
  35614. _this.duration_ = options.duration !== undefined ? options.duration : 200;
  35615. /**
  35616. * @private
  35617. * @type {boolean}
  35618. */
  35619. _this.out_ = options.out !== undefined ? options.out : false;
  35620. return _this;
  35621. }
  35622. /**
  35623. * Function to execute just before `onboxend` is fired
  35624. * @param {import("../MapBrowserEvent.js").default} event Event.
  35625. */
  35626. DragZoom.prototype.onBoxEnd = function (event) {
  35627. var map = this.getMap();
  35628. var view = /** @type {!import("../View.js").default} */ (map.getView());
  35629. var geometry = this.getGeometry();
  35630. if (this.out_) {
  35631. var rotatedExtent = view.rotatedExtentForGeometry(geometry);
  35632. var resolution = view.getResolutionForExtentInternal(rotatedExtent);
  35633. var factor = view.getResolution() / resolution;
  35634. geometry = geometry.clone();
  35635. geometry.scale(factor * factor);
  35636. }
  35637. view.fitInternal(geometry, {
  35638. duration: this.duration_,
  35639. easing: easeOut,
  35640. });
  35641. };
  35642. return DragZoom;
  35643. }(interaction_DragBox));
  35644. /* harmony default export */ var interaction_DragZoom = (DragZoom);
  35645. //# sourceMappingURL=DragZoom.js.map
  35646. ;// ./node_modules/ol/events/KeyCode.js
  35647. /**
  35648. * @module ol/events/KeyCode
  35649. */
  35650. /**
  35651. * @enum {number}
  35652. * @const
  35653. */
  35654. /* harmony default export */ var KeyCode = ({
  35655. LEFT: 37,
  35656. UP: 38,
  35657. RIGHT: 39,
  35658. DOWN: 40,
  35659. });
  35660. //# sourceMappingURL=KeyCode.js.map
  35661. ;// ./node_modules/ol/interaction/KeyboardPan.js
  35662. var KeyboardPan_extends = (undefined && undefined.__extends) || (function () {
  35663. var extendStatics = function (d, b) {
  35664. extendStatics = Object.setPrototypeOf ||
  35665. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35666. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35667. return extendStatics(d, b);
  35668. };
  35669. return function (d, b) {
  35670. if (typeof b !== "function" && b !== null)
  35671. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35672. extendStatics(d, b);
  35673. function __() { this.constructor = d; }
  35674. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35675. };
  35676. })();
  35677. /**
  35678. * @module ol/interaction/KeyboardPan
  35679. */
  35680. /**
  35681. * @typedef {Object} Options
  35682. * @property {import("../events/condition.js").Condition} [condition] A function that
  35683. * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
  35684. * boolean to indicate whether that event should be handled. Default is
  35685. * {@link module:ol/events/condition.noModifierKeys} and
  35686. * {@link module:ol/events/condition.targetNotEditable}.
  35687. * @property {number} [duration=100] Animation duration in milliseconds.
  35688. * @property {number} [pixelDelta=128] The amount of pixels to pan on each key
  35689. * press.
  35690. */
  35691. /**
  35692. * @classdesc
  35693. * Allows the user to pan the map using keyboard arrows.
  35694. * Note that, although this interaction is by default included in maps,
  35695. * the keys can only be used when browser focus is on the element to which
  35696. * the keyboard events are attached. By default, this is the map div,
  35697. * though you can change this with the `keyboardEventTarget` in
  35698. * {@link module:ol/Map~Map}. `document` never loses focus but, for any other
  35699. * element, focus will have to be on, and returned to, this element if the keys
  35700. * are to function.
  35701. * See also {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}.
  35702. * @api
  35703. */
  35704. var KeyboardPan = /** @class */ (function (_super) {
  35705. KeyboardPan_extends(KeyboardPan, _super);
  35706. /**
  35707. * @param {Options} [opt_options] Options.
  35708. */
  35709. function KeyboardPan(opt_options) {
  35710. var _this = _super.call(this) || this;
  35711. var options = opt_options || {};
  35712. /**
  35713. * @private
  35714. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Browser event.
  35715. * @return {boolean} Combined condition result.
  35716. */
  35717. _this.defaultCondition_ = function (mapBrowserEvent) {
  35718. return (noModifierKeys(mapBrowserEvent) && targetNotEditable(mapBrowserEvent));
  35719. };
  35720. /**
  35721. * @private
  35722. * @type {import("../events/condition.js").Condition}
  35723. */
  35724. _this.condition_ =
  35725. options.condition !== undefined
  35726. ? options.condition
  35727. : _this.defaultCondition_;
  35728. /**
  35729. * @private
  35730. * @type {number}
  35731. */
  35732. _this.duration_ = options.duration !== undefined ? options.duration : 100;
  35733. /**
  35734. * @private
  35735. * @type {number}
  35736. */
  35737. _this.pixelDelta_ =
  35738. options.pixelDelta !== undefined ? options.pixelDelta : 128;
  35739. return _this;
  35740. }
  35741. /**
  35742. * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} if it was a
  35743. * `KeyEvent`, and decides the direction to pan to (if an arrow key was
  35744. * pressed).
  35745. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  35746. * @return {boolean} `false` to stop event propagation.
  35747. * @this {KeyboardPan}
  35748. */
  35749. KeyboardPan.prototype.handleEvent = function (mapBrowserEvent) {
  35750. var stopEvent = false;
  35751. if (mapBrowserEvent.type == EventType.KEYDOWN) {
  35752. var keyEvent = /** @type {KeyboardEvent} */ (mapBrowserEvent.originalEvent);
  35753. var keyCode = keyEvent.keyCode;
  35754. if (this.condition_(mapBrowserEvent) &&
  35755. (keyCode == KeyCode.DOWN ||
  35756. keyCode == KeyCode.LEFT ||
  35757. keyCode == KeyCode.RIGHT ||
  35758. keyCode == KeyCode.UP)) {
  35759. var map = mapBrowserEvent.map;
  35760. var view = map.getView();
  35761. var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
  35762. var deltaX = 0, deltaY = 0;
  35763. if (keyCode == KeyCode.DOWN) {
  35764. deltaY = -mapUnitsDelta;
  35765. }
  35766. else if (keyCode == KeyCode.LEFT) {
  35767. deltaX = -mapUnitsDelta;
  35768. }
  35769. else if (keyCode == KeyCode.RIGHT) {
  35770. deltaX = mapUnitsDelta;
  35771. }
  35772. else {
  35773. deltaY = mapUnitsDelta;
  35774. }
  35775. var delta = [deltaX, deltaY];
  35776. rotate(delta, view.getRotation());
  35777. pan(view, delta, this.duration_);
  35778. keyEvent.preventDefault();
  35779. stopEvent = true;
  35780. }
  35781. }
  35782. return !stopEvent;
  35783. };
  35784. return KeyboardPan;
  35785. }(interaction_Interaction));
  35786. /* harmony default export */ var interaction_KeyboardPan = (KeyboardPan);
  35787. //# sourceMappingURL=KeyboardPan.js.map
  35788. ;// ./node_modules/ol/interaction/KeyboardZoom.js
  35789. var KeyboardZoom_extends = (undefined && undefined.__extends) || (function () {
  35790. var extendStatics = function (d, b) {
  35791. extendStatics = Object.setPrototypeOf ||
  35792. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35793. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35794. return extendStatics(d, b);
  35795. };
  35796. return function (d, b) {
  35797. if (typeof b !== "function" && b !== null)
  35798. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35799. extendStatics(d, b);
  35800. function __() { this.constructor = d; }
  35801. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35802. };
  35803. })();
  35804. /**
  35805. * @module ol/interaction/KeyboardZoom
  35806. */
  35807. /**
  35808. * @typedef {Object} Options
  35809. * @property {number} [duration=100] Animation duration in milliseconds.
  35810. * @property {import("../events/condition.js").Condition} [condition] A function that
  35811. * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
  35812. * boolean to indicate whether that event should be handled. Default is
  35813. * {@link module:ol/events/condition.targetNotEditable}.
  35814. * @property {number} [delta=1] The zoom level delta on each key press.
  35815. */
  35816. /**
  35817. * @classdesc
  35818. * Allows the user to zoom the map using keyboard + and -.
  35819. * Note that, although this interaction is by default included in maps,
  35820. * the keys can only be used when browser focus is on the element to which
  35821. * the keyboard events are attached. By default, this is the map div,
  35822. * though you can change this with the `keyboardEventTarget` in
  35823. * {@link module:ol/Map~Map}. `document` never loses focus but, for any other
  35824. * element, focus will have to be on, and returned to, this element if the keys
  35825. * are to function.
  35826. * See also {@link module:ol/interaction/KeyboardPan~KeyboardPan}.
  35827. * @api
  35828. */
  35829. var KeyboardZoom = /** @class */ (function (_super) {
  35830. KeyboardZoom_extends(KeyboardZoom, _super);
  35831. /**
  35832. * @param {Options} [opt_options] Options.
  35833. */
  35834. function KeyboardZoom(opt_options) {
  35835. var _this = _super.call(this) || this;
  35836. var options = opt_options ? opt_options : {};
  35837. /**
  35838. * @private
  35839. * @type {import("../events/condition.js").Condition}
  35840. */
  35841. _this.condition_ = options.condition ? options.condition : targetNotEditable;
  35842. /**
  35843. * @private
  35844. * @type {number}
  35845. */
  35846. _this.delta_ = options.delta ? options.delta : 1;
  35847. /**
  35848. * @private
  35849. * @type {number}
  35850. */
  35851. _this.duration_ = options.duration !== undefined ? options.duration : 100;
  35852. return _this;
  35853. }
  35854. /**
  35855. * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} if it was a
  35856. * `KeyEvent`, and decides whether to zoom in or out (depending on whether the
  35857. * key pressed was '+' or '-').
  35858. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  35859. * @return {boolean} `false` to stop event propagation.
  35860. * @this {KeyboardZoom}
  35861. */
  35862. KeyboardZoom.prototype.handleEvent = function (mapBrowserEvent) {
  35863. var stopEvent = false;
  35864. if (mapBrowserEvent.type == EventType.KEYDOWN ||
  35865. mapBrowserEvent.type == EventType.KEYPRESS) {
  35866. var keyEvent = /** @type {KeyboardEvent} */ (mapBrowserEvent.originalEvent);
  35867. var charCode = keyEvent.charCode;
  35868. if (this.condition_(mapBrowserEvent) &&
  35869. (charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0))) {
  35870. var map = mapBrowserEvent.map;
  35871. var delta = charCode == '+'.charCodeAt(0) ? this.delta_ : -this.delta_;
  35872. var view = map.getView();
  35873. zoomByDelta(view, delta, undefined, this.duration_);
  35874. keyEvent.preventDefault();
  35875. stopEvent = true;
  35876. }
  35877. }
  35878. return !stopEvent;
  35879. };
  35880. return KeyboardZoom;
  35881. }(interaction_Interaction));
  35882. /* harmony default export */ var interaction_KeyboardZoom = (KeyboardZoom);
  35883. //# sourceMappingURL=KeyboardZoom.js.map
  35884. ;// ./node_modules/ol/Kinetic.js
  35885. /**
  35886. * @module ol/Kinetic
  35887. */
  35888. /**
  35889. * @classdesc
  35890. * Implementation of inertial deceleration for map movement.
  35891. *
  35892. * @api
  35893. */
  35894. var Kinetic = /** @class */ (function () {
  35895. /**
  35896. * @param {number} decay Rate of decay (must be negative).
  35897. * @param {number} minVelocity Minimum velocity (pixels/millisecond).
  35898. * @param {number} delay Delay to consider to calculate the kinetic
  35899. * initial values (milliseconds).
  35900. */
  35901. function Kinetic(decay, minVelocity, delay) {
  35902. /**
  35903. * @private
  35904. * @type {number}
  35905. */
  35906. this.decay_ = decay;
  35907. /**
  35908. * @private
  35909. * @type {number}
  35910. */
  35911. this.minVelocity_ = minVelocity;
  35912. /**
  35913. * @private
  35914. * @type {number}
  35915. */
  35916. this.delay_ = delay;
  35917. /**
  35918. * @private
  35919. * @type {Array<number>}
  35920. */
  35921. this.points_ = [];
  35922. /**
  35923. * @private
  35924. * @type {number}
  35925. */
  35926. this.angle_ = 0;
  35927. /**
  35928. * @private
  35929. * @type {number}
  35930. */
  35931. this.initialVelocity_ = 0;
  35932. }
  35933. /**
  35934. * FIXME empty description for jsdoc
  35935. */
  35936. Kinetic.prototype.begin = function () {
  35937. this.points_.length = 0;
  35938. this.angle_ = 0;
  35939. this.initialVelocity_ = 0;
  35940. };
  35941. /**
  35942. * @param {number} x X.
  35943. * @param {number} y Y.
  35944. */
  35945. Kinetic.prototype.update = function (x, y) {
  35946. this.points_.push(x, y, Date.now());
  35947. };
  35948. /**
  35949. * @return {boolean} Whether we should do kinetic animation.
  35950. */
  35951. Kinetic.prototype.end = function () {
  35952. if (this.points_.length < 6) {
  35953. // at least 2 points are required (i.e. there must be at least 6 elements
  35954. // in the array)
  35955. return false;
  35956. }
  35957. var delay = Date.now() - this.delay_;
  35958. var lastIndex = this.points_.length - 3;
  35959. if (this.points_[lastIndex + 2] < delay) {
  35960. // the last tracked point is too old, which means that the user stopped
  35961. // panning before releasing the map
  35962. return false;
  35963. }
  35964. // get the first point which still falls into the delay time
  35965. var firstIndex = lastIndex - 3;
  35966. while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
  35967. firstIndex -= 3;
  35968. }
  35969. var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
  35970. // we don't want a duration of 0 (divide by zero)
  35971. // we also make sure the user panned for a duration of at least one frame
  35972. // (1/60s) to compute sane displacement values
  35973. if (duration < 1000 / 60) {
  35974. return false;
  35975. }
  35976. var dx = this.points_[lastIndex] - this.points_[firstIndex];
  35977. var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
  35978. this.angle_ = Math.atan2(dy, dx);
  35979. this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / duration;
  35980. return this.initialVelocity_ > this.minVelocity_;
  35981. };
  35982. /**
  35983. * @return {number} Total distance travelled (pixels).
  35984. */
  35985. Kinetic.prototype.getDistance = function () {
  35986. return (this.minVelocity_ - this.initialVelocity_) / this.decay_;
  35987. };
  35988. /**
  35989. * @return {number} Angle of the kinetic panning animation (radians).
  35990. */
  35991. Kinetic.prototype.getAngle = function () {
  35992. return this.angle_;
  35993. };
  35994. return Kinetic;
  35995. }());
  35996. /* harmony default export */ var ol_Kinetic = (Kinetic);
  35997. //# sourceMappingURL=Kinetic.js.map
  35998. ;// ./node_modules/ol/interaction/MouseWheelZoom.js
  35999. var MouseWheelZoom_extends = (undefined && undefined.__extends) || (function () {
  36000. var extendStatics = function (d, b) {
  36001. extendStatics = Object.setPrototypeOf ||
  36002. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36003. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  36004. return extendStatics(d, b);
  36005. };
  36006. return function (d, b) {
  36007. if (typeof b !== "function" && b !== null)
  36008. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  36009. extendStatics(d, b);
  36010. function __() { this.constructor = d; }
  36011. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36012. };
  36013. })();
  36014. /**
  36015. * @module ol/interaction/MouseWheelZoom
  36016. */
  36017. /**
  36018. * @enum {string}
  36019. */
  36020. var Mode = {
  36021. TRACKPAD: 'trackpad',
  36022. WHEEL: 'wheel',
  36023. };
  36024. /**
  36025. * @typedef {Object} Options
  36026. * @property {import("../events/condition.js").Condition} [condition] A function that
  36027. * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
  36028. * boolean to indicate whether that event should be handled. Default is
  36029. * {@link module:ol/events/condition.always}.
  36030. * @property {boolean} [onFocusOnly=false] When the map's target has a `tabindex` attribute set,
  36031. * the interaction will only handle events when the map has the focus.
  36032. * @property {number} [maxDelta=1] Maximum mouse wheel delta.
  36033. * @property {number} [duration=250] Animation duration in milliseconds.
  36034. * @property {number} [timeout=80] Mouse wheel timeout duration in milliseconds.
  36035. * @property {boolean} [useAnchor=true] Enable zooming using the mouse's
  36036. * location as the anchor. When set to `false`, zooming in and out will zoom to
  36037. * the center of the screen instead of zooming on the mouse's location.
  36038. * @property {boolean} [constrainResolution=false] If true, the mouse wheel zoom
  36039. * event will always animate to the closest zoom level after an interaction;
  36040. * false means intermediary zoom levels are allowed.
  36041. */
  36042. /**
  36043. * @classdesc
  36044. * Allows the user to zoom the map by scrolling the mouse wheel.
  36045. * @api
  36046. */
  36047. var MouseWheelZoom = /** @class */ (function (_super) {
  36048. MouseWheelZoom_extends(MouseWheelZoom, _super);
  36049. /**
  36050. * @param {Options} [opt_options] Options.
  36051. */
  36052. function MouseWheelZoom(opt_options) {
  36053. var _this = this;
  36054. var options = opt_options ? opt_options : {};
  36055. _this = _super.call(this,
  36056. /** @type {import("./Interaction.js").InteractionOptions} */ (options)) || this;
  36057. /**
  36058. * @private
  36059. * @type {number}
  36060. */
  36061. _this.totalDelta_ = 0;
  36062. /**
  36063. * @private
  36064. * @type {number}
  36065. */
  36066. _this.lastDelta_ = 0;
  36067. /**
  36068. * @private
  36069. * @type {number}
  36070. */
  36071. _this.maxDelta_ = options.maxDelta !== undefined ? options.maxDelta : 1;
  36072. /**
  36073. * @private
  36074. * @type {number}
  36075. */
  36076. _this.duration_ = options.duration !== undefined ? options.duration : 250;
  36077. /**
  36078. * @private
  36079. * @type {number}
  36080. */
  36081. _this.timeout_ = options.timeout !== undefined ? options.timeout : 80;
  36082. /**
  36083. * @private
  36084. * @type {boolean}
  36085. */
  36086. _this.useAnchor_ =
  36087. options.useAnchor !== undefined ? options.useAnchor : true;
  36088. /**
  36089. * @private
  36090. * @type {boolean}
  36091. */
  36092. _this.constrainResolution_ =
  36093. options.constrainResolution !== undefined
  36094. ? options.constrainResolution
  36095. : false;
  36096. var condition = options.condition ? options.condition : always;
  36097. /**
  36098. * @private
  36099. * @type {import("../events/condition.js").Condition}
  36100. */
  36101. _this.condition_ = options.onFocusOnly
  36102. ? condition_all(focusWithTabindex, condition)
  36103. : condition;
  36104. /**
  36105. * @private
  36106. * @type {?import("../coordinate.js").Coordinate}
  36107. */
  36108. _this.lastAnchor_ = null;
  36109. /**
  36110. * @private
  36111. * @type {number|undefined}
  36112. */
  36113. _this.startTime_ = undefined;
  36114. /**
  36115. * @private
  36116. * @type {?}
  36117. */
  36118. _this.timeoutId_;
  36119. /**
  36120. * @private
  36121. * @type {Mode|undefined}
  36122. */
  36123. _this.mode_ = undefined;
  36124. /**
  36125. * Trackpad events separated by this delay will be considered separate
  36126. * interactions.
  36127. * @type {number}
  36128. */
  36129. _this.trackpadEventGap_ = 400;
  36130. /**
  36131. * @type {?}
  36132. */
  36133. _this.trackpadTimeoutId_;
  36134. /**
  36135. * The number of delta values per zoom level
  36136. * @private
  36137. * @type {number}
  36138. */
  36139. _this.deltaPerZoom_ = 300;
  36140. return _this;
  36141. }
  36142. /**
  36143. * @private
  36144. */
  36145. MouseWheelZoom.prototype.endInteraction_ = function () {
  36146. this.trackpadTimeoutId_ = undefined;
  36147. var map = this.getMap();
  36148. if (!map) {
  36149. return;
  36150. }
  36151. var view = map.getView();
  36152. view.endInteraction(undefined, this.lastDelta_ ? (this.lastDelta_ > 0 ? 1 : -1) : 0, this.lastAnchor_);
  36153. };
  36154. /**
  36155. * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} (if it was a mousewheel-event) and eventually
  36156. * zooms the map.
  36157. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
  36158. * @return {boolean} `false` to stop event propagation.
  36159. */
  36160. MouseWheelZoom.prototype.handleEvent = function (mapBrowserEvent) {
  36161. if (!this.condition_(mapBrowserEvent)) {
  36162. return true;
  36163. }
  36164. var type = mapBrowserEvent.type;
  36165. if (type !== EventType.WHEEL) {
  36166. return true;
  36167. }
  36168. var map = mapBrowserEvent.map;
  36169. var wheelEvent = /** @type {WheelEvent} */ (mapBrowserEvent.originalEvent);
  36170. wheelEvent.preventDefault();
  36171. if (this.useAnchor_) {
  36172. this.lastAnchor_ = mapBrowserEvent.coordinate;
  36173. }
  36174. // Delta normalisation inspired by
  36175. // https://github.com/mapbox/mapbox-gl-js/blob/001c7b9/js/ui/handler/scroll_zoom.js
  36176. var delta;
  36177. if (mapBrowserEvent.type == EventType.WHEEL) {
  36178. delta = wheelEvent.deltaY;
  36179. if (FIREFOX && wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  36180. delta /= DEVICE_PIXEL_RATIO;
  36181. }
  36182. if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) {
  36183. delta *= 40;
  36184. }
  36185. }
  36186. if (delta === 0) {
  36187. return false;
  36188. }
  36189. else {
  36190. this.lastDelta_ = delta;
  36191. }
  36192. var now = Date.now();
  36193. if (this.startTime_ === undefined) {
  36194. this.startTime_ = now;
  36195. }
  36196. if (!this.mode_ || now - this.startTime_ > this.trackpadEventGap_) {
  36197. this.mode_ = Math.abs(delta) < 4 ? Mode.TRACKPAD : Mode.WHEEL;
  36198. }
  36199. var view = map.getView();
  36200. if (this.mode_ === Mode.TRACKPAD &&
  36201. !(view.getConstrainResolution() || this.constrainResolution_)) {
  36202. if (this.trackpadTimeoutId_) {
  36203. clearTimeout(this.trackpadTimeoutId_);
  36204. }
  36205. else {
  36206. if (view.getAnimating()) {
  36207. view.cancelAnimations();
  36208. }
  36209. view.beginInteraction();
  36210. }
  36211. this.trackpadTimeoutId_ = setTimeout(this.endInteraction_.bind(this), this.timeout_);
  36212. view.adjustZoom(-delta / this.deltaPerZoom_, this.lastAnchor_);
  36213. this.startTime_ = now;
  36214. return false;
  36215. }
  36216. this.totalDelta_ += delta;
  36217. var timeLeft = Math.max(this.timeout_ - (now - this.startTime_), 0);
  36218. clearTimeout(this.timeoutId_);
  36219. this.timeoutId_ = setTimeout(this.handleWheelZoom_.bind(this, map), timeLeft);
  36220. return false;
  36221. };
  36222. /**
  36223. * @private
  36224. * @param {import("../PluggableMap.js").default} map Map.
  36225. */
  36226. MouseWheelZoom.prototype.handleWheelZoom_ = function (map) {
  36227. var view = map.getView();
  36228. if (view.getAnimating()) {
  36229. view.cancelAnimations();
  36230. }
  36231. var delta = -math_clamp(this.totalDelta_, -this.maxDelta_ * this.deltaPerZoom_, this.maxDelta_ * this.deltaPerZoom_) / this.deltaPerZoom_;
  36232. if (view.getConstrainResolution() || this.constrainResolution_) {
  36233. // view has a zoom constraint, zoom by 1
  36234. delta = delta ? (delta > 0 ? 1 : -1) : 0;
  36235. }
  36236. zoomByDelta(view, delta, this.lastAnchor_, this.duration_);
  36237. this.mode_ = undefined;
  36238. this.totalDelta_ = 0;
  36239. this.lastAnchor_ = null;
  36240. this.startTime_ = undefined;
  36241. this.timeoutId_ = undefined;
  36242. };
  36243. /**
  36244. * Enable or disable using the mouse's location as an anchor when zooming
  36245. * @param {boolean} useAnchor true to zoom to the mouse's location, false
  36246. * to zoom to the center of the map
  36247. * @api
  36248. */
  36249. MouseWheelZoom.prototype.setMouseAnchor = function (useAnchor) {
  36250. this.useAnchor_ = useAnchor;
  36251. if (!useAnchor) {
  36252. this.lastAnchor_ = null;
  36253. }
  36254. };
  36255. return MouseWheelZoom;
  36256. }(interaction_Interaction));
  36257. /* harmony default export */ var interaction_MouseWheelZoom = (MouseWheelZoom);
  36258. //# sourceMappingURL=MouseWheelZoom.js.map
  36259. ;// ./node_modules/ol/interaction/PinchRotate.js
  36260. var PinchRotate_extends = (undefined && undefined.__extends) || (function () {
  36261. var extendStatics = function (d, b) {
  36262. extendStatics = Object.setPrototypeOf ||
  36263. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36264. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  36265. return extendStatics(d, b);
  36266. };
  36267. return function (d, b) {
  36268. if (typeof b !== "function" && b !== null)
  36269. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  36270. extendStatics(d, b);
  36271. function __() { this.constructor = d; }
  36272. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36273. };
  36274. })();
  36275. /**
  36276. * @module ol/interaction/PinchRotate
  36277. */
  36278. /**
  36279. * @typedef {Object} Options
  36280. * @property {number} [duration=250] The duration of the animation in
  36281. * milliseconds.
  36282. * @property {number} [threshold=0.3] Minimal angle in radians to start a rotation.
  36283. */
  36284. /**
  36285. * @classdesc
  36286. * Allows the user to rotate the map by twisting with two fingers
  36287. * on a touch screen.
  36288. * @api
  36289. */
  36290. var PinchRotate = /** @class */ (function (_super) {
  36291. PinchRotate_extends(PinchRotate, _super);
  36292. /**
  36293. * @param {Options} [opt_options] Options.
  36294. */
  36295. function PinchRotate(opt_options) {
  36296. var _this = this;
  36297. var options = opt_options ? opt_options : {};
  36298. var pointerOptions = /** @type {import("./Pointer.js").Options} */ (options);
  36299. if (!pointerOptions.stopDown) {
  36300. pointerOptions.stopDown = functions_FALSE;
  36301. }
  36302. _this = _super.call(this, pointerOptions) || this;
  36303. /**
  36304. * @private
  36305. * @type {import("../coordinate.js").Coordinate}
  36306. */
  36307. _this.anchor_ = null;
  36308. /**
  36309. * @private
  36310. * @type {number|undefined}
  36311. */
  36312. _this.lastAngle_ = undefined;
  36313. /**
  36314. * @private
  36315. * @type {boolean}
  36316. */
  36317. _this.rotating_ = false;
  36318. /**
  36319. * @private
  36320. * @type {number}
  36321. */
  36322. _this.rotationDelta_ = 0.0;
  36323. /**
  36324. * @private
  36325. * @type {number}
  36326. */
  36327. _this.threshold_ = options.threshold !== undefined ? options.threshold : 0.3;
  36328. /**
  36329. * @private
  36330. * @type {number}
  36331. */
  36332. _this.duration_ = options.duration !== undefined ? options.duration : 250;
  36333. return _this;
  36334. }
  36335. /**
  36336. * Handle pointer drag events.
  36337. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  36338. */
  36339. PinchRotate.prototype.handleDragEvent = function (mapBrowserEvent) {
  36340. var rotationDelta = 0.0;
  36341. var touch0 = this.targetPointers[0];
  36342. var touch1 = this.targetPointers[1];
  36343. // angle between touches
  36344. var angle = Math.atan2(touch1.clientY - touch0.clientY, touch1.clientX - touch0.clientX);
  36345. if (this.lastAngle_ !== undefined) {
  36346. var delta = angle - this.lastAngle_;
  36347. this.rotationDelta_ += delta;
  36348. if (!this.rotating_ && Math.abs(this.rotationDelta_) > this.threshold_) {
  36349. this.rotating_ = true;
  36350. }
  36351. rotationDelta = delta;
  36352. }
  36353. this.lastAngle_ = angle;
  36354. var map = mapBrowserEvent.map;
  36355. var view = map.getView();
  36356. if (view.getConstraints().rotation === disable) {
  36357. return;
  36358. }
  36359. // rotate anchor point.
  36360. // FIXME: should be the intersection point between the lines:
  36361. // touch0,touch1 and previousTouch0,previousTouch1
  36362. var viewportPosition = map.getViewport().getBoundingClientRect();
  36363. var centroid = Pointer_centroid(this.targetPointers);
  36364. centroid[0] -= viewportPosition.left;
  36365. centroid[1] -= viewportPosition.top;
  36366. this.anchor_ = map.getCoordinateFromPixelInternal(centroid);
  36367. // rotate
  36368. if (this.rotating_) {
  36369. map.render();
  36370. view.adjustRotationInternal(rotationDelta, this.anchor_);
  36371. }
  36372. };
  36373. /**
  36374. * Handle pointer up events.
  36375. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  36376. * @return {boolean} If the event was consumed.
  36377. */
  36378. PinchRotate.prototype.handleUpEvent = function (mapBrowserEvent) {
  36379. if (this.targetPointers.length < 2) {
  36380. var map = mapBrowserEvent.map;
  36381. var view = map.getView();
  36382. view.endInteraction(this.duration_);
  36383. return false;
  36384. }
  36385. else {
  36386. return true;
  36387. }
  36388. };
  36389. /**
  36390. * Handle pointer down events.
  36391. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  36392. * @return {boolean} If the event was consumed.
  36393. */
  36394. PinchRotate.prototype.handleDownEvent = function (mapBrowserEvent) {
  36395. if (this.targetPointers.length >= 2) {
  36396. var map = mapBrowserEvent.map;
  36397. this.anchor_ = null;
  36398. this.lastAngle_ = undefined;
  36399. this.rotating_ = false;
  36400. this.rotationDelta_ = 0.0;
  36401. if (!this.handlingDownUpSequence) {
  36402. map.getView().beginInteraction();
  36403. }
  36404. return true;
  36405. }
  36406. else {
  36407. return false;
  36408. }
  36409. };
  36410. return PinchRotate;
  36411. }(Pointer));
  36412. /* harmony default export */ var interaction_PinchRotate = (PinchRotate);
  36413. //# sourceMappingURL=PinchRotate.js.map
  36414. ;// ./node_modules/ol/interaction/PinchZoom.js
  36415. var PinchZoom_extends = (undefined && undefined.__extends) || (function () {
  36416. var extendStatics = function (d, b) {
  36417. extendStatics = Object.setPrototypeOf ||
  36418. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36419. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  36420. return extendStatics(d, b);
  36421. };
  36422. return function (d, b) {
  36423. if (typeof b !== "function" && b !== null)
  36424. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  36425. extendStatics(d, b);
  36426. function __() { this.constructor = d; }
  36427. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36428. };
  36429. })();
  36430. /**
  36431. * @module ol/interaction/PinchZoom
  36432. */
  36433. /**
  36434. * @typedef {Object} Options
  36435. * @property {number} [duration=400] Animation duration in milliseconds.
  36436. */
  36437. /**
  36438. * @classdesc
  36439. * Allows the user to zoom the map by pinching with two fingers
  36440. * on a touch screen.
  36441. * @api
  36442. */
  36443. var PinchZoom = /** @class */ (function (_super) {
  36444. PinchZoom_extends(PinchZoom, _super);
  36445. /**
  36446. * @param {Options} [opt_options] Options.
  36447. */
  36448. function PinchZoom(opt_options) {
  36449. var _this = this;
  36450. var options = opt_options ? opt_options : {};
  36451. var pointerOptions = /** @type {import("./Pointer.js").Options} */ (options);
  36452. if (!pointerOptions.stopDown) {
  36453. pointerOptions.stopDown = functions_FALSE;
  36454. }
  36455. _this = _super.call(this, pointerOptions) || this;
  36456. /**
  36457. * @private
  36458. * @type {import("../coordinate.js").Coordinate}
  36459. */
  36460. _this.anchor_ = null;
  36461. /**
  36462. * @private
  36463. * @type {number}
  36464. */
  36465. _this.duration_ = options.duration !== undefined ? options.duration : 400;
  36466. /**
  36467. * @private
  36468. * @type {number|undefined}
  36469. */
  36470. _this.lastDistance_ = undefined;
  36471. /**
  36472. * @private
  36473. * @type {number}
  36474. */
  36475. _this.lastScaleDelta_ = 1;
  36476. return _this;
  36477. }
  36478. /**
  36479. * Handle pointer drag events.
  36480. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  36481. */
  36482. PinchZoom.prototype.handleDragEvent = function (mapBrowserEvent) {
  36483. var scaleDelta = 1.0;
  36484. var touch0 = this.targetPointers[0];
  36485. var touch1 = this.targetPointers[1];
  36486. var dx = touch0.clientX - touch1.clientX;
  36487. var dy = touch0.clientY - touch1.clientY;
  36488. // distance between touches
  36489. var distance = Math.sqrt(dx * dx + dy * dy);
  36490. if (this.lastDistance_ !== undefined) {
  36491. scaleDelta = this.lastDistance_ / distance;
  36492. }
  36493. this.lastDistance_ = distance;
  36494. var map = mapBrowserEvent.map;
  36495. var view = map.getView();
  36496. if (scaleDelta != 1.0) {
  36497. this.lastScaleDelta_ = scaleDelta;
  36498. }
  36499. // scale anchor point.
  36500. var viewportPosition = map.getViewport().getBoundingClientRect();
  36501. var centroid = Pointer_centroid(this.targetPointers);
  36502. centroid[0] -= viewportPosition.left;
  36503. centroid[1] -= viewportPosition.top;
  36504. this.anchor_ = map.getCoordinateFromPixelInternal(centroid);
  36505. // scale, bypass the resolution constraint
  36506. map.render();
  36507. view.adjustResolutionInternal(scaleDelta, this.anchor_);
  36508. };
  36509. /**
  36510. * Handle pointer up events.
  36511. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  36512. * @return {boolean} If the event was consumed.
  36513. */
  36514. PinchZoom.prototype.handleUpEvent = function (mapBrowserEvent) {
  36515. if (this.targetPointers.length < 2) {
  36516. var map = mapBrowserEvent.map;
  36517. var view = map.getView();
  36518. var direction = this.lastScaleDelta_ > 1 ? 1 : -1;
  36519. view.endInteraction(this.duration_, direction);
  36520. return false;
  36521. }
  36522. else {
  36523. return true;
  36524. }
  36525. };
  36526. /**
  36527. * Handle pointer down events.
  36528. * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
  36529. * @return {boolean} If the event was consumed.
  36530. */
  36531. PinchZoom.prototype.handleDownEvent = function (mapBrowserEvent) {
  36532. if (this.targetPointers.length >= 2) {
  36533. var map = mapBrowserEvent.map;
  36534. this.anchor_ = null;
  36535. this.lastDistance_ = undefined;
  36536. this.lastScaleDelta_ = 1;
  36537. if (!this.handlingDownUpSequence) {
  36538. map.getView().beginInteraction();
  36539. }
  36540. return true;
  36541. }
  36542. else {
  36543. return false;
  36544. }
  36545. };
  36546. return PinchZoom;
  36547. }(Pointer));
  36548. /* harmony default export */ var interaction_PinchZoom = (PinchZoom);
  36549. //# sourceMappingURL=PinchZoom.js.map
  36550. ;// ./node_modules/ol/interaction.js
  36551. /**
  36552. * @module ol/interaction
  36553. */
  36554. /**
  36555. * @typedef {Object} DefaultsOptions
  36556. * @property {boolean} [altShiftDragRotate=true] Whether Alt-Shift-drag rotate is
  36557. * desired.
  36558. * @property {boolean} [onFocusOnly=false] Interact only when the map has the
  36559. * focus. This affects the `MouseWheelZoom` and `DragPan` interactions and is
  36560. * useful when page scroll is desired for maps that do not have the browser's
  36561. * focus.
  36562. * @property {boolean} [doubleClickZoom=true] Whether double click zoom is
  36563. * desired.
  36564. * @property {boolean} [keyboard=true] Whether keyboard interaction is desired.
  36565. * @property {boolean} [mouseWheelZoom=true] Whether mousewheel zoom is desired.
  36566. * @property {boolean} [shiftDragZoom=true] Whether Shift-drag zoom is desired.
  36567. * @property {boolean} [dragPan=true] Whether drag pan is desired.
  36568. * @property {boolean} [pinchRotate=true] Whether pinch rotate is desired.
  36569. * @property {boolean} [pinchZoom=true] Whether pinch zoom is desired.
  36570. * @property {number} [zoomDelta] Zoom level delta when using keyboard or double click zoom.
  36571. * @property {number} [zoomDuration] Duration of the zoom animation in
  36572. * milliseconds.
  36573. */
  36574. /**
  36575. * Set of interactions included in maps by default. Specific interactions can be
  36576. * excluded by setting the appropriate option to false in the constructor
  36577. * options, but the order of the interactions is fixed. If you want to specify
  36578. * a different order for interactions, you will need to create your own
  36579. * {@link module:ol/interaction/Interaction~Interaction} instances and insert
  36580. * them into a {@link module:ol/Collection~Collection} in the order you want
  36581. * before creating your {@link module:ol/Map~Map} instance. Changing the order can
  36582. * be of interest if the event propagation needs to be stopped at a point.
  36583. * The default set of interactions, in sequence, is:
  36584. * * {@link module:ol/interaction/DragRotate~DragRotate}
  36585. * * {@link module:ol/interaction/DoubleClickZoom~DoubleClickZoom}
  36586. * * {@link module:ol/interaction/DragPan~DragPan}
  36587. * * {@link module:ol/interaction/PinchRotate~PinchRotate}
  36588. * * {@link module:ol/interaction/PinchZoom~PinchZoom}
  36589. * * {@link module:ol/interaction/KeyboardPan~KeyboardPan}
  36590. * * {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}
  36591. * * {@link module:ol/interaction/MouseWheelZoom~MouseWheelZoom}
  36592. * * {@link module:ol/interaction/DragZoom~DragZoom}
  36593. *
  36594. * @param {DefaultsOptions} [opt_options] Defaults options.
  36595. * @return {import("./Collection.js").default<import("./interaction/Interaction.js").default>}
  36596. * A collection of interactions to be used with the {@link module:ol/Map~Map}
  36597. * constructor's `interactions` option.
  36598. * @api
  36599. */
  36600. function interaction_defaults(opt_options) {
  36601. var options = opt_options ? opt_options : {};
  36602. var interactions = new ol_Collection();
  36603. var kinetic = new ol_Kinetic(-0.005, 0.05, 100);
  36604. var altShiftDragRotate = options.altShiftDragRotate !== undefined
  36605. ? options.altShiftDragRotate
  36606. : true;
  36607. if (altShiftDragRotate) {
  36608. interactions.push(new interaction_DragRotate());
  36609. }
  36610. var doubleClickZoom = options.doubleClickZoom !== undefined ? options.doubleClickZoom : true;
  36611. if (doubleClickZoom) {
  36612. interactions.push(new interaction_DoubleClickZoom({
  36613. delta: options.zoomDelta,
  36614. duration: options.zoomDuration,
  36615. }));
  36616. }
  36617. var dragPan = options.dragPan !== undefined ? options.dragPan : true;
  36618. if (dragPan) {
  36619. interactions.push(new interaction_DragPan({
  36620. onFocusOnly: options.onFocusOnly,
  36621. kinetic: kinetic,
  36622. }));
  36623. }
  36624. var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate : true;
  36625. if (pinchRotate) {
  36626. interactions.push(new interaction_PinchRotate());
  36627. }
  36628. var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
  36629. if (pinchZoom) {
  36630. interactions.push(new interaction_PinchZoom({
  36631. duration: options.zoomDuration,
  36632. }));
  36633. }
  36634. var keyboard = options.keyboard !== undefined ? options.keyboard : true;
  36635. if (keyboard) {
  36636. interactions.push(new interaction_KeyboardPan());
  36637. interactions.push(new interaction_KeyboardZoom({
  36638. delta: options.zoomDelta,
  36639. duration: options.zoomDuration,
  36640. }));
  36641. }
  36642. var mouseWheelZoom = options.mouseWheelZoom !== undefined ? options.mouseWheelZoom : true;
  36643. if (mouseWheelZoom) {
  36644. interactions.push(new interaction_MouseWheelZoom({
  36645. onFocusOnly: options.onFocusOnly,
  36646. duration: options.zoomDuration,
  36647. }));
  36648. }
  36649. var shiftDragZoom = options.shiftDragZoom !== undefined ? options.shiftDragZoom : true;
  36650. if (shiftDragZoom) {
  36651. interactions.push(new interaction_DragZoom({
  36652. duration: options.zoomDuration,
  36653. }));
  36654. }
  36655. return interactions;
  36656. }
  36657. //# sourceMappingURL=interaction.js.map
  36658. ;// ./node_modules/ol/Map.js
  36659. var ol_Map_extends = (undefined && undefined.__extends) || (function () {
  36660. var extendStatics = function (d, b) {
  36661. extendStatics = Object.setPrototypeOf ||
  36662. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36663. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  36664. return extendStatics(d, b);
  36665. };
  36666. return function (d, b) {
  36667. if (typeof b !== "function" && b !== null)
  36668. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  36669. extendStatics(d, b);
  36670. function __() { this.constructor = d; }
  36671. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36672. };
  36673. })();
  36674. /**
  36675. * @module ol/Map
  36676. */
  36677. /**
  36678. * @classdesc
  36679. * The map is the core component of OpenLayers. For a map to render, a view,
  36680. * one or more layers, and a target container are needed:
  36681. *
  36682. * import Map from 'ol/Map';
  36683. * import View from 'ol/View';
  36684. * import TileLayer from 'ol/layer/Tile';
  36685. * import OSM from 'ol/source/OSM';
  36686. *
  36687. * var map = new Map({
  36688. * view: new View({
  36689. * center: [0, 0],
  36690. * zoom: 1
  36691. * }),
  36692. * layers: [
  36693. * new TileLayer({
  36694. * source: new OSM()
  36695. * })
  36696. * ],
  36697. * target: 'map'
  36698. * });
  36699. *
  36700. * The above snippet creates a map using a {@link module:ol/layer/Tile~TileLayer} to
  36701. * display {@link module:ol/source/OSM~OSM} OSM data and render it to a DOM
  36702. * element with the id `map`.
  36703. *
  36704. * The constructor places a viewport container (with CSS class name
  36705. * `ol-viewport`) in the target element (see `getViewport()`), and then two
  36706. * further elements within the viewport: one with CSS class name
  36707. * `ol-overlaycontainer-stopevent` for controls and some overlays, and one with
  36708. * CSS class name `ol-overlaycontainer` for other overlays (see the `stopEvent`
  36709. * option of {@link module:ol/Overlay~Overlay} for the difference). The map
  36710. * itself is placed in a further element within the viewport.
  36711. *
  36712. * Layers are stored as a {@link module:ol/Collection~Collection} in
  36713. * layerGroups. A top-level group is provided by the library. This is what is
  36714. * accessed by `getLayerGroup` and `setLayerGroup`. Layers entered in the
  36715. * options are added to this group, and `addLayer` and `removeLayer` change the
  36716. * layer collection in the group. `getLayers` is a convenience function for
  36717. * `getLayerGroup().getLayers()`. Note that {@link module:ol/layer/Group~LayerGroup}
  36718. * is a subclass of {@link module:ol/layer/Base~BaseLayer}, so layers entered in the
  36719. * options or added with `addLayer` can be groups, which can contain further
  36720. * groups, and so on.
  36721. *
  36722. * @api
  36723. */
  36724. var Map_Map = /** @class */ (function (_super) {
  36725. ol_Map_extends(Map, _super);
  36726. /**
  36727. * @param {import("./PluggableMap.js").MapOptions} options Map options.
  36728. */
  36729. function Map(options) {
  36730. options = obj_assign({}, options);
  36731. if (!options.controls) {
  36732. options.controls = defaults();
  36733. }
  36734. if (!options.interactions) {
  36735. options.interactions = interaction_defaults({
  36736. onFocusOnly: true,
  36737. });
  36738. }
  36739. return _super.call(this, options) || this;
  36740. }
  36741. Map.prototype.createRenderer = function () {
  36742. return new Composite(this);
  36743. };
  36744. return Map;
  36745. }(ol_PluggableMap));
  36746. /* harmony default export */ var ol_Map = (Map_Map);
  36747. //# sourceMappingURL=Map.js.map
  36748. ;// ./js/src/ol.mjs
  36749. const ol = {
  36750. control: {
  36751. Attribution: control_Attribution, MousePosition: control_MousePosition, Zoom: control_Zoom
  36752. },
  36753. coordinate: {
  36754. createStringXY: createStringXY
  36755. },
  36756. extent: {
  36757. boundingExtent: boundingExtent
  36758. },
  36759. geom: {
  36760. LineString: geom_LineString, LinearRing: geom_LinearRing, MultiLineString: geom_MultiLineString, MultiPoint: geom_MultiPoint, MultiPolygon: geom_MultiPolygon, Point: geom_Point, Polygon: geom_Polygon
  36761. },
  36762. layer: {
  36763. Tile: layer_Tile, Vector: Vector
  36764. },
  36765. proj: {
  36766. fromLonLat: fromLonLat, get: proj_get, transformExtent: transformExtent
  36767. },
  36768. source: {
  36769. OSM: source_OSM, Vector: source_Vector
  36770. },
  36771. style: {
  36772. Circle: Circle, Fill: style_Fill, Stroke: style_Stroke, Style: style_Style, Text: style_Text
  36773. },
  36774. Feature: ol_Feature, Map: ol_Map, View: ol_View
  36775. }
  36776. /* harmony default export */ var src_ol = (ol);
  36777. }();
  36778. __webpack_exports__ = __webpack_exports__["default"];
  36779. /******/ return __webpack_exports__;
  36780. /******/ })()
  36781. ;
  36782. });
  36783. //# sourceMappingURL=OpenLayers.js.map