@turf_turf.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633
  1. import {
  2. merge_default,
  3. require_earcut
  4. } from "./chunk-7ANULLBZ.js";
  5. import {
  6. __commonJS,
  7. __esm,
  8. __export,
  9. __toCommonJS,
  10. __toESM
  11. } from "./chunk-S5KM4IGW.js";
  12. // node_modules/object-assign/index.js
  13. var require_object_assign = __commonJS({
  14. "node_modules/object-assign/index.js"(exports, module) {
  15. "use strict";
  16. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  17. var hasOwnProperty2 = Object.prototype.hasOwnProperty;
  18. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  19. function toObject(val) {
  20. if (val === null || val === void 0) {
  21. throw new TypeError("Object.assign cannot be called with null or undefined");
  22. }
  23. return Object(val);
  24. }
  25. function shouldUseNative() {
  26. try {
  27. if (!Object.assign) {
  28. return false;
  29. }
  30. var test1 = new String("abc");
  31. test1[5] = "de";
  32. if (Object.getOwnPropertyNames(test1)[0] === "5") {
  33. return false;
  34. }
  35. var test2 = {};
  36. for (var i = 0; i < 10; i++) {
  37. test2["_" + String.fromCharCode(i)] = i;
  38. }
  39. var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
  40. return test2[n];
  41. });
  42. if (order2.join("") !== "0123456789") {
  43. return false;
  44. }
  45. var test3 = {};
  46. "abcdefghijklmnopqrst".split("").forEach(function(letter) {
  47. test3[letter] = letter;
  48. });
  49. if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
  50. return false;
  51. }
  52. return true;
  53. } catch (err) {
  54. return false;
  55. }
  56. }
  57. module.exports = shouldUseNative() ? Object.assign : function(target, source) {
  58. var from;
  59. var to = toObject(target);
  60. var symbols;
  61. for (var s = 1; s < arguments.length; s++) {
  62. from = Object(arguments[s]);
  63. for (var key in from) {
  64. if (hasOwnProperty2.call(from, key)) {
  65. to[key] = from[key];
  66. }
  67. }
  68. if (getOwnPropertySymbols) {
  69. symbols = getOwnPropertySymbols(from);
  70. for (var i = 0; i < symbols.length; i++) {
  71. if (propIsEnumerable.call(from, symbols[i])) {
  72. to[symbols[i]] = from[symbols[i]];
  73. }
  74. }
  75. }
  76. }
  77. return to;
  78. };
  79. }
  80. });
  81. // node_modules/concaveman/node_modules/rbush/rbush.min.js
  82. var require_rbush_min = __commonJS({
  83. "node_modules/concaveman/node_modules/rbush/rbush.min.js"(exports, module) {
  84. !function(t, i) {
  85. "object" == typeof exports && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : (t = t || self).RBush = i();
  86. }(exports, function() {
  87. "use strict";
  88. function t(t2, r2, e3, a2, h2) {
  89. !function t3(n2, r3, e4, a3, h3) {
  90. for (; a3 > e4; ) {
  91. if (a3 - e4 > 600) {
  92. var o2 = a3 - e4 + 1, s2 = r3 - e4 + 1, l2 = Math.log(o2), f2 = 0.5 * Math.exp(2 * l2 / 3), u2 = 0.5 * Math.sqrt(l2 * f2 * (o2 - f2) / o2) * (s2 - o2 / 2 < 0 ? -1 : 1), m2 = Math.max(e4, Math.floor(r3 - s2 * f2 / o2 + u2)), c2 = Math.min(a3, Math.floor(r3 + (o2 - s2) * f2 / o2 + u2));
  93. t3(n2, r3, m2, c2, h3);
  94. }
  95. var p2 = n2[r3], d2 = e4, x2 = a3;
  96. for (i(n2, e4, r3), h3(n2[a3], p2) > 0 && i(n2, e4, a3); d2 < x2; ) {
  97. for (i(n2, d2, x2), d2++, x2--; h3(n2[d2], p2) < 0; )
  98. d2++;
  99. for (; h3(n2[x2], p2) > 0; )
  100. x2--;
  101. }
  102. 0 === h3(n2[e4], p2) ? i(n2, e4, x2) : i(n2, ++x2, a3), x2 <= r3 && (e4 = x2 + 1), r3 <= x2 && (a3 = x2 - 1);
  103. }
  104. }(t2, r2, e3 || 0, a2 || t2.length - 1, h2 || n);
  105. }
  106. function i(t2, i2, n2) {
  107. var r2 = t2[i2];
  108. t2[i2] = t2[n2], t2[n2] = r2;
  109. }
  110. function n(t2, i2) {
  111. return t2 < i2 ? -1 : t2 > i2 ? 1 : 0;
  112. }
  113. var r = function(t2) {
  114. void 0 === t2 && (t2 = 9), this._maxEntries = Math.max(4, t2), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
  115. };
  116. function e(t2, i2, n2) {
  117. if (!n2)
  118. return i2.indexOf(t2);
  119. for (var r2 = 0; r2 < i2.length; r2++)
  120. if (n2(t2, i2[r2]))
  121. return r2;
  122. return -1;
  123. }
  124. function a(t2, i2) {
  125. h(t2, 0, t2.children.length, i2, t2);
  126. }
  127. function h(t2, i2, n2, r2, e3) {
  128. e3 || (e3 = p(null)), e3.minX = 1 / 0, e3.minY = 1 / 0, e3.maxX = -1 / 0, e3.maxY = -1 / 0;
  129. for (var a2 = i2; a2 < n2; a2++) {
  130. var h2 = t2.children[a2];
  131. o(e3, t2.leaf ? r2(h2) : h2);
  132. }
  133. return e3;
  134. }
  135. function o(t2, i2) {
  136. return t2.minX = Math.min(t2.minX, i2.minX), t2.minY = Math.min(t2.minY, i2.minY), t2.maxX = Math.max(t2.maxX, i2.maxX), t2.maxY = Math.max(t2.maxY, i2.maxY), t2;
  137. }
  138. function s(t2, i2) {
  139. return t2.minX - i2.minX;
  140. }
  141. function l(t2, i2) {
  142. return t2.minY - i2.minY;
  143. }
  144. function f(t2) {
  145. return (t2.maxX - t2.minX) * (t2.maxY - t2.minY);
  146. }
  147. function u(t2) {
  148. return t2.maxX - t2.minX + (t2.maxY - t2.minY);
  149. }
  150. function m(t2, i2) {
  151. return t2.minX <= i2.minX && t2.minY <= i2.minY && i2.maxX <= t2.maxX && i2.maxY <= t2.maxY;
  152. }
  153. function c(t2, i2) {
  154. return i2.minX <= t2.maxX && i2.minY <= t2.maxY && i2.maxX >= t2.minX && i2.maxY >= t2.minY;
  155. }
  156. function p(t2) {
  157. return { children: t2, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
  158. }
  159. function d(i2, n2, r2, e3, a2) {
  160. for (var h2 = [n2, r2]; h2.length; )
  161. if (!((r2 = h2.pop()) - (n2 = h2.pop()) <= e3)) {
  162. var o2 = n2 + Math.ceil((r2 - n2) / e3 / 2) * e3;
  163. t(i2, o2, n2, r2, a2), h2.push(n2, o2, o2, r2);
  164. }
  165. }
  166. return r.prototype.all = function() {
  167. return this._all(this.data, []);
  168. }, r.prototype.search = function(t2) {
  169. var i2 = this.data, n2 = [];
  170. if (!c(t2, i2))
  171. return n2;
  172. for (var r2 = this.toBBox, e3 = []; i2; ) {
  173. for (var a2 = 0; a2 < i2.children.length; a2++) {
  174. var h2 = i2.children[a2], o2 = i2.leaf ? r2(h2) : h2;
  175. c(t2, o2) && (i2.leaf ? n2.push(h2) : m(t2, o2) ? this._all(h2, n2) : e3.push(h2));
  176. }
  177. i2 = e3.pop();
  178. }
  179. return n2;
  180. }, r.prototype.collides = function(t2) {
  181. var i2 = this.data;
  182. if (!c(t2, i2))
  183. return false;
  184. for (var n2 = []; i2; ) {
  185. for (var r2 = 0; r2 < i2.children.length; r2++) {
  186. var e3 = i2.children[r2], a2 = i2.leaf ? this.toBBox(e3) : e3;
  187. if (c(t2, a2)) {
  188. if (i2.leaf || m(t2, a2))
  189. return true;
  190. n2.push(e3);
  191. }
  192. }
  193. i2 = n2.pop();
  194. }
  195. return false;
  196. }, r.prototype.load = function(t2) {
  197. if (!t2 || !t2.length)
  198. return this;
  199. if (t2.length < this._minEntries) {
  200. for (var i2 = 0; i2 < t2.length; i2++)
  201. this.insert(t2[i2]);
  202. return this;
  203. }
  204. var n2 = this._build(t2.slice(), 0, t2.length - 1, 0);
  205. if (this.data.children.length)
  206. if (this.data.height === n2.height)
  207. this._splitRoot(this.data, n2);
  208. else {
  209. if (this.data.height < n2.height) {
  210. var r2 = this.data;
  211. this.data = n2, n2 = r2;
  212. }
  213. this._insert(n2, this.data.height - n2.height - 1, true);
  214. }
  215. else
  216. this.data = n2;
  217. return this;
  218. }, r.prototype.insert = function(t2) {
  219. return t2 && this._insert(t2, this.data.height - 1), this;
  220. }, r.prototype.clear = function() {
  221. return this.data = p([]), this;
  222. }, r.prototype.remove = function(t2, i2) {
  223. if (!t2)
  224. return this;
  225. for (var n2, r2, a2, h2 = this.data, o2 = this.toBBox(t2), s2 = [], l2 = []; h2 || s2.length; ) {
  226. if (h2 || (h2 = s2.pop(), r2 = s2[s2.length - 1], n2 = l2.pop(), a2 = true), h2.leaf) {
  227. var f2 = e(t2, h2.children, i2);
  228. if (-1 !== f2)
  229. return h2.children.splice(f2, 1), s2.push(h2), this._condense(s2), this;
  230. }
  231. a2 || h2.leaf || !m(h2, o2) ? r2 ? (n2++, h2 = r2.children[n2], a2 = false) : h2 = null : (s2.push(h2), l2.push(n2), n2 = 0, r2 = h2, h2 = h2.children[0]);
  232. }
  233. return this;
  234. }, r.prototype.toBBox = function(t2) {
  235. return t2;
  236. }, r.prototype.compareMinX = function(t2, i2) {
  237. return t2.minX - i2.minX;
  238. }, r.prototype.compareMinY = function(t2, i2) {
  239. return t2.minY - i2.minY;
  240. }, r.prototype.toJSON = function() {
  241. return this.data;
  242. }, r.prototype.fromJSON = function(t2) {
  243. return this.data = t2, this;
  244. }, r.prototype._all = function(t2, i2) {
  245. for (var n2 = []; t2; )
  246. t2.leaf ? i2.push.apply(i2, t2.children) : n2.push.apply(n2, t2.children), t2 = n2.pop();
  247. return i2;
  248. }, r.prototype._build = function(t2, i2, n2, r2) {
  249. var e3, h2 = n2 - i2 + 1, o2 = this._maxEntries;
  250. if (h2 <= o2)
  251. return a(e3 = p(t2.slice(i2, n2 + 1)), this.toBBox), e3;
  252. r2 || (r2 = Math.ceil(Math.log(h2) / Math.log(o2)), o2 = Math.ceil(h2 / Math.pow(o2, r2 - 1))), (e3 = p([])).leaf = false, e3.height = r2;
  253. var s2 = Math.ceil(h2 / o2), l2 = s2 * Math.ceil(Math.sqrt(o2));
  254. d(t2, i2, n2, l2, this.compareMinX);
  255. for (var f2 = i2; f2 <= n2; f2 += l2) {
  256. var u2 = Math.min(f2 + l2 - 1, n2);
  257. d(t2, f2, u2, s2, this.compareMinY);
  258. for (var m2 = f2; m2 <= u2; m2 += s2) {
  259. var c2 = Math.min(m2 + s2 - 1, u2);
  260. e3.children.push(this._build(t2, m2, c2, r2 - 1));
  261. }
  262. }
  263. return a(e3, this.toBBox), e3;
  264. }, r.prototype._chooseSubtree = function(t2, i2, n2, r2) {
  265. for (; r2.push(i2), !i2.leaf && r2.length - 1 !== n2; ) {
  266. for (var e3 = 1 / 0, a2 = 1 / 0, h2 = void 0, o2 = 0; o2 < i2.children.length; o2++) {
  267. var s2 = i2.children[o2], l2 = f(s2), u2 = (m2 = t2, c2 = s2, (Math.max(c2.maxX, m2.maxX) - Math.min(c2.minX, m2.minX)) * (Math.max(c2.maxY, m2.maxY) - Math.min(c2.minY, m2.minY)) - l2);
  268. u2 < a2 ? (a2 = u2, e3 = l2 < e3 ? l2 : e3, h2 = s2) : u2 === a2 && l2 < e3 && (e3 = l2, h2 = s2);
  269. }
  270. i2 = h2 || i2.children[0];
  271. }
  272. var m2, c2;
  273. return i2;
  274. }, r.prototype._insert = function(t2, i2, n2) {
  275. var r2 = n2 ? t2 : this.toBBox(t2), e3 = [], a2 = this._chooseSubtree(r2, this.data, i2, e3);
  276. for (a2.children.push(t2), o(a2, r2); i2 >= 0 && e3[i2].children.length > this._maxEntries; )
  277. this._split(e3, i2), i2--;
  278. this._adjustParentBBoxes(r2, e3, i2);
  279. }, r.prototype._split = function(t2, i2) {
  280. var n2 = t2[i2], r2 = n2.children.length, e3 = this._minEntries;
  281. this._chooseSplitAxis(n2, e3, r2);
  282. var h2 = this._chooseSplitIndex(n2, e3, r2), o2 = p(n2.children.splice(h2, n2.children.length - h2));
  283. o2.height = n2.height, o2.leaf = n2.leaf, a(n2, this.toBBox), a(o2, this.toBBox), i2 ? t2[i2 - 1].children.push(o2) : this._splitRoot(n2, o2);
  284. }, r.prototype._splitRoot = function(t2, i2) {
  285. this.data = p([t2, i2]), this.data.height = t2.height + 1, this.data.leaf = false, a(this.data, this.toBBox);
  286. }, r.prototype._chooseSplitIndex = function(t2, i2, n2) {
  287. for (var r2, e3, a2, o2, s2, l2, u2, m2 = 1 / 0, c2 = 1 / 0, p2 = i2; p2 <= n2 - i2; p2++) {
  288. var d2 = h(t2, 0, p2, this.toBBox), x2 = h(t2, p2, n2, this.toBBox), v = (e3 = d2, a2 = x2, o2 = void 0, s2 = void 0, l2 = void 0, u2 = void 0, o2 = Math.max(e3.minX, a2.minX), s2 = Math.max(e3.minY, a2.minY), l2 = Math.min(e3.maxX, a2.maxX), u2 = Math.min(e3.maxY, a2.maxY), Math.max(0, l2 - o2) * Math.max(0, u2 - s2)), M = f(d2) + f(x2);
  289. v < m2 ? (m2 = v, r2 = p2, c2 = M < c2 ? M : c2) : v === m2 && M < c2 && (c2 = M, r2 = p2);
  290. }
  291. return r2 || n2 - i2;
  292. }, r.prototype._chooseSplitAxis = function(t2, i2, n2) {
  293. var r2 = t2.leaf ? this.compareMinX : s, e3 = t2.leaf ? this.compareMinY : l;
  294. this._allDistMargin(t2, i2, n2, r2) < this._allDistMargin(t2, i2, n2, e3) && t2.children.sort(r2);
  295. }, r.prototype._allDistMargin = function(t2, i2, n2, r2) {
  296. t2.children.sort(r2);
  297. for (var e3 = this.toBBox, a2 = h(t2, 0, i2, e3), s2 = h(t2, n2 - i2, n2, e3), l2 = u(a2) + u(s2), f2 = i2; f2 < n2 - i2; f2++) {
  298. var m2 = t2.children[f2];
  299. o(a2, t2.leaf ? e3(m2) : m2), l2 += u(a2);
  300. }
  301. for (var c2 = n2 - i2 - 1; c2 >= i2; c2--) {
  302. var p2 = t2.children[c2];
  303. o(s2, t2.leaf ? e3(p2) : p2), l2 += u(s2);
  304. }
  305. return l2;
  306. }, r.prototype._adjustParentBBoxes = function(t2, i2, n2) {
  307. for (var r2 = n2; r2 >= 0; r2--)
  308. o(i2[r2], t2);
  309. }, r.prototype._condense = function(t2) {
  310. for (var i2 = t2.length - 1, n2 = void 0; i2 >= 0; i2--)
  311. 0 === t2[i2].children.length ? i2 > 0 ? (n2 = t2[i2 - 1].children).splice(n2.indexOf(t2[i2]), 1) : this.clear() : a(t2[i2], this.toBBox);
  312. }, r;
  313. });
  314. }
  315. });
  316. // node_modules/tinyqueue/index.js
  317. var tinyqueue_exports = {};
  318. __export(tinyqueue_exports, {
  319. default: () => TinyQueue
  320. });
  321. function defaultCompare(a, b) {
  322. return a < b ? -1 : a > b ? 1 : 0;
  323. }
  324. var TinyQueue;
  325. var init_tinyqueue = __esm({
  326. "node_modules/tinyqueue/index.js"() {
  327. TinyQueue = class {
  328. constructor(data = [], compare10 = defaultCompare) {
  329. this.data = data;
  330. this.length = this.data.length;
  331. this.compare = compare10;
  332. if (this.length > 0) {
  333. for (let i = (this.length >> 1) - 1; i >= 0; i--)
  334. this._down(i);
  335. }
  336. }
  337. push(item) {
  338. this.data.push(item);
  339. this.length++;
  340. this._up(this.length - 1);
  341. }
  342. pop() {
  343. if (this.length === 0)
  344. return void 0;
  345. const top = this.data[0];
  346. const bottom = this.data.pop();
  347. this.length--;
  348. if (this.length > 0) {
  349. this.data[0] = bottom;
  350. this._down(0);
  351. }
  352. return top;
  353. }
  354. peek() {
  355. return this.data[0];
  356. }
  357. _up(pos) {
  358. const { data, compare: compare10 } = this;
  359. const item = data[pos];
  360. while (pos > 0) {
  361. const parent = pos - 1 >> 1;
  362. const current = data[parent];
  363. if (compare10(item, current) >= 0)
  364. break;
  365. data[pos] = current;
  366. pos = parent;
  367. }
  368. data[pos] = item;
  369. }
  370. _down(pos) {
  371. const { data, compare: compare10 } = this;
  372. const halfLength = this.length >> 1;
  373. const item = data[pos];
  374. while (pos < halfLength) {
  375. let left = (pos << 1) + 1;
  376. let best = data[left];
  377. const right = left + 1;
  378. if (right < this.length && compare10(data[right], best) < 0) {
  379. left = right;
  380. best = data[right];
  381. }
  382. if (compare10(best, item) >= 0)
  383. break;
  384. data[pos] = best;
  385. pos = left;
  386. }
  387. data[pos] = item;
  388. }
  389. };
  390. }
  391. });
  392. // node_modules/point-in-polygon/flat.js
  393. var require_flat = __commonJS({
  394. "node_modules/point-in-polygon/flat.js"(exports, module) {
  395. module.exports = function pointInPolygonFlat(point4, vs, start, end) {
  396. var x2 = point4[0], y2 = point4[1];
  397. var inside = false;
  398. if (start === void 0)
  399. start = 0;
  400. if (end === void 0)
  401. end = vs.length;
  402. var len = (end - start) / 2;
  403. for (var i = 0, j = len - 1; i < len; j = i++) {
  404. var xi = vs[start + i * 2 + 0], yi = vs[start + i * 2 + 1];
  405. var xj = vs[start + j * 2 + 0], yj = vs[start + j * 2 + 1];
  406. var intersect4 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
  407. if (intersect4)
  408. inside = !inside;
  409. }
  410. return inside;
  411. };
  412. }
  413. });
  414. // node_modules/point-in-polygon/nested.js
  415. var require_nested = __commonJS({
  416. "node_modules/point-in-polygon/nested.js"(exports, module) {
  417. module.exports = function pointInPolygonNested(point4, vs, start, end) {
  418. var x2 = point4[0], y2 = point4[1];
  419. var inside = false;
  420. if (start === void 0)
  421. start = 0;
  422. if (end === void 0)
  423. end = vs.length;
  424. var len = end - start;
  425. for (var i = 0, j = len - 1; i < len; j = i++) {
  426. var xi = vs[i + start][0], yi = vs[i + start][1];
  427. var xj = vs[j + start][0], yj = vs[j + start][1];
  428. var intersect4 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
  429. if (intersect4)
  430. inside = !inside;
  431. }
  432. return inside;
  433. };
  434. }
  435. });
  436. // node_modules/point-in-polygon/index.js
  437. var require_point_in_polygon = __commonJS({
  438. "node_modules/point-in-polygon/index.js"(exports, module) {
  439. var pointInPolygonFlat = require_flat();
  440. var pointInPolygonNested = require_nested();
  441. module.exports = function pointInPolygon(point4, vs, start, end) {
  442. if (vs.length > 0 && Array.isArray(vs[0])) {
  443. return pointInPolygonNested(point4, vs, start, end);
  444. } else {
  445. return pointInPolygonFlat(point4, vs, start, end);
  446. }
  447. };
  448. module.exports.nested = pointInPolygonNested;
  449. module.exports.flat = pointInPolygonFlat;
  450. }
  451. });
  452. // node_modules/robust-predicates/umd/orient2d.min.js
  453. var require_orient2d_min = __commonJS({
  454. "node_modules/robust-predicates/umd/orient2d.min.js"(exports, module) {
  455. !function(t, e) {
  456. "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e((t = t || self).predicates = {});
  457. }(exports, function(t) {
  458. "use strict";
  459. const e = 134217729, n = 33306690738754706e-32;
  460. function r(t2, e3, n2, r2, o2) {
  461. let f2, i2, u2, c2, s2 = e3[0], a2 = r2[0], d2 = 0, l2 = 0;
  462. a2 > s2 == a2 > -s2 ? (f2 = s2, s2 = e3[++d2]) : (f2 = a2, a2 = r2[++l2]);
  463. let p = 0;
  464. if (d2 < t2 && l2 < n2)
  465. for (a2 > s2 == a2 > -s2 ? (u2 = f2 - ((i2 = s2 + f2) - s2), s2 = e3[++d2]) : (u2 = f2 - ((i2 = a2 + f2) - a2), a2 = r2[++l2]), f2 = i2, 0 !== u2 && (o2[p++] = u2); d2 < t2 && l2 < n2; )
  466. a2 > s2 == a2 > -s2 ? (u2 = f2 - ((i2 = f2 + s2) - (c2 = i2 - f2)) + (s2 - c2), s2 = e3[++d2]) : (u2 = f2 - ((i2 = f2 + a2) - (c2 = i2 - f2)) + (a2 - c2), a2 = r2[++l2]), f2 = i2, 0 !== u2 && (o2[p++] = u2);
  467. for (; d2 < t2; )
  468. u2 = f2 - ((i2 = f2 + s2) - (c2 = i2 - f2)) + (s2 - c2), s2 = e3[++d2], f2 = i2, 0 !== u2 && (o2[p++] = u2);
  469. for (; l2 < n2; )
  470. u2 = f2 - ((i2 = f2 + a2) - (c2 = i2 - f2)) + (a2 - c2), a2 = r2[++l2], f2 = i2, 0 !== u2 && (o2[p++] = u2);
  471. return 0 === f2 && 0 !== p || (o2[p++] = f2), p;
  472. }
  473. function o(t2) {
  474. return new Float64Array(t2);
  475. }
  476. const f = 33306690738754716e-32, i = 22204460492503146e-32, u = 11093356479670487e-47, c = o(4), s = o(8), a = o(12), d = o(16), l = o(4);
  477. t.orient2d = function(t2, o2, p, b, y2, h) {
  478. const M = (o2 - h) * (p - y2), x2 = (t2 - y2) * (b - h), j = M - x2;
  479. if (0 === M || 0 === x2 || M > 0 != x2 > 0)
  480. return j;
  481. const m = Math.abs(M + x2);
  482. return Math.abs(j) >= f * m ? j : -function(t3, o3, f2, p2, b2, y3, h2) {
  483. let M2, x3, j2, m2, _, v, w, A, F, O, P, g, k, q, z, B2, C, D;
  484. const E = t3 - b2, G = f2 - b2, H = o3 - y3, I = p2 - y3;
  485. _ = (z = (A = E - (w = (v = e * E) - (v - E))) * (O = I - (F = (v = e * I) - (v - I))) - ((q = E * I) - w * F - A * F - w * O)) - (P = z - (C = (A = H - (w = (v = e * H) - (v - H))) * (O = G - (F = (v = e * G) - (v - G))) - ((B2 = H * G) - w * F - A * F - w * O))), c[0] = z - (P + _) + (_ - C), _ = (k = q - ((g = q + P) - (_ = g - q)) + (P - _)) - (P = k - B2), c[1] = k - (P + _) + (_ - B2), _ = (D = g + P) - g, c[2] = g - (D - _) + (P - _), c[3] = D;
  486. let J = function(t4, e3) {
  487. let n2 = e3[0];
  488. for (let r2 = 1; r2 < t4; r2++)
  489. n2 += e3[r2];
  490. return n2;
  491. }(4, c), K = i * h2;
  492. if (J >= K || -J >= K)
  493. return J;
  494. if (M2 = t3 - (E + (_ = t3 - E)) + (_ - b2), j2 = f2 - (G + (_ = f2 - G)) + (_ - b2), x3 = o3 - (H + (_ = o3 - H)) + (_ - y3), m2 = p2 - (I + (_ = p2 - I)) + (_ - y3), 0 === M2 && 0 === x3 && 0 === j2 && 0 === m2)
  495. return J;
  496. if (K = u * h2 + n * Math.abs(J), (J += E * m2 + I * M2 - (H * j2 + G * x3)) >= K || -J >= K)
  497. return J;
  498. _ = (z = (A = M2 - (w = (v = e * M2) - (v - M2))) * (O = I - (F = (v = e * I) - (v - I))) - ((q = M2 * I) - w * F - A * F - w * O)) - (P = z - (C = (A = x3 - (w = (v = e * x3) - (v - x3))) * (O = G - (F = (v = e * G) - (v - G))) - ((B2 = x3 * G) - w * F - A * F - w * O))), l[0] = z - (P + _) + (_ - C), _ = (k = q - ((g = q + P) - (_ = g - q)) + (P - _)) - (P = k - B2), l[1] = k - (P + _) + (_ - B2), _ = (D = g + P) - g, l[2] = g - (D - _) + (P - _), l[3] = D;
  499. const L = r(4, c, 4, l, s);
  500. _ = (z = (A = E - (w = (v = e * E) - (v - E))) * (O = m2 - (F = (v = e * m2) - (v - m2))) - ((q = E * m2) - w * F - A * F - w * O)) - (P = z - (C = (A = H - (w = (v = e * H) - (v - H))) * (O = j2 - (F = (v = e * j2) - (v - j2))) - ((B2 = H * j2) - w * F - A * F - w * O))), l[0] = z - (P + _) + (_ - C), _ = (k = q - ((g = q + P) - (_ = g - q)) + (P - _)) - (P = k - B2), l[1] = k - (P + _) + (_ - B2), _ = (D = g + P) - g, l[2] = g - (D - _) + (P - _), l[3] = D;
  501. const N = r(L, s, 4, l, a);
  502. _ = (z = (A = M2 - (w = (v = e * M2) - (v - M2))) * (O = m2 - (F = (v = e * m2) - (v - m2))) - ((q = M2 * m2) - w * F - A * F - w * O)) - (P = z - (C = (A = x3 - (w = (v = e * x3) - (v - x3))) * (O = j2 - (F = (v = e * j2) - (v - j2))) - ((B2 = x3 * j2) - w * F - A * F - w * O))), l[0] = z - (P + _) + (_ - C), _ = (k = q - ((g = q + P) - (_ = g - q)) + (P - _)) - (P = k - B2), l[1] = k - (P + _) + (_ - B2), _ = (D = g + P) - g, l[2] = g - (D - _) + (P - _), l[3] = D;
  503. const Q = r(N, a, 4, l, d);
  504. return d[Q - 1];
  505. }(t2, o2, p, b, y2, h, m);
  506. }, t.orient2dfast = function(t2, e3, n2, r2, o2, f2) {
  507. return (e3 - f2) * (n2 - o2) - (t2 - o2) * (r2 - f2);
  508. }, Object.defineProperty(t, "__esModule", { value: true });
  509. });
  510. }
  511. });
  512. // node_modules/concaveman/index.js
  513. var require_concaveman = __commonJS({
  514. "node_modules/concaveman/index.js"(exports, module) {
  515. "use strict";
  516. var RBush = require_rbush_min();
  517. var Queue = (init_tinyqueue(), __toCommonJS(tinyqueue_exports));
  518. var pointInPolygon = require_point_in_polygon();
  519. var orient = require_orient2d_min().orient2d;
  520. if (Queue.default) {
  521. Queue = Queue.default;
  522. }
  523. module.exports = concaveman2;
  524. module.exports.default = concaveman2;
  525. function concaveman2(points2, concavity, lengthThreshold) {
  526. concavity = Math.max(0, concavity === void 0 ? 2 : concavity);
  527. lengthThreshold = lengthThreshold || 0;
  528. var hull = fastConvexHull(points2);
  529. var tree = new RBush(16);
  530. tree.toBBox = function(a2) {
  531. return {
  532. minX: a2[0],
  533. minY: a2[1],
  534. maxX: a2[0],
  535. maxY: a2[1]
  536. };
  537. };
  538. tree.compareMinX = function(a2, b2) {
  539. return a2[0] - b2[0];
  540. };
  541. tree.compareMinY = function(a2, b2) {
  542. return a2[1] - b2[1];
  543. };
  544. tree.load(points2);
  545. var queue = [];
  546. for (var i = 0, last; i < hull.length; i++) {
  547. var p = hull[i];
  548. tree.remove(p);
  549. last = insertNode(p, last);
  550. queue.push(last);
  551. }
  552. var segTree = new RBush(16);
  553. for (i = 0; i < queue.length; i++)
  554. segTree.insert(updateBBox(queue[i]));
  555. var sqConcavity = concavity * concavity;
  556. var sqLenThreshold = lengthThreshold * lengthThreshold;
  557. while (queue.length) {
  558. var node = queue.shift();
  559. var a = node.p;
  560. var b = node.next.p;
  561. var sqLen = getSqDist2(a, b);
  562. if (sqLen < sqLenThreshold)
  563. continue;
  564. var maxSqLen = sqLen / sqConcavity;
  565. p = findCandidate(tree, node.prev.p, a, b, node.next.next.p, maxSqLen, segTree);
  566. if (p && Math.min(getSqDist2(p, a), getSqDist2(p, b)) <= maxSqLen) {
  567. queue.push(node);
  568. queue.push(insertNode(p, node));
  569. tree.remove(p);
  570. segTree.remove(node);
  571. segTree.insert(updateBBox(node));
  572. segTree.insert(updateBBox(node.next));
  573. }
  574. }
  575. node = last;
  576. var concave2 = [];
  577. do {
  578. concave2.push(node.p);
  579. node = node.next;
  580. } while (node !== last);
  581. concave2.push(node.p);
  582. return concave2;
  583. }
  584. function findCandidate(tree, a, b, c, d, maxDist, segTree) {
  585. var queue = new Queue([], compareDist);
  586. var node = tree.data;
  587. while (node) {
  588. for (var i = 0; i < node.children.length; i++) {
  589. var child = node.children[i];
  590. var dist = node.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child);
  591. if (dist > maxDist)
  592. continue;
  593. queue.push({
  594. node: child,
  595. dist
  596. });
  597. }
  598. while (queue.length && !queue.peek().node.children) {
  599. var item = queue.pop();
  600. var p = item.node;
  601. var d0 = sqSegDist(p, a, b);
  602. var d1 = sqSegDist(p, c, d);
  603. if (item.dist < d0 && item.dist < d1 && noIntersections(b, p, segTree) && noIntersections(c, p, segTree))
  604. return p;
  605. }
  606. node = queue.pop();
  607. if (node)
  608. node = node.node;
  609. }
  610. return null;
  611. }
  612. function compareDist(a, b) {
  613. return a.dist - b.dist;
  614. }
  615. function sqSegBoxDist(a, b, bbox3) {
  616. if (inside(a, bbox3) || inside(b, bbox3))
  617. return 0;
  618. var d1 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox3.minX, bbox3.minY, bbox3.maxX, bbox3.minY);
  619. if (d1 === 0)
  620. return 0;
  621. var d2 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox3.minX, bbox3.minY, bbox3.minX, bbox3.maxY);
  622. if (d2 === 0)
  623. return 0;
  624. var d3 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox3.maxX, bbox3.minY, bbox3.maxX, bbox3.maxY);
  625. if (d3 === 0)
  626. return 0;
  627. var d4 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox3.minX, bbox3.maxY, bbox3.maxX, bbox3.maxY);
  628. if (d4 === 0)
  629. return 0;
  630. return Math.min(d1, d2, d3, d4);
  631. }
  632. function inside(a, bbox3) {
  633. return a[0] >= bbox3.minX && a[0] <= bbox3.maxX && a[1] >= bbox3.minY && a[1] <= bbox3.maxY;
  634. }
  635. function noIntersections(a, b, segTree) {
  636. var minX2 = Math.min(a[0], b[0]);
  637. var minY2 = Math.min(a[1], b[1]);
  638. var maxX2 = Math.max(a[0], b[0]);
  639. var maxY2 = Math.max(a[1], b[1]);
  640. var edges2 = segTree.search({ minX: minX2, minY: minY2, maxX: maxX2, maxY: maxY2 });
  641. for (var i = 0; i < edges2.length; i++) {
  642. if (intersects7(edges2[i].p, edges2[i].next.p, a, b))
  643. return false;
  644. }
  645. return true;
  646. }
  647. function cross(p1, p2, p3) {
  648. return orient(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
  649. }
  650. function intersects7(p1, q1, p2, q2) {
  651. return p1 !== q2 && q1 !== p2 && cross(p1, q1, p2) > 0 !== cross(p1, q1, q2) > 0 && cross(p2, q2, p1) > 0 !== cross(p2, q2, q1) > 0;
  652. }
  653. function updateBBox(node) {
  654. var p1 = node.p;
  655. var p2 = node.next.p;
  656. node.minX = Math.min(p1[0], p2[0]);
  657. node.minY = Math.min(p1[1], p2[1]);
  658. node.maxX = Math.max(p1[0], p2[0]);
  659. node.maxY = Math.max(p1[1], p2[1]);
  660. return node;
  661. }
  662. function fastConvexHull(points2) {
  663. var left = points2[0];
  664. var top = points2[0];
  665. var right = points2[0];
  666. var bottom = points2[0];
  667. for (var i = 0; i < points2.length; i++) {
  668. var p = points2[i];
  669. if (p[0] < left[0])
  670. left = p;
  671. if (p[0] > right[0])
  672. right = p;
  673. if (p[1] < top[1])
  674. top = p;
  675. if (p[1] > bottom[1])
  676. bottom = p;
  677. }
  678. var cull = [left, top, right, bottom];
  679. var filtered = cull.slice();
  680. for (i = 0; i < points2.length; i++) {
  681. if (!pointInPolygon(points2[i], cull))
  682. filtered.push(points2[i]);
  683. }
  684. return convexHull(filtered);
  685. }
  686. function insertNode(p, prev) {
  687. var node = {
  688. p,
  689. prev: null,
  690. next: null,
  691. minX: 0,
  692. minY: 0,
  693. maxX: 0,
  694. maxY: 0
  695. };
  696. if (!prev) {
  697. node.prev = node;
  698. node.next = node;
  699. } else {
  700. node.next = prev.next;
  701. node.prev = prev;
  702. prev.next.prev = node;
  703. prev.next = node;
  704. }
  705. return node;
  706. }
  707. function getSqDist2(p1, p2) {
  708. var dx = p1[0] - p2[0], dy = p1[1] - p2[1];
  709. return dx * dx + dy * dy;
  710. }
  711. function sqSegDist(p, p1, p2) {
  712. var x2 = p1[0], y2 = p1[1], dx = p2[0] - x2, dy = p2[1] - y2;
  713. if (dx !== 0 || dy !== 0) {
  714. var t = ((p[0] - x2) * dx + (p[1] - y2) * dy) / (dx * dx + dy * dy);
  715. if (t > 1) {
  716. x2 = p2[0];
  717. y2 = p2[1];
  718. } else if (t > 0) {
  719. x2 += dx * t;
  720. y2 += dy * t;
  721. }
  722. }
  723. dx = p[0] - x2;
  724. dy = p[1] - y2;
  725. return dx * dx + dy * dy;
  726. }
  727. function sqSegSegDist(x02, y02, x12, y12, x2, y2, x3, y3) {
  728. var ux = x12 - x02;
  729. var uy = y12 - y02;
  730. var vx = x3 - x2;
  731. var vy = y3 - y2;
  732. var wx = x02 - x2;
  733. var wy = y02 - y2;
  734. var a = ux * ux + uy * uy;
  735. var b = ux * vx + uy * vy;
  736. var c = vx * vx + vy * vy;
  737. var d = ux * wx + uy * wy;
  738. var e = vx * wx + vy * wy;
  739. var D = a * c - b * b;
  740. var sc, sN, tc, tN;
  741. var sD = D;
  742. var tD = D;
  743. if (D === 0) {
  744. sN = 0;
  745. sD = 1;
  746. tN = e;
  747. tD = c;
  748. } else {
  749. sN = b * e - c * d;
  750. tN = a * e - b * d;
  751. if (sN < 0) {
  752. sN = 0;
  753. tN = e;
  754. tD = c;
  755. } else if (sN > sD) {
  756. sN = sD;
  757. tN = e + b;
  758. tD = c;
  759. }
  760. }
  761. if (tN < 0) {
  762. tN = 0;
  763. if (-d < 0)
  764. sN = 0;
  765. else if (-d > a)
  766. sN = sD;
  767. else {
  768. sN = -d;
  769. sD = a;
  770. }
  771. } else if (tN > tD) {
  772. tN = tD;
  773. if (-d + b < 0)
  774. sN = 0;
  775. else if (-d + b > a)
  776. sN = sD;
  777. else {
  778. sN = -d + b;
  779. sD = a;
  780. }
  781. }
  782. sc = sN === 0 ? 0 : sN / sD;
  783. tc = tN === 0 ? 0 : tN / tD;
  784. var cx = (1 - sc) * x02 + sc * x12;
  785. var cy = (1 - sc) * y02 + sc * y12;
  786. var cx2 = (1 - tc) * x2 + tc * x3;
  787. var cy2 = (1 - tc) * y2 + tc * y3;
  788. var dx = cx2 - cx;
  789. var dy = cy2 - cy;
  790. return dx * dx + dy * dy;
  791. }
  792. function compareByX(a, b) {
  793. return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
  794. }
  795. function convexHull(points2) {
  796. points2.sort(compareByX);
  797. var lower = [];
  798. for (var i = 0; i < points2.length; i++) {
  799. while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], points2[i]) <= 0) {
  800. lower.pop();
  801. }
  802. lower.push(points2[i]);
  803. }
  804. var upper = [];
  805. for (var ii = points2.length - 1; ii >= 0; ii--) {
  806. while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], points2[ii]) <= 0) {
  807. upper.pop();
  808. }
  809. upper.push(points2[ii]);
  810. }
  811. upper.pop();
  812. lower.pop();
  813. return lower.concat(upper);
  814. }
  815. }
  816. });
  817. // node_modules/quickselect/quickselect.js
  818. var require_quickselect = __commonJS({
  819. "node_modules/quickselect/quickselect.js"(exports, module) {
  820. (function(global, factory) {
  821. typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.quickselect = factory();
  822. })(exports, function() {
  823. "use strict";
  824. function quickselect(arr, k, left, right, compare10) {
  825. quickselectStep(arr, k, left || 0, right || arr.length - 1, compare10 || defaultCompare2);
  826. }
  827. function quickselectStep(arr, k, left, right, compare10) {
  828. while (right > left) {
  829. if (right - left > 600) {
  830. var n = right - left + 1;
  831. var m = k - left + 1;
  832. var z = Math.log(n);
  833. var s = 0.5 * Math.exp(2 * z / 3);
  834. var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
  835. var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
  836. var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
  837. quickselectStep(arr, k, newLeft, newRight, compare10);
  838. }
  839. var t = arr[k];
  840. var i = left;
  841. var j = right;
  842. swap2(arr, left, k);
  843. if (compare10(arr[right], t) > 0)
  844. swap2(arr, left, right);
  845. while (i < j) {
  846. swap2(arr, i, j);
  847. i++;
  848. j--;
  849. while (compare10(arr[i], t) < 0)
  850. i++;
  851. while (compare10(arr[j], t) > 0)
  852. j--;
  853. }
  854. if (compare10(arr[left], t) === 0)
  855. swap2(arr, left, j);
  856. else {
  857. j++;
  858. swap2(arr, j, right);
  859. }
  860. if (j <= k)
  861. left = j + 1;
  862. if (k <= j)
  863. right = j - 1;
  864. }
  865. }
  866. function swap2(arr, i, j) {
  867. var tmp = arr[i];
  868. arr[i] = arr[j];
  869. arr[j] = tmp;
  870. }
  871. function defaultCompare2(a, b) {
  872. return a < b ? -1 : a > b ? 1 : 0;
  873. }
  874. return quickselect;
  875. });
  876. }
  877. });
  878. // node_modules/rbush/index.js
  879. var require_rbush = __commonJS({
  880. "node_modules/rbush/index.js"(exports, module) {
  881. "use strict";
  882. module.exports = rbush6;
  883. module.exports.default = rbush6;
  884. var quickselect = require_quickselect();
  885. function rbush6(maxEntries, format) {
  886. if (!(this instanceof rbush6))
  887. return new rbush6(maxEntries, format);
  888. this._maxEntries = Math.max(4, maxEntries || 9);
  889. this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
  890. if (format) {
  891. this._initFormat(format);
  892. }
  893. this.clear();
  894. }
  895. rbush6.prototype = {
  896. all: function() {
  897. return this._all(this.data, []);
  898. },
  899. search: function(bbox3) {
  900. var node = this.data, result = [], toBBox = this.toBBox;
  901. if (!intersects7(bbox3, node))
  902. return result;
  903. var nodesToSearch = [], i, len, child, childBBox;
  904. while (node) {
  905. for (i = 0, len = node.children.length; i < len; i++) {
  906. child = node.children[i];
  907. childBBox = node.leaf ? toBBox(child) : child;
  908. if (intersects7(bbox3, childBBox)) {
  909. if (node.leaf)
  910. result.push(child);
  911. else if (contains2(bbox3, childBBox))
  912. this._all(child, result);
  913. else
  914. nodesToSearch.push(child);
  915. }
  916. }
  917. node = nodesToSearch.pop();
  918. }
  919. return result;
  920. },
  921. collides: function(bbox3) {
  922. var node = this.data, toBBox = this.toBBox;
  923. if (!intersects7(bbox3, node))
  924. return false;
  925. var nodesToSearch = [], i, len, child, childBBox;
  926. while (node) {
  927. for (i = 0, len = node.children.length; i < len; i++) {
  928. child = node.children[i];
  929. childBBox = node.leaf ? toBBox(child) : child;
  930. if (intersects7(bbox3, childBBox)) {
  931. if (node.leaf || contains2(bbox3, childBBox))
  932. return true;
  933. nodesToSearch.push(child);
  934. }
  935. }
  936. node = nodesToSearch.pop();
  937. }
  938. return false;
  939. },
  940. load: function(data) {
  941. if (!(data && data.length))
  942. return this;
  943. if (data.length < this._minEntries) {
  944. for (var i = 0, len = data.length; i < len; i++) {
  945. this.insert(data[i]);
  946. }
  947. return this;
  948. }
  949. var node = this._build(data.slice(), 0, data.length - 1, 0);
  950. if (!this.data.children.length) {
  951. this.data = node;
  952. } else if (this.data.height === node.height) {
  953. this._splitRoot(this.data, node);
  954. } else {
  955. if (this.data.height < node.height) {
  956. var tmpNode = this.data;
  957. this.data = node;
  958. node = tmpNode;
  959. }
  960. this._insert(node, this.data.height - node.height - 1, true);
  961. }
  962. return this;
  963. },
  964. insert: function(item) {
  965. if (item)
  966. this._insert(item, this.data.height - 1);
  967. return this;
  968. },
  969. clear: function() {
  970. this.data = createNode2([]);
  971. return this;
  972. },
  973. remove: function(item, equalsFn) {
  974. if (!item)
  975. return this;
  976. var node = this.data, bbox3 = this.toBBox(item), path = [], indexes = [], i, parent, index2, goingUp;
  977. while (node || path.length) {
  978. if (!node) {
  979. node = path.pop();
  980. parent = path[path.length - 1];
  981. i = indexes.pop();
  982. goingUp = true;
  983. }
  984. if (node.leaf) {
  985. index2 = findItem(item, node.children, equalsFn);
  986. if (index2 !== -1) {
  987. node.children.splice(index2, 1);
  988. path.push(node);
  989. this._condense(path);
  990. return this;
  991. }
  992. }
  993. if (!goingUp && !node.leaf && contains2(node, bbox3)) {
  994. path.push(node);
  995. indexes.push(i);
  996. i = 0;
  997. parent = node;
  998. node = node.children[0];
  999. } else if (parent) {
  1000. i++;
  1001. node = parent.children[i];
  1002. goingUp = false;
  1003. } else
  1004. node = null;
  1005. }
  1006. return this;
  1007. },
  1008. toBBox: function(item) {
  1009. return item;
  1010. },
  1011. compareMinX: compareNodeMinX,
  1012. compareMinY: compareNodeMinY,
  1013. toJSON: function() {
  1014. return this.data;
  1015. },
  1016. fromJSON: function(data) {
  1017. this.data = data;
  1018. return this;
  1019. },
  1020. _all: function(node, result) {
  1021. var nodesToSearch = [];
  1022. while (node) {
  1023. if (node.leaf)
  1024. result.push.apply(result, node.children);
  1025. else
  1026. nodesToSearch.push.apply(nodesToSearch, node.children);
  1027. node = nodesToSearch.pop();
  1028. }
  1029. return result;
  1030. },
  1031. _build: function(items, left, right, height) {
  1032. var N = right - left + 1, M = this._maxEntries, node;
  1033. if (N <= M) {
  1034. node = createNode2(items.slice(left, right + 1));
  1035. calcBBox(node, this.toBBox);
  1036. return node;
  1037. }
  1038. if (!height) {
  1039. height = Math.ceil(Math.log(N) / Math.log(M));
  1040. M = Math.ceil(N / Math.pow(M, height - 1));
  1041. }
  1042. node = createNode2([]);
  1043. node.leaf = false;
  1044. node.height = height;
  1045. var N2 = Math.ceil(N / M), N1 = N2 * Math.ceil(Math.sqrt(M)), i, j, right2, right3;
  1046. multiSelect(items, left, right, N1, this.compareMinX);
  1047. for (i = left; i <= right; i += N1) {
  1048. right2 = Math.min(i + N1 - 1, right);
  1049. multiSelect(items, i, right2, N2, this.compareMinY);
  1050. for (j = i; j <= right2; j += N2) {
  1051. right3 = Math.min(j + N2 - 1, right2);
  1052. node.children.push(this._build(items, j, right3, height - 1));
  1053. }
  1054. }
  1055. calcBBox(node, this.toBBox);
  1056. return node;
  1057. },
  1058. _chooseSubtree: function(bbox3, node, level, path) {
  1059. var i, len, child, targetNode, area5, enlargement, minArea, minEnlargement;
  1060. while (true) {
  1061. path.push(node);
  1062. if (node.leaf || path.length - 1 === level)
  1063. break;
  1064. minArea = minEnlargement = Infinity;
  1065. for (i = 0, len = node.children.length; i < len; i++) {
  1066. child = node.children[i];
  1067. area5 = bboxArea(child);
  1068. enlargement = enlargedArea(bbox3, child) - area5;
  1069. if (enlargement < minEnlargement) {
  1070. minEnlargement = enlargement;
  1071. minArea = area5 < minArea ? area5 : minArea;
  1072. targetNode = child;
  1073. } else if (enlargement === minEnlargement) {
  1074. if (area5 < minArea) {
  1075. minArea = area5;
  1076. targetNode = child;
  1077. }
  1078. }
  1079. }
  1080. node = targetNode || node.children[0];
  1081. }
  1082. return node;
  1083. },
  1084. _insert: function(item, level, isNode) {
  1085. var toBBox = this.toBBox, bbox3 = isNode ? item : toBBox(item), insertPath = [];
  1086. var node = this._chooseSubtree(bbox3, this.data, level, insertPath);
  1087. node.children.push(item);
  1088. extend2(node, bbox3);
  1089. while (level >= 0) {
  1090. if (insertPath[level].children.length > this._maxEntries) {
  1091. this._split(insertPath, level);
  1092. level--;
  1093. } else
  1094. break;
  1095. }
  1096. this._adjustParentBBoxes(bbox3, insertPath, level);
  1097. },
  1098. _split: function(insertPath, level) {
  1099. var node = insertPath[level], M = node.children.length, m = this._minEntries;
  1100. this._chooseSplitAxis(node, m, M);
  1101. var splitIndex = this._chooseSplitIndex(node, m, M);
  1102. var newNode = createNode2(node.children.splice(splitIndex, node.children.length - splitIndex));
  1103. newNode.height = node.height;
  1104. newNode.leaf = node.leaf;
  1105. calcBBox(node, this.toBBox);
  1106. calcBBox(newNode, this.toBBox);
  1107. if (level)
  1108. insertPath[level - 1].children.push(newNode);
  1109. else
  1110. this._splitRoot(node, newNode);
  1111. },
  1112. _splitRoot: function(node, newNode) {
  1113. this.data = createNode2([node, newNode]);
  1114. this.data.height = node.height + 1;
  1115. this.data.leaf = false;
  1116. calcBBox(this.data, this.toBBox);
  1117. },
  1118. _chooseSplitIndex: function(node, m, M) {
  1119. var i, bbox1, bbox22, overlap2, area5, minOverlap, minArea, index2;
  1120. minOverlap = minArea = Infinity;
  1121. for (i = m; i <= M - m; i++) {
  1122. bbox1 = distBBox(node, 0, i, this.toBBox);
  1123. bbox22 = distBBox(node, i, M, this.toBBox);
  1124. overlap2 = intersectionArea(bbox1, bbox22);
  1125. area5 = bboxArea(bbox1) + bboxArea(bbox22);
  1126. if (overlap2 < minOverlap) {
  1127. minOverlap = overlap2;
  1128. index2 = i;
  1129. minArea = area5 < minArea ? area5 : minArea;
  1130. } else if (overlap2 === minOverlap) {
  1131. if (area5 < minArea) {
  1132. minArea = area5;
  1133. index2 = i;
  1134. }
  1135. }
  1136. }
  1137. return index2;
  1138. },
  1139. _chooseSplitAxis: function(node, m, M) {
  1140. var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, xMargin = this._allDistMargin(node, m, M, compareMinX), yMargin = this._allDistMargin(node, m, M, compareMinY);
  1141. if (xMargin < yMargin)
  1142. node.children.sort(compareMinX);
  1143. },
  1144. _allDistMargin: function(node, m, M, compare10) {
  1145. node.children.sort(compare10);
  1146. var toBBox = this.toBBox, leftBBox = distBBox(node, 0, m, toBBox), rightBBox = distBBox(node, M - m, M, toBBox), margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), i, child;
  1147. for (i = m; i < M - m; i++) {
  1148. child = node.children[i];
  1149. extend2(leftBBox, node.leaf ? toBBox(child) : child);
  1150. margin += bboxMargin(leftBBox);
  1151. }
  1152. for (i = M - m - 1; i >= m; i--) {
  1153. child = node.children[i];
  1154. extend2(rightBBox, node.leaf ? toBBox(child) : child);
  1155. margin += bboxMargin(rightBBox);
  1156. }
  1157. return margin;
  1158. },
  1159. _adjustParentBBoxes: function(bbox3, path, level) {
  1160. for (var i = level; i >= 0; i--) {
  1161. extend2(path[i], bbox3);
  1162. }
  1163. },
  1164. _condense: function(path) {
  1165. for (var i = path.length - 1, siblings; i >= 0; i--) {
  1166. if (path[i].children.length === 0) {
  1167. if (i > 0) {
  1168. siblings = path[i - 1].children;
  1169. siblings.splice(siblings.indexOf(path[i]), 1);
  1170. } else
  1171. this.clear();
  1172. } else
  1173. calcBBox(path[i], this.toBBox);
  1174. }
  1175. },
  1176. _initFormat: function(format) {
  1177. var compareArr = ["return a", " - b", ";"];
  1178. this.compareMinX = new Function("a", "b", compareArr.join(format[0]));
  1179. this.compareMinY = new Function("a", "b", compareArr.join(format[1]));
  1180. this.toBBox = new Function(
  1181. "a",
  1182. "return {minX: a" + format[0] + ", minY: a" + format[1] + ", maxX: a" + format[2] + ", maxY: a" + format[3] + "};"
  1183. );
  1184. }
  1185. };
  1186. function findItem(item, items, equalsFn) {
  1187. if (!equalsFn)
  1188. return items.indexOf(item);
  1189. for (var i = 0; i < items.length; i++) {
  1190. if (equalsFn(item, items[i]))
  1191. return i;
  1192. }
  1193. return -1;
  1194. }
  1195. function calcBBox(node, toBBox) {
  1196. distBBox(node, 0, node.children.length, toBBox, node);
  1197. }
  1198. function distBBox(node, k, p, toBBox, destNode) {
  1199. if (!destNode)
  1200. destNode = createNode2(null);
  1201. destNode.minX = Infinity;
  1202. destNode.minY = Infinity;
  1203. destNode.maxX = -Infinity;
  1204. destNode.maxY = -Infinity;
  1205. for (var i = k, child; i < p; i++) {
  1206. child = node.children[i];
  1207. extend2(destNode, node.leaf ? toBBox(child) : child);
  1208. }
  1209. return destNode;
  1210. }
  1211. function extend2(a, b) {
  1212. a.minX = Math.min(a.minX, b.minX);
  1213. a.minY = Math.min(a.minY, b.minY);
  1214. a.maxX = Math.max(a.maxX, b.maxX);
  1215. a.maxY = Math.max(a.maxY, b.maxY);
  1216. return a;
  1217. }
  1218. function compareNodeMinX(a, b) {
  1219. return a.minX - b.minX;
  1220. }
  1221. function compareNodeMinY(a, b) {
  1222. return a.minY - b.minY;
  1223. }
  1224. function bboxArea(a) {
  1225. return (a.maxX - a.minX) * (a.maxY - a.minY);
  1226. }
  1227. function bboxMargin(a) {
  1228. return a.maxX - a.minX + (a.maxY - a.minY);
  1229. }
  1230. function enlargedArea(a, b) {
  1231. return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
  1232. }
  1233. function intersectionArea(a, b) {
  1234. var minX2 = Math.max(a.minX, b.minX), minY2 = Math.max(a.minY, b.minY), maxX2 = Math.min(a.maxX, b.maxX), maxY2 = Math.min(a.maxY, b.maxY);
  1235. return Math.max(0, maxX2 - minX2) * Math.max(0, maxY2 - minY2);
  1236. }
  1237. function contains2(a, b) {
  1238. return a.minX <= b.minX && a.minY <= b.minY && b.maxX <= a.maxX && b.maxY <= a.maxY;
  1239. }
  1240. function intersects7(a, b) {
  1241. return b.minX <= a.maxX && b.minY <= a.maxY && b.maxX >= a.minX && b.maxY >= a.minY;
  1242. }
  1243. function createNode2(children) {
  1244. return {
  1245. children,
  1246. height: 1,
  1247. leaf: true,
  1248. minX: Infinity,
  1249. minY: Infinity,
  1250. maxX: -Infinity,
  1251. maxY: -Infinity
  1252. };
  1253. }
  1254. function multiSelect(arr, left, right, n, compare10) {
  1255. var stack = [left, right], mid;
  1256. while (stack.length) {
  1257. right = stack.pop();
  1258. left = stack.pop();
  1259. if (right - left <= n)
  1260. continue;
  1261. mid = left + Math.ceil((right - left) / n / 2) * n;
  1262. quickselect(arr, mid, left, right, compare10);
  1263. stack.push(left, mid, mid, right);
  1264. }
  1265. }
  1266. }
  1267. });
  1268. // node_modules/geojson-rbush/node_modules/rbush/rbush.min.js
  1269. var require_rbush_min2 = __commonJS({
  1270. "node_modules/geojson-rbush/node_modules/rbush/rbush.min.js"(exports, module) {
  1271. !function(t, i) {
  1272. "object" == typeof exports && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : (t = t || self).RBush = i();
  1273. }(exports, function() {
  1274. "use strict";
  1275. function t(t2, r2, e3, a2, h2) {
  1276. !function t3(n2, r3, e4, a3, h3) {
  1277. for (; a3 > e4; ) {
  1278. if (a3 - e4 > 600) {
  1279. var o2 = a3 - e4 + 1, s2 = r3 - e4 + 1, l2 = Math.log(o2), f2 = 0.5 * Math.exp(2 * l2 / 3), u2 = 0.5 * Math.sqrt(l2 * f2 * (o2 - f2) / o2) * (s2 - o2 / 2 < 0 ? -1 : 1), m2 = Math.max(e4, Math.floor(r3 - s2 * f2 / o2 + u2)), c2 = Math.min(a3, Math.floor(r3 + (o2 - s2) * f2 / o2 + u2));
  1280. t3(n2, r3, m2, c2, h3);
  1281. }
  1282. var p2 = n2[r3], d2 = e4, x2 = a3;
  1283. for (i(n2, e4, r3), h3(n2[a3], p2) > 0 && i(n2, e4, a3); d2 < x2; ) {
  1284. for (i(n2, d2, x2), d2++, x2--; h3(n2[d2], p2) < 0; )
  1285. d2++;
  1286. for (; h3(n2[x2], p2) > 0; )
  1287. x2--;
  1288. }
  1289. 0 === h3(n2[e4], p2) ? i(n2, e4, x2) : i(n2, ++x2, a3), x2 <= r3 && (e4 = x2 + 1), r3 <= x2 && (a3 = x2 - 1);
  1290. }
  1291. }(t2, r2, e3 || 0, a2 || t2.length - 1, h2 || n);
  1292. }
  1293. function i(t2, i2, n2) {
  1294. var r2 = t2[i2];
  1295. t2[i2] = t2[n2], t2[n2] = r2;
  1296. }
  1297. function n(t2, i2) {
  1298. return t2 < i2 ? -1 : t2 > i2 ? 1 : 0;
  1299. }
  1300. var r = function(t2) {
  1301. void 0 === t2 && (t2 = 9), this._maxEntries = Math.max(4, t2), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
  1302. };
  1303. function e(t2, i2, n2) {
  1304. if (!n2)
  1305. return i2.indexOf(t2);
  1306. for (var r2 = 0; r2 < i2.length; r2++)
  1307. if (n2(t2, i2[r2]))
  1308. return r2;
  1309. return -1;
  1310. }
  1311. function a(t2, i2) {
  1312. h(t2, 0, t2.children.length, i2, t2);
  1313. }
  1314. function h(t2, i2, n2, r2, e3) {
  1315. e3 || (e3 = p(null)), e3.minX = 1 / 0, e3.minY = 1 / 0, e3.maxX = -1 / 0, e3.maxY = -1 / 0;
  1316. for (var a2 = i2; a2 < n2; a2++) {
  1317. var h2 = t2.children[a2];
  1318. o(e3, t2.leaf ? r2(h2) : h2);
  1319. }
  1320. return e3;
  1321. }
  1322. function o(t2, i2) {
  1323. return t2.minX = Math.min(t2.minX, i2.minX), t2.minY = Math.min(t2.minY, i2.minY), t2.maxX = Math.max(t2.maxX, i2.maxX), t2.maxY = Math.max(t2.maxY, i2.maxY), t2;
  1324. }
  1325. function s(t2, i2) {
  1326. return t2.minX - i2.minX;
  1327. }
  1328. function l(t2, i2) {
  1329. return t2.minY - i2.minY;
  1330. }
  1331. function f(t2) {
  1332. return (t2.maxX - t2.minX) * (t2.maxY - t2.minY);
  1333. }
  1334. function u(t2) {
  1335. return t2.maxX - t2.minX + (t2.maxY - t2.minY);
  1336. }
  1337. function m(t2, i2) {
  1338. return t2.minX <= i2.minX && t2.minY <= i2.minY && i2.maxX <= t2.maxX && i2.maxY <= t2.maxY;
  1339. }
  1340. function c(t2, i2) {
  1341. return i2.minX <= t2.maxX && i2.minY <= t2.maxY && i2.maxX >= t2.minX && i2.maxY >= t2.minY;
  1342. }
  1343. function p(t2) {
  1344. return { children: t2, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
  1345. }
  1346. function d(i2, n2, r2, e3, a2) {
  1347. for (var h2 = [n2, r2]; h2.length; )
  1348. if (!((r2 = h2.pop()) - (n2 = h2.pop()) <= e3)) {
  1349. var o2 = n2 + Math.ceil((r2 - n2) / e3 / 2) * e3;
  1350. t(i2, o2, n2, r2, a2), h2.push(n2, o2, o2, r2);
  1351. }
  1352. }
  1353. return r.prototype.all = function() {
  1354. return this._all(this.data, []);
  1355. }, r.prototype.search = function(t2) {
  1356. var i2 = this.data, n2 = [];
  1357. if (!c(t2, i2))
  1358. return n2;
  1359. for (var r2 = this.toBBox, e3 = []; i2; ) {
  1360. for (var a2 = 0; a2 < i2.children.length; a2++) {
  1361. var h2 = i2.children[a2], o2 = i2.leaf ? r2(h2) : h2;
  1362. c(t2, o2) && (i2.leaf ? n2.push(h2) : m(t2, o2) ? this._all(h2, n2) : e3.push(h2));
  1363. }
  1364. i2 = e3.pop();
  1365. }
  1366. return n2;
  1367. }, r.prototype.collides = function(t2) {
  1368. var i2 = this.data;
  1369. if (!c(t2, i2))
  1370. return false;
  1371. for (var n2 = []; i2; ) {
  1372. for (var r2 = 0; r2 < i2.children.length; r2++) {
  1373. var e3 = i2.children[r2], a2 = i2.leaf ? this.toBBox(e3) : e3;
  1374. if (c(t2, a2)) {
  1375. if (i2.leaf || m(t2, a2))
  1376. return true;
  1377. n2.push(e3);
  1378. }
  1379. }
  1380. i2 = n2.pop();
  1381. }
  1382. return false;
  1383. }, r.prototype.load = function(t2) {
  1384. if (!t2 || !t2.length)
  1385. return this;
  1386. if (t2.length < this._minEntries) {
  1387. for (var i2 = 0; i2 < t2.length; i2++)
  1388. this.insert(t2[i2]);
  1389. return this;
  1390. }
  1391. var n2 = this._build(t2.slice(), 0, t2.length - 1, 0);
  1392. if (this.data.children.length)
  1393. if (this.data.height === n2.height)
  1394. this._splitRoot(this.data, n2);
  1395. else {
  1396. if (this.data.height < n2.height) {
  1397. var r2 = this.data;
  1398. this.data = n2, n2 = r2;
  1399. }
  1400. this._insert(n2, this.data.height - n2.height - 1, true);
  1401. }
  1402. else
  1403. this.data = n2;
  1404. return this;
  1405. }, r.prototype.insert = function(t2) {
  1406. return t2 && this._insert(t2, this.data.height - 1), this;
  1407. }, r.prototype.clear = function() {
  1408. return this.data = p([]), this;
  1409. }, r.prototype.remove = function(t2, i2) {
  1410. if (!t2)
  1411. return this;
  1412. for (var n2, r2, a2, h2 = this.data, o2 = this.toBBox(t2), s2 = [], l2 = []; h2 || s2.length; ) {
  1413. if (h2 || (h2 = s2.pop(), r2 = s2[s2.length - 1], n2 = l2.pop(), a2 = true), h2.leaf) {
  1414. var f2 = e(t2, h2.children, i2);
  1415. if (-1 !== f2)
  1416. return h2.children.splice(f2, 1), s2.push(h2), this._condense(s2), this;
  1417. }
  1418. a2 || h2.leaf || !m(h2, o2) ? r2 ? (n2++, h2 = r2.children[n2], a2 = false) : h2 = null : (s2.push(h2), l2.push(n2), n2 = 0, r2 = h2, h2 = h2.children[0]);
  1419. }
  1420. return this;
  1421. }, r.prototype.toBBox = function(t2) {
  1422. return t2;
  1423. }, r.prototype.compareMinX = function(t2, i2) {
  1424. return t2.minX - i2.minX;
  1425. }, r.prototype.compareMinY = function(t2, i2) {
  1426. return t2.minY - i2.minY;
  1427. }, r.prototype.toJSON = function() {
  1428. return this.data;
  1429. }, r.prototype.fromJSON = function(t2) {
  1430. return this.data = t2, this;
  1431. }, r.prototype._all = function(t2, i2) {
  1432. for (var n2 = []; t2; )
  1433. t2.leaf ? i2.push.apply(i2, t2.children) : n2.push.apply(n2, t2.children), t2 = n2.pop();
  1434. return i2;
  1435. }, r.prototype._build = function(t2, i2, n2, r2) {
  1436. var e3, h2 = n2 - i2 + 1, o2 = this._maxEntries;
  1437. if (h2 <= o2)
  1438. return a(e3 = p(t2.slice(i2, n2 + 1)), this.toBBox), e3;
  1439. r2 || (r2 = Math.ceil(Math.log(h2) / Math.log(o2)), o2 = Math.ceil(h2 / Math.pow(o2, r2 - 1))), (e3 = p([])).leaf = false, e3.height = r2;
  1440. var s2 = Math.ceil(h2 / o2), l2 = s2 * Math.ceil(Math.sqrt(o2));
  1441. d(t2, i2, n2, l2, this.compareMinX);
  1442. for (var f2 = i2; f2 <= n2; f2 += l2) {
  1443. var u2 = Math.min(f2 + l2 - 1, n2);
  1444. d(t2, f2, u2, s2, this.compareMinY);
  1445. for (var m2 = f2; m2 <= u2; m2 += s2) {
  1446. var c2 = Math.min(m2 + s2 - 1, u2);
  1447. e3.children.push(this._build(t2, m2, c2, r2 - 1));
  1448. }
  1449. }
  1450. return a(e3, this.toBBox), e3;
  1451. }, r.prototype._chooseSubtree = function(t2, i2, n2, r2) {
  1452. for (; r2.push(i2), !i2.leaf && r2.length - 1 !== n2; ) {
  1453. for (var e3 = 1 / 0, a2 = 1 / 0, h2 = void 0, o2 = 0; o2 < i2.children.length; o2++) {
  1454. var s2 = i2.children[o2], l2 = f(s2), u2 = (m2 = t2, c2 = s2, (Math.max(c2.maxX, m2.maxX) - Math.min(c2.minX, m2.minX)) * (Math.max(c2.maxY, m2.maxY) - Math.min(c2.minY, m2.minY)) - l2);
  1455. u2 < a2 ? (a2 = u2, e3 = l2 < e3 ? l2 : e3, h2 = s2) : u2 === a2 && l2 < e3 && (e3 = l2, h2 = s2);
  1456. }
  1457. i2 = h2 || i2.children[0];
  1458. }
  1459. var m2, c2;
  1460. return i2;
  1461. }, r.prototype._insert = function(t2, i2, n2) {
  1462. var r2 = n2 ? t2 : this.toBBox(t2), e3 = [], a2 = this._chooseSubtree(r2, this.data, i2, e3);
  1463. for (a2.children.push(t2), o(a2, r2); i2 >= 0 && e3[i2].children.length > this._maxEntries; )
  1464. this._split(e3, i2), i2--;
  1465. this._adjustParentBBoxes(r2, e3, i2);
  1466. }, r.prototype._split = function(t2, i2) {
  1467. var n2 = t2[i2], r2 = n2.children.length, e3 = this._minEntries;
  1468. this._chooseSplitAxis(n2, e3, r2);
  1469. var h2 = this._chooseSplitIndex(n2, e3, r2), o2 = p(n2.children.splice(h2, n2.children.length - h2));
  1470. o2.height = n2.height, o2.leaf = n2.leaf, a(n2, this.toBBox), a(o2, this.toBBox), i2 ? t2[i2 - 1].children.push(o2) : this._splitRoot(n2, o2);
  1471. }, r.prototype._splitRoot = function(t2, i2) {
  1472. this.data = p([t2, i2]), this.data.height = t2.height + 1, this.data.leaf = false, a(this.data, this.toBBox);
  1473. }, r.prototype._chooseSplitIndex = function(t2, i2, n2) {
  1474. for (var r2, e3, a2, o2, s2, l2, u2, m2 = 1 / 0, c2 = 1 / 0, p2 = i2; p2 <= n2 - i2; p2++) {
  1475. var d2 = h(t2, 0, p2, this.toBBox), x2 = h(t2, p2, n2, this.toBBox), v = (e3 = d2, a2 = x2, o2 = void 0, s2 = void 0, l2 = void 0, u2 = void 0, o2 = Math.max(e3.minX, a2.minX), s2 = Math.max(e3.minY, a2.minY), l2 = Math.min(e3.maxX, a2.maxX), u2 = Math.min(e3.maxY, a2.maxY), Math.max(0, l2 - o2) * Math.max(0, u2 - s2)), M = f(d2) + f(x2);
  1476. v < m2 ? (m2 = v, r2 = p2, c2 = M < c2 ? M : c2) : v === m2 && M < c2 && (c2 = M, r2 = p2);
  1477. }
  1478. return r2 || n2 - i2;
  1479. }, r.prototype._chooseSplitAxis = function(t2, i2, n2) {
  1480. var r2 = t2.leaf ? this.compareMinX : s, e3 = t2.leaf ? this.compareMinY : l;
  1481. this._allDistMargin(t2, i2, n2, r2) < this._allDistMargin(t2, i2, n2, e3) && t2.children.sort(r2);
  1482. }, r.prototype._allDistMargin = function(t2, i2, n2, r2) {
  1483. t2.children.sort(r2);
  1484. for (var e3 = this.toBBox, a2 = h(t2, 0, i2, e3), s2 = h(t2, n2 - i2, n2, e3), l2 = u(a2) + u(s2), f2 = i2; f2 < n2 - i2; f2++) {
  1485. var m2 = t2.children[f2];
  1486. o(a2, t2.leaf ? e3(m2) : m2), l2 += u(a2);
  1487. }
  1488. for (var c2 = n2 - i2 - 1; c2 >= i2; c2--) {
  1489. var p2 = t2.children[c2];
  1490. o(s2, t2.leaf ? e3(p2) : p2), l2 += u(s2);
  1491. }
  1492. return l2;
  1493. }, r.prototype._adjustParentBBoxes = function(t2, i2, n2) {
  1494. for (var r2 = n2; r2 >= 0; r2--)
  1495. o(i2[r2], t2);
  1496. }, r.prototype._condense = function(t2) {
  1497. for (var i2 = t2.length - 1, n2 = void 0; i2 >= 0; i2--)
  1498. 0 === t2[i2].children.length ? i2 > 0 ? (n2 = t2[i2 - 1].children).splice(n2.indexOf(t2[i2]), 1) : this.clear() : a(t2[i2], this.toBBox);
  1499. }, r;
  1500. });
  1501. }
  1502. });
  1503. // node_modules/@turf/helpers/dist/js/index.js
  1504. var require_js = __commonJS({
  1505. "node_modules/@turf/helpers/dist/js/index.js"(exports) {
  1506. "use strict";
  1507. Object.defineProperty(exports, "__esModule", { value: true });
  1508. exports.earthRadius = 63710088e-1;
  1509. exports.factors = {
  1510. centimeters: exports.earthRadius * 100,
  1511. centimetres: exports.earthRadius * 100,
  1512. degrees: exports.earthRadius / 111325,
  1513. feet: exports.earthRadius * 3.28084,
  1514. inches: exports.earthRadius * 39.37,
  1515. kilometers: exports.earthRadius / 1e3,
  1516. kilometres: exports.earthRadius / 1e3,
  1517. meters: exports.earthRadius,
  1518. metres: exports.earthRadius,
  1519. miles: exports.earthRadius / 1609.344,
  1520. millimeters: exports.earthRadius * 1e3,
  1521. millimetres: exports.earthRadius * 1e3,
  1522. nauticalmiles: exports.earthRadius / 1852,
  1523. radians: 1,
  1524. yards: exports.earthRadius * 1.0936
  1525. };
  1526. exports.unitsFactors = {
  1527. centimeters: 100,
  1528. centimetres: 100,
  1529. degrees: 1 / 111325,
  1530. feet: 3.28084,
  1531. inches: 39.37,
  1532. kilometers: 1 / 1e3,
  1533. kilometres: 1 / 1e3,
  1534. meters: 1,
  1535. metres: 1,
  1536. miles: 1 / 1609.344,
  1537. millimeters: 1e3,
  1538. millimetres: 1e3,
  1539. nauticalmiles: 1 / 1852,
  1540. radians: 1 / exports.earthRadius,
  1541. yards: 1.0936133
  1542. };
  1543. exports.areaFactors = {
  1544. acres: 247105e-9,
  1545. centimeters: 1e4,
  1546. centimetres: 1e4,
  1547. feet: 10.763910417,
  1548. hectares: 1e-4,
  1549. inches: 1550.003100006,
  1550. kilometers: 1e-6,
  1551. kilometres: 1e-6,
  1552. meters: 1,
  1553. metres: 1,
  1554. miles: 386e-9,
  1555. millimeters: 1e6,
  1556. millimetres: 1e6,
  1557. yards: 1.195990046
  1558. };
  1559. function feature2(geom, properties, options) {
  1560. if (options === void 0) {
  1561. options = {};
  1562. }
  1563. var feat = { type: "Feature" };
  1564. if (options.id === 0 || options.id) {
  1565. feat.id = options.id;
  1566. }
  1567. if (options.bbox) {
  1568. feat.bbox = options.bbox;
  1569. }
  1570. feat.properties = properties || {};
  1571. feat.geometry = geom;
  1572. return feat;
  1573. }
  1574. exports.feature = feature2;
  1575. function geometry2(type, coordinates, _options) {
  1576. if (_options === void 0) {
  1577. _options = {};
  1578. }
  1579. switch (type) {
  1580. case "Point":
  1581. return point4(coordinates).geometry;
  1582. case "LineString":
  1583. return lineString2(coordinates).geometry;
  1584. case "Polygon":
  1585. return polygon4(coordinates).geometry;
  1586. case "MultiPoint":
  1587. return multiPoint2(coordinates).geometry;
  1588. case "MultiLineString":
  1589. return multiLineString2(coordinates).geometry;
  1590. case "MultiPolygon":
  1591. return multiPolygon2(coordinates).geometry;
  1592. default:
  1593. throw new Error(type + " is invalid");
  1594. }
  1595. }
  1596. exports.geometry = geometry2;
  1597. function point4(coordinates, properties, options) {
  1598. if (options === void 0) {
  1599. options = {};
  1600. }
  1601. if (!coordinates) {
  1602. throw new Error("coordinates is required");
  1603. }
  1604. if (!Array.isArray(coordinates)) {
  1605. throw new Error("coordinates must be an Array");
  1606. }
  1607. if (coordinates.length < 2) {
  1608. throw new Error("coordinates must be at least 2 numbers long");
  1609. }
  1610. if (!isNumber2(coordinates[0]) || !isNumber2(coordinates[1])) {
  1611. throw new Error("coordinates must contain numbers");
  1612. }
  1613. var geom = {
  1614. type: "Point",
  1615. coordinates
  1616. };
  1617. return feature2(geom, properties, options);
  1618. }
  1619. exports.point = point4;
  1620. function points2(coordinates, properties, options) {
  1621. if (options === void 0) {
  1622. options = {};
  1623. }
  1624. return featureCollection2(coordinates.map(function(coords) {
  1625. return point4(coords, properties);
  1626. }), options);
  1627. }
  1628. exports.points = points2;
  1629. function polygon4(coordinates, properties, options) {
  1630. if (options === void 0) {
  1631. options = {};
  1632. }
  1633. for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
  1634. var ring = coordinates_1[_i];
  1635. if (ring.length < 4) {
  1636. throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
  1637. }
  1638. for (var j = 0; j < ring[ring.length - 1].length; j++) {
  1639. if (ring[ring.length - 1][j] !== ring[0][j]) {
  1640. throw new Error("First and last Position are not equivalent.");
  1641. }
  1642. }
  1643. }
  1644. var geom = {
  1645. type: "Polygon",
  1646. coordinates
  1647. };
  1648. return feature2(geom, properties, options);
  1649. }
  1650. exports.polygon = polygon4;
  1651. function polygons2(coordinates, properties, options) {
  1652. if (options === void 0) {
  1653. options = {};
  1654. }
  1655. return featureCollection2(coordinates.map(function(coords) {
  1656. return polygon4(coords, properties);
  1657. }), options);
  1658. }
  1659. exports.polygons = polygons2;
  1660. function lineString2(coordinates, properties, options) {
  1661. if (options === void 0) {
  1662. options = {};
  1663. }
  1664. if (coordinates.length < 2) {
  1665. throw new Error("coordinates must be an array of two or more positions");
  1666. }
  1667. var geom = {
  1668. type: "LineString",
  1669. coordinates
  1670. };
  1671. return feature2(geom, properties, options);
  1672. }
  1673. exports.lineString = lineString2;
  1674. function lineStrings2(coordinates, properties, options) {
  1675. if (options === void 0) {
  1676. options = {};
  1677. }
  1678. return featureCollection2(coordinates.map(function(coords) {
  1679. return lineString2(coords, properties);
  1680. }), options);
  1681. }
  1682. exports.lineStrings = lineStrings2;
  1683. function featureCollection2(features, options) {
  1684. if (options === void 0) {
  1685. options = {};
  1686. }
  1687. var fc = { type: "FeatureCollection" };
  1688. if (options.id) {
  1689. fc.id = options.id;
  1690. }
  1691. if (options.bbox) {
  1692. fc.bbox = options.bbox;
  1693. }
  1694. fc.features = features;
  1695. return fc;
  1696. }
  1697. exports.featureCollection = featureCollection2;
  1698. function multiLineString2(coordinates, properties, options) {
  1699. if (options === void 0) {
  1700. options = {};
  1701. }
  1702. var geom = {
  1703. type: "MultiLineString",
  1704. coordinates
  1705. };
  1706. return feature2(geom, properties, options);
  1707. }
  1708. exports.multiLineString = multiLineString2;
  1709. function multiPoint2(coordinates, properties, options) {
  1710. if (options === void 0) {
  1711. options = {};
  1712. }
  1713. var geom = {
  1714. type: "MultiPoint",
  1715. coordinates
  1716. };
  1717. return feature2(geom, properties, options);
  1718. }
  1719. exports.multiPoint = multiPoint2;
  1720. function multiPolygon2(coordinates, properties, options) {
  1721. if (options === void 0) {
  1722. options = {};
  1723. }
  1724. var geom = {
  1725. type: "MultiPolygon",
  1726. coordinates
  1727. };
  1728. return feature2(geom, properties, options);
  1729. }
  1730. exports.multiPolygon = multiPolygon2;
  1731. function geometryCollection2(geometries, properties, options) {
  1732. if (options === void 0) {
  1733. options = {};
  1734. }
  1735. var geom = {
  1736. type: "GeometryCollection",
  1737. geometries
  1738. };
  1739. return feature2(geom, properties, options);
  1740. }
  1741. exports.geometryCollection = geometryCollection2;
  1742. function round2(num, precision) {
  1743. if (precision === void 0) {
  1744. precision = 0;
  1745. }
  1746. if (precision && !(precision >= 0)) {
  1747. throw new Error("precision must be a positive number");
  1748. }
  1749. var multiplier = Math.pow(10, precision || 0);
  1750. return Math.round(num * multiplier) / multiplier;
  1751. }
  1752. exports.round = round2;
  1753. function radiansToLength2(radians2, units) {
  1754. if (units === void 0) {
  1755. units = "kilometers";
  1756. }
  1757. var factor = exports.factors[units];
  1758. if (!factor) {
  1759. throw new Error(units + " units is invalid");
  1760. }
  1761. return radians2 * factor;
  1762. }
  1763. exports.radiansToLength = radiansToLength2;
  1764. function lengthToRadians2(distance11, units) {
  1765. if (units === void 0) {
  1766. units = "kilometers";
  1767. }
  1768. var factor = exports.factors[units];
  1769. if (!factor) {
  1770. throw new Error(units + " units is invalid");
  1771. }
  1772. return distance11 / factor;
  1773. }
  1774. exports.lengthToRadians = lengthToRadians2;
  1775. function lengthToDegrees2(distance11, units) {
  1776. return radiansToDegrees2(lengthToRadians2(distance11, units));
  1777. }
  1778. exports.lengthToDegrees = lengthToDegrees2;
  1779. function bearingToAzimuth2(bearing2) {
  1780. var angle4 = bearing2 % 360;
  1781. if (angle4 < 0) {
  1782. angle4 += 360;
  1783. }
  1784. return angle4;
  1785. }
  1786. exports.bearingToAzimuth = bearingToAzimuth2;
  1787. function radiansToDegrees2(radians2) {
  1788. var degrees2 = radians2 % (2 * Math.PI);
  1789. return degrees2 * 180 / Math.PI;
  1790. }
  1791. exports.radiansToDegrees = radiansToDegrees2;
  1792. function degreesToRadians2(degrees2) {
  1793. var radians2 = degrees2 % 360;
  1794. return radians2 * Math.PI / 180;
  1795. }
  1796. exports.degreesToRadians = degreesToRadians2;
  1797. function convertLength2(length4, originalUnit, finalUnit) {
  1798. if (originalUnit === void 0) {
  1799. originalUnit = "kilometers";
  1800. }
  1801. if (finalUnit === void 0) {
  1802. finalUnit = "kilometers";
  1803. }
  1804. if (!(length4 >= 0)) {
  1805. throw new Error("length must be a positive number");
  1806. }
  1807. return radiansToLength2(lengthToRadians2(length4, originalUnit), finalUnit);
  1808. }
  1809. exports.convertLength = convertLength2;
  1810. function convertArea2(area5, originalUnit, finalUnit) {
  1811. if (originalUnit === void 0) {
  1812. originalUnit = "meters";
  1813. }
  1814. if (finalUnit === void 0) {
  1815. finalUnit = "kilometers";
  1816. }
  1817. if (!(area5 >= 0)) {
  1818. throw new Error("area must be a positive number");
  1819. }
  1820. var startFactor = exports.areaFactors[originalUnit];
  1821. if (!startFactor) {
  1822. throw new Error("invalid original units");
  1823. }
  1824. var finalFactor = exports.areaFactors[finalUnit];
  1825. if (!finalFactor) {
  1826. throw new Error("invalid final units");
  1827. }
  1828. return area5 / startFactor * finalFactor;
  1829. }
  1830. exports.convertArea = convertArea2;
  1831. function isNumber2(num) {
  1832. return !isNaN(num) && num !== null && !Array.isArray(num);
  1833. }
  1834. exports.isNumber = isNumber2;
  1835. function isObject2(input) {
  1836. return !!input && input.constructor === Object;
  1837. }
  1838. exports.isObject = isObject2;
  1839. function validateBBox2(bbox3) {
  1840. if (!bbox3) {
  1841. throw new Error("bbox is required");
  1842. }
  1843. if (!Array.isArray(bbox3)) {
  1844. throw new Error("bbox must be an Array");
  1845. }
  1846. if (bbox3.length !== 4 && bbox3.length !== 6) {
  1847. throw new Error("bbox must be an Array of 4 or 6 numbers");
  1848. }
  1849. bbox3.forEach(function(num) {
  1850. if (!isNumber2(num)) {
  1851. throw new Error("bbox must only contain numbers");
  1852. }
  1853. });
  1854. }
  1855. exports.validateBBox = validateBBox2;
  1856. function validateId2(id) {
  1857. if (!id) {
  1858. throw new Error("id is required");
  1859. }
  1860. if (["string", "number"].indexOf(typeof id) === -1) {
  1861. throw new Error("id must be a number or a string");
  1862. }
  1863. }
  1864. exports.validateId = validateId2;
  1865. }
  1866. });
  1867. // node_modules/@turf/meta/dist/js/index.js
  1868. var require_js2 = __commonJS({
  1869. "node_modules/@turf/meta/dist/js/index.js"(exports) {
  1870. "use strict";
  1871. Object.defineProperty(exports, "__esModule", { value: true });
  1872. var helpers = require_js();
  1873. function coordEach2(geojson, callback, excludeWrapCoord) {
  1874. if (geojson === null)
  1875. return;
  1876. var j, k, l, geometry2, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection2, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
  1877. for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
  1878. geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
  1879. isGeometryCollection2 = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
  1880. stopG = isGeometryCollection2 ? geometryMaybeCollection.geometries.length : 1;
  1881. for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
  1882. var multiFeatureIndex = 0;
  1883. var geometryIndex = 0;
  1884. geometry2 = isGeometryCollection2 ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
  1885. if (geometry2 === null)
  1886. continue;
  1887. coords = geometry2.coordinates;
  1888. var geomType = geometry2.type;
  1889. wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
  1890. switch (geomType) {
  1891. case null:
  1892. break;
  1893. case "Point":
  1894. if (callback(
  1895. coords,
  1896. coordIndex,
  1897. featureIndex,
  1898. multiFeatureIndex,
  1899. geometryIndex
  1900. ) === false)
  1901. return false;
  1902. coordIndex++;
  1903. multiFeatureIndex++;
  1904. break;
  1905. case "LineString":
  1906. case "MultiPoint":
  1907. for (j = 0; j < coords.length; j++) {
  1908. if (callback(
  1909. coords[j],
  1910. coordIndex,
  1911. featureIndex,
  1912. multiFeatureIndex,
  1913. geometryIndex
  1914. ) === false)
  1915. return false;
  1916. coordIndex++;
  1917. if (geomType === "MultiPoint")
  1918. multiFeatureIndex++;
  1919. }
  1920. if (geomType === "LineString")
  1921. multiFeatureIndex++;
  1922. break;
  1923. case "Polygon":
  1924. case "MultiLineString":
  1925. for (j = 0; j < coords.length; j++) {
  1926. for (k = 0; k < coords[j].length - wrapShrink; k++) {
  1927. if (callback(
  1928. coords[j][k],
  1929. coordIndex,
  1930. featureIndex,
  1931. multiFeatureIndex,
  1932. geometryIndex
  1933. ) === false)
  1934. return false;
  1935. coordIndex++;
  1936. }
  1937. if (geomType === "MultiLineString")
  1938. multiFeatureIndex++;
  1939. if (geomType === "Polygon")
  1940. geometryIndex++;
  1941. }
  1942. if (geomType === "Polygon")
  1943. multiFeatureIndex++;
  1944. break;
  1945. case "MultiPolygon":
  1946. for (j = 0; j < coords.length; j++) {
  1947. geometryIndex = 0;
  1948. for (k = 0; k < coords[j].length; k++) {
  1949. for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
  1950. if (callback(
  1951. coords[j][k][l],
  1952. coordIndex,
  1953. featureIndex,
  1954. multiFeatureIndex,
  1955. geometryIndex
  1956. ) === false)
  1957. return false;
  1958. coordIndex++;
  1959. }
  1960. geometryIndex++;
  1961. }
  1962. multiFeatureIndex++;
  1963. }
  1964. break;
  1965. case "GeometryCollection":
  1966. for (j = 0; j < geometry2.geometries.length; j++)
  1967. if (coordEach2(geometry2.geometries[j], callback, excludeWrapCoord) === false)
  1968. return false;
  1969. break;
  1970. default:
  1971. throw new Error("Unknown Geometry Type");
  1972. }
  1973. }
  1974. }
  1975. }
  1976. function coordReduce2(geojson, callback, initialValue, excludeWrapCoord) {
  1977. var previousValue = initialValue;
  1978. coordEach2(
  1979. geojson,
  1980. function(currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  1981. if (coordIndex === 0 && initialValue === void 0)
  1982. previousValue = currentCoord;
  1983. else
  1984. previousValue = callback(
  1985. previousValue,
  1986. currentCoord,
  1987. coordIndex,
  1988. featureIndex,
  1989. multiFeatureIndex,
  1990. geometryIndex
  1991. );
  1992. },
  1993. excludeWrapCoord
  1994. );
  1995. return previousValue;
  1996. }
  1997. function propEach2(geojson, callback) {
  1998. var i;
  1999. switch (geojson.type) {
  2000. case "FeatureCollection":
  2001. for (i = 0; i < geojson.features.length; i++) {
  2002. if (callback(geojson.features[i].properties, i) === false)
  2003. break;
  2004. }
  2005. break;
  2006. case "Feature":
  2007. callback(geojson.properties, 0);
  2008. break;
  2009. }
  2010. }
  2011. function propReduce2(geojson, callback, initialValue) {
  2012. var previousValue = initialValue;
  2013. propEach2(geojson, function(currentProperties, featureIndex) {
  2014. if (featureIndex === 0 && initialValue === void 0)
  2015. previousValue = currentProperties;
  2016. else
  2017. previousValue = callback(previousValue, currentProperties, featureIndex);
  2018. });
  2019. return previousValue;
  2020. }
  2021. function featureEach2(geojson, callback) {
  2022. if (geojson.type === "Feature") {
  2023. callback(geojson, 0);
  2024. } else if (geojson.type === "FeatureCollection") {
  2025. for (var i = 0; i < geojson.features.length; i++) {
  2026. if (callback(geojson.features[i], i) === false)
  2027. break;
  2028. }
  2029. }
  2030. }
  2031. function featureReduce2(geojson, callback, initialValue) {
  2032. var previousValue = initialValue;
  2033. featureEach2(geojson, function(currentFeature, featureIndex) {
  2034. if (featureIndex === 0 && initialValue === void 0)
  2035. previousValue = currentFeature;
  2036. else
  2037. previousValue = callback(previousValue, currentFeature, featureIndex);
  2038. });
  2039. return previousValue;
  2040. }
  2041. function coordAll2(geojson) {
  2042. var coords = [];
  2043. coordEach2(geojson, function(coord) {
  2044. coords.push(coord);
  2045. });
  2046. return coords;
  2047. }
  2048. function geomEach2(geojson, callback) {
  2049. var i, j, g, geometry2, stopG, geometryMaybeCollection, isGeometryCollection2, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
  2050. for (i = 0; i < stop; i++) {
  2051. geometryMaybeCollection = isFeatureCollection ? geojson.features[i].geometry : isFeature ? geojson.geometry : geojson;
  2052. featureProperties = isFeatureCollection ? geojson.features[i].properties : isFeature ? geojson.properties : {};
  2053. featureBBox = isFeatureCollection ? geojson.features[i].bbox : isFeature ? geojson.bbox : void 0;
  2054. featureId = isFeatureCollection ? geojson.features[i].id : isFeature ? geojson.id : void 0;
  2055. isGeometryCollection2 = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
  2056. stopG = isGeometryCollection2 ? geometryMaybeCollection.geometries.length : 1;
  2057. for (g = 0; g < stopG; g++) {
  2058. geometry2 = isGeometryCollection2 ? geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
  2059. if (geometry2 === null) {
  2060. if (callback(
  2061. null,
  2062. featureIndex,
  2063. featureProperties,
  2064. featureBBox,
  2065. featureId
  2066. ) === false)
  2067. return false;
  2068. continue;
  2069. }
  2070. switch (geometry2.type) {
  2071. case "Point":
  2072. case "LineString":
  2073. case "MultiPoint":
  2074. case "Polygon":
  2075. case "MultiLineString":
  2076. case "MultiPolygon": {
  2077. if (callback(
  2078. geometry2,
  2079. featureIndex,
  2080. featureProperties,
  2081. featureBBox,
  2082. featureId
  2083. ) === false)
  2084. return false;
  2085. break;
  2086. }
  2087. case "GeometryCollection": {
  2088. for (j = 0; j < geometry2.geometries.length; j++) {
  2089. if (callback(
  2090. geometry2.geometries[j],
  2091. featureIndex,
  2092. featureProperties,
  2093. featureBBox,
  2094. featureId
  2095. ) === false)
  2096. return false;
  2097. }
  2098. break;
  2099. }
  2100. default:
  2101. throw new Error("Unknown Geometry Type");
  2102. }
  2103. }
  2104. featureIndex++;
  2105. }
  2106. }
  2107. function geomReduce2(geojson, callback, initialValue) {
  2108. var previousValue = initialValue;
  2109. geomEach2(
  2110. geojson,
  2111. function(currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
  2112. if (featureIndex === 0 && initialValue === void 0)
  2113. previousValue = currentGeometry;
  2114. else
  2115. previousValue = callback(
  2116. previousValue,
  2117. currentGeometry,
  2118. featureIndex,
  2119. featureProperties,
  2120. featureBBox,
  2121. featureId
  2122. );
  2123. }
  2124. );
  2125. return previousValue;
  2126. }
  2127. function flattenEach2(geojson, callback) {
  2128. geomEach2(geojson, function(geometry2, featureIndex, properties, bbox3, id) {
  2129. var type = geometry2 === null ? null : geometry2.type;
  2130. switch (type) {
  2131. case null:
  2132. case "Point":
  2133. case "LineString":
  2134. case "Polygon":
  2135. if (callback(
  2136. helpers.feature(geometry2, properties, { bbox: bbox3, id }),
  2137. featureIndex,
  2138. 0
  2139. ) === false)
  2140. return false;
  2141. return;
  2142. }
  2143. var geomType;
  2144. switch (type) {
  2145. case "MultiPoint":
  2146. geomType = "Point";
  2147. break;
  2148. case "MultiLineString":
  2149. geomType = "LineString";
  2150. break;
  2151. case "MultiPolygon":
  2152. geomType = "Polygon";
  2153. break;
  2154. }
  2155. for (var multiFeatureIndex = 0; multiFeatureIndex < geometry2.coordinates.length; multiFeatureIndex++) {
  2156. var coordinate2 = geometry2.coordinates[multiFeatureIndex];
  2157. var geom = {
  2158. type: geomType,
  2159. coordinates: coordinate2
  2160. };
  2161. if (callback(helpers.feature(geom, properties), featureIndex, multiFeatureIndex) === false)
  2162. return false;
  2163. }
  2164. });
  2165. }
  2166. function flattenReduce2(geojson, callback, initialValue) {
  2167. var previousValue = initialValue;
  2168. flattenEach2(
  2169. geojson,
  2170. function(currentFeature, featureIndex, multiFeatureIndex) {
  2171. if (featureIndex === 0 && multiFeatureIndex === 0 && initialValue === void 0)
  2172. previousValue = currentFeature;
  2173. else
  2174. previousValue = callback(
  2175. previousValue,
  2176. currentFeature,
  2177. featureIndex,
  2178. multiFeatureIndex
  2179. );
  2180. }
  2181. );
  2182. return previousValue;
  2183. }
  2184. function segmentEach2(geojson, callback) {
  2185. flattenEach2(geojson, function(feature2, featureIndex, multiFeatureIndex) {
  2186. var segmentIndex = 0;
  2187. if (!feature2.geometry)
  2188. return;
  2189. var type = feature2.geometry.type;
  2190. if (type === "Point" || type === "MultiPoint")
  2191. return;
  2192. var previousCoords;
  2193. var previousFeatureIndex = 0;
  2194. var previousMultiIndex = 0;
  2195. var prevGeomIndex = 0;
  2196. if (coordEach2(
  2197. feature2,
  2198. function(currentCoord, coordIndex, featureIndexCoord, multiPartIndexCoord, geometryIndex) {
  2199. if (previousCoords === void 0 || featureIndex > previousFeatureIndex || multiPartIndexCoord > previousMultiIndex || geometryIndex > prevGeomIndex) {
  2200. previousCoords = currentCoord;
  2201. previousFeatureIndex = featureIndex;
  2202. previousMultiIndex = multiPartIndexCoord;
  2203. prevGeomIndex = geometryIndex;
  2204. segmentIndex = 0;
  2205. return;
  2206. }
  2207. var currentSegment = helpers.lineString(
  2208. [previousCoords, currentCoord],
  2209. feature2.properties
  2210. );
  2211. if (callback(
  2212. currentSegment,
  2213. featureIndex,
  2214. multiFeatureIndex,
  2215. geometryIndex,
  2216. segmentIndex
  2217. ) === false)
  2218. return false;
  2219. segmentIndex++;
  2220. previousCoords = currentCoord;
  2221. }
  2222. ) === false)
  2223. return false;
  2224. });
  2225. }
  2226. function segmentReduce2(geojson, callback, initialValue) {
  2227. var previousValue = initialValue;
  2228. var started = false;
  2229. segmentEach2(
  2230. geojson,
  2231. function(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
  2232. if (started === false && initialValue === void 0)
  2233. previousValue = currentSegment;
  2234. else
  2235. previousValue = callback(
  2236. previousValue,
  2237. currentSegment,
  2238. featureIndex,
  2239. multiFeatureIndex,
  2240. geometryIndex,
  2241. segmentIndex
  2242. );
  2243. started = true;
  2244. }
  2245. );
  2246. return previousValue;
  2247. }
  2248. function lineEach2(geojson, callback) {
  2249. if (!geojson)
  2250. throw new Error("geojson is required");
  2251. flattenEach2(geojson, function(feature2, featureIndex, multiFeatureIndex) {
  2252. if (feature2.geometry === null)
  2253. return;
  2254. var type = feature2.geometry.type;
  2255. var coords = feature2.geometry.coordinates;
  2256. switch (type) {
  2257. case "LineString":
  2258. if (callback(feature2, featureIndex, multiFeatureIndex, 0, 0) === false)
  2259. return false;
  2260. break;
  2261. case "Polygon":
  2262. for (var geometryIndex = 0; geometryIndex < coords.length; geometryIndex++) {
  2263. if (callback(
  2264. helpers.lineString(coords[geometryIndex], feature2.properties),
  2265. featureIndex,
  2266. multiFeatureIndex,
  2267. geometryIndex
  2268. ) === false)
  2269. return false;
  2270. }
  2271. break;
  2272. }
  2273. });
  2274. }
  2275. function lineReduce2(geojson, callback, initialValue) {
  2276. var previousValue = initialValue;
  2277. lineEach2(
  2278. geojson,
  2279. function(currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
  2280. if (featureIndex === 0 && initialValue === void 0)
  2281. previousValue = currentLine;
  2282. else
  2283. previousValue = callback(
  2284. previousValue,
  2285. currentLine,
  2286. featureIndex,
  2287. multiFeatureIndex,
  2288. geometryIndex
  2289. );
  2290. }
  2291. );
  2292. return previousValue;
  2293. }
  2294. function findSegment2(geojson, options) {
  2295. options = options || {};
  2296. if (!helpers.isObject(options))
  2297. throw new Error("options is invalid");
  2298. var featureIndex = options.featureIndex || 0;
  2299. var multiFeatureIndex = options.multiFeatureIndex || 0;
  2300. var geometryIndex = options.geometryIndex || 0;
  2301. var segmentIndex = options.segmentIndex || 0;
  2302. var properties = options.properties;
  2303. var geometry2;
  2304. switch (geojson.type) {
  2305. case "FeatureCollection":
  2306. if (featureIndex < 0)
  2307. featureIndex = geojson.features.length + featureIndex;
  2308. properties = properties || geojson.features[featureIndex].properties;
  2309. geometry2 = geojson.features[featureIndex].geometry;
  2310. break;
  2311. case "Feature":
  2312. properties = properties || geojson.properties;
  2313. geometry2 = geojson.geometry;
  2314. break;
  2315. case "Point":
  2316. case "MultiPoint":
  2317. return null;
  2318. case "LineString":
  2319. case "Polygon":
  2320. case "MultiLineString":
  2321. case "MultiPolygon":
  2322. geometry2 = geojson;
  2323. break;
  2324. default:
  2325. throw new Error("geojson is invalid");
  2326. }
  2327. if (geometry2 === null)
  2328. return null;
  2329. var coords = geometry2.coordinates;
  2330. switch (geometry2.type) {
  2331. case "Point":
  2332. case "MultiPoint":
  2333. return null;
  2334. case "LineString":
  2335. if (segmentIndex < 0)
  2336. segmentIndex = coords.length + segmentIndex - 1;
  2337. return helpers.lineString(
  2338. [coords[segmentIndex], coords[segmentIndex + 1]],
  2339. properties,
  2340. options
  2341. );
  2342. case "Polygon":
  2343. if (geometryIndex < 0)
  2344. geometryIndex = coords.length + geometryIndex;
  2345. if (segmentIndex < 0)
  2346. segmentIndex = coords[geometryIndex].length + segmentIndex - 1;
  2347. return helpers.lineString(
  2348. [
  2349. coords[geometryIndex][segmentIndex],
  2350. coords[geometryIndex][segmentIndex + 1]
  2351. ],
  2352. properties,
  2353. options
  2354. );
  2355. case "MultiLineString":
  2356. if (multiFeatureIndex < 0)
  2357. multiFeatureIndex = coords.length + multiFeatureIndex;
  2358. if (segmentIndex < 0)
  2359. segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;
  2360. return helpers.lineString(
  2361. [
  2362. coords[multiFeatureIndex][segmentIndex],
  2363. coords[multiFeatureIndex][segmentIndex + 1]
  2364. ],
  2365. properties,
  2366. options
  2367. );
  2368. case "MultiPolygon":
  2369. if (multiFeatureIndex < 0)
  2370. multiFeatureIndex = coords.length + multiFeatureIndex;
  2371. if (geometryIndex < 0)
  2372. geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
  2373. if (segmentIndex < 0)
  2374. segmentIndex = coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;
  2375. return helpers.lineString(
  2376. [
  2377. coords[multiFeatureIndex][geometryIndex][segmentIndex],
  2378. coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]
  2379. ],
  2380. properties,
  2381. options
  2382. );
  2383. }
  2384. throw new Error("geojson is invalid");
  2385. }
  2386. function findPoint2(geojson, options) {
  2387. options = options || {};
  2388. if (!helpers.isObject(options))
  2389. throw new Error("options is invalid");
  2390. var featureIndex = options.featureIndex || 0;
  2391. var multiFeatureIndex = options.multiFeatureIndex || 0;
  2392. var geometryIndex = options.geometryIndex || 0;
  2393. var coordIndex = options.coordIndex || 0;
  2394. var properties = options.properties;
  2395. var geometry2;
  2396. switch (geojson.type) {
  2397. case "FeatureCollection":
  2398. if (featureIndex < 0)
  2399. featureIndex = geojson.features.length + featureIndex;
  2400. properties = properties || geojson.features[featureIndex].properties;
  2401. geometry2 = geojson.features[featureIndex].geometry;
  2402. break;
  2403. case "Feature":
  2404. properties = properties || geojson.properties;
  2405. geometry2 = geojson.geometry;
  2406. break;
  2407. case "Point":
  2408. case "MultiPoint":
  2409. return null;
  2410. case "LineString":
  2411. case "Polygon":
  2412. case "MultiLineString":
  2413. case "MultiPolygon":
  2414. geometry2 = geojson;
  2415. break;
  2416. default:
  2417. throw new Error("geojson is invalid");
  2418. }
  2419. if (geometry2 === null)
  2420. return null;
  2421. var coords = geometry2.coordinates;
  2422. switch (geometry2.type) {
  2423. case "Point":
  2424. return helpers.point(coords, properties, options);
  2425. case "MultiPoint":
  2426. if (multiFeatureIndex < 0)
  2427. multiFeatureIndex = coords.length + multiFeatureIndex;
  2428. return helpers.point(coords[multiFeatureIndex], properties, options);
  2429. case "LineString":
  2430. if (coordIndex < 0)
  2431. coordIndex = coords.length + coordIndex;
  2432. return helpers.point(coords[coordIndex], properties, options);
  2433. case "Polygon":
  2434. if (geometryIndex < 0)
  2435. geometryIndex = coords.length + geometryIndex;
  2436. if (coordIndex < 0)
  2437. coordIndex = coords[geometryIndex].length + coordIndex;
  2438. return helpers.point(coords[geometryIndex][coordIndex], properties, options);
  2439. case "MultiLineString":
  2440. if (multiFeatureIndex < 0)
  2441. multiFeatureIndex = coords.length + multiFeatureIndex;
  2442. if (coordIndex < 0)
  2443. coordIndex = coords[multiFeatureIndex].length + coordIndex;
  2444. return helpers.point(coords[multiFeatureIndex][coordIndex], properties, options);
  2445. case "MultiPolygon":
  2446. if (multiFeatureIndex < 0)
  2447. multiFeatureIndex = coords.length + multiFeatureIndex;
  2448. if (geometryIndex < 0)
  2449. geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
  2450. if (coordIndex < 0)
  2451. coordIndex = coords[multiFeatureIndex][geometryIndex].length - coordIndex;
  2452. return helpers.point(
  2453. coords[multiFeatureIndex][geometryIndex][coordIndex],
  2454. properties,
  2455. options
  2456. );
  2457. }
  2458. throw new Error("geojson is invalid");
  2459. }
  2460. exports.coordAll = coordAll2;
  2461. exports.coordEach = coordEach2;
  2462. exports.coordReduce = coordReduce2;
  2463. exports.featureEach = featureEach2;
  2464. exports.featureReduce = featureReduce2;
  2465. exports.findPoint = findPoint2;
  2466. exports.findSegment = findSegment2;
  2467. exports.flattenEach = flattenEach2;
  2468. exports.flattenReduce = flattenReduce2;
  2469. exports.geomEach = geomEach2;
  2470. exports.geomReduce = geomReduce2;
  2471. exports.lineEach = lineEach2;
  2472. exports.lineReduce = lineReduce2;
  2473. exports.propEach = propEach2;
  2474. exports.propReduce = propReduce2;
  2475. exports.segmentEach = segmentEach2;
  2476. exports.segmentReduce = segmentReduce2;
  2477. }
  2478. });
  2479. // node_modules/@turf/bbox/dist/js/index.js
  2480. var require_js3 = __commonJS({
  2481. "node_modules/@turf/bbox/dist/js/index.js"(exports) {
  2482. "use strict";
  2483. Object.defineProperty(exports, "__esModule", { value: true });
  2484. var meta_1 = require_js2();
  2485. function bbox3(geojson) {
  2486. var result = [Infinity, Infinity, -Infinity, -Infinity];
  2487. meta_1.coordEach(geojson, function(coord) {
  2488. if (result[0] > coord[0]) {
  2489. result[0] = coord[0];
  2490. }
  2491. if (result[1] > coord[1]) {
  2492. result[1] = coord[1];
  2493. }
  2494. if (result[2] < coord[0]) {
  2495. result[2] = coord[0];
  2496. }
  2497. if (result[3] < coord[1]) {
  2498. result[3] = coord[1];
  2499. }
  2500. });
  2501. return result;
  2502. }
  2503. bbox3["default"] = bbox3;
  2504. exports.default = bbox3;
  2505. }
  2506. });
  2507. // node_modules/geojson-rbush/index.js
  2508. var require_geojson_rbush = __commonJS({
  2509. "node_modules/geojson-rbush/index.js"(exports, module) {
  2510. var rbush6 = require_rbush_min2();
  2511. var helpers = require_js();
  2512. var meta = require_js2();
  2513. var turfBBox = require_js3().default;
  2514. var featureEach2 = meta.featureEach;
  2515. var coordEach2 = meta.coordEach;
  2516. var polygon4 = helpers.polygon;
  2517. var featureCollection2 = helpers.featureCollection;
  2518. function geojsonRbush(maxEntries) {
  2519. var tree = new rbush6(maxEntries);
  2520. tree.insert = function(feature2) {
  2521. if (feature2.type !== "Feature")
  2522. throw new Error("invalid feature");
  2523. feature2.bbox = feature2.bbox ? feature2.bbox : turfBBox(feature2);
  2524. return rbush6.prototype.insert.call(this, feature2);
  2525. };
  2526. tree.load = function(features) {
  2527. var load = [];
  2528. if (Array.isArray(features)) {
  2529. features.forEach(function(feature2) {
  2530. if (feature2.type !== "Feature")
  2531. throw new Error("invalid features");
  2532. feature2.bbox = feature2.bbox ? feature2.bbox : turfBBox(feature2);
  2533. load.push(feature2);
  2534. });
  2535. } else {
  2536. featureEach2(features, function(feature2) {
  2537. if (feature2.type !== "Feature")
  2538. throw new Error("invalid features");
  2539. feature2.bbox = feature2.bbox ? feature2.bbox : turfBBox(feature2);
  2540. load.push(feature2);
  2541. });
  2542. }
  2543. return rbush6.prototype.load.call(this, load);
  2544. };
  2545. tree.remove = function(feature2, equals10) {
  2546. if (feature2.type !== "Feature")
  2547. throw new Error("invalid feature");
  2548. feature2.bbox = feature2.bbox ? feature2.bbox : turfBBox(feature2);
  2549. return rbush6.prototype.remove.call(this, feature2, equals10);
  2550. };
  2551. tree.clear = function() {
  2552. return rbush6.prototype.clear.call(this);
  2553. };
  2554. tree.search = function(geojson) {
  2555. var features = rbush6.prototype.search.call(this, this.toBBox(geojson));
  2556. return featureCollection2(features);
  2557. };
  2558. tree.collides = function(geojson) {
  2559. return rbush6.prototype.collides.call(this, this.toBBox(geojson));
  2560. };
  2561. tree.all = function() {
  2562. var features = rbush6.prototype.all.call(this);
  2563. return featureCollection2(features);
  2564. };
  2565. tree.toJSON = function() {
  2566. return rbush6.prototype.toJSON.call(this);
  2567. };
  2568. tree.fromJSON = function(json) {
  2569. return rbush6.prototype.fromJSON.call(this, json);
  2570. };
  2571. tree.toBBox = function(geojson) {
  2572. var bbox3;
  2573. if (geojson.bbox)
  2574. bbox3 = geojson.bbox;
  2575. else if (Array.isArray(geojson) && geojson.length === 4)
  2576. bbox3 = geojson;
  2577. else if (Array.isArray(geojson) && geojson.length === 6)
  2578. bbox3 = [geojson[0], geojson[1], geojson[3], geojson[4]];
  2579. else if (geojson.type === "Feature")
  2580. bbox3 = turfBBox(geojson);
  2581. else if (geojson.type === "FeatureCollection")
  2582. bbox3 = turfBBox(geojson);
  2583. else
  2584. throw new Error("invalid geojson");
  2585. return {
  2586. minX: bbox3[0],
  2587. minY: bbox3[1],
  2588. maxX: bbox3[2],
  2589. maxY: bbox3[3]
  2590. };
  2591. };
  2592. return tree;
  2593. }
  2594. module.exports = geojsonRbush;
  2595. module.exports.default = geojsonRbush;
  2596. }
  2597. });
  2598. // node_modules/object-keys/isArguments.js
  2599. var require_isArguments = __commonJS({
  2600. "node_modules/object-keys/isArguments.js"(exports, module) {
  2601. "use strict";
  2602. var toStr = Object.prototype.toString;
  2603. module.exports = function isArguments(value) {
  2604. var str = toStr.call(value);
  2605. var isArgs = str === "[object Arguments]";
  2606. if (!isArgs) {
  2607. isArgs = str !== "[object Array]" && value !== null && typeof value === "object" && typeof value.length === "number" && value.length >= 0 && toStr.call(value.callee) === "[object Function]";
  2608. }
  2609. return isArgs;
  2610. };
  2611. }
  2612. });
  2613. // node_modules/object-keys/implementation.js
  2614. var require_implementation = __commonJS({
  2615. "node_modules/object-keys/implementation.js"(exports, module) {
  2616. "use strict";
  2617. var keysShim;
  2618. if (!Object.keys) {
  2619. has = Object.prototype.hasOwnProperty;
  2620. toStr = Object.prototype.toString;
  2621. isArgs = require_isArguments();
  2622. isEnumerable = Object.prototype.propertyIsEnumerable;
  2623. hasDontEnumBug = !isEnumerable.call({ toString: null }, "toString");
  2624. hasProtoEnumBug = isEnumerable.call(function() {
  2625. }, "prototype");
  2626. dontEnums = [
  2627. "toString",
  2628. "toLocaleString",
  2629. "valueOf",
  2630. "hasOwnProperty",
  2631. "isPrototypeOf",
  2632. "propertyIsEnumerable",
  2633. "constructor"
  2634. ];
  2635. equalsConstructorPrototype = function(o) {
  2636. var ctor = o.constructor;
  2637. return ctor && ctor.prototype === o;
  2638. };
  2639. excludedKeys = {
  2640. $applicationCache: true,
  2641. $console: true,
  2642. $external: true,
  2643. $frame: true,
  2644. $frameElement: true,
  2645. $frames: true,
  2646. $innerHeight: true,
  2647. $innerWidth: true,
  2648. $onmozfullscreenchange: true,
  2649. $onmozfullscreenerror: true,
  2650. $outerHeight: true,
  2651. $outerWidth: true,
  2652. $pageXOffset: true,
  2653. $pageYOffset: true,
  2654. $parent: true,
  2655. $scrollLeft: true,
  2656. $scrollTop: true,
  2657. $scrollX: true,
  2658. $scrollY: true,
  2659. $self: true,
  2660. $webkitIndexedDB: true,
  2661. $webkitStorageInfo: true,
  2662. $window: true
  2663. };
  2664. hasAutomationEqualityBug = function() {
  2665. if (typeof window === "undefined") {
  2666. return false;
  2667. }
  2668. for (var k in window) {
  2669. try {
  2670. if (!excludedKeys["$" + k] && has.call(window, k) && window[k] !== null && typeof window[k] === "object") {
  2671. try {
  2672. equalsConstructorPrototype(window[k]);
  2673. } catch (e) {
  2674. return true;
  2675. }
  2676. }
  2677. } catch (e) {
  2678. return true;
  2679. }
  2680. }
  2681. return false;
  2682. }();
  2683. equalsConstructorPrototypeIfNotBuggy = function(o) {
  2684. if (typeof window === "undefined" || !hasAutomationEqualityBug) {
  2685. return equalsConstructorPrototype(o);
  2686. }
  2687. try {
  2688. return equalsConstructorPrototype(o);
  2689. } catch (e) {
  2690. return false;
  2691. }
  2692. };
  2693. keysShim = function keys(object) {
  2694. var isObject2 = object !== null && typeof object === "object";
  2695. var isFunction = toStr.call(object) === "[object Function]";
  2696. var isArguments = isArgs(object);
  2697. var isString = isObject2 && toStr.call(object) === "[object String]";
  2698. var theKeys = [];
  2699. if (!isObject2 && !isFunction && !isArguments) {
  2700. throw new TypeError("Object.keys called on a non-object");
  2701. }
  2702. var skipProto = hasProtoEnumBug && isFunction;
  2703. if (isString && object.length > 0 && !has.call(object, 0)) {
  2704. for (var i = 0; i < object.length; ++i) {
  2705. theKeys.push(String(i));
  2706. }
  2707. }
  2708. if (isArguments && object.length > 0) {
  2709. for (var j = 0; j < object.length; ++j) {
  2710. theKeys.push(String(j));
  2711. }
  2712. } else {
  2713. for (var name in object) {
  2714. if (!(skipProto && name === "prototype") && has.call(object, name)) {
  2715. theKeys.push(String(name));
  2716. }
  2717. }
  2718. }
  2719. if (hasDontEnumBug) {
  2720. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  2721. for (var k = 0; k < dontEnums.length; ++k) {
  2722. if (!(skipConstructor && dontEnums[k] === "constructor") && has.call(object, dontEnums[k])) {
  2723. theKeys.push(dontEnums[k]);
  2724. }
  2725. }
  2726. }
  2727. return theKeys;
  2728. };
  2729. }
  2730. var has;
  2731. var toStr;
  2732. var isArgs;
  2733. var isEnumerable;
  2734. var hasDontEnumBug;
  2735. var hasProtoEnumBug;
  2736. var dontEnums;
  2737. var equalsConstructorPrototype;
  2738. var excludedKeys;
  2739. var hasAutomationEqualityBug;
  2740. var equalsConstructorPrototypeIfNotBuggy;
  2741. module.exports = keysShim;
  2742. }
  2743. });
  2744. // node_modules/object-keys/index.js
  2745. var require_object_keys = __commonJS({
  2746. "node_modules/object-keys/index.js"(exports, module) {
  2747. "use strict";
  2748. var slice2 = Array.prototype.slice;
  2749. var isArgs = require_isArguments();
  2750. var origKeys = Object.keys;
  2751. var keysShim = origKeys ? function keys(o) {
  2752. return origKeys(o);
  2753. } : require_implementation();
  2754. var originalKeys = Object.keys;
  2755. keysShim.shim = function shimObjectKeys() {
  2756. if (Object.keys) {
  2757. var keysWorksWithArguments = function() {
  2758. var args = Object.keys(arguments);
  2759. return args && args.length === arguments.length;
  2760. }(1, 2);
  2761. if (!keysWorksWithArguments) {
  2762. Object.keys = function keys(object) {
  2763. if (isArgs(object)) {
  2764. return originalKeys(slice2.call(object));
  2765. }
  2766. return originalKeys(object);
  2767. };
  2768. }
  2769. } else {
  2770. Object.keys = keysShim;
  2771. }
  2772. return Object.keys || keysShim;
  2773. };
  2774. module.exports = keysShim;
  2775. }
  2776. });
  2777. // node_modules/has-symbols/shams.js
  2778. var require_shams = __commonJS({
  2779. "node_modules/has-symbols/shams.js"(exports, module) {
  2780. "use strict";
  2781. module.exports = function hasSymbols() {
  2782. if (typeof Symbol !== "function" || typeof Object.getOwnPropertySymbols !== "function") {
  2783. return false;
  2784. }
  2785. if (typeof Symbol.iterator === "symbol") {
  2786. return true;
  2787. }
  2788. var obj = {};
  2789. var sym = Symbol("test");
  2790. var symObj = Object(sym);
  2791. if (typeof sym === "string") {
  2792. return false;
  2793. }
  2794. if (Object.prototype.toString.call(sym) !== "[object Symbol]") {
  2795. return false;
  2796. }
  2797. if (Object.prototype.toString.call(symObj) !== "[object Symbol]") {
  2798. return false;
  2799. }
  2800. var symVal = 42;
  2801. obj[sym] = symVal;
  2802. for (sym in obj) {
  2803. return false;
  2804. }
  2805. if (typeof Object.keys === "function" && Object.keys(obj).length !== 0) {
  2806. return false;
  2807. }
  2808. if (typeof Object.getOwnPropertyNames === "function" && Object.getOwnPropertyNames(obj).length !== 0) {
  2809. return false;
  2810. }
  2811. var syms = Object.getOwnPropertySymbols(obj);
  2812. if (syms.length !== 1 || syms[0] !== sym) {
  2813. return false;
  2814. }
  2815. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
  2816. return false;
  2817. }
  2818. if (typeof Object.getOwnPropertyDescriptor === "function") {
  2819. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  2820. if (descriptor.value !== symVal || descriptor.enumerable !== true) {
  2821. return false;
  2822. }
  2823. }
  2824. return true;
  2825. };
  2826. }
  2827. });
  2828. // node_modules/has-tostringtag/shams.js
  2829. var require_shams2 = __commonJS({
  2830. "node_modules/has-tostringtag/shams.js"(exports, module) {
  2831. "use strict";
  2832. var hasSymbols = require_shams();
  2833. module.exports = function hasToStringTagShams() {
  2834. return hasSymbols() && !!Symbol.toStringTag;
  2835. };
  2836. }
  2837. });
  2838. // node_modules/has-symbols/index.js
  2839. var require_has_symbols = __commonJS({
  2840. "node_modules/has-symbols/index.js"(exports, module) {
  2841. "use strict";
  2842. var origSymbol = typeof Symbol !== "undefined" && Symbol;
  2843. var hasSymbolSham = require_shams();
  2844. module.exports = function hasNativeSymbols() {
  2845. if (typeof origSymbol !== "function") {
  2846. return false;
  2847. }
  2848. if (typeof Symbol !== "function") {
  2849. return false;
  2850. }
  2851. if (typeof origSymbol("foo") !== "symbol") {
  2852. return false;
  2853. }
  2854. if (typeof Symbol("bar") !== "symbol") {
  2855. return false;
  2856. }
  2857. return hasSymbolSham();
  2858. };
  2859. }
  2860. });
  2861. // node_modules/function-bind/implementation.js
  2862. var require_implementation2 = __commonJS({
  2863. "node_modules/function-bind/implementation.js"(exports, module) {
  2864. "use strict";
  2865. var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
  2866. var slice2 = Array.prototype.slice;
  2867. var toStr = Object.prototype.toString;
  2868. var funcType = "[object Function]";
  2869. module.exports = function bind(that) {
  2870. var target = this;
  2871. if (typeof target !== "function" || toStr.call(target) !== funcType) {
  2872. throw new TypeError(ERROR_MESSAGE + target);
  2873. }
  2874. var args = slice2.call(arguments, 1);
  2875. var bound;
  2876. var binder = function() {
  2877. if (this instanceof bound) {
  2878. var result = target.apply(
  2879. this,
  2880. args.concat(slice2.call(arguments))
  2881. );
  2882. if (Object(result) === result) {
  2883. return result;
  2884. }
  2885. return this;
  2886. } else {
  2887. return target.apply(
  2888. that,
  2889. args.concat(slice2.call(arguments))
  2890. );
  2891. }
  2892. };
  2893. var boundLength = Math.max(0, target.length - args.length);
  2894. var boundArgs = [];
  2895. for (var i = 0; i < boundLength; i++) {
  2896. boundArgs.push("$" + i);
  2897. }
  2898. bound = Function("binder", "return function (" + boundArgs.join(",") + "){ return binder.apply(this,arguments); }")(binder);
  2899. if (target.prototype) {
  2900. var Empty = function Empty2() {
  2901. };
  2902. Empty.prototype = target.prototype;
  2903. bound.prototype = new Empty();
  2904. Empty.prototype = null;
  2905. }
  2906. return bound;
  2907. };
  2908. }
  2909. });
  2910. // node_modules/function-bind/index.js
  2911. var require_function_bind = __commonJS({
  2912. "node_modules/function-bind/index.js"(exports, module) {
  2913. "use strict";
  2914. var implementation = require_implementation2();
  2915. module.exports = Function.prototype.bind || implementation;
  2916. }
  2917. });
  2918. // node_modules/has/src/index.js
  2919. var require_src = __commonJS({
  2920. "node_modules/has/src/index.js"(exports, module) {
  2921. "use strict";
  2922. var bind = require_function_bind();
  2923. module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
  2924. }
  2925. });
  2926. // node_modules/get-intrinsic/index.js
  2927. var require_get_intrinsic = __commonJS({
  2928. "node_modules/get-intrinsic/index.js"(exports, module) {
  2929. "use strict";
  2930. var undefined2;
  2931. var $SyntaxError = SyntaxError;
  2932. var $Function = Function;
  2933. var $TypeError = TypeError;
  2934. var getEvalledConstructor = function(expressionSyntax) {
  2935. try {
  2936. return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")();
  2937. } catch (e) {
  2938. }
  2939. };
  2940. var $gOPD = Object.getOwnPropertyDescriptor;
  2941. if ($gOPD) {
  2942. try {
  2943. $gOPD({}, "");
  2944. } catch (e) {
  2945. $gOPD = null;
  2946. }
  2947. }
  2948. var throwTypeError = function() {
  2949. throw new $TypeError();
  2950. };
  2951. var ThrowTypeError = $gOPD ? function() {
  2952. try {
  2953. arguments.callee;
  2954. return throwTypeError;
  2955. } catch (calleeThrows) {
  2956. try {
  2957. return $gOPD(arguments, "callee").get;
  2958. } catch (gOPDthrows) {
  2959. return throwTypeError;
  2960. }
  2961. }
  2962. }() : throwTypeError;
  2963. var hasSymbols = require_has_symbols()();
  2964. var getProto = Object.getPrototypeOf || function(x2) {
  2965. return x2.__proto__;
  2966. };
  2967. var needsEval = {};
  2968. var TypedArray = typeof Uint8Array === "undefined" ? undefined2 : getProto(Uint8Array);
  2969. var INTRINSICS = {
  2970. "%AggregateError%": typeof AggregateError === "undefined" ? undefined2 : AggregateError,
  2971. "%Array%": Array,
  2972. "%ArrayBuffer%": typeof ArrayBuffer === "undefined" ? undefined2 : ArrayBuffer,
  2973. "%ArrayIteratorPrototype%": hasSymbols ? getProto([][Symbol.iterator]()) : undefined2,
  2974. "%AsyncFromSyncIteratorPrototype%": undefined2,
  2975. "%AsyncFunction%": needsEval,
  2976. "%AsyncGenerator%": needsEval,
  2977. "%AsyncGeneratorFunction%": needsEval,
  2978. "%AsyncIteratorPrototype%": needsEval,
  2979. "%Atomics%": typeof Atomics === "undefined" ? undefined2 : Atomics,
  2980. "%BigInt%": typeof BigInt === "undefined" ? undefined2 : BigInt,
  2981. "%Boolean%": Boolean,
  2982. "%DataView%": typeof DataView === "undefined" ? undefined2 : DataView,
  2983. "%Date%": Date,
  2984. "%decodeURI%": decodeURI,
  2985. "%decodeURIComponent%": decodeURIComponent,
  2986. "%encodeURI%": encodeURI,
  2987. "%encodeURIComponent%": encodeURIComponent,
  2988. "%Error%": Error,
  2989. "%eval%": eval,
  2990. "%EvalError%": EvalError,
  2991. "%Float32Array%": typeof Float32Array === "undefined" ? undefined2 : Float32Array,
  2992. "%Float64Array%": typeof Float64Array === "undefined" ? undefined2 : Float64Array,
  2993. "%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined2 : FinalizationRegistry,
  2994. "%Function%": $Function,
  2995. "%GeneratorFunction%": needsEval,
  2996. "%Int8Array%": typeof Int8Array === "undefined" ? undefined2 : Int8Array,
  2997. "%Int16Array%": typeof Int16Array === "undefined" ? undefined2 : Int16Array,
  2998. "%Int32Array%": typeof Int32Array === "undefined" ? undefined2 : Int32Array,
  2999. "%isFinite%": isFinite,
  3000. "%isNaN%": isNaN,
  3001. "%IteratorPrototype%": hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined2,
  3002. "%JSON%": typeof JSON === "object" ? JSON : undefined2,
  3003. "%Map%": typeof Map === "undefined" ? undefined2 : Map,
  3004. "%MapIteratorPrototype%": typeof Map === "undefined" || !hasSymbols ? undefined2 : getProto((/* @__PURE__ */ new Map())[Symbol.iterator]()),
  3005. "%Math%": Math,
  3006. "%Number%": Number,
  3007. "%Object%": Object,
  3008. "%parseFloat%": parseFloat,
  3009. "%parseInt%": parseInt,
  3010. "%Promise%": typeof Promise === "undefined" ? undefined2 : Promise,
  3011. "%Proxy%": typeof Proxy === "undefined" ? undefined2 : Proxy,
  3012. "%RangeError%": RangeError,
  3013. "%ReferenceError%": ReferenceError,
  3014. "%Reflect%": typeof Reflect === "undefined" ? undefined2 : Reflect,
  3015. "%RegExp%": RegExp,
  3016. "%Set%": typeof Set === "undefined" ? undefined2 : Set,
  3017. "%SetIteratorPrototype%": typeof Set === "undefined" || !hasSymbols ? undefined2 : getProto((/* @__PURE__ */ new Set())[Symbol.iterator]()),
  3018. "%SharedArrayBuffer%": typeof SharedArrayBuffer === "undefined" ? undefined2 : SharedArrayBuffer,
  3019. "%String%": String,
  3020. "%StringIteratorPrototype%": hasSymbols ? getProto(""[Symbol.iterator]()) : undefined2,
  3021. "%Symbol%": hasSymbols ? Symbol : undefined2,
  3022. "%SyntaxError%": $SyntaxError,
  3023. "%ThrowTypeError%": ThrowTypeError,
  3024. "%TypedArray%": TypedArray,
  3025. "%TypeError%": $TypeError,
  3026. "%Uint8Array%": typeof Uint8Array === "undefined" ? undefined2 : Uint8Array,
  3027. "%Uint8ClampedArray%": typeof Uint8ClampedArray === "undefined" ? undefined2 : Uint8ClampedArray,
  3028. "%Uint16Array%": typeof Uint16Array === "undefined" ? undefined2 : Uint16Array,
  3029. "%Uint32Array%": typeof Uint32Array === "undefined" ? undefined2 : Uint32Array,
  3030. "%URIError%": URIError,
  3031. "%WeakMap%": typeof WeakMap === "undefined" ? undefined2 : WeakMap,
  3032. "%WeakRef%": typeof WeakRef === "undefined" ? undefined2 : WeakRef,
  3033. "%WeakSet%": typeof WeakSet === "undefined" ? undefined2 : WeakSet
  3034. };
  3035. var doEval = function doEval2(name) {
  3036. var value;
  3037. if (name === "%AsyncFunction%") {
  3038. value = getEvalledConstructor("async function () {}");
  3039. } else if (name === "%GeneratorFunction%") {
  3040. value = getEvalledConstructor("function* () {}");
  3041. } else if (name === "%AsyncGeneratorFunction%") {
  3042. value = getEvalledConstructor("async function* () {}");
  3043. } else if (name === "%AsyncGenerator%") {
  3044. var fn = doEval2("%AsyncGeneratorFunction%");
  3045. if (fn) {
  3046. value = fn.prototype;
  3047. }
  3048. } else if (name === "%AsyncIteratorPrototype%") {
  3049. var gen = doEval2("%AsyncGenerator%");
  3050. if (gen) {
  3051. value = getProto(gen.prototype);
  3052. }
  3053. }
  3054. INTRINSICS[name] = value;
  3055. return value;
  3056. };
  3057. var LEGACY_ALIASES = {
  3058. "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
  3059. "%ArrayPrototype%": ["Array", "prototype"],
  3060. "%ArrayProto_entries%": ["Array", "prototype", "entries"],
  3061. "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
  3062. "%ArrayProto_keys%": ["Array", "prototype", "keys"],
  3063. "%ArrayProto_values%": ["Array", "prototype", "values"],
  3064. "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
  3065. "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
  3066. "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
  3067. "%BooleanPrototype%": ["Boolean", "prototype"],
  3068. "%DataViewPrototype%": ["DataView", "prototype"],
  3069. "%DatePrototype%": ["Date", "prototype"],
  3070. "%ErrorPrototype%": ["Error", "prototype"],
  3071. "%EvalErrorPrototype%": ["EvalError", "prototype"],
  3072. "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
  3073. "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
  3074. "%FunctionPrototype%": ["Function", "prototype"],
  3075. "%Generator%": ["GeneratorFunction", "prototype"],
  3076. "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
  3077. "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
  3078. "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
  3079. "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
  3080. "%JSONParse%": ["JSON", "parse"],
  3081. "%JSONStringify%": ["JSON", "stringify"],
  3082. "%MapPrototype%": ["Map", "prototype"],
  3083. "%NumberPrototype%": ["Number", "prototype"],
  3084. "%ObjectPrototype%": ["Object", "prototype"],
  3085. "%ObjProto_toString%": ["Object", "prototype", "toString"],
  3086. "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
  3087. "%PromisePrototype%": ["Promise", "prototype"],
  3088. "%PromiseProto_then%": ["Promise", "prototype", "then"],
  3089. "%Promise_all%": ["Promise", "all"],
  3090. "%Promise_reject%": ["Promise", "reject"],
  3091. "%Promise_resolve%": ["Promise", "resolve"],
  3092. "%RangeErrorPrototype%": ["RangeError", "prototype"],
  3093. "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
  3094. "%RegExpPrototype%": ["RegExp", "prototype"],
  3095. "%SetPrototype%": ["Set", "prototype"],
  3096. "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
  3097. "%StringPrototype%": ["String", "prototype"],
  3098. "%SymbolPrototype%": ["Symbol", "prototype"],
  3099. "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
  3100. "%TypedArrayPrototype%": ["TypedArray", "prototype"],
  3101. "%TypeErrorPrototype%": ["TypeError", "prototype"],
  3102. "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
  3103. "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
  3104. "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
  3105. "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
  3106. "%URIErrorPrototype%": ["URIError", "prototype"],
  3107. "%WeakMapPrototype%": ["WeakMap", "prototype"],
  3108. "%WeakSetPrototype%": ["WeakSet", "prototype"]
  3109. };
  3110. var bind = require_function_bind();
  3111. var hasOwn = require_src();
  3112. var $concat = bind.call(Function.call, Array.prototype.concat);
  3113. var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
  3114. var $replace = bind.call(Function.call, String.prototype.replace);
  3115. var $strSlice = bind.call(Function.call, String.prototype.slice);
  3116. var $exec = bind.call(Function.call, RegExp.prototype.exec);
  3117. var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  3118. var reEscapeChar = /\\(\\)?/g;
  3119. var stringToPath = function stringToPath2(string) {
  3120. var first = $strSlice(string, 0, 1);
  3121. var last = $strSlice(string, -1);
  3122. if (first === "%" && last !== "%") {
  3123. throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`");
  3124. } else if (last === "%" && first !== "%") {
  3125. throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
  3126. }
  3127. var result = [];
  3128. $replace(string, rePropName, function(match, number, quote, subString) {
  3129. result[result.length] = quote ? $replace(subString, reEscapeChar, "$1") : number || match;
  3130. });
  3131. return result;
  3132. };
  3133. var getBaseIntrinsic = function getBaseIntrinsic2(name, allowMissing) {
  3134. var intrinsicName = name;
  3135. var alias;
  3136. if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
  3137. alias = LEGACY_ALIASES[intrinsicName];
  3138. intrinsicName = "%" + alias[0] + "%";
  3139. }
  3140. if (hasOwn(INTRINSICS, intrinsicName)) {
  3141. var value = INTRINSICS[intrinsicName];
  3142. if (value === needsEval) {
  3143. value = doEval(intrinsicName);
  3144. }
  3145. if (typeof value === "undefined" && !allowMissing) {
  3146. throw new $TypeError("intrinsic " + name + " exists, but is not available. Please file an issue!");
  3147. }
  3148. return {
  3149. alias,
  3150. name: intrinsicName,
  3151. value
  3152. };
  3153. }
  3154. throw new $SyntaxError("intrinsic " + name + " does not exist!");
  3155. };
  3156. module.exports = function GetIntrinsic(name, allowMissing) {
  3157. if (typeof name !== "string" || name.length === 0) {
  3158. throw new $TypeError("intrinsic name must be a non-empty string");
  3159. }
  3160. if (arguments.length > 1 && typeof allowMissing !== "boolean") {
  3161. throw new $TypeError('"allowMissing" argument must be a boolean');
  3162. }
  3163. if ($exec(/^%?[^%]*%?$/, name) === null) {
  3164. throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
  3165. }
  3166. var parts = stringToPath(name);
  3167. var intrinsicBaseName = parts.length > 0 ? parts[0] : "";
  3168. var intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing);
  3169. var intrinsicRealName = intrinsic.name;
  3170. var value = intrinsic.value;
  3171. var skipFurtherCaching = false;
  3172. var alias = intrinsic.alias;
  3173. if (alias) {
  3174. intrinsicBaseName = alias[0];
  3175. $spliceApply(parts, $concat([0, 1], alias));
  3176. }
  3177. for (var i = 1, isOwn = true; i < parts.length; i += 1) {
  3178. var part = parts[i];
  3179. var first = $strSlice(part, 0, 1);
  3180. var last = $strSlice(part, -1);
  3181. if ((first === '"' || first === "'" || first === "`" || (last === '"' || last === "'" || last === "`")) && first !== last) {
  3182. throw new $SyntaxError("property names with quotes must have matching quotes");
  3183. }
  3184. if (part === "constructor" || !isOwn) {
  3185. skipFurtherCaching = true;
  3186. }
  3187. intrinsicBaseName += "." + part;
  3188. intrinsicRealName = "%" + intrinsicBaseName + "%";
  3189. if (hasOwn(INTRINSICS, intrinsicRealName)) {
  3190. value = INTRINSICS[intrinsicRealName];
  3191. } else if (value != null) {
  3192. if (!(part in value)) {
  3193. if (!allowMissing) {
  3194. throw new $TypeError("base intrinsic for " + name + " exists, but the property is not available.");
  3195. }
  3196. return void 0;
  3197. }
  3198. if ($gOPD && i + 1 >= parts.length) {
  3199. var desc = $gOPD(value, part);
  3200. isOwn = !!desc;
  3201. if (isOwn && "get" in desc && !("originalValue" in desc.get)) {
  3202. value = desc.get;
  3203. } else {
  3204. value = value[part];
  3205. }
  3206. } else {
  3207. isOwn = hasOwn(value, part);
  3208. value = value[part];
  3209. }
  3210. if (isOwn && !skipFurtherCaching) {
  3211. INTRINSICS[intrinsicRealName] = value;
  3212. }
  3213. }
  3214. }
  3215. return value;
  3216. };
  3217. }
  3218. });
  3219. // node_modules/call-bind/index.js
  3220. var require_call_bind = __commonJS({
  3221. "node_modules/call-bind/index.js"(exports, module) {
  3222. "use strict";
  3223. var bind = require_function_bind();
  3224. var GetIntrinsic = require_get_intrinsic();
  3225. var $apply = GetIntrinsic("%Function.prototype.apply%");
  3226. var $call = GetIntrinsic("%Function.prototype.call%");
  3227. var $reflectApply = GetIntrinsic("%Reflect.apply%", true) || bind.call($call, $apply);
  3228. var $gOPD = GetIntrinsic("%Object.getOwnPropertyDescriptor%", true);
  3229. var $defineProperty = GetIntrinsic("%Object.defineProperty%", true);
  3230. var $max = GetIntrinsic("%Math.max%");
  3231. if ($defineProperty) {
  3232. try {
  3233. $defineProperty({}, "a", { value: 1 });
  3234. } catch (e) {
  3235. $defineProperty = null;
  3236. }
  3237. }
  3238. module.exports = function callBind(originalFunction) {
  3239. var func = $reflectApply(bind, $call, arguments);
  3240. if ($gOPD && $defineProperty) {
  3241. var desc = $gOPD(func, "length");
  3242. if (desc.configurable) {
  3243. $defineProperty(
  3244. func,
  3245. "length",
  3246. { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
  3247. );
  3248. }
  3249. }
  3250. return func;
  3251. };
  3252. var applyBind = function applyBind2() {
  3253. return $reflectApply(bind, $apply, arguments);
  3254. };
  3255. if ($defineProperty) {
  3256. $defineProperty(module.exports, "apply", { value: applyBind });
  3257. } else {
  3258. module.exports.apply = applyBind;
  3259. }
  3260. }
  3261. });
  3262. // node_modules/call-bind/callBound.js
  3263. var require_callBound = __commonJS({
  3264. "node_modules/call-bind/callBound.js"(exports, module) {
  3265. "use strict";
  3266. var GetIntrinsic = require_get_intrinsic();
  3267. var callBind = require_call_bind();
  3268. var $indexOf = callBind(GetIntrinsic("String.prototype.indexOf"));
  3269. module.exports = function callBoundIntrinsic(name, allowMissing) {
  3270. var intrinsic = GetIntrinsic(name, !!allowMissing);
  3271. if (typeof intrinsic === "function" && $indexOf(name, ".prototype.") > -1) {
  3272. return callBind(intrinsic);
  3273. }
  3274. return intrinsic;
  3275. };
  3276. }
  3277. });
  3278. // node_modules/is-arguments/index.js
  3279. var require_is_arguments = __commonJS({
  3280. "node_modules/is-arguments/index.js"(exports, module) {
  3281. "use strict";
  3282. var hasToStringTag = require_shams2()();
  3283. var callBound = require_callBound();
  3284. var $toString = callBound("Object.prototype.toString");
  3285. var isStandardArguments = function isArguments(value) {
  3286. if (hasToStringTag && value && typeof value === "object" && Symbol.toStringTag in value) {
  3287. return false;
  3288. }
  3289. return $toString(value) === "[object Arguments]";
  3290. };
  3291. var isLegacyArguments = function isArguments(value) {
  3292. if (isStandardArguments(value)) {
  3293. return true;
  3294. }
  3295. return value !== null && typeof value === "object" && typeof value.length === "number" && value.length >= 0 && $toString(value) !== "[object Array]" && $toString(value.callee) === "[object Function]";
  3296. };
  3297. var supportsStandardArguments = function() {
  3298. return isStandardArguments(arguments);
  3299. }();
  3300. isStandardArguments.isLegacyArguments = isLegacyArguments;
  3301. module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
  3302. }
  3303. });
  3304. // node_modules/has-property-descriptors/index.js
  3305. var require_has_property_descriptors = __commonJS({
  3306. "node_modules/has-property-descriptors/index.js"(exports, module) {
  3307. "use strict";
  3308. var GetIntrinsic = require_get_intrinsic();
  3309. var $defineProperty = GetIntrinsic("%Object.defineProperty%", true);
  3310. var hasPropertyDescriptors = function hasPropertyDescriptors2() {
  3311. if ($defineProperty) {
  3312. try {
  3313. $defineProperty({}, "a", { value: 1 });
  3314. return true;
  3315. } catch (e) {
  3316. return false;
  3317. }
  3318. }
  3319. return false;
  3320. };
  3321. hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
  3322. if (!hasPropertyDescriptors()) {
  3323. return null;
  3324. }
  3325. try {
  3326. return $defineProperty([], "length", { value: 1 }).length !== 1;
  3327. } catch (e) {
  3328. return true;
  3329. }
  3330. };
  3331. module.exports = hasPropertyDescriptors;
  3332. }
  3333. });
  3334. // node_modules/define-properties/index.js
  3335. var require_define_properties = __commonJS({
  3336. "node_modules/define-properties/index.js"(exports, module) {
  3337. "use strict";
  3338. var keys = require_object_keys();
  3339. var hasSymbols = typeof Symbol === "function" && typeof Symbol("foo") === "symbol";
  3340. var toStr = Object.prototype.toString;
  3341. var concat = Array.prototype.concat;
  3342. var origDefineProperty = Object.defineProperty;
  3343. var isFunction = function(fn) {
  3344. return typeof fn === "function" && toStr.call(fn) === "[object Function]";
  3345. };
  3346. var hasPropertyDescriptors = require_has_property_descriptors()();
  3347. var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
  3348. var defineProperty = function(object, name, value, predicate) {
  3349. if (name in object && (!isFunction(predicate) || !predicate())) {
  3350. return;
  3351. }
  3352. if (supportsDescriptors) {
  3353. origDefineProperty(object, name, {
  3354. configurable: true,
  3355. enumerable: false,
  3356. value,
  3357. writable: true
  3358. });
  3359. } else {
  3360. object[name] = value;
  3361. }
  3362. };
  3363. var defineProperties = function(object, map5) {
  3364. var predicates = arguments.length > 2 ? arguments[2] : {};
  3365. var props = keys(map5);
  3366. if (hasSymbols) {
  3367. props = concat.call(props, Object.getOwnPropertySymbols(map5));
  3368. }
  3369. for (var i = 0; i < props.length; i += 1) {
  3370. defineProperty(object, props[i], map5[props[i]], predicates[props[i]]);
  3371. }
  3372. };
  3373. defineProperties.supportsDescriptors = !!supportsDescriptors;
  3374. module.exports = defineProperties;
  3375. }
  3376. });
  3377. // node_modules/object-is/implementation.js
  3378. var require_implementation3 = __commonJS({
  3379. "node_modules/object-is/implementation.js"(exports, module) {
  3380. "use strict";
  3381. var numberIsNaN = function(value) {
  3382. return value !== value;
  3383. };
  3384. module.exports = function is(a, b) {
  3385. if (a === 0 && b === 0) {
  3386. return 1 / a === 1 / b;
  3387. }
  3388. if (a === b) {
  3389. return true;
  3390. }
  3391. if (numberIsNaN(a) && numberIsNaN(b)) {
  3392. return true;
  3393. }
  3394. return false;
  3395. };
  3396. }
  3397. });
  3398. // node_modules/object-is/polyfill.js
  3399. var require_polyfill = __commonJS({
  3400. "node_modules/object-is/polyfill.js"(exports, module) {
  3401. "use strict";
  3402. var implementation = require_implementation3();
  3403. module.exports = function getPolyfill() {
  3404. return typeof Object.is === "function" ? Object.is : implementation;
  3405. };
  3406. }
  3407. });
  3408. // node_modules/object-is/shim.js
  3409. var require_shim = __commonJS({
  3410. "node_modules/object-is/shim.js"(exports, module) {
  3411. "use strict";
  3412. var getPolyfill = require_polyfill();
  3413. var define2 = require_define_properties();
  3414. module.exports = function shimObjectIs() {
  3415. var polyfill = getPolyfill();
  3416. define2(Object, { is: polyfill }, {
  3417. is: function testObjectIs() {
  3418. return Object.is !== polyfill;
  3419. }
  3420. });
  3421. return polyfill;
  3422. };
  3423. }
  3424. });
  3425. // node_modules/object-is/index.js
  3426. var require_object_is = __commonJS({
  3427. "node_modules/object-is/index.js"(exports, module) {
  3428. "use strict";
  3429. var define2 = require_define_properties();
  3430. var callBind = require_call_bind();
  3431. var implementation = require_implementation3();
  3432. var getPolyfill = require_polyfill();
  3433. var shim = require_shim();
  3434. var polyfill = callBind(getPolyfill(), Object);
  3435. define2(polyfill, {
  3436. getPolyfill,
  3437. implementation,
  3438. shim
  3439. });
  3440. module.exports = polyfill;
  3441. }
  3442. });
  3443. // node_modules/is-regex/index.js
  3444. var require_is_regex = __commonJS({
  3445. "node_modules/is-regex/index.js"(exports, module) {
  3446. "use strict";
  3447. var callBound = require_callBound();
  3448. var hasToStringTag = require_shams2()();
  3449. var has;
  3450. var $exec;
  3451. var isRegexMarker;
  3452. var badStringifier;
  3453. if (hasToStringTag) {
  3454. has = callBound("Object.prototype.hasOwnProperty");
  3455. $exec = callBound("RegExp.prototype.exec");
  3456. isRegexMarker = {};
  3457. throwRegexMarker = function() {
  3458. throw isRegexMarker;
  3459. };
  3460. badStringifier = {
  3461. toString: throwRegexMarker,
  3462. valueOf: throwRegexMarker
  3463. };
  3464. if (typeof Symbol.toPrimitive === "symbol") {
  3465. badStringifier[Symbol.toPrimitive] = throwRegexMarker;
  3466. }
  3467. }
  3468. var throwRegexMarker;
  3469. var $toString = callBound("Object.prototype.toString");
  3470. var gOPD = Object.getOwnPropertyDescriptor;
  3471. var regexClass = "[object RegExp]";
  3472. module.exports = hasToStringTag ? function isRegex(value) {
  3473. if (!value || typeof value !== "object") {
  3474. return false;
  3475. }
  3476. var descriptor = gOPD(value, "lastIndex");
  3477. var hasLastIndexDataProperty = descriptor && has(descriptor, "value");
  3478. if (!hasLastIndexDataProperty) {
  3479. return false;
  3480. }
  3481. try {
  3482. $exec(value, badStringifier);
  3483. } catch (e) {
  3484. return e === isRegexMarker;
  3485. }
  3486. } : function isRegex(value) {
  3487. if (!value || typeof value !== "object" && typeof value !== "function") {
  3488. return false;
  3489. }
  3490. return $toString(value) === regexClass;
  3491. };
  3492. }
  3493. });
  3494. // node_modules/functions-have-names/index.js
  3495. var require_functions_have_names = __commonJS({
  3496. "node_modules/functions-have-names/index.js"(exports, module) {
  3497. "use strict";
  3498. var functionsHaveNames = function functionsHaveNames2() {
  3499. return typeof function f() {
  3500. }.name === "string";
  3501. };
  3502. var gOPD = Object.getOwnPropertyDescriptor;
  3503. if (gOPD) {
  3504. try {
  3505. gOPD([], "length");
  3506. } catch (e) {
  3507. gOPD = null;
  3508. }
  3509. }
  3510. functionsHaveNames.functionsHaveConfigurableNames = function functionsHaveConfigurableNames() {
  3511. if (!functionsHaveNames() || !gOPD) {
  3512. return false;
  3513. }
  3514. var desc = gOPD(function() {
  3515. }, "name");
  3516. return !!desc && !!desc.configurable;
  3517. };
  3518. var $bind = Function.prototype.bind;
  3519. functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() {
  3520. return functionsHaveNames() && typeof $bind === "function" && function f() {
  3521. }.bind().name !== "";
  3522. };
  3523. module.exports = functionsHaveNames;
  3524. }
  3525. });
  3526. // node_modules/regexp.prototype.flags/implementation.js
  3527. var require_implementation4 = __commonJS({
  3528. "node_modules/regexp.prototype.flags/implementation.js"(exports, module) {
  3529. "use strict";
  3530. var functionsHaveConfigurableNames = require_functions_have_names().functionsHaveConfigurableNames();
  3531. var $Object = Object;
  3532. var $TypeError = TypeError;
  3533. module.exports = function flags() {
  3534. if (this != null && this !== $Object(this)) {
  3535. throw new $TypeError("RegExp.prototype.flags getter called on non-object");
  3536. }
  3537. var result = "";
  3538. if (this.hasIndices) {
  3539. result += "d";
  3540. }
  3541. if (this.global) {
  3542. result += "g";
  3543. }
  3544. if (this.ignoreCase) {
  3545. result += "i";
  3546. }
  3547. if (this.multiline) {
  3548. result += "m";
  3549. }
  3550. if (this.dotAll) {
  3551. result += "s";
  3552. }
  3553. if (this.unicode) {
  3554. result += "u";
  3555. }
  3556. if (this.sticky) {
  3557. result += "y";
  3558. }
  3559. return result;
  3560. };
  3561. if (functionsHaveConfigurableNames && Object.defineProperty) {
  3562. Object.defineProperty(module.exports, "name", { value: "get flags" });
  3563. }
  3564. }
  3565. });
  3566. // node_modules/regexp.prototype.flags/polyfill.js
  3567. var require_polyfill2 = __commonJS({
  3568. "node_modules/regexp.prototype.flags/polyfill.js"(exports, module) {
  3569. "use strict";
  3570. var implementation = require_implementation4();
  3571. var supportsDescriptors = require_define_properties().supportsDescriptors;
  3572. var $gOPD = Object.getOwnPropertyDescriptor;
  3573. module.exports = function getPolyfill() {
  3574. if (supportsDescriptors && /a/mig.flags === "gim") {
  3575. var descriptor = $gOPD(RegExp.prototype, "flags");
  3576. if (descriptor && typeof descriptor.get === "function" && typeof RegExp.prototype.dotAll === "boolean" && typeof RegExp.prototype.hasIndices === "boolean") {
  3577. var calls = "";
  3578. var o = {};
  3579. Object.defineProperty(o, "hasIndices", {
  3580. get: function() {
  3581. calls += "d";
  3582. }
  3583. });
  3584. Object.defineProperty(o, "sticky", {
  3585. get: function() {
  3586. calls += "y";
  3587. }
  3588. });
  3589. if (calls === "dy") {
  3590. return descriptor.get;
  3591. }
  3592. }
  3593. }
  3594. return implementation;
  3595. };
  3596. }
  3597. });
  3598. // node_modules/regexp.prototype.flags/shim.js
  3599. var require_shim2 = __commonJS({
  3600. "node_modules/regexp.prototype.flags/shim.js"(exports, module) {
  3601. "use strict";
  3602. var supportsDescriptors = require_define_properties().supportsDescriptors;
  3603. var getPolyfill = require_polyfill2();
  3604. var gOPD = Object.getOwnPropertyDescriptor;
  3605. var defineProperty = Object.defineProperty;
  3606. var TypeErr = TypeError;
  3607. var getProto = Object.getPrototypeOf;
  3608. var regex = /a/;
  3609. module.exports = function shimFlags() {
  3610. if (!supportsDescriptors || !getProto) {
  3611. throw new TypeErr("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");
  3612. }
  3613. var polyfill = getPolyfill();
  3614. var proto = getProto(regex);
  3615. var descriptor = gOPD(proto, "flags");
  3616. if (!descriptor || descriptor.get !== polyfill) {
  3617. defineProperty(proto, "flags", {
  3618. configurable: true,
  3619. enumerable: false,
  3620. get: polyfill
  3621. });
  3622. }
  3623. return polyfill;
  3624. };
  3625. }
  3626. });
  3627. // node_modules/regexp.prototype.flags/index.js
  3628. var require_regexp_prototype = __commonJS({
  3629. "node_modules/regexp.prototype.flags/index.js"(exports, module) {
  3630. "use strict";
  3631. var define2 = require_define_properties();
  3632. var callBind = require_call_bind();
  3633. var implementation = require_implementation4();
  3634. var getPolyfill = require_polyfill2();
  3635. var shim = require_shim2();
  3636. var flagsBound = callBind(getPolyfill());
  3637. define2(flagsBound, {
  3638. getPolyfill,
  3639. implementation,
  3640. shim
  3641. });
  3642. module.exports = flagsBound;
  3643. }
  3644. });
  3645. // node_modules/is-date-object/index.js
  3646. var require_is_date_object = __commonJS({
  3647. "node_modules/is-date-object/index.js"(exports, module) {
  3648. "use strict";
  3649. var getDay = Date.prototype.getDay;
  3650. var tryDateObject = function tryDateGetDayCall(value) {
  3651. try {
  3652. getDay.call(value);
  3653. return true;
  3654. } catch (e) {
  3655. return false;
  3656. }
  3657. };
  3658. var toStr = Object.prototype.toString;
  3659. var dateClass = "[object Date]";
  3660. var hasToStringTag = require_shams2()();
  3661. module.exports = function isDateObject(value) {
  3662. if (typeof value !== "object" || value === null) {
  3663. return false;
  3664. }
  3665. return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
  3666. };
  3667. }
  3668. });
  3669. // node_modules/deep-equal/index.js
  3670. var require_deep_equal = __commonJS({
  3671. "node_modules/deep-equal/index.js"(exports, module) {
  3672. var objectKeys = require_object_keys();
  3673. var isArguments = require_is_arguments();
  3674. var is = require_object_is();
  3675. var isRegex = require_is_regex();
  3676. var flags = require_regexp_prototype();
  3677. var isDate = require_is_date_object();
  3678. var getTime = Date.prototype.getTime;
  3679. function deepEqual(actual, expected, options) {
  3680. var opts = options || {};
  3681. if (opts.strict ? is(actual, expected) : actual === expected) {
  3682. return true;
  3683. }
  3684. if (!actual || !expected || typeof actual !== "object" && typeof expected !== "object") {
  3685. return opts.strict ? is(actual, expected) : actual == expected;
  3686. }
  3687. return objEquiv(actual, expected, opts);
  3688. }
  3689. function isUndefinedOrNull(value) {
  3690. return value === null || value === void 0;
  3691. }
  3692. function isBuffer(x2) {
  3693. if (!x2 || typeof x2 !== "object" || typeof x2.length !== "number") {
  3694. return false;
  3695. }
  3696. if (typeof x2.copy !== "function" || typeof x2.slice !== "function") {
  3697. return false;
  3698. }
  3699. if (x2.length > 0 && typeof x2[0] !== "number") {
  3700. return false;
  3701. }
  3702. return true;
  3703. }
  3704. function objEquiv(a, b, opts) {
  3705. var i, key;
  3706. if (typeof a !== typeof b) {
  3707. return false;
  3708. }
  3709. if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) {
  3710. return false;
  3711. }
  3712. if (a.prototype !== b.prototype) {
  3713. return false;
  3714. }
  3715. if (isArguments(a) !== isArguments(b)) {
  3716. return false;
  3717. }
  3718. var aIsRegex = isRegex(a);
  3719. var bIsRegex = isRegex(b);
  3720. if (aIsRegex !== bIsRegex) {
  3721. return false;
  3722. }
  3723. if (aIsRegex || bIsRegex) {
  3724. return a.source === b.source && flags(a) === flags(b);
  3725. }
  3726. if (isDate(a) && isDate(b)) {
  3727. return getTime.call(a) === getTime.call(b);
  3728. }
  3729. var aIsBuffer = isBuffer(a);
  3730. var bIsBuffer = isBuffer(b);
  3731. if (aIsBuffer !== bIsBuffer) {
  3732. return false;
  3733. }
  3734. if (aIsBuffer || bIsBuffer) {
  3735. if (a.length !== b.length) {
  3736. return false;
  3737. }
  3738. for (i = 0; i < a.length; i++) {
  3739. if (a[i] !== b[i]) {
  3740. return false;
  3741. }
  3742. }
  3743. return true;
  3744. }
  3745. if (typeof a !== typeof b) {
  3746. return false;
  3747. }
  3748. try {
  3749. var ka = objectKeys(a);
  3750. var kb = objectKeys(b);
  3751. } catch (e) {
  3752. return false;
  3753. }
  3754. if (ka.length !== kb.length) {
  3755. return false;
  3756. }
  3757. ka.sort();
  3758. kb.sort();
  3759. for (i = ka.length - 1; i >= 0; i--) {
  3760. if (ka[i] != kb[i]) {
  3761. return false;
  3762. }
  3763. }
  3764. for (i = ka.length - 1; i >= 0; i--) {
  3765. key = ka[i];
  3766. if (!deepEqual(a[key], b[key], opts)) {
  3767. return false;
  3768. }
  3769. }
  3770. return true;
  3771. }
  3772. module.exports = deepEqual;
  3773. }
  3774. });
  3775. // node_modules/geojson-equality/index.js
  3776. var require_geojson_equality = __commonJS({
  3777. "node_modules/geojson-equality/index.js"(exports, module) {
  3778. var deepEqual = require_deep_equal();
  3779. var Equality = function(opt) {
  3780. this.precision = opt && opt.precision ? opt.precision : 17;
  3781. this.direction = opt && opt.direction ? opt.direction : false;
  3782. this.pseudoNode = opt && opt.pseudoNode ? opt.pseudoNode : false;
  3783. this.objectComparator = opt && opt.objectComparator ? opt.objectComparator : objectComparator;
  3784. };
  3785. Equality.prototype.compare = function(g1, g2) {
  3786. if (g1.type !== g2.type || !sameLength(g1, g2))
  3787. return false;
  3788. switch (g1.type) {
  3789. case "Point":
  3790. return this.compareCoord(g1.coordinates, g2.coordinates);
  3791. break;
  3792. case "LineString":
  3793. return this.compareLine(g1.coordinates, g2.coordinates, 0, false);
  3794. break;
  3795. case "Polygon":
  3796. return this.comparePolygon(g1, g2);
  3797. break;
  3798. case "Feature":
  3799. return this.compareFeature(g1, g2);
  3800. default:
  3801. if (g1.type.indexOf("Multi") === 0) {
  3802. var context = this;
  3803. var g1s = explode2(g1);
  3804. var g2s = explode2(g2);
  3805. return g1s.every(function(g1part) {
  3806. return this.some(function(g2part) {
  3807. return context.compare(g1part, g2part);
  3808. });
  3809. }, g2s);
  3810. }
  3811. }
  3812. return false;
  3813. };
  3814. function explode2(g) {
  3815. return g.coordinates.map(function(part) {
  3816. return {
  3817. type: g.type.replace("Multi", ""),
  3818. coordinates: part
  3819. };
  3820. });
  3821. }
  3822. function sameLength(g1, g2) {
  3823. return g1.hasOwnProperty("coordinates") ? g1.coordinates.length === g2.coordinates.length : g1.length === g2.length;
  3824. }
  3825. Equality.prototype.compareCoord = function(c1, c2) {
  3826. if (c1.length !== c2.length) {
  3827. return false;
  3828. }
  3829. for (var i = 0; i < c1.length; i++) {
  3830. if (c1[i].toFixed(this.precision) !== c2[i].toFixed(this.precision)) {
  3831. return false;
  3832. }
  3833. }
  3834. return true;
  3835. };
  3836. Equality.prototype.compareLine = function(path1, path2, ind, isPoly) {
  3837. if (!sameLength(path1, path2))
  3838. return false;
  3839. var p1 = this.pseudoNode ? path1 : this.removePseudo(path1);
  3840. var p2 = this.pseudoNode ? path2 : this.removePseudo(path2);
  3841. if (isPoly && !this.compareCoord(p1[0], p2[0])) {
  3842. p2 = this.fixStartIndex(p2, p1);
  3843. if (!p2)
  3844. return;
  3845. }
  3846. var sameDirection = this.compareCoord(p1[ind], p2[ind]);
  3847. if (this.direction || sameDirection) {
  3848. return this.comparePath(p1, p2);
  3849. } else {
  3850. if (this.compareCoord(p1[ind], p2[p2.length - (1 + ind)])) {
  3851. return this.comparePath(p1.slice().reverse(), p2);
  3852. }
  3853. return false;
  3854. }
  3855. };
  3856. Equality.prototype.fixStartIndex = function(sourcePath, targetPath) {
  3857. var correctPath, ind = -1;
  3858. for (var i = 0; i < sourcePath.length; i++) {
  3859. if (this.compareCoord(sourcePath[i], targetPath[0])) {
  3860. ind = i;
  3861. break;
  3862. }
  3863. }
  3864. if (ind >= 0) {
  3865. correctPath = [].concat(
  3866. sourcePath.slice(ind, sourcePath.length),
  3867. sourcePath.slice(1, ind + 1)
  3868. );
  3869. }
  3870. return correctPath;
  3871. };
  3872. Equality.prototype.comparePath = function(p1, p2) {
  3873. var cont = this;
  3874. return p1.every(function(c, i) {
  3875. return cont.compareCoord(c, this[i]);
  3876. }, p2);
  3877. };
  3878. Equality.prototype.comparePolygon = function(g1, g2) {
  3879. if (this.compareLine(g1.coordinates[0], g2.coordinates[0], 1, true)) {
  3880. var holes1 = g1.coordinates.slice(1, g1.coordinates.length);
  3881. var holes2 = g2.coordinates.slice(1, g2.coordinates.length);
  3882. var cont = this;
  3883. return holes1.every(function(h1) {
  3884. return this.some(function(h2) {
  3885. return cont.compareLine(h1, h2, 1, true);
  3886. });
  3887. }, holes2);
  3888. } else {
  3889. return false;
  3890. }
  3891. };
  3892. Equality.prototype.compareFeature = function(g1, g2) {
  3893. if (g1.id !== g2.id || !this.objectComparator(g1.properties, g2.properties) || !this.compareBBox(g1, g2)) {
  3894. return false;
  3895. }
  3896. return this.compare(g1.geometry, g2.geometry);
  3897. };
  3898. Equality.prototype.compareBBox = function(g1, g2) {
  3899. if (!g1.bbox && !g2.bbox || g1.bbox && g2.bbox && this.compareCoord(g1.bbox, g2.bbox)) {
  3900. return true;
  3901. }
  3902. return false;
  3903. };
  3904. Equality.prototype.removePseudo = function(path) {
  3905. return path;
  3906. };
  3907. function objectComparator(obj1, obj2) {
  3908. return deepEqual(obj1, obj2, { strict: true });
  3909. }
  3910. module.exports = Equality;
  3911. }
  3912. });
  3913. // node_modules/density-clustering/lib/DBSCAN.js
  3914. var require_DBSCAN = __commonJS({
  3915. "node_modules/density-clustering/lib/DBSCAN.js"(exports, module) {
  3916. function DBSCAN(dataset, epsilon5, minPts, distanceFunction) {
  3917. this.dataset = [];
  3918. this.epsilon = 1;
  3919. this.minPts = 2;
  3920. this.distance = this._euclideanDistance;
  3921. this.clusters = [];
  3922. this.noise = [];
  3923. this._visited = [];
  3924. this._assigned = [];
  3925. this._datasetLength = 0;
  3926. this._init(dataset, epsilon5, minPts, distanceFunction);
  3927. }
  3928. DBSCAN.prototype.run = function(dataset, epsilon5, minPts, distanceFunction) {
  3929. this._init(dataset, epsilon5, minPts, distanceFunction);
  3930. for (var pointId = 0; pointId < this._datasetLength; pointId++) {
  3931. if (this._visited[pointId] !== 1) {
  3932. this._visited[pointId] = 1;
  3933. var neighbors = this._regionQuery(pointId);
  3934. if (neighbors.length < this.minPts) {
  3935. this.noise.push(pointId);
  3936. } else {
  3937. var clusterId = this.clusters.length;
  3938. this.clusters.push([]);
  3939. this._addToCluster(pointId, clusterId);
  3940. this._expandCluster(clusterId, neighbors);
  3941. }
  3942. }
  3943. }
  3944. return this.clusters;
  3945. };
  3946. DBSCAN.prototype._init = function(dataset, epsilon5, minPts, distance11) {
  3947. if (dataset) {
  3948. if (!(dataset instanceof Array)) {
  3949. throw Error("Dataset must be of type array, " + typeof dataset + " given");
  3950. }
  3951. this.dataset = dataset;
  3952. this.clusters = [];
  3953. this.noise = [];
  3954. this._datasetLength = dataset.length;
  3955. this._visited = new Array(this._datasetLength);
  3956. this._assigned = new Array(this._datasetLength);
  3957. }
  3958. if (epsilon5) {
  3959. this.epsilon = epsilon5;
  3960. }
  3961. if (minPts) {
  3962. this.minPts = minPts;
  3963. }
  3964. if (distance11) {
  3965. this.distance = distance11;
  3966. }
  3967. };
  3968. DBSCAN.prototype._expandCluster = function(clusterId, neighbors) {
  3969. for (var i = 0; i < neighbors.length; i++) {
  3970. var pointId2 = neighbors[i];
  3971. if (this._visited[pointId2] !== 1) {
  3972. this._visited[pointId2] = 1;
  3973. var neighbors2 = this._regionQuery(pointId2);
  3974. if (neighbors2.length >= this.minPts) {
  3975. neighbors = this._mergeArrays(neighbors, neighbors2);
  3976. }
  3977. }
  3978. if (this._assigned[pointId2] !== 1) {
  3979. this._addToCluster(pointId2, clusterId);
  3980. }
  3981. }
  3982. };
  3983. DBSCAN.prototype._addToCluster = function(pointId, clusterId) {
  3984. this.clusters[clusterId].push(pointId);
  3985. this._assigned[pointId] = 1;
  3986. };
  3987. DBSCAN.prototype._regionQuery = function(pointId) {
  3988. var neighbors = [];
  3989. for (var id = 0; id < this._datasetLength; id++) {
  3990. var dist = this.distance(this.dataset[pointId], this.dataset[id]);
  3991. if (dist < this.epsilon) {
  3992. neighbors.push(id);
  3993. }
  3994. }
  3995. return neighbors;
  3996. };
  3997. DBSCAN.prototype._mergeArrays = function(a, b) {
  3998. var len = b.length;
  3999. for (var i = 0; i < len; i++) {
  4000. var P = b[i];
  4001. if (a.indexOf(P) < 0) {
  4002. a.push(P);
  4003. }
  4004. }
  4005. return a;
  4006. };
  4007. DBSCAN.prototype._euclideanDistance = function(p, q) {
  4008. var sum2 = 0;
  4009. var i = Math.min(p.length, q.length);
  4010. while (i--) {
  4011. sum2 += (p[i] - q[i]) * (p[i] - q[i]);
  4012. }
  4013. return Math.sqrt(sum2);
  4014. };
  4015. if (typeof module !== "undefined" && module.exports) {
  4016. module.exports = DBSCAN;
  4017. }
  4018. }
  4019. });
  4020. // node_modules/density-clustering/lib/KMEANS.js
  4021. var require_KMEANS = __commonJS({
  4022. "node_modules/density-clustering/lib/KMEANS.js"(exports, module) {
  4023. function KMEANS(dataset, k, distance11) {
  4024. this.k = 3;
  4025. this.dataset = [];
  4026. this.assignments = [];
  4027. this.centroids = [];
  4028. this.init(dataset, k, distance11);
  4029. }
  4030. KMEANS.prototype.init = function(dataset, k, distance11) {
  4031. this.assignments = [];
  4032. this.centroids = [];
  4033. if (typeof dataset !== "undefined") {
  4034. this.dataset = dataset;
  4035. }
  4036. if (typeof k !== "undefined") {
  4037. this.k = k;
  4038. }
  4039. if (typeof distance11 !== "undefined") {
  4040. this.distance = distance11;
  4041. }
  4042. };
  4043. KMEANS.prototype.run = function(dataset, k) {
  4044. this.init(dataset, k);
  4045. var len = this.dataset.length;
  4046. for (var i = 0; i < this.k; i++) {
  4047. this.centroids[i] = this.randomCentroid();
  4048. }
  4049. var change = true;
  4050. while (change) {
  4051. change = this.assign();
  4052. for (var centroidId = 0; centroidId < this.k; centroidId++) {
  4053. var mean2 = new Array(maxDim);
  4054. var count2 = 0;
  4055. for (var dim = 0; dim < maxDim; dim++) {
  4056. mean2[dim] = 0;
  4057. }
  4058. for (var j = 0; j < len; j++) {
  4059. var maxDim = this.dataset[j].length;
  4060. if (centroidId === this.assignments[j]) {
  4061. for (var dim = 0; dim < maxDim; dim++) {
  4062. mean2[dim] += this.dataset[j][dim];
  4063. }
  4064. count2++;
  4065. }
  4066. }
  4067. if (count2 > 0) {
  4068. for (var dim = 0; dim < maxDim; dim++) {
  4069. mean2[dim] /= count2;
  4070. }
  4071. this.centroids[centroidId] = mean2;
  4072. } else {
  4073. this.centroids[centroidId] = this.randomCentroid();
  4074. change = true;
  4075. }
  4076. }
  4077. }
  4078. return this.getClusters();
  4079. };
  4080. KMEANS.prototype.randomCentroid = function() {
  4081. var maxId = this.dataset.length - 1;
  4082. var centroid4;
  4083. var id;
  4084. do {
  4085. id = Math.round(Math.random() * maxId);
  4086. centroid4 = this.dataset[id];
  4087. } while (this.centroids.indexOf(centroid4) >= 0);
  4088. return centroid4;
  4089. };
  4090. KMEANS.prototype.assign = function() {
  4091. var change = false;
  4092. var len = this.dataset.length;
  4093. var closestCentroid;
  4094. for (var i = 0; i < len; i++) {
  4095. closestCentroid = this.argmin(this.dataset[i], this.centroids, this.distance);
  4096. if (closestCentroid != this.assignments[i]) {
  4097. this.assignments[i] = closestCentroid;
  4098. change = true;
  4099. }
  4100. }
  4101. return change;
  4102. };
  4103. KMEANS.prototype.getClusters = function() {
  4104. var clusters = new Array(this.k);
  4105. var centroidId;
  4106. for (var pointId = 0; pointId < this.assignments.length; pointId++) {
  4107. centroidId = this.assignments[pointId];
  4108. if (typeof clusters[centroidId] === "undefined") {
  4109. clusters[centroidId] = [];
  4110. }
  4111. clusters[centroidId].push(pointId);
  4112. }
  4113. return clusters;
  4114. };
  4115. KMEANS.prototype.argmin = function(point4, set, f) {
  4116. var min4 = Number.MAX_VALUE;
  4117. var arg = 0;
  4118. var len = set.length;
  4119. var d;
  4120. for (var i = 0; i < len; i++) {
  4121. d = f(point4, set[i]);
  4122. if (d < min4) {
  4123. min4 = d;
  4124. arg = i;
  4125. }
  4126. }
  4127. return arg;
  4128. };
  4129. KMEANS.prototype.distance = function(p, q) {
  4130. var sum2 = 0;
  4131. var i = Math.min(p.length, q.length);
  4132. while (i--) {
  4133. var diff2 = p[i] - q[i];
  4134. sum2 += diff2 * diff2;
  4135. }
  4136. return Math.sqrt(sum2);
  4137. };
  4138. if (typeof module !== "undefined" && module.exports) {
  4139. module.exports = KMEANS;
  4140. }
  4141. }
  4142. });
  4143. // node_modules/density-clustering/lib/PriorityQueue.js
  4144. var require_PriorityQueue = __commonJS({
  4145. "node_modules/density-clustering/lib/PriorityQueue.js"(exports, module) {
  4146. function PriorityQueue3(elements, priorities, sorting) {
  4147. this._queue = [];
  4148. this._priorities = [];
  4149. this._sorting = "desc";
  4150. this._init(elements, priorities, sorting);
  4151. }
  4152. PriorityQueue3.prototype.insert = function(ele, priority) {
  4153. var indexToInsert = this._queue.length;
  4154. var index2 = indexToInsert;
  4155. while (index2--) {
  4156. var priority2 = this._priorities[index2];
  4157. if (this._sorting === "desc") {
  4158. if (priority > priority2) {
  4159. indexToInsert = index2;
  4160. }
  4161. } else {
  4162. if (priority < priority2) {
  4163. indexToInsert = index2;
  4164. }
  4165. }
  4166. }
  4167. this._insertAt(ele, priority, indexToInsert);
  4168. };
  4169. PriorityQueue3.prototype.remove = function(ele) {
  4170. var index2 = this._queue.length;
  4171. while (index2--) {
  4172. var ele2 = this._queue[index2];
  4173. if (ele === ele2) {
  4174. this._queue.splice(index2, 1);
  4175. this._priorities.splice(index2, 1);
  4176. break;
  4177. }
  4178. }
  4179. };
  4180. PriorityQueue3.prototype.forEach = function(func) {
  4181. this._queue.forEach(func);
  4182. };
  4183. PriorityQueue3.prototype.getElements = function() {
  4184. return this._queue;
  4185. };
  4186. PriorityQueue3.prototype.getElementPriority = function(index2) {
  4187. return this._priorities[index2];
  4188. };
  4189. PriorityQueue3.prototype.getPriorities = function() {
  4190. return this._priorities;
  4191. };
  4192. PriorityQueue3.prototype.getElementsWithPriorities = function() {
  4193. var result = [];
  4194. for (var i = 0, l = this._queue.length; i < l; i++) {
  4195. result.push([this._queue[i], this._priorities[i]]);
  4196. }
  4197. return result;
  4198. };
  4199. PriorityQueue3.prototype._init = function(elements, priorities, sorting) {
  4200. if (elements && priorities) {
  4201. this._queue = [];
  4202. this._priorities = [];
  4203. if (elements.length !== priorities.length) {
  4204. throw new Error("Arrays must have the same length");
  4205. }
  4206. for (var i = 0; i < elements.length; i++) {
  4207. this.insert(elements[i], priorities[i]);
  4208. }
  4209. }
  4210. if (sorting) {
  4211. this._sorting = sorting;
  4212. }
  4213. };
  4214. PriorityQueue3.prototype._insertAt = function(ele, priority, index2) {
  4215. if (this._queue.length === index2) {
  4216. this._queue.push(ele);
  4217. this._priorities.push(priority);
  4218. } else {
  4219. this._queue.splice(index2, 0, ele);
  4220. this._priorities.splice(index2, 0, priority);
  4221. }
  4222. };
  4223. if (typeof module !== "undefined" && module.exports) {
  4224. module.exports = PriorityQueue3;
  4225. }
  4226. }
  4227. });
  4228. // node_modules/density-clustering/lib/OPTICS.js
  4229. var require_OPTICS = __commonJS({
  4230. "node_modules/density-clustering/lib/OPTICS.js"(exports, module) {
  4231. if (typeof module !== "undefined" && module.exports) {
  4232. PriorityQueue3 = require_PriorityQueue();
  4233. }
  4234. var PriorityQueue3;
  4235. function OPTICS(dataset, epsilon5, minPts, distanceFunction) {
  4236. this.epsilon = 1;
  4237. this.minPts = 1;
  4238. this.distance = this._euclideanDistance;
  4239. this._reachability = [];
  4240. this._processed = [];
  4241. this._coreDistance = 0;
  4242. this._orderedList = [];
  4243. this._init(dataset, epsilon5, minPts, distanceFunction);
  4244. }
  4245. OPTICS.prototype.run = function(dataset, epsilon5, minPts, distanceFunction) {
  4246. this._init(dataset, epsilon5, minPts, distanceFunction);
  4247. for (var pointId = 0, l = this.dataset.length; pointId < l; pointId++) {
  4248. if (this._processed[pointId] !== 1) {
  4249. this._processed[pointId] = 1;
  4250. this.clusters.push([pointId]);
  4251. var clusterId = this.clusters.length - 1;
  4252. this._orderedList.push(pointId);
  4253. var priorityQueue = new PriorityQueue3(null, null, "asc");
  4254. var neighbors = this._regionQuery(pointId);
  4255. if (this._distanceToCore(pointId) !== void 0) {
  4256. this._updateQueue(pointId, neighbors, priorityQueue);
  4257. this._expandCluster(clusterId, priorityQueue);
  4258. }
  4259. }
  4260. }
  4261. return this.clusters;
  4262. };
  4263. OPTICS.prototype.getReachabilityPlot = function() {
  4264. var reachabilityPlot = [];
  4265. for (var i = 0, l = this._orderedList.length; i < l; i++) {
  4266. var pointId = this._orderedList[i];
  4267. var distance11 = this._reachability[pointId];
  4268. reachabilityPlot.push([pointId, distance11]);
  4269. }
  4270. return reachabilityPlot;
  4271. };
  4272. OPTICS.prototype._init = function(dataset, epsilon5, minPts, distance11) {
  4273. if (dataset) {
  4274. if (!(dataset instanceof Array)) {
  4275. throw Error("Dataset must be of type array, " + typeof dataset + " given");
  4276. }
  4277. this.dataset = dataset;
  4278. this.clusters = [];
  4279. this._reachability = new Array(this.dataset.length);
  4280. this._processed = new Array(this.dataset.length);
  4281. this._coreDistance = 0;
  4282. this._orderedList = [];
  4283. }
  4284. if (epsilon5) {
  4285. this.epsilon = epsilon5;
  4286. }
  4287. if (minPts) {
  4288. this.minPts = minPts;
  4289. }
  4290. if (distance11) {
  4291. this.distance = distance11;
  4292. }
  4293. };
  4294. OPTICS.prototype._updateQueue = function(pointId, neighbors, queue) {
  4295. var self2 = this;
  4296. this._coreDistance = this._distanceToCore(pointId);
  4297. neighbors.forEach(function(pointId2) {
  4298. if (self2._processed[pointId2] === void 0) {
  4299. var dist = self2.distance(self2.dataset[pointId], self2.dataset[pointId2]);
  4300. var newReachableDistance = Math.max(self2._coreDistance, dist);
  4301. if (self2._reachability[pointId2] === void 0) {
  4302. self2._reachability[pointId2] = newReachableDistance;
  4303. queue.insert(pointId2, newReachableDistance);
  4304. } else {
  4305. if (newReachableDistance < self2._reachability[pointId2]) {
  4306. self2._reachability[pointId2] = newReachableDistance;
  4307. queue.remove(pointId2);
  4308. queue.insert(pointId2, newReachableDistance);
  4309. }
  4310. }
  4311. }
  4312. });
  4313. };
  4314. OPTICS.prototype._expandCluster = function(clusterId, queue) {
  4315. var queueElements = queue.getElements();
  4316. for (var p = 0, l = queueElements.length; p < l; p++) {
  4317. var pointId = queueElements[p];
  4318. if (this._processed[pointId] === void 0) {
  4319. var neighbors = this._regionQuery(pointId);
  4320. this._processed[pointId] = 1;
  4321. this.clusters[clusterId].push(pointId);
  4322. this._orderedList.push(pointId);
  4323. if (this._distanceToCore(pointId) !== void 0) {
  4324. this._updateQueue(pointId, neighbors, queue);
  4325. this._expandCluster(clusterId, queue);
  4326. }
  4327. }
  4328. }
  4329. };
  4330. OPTICS.prototype._distanceToCore = function(pointId) {
  4331. var l = this.epsilon;
  4332. for (var coreDistCand = 0; coreDistCand < l; coreDistCand++) {
  4333. var neighbors = this._regionQuery(pointId, coreDistCand);
  4334. if (neighbors.length >= this.minPts) {
  4335. return coreDistCand;
  4336. }
  4337. }
  4338. return;
  4339. };
  4340. OPTICS.prototype._regionQuery = function(pointId, epsilon5) {
  4341. epsilon5 = epsilon5 || this.epsilon;
  4342. var neighbors = [];
  4343. for (var id = 0, l = this.dataset.length; id < l; id++) {
  4344. if (this.distance(this.dataset[pointId], this.dataset[id]) < epsilon5) {
  4345. neighbors.push(id);
  4346. }
  4347. }
  4348. return neighbors;
  4349. };
  4350. OPTICS.prototype._euclideanDistance = function(p, q) {
  4351. var sum2 = 0;
  4352. var i = Math.min(p.length, q.length);
  4353. while (i--) {
  4354. sum2 += (p[i] - q[i]) * (p[i] - q[i]);
  4355. }
  4356. return Math.sqrt(sum2);
  4357. };
  4358. if (typeof module !== "undefined" && module.exports) {
  4359. module.exports = OPTICS;
  4360. }
  4361. }
  4362. });
  4363. // node_modules/density-clustering/lib/index.js
  4364. var require_lib = __commonJS({
  4365. "node_modules/density-clustering/lib/index.js"(exports, module) {
  4366. if (typeof module !== "undefined" && module.exports) {
  4367. module.exports = {
  4368. DBSCAN: require_DBSCAN(),
  4369. KMEANS: require_KMEANS(),
  4370. OPTICS: require_OPTICS(),
  4371. PriorityQueue: require_PriorityQueue()
  4372. };
  4373. }
  4374. }
  4375. });
  4376. // node_modules/skmeans/dist/node/distance.js
  4377. var require_distance = __commonJS({
  4378. "node_modules/skmeans/dist/node/distance.js"(exports, module) {
  4379. "use strict";
  4380. module.exports = {
  4381. eudist: function eudist(v1, v2, sqrt4) {
  4382. var len = v1.length;
  4383. var sum2 = 0;
  4384. for (var i = 0; i < len; i++) {
  4385. var d = (v1[i] || 0) - (v2[i] || 0);
  4386. sum2 += d * d;
  4387. }
  4388. return sqrt4 ? Math.sqrt(sum2) : sum2;
  4389. },
  4390. mandist: function mandist(v1, v2, sqrt4) {
  4391. var len = v1.length;
  4392. var sum2 = 0;
  4393. for (var i = 0; i < len; i++) {
  4394. sum2 += Math.abs((v1[i] || 0) - (v2[i] || 0));
  4395. }
  4396. return sqrt4 ? Math.sqrt(sum2) : sum2;
  4397. },
  4398. dist: function dist(v1, v2, sqrt4) {
  4399. var d = Math.abs(v1 - v2);
  4400. return sqrt4 ? d : d * d;
  4401. }
  4402. };
  4403. }
  4404. });
  4405. // node_modules/skmeans/dist/node/kinit.js
  4406. var require_kinit = __commonJS({
  4407. "node_modules/skmeans/dist/node/kinit.js"(exports, module) {
  4408. "use strict";
  4409. var Distance = require_distance();
  4410. var eudist = Distance.eudist;
  4411. var dist = Distance.dist;
  4412. module.exports = {
  4413. kmrand: function kmrand(data, k) {
  4414. var map5 = {}, ks = [], t = k << 2;
  4415. var len = data.length;
  4416. var multi = data[0].length > 0;
  4417. while (ks.length < k && t-- > 0) {
  4418. var d = data[Math.floor(Math.random() * len)];
  4419. var key = multi ? d.join("_") : "" + d;
  4420. if (!map5[key]) {
  4421. map5[key] = true;
  4422. ks.push(d);
  4423. }
  4424. }
  4425. if (ks.length < k)
  4426. throw new Error("Error initializating clusters");
  4427. else
  4428. return ks;
  4429. },
  4430. kmpp: function kmpp(data, k) {
  4431. var distance11 = data[0].length ? eudist : dist;
  4432. var ks = [], len = data.length;
  4433. var multi = data[0].length > 0;
  4434. var map5 = {};
  4435. var c = data[Math.floor(Math.random() * len)];
  4436. var key = multi ? c.join("_") : "" + c;
  4437. ks.push(c);
  4438. map5[key] = true;
  4439. while (ks.length < k) {
  4440. var dists = [], lk = ks.length;
  4441. var dsum = 0, prs = [];
  4442. for (var i = 0; i < len; i++) {
  4443. var min4 = Infinity;
  4444. for (var j = 0; j < lk; j++) {
  4445. var _dist = distance11(data[i], ks[j]);
  4446. if (_dist <= min4)
  4447. min4 = _dist;
  4448. }
  4449. dists[i] = min4;
  4450. }
  4451. for (var _i = 0; _i < len; _i++) {
  4452. dsum += dists[_i];
  4453. }
  4454. for (var _i2 = 0; _i2 < len; _i2++) {
  4455. prs[_i2] = { i: _i2, v: data[_i2], pr: dists[_i2] / dsum, cs: 0 };
  4456. }
  4457. prs.sort(function(a, b) {
  4458. return a.pr - b.pr;
  4459. });
  4460. prs[0].cs = prs[0].pr;
  4461. for (var _i3 = 1; _i3 < len; _i3++) {
  4462. prs[_i3].cs = prs[_i3 - 1].cs + prs[_i3].pr;
  4463. }
  4464. var rnd2 = Math.random();
  4465. var idx = 0;
  4466. while (idx < len - 1 && prs[idx++].cs < rnd2) {
  4467. }
  4468. ks.push(prs[idx - 1].v);
  4469. }
  4470. return ks;
  4471. }
  4472. };
  4473. }
  4474. });
  4475. // node_modules/skmeans/dist/node/main.js
  4476. var require_main = __commonJS({
  4477. "node_modules/skmeans/dist/node/main.js"(exports, module) {
  4478. "use strict";
  4479. var Distance = require_distance();
  4480. var ClusterInit = require_kinit();
  4481. var eudist = Distance.eudist;
  4482. var mandist = Distance.mandist;
  4483. var dist = Distance.dist;
  4484. var kmrand = ClusterInit.kmrand;
  4485. var kmpp = ClusterInit.kmpp;
  4486. var MAX = 1e4;
  4487. function init8(len, val, v) {
  4488. v = v || [];
  4489. for (var i = 0; i < len; i++) {
  4490. v[i] = val;
  4491. }
  4492. return v;
  4493. }
  4494. function skmeans2(data, k, initial, maxit) {
  4495. var ks = [], old = [], idxs = [], dist2 = [];
  4496. var conv = false, it = maxit || MAX;
  4497. var len = data.length, vlen = data[0].length, multi = vlen > 0;
  4498. var count2 = [];
  4499. if (!initial) {
  4500. var _idxs = {};
  4501. while (ks.length < k) {
  4502. var idx = Math.floor(Math.random() * len);
  4503. if (!_idxs[idx]) {
  4504. _idxs[idx] = true;
  4505. ks.push(data[idx]);
  4506. }
  4507. }
  4508. } else if (initial == "kmrand") {
  4509. ks = kmrand(data, k);
  4510. } else if (initial == "kmpp") {
  4511. ks = kmpp(data, k);
  4512. } else {
  4513. ks = initial;
  4514. }
  4515. do {
  4516. init8(k, 0, count2);
  4517. for (var i = 0; i < len; i++) {
  4518. var min4 = Infinity, _idx = 0;
  4519. for (var j = 0; j < k; j++) {
  4520. var dist2 = multi ? eudist(data[i], ks[j]) : Math.abs(data[i] - ks[j]);
  4521. if (dist2 <= min4) {
  4522. min4 = dist2;
  4523. _idx = j;
  4524. }
  4525. }
  4526. idxs[i] = _idx;
  4527. count2[_idx]++;
  4528. }
  4529. var sum2 = [], old = [], dif = 0;
  4530. for (var _j = 0; _j < k; _j++) {
  4531. sum2[_j] = multi ? init8(vlen, 0, sum2[_j]) : 0;
  4532. old[_j] = ks[_j];
  4533. }
  4534. if (multi) {
  4535. for (var _j2 = 0; _j2 < k; _j2++) {
  4536. ks[_j2] = [];
  4537. }
  4538. for (var _i = 0; _i < len; _i++) {
  4539. var _idx2 = idxs[_i], vsum = sum2[_idx2], vect = data[_i];
  4540. for (var h = 0; h < vlen; h++) {
  4541. vsum[h] += vect[h];
  4542. }
  4543. }
  4544. conv = true;
  4545. for (var _j3 = 0; _j3 < k; _j3++) {
  4546. var ksj = ks[_j3], sumj = sum2[_j3], oldj = old[_j3], cj = count2[_j3];
  4547. for (var _h = 0; _h < vlen; _h++) {
  4548. ksj[_h] = sumj[_h] / cj || 0;
  4549. }
  4550. if (conv) {
  4551. for (var _h2 = 0; _h2 < vlen; _h2++) {
  4552. if (oldj[_h2] != ksj[_h2]) {
  4553. conv = false;
  4554. break;
  4555. }
  4556. }
  4557. }
  4558. }
  4559. } else {
  4560. for (var _i2 = 0; _i2 < len; _i2++) {
  4561. var _idx3 = idxs[_i2];
  4562. sum2[_idx3] += data[_i2];
  4563. }
  4564. for (var _j4 = 0; _j4 < k; _j4++) {
  4565. ks[_j4] = sum2[_j4] / count2[_j4] || 0;
  4566. }
  4567. conv = true;
  4568. for (var _j5 = 0; _j5 < k; _j5++) {
  4569. if (old[_j5] != ks[_j5]) {
  4570. conv = false;
  4571. break;
  4572. }
  4573. }
  4574. }
  4575. conv = conv || --it <= 0;
  4576. } while (!conv);
  4577. return {
  4578. it: MAX - it,
  4579. k,
  4580. idxs,
  4581. centroids: ks
  4582. };
  4583. }
  4584. module.exports = skmeans2;
  4585. }
  4586. });
  4587. // node_modules/@turf/meta/dist/es/index.js
  4588. var es_exports2 = {};
  4589. __export(es_exports2, {
  4590. coordAll: () => coordAll,
  4591. coordEach: () => coordEach,
  4592. coordReduce: () => coordReduce,
  4593. featureEach: () => featureEach,
  4594. featureReduce: () => featureReduce,
  4595. findPoint: () => findPoint,
  4596. findSegment: () => findSegment,
  4597. flattenEach: () => flattenEach,
  4598. flattenReduce: () => flattenReduce,
  4599. geomEach: () => geomEach,
  4600. geomReduce: () => geomReduce,
  4601. lineEach: () => lineEach,
  4602. lineReduce: () => lineReduce,
  4603. propEach: () => propEach,
  4604. propReduce: () => propReduce,
  4605. segmentEach: () => segmentEach,
  4606. segmentReduce: () => segmentReduce
  4607. });
  4608. // node_modules/@turf/helpers/dist/es/index.js
  4609. var es_exports = {};
  4610. __export(es_exports, {
  4611. areaFactors: () => areaFactors,
  4612. bearingToAzimuth: () => bearingToAzimuth,
  4613. convertArea: () => convertArea,
  4614. convertLength: () => convertLength,
  4615. degreesToRadians: () => degreesToRadians,
  4616. earthRadius: () => earthRadius,
  4617. factors: () => factors,
  4618. feature: () => feature,
  4619. featureCollection: () => featureCollection,
  4620. geometry: () => geometry,
  4621. geometryCollection: () => geometryCollection,
  4622. isNumber: () => isNumber,
  4623. isObject: () => isObject,
  4624. lengthToDegrees: () => lengthToDegrees,
  4625. lengthToRadians: () => lengthToRadians,
  4626. lineString: () => lineString,
  4627. lineStrings: () => lineStrings,
  4628. multiLineString: () => multiLineString,
  4629. multiPoint: () => multiPoint,
  4630. multiPolygon: () => multiPolygon,
  4631. point: () => point,
  4632. points: () => points,
  4633. polygon: () => polygon,
  4634. polygons: () => polygons,
  4635. radiansToDegrees: () => radiansToDegrees,
  4636. radiansToLength: () => radiansToLength,
  4637. round: () => round,
  4638. unitsFactors: () => unitsFactors,
  4639. validateBBox: () => validateBBox,
  4640. validateId: () => validateId
  4641. });
  4642. var earthRadius = 63710088e-1;
  4643. var factors = {
  4644. centimeters: earthRadius * 100,
  4645. centimetres: earthRadius * 100,
  4646. degrees: earthRadius / 111325,
  4647. feet: earthRadius * 3.28084,
  4648. inches: earthRadius * 39.37,
  4649. kilometers: earthRadius / 1e3,
  4650. kilometres: earthRadius / 1e3,
  4651. meters: earthRadius,
  4652. metres: earthRadius,
  4653. miles: earthRadius / 1609.344,
  4654. millimeters: earthRadius * 1e3,
  4655. millimetres: earthRadius * 1e3,
  4656. nauticalmiles: earthRadius / 1852,
  4657. radians: 1,
  4658. yards: earthRadius * 1.0936
  4659. };
  4660. var unitsFactors = {
  4661. centimeters: 100,
  4662. centimetres: 100,
  4663. degrees: 1 / 111325,
  4664. feet: 3.28084,
  4665. inches: 39.37,
  4666. kilometers: 1 / 1e3,
  4667. kilometres: 1 / 1e3,
  4668. meters: 1,
  4669. metres: 1,
  4670. miles: 1 / 1609.344,
  4671. millimeters: 1e3,
  4672. millimetres: 1e3,
  4673. nauticalmiles: 1 / 1852,
  4674. radians: 1 / earthRadius,
  4675. yards: 1.0936133
  4676. };
  4677. var areaFactors = {
  4678. acres: 247105e-9,
  4679. centimeters: 1e4,
  4680. centimetres: 1e4,
  4681. feet: 10.763910417,
  4682. hectares: 1e-4,
  4683. inches: 1550.003100006,
  4684. kilometers: 1e-6,
  4685. kilometres: 1e-6,
  4686. meters: 1,
  4687. metres: 1,
  4688. miles: 386e-9,
  4689. millimeters: 1e6,
  4690. millimetres: 1e6,
  4691. yards: 1.195990046
  4692. };
  4693. function feature(geom, properties, options) {
  4694. if (options === void 0) {
  4695. options = {};
  4696. }
  4697. var feat = { type: "Feature" };
  4698. if (options.id === 0 || options.id) {
  4699. feat.id = options.id;
  4700. }
  4701. if (options.bbox) {
  4702. feat.bbox = options.bbox;
  4703. }
  4704. feat.properties = properties || {};
  4705. feat.geometry = geom;
  4706. return feat;
  4707. }
  4708. function geometry(type, coordinates, _options) {
  4709. if (_options === void 0) {
  4710. _options = {};
  4711. }
  4712. switch (type) {
  4713. case "Point":
  4714. return point(coordinates).geometry;
  4715. case "LineString":
  4716. return lineString(coordinates).geometry;
  4717. case "Polygon":
  4718. return polygon(coordinates).geometry;
  4719. case "MultiPoint":
  4720. return multiPoint(coordinates).geometry;
  4721. case "MultiLineString":
  4722. return multiLineString(coordinates).geometry;
  4723. case "MultiPolygon":
  4724. return multiPolygon(coordinates).geometry;
  4725. default:
  4726. throw new Error(type + " is invalid");
  4727. }
  4728. }
  4729. function point(coordinates, properties, options) {
  4730. if (options === void 0) {
  4731. options = {};
  4732. }
  4733. if (!coordinates) {
  4734. throw new Error("coordinates is required");
  4735. }
  4736. if (!Array.isArray(coordinates)) {
  4737. throw new Error("coordinates must be an Array");
  4738. }
  4739. if (coordinates.length < 2) {
  4740. throw new Error("coordinates must be at least 2 numbers long");
  4741. }
  4742. if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
  4743. throw new Error("coordinates must contain numbers");
  4744. }
  4745. var geom = {
  4746. type: "Point",
  4747. coordinates
  4748. };
  4749. return feature(geom, properties, options);
  4750. }
  4751. function points(coordinates, properties, options) {
  4752. if (options === void 0) {
  4753. options = {};
  4754. }
  4755. return featureCollection(coordinates.map(function(coords) {
  4756. return point(coords, properties);
  4757. }), options);
  4758. }
  4759. function polygon(coordinates, properties, options) {
  4760. if (options === void 0) {
  4761. options = {};
  4762. }
  4763. for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
  4764. var ring = coordinates_1[_i];
  4765. if (ring.length < 4) {
  4766. throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
  4767. }
  4768. for (var j = 0; j < ring[ring.length - 1].length; j++) {
  4769. if (ring[ring.length - 1][j] !== ring[0][j]) {
  4770. throw new Error("First and last Position are not equivalent.");
  4771. }
  4772. }
  4773. }
  4774. var geom = {
  4775. type: "Polygon",
  4776. coordinates
  4777. };
  4778. return feature(geom, properties, options);
  4779. }
  4780. function polygons(coordinates, properties, options) {
  4781. if (options === void 0) {
  4782. options = {};
  4783. }
  4784. return featureCollection(coordinates.map(function(coords) {
  4785. return polygon(coords, properties);
  4786. }), options);
  4787. }
  4788. function lineString(coordinates, properties, options) {
  4789. if (options === void 0) {
  4790. options = {};
  4791. }
  4792. if (coordinates.length < 2) {
  4793. throw new Error("coordinates must be an array of two or more positions");
  4794. }
  4795. var geom = {
  4796. type: "LineString",
  4797. coordinates
  4798. };
  4799. return feature(geom, properties, options);
  4800. }
  4801. function lineStrings(coordinates, properties, options) {
  4802. if (options === void 0) {
  4803. options = {};
  4804. }
  4805. return featureCollection(coordinates.map(function(coords) {
  4806. return lineString(coords, properties);
  4807. }), options);
  4808. }
  4809. function featureCollection(features, options) {
  4810. if (options === void 0) {
  4811. options = {};
  4812. }
  4813. var fc = { type: "FeatureCollection" };
  4814. if (options.id) {
  4815. fc.id = options.id;
  4816. }
  4817. if (options.bbox) {
  4818. fc.bbox = options.bbox;
  4819. }
  4820. fc.features = features;
  4821. return fc;
  4822. }
  4823. function multiLineString(coordinates, properties, options) {
  4824. if (options === void 0) {
  4825. options = {};
  4826. }
  4827. var geom = {
  4828. type: "MultiLineString",
  4829. coordinates
  4830. };
  4831. return feature(geom, properties, options);
  4832. }
  4833. function multiPoint(coordinates, properties, options) {
  4834. if (options === void 0) {
  4835. options = {};
  4836. }
  4837. var geom = {
  4838. type: "MultiPoint",
  4839. coordinates
  4840. };
  4841. return feature(geom, properties, options);
  4842. }
  4843. function multiPolygon(coordinates, properties, options) {
  4844. if (options === void 0) {
  4845. options = {};
  4846. }
  4847. var geom = {
  4848. type: "MultiPolygon",
  4849. coordinates
  4850. };
  4851. return feature(geom, properties, options);
  4852. }
  4853. function geometryCollection(geometries, properties, options) {
  4854. if (options === void 0) {
  4855. options = {};
  4856. }
  4857. var geom = {
  4858. type: "GeometryCollection",
  4859. geometries
  4860. };
  4861. return feature(geom, properties, options);
  4862. }
  4863. function round(num, precision) {
  4864. if (precision === void 0) {
  4865. precision = 0;
  4866. }
  4867. if (precision && !(precision >= 0)) {
  4868. throw new Error("precision must be a positive number");
  4869. }
  4870. var multiplier = Math.pow(10, precision || 0);
  4871. return Math.round(num * multiplier) / multiplier;
  4872. }
  4873. function radiansToLength(radians2, units) {
  4874. if (units === void 0) {
  4875. units = "kilometers";
  4876. }
  4877. var factor = factors[units];
  4878. if (!factor) {
  4879. throw new Error(units + " units is invalid");
  4880. }
  4881. return radians2 * factor;
  4882. }
  4883. function lengthToRadians(distance11, units) {
  4884. if (units === void 0) {
  4885. units = "kilometers";
  4886. }
  4887. var factor = factors[units];
  4888. if (!factor) {
  4889. throw new Error(units + " units is invalid");
  4890. }
  4891. return distance11 / factor;
  4892. }
  4893. function lengthToDegrees(distance11, units) {
  4894. return radiansToDegrees(lengthToRadians(distance11, units));
  4895. }
  4896. function bearingToAzimuth(bearing2) {
  4897. var angle4 = bearing2 % 360;
  4898. if (angle4 < 0) {
  4899. angle4 += 360;
  4900. }
  4901. return angle4;
  4902. }
  4903. function radiansToDegrees(radians2) {
  4904. var degrees2 = radians2 % (2 * Math.PI);
  4905. return degrees2 * 180 / Math.PI;
  4906. }
  4907. function degreesToRadians(degrees2) {
  4908. var radians2 = degrees2 % 360;
  4909. return radians2 * Math.PI / 180;
  4910. }
  4911. function convertLength(length4, originalUnit, finalUnit) {
  4912. if (originalUnit === void 0) {
  4913. originalUnit = "kilometers";
  4914. }
  4915. if (finalUnit === void 0) {
  4916. finalUnit = "kilometers";
  4917. }
  4918. if (!(length4 >= 0)) {
  4919. throw new Error("length must be a positive number");
  4920. }
  4921. return radiansToLength(lengthToRadians(length4, originalUnit), finalUnit);
  4922. }
  4923. function convertArea(area5, originalUnit, finalUnit) {
  4924. if (originalUnit === void 0) {
  4925. originalUnit = "meters";
  4926. }
  4927. if (finalUnit === void 0) {
  4928. finalUnit = "kilometers";
  4929. }
  4930. if (!(area5 >= 0)) {
  4931. throw new Error("area must be a positive number");
  4932. }
  4933. var startFactor = areaFactors[originalUnit];
  4934. if (!startFactor) {
  4935. throw new Error("invalid original units");
  4936. }
  4937. var finalFactor = areaFactors[finalUnit];
  4938. if (!finalFactor) {
  4939. throw new Error("invalid final units");
  4940. }
  4941. return area5 / startFactor * finalFactor;
  4942. }
  4943. function isNumber(num) {
  4944. return !isNaN(num) && num !== null && !Array.isArray(num);
  4945. }
  4946. function isObject(input) {
  4947. return !!input && input.constructor === Object;
  4948. }
  4949. function validateBBox(bbox3) {
  4950. if (!bbox3) {
  4951. throw new Error("bbox is required");
  4952. }
  4953. if (!Array.isArray(bbox3)) {
  4954. throw new Error("bbox must be an Array");
  4955. }
  4956. if (bbox3.length !== 4 && bbox3.length !== 6) {
  4957. throw new Error("bbox must be an Array of 4 or 6 numbers");
  4958. }
  4959. bbox3.forEach(function(num) {
  4960. if (!isNumber(num)) {
  4961. throw new Error("bbox must only contain numbers");
  4962. }
  4963. });
  4964. }
  4965. function validateId(id) {
  4966. if (!id) {
  4967. throw new Error("id is required");
  4968. }
  4969. if (["string", "number"].indexOf(typeof id) === -1) {
  4970. throw new Error("id must be a number or a string");
  4971. }
  4972. }
  4973. // node_modules/@turf/meta/dist/es/index.js
  4974. function coordEach(geojson, callback, excludeWrapCoord) {
  4975. if (geojson === null)
  4976. return;
  4977. var j, k, l, geometry2, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection2, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
  4978. for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
  4979. geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
  4980. isGeometryCollection2 = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
  4981. stopG = isGeometryCollection2 ? geometryMaybeCollection.geometries.length : 1;
  4982. for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
  4983. var multiFeatureIndex = 0;
  4984. var geometryIndex = 0;
  4985. geometry2 = isGeometryCollection2 ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
  4986. if (geometry2 === null)
  4987. continue;
  4988. coords = geometry2.coordinates;
  4989. var geomType = geometry2.type;
  4990. wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
  4991. switch (geomType) {
  4992. case null:
  4993. break;
  4994. case "Point":
  4995. if (callback(
  4996. coords,
  4997. coordIndex,
  4998. featureIndex,
  4999. multiFeatureIndex,
  5000. geometryIndex
  5001. ) === false)
  5002. return false;
  5003. coordIndex++;
  5004. multiFeatureIndex++;
  5005. break;
  5006. case "LineString":
  5007. case "MultiPoint":
  5008. for (j = 0; j < coords.length; j++) {
  5009. if (callback(
  5010. coords[j],
  5011. coordIndex,
  5012. featureIndex,
  5013. multiFeatureIndex,
  5014. geometryIndex
  5015. ) === false)
  5016. return false;
  5017. coordIndex++;
  5018. if (geomType === "MultiPoint")
  5019. multiFeatureIndex++;
  5020. }
  5021. if (geomType === "LineString")
  5022. multiFeatureIndex++;
  5023. break;
  5024. case "Polygon":
  5025. case "MultiLineString":
  5026. for (j = 0; j < coords.length; j++) {
  5027. for (k = 0; k < coords[j].length - wrapShrink; k++) {
  5028. if (callback(
  5029. coords[j][k],
  5030. coordIndex,
  5031. featureIndex,
  5032. multiFeatureIndex,
  5033. geometryIndex
  5034. ) === false)
  5035. return false;
  5036. coordIndex++;
  5037. }
  5038. if (geomType === "MultiLineString")
  5039. multiFeatureIndex++;
  5040. if (geomType === "Polygon")
  5041. geometryIndex++;
  5042. }
  5043. if (geomType === "Polygon")
  5044. multiFeatureIndex++;
  5045. break;
  5046. case "MultiPolygon":
  5047. for (j = 0; j < coords.length; j++) {
  5048. geometryIndex = 0;
  5049. for (k = 0; k < coords[j].length; k++) {
  5050. for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
  5051. if (callback(
  5052. coords[j][k][l],
  5053. coordIndex,
  5054. featureIndex,
  5055. multiFeatureIndex,
  5056. geometryIndex
  5057. ) === false)
  5058. return false;
  5059. coordIndex++;
  5060. }
  5061. geometryIndex++;
  5062. }
  5063. multiFeatureIndex++;
  5064. }
  5065. break;
  5066. case "GeometryCollection":
  5067. for (j = 0; j < geometry2.geometries.length; j++)
  5068. if (coordEach(geometry2.geometries[j], callback, excludeWrapCoord) === false)
  5069. return false;
  5070. break;
  5071. default:
  5072. throw new Error("Unknown Geometry Type");
  5073. }
  5074. }
  5075. }
  5076. }
  5077. function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
  5078. var previousValue = initialValue;
  5079. coordEach(
  5080. geojson,
  5081. function(currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  5082. if (coordIndex === 0 && initialValue === void 0)
  5083. previousValue = currentCoord;
  5084. else
  5085. previousValue = callback(
  5086. previousValue,
  5087. currentCoord,
  5088. coordIndex,
  5089. featureIndex,
  5090. multiFeatureIndex,
  5091. geometryIndex
  5092. );
  5093. },
  5094. excludeWrapCoord
  5095. );
  5096. return previousValue;
  5097. }
  5098. function propEach(geojson, callback) {
  5099. var i;
  5100. switch (geojson.type) {
  5101. case "FeatureCollection":
  5102. for (i = 0; i < geojson.features.length; i++) {
  5103. if (callback(geojson.features[i].properties, i) === false)
  5104. break;
  5105. }
  5106. break;
  5107. case "Feature":
  5108. callback(geojson.properties, 0);
  5109. break;
  5110. }
  5111. }
  5112. function propReduce(geojson, callback, initialValue) {
  5113. var previousValue = initialValue;
  5114. propEach(geojson, function(currentProperties, featureIndex) {
  5115. if (featureIndex === 0 && initialValue === void 0)
  5116. previousValue = currentProperties;
  5117. else
  5118. previousValue = callback(previousValue, currentProperties, featureIndex);
  5119. });
  5120. return previousValue;
  5121. }
  5122. function featureEach(geojson, callback) {
  5123. if (geojson.type === "Feature") {
  5124. callback(geojson, 0);
  5125. } else if (geojson.type === "FeatureCollection") {
  5126. for (var i = 0; i < geojson.features.length; i++) {
  5127. if (callback(geojson.features[i], i) === false)
  5128. break;
  5129. }
  5130. }
  5131. }
  5132. function featureReduce(geojson, callback, initialValue) {
  5133. var previousValue = initialValue;
  5134. featureEach(geojson, function(currentFeature, featureIndex) {
  5135. if (featureIndex === 0 && initialValue === void 0)
  5136. previousValue = currentFeature;
  5137. else
  5138. previousValue = callback(previousValue, currentFeature, featureIndex);
  5139. });
  5140. return previousValue;
  5141. }
  5142. function coordAll(geojson) {
  5143. var coords = [];
  5144. coordEach(geojson, function(coord) {
  5145. coords.push(coord);
  5146. });
  5147. return coords;
  5148. }
  5149. function geomEach(geojson, callback) {
  5150. var i, j, g, geometry2, stopG, geometryMaybeCollection, isGeometryCollection2, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
  5151. for (i = 0; i < stop; i++) {
  5152. geometryMaybeCollection = isFeatureCollection ? geojson.features[i].geometry : isFeature ? geojson.geometry : geojson;
  5153. featureProperties = isFeatureCollection ? geojson.features[i].properties : isFeature ? geojson.properties : {};
  5154. featureBBox = isFeatureCollection ? geojson.features[i].bbox : isFeature ? geojson.bbox : void 0;
  5155. featureId = isFeatureCollection ? geojson.features[i].id : isFeature ? geojson.id : void 0;
  5156. isGeometryCollection2 = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
  5157. stopG = isGeometryCollection2 ? geometryMaybeCollection.geometries.length : 1;
  5158. for (g = 0; g < stopG; g++) {
  5159. geometry2 = isGeometryCollection2 ? geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
  5160. if (geometry2 === null) {
  5161. if (callback(
  5162. null,
  5163. featureIndex,
  5164. featureProperties,
  5165. featureBBox,
  5166. featureId
  5167. ) === false)
  5168. return false;
  5169. continue;
  5170. }
  5171. switch (geometry2.type) {
  5172. case "Point":
  5173. case "LineString":
  5174. case "MultiPoint":
  5175. case "Polygon":
  5176. case "MultiLineString":
  5177. case "MultiPolygon": {
  5178. if (callback(
  5179. geometry2,
  5180. featureIndex,
  5181. featureProperties,
  5182. featureBBox,
  5183. featureId
  5184. ) === false)
  5185. return false;
  5186. break;
  5187. }
  5188. case "GeometryCollection": {
  5189. for (j = 0; j < geometry2.geometries.length; j++) {
  5190. if (callback(
  5191. geometry2.geometries[j],
  5192. featureIndex,
  5193. featureProperties,
  5194. featureBBox,
  5195. featureId
  5196. ) === false)
  5197. return false;
  5198. }
  5199. break;
  5200. }
  5201. default:
  5202. throw new Error("Unknown Geometry Type");
  5203. }
  5204. }
  5205. featureIndex++;
  5206. }
  5207. }
  5208. function geomReduce(geojson, callback, initialValue) {
  5209. var previousValue = initialValue;
  5210. geomEach(
  5211. geojson,
  5212. function(currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
  5213. if (featureIndex === 0 && initialValue === void 0)
  5214. previousValue = currentGeometry;
  5215. else
  5216. previousValue = callback(
  5217. previousValue,
  5218. currentGeometry,
  5219. featureIndex,
  5220. featureProperties,
  5221. featureBBox,
  5222. featureId
  5223. );
  5224. }
  5225. );
  5226. return previousValue;
  5227. }
  5228. function flattenEach(geojson, callback) {
  5229. geomEach(geojson, function(geometry2, featureIndex, properties, bbox3, id) {
  5230. var type = geometry2 === null ? null : geometry2.type;
  5231. switch (type) {
  5232. case null:
  5233. case "Point":
  5234. case "LineString":
  5235. case "Polygon":
  5236. if (callback(
  5237. feature(geometry2, properties, { bbox: bbox3, id }),
  5238. featureIndex,
  5239. 0
  5240. ) === false)
  5241. return false;
  5242. return;
  5243. }
  5244. var geomType;
  5245. switch (type) {
  5246. case "MultiPoint":
  5247. geomType = "Point";
  5248. break;
  5249. case "MultiLineString":
  5250. geomType = "LineString";
  5251. break;
  5252. case "MultiPolygon":
  5253. geomType = "Polygon";
  5254. break;
  5255. }
  5256. for (var multiFeatureIndex = 0; multiFeatureIndex < geometry2.coordinates.length; multiFeatureIndex++) {
  5257. var coordinate2 = geometry2.coordinates[multiFeatureIndex];
  5258. var geom = {
  5259. type: geomType,
  5260. coordinates: coordinate2
  5261. };
  5262. if (callback(feature(geom, properties), featureIndex, multiFeatureIndex) === false)
  5263. return false;
  5264. }
  5265. });
  5266. }
  5267. function flattenReduce(geojson, callback, initialValue) {
  5268. var previousValue = initialValue;
  5269. flattenEach(
  5270. geojson,
  5271. function(currentFeature, featureIndex, multiFeatureIndex) {
  5272. if (featureIndex === 0 && multiFeatureIndex === 0 && initialValue === void 0)
  5273. previousValue = currentFeature;
  5274. else
  5275. previousValue = callback(
  5276. previousValue,
  5277. currentFeature,
  5278. featureIndex,
  5279. multiFeatureIndex
  5280. );
  5281. }
  5282. );
  5283. return previousValue;
  5284. }
  5285. function segmentEach(geojson, callback) {
  5286. flattenEach(geojson, function(feature2, featureIndex, multiFeatureIndex) {
  5287. var segmentIndex = 0;
  5288. if (!feature2.geometry)
  5289. return;
  5290. var type = feature2.geometry.type;
  5291. if (type === "Point" || type === "MultiPoint")
  5292. return;
  5293. var previousCoords;
  5294. var previousFeatureIndex = 0;
  5295. var previousMultiIndex = 0;
  5296. var prevGeomIndex = 0;
  5297. if (coordEach(
  5298. feature2,
  5299. function(currentCoord, coordIndex, featureIndexCoord, multiPartIndexCoord, geometryIndex) {
  5300. if (previousCoords === void 0 || featureIndex > previousFeatureIndex || multiPartIndexCoord > previousMultiIndex || geometryIndex > prevGeomIndex) {
  5301. previousCoords = currentCoord;
  5302. previousFeatureIndex = featureIndex;
  5303. previousMultiIndex = multiPartIndexCoord;
  5304. prevGeomIndex = geometryIndex;
  5305. segmentIndex = 0;
  5306. return;
  5307. }
  5308. var currentSegment = lineString(
  5309. [previousCoords, currentCoord],
  5310. feature2.properties
  5311. );
  5312. if (callback(
  5313. currentSegment,
  5314. featureIndex,
  5315. multiFeatureIndex,
  5316. geometryIndex,
  5317. segmentIndex
  5318. ) === false)
  5319. return false;
  5320. segmentIndex++;
  5321. previousCoords = currentCoord;
  5322. }
  5323. ) === false)
  5324. return false;
  5325. });
  5326. }
  5327. function segmentReduce(geojson, callback, initialValue) {
  5328. var previousValue = initialValue;
  5329. var started = false;
  5330. segmentEach(
  5331. geojson,
  5332. function(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
  5333. if (started === false && initialValue === void 0)
  5334. previousValue = currentSegment;
  5335. else
  5336. previousValue = callback(
  5337. previousValue,
  5338. currentSegment,
  5339. featureIndex,
  5340. multiFeatureIndex,
  5341. geometryIndex,
  5342. segmentIndex
  5343. );
  5344. started = true;
  5345. }
  5346. );
  5347. return previousValue;
  5348. }
  5349. function lineEach(geojson, callback) {
  5350. if (!geojson)
  5351. throw new Error("geojson is required");
  5352. flattenEach(geojson, function(feature2, featureIndex, multiFeatureIndex) {
  5353. if (feature2.geometry === null)
  5354. return;
  5355. var type = feature2.geometry.type;
  5356. var coords = feature2.geometry.coordinates;
  5357. switch (type) {
  5358. case "LineString":
  5359. if (callback(feature2, featureIndex, multiFeatureIndex, 0, 0) === false)
  5360. return false;
  5361. break;
  5362. case "Polygon":
  5363. for (var geometryIndex = 0; geometryIndex < coords.length; geometryIndex++) {
  5364. if (callback(
  5365. lineString(coords[geometryIndex], feature2.properties),
  5366. featureIndex,
  5367. multiFeatureIndex,
  5368. geometryIndex
  5369. ) === false)
  5370. return false;
  5371. }
  5372. break;
  5373. }
  5374. });
  5375. }
  5376. function lineReduce(geojson, callback, initialValue) {
  5377. var previousValue = initialValue;
  5378. lineEach(
  5379. geojson,
  5380. function(currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
  5381. if (featureIndex === 0 && initialValue === void 0)
  5382. previousValue = currentLine;
  5383. else
  5384. previousValue = callback(
  5385. previousValue,
  5386. currentLine,
  5387. featureIndex,
  5388. multiFeatureIndex,
  5389. geometryIndex
  5390. );
  5391. }
  5392. );
  5393. return previousValue;
  5394. }
  5395. function findSegment(geojson, options) {
  5396. options = options || {};
  5397. if (!isObject(options))
  5398. throw new Error("options is invalid");
  5399. var featureIndex = options.featureIndex || 0;
  5400. var multiFeatureIndex = options.multiFeatureIndex || 0;
  5401. var geometryIndex = options.geometryIndex || 0;
  5402. var segmentIndex = options.segmentIndex || 0;
  5403. var properties = options.properties;
  5404. var geometry2;
  5405. switch (geojson.type) {
  5406. case "FeatureCollection":
  5407. if (featureIndex < 0)
  5408. featureIndex = geojson.features.length + featureIndex;
  5409. properties = properties || geojson.features[featureIndex].properties;
  5410. geometry2 = geojson.features[featureIndex].geometry;
  5411. break;
  5412. case "Feature":
  5413. properties = properties || geojson.properties;
  5414. geometry2 = geojson.geometry;
  5415. break;
  5416. case "Point":
  5417. case "MultiPoint":
  5418. return null;
  5419. case "LineString":
  5420. case "Polygon":
  5421. case "MultiLineString":
  5422. case "MultiPolygon":
  5423. geometry2 = geojson;
  5424. break;
  5425. default:
  5426. throw new Error("geojson is invalid");
  5427. }
  5428. if (geometry2 === null)
  5429. return null;
  5430. var coords = geometry2.coordinates;
  5431. switch (geometry2.type) {
  5432. case "Point":
  5433. case "MultiPoint":
  5434. return null;
  5435. case "LineString":
  5436. if (segmentIndex < 0)
  5437. segmentIndex = coords.length + segmentIndex - 1;
  5438. return lineString(
  5439. [coords[segmentIndex], coords[segmentIndex + 1]],
  5440. properties,
  5441. options
  5442. );
  5443. case "Polygon":
  5444. if (geometryIndex < 0)
  5445. geometryIndex = coords.length + geometryIndex;
  5446. if (segmentIndex < 0)
  5447. segmentIndex = coords[geometryIndex].length + segmentIndex - 1;
  5448. return lineString(
  5449. [
  5450. coords[geometryIndex][segmentIndex],
  5451. coords[geometryIndex][segmentIndex + 1]
  5452. ],
  5453. properties,
  5454. options
  5455. );
  5456. case "MultiLineString":
  5457. if (multiFeatureIndex < 0)
  5458. multiFeatureIndex = coords.length + multiFeatureIndex;
  5459. if (segmentIndex < 0)
  5460. segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;
  5461. return lineString(
  5462. [
  5463. coords[multiFeatureIndex][segmentIndex],
  5464. coords[multiFeatureIndex][segmentIndex + 1]
  5465. ],
  5466. properties,
  5467. options
  5468. );
  5469. case "MultiPolygon":
  5470. if (multiFeatureIndex < 0)
  5471. multiFeatureIndex = coords.length + multiFeatureIndex;
  5472. if (geometryIndex < 0)
  5473. geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
  5474. if (segmentIndex < 0)
  5475. segmentIndex = coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;
  5476. return lineString(
  5477. [
  5478. coords[multiFeatureIndex][geometryIndex][segmentIndex],
  5479. coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]
  5480. ],
  5481. properties,
  5482. options
  5483. );
  5484. }
  5485. throw new Error("geojson is invalid");
  5486. }
  5487. function findPoint(geojson, options) {
  5488. options = options || {};
  5489. if (!isObject(options))
  5490. throw new Error("options is invalid");
  5491. var featureIndex = options.featureIndex || 0;
  5492. var multiFeatureIndex = options.multiFeatureIndex || 0;
  5493. var geometryIndex = options.geometryIndex || 0;
  5494. var coordIndex = options.coordIndex || 0;
  5495. var properties = options.properties;
  5496. var geometry2;
  5497. switch (geojson.type) {
  5498. case "FeatureCollection":
  5499. if (featureIndex < 0)
  5500. featureIndex = geojson.features.length + featureIndex;
  5501. properties = properties || geojson.features[featureIndex].properties;
  5502. geometry2 = geojson.features[featureIndex].geometry;
  5503. break;
  5504. case "Feature":
  5505. properties = properties || geojson.properties;
  5506. geometry2 = geojson.geometry;
  5507. break;
  5508. case "Point":
  5509. case "MultiPoint":
  5510. return null;
  5511. case "LineString":
  5512. case "Polygon":
  5513. case "MultiLineString":
  5514. case "MultiPolygon":
  5515. geometry2 = geojson;
  5516. break;
  5517. default:
  5518. throw new Error("geojson is invalid");
  5519. }
  5520. if (geometry2 === null)
  5521. return null;
  5522. var coords = geometry2.coordinates;
  5523. switch (geometry2.type) {
  5524. case "Point":
  5525. return point(coords, properties, options);
  5526. case "MultiPoint":
  5527. if (multiFeatureIndex < 0)
  5528. multiFeatureIndex = coords.length + multiFeatureIndex;
  5529. return point(coords[multiFeatureIndex], properties, options);
  5530. case "LineString":
  5531. if (coordIndex < 0)
  5532. coordIndex = coords.length + coordIndex;
  5533. return point(coords[coordIndex], properties, options);
  5534. case "Polygon":
  5535. if (geometryIndex < 0)
  5536. geometryIndex = coords.length + geometryIndex;
  5537. if (coordIndex < 0)
  5538. coordIndex = coords[geometryIndex].length + coordIndex;
  5539. return point(coords[geometryIndex][coordIndex], properties, options);
  5540. case "MultiLineString":
  5541. if (multiFeatureIndex < 0)
  5542. multiFeatureIndex = coords.length + multiFeatureIndex;
  5543. if (coordIndex < 0)
  5544. coordIndex = coords[multiFeatureIndex].length + coordIndex;
  5545. return point(coords[multiFeatureIndex][coordIndex], properties, options);
  5546. case "MultiPolygon":
  5547. if (multiFeatureIndex < 0)
  5548. multiFeatureIndex = coords.length + multiFeatureIndex;
  5549. if (geometryIndex < 0)
  5550. geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
  5551. if (coordIndex < 0)
  5552. coordIndex = coords[multiFeatureIndex][geometryIndex].length - coordIndex;
  5553. return point(
  5554. coords[multiFeatureIndex][geometryIndex][coordIndex],
  5555. properties,
  5556. options
  5557. );
  5558. }
  5559. throw new Error("geojson is invalid");
  5560. }
  5561. // node_modules/@turf/bbox/dist/es/index.js
  5562. function bbox(geojson) {
  5563. var result = [Infinity, Infinity, -Infinity, -Infinity];
  5564. coordEach(geojson, function(coord) {
  5565. if (result[0] > coord[0]) {
  5566. result[0] = coord[0];
  5567. }
  5568. if (result[1] > coord[1]) {
  5569. result[1] = coord[1];
  5570. }
  5571. if (result[2] < coord[0]) {
  5572. result[2] = coord[0];
  5573. }
  5574. if (result[3] < coord[1]) {
  5575. result[3] = coord[1];
  5576. }
  5577. });
  5578. return result;
  5579. }
  5580. bbox["default"] = bbox;
  5581. var es_default = bbox;
  5582. // node_modules/@turf/invariant/dist/es/index.js
  5583. var es_exports3 = {};
  5584. __export(es_exports3, {
  5585. collectionOf: () => collectionOf,
  5586. containsNumber: () => containsNumber,
  5587. featureOf: () => featureOf,
  5588. geojsonType: () => geojsonType,
  5589. getCoord: () => getCoord,
  5590. getCoords: () => getCoords,
  5591. getGeom: () => getGeom,
  5592. getType: () => getType
  5593. });
  5594. function getCoord(coord) {
  5595. if (!coord) {
  5596. throw new Error("coord is required");
  5597. }
  5598. if (!Array.isArray(coord)) {
  5599. if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
  5600. return coord.geometry.coordinates;
  5601. }
  5602. if (coord.type === "Point") {
  5603. return coord.coordinates;
  5604. }
  5605. }
  5606. if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
  5607. return coord;
  5608. }
  5609. throw new Error("coord must be GeoJSON Point or an Array of numbers");
  5610. }
  5611. function getCoords(coords) {
  5612. if (Array.isArray(coords)) {
  5613. return coords;
  5614. }
  5615. if (coords.type === "Feature") {
  5616. if (coords.geometry !== null) {
  5617. return coords.geometry.coordinates;
  5618. }
  5619. } else {
  5620. if (coords.coordinates) {
  5621. return coords.coordinates;
  5622. }
  5623. }
  5624. throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");
  5625. }
  5626. function containsNumber(coordinates) {
  5627. if (coordinates.length > 1 && isNumber(coordinates[0]) && isNumber(coordinates[1])) {
  5628. return true;
  5629. }
  5630. if (Array.isArray(coordinates[0]) && coordinates[0].length) {
  5631. return containsNumber(coordinates[0]);
  5632. }
  5633. throw new Error("coordinates must only contain numbers");
  5634. }
  5635. function geojsonType(value, type, name) {
  5636. if (!type || !name) {
  5637. throw new Error("type and name required");
  5638. }
  5639. if (!value || value.type !== type) {
  5640. throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + value.type);
  5641. }
  5642. }
  5643. function featureOf(feature2, type, name) {
  5644. if (!feature2) {
  5645. throw new Error("No feature passed");
  5646. }
  5647. if (!name) {
  5648. throw new Error(".featureOf() requires a name");
  5649. }
  5650. if (!feature2 || feature2.type !== "Feature" || !feature2.geometry) {
  5651. throw new Error("Invalid input to " + name + ", Feature with geometry required");
  5652. }
  5653. if (!feature2.geometry || feature2.geometry.type !== type) {
  5654. throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + feature2.geometry.type);
  5655. }
  5656. }
  5657. function collectionOf(featureCollection2, type, name) {
  5658. if (!featureCollection2) {
  5659. throw new Error("No featureCollection passed");
  5660. }
  5661. if (!name) {
  5662. throw new Error(".collectionOf() requires a name");
  5663. }
  5664. if (!featureCollection2 || featureCollection2.type !== "FeatureCollection") {
  5665. throw new Error("Invalid input to " + name + ", FeatureCollection required");
  5666. }
  5667. for (var _i = 0, _a = featureCollection2.features; _i < _a.length; _i++) {
  5668. var feature2 = _a[_i];
  5669. if (!feature2 || feature2.type !== "Feature" || !feature2.geometry) {
  5670. throw new Error("Invalid input to " + name + ", Feature with geometry required");
  5671. }
  5672. if (!feature2.geometry || feature2.geometry.type !== type) {
  5673. throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + feature2.geometry.type);
  5674. }
  5675. }
  5676. }
  5677. function getGeom(geojson) {
  5678. if (geojson.type === "Feature") {
  5679. return geojson.geometry;
  5680. }
  5681. return geojson;
  5682. }
  5683. function getType(geojson, _name) {
  5684. if (geojson.type === "FeatureCollection") {
  5685. return "FeatureCollection";
  5686. }
  5687. if (geojson.type === "GeometryCollection") {
  5688. return "GeometryCollection";
  5689. }
  5690. if (geojson.type === "Feature" && geojson.geometry !== null) {
  5691. return geojson.geometry.type;
  5692. }
  5693. return geojson.type;
  5694. }
  5695. // node_modules/@turf/isolines/dist/es/index.js
  5696. var import_object_assign = __toESM(require_object_assign());
  5697. var defaultSettings = {
  5698. successCallback: null,
  5699. verbose: false
  5700. };
  5701. var settings = {};
  5702. function isoContours(data, threshold, options) {
  5703. options = options ? options : {};
  5704. var optionKeys = Object.keys(defaultSettings);
  5705. for (var i = 0; i < optionKeys.length; i++) {
  5706. var key = optionKeys[i];
  5707. var val = options[key];
  5708. val = typeof val !== "undefined" && val !== null ? val : defaultSettings[key];
  5709. settings[key] = val;
  5710. }
  5711. if (settings.verbose)
  5712. console.log(
  5713. "MarchingSquaresJS-isoContours: computing isocontour for " + threshold
  5714. );
  5715. var ret = contourGrid2Paths(computeContourGrid(data, threshold));
  5716. if (typeof settings.successCallback === "function")
  5717. settings.successCallback(ret);
  5718. return ret;
  5719. }
  5720. function interpolateX(y2, y02, y12) {
  5721. return (y2 - y02) / (y12 - y02);
  5722. }
  5723. function computeContourGrid(data, threshold) {
  5724. var rows = data.length - 1;
  5725. var cols = data[0].length - 1;
  5726. var ContourGrid = { rows, cols, cells: [] };
  5727. for (var j = 0; j < rows; ++j) {
  5728. ContourGrid.cells[j] = [];
  5729. for (var i = 0; i < cols; ++i) {
  5730. var cval = 0;
  5731. var tl = data[j + 1][i];
  5732. var tr = data[j + 1][i + 1];
  5733. var br = data[j][i + 1];
  5734. var bl = data[j][i];
  5735. if (isNaN(tl) || isNaN(tr) || isNaN(br) || isNaN(bl)) {
  5736. continue;
  5737. }
  5738. cval |= tl >= threshold ? 8 : 0;
  5739. cval |= tr >= threshold ? 4 : 0;
  5740. cval |= br >= threshold ? 2 : 0;
  5741. cval |= bl >= threshold ? 1 : 0;
  5742. var flipped = false;
  5743. if (cval === 5 || cval === 10) {
  5744. var average2 = (tl + tr + br + bl) / 4;
  5745. if (cval === 5 && average2 < threshold) {
  5746. cval = 10;
  5747. flipped = true;
  5748. } else if (cval === 10 && average2 < threshold) {
  5749. cval = 5;
  5750. flipped = true;
  5751. }
  5752. }
  5753. if (cval !== 0 && cval !== 15) {
  5754. var top, bottom, left, right;
  5755. top = bottom = left = right = 0.5;
  5756. if (cval === 1) {
  5757. left = 1 - interpolateX(threshold, tl, bl);
  5758. bottom = 1 - interpolateX(threshold, br, bl);
  5759. } else if (cval === 2) {
  5760. bottom = interpolateX(threshold, bl, br);
  5761. right = 1 - interpolateX(threshold, tr, br);
  5762. } else if (cval === 3) {
  5763. left = 1 - interpolateX(threshold, tl, bl);
  5764. right = 1 - interpolateX(threshold, tr, br);
  5765. } else if (cval === 4) {
  5766. top = interpolateX(threshold, tl, tr);
  5767. right = interpolateX(threshold, br, tr);
  5768. } else if (cval === 5) {
  5769. top = interpolateX(threshold, tl, tr);
  5770. right = interpolateX(threshold, br, tr);
  5771. bottom = 1 - interpolateX(threshold, br, bl);
  5772. left = 1 - interpolateX(threshold, tl, bl);
  5773. } else if (cval === 6) {
  5774. bottom = interpolateX(threshold, bl, br);
  5775. top = interpolateX(threshold, tl, tr);
  5776. } else if (cval === 7) {
  5777. left = 1 - interpolateX(threshold, tl, bl);
  5778. top = interpolateX(threshold, tl, tr);
  5779. } else if (cval === 8) {
  5780. left = interpolateX(threshold, bl, tl);
  5781. top = 1 - interpolateX(threshold, tr, tl);
  5782. } else if (cval === 9) {
  5783. bottom = 1 - interpolateX(threshold, br, bl);
  5784. top = 1 - interpolateX(threshold, tr, tl);
  5785. } else if (cval === 10) {
  5786. top = 1 - interpolateX(threshold, tr, tl);
  5787. right = 1 - interpolateX(threshold, tr, br);
  5788. bottom = interpolateX(threshold, bl, br);
  5789. left = interpolateX(threshold, bl, tl);
  5790. } else if (cval === 11) {
  5791. top = 1 - interpolateX(threshold, tr, tl);
  5792. right = 1 - interpolateX(threshold, tr, br);
  5793. } else if (cval === 12) {
  5794. left = interpolateX(threshold, bl, tl);
  5795. right = interpolateX(threshold, br, tr);
  5796. } else if (cval === 13) {
  5797. bottom = 1 - interpolateX(threshold, br, bl);
  5798. right = interpolateX(threshold, br, tr);
  5799. } else if (cval === 14) {
  5800. left = interpolateX(threshold, bl, tl);
  5801. bottom = interpolateX(threshold, bl, br);
  5802. } else {
  5803. console.log(
  5804. "MarchingSquaresJS-isoContours: Illegal cval detected: " + cval
  5805. );
  5806. }
  5807. ContourGrid.cells[j][i] = {
  5808. cval,
  5809. flipped,
  5810. top,
  5811. right,
  5812. bottom,
  5813. left
  5814. };
  5815. }
  5816. }
  5817. }
  5818. return ContourGrid;
  5819. }
  5820. function isSaddle(cell) {
  5821. return cell.cval === 5 || cell.cval === 10;
  5822. }
  5823. function isTrivial(cell) {
  5824. return cell.cval === 0 || cell.cval === 15;
  5825. }
  5826. function clearCell(cell) {
  5827. if (!isTrivial(cell) && cell.cval !== 5 && cell.cval !== 10) {
  5828. cell.cval = 15;
  5829. }
  5830. }
  5831. function getXY(cell, edge) {
  5832. if (edge === "top") {
  5833. return [cell.top, 1];
  5834. } else if (edge === "bottom") {
  5835. return [cell.bottom, 0];
  5836. } else if (edge === "right") {
  5837. return [1, cell.right];
  5838. } else if (edge === "left") {
  5839. return [0, cell.left];
  5840. }
  5841. }
  5842. function contourGrid2Paths(grid) {
  5843. var paths = [];
  5844. var path_idx = 0;
  5845. var epsilon5 = 1e-7;
  5846. grid.cells.forEach(function(g, j) {
  5847. g.forEach(function(gg, i) {
  5848. if (typeof gg !== "undefined" && !isSaddle(gg) && !isTrivial(gg)) {
  5849. var p = tracePath(grid.cells, j, i);
  5850. var merged = false;
  5851. if (p.info === "mergeable") {
  5852. var x2 = p.path[p.path.length - 1][0], y2 = p.path[p.path.length - 1][1];
  5853. for (var k = path_idx - 1; k >= 0; k--) {
  5854. if (Math.abs(paths[k][0][0] - x2) <= epsilon5 && Math.abs(paths[k][0][1] - y2) <= epsilon5) {
  5855. for (var l = p.path.length - 2; l >= 0; --l) {
  5856. paths[k].unshift(p.path[l]);
  5857. }
  5858. merged = true;
  5859. break;
  5860. }
  5861. }
  5862. }
  5863. if (!merged)
  5864. paths[path_idx++] = p.path;
  5865. }
  5866. });
  5867. });
  5868. return paths;
  5869. }
  5870. function tracePath(grid, j, i) {
  5871. var maxj = grid.length;
  5872. var p = [];
  5873. var dxContour = [0, 0, 1, 1, 0, 0, 0, 0, -1, 0, 1, 1, -1, 0, -1, 0];
  5874. var dyContour = [0, -1, 0, 0, 1, 1, 1, 1, 0, -1, 0, 0, 0, -1, 0, 0];
  5875. var dx, dy;
  5876. var startEdge = [
  5877. "none",
  5878. "left",
  5879. "bottom",
  5880. "left",
  5881. "right",
  5882. "none",
  5883. "bottom",
  5884. "left",
  5885. "top",
  5886. "top",
  5887. "none",
  5888. "top",
  5889. "right",
  5890. "right",
  5891. "bottom",
  5892. "none"
  5893. ];
  5894. var nextEdge = [
  5895. "none",
  5896. "bottom",
  5897. "right",
  5898. "right",
  5899. "top",
  5900. "top",
  5901. "top",
  5902. "top",
  5903. "left",
  5904. "bottom",
  5905. "right",
  5906. "right",
  5907. "left",
  5908. "bottom",
  5909. "left",
  5910. "none"
  5911. ];
  5912. var edge;
  5913. var currentCell = grid[j][i];
  5914. var cval = currentCell.cval;
  5915. var edge = startEdge[cval];
  5916. var pt = getXY(currentCell, edge);
  5917. p.push([i + pt[0], j + pt[1]]);
  5918. edge = nextEdge[cval];
  5919. pt = getXY(currentCell, edge);
  5920. p.push([i + pt[0], j + pt[1]]);
  5921. clearCell(currentCell);
  5922. var k = i + dxContour[cval];
  5923. var l = j + dyContour[cval];
  5924. var prev_cval = cval;
  5925. while (k >= 0 && l >= 0 && l < maxj && (k != i || l != j)) {
  5926. currentCell = grid[l][k];
  5927. if (typeof currentCell === "undefined") {
  5928. break;
  5929. }
  5930. cval = currentCell.cval;
  5931. if (cval === 0 || cval === 15) {
  5932. return { path: p, info: "mergeable" };
  5933. }
  5934. edge = nextEdge[cval];
  5935. dx = dxContour[cval];
  5936. dy = dyContour[cval];
  5937. if (cval === 5 || cval === 10) {
  5938. if (cval === 5) {
  5939. if (currentCell.flipped) {
  5940. if (dyContour[prev_cval] === -1) {
  5941. edge = "left";
  5942. dx = -1;
  5943. dy = 0;
  5944. } else {
  5945. edge = "right";
  5946. dx = 1;
  5947. dy = 0;
  5948. }
  5949. } else {
  5950. if (dxContour[prev_cval] === -1) {
  5951. edge = "bottom";
  5952. dx = 0;
  5953. dy = -1;
  5954. }
  5955. }
  5956. } else if (cval === 10) {
  5957. if (currentCell.flipped) {
  5958. if (dxContour[prev_cval] === -1) {
  5959. edge = "top";
  5960. dx = 0;
  5961. dy = 1;
  5962. } else {
  5963. edge = "bottom";
  5964. dx = 0;
  5965. dy = -1;
  5966. }
  5967. } else {
  5968. if (dyContour[prev_cval] === 1) {
  5969. edge = "left";
  5970. dx = -1;
  5971. dy = 0;
  5972. }
  5973. }
  5974. }
  5975. }
  5976. pt = getXY(currentCell, edge);
  5977. p.push([k + pt[0], l + pt[1]]);
  5978. clearCell(currentCell);
  5979. k += dx;
  5980. l += dy;
  5981. prev_cval = cval;
  5982. }
  5983. return { path: p, info: "closed" };
  5984. }
  5985. function gridToMatrix(grid, options) {
  5986. options = options || {};
  5987. if (!isObject(options))
  5988. throw new Error("options is invalid");
  5989. var zProperty = options.zProperty || "elevation";
  5990. var flip4 = options.flip;
  5991. var flags = options.flags;
  5992. collectionOf(grid, "Point", "input must contain Points");
  5993. var pointsMatrix = sortPointsByLatLng(grid, flip4);
  5994. var matrix = [];
  5995. for (var r = 0; r < pointsMatrix.length; r++) {
  5996. var pointRow = pointsMatrix[r];
  5997. var row = [];
  5998. for (var c = 0; c < pointRow.length; c++) {
  5999. var point4 = pointRow[c];
  6000. if (point4.properties[zProperty])
  6001. row.push(point4.properties[zProperty]);
  6002. else
  6003. row.push(0);
  6004. if (flags === true)
  6005. point4.properties.matrixPosition = [r, c];
  6006. }
  6007. matrix.push(row);
  6008. }
  6009. return matrix;
  6010. }
  6011. function sortPointsByLatLng(points2, flip4) {
  6012. var pointsByLatitude = {};
  6013. featureEach(points2, function(point4) {
  6014. var lat2 = getCoords(point4)[1];
  6015. if (!pointsByLatitude[lat2])
  6016. pointsByLatitude[lat2] = [];
  6017. pointsByLatitude[lat2].push(point4);
  6018. });
  6019. var orderedRowsByLatitude = Object.keys(pointsByLatitude).map(function(lat2) {
  6020. var row = pointsByLatitude[lat2];
  6021. var rowOrderedByLongitude = row.sort(function(a, b) {
  6022. return getCoords(a)[0] - getCoords(b)[0];
  6023. });
  6024. return rowOrderedByLongitude;
  6025. });
  6026. var pointMatrix = orderedRowsByLatitude.sort(function(a, b) {
  6027. if (flip4)
  6028. return getCoords(a[0])[1] - getCoords(b[0])[1];
  6029. else
  6030. return getCoords(b[0])[1] - getCoords(a[0])[1];
  6031. });
  6032. return pointMatrix;
  6033. }
  6034. function isolines(pointGrid2, breaks, options) {
  6035. options = options || {};
  6036. if (!isObject(options))
  6037. throw new Error("options is invalid");
  6038. var zProperty = options.zProperty || "elevation";
  6039. var commonProperties = options.commonProperties || {};
  6040. var breaksProperties = options.breaksProperties || [];
  6041. collectionOf(pointGrid2, "Point", "Input must contain Points");
  6042. if (!breaks)
  6043. throw new Error("breaks is required");
  6044. if (!Array.isArray(breaks))
  6045. throw new Error("breaks must be an Array");
  6046. if (!isObject(commonProperties))
  6047. throw new Error("commonProperties must be an Object");
  6048. if (!Array.isArray(breaksProperties))
  6049. throw new Error("breaksProperties must be an Array");
  6050. var matrix = gridToMatrix(pointGrid2, { zProperty, flip: true });
  6051. var createdIsoLines = createIsoLines(
  6052. matrix,
  6053. breaks,
  6054. zProperty,
  6055. commonProperties,
  6056. breaksProperties
  6057. );
  6058. var scaledIsolines = rescaleIsolines(createdIsoLines, matrix, pointGrid2);
  6059. return featureCollection(scaledIsolines);
  6060. }
  6061. function createIsoLines(matrix, breaks, zProperty, commonProperties, breaksProperties) {
  6062. var results = [];
  6063. for (var i = 1; i < breaks.length; i++) {
  6064. var threshold = +breaks[i];
  6065. var properties = (0, import_object_assign.default)({}, commonProperties, breaksProperties[i]);
  6066. properties[zProperty] = threshold;
  6067. var isoline = multiLineString(isoContours(matrix, threshold), properties);
  6068. results.push(isoline);
  6069. }
  6070. return results;
  6071. }
  6072. function rescaleIsolines(createdIsoLines, matrix, points2) {
  6073. var gridBbox = es_default(points2);
  6074. var originalWidth = gridBbox[2] - gridBbox[0];
  6075. var originalHeigth = gridBbox[3] - gridBbox[1];
  6076. var x02 = gridBbox[0];
  6077. var y02 = gridBbox[1];
  6078. var matrixWidth = matrix[0].length - 1;
  6079. var matrixHeight = matrix.length - 1;
  6080. var scaleX = originalWidth / matrixWidth;
  6081. var scaleY = originalHeigth / matrixHeight;
  6082. var resize = function(point4) {
  6083. point4[0] = point4[0] * scaleX + x02;
  6084. point4[1] = point4[1] * scaleY + y02;
  6085. };
  6086. createdIsoLines.forEach(function(isoline) {
  6087. coordEach(isoline, resize);
  6088. });
  6089. return createdIsoLines;
  6090. }
  6091. var es_default2 = isolines;
  6092. // node_modules/@turf/convex/dist/es/index.js
  6093. var import_concaveman = __toESM(require_concaveman());
  6094. function convex(geojson, options) {
  6095. if (options === void 0) {
  6096. options = {};
  6097. }
  6098. options.concavity = options.concavity || Infinity;
  6099. var points2 = [];
  6100. coordEach(geojson, function(coord) {
  6101. points2.push([coord[0], coord[1]]);
  6102. });
  6103. if (!points2.length) {
  6104. return null;
  6105. }
  6106. var convexHull = (0, import_concaveman.default)(points2, options.concavity);
  6107. if (convexHull.length > 3) {
  6108. return polygon([convexHull]);
  6109. }
  6110. return null;
  6111. }
  6112. // node_modules/@turf/boolean-point-in-polygon/dist/es/index.js
  6113. function booleanPointInPolygon(point4, polygon4, options) {
  6114. if (options === void 0) {
  6115. options = {};
  6116. }
  6117. if (!point4) {
  6118. throw new Error("point is required");
  6119. }
  6120. if (!polygon4) {
  6121. throw new Error("polygon is required");
  6122. }
  6123. var pt = getCoord(point4);
  6124. var geom = getGeom(polygon4);
  6125. var type = geom.type;
  6126. var bbox3 = polygon4.bbox;
  6127. var polys = geom.coordinates;
  6128. if (bbox3 && inBBox(pt, bbox3) === false) {
  6129. return false;
  6130. }
  6131. if (type === "Polygon") {
  6132. polys = [polys];
  6133. }
  6134. var insidePoly = false;
  6135. for (var i = 0; i < polys.length && !insidePoly; i++) {
  6136. if (inRing(pt, polys[i][0], options.ignoreBoundary)) {
  6137. var inHole = false;
  6138. var k = 1;
  6139. while (k < polys[i].length && !inHole) {
  6140. if (inRing(pt, polys[i][k], !options.ignoreBoundary)) {
  6141. inHole = true;
  6142. }
  6143. k++;
  6144. }
  6145. if (!inHole) {
  6146. insidePoly = true;
  6147. }
  6148. }
  6149. }
  6150. return insidePoly;
  6151. }
  6152. function inRing(pt, ring, ignoreBoundary) {
  6153. var isInside3 = false;
  6154. if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1]) {
  6155. ring = ring.slice(0, ring.length - 1);
  6156. }
  6157. for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) {
  6158. var xi = ring[i][0];
  6159. var yi = ring[i][1];
  6160. var xj = ring[j][0];
  6161. var yj = ring[j][1];
  6162. var onBoundary = pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0 && (xi - pt[0]) * (xj - pt[0]) <= 0 && (yi - pt[1]) * (yj - pt[1]) <= 0;
  6163. if (onBoundary) {
  6164. return !ignoreBoundary;
  6165. }
  6166. var intersect4 = yi > pt[1] !== yj > pt[1] && pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi;
  6167. if (intersect4) {
  6168. isInside3 = !isInside3;
  6169. }
  6170. }
  6171. return isInside3;
  6172. }
  6173. function inBBox(pt, bbox3) {
  6174. return bbox3[0] <= pt[0] && bbox3[1] <= pt[1] && bbox3[2] >= pt[0] && bbox3[3] >= pt[1];
  6175. }
  6176. // node_modules/@turf/points-within-polygon/dist/es/index.js
  6177. function pointsWithinPolygon(points2, polygons2) {
  6178. var results = [];
  6179. featureEach(points2, function(point4) {
  6180. var contained = false;
  6181. if (point4.geometry.type === "Point") {
  6182. geomEach(polygons2, function(polygon4) {
  6183. if (booleanPointInPolygon(point4, polygon4))
  6184. contained = true;
  6185. });
  6186. if (contained) {
  6187. results.push(point4);
  6188. }
  6189. } else if (point4.geometry.type === "MultiPoint") {
  6190. var pointsWithin = [];
  6191. geomEach(polygons2, function(polygon4) {
  6192. coordEach(point4, function(pointCoord) {
  6193. if (booleanPointInPolygon(pointCoord, polygon4)) {
  6194. contained = true;
  6195. pointsWithin.push(pointCoord);
  6196. }
  6197. });
  6198. });
  6199. if (contained) {
  6200. results.push(multiPoint(pointsWithin));
  6201. }
  6202. } else {
  6203. throw new Error("Input geometry must be a Point or MultiPoint");
  6204. }
  6205. });
  6206. return featureCollection(results);
  6207. }
  6208. var es_default3 = pointsWithinPolygon;
  6209. // node_modules/@turf/distance/dist/es/index.js
  6210. function distance(from, to, options) {
  6211. if (options === void 0) {
  6212. options = {};
  6213. }
  6214. var coordinates1 = getCoord(from);
  6215. var coordinates2 = getCoord(to);
  6216. var dLat = degreesToRadians(coordinates2[1] - coordinates1[1]);
  6217. var dLon = degreesToRadians(coordinates2[0] - coordinates1[0]);
  6218. var lat1 = degreesToRadians(coordinates1[1]);
  6219. var lat2 = degreesToRadians(coordinates2[1]);
  6220. var a = Math.pow(Math.sin(dLat / 2), 2) + Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
  6221. return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), options.units);
  6222. }
  6223. var es_default4 = distance;
  6224. // node_modules/@turf/tin/dist/es/index.js
  6225. function tin(points2, z) {
  6226. var isPointZ = false;
  6227. return featureCollection(triangulate(points2.features.map(function(p) {
  6228. var point4 = {
  6229. x: p.geometry.coordinates[0],
  6230. y: p.geometry.coordinates[1]
  6231. };
  6232. if (z) {
  6233. point4.z = p.properties[z];
  6234. } else if (p.geometry.coordinates.length === 3) {
  6235. isPointZ = true;
  6236. point4.z = p.geometry.coordinates[2];
  6237. }
  6238. return point4;
  6239. })).map(function(triangle) {
  6240. var a = [triangle.a.x, triangle.a.y];
  6241. var b = [triangle.b.x, triangle.b.y];
  6242. var c = [triangle.c.x, triangle.c.y];
  6243. var properties = {};
  6244. if (isPointZ) {
  6245. a.push(triangle.a.z);
  6246. b.push(triangle.b.z);
  6247. c.push(triangle.c.z);
  6248. } else {
  6249. properties = {
  6250. a: triangle.a.z,
  6251. b: triangle.b.z,
  6252. c: triangle.c.z
  6253. };
  6254. }
  6255. return polygon([[a, b, c, a]], properties);
  6256. }));
  6257. }
  6258. var Triangle = function() {
  6259. function Triangle4(a, b, c) {
  6260. this.a = a;
  6261. this.b = b;
  6262. this.c = c;
  6263. var A = b.x - a.x;
  6264. var B2 = b.y - a.y;
  6265. var C = c.x - a.x;
  6266. var D = c.y - a.y;
  6267. var E = A * (a.x + b.x) + B2 * (a.y + b.y);
  6268. var F = C * (a.x + c.x) + D * (a.y + c.y);
  6269. var G = 2 * (A * (c.y - b.y) - B2 * (c.x - b.x));
  6270. var dx;
  6271. var dy;
  6272. this.x = (D * E - B2 * F) / G;
  6273. this.y = (A * F - C * E) / G;
  6274. dx = this.x - a.x;
  6275. dy = this.y - a.y;
  6276. this.r = dx * dx + dy * dy;
  6277. }
  6278. return Triangle4;
  6279. }();
  6280. function byX(a, b) {
  6281. return b.x - a.x;
  6282. }
  6283. function dedup(edges2) {
  6284. var j = edges2.length;
  6285. var a;
  6286. var b;
  6287. var i;
  6288. var m;
  6289. var n;
  6290. outer:
  6291. while (j) {
  6292. b = edges2[--j];
  6293. a = edges2[--j];
  6294. i = j;
  6295. while (i) {
  6296. n = edges2[--i];
  6297. m = edges2[--i];
  6298. if (a === m && b === n || a === n && b === m) {
  6299. edges2.splice(j, 2);
  6300. edges2.splice(i, 2);
  6301. j -= 2;
  6302. continue outer;
  6303. }
  6304. }
  6305. }
  6306. }
  6307. function triangulate(vertices) {
  6308. if (vertices.length < 3) {
  6309. return [];
  6310. }
  6311. vertices.sort(byX);
  6312. var i = vertices.length - 1;
  6313. var xmin = vertices[i].x;
  6314. var xmax = vertices[0].x;
  6315. var ymin = vertices[i].y;
  6316. var ymax = ymin;
  6317. var epsilon5 = 1e-12;
  6318. var a;
  6319. var b;
  6320. var c;
  6321. var A;
  6322. var B2;
  6323. var G;
  6324. while (i--) {
  6325. if (vertices[i].y < ymin) {
  6326. ymin = vertices[i].y;
  6327. }
  6328. if (vertices[i].y > ymax) {
  6329. ymax = vertices[i].y;
  6330. }
  6331. }
  6332. var dx = xmax - xmin;
  6333. var dy = ymax - ymin;
  6334. var dmax = dx > dy ? dx : dy;
  6335. var xmid = (xmax + xmin) * 0.5;
  6336. var ymid = (ymax + ymin) * 0.5;
  6337. var open = [
  6338. new Triangle({
  6339. __sentinel: true,
  6340. x: xmid - 20 * dmax,
  6341. y: ymid - dmax
  6342. }, {
  6343. __sentinel: true,
  6344. x: xmid,
  6345. y: ymid + 20 * dmax
  6346. }, {
  6347. __sentinel: true,
  6348. x: xmid + 20 * dmax,
  6349. y: ymid - dmax
  6350. })
  6351. ];
  6352. var closed = [];
  6353. var edges2 = [];
  6354. var j;
  6355. i = vertices.length;
  6356. while (i--) {
  6357. edges2.length = 0;
  6358. j = open.length;
  6359. while (j--) {
  6360. dx = vertices[i].x - open[j].x;
  6361. if (dx > 0 && dx * dx > open[j].r) {
  6362. closed.push(open[j]);
  6363. open.splice(j, 1);
  6364. continue;
  6365. }
  6366. dy = vertices[i].y - open[j].y;
  6367. if (dx * dx + dy * dy > open[j].r) {
  6368. continue;
  6369. }
  6370. edges2.push(open[j].a, open[j].b, open[j].b, open[j].c, open[j].c, open[j].a);
  6371. open.splice(j, 1);
  6372. }
  6373. dedup(edges2);
  6374. j = edges2.length;
  6375. while (j) {
  6376. b = edges2[--j];
  6377. a = edges2[--j];
  6378. c = vertices[i];
  6379. A = b.x - a.x;
  6380. B2 = b.y - a.y;
  6381. G = 2 * (A * (c.y - b.y) - B2 * (c.x - b.x));
  6382. if (Math.abs(G) > epsilon5) {
  6383. open.push(new Triangle(a, b, c));
  6384. }
  6385. }
  6386. }
  6387. Array.prototype.push.apply(closed, open);
  6388. i = closed.length;
  6389. while (i--) {
  6390. if (closed[i].a.__sentinel || closed[i].b.__sentinel || closed[i].c.__sentinel) {
  6391. closed.splice(i, 1);
  6392. }
  6393. }
  6394. return closed;
  6395. }
  6396. // node_modules/@turf/clone/dist/es/index.js
  6397. function clone(geojson) {
  6398. if (!geojson) {
  6399. throw new Error("geojson is required");
  6400. }
  6401. switch (geojson.type) {
  6402. case "Feature":
  6403. return cloneFeature(geojson);
  6404. case "FeatureCollection":
  6405. return cloneFeatureCollection(geojson);
  6406. case "Point":
  6407. case "LineString":
  6408. case "Polygon":
  6409. case "MultiPoint":
  6410. case "MultiLineString":
  6411. case "MultiPolygon":
  6412. case "GeometryCollection":
  6413. return cloneGeometry(geojson);
  6414. default:
  6415. throw new Error("unknown GeoJSON type");
  6416. }
  6417. }
  6418. function cloneFeature(geojson) {
  6419. var cloned = { type: "Feature" };
  6420. Object.keys(geojson).forEach(function(key) {
  6421. switch (key) {
  6422. case "type":
  6423. case "properties":
  6424. case "geometry":
  6425. return;
  6426. default:
  6427. cloned[key] = geojson[key];
  6428. }
  6429. });
  6430. cloned.properties = cloneProperties(geojson.properties);
  6431. cloned.geometry = cloneGeometry(geojson.geometry);
  6432. return cloned;
  6433. }
  6434. function cloneProperties(properties) {
  6435. var cloned = {};
  6436. if (!properties) {
  6437. return cloned;
  6438. }
  6439. Object.keys(properties).forEach(function(key) {
  6440. var value = properties[key];
  6441. if (typeof value === "object") {
  6442. if (value === null) {
  6443. cloned[key] = null;
  6444. } else if (Array.isArray(value)) {
  6445. cloned[key] = value.map(function(item) {
  6446. return item;
  6447. });
  6448. } else {
  6449. cloned[key] = cloneProperties(value);
  6450. }
  6451. } else {
  6452. cloned[key] = value;
  6453. }
  6454. });
  6455. return cloned;
  6456. }
  6457. function cloneFeatureCollection(geojson) {
  6458. var cloned = { type: "FeatureCollection" };
  6459. Object.keys(geojson).forEach(function(key) {
  6460. switch (key) {
  6461. case "type":
  6462. case "features":
  6463. return;
  6464. default:
  6465. cloned[key] = geojson[key];
  6466. }
  6467. });
  6468. cloned.features = geojson.features.map(function(feature2) {
  6469. return cloneFeature(feature2);
  6470. });
  6471. return cloned;
  6472. }
  6473. function cloneGeometry(geometry2) {
  6474. var geom = { type: geometry2.type };
  6475. if (geometry2.bbox) {
  6476. geom.bbox = geometry2.bbox;
  6477. }
  6478. if (geometry2.type === "GeometryCollection") {
  6479. geom.geometries = geometry2.geometries.map(function(g) {
  6480. return cloneGeometry(g);
  6481. });
  6482. return geom;
  6483. }
  6484. geom.coordinates = deepSlice(geometry2.coordinates);
  6485. return geom;
  6486. }
  6487. function deepSlice(coords) {
  6488. var cloned = coords;
  6489. if (typeof cloned[0] !== "object") {
  6490. return cloned.slice();
  6491. }
  6492. return cloned.map(function(coord) {
  6493. return deepSlice(coord);
  6494. });
  6495. }
  6496. var es_default5 = clone;
  6497. // node_modules/@turf/concave/dist/es/lib/turf-line-dissolve.js
  6498. function lineDissolve(geojson, options) {
  6499. if (options === void 0) {
  6500. options = {};
  6501. }
  6502. options = options || {};
  6503. if (!isObject(options)) {
  6504. throw new Error("options is invalid");
  6505. }
  6506. var mutate = options.mutate;
  6507. if (getType(geojson) !== "FeatureCollection") {
  6508. throw new Error("geojson must be a FeatureCollection");
  6509. }
  6510. if (!geojson.features.length) {
  6511. throw new Error("geojson is empty");
  6512. }
  6513. if (mutate === false || mutate === void 0) {
  6514. geojson = es_default5(geojson);
  6515. }
  6516. var result = [];
  6517. var lastLine = lineReduce(geojson, function(previousLine, currentLine) {
  6518. var merged = mergeLineStrings(previousLine, currentLine);
  6519. if (merged) {
  6520. return merged;
  6521. } else {
  6522. result.push(previousLine);
  6523. return currentLine;
  6524. }
  6525. });
  6526. if (lastLine) {
  6527. result.push(lastLine);
  6528. }
  6529. if (!result.length) {
  6530. return null;
  6531. } else if (result.length === 1) {
  6532. return result[0];
  6533. } else {
  6534. return multiLineString(result.map(function(line) {
  6535. return line.coordinates;
  6536. }));
  6537. }
  6538. }
  6539. function coordId(coord) {
  6540. return coord[0].toString() + "," + coord[1].toString();
  6541. }
  6542. function mergeLineStrings(a, b) {
  6543. var coords1 = a.geometry.coordinates;
  6544. var coords2 = b.geometry.coordinates;
  6545. var s1 = coordId(coords1[0]);
  6546. var e1 = coordId(coords1[coords1.length - 1]);
  6547. var s2 = coordId(coords2[0]);
  6548. var e22 = coordId(coords2[coords2.length - 1]);
  6549. var coords;
  6550. if (s1 === e22) {
  6551. coords = coords2.concat(coords1.slice(1));
  6552. } else if (s2 === e1) {
  6553. coords = coords1.concat(coords2.slice(1));
  6554. } else if (s1 === s2) {
  6555. coords = coords1.slice(1).reverse().concat(coords2);
  6556. } else if (e1 === e22) {
  6557. coords = coords1.concat(coords2.reverse().slice(1));
  6558. } else {
  6559. return null;
  6560. }
  6561. return lineString(coords);
  6562. }
  6563. var turf_line_dissolve_default = lineDissolve;
  6564. // node_modules/topojson-server/src/object.js
  6565. var hasOwnProperty = Object.prototype.hasOwnProperty;
  6566. // node_modules/topojson-server/src/bounds.js
  6567. function bounds_default(objects) {
  6568. var x02 = Infinity, y02 = Infinity, x12 = -Infinity, y12 = -Infinity;
  6569. function boundGeometry(geometry2) {
  6570. if (geometry2 != null && hasOwnProperty.call(boundGeometryType, geometry2.type))
  6571. boundGeometryType[geometry2.type](geometry2);
  6572. }
  6573. var boundGeometryType = {
  6574. GeometryCollection: function(o) {
  6575. o.geometries.forEach(boundGeometry);
  6576. },
  6577. Point: function(o) {
  6578. boundPoint(o.coordinates);
  6579. },
  6580. MultiPoint: function(o) {
  6581. o.coordinates.forEach(boundPoint);
  6582. },
  6583. LineString: function(o) {
  6584. boundLine(o.arcs);
  6585. },
  6586. MultiLineString: function(o) {
  6587. o.arcs.forEach(boundLine);
  6588. },
  6589. Polygon: function(o) {
  6590. o.arcs.forEach(boundLine);
  6591. },
  6592. MultiPolygon: function(o) {
  6593. o.arcs.forEach(boundMultiLine);
  6594. }
  6595. };
  6596. function boundPoint(coordinates) {
  6597. var x2 = coordinates[0], y2 = coordinates[1];
  6598. if (x2 < x02)
  6599. x02 = x2;
  6600. if (x2 > x12)
  6601. x12 = x2;
  6602. if (y2 < y02)
  6603. y02 = y2;
  6604. if (y2 > y12)
  6605. y12 = y2;
  6606. }
  6607. function boundLine(coordinates) {
  6608. coordinates.forEach(boundPoint);
  6609. }
  6610. function boundMultiLine(coordinates) {
  6611. coordinates.forEach(boundLine);
  6612. }
  6613. for (var key in objects) {
  6614. boundGeometry(objects[key]);
  6615. }
  6616. return x12 >= x02 && y12 >= y02 ? [x02, y02, x12, y12] : void 0;
  6617. }
  6618. // node_modules/topojson-server/src/hash/hashset.js
  6619. function hashset_default(size11, hash, equal3, type, empty) {
  6620. if (arguments.length === 3) {
  6621. type = Array;
  6622. empty = null;
  6623. }
  6624. var store = new type(size11 = 1 << Math.max(4, Math.ceil(Math.log(size11) / Math.LN2))), mask2 = size11 - 1;
  6625. for (var i = 0; i < size11; ++i) {
  6626. store[i] = empty;
  6627. }
  6628. function add17(value) {
  6629. var index2 = hash(value) & mask2, match = store[index2], collisions = 0;
  6630. while (match != empty) {
  6631. if (equal3(match, value))
  6632. return true;
  6633. if (++collisions >= size11)
  6634. throw new Error("full hashset");
  6635. match = store[index2 = index2 + 1 & mask2];
  6636. }
  6637. store[index2] = value;
  6638. return true;
  6639. }
  6640. function has(value) {
  6641. var index2 = hash(value) & mask2, match = store[index2], collisions = 0;
  6642. while (match != empty) {
  6643. if (equal3(match, value))
  6644. return true;
  6645. if (++collisions >= size11)
  6646. break;
  6647. match = store[index2 = index2 + 1 & mask2];
  6648. }
  6649. return false;
  6650. }
  6651. function values3() {
  6652. var values4 = [];
  6653. for (var i2 = 0, n = store.length; i2 < n; ++i2) {
  6654. var match = store[i2];
  6655. if (match != empty)
  6656. values4.push(match);
  6657. }
  6658. return values4;
  6659. }
  6660. return {
  6661. add: add17,
  6662. has,
  6663. values: values3
  6664. };
  6665. }
  6666. // node_modules/topojson-server/src/hash/hashmap.js
  6667. function hashmap_default(size11, hash, equal3, keyType, keyEmpty, valueType) {
  6668. if (arguments.length === 3) {
  6669. keyType = valueType = Array;
  6670. keyEmpty = null;
  6671. }
  6672. var keystore = new keyType(size11 = 1 << Math.max(4, Math.ceil(Math.log(size11) / Math.LN2))), valstore = new valueType(size11), mask2 = size11 - 1;
  6673. for (var i = 0; i < size11; ++i) {
  6674. keystore[i] = keyEmpty;
  6675. }
  6676. function set(key, value) {
  6677. var index2 = hash(key) & mask2, matchKey = keystore[index2], collisions = 0;
  6678. while (matchKey != keyEmpty) {
  6679. if (equal3(matchKey, key))
  6680. return valstore[index2] = value;
  6681. if (++collisions >= size11)
  6682. throw new Error("full hashmap");
  6683. matchKey = keystore[index2 = index2 + 1 & mask2];
  6684. }
  6685. keystore[index2] = key;
  6686. valstore[index2] = value;
  6687. return value;
  6688. }
  6689. function maybeSet(key, value) {
  6690. var index2 = hash(key) & mask2, matchKey = keystore[index2], collisions = 0;
  6691. while (matchKey != keyEmpty) {
  6692. if (equal3(matchKey, key))
  6693. return valstore[index2];
  6694. if (++collisions >= size11)
  6695. throw new Error("full hashmap");
  6696. matchKey = keystore[index2 = index2 + 1 & mask2];
  6697. }
  6698. keystore[index2] = key;
  6699. valstore[index2] = value;
  6700. return value;
  6701. }
  6702. function get4(key, missingValue) {
  6703. var index2 = hash(key) & mask2, matchKey = keystore[index2], collisions = 0;
  6704. while (matchKey != keyEmpty) {
  6705. if (equal3(matchKey, key))
  6706. return valstore[index2];
  6707. if (++collisions >= size11)
  6708. break;
  6709. matchKey = keystore[index2 = index2 + 1 & mask2];
  6710. }
  6711. return missingValue;
  6712. }
  6713. function keys() {
  6714. var keys2 = [];
  6715. for (var i2 = 0, n = keystore.length; i2 < n; ++i2) {
  6716. var matchKey = keystore[i2];
  6717. if (matchKey != keyEmpty)
  6718. keys2.push(matchKey);
  6719. }
  6720. return keys2;
  6721. }
  6722. return {
  6723. set,
  6724. maybeSet,
  6725. get: get4,
  6726. keys
  6727. };
  6728. }
  6729. // node_modules/topojson-server/src/hash/point-equal.js
  6730. function point_equal_default(pointA, pointB) {
  6731. return pointA[0] === pointB[0] && pointA[1] === pointB[1];
  6732. }
  6733. // node_modules/topojson-server/src/hash/point-hash.js
  6734. var buffer = new ArrayBuffer(16);
  6735. var floats = new Float64Array(buffer);
  6736. var uints = new Uint32Array(buffer);
  6737. function point_hash_default(point4) {
  6738. floats[0] = point4[0];
  6739. floats[1] = point4[1];
  6740. var hash = uints[0] ^ uints[1];
  6741. hash = hash << 5 ^ hash >> 7 ^ uints[2] ^ uints[3];
  6742. return hash & 2147483647;
  6743. }
  6744. // node_modules/topojson-server/src/join.js
  6745. function join_default(topology) {
  6746. var coordinates = topology.coordinates, lines = topology.lines, rings = topology.rings, indexes = index2(), visitedByIndex = new Int32Array(coordinates.length), leftByIndex = new Int32Array(coordinates.length), rightByIndex = new Int32Array(coordinates.length), junctionByIndex = new Int8Array(coordinates.length), junctionCount = 0, i, n, previousIndex, currentIndex, nextIndex;
  6747. for (i = 0, n = coordinates.length; i < n; ++i) {
  6748. visitedByIndex[i] = leftByIndex[i] = rightByIndex[i] = -1;
  6749. }
  6750. for (i = 0, n = lines.length; i < n; ++i) {
  6751. var line = lines[i], lineStart = line[0], lineEnd = line[1];
  6752. currentIndex = indexes[lineStart];
  6753. nextIndex = indexes[++lineStart];
  6754. ++junctionCount, junctionByIndex[currentIndex] = 1;
  6755. while (++lineStart <= lineEnd) {
  6756. sequence(i, previousIndex = currentIndex, currentIndex = nextIndex, nextIndex = indexes[lineStart]);
  6757. }
  6758. ++junctionCount, junctionByIndex[nextIndex] = 1;
  6759. }
  6760. for (i = 0, n = coordinates.length; i < n; ++i) {
  6761. visitedByIndex[i] = -1;
  6762. }
  6763. for (i = 0, n = rings.length; i < n; ++i) {
  6764. var ring = rings[i], ringStart = ring[0] + 1, ringEnd = ring[1];
  6765. previousIndex = indexes[ringEnd - 1];
  6766. currentIndex = indexes[ringStart - 1];
  6767. nextIndex = indexes[ringStart];
  6768. sequence(i, previousIndex, currentIndex, nextIndex);
  6769. while (++ringStart <= ringEnd) {
  6770. sequence(i, previousIndex = currentIndex, currentIndex = nextIndex, nextIndex = indexes[ringStart]);
  6771. }
  6772. }
  6773. function sequence(i2, previousIndex2, currentIndex2, nextIndex2) {
  6774. if (visitedByIndex[currentIndex2] === i2)
  6775. return;
  6776. visitedByIndex[currentIndex2] = i2;
  6777. var leftIndex = leftByIndex[currentIndex2];
  6778. if (leftIndex >= 0) {
  6779. var rightIndex = rightByIndex[currentIndex2];
  6780. if ((leftIndex !== previousIndex2 || rightIndex !== nextIndex2) && (leftIndex !== nextIndex2 || rightIndex !== previousIndex2)) {
  6781. ++junctionCount, junctionByIndex[currentIndex2] = 1;
  6782. }
  6783. } else {
  6784. leftByIndex[currentIndex2] = previousIndex2;
  6785. rightByIndex[currentIndex2] = nextIndex2;
  6786. }
  6787. }
  6788. function index2() {
  6789. var indexByPoint = hashmap_default(coordinates.length * 1.4, hashIndex, equalIndex, Int32Array, -1, Int32Array), indexes2 = new Int32Array(coordinates.length);
  6790. for (var i2 = 0, n2 = coordinates.length; i2 < n2; ++i2) {
  6791. indexes2[i2] = indexByPoint.maybeSet(i2, i2);
  6792. }
  6793. return indexes2;
  6794. }
  6795. function hashIndex(i2) {
  6796. return point_hash_default(coordinates[i2]);
  6797. }
  6798. function equalIndex(i2, j2) {
  6799. return point_equal_default(coordinates[i2], coordinates[j2]);
  6800. }
  6801. visitedByIndex = leftByIndex = rightByIndex = null;
  6802. var junctionByPoint = hashset_default(junctionCount * 1.4, point_hash_default, point_equal_default), j;
  6803. for (i = 0, n = coordinates.length; i < n; ++i) {
  6804. if (junctionByIndex[j = indexes[i]]) {
  6805. junctionByPoint.add(coordinates[j]);
  6806. }
  6807. }
  6808. return junctionByPoint;
  6809. }
  6810. // node_modules/topojson-server/src/cut.js
  6811. function cut_default(topology) {
  6812. var junctions = join_default(topology), coordinates = topology.coordinates, lines = topology.lines, rings = topology.rings, next3, i, n;
  6813. for (i = 0, n = lines.length; i < n; ++i) {
  6814. var line = lines[i], lineMid = line[0], lineEnd = line[1];
  6815. while (++lineMid < lineEnd) {
  6816. if (junctions.has(coordinates[lineMid])) {
  6817. next3 = { 0: lineMid, 1: line[1] };
  6818. line[1] = lineMid;
  6819. line = line.next = next3;
  6820. }
  6821. }
  6822. }
  6823. for (i = 0, n = rings.length; i < n; ++i) {
  6824. var ring = rings[i], ringStart = ring[0], ringMid = ringStart, ringEnd = ring[1], ringFixed = junctions.has(coordinates[ringStart]);
  6825. while (++ringMid < ringEnd) {
  6826. if (junctions.has(coordinates[ringMid])) {
  6827. if (ringFixed) {
  6828. next3 = { 0: ringMid, 1: ring[1] };
  6829. ring[1] = ringMid;
  6830. ring = ring.next = next3;
  6831. } else {
  6832. rotateArray(coordinates, ringStart, ringEnd, ringEnd - ringMid);
  6833. coordinates[ringEnd] = coordinates[ringStart];
  6834. ringFixed = true;
  6835. ringMid = ringStart;
  6836. }
  6837. }
  6838. }
  6839. }
  6840. return topology;
  6841. }
  6842. function rotateArray(array2, start, end, offset) {
  6843. reverse(array2, start, end);
  6844. reverse(array2, start, start + offset);
  6845. reverse(array2, start + offset, end);
  6846. }
  6847. function reverse(array2, start, end) {
  6848. for (var mid = start + (end-- - start >> 1), t; start < mid; ++start, --end) {
  6849. t = array2[start], array2[start] = array2[end], array2[end] = t;
  6850. }
  6851. }
  6852. // node_modules/topojson-server/src/dedup.js
  6853. function dedup_default(topology) {
  6854. var coordinates = topology.coordinates, lines = topology.lines, line, rings = topology.rings, ring, arcCount = lines.length + rings.length, i, n;
  6855. delete topology.lines;
  6856. delete topology.rings;
  6857. for (i = 0, n = lines.length; i < n; ++i) {
  6858. line = lines[i];
  6859. while (line = line.next)
  6860. ++arcCount;
  6861. }
  6862. for (i = 0, n = rings.length; i < n; ++i) {
  6863. ring = rings[i];
  6864. while (ring = ring.next)
  6865. ++arcCount;
  6866. }
  6867. var arcsByEnd = hashmap_default(arcCount * 2 * 1.4, point_hash_default, point_equal_default), arcs = topology.arcs = [];
  6868. for (i = 0, n = lines.length; i < n; ++i) {
  6869. line = lines[i];
  6870. do {
  6871. dedupLine(line);
  6872. } while (line = line.next);
  6873. }
  6874. for (i = 0, n = rings.length; i < n; ++i) {
  6875. ring = rings[i];
  6876. if (ring.next) {
  6877. do {
  6878. dedupLine(ring);
  6879. } while (ring = ring.next);
  6880. } else {
  6881. dedupRing(ring);
  6882. }
  6883. }
  6884. function dedupLine(arc) {
  6885. var startPoint, endPoint, startArcs, startArc, endArcs, endArc, i2, n2;
  6886. if (startArcs = arcsByEnd.get(startPoint = coordinates[arc[0]])) {
  6887. for (i2 = 0, n2 = startArcs.length; i2 < n2; ++i2) {
  6888. startArc = startArcs[i2];
  6889. if (equalLine(startArc, arc)) {
  6890. arc[0] = startArc[0];
  6891. arc[1] = startArc[1];
  6892. return;
  6893. }
  6894. }
  6895. }
  6896. if (endArcs = arcsByEnd.get(endPoint = coordinates[arc[1]])) {
  6897. for (i2 = 0, n2 = endArcs.length; i2 < n2; ++i2) {
  6898. endArc = endArcs[i2];
  6899. if (reverseEqualLine(endArc, arc)) {
  6900. arc[1] = endArc[0];
  6901. arc[0] = endArc[1];
  6902. return;
  6903. }
  6904. }
  6905. }
  6906. if (startArcs)
  6907. startArcs.push(arc);
  6908. else
  6909. arcsByEnd.set(startPoint, [arc]);
  6910. if (endArcs)
  6911. endArcs.push(arc);
  6912. else
  6913. arcsByEnd.set(endPoint, [arc]);
  6914. arcs.push(arc);
  6915. }
  6916. function dedupRing(arc) {
  6917. var endPoint, endArcs, endArc, i2, n2;
  6918. if (endArcs = arcsByEnd.get(endPoint = coordinates[arc[0]])) {
  6919. for (i2 = 0, n2 = endArcs.length; i2 < n2; ++i2) {
  6920. endArc = endArcs[i2];
  6921. if (equalRing(endArc, arc)) {
  6922. arc[0] = endArc[0];
  6923. arc[1] = endArc[1];
  6924. return;
  6925. }
  6926. if (reverseEqualRing(endArc, arc)) {
  6927. arc[0] = endArc[1];
  6928. arc[1] = endArc[0];
  6929. return;
  6930. }
  6931. }
  6932. }
  6933. if (endArcs = arcsByEnd.get(endPoint = coordinates[arc[0] + findMinimumOffset(arc)])) {
  6934. for (i2 = 0, n2 = endArcs.length; i2 < n2; ++i2) {
  6935. endArc = endArcs[i2];
  6936. if (equalRing(endArc, arc)) {
  6937. arc[0] = endArc[0];
  6938. arc[1] = endArc[1];
  6939. return;
  6940. }
  6941. if (reverseEqualRing(endArc, arc)) {
  6942. arc[0] = endArc[1];
  6943. arc[1] = endArc[0];
  6944. return;
  6945. }
  6946. }
  6947. }
  6948. if (endArcs)
  6949. endArcs.push(arc);
  6950. else
  6951. arcsByEnd.set(endPoint, [arc]);
  6952. arcs.push(arc);
  6953. }
  6954. function equalLine(arcA, arcB) {
  6955. var ia = arcA[0], ib = arcB[0], ja = arcA[1], jb = arcB[1];
  6956. if (ia - ja !== ib - jb)
  6957. return false;
  6958. for (; ia <= ja; ++ia, ++ib)
  6959. if (!point_equal_default(coordinates[ia], coordinates[ib]))
  6960. return false;
  6961. return true;
  6962. }
  6963. function reverseEqualLine(arcA, arcB) {
  6964. var ia = arcA[0], ib = arcB[0], ja = arcA[1], jb = arcB[1];
  6965. if (ia - ja !== ib - jb)
  6966. return false;
  6967. for (; ia <= ja; ++ia, --jb)
  6968. if (!point_equal_default(coordinates[ia], coordinates[jb]))
  6969. return false;
  6970. return true;
  6971. }
  6972. function equalRing(arcA, arcB) {
  6973. var ia = arcA[0], ib = arcB[0], ja = arcA[1], jb = arcB[1], n2 = ja - ia;
  6974. if (n2 !== jb - ib)
  6975. return false;
  6976. var ka = findMinimumOffset(arcA), kb = findMinimumOffset(arcB);
  6977. for (var i2 = 0; i2 < n2; ++i2) {
  6978. if (!point_equal_default(coordinates[ia + (i2 + ka) % n2], coordinates[ib + (i2 + kb) % n2]))
  6979. return false;
  6980. }
  6981. return true;
  6982. }
  6983. function reverseEqualRing(arcA, arcB) {
  6984. var ia = arcA[0], ib = arcB[0], ja = arcA[1], jb = arcB[1], n2 = ja - ia;
  6985. if (n2 !== jb - ib)
  6986. return false;
  6987. var ka = findMinimumOffset(arcA), kb = n2 - findMinimumOffset(arcB);
  6988. for (var i2 = 0; i2 < n2; ++i2) {
  6989. if (!point_equal_default(coordinates[ia + (i2 + ka) % n2], coordinates[jb - (i2 + kb) % n2]))
  6990. return false;
  6991. }
  6992. return true;
  6993. }
  6994. function findMinimumOffset(arc) {
  6995. var start = arc[0], end = arc[1], mid = start, minimum = mid, minimumPoint = coordinates[mid];
  6996. while (++mid < end) {
  6997. var point4 = coordinates[mid];
  6998. if (point4[0] < minimumPoint[0] || point4[0] === minimumPoint[0] && point4[1] < minimumPoint[1]) {
  6999. minimum = mid;
  7000. minimumPoint = point4;
  7001. }
  7002. }
  7003. return minimum - start;
  7004. }
  7005. return topology;
  7006. }
  7007. // node_modules/topojson-server/src/delta.js
  7008. function delta_default(arcs) {
  7009. var i = -1, n = arcs.length;
  7010. while (++i < n) {
  7011. var arc = arcs[i], j = 0, k = 1, m = arc.length, point4 = arc[0], x02 = point4[0], y02 = point4[1], x12, y12;
  7012. while (++j < m) {
  7013. point4 = arc[j], x12 = point4[0], y12 = point4[1];
  7014. if (x12 !== x02 || y12 !== y02)
  7015. arc[k++] = [x12 - x02, y12 - y02], x02 = x12, y02 = y12;
  7016. }
  7017. if (k === 1)
  7018. arc[k++] = [0, 0];
  7019. arc.length = k;
  7020. }
  7021. return arcs;
  7022. }
  7023. // node_modules/topojson-server/src/extract.js
  7024. function extract_default(objects) {
  7025. var index2 = -1, lines = [], rings = [], coordinates = [];
  7026. function extractGeometry2(geometry2) {
  7027. if (geometry2 && hasOwnProperty.call(extractGeometryType, geometry2.type))
  7028. extractGeometryType[geometry2.type](geometry2);
  7029. }
  7030. var extractGeometryType = {
  7031. GeometryCollection: function(o) {
  7032. o.geometries.forEach(extractGeometry2);
  7033. },
  7034. LineString: function(o) {
  7035. o.arcs = extractLine(o.arcs);
  7036. },
  7037. MultiLineString: function(o) {
  7038. o.arcs = o.arcs.map(extractLine);
  7039. },
  7040. Polygon: function(o) {
  7041. o.arcs = o.arcs.map(extractRing);
  7042. },
  7043. MultiPolygon: function(o) {
  7044. o.arcs = o.arcs.map(extractMultiRing);
  7045. }
  7046. };
  7047. function extractLine(line) {
  7048. for (var i = 0, n = line.length; i < n; ++i)
  7049. coordinates[++index2] = line[i];
  7050. var arc = { 0: index2 - n + 1, 1: index2 };
  7051. lines.push(arc);
  7052. return arc;
  7053. }
  7054. function extractRing(ring) {
  7055. for (var i = 0, n = ring.length; i < n; ++i)
  7056. coordinates[++index2] = ring[i];
  7057. var arc = { 0: index2 - n + 1, 1: index2 };
  7058. rings.push(arc);
  7059. return arc;
  7060. }
  7061. function extractMultiRing(rings2) {
  7062. return rings2.map(extractRing);
  7063. }
  7064. for (var key in objects) {
  7065. extractGeometry2(objects[key]);
  7066. }
  7067. return {
  7068. type: "Topology",
  7069. coordinates,
  7070. lines,
  7071. rings,
  7072. objects
  7073. };
  7074. }
  7075. // node_modules/topojson-server/src/geometry.js
  7076. function geometry_default(inputs) {
  7077. var outputs = {}, key;
  7078. for (key in inputs)
  7079. outputs[key] = geomifyObject(inputs[key]);
  7080. return outputs;
  7081. }
  7082. function geomifyObject(input) {
  7083. return input == null ? { type: null } : (input.type === "FeatureCollection" ? geomifyFeatureCollection : input.type === "Feature" ? geomifyFeature : geomifyGeometry)(input);
  7084. }
  7085. function geomifyFeatureCollection(input) {
  7086. var output = { type: "GeometryCollection", geometries: input.features.map(geomifyFeature) };
  7087. if (input.bbox != null)
  7088. output.bbox = input.bbox;
  7089. return output;
  7090. }
  7091. function geomifyFeature(input) {
  7092. var output = geomifyGeometry(input.geometry), key;
  7093. if (input.id != null)
  7094. output.id = input.id;
  7095. if (input.bbox != null)
  7096. output.bbox = input.bbox;
  7097. for (key in input.properties) {
  7098. output.properties = input.properties;
  7099. break;
  7100. }
  7101. return output;
  7102. }
  7103. function geomifyGeometry(input) {
  7104. if (input == null)
  7105. return { type: null };
  7106. var output = input.type === "GeometryCollection" ? { type: "GeometryCollection", geometries: input.geometries.map(geomifyGeometry) } : input.type === "Point" || input.type === "MultiPoint" ? { type: input.type, coordinates: input.coordinates } : { type: input.type, arcs: input.coordinates };
  7107. if (input.bbox != null)
  7108. output.bbox = input.bbox;
  7109. return output;
  7110. }
  7111. // node_modules/topojson-server/src/prequantize.js
  7112. function prequantize_default(objects, bbox3, n) {
  7113. var x02 = bbox3[0], y02 = bbox3[1], x12 = bbox3[2], y12 = bbox3[3], kx = x12 - x02 ? (n - 1) / (x12 - x02) : 1, ky = y12 - y02 ? (n - 1) / (y12 - y02) : 1;
  7114. function quantizePoint(input) {
  7115. return [Math.round((input[0] - x02) * kx), Math.round((input[1] - y02) * ky)];
  7116. }
  7117. function quantizePoints(input, m) {
  7118. var i = -1, j = 0, n2 = input.length, output = new Array(n2), pi2, px, py, x2, y2;
  7119. while (++i < n2) {
  7120. pi2 = input[i];
  7121. x2 = Math.round((pi2[0] - x02) * kx);
  7122. y2 = Math.round((pi2[1] - y02) * ky);
  7123. if (x2 !== px || y2 !== py)
  7124. output[j++] = [px = x2, py = y2];
  7125. }
  7126. output.length = j;
  7127. while (j < m)
  7128. j = output.push([output[0][0], output[0][1]]);
  7129. return output;
  7130. }
  7131. function quantizeLine(input) {
  7132. return quantizePoints(input, 2);
  7133. }
  7134. function quantizeRing(input) {
  7135. return quantizePoints(input, 4);
  7136. }
  7137. function quantizePolygon(input) {
  7138. return input.map(quantizeRing);
  7139. }
  7140. function quantizeGeometry(o) {
  7141. if (o != null && hasOwnProperty.call(quantizeGeometryType, o.type))
  7142. quantizeGeometryType[o.type](o);
  7143. }
  7144. var quantizeGeometryType = {
  7145. GeometryCollection: function(o) {
  7146. o.geometries.forEach(quantizeGeometry);
  7147. },
  7148. Point: function(o) {
  7149. o.coordinates = quantizePoint(o.coordinates);
  7150. },
  7151. MultiPoint: function(o) {
  7152. o.coordinates = o.coordinates.map(quantizePoint);
  7153. },
  7154. LineString: function(o) {
  7155. o.arcs = quantizeLine(o.arcs);
  7156. },
  7157. MultiLineString: function(o) {
  7158. o.arcs = o.arcs.map(quantizeLine);
  7159. },
  7160. Polygon: function(o) {
  7161. o.arcs = quantizePolygon(o.arcs);
  7162. },
  7163. MultiPolygon: function(o) {
  7164. o.arcs = o.arcs.map(quantizePolygon);
  7165. }
  7166. };
  7167. for (var key in objects) {
  7168. quantizeGeometry(objects[key]);
  7169. }
  7170. return {
  7171. scale: [1 / kx, 1 / ky],
  7172. translate: [x02, y02]
  7173. };
  7174. }
  7175. // node_modules/topojson-server/src/topology.js
  7176. function topology_default(objects, quantization) {
  7177. var bbox3 = bounds_default(objects = geometry_default(objects)), transform2 = quantization > 0 && bbox3 && prequantize_default(objects, bbox3, quantization), topology = dedup_default(cut_default(extract_default(objects))), coordinates = topology.coordinates, indexByArc = hashmap_default(topology.arcs.length * 1.4, hashArc, equalArc);
  7178. objects = topology.objects;
  7179. topology.bbox = bbox3;
  7180. topology.arcs = topology.arcs.map(function(arc, i) {
  7181. indexByArc.set(arc, i);
  7182. return coordinates.slice(arc[0], arc[1] + 1);
  7183. });
  7184. delete topology.coordinates;
  7185. coordinates = null;
  7186. function indexGeometry(geometry2) {
  7187. if (geometry2 && hasOwnProperty.call(indexGeometryType, geometry2.type))
  7188. indexGeometryType[geometry2.type](geometry2);
  7189. }
  7190. var indexGeometryType = {
  7191. GeometryCollection: function(o) {
  7192. o.geometries.forEach(indexGeometry);
  7193. },
  7194. LineString: function(o) {
  7195. o.arcs = indexArcs(o.arcs);
  7196. },
  7197. MultiLineString: function(o) {
  7198. o.arcs = o.arcs.map(indexArcs);
  7199. },
  7200. Polygon: function(o) {
  7201. o.arcs = o.arcs.map(indexArcs);
  7202. },
  7203. MultiPolygon: function(o) {
  7204. o.arcs = o.arcs.map(indexMultiArcs);
  7205. }
  7206. };
  7207. function indexArcs(arc) {
  7208. var indexes = [];
  7209. do {
  7210. var index2 = indexByArc.get(arc);
  7211. indexes.push(arc[0] < arc[1] ? index2 : ~index2);
  7212. } while (arc = arc.next);
  7213. return indexes;
  7214. }
  7215. function indexMultiArcs(arcs) {
  7216. return arcs.map(indexArcs);
  7217. }
  7218. for (var key in objects) {
  7219. indexGeometry(objects[key]);
  7220. }
  7221. if (transform2) {
  7222. topology.transform = transform2;
  7223. topology.arcs = delta_default(topology.arcs);
  7224. }
  7225. return topology;
  7226. }
  7227. function hashArc(arc) {
  7228. var i = arc[0], j = arc[1], t;
  7229. if (j < i)
  7230. t = i, i = j, j = t;
  7231. return i + 31 * j;
  7232. }
  7233. function equalArc(arcA, arcB) {
  7234. var ia = arcA[0], ja = arcA[1], ib = arcB[0], jb = arcB[1], t;
  7235. if (ja < ia)
  7236. t = ia, ia = ja, ja = t;
  7237. if (jb < ib)
  7238. t = ib, ib = jb, jb = t;
  7239. return ia === ib && ja === jb;
  7240. }
  7241. // node_modules/@turf/concave/dist/es/lib/turf-polygon-dissolve.js
  7242. function polygonDissolve(geojson, options) {
  7243. if (options === void 0) {
  7244. options = {};
  7245. }
  7246. if (getType(geojson) !== "FeatureCollection") {
  7247. throw new Error("geojson must be a FeatureCollection");
  7248. }
  7249. if (!geojson.features.length) {
  7250. throw new Error("geojson is empty");
  7251. }
  7252. if (options.mutate === false || options.mutate === void 0) {
  7253. geojson = es_default5(geojson);
  7254. }
  7255. var geoms = [];
  7256. flattenEach(geojson, function(feature2) {
  7257. geoms.push(feature2.geometry);
  7258. });
  7259. var topo = topology_default({ geoms: geometryCollection(geoms).geometry });
  7260. var merged = merge_default(topo, topo.objects.geoms.geometries);
  7261. return merged;
  7262. }
  7263. // node_modules/@turf/concave/dist/es/lib/turf-dissolve.js
  7264. function dissolve(geojson, options) {
  7265. if (options === void 0) {
  7266. options = {};
  7267. }
  7268. options = options || {};
  7269. if (!isObject(options)) {
  7270. throw new Error("options is invalid");
  7271. }
  7272. var mutate = options.mutate;
  7273. if (getType(geojson) !== "FeatureCollection") {
  7274. throw new Error("geojson must be a FeatureCollection");
  7275. }
  7276. if (!geojson.features.length) {
  7277. throw new Error("geojson is empty");
  7278. }
  7279. if (mutate === false || mutate === void 0) {
  7280. geojson = es_default5(geojson);
  7281. }
  7282. var type = getHomogenousType(geojson);
  7283. if (!type) {
  7284. throw new Error("geojson must be homogenous");
  7285. }
  7286. var data = geojson;
  7287. switch (type) {
  7288. case "LineString":
  7289. return turf_line_dissolve_default(data, options);
  7290. case "Polygon":
  7291. return polygonDissolve(data, options);
  7292. default:
  7293. throw new Error(type + " is not supported");
  7294. }
  7295. }
  7296. function getHomogenousType(geojson) {
  7297. var types = {};
  7298. flattenEach(geojson, function(feature2) {
  7299. types[feature2.geometry.type] = true;
  7300. });
  7301. var keys = Object.keys(types);
  7302. if (keys.length === 1) {
  7303. return keys[0];
  7304. }
  7305. return null;
  7306. }
  7307. var turf_dissolve_default = dissolve;
  7308. // node_modules/@turf/concave/dist/es/index.js
  7309. function concave(points2, options) {
  7310. if (options === void 0) {
  7311. options = {};
  7312. }
  7313. var maxEdge = options.maxEdge || Infinity;
  7314. var cleaned = removeDuplicates(points2);
  7315. var tinPolys = tin(cleaned);
  7316. tinPolys.features = tinPolys.features.filter(function(triangle) {
  7317. var pt1 = triangle.geometry.coordinates[0][0];
  7318. var pt2 = triangle.geometry.coordinates[0][1];
  7319. var pt3 = triangle.geometry.coordinates[0][2];
  7320. var dist1 = es_default4(pt1, pt2, options);
  7321. var dist2 = es_default4(pt2, pt3, options);
  7322. var dist3 = es_default4(pt1, pt3, options);
  7323. return dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge;
  7324. });
  7325. if (tinPolys.features.length < 1) {
  7326. return null;
  7327. }
  7328. var dissolved = turf_dissolve_default(tinPolys);
  7329. if (dissolved.coordinates.length === 1) {
  7330. dissolved.coordinates = dissolved.coordinates[0];
  7331. dissolved.type = "Polygon";
  7332. }
  7333. return feature(dissolved);
  7334. }
  7335. function removeDuplicates(points2) {
  7336. var cleaned = [];
  7337. var existing = {};
  7338. featureEach(points2, function(pt) {
  7339. if (!pt.geometry) {
  7340. return;
  7341. }
  7342. var key = pt.geometry.coordinates.join("-");
  7343. if (!Object.prototype.hasOwnProperty.call(existing, key)) {
  7344. cleaned.push(pt);
  7345. existing[key] = true;
  7346. }
  7347. });
  7348. return featureCollection(cleaned);
  7349. }
  7350. var es_default6 = concave;
  7351. // node_modules/@turf/collect/dist/es/index.js
  7352. var import_rbush = __toESM(require_rbush());
  7353. function collect(polygons2, points2, inProperty, outProperty) {
  7354. var rtree = (0, import_rbush.default)(6);
  7355. var treeItems = points2.features.map(function(item) {
  7356. var _a;
  7357. return {
  7358. minX: item.geometry.coordinates[0],
  7359. minY: item.geometry.coordinates[1],
  7360. maxX: item.geometry.coordinates[0],
  7361. maxY: item.geometry.coordinates[1],
  7362. property: (_a = item.properties) === null || _a === void 0 ? void 0 : _a[inProperty]
  7363. };
  7364. });
  7365. rtree.load(treeItems);
  7366. polygons2.features.forEach(function(poly) {
  7367. if (!poly.properties) {
  7368. poly.properties = {};
  7369. }
  7370. var bbox3 = es_default(poly);
  7371. var potentialPoints = rtree.search({
  7372. minX: bbox3[0],
  7373. minY: bbox3[1],
  7374. maxX: bbox3[2],
  7375. maxY: bbox3[3]
  7376. });
  7377. var values3 = [];
  7378. potentialPoints.forEach(function(pt) {
  7379. if (booleanPointInPolygon([pt.minX, pt.minY], poly)) {
  7380. values3.push(pt.property);
  7381. }
  7382. });
  7383. poly.properties[outProperty] = values3;
  7384. });
  7385. return polygons2;
  7386. }
  7387. var es_default7 = collect;
  7388. // node_modules/@turf/flip/dist/es/index.js
  7389. function flip(geojson, options) {
  7390. options = options || {};
  7391. if (!isObject(options))
  7392. throw new Error("options is invalid");
  7393. var mutate = options.mutate;
  7394. if (!geojson)
  7395. throw new Error("geojson is required");
  7396. if (mutate === false || mutate === void 0)
  7397. geojson = es_default5(geojson);
  7398. coordEach(geojson, function(coord) {
  7399. var x2 = coord[0];
  7400. var y2 = coord[1];
  7401. coord[0] = y2;
  7402. coord[1] = x2;
  7403. });
  7404. return geojson;
  7405. }
  7406. var es_default8 = flip;
  7407. // node_modules/@turf/clean-coords/dist/es/index.js
  7408. function cleanCoords(geojson, options) {
  7409. if (options === void 0) {
  7410. options = {};
  7411. }
  7412. var mutate = typeof options === "object" ? options.mutate : options;
  7413. if (!geojson)
  7414. throw new Error("geojson is required");
  7415. var type = getType(geojson);
  7416. var newCoords = [];
  7417. switch (type) {
  7418. case "LineString":
  7419. newCoords = cleanLine(geojson);
  7420. break;
  7421. case "MultiLineString":
  7422. case "Polygon":
  7423. getCoords(geojson).forEach(function(line) {
  7424. newCoords.push(cleanLine(line));
  7425. });
  7426. break;
  7427. case "MultiPolygon":
  7428. getCoords(geojson).forEach(function(polygons2) {
  7429. var polyPoints = [];
  7430. polygons2.forEach(function(ring) {
  7431. polyPoints.push(cleanLine(ring));
  7432. });
  7433. newCoords.push(polyPoints);
  7434. });
  7435. break;
  7436. case "Point":
  7437. return geojson;
  7438. case "MultiPoint":
  7439. var existing = {};
  7440. getCoords(geojson).forEach(function(coord) {
  7441. var key = coord.join("-");
  7442. if (!Object.prototype.hasOwnProperty.call(existing, key)) {
  7443. newCoords.push(coord);
  7444. existing[key] = true;
  7445. }
  7446. });
  7447. break;
  7448. default:
  7449. throw new Error(type + " geometry not supported");
  7450. }
  7451. if (geojson.coordinates) {
  7452. if (mutate === true) {
  7453. geojson.coordinates = newCoords;
  7454. return geojson;
  7455. }
  7456. return { type, coordinates: newCoords };
  7457. } else {
  7458. if (mutate === true) {
  7459. geojson.geometry.coordinates = newCoords;
  7460. return geojson;
  7461. }
  7462. return feature({ type, coordinates: newCoords }, geojson.properties, {
  7463. bbox: geojson.bbox,
  7464. id: geojson.id
  7465. });
  7466. }
  7467. }
  7468. function cleanLine(line) {
  7469. var points2 = getCoords(line);
  7470. if (points2.length === 2 && !equals(points2[0], points2[1]))
  7471. return points2;
  7472. var newPoints = [];
  7473. var secondToLast = points2.length - 1;
  7474. var newPointsLength = newPoints.length;
  7475. newPoints.push(points2[0]);
  7476. for (var i = 1; i < secondToLast; i++) {
  7477. var prevAddedPoint = newPoints[newPoints.length - 1];
  7478. if (points2[i][0] === prevAddedPoint[0] && points2[i][1] === prevAddedPoint[1])
  7479. continue;
  7480. else {
  7481. newPoints.push(points2[i]);
  7482. newPointsLength = newPoints.length;
  7483. if (newPointsLength > 2) {
  7484. if (isPointOnLineSegment(newPoints[newPointsLength - 3], newPoints[newPointsLength - 1], newPoints[newPointsLength - 2]))
  7485. newPoints.splice(newPoints.length - 2, 1);
  7486. }
  7487. }
  7488. }
  7489. newPoints.push(points2[points2.length - 1]);
  7490. newPointsLength = newPoints.length;
  7491. if (equals(points2[0], points2[points2.length - 1]) && newPointsLength < 4)
  7492. throw new Error("invalid polygon");
  7493. if (isPointOnLineSegment(newPoints[newPointsLength - 3], newPoints[newPointsLength - 1], newPoints[newPointsLength - 2]))
  7494. newPoints.splice(newPoints.length - 2, 1);
  7495. return newPoints;
  7496. }
  7497. function equals(pt1, pt2) {
  7498. return pt1[0] === pt2[0] && pt1[1] === pt2[1];
  7499. }
  7500. function isPointOnLineSegment(start, end, point4) {
  7501. var x2 = point4[0], y2 = point4[1];
  7502. var startX = start[0], startY = start[1];
  7503. var endX = end[0], endY = end[1];
  7504. var dxc = x2 - startX;
  7505. var dyc = y2 - startY;
  7506. var dxl = endX - startX;
  7507. var dyl = endY - startY;
  7508. var cross = dxc * dyl - dyc * dxl;
  7509. if (cross !== 0)
  7510. return false;
  7511. else if (Math.abs(dxl) >= Math.abs(dyl))
  7512. return dxl > 0 ? startX <= x2 && x2 <= endX : endX <= x2 && x2 <= startX;
  7513. else
  7514. return dyl > 0 ? startY <= y2 && y2 <= endY : endY <= y2 && y2 <= startY;
  7515. }
  7516. var es_default9 = cleanCoords;
  7517. // node_modules/@turf/simplify/dist/es/index.js
  7518. function getSqDist(p1, p2) {
  7519. var dx = p1.x - p2.x, dy = p1.y - p2.y;
  7520. return dx * dx + dy * dy;
  7521. }
  7522. function getSqSegDist(p, p1, p2) {
  7523. var x2 = p1.x, y2 = p1.y, dx = p2.x - x2, dy = p2.y - y2;
  7524. if (dx !== 0 || dy !== 0) {
  7525. var t = ((p.x - x2) * dx + (p.y - y2) * dy) / (dx * dx + dy * dy);
  7526. if (t > 1) {
  7527. x2 = p2.x;
  7528. y2 = p2.y;
  7529. } else if (t > 0) {
  7530. x2 += dx * t;
  7531. y2 += dy * t;
  7532. }
  7533. }
  7534. dx = p.x - x2;
  7535. dy = p.y - y2;
  7536. return dx * dx + dy * dy;
  7537. }
  7538. function simplifyRadialDist(points2, sqTolerance) {
  7539. var prevPoint = points2[0], newPoints = [prevPoint], point4;
  7540. for (var i = 1, len = points2.length; i < len; i++) {
  7541. point4 = points2[i];
  7542. if (getSqDist(point4, prevPoint) > sqTolerance) {
  7543. newPoints.push(point4);
  7544. prevPoint = point4;
  7545. }
  7546. }
  7547. if (prevPoint !== point4)
  7548. newPoints.push(point4);
  7549. return newPoints;
  7550. }
  7551. function simplifyDPStep(points2, first, last, sqTolerance, simplified) {
  7552. var maxSqDist = sqTolerance, index2;
  7553. for (var i = first + 1; i < last; i++) {
  7554. var sqDist = getSqSegDist(points2[i], points2[first], points2[last]);
  7555. if (sqDist > maxSqDist) {
  7556. index2 = i;
  7557. maxSqDist = sqDist;
  7558. }
  7559. }
  7560. if (maxSqDist > sqTolerance) {
  7561. if (index2 - first > 1)
  7562. simplifyDPStep(points2, first, index2, sqTolerance, simplified);
  7563. simplified.push(points2[index2]);
  7564. if (last - index2 > 1)
  7565. simplifyDPStep(points2, index2, last, sqTolerance, simplified);
  7566. }
  7567. }
  7568. function simplifyDouglasPeucker(points2, sqTolerance) {
  7569. var last = points2.length - 1;
  7570. var simplified = [points2[0]];
  7571. simplifyDPStep(points2, 0, last, sqTolerance, simplified);
  7572. simplified.push(points2[last]);
  7573. return simplified;
  7574. }
  7575. function simplify(points2, tolerance, highestQuality) {
  7576. if (points2.length <= 2)
  7577. return points2;
  7578. var sqTolerance = tolerance !== void 0 ? tolerance * tolerance : 1;
  7579. points2 = highestQuality ? points2 : simplifyRadialDist(points2, sqTolerance);
  7580. points2 = simplifyDouglasPeucker(points2, sqTolerance);
  7581. return points2;
  7582. }
  7583. function simplify$1(geojson, options) {
  7584. options = options || {};
  7585. if (!isObject(options))
  7586. throw new Error("options is invalid");
  7587. var tolerance = options.tolerance !== void 0 ? options.tolerance : 1;
  7588. var highQuality = options.highQuality || false;
  7589. var mutate = options.mutate || false;
  7590. if (!geojson)
  7591. throw new Error("geojson is required");
  7592. if (tolerance && tolerance < 0)
  7593. throw new Error("invalid tolerance");
  7594. if (mutate !== true)
  7595. geojson = es_default5(geojson);
  7596. geomEach(geojson, function(geom) {
  7597. simplifyGeom(geom, tolerance, highQuality);
  7598. });
  7599. return geojson;
  7600. }
  7601. function simplifyGeom(geometry2, tolerance, highQuality) {
  7602. var type = geometry2.type;
  7603. if (type === "Point" || type === "MultiPoint")
  7604. return geometry2;
  7605. es_default9(geometry2, true);
  7606. var coordinates = geometry2.coordinates;
  7607. switch (type) {
  7608. case "LineString":
  7609. geometry2["coordinates"] = simplifyLine(
  7610. coordinates,
  7611. tolerance,
  7612. highQuality
  7613. );
  7614. break;
  7615. case "MultiLineString":
  7616. geometry2["coordinates"] = coordinates.map(function(lines) {
  7617. return simplifyLine(lines, tolerance, highQuality);
  7618. });
  7619. break;
  7620. case "Polygon":
  7621. geometry2["coordinates"] = simplifyPolygon(
  7622. coordinates,
  7623. tolerance,
  7624. highQuality
  7625. );
  7626. break;
  7627. case "MultiPolygon":
  7628. geometry2["coordinates"] = coordinates.map(function(rings) {
  7629. return simplifyPolygon(rings, tolerance, highQuality);
  7630. });
  7631. }
  7632. return geometry2;
  7633. }
  7634. function simplifyLine(coordinates, tolerance, highQuality) {
  7635. return simplify(
  7636. coordinates.map(function(coord) {
  7637. return { x: coord[0], y: coord[1], z: coord[2] };
  7638. }),
  7639. tolerance,
  7640. highQuality
  7641. ).map(function(coords) {
  7642. return coords.z ? [coords.x, coords.y, coords.z] : [coords.x, coords.y];
  7643. });
  7644. }
  7645. function simplifyPolygon(coordinates, tolerance, highQuality) {
  7646. return coordinates.map(function(ring) {
  7647. var pts = ring.map(function(coord) {
  7648. return { x: coord[0], y: coord[1] };
  7649. });
  7650. if (pts.length < 4) {
  7651. throw new Error("invalid polygon");
  7652. }
  7653. var simpleRing = simplify(pts, tolerance, highQuality).map(function(coords) {
  7654. return [coords.x, coords.y];
  7655. });
  7656. while (!checkValidity(simpleRing)) {
  7657. tolerance -= tolerance * 0.01;
  7658. simpleRing = simplify(pts, tolerance, highQuality).map(function(coords) {
  7659. return [coords.x, coords.y];
  7660. });
  7661. }
  7662. if (simpleRing[simpleRing.length - 1][0] !== simpleRing[0][0] || simpleRing[simpleRing.length - 1][1] !== simpleRing[0][1]) {
  7663. simpleRing.push(simpleRing[0]);
  7664. }
  7665. return simpleRing;
  7666. });
  7667. }
  7668. function checkValidity(ring) {
  7669. if (ring.length < 3)
  7670. return false;
  7671. return !(ring.length === 3 && ring[2][0] === ring[0][0] && ring[2][1] === ring[0][1]);
  7672. }
  7673. var es_default10 = simplify$1;
  7674. // node_modules/@turf/bezier-spline/dist/es/lib/spline.js
  7675. var Spline = function() {
  7676. function Spline2(options) {
  7677. this.points = options.points || [];
  7678. this.duration = options.duration || 1e4;
  7679. this.sharpness = options.sharpness || 0.85;
  7680. this.centers = [];
  7681. this.controls = [];
  7682. this.stepLength = options.stepLength || 60;
  7683. this.length = this.points.length;
  7684. this.delay = 0;
  7685. for (var i = 0; i < this.length; i++) {
  7686. this.points[i].z = this.points[i].z || 0;
  7687. }
  7688. for (var i = 0; i < this.length - 1; i++) {
  7689. var p1 = this.points[i];
  7690. var p2 = this.points[i + 1];
  7691. this.centers.push({
  7692. x: (p1.x + p2.x) / 2,
  7693. y: (p1.y + p2.y) / 2,
  7694. z: (p1.z + p2.z) / 2
  7695. });
  7696. }
  7697. this.controls.push([this.points[0], this.points[0]]);
  7698. for (var i = 0; i < this.centers.length - 1; i++) {
  7699. var dx = this.points[i + 1].x - (this.centers[i].x + this.centers[i + 1].x) / 2;
  7700. var dy = this.points[i + 1].y - (this.centers[i].y + this.centers[i + 1].y) / 2;
  7701. var dz = this.points[i + 1].z - (this.centers[i].y + this.centers[i + 1].z) / 2;
  7702. this.controls.push([
  7703. {
  7704. x: (1 - this.sharpness) * this.points[i + 1].x + this.sharpness * (this.centers[i].x + dx),
  7705. y: (1 - this.sharpness) * this.points[i + 1].y + this.sharpness * (this.centers[i].y + dy),
  7706. z: (1 - this.sharpness) * this.points[i + 1].z + this.sharpness * (this.centers[i].z + dz)
  7707. },
  7708. {
  7709. x: (1 - this.sharpness) * this.points[i + 1].x + this.sharpness * (this.centers[i + 1].x + dx),
  7710. y: (1 - this.sharpness) * this.points[i + 1].y + this.sharpness * (this.centers[i + 1].y + dy),
  7711. z: (1 - this.sharpness) * this.points[i + 1].z + this.sharpness * (this.centers[i + 1].z + dz)
  7712. }
  7713. ]);
  7714. }
  7715. this.controls.push([
  7716. this.points[this.length - 1],
  7717. this.points[this.length - 1]
  7718. ]);
  7719. this.steps = this.cacheSteps(this.stepLength);
  7720. return this;
  7721. }
  7722. Spline2.prototype.cacheSteps = function(mindist) {
  7723. var steps = [];
  7724. var laststep = this.pos(0);
  7725. steps.push(0);
  7726. for (var t = 0; t < this.duration; t += 10) {
  7727. var step = this.pos(t);
  7728. var dist = Math.sqrt((step.x - laststep.x) * (step.x - laststep.x) + (step.y - laststep.y) * (step.y - laststep.y) + (step.z - laststep.z) * (step.z - laststep.z));
  7729. if (dist > mindist) {
  7730. steps.push(t);
  7731. laststep = step;
  7732. }
  7733. }
  7734. return steps;
  7735. };
  7736. Spline2.prototype.vector = function(t) {
  7737. var p1 = this.pos(t + 10);
  7738. var p2 = this.pos(t - 10);
  7739. return {
  7740. angle: 180 * Math.atan2(p1.y - p2.y, p1.x - p2.x) / 3.14,
  7741. speed: Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y) + (p2.z - p1.z) * (p2.z - p1.z))
  7742. };
  7743. };
  7744. Spline2.prototype.pos = function(time) {
  7745. var t = time - this.delay;
  7746. if (t < 0) {
  7747. t = 0;
  7748. }
  7749. if (t > this.duration) {
  7750. t = this.duration - 1;
  7751. }
  7752. var t2 = t / this.duration;
  7753. if (t2 >= 1) {
  7754. return this.points[this.length - 1];
  7755. }
  7756. var n = Math.floor((this.points.length - 1) * t2);
  7757. var t1 = (this.length - 1) * t2 - n;
  7758. return bezier(t1, this.points[n], this.controls[n][1], this.controls[n + 1][0], this.points[n + 1]);
  7759. };
  7760. return Spline2;
  7761. }();
  7762. var spline_default = Spline;
  7763. function bezier(t, p1, c1, c2, p2) {
  7764. var b = B(t);
  7765. var pos = {
  7766. x: p2.x * b[0] + c2.x * b[1] + c1.x * b[2] + p1.x * b[3],
  7767. y: p2.y * b[0] + c2.y * b[1] + c1.y * b[2] + p1.y * b[3],
  7768. z: p2.z * b[0] + c2.z * b[1] + c1.z * b[2] + p1.z * b[3]
  7769. };
  7770. return pos;
  7771. }
  7772. function B(t) {
  7773. var t2 = t * t;
  7774. var t3 = t2 * t;
  7775. return [
  7776. t3,
  7777. 3 * t2 * (1 - t),
  7778. 3 * t * (1 - t) * (1 - t),
  7779. (1 - t) * (1 - t) * (1 - t)
  7780. ];
  7781. }
  7782. // node_modules/@turf/bezier-spline/dist/es/index.js
  7783. function bezier2(line, options) {
  7784. if (options === void 0) {
  7785. options = {};
  7786. }
  7787. var resolution = options.resolution || 1e4;
  7788. var sharpness = options.sharpness || 0.85;
  7789. var coords = [];
  7790. var points2 = getGeom(line).coordinates.map(function(pt) {
  7791. return { x: pt[0], y: pt[1] };
  7792. });
  7793. var spline = new spline_default({
  7794. duration: resolution,
  7795. points: points2,
  7796. sharpness
  7797. });
  7798. var pushCoord = function(time) {
  7799. var pos = spline.pos(time);
  7800. if (Math.floor(time / 100) % 2 === 0) {
  7801. coords.push([pos.x, pos.y]);
  7802. }
  7803. };
  7804. for (var i = 0; i < spline.duration; i += 10) {
  7805. pushCoord(i);
  7806. }
  7807. pushCoord(spline.duration);
  7808. return lineString(coords, options.properties);
  7809. }
  7810. var es_default11 = bezier2;
  7811. // node_modules/@turf/tag/dist/es/index.js
  7812. function tag(points2, polygons2, field, outField) {
  7813. points2 = es_default5(points2);
  7814. polygons2 = es_default5(polygons2);
  7815. featureEach(points2, function(pt) {
  7816. if (!pt.properties)
  7817. pt.properties = {};
  7818. featureEach(polygons2, function(poly) {
  7819. if (pt.properties[outField] === void 0) {
  7820. if (booleanPointInPolygon(pt, poly))
  7821. pt.properties[outField] = poly.properties[field];
  7822. }
  7823. });
  7824. });
  7825. return points2;
  7826. }
  7827. var es_default12 = tag;
  7828. // node_modules/@turf/sample/dist/es/index.js
  7829. function sample(featurecollection, num) {
  7830. if (!featurecollection)
  7831. throw new Error("featurecollection is required");
  7832. if (num === null || num === void 0)
  7833. throw new Error("num is required");
  7834. if (typeof num !== "number")
  7835. throw new Error("num must be a number");
  7836. var outFC = featureCollection(
  7837. getRandomSubarray(featurecollection.features, num)
  7838. );
  7839. return outFC;
  7840. }
  7841. function getRandomSubarray(arr, size11) {
  7842. var shuffled = arr.slice(0), i = arr.length, min4 = i - size11, temp2, index2;
  7843. while (i-- > min4) {
  7844. index2 = Math.floor((i + 1) * Math.random());
  7845. temp2 = shuffled[index2];
  7846. shuffled[index2] = shuffled[i];
  7847. shuffled[i] = temp2;
  7848. }
  7849. return shuffled.slice(min4);
  7850. }
  7851. var es_default13 = sample;
  7852. // node_modules/@turf/bbox-polygon/dist/es/index.js
  7853. function bboxPolygon(bbox3, options) {
  7854. if (options === void 0) {
  7855. options = {};
  7856. }
  7857. var west = Number(bbox3[0]);
  7858. var south = Number(bbox3[1]);
  7859. var east = Number(bbox3[2]);
  7860. var north = Number(bbox3[3]);
  7861. if (bbox3.length === 6) {
  7862. throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");
  7863. }
  7864. var lowLeft = [west, south];
  7865. var topLeft = [west, north];
  7866. var topRight = [east, north];
  7867. var lowRight = [east, south];
  7868. return polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox: bbox3, id: options.id });
  7869. }
  7870. // node_modules/@turf/envelope/dist/es/index.js
  7871. function envelope(geojson) {
  7872. return bboxPolygon(es_default(geojson));
  7873. }
  7874. var es_default14 = envelope;
  7875. // node_modules/@turf/square/dist/es/index.js
  7876. function square(bbox3) {
  7877. var west = bbox3[0];
  7878. var south = bbox3[1];
  7879. var east = bbox3[2];
  7880. var north = bbox3[3];
  7881. var horizontalDistance = es_default4(bbox3.slice(0, 2), [east, south]);
  7882. var verticalDistance = es_default4(bbox3.slice(0, 2), [west, north]);
  7883. if (horizontalDistance >= verticalDistance) {
  7884. var verticalMidpoint = (south + north) / 2;
  7885. return [
  7886. west,
  7887. verticalMidpoint - (east - west) / 2,
  7888. east,
  7889. verticalMidpoint + (east - west) / 2
  7890. ];
  7891. } else {
  7892. var horizontalMidpoint = (west + east) / 2;
  7893. return [
  7894. horizontalMidpoint - (north - south) / 2,
  7895. south,
  7896. horizontalMidpoint + (north - south) / 2,
  7897. north
  7898. ];
  7899. }
  7900. }
  7901. var es_default15 = square;
  7902. // node_modules/@turf/destination/dist/es/index.js
  7903. function destination(origin, distance11, bearing2, options) {
  7904. if (options === void 0) {
  7905. options = {};
  7906. }
  7907. var coordinates1 = getCoord(origin);
  7908. var longitude1 = degreesToRadians(coordinates1[0]);
  7909. var latitude1 = degreesToRadians(coordinates1[1]);
  7910. var bearingRad = degreesToRadians(bearing2);
  7911. var radians2 = lengthToRadians(distance11, options.units);
  7912. var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians2) + Math.cos(latitude1) * Math.sin(radians2) * Math.cos(bearingRad));
  7913. var longitude2 = longitude1 + Math.atan2(Math.sin(bearingRad) * Math.sin(radians2) * Math.cos(latitude1), Math.cos(radians2) - Math.sin(latitude1) * Math.sin(latitude2));
  7914. var lng = radiansToDegrees(longitude2);
  7915. var lat2 = radiansToDegrees(latitude2);
  7916. return point([lng, lat2], options.properties);
  7917. }
  7918. // node_modules/@turf/circle/dist/es/index.js
  7919. function circle(center2, radius, options) {
  7920. if (options === void 0) {
  7921. options = {};
  7922. }
  7923. var steps = options.steps || 64;
  7924. var properties = options.properties ? options.properties : !Array.isArray(center2) && center2.type === "Feature" && center2.properties ? center2.properties : {};
  7925. var coordinates = [];
  7926. for (var i = 0; i < steps; i++) {
  7927. coordinates.push(destination(center2, radius, i * -360 / steps, options).geometry.coordinates);
  7928. }
  7929. coordinates.push(coordinates[0]);
  7930. return polygon([coordinates], properties);
  7931. }
  7932. var es_default16 = circle;
  7933. // node_modules/@turf/bearing/dist/es/index.js
  7934. function bearing(start, end, options) {
  7935. if (options === void 0) {
  7936. options = {};
  7937. }
  7938. if (options.final === true) {
  7939. return calculateFinalBearing(start, end);
  7940. }
  7941. var coordinates1 = getCoord(start);
  7942. var coordinates2 = getCoord(end);
  7943. var lon1 = degreesToRadians(coordinates1[0]);
  7944. var lon2 = degreesToRadians(coordinates2[0]);
  7945. var lat1 = degreesToRadians(coordinates1[1]);
  7946. var lat2 = degreesToRadians(coordinates2[1]);
  7947. var a = Math.sin(lon2 - lon1) * Math.cos(lat2);
  7948. var b = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
  7949. return radiansToDegrees(Math.atan2(a, b));
  7950. }
  7951. function calculateFinalBearing(start, end) {
  7952. var bear = bearing(end, start);
  7953. bear = (bear + 180) % 360;
  7954. return bear;
  7955. }
  7956. // node_modules/@turf/midpoint/dist/es/index.js
  7957. function midpoint(point1, point22) {
  7958. var dist = es_default4(point1, point22);
  7959. var heading = bearing(point1, point22);
  7960. var midpoint2 = destination(point1, dist / 2, heading);
  7961. return midpoint2;
  7962. }
  7963. var es_default17 = midpoint;
  7964. // node_modules/@turf/center/dist/es/index.js
  7965. function center(geojson, options) {
  7966. if (options === void 0) {
  7967. options = {};
  7968. }
  7969. var ext = es_default(geojson);
  7970. var x2 = (ext[0] + ext[2]) / 2;
  7971. var y2 = (ext[1] + ext[3]) / 2;
  7972. return point([x2, y2], options.properties, options);
  7973. }
  7974. var es_default18 = center;
  7975. // node_modules/@turf/centroid/dist/es/index.js
  7976. function centroid(geojson, options) {
  7977. if (options === void 0) {
  7978. options = {};
  7979. }
  7980. var xSum = 0;
  7981. var ySum = 0;
  7982. var len = 0;
  7983. coordEach(geojson, function(coord) {
  7984. xSum += coord[0];
  7985. ySum += coord[1];
  7986. len++;
  7987. }, true);
  7988. return point([xSum / len, ySum / len], options.properties);
  7989. }
  7990. var es_default19 = centroid;
  7991. // node_modules/@turf/center-of-mass/dist/es/index.js
  7992. function centerOfMass(geojson, options) {
  7993. if (options === void 0) {
  7994. options = {};
  7995. }
  7996. switch (getType(geojson)) {
  7997. case "Point":
  7998. return point(getCoord(geojson), options.properties);
  7999. case "Polygon":
  8000. var coords = [];
  8001. coordEach(geojson, function(coord) {
  8002. coords.push(coord);
  8003. });
  8004. var centre2 = es_default19(geojson, { properties: options.properties });
  8005. var translation = centre2.geometry.coordinates;
  8006. var sx = 0;
  8007. var sy = 0;
  8008. var sArea = 0;
  8009. var i, pi2, pj, xi, xj, yi, yj, a;
  8010. var neutralizedPoints = coords.map(function(point4) {
  8011. return [point4[0] - translation[0], point4[1] - translation[1]];
  8012. });
  8013. for (i = 0; i < coords.length - 1; i++) {
  8014. pi2 = neutralizedPoints[i];
  8015. xi = pi2[0];
  8016. yi = pi2[1];
  8017. pj = neutralizedPoints[i + 1];
  8018. xj = pj[0];
  8019. yj = pj[1];
  8020. a = xi * yj - xj * yi;
  8021. sArea += a;
  8022. sx += (xi + xj) * a;
  8023. sy += (yi + yj) * a;
  8024. }
  8025. if (sArea === 0) {
  8026. return centre2;
  8027. } else {
  8028. var area5 = sArea * 0.5;
  8029. var areaFactor = 1 / (6 * area5);
  8030. return point([translation[0] + areaFactor * sx, translation[1] + areaFactor * sy], options.properties);
  8031. }
  8032. default:
  8033. var hull = convex(geojson);
  8034. if (hull)
  8035. return centerOfMass(hull, { properties: options.properties });
  8036. else
  8037. return es_default19(geojson, { properties: options.properties });
  8038. }
  8039. }
  8040. var es_default20 = centerOfMass;
  8041. // node_modules/@turf/combine/dist/es/index.js
  8042. function combine(fc) {
  8043. var groups = {
  8044. MultiPoint: {
  8045. coordinates: [],
  8046. properties: []
  8047. },
  8048. MultiLineString: {
  8049. coordinates: [],
  8050. properties: []
  8051. },
  8052. MultiPolygon: {
  8053. coordinates: [],
  8054. properties: []
  8055. }
  8056. };
  8057. featureEach(fc, function(feature2) {
  8058. var _a, _b, _c;
  8059. var _d;
  8060. switch ((_d = feature2.geometry) === null || _d === void 0 ? void 0 : _d.type) {
  8061. case "Point":
  8062. groups.MultiPoint.coordinates.push(feature2.geometry.coordinates);
  8063. groups.MultiPoint.properties.push(feature2.properties);
  8064. break;
  8065. case "MultiPoint":
  8066. (_a = groups.MultiPoint.coordinates).push.apply(_a, feature2.geometry.coordinates);
  8067. groups.MultiPoint.properties.push(feature2.properties);
  8068. break;
  8069. case "LineString":
  8070. groups.MultiLineString.coordinates.push(feature2.geometry.coordinates);
  8071. groups.MultiLineString.properties.push(feature2.properties);
  8072. break;
  8073. case "MultiLineString":
  8074. (_b = groups.MultiLineString.coordinates).push.apply(_b, feature2.geometry.coordinates);
  8075. groups.MultiLineString.properties.push(feature2.properties);
  8076. break;
  8077. case "Polygon":
  8078. groups.MultiPolygon.coordinates.push(feature2.geometry.coordinates);
  8079. groups.MultiPolygon.properties.push(feature2.properties);
  8080. break;
  8081. case "MultiPolygon":
  8082. (_c = groups.MultiPolygon.coordinates).push.apply(_c, feature2.geometry.coordinates);
  8083. groups.MultiPolygon.properties.push(feature2.properties);
  8084. break;
  8085. default:
  8086. break;
  8087. }
  8088. });
  8089. return featureCollection(Object.keys(groups).filter(function(key) {
  8090. return groups[key].coordinates.length;
  8091. }).sort().map(function(key) {
  8092. var geometry2 = { type: key, coordinates: groups[key].coordinates };
  8093. var properties = { collectedProperties: groups[key].properties };
  8094. return feature(geometry2, properties);
  8095. }));
  8096. }
  8097. var es_default21 = combine;
  8098. // node_modules/@turf/explode/dist/es/index.js
  8099. function explode(geojson) {
  8100. var points2 = [];
  8101. if (geojson.type === "FeatureCollection") {
  8102. featureEach(geojson, function(feature2) {
  8103. coordEach(feature2, function(coord) {
  8104. points2.push(point(coord, feature2.properties));
  8105. });
  8106. });
  8107. } else {
  8108. coordEach(geojson, function(coord) {
  8109. points2.push(point(coord, geojson.properties));
  8110. });
  8111. }
  8112. return featureCollection(points2);
  8113. }
  8114. var es_default22 = explode;
  8115. // node_modules/@turf/tesselate/dist/es/index.js
  8116. var import_earcut = __toESM(require_earcut());
  8117. function tesselate(poly) {
  8118. if (!poly.geometry || poly.geometry.type !== "Polygon" && poly.geometry.type !== "MultiPolygon") {
  8119. throw new Error("input must be a Polygon or MultiPolygon");
  8120. }
  8121. var fc = { type: "FeatureCollection", features: [] };
  8122. if (poly.geometry.type === "Polygon") {
  8123. fc.features = processPolygon(poly.geometry.coordinates);
  8124. } else {
  8125. poly.geometry.coordinates.forEach(function(coordinates) {
  8126. fc.features = fc.features.concat(processPolygon(coordinates));
  8127. });
  8128. }
  8129. return fc;
  8130. }
  8131. function processPolygon(coordinates) {
  8132. var data = flattenCoords(coordinates);
  8133. var dim = 2;
  8134. var result = (0, import_earcut.default)(data.vertices, data.holes, dim);
  8135. var features = [];
  8136. var vertices = [];
  8137. result.forEach(function(vert, i2) {
  8138. var index2 = result[i2];
  8139. vertices.push([data.vertices[index2 * dim], data.vertices[index2 * dim + 1]]);
  8140. });
  8141. for (var i = 0; i < vertices.length; i += 3) {
  8142. var coords = vertices.slice(i, i + 3);
  8143. coords.push(vertices[i]);
  8144. features.push(polygon([coords]));
  8145. }
  8146. return features;
  8147. }
  8148. function flattenCoords(data) {
  8149. var dim = data[0][0].length, result = { vertices: [], holes: [], dimensions: dim }, holeIndex = 0;
  8150. for (var i = 0; i < data.length; i++) {
  8151. for (var j = 0; j < data[i].length; j++) {
  8152. for (var d = 0; d < dim; d++)
  8153. result.vertices.push(data[i][j][d]);
  8154. }
  8155. if (i > 0) {
  8156. holeIndex += data[i - 1].length;
  8157. result.holes.push(holeIndex);
  8158. }
  8159. }
  8160. return result;
  8161. }
  8162. var es_default23 = tesselate;
  8163. // node_modules/@turf/nearest-point/dist/es/index.js
  8164. function nearestPoint(targetPoint, points2) {
  8165. if (!targetPoint)
  8166. throw new Error("targetPoint is required");
  8167. if (!points2)
  8168. throw new Error("points is required");
  8169. var nearest;
  8170. var minDist = Infinity;
  8171. var bestFeatureIndex = 0;
  8172. featureEach(points2, function(pt, featureIndex) {
  8173. var distanceToPoint = es_default4(targetPoint, pt);
  8174. if (distanceToPoint < minDist) {
  8175. bestFeatureIndex = featureIndex;
  8176. minDist = distanceToPoint;
  8177. }
  8178. });
  8179. nearest = es_default5(points2.features[bestFeatureIndex]);
  8180. nearest.properties.featureIndex = bestFeatureIndex;
  8181. nearest.properties.distanceToPoint = minDist;
  8182. return nearest;
  8183. }
  8184. var es_default24 = nearestPoint;
  8185. // node_modules/@turf/line-segment/dist/es/index.js
  8186. function lineSegment(geojson) {
  8187. if (!geojson) {
  8188. throw new Error("geojson is required");
  8189. }
  8190. var results = [];
  8191. flattenEach(geojson, function(feature2) {
  8192. lineSegmentFeature(feature2, results);
  8193. });
  8194. return featureCollection(results);
  8195. }
  8196. function lineSegmentFeature(geojson, results) {
  8197. var coords = [];
  8198. var geometry2 = geojson.geometry;
  8199. if (geometry2 !== null) {
  8200. switch (geometry2.type) {
  8201. case "Polygon":
  8202. coords = getCoords(geometry2);
  8203. break;
  8204. case "LineString":
  8205. coords = [getCoords(geometry2)];
  8206. }
  8207. coords.forEach(function(coord) {
  8208. var segments = createSegments(coord, geojson.properties);
  8209. segments.forEach(function(segment) {
  8210. segment.id = results.length;
  8211. results.push(segment);
  8212. });
  8213. });
  8214. }
  8215. }
  8216. function createSegments(coords, properties) {
  8217. var segments = [];
  8218. coords.reduce(function(previousCoords, currentCoords) {
  8219. var segment = lineString([previousCoords, currentCoords], properties);
  8220. segment.bbox = bbox2(previousCoords, currentCoords);
  8221. segments.push(segment);
  8222. return currentCoords;
  8223. });
  8224. return segments;
  8225. }
  8226. function bbox2(coords1, coords2) {
  8227. var x12 = coords1[0];
  8228. var y12 = coords1[1];
  8229. var x2 = coords2[0];
  8230. var y2 = coords2[1];
  8231. var west = x12 < x2 ? x12 : x2;
  8232. var south = y12 < y2 ? y12 : y2;
  8233. var east = x12 > x2 ? x12 : x2;
  8234. var north = y12 > y2 ? y12 : y2;
  8235. return [west, south, east, north];
  8236. }
  8237. var es_default25 = lineSegment;
  8238. // node_modules/@turf/line-intersect/dist/es/index.js
  8239. var import_geojson_rbush = __toESM(require_geojson_rbush());
  8240. function lineIntersect(line1, line2) {
  8241. var unique = {};
  8242. var results = [];
  8243. if (line1.type === "LineString") {
  8244. line1 = feature(line1);
  8245. }
  8246. if (line2.type === "LineString") {
  8247. line2 = feature(line2);
  8248. }
  8249. if (line1.type === "Feature" && line2.type === "Feature" && line1.geometry !== null && line2.geometry !== null && line1.geometry.type === "LineString" && line2.geometry.type === "LineString" && line1.geometry.coordinates.length === 2 && line2.geometry.coordinates.length === 2) {
  8250. var intersect4 = intersects(line1, line2);
  8251. if (intersect4) {
  8252. results.push(intersect4);
  8253. }
  8254. return featureCollection(results);
  8255. }
  8256. var tree = (0, import_geojson_rbush.default)();
  8257. tree.load(es_default25(line2));
  8258. featureEach(es_default25(line1), function(segment) {
  8259. featureEach(tree.search(segment), function(match) {
  8260. var intersect5 = intersects(segment, match);
  8261. if (intersect5) {
  8262. var key = getCoords(intersect5).join(",");
  8263. if (!unique[key]) {
  8264. unique[key] = true;
  8265. results.push(intersect5);
  8266. }
  8267. }
  8268. });
  8269. });
  8270. return featureCollection(results);
  8271. }
  8272. function intersects(line1, line2) {
  8273. var coords1 = getCoords(line1);
  8274. var coords2 = getCoords(line2);
  8275. if (coords1.length !== 2) {
  8276. throw new Error("<intersects> line1 must only contain 2 coordinates");
  8277. }
  8278. if (coords2.length !== 2) {
  8279. throw new Error("<intersects> line2 must only contain 2 coordinates");
  8280. }
  8281. var x12 = coords1[0][0];
  8282. var y12 = coords1[0][1];
  8283. var x2 = coords1[1][0];
  8284. var y2 = coords1[1][1];
  8285. var x3 = coords2[0][0];
  8286. var y3 = coords2[0][1];
  8287. var x4 = coords2[1][0];
  8288. var y4 = coords2[1][1];
  8289. var denom = (y4 - y3) * (x2 - x12) - (x4 - x3) * (y2 - y12);
  8290. var numeA = (x4 - x3) * (y12 - y3) - (y4 - y3) * (x12 - x3);
  8291. var numeB = (x2 - x12) * (y12 - y3) - (y2 - y12) * (x12 - x3);
  8292. if (denom === 0) {
  8293. if (numeA === 0 && numeB === 0) {
  8294. return null;
  8295. }
  8296. return null;
  8297. }
  8298. var uA = numeA / denom;
  8299. var uB = numeB / denom;
  8300. if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) {
  8301. var x5 = x12 + uA * (x2 - x12);
  8302. var y5 = y12 + uA * (y2 - y12);
  8303. return point([x5, y5]);
  8304. }
  8305. return null;
  8306. }
  8307. var es_default26 = lineIntersect;
  8308. // node_modules/@turf/nearest-point-on-line/dist/es/index.js
  8309. function nearestPointOnLine(lines, pt, options) {
  8310. if (options === void 0) {
  8311. options = {};
  8312. }
  8313. var closestPt = point([Infinity, Infinity], {
  8314. dist: Infinity
  8315. });
  8316. var length4 = 0;
  8317. flattenEach(lines, function(line) {
  8318. var coords = getCoords(line);
  8319. for (var i = 0; i < coords.length - 1; i++) {
  8320. var start = point(coords[i]);
  8321. start.properties.dist = es_default4(pt, start, options);
  8322. var stop_1 = point(coords[i + 1]);
  8323. stop_1.properties.dist = es_default4(pt, stop_1, options);
  8324. var sectionLength = es_default4(start, stop_1, options);
  8325. var heightDistance = Math.max(start.properties.dist, stop_1.properties.dist);
  8326. var direction = bearing(start, stop_1);
  8327. var perpendicularPt1 = destination(pt, heightDistance, direction + 90, options);
  8328. var perpendicularPt2 = destination(pt, heightDistance, direction - 90, options);
  8329. var intersect4 = es_default26(lineString([
  8330. perpendicularPt1.geometry.coordinates,
  8331. perpendicularPt2.geometry.coordinates
  8332. ]), lineString([start.geometry.coordinates, stop_1.geometry.coordinates]));
  8333. var intersectPt = null;
  8334. if (intersect4.features.length > 0) {
  8335. intersectPt = intersect4.features[0];
  8336. intersectPt.properties.dist = es_default4(pt, intersectPt, options);
  8337. intersectPt.properties.location = length4 + es_default4(start, intersectPt, options);
  8338. }
  8339. if (start.properties.dist < closestPt.properties.dist) {
  8340. closestPt = start;
  8341. closestPt.properties.index = i;
  8342. closestPt.properties.location = length4;
  8343. }
  8344. if (stop_1.properties.dist < closestPt.properties.dist) {
  8345. closestPt = stop_1;
  8346. closestPt.properties.index = i + 1;
  8347. closestPt.properties.location = length4 + sectionLength;
  8348. }
  8349. if (intersectPt && intersectPt.properties.dist < closestPt.properties.dist) {
  8350. closestPt = intersectPt;
  8351. closestPt.properties.index = i;
  8352. }
  8353. length4 += sectionLength;
  8354. }
  8355. });
  8356. return closestPt;
  8357. }
  8358. var es_default27 = nearestPointOnLine;
  8359. // node_modules/@turf/rhumb-distance/dist/es/index.js
  8360. function rhumbDistance(from, to, options) {
  8361. if (options === void 0) {
  8362. options = {};
  8363. }
  8364. var origin = getCoord(from);
  8365. var destination2 = getCoord(to);
  8366. destination2[0] += destination2[0] - origin[0] > 180 ? -360 : origin[0] - destination2[0] > 180 ? 360 : 0;
  8367. var distanceInMeters = calculateRhumbDistance(origin, destination2);
  8368. var distance11 = convertLength(distanceInMeters, "meters", options.units);
  8369. return distance11;
  8370. }
  8371. function calculateRhumbDistance(origin, destination2, radius) {
  8372. radius = radius === void 0 ? earthRadius : Number(radius);
  8373. var R = radius;
  8374. var phi1 = origin[1] * Math.PI / 180;
  8375. var phi2 = destination2[1] * Math.PI / 180;
  8376. var DeltaPhi = phi2 - phi1;
  8377. var DeltaLambda = Math.abs(destination2[0] - origin[0]) * Math.PI / 180;
  8378. if (DeltaLambda > Math.PI) {
  8379. DeltaLambda -= 2 * Math.PI;
  8380. }
  8381. var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
  8382. var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
  8383. var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
  8384. var dist = delta * R;
  8385. return dist;
  8386. }
  8387. var es_default28 = rhumbDistance;
  8388. // node_modules/@turf/point-to-line-distance/dist/es/index.js
  8389. function pointToLineDistance(pt, line, options) {
  8390. if (options === void 0) {
  8391. options = {};
  8392. }
  8393. if (!options.method) {
  8394. options.method = "geodesic";
  8395. }
  8396. if (!options.units) {
  8397. options.units = "kilometers";
  8398. }
  8399. if (!pt) {
  8400. throw new Error("pt is required");
  8401. }
  8402. if (Array.isArray(pt)) {
  8403. pt = point(pt);
  8404. } else if (pt.type === "Point") {
  8405. pt = feature(pt);
  8406. } else {
  8407. featureOf(pt, "Point", "point");
  8408. }
  8409. if (!line) {
  8410. throw new Error("line is required");
  8411. }
  8412. if (Array.isArray(line)) {
  8413. line = lineString(line);
  8414. } else if (line.type === "LineString") {
  8415. line = feature(line);
  8416. } else {
  8417. featureOf(line, "LineString", "line");
  8418. }
  8419. var distance11 = Infinity;
  8420. var p = pt.geometry.coordinates;
  8421. segmentEach(line, function(segment) {
  8422. var a = segment.geometry.coordinates[0];
  8423. var b = segment.geometry.coordinates[1];
  8424. var d = distanceToSegment(p, a, b, options);
  8425. if (d < distance11) {
  8426. distance11 = d;
  8427. }
  8428. });
  8429. return convertLength(distance11, "degrees", options.units);
  8430. }
  8431. function distanceToSegment(p, a, b, options) {
  8432. var v = [b[0] - a[0], b[1] - a[1]];
  8433. var w = [p[0] - a[0], p[1] - a[1]];
  8434. var c1 = dot(w, v);
  8435. if (c1 <= 0) {
  8436. return calcDistance(p, a, { method: options.method, units: "degrees" });
  8437. }
  8438. var c2 = dot(v, v);
  8439. if (c2 <= c1) {
  8440. return calcDistance(p, b, { method: options.method, units: "degrees" });
  8441. }
  8442. var b2 = c1 / c2;
  8443. var Pb = [a[0] + b2 * v[0], a[1] + b2 * v[1]];
  8444. return calcDistance(p, Pb, { method: options.method, units: "degrees" });
  8445. }
  8446. function dot(u, v) {
  8447. return u[0] * v[0] + u[1] * v[1];
  8448. }
  8449. function calcDistance(a, b, options) {
  8450. return options.method === "planar" ? es_default28(a, b, options) : es_default4(a, b, options);
  8451. }
  8452. var es_default29 = pointToLineDistance;
  8453. // node_modules/@turf/nearest-point-to-line/dist/es/index.js
  8454. var import_object_assign2 = __toESM(require_object_assign());
  8455. function nearestPointToLine(points2, line, options) {
  8456. if (options === void 0) {
  8457. options = {};
  8458. }
  8459. var units = options.units;
  8460. var properties = options.properties || {};
  8461. var pts = normalize(points2);
  8462. if (!pts.features.length) {
  8463. throw new Error("points must contain features");
  8464. }
  8465. if (!line) {
  8466. throw new Error("line is required");
  8467. }
  8468. if (getType(line) !== "LineString") {
  8469. throw new Error("line must be a LineString");
  8470. }
  8471. var dist = Infinity;
  8472. var pt = null;
  8473. featureEach(pts, function(point4) {
  8474. var d = es_default29(point4, line, { units });
  8475. if (d < dist) {
  8476. dist = d;
  8477. pt = point4;
  8478. }
  8479. });
  8480. if (pt) {
  8481. pt.properties = (0, import_object_assign2.default)({ dist }, pt.properties, properties);
  8482. }
  8483. return pt;
  8484. }
  8485. function normalize(points2) {
  8486. var features = [];
  8487. var type = points2.geometry ? points2.geometry.type : points2.type;
  8488. switch (type) {
  8489. case "GeometryCollection":
  8490. geomEach(points2, function(geom) {
  8491. if (geom.type === "Point") {
  8492. features.push({ type: "Feature", properties: {}, geometry: geom });
  8493. }
  8494. });
  8495. return { type: "FeatureCollection", features };
  8496. case "FeatureCollection":
  8497. points2.features = points2.features.filter(function(feature2) {
  8498. return feature2.geometry.type === "Point";
  8499. });
  8500. return points2;
  8501. default:
  8502. throw new Error("points must be a Point Collection");
  8503. }
  8504. }
  8505. var es_default30 = nearestPointToLine;
  8506. // node_modules/@turf/planepoint/dist/es/index.js
  8507. function planepoint(point4, triangle) {
  8508. var coord = getCoord(point4);
  8509. var geom = getGeom(triangle);
  8510. var coords = geom.coordinates;
  8511. var outer = coords[0];
  8512. if (outer.length < 4)
  8513. throw new Error("OuterRing of a Polygon must have 4 or more Positions.");
  8514. var properties = triangle.properties || {};
  8515. var a = properties.a;
  8516. var b = properties.b;
  8517. var c = properties.c;
  8518. var x2 = coord[0];
  8519. var y2 = coord[1];
  8520. var x12 = outer[0][0];
  8521. var y12 = outer[0][1];
  8522. var z1 = a !== void 0 ? a : outer[0][2];
  8523. var x22 = outer[1][0];
  8524. var y22 = outer[1][1];
  8525. var z2 = b !== void 0 ? b : outer[1][2];
  8526. var x3 = outer[2][0];
  8527. var y3 = outer[2][1];
  8528. var z3 = c !== void 0 ? c : outer[2][2];
  8529. var z = (z3 * (x2 - x12) * (y2 - y22) + z1 * (x2 - x22) * (y2 - y3) + z2 * (x2 - x3) * (y2 - y12) - z2 * (x2 - x12) * (y2 - y3) - z3 * (x2 - x22) * (y2 - y12) - z1 * (x2 - x3) * (y2 - y22)) / ((x2 - x12) * (y2 - y22) + (x2 - x22) * (y2 - y3) + (x2 - x3) * (y2 - y12) - (x2 - x12) * (y2 - y3) - (x2 - x22) * (y2 - y12) - (x2 - x3) * (y2 - y22));
  8530. return z;
  8531. }
  8532. var es_default31 = planepoint;
  8533. // node_modules/@turf/kinks/dist/es/index.js
  8534. function kinks(featureIn) {
  8535. var coordinates;
  8536. var feature2;
  8537. var results = {
  8538. type: "FeatureCollection",
  8539. features: []
  8540. };
  8541. if (featureIn.type === "Feature") {
  8542. feature2 = featureIn.geometry;
  8543. } else {
  8544. feature2 = featureIn;
  8545. }
  8546. if (feature2.type === "LineString") {
  8547. coordinates = [feature2.coordinates];
  8548. } else if (feature2.type === "MultiLineString") {
  8549. coordinates = feature2.coordinates;
  8550. } else if (feature2.type === "MultiPolygon") {
  8551. coordinates = [].concat.apply([], feature2.coordinates);
  8552. } else if (feature2.type === "Polygon") {
  8553. coordinates = feature2.coordinates;
  8554. } else {
  8555. throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");
  8556. }
  8557. coordinates.forEach(function(line1) {
  8558. coordinates.forEach(function(line2) {
  8559. for (var i = 0; i < line1.length - 1; i++) {
  8560. for (var k = i; k < line2.length - 1; k++) {
  8561. if (line1 === line2) {
  8562. if (Math.abs(i - k) === 1) {
  8563. continue;
  8564. }
  8565. if (i === 0 && k === line1.length - 2 && line1[i][0] === line1[line1.length - 1][0] && line1[i][1] === line1[line1.length - 1][1]) {
  8566. continue;
  8567. }
  8568. }
  8569. var intersection12 = lineIntersects(line1[i][0], line1[i][1], line1[i + 1][0], line1[i + 1][1], line2[k][0], line2[k][1], line2[k + 1][0], line2[k + 1][1]);
  8570. if (intersection12) {
  8571. results.features.push(point([intersection12[0], intersection12[1]]));
  8572. }
  8573. }
  8574. }
  8575. });
  8576. });
  8577. return results;
  8578. }
  8579. function lineIntersects(line1StartX, line1StartY, line1EndX, line1EndY, line2StartX, line2StartY, line2EndX, line2EndY) {
  8580. var denominator;
  8581. var a;
  8582. var b;
  8583. var numerator1;
  8584. var numerator2;
  8585. var result = {
  8586. x: null,
  8587. y: null,
  8588. onLine1: false,
  8589. onLine2: false
  8590. };
  8591. denominator = (line2EndY - line2StartY) * (line1EndX - line1StartX) - (line2EndX - line2StartX) * (line1EndY - line1StartY);
  8592. if (denominator === 0) {
  8593. if (result.x !== null && result.y !== null) {
  8594. return result;
  8595. } else {
  8596. return false;
  8597. }
  8598. }
  8599. a = line1StartY - line2StartY;
  8600. b = line1StartX - line2StartX;
  8601. numerator1 = (line2EndX - line2StartX) * a - (line2EndY - line2StartY) * b;
  8602. numerator2 = (line1EndX - line1StartX) * a - (line1EndY - line1StartY) * b;
  8603. a = numerator1 / denominator;
  8604. b = numerator2 / denominator;
  8605. result.x = line1StartX + a * (line1EndX - line1StartX);
  8606. result.y = line1StartY + a * (line1EndY - line1StartY);
  8607. if (a >= 0 && a <= 1) {
  8608. result.onLine1 = true;
  8609. }
  8610. if (b >= 0 && b <= 1) {
  8611. result.onLine2 = true;
  8612. }
  8613. if (result.onLine1 && result.onLine2) {
  8614. return [result.x, result.y];
  8615. } else {
  8616. return false;
  8617. }
  8618. }
  8619. // node_modules/@turf/point-on-feature/dist/es/index.js
  8620. function pointOnFeature(geojson) {
  8621. var fc = normalize2(geojson);
  8622. var cent = es_default18(fc);
  8623. var onSurface = false;
  8624. var i = 0;
  8625. while (!onSurface && i < fc.features.length) {
  8626. var geom = fc.features[i].geometry;
  8627. var x2, y2, x12, y12, x22, y22, k;
  8628. var onLine = false;
  8629. if (geom.type === "Point") {
  8630. if (cent.geometry.coordinates[0] === geom.coordinates[0] && cent.geometry.coordinates[1] === geom.coordinates[1]) {
  8631. onSurface = true;
  8632. }
  8633. } else if (geom.type === "MultiPoint") {
  8634. var onMultiPoint = false;
  8635. k = 0;
  8636. while (!onMultiPoint && k < geom.coordinates.length) {
  8637. if (cent.geometry.coordinates[0] === geom.coordinates[k][0] && cent.geometry.coordinates[1] === geom.coordinates[k][1]) {
  8638. onSurface = true;
  8639. onMultiPoint = true;
  8640. }
  8641. k++;
  8642. }
  8643. } else if (geom.type === "LineString") {
  8644. k = 0;
  8645. while (!onLine && k < geom.coordinates.length - 1) {
  8646. x2 = cent.geometry.coordinates[0];
  8647. y2 = cent.geometry.coordinates[1];
  8648. x12 = geom.coordinates[k][0];
  8649. y12 = geom.coordinates[k][1];
  8650. x22 = geom.coordinates[k + 1][0];
  8651. y22 = geom.coordinates[k + 1][1];
  8652. if (pointOnSegment(x2, y2, x12, y12, x22, y22)) {
  8653. onLine = true;
  8654. onSurface = true;
  8655. }
  8656. k++;
  8657. }
  8658. } else if (geom.type === "MultiLineString") {
  8659. var j = 0;
  8660. while (j < geom.coordinates.length) {
  8661. onLine = false;
  8662. k = 0;
  8663. var line = geom.coordinates[j];
  8664. while (!onLine && k < line.length - 1) {
  8665. x2 = cent.geometry.coordinates[0];
  8666. y2 = cent.geometry.coordinates[1];
  8667. x12 = line[k][0];
  8668. y12 = line[k][1];
  8669. x22 = line[k + 1][0];
  8670. y22 = line[k + 1][1];
  8671. if (pointOnSegment(x2, y2, x12, y12, x22, y22)) {
  8672. onLine = true;
  8673. onSurface = true;
  8674. }
  8675. k++;
  8676. }
  8677. j++;
  8678. }
  8679. } else if (geom.type === "Polygon" || geom.type === "MultiPolygon") {
  8680. if (booleanPointInPolygon(cent, geom)) {
  8681. onSurface = true;
  8682. }
  8683. }
  8684. i++;
  8685. }
  8686. if (onSurface) {
  8687. return cent;
  8688. } else {
  8689. var vertices = featureCollection([]);
  8690. for (i = 0; i < fc.features.length; i++) {
  8691. vertices.features = vertices.features.concat(
  8692. es_default22(fc.features[i]).features
  8693. );
  8694. }
  8695. return point(es_default24(cent, vertices).geometry.coordinates);
  8696. }
  8697. }
  8698. function normalize2(geojson) {
  8699. if (geojson.type !== "FeatureCollection") {
  8700. if (geojson.type !== "Feature") {
  8701. return featureCollection([feature(geojson)]);
  8702. }
  8703. return featureCollection([geojson]);
  8704. }
  8705. return geojson;
  8706. }
  8707. function pointOnSegment(x2, y2, x12, y12, x22, y22) {
  8708. var ab2 = Math.sqrt((x22 - x12) * (x22 - x12) + (y22 - y12) * (y22 - y12));
  8709. var ap = Math.sqrt((x2 - x12) * (x2 - x12) + (y2 - y12) * (y2 - y12));
  8710. var pb = Math.sqrt((x22 - x2) * (x22 - x2) + (y22 - y2) * (y22 - y2));
  8711. return ab2 === ap + pb;
  8712. }
  8713. var es_default32 = pointOnFeature;
  8714. // node_modules/@turf/area/dist/es/index.js
  8715. var RADIUS = 6378137;
  8716. function area(geojson) {
  8717. return geomReduce(geojson, function(value, geom) {
  8718. return value + calculateArea(geom);
  8719. }, 0);
  8720. }
  8721. function calculateArea(geom) {
  8722. var total = 0;
  8723. var i;
  8724. switch (geom.type) {
  8725. case "Polygon":
  8726. return polygonArea(geom.coordinates);
  8727. case "MultiPolygon":
  8728. for (i = 0; i < geom.coordinates.length; i++) {
  8729. total += polygonArea(geom.coordinates[i]);
  8730. }
  8731. return total;
  8732. case "Point":
  8733. case "MultiPoint":
  8734. case "LineString":
  8735. case "MultiLineString":
  8736. return 0;
  8737. }
  8738. return 0;
  8739. }
  8740. function polygonArea(coords) {
  8741. var total = 0;
  8742. if (coords && coords.length > 0) {
  8743. total += Math.abs(ringArea(coords[0]));
  8744. for (var i = 1; i < coords.length; i++) {
  8745. total -= Math.abs(ringArea(coords[i]));
  8746. }
  8747. }
  8748. return total;
  8749. }
  8750. function ringArea(coords) {
  8751. var p1;
  8752. var p2;
  8753. var p3;
  8754. var lowerIndex;
  8755. var middleIndex;
  8756. var upperIndex;
  8757. var i;
  8758. var total = 0;
  8759. var coordsLength = coords.length;
  8760. if (coordsLength > 2) {
  8761. for (i = 0; i < coordsLength; i++) {
  8762. if (i === coordsLength - 2) {
  8763. lowerIndex = coordsLength - 2;
  8764. middleIndex = coordsLength - 1;
  8765. upperIndex = 0;
  8766. } else if (i === coordsLength - 1) {
  8767. lowerIndex = coordsLength - 1;
  8768. middleIndex = 0;
  8769. upperIndex = 1;
  8770. } else {
  8771. lowerIndex = i;
  8772. middleIndex = i + 1;
  8773. upperIndex = i + 2;
  8774. }
  8775. p1 = coords[lowerIndex];
  8776. p2 = coords[middleIndex];
  8777. p3 = coords[upperIndex];
  8778. total += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
  8779. }
  8780. total = total * RADIUS * RADIUS / 2;
  8781. }
  8782. return total;
  8783. }
  8784. function rad(num) {
  8785. return num * Math.PI / 180;
  8786. }
  8787. // node_modules/@turf/along/dist/es/index.js
  8788. function along(line, distance11, options) {
  8789. if (options === void 0) {
  8790. options = {};
  8791. }
  8792. var geom = getGeom(line);
  8793. var coords = geom.coordinates;
  8794. var travelled = 0;
  8795. for (var i = 0; i < coords.length; i++) {
  8796. if (distance11 >= travelled && i === coords.length - 1) {
  8797. break;
  8798. } else if (travelled >= distance11) {
  8799. var overshot = distance11 - travelled;
  8800. if (!overshot) {
  8801. return point(coords[i]);
  8802. } else {
  8803. var direction = bearing(coords[i], coords[i - 1]) - 180;
  8804. var interpolated = destination(coords[i], overshot, direction, options);
  8805. return interpolated;
  8806. }
  8807. } else {
  8808. travelled += es_default4(coords[i], coords[i + 1], options);
  8809. }
  8810. }
  8811. return point(coords[coords.length - 1]);
  8812. }
  8813. // node_modules/@turf/length/dist/es/index.js
  8814. function length(geojson, options) {
  8815. if (options === void 0) {
  8816. options = {};
  8817. }
  8818. return segmentReduce(geojson, function(previousValue, segment) {
  8819. var coords = segment.geometry.coordinates;
  8820. return previousValue + es_default4(coords[0], coords[1], options);
  8821. }, 0);
  8822. }
  8823. // node_modules/@turf/line-slice/dist/es/index.js
  8824. function lineSlice(startPt, stopPt, line) {
  8825. var coords = getCoords(line);
  8826. if (getType(line) !== "LineString")
  8827. throw new Error("line must be a LineString");
  8828. var startVertex = es_default27(line, startPt);
  8829. var stopVertex = es_default27(line, stopPt);
  8830. var ends;
  8831. if (startVertex.properties.index <= stopVertex.properties.index) {
  8832. ends = [startVertex, stopVertex];
  8833. } else {
  8834. ends = [stopVertex, startVertex];
  8835. }
  8836. var clipCoords = [ends[0].geometry.coordinates];
  8837. for (var i = ends[0].properties.index + 1; i < ends[1].properties.index + 1; i++) {
  8838. clipCoords.push(coords[i]);
  8839. }
  8840. clipCoords.push(ends[1].geometry.coordinates);
  8841. return lineString(clipCoords, line.properties);
  8842. }
  8843. var es_default33 = lineSlice;
  8844. // node_modules/@turf/line-slice-along/dist/es/index.js
  8845. function lineSliceAlong(line, startDist, stopDist, options) {
  8846. options = options || {};
  8847. if (!isObject(options))
  8848. throw new Error("options is invalid");
  8849. var coords;
  8850. var slice2 = [];
  8851. if (line.type === "Feature")
  8852. coords = line.geometry.coordinates;
  8853. else if (line.type === "LineString")
  8854. coords = line.coordinates;
  8855. else
  8856. throw new Error("input must be a LineString Feature or Geometry");
  8857. var origCoordsLength = coords.length;
  8858. var travelled = 0;
  8859. var overshot, direction, interpolated;
  8860. for (var i = 0; i < coords.length; i++) {
  8861. if (startDist >= travelled && i === coords.length - 1)
  8862. break;
  8863. else if (travelled > startDist && slice2.length === 0) {
  8864. overshot = startDist - travelled;
  8865. if (!overshot) {
  8866. slice2.push(coords[i]);
  8867. return lineString(slice2);
  8868. }
  8869. direction = bearing(coords[i], coords[i - 1]) - 180;
  8870. interpolated = destination(coords[i], overshot, direction, options);
  8871. slice2.push(interpolated.geometry.coordinates);
  8872. }
  8873. if (travelled >= stopDist) {
  8874. overshot = stopDist - travelled;
  8875. if (!overshot) {
  8876. slice2.push(coords[i]);
  8877. return lineString(slice2);
  8878. }
  8879. direction = bearing(coords[i], coords[i - 1]) - 180;
  8880. interpolated = destination(coords[i], overshot, direction, options);
  8881. slice2.push(interpolated.geometry.coordinates);
  8882. return lineString(slice2);
  8883. }
  8884. if (travelled >= startDist) {
  8885. slice2.push(coords[i]);
  8886. }
  8887. if (i === coords.length - 1) {
  8888. return lineString(slice2);
  8889. }
  8890. travelled += es_default4(coords[i], coords[i + 1], options);
  8891. }
  8892. if (travelled < startDist && coords.length === origCoordsLength)
  8893. throw new Error("Start position is beyond line");
  8894. var last = coords[coords.length - 1];
  8895. return lineString([last, last]);
  8896. }
  8897. var es_default34 = lineSliceAlong;
  8898. // node_modules/@turf/boolean-point-on-line/dist/es/index.js
  8899. function booleanPointOnLine(pt, line, options) {
  8900. if (options === void 0) {
  8901. options = {};
  8902. }
  8903. var ptCoords = getCoord(pt);
  8904. var lineCoords = getCoords(line);
  8905. for (var i = 0; i < lineCoords.length - 1; i++) {
  8906. var ignoreBoundary = false;
  8907. if (options.ignoreEndVertices) {
  8908. if (i === 0) {
  8909. ignoreBoundary = "start";
  8910. }
  8911. if (i === lineCoords.length - 2) {
  8912. ignoreBoundary = "end";
  8913. }
  8914. if (i === 0 && i + 1 === lineCoords.length - 1) {
  8915. ignoreBoundary = "both";
  8916. }
  8917. }
  8918. if (isPointOnLineSegment2(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary, typeof options.epsilon === "undefined" ? null : options.epsilon)) {
  8919. return true;
  8920. }
  8921. }
  8922. return false;
  8923. }
  8924. function isPointOnLineSegment2(lineSegmentStart, lineSegmentEnd, pt, excludeBoundary, epsilon5) {
  8925. var x2 = pt[0];
  8926. var y2 = pt[1];
  8927. var x12 = lineSegmentStart[0];
  8928. var y12 = lineSegmentStart[1];
  8929. var x22 = lineSegmentEnd[0];
  8930. var y22 = lineSegmentEnd[1];
  8931. var dxc = pt[0] - x12;
  8932. var dyc = pt[1] - y12;
  8933. var dxl = x22 - x12;
  8934. var dyl = y22 - y12;
  8935. var cross = dxc * dyl - dyc * dxl;
  8936. if (epsilon5 !== null) {
  8937. if (Math.abs(cross) > epsilon5) {
  8938. return false;
  8939. }
  8940. } else if (cross !== 0) {
  8941. return false;
  8942. }
  8943. if (!excludeBoundary) {
  8944. if (Math.abs(dxl) >= Math.abs(dyl)) {
  8945. return dxl > 0 ? x12 <= x2 && x2 <= x22 : x22 <= x2 && x2 <= x12;
  8946. }
  8947. return dyl > 0 ? y12 <= y2 && y2 <= y22 : y22 <= y2 && y2 <= y12;
  8948. } else if (excludeBoundary === "start") {
  8949. if (Math.abs(dxl) >= Math.abs(dyl)) {
  8950. return dxl > 0 ? x12 < x2 && x2 <= x22 : x22 <= x2 && x2 < x12;
  8951. }
  8952. return dyl > 0 ? y12 < y2 && y2 <= y22 : y22 <= y2 && y2 < y12;
  8953. } else if (excludeBoundary === "end") {
  8954. if (Math.abs(dxl) >= Math.abs(dyl)) {
  8955. return dxl > 0 ? x12 <= x2 && x2 < x22 : x22 < x2 && x2 <= x12;
  8956. }
  8957. return dyl > 0 ? y12 <= y2 && y2 < y22 : y22 < y2 && y2 <= y12;
  8958. } else if (excludeBoundary === "both") {
  8959. if (Math.abs(dxl) >= Math.abs(dyl)) {
  8960. return dxl > 0 ? x12 < x2 && x2 < x22 : x22 < x2 && x2 < x12;
  8961. }
  8962. return dyl > 0 ? y12 < y2 && y2 < y22 : y22 < y2 && y2 < y12;
  8963. }
  8964. return false;
  8965. }
  8966. var es_default35 = booleanPointOnLine;
  8967. // node_modules/@turf/boolean-within/dist/es/index.js
  8968. function booleanWithin(feature1, feature2) {
  8969. var geom1 = getGeom(feature1);
  8970. var geom2 = getGeom(feature2);
  8971. var type1 = geom1.type;
  8972. var type2 = geom2.type;
  8973. switch (type1) {
  8974. case "Point":
  8975. switch (type2) {
  8976. case "MultiPoint":
  8977. return isPointInMultiPoint(geom1, geom2);
  8978. case "LineString":
  8979. return es_default35(geom1, geom2, { ignoreEndVertices: true });
  8980. case "Polygon":
  8981. case "MultiPolygon":
  8982. return booleanPointInPolygon(geom1, geom2, { ignoreBoundary: true });
  8983. default:
  8984. throw new Error("feature2 " + type2 + " geometry not supported");
  8985. }
  8986. case "MultiPoint":
  8987. switch (type2) {
  8988. case "MultiPoint":
  8989. return isMultiPointInMultiPoint(geom1, geom2);
  8990. case "LineString":
  8991. return isMultiPointOnLine(geom1, geom2);
  8992. case "Polygon":
  8993. case "MultiPolygon":
  8994. return isMultiPointInPoly(geom1, geom2);
  8995. default:
  8996. throw new Error("feature2 " + type2 + " geometry not supported");
  8997. }
  8998. case "LineString":
  8999. switch (type2) {
  9000. case "LineString":
  9001. return isLineOnLine(geom1, geom2);
  9002. case "Polygon":
  9003. case "MultiPolygon":
  9004. return isLineInPoly(geom1, geom2);
  9005. default:
  9006. throw new Error("feature2 " + type2 + " geometry not supported");
  9007. }
  9008. case "Polygon":
  9009. switch (type2) {
  9010. case "Polygon":
  9011. case "MultiPolygon":
  9012. return isPolyInPoly(geom1, geom2);
  9013. default:
  9014. throw new Error("feature2 " + type2 + " geometry not supported");
  9015. }
  9016. default:
  9017. throw new Error("feature1 " + type1 + " geometry not supported");
  9018. }
  9019. }
  9020. function isPointInMultiPoint(point4, multiPoint2) {
  9021. var i;
  9022. var output = false;
  9023. for (i = 0; i < multiPoint2.coordinates.length; i++) {
  9024. if (compareCoords(multiPoint2.coordinates[i], point4.coordinates)) {
  9025. output = true;
  9026. break;
  9027. }
  9028. }
  9029. return output;
  9030. }
  9031. function isMultiPointInMultiPoint(multiPoint1, multiPoint2) {
  9032. for (var i = 0; i < multiPoint1.coordinates.length; i++) {
  9033. var anyMatch = false;
  9034. for (var i2 = 0; i2 < multiPoint2.coordinates.length; i2++) {
  9035. if (compareCoords(multiPoint1.coordinates[i], multiPoint2.coordinates[i2])) {
  9036. anyMatch = true;
  9037. }
  9038. }
  9039. if (!anyMatch) {
  9040. return false;
  9041. }
  9042. }
  9043. return true;
  9044. }
  9045. function isMultiPointOnLine(multiPoint2, lineString2) {
  9046. var foundInsidePoint = false;
  9047. for (var i = 0; i < multiPoint2.coordinates.length; i++) {
  9048. if (!es_default35(multiPoint2.coordinates[i], lineString2)) {
  9049. return false;
  9050. }
  9051. if (!foundInsidePoint) {
  9052. foundInsidePoint = es_default35(multiPoint2.coordinates[i], lineString2, { ignoreEndVertices: true });
  9053. }
  9054. }
  9055. return foundInsidePoint;
  9056. }
  9057. function isMultiPointInPoly(multiPoint2, polygon4) {
  9058. var output = true;
  9059. var oneInside = false;
  9060. var isInside3 = false;
  9061. for (var i = 0; i < multiPoint2.coordinates.length; i++) {
  9062. isInside3 = booleanPointInPolygon(multiPoint2.coordinates[1], polygon4);
  9063. if (!isInside3) {
  9064. output = false;
  9065. break;
  9066. }
  9067. if (!oneInside) {
  9068. isInside3 = booleanPointInPolygon(multiPoint2.coordinates[1], polygon4, {
  9069. ignoreBoundary: true
  9070. });
  9071. }
  9072. }
  9073. return output && isInside3;
  9074. }
  9075. function isLineOnLine(lineString1, lineString2) {
  9076. for (var i = 0; i < lineString1.coordinates.length; i++) {
  9077. if (!es_default35(lineString1.coordinates[i], lineString2)) {
  9078. return false;
  9079. }
  9080. }
  9081. return true;
  9082. }
  9083. function isLineInPoly(linestring3, polygon4) {
  9084. var polyBbox = es_default(polygon4);
  9085. var lineBbox = es_default(linestring3);
  9086. if (!doBBoxOverlap(polyBbox, lineBbox)) {
  9087. return false;
  9088. }
  9089. var foundInsidePoint = false;
  9090. for (var i = 0; i < linestring3.coordinates.length - 1; i++) {
  9091. if (!booleanPointInPolygon(linestring3.coordinates[i], polygon4)) {
  9092. return false;
  9093. }
  9094. if (!foundInsidePoint) {
  9095. foundInsidePoint = booleanPointInPolygon(linestring3.coordinates[i], polygon4, { ignoreBoundary: true });
  9096. }
  9097. if (!foundInsidePoint) {
  9098. var midpoint2 = getMidpoint(linestring3.coordinates[i], linestring3.coordinates[i + 1]);
  9099. foundInsidePoint = booleanPointInPolygon(midpoint2, polygon4, {
  9100. ignoreBoundary: true
  9101. });
  9102. }
  9103. }
  9104. return foundInsidePoint;
  9105. }
  9106. function isPolyInPoly(geometry1, geometry2) {
  9107. var poly1Bbox = es_default(geometry1);
  9108. var poly2Bbox = es_default(geometry2);
  9109. if (!doBBoxOverlap(poly2Bbox, poly1Bbox)) {
  9110. return false;
  9111. }
  9112. for (var i = 0; i < geometry1.coordinates[0].length; i++) {
  9113. if (!booleanPointInPolygon(geometry1.coordinates[0][i], geometry2)) {
  9114. return false;
  9115. }
  9116. }
  9117. return true;
  9118. }
  9119. function doBBoxOverlap(bbox1, bbox22) {
  9120. if (bbox1[0] > bbox22[0])
  9121. return false;
  9122. if (bbox1[2] < bbox22[2])
  9123. return false;
  9124. if (bbox1[1] > bbox22[1])
  9125. return false;
  9126. if (bbox1[3] < bbox22[3])
  9127. return false;
  9128. return true;
  9129. }
  9130. function compareCoords(pair1, pair2) {
  9131. return pair1[0] === pair2[0] && pair1[1] === pair2[1];
  9132. }
  9133. function getMidpoint(pair1, pair2) {
  9134. return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];
  9135. }
  9136. var es_default36 = booleanWithin;
  9137. // node_modules/@turf/point-grid/dist/es/index.js
  9138. function pointGrid(bbox3, cellSide, options) {
  9139. if (options === void 0) {
  9140. options = {};
  9141. }
  9142. if (options.mask && !options.units)
  9143. options.units = "kilometers";
  9144. var results = [];
  9145. var west = bbox3[0];
  9146. var south = bbox3[1];
  9147. var east = bbox3[2];
  9148. var north = bbox3[3];
  9149. var xFraction = cellSide / es_default4([west, south], [east, south], options);
  9150. var cellWidth = xFraction * (east - west);
  9151. var yFraction = cellSide / es_default4([west, south], [west, north], options);
  9152. var cellHeight = yFraction * (north - south);
  9153. var bboxWidth = east - west;
  9154. var bboxHeight = north - south;
  9155. var columns = Math.floor(bboxWidth / cellWidth);
  9156. var rows = Math.floor(bboxHeight / cellHeight);
  9157. var deltaX = (bboxWidth - columns * cellWidth) / 2;
  9158. var deltaY = (bboxHeight - rows * cellHeight) / 2;
  9159. var currentX = west + deltaX;
  9160. while (currentX <= east) {
  9161. var currentY = south + deltaY;
  9162. while (currentY <= north) {
  9163. var cellPt = point([currentX, currentY], options.properties);
  9164. if (options.mask) {
  9165. if (es_default36(cellPt, options.mask))
  9166. results.push(cellPt);
  9167. } else {
  9168. results.push(cellPt);
  9169. }
  9170. currentY += cellHeight;
  9171. }
  9172. currentX += cellWidth;
  9173. }
  9174. return featureCollection(results);
  9175. }
  9176. var es_default37 = pointGrid;
  9177. // node_modules/@turf/truncate/dist/es/index.js
  9178. function truncate(geojson, options) {
  9179. if (options === void 0) {
  9180. options = {};
  9181. }
  9182. var precision = options.precision;
  9183. var coordinates = options.coordinates;
  9184. var mutate = options.mutate;
  9185. precision = precision === void 0 || precision === null || isNaN(precision) ? 6 : precision;
  9186. coordinates = coordinates === void 0 || coordinates === null || isNaN(coordinates) ? 3 : coordinates;
  9187. if (!geojson)
  9188. throw new Error("<geojson> is required");
  9189. if (typeof precision !== "number")
  9190. throw new Error("<precision> must be a number");
  9191. if (typeof coordinates !== "number")
  9192. throw new Error("<coordinates> must be a number");
  9193. if (mutate === false || mutate === void 0)
  9194. geojson = JSON.parse(JSON.stringify(geojson));
  9195. var factor = Math.pow(10, precision);
  9196. coordEach(geojson, function(coords) {
  9197. truncateCoords(coords, factor, coordinates);
  9198. });
  9199. return geojson;
  9200. }
  9201. function truncateCoords(coords, factor, coordinates) {
  9202. if (coords.length > coordinates)
  9203. coords.splice(coordinates, coords.length);
  9204. for (var i = 0; i < coords.length; i++) {
  9205. coords[i] = Math.round(coords[i] * factor) / factor;
  9206. }
  9207. return coords;
  9208. }
  9209. var es_default38 = truncate;
  9210. // node_modules/@turf/flatten/dist/es/index.js
  9211. function flatten(geojson) {
  9212. if (!geojson)
  9213. throw new Error("geojson is required");
  9214. var results = [];
  9215. flattenEach(geojson, function(feature2) {
  9216. results.push(feature2);
  9217. });
  9218. return featureCollection(results);
  9219. }
  9220. var es_default39 = flatten;
  9221. // node_modules/@turf/line-chunk/dist/es/index.js
  9222. function lineChunk(geojson, segmentLength, options) {
  9223. options = options || {};
  9224. if (!isObject(options))
  9225. throw new Error("options is invalid");
  9226. var units = options.units;
  9227. var reverse5 = options.reverse;
  9228. if (!geojson)
  9229. throw new Error("geojson is required");
  9230. if (segmentLength <= 0)
  9231. throw new Error("segmentLength must be greater than 0");
  9232. var results = [];
  9233. flattenEach(geojson, function(feature2) {
  9234. if (reverse5)
  9235. feature2.geometry.coordinates = feature2.geometry.coordinates.reverse();
  9236. sliceLineSegments(feature2, segmentLength, units, function(segment) {
  9237. results.push(segment);
  9238. });
  9239. });
  9240. return featureCollection(results);
  9241. }
  9242. function sliceLineSegments(line, segmentLength, units, callback) {
  9243. var lineLength = length(line, { units });
  9244. if (lineLength <= segmentLength)
  9245. return callback(line);
  9246. var numberOfSegments = lineLength / segmentLength;
  9247. if (!Number.isInteger(numberOfSegments)) {
  9248. numberOfSegments = Math.floor(numberOfSegments) + 1;
  9249. }
  9250. for (var i = 0; i < numberOfSegments; i++) {
  9251. var outline = es_default34(
  9252. line,
  9253. segmentLength * i,
  9254. segmentLength * (i + 1),
  9255. { units }
  9256. );
  9257. callback(outline, i);
  9258. }
  9259. }
  9260. var es_default40 = lineChunk;
  9261. // node_modules/@turf/unkink-polygon/dist/es/index.js
  9262. var import_rbush2 = __toESM(require_rbush());
  9263. function isects(feature2, filterFn, useSpatialIndex) {
  9264. if (feature2.geometry.type !== "Polygon")
  9265. throw new Error("The input feature must be a Polygon");
  9266. if (useSpatialIndex === void 0)
  9267. useSpatialIndex = 1;
  9268. var coord = feature2.geometry.coordinates;
  9269. var output = [];
  9270. var seen = {};
  9271. if (useSpatialIndex) {
  9272. var allEdgesAsRbushTreeItems = [];
  9273. for (var ring0 = 0; ring0 < coord.length; ring0++) {
  9274. for (var edge0 = 0; edge0 < coord[ring0].length - 1; edge0++) {
  9275. allEdgesAsRbushTreeItems.push(rbushTreeItem(ring0, edge0));
  9276. }
  9277. }
  9278. var tree = (0, import_rbush2.default)();
  9279. tree.load(allEdgesAsRbushTreeItems);
  9280. }
  9281. for (var ringA = 0; ringA < coord.length; ringA++) {
  9282. for (var edgeA = 0; edgeA < coord[ringA].length - 1; edgeA++) {
  9283. if (useSpatialIndex) {
  9284. var bboxOverlaps = tree.search(rbushTreeItem(ringA, edgeA));
  9285. bboxOverlaps.forEach(function(bboxIsect) {
  9286. var ring12 = bboxIsect.ring;
  9287. var edge12 = bboxIsect.edge;
  9288. ifIsectAddToOutput(ringA, edgeA, ring12, edge12);
  9289. });
  9290. } else {
  9291. for (var ring1 = 0; ring1 < coord.length; ring1++) {
  9292. for (var edge1 = 0; edge1 < coord[ring1].length - 1; edge1++) {
  9293. ifIsectAddToOutput(ringA, edgeA, ring1, edge1);
  9294. }
  9295. }
  9296. }
  9297. }
  9298. }
  9299. if (!filterFn)
  9300. output = {
  9301. type: "Feature",
  9302. geometry: { type: "MultiPoint", coordinates: output }
  9303. };
  9304. return output;
  9305. function ifIsectAddToOutput(ring02, edge02, ring12, edge12) {
  9306. var start0 = coord[ring02][edge02];
  9307. var end0 = coord[ring02][edge02 + 1];
  9308. var start1 = coord[ring12][edge12];
  9309. var end1 = coord[ring12][edge12 + 1];
  9310. var isect = intersect(start0, end0, start1, end1);
  9311. if (isect === null)
  9312. return;
  9313. var frac0;
  9314. var frac1;
  9315. if (end0[0] !== start0[0]) {
  9316. frac0 = (isect[0] - start0[0]) / (end0[0] - start0[0]);
  9317. } else {
  9318. frac0 = (isect[1] - start0[1]) / (end0[1] - start0[1]);
  9319. }
  9320. if (end1[0] !== start1[0]) {
  9321. frac1 = (isect[0] - start1[0]) / (end1[0] - start1[0]);
  9322. } else {
  9323. frac1 = (isect[1] - start1[1]) / (end1[1] - start1[1]);
  9324. }
  9325. if (frac0 >= 1 || frac0 <= 0 || frac1 >= 1 || frac1 <= 0)
  9326. return;
  9327. var key = isect;
  9328. var unique = !seen[key];
  9329. if (unique) {
  9330. seen[key] = true;
  9331. }
  9332. if (filterFn) {
  9333. output.push(
  9334. filterFn(
  9335. isect,
  9336. ring02,
  9337. edge02,
  9338. start0,
  9339. end0,
  9340. frac0,
  9341. ring12,
  9342. edge12,
  9343. start1,
  9344. end1,
  9345. frac1,
  9346. unique
  9347. )
  9348. );
  9349. } else {
  9350. output.push(isect);
  9351. }
  9352. }
  9353. function rbushTreeItem(ring, edge) {
  9354. var start = coord[ring][edge];
  9355. var end = coord[ring][edge + 1];
  9356. var minX2;
  9357. var maxX2;
  9358. var minY2;
  9359. var maxY2;
  9360. if (start[0] < end[0]) {
  9361. minX2 = start[0];
  9362. maxX2 = end[0];
  9363. } else {
  9364. minX2 = end[0];
  9365. maxX2 = start[0];
  9366. }
  9367. if (start[1] < end[1]) {
  9368. minY2 = start[1];
  9369. maxY2 = end[1];
  9370. } else {
  9371. minY2 = end[1];
  9372. maxY2 = start[1];
  9373. }
  9374. return {
  9375. minX: minX2,
  9376. minY: minY2,
  9377. maxX: maxX2,
  9378. maxY: maxY2,
  9379. ring,
  9380. edge
  9381. };
  9382. }
  9383. }
  9384. function intersect(start0, end0, start1, end1) {
  9385. if (equalArrays(start0, start1) || equalArrays(start0, end1) || equalArrays(end0, start1) || equalArrays(end1, start1))
  9386. return null;
  9387. var x02 = start0[0], y02 = start0[1], x12 = end0[0], y12 = end0[1], x2 = start1[0], y2 = start1[1], x3 = end1[0], y3 = end1[1];
  9388. var denom = (x02 - x12) * (y2 - y3) - (y02 - y12) * (x2 - x3);
  9389. if (denom === 0)
  9390. return null;
  9391. var x4 = ((x02 * y12 - y02 * x12) * (x2 - x3) - (x02 - x12) * (x2 * y3 - y2 * x3)) / denom;
  9392. var y4 = ((x02 * y12 - y02 * x12) * (y2 - y3) - (y02 - y12) * (x2 * y3 - y2 * x3)) / denom;
  9393. return [x4, y4];
  9394. }
  9395. function equalArrays(array1, array2) {
  9396. if (!array1 || !array2)
  9397. return false;
  9398. if (array1.length !== array2.length)
  9399. return false;
  9400. for (var i = 0, l = array1.length; i < l; i++) {
  9401. if (array1[i] instanceof Array && array2[i] instanceof Array) {
  9402. if (!equalArrays(array1[i], array2[i]))
  9403. return false;
  9404. } else if (array1[i] !== array2[i]) {
  9405. return false;
  9406. }
  9407. }
  9408. return true;
  9409. }
  9410. function simplepolygon(feature2) {
  9411. if (feature2.type != "Feature")
  9412. throw new Error("The input must a geojson object of type Feature");
  9413. if (feature2.geometry === void 0 || feature2.geometry == null)
  9414. throw new Error(
  9415. "The input must a geojson object with a non-empty geometry"
  9416. );
  9417. if (feature2.geometry.type != "Polygon")
  9418. throw new Error("The input must be a geojson Polygon");
  9419. var numRings = feature2.geometry.coordinates.length;
  9420. var vertices = [];
  9421. for (var i = 0; i < numRings; i++) {
  9422. var ring = feature2.geometry.coordinates[i];
  9423. if (!equalArrays$1(ring[0], ring[ring.length - 1])) {
  9424. ring.push(ring[0]);
  9425. }
  9426. vertices.push.apply(vertices, ring.slice(0, ring.length - 1));
  9427. }
  9428. if (!isUnique(vertices))
  9429. throw new Error(
  9430. "The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)"
  9431. );
  9432. var numvertices = vertices.length;
  9433. var selfIsectsData = isects(
  9434. feature2,
  9435. function filterFn(isect, ring0, edge0, start0, end0, frac0, ring1, edge1, start1, end1, frac1, unique) {
  9436. return [
  9437. isect,
  9438. ring0,
  9439. edge0,
  9440. start0,
  9441. end0,
  9442. frac0,
  9443. ring1,
  9444. edge1,
  9445. start1,
  9446. end1,
  9447. frac1,
  9448. unique
  9449. ];
  9450. }
  9451. );
  9452. var numSelfIsect = selfIsectsData.length;
  9453. if (numSelfIsect == 0) {
  9454. var outputFeatureArray = [];
  9455. for (var i = 0; i < numRings; i++) {
  9456. outputFeatureArray.push(
  9457. polygon([feature2.geometry.coordinates[i]], {
  9458. parent: -1,
  9459. winding: windingOfRing(feature2.geometry.coordinates[i])
  9460. })
  9461. );
  9462. }
  9463. var output = featureCollection(outputFeatureArray);
  9464. determineParents();
  9465. setNetWinding();
  9466. return output;
  9467. }
  9468. var pseudoVtxListByRingAndEdge = [];
  9469. var isectList = [];
  9470. for (var i = 0; i < numRings; i++) {
  9471. pseudoVtxListByRingAndEdge.push([]);
  9472. for (var j = 0; j < feature2.geometry.coordinates[i].length - 1; j++) {
  9473. pseudoVtxListByRingAndEdge[i].push([
  9474. new PseudoVtx(
  9475. feature2.geometry.coordinates[i][modulo(j + 1, feature2.geometry.coordinates[i].length - 1)],
  9476. 1,
  9477. [i, j],
  9478. [i, modulo(j + 1, feature2.geometry.coordinates[i].length - 1)],
  9479. void 0
  9480. )
  9481. ]);
  9482. isectList.push(
  9483. new Isect(
  9484. feature2.geometry.coordinates[i][j],
  9485. [i, modulo(j - 1, feature2.geometry.coordinates[i].length - 1)],
  9486. [i, j],
  9487. void 0,
  9488. void 0,
  9489. false,
  9490. true
  9491. )
  9492. );
  9493. }
  9494. }
  9495. for (var i = 0; i < numSelfIsect; i++) {
  9496. pseudoVtxListByRingAndEdge[selfIsectsData[i][1]][selfIsectsData[i][2]].push(
  9497. new PseudoVtx(
  9498. selfIsectsData[i][0],
  9499. selfIsectsData[i][5],
  9500. [selfIsectsData[i][1], selfIsectsData[i][2]],
  9501. [selfIsectsData[i][6], selfIsectsData[i][7]],
  9502. void 0
  9503. )
  9504. );
  9505. if (selfIsectsData[i][11])
  9506. isectList.push(
  9507. new Isect(
  9508. selfIsectsData[i][0],
  9509. [selfIsectsData[i][1], selfIsectsData[i][2]],
  9510. [selfIsectsData[i][6], selfIsectsData[i][7]],
  9511. void 0,
  9512. void 0,
  9513. true,
  9514. true
  9515. )
  9516. );
  9517. }
  9518. var numIsect = isectList.length;
  9519. for (var i = 0; i < pseudoVtxListByRingAndEdge.length; i++) {
  9520. for (var j = 0; j < pseudoVtxListByRingAndEdge[i].length; j++) {
  9521. pseudoVtxListByRingAndEdge[i][j].sort(function(a, b) {
  9522. return a.param < b.param ? -1 : 1;
  9523. });
  9524. }
  9525. }
  9526. var allIsectsAsIsectRbushTreeItem = [];
  9527. for (var i = 0; i < numIsect; i++) {
  9528. allIsectsAsIsectRbushTreeItem.push({
  9529. minX: isectList[i].coord[0],
  9530. minY: isectList[i].coord[1],
  9531. maxX: isectList[i].coord[0],
  9532. maxY: isectList[i].coord[1],
  9533. index: i
  9534. });
  9535. }
  9536. var isectRbushTree = (0, import_rbush2.default)();
  9537. isectRbushTree.load(allIsectsAsIsectRbushTreeItem);
  9538. for (var i = 0; i < pseudoVtxListByRingAndEdge.length; i++) {
  9539. for (var j = 0; j < pseudoVtxListByRingAndEdge[i].length; j++) {
  9540. for (var k = 0; k < pseudoVtxListByRingAndEdge[i][j].length; k++) {
  9541. var coordToFind;
  9542. if (k == pseudoVtxListByRingAndEdge[i][j].length - 1) {
  9543. coordToFind = pseudoVtxListByRingAndEdge[i][modulo(j + 1, feature2.geometry.coordinates[i].length - 1)][0].coord;
  9544. } else {
  9545. coordToFind = pseudoVtxListByRingAndEdge[i][j][k + 1].coord;
  9546. }
  9547. var IsectRbushTreeItemFound = isectRbushTree.search({
  9548. minX: coordToFind[0],
  9549. minY: coordToFind[1],
  9550. maxX: coordToFind[0],
  9551. maxY: coordToFind[1]
  9552. })[0];
  9553. pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn = IsectRbushTreeItemFound.index;
  9554. }
  9555. }
  9556. }
  9557. for (var i = 0; i < pseudoVtxListByRingAndEdge.length; i++) {
  9558. for (var j = 0; j < pseudoVtxListByRingAndEdge[i].length; j++) {
  9559. for (var k = 0; k < pseudoVtxListByRingAndEdge[i][j].length; k++) {
  9560. var coordToFind = pseudoVtxListByRingAndEdge[i][j][k].coord;
  9561. var IsectRbushTreeItemFound = isectRbushTree.search({
  9562. minX: coordToFind[0],
  9563. minY: coordToFind[1],
  9564. maxX: coordToFind[0],
  9565. maxY: coordToFind[1]
  9566. })[0];
  9567. var l = IsectRbushTreeItemFound.index;
  9568. if (l < numvertices) {
  9569. isectList[l].nxtIsectAlongRingAndEdge2 = pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn;
  9570. } else {
  9571. if (equalArrays$1(
  9572. isectList[l].ringAndEdge1,
  9573. pseudoVtxListByRingAndEdge[i][j][k].ringAndEdgeIn
  9574. )) {
  9575. isectList[l].nxtIsectAlongRingAndEdge1 = pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn;
  9576. } else {
  9577. isectList[l].nxtIsectAlongRingAndEdge2 = pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn;
  9578. }
  9579. }
  9580. }
  9581. }
  9582. }
  9583. var queue = [];
  9584. var i = 0;
  9585. for (var j = 0; j < numRings; j++) {
  9586. var leftIsect = i;
  9587. for (var k = 0; k < feature2.geometry.coordinates[j].length - 1; k++) {
  9588. if (isectList[i].coord[0] < isectList[leftIsect].coord[0]) {
  9589. leftIsect = i;
  9590. }
  9591. i++;
  9592. }
  9593. var isectAfterLeftIsect = isectList[leftIsect].nxtIsectAlongRingAndEdge2;
  9594. for (var k = 0; k < isectList.length; k++) {
  9595. if (isectList[k].nxtIsectAlongRingAndEdge1 == leftIsect || isectList[k].nxtIsectAlongRingAndEdge2 == leftIsect) {
  9596. var isectBeforeLeftIsect = k;
  9597. break;
  9598. }
  9599. }
  9600. var windingAtIsect = isConvex(
  9601. [
  9602. isectList[isectBeforeLeftIsect].coord,
  9603. isectList[leftIsect].coord,
  9604. isectList[isectAfterLeftIsect].coord
  9605. ],
  9606. true
  9607. ) ? 1 : -1;
  9608. queue.push({ isect: leftIsect, parent: -1, winding: windingAtIsect });
  9609. }
  9610. queue.sort(function(a, b) {
  9611. return isectList[a.isect].coord > isectList[b.isect].coord ? -1 : 1;
  9612. });
  9613. var outputFeatureArray = [];
  9614. while (queue.length > 0) {
  9615. var popped = queue.pop();
  9616. var startIsect = popped.isect;
  9617. var currentOutputRingParent = popped.parent;
  9618. var currentOutputRingWinding = popped.winding;
  9619. var currentOutputRing = outputFeatureArray.length;
  9620. var currentOutputRingCoords = [isectList[startIsect].coord];
  9621. var currentIsect = startIsect;
  9622. if (isectList[startIsect].ringAndEdge1Walkable) {
  9623. var walkingRingAndEdge = isectList[startIsect].ringAndEdge1;
  9624. var nxtIsect = isectList[startIsect].nxtIsectAlongRingAndEdge1;
  9625. } else {
  9626. var walkingRingAndEdge = isectList[startIsect].ringAndEdge2;
  9627. var nxtIsect = isectList[startIsect].nxtIsectAlongRingAndEdge2;
  9628. }
  9629. while (!equalArrays$1(isectList[startIsect].coord, isectList[nxtIsect].coord)) {
  9630. currentOutputRingCoords.push(isectList[nxtIsect].coord);
  9631. var nxtIsectInQueue = void 0;
  9632. for (var i = 0; i < queue.length; i++) {
  9633. if (queue[i].isect == nxtIsect) {
  9634. nxtIsectInQueue = i;
  9635. break;
  9636. }
  9637. }
  9638. if (nxtIsectInQueue != void 0) {
  9639. queue.splice(nxtIsectInQueue, 1);
  9640. }
  9641. if (equalArrays$1(walkingRingAndEdge, isectList[nxtIsect].ringAndEdge1)) {
  9642. walkingRingAndEdge = isectList[nxtIsect].ringAndEdge2;
  9643. isectList[nxtIsect].ringAndEdge2Walkable = false;
  9644. if (isectList[nxtIsect].ringAndEdge1Walkable) {
  9645. var pushing = { isect: nxtIsect };
  9646. if (isConvex(
  9647. [
  9648. isectList[currentIsect].coord,
  9649. isectList[nxtIsect].coord,
  9650. isectList[isectList[nxtIsect].nxtIsectAlongRingAndEdge2].coord
  9651. ],
  9652. currentOutputRingWinding == 1
  9653. )) {
  9654. pushing.parent = currentOutputRingParent;
  9655. pushing.winding = -currentOutputRingWinding;
  9656. } else {
  9657. pushing.parent = currentOutputRing;
  9658. pushing.winding = currentOutputRingWinding;
  9659. }
  9660. queue.push(pushing);
  9661. }
  9662. currentIsect = nxtIsect;
  9663. nxtIsect = isectList[nxtIsect].nxtIsectAlongRingAndEdge2;
  9664. } else {
  9665. walkingRingAndEdge = isectList[nxtIsect].ringAndEdge1;
  9666. isectList[nxtIsect].ringAndEdge1Walkable = false;
  9667. if (isectList[nxtIsect].ringAndEdge2Walkable) {
  9668. var pushing = { isect: nxtIsect };
  9669. if (isConvex(
  9670. [
  9671. isectList[currentIsect].coord,
  9672. isectList[nxtIsect].coord,
  9673. isectList[isectList[nxtIsect].nxtIsectAlongRingAndEdge1].coord
  9674. ],
  9675. currentOutputRingWinding == 1
  9676. )) {
  9677. pushing.parent = currentOutputRingParent;
  9678. pushing.winding = -currentOutputRingWinding;
  9679. } else {
  9680. pushing.parent = currentOutputRing;
  9681. pushing.winding = currentOutputRingWinding;
  9682. }
  9683. queue.push(pushing);
  9684. }
  9685. currentIsect = nxtIsect;
  9686. nxtIsect = isectList[nxtIsect].nxtIsectAlongRingAndEdge1;
  9687. }
  9688. }
  9689. currentOutputRingCoords.push(isectList[nxtIsect].coord);
  9690. outputFeatureArray.push(
  9691. polygon([currentOutputRingCoords], {
  9692. index: currentOutputRing,
  9693. parent: currentOutputRingParent,
  9694. winding: currentOutputRingWinding,
  9695. netWinding: void 0
  9696. })
  9697. );
  9698. }
  9699. var output = featureCollection(outputFeatureArray);
  9700. determineParents();
  9701. setNetWinding();
  9702. function determineParents() {
  9703. var featuresWithoutParent = [];
  9704. for (var i2 = 0; i2 < output.features.length; i2++) {
  9705. if (output.features[i2].properties.parent == -1)
  9706. featuresWithoutParent.push(i2);
  9707. }
  9708. if (featuresWithoutParent.length > 1) {
  9709. for (var i2 = 0; i2 < featuresWithoutParent.length; i2++) {
  9710. var parent = -1;
  9711. var parentArea = Infinity;
  9712. for (var j2 = 0; j2 < output.features.length; j2++) {
  9713. if (featuresWithoutParent[i2] == j2)
  9714. continue;
  9715. if (booleanPointInPolygon(
  9716. output.features[featuresWithoutParent[i2]].geometry.coordinates[0][0],
  9717. output.features[j2],
  9718. { ignoreBoundary: true }
  9719. )) {
  9720. if (area(output.features[j2]) < parentArea) {
  9721. parent = j2;
  9722. }
  9723. }
  9724. }
  9725. output.features[featuresWithoutParent[i2]].properties.parent = parent;
  9726. }
  9727. }
  9728. }
  9729. function setNetWinding() {
  9730. for (var i2 = 0; i2 < output.features.length; i2++) {
  9731. if (output.features[i2].properties.parent == -1) {
  9732. var netWinding = output.features[i2].properties.winding;
  9733. output.features[i2].properties.netWinding = netWinding;
  9734. setNetWindingOfChildren(i2, netWinding);
  9735. }
  9736. }
  9737. }
  9738. function setNetWindingOfChildren(parent, ParentNetWinding) {
  9739. for (var i2 = 0; i2 < output.features.length; i2++) {
  9740. if (output.features[i2].properties.parent == parent) {
  9741. var netWinding = ParentNetWinding + output.features[i2].properties.winding;
  9742. output.features[i2].properties.netWinding = netWinding;
  9743. setNetWindingOfChildren(i2, netWinding);
  9744. }
  9745. }
  9746. }
  9747. return output;
  9748. }
  9749. var PseudoVtx = function(coord, param, ringAndEdgeIn, ringAndEdgeOut, nxtIsectAlongEdgeIn) {
  9750. this.coord = coord;
  9751. this.param = param;
  9752. this.ringAndEdgeIn = ringAndEdgeIn;
  9753. this.ringAndEdgeOut = ringAndEdgeOut;
  9754. this.nxtIsectAlongEdgeIn = nxtIsectAlongEdgeIn;
  9755. };
  9756. var Isect = function(coord, ringAndEdge1, ringAndEdge2, nxtIsectAlongRingAndEdge1, nxtIsectAlongRingAndEdge2, ringAndEdge1Walkable, ringAndEdge2Walkable) {
  9757. this.coord = coord;
  9758. this.ringAndEdge1 = ringAndEdge1;
  9759. this.ringAndEdge2 = ringAndEdge2;
  9760. this.nxtIsectAlongRingAndEdge1 = nxtIsectAlongRingAndEdge1;
  9761. this.nxtIsectAlongRingAndEdge2 = nxtIsectAlongRingAndEdge2;
  9762. this.ringAndEdge1Walkable = ringAndEdge1Walkable;
  9763. this.ringAndEdge2Walkable = ringAndEdge2Walkable;
  9764. };
  9765. function isConvex(pts, righthanded) {
  9766. if (typeof righthanded === "undefined")
  9767. righthanded = true;
  9768. if (pts.length != 3)
  9769. throw new Error("This function requires an array of three points [x,y]");
  9770. var d = (pts[1][0] - pts[0][0]) * (pts[2][1] - pts[0][1]) - (pts[1][1] - pts[0][1]) * (pts[2][0] - pts[0][0]);
  9771. return d >= 0 == righthanded;
  9772. }
  9773. function windingOfRing(ring) {
  9774. var leftVtx = 0;
  9775. for (var i = 0; i < ring.length - 1; i++) {
  9776. if (ring[i][0] < ring[leftVtx][0])
  9777. leftVtx = i;
  9778. }
  9779. if (isConvex(
  9780. [
  9781. ring[modulo(leftVtx - 1, ring.length - 1)],
  9782. ring[leftVtx],
  9783. ring[modulo(leftVtx + 1, ring.length - 1)]
  9784. ],
  9785. true
  9786. )) {
  9787. var winding = 1;
  9788. } else {
  9789. var winding = -1;
  9790. }
  9791. return winding;
  9792. }
  9793. function equalArrays$1(array1, array2) {
  9794. if (!array1 || !array2)
  9795. return false;
  9796. if (array1.length != array2.length)
  9797. return false;
  9798. for (var i = 0, l = array1.length; i < l; i++) {
  9799. if (array1[i] instanceof Array && array2[i] instanceof Array) {
  9800. if (!equalArrays$1(array1[i], array2[i]))
  9801. return false;
  9802. } else if (array1[i] != array2[i]) {
  9803. return false;
  9804. }
  9805. }
  9806. return true;
  9807. }
  9808. function modulo(n, m) {
  9809. return (n % m + m) % m;
  9810. }
  9811. function isUnique(array2) {
  9812. var u = {};
  9813. var isUnique2 = 1;
  9814. for (var i = 0, l = array2.length; i < l; ++i) {
  9815. if (Object.prototype.hasOwnProperty.call(u, array2[i])) {
  9816. isUnique2 = 0;
  9817. break;
  9818. }
  9819. u[array2[i]] = 1;
  9820. }
  9821. return isUnique2;
  9822. }
  9823. function unkinkPolygon(geojson) {
  9824. var features = [];
  9825. flattenEach(geojson, function(feature2) {
  9826. if (feature2.geometry.type !== "Polygon")
  9827. return;
  9828. featureEach(simplepolygon(feature2), function(poly) {
  9829. features.push(polygon(poly.geometry.coordinates, feature2.properties));
  9830. });
  9831. });
  9832. return featureCollection(features);
  9833. }
  9834. var es_default41 = unkinkPolygon;
  9835. // node_modules/@turf/great-circle/dist/es/index.js
  9836. var D2R = Math.PI / 180;
  9837. var R2D = 180 / Math.PI;
  9838. var Coord = function(lon2, lat2) {
  9839. this.lon = lon2;
  9840. this.lat = lat2;
  9841. this.x = D2R * lon2;
  9842. this.y = D2R * lat2;
  9843. };
  9844. Coord.prototype.view = function() {
  9845. return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4);
  9846. };
  9847. Coord.prototype.antipode = function() {
  9848. var anti_lat = -1 * this.lat;
  9849. var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;
  9850. return new Coord(anti_lon, anti_lat);
  9851. };
  9852. var LineString = function() {
  9853. this.coords = [];
  9854. this.length = 0;
  9855. };
  9856. LineString.prototype.move_to = function(coord) {
  9857. this.length++;
  9858. this.coords.push(coord);
  9859. };
  9860. var Arc = function(properties) {
  9861. this.properties = properties || {};
  9862. this.geometries = [];
  9863. };
  9864. Arc.prototype.json = function() {
  9865. if (this.geometries.length <= 0) {
  9866. return {
  9867. geometry: { type: "LineString", coordinates: null },
  9868. type: "Feature",
  9869. properties: this.properties
  9870. };
  9871. } else if (this.geometries.length === 1) {
  9872. return {
  9873. geometry: { type: "LineString", coordinates: this.geometries[0].coords },
  9874. type: "Feature",
  9875. properties: this.properties
  9876. };
  9877. } else {
  9878. var multiline = [];
  9879. for (var i = 0; i < this.geometries.length; i++) {
  9880. multiline.push(this.geometries[i].coords);
  9881. }
  9882. return {
  9883. geometry: { type: "MultiLineString", coordinates: multiline },
  9884. type: "Feature",
  9885. properties: this.properties
  9886. };
  9887. }
  9888. };
  9889. Arc.prototype.wkt = function() {
  9890. var wkt_string = "";
  9891. var wkt = "LINESTRING(";
  9892. var collect2 = function(c) {
  9893. wkt += c[0] + " " + c[1] + ",";
  9894. };
  9895. for (var i = 0; i < this.geometries.length; i++) {
  9896. if (this.geometries[i].coords.length === 0) {
  9897. return "LINESTRING(empty)";
  9898. } else {
  9899. var coords = this.geometries[i].coords;
  9900. coords.forEach(collect2);
  9901. wkt_string += wkt.substring(0, wkt.length - 1) + ")";
  9902. }
  9903. }
  9904. return wkt_string;
  9905. };
  9906. var GreatCircle = function(start, end, properties) {
  9907. if (!start || start.x === void 0 || start.y === void 0) {
  9908. throw new Error(
  9909. "GreatCircle constructor expects two args: start and end objects with x and y properties"
  9910. );
  9911. }
  9912. if (!end || end.x === void 0 || end.y === void 0) {
  9913. throw new Error(
  9914. "GreatCircle constructor expects two args: start and end objects with x and y properties"
  9915. );
  9916. }
  9917. this.start = new Coord(start.x, start.y);
  9918. this.end = new Coord(end.x, end.y);
  9919. this.properties = properties || {};
  9920. var w = this.start.x - this.end.x;
  9921. var h = this.start.y - this.end.y;
  9922. var z = Math.pow(Math.sin(h / 2), 2) + Math.cos(this.start.y) * Math.cos(this.end.y) * Math.pow(Math.sin(w / 2), 2);
  9923. this.g = 2 * Math.asin(Math.sqrt(z));
  9924. if (this.g === Math.PI) {
  9925. throw new Error(
  9926. "it appears " + start.view() + " and " + end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
  9927. );
  9928. } else if (isNaN(this.g)) {
  9929. throw new Error(
  9930. "could not calculate great circle between " + start + " and " + end
  9931. );
  9932. }
  9933. };
  9934. GreatCircle.prototype.interpolate = function(f) {
  9935. var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);
  9936. var B2 = Math.sin(f * this.g) / Math.sin(this.g);
  9937. var x2 = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B2 * Math.cos(this.end.y) * Math.cos(this.end.x);
  9938. var y2 = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B2 * Math.cos(this.end.y) * Math.sin(this.end.x);
  9939. var z = A * Math.sin(this.start.y) + B2 * Math.sin(this.end.y);
  9940. var lat2 = R2D * Math.atan2(z, Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)));
  9941. var lon2 = R2D * Math.atan2(y2, x2);
  9942. return [lon2, lat2];
  9943. };
  9944. GreatCircle.prototype.Arc = function(npoints, options) {
  9945. var first_pass = [];
  9946. if (!npoints || npoints <= 2) {
  9947. first_pass.push([this.start.lon, this.start.lat]);
  9948. first_pass.push([this.end.lon, this.end.lat]);
  9949. } else {
  9950. var delta = 1 / (npoints - 1);
  9951. for (var i = 0; i < npoints; ++i) {
  9952. var step = delta * i;
  9953. var pair2 = this.interpolate(step);
  9954. first_pass.push(pair2);
  9955. }
  9956. }
  9957. var bHasBigDiff = false;
  9958. var dfMaxSmallDiffLong = 0;
  9959. var dfDateLineOffset = options && options.offset ? options.offset : 10;
  9960. var dfLeftBorderX = 180 - dfDateLineOffset;
  9961. var dfRightBorderX = -180 + dfDateLineOffset;
  9962. var dfDiffSpace = 360 - dfDateLineOffset;
  9963. for (var j = 1; j < first_pass.length; ++j) {
  9964. var dfPrevX = first_pass[j - 1][0];
  9965. var dfX = first_pass[j][0];
  9966. var dfDiffLong = Math.abs(dfX - dfPrevX);
  9967. if (dfDiffLong > dfDiffSpace && (dfX > dfLeftBorderX && dfPrevX < dfRightBorderX || dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) {
  9968. bHasBigDiff = true;
  9969. } else if (dfDiffLong > dfMaxSmallDiffLong) {
  9970. dfMaxSmallDiffLong = dfDiffLong;
  9971. }
  9972. }
  9973. var poMulti = [];
  9974. if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {
  9975. var poNewLS = [];
  9976. poMulti.push(poNewLS);
  9977. for (var k = 0; k < first_pass.length; ++k) {
  9978. var dfX0 = parseFloat(first_pass[k][0]);
  9979. if (k > 0 && Math.abs(dfX0 - first_pass[k - 1][0]) > dfDiffSpace) {
  9980. var dfX1 = parseFloat(first_pass[k - 1][0]);
  9981. var dfY1 = parseFloat(first_pass[k - 1][1]);
  9982. var dfX2 = parseFloat(first_pass[k][0]);
  9983. var dfY2 = parseFloat(first_pass[k][1]);
  9984. if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 && k + 1 < first_pass.length && first_pass[k - 1][0] > -180 && first_pass[k - 1][0] < dfRightBorderX) {
  9985. poNewLS.push([-180, first_pass[k][1]]);
  9986. k++;
  9987. poNewLS.push([first_pass[k][0], first_pass[k][1]]);
  9988. continue;
  9989. } else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 && k + 1 < first_pass.length && first_pass[k - 1][0] > dfLeftBorderX && first_pass[k - 1][0] < 180) {
  9990. poNewLS.push([180, first_pass[k][1]]);
  9991. k++;
  9992. poNewLS.push([first_pass[k][0], first_pass[k][1]]);
  9993. continue;
  9994. }
  9995. if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {
  9996. var tmpX = dfX1;
  9997. dfX1 = dfX2;
  9998. dfX2 = tmpX;
  9999. var tmpY = dfY1;
  10000. dfY1 = dfY2;
  10001. dfY2 = tmpY;
  10002. }
  10003. if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {
  10004. dfX2 += 360;
  10005. }
  10006. if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {
  10007. var dfRatio = (180 - dfX1) / (dfX2 - dfX1);
  10008. var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;
  10009. poNewLS.push([
  10010. first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,
  10011. dfY
  10012. ]);
  10013. poNewLS = [];
  10014. poNewLS.push([
  10015. first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,
  10016. dfY
  10017. ]);
  10018. poMulti.push(poNewLS);
  10019. } else {
  10020. poNewLS = [];
  10021. poMulti.push(poNewLS);
  10022. }
  10023. poNewLS.push([dfX0, first_pass[k][1]]);
  10024. } else {
  10025. poNewLS.push([first_pass[k][0], first_pass[k][1]]);
  10026. }
  10027. }
  10028. } else {
  10029. var poNewLS0 = [];
  10030. poMulti.push(poNewLS0);
  10031. for (var l = 0; l < first_pass.length; ++l) {
  10032. poNewLS0.push([first_pass[l][0], first_pass[l][1]]);
  10033. }
  10034. }
  10035. var arc = new Arc(this.properties);
  10036. for (var m = 0; m < poMulti.length; ++m) {
  10037. var line = new LineString();
  10038. arc.geometries.push(line);
  10039. var points2 = poMulti[m];
  10040. for (var j0 = 0; j0 < points2.length; ++j0) {
  10041. line.move_to(points2[j0]);
  10042. }
  10043. }
  10044. return arc;
  10045. };
  10046. function greatCircle(start, end, options) {
  10047. options = options || {};
  10048. if (typeof options !== "object")
  10049. throw new Error("options is invalid");
  10050. var properties = options.properties;
  10051. var npoints = options.npoints;
  10052. var offset = options.offset;
  10053. start = getCoord(start);
  10054. end = getCoord(end);
  10055. properties = properties || {};
  10056. npoints = npoints || 100;
  10057. offset = offset || 10;
  10058. var generator = new GreatCircle(
  10059. { x: start[0], y: start[1] },
  10060. { x: end[0], y: end[1] },
  10061. properties
  10062. );
  10063. var line = generator.Arc(npoints, { offset });
  10064. return line.json();
  10065. }
  10066. var es_default42 = greatCircle;
  10067. // node_modules/@turf/line-split/dist/es/index.js
  10068. var import_geojson_rbush2 = __toESM(require_geojson_rbush());
  10069. function lineSplit(line, splitter) {
  10070. if (!line)
  10071. throw new Error("line is required");
  10072. if (!splitter)
  10073. throw new Error("splitter is required");
  10074. var lineType = getType(line);
  10075. var splitterType = getType(splitter);
  10076. if (lineType !== "LineString")
  10077. throw new Error("line must be LineString");
  10078. if (splitterType === "FeatureCollection")
  10079. throw new Error("splitter cannot be a FeatureCollection");
  10080. if (splitterType === "GeometryCollection")
  10081. throw new Error("splitter cannot be a GeometryCollection");
  10082. var truncatedSplitter = es_default38(splitter, { precision: 7 });
  10083. switch (splitterType) {
  10084. case "Point":
  10085. return splitLineWithPoint(line, truncatedSplitter);
  10086. case "MultiPoint":
  10087. return splitLineWithPoints(line, truncatedSplitter);
  10088. case "LineString":
  10089. case "MultiLineString":
  10090. case "Polygon":
  10091. case "MultiPolygon":
  10092. return splitLineWithPoints(line, es_default26(line, truncatedSplitter));
  10093. }
  10094. }
  10095. function splitLineWithPoints(line, splitter) {
  10096. var results = [];
  10097. var tree = (0, import_geojson_rbush2.default)();
  10098. flattenEach(splitter, function(point4) {
  10099. results.forEach(function(feature2, index2) {
  10100. feature2.id = index2;
  10101. });
  10102. if (!results.length) {
  10103. results = splitLineWithPoint(line, point4).features;
  10104. results.forEach(function(feature2) {
  10105. if (!feature2.bbox)
  10106. feature2.bbox = es_default15(es_default(feature2));
  10107. });
  10108. tree.load(featureCollection(results));
  10109. } else {
  10110. var search = tree.search(point4);
  10111. if (search.features.length) {
  10112. var closestLine = findClosestFeature(point4, search);
  10113. results = results.filter(function(feature2) {
  10114. return feature2.id !== closestLine.id;
  10115. });
  10116. tree.remove(closestLine);
  10117. featureEach(splitLineWithPoint(closestLine, point4), function(line2) {
  10118. results.push(line2);
  10119. tree.insert(line2);
  10120. });
  10121. }
  10122. }
  10123. });
  10124. return featureCollection(results);
  10125. }
  10126. function splitLineWithPoint(line, splitter) {
  10127. var results = [];
  10128. var startPoint = getCoords(line)[0];
  10129. var endPoint = getCoords(line)[line.geometry.coordinates.length - 1];
  10130. if (pointsEquals(startPoint, getCoord(splitter)) || pointsEquals(endPoint, getCoord(splitter)))
  10131. return featureCollection([line]);
  10132. var tree = (0, import_geojson_rbush2.default)();
  10133. var segments = es_default25(line);
  10134. tree.load(segments);
  10135. var search = tree.search(splitter);
  10136. if (!search.features.length)
  10137. return featureCollection([line]);
  10138. var closestSegment = findClosestFeature(splitter, search);
  10139. var initialValue = [startPoint];
  10140. var lastCoords = featureReduce(
  10141. segments,
  10142. function(previous, current, index2) {
  10143. var currentCoords = getCoords(current)[1];
  10144. var splitterCoords = getCoord(splitter);
  10145. if (index2 === closestSegment.id) {
  10146. previous.push(splitterCoords);
  10147. results.push(lineString(previous));
  10148. if (pointsEquals(splitterCoords, currentCoords))
  10149. return [splitterCoords];
  10150. return [splitterCoords, currentCoords];
  10151. } else {
  10152. previous.push(currentCoords);
  10153. return previous;
  10154. }
  10155. },
  10156. initialValue
  10157. );
  10158. if (lastCoords.length > 1) {
  10159. results.push(lineString(lastCoords));
  10160. }
  10161. return featureCollection(results);
  10162. }
  10163. function findClosestFeature(point4, lines) {
  10164. if (!lines.features.length)
  10165. throw new Error("lines must contain features");
  10166. if (lines.features.length === 1)
  10167. return lines.features[0];
  10168. var closestFeature;
  10169. var closestDistance = Infinity;
  10170. featureEach(lines, function(segment) {
  10171. var pt = es_default27(segment, point4);
  10172. var dist = pt.properties.dist;
  10173. if (dist < closestDistance) {
  10174. closestFeature = segment;
  10175. closestDistance = dist;
  10176. }
  10177. });
  10178. return closestFeature;
  10179. }
  10180. function pointsEquals(pt1, pt2) {
  10181. return pt1[0] === pt2[0] && pt1[1] === pt2[1];
  10182. }
  10183. var es_default43 = lineSplit;
  10184. // node_modules/@turf/line-arc/dist/es/index.js
  10185. function lineArc(center2, radius, bearing1, bearing2, options) {
  10186. if (options === void 0) {
  10187. options = {};
  10188. }
  10189. var steps = options.steps || 64;
  10190. var angle1 = convertAngleTo360(bearing1);
  10191. var angle22 = convertAngleTo360(bearing2);
  10192. var properties = !Array.isArray(center2) && center2.type === "Feature" ? center2.properties : {};
  10193. if (angle1 === angle22) {
  10194. return lineString(es_default16(center2, radius, options).geometry.coordinates[0], properties);
  10195. }
  10196. var arcStartDegree = angle1;
  10197. var arcEndDegree = angle1 < angle22 ? angle22 : angle22 + 360;
  10198. var alfa = arcStartDegree;
  10199. var coordinates = [];
  10200. var i = 0;
  10201. while (alfa < arcEndDegree) {
  10202. coordinates.push(destination(center2, radius, alfa, options).geometry.coordinates);
  10203. i++;
  10204. alfa = arcStartDegree + i * 360 / steps;
  10205. }
  10206. if (alfa > arcEndDegree) {
  10207. coordinates.push(destination(center2, radius, arcEndDegree, options).geometry.coordinates);
  10208. }
  10209. return lineString(coordinates, properties);
  10210. }
  10211. function convertAngleTo360(alfa) {
  10212. var beta = alfa % 360;
  10213. if (beta < 0) {
  10214. beta += 360;
  10215. }
  10216. return beta;
  10217. }
  10218. // node_modules/@turf/polygon-to-line/dist/es/index.js
  10219. function es_default44(poly, options) {
  10220. if (options === void 0) {
  10221. options = {};
  10222. }
  10223. var geom = getGeom(poly);
  10224. if (!options.properties && poly.type === "Feature") {
  10225. options.properties = poly.properties;
  10226. }
  10227. switch (geom.type) {
  10228. case "Polygon":
  10229. return polygonToLine(geom, options);
  10230. case "MultiPolygon":
  10231. return multiPolygonToLine(geom, options);
  10232. default:
  10233. throw new Error("invalid poly");
  10234. }
  10235. }
  10236. function polygonToLine(poly, options) {
  10237. if (options === void 0) {
  10238. options = {};
  10239. }
  10240. var geom = getGeom(poly);
  10241. var coords = geom.coordinates;
  10242. var properties = options.properties ? options.properties : poly.type === "Feature" ? poly.properties : {};
  10243. return coordsToLine(coords, properties);
  10244. }
  10245. function multiPolygonToLine(multiPoly, options) {
  10246. if (options === void 0) {
  10247. options = {};
  10248. }
  10249. var geom = getGeom(multiPoly);
  10250. var coords = geom.coordinates;
  10251. var properties = options.properties ? options.properties : multiPoly.type === "Feature" ? multiPoly.properties : {};
  10252. var lines = [];
  10253. coords.forEach(function(coord) {
  10254. lines.push(coordsToLine(coord, properties));
  10255. });
  10256. return featureCollection(lines);
  10257. }
  10258. function coordsToLine(coords, properties) {
  10259. if (coords.length > 1) {
  10260. return multiLineString(coords, properties);
  10261. }
  10262. return lineString(coords[0], properties);
  10263. }
  10264. // node_modules/@turf/line-to-polygon/dist/es/index.js
  10265. function lineToPolygon(lines, options) {
  10266. if (options === void 0) {
  10267. options = {};
  10268. }
  10269. var _a, _b, _c;
  10270. var properties = options.properties;
  10271. var autoComplete = (_a = options.autoComplete) !== null && _a !== void 0 ? _a : true;
  10272. var orderCoords = (_b = options.orderCoords) !== null && _b !== void 0 ? _b : true;
  10273. var mutate = (_c = options.mutate) !== null && _c !== void 0 ? _c : false;
  10274. if (!mutate) {
  10275. lines = es_default5(lines);
  10276. }
  10277. switch (lines.type) {
  10278. case "FeatureCollection":
  10279. var coords = [];
  10280. lines.features.forEach(function(line) {
  10281. coords.push(getCoords(lineStringToPolygon(line, {}, autoComplete, orderCoords)));
  10282. });
  10283. return multiPolygon(coords, properties);
  10284. default:
  10285. return lineStringToPolygon(lines, properties, autoComplete, orderCoords);
  10286. }
  10287. }
  10288. function lineStringToPolygon(line, properties, autoComplete, orderCoords) {
  10289. properties = properties ? properties : line.type === "Feature" ? line.properties : {};
  10290. var geom = getGeom(line);
  10291. var coords = geom.coordinates;
  10292. var type = geom.type;
  10293. if (!coords.length)
  10294. throw new Error("line must contain coordinates");
  10295. switch (type) {
  10296. case "LineString":
  10297. if (autoComplete)
  10298. coords = autoCompleteCoords(coords);
  10299. return polygon([coords], properties);
  10300. case "MultiLineString":
  10301. var multiCoords = [];
  10302. var largestArea = 0;
  10303. coords.forEach(function(coord) {
  10304. if (autoComplete)
  10305. coord = autoCompleteCoords(coord);
  10306. if (orderCoords) {
  10307. var area5 = calculateArea2(es_default(lineString(coord)));
  10308. if (area5 > largestArea) {
  10309. multiCoords.unshift(coord);
  10310. largestArea = area5;
  10311. } else
  10312. multiCoords.push(coord);
  10313. } else {
  10314. multiCoords.push(coord);
  10315. }
  10316. });
  10317. return polygon(multiCoords, properties);
  10318. default:
  10319. throw new Error("geometry type " + type + " is not supported");
  10320. }
  10321. }
  10322. function autoCompleteCoords(coords) {
  10323. var first = coords[0];
  10324. var x12 = first[0];
  10325. var y12 = first[1];
  10326. var last = coords[coords.length - 1];
  10327. var x2 = last[0];
  10328. var y2 = last[1];
  10329. if (x12 !== x2 || y12 !== y2) {
  10330. coords.push(first);
  10331. }
  10332. return coords;
  10333. }
  10334. function calculateArea2(bbox3) {
  10335. var west = bbox3[0];
  10336. var south = bbox3[1];
  10337. var east = bbox3[2];
  10338. var north = bbox3[3];
  10339. return Math.abs(west - east) * Math.abs(south - north);
  10340. }
  10341. var es_default45 = lineToPolygon;
  10342. // node_modules/@turf/bbox-clip/dist/es/lib/lineclip.js
  10343. function lineclip(points2, bbox3, result) {
  10344. var len = points2.length, codeA = bitCode(points2[0], bbox3), part = [], i, codeB, lastCode;
  10345. var a;
  10346. var b;
  10347. if (!result)
  10348. result = [];
  10349. for (i = 1; i < len; i++) {
  10350. a = points2[i - 1];
  10351. b = points2[i];
  10352. codeB = lastCode = bitCode(b, bbox3);
  10353. while (true) {
  10354. if (!(codeA | codeB)) {
  10355. part.push(a);
  10356. if (codeB !== lastCode) {
  10357. part.push(b);
  10358. if (i < len - 1) {
  10359. result.push(part);
  10360. part = [];
  10361. }
  10362. } else if (i === len - 1) {
  10363. part.push(b);
  10364. }
  10365. break;
  10366. } else if (codeA & codeB) {
  10367. break;
  10368. } else if (codeA) {
  10369. a = intersect2(a, b, codeA, bbox3);
  10370. codeA = bitCode(a, bbox3);
  10371. } else {
  10372. b = intersect2(a, b, codeB, bbox3);
  10373. codeB = bitCode(b, bbox3);
  10374. }
  10375. }
  10376. codeA = lastCode;
  10377. }
  10378. if (part.length)
  10379. result.push(part);
  10380. return result;
  10381. }
  10382. function polygonclip(points2, bbox3) {
  10383. var result, edge, prev, prevInside, i, p, inside;
  10384. for (edge = 1; edge <= 8; edge *= 2) {
  10385. result = [];
  10386. prev = points2[points2.length - 1];
  10387. prevInside = !(bitCode(prev, bbox3) & edge);
  10388. for (i = 0; i < points2.length; i++) {
  10389. p = points2[i];
  10390. inside = !(bitCode(p, bbox3) & edge);
  10391. if (inside !== prevInside)
  10392. result.push(intersect2(prev, p, edge, bbox3));
  10393. if (inside)
  10394. result.push(p);
  10395. prev = p;
  10396. prevInside = inside;
  10397. }
  10398. points2 = result;
  10399. if (!points2.length)
  10400. break;
  10401. }
  10402. return result;
  10403. }
  10404. function intersect2(a, b, edge, bbox3) {
  10405. return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox3[3] - a[1]) / (b[1] - a[1]), bbox3[3]] : edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox3[1] - a[1]) / (b[1] - a[1]), bbox3[1]] : edge & 2 ? [bbox3[2], a[1] + (b[1] - a[1]) * (bbox3[2] - a[0]) / (b[0] - a[0])] : edge & 1 ? [bbox3[0], a[1] + (b[1] - a[1]) * (bbox3[0] - a[0]) / (b[0] - a[0])] : null;
  10406. }
  10407. function bitCode(p, bbox3) {
  10408. var code = 0;
  10409. if (p[0] < bbox3[0])
  10410. code |= 1;
  10411. else if (p[0] > bbox3[2])
  10412. code |= 2;
  10413. if (p[1] < bbox3[1])
  10414. code |= 4;
  10415. else if (p[1] > bbox3[3])
  10416. code |= 8;
  10417. return code;
  10418. }
  10419. // node_modules/@turf/bbox-clip/dist/es/index.js
  10420. function bboxClip(feature2, bbox3) {
  10421. var geom = getGeom(feature2);
  10422. var type = geom.type;
  10423. var properties = feature2.type === "Feature" ? feature2.properties : {};
  10424. var coords = geom.coordinates;
  10425. switch (type) {
  10426. case "LineString":
  10427. case "MultiLineString": {
  10428. var lines_1 = [];
  10429. if (type === "LineString") {
  10430. coords = [coords];
  10431. }
  10432. coords.forEach(function(line) {
  10433. lineclip(line, bbox3, lines_1);
  10434. });
  10435. if (lines_1.length === 1) {
  10436. return lineString(lines_1[0], properties);
  10437. }
  10438. return multiLineString(lines_1, properties);
  10439. }
  10440. case "Polygon":
  10441. return polygon(clipPolygon(coords, bbox3), properties);
  10442. case "MultiPolygon":
  10443. return multiPolygon(coords.map(function(poly) {
  10444. return clipPolygon(poly, bbox3);
  10445. }), properties);
  10446. default:
  10447. throw new Error("geometry " + type + " not supported");
  10448. }
  10449. }
  10450. function clipPolygon(rings, bbox3) {
  10451. var outRings = [];
  10452. for (var _i = 0, rings_1 = rings; _i < rings_1.length; _i++) {
  10453. var ring = rings_1[_i];
  10454. var clipped = polygonclip(ring, bbox3);
  10455. if (clipped.length > 0) {
  10456. if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
  10457. clipped.push(clipped[0]);
  10458. }
  10459. if (clipped.length >= 4) {
  10460. outRings.push(clipped);
  10461. }
  10462. }
  10463. }
  10464. return outRings;
  10465. }
  10466. // node_modules/@turf/line-overlap/dist/es/index.js
  10467. var import_geojson_rbush3 = __toESM(require_geojson_rbush());
  10468. var import_deep_equal = __toESM(require_deep_equal());
  10469. function lineOverlap(line1, line2, options) {
  10470. if (options === void 0) {
  10471. options = {};
  10472. }
  10473. options = options || {};
  10474. if (!isObject(options))
  10475. throw new Error("options is invalid");
  10476. var tolerance = options.tolerance || 0;
  10477. var features = [];
  10478. var tree = (0, import_geojson_rbush3.default)();
  10479. var line = es_default25(line1);
  10480. tree.load(line);
  10481. var overlapSegment;
  10482. segmentEach(line2, function(segment) {
  10483. var doesOverlaps = false;
  10484. if (!segment) {
  10485. return;
  10486. }
  10487. featureEach(tree.search(segment), function(match) {
  10488. if (doesOverlaps === false) {
  10489. var coordsSegment = getCoords(segment).sort();
  10490. var coordsMatch = getCoords(match).sort();
  10491. if ((0, import_deep_equal.default)(coordsSegment, coordsMatch)) {
  10492. doesOverlaps = true;
  10493. if (overlapSegment)
  10494. overlapSegment = concatSegment(overlapSegment, segment);
  10495. else
  10496. overlapSegment = segment;
  10497. } else if (tolerance === 0 ? es_default35(coordsSegment[0], match) && es_default35(coordsSegment[1], match) : es_default27(match, coordsSegment[0]).properties.dist <= tolerance && es_default27(match, coordsSegment[1]).properties.dist <= tolerance) {
  10498. doesOverlaps = true;
  10499. if (overlapSegment)
  10500. overlapSegment = concatSegment(overlapSegment, segment);
  10501. else
  10502. overlapSegment = segment;
  10503. } else if (tolerance === 0 ? es_default35(coordsMatch[0], segment) && es_default35(coordsMatch[1], segment) : es_default27(segment, coordsMatch[0]).properties.dist <= tolerance && es_default27(segment, coordsMatch[1]).properties.dist <= tolerance) {
  10504. if (overlapSegment)
  10505. overlapSegment = concatSegment(overlapSegment, match);
  10506. else
  10507. overlapSegment = match;
  10508. }
  10509. }
  10510. });
  10511. if (doesOverlaps === false && overlapSegment) {
  10512. features.push(overlapSegment);
  10513. overlapSegment = void 0;
  10514. }
  10515. });
  10516. if (overlapSegment)
  10517. features.push(overlapSegment);
  10518. return featureCollection(features);
  10519. }
  10520. function concatSegment(line, segment) {
  10521. var coords = getCoords(segment);
  10522. var lineCoords = getCoords(line);
  10523. var start = lineCoords[0];
  10524. var end = lineCoords[lineCoords.length - 1];
  10525. var geom = line.geometry.coordinates;
  10526. if ((0, import_deep_equal.default)(coords[0], start))
  10527. geom.unshift(coords[1]);
  10528. else if ((0, import_deep_equal.default)(coords[0], end))
  10529. geom.push(coords[1]);
  10530. else if ((0, import_deep_equal.default)(coords[1], start))
  10531. geom.unshift(coords[0]);
  10532. else if ((0, import_deep_equal.default)(coords[1], end))
  10533. geom.push(coords[0]);
  10534. return line;
  10535. }
  10536. var es_default46 = lineOverlap;
  10537. // node_modules/@turf/sector/dist/es/index.js
  10538. function sector(center2, radius, bearing1, bearing2, options) {
  10539. options = options || {};
  10540. if (!isObject(options))
  10541. throw new Error("options is invalid");
  10542. var properties = options.properties;
  10543. if (!center2)
  10544. throw new Error("center is required");
  10545. if (bearing1 === void 0 || bearing1 === null)
  10546. throw new Error("bearing1 is required");
  10547. if (bearing2 === void 0 || bearing2 === null)
  10548. throw new Error("bearing2 is required");
  10549. if (!radius)
  10550. throw new Error("radius is required");
  10551. if (typeof options !== "object")
  10552. throw new Error("options must be an object");
  10553. if (convertAngleTo3602(bearing1) === convertAngleTo3602(bearing2)) {
  10554. return es_default16(center2, radius, options);
  10555. }
  10556. var coords = getCoords(center2);
  10557. var arc = lineArc(center2, radius, bearing1, bearing2, options);
  10558. var sliceCoords = [[coords]];
  10559. coordEach(arc, function(currentCoords) {
  10560. sliceCoords[0].push(currentCoords);
  10561. });
  10562. sliceCoords[0].push(coords);
  10563. return polygon(sliceCoords, properties);
  10564. }
  10565. function convertAngleTo3602(alfa) {
  10566. var beta = alfa % 360;
  10567. if (beta < 0)
  10568. beta += 360;
  10569. return beta;
  10570. }
  10571. var es_default47 = sector;
  10572. // node_modules/@turf/rhumb-bearing/dist/es/index.js
  10573. function rhumbBearing(start, end, options) {
  10574. if (options === void 0) {
  10575. options = {};
  10576. }
  10577. var bear360;
  10578. if (options.final) {
  10579. bear360 = calculateRhumbBearing(getCoord(end), getCoord(start));
  10580. } else {
  10581. bear360 = calculateRhumbBearing(getCoord(start), getCoord(end));
  10582. }
  10583. var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
  10584. return bear180;
  10585. }
  10586. function calculateRhumbBearing(from, to) {
  10587. var phi1 = degreesToRadians(from[1]);
  10588. var phi2 = degreesToRadians(to[1]);
  10589. var deltaLambda = degreesToRadians(to[0] - from[0]);
  10590. if (deltaLambda > Math.PI) {
  10591. deltaLambda -= 2 * Math.PI;
  10592. }
  10593. if (deltaLambda < -Math.PI) {
  10594. deltaLambda += 2 * Math.PI;
  10595. }
  10596. var deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
  10597. var theta = Math.atan2(deltaLambda, deltaPsi);
  10598. return (radiansToDegrees(theta) + 360) % 360;
  10599. }
  10600. var es_default48 = rhumbBearing;
  10601. // node_modules/@turf/rhumb-destination/dist/es/index.js
  10602. function rhumbDestination(origin, distance11, bearing2, options) {
  10603. if (options === void 0) {
  10604. options = {};
  10605. }
  10606. var wasNegativeDistance = distance11 < 0;
  10607. var distanceInMeters = convertLength(Math.abs(distance11), options.units, "meters");
  10608. if (wasNegativeDistance)
  10609. distanceInMeters = -Math.abs(distanceInMeters);
  10610. var coords = getCoord(origin);
  10611. var destination2 = calculateRhumbDestination(coords, distanceInMeters, bearing2);
  10612. destination2[0] += destination2[0] - coords[0] > 180 ? -360 : coords[0] - destination2[0] > 180 ? 360 : 0;
  10613. return point(destination2, options.properties);
  10614. }
  10615. function calculateRhumbDestination(origin, distance11, bearing2, radius) {
  10616. radius = radius === void 0 ? earthRadius : Number(radius);
  10617. var delta = distance11 / radius;
  10618. var lambda1 = origin[0] * Math.PI / 180;
  10619. var phi1 = degreesToRadians(origin[1]);
  10620. var theta = degreesToRadians(bearing2);
  10621. var DeltaPhi = delta * Math.cos(theta);
  10622. var phi2 = phi1 + DeltaPhi;
  10623. if (Math.abs(phi2) > Math.PI / 2) {
  10624. phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;
  10625. }
  10626. var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
  10627. var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
  10628. var DeltaLambda = delta * Math.sin(theta) / q;
  10629. var lambda2 = lambda1 + DeltaLambda;
  10630. return [
  10631. (lambda2 * 180 / Math.PI + 540) % 360 - 180,
  10632. phi2 * 180 / Math.PI
  10633. ];
  10634. }
  10635. var es_default49 = rhumbDestination;
  10636. // node_modules/@turf/polygon-tangents/dist/es/index.js
  10637. function polygonTangents(pt, polygon4) {
  10638. var pointCoords = getCoords(pt);
  10639. var polyCoords = getCoords(polygon4);
  10640. var rtan;
  10641. var ltan;
  10642. var enext;
  10643. var eprev;
  10644. var bbox3 = es_default(polygon4);
  10645. var nearestPtIndex = 0;
  10646. var nearest = null;
  10647. if (pointCoords[0] > bbox3[0] && pointCoords[0] < bbox3[2] && pointCoords[1] > bbox3[1] && pointCoords[1] < bbox3[3]) {
  10648. nearest = es_default24(pt, es_default22(polygon4));
  10649. nearestPtIndex = nearest.properties.featureIndex;
  10650. }
  10651. var type = getType(polygon4);
  10652. switch (type) {
  10653. case "Polygon":
  10654. rtan = polyCoords[0][nearestPtIndex];
  10655. ltan = polyCoords[0][0];
  10656. if (nearest !== null) {
  10657. if (nearest.geometry.coordinates[1] < pointCoords[1])
  10658. ltan = polyCoords[0][nearestPtIndex];
  10659. }
  10660. eprev = isLeft(
  10661. polyCoords[0][0],
  10662. polyCoords[0][polyCoords[0].length - 1],
  10663. pointCoords
  10664. );
  10665. var out = processPolygon2(
  10666. polyCoords[0],
  10667. pointCoords,
  10668. eprev,
  10669. enext,
  10670. rtan,
  10671. ltan
  10672. );
  10673. rtan = out[0];
  10674. ltan = out[1];
  10675. break;
  10676. case "MultiPolygon":
  10677. var closestFeature = 0;
  10678. var closestVertex = 0;
  10679. var verticesCounted = 0;
  10680. for (var i = 0; i < polyCoords[0].length; i++) {
  10681. closestFeature = i;
  10682. var verticeFound = false;
  10683. for (var i2 = 0; i2 < polyCoords[0][i].length; i2++) {
  10684. closestVertex = i2;
  10685. if (verticesCounted === nearestPtIndex) {
  10686. verticeFound = true;
  10687. break;
  10688. }
  10689. verticesCounted++;
  10690. }
  10691. if (verticeFound)
  10692. break;
  10693. }
  10694. rtan = polyCoords[0][closestFeature][closestVertex];
  10695. ltan = polyCoords[0][closestFeature][closestVertex];
  10696. eprev = isLeft(
  10697. polyCoords[0][0][0],
  10698. polyCoords[0][0][polyCoords[0][0].length - 1],
  10699. pointCoords
  10700. );
  10701. polyCoords.forEach(function(ring) {
  10702. var out2 = processPolygon2(
  10703. ring[0],
  10704. pointCoords,
  10705. eprev,
  10706. enext,
  10707. rtan,
  10708. ltan
  10709. );
  10710. rtan = out2[0];
  10711. ltan = out2[1];
  10712. });
  10713. break;
  10714. }
  10715. return featureCollection([point(rtan), point(ltan)]);
  10716. }
  10717. function processPolygon2(polygonCoords, ptCoords, eprev, enext, rtan, ltan) {
  10718. for (var i = 0; i < polygonCoords.length; i++) {
  10719. var currentCoords = polygonCoords[i];
  10720. var nextCoordPair = polygonCoords[i + 1];
  10721. if (i === polygonCoords.length - 1) {
  10722. nextCoordPair = polygonCoords[0];
  10723. }
  10724. enext = isLeft(currentCoords, nextCoordPair, ptCoords);
  10725. if (eprev <= 0 && enext > 0) {
  10726. if (!isBelow(ptCoords, currentCoords, rtan)) {
  10727. rtan = currentCoords;
  10728. }
  10729. } else if (eprev > 0 && enext <= 0) {
  10730. if (!isAbove(ptCoords, currentCoords, ltan)) {
  10731. ltan = currentCoords;
  10732. }
  10733. }
  10734. eprev = enext;
  10735. }
  10736. return [rtan, ltan];
  10737. }
  10738. function isAbove(point1, point22, point32) {
  10739. return isLeft(point1, point22, point32) > 0;
  10740. }
  10741. function isBelow(point1, point22, point32) {
  10742. return isLeft(point1, point22, point32) < 0;
  10743. }
  10744. function isLeft(point1, point22, point32) {
  10745. return (point22[0] - point1[0]) * (point32[1] - point1[1]) - (point32[0] - point1[0]) * (point22[1] - point1[1]);
  10746. }
  10747. var es_default50 = polygonTangents;
  10748. // node_modules/@turf/boolean-clockwise/dist/es/index.js
  10749. function booleanClockwise(line) {
  10750. var ring = getCoords(line);
  10751. var sum2 = 0;
  10752. var i = 1;
  10753. var prev;
  10754. var cur;
  10755. while (i < ring.length) {
  10756. prev = cur || ring[0];
  10757. cur = ring[i];
  10758. sum2 += (cur[0] - prev[0]) * (cur[1] + prev[1]);
  10759. i++;
  10760. }
  10761. return sum2 > 0;
  10762. }
  10763. // node_modules/@turf/rewind/dist/es/index.js
  10764. function rewind(geojson, options) {
  10765. options = options || {};
  10766. if (!isObject(options))
  10767. throw new Error("options is invalid");
  10768. var reverse5 = options.reverse || false;
  10769. var mutate = options.mutate || false;
  10770. if (!geojson)
  10771. throw new Error("<geojson> is required");
  10772. if (typeof reverse5 !== "boolean")
  10773. throw new Error("<reverse> must be a boolean");
  10774. if (typeof mutate !== "boolean")
  10775. throw new Error("<mutate> must be a boolean");
  10776. if (mutate === false)
  10777. geojson = es_default5(geojson);
  10778. var results = [];
  10779. switch (geojson.type) {
  10780. case "GeometryCollection":
  10781. geomEach(geojson, function(geometry2) {
  10782. rewindFeature(geometry2, reverse5);
  10783. });
  10784. return geojson;
  10785. case "FeatureCollection":
  10786. featureEach(geojson, function(feature2) {
  10787. featureEach(rewindFeature(feature2, reverse5), function(result) {
  10788. results.push(result);
  10789. });
  10790. });
  10791. return featureCollection(results);
  10792. }
  10793. return rewindFeature(geojson, reverse5);
  10794. }
  10795. function rewindFeature(geojson, reverse5) {
  10796. var type = geojson.type === "Feature" ? geojson.geometry.type : geojson.type;
  10797. switch (type) {
  10798. case "GeometryCollection":
  10799. geomEach(geojson, function(geometry2) {
  10800. rewindFeature(geometry2, reverse5);
  10801. });
  10802. return geojson;
  10803. case "LineString":
  10804. rewindLineString(getCoords(geojson), reverse5);
  10805. return geojson;
  10806. case "Polygon":
  10807. rewindPolygon(getCoords(geojson), reverse5);
  10808. return geojson;
  10809. case "MultiLineString":
  10810. getCoords(geojson).forEach(function(lineCoords) {
  10811. rewindLineString(lineCoords, reverse5);
  10812. });
  10813. return geojson;
  10814. case "MultiPolygon":
  10815. getCoords(geojson).forEach(function(lineCoords) {
  10816. rewindPolygon(lineCoords, reverse5);
  10817. });
  10818. return geojson;
  10819. case "Point":
  10820. case "MultiPoint":
  10821. return geojson;
  10822. }
  10823. }
  10824. function rewindLineString(coords, reverse5) {
  10825. if (booleanClockwise(coords) === reverse5)
  10826. coords.reverse();
  10827. }
  10828. function rewindPolygon(coords, reverse5) {
  10829. if (booleanClockwise(coords[0]) !== reverse5) {
  10830. coords[0].reverse();
  10831. }
  10832. for (var i = 1; i < coords.length; i++) {
  10833. if (booleanClockwise(coords[i]) === reverse5) {
  10834. coords[i].reverse();
  10835. }
  10836. }
  10837. }
  10838. var es_default51 = rewind;
  10839. // node_modules/@turf/isobands/dist/es/index.js
  10840. var import_object_assign3 = __toESM(require_object_assign());
  10841. function gridToMatrix2(grid, options) {
  10842. options = options || {};
  10843. if (!isObject(options))
  10844. throw new Error("options is invalid");
  10845. var zProperty = options.zProperty || "elevation";
  10846. var flip4 = options.flip;
  10847. var flags = options.flags;
  10848. collectionOf(grid, "Point", "input must contain Points");
  10849. var pointsMatrix = sortPointsByLatLng2(grid, flip4);
  10850. var matrix = [];
  10851. for (var r = 0; r < pointsMatrix.length; r++) {
  10852. var pointRow = pointsMatrix[r];
  10853. var row = [];
  10854. for (var c = 0; c < pointRow.length; c++) {
  10855. var point4 = pointRow[c];
  10856. if (point4.properties[zProperty])
  10857. row.push(point4.properties[zProperty]);
  10858. else
  10859. row.push(0);
  10860. if (flags === true)
  10861. point4.properties.matrixPosition = [r, c];
  10862. }
  10863. matrix.push(row);
  10864. }
  10865. return matrix;
  10866. }
  10867. function sortPointsByLatLng2(points2, flip4) {
  10868. var pointsByLatitude = {};
  10869. featureEach(points2, function(point4) {
  10870. var lat2 = getCoords(point4)[1];
  10871. if (!pointsByLatitude[lat2])
  10872. pointsByLatitude[lat2] = [];
  10873. pointsByLatitude[lat2].push(point4);
  10874. });
  10875. var orderedRowsByLatitude = Object.keys(pointsByLatitude).map(function(lat2) {
  10876. var row = pointsByLatitude[lat2];
  10877. var rowOrderedByLongitude = row.sort(function(a, b) {
  10878. return getCoords(a)[0] - getCoords(b)[0];
  10879. });
  10880. return rowOrderedByLongitude;
  10881. });
  10882. var pointMatrix = orderedRowsByLatitude.sort(function(a, b) {
  10883. if (flip4)
  10884. return getCoords(a[0])[1] - getCoords(b[0])[1];
  10885. else
  10886. return getCoords(b[0])[1] - getCoords(a[0])[1];
  10887. });
  10888. return pointMatrix;
  10889. }
  10890. var defaultSettings2 = {
  10891. successCallback: null,
  10892. verbose: false,
  10893. polygons: false
  10894. };
  10895. var settings2 = {};
  10896. function isoBands(data, minV, bandwidth, options) {
  10897. options = options ? options : {};
  10898. var optionKeys = Object.keys(defaultSettings2);
  10899. for (var i = 0; i < optionKeys.length; i++) {
  10900. var key = optionKeys[i];
  10901. var val = options[key];
  10902. val = typeof val !== "undefined" && val !== null ? val : defaultSettings2[key];
  10903. settings2[key] = val;
  10904. }
  10905. if (settings2.verbose)
  10906. console.log(
  10907. "MarchingSquaresJS-isoBands: computing isobands for [" + minV + ":" + (minV + bandwidth) + "]"
  10908. );
  10909. var grid = computeBandGrid(data, minV, bandwidth);
  10910. var ret;
  10911. if (settings2.polygons) {
  10912. if (settings2.verbose)
  10913. console.log(
  10914. "MarchingSquaresJS-isoBands: returning single polygons for each grid cell"
  10915. );
  10916. ret = BandGrid2Areas(grid);
  10917. } else {
  10918. if (settings2.verbose)
  10919. console.log(
  10920. "MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"
  10921. );
  10922. ret = BandGrid2AreaPaths(grid);
  10923. }
  10924. if (typeof settings2.successCallback === "function")
  10925. settings2.successCallback(ret);
  10926. return ret;
  10927. }
  10928. var Node0 = 64;
  10929. var Node1 = 16;
  10930. var Node2 = 4;
  10931. var Node3 = 1;
  10932. var isoBandNextXTL = [];
  10933. var isoBandNextYTL = [];
  10934. var isoBandNextOTL = [];
  10935. var isoBandNextXTR = [];
  10936. var isoBandNextYTR = [];
  10937. var isoBandNextOTR = [];
  10938. var isoBandNextXRT = [];
  10939. var isoBandNextYRT = [];
  10940. var isoBandNextORT = [];
  10941. var isoBandNextXRB = [];
  10942. var isoBandNextYRB = [];
  10943. var isoBandNextORB = [];
  10944. var isoBandNextXBL = [];
  10945. var isoBandNextYBL = [];
  10946. var isoBandNextOBL = [];
  10947. var isoBandNextXBR = [];
  10948. var isoBandNextYBR = [];
  10949. var isoBandNextOBR = [];
  10950. var isoBandNextXLT = [];
  10951. var isoBandNextYLT = [];
  10952. var isoBandNextOLT = [];
  10953. var isoBandNextXLB = [];
  10954. var isoBandNextYLB = [];
  10955. var isoBandNextOLB = [];
  10956. isoBandNextXRT[85] = isoBandNextXRB[85] = -1;
  10957. isoBandNextYRT[85] = isoBandNextYRB[85] = 0;
  10958. isoBandNextORT[85] = isoBandNextORB[85] = 1;
  10959. isoBandNextXLT[85] = isoBandNextXLB[85] = 1;
  10960. isoBandNextYLT[85] = isoBandNextYLB[85] = 0;
  10961. isoBandNextOLT[85] = isoBandNextOLB[85] = 1;
  10962. isoBandNextXTL[85] = isoBandNextXTR[85] = 0;
  10963. isoBandNextYTL[85] = isoBandNextYTR[85] = -1;
  10964. isoBandNextOTL[85] = isoBandNextOBL[85] = 0;
  10965. isoBandNextXBR[85] = isoBandNextXBL[85] = 0;
  10966. isoBandNextYBR[85] = isoBandNextYBL[85] = 1;
  10967. isoBandNextOTR[85] = isoBandNextOBR[85] = 1;
  10968. isoBandNextXLB[1] = isoBandNextXLB[169] = 0;
  10969. isoBandNextYLB[1] = isoBandNextYLB[169] = -1;
  10970. isoBandNextOLB[1] = isoBandNextOLB[169] = 0;
  10971. isoBandNextXBL[1] = isoBandNextXBL[169] = -1;
  10972. isoBandNextYBL[1] = isoBandNextYBL[169] = 0;
  10973. isoBandNextOBL[1] = isoBandNextOBL[169] = 0;
  10974. isoBandNextXRB[4] = isoBandNextXRB[166] = 0;
  10975. isoBandNextYRB[4] = isoBandNextYRB[166] = -1;
  10976. isoBandNextORB[4] = isoBandNextORB[166] = 1;
  10977. isoBandNextXBR[4] = isoBandNextXBR[166] = 1;
  10978. isoBandNextYBR[4] = isoBandNextYBR[166] = 0;
  10979. isoBandNextOBR[4] = isoBandNextOBR[166] = 0;
  10980. isoBandNextXRT[16] = isoBandNextXRT[154] = 0;
  10981. isoBandNextYRT[16] = isoBandNextYRT[154] = 1;
  10982. isoBandNextORT[16] = isoBandNextORT[154] = 1;
  10983. isoBandNextXTR[16] = isoBandNextXTR[154] = 1;
  10984. isoBandNextYTR[16] = isoBandNextYTR[154] = 0;
  10985. isoBandNextOTR[16] = isoBandNextOTR[154] = 1;
  10986. isoBandNextXLT[64] = isoBandNextXLT[106] = 0;
  10987. isoBandNextYLT[64] = isoBandNextYLT[106] = 1;
  10988. isoBandNextOLT[64] = isoBandNextOLT[106] = 0;
  10989. isoBandNextXTL[64] = isoBandNextXTL[106] = -1;
  10990. isoBandNextYTL[64] = isoBandNextYTL[106] = 0;
  10991. isoBandNextOTL[64] = isoBandNextOTL[106] = 1;
  10992. isoBandNextXLT[2] = isoBandNextXLT[168] = 0;
  10993. isoBandNextYLT[2] = isoBandNextYLT[168] = -1;
  10994. isoBandNextOLT[2] = isoBandNextOLT[168] = 1;
  10995. isoBandNextXLB[2] = isoBandNextXLB[168] = 0;
  10996. isoBandNextYLB[2] = isoBandNextYLB[168] = -1;
  10997. isoBandNextOLB[2] = isoBandNextOLB[168] = 0;
  10998. isoBandNextXBL[2] = isoBandNextXBL[168] = -1;
  10999. isoBandNextYBL[2] = isoBandNextYBL[168] = 0;
  11000. isoBandNextOBL[2] = isoBandNextOBL[168] = 0;
  11001. isoBandNextXBR[2] = isoBandNextXBR[168] = -1;
  11002. isoBandNextYBR[2] = isoBandNextYBR[168] = 0;
  11003. isoBandNextOBR[2] = isoBandNextOBR[168] = 1;
  11004. isoBandNextXRT[8] = isoBandNextXRT[162] = 0;
  11005. isoBandNextYRT[8] = isoBandNextYRT[162] = -1;
  11006. isoBandNextORT[8] = isoBandNextORT[162] = 0;
  11007. isoBandNextXRB[8] = isoBandNextXRB[162] = 0;
  11008. isoBandNextYRB[8] = isoBandNextYRB[162] = -1;
  11009. isoBandNextORB[8] = isoBandNextORB[162] = 1;
  11010. isoBandNextXBL[8] = isoBandNextXBL[162] = 1;
  11011. isoBandNextYBL[8] = isoBandNextYBL[162] = 0;
  11012. isoBandNextOBL[8] = isoBandNextOBL[162] = 1;
  11013. isoBandNextXBR[8] = isoBandNextXBR[162] = 1;
  11014. isoBandNextYBR[8] = isoBandNextYBR[162] = 0;
  11015. isoBandNextOBR[8] = isoBandNextOBR[162] = 0;
  11016. isoBandNextXRT[32] = isoBandNextXRT[138] = 0;
  11017. isoBandNextYRT[32] = isoBandNextYRT[138] = 1;
  11018. isoBandNextORT[32] = isoBandNextORT[138] = 1;
  11019. isoBandNextXRB[32] = isoBandNextXRB[138] = 0;
  11020. isoBandNextYRB[32] = isoBandNextYRB[138] = 1;
  11021. isoBandNextORB[32] = isoBandNextORB[138] = 0;
  11022. isoBandNextXTL[32] = isoBandNextXTL[138] = 1;
  11023. isoBandNextYTL[32] = isoBandNextYTL[138] = 0;
  11024. isoBandNextOTL[32] = isoBandNextOTL[138] = 0;
  11025. isoBandNextXTR[32] = isoBandNextXTR[138] = 1;
  11026. isoBandNextYTR[32] = isoBandNextYTR[138] = 0;
  11027. isoBandNextOTR[32] = isoBandNextOTR[138] = 1;
  11028. isoBandNextXLB[128] = isoBandNextXLB[42] = 0;
  11029. isoBandNextYLB[128] = isoBandNextYLB[42] = 1;
  11030. isoBandNextOLB[128] = isoBandNextOLB[42] = 1;
  11031. isoBandNextXLT[128] = isoBandNextXLT[42] = 0;
  11032. isoBandNextYLT[128] = isoBandNextYLT[42] = 1;
  11033. isoBandNextOLT[128] = isoBandNextOLT[42] = 0;
  11034. isoBandNextXTL[128] = isoBandNextXTL[42] = -1;
  11035. isoBandNextYTL[128] = isoBandNextYTL[42] = 0;
  11036. isoBandNextOTL[128] = isoBandNextOTL[42] = 1;
  11037. isoBandNextXTR[128] = isoBandNextXTR[42] = -1;
  11038. isoBandNextYTR[128] = isoBandNextYTR[42] = 0;
  11039. isoBandNextOTR[128] = isoBandNextOTR[42] = 0;
  11040. isoBandNextXRB[5] = isoBandNextXRB[165] = -1;
  11041. isoBandNextYRB[5] = isoBandNextYRB[165] = 0;
  11042. isoBandNextORB[5] = isoBandNextORB[165] = 0;
  11043. isoBandNextXLB[5] = isoBandNextXLB[165] = 1;
  11044. isoBandNextYLB[5] = isoBandNextYLB[165] = 0;
  11045. isoBandNextOLB[5] = isoBandNextOLB[165] = 0;
  11046. isoBandNextXBR[20] = isoBandNextXBR[150] = 0;
  11047. isoBandNextYBR[20] = isoBandNextYBR[150] = 1;
  11048. isoBandNextOBR[20] = isoBandNextOBR[150] = 1;
  11049. isoBandNextXTR[20] = isoBandNextXTR[150] = 0;
  11050. isoBandNextYTR[20] = isoBandNextYTR[150] = -1;
  11051. isoBandNextOTR[20] = isoBandNextOTR[150] = 1;
  11052. isoBandNextXRT[80] = isoBandNextXRT[90] = -1;
  11053. isoBandNextYRT[80] = isoBandNextYRT[90] = 0;
  11054. isoBandNextORT[80] = isoBandNextORT[90] = 1;
  11055. isoBandNextXLT[80] = isoBandNextXLT[90] = 1;
  11056. isoBandNextYLT[80] = isoBandNextYLT[90] = 0;
  11057. isoBandNextOLT[80] = isoBandNextOLT[90] = 1;
  11058. isoBandNextXBL[65] = isoBandNextXBL[105] = 0;
  11059. isoBandNextYBL[65] = isoBandNextYBL[105] = 1;
  11060. isoBandNextOBL[65] = isoBandNextOBL[105] = 0;
  11061. isoBandNextXTL[65] = isoBandNextXTL[105] = 0;
  11062. isoBandNextYTL[65] = isoBandNextYTL[105] = -1;
  11063. isoBandNextOTL[65] = isoBandNextOTL[105] = 0;
  11064. isoBandNextXRT[160] = isoBandNextXRT[10] = -1;
  11065. isoBandNextYRT[160] = isoBandNextYRT[10] = 0;
  11066. isoBandNextORT[160] = isoBandNextORT[10] = 1;
  11067. isoBandNextXRB[160] = isoBandNextXRB[10] = -1;
  11068. isoBandNextYRB[160] = isoBandNextYRB[10] = 0;
  11069. isoBandNextORB[160] = isoBandNextORB[10] = 0;
  11070. isoBandNextXLB[160] = isoBandNextXLB[10] = 1;
  11071. isoBandNextYLB[160] = isoBandNextYLB[10] = 0;
  11072. isoBandNextOLB[160] = isoBandNextOLB[10] = 0;
  11073. isoBandNextXLT[160] = isoBandNextXLT[10] = 1;
  11074. isoBandNextYLT[160] = isoBandNextYLT[10] = 0;
  11075. isoBandNextOLT[160] = isoBandNextOLT[10] = 1;
  11076. isoBandNextXBR[130] = isoBandNextXBR[40] = 0;
  11077. isoBandNextYBR[130] = isoBandNextYBR[40] = 1;
  11078. isoBandNextOBR[130] = isoBandNextOBR[40] = 1;
  11079. isoBandNextXBL[130] = isoBandNextXBL[40] = 0;
  11080. isoBandNextYBL[130] = isoBandNextYBL[40] = 1;
  11081. isoBandNextOBL[130] = isoBandNextOBL[40] = 0;
  11082. isoBandNextXTL[130] = isoBandNextXTL[40] = 0;
  11083. isoBandNextYTL[130] = isoBandNextYTL[40] = -1;
  11084. isoBandNextOTL[130] = isoBandNextOTL[40] = 0;
  11085. isoBandNextXTR[130] = isoBandNextXTR[40] = 0;
  11086. isoBandNextYTR[130] = isoBandNextYTR[40] = -1;
  11087. isoBandNextOTR[130] = isoBandNextOTR[40] = 1;
  11088. isoBandNextXRB[37] = isoBandNextXRB[133] = 0;
  11089. isoBandNextYRB[37] = isoBandNextYRB[133] = 1;
  11090. isoBandNextORB[37] = isoBandNextORB[133] = 1;
  11091. isoBandNextXLB[37] = isoBandNextXLB[133] = 0;
  11092. isoBandNextYLB[37] = isoBandNextYLB[133] = 1;
  11093. isoBandNextOLB[37] = isoBandNextOLB[133] = 0;
  11094. isoBandNextXTL[37] = isoBandNextXTL[133] = -1;
  11095. isoBandNextYTL[37] = isoBandNextYTL[133] = 0;
  11096. isoBandNextOTL[37] = isoBandNextOTL[133] = 0;
  11097. isoBandNextXTR[37] = isoBandNextXTR[133] = 1;
  11098. isoBandNextYTR[37] = isoBandNextYTR[133] = 0;
  11099. isoBandNextOTR[37] = isoBandNextOTR[133] = 0;
  11100. isoBandNextXBR[148] = isoBandNextXBR[22] = -1;
  11101. isoBandNextYBR[148] = isoBandNextYBR[22] = 0;
  11102. isoBandNextOBR[148] = isoBandNextOBR[22] = 0;
  11103. isoBandNextXLB[148] = isoBandNextXLB[22] = 0;
  11104. isoBandNextYLB[148] = isoBandNextYLB[22] = -1;
  11105. isoBandNextOLB[148] = isoBandNextOLB[22] = 1;
  11106. isoBandNextXLT[148] = isoBandNextXLT[22] = 0;
  11107. isoBandNextYLT[148] = isoBandNextYLT[22] = 1;
  11108. isoBandNextOLT[148] = isoBandNextOLT[22] = 1;
  11109. isoBandNextXTR[148] = isoBandNextXTR[22] = -1;
  11110. isoBandNextYTR[148] = isoBandNextYTR[22] = 0;
  11111. isoBandNextOTR[148] = isoBandNextOTR[22] = 1;
  11112. isoBandNextXRT[82] = isoBandNextXRT[88] = 0;
  11113. isoBandNextYRT[82] = isoBandNextYRT[88] = -1;
  11114. isoBandNextORT[82] = isoBandNextORT[88] = 1;
  11115. isoBandNextXBR[82] = isoBandNextXBR[88] = 1;
  11116. isoBandNextYBR[82] = isoBandNextYBR[88] = 0;
  11117. isoBandNextOBR[82] = isoBandNextOBR[88] = 1;
  11118. isoBandNextXBL[82] = isoBandNextXBL[88] = -1;
  11119. isoBandNextYBL[82] = isoBandNextYBL[88] = 0;
  11120. isoBandNextOBL[82] = isoBandNextOBL[88] = 1;
  11121. isoBandNextXLT[82] = isoBandNextXLT[88] = 0;
  11122. isoBandNextYLT[82] = isoBandNextYLT[88] = -1;
  11123. isoBandNextOLT[82] = isoBandNextOLT[88] = 0;
  11124. isoBandNextXRT[73] = isoBandNextXRT[97] = 0;
  11125. isoBandNextYRT[73] = isoBandNextYRT[97] = 1;
  11126. isoBandNextORT[73] = isoBandNextORT[97] = 0;
  11127. isoBandNextXRB[73] = isoBandNextXRB[97] = 0;
  11128. isoBandNextYRB[73] = isoBandNextYRB[97] = -1;
  11129. isoBandNextORB[73] = isoBandNextORB[97] = 0;
  11130. isoBandNextXBL[73] = isoBandNextXBL[97] = 1;
  11131. isoBandNextYBL[73] = isoBandNextYBL[97] = 0;
  11132. isoBandNextOBL[73] = isoBandNextOBL[97] = 0;
  11133. isoBandNextXTL[73] = isoBandNextXTL[97] = 1;
  11134. isoBandNextYTL[73] = isoBandNextYTL[97] = 0;
  11135. isoBandNextOTL[73] = isoBandNextOTL[97] = 1;
  11136. isoBandNextXRT[145] = isoBandNextXRT[25] = 0;
  11137. isoBandNextYRT[145] = isoBandNextYRT[25] = -1;
  11138. isoBandNextORT[145] = isoBandNextORT[25] = 0;
  11139. isoBandNextXBL[145] = isoBandNextXBL[25] = 1;
  11140. isoBandNextYBL[145] = isoBandNextYBL[25] = 0;
  11141. isoBandNextOBL[145] = isoBandNextOBL[25] = 1;
  11142. isoBandNextXLB[145] = isoBandNextXLB[25] = 0;
  11143. isoBandNextYLB[145] = isoBandNextYLB[25] = 1;
  11144. isoBandNextOLB[145] = isoBandNextOLB[25] = 1;
  11145. isoBandNextXTR[145] = isoBandNextXTR[25] = -1;
  11146. isoBandNextYTR[145] = isoBandNextYTR[25] = 0;
  11147. isoBandNextOTR[145] = isoBandNextOTR[25] = 0;
  11148. isoBandNextXRB[70] = isoBandNextXRB[100] = 0;
  11149. isoBandNextYRB[70] = isoBandNextYRB[100] = 1;
  11150. isoBandNextORB[70] = isoBandNextORB[100] = 0;
  11151. isoBandNextXBR[70] = isoBandNextXBR[100] = -1;
  11152. isoBandNextYBR[70] = isoBandNextYBR[100] = 0;
  11153. isoBandNextOBR[70] = isoBandNextOBR[100] = 1;
  11154. isoBandNextXLT[70] = isoBandNextXLT[100] = 0;
  11155. isoBandNextYLT[70] = isoBandNextYLT[100] = -1;
  11156. isoBandNextOLT[70] = isoBandNextOLT[100] = 1;
  11157. isoBandNextXTL[70] = isoBandNextXTL[100] = 1;
  11158. isoBandNextYTL[70] = isoBandNextYTL[100] = 0;
  11159. isoBandNextOTL[70] = isoBandNextOTL[100] = 0;
  11160. isoBandNextXRB[101] = isoBandNextXRB[69] = 0;
  11161. isoBandNextYRB[101] = isoBandNextYRB[69] = 1;
  11162. isoBandNextORB[101] = isoBandNextORB[69] = 0;
  11163. isoBandNextXTL[101] = isoBandNextXTL[69] = 1;
  11164. isoBandNextYTL[101] = isoBandNextYTL[69] = 0;
  11165. isoBandNextOTL[101] = isoBandNextOTL[69] = 0;
  11166. isoBandNextXLB[149] = isoBandNextXLB[21] = 0;
  11167. isoBandNextYLB[149] = isoBandNextYLB[21] = 1;
  11168. isoBandNextOLB[149] = isoBandNextOLB[21] = 1;
  11169. isoBandNextXTR[149] = isoBandNextXTR[21] = -1;
  11170. isoBandNextYTR[149] = isoBandNextYTR[21] = 0;
  11171. isoBandNextOTR[149] = isoBandNextOTR[21] = 0;
  11172. isoBandNextXBR[86] = isoBandNextXBR[84] = -1;
  11173. isoBandNextYBR[86] = isoBandNextYBR[84] = 0;
  11174. isoBandNextOBR[86] = isoBandNextOBR[84] = 1;
  11175. isoBandNextXLT[86] = isoBandNextXLT[84] = 0;
  11176. isoBandNextYLT[86] = isoBandNextYLT[84] = -1;
  11177. isoBandNextOLT[86] = isoBandNextOLT[84] = 1;
  11178. isoBandNextXRT[89] = isoBandNextXRT[81] = 0;
  11179. isoBandNextYRT[89] = isoBandNextYRT[81] = -1;
  11180. isoBandNextORT[89] = isoBandNextORT[81] = 0;
  11181. isoBandNextXBL[89] = isoBandNextXBL[81] = 1;
  11182. isoBandNextYBL[89] = isoBandNextYBL[81] = 0;
  11183. isoBandNextOBL[89] = isoBandNextOBL[81] = 1;
  11184. isoBandNextXRT[96] = isoBandNextXRT[74] = 0;
  11185. isoBandNextYRT[96] = isoBandNextYRT[74] = 1;
  11186. isoBandNextORT[96] = isoBandNextORT[74] = 0;
  11187. isoBandNextXRB[96] = isoBandNextXRB[74] = -1;
  11188. isoBandNextYRB[96] = isoBandNextYRB[74] = 0;
  11189. isoBandNextORB[96] = isoBandNextORB[74] = 1;
  11190. isoBandNextXLT[96] = isoBandNextXLT[74] = 1;
  11191. isoBandNextYLT[96] = isoBandNextYLT[74] = 0;
  11192. isoBandNextOLT[96] = isoBandNextOLT[74] = 0;
  11193. isoBandNextXTL[96] = isoBandNextXTL[74] = 1;
  11194. isoBandNextYTL[96] = isoBandNextYTL[74] = 0;
  11195. isoBandNextOTL[96] = isoBandNextOTL[74] = 1;
  11196. isoBandNextXRT[24] = isoBandNextXRT[146] = 0;
  11197. isoBandNextYRT[24] = isoBandNextYRT[146] = -1;
  11198. isoBandNextORT[24] = isoBandNextORT[146] = 1;
  11199. isoBandNextXBR[24] = isoBandNextXBR[146] = 1;
  11200. isoBandNextYBR[24] = isoBandNextYBR[146] = 0;
  11201. isoBandNextOBR[24] = isoBandNextOBR[146] = 1;
  11202. isoBandNextXBL[24] = isoBandNextXBL[146] = 0;
  11203. isoBandNextYBL[24] = isoBandNextYBL[146] = 1;
  11204. isoBandNextOBL[24] = isoBandNextOBL[146] = 1;
  11205. isoBandNextXTR[24] = isoBandNextXTR[146] = 0;
  11206. isoBandNextYTR[24] = isoBandNextYTR[146] = -1;
  11207. isoBandNextOTR[24] = isoBandNextOTR[146] = 0;
  11208. isoBandNextXRB[6] = isoBandNextXRB[164] = -1;
  11209. isoBandNextYRB[6] = isoBandNextYRB[164] = 0;
  11210. isoBandNextORB[6] = isoBandNextORB[164] = 1;
  11211. isoBandNextXBR[6] = isoBandNextXBR[164] = -1;
  11212. isoBandNextYBR[6] = isoBandNextYBR[164] = 0;
  11213. isoBandNextOBR[6] = isoBandNextOBR[164] = 0;
  11214. isoBandNextXLB[6] = isoBandNextXLB[164] = 0;
  11215. isoBandNextYLB[6] = isoBandNextYLB[164] = -1;
  11216. isoBandNextOLB[6] = isoBandNextOLB[164] = 1;
  11217. isoBandNextXLT[6] = isoBandNextXLT[164] = 1;
  11218. isoBandNextYLT[6] = isoBandNextYLT[164] = 0;
  11219. isoBandNextOLT[6] = isoBandNextOLT[164] = 0;
  11220. isoBandNextXBL[129] = isoBandNextXBL[41] = 0;
  11221. isoBandNextYBL[129] = isoBandNextYBL[41] = 1;
  11222. isoBandNextOBL[129] = isoBandNextOBL[41] = 1;
  11223. isoBandNextXLB[129] = isoBandNextXLB[41] = 0;
  11224. isoBandNextYLB[129] = isoBandNextYLB[41] = 1;
  11225. isoBandNextOLB[129] = isoBandNextOLB[41] = 0;
  11226. isoBandNextXTL[129] = isoBandNextXTL[41] = -1;
  11227. isoBandNextYTL[129] = isoBandNextYTL[41] = 0;
  11228. isoBandNextOTL[129] = isoBandNextOTL[41] = 0;
  11229. isoBandNextXTR[129] = isoBandNextXTR[41] = 0;
  11230. isoBandNextYTR[129] = isoBandNextYTR[41] = -1;
  11231. isoBandNextOTR[129] = isoBandNextOTR[41] = 0;
  11232. isoBandNextXBR[66] = isoBandNextXBR[104] = 0;
  11233. isoBandNextYBR[66] = isoBandNextYBR[104] = 1;
  11234. isoBandNextOBR[66] = isoBandNextOBR[104] = 0;
  11235. isoBandNextXBL[66] = isoBandNextXBL[104] = -1;
  11236. isoBandNextYBL[66] = isoBandNextYBL[104] = 0;
  11237. isoBandNextOBL[66] = isoBandNextOBL[104] = 1;
  11238. isoBandNextXLT[66] = isoBandNextXLT[104] = 0;
  11239. isoBandNextYLT[66] = isoBandNextYLT[104] = -1;
  11240. isoBandNextOLT[66] = isoBandNextOLT[104] = 0;
  11241. isoBandNextXTL[66] = isoBandNextXTL[104] = 0;
  11242. isoBandNextYTL[66] = isoBandNextYTL[104] = -1;
  11243. isoBandNextOTL[66] = isoBandNextOTL[104] = 1;
  11244. isoBandNextXRT[144] = isoBandNextXRT[26] = -1;
  11245. isoBandNextYRT[144] = isoBandNextYRT[26] = 0;
  11246. isoBandNextORT[144] = isoBandNextORT[26] = 0;
  11247. isoBandNextXLB[144] = isoBandNextXLB[26] = 1;
  11248. isoBandNextYLB[144] = isoBandNextYLB[26] = 0;
  11249. isoBandNextOLB[144] = isoBandNextOLB[26] = 1;
  11250. isoBandNextXLT[144] = isoBandNextXLT[26] = 0;
  11251. isoBandNextYLT[144] = isoBandNextYLT[26] = 1;
  11252. isoBandNextOLT[144] = isoBandNextOLT[26] = 1;
  11253. isoBandNextXTR[144] = isoBandNextXTR[26] = -1;
  11254. isoBandNextYTR[144] = isoBandNextYTR[26] = 0;
  11255. isoBandNextOTR[144] = isoBandNextOTR[26] = 1;
  11256. isoBandNextXRB[36] = isoBandNextXRB[134] = 0;
  11257. isoBandNextYRB[36] = isoBandNextYRB[134] = 1;
  11258. isoBandNextORB[36] = isoBandNextORB[134] = 1;
  11259. isoBandNextXBR[36] = isoBandNextXBR[134] = 0;
  11260. isoBandNextYBR[36] = isoBandNextYBR[134] = 1;
  11261. isoBandNextOBR[36] = isoBandNextOBR[134] = 0;
  11262. isoBandNextXTL[36] = isoBandNextXTL[134] = 0;
  11263. isoBandNextYTL[36] = isoBandNextYTL[134] = -1;
  11264. isoBandNextOTL[36] = isoBandNextOTL[134] = 1;
  11265. isoBandNextXTR[36] = isoBandNextXTR[134] = 1;
  11266. isoBandNextYTR[36] = isoBandNextYTR[134] = 0;
  11267. isoBandNextOTR[36] = isoBandNextOTR[134] = 0;
  11268. isoBandNextXRT[9] = isoBandNextXRT[161] = -1;
  11269. isoBandNextYRT[9] = isoBandNextYRT[161] = 0;
  11270. isoBandNextORT[9] = isoBandNextORT[161] = 0;
  11271. isoBandNextXRB[9] = isoBandNextXRB[161] = 0;
  11272. isoBandNextYRB[9] = isoBandNextYRB[161] = -1;
  11273. isoBandNextORB[9] = isoBandNextORB[161] = 0;
  11274. isoBandNextXBL[9] = isoBandNextXBL[161] = 1;
  11275. isoBandNextYBL[9] = isoBandNextYBL[161] = 0;
  11276. isoBandNextOBL[9] = isoBandNextOBL[161] = 0;
  11277. isoBandNextXLB[9] = isoBandNextXLB[161] = 1;
  11278. isoBandNextYLB[9] = isoBandNextYLB[161] = 0;
  11279. isoBandNextOLB[9] = isoBandNextOLB[161] = 1;
  11280. isoBandNextXRT[136] = 0;
  11281. isoBandNextYRT[136] = 1;
  11282. isoBandNextORT[136] = 1;
  11283. isoBandNextXRB[136] = 0;
  11284. isoBandNextYRB[136] = 1;
  11285. isoBandNextORB[136] = 0;
  11286. isoBandNextXBR[136] = -1;
  11287. isoBandNextYBR[136] = 0;
  11288. isoBandNextOBR[136] = 1;
  11289. isoBandNextXBL[136] = -1;
  11290. isoBandNextYBL[136] = 0;
  11291. isoBandNextOBL[136] = 0;
  11292. isoBandNextXLB[136] = 0;
  11293. isoBandNextYLB[136] = -1;
  11294. isoBandNextOLB[136] = 0;
  11295. isoBandNextXLT[136] = 0;
  11296. isoBandNextYLT[136] = -1;
  11297. isoBandNextOLT[136] = 1;
  11298. isoBandNextXTL[136] = 1;
  11299. isoBandNextYTL[136] = 0;
  11300. isoBandNextOTL[136] = 0;
  11301. isoBandNextXTR[136] = 1;
  11302. isoBandNextYTR[136] = 0;
  11303. isoBandNextOTR[136] = 1;
  11304. isoBandNextXRT[34] = 0;
  11305. isoBandNextYRT[34] = -1;
  11306. isoBandNextORT[34] = 0;
  11307. isoBandNextXRB[34] = 0;
  11308. isoBandNextYRB[34] = -1;
  11309. isoBandNextORB[34] = 1;
  11310. isoBandNextXBR[34] = 1;
  11311. isoBandNextYBR[34] = 0;
  11312. isoBandNextOBR[34] = 0;
  11313. isoBandNextXBL[34] = 1;
  11314. isoBandNextYBL[34] = 0;
  11315. isoBandNextOBL[34] = 1;
  11316. isoBandNextXLB[34] = 0;
  11317. isoBandNextYLB[34] = 1;
  11318. isoBandNextOLB[34] = 1;
  11319. isoBandNextXLT[34] = 0;
  11320. isoBandNextYLT[34] = 1;
  11321. isoBandNextOLT[34] = 0;
  11322. isoBandNextXTL[34] = -1;
  11323. isoBandNextYTL[34] = 0;
  11324. isoBandNextOTL[34] = 1;
  11325. isoBandNextXTR[34] = -1;
  11326. isoBandNextYTR[34] = 0;
  11327. isoBandNextOTR[34] = 0;
  11328. isoBandNextXRT[35] = 0;
  11329. isoBandNextYRT[35] = 1;
  11330. isoBandNextORT[35] = 1;
  11331. isoBandNextXRB[35] = 0;
  11332. isoBandNextYRB[35] = -1;
  11333. isoBandNextORB[35] = 1;
  11334. isoBandNextXBR[35] = 1;
  11335. isoBandNextYBR[35] = 0;
  11336. isoBandNextOBR[35] = 0;
  11337. isoBandNextXBL[35] = -1;
  11338. isoBandNextYBL[35] = 0;
  11339. isoBandNextOBL[35] = 0;
  11340. isoBandNextXLB[35] = 0;
  11341. isoBandNextYLB[35] = -1;
  11342. isoBandNextOLB[35] = 0;
  11343. isoBandNextXLT[35] = 0;
  11344. isoBandNextYLT[35] = 1;
  11345. isoBandNextOLT[35] = 0;
  11346. isoBandNextXTL[35] = -1;
  11347. isoBandNextYTL[35] = 0;
  11348. isoBandNextOTL[35] = 1;
  11349. isoBandNextXTR[35] = 1;
  11350. isoBandNextYTR[35] = 0;
  11351. isoBandNextOTR[35] = 1;
  11352. isoBandNextXRT[153] = 0;
  11353. isoBandNextYRT[153] = 1;
  11354. isoBandNextORT[153] = 1;
  11355. isoBandNextXBL[153] = -1;
  11356. isoBandNextYBL[153] = 0;
  11357. isoBandNextOBL[153] = 0;
  11358. isoBandNextXLB[153] = 0;
  11359. isoBandNextYLB[153] = -1;
  11360. isoBandNextOLB[153] = 0;
  11361. isoBandNextXTR[153] = 1;
  11362. isoBandNextYTR[153] = 0;
  11363. isoBandNextOTR[153] = 1;
  11364. isoBandNextXRB[102] = 0;
  11365. isoBandNextYRB[102] = -1;
  11366. isoBandNextORB[102] = 1;
  11367. isoBandNextXBR[102] = 1;
  11368. isoBandNextYBR[102] = 0;
  11369. isoBandNextOBR[102] = 0;
  11370. isoBandNextXLT[102] = 0;
  11371. isoBandNextYLT[102] = 1;
  11372. isoBandNextOLT[102] = 0;
  11373. isoBandNextXTL[102] = -1;
  11374. isoBandNextYTL[102] = 0;
  11375. isoBandNextOTL[102] = 1;
  11376. isoBandNextXRT[155] = 0;
  11377. isoBandNextYRT[155] = -1;
  11378. isoBandNextORT[155] = 0;
  11379. isoBandNextXBL[155] = 1;
  11380. isoBandNextYBL[155] = 0;
  11381. isoBandNextOBL[155] = 1;
  11382. isoBandNextXLB[155] = 0;
  11383. isoBandNextYLB[155] = 1;
  11384. isoBandNextOLB[155] = 1;
  11385. isoBandNextXTR[155] = -1;
  11386. isoBandNextYTR[155] = 0;
  11387. isoBandNextOTR[155] = 0;
  11388. isoBandNextXRB[103] = 0;
  11389. isoBandNextYRB[103] = 1;
  11390. isoBandNextORB[103] = 0;
  11391. isoBandNextXBR[103] = -1;
  11392. isoBandNextYBR[103] = 0;
  11393. isoBandNextOBR[103] = 1;
  11394. isoBandNextXLT[103] = 0;
  11395. isoBandNextYLT[103] = -1;
  11396. isoBandNextOLT[103] = 1;
  11397. isoBandNextXTL[103] = 1;
  11398. isoBandNextYTL[103] = 0;
  11399. isoBandNextOTL[103] = 0;
  11400. isoBandNextXRT[152] = 0;
  11401. isoBandNextYRT[152] = 1;
  11402. isoBandNextORT[152] = 1;
  11403. isoBandNextXBR[152] = -1;
  11404. isoBandNextYBR[152] = 0;
  11405. isoBandNextOBR[152] = 1;
  11406. isoBandNextXBL[152] = -1;
  11407. isoBandNextYBL[152] = 0;
  11408. isoBandNextOBL[152] = 0;
  11409. isoBandNextXLB[152] = 0;
  11410. isoBandNextYLB[152] = -1;
  11411. isoBandNextOLB[152] = 0;
  11412. isoBandNextXLT[152] = 0;
  11413. isoBandNextYLT[152] = -1;
  11414. isoBandNextOLT[152] = 1;
  11415. isoBandNextXTR[152] = 1;
  11416. isoBandNextYTR[152] = 0;
  11417. isoBandNextOTR[152] = 1;
  11418. isoBandNextXRT[156] = 0;
  11419. isoBandNextYRT[156] = -1;
  11420. isoBandNextORT[156] = 1;
  11421. isoBandNextXBR[156] = 1;
  11422. isoBandNextYBR[156] = 0;
  11423. isoBandNextOBR[156] = 1;
  11424. isoBandNextXBL[156] = -1;
  11425. isoBandNextYBL[156] = 0;
  11426. isoBandNextOBL[156] = 0;
  11427. isoBandNextXLB[156] = 0;
  11428. isoBandNextYLB[156] = -1;
  11429. isoBandNextOLB[156] = 0;
  11430. isoBandNextXLT[156] = 0;
  11431. isoBandNextYLT[156] = 1;
  11432. isoBandNextOLT[156] = 1;
  11433. isoBandNextXTR[156] = -1;
  11434. isoBandNextYTR[156] = 0;
  11435. isoBandNextOTR[156] = 1;
  11436. isoBandNextXRT[137] = 0;
  11437. isoBandNextYRT[137] = 1;
  11438. isoBandNextORT[137] = 1;
  11439. isoBandNextXRB[137] = 0;
  11440. isoBandNextYRB[137] = 1;
  11441. isoBandNextORB[137] = 0;
  11442. isoBandNextXBL[137] = -1;
  11443. isoBandNextYBL[137] = 0;
  11444. isoBandNextOBL[137] = 0;
  11445. isoBandNextXLB[137] = 0;
  11446. isoBandNextYLB[137] = -1;
  11447. isoBandNextOLB[137] = 0;
  11448. isoBandNextXTL[137] = 1;
  11449. isoBandNextYTL[137] = 0;
  11450. isoBandNextOTL[137] = 0;
  11451. isoBandNextXTR[137] = 1;
  11452. isoBandNextYTR[137] = 0;
  11453. isoBandNextOTR[137] = 1;
  11454. isoBandNextXRT[139] = 0;
  11455. isoBandNextYRT[139] = 1;
  11456. isoBandNextORT[139] = 1;
  11457. isoBandNextXRB[139] = 0;
  11458. isoBandNextYRB[139] = -1;
  11459. isoBandNextORB[139] = 0;
  11460. isoBandNextXBL[139] = 1;
  11461. isoBandNextYBL[139] = 0;
  11462. isoBandNextOBL[139] = 0;
  11463. isoBandNextXLB[139] = 0;
  11464. isoBandNextYLB[139] = 1;
  11465. isoBandNextOLB[139] = 0;
  11466. isoBandNextXTL[139] = -1;
  11467. isoBandNextYTL[139] = 0;
  11468. isoBandNextOTL[139] = 0;
  11469. isoBandNextXTR[139] = 1;
  11470. isoBandNextYTR[139] = 0;
  11471. isoBandNextOTR[139] = 1;
  11472. isoBandNextXRT[98] = 0;
  11473. isoBandNextYRT[98] = -1;
  11474. isoBandNextORT[98] = 0;
  11475. isoBandNextXRB[98] = 0;
  11476. isoBandNextYRB[98] = -1;
  11477. isoBandNextORB[98] = 1;
  11478. isoBandNextXBR[98] = 1;
  11479. isoBandNextYBR[98] = 0;
  11480. isoBandNextOBR[98] = 0;
  11481. isoBandNextXBL[98] = 1;
  11482. isoBandNextYBL[98] = 0;
  11483. isoBandNextOBL[98] = 1;
  11484. isoBandNextXLT[98] = 0;
  11485. isoBandNextYLT[98] = 1;
  11486. isoBandNextOLT[98] = 0;
  11487. isoBandNextXTL[98] = -1;
  11488. isoBandNextYTL[98] = 0;
  11489. isoBandNextOTL[98] = 1;
  11490. isoBandNextXRT[99] = 0;
  11491. isoBandNextYRT[99] = 1;
  11492. isoBandNextORT[99] = 0;
  11493. isoBandNextXRB[99] = 0;
  11494. isoBandNextYRB[99] = -1;
  11495. isoBandNextORB[99] = 1;
  11496. isoBandNextXBR[99] = 1;
  11497. isoBandNextYBR[99] = 0;
  11498. isoBandNextOBR[99] = 0;
  11499. isoBandNextXBL[99] = -1;
  11500. isoBandNextYBL[99] = 0;
  11501. isoBandNextOBL[99] = 1;
  11502. isoBandNextXLT[99] = 0;
  11503. isoBandNextYLT[99] = -1;
  11504. isoBandNextOLT[99] = 0;
  11505. isoBandNextXTL[99] = 1;
  11506. isoBandNextYTL[99] = 0;
  11507. isoBandNextOTL[99] = 1;
  11508. isoBandNextXRB[38] = 0;
  11509. isoBandNextYRB[38] = -1;
  11510. isoBandNextORB[38] = 1;
  11511. isoBandNextXBR[38] = 1;
  11512. isoBandNextYBR[38] = 0;
  11513. isoBandNextOBR[38] = 0;
  11514. isoBandNextXLB[38] = 0;
  11515. isoBandNextYLB[38] = 1;
  11516. isoBandNextOLB[38] = 1;
  11517. isoBandNextXLT[38] = 0;
  11518. isoBandNextYLT[38] = 1;
  11519. isoBandNextOLT[38] = 0;
  11520. isoBandNextXTL[38] = -1;
  11521. isoBandNextYTL[38] = 0;
  11522. isoBandNextOTL[38] = 1;
  11523. isoBandNextXTR[38] = -1;
  11524. isoBandNextYTR[38] = 0;
  11525. isoBandNextOTR[38] = 0;
  11526. isoBandNextXRB[39] = 0;
  11527. isoBandNextYRB[39] = 1;
  11528. isoBandNextORB[39] = 1;
  11529. isoBandNextXBR[39] = -1;
  11530. isoBandNextYBR[39] = 0;
  11531. isoBandNextOBR[39] = 0;
  11532. isoBandNextXLB[39] = 0;
  11533. isoBandNextYLB[39] = -1;
  11534. isoBandNextOLB[39] = 1;
  11535. isoBandNextXLT[39] = 0;
  11536. isoBandNextYLT[39] = 1;
  11537. isoBandNextOLT[39] = 0;
  11538. isoBandNextXTL[39] = -1;
  11539. isoBandNextYTL[39] = 0;
  11540. isoBandNextOTL[39] = 1;
  11541. isoBandNextXTR[39] = 1;
  11542. isoBandNextYTR[39] = 0;
  11543. isoBandNextOTR[39] = 0;
  11544. var p00 = function(cell) {
  11545. return [
  11546. [cell.bottomleft, 0],
  11547. [0, 0],
  11548. [0, cell.leftbottom]
  11549. ];
  11550. };
  11551. var p01 = function(cell) {
  11552. return [
  11553. [1, cell.rightbottom],
  11554. [1, 0],
  11555. [cell.bottomright, 0]
  11556. ];
  11557. };
  11558. var p02 = function(cell) {
  11559. return [
  11560. [cell.topright, 1],
  11561. [1, 1],
  11562. [1, cell.righttop]
  11563. ];
  11564. };
  11565. var p03 = function(cell) {
  11566. return [
  11567. [0, cell.lefttop],
  11568. [0, 1],
  11569. [cell.topleft, 1]
  11570. ];
  11571. };
  11572. var p04 = function(cell) {
  11573. return [
  11574. [cell.bottomright, 0],
  11575. [cell.bottomleft, 0],
  11576. [0, cell.leftbottom],
  11577. [0, cell.lefttop]
  11578. ];
  11579. };
  11580. var p05 = function(cell) {
  11581. return [
  11582. [cell.bottomright, 0],
  11583. [cell.bottomleft, 0],
  11584. [1, cell.righttop],
  11585. [1, cell.rightbottom]
  11586. ];
  11587. };
  11588. var p06 = function(cell) {
  11589. return [
  11590. [1, cell.righttop],
  11591. [1, cell.rightbottom],
  11592. [cell.topleft, 1],
  11593. [cell.topright, 1]
  11594. ];
  11595. };
  11596. var p07 = function(cell) {
  11597. return [
  11598. [0, cell.leftbottom],
  11599. [0, cell.lefttop],
  11600. [cell.topleft, 1],
  11601. [cell.topright, 1]
  11602. ];
  11603. };
  11604. var p08 = function(cell) {
  11605. return [
  11606. [0, 0],
  11607. [0, cell.leftbottom],
  11608. [1, cell.rightbottom],
  11609. [1, 0]
  11610. ];
  11611. };
  11612. var p09 = function(cell) {
  11613. return [
  11614. [1, 0],
  11615. [cell.bottomright, 0],
  11616. [cell.topright, 1],
  11617. [1, 1]
  11618. ];
  11619. };
  11620. var p10 = function(cell) {
  11621. return [
  11622. [1, 1],
  11623. [1, cell.righttop],
  11624. [0, cell.lefttop],
  11625. [0, 1]
  11626. ];
  11627. };
  11628. var p11 = function(cell) {
  11629. return [
  11630. [cell.bottomleft, 0],
  11631. [0, 0],
  11632. [0, 1],
  11633. [cell.topleft, 1]
  11634. ];
  11635. };
  11636. var p12 = function(cell) {
  11637. return [
  11638. [1, cell.righttop],
  11639. [1, cell.rightbottom],
  11640. [0, cell.leftbottom],
  11641. [0, cell.lefttop]
  11642. ];
  11643. };
  11644. var p13 = function(cell) {
  11645. return [
  11646. [cell.topleft, 1],
  11647. [cell.topright, 1],
  11648. [cell.bottomright, 0],
  11649. [cell.bottomleft, 0]
  11650. ];
  11651. };
  11652. var p14 = function() {
  11653. return [
  11654. [0, 0],
  11655. [0, 1],
  11656. [1, 1],
  11657. [1, 0]
  11658. ];
  11659. };
  11660. var p15 = function(cell) {
  11661. return [
  11662. [1, cell.rightbottom],
  11663. [1, 0],
  11664. [0, 0],
  11665. [0, 1],
  11666. [cell.topleft, 1]
  11667. ];
  11668. };
  11669. var p16 = function(cell) {
  11670. return [
  11671. [cell.topright, 1],
  11672. [1, 1],
  11673. [1, 0],
  11674. [0, 0],
  11675. [0, cell.leftbottom]
  11676. ];
  11677. };
  11678. var p17 = function(cell) {
  11679. return [
  11680. [1, 0],
  11681. [cell.bottomright, 0],
  11682. [0, cell.lefttop],
  11683. [0, 1],
  11684. [1, 1]
  11685. ];
  11686. };
  11687. var p18 = function(cell) {
  11688. return [
  11689. [1, 1],
  11690. [1, cell.righttop],
  11691. [cell.bottomleft, 0],
  11692. [0, 0],
  11693. [0, 1]
  11694. ];
  11695. };
  11696. var p19 = function(cell) {
  11697. return [
  11698. [1, cell.righttop],
  11699. [1, cell.rightbottom],
  11700. [0, cell.lefttop],
  11701. [0, 1],
  11702. [cell.topleft, 1]
  11703. ];
  11704. };
  11705. var p20 = function(cell) {
  11706. return [
  11707. [1, 1],
  11708. [1, cell.righttop],
  11709. [cell.bottomright, 0],
  11710. [cell.bottomleft, 0],
  11711. [cell.topright, 1]
  11712. ];
  11713. };
  11714. var p21 = function(cell) {
  11715. return [
  11716. [1, cell.rightbottom],
  11717. [1, 0],
  11718. [cell.bottomright, 0],
  11719. [0, cell.leftbottom],
  11720. [0, cell.lefttop]
  11721. ];
  11722. };
  11723. var p22 = function(cell) {
  11724. return [
  11725. [cell.topright, 1],
  11726. [cell.bottomleft, 0],
  11727. [0, 0],
  11728. [0, cell.leftbottom],
  11729. [cell.topleft, 1]
  11730. ];
  11731. };
  11732. var p23 = function(cell) {
  11733. return [
  11734. [cell.bottomright, 0],
  11735. [cell.bottomleft, 0],
  11736. [0, cell.lefttop],
  11737. [0, 1],
  11738. [cell.topleft, 1]
  11739. ];
  11740. };
  11741. var p24 = function(cell) {
  11742. return [
  11743. [1, 1],
  11744. [1, cell.righttop],
  11745. [0, cell.leftbottom],
  11746. [0, cell.lefttop],
  11747. [cell.topright, 1]
  11748. ];
  11749. };
  11750. var p25 = function(cell) {
  11751. return [
  11752. [1, cell.rightbottom],
  11753. [1, 0],
  11754. [cell.bottomright, 0],
  11755. [cell.topleft, 1],
  11756. [cell.topright, 1]
  11757. ];
  11758. };
  11759. var p26 = function(cell) {
  11760. return [
  11761. [1, cell.righttop],
  11762. [1, cell.rightbottom],
  11763. [cell.bottomleft, 0],
  11764. [0, 0],
  11765. [0, cell.leftbottom]
  11766. ];
  11767. };
  11768. var p27 = function(cell) {
  11769. return [
  11770. [1, cell.rightbottom],
  11771. [1, 0],
  11772. [0, 0],
  11773. [0, cell.leftbottom],
  11774. [cell.topleft, 1],
  11775. [cell.topright, 1]
  11776. ];
  11777. };
  11778. var p28 = function(cell) {
  11779. return [
  11780. [1, 1],
  11781. [1, 0],
  11782. [cell.bottomright, 0],
  11783. [0, cell.leftbottom],
  11784. [0, cell.lefttop],
  11785. [cell.topright, 1]
  11786. ];
  11787. };
  11788. var p29 = function(cell) {
  11789. return [
  11790. [1, 1],
  11791. [1, cell.righttop],
  11792. [cell.bottomright, 0],
  11793. [cell.bottomleft, 0],
  11794. [0, cell.lefttop],
  11795. [0, 1]
  11796. ];
  11797. };
  11798. var p30 = function(cell) {
  11799. return [
  11800. [1, cell.righttop],
  11801. [1, cell.rightbottom],
  11802. [cell.bottomleft, 0],
  11803. [0, 0],
  11804. [0, 1],
  11805. [cell.topleft, 1]
  11806. ];
  11807. };
  11808. var p31 = function(cell) {
  11809. return [
  11810. [1, 1],
  11811. [1, cell.righttop],
  11812. [cell.bottomleft, 0],
  11813. [0, 0],
  11814. [0, cell.leftbottom],
  11815. [cell.topright, 1]
  11816. ];
  11817. };
  11818. var p32 = function(cell) {
  11819. return [
  11820. [1, cell.rightbottom],
  11821. [1, 0],
  11822. [cell.bottomright, 0],
  11823. [0, cell.lefttop],
  11824. [0, 1],
  11825. [cell.topleft, 1]
  11826. ];
  11827. };
  11828. var p33 = function(cell) {
  11829. return [
  11830. [1, cell.righttop],
  11831. [1, cell.rightbottom],
  11832. [cell.bottomright, 0],
  11833. [cell.bottomleft, 0],
  11834. [0, cell.leftbottom],
  11835. [0, cell.lefttop],
  11836. [cell.topleft, 1],
  11837. [cell.topright, 1]
  11838. ];
  11839. };
  11840. var p34 = function(cell) {
  11841. return [
  11842. [1, 1],
  11843. [1, cell.righttop],
  11844. [cell.bottomleft, 0],
  11845. [0, 0],
  11846. [0, cell.leftbottom],
  11847. [cell.topright, 1]
  11848. ];
  11849. };
  11850. var p35 = function(cell) {
  11851. return [
  11852. [1, cell.rightbottom],
  11853. [1, 0],
  11854. [cell.bottomright, 0],
  11855. [0, cell.lefttop],
  11856. [0, 1],
  11857. [cell.topleft, 1]
  11858. ];
  11859. };
  11860. var p36 = function(cell) {
  11861. return [
  11862. [1, 1],
  11863. [1, cell.righttop],
  11864. [cell.bottomright, 0],
  11865. [cell.bottomleft, 0],
  11866. [0, cell.leftbottom],
  11867. [0, cell.lefttop],
  11868. [cell.topright, 1]
  11869. ];
  11870. };
  11871. var p37 = function(cell) {
  11872. return [
  11873. [1, cell.righttop],
  11874. [1, cell.rightbottom],
  11875. [cell.bottomleft, 0],
  11876. [0, 0],
  11877. [0, cell.leftbottom],
  11878. [cell.topleft, 1],
  11879. [cell.topright, 1]
  11880. ];
  11881. };
  11882. var p38 = function(cell) {
  11883. return [
  11884. [1, cell.righttop],
  11885. [1, cell.rightbottom],
  11886. [cell.bottomright, 0],
  11887. [cell.bottomleft, 0],
  11888. [0, cell.lefttop],
  11889. [0, 1],
  11890. [cell.topleft, 1]
  11891. ];
  11892. };
  11893. var p39 = function(cell) {
  11894. return [
  11895. [1, cell.rightbottom],
  11896. [1, 0],
  11897. [cell.bottomright, 0],
  11898. [0, cell.leftbottom],
  11899. [0, cell.lefttop],
  11900. [cell.topleft, 1],
  11901. [cell.topright, 1]
  11902. ];
  11903. };
  11904. var isoBandEdgeRT = [];
  11905. var isoBandEdgeRB = [];
  11906. var isoBandEdgeBR = [];
  11907. var isoBandEdgeBL = [];
  11908. var isoBandEdgeLB = [];
  11909. var isoBandEdgeLT = [];
  11910. var isoBandEdgeTL = [];
  11911. var isoBandEdgeTR = [];
  11912. isoBandEdgeBL[1] = isoBandEdgeLB[1] = 18;
  11913. isoBandEdgeBL[169] = isoBandEdgeLB[169] = 18;
  11914. isoBandEdgeBR[4] = isoBandEdgeRB[4] = 12;
  11915. isoBandEdgeBR[166] = isoBandEdgeRB[166] = 12;
  11916. isoBandEdgeRT[16] = isoBandEdgeTR[16] = 4;
  11917. isoBandEdgeRT[154] = isoBandEdgeTR[154] = 4;
  11918. isoBandEdgeLT[64] = isoBandEdgeTL[64] = 22;
  11919. isoBandEdgeLT[106] = isoBandEdgeTL[106] = 22;
  11920. isoBandEdgeBR[2] = isoBandEdgeLT[2] = 17;
  11921. isoBandEdgeBL[2] = isoBandEdgeLB[2] = 18;
  11922. isoBandEdgeBR[168] = isoBandEdgeLT[168] = 17;
  11923. isoBandEdgeBL[168] = isoBandEdgeLB[168] = 18;
  11924. isoBandEdgeRT[8] = isoBandEdgeBL[8] = 9;
  11925. isoBandEdgeRB[8] = isoBandEdgeBR[8] = 12;
  11926. isoBandEdgeRT[162] = isoBandEdgeBL[162] = 9;
  11927. isoBandEdgeRB[162] = isoBandEdgeBR[162] = 12;
  11928. isoBandEdgeRT[32] = isoBandEdgeTR[32] = 4;
  11929. isoBandEdgeRB[32] = isoBandEdgeTL[32] = 1;
  11930. isoBandEdgeRT[138] = isoBandEdgeTR[138] = 4;
  11931. isoBandEdgeRB[138] = isoBandEdgeTL[138] = 1;
  11932. isoBandEdgeLB[128] = isoBandEdgeTR[128] = 21;
  11933. isoBandEdgeLT[128] = isoBandEdgeTL[128] = 22;
  11934. isoBandEdgeLB[42] = isoBandEdgeTR[42] = 21;
  11935. isoBandEdgeLT[42] = isoBandEdgeTL[42] = 22;
  11936. isoBandEdgeRB[5] = isoBandEdgeLB[5] = 14;
  11937. isoBandEdgeRB[165] = isoBandEdgeLB[165] = 14;
  11938. isoBandEdgeBR[20] = isoBandEdgeTR[20] = 6;
  11939. isoBandEdgeBR[150] = isoBandEdgeTR[150] = 6;
  11940. isoBandEdgeRT[80] = isoBandEdgeLT[80] = 11;
  11941. isoBandEdgeRT[90] = isoBandEdgeLT[90] = 11;
  11942. isoBandEdgeBL[65] = isoBandEdgeTL[65] = 3;
  11943. isoBandEdgeBL[105] = isoBandEdgeTL[105] = 3;
  11944. isoBandEdgeRT[160] = isoBandEdgeLT[160] = 11;
  11945. isoBandEdgeRB[160] = isoBandEdgeLB[160] = 14;
  11946. isoBandEdgeRT[10] = isoBandEdgeLT[10] = 11;
  11947. isoBandEdgeRB[10] = isoBandEdgeLB[10] = 14;
  11948. isoBandEdgeBR[130] = isoBandEdgeTR[130] = 6;
  11949. isoBandEdgeBL[130] = isoBandEdgeTL[130] = 3;
  11950. isoBandEdgeBR[40] = isoBandEdgeTR[40] = 6;
  11951. isoBandEdgeBL[40] = isoBandEdgeTL[40] = 3;
  11952. isoBandEdgeRB[101] = isoBandEdgeTL[101] = 1;
  11953. isoBandEdgeRB[69] = isoBandEdgeTL[69] = 1;
  11954. isoBandEdgeLB[149] = isoBandEdgeTR[149] = 21;
  11955. isoBandEdgeLB[21] = isoBandEdgeTR[21] = 21;
  11956. isoBandEdgeBR[86] = isoBandEdgeLT[86] = 17;
  11957. isoBandEdgeBR[84] = isoBandEdgeLT[84] = 17;
  11958. isoBandEdgeRT[89] = isoBandEdgeBL[89] = 9;
  11959. isoBandEdgeRT[81] = isoBandEdgeBL[81] = 9;
  11960. isoBandEdgeRT[96] = isoBandEdgeTL[96] = 0;
  11961. isoBandEdgeRB[96] = isoBandEdgeLT[96] = 15;
  11962. isoBandEdgeRT[74] = isoBandEdgeTL[74] = 0;
  11963. isoBandEdgeRB[74] = isoBandEdgeLT[74] = 15;
  11964. isoBandEdgeRT[24] = isoBandEdgeBR[24] = 8;
  11965. isoBandEdgeBL[24] = isoBandEdgeTR[24] = 7;
  11966. isoBandEdgeRT[146] = isoBandEdgeBR[146] = 8;
  11967. isoBandEdgeBL[146] = isoBandEdgeTR[146] = 7;
  11968. isoBandEdgeRB[6] = isoBandEdgeLT[6] = 15;
  11969. isoBandEdgeBR[6] = isoBandEdgeLB[6] = 16;
  11970. isoBandEdgeRB[164] = isoBandEdgeLT[164] = 15;
  11971. isoBandEdgeBR[164] = isoBandEdgeLB[164] = 16;
  11972. isoBandEdgeBL[129] = isoBandEdgeTR[129] = 7;
  11973. isoBandEdgeLB[129] = isoBandEdgeTL[129] = 20;
  11974. isoBandEdgeBL[41] = isoBandEdgeTR[41] = 7;
  11975. isoBandEdgeLB[41] = isoBandEdgeTL[41] = 20;
  11976. isoBandEdgeBR[66] = isoBandEdgeTL[66] = 2;
  11977. isoBandEdgeBL[66] = isoBandEdgeLT[66] = 19;
  11978. isoBandEdgeBR[104] = isoBandEdgeTL[104] = 2;
  11979. isoBandEdgeBL[104] = isoBandEdgeLT[104] = 19;
  11980. isoBandEdgeRT[144] = isoBandEdgeLB[144] = 10;
  11981. isoBandEdgeLT[144] = isoBandEdgeTR[144] = 23;
  11982. isoBandEdgeRT[26] = isoBandEdgeLB[26] = 10;
  11983. isoBandEdgeLT[26] = isoBandEdgeTR[26] = 23;
  11984. isoBandEdgeRB[36] = isoBandEdgeTR[36] = 5;
  11985. isoBandEdgeBR[36] = isoBandEdgeTL[36] = 2;
  11986. isoBandEdgeRB[134] = isoBandEdgeTR[134] = 5;
  11987. isoBandEdgeBR[134] = isoBandEdgeTL[134] = 2;
  11988. isoBandEdgeRT[9] = isoBandEdgeLB[9] = 10;
  11989. isoBandEdgeRB[9] = isoBandEdgeBL[9] = 13;
  11990. isoBandEdgeRT[161] = isoBandEdgeLB[161] = 10;
  11991. isoBandEdgeRB[161] = isoBandEdgeBL[161] = 13;
  11992. isoBandEdgeRB[37] = isoBandEdgeTR[37] = 5;
  11993. isoBandEdgeLB[37] = isoBandEdgeTL[37] = 20;
  11994. isoBandEdgeRB[133] = isoBandEdgeTR[133] = 5;
  11995. isoBandEdgeLB[133] = isoBandEdgeTL[133] = 20;
  11996. isoBandEdgeBR[148] = isoBandEdgeLB[148] = 16;
  11997. isoBandEdgeLT[148] = isoBandEdgeTR[148] = 23;
  11998. isoBandEdgeBR[22] = isoBandEdgeLB[22] = 16;
  11999. isoBandEdgeLT[22] = isoBandEdgeTR[22] = 23;
  12000. isoBandEdgeRT[82] = isoBandEdgeBR[82] = 8;
  12001. isoBandEdgeBL[82] = isoBandEdgeLT[82] = 19;
  12002. isoBandEdgeRT[88] = isoBandEdgeBR[88] = 8;
  12003. isoBandEdgeBL[88] = isoBandEdgeLT[88] = 19;
  12004. isoBandEdgeRT[73] = isoBandEdgeTL[73] = 0;
  12005. isoBandEdgeRB[73] = isoBandEdgeBL[73] = 13;
  12006. isoBandEdgeRT[97] = isoBandEdgeTL[97] = 0;
  12007. isoBandEdgeRB[97] = isoBandEdgeBL[97] = 13;
  12008. isoBandEdgeRT[145] = isoBandEdgeBL[145] = 9;
  12009. isoBandEdgeLB[145] = isoBandEdgeTR[145] = 21;
  12010. isoBandEdgeRT[25] = isoBandEdgeBL[25] = 9;
  12011. isoBandEdgeLB[25] = isoBandEdgeTR[25] = 21;
  12012. isoBandEdgeRB[70] = isoBandEdgeTL[70] = 1;
  12013. isoBandEdgeBR[70] = isoBandEdgeLT[70] = 17;
  12014. isoBandEdgeRB[100] = isoBandEdgeTL[100] = 1;
  12015. isoBandEdgeBR[100] = isoBandEdgeLT[100] = 17;
  12016. isoBandEdgeRT[34] = isoBandEdgeBL[34] = 9;
  12017. isoBandEdgeRB[34] = isoBandEdgeBR[34] = 12;
  12018. isoBandEdgeLB[34] = isoBandEdgeTR[34] = 21;
  12019. isoBandEdgeLT[34] = isoBandEdgeTL[34] = 22;
  12020. isoBandEdgeRT[136] = isoBandEdgeTR[136] = 4;
  12021. isoBandEdgeRB[136] = isoBandEdgeTL[136] = 1;
  12022. isoBandEdgeBR[136] = isoBandEdgeLT[136] = 17;
  12023. isoBandEdgeBL[136] = isoBandEdgeLB[136] = 18;
  12024. isoBandEdgeRT[35] = isoBandEdgeTR[35] = 4;
  12025. isoBandEdgeRB[35] = isoBandEdgeBR[35] = 12;
  12026. isoBandEdgeBL[35] = isoBandEdgeLB[35] = 18;
  12027. isoBandEdgeLT[35] = isoBandEdgeTL[35] = 22;
  12028. isoBandEdgeRT[153] = isoBandEdgeTR[153] = 4;
  12029. isoBandEdgeBL[153] = isoBandEdgeLB[153] = 18;
  12030. isoBandEdgeRB[102] = isoBandEdgeBR[102] = 12;
  12031. isoBandEdgeLT[102] = isoBandEdgeTL[102] = 22;
  12032. isoBandEdgeRT[155] = isoBandEdgeBL[155] = 9;
  12033. isoBandEdgeLB[155] = isoBandEdgeTR[155] = 23;
  12034. isoBandEdgeRB[103] = isoBandEdgeTL[103] = 1;
  12035. isoBandEdgeBR[103] = isoBandEdgeLT[103] = 17;
  12036. isoBandEdgeRT[152] = isoBandEdgeTR[152] = 4;
  12037. isoBandEdgeBR[152] = isoBandEdgeLT[152] = 17;
  12038. isoBandEdgeBL[152] = isoBandEdgeLB[152] = 18;
  12039. isoBandEdgeRT[156] = isoBandEdgeBR[156] = 8;
  12040. isoBandEdgeBL[156] = isoBandEdgeLB[156] = 18;
  12041. isoBandEdgeLT[156] = isoBandEdgeTR[156] = 23;
  12042. isoBandEdgeRT[137] = isoBandEdgeTR[137] = 4;
  12043. isoBandEdgeRB[137] = isoBandEdgeTL[137] = 1;
  12044. isoBandEdgeBL[137] = isoBandEdgeLB[137] = 18;
  12045. isoBandEdgeRT[139] = isoBandEdgeTR[139] = 4;
  12046. isoBandEdgeRB[139] = isoBandEdgeBL[139] = 13;
  12047. isoBandEdgeLB[139] = isoBandEdgeTL[139] = 20;
  12048. isoBandEdgeRT[98] = isoBandEdgeBL[98] = 9;
  12049. isoBandEdgeRB[98] = isoBandEdgeBR[98] = 12;
  12050. isoBandEdgeLT[98] = isoBandEdgeTL[98] = 22;
  12051. isoBandEdgeRT[99] = isoBandEdgeTL[99] = 0;
  12052. isoBandEdgeRB[99] = isoBandEdgeBR[99] = 12;
  12053. isoBandEdgeBL[99] = isoBandEdgeLT[99] = 19;
  12054. isoBandEdgeRB[38] = isoBandEdgeBR[38] = 12;
  12055. isoBandEdgeLB[38] = isoBandEdgeTR[38] = 21;
  12056. isoBandEdgeLT[38] = isoBandEdgeTL[38] = 22;
  12057. isoBandEdgeRB[39] = isoBandEdgeTR[39] = 5;
  12058. isoBandEdgeBR[39] = isoBandEdgeLB[39] = 16;
  12059. isoBandEdgeLT[39] = isoBandEdgeTL[39] = 22;
  12060. var polygon_table = [];
  12061. polygon_table[1] = polygon_table[169] = p00;
  12062. polygon_table[4] = polygon_table[166] = p01;
  12063. polygon_table[16] = polygon_table[154] = p02;
  12064. polygon_table[64] = polygon_table[106] = p03;
  12065. polygon_table[168] = polygon_table[2] = p04;
  12066. polygon_table[162] = polygon_table[8] = p05;
  12067. polygon_table[138] = polygon_table[32] = p06;
  12068. polygon_table[42] = polygon_table[128] = p07;
  12069. polygon_table[5] = polygon_table[165] = p08;
  12070. polygon_table[20] = polygon_table[150] = p09;
  12071. polygon_table[80] = polygon_table[90] = p10;
  12072. polygon_table[65] = polygon_table[105] = p11;
  12073. polygon_table[160] = polygon_table[10] = p12;
  12074. polygon_table[130] = polygon_table[40] = p13;
  12075. polygon_table[85] = p14;
  12076. polygon_table[101] = polygon_table[69] = p15;
  12077. polygon_table[149] = polygon_table[21] = p16;
  12078. polygon_table[86] = polygon_table[84] = p17;
  12079. polygon_table[89] = polygon_table[81] = p18;
  12080. polygon_table[96] = polygon_table[74] = p19;
  12081. polygon_table[24] = polygon_table[146] = p20;
  12082. polygon_table[6] = polygon_table[164] = p21;
  12083. polygon_table[129] = polygon_table[41] = p22;
  12084. polygon_table[66] = polygon_table[104] = p23;
  12085. polygon_table[144] = polygon_table[26] = p24;
  12086. polygon_table[36] = polygon_table[134] = p25;
  12087. polygon_table[9] = polygon_table[161] = p26;
  12088. polygon_table[37] = polygon_table[133] = p27;
  12089. polygon_table[148] = polygon_table[22] = p28;
  12090. polygon_table[82] = polygon_table[88] = p29;
  12091. polygon_table[73] = polygon_table[97] = p30;
  12092. polygon_table[145] = polygon_table[25] = p31;
  12093. polygon_table[70] = polygon_table[100] = p32;
  12094. polygon_table[34] = function(c) {
  12095. return [p07(c), p05(c)];
  12096. };
  12097. polygon_table[35] = p33;
  12098. polygon_table[136] = function(c) {
  12099. return [p06(c), p04(c)];
  12100. };
  12101. polygon_table[153] = function(c) {
  12102. return [p02(c), p00(c)];
  12103. };
  12104. polygon_table[102] = function(c) {
  12105. return [p01(c), p03(c)];
  12106. };
  12107. polygon_table[155] = p34;
  12108. polygon_table[103] = p35;
  12109. polygon_table[152] = function(c) {
  12110. return [p02(c), p04(c)];
  12111. };
  12112. polygon_table[156] = p36;
  12113. polygon_table[137] = function(c) {
  12114. return [p06(c), p00(c)];
  12115. };
  12116. polygon_table[139] = p37;
  12117. polygon_table[98] = function(c) {
  12118. return [p05(c), p03(c)];
  12119. };
  12120. polygon_table[99] = p38;
  12121. polygon_table[38] = function(c) {
  12122. return [p01(c), p07(c)];
  12123. };
  12124. polygon_table[39] = p39;
  12125. function interpolateX2(y2, y02, y12) {
  12126. return (y2 - y02) / (y12 - y02);
  12127. }
  12128. function isArray(myArray) {
  12129. return myArray.constructor.toString().indexOf("Array") > -1;
  12130. }
  12131. function computeBandGrid(data, minV, bandwidth) {
  12132. var rows = data.length - 1;
  12133. var cols = data[0].length - 1;
  12134. var BandGrid = { rows, cols, cells: [] };
  12135. var maxV = minV + Math.abs(bandwidth);
  12136. for (var j = 0; j < rows; ++j) {
  12137. BandGrid.cells[j] = [];
  12138. for (var i = 0; i < cols; ++i) {
  12139. var cval = 0;
  12140. var tl = data[j + 1][i];
  12141. var tr = data[j + 1][i + 1];
  12142. var br = data[j][i + 1];
  12143. var bl = data[j][i];
  12144. if (isNaN(tl) || isNaN(tr) || isNaN(br) || isNaN(bl)) {
  12145. continue;
  12146. }
  12147. cval |= tl < minV ? 0 : tl > maxV ? 128 : 64;
  12148. cval |= tr < minV ? 0 : tr > maxV ? 32 : 16;
  12149. cval |= br < minV ? 0 : br > maxV ? 8 : 4;
  12150. cval |= bl < minV ? 0 : bl > maxV ? 2 : 1;
  12151. var cval_real = +cval;
  12152. var flipped = 0;
  12153. if (cval === 17 || cval === 18 || cval === 33 || cval === 34 || cval === 38 || cval === 68 || cval === 72 || cval === 98 || cval === 102 || cval === 132 || cval === 136 || cval === 137 || cval === 152 || cval === 153) {
  12154. var average2 = (tl + tr + br + bl) / 4;
  12155. flipped = average2 > maxV ? 2 : average2 < minV ? 0 : 1;
  12156. if (cval === 34) {
  12157. if (flipped === 1) {
  12158. cval = 35;
  12159. } else if (flipped === 0) {
  12160. cval = 136;
  12161. }
  12162. } else if (cval === 136) {
  12163. if (flipped === 1) {
  12164. cval = 35;
  12165. flipped = 4;
  12166. } else if (flipped === 0) {
  12167. cval = 34;
  12168. }
  12169. } else if (cval === 17) {
  12170. if (flipped === 1) {
  12171. cval = 155;
  12172. flipped = 4;
  12173. } else if (flipped === 0) {
  12174. cval = 153;
  12175. }
  12176. } else if (cval === 68) {
  12177. if (flipped === 1) {
  12178. cval = 103;
  12179. flipped = 4;
  12180. } else if (flipped === 0) {
  12181. cval = 102;
  12182. }
  12183. } else if (cval === 153) {
  12184. if (flipped === 1)
  12185. cval = 155;
  12186. } else if (cval === 102) {
  12187. if (flipped === 1)
  12188. cval = 103;
  12189. } else if (cval === 152) {
  12190. if (flipped < 2) {
  12191. cval = 156;
  12192. flipped = 1;
  12193. }
  12194. } else if (cval === 137) {
  12195. if (flipped < 2) {
  12196. cval = 139;
  12197. flipped = 1;
  12198. }
  12199. } else if (cval === 98) {
  12200. if (flipped < 2) {
  12201. cval = 99;
  12202. flipped = 1;
  12203. }
  12204. } else if (cval === 38) {
  12205. if (flipped < 2) {
  12206. cval = 39;
  12207. flipped = 1;
  12208. }
  12209. } else if (cval === 18) {
  12210. if (flipped > 0) {
  12211. cval = 156;
  12212. flipped = 4;
  12213. } else {
  12214. cval = 152;
  12215. }
  12216. } else if (cval === 33) {
  12217. if (flipped > 0) {
  12218. cval = 139;
  12219. flipped = 4;
  12220. } else {
  12221. cval = 137;
  12222. }
  12223. } else if (cval === 72) {
  12224. if (flipped > 0) {
  12225. cval = 99;
  12226. flipped = 4;
  12227. } else {
  12228. cval = 98;
  12229. }
  12230. } else if (cval === 132) {
  12231. if (flipped > 0) {
  12232. cval = 39;
  12233. flipped = 4;
  12234. } else {
  12235. cval = 38;
  12236. }
  12237. }
  12238. }
  12239. if (cval != 0 && cval != 170) {
  12240. var topleft, topright, bottomleft, bottomright, righttop, rightbottom, lefttop, leftbottom;
  12241. topleft = topright = bottomleft = bottomright = righttop = rightbottom = lefttop = leftbottom = 0.5;
  12242. var edges2 = [];
  12243. if (cval === 1) {
  12244. bottomleft = 1 - interpolateX2(minV, br, bl);
  12245. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12246. edges2.push(isoBandEdgeBL[cval]);
  12247. } else if (cval === 169) {
  12248. bottomleft = interpolateX2(maxV, bl, br);
  12249. leftbottom = interpolateX2(maxV, bl, tl);
  12250. edges2.push(isoBandEdgeBL[cval]);
  12251. } else if (cval === 4) {
  12252. rightbottom = 1 - interpolateX2(minV, tr, br);
  12253. bottomright = interpolateX2(minV, bl, br);
  12254. edges2.push(isoBandEdgeRB[cval]);
  12255. } else if (cval === 166) {
  12256. rightbottom = interpolateX2(maxV, br, tr);
  12257. bottomright = 1 - interpolateX2(maxV, br, bl);
  12258. edges2.push(isoBandEdgeRB[cval]);
  12259. } else if (cval === 16) {
  12260. righttop = interpolateX2(minV, br, tr);
  12261. topright = interpolateX2(minV, tl, tr);
  12262. edges2.push(isoBandEdgeRT[cval]);
  12263. } else if (cval === 154) {
  12264. righttop = 1 - interpolateX2(maxV, tr, br);
  12265. topright = 1 - interpolateX2(maxV, tr, tl);
  12266. edges2.push(isoBandEdgeRT[cval]);
  12267. } else if (cval === 64) {
  12268. lefttop = interpolateX2(minV, bl, tl);
  12269. topleft = 1 - interpolateX2(minV, tr, tl);
  12270. edges2.push(isoBandEdgeLT[cval]);
  12271. } else if (cval === 106) {
  12272. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12273. topleft = interpolateX2(maxV, tl, tr);
  12274. edges2.push(isoBandEdgeLT[cval]);
  12275. } else if (cval === 168) {
  12276. bottomright = interpolateX2(maxV, bl, br);
  12277. bottomleft = interpolateX2(minV, bl, br);
  12278. leftbottom = interpolateX2(minV, bl, tl);
  12279. lefttop = interpolateX2(maxV, bl, tl);
  12280. edges2.push(isoBandEdgeBR[cval]);
  12281. edges2.push(isoBandEdgeBL[cval]);
  12282. } else if (cval === 2) {
  12283. bottomright = 1 - interpolateX2(minV, br, bl);
  12284. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12285. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12286. lefttop = 1 - interpolateX2(minV, tl, bl);
  12287. edges2.push(isoBandEdgeBR[cval]);
  12288. edges2.push(isoBandEdgeBL[cval]);
  12289. } else if (cval === 162) {
  12290. righttop = interpolateX2(maxV, br, tr);
  12291. rightbottom = interpolateX2(minV, br, tr);
  12292. bottomright = 1 - interpolateX2(minV, br, bl);
  12293. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12294. edges2.push(isoBandEdgeBR[cval]);
  12295. edges2.push(isoBandEdgeBL[cval]);
  12296. } else if (cval === 8) {
  12297. righttop = 1 - interpolateX2(minV, tr, br);
  12298. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12299. bottomright = interpolateX2(maxV, bl, br);
  12300. bottomleft = interpolateX2(minV, bl, br);
  12301. edges2.push(isoBandEdgeRT[cval]);
  12302. edges2.push(isoBandEdgeRB[cval]);
  12303. } else if (cval === 138) {
  12304. righttop = 1 - interpolateX2(minV, tr, br);
  12305. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12306. topleft = 1 - interpolateX2(maxV, tr, tl);
  12307. topright = 1 - interpolateX2(minV, tr, tl);
  12308. edges2.push(isoBandEdgeRT[cval]);
  12309. edges2.push(isoBandEdgeRB[cval]);
  12310. } else if (cval === 32) {
  12311. righttop = interpolateX2(maxV, br, tr);
  12312. rightbottom = interpolateX2(minV, br, tr);
  12313. topleft = interpolateX2(minV, tl, tr);
  12314. topright = interpolateX2(maxV, tl, tr);
  12315. edges2.push(isoBandEdgeRT[cval]);
  12316. edges2.push(isoBandEdgeRB[cval]);
  12317. } else if (cval === 42) {
  12318. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12319. lefttop = 1 - interpolateX2(minV, tl, bl);
  12320. topleft = interpolateX2(minV, tl, tr);
  12321. topright = interpolateX2(maxV, tl, tr);
  12322. edges2.push(isoBandEdgeLB[cval]);
  12323. edges2.push(isoBandEdgeLT[cval]);
  12324. } else if (cval === 128) {
  12325. leftbottom = interpolateX2(minV, bl, tl);
  12326. lefttop = interpolateX2(maxV, bl, tl);
  12327. topleft = 1 - interpolateX2(maxV, tr, tl);
  12328. topright = 1 - interpolateX2(minV, tr, tl);
  12329. edges2.push(isoBandEdgeLB[cval]);
  12330. edges2.push(isoBandEdgeLT[cval]);
  12331. }
  12332. if (cval === 5) {
  12333. rightbottom = 1 - interpolateX2(minV, tr, br);
  12334. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12335. edges2.push(isoBandEdgeRB[cval]);
  12336. } else if (cval === 165) {
  12337. rightbottom = interpolateX2(maxV, br, tr);
  12338. leftbottom = interpolateX2(maxV, bl, tl);
  12339. edges2.push(isoBandEdgeRB[cval]);
  12340. } else if (cval === 20) {
  12341. bottomright = interpolateX2(minV, bl, br);
  12342. topright = interpolateX2(minV, tl, tr);
  12343. edges2.push(isoBandEdgeBR[cval]);
  12344. } else if (cval === 150) {
  12345. bottomright = 1 - interpolateX2(maxV, br, bl);
  12346. topright = 1 - interpolateX2(maxV, tr, tl);
  12347. edges2.push(isoBandEdgeBR[cval]);
  12348. } else if (cval === 80) {
  12349. righttop = interpolateX2(minV, br, tr);
  12350. lefttop = interpolateX2(minV, bl, tl);
  12351. edges2.push(isoBandEdgeRT[cval]);
  12352. } else if (cval === 90) {
  12353. righttop = 1 - interpolateX2(maxV, tr, br);
  12354. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12355. edges2.push(isoBandEdgeRT[cval]);
  12356. } else if (cval === 65) {
  12357. bottomleft = 1 - interpolateX2(minV, br, bl);
  12358. topleft = 1 - interpolateX2(minV, tr, tl);
  12359. edges2.push(isoBandEdgeBL[cval]);
  12360. } else if (cval === 105) {
  12361. bottomleft = interpolateX2(maxV, bl, br);
  12362. topleft = interpolateX2(maxV, tl, tr);
  12363. edges2.push(isoBandEdgeBL[cval]);
  12364. } else if (cval === 160) {
  12365. righttop = interpolateX2(maxV, br, tr);
  12366. rightbottom = interpolateX2(minV, br, tr);
  12367. leftbottom = interpolateX2(minV, bl, tl);
  12368. lefttop = interpolateX2(maxV, bl, tl);
  12369. edges2.push(isoBandEdgeRT[cval]);
  12370. edges2.push(isoBandEdgeRB[cval]);
  12371. } else if (cval === 10) {
  12372. righttop = 1 - interpolateX2(minV, tr, br);
  12373. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12374. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12375. lefttop = 1 - interpolateX2(minV, tl, bl);
  12376. edges2.push(isoBandEdgeRT[cval]);
  12377. edges2.push(isoBandEdgeRB[cval]);
  12378. } else if (cval === 130) {
  12379. bottomright = 1 - interpolateX2(minV, br, bl);
  12380. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12381. topleft = 1 - interpolateX2(maxV, tr, tl);
  12382. topright = 1 - interpolateX2(minV, tr, tl);
  12383. edges2.push(isoBandEdgeBR[cval]);
  12384. edges2.push(isoBandEdgeBL[cval]);
  12385. } else if (cval === 40) {
  12386. bottomright = interpolateX2(maxV, bl, br);
  12387. bottomleft = interpolateX2(minV, bl, br);
  12388. topleft = interpolateX2(minV, tl, tr);
  12389. topright = interpolateX2(maxV, tl, tr);
  12390. edges2.push(isoBandEdgeBR[cval]);
  12391. edges2.push(isoBandEdgeBL[cval]);
  12392. } else if (cval === 101) {
  12393. rightbottom = interpolateX2(maxV, br, tr);
  12394. topleft = interpolateX2(maxV, tl, tr);
  12395. edges2.push(isoBandEdgeRB[cval]);
  12396. } else if (cval === 69) {
  12397. rightbottom = 1 - interpolateX2(minV, tr, br);
  12398. topleft = 1 - interpolateX2(minV, tr, tl);
  12399. edges2.push(isoBandEdgeRB[cval]);
  12400. } else if (cval === 149) {
  12401. leftbottom = interpolateX2(maxV, bl, tl);
  12402. topright = 1 - interpolateX2(maxV, tr, tl);
  12403. edges2.push(isoBandEdgeLB[cval]);
  12404. } else if (cval === 21) {
  12405. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12406. topright = interpolateX2(minV, tl, tr);
  12407. edges2.push(isoBandEdgeLB[cval]);
  12408. } else if (cval === 86) {
  12409. bottomright = 1 - interpolateX2(maxV, br, bl);
  12410. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12411. edges2.push(isoBandEdgeBR[cval]);
  12412. } else if (cval === 84) {
  12413. bottomright = interpolateX2(minV, bl, br);
  12414. lefttop = interpolateX2(minV, bl, tl);
  12415. edges2.push(isoBandEdgeBR[cval]);
  12416. } else if (cval === 89) {
  12417. righttop = 1 - interpolateX2(maxV, tr, br);
  12418. bottomleft = interpolateX2(maxV, bl, br);
  12419. edges2.push(isoBandEdgeBL[cval]);
  12420. } else if (cval === 81) {
  12421. righttop = interpolateX2(minV, br, tr);
  12422. bottomleft = 1 - interpolateX2(minV, br, bl);
  12423. edges2.push(isoBandEdgeBL[cval]);
  12424. } else if (cval === 96) {
  12425. righttop = interpolateX2(maxV, br, tr);
  12426. rightbottom = interpolateX2(minV, br, tr);
  12427. lefttop = interpolateX2(minV, bl, tl);
  12428. topleft = interpolateX2(maxV, tl, tr);
  12429. edges2.push(isoBandEdgeRT[cval]);
  12430. edges2.push(isoBandEdgeRB[cval]);
  12431. } else if (cval === 74) {
  12432. righttop = 1 - interpolateX2(minV, tr, br);
  12433. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12434. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12435. topleft = 1 - interpolateX2(minV, tr, tl);
  12436. edges2.push(isoBandEdgeRT[cval]);
  12437. edges2.push(isoBandEdgeRB[cval]);
  12438. } else if (cval === 24) {
  12439. righttop = 1 - interpolateX2(maxV, tr, br);
  12440. bottomright = interpolateX2(maxV, bl, br);
  12441. bottomleft = interpolateX2(minV, bl, br);
  12442. topright = interpolateX2(minV, tl, tr);
  12443. edges2.push(isoBandEdgeRT[cval]);
  12444. edges2.push(isoBandEdgeBL[cval]);
  12445. } else if (cval === 146) {
  12446. righttop = interpolateX2(minV, br, tr);
  12447. bottomright = 1 - interpolateX2(minV, br, bl);
  12448. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12449. topright = 1 - interpolateX2(maxV, tr, tl);
  12450. edges2.push(isoBandEdgeRT[cval]);
  12451. edges2.push(isoBandEdgeBL[cval]);
  12452. } else if (cval === 6) {
  12453. rightbottom = 1 - interpolateX2(minV, tr, br);
  12454. bottomright = 1 - interpolateX2(maxV, br, bl);
  12455. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12456. lefttop = 1 - interpolateX2(minV, tl, bl);
  12457. edges2.push(isoBandEdgeRB[cval]);
  12458. edges2.push(isoBandEdgeBR[cval]);
  12459. } else if (cval === 164) {
  12460. rightbottom = interpolateX2(maxV, br, tr);
  12461. bottomright = interpolateX2(minV, bl, br);
  12462. leftbottom = interpolateX2(minV, bl, tl);
  12463. lefttop = interpolateX2(maxV, bl, tl);
  12464. edges2.push(isoBandEdgeRB[cval]);
  12465. edges2.push(isoBandEdgeBR[cval]);
  12466. } else if (cval === 129) {
  12467. bottomleft = 1 - interpolateX2(minV, br, bl);
  12468. leftbottom = interpolateX2(maxV, bl, tl);
  12469. topleft = 1 - interpolateX2(maxV, tr, tl);
  12470. topright = 1 - interpolateX2(minV, tr, tl);
  12471. edges2.push(isoBandEdgeBL[cval]);
  12472. edges2.push(isoBandEdgeLB[cval]);
  12473. } else if (cval === 41) {
  12474. bottomleft = interpolateX2(maxV, bl, br);
  12475. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12476. topleft = interpolateX2(minV, tl, tr);
  12477. topright = interpolateX2(maxV, tl, tr);
  12478. edges2.push(isoBandEdgeBL[cval]);
  12479. edges2.push(isoBandEdgeLB[cval]);
  12480. } else if (cval === 66) {
  12481. bottomright = 1 - interpolateX2(minV, br, bl);
  12482. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12483. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12484. topleft = 1 - interpolateX2(minV, tr, tl);
  12485. edges2.push(isoBandEdgeBR[cval]);
  12486. edges2.push(isoBandEdgeBL[cval]);
  12487. } else if (cval === 104) {
  12488. bottomright = interpolateX2(maxV, bl, br);
  12489. bottomleft = interpolateX2(minV, bl, br);
  12490. lefttop = interpolateX2(minV, bl, tl);
  12491. topleft = interpolateX2(maxV, tl, tr);
  12492. edges2.push(isoBandEdgeBL[cval]);
  12493. edges2.push(isoBandEdgeTL[cval]);
  12494. } else if (cval === 144) {
  12495. righttop = interpolateX2(minV, br, tr);
  12496. leftbottom = interpolateX2(minV, bl, tl);
  12497. lefttop = interpolateX2(maxV, bl, tl);
  12498. topright = 1 - interpolateX2(maxV, tr, tl);
  12499. edges2.push(isoBandEdgeRT[cval]);
  12500. edges2.push(isoBandEdgeLT[cval]);
  12501. } else if (cval === 26) {
  12502. righttop = 1 - interpolateX2(maxV, tr, br);
  12503. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12504. lefttop = 1 - interpolateX2(minV, tl, bl);
  12505. topright = interpolateX2(minV, tl, tr);
  12506. edges2.push(isoBandEdgeRT[cval]);
  12507. edges2.push(isoBandEdgeLT[cval]);
  12508. } else if (cval === 36) {
  12509. rightbottom = interpolateX2(maxV, br, tr);
  12510. bottomright = interpolateX2(minV, bl, br);
  12511. topleft = interpolateX2(minV, tl, tr);
  12512. topright = interpolateX2(maxV, tl, tr);
  12513. edges2.push(isoBandEdgeRB[cval]);
  12514. edges2.push(isoBandEdgeBR[cval]);
  12515. } else if (cval === 134) {
  12516. rightbottom = 1 - interpolateX2(minV, tr, br);
  12517. bottomright = 1 - interpolateX2(maxV, br, bl);
  12518. topleft = 1 - interpolateX2(maxV, tr, tl);
  12519. topright = 1 - interpolateX2(minV, tr, tl);
  12520. edges2.push(isoBandEdgeRB[cval]);
  12521. edges2.push(isoBandEdgeBR[cval]);
  12522. } else if (cval === 9) {
  12523. righttop = 1 - interpolateX2(minV, tr, br);
  12524. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12525. bottomleft = interpolateX2(maxV, bl, br);
  12526. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12527. edges2.push(isoBandEdgeRT[cval]);
  12528. edges2.push(isoBandEdgeRB[cval]);
  12529. } else if (cval === 161) {
  12530. righttop = interpolateX2(maxV, br, tr);
  12531. rightbottom = interpolateX2(minV, br, tr);
  12532. bottomleft = 1 - interpolateX2(minV, br, bl);
  12533. leftbottom = interpolateX2(maxV, bl, tl);
  12534. edges2.push(isoBandEdgeRT[cval]);
  12535. edges2.push(isoBandEdgeRB[cval]);
  12536. } else if (cval === 37) {
  12537. rightbottom = interpolateX2(maxV, br, tr);
  12538. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12539. topleft = interpolateX2(minV, tl, tr);
  12540. topright = interpolateX2(maxV, tl, tr);
  12541. edges2.push(isoBandEdgeRB[cval]);
  12542. edges2.push(isoBandEdgeLB[cval]);
  12543. } else if (cval === 133) {
  12544. rightbottom = 1 - interpolateX2(minV, tr, br);
  12545. leftbottom = interpolateX2(maxV, bl, tl);
  12546. topleft = 1 - interpolateX2(maxV, tr, tl);
  12547. topright = 1 - interpolateX2(minV, tr, tl);
  12548. edges2.push(isoBandEdgeRB[cval]);
  12549. edges2.push(isoBandEdgeLB[cval]);
  12550. } else if (cval === 148) {
  12551. bottomright = interpolateX2(minV, bl, br);
  12552. leftbottom = interpolateX2(minV, bl, tl);
  12553. lefttop = interpolateX2(maxV, bl, tl);
  12554. topright = 1 - interpolateX2(maxV, tr, tl);
  12555. edges2.push(isoBandEdgeBR[cval]);
  12556. edges2.push(isoBandEdgeLT[cval]);
  12557. } else if (cval === 22) {
  12558. bottomright = 1 - interpolateX2(maxV, br, bl);
  12559. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12560. lefttop = 1 - interpolateX2(minV, tl, bl);
  12561. topright = interpolateX2(minV, tl, tr);
  12562. edges2.push(isoBandEdgeBR[cval]);
  12563. edges2.push(isoBandEdgeLT[cval]);
  12564. } else if (cval === 82) {
  12565. righttop = interpolateX2(minV, br, tr);
  12566. bottomright = 1 - interpolateX2(minV, br, bl);
  12567. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12568. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12569. edges2.push(isoBandEdgeRT[cval]);
  12570. edges2.push(isoBandEdgeBL[cval]);
  12571. } else if (cval === 88) {
  12572. righttop = 1 - interpolateX2(maxV, tr, br);
  12573. bottomright = interpolateX2(maxV, bl, br);
  12574. bottomleft = interpolateX2(minV, bl, br);
  12575. lefttop = interpolateX2(minV, bl, tl);
  12576. edges2.push(isoBandEdgeRT[cval]);
  12577. edges2.push(isoBandEdgeBL[cval]);
  12578. } else if (cval === 73) {
  12579. righttop = 1 - interpolateX2(minV, tr, br);
  12580. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12581. bottomleft = interpolateX2(maxV, bl, br);
  12582. topleft = 1 - interpolateX2(minV, tr, tl);
  12583. edges2.push(isoBandEdgeRT[cval]);
  12584. edges2.push(isoBandEdgeRB[cval]);
  12585. } else if (cval === 97) {
  12586. righttop = interpolateX2(maxV, br, tr);
  12587. rightbottom = interpolateX2(minV, br, tr);
  12588. bottomleft = 1 - interpolateX2(minV, br, bl);
  12589. topleft = interpolateX2(maxV, tl, tr);
  12590. edges2.push(isoBandEdgeRT[cval]);
  12591. edges2.push(isoBandEdgeRB[cval]);
  12592. } else if (cval === 145) {
  12593. righttop = interpolateX2(minV, br, tr);
  12594. bottomleft = 1 - interpolateX2(minV, br, bl);
  12595. leftbottom = interpolateX2(maxV, bl, tl);
  12596. topright = 1 - interpolateX2(maxV, tr, tl);
  12597. edges2.push(isoBandEdgeRT[cval]);
  12598. edges2.push(isoBandEdgeLB[cval]);
  12599. } else if (cval === 25) {
  12600. righttop = 1 - interpolateX2(maxV, tr, br);
  12601. bottomleft = interpolateX2(maxV, bl, br);
  12602. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12603. topright = interpolateX2(minV, tl, tr);
  12604. edges2.push(isoBandEdgeRT[cval]);
  12605. edges2.push(isoBandEdgeLB[cval]);
  12606. } else if (cval === 70) {
  12607. rightbottom = 1 - interpolateX2(minV, tr, br);
  12608. bottomright = 1 - interpolateX2(maxV, br, bl);
  12609. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12610. topleft = 1 - interpolateX2(minV, tr, tl);
  12611. edges2.push(isoBandEdgeRB[cval]);
  12612. edges2.push(isoBandEdgeBR[cval]);
  12613. } else if (cval === 100) {
  12614. rightbottom = interpolateX2(maxV, br, tr);
  12615. bottomright = interpolateX2(minV, bl, br);
  12616. lefttop = interpolateX2(minV, bl, tl);
  12617. topleft = interpolateX2(maxV, tl, tr);
  12618. edges2.push(isoBandEdgeRB[cval]);
  12619. edges2.push(isoBandEdgeBR[cval]);
  12620. } else if (cval === 34) {
  12621. if (flipped === 0) {
  12622. righttop = 1 - interpolateX2(minV, tr, br);
  12623. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12624. bottomright = interpolateX2(maxV, bl, br);
  12625. bottomleft = interpolateX2(minV, bl, br);
  12626. leftbottom = interpolateX2(minV, bl, tl);
  12627. lefttop = interpolateX2(maxV, bl, tl);
  12628. topleft = 1 - interpolateX2(maxV, tr, tl);
  12629. topright = 1 - interpolateX2(minV, tr, tl);
  12630. } else {
  12631. righttop = interpolateX2(maxV, br, tr);
  12632. rightbottom = interpolateX2(minV, br, tr);
  12633. bottomright = 1 - interpolateX2(minV, br, bl);
  12634. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12635. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12636. lefttop = 1 - interpolateX2(minV, tl, bl);
  12637. topleft = interpolateX2(minV, tl, tr);
  12638. topright = interpolateX2(maxV, tl, tr);
  12639. }
  12640. edges2.push(isoBandEdgeRT[cval]);
  12641. edges2.push(isoBandEdgeRB[cval]);
  12642. edges2.push(isoBandEdgeLB[cval]);
  12643. edges2.push(isoBandEdgeLT[cval]);
  12644. } else if (cval === 35) {
  12645. if (flipped === 4) {
  12646. righttop = 1 - interpolateX2(minV, tr, br);
  12647. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12648. bottomright = interpolateX2(maxV, bl, br);
  12649. bottomleft = interpolateX2(minV, bl, br);
  12650. leftbottom = interpolateX2(minV, bl, tl);
  12651. lefttop = interpolateX2(maxV, bl, tl);
  12652. topleft = 1 - interpolateX2(maxV, tr, tl);
  12653. topright = 1 - interpolateX2(minV, tr, tl);
  12654. } else {
  12655. righttop = interpolateX2(maxV, br, tr);
  12656. rightbottom = interpolateX2(minV, br, tr);
  12657. bottomright = 1 - interpolateX2(minV, br, bl);
  12658. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12659. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12660. lefttop = 1 - interpolateX2(minV, tl, bl);
  12661. topleft = interpolateX2(minV, tl, tr);
  12662. topright = interpolateX2(maxV, tl, tr);
  12663. }
  12664. edges2.push(isoBandEdgeRT[cval]);
  12665. edges2.push(isoBandEdgeRB[cval]);
  12666. edges2.push(isoBandEdgeBL[cval]);
  12667. edges2.push(isoBandEdgeLT[cval]);
  12668. } else if (cval === 136) {
  12669. if (flipped === 0) {
  12670. righttop = interpolateX2(maxV, br, tr);
  12671. rightbottom = interpolateX2(minV, br, tr);
  12672. bottomright = 1 - interpolateX2(minV, br, bl);
  12673. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12674. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12675. lefttop = 1 - interpolateX2(minV, tl, bl);
  12676. topleft = interpolateX2(minV, tl, tr);
  12677. topright = interpolateX2(maxV, tl, tr);
  12678. } else {
  12679. righttop = 1 - interpolateX2(minV, tr, br);
  12680. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12681. bottomright = interpolateX2(maxV, bl, br);
  12682. bottomleft = interpolateX2(minV, bl, br);
  12683. leftbottom = interpolateX2(minV, bl, tl);
  12684. lefttop = interpolateX2(maxV, bl, tl);
  12685. topleft = 1 - interpolateX2(maxV, tr, tl);
  12686. topright = 1 - interpolateX2(minV, tr, tl);
  12687. }
  12688. edges2.push(isoBandEdgeRT[cval]);
  12689. edges2.push(isoBandEdgeRB[cval]);
  12690. edges2.push(isoBandEdgeLB[cval]);
  12691. edges2.push(isoBandEdgeLT[cval]);
  12692. } else if (cval === 153) {
  12693. if (flipped === 0) {
  12694. righttop = interpolateX2(minV, br, tr);
  12695. bottomleft = 1 - interpolateX2(minV, br, bl);
  12696. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12697. topright = interpolateX2(minV, tl, tr);
  12698. } else {
  12699. righttop = 1 - interpolateX2(maxV, tr, br);
  12700. bottomleft = interpolateX2(maxV, bl, br);
  12701. leftbottom = interpolateX2(maxV, bl, tl);
  12702. topright = 1 - interpolateX2(maxV, tr, tl);
  12703. }
  12704. edges2.push(isoBandEdgeRT[cval]);
  12705. edges2.push(isoBandEdgeBL[cval]);
  12706. } else if (cval === 102) {
  12707. if (flipped === 0) {
  12708. rightbottom = 1 - interpolateX2(minV, tr, br);
  12709. bottomright = interpolateX2(minV, bl, br);
  12710. lefttop = interpolateX2(minV, bl, tl);
  12711. topleft = 1 - interpolateX2(minV, tr, tl);
  12712. } else {
  12713. rightbottom = interpolateX2(maxV, br, tr);
  12714. bottomright = 1 - interpolateX2(maxV, br, bl);
  12715. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12716. topleft = interpolateX2(maxV, tl, tr);
  12717. }
  12718. edges2.push(isoBandEdgeRB[cval]);
  12719. edges2.push(isoBandEdgeLT[cval]);
  12720. } else if (cval === 155) {
  12721. if (flipped === 4) {
  12722. righttop = interpolateX2(minV, br, tr);
  12723. bottomleft = 1 - interpolateX2(minV, br, bl);
  12724. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12725. topright = interpolateX2(minV, tl, tr);
  12726. } else {
  12727. righttop = 1 - interpolateX2(maxV, tr, br);
  12728. bottomleft = interpolateX2(maxV, bl, br);
  12729. leftbottom = interpolateX2(maxV, bl, tl);
  12730. topright = 1 - interpolateX2(maxV, tr, tl);
  12731. }
  12732. edges2.push(isoBandEdgeRT[cval]);
  12733. edges2.push(isoBandEdgeLB[cval]);
  12734. } else if (cval === 103) {
  12735. if (flipped === 4) {
  12736. rightbottom = 1 - interpolateX2(minV, tr, br);
  12737. bottomright = interpolateX2(minV, bl, br);
  12738. lefttop = interpolateX2(minV, bl, tl);
  12739. topleft = 1 - interpolateX2(minV, tr, tl);
  12740. } else {
  12741. rightbottom = interpolateX2(maxV, br, tr);
  12742. bottomright = 1 - interpolateX2(maxV, br, bl);
  12743. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12744. topleft = interpolateX2(maxV, tl, tr);
  12745. }
  12746. edges2.push(isoBandEdgeRB[cval]);
  12747. edges2.push(isoBandEdgeBR[cval]);
  12748. } else if (cval === 152) {
  12749. if (flipped === 0) {
  12750. righttop = interpolateX2(minV, br, tr);
  12751. bottomright = 1 - interpolateX2(minV, br, bl);
  12752. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12753. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12754. lefttop = 1 - interpolateX2(minV, tl, bl);
  12755. topright = interpolateX2(minV, tl, tr);
  12756. } else {
  12757. righttop = 1 - interpolateX2(maxV, tr, br);
  12758. bottomright = interpolateX2(maxV, bl, br);
  12759. bottomleft = interpolateX2(minV, bl, br);
  12760. leftbottom = interpolateX2(minV, bl, tl);
  12761. lefttop = interpolateX2(maxV, bl, tl);
  12762. topright = 1 - interpolateX2(maxV, tr, tl);
  12763. }
  12764. edges2.push(isoBandEdgeRT[cval]);
  12765. edges2.push(isoBandEdgeBR[cval]);
  12766. edges2.push(isoBandEdgeBL[cval]);
  12767. } else if (cval === 156) {
  12768. if (flipped === 4) {
  12769. righttop = interpolateX2(minV, br, tr);
  12770. bottomright = 1 - interpolateX2(minV, br, bl);
  12771. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12772. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12773. lefttop = 1 - interpolateX2(minV, tl, bl);
  12774. topright = interpolateX2(minV, tl, tr);
  12775. } else {
  12776. righttop = 1 - interpolateX2(maxV, tr, br);
  12777. bottomright = interpolateX2(maxV, bl, br);
  12778. bottomleft = interpolateX2(minV, bl, br);
  12779. leftbottom = interpolateX2(minV, bl, tl);
  12780. lefttop = interpolateX2(maxV, bl, tl);
  12781. topright = 1 - interpolateX2(maxV, tr, tl);
  12782. }
  12783. edges2.push(isoBandEdgeRT[cval]);
  12784. edges2.push(isoBandEdgeBL[cval]);
  12785. edges2.push(isoBandEdgeLT[cval]);
  12786. } else if (cval === 137) {
  12787. if (flipped === 0) {
  12788. righttop = interpolateX2(maxV, br, tr);
  12789. rightbottom = interpolateX2(minV, br, tr);
  12790. bottomleft = 1 - interpolateX2(minV, br, bl);
  12791. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12792. topleft = interpolateX2(minV, tl, tr);
  12793. topright = interpolateX2(maxV, tl, tr);
  12794. } else {
  12795. righttop = 1 - interpolateX2(minV, tr, br);
  12796. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12797. bottomleft = interpolateX2(maxV, bl, br);
  12798. leftbottom = interpolateX2(maxV, bl, tl);
  12799. topleft = 1 - interpolateX2(maxV, tr, tl);
  12800. topright = 1 - interpolateX2(minV, tr, tl);
  12801. }
  12802. edges2.push(isoBandEdgeRT[cval]);
  12803. edges2.push(isoBandEdgeRB[cval]);
  12804. edges2.push(isoBandEdgeBL[cval]);
  12805. } else if (cval === 139) {
  12806. if (flipped === 4) {
  12807. righttop = interpolateX2(maxV, br, tr);
  12808. rightbottom = interpolateX2(minV, br, tr);
  12809. bottomleft = 1 - interpolateX2(minV, br, bl);
  12810. leftbottom = 1 - interpolateX2(minV, tl, bl);
  12811. topleft = interpolateX2(minV, tl, tr);
  12812. topright = interpolateX2(maxV, tl, tr);
  12813. } else {
  12814. righttop = 1 - interpolateX2(minV, tr, br);
  12815. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12816. bottomleft = interpolateX2(maxV, bl, br);
  12817. leftbottom = interpolateX2(maxV, bl, tl);
  12818. topleft = 1 - interpolateX2(maxV, tr, tl);
  12819. topright = 1 - interpolateX2(minV, tr, tl);
  12820. }
  12821. edges2.push(isoBandEdgeRT[cval]);
  12822. edges2.push(isoBandEdgeRB[cval]);
  12823. edges2.push(isoBandEdgeLB[cval]);
  12824. } else if (cval === 98) {
  12825. if (flipped === 0) {
  12826. righttop = 1 - interpolateX2(minV, tr, br);
  12827. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12828. bottomright = interpolateX2(maxV, bl, br);
  12829. bottomleft = interpolateX2(minV, bl, br);
  12830. lefttop = interpolateX2(minV, bl, tl);
  12831. topleft = 1 - interpolateX2(minV, tr, tl);
  12832. } else {
  12833. righttop = interpolateX2(maxV, br, tr);
  12834. rightbottom = interpolateX2(minV, br, tr);
  12835. bottomright = 1 - interpolateX2(minV, br, bl);
  12836. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12837. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12838. topleft = interpolateX2(maxV, tl, tr);
  12839. }
  12840. edges2.push(isoBandEdgeRT[cval]);
  12841. edges2.push(isoBandEdgeRB[cval]);
  12842. edges2.push(isoBandEdgeLT[cval]);
  12843. } else if (cval === 99) {
  12844. if (flipped === 4) {
  12845. righttop = 1 - interpolateX2(minV, tr, br);
  12846. rightbottom = 1 - interpolateX2(maxV, tr, br);
  12847. bottomright = interpolateX2(maxV, bl, br);
  12848. bottomleft = interpolateX2(minV, bl, br);
  12849. lefttop = interpolateX2(minV, bl, tl);
  12850. topleft = 1 - interpolateX2(minV, tr, tl);
  12851. } else {
  12852. righttop = interpolateX2(maxV, br, tr);
  12853. rightbottom = interpolateX2(minV, br, tr);
  12854. bottomright = 1 - interpolateX2(minV, br, bl);
  12855. bottomleft = 1 - interpolateX2(maxV, br, bl);
  12856. lefttop = 1 - interpolateX2(maxV, tl, bl);
  12857. topleft = interpolateX2(maxV, tl, tr);
  12858. }
  12859. edges2.push(isoBandEdgeRT[cval]);
  12860. edges2.push(isoBandEdgeRB[cval]);
  12861. edges2.push(isoBandEdgeBL[cval]);
  12862. } else if (cval === 38) {
  12863. if (flipped === 0) {
  12864. rightbottom = 1 - interpolateX2(minV, tr, br);
  12865. bottomright = interpolateX2(minV, bl, br);
  12866. leftbottom = interpolateX2(minV, bl, tl);
  12867. lefttop = interpolateX2(maxV, bl, tl);
  12868. topleft = 1 - interpolateX2(maxV, tr, tl);
  12869. topright = 1 - interpolateX2(minV, tr, tl);
  12870. } else {
  12871. rightbottom = interpolateX2(maxV, br, tr);
  12872. bottomright = 1 - interpolateX2(maxV, br, bl);
  12873. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12874. lefttop = 1 - interpolateX2(minV, tl, bl);
  12875. topleft = interpolateX2(minV, tl, tr);
  12876. topright = interpolateX2(maxV, tl, tr);
  12877. }
  12878. edges2.push(isoBandEdgeRB[cval]);
  12879. edges2.push(isoBandEdgeLB[cval]);
  12880. edges2.push(isoBandEdgeLT[cval]);
  12881. } else if (cval === 39) {
  12882. if (flipped === 4) {
  12883. rightbottom = 1 - interpolateX2(minV, tr, br);
  12884. bottomright = interpolateX2(minV, bl, br);
  12885. leftbottom = interpolateX2(minV, bl, tl);
  12886. lefttop = interpolateX2(maxV, bl, tl);
  12887. topleft = 1 - interpolateX2(maxV, tr, tl);
  12888. topright = 1 - interpolateX2(minV, tr, tl);
  12889. } else {
  12890. rightbottom = interpolateX2(maxV, br, tr);
  12891. bottomright = 1 - interpolateX2(maxV, br, bl);
  12892. leftbottom = 1 - interpolateX2(maxV, tl, bl);
  12893. lefttop = 1 - interpolateX2(minV, tl, bl);
  12894. topleft = interpolateX2(minV, tl, tr);
  12895. topright = interpolateX2(maxV, tl, tr);
  12896. }
  12897. edges2.push(isoBandEdgeRB[cval]);
  12898. edges2.push(isoBandEdgeBR[cval]);
  12899. edges2.push(isoBandEdgeLT[cval]);
  12900. } else if (cval === 85) {
  12901. righttop = 1;
  12902. rightbottom = 0;
  12903. bottomright = 1;
  12904. bottomleft = 0;
  12905. leftbottom = 0;
  12906. lefttop = 1;
  12907. topleft = 0;
  12908. topright = 1;
  12909. }
  12910. if (topleft < 0 || topleft > 1 || topright < 0 || topright > 1 || righttop < 0 || righttop > 1 || bottomright < 0 || bottomright > 1 || leftbottom < 0 || leftbottom > 1 || lefttop < 0 || lefttop > 1) {
  12911. console.log(
  12912. "MarchingSquaresJS-isoBands: " + cval + " " + cval_real + " " + tl + "," + tr + "," + br + "," + bl + " " + flipped + " " + topleft + " " + topright + " " + righttop + " " + rightbottom + " " + bottomright + " " + bottomleft + " " + leftbottom + " " + lefttop
  12913. );
  12914. }
  12915. BandGrid.cells[j][i] = {
  12916. cval,
  12917. cval_real,
  12918. flipped,
  12919. topleft,
  12920. topright,
  12921. righttop,
  12922. rightbottom,
  12923. bottomright,
  12924. bottomleft,
  12925. leftbottom,
  12926. lefttop,
  12927. edges: edges2
  12928. };
  12929. }
  12930. }
  12931. }
  12932. return BandGrid;
  12933. }
  12934. function BandGrid2AreaPaths(grid) {
  12935. var areas = [];
  12936. var rows = grid.rows;
  12937. var cols = grid.cols;
  12938. var currentPolygon = [];
  12939. for (var j = 0; j < rows; j++) {
  12940. for (var i = 0; i < cols; i++) {
  12941. if (typeof grid.cells[j][i] !== "undefined" && grid.cells[j][i].edges.length > 0) {
  12942. var cell = grid.cells[j][i];
  12943. var prev = getStartXY(cell), next3 = null, p = i, q = j;
  12944. if (prev !== null) {
  12945. currentPolygon.push([prev.p[0] + p, prev.p[1] + q]);
  12946. }
  12947. do {
  12948. next3 = getExitXY(grid.cells[q][p], prev.x, prev.y, prev.o);
  12949. if (next3 !== null) {
  12950. currentPolygon.push([next3.p[0] + p, next3.p[1] + q]);
  12951. p += next3.x;
  12952. q += next3.y;
  12953. prev = next3;
  12954. } else {
  12955. break;
  12956. }
  12957. if (q < 0 || q >= rows || p < 0 || p >= cols || typeof grid.cells[q][p] === "undefined") {
  12958. p -= next3.x;
  12959. q -= next3.y;
  12960. var missing = traceOutOfGridPath(
  12961. grid,
  12962. p,
  12963. q,
  12964. next3.x,
  12965. next3.y,
  12966. next3.o
  12967. );
  12968. if (missing !== null) {
  12969. missing.path.forEach(function(pp) {
  12970. currentPolygon.push(pp);
  12971. });
  12972. p = missing.i;
  12973. q = missing.j;
  12974. prev = missing;
  12975. } else {
  12976. break;
  12977. }
  12978. }
  12979. } while (typeof grid.cells[q][p] !== "undefined" && grid.cells[q][p].edges.length > 0);
  12980. areas.push(currentPolygon);
  12981. currentPolygon = [];
  12982. if (grid.cells[j][i].edges.length > 0)
  12983. i--;
  12984. }
  12985. }
  12986. }
  12987. return areas;
  12988. }
  12989. function traceOutOfGridPath(grid, i, j, d_x, d_y, d_o) {
  12990. var cell = grid.cells[j][i];
  12991. var cval = cell.cval_real;
  12992. var p = i + d_x, q = j + d_y;
  12993. var path = [];
  12994. var closed = false;
  12995. while (!closed) {
  12996. if (typeof grid.cells[q] === "undefined" || typeof grid.cells[q][p] === "undefined") {
  12997. q -= d_y;
  12998. p -= d_x;
  12999. cell = grid.cells[q][p];
  13000. cval = cell.cval_real;
  13001. if (d_y === -1) {
  13002. if (d_o === 0) {
  13003. if (cval & Node3) {
  13004. path.push([p, q]);
  13005. d_x = -1;
  13006. d_y = 0;
  13007. d_o = 0;
  13008. } else if (cval & Node2) {
  13009. path.push([p + 1, q]);
  13010. d_x = 1;
  13011. d_y = 0;
  13012. d_o = 0;
  13013. } else {
  13014. path.push([p + cell.bottomright, q]);
  13015. d_x = 0;
  13016. d_y = 1;
  13017. d_o = 1;
  13018. closed = true;
  13019. break;
  13020. }
  13021. } else if (cval & Node3) {
  13022. path.push([p, q]);
  13023. d_x = -1;
  13024. d_y = 0;
  13025. d_o = 0;
  13026. } else if (cval & Node2) {
  13027. path.push([p + cell.bottomright, q]);
  13028. d_x = 0;
  13029. d_y = 1;
  13030. d_o = 1;
  13031. closed = true;
  13032. break;
  13033. } else {
  13034. path.push([p + cell.bottomleft, q]);
  13035. d_x = 0;
  13036. d_y = 1;
  13037. d_o = 0;
  13038. closed = true;
  13039. break;
  13040. }
  13041. } else if (d_y === 1) {
  13042. if (d_o === 0) {
  13043. if (cval & Node1) {
  13044. path.push([p + 1, q + 1]);
  13045. d_x = 1;
  13046. d_y = 0;
  13047. d_o = 1;
  13048. } else if (!(cval & Node0)) {
  13049. path.push([p + cell.topright, q + 1]);
  13050. d_x = 0;
  13051. d_y = -1;
  13052. d_o = 1;
  13053. closed = true;
  13054. break;
  13055. } else {
  13056. path.push([p + cell.topleft, q + 1]);
  13057. d_x = 0;
  13058. d_y = -1;
  13059. d_o = 0;
  13060. closed = true;
  13061. break;
  13062. }
  13063. } else if (cval & Node1) {
  13064. path.push([p + 1, q + 1]);
  13065. d_x = 1;
  13066. d_y = 0;
  13067. d_o = 1;
  13068. } else {
  13069. path.push([p + 1, q + 1]);
  13070. d_x = 1;
  13071. d_y = 0;
  13072. d_o = 1;
  13073. }
  13074. } else if (d_x === -1) {
  13075. if (d_o === 0) {
  13076. if (cval & Node0) {
  13077. path.push([p, q + 1]);
  13078. d_x = 0;
  13079. d_y = 1;
  13080. d_o = 0;
  13081. } else if (!(cval & Node3)) {
  13082. path.push([p, q + cell.lefttop]);
  13083. d_x = 1;
  13084. d_y = 0;
  13085. d_o = 1;
  13086. closed = true;
  13087. break;
  13088. } else {
  13089. path.push([p, q + cell.leftbottom]);
  13090. d_x = 1;
  13091. d_y = 0;
  13092. d_o = 0;
  13093. closed = true;
  13094. break;
  13095. }
  13096. } else {
  13097. if (cval & Node0) {
  13098. path.push([p, q + 1]);
  13099. d_x = 0;
  13100. d_y = 1;
  13101. d_o = 0;
  13102. } else {
  13103. console.log("MarchingSquaresJS-isoBands: wtf");
  13104. break;
  13105. }
  13106. }
  13107. } else if (d_x === 1) {
  13108. if (d_o === 0) {
  13109. if (cval & Node2) {
  13110. path.push([p + 1, q]);
  13111. d_x = 0;
  13112. d_y = -1;
  13113. d_o = 1;
  13114. } else {
  13115. path.push([p + 1, q + cell.rightbottom]);
  13116. d_x = -1;
  13117. d_y = 0;
  13118. d_o = 0;
  13119. closed = true;
  13120. break;
  13121. }
  13122. } else {
  13123. if (cval & Node2) {
  13124. path.push([p + 1, q]);
  13125. d_x = 0;
  13126. d_y = -1;
  13127. d_o = 1;
  13128. } else if (!(cval & Node1)) {
  13129. path.push([p + 1, q + cell.rightbottom]);
  13130. d_x = -1;
  13131. d_y = 0;
  13132. d_o = 0;
  13133. closed = true;
  13134. break;
  13135. } else {
  13136. path.push([p + 1, q + cell.righttop]);
  13137. d_x = -1;
  13138. d_y = 0;
  13139. d_o = 1;
  13140. break;
  13141. }
  13142. }
  13143. } else {
  13144. console.log("MarchingSquaresJS-isoBands: we came from nowhere!");
  13145. break;
  13146. }
  13147. } else {
  13148. cell = grid.cells[q][p];
  13149. cval = cell.cval_real;
  13150. if (d_x === -1) {
  13151. if (d_o === 0) {
  13152. if (typeof grid.cells[q - 1] !== "undefined" && typeof grid.cells[q - 1][p] !== "undefined") {
  13153. d_x = 0;
  13154. d_y = -1;
  13155. d_o = 1;
  13156. } else if (cval & Node3) {
  13157. path.push([p, q]);
  13158. } else {
  13159. path.push([p + cell.bottomright, q]);
  13160. d_x = 0;
  13161. d_y = 1;
  13162. d_o = 1;
  13163. closed = true;
  13164. break;
  13165. }
  13166. } else if (cval & Node0) {
  13167. console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!");
  13168. } else {
  13169. console.log(
  13170. "MarchingSquaresJS-isoBands: found entry from top at " + p + "," + q
  13171. );
  13172. break;
  13173. }
  13174. } else if (d_x === 1) {
  13175. if (d_o === 0) {
  13176. console.log("MarchingSquaresJS-isoBands: wtf");
  13177. break;
  13178. } else {
  13179. if (typeof grid.cells[q + 1] !== "undefined" && typeof grid.cells[q + 1][p] !== "undefined") {
  13180. d_x = 0;
  13181. d_y = 1;
  13182. d_o = 0;
  13183. } else if (cval & Node1) {
  13184. path.push([p + 1, q + 1]);
  13185. d_x = 1;
  13186. d_y = 0;
  13187. d_o = 1;
  13188. } else {
  13189. path.push([p + cell.topleft, q + 1]);
  13190. d_x = 0;
  13191. d_y = -1;
  13192. d_o = 0;
  13193. closed = true;
  13194. break;
  13195. }
  13196. }
  13197. } else if (d_y === -1) {
  13198. if (d_o === 1) {
  13199. if (typeof grid.cells[q][p + 1] !== "undefined") {
  13200. d_x = 1;
  13201. d_y = 0;
  13202. d_o = 1;
  13203. } else if (cval & Node2) {
  13204. path.push([p + 1, q]);
  13205. d_x = 0;
  13206. d_y = -1;
  13207. d_o = 1;
  13208. } else {
  13209. path.push([p + 1, q + cell.righttop]);
  13210. d_x = -1;
  13211. d_y = 0;
  13212. d_o = 1;
  13213. closed = true;
  13214. break;
  13215. }
  13216. } else {
  13217. console.log("MarchingSquaresJS-isoBands: wtf");
  13218. break;
  13219. }
  13220. } else if (d_y === 1) {
  13221. if (d_o === 0) {
  13222. if (typeof grid.cells[q][p - 1] !== "undefined") {
  13223. d_x = -1;
  13224. d_y = 0;
  13225. d_o = 0;
  13226. } else if (cval & Node0) {
  13227. path.push([p, q + 1]);
  13228. d_x = 0;
  13229. d_y = 1;
  13230. d_o = 0;
  13231. } else {
  13232. path.push([p, q + cell.leftbottom]);
  13233. d_x = 1;
  13234. d_y = 0;
  13235. d_o = 0;
  13236. closed = true;
  13237. break;
  13238. }
  13239. } else {
  13240. console.log("MarchingSquaresJS-isoBands: wtf");
  13241. break;
  13242. }
  13243. } else {
  13244. console.log("MarchingSquaresJS-isoBands: where did we came from???");
  13245. break;
  13246. }
  13247. }
  13248. p += d_x;
  13249. q += d_y;
  13250. if (p === i && q === j) {
  13251. break;
  13252. }
  13253. }
  13254. return { path, i: p, j: q, x: d_x, y: d_y, o: d_o };
  13255. }
  13256. function deleteEdge(cell, edgeIdx) {
  13257. delete cell.edges[edgeIdx];
  13258. for (var k = edgeIdx + 1; k < cell.edges.length; k++) {
  13259. cell.edges[k - 1] = cell.edges[k];
  13260. }
  13261. cell.edges.pop();
  13262. }
  13263. function getStartXY(cell) {
  13264. if (cell.edges.length > 0) {
  13265. var e = cell.edges[cell.edges.length - 1];
  13266. var cval = cell.cval_real;
  13267. switch (e) {
  13268. case 0:
  13269. if (cval & Node1) {
  13270. return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
  13271. } else {
  13272. return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
  13273. }
  13274. case 1:
  13275. if (cval & Node2) {
  13276. return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
  13277. } else {
  13278. return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
  13279. }
  13280. case 2:
  13281. if (cval & Node2) {
  13282. return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
  13283. } else {
  13284. return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
  13285. }
  13286. case 3:
  13287. if (cval & Node3) {
  13288. return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
  13289. } else {
  13290. return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
  13291. }
  13292. case 4:
  13293. if (cval & Node1) {
  13294. return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
  13295. } else {
  13296. return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
  13297. }
  13298. case 5:
  13299. if (cval & Node2) {
  13300. return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
  13301. } else {
  13302. return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
  13303. }
  13304. case 6:
  13305. if (cval & Node2) {
  13306. return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
  13307. } else {
  13308. return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
  13309. }
  13310. case 7:
  13311. if (cval & Node3) {
  13312. return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
  13313. } else {
  13314. return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
  13315. }
  13316. case 8:
  13317. if (cval & Node2) {
  13318. return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
  13319. } else {
  13320. return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
  13321. }
  13322. case 9:
  13323. if (cval & Node3) {
  13324. return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
  13325. } else {
  13326. return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
  13327. }
  13328. case 10:
  13329. if (cval & Node3) {
  13330. return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
  13331. } else {
  13332. return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
  13333. }
  13334. case 11:
  13335. if (cval & Node0) {
  13336. return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
  13337. } else {
  13338. return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
  13339. }
  13340. case 12:
  13341. if (cval & Node2) {
  13342. return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
  13343. } else {
  13344. return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
  13345. }
  13346. case 13:
  13347. if (cval & Node3) {
  13348. return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
  13349. } else {
  13350. return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
  13351. }
  13352. case 14:
  13353. if (cval & Node3) {
  13354. return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
  13355. } else {
  13356. return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
  13357. }
  13358. case 15:
  13359. if (cval & Node0) {
  13360. return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
  13361. } else {
  13362. return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
  13363. }
  13364. case 16:
  13365. if (cval & Node2) {
  13366. return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
  13367. } else {
  13368. return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
  13369. }
  13370. case 17:
  13371. if (cval & Node0) {
  13372. return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
  13373. } else {
  13374. return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
  13375. }
  13376. case 18:
  13377. if (cval & Node3) {
  13378. return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
  13379. } else {
  13380. return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
  13381. }
  13382. case 19:
  13383. if (cval & Node0) {
  13384. return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
  13385. } else {
  13386. return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
  13387. }
  13388. case 20:
  13389. if (cval & Node0) {
  13390. return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
  13391. } else {
  13392. return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
  13393. }
  13394. case 21:
  13395. if (cval & Node1) {
  13396. return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
  13397. } else {
  13398. return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
  13399. }
  13400. case 22:
  13401. if (cval & Node0) {
  13402. return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
  13403. } else {
  13404. return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
  13405. }
  13406. case 23:
  13407. if (cval & Node1) {
  13408. return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
  13409. } else {
  13410. return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
  13411. }
  13412. default:
  13413. console.log("MarchingSquaresJS-isoBands: edge index out of range!");
  13414. console.log(cell);
  13415. break;
  13416. }
  13417. }
  13418. return null;
  13419. }
  13420. function getExitXY(cell, x2, y2, o) {
  13421. var e, id_x, d_x, d_y, cval = cell.cval;
  13422. var d_o;
  13423. switch (x2) {
  13424. case -1:
  13425. switch (o) {
  13426. case 0:
  13427. e = isoBandEdgeRB[cval];
  13428. d_x = isoBandNextXRB[cval];
  13429. d_y = isoBandNextYRB[cval];
  13430. d_o = isoBandNextORB[cval];
  13431. break;
  13432. default:
  13433. e = isoBandEdgeRT[cval];
  13434. d_x = isoBandNextXRT[cval];
  13435. d_y = isoBandNextYRT[cval];
  13436. d_o = isoBandNextORT[cval];
  13437. break;
  13438. }
  13439. break;
  13440. case 1:
  13441. switch (o) {
  13442. case 0:
  13443. e = isoBandEdgeLB[cval];
  13444. d_x = isoBandNextXLB[cval];
  13445. d_y = isoBandNextYLB[cval];
  13446. d_o = isoBandNextOLB[cval];
  13447. break;
  13448. default:
  13449. e = isoBandEdgeLT[cval];
  13450. d_x = isoBandNextXLT[cval];
  13451. d_y = isoBandNextYLT[cval];
  13452. d_o = isoBandNextOLT[cval];
  13453. break;
  13454. }
  13455. break;
  13456. default:
  13457. switch (y2) {
  13458. case -1:
  13459. switch (o) {
  13460. case 0:
  13461. e = isoBandEdgeTL[cval];
  13462. d_x = isoBandNextXTL[cval];
  13463. d_y = isoBandNextYTL[cval];
  13464. d_o = isoBandNextOTL[cval];
  13465. break;
  13466. default:
  13467. e = isoBandEdgeTR[cval];
  13468. d_x = isoBandNextXTR[cval];
  13469. d_y = isoBandNextYTR[cval];
  13470. d_o = isoBandNextOTR[cval];
  13471. break;
  13472. }
  13473. break;
  13474. case 1:
  13475. switch (o) {
  13476. case 0:
  13477. e = isoBandEdgeBL[cval];
  13478. d_x = isoBandNextXBL[cval];
  13479. d_y = isoBandNextYBL[cval];
  13480. d_o = isoBandNextOBL[cval];
  13481. break;
  13482. default:
  13483. e = isoBandEdgeBR[cval];
  13484. d_x = isoBandNextXBR[cval];
  13485. d_y = isoBandNextYBR[cval];
  13486. d_o = isoBandNextOBR[cval];
  13487. break;
  13488. }
  13489. break;
  13490. }
  13491. break;
  13492. }
  13493. id_x = cell.edges.indexOf(e);
  13494. if (typeof cell.edges[id_x] !== "undefined") {
  13495. deleteEdge(cell, id_x);
  13496. } else {
  13497. return null;
  13498. }
  13499. cval = cell.cval_real;
  13500. switch (e) {
  13501. case 0:
  13502. if (cval & Node1) {
  13503. x2 = cell.topleft;
  13504. y2 = 1;
  13505. } else {
  13506. x2 = 1;
  13507. y2 = cell.righttop;
  13508. }
  13509. break;
  13510. case 1:
  13511. if (cval & Node2) {
  13512. x2 = 1;
  13513. y2 = cell.rightbottom;
  13514. } else {
  13515. x2 = cell.topleft;
  13516. y2 = 1;
  13517. }
  13518. break;
  13519. case 2:
  13520. if (cval & Node2) {
  13521. x2 = cell.topleft;
  13522. y2 = 1;
  13523. } else {
  13524. x2 = cell.bottomright;
  13525. y2 = 0;
  13526. }
  13527. break;
  13528. case 3:
  13529. if (cval & Node3) {
  13530. x2 = cell.bottomleft;
  13531. y2 = 0;
  13532. } else {
  13533. x2 = cell.topleft;
  13534. y2 = 1;
  13535. }
  13536. break;
  13537. case 4:
  13538. if (cval & Node1) {
  13539. x2 = cell.topright;
  13540. y2 = 1;
  13541. } else {
  13542. x2 = 1;
  13543. y2 = cell.righttop;
  13544. }
  13545. break;
  13546. case 5:
  13547. if (cval & Node2) {
  13548. x2 = 1;
  13549. y2 = cell.rightbottom;
  13550. } else {
  13551. x2 = cell.topright;
  13552. y2 = 1;
  13553. }
  13554. break;
  13555. case 6:
  13556. if (cval & Node2) {
  13557. x2 = cell.topright;
  13558. y2 = 1;
  13559. } else {
  13560. x2 = cell.bottomright;
  13561. y2 = 0;
  13562. }
  13563. break;
  13564. case 7:
  13565. if (cval & Node3) {
  13566. x2 = cell.bottomleft;
  13567. y2 = 0;
  13568. } else {
  13569. x2 = cell.topright;
  13570. y2 = 1;
  13571. }
  13572. break;
  13573. case 8:
  13574. if (cval & Node2) {
  13575. x2 = 1;
  13576. y2 = cell.righttop;
  13577. } else {
  13578. x2 = cell.bottomright;
  13579. y2 = 0;
  13580. }
  13581. break;
  13582. case 9:
  13583. if (cval & Node3) {
  13584. x2 = cell.bottomleft;
  13585. y2 = 0;
  13586. } else {
  13587. x2 = 1;
  13588. y2 = cell.righttop;
  13589. }
  13590. break;
  13591. case 10:
  13592. if (cval & Node3) {
  13593. x2 = 1;
  13594. y2 = cell.righttop;
  13595. } else {
  13596. x2 = 0;
  13597. y2 = cell.leftbottom;
  13598. }
  13599. break;
  13600. case 11:
  13601. if (cval & Node0) {
  13602. x2 = 0;
  13603. y2 = cell.lefttop;
  13604. } else {
  13605. x2 = 1;
  13606. y2 = cell.righttop;
  13607. }
  13608. break;
  13609. case 12:
  13610. if (cval & Node2) {
  13611. x2 = 1;
  13612. y2 = cell.rightbottom;
  13613. } else {
  13614. x2 = cell.bottomright;
  13615. y2 = 0;
  13616. }
  13617. break;
  13618. case 13:
  13619. if (cval & Node3) {
  13620. x2 = cell.bottomleft;
  13621. y2 = 0;
  13622. } else {
  13623. x2 = 1;
  13624. y2 = cell.rightbottom;
  13625. }
  13626. break;
  13627. case 14:
  13628. if (cval & Node3) {
  13629. x2 = 1;
  13630. y2 = cell.rightbottom;
  13631. } else {
  13632. x2 = 0;
  13633. y2 = cell.leftbottom;
  13634. }
  13635. break;
  13636. case 15:
  13637. if (cval & Node0) {
  13638. x2 = 0;
  13639. y2 = cell.lefttop;
  13640. } else {
  13641. x2 = 1;
  13642. y2 = cell.rightbottom;
  13643. }
  13644. break;
  13645. case 16:
  13646. if (cval & Node2) {
  13647. x2 = 0;
  13648. y2 = cell.leftbottom;
  13649. } else {
  13650. x2 = cell.bottomright;
  13651. y2 = 0;
  13652. }
  13653. break;
  13654. case 17:
  13655. if (cval & Node0) {
  13656. x2 = 0;
  13657. y2 = cell.lefttop;
  13658. } else {
  13659. x2 = cell.bottomright;
  13660. y2 = 0;
  13661. }
  13662. break;
  13663. case 18:
  13664. if (cval & Node3) {
  13665. x2 = cell.bottomleft;
  13666. y2 = 0;
  13667. } else {
  13668. x2 = 0;
  13669. y2 = cell.leftbottom;
  13670. }
  13671. break;
  13672. case 19:
  13673. if (cval & Node0) {
  13674. x2 = 0;
  13675. y2 = cell.lefttop;
  13676. } else {
  13677. x2 = cell.bottomleft;
  13678. y2 = 0;
  13679. }
  13680. break;
  13681. case 20:
  13682. if (cval & Node0) {
  13683. x2 = 0;
  13684. y2 = cell.leftbottom;
  13685. } else {
  13686. x2 = cell.topleft;
  13687. y2 = 1;
  13688. }
  13689. break;
  13690. case 21:
  13691. if (cval & Node1) {
  13692. x2 = cell.topright;
  13693. y2 = 1;
  13694. } else {
  13695. x2 = 0;
  13696. y2 = cell.leftbottom;
  13697. }
  13698. break;
  13699. case 22:
  13700. if (cval & Node0) {
  13701. x2 = 0;
  13702. y2 = cell.lefttop;
  13703. } else {
  13704. x2 = cell.topleft;
  13705. y2 = 1;
  13706. }
  13707. break;
  13708. case 23:
  13709. if (cval & Node1) {
  13710. x2 = cell.topright;
  13711. y2 = 1;
  13712. } else {
  13713. x2 = 0;
  13714. y2 = cell.lefttop;
  13715. }
  13716. break;
  13717. default:
  13718. console.log("MarchingSquaresJS-isoBands: edge index out of range!");
  13719. console.log(cell);
  13720. return null;
  13721. }
  13722. if (typeof x2 === "undefined" || typeof y2 === "undefined" || typeof d_x === "undefined" || typeof d_y === "undefined" || typeof d_o === "undefined") {
  13723. console.log("MarchingSquaresJS-isoBands: undefined value!");
  13724. console.log(cell);
  13725. console.log(x2 + " " + y2 + " " + d_x + " " + d_y + " " + d_o);
  13726. }
  13727. return { p: [x2, y2], x: d_x, y: d_y, o: d_o };
  13728. }
  13729. function BandGrid2Areas(grid) {
  13730. var areas = [];
  13731. var area_idx = 0;
  13732. grid.cells.forEach(function(g, j) {
  13733. g.forEach(function(gg, i) {
  13734. if (typeof gg !== "undefined") {
  13735. var a = polygon_table[gg.cval](gg);
  13736. if (typeof a === "object" && isArray(a)) {
  13737. if (typeof a[0] === "object" && isArray(a[0])) {
  13738. if (typeof a[0][0] === "object" && isArray(a[0][0])) {
  13739. a.forEach(function(aa) {
  13740. aa.forEach(function(aaa) {
  13741. aaa[0] += i;
  13742. aaa[1] += j;
  13743. });
  13744. areas[area_idx++] = aa;
  13745. });
  13746. } else {
  13747. a.forEach(function(aa) {
  13748. aa[0] += i;
  13749. aa[1] += j;
  13750. });
  13751. areas[area_idx++] = a;
  13752. }
  13753. } else {
  13754. console.log(
  13755. "MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"
  13756. );
  13757. }
  13758. } else {
  13759. console.log(
  13760. "MarchingSquaresJS-isoBands: bandcell polygon with null coordinates"
  13761. );
  13762. }
  13763. }
  13764. });
  13765. });
  13766. return areas;
  13767. }
  13768. function isobands(pointGrid2, breaks, options) {
  13769. options = options || {};
  13770. if (!isObject(options))
  13771. throw new Error("options is invalid");
  13772. var zProperty = options.zProperty || "elevation";
  13773. var commonProperties = options.commonProperties || {};
  13774. var breaksProperties = options.breaksProperties || [];
  13775. collectionOf(pointGrid2, "Point", "Input must contain Points");
  13776. if (!breaks)
  13777. throw new Error("breaks is required");
  13778. if (!Array.isArray(breaks))
  13779. throw new Error("breaks is not an Array");
  13780. if (!isObject(commonProperties))
  13781. throw new Error("commonProperties is not an Object");
  13782. if (!Array.isArray(breaksProperties))
  13783. throw new Error("breaksProperties is not an Array");
  13784. var matrix = gridToMatrix2(pointGrid2, { zProperty, flip: true });
  13785. var contours = createContourLines(matrix, breaks, zProperty);
  13786. contours = rescaleContours(contours, matrix, pointGrid2);
  13787. var multipolygons = contours.map(function(contour, index2) {
  13788. if (breaksProperties[index2] && !isObject(breaksProperties[index2])) {
  13789. throw new Error("Each mappedProperty is required to be an Object");
  13790. }
  13791. var contourProperties = (0, import_object_assign3.default)(
  13792. {},
  13793. commonProperties,
  13794. breaksProperties[index2]
  13795. );
  13796. contourProperties[zProperty] = contour[zProperty];
  13797. var multiP = multiPolygon(contour.groupedRings, contourProperties);
  13798. return multiP;
  13799. });
  13800. return featureCollection(multipolygons);
  13801. }
  13802. function createContourLines(matrix, breaks, property) {
  13803. var contours = [];
  13804. for (var i = 1; i < breaks.length; i++) {
  13805. var lowerBand = +breaks[i - 1];
  13806. var upperBand = +breaks[i];
  13807. var isobandsCoords = isoBands(matrix, lowerBand, upperBand - lowerBand);
  13808. var nestedRings = orderByArea(isobandsCoords);
  13809. var groupedRings = groupNestedRings(nestedRings);
  13810. var obj = {};
  13811. obj["groupedRings"] = groupedRings;
  13812. obj[property] = lowerBand + "-" + upperBand;
  13813. contours.push(obj);
  13814. }
  13815. return contours;
  13816. }
  13817. function rescaleContours(contours, matrix, points2) {
  13818. var gridBbox = es_default(points2);
  13819. var originalWidth = gridBbox[2] - gridBbox[0];
  13820. var originalHeigth = gridBbox[3] - gridBbox[1];
  13821. var x02 = gridBbox[0];
  13822. var y02 = gridBbox[1];
  13823. var matrixWidth = matrix[0].length - 1;
  13824. var matrixHeight = matrix.length - 1;
  13825. var scaleX = originalWidth / matrixWidth;
  13826. var scaleY = originalHeigth / matrixHeight;
  13827. var resize = function(point4) {
  13828. point4[0] = point4[0] * scaleX + x02;
  13829. point4[1] = point4[1] * scaleY + y02;
  13830. };
  13831. contours.forEach(function(contour) {
  13832. contour.groupedRings.forEach(function(lineRingSet) {
  13833. lineRingSet.forEach(function(lineRing) {
  13834. lineRing.forEach(resize);
  13835. });
  13836. });
  13837. });
  13838. return contours;
  13839. }
  13840. function orderByArea(ringsCoords) {
  13841. var ringsWithArea = [];
  13842. var areas = [];
  13843. ringsCoords.forEach(function(coords) {
  13844. var ringArea2 = area(polygon([coords]));
  13845. areas.push(ringArea2);
  13846. ringsWithArea.push({ ring: coords, area: ringArea2 });
  13847. });
  13848. areas.sort(function(a, b) {
  13849. return b - a;
  13850. });
  13851. var orderedByArea = [];
  13852. areas.forEach(function(area5) {
  13853. for (var lr = 0; lr < ringsWithArea.length; lr++) {
  13854. if (ringsWithArea[lr].area === area5) {
  13855. orderedByArea.push(ringsWithArea[lr].ring);
  13856. ringsWithArea.splice(lr, 1);
  13857. break;
  13858. }
  13859. }
  13860. });
  13861. return orderedByArea;
  13862. }
  13863. function groupNestedRings(orderedLinearRings) {
  13864. var lrList = orderedLinearRings.map(function(lr) {
  13865. return { lrCoordinates: lr, grouped: false };
  13866. });
  13867. var groupedLinearRingsCoords = [];
  13868. while (!allGrouped(lrList)) {
  13869. for (var i = 0; i < lrList.length; i++) {
  13870. if (!lrList[i].grouped) {
  13871. var group = [];
  13872. group.push(lrList[i].lrCoordinates);
  13873. lrList[i].grouped = true;
  13874. var outerMostPoly = polygon([lrList[i].lrCoordinates]);
  13875. for (var j = i + 1; j < lrList.length; j++) {
  13876. if (!lrList[j].grouped) {
  13877. var lrPoly = polygon([lrList[j].lrCoordinates]);
  13878. if (isInside(lrPoly, outerMostPoly)) {
  13879. group.push(lrList[j].lrCoordinates);
  13880. lrList[j].grouped = true;
  13881. }
  13882. }
  13883. }
  13884. groupedLinearRingsCoords.push(group);
  13885. }
  13886. }
  13887. }
  13888. return groupedLinearRingsCoords;
  13889. }
  13890. function isInside(testPolygon, targetPolygon) {
  13891. var points2 = es_default22(testPolygon);
  13892. for (var i = 0; i < points2.features.length; i++) {
  13893. if (!booleanPointInPolygon(points2.features[i], targetPolygon)) {
  13894. return false;
  13895. }
  13896. }
  13897. return true;
  13898. }
  13899. function allGrouped(list) {
  13900. for (var i = 0; i < list.length; i++) {
  13901. if (list[i].grouped === false) {
  13902. return false;
  13903. }
  13904. }
  13905. return true;
  13906. }
  13907. var es_default52 = isobands;
  13908. // node_modules/@turf/transform-rotate/dist/es/index.js
  13909. function transformRotate(geojson, angle4, options) {
  13910. options = options || {};
  13911. if (!isObject(options))
  13912. throw new Error("options is invalid");
  13913. var pivot = options.pivot;
  13914. var mutate = options.mutate;
  13915. if (!geojson)
  13916. throw new Error("geojson is required");
  13917. if (angle4 === void 0 || angle4 === null || isNaN(angle4))
  13918. throw new Error("angle is required");
  13919. if (angle4 === 0)
  13920. return geojson;
  13921. if (!pivot)
  13922. pivot = es_default19(geojson);
  13923. if (mutate === false || mutate === void 0)
  13924. geojson = es_default5(geojson);
  13925. coordEach(geojson, function(pointCoords) {
  13926. var initialAngle = es_default48(pivot, pointCoords);
  13927. var finalAngle = initialAngle + angle4;
  13928. var distance11 = es_default28(pivot, pointCoords);
  13929. var newCoords = getCoords(es_default49(pivot, distance11, finalAngle));
  13930. pointCoords[0] = newCoords[0];
  13931. pointCoords[1] = newCoords[1];
  13932. });
  13933. return geojson;
  13934. }
  13935. var es_default53 = transformRotate;
  13936. // node_modules/@turf/transform-scale/dist/es/index.js
  13937. function transformScale(geojson, factor, options) {
  13938. options = options || {};
  13939. if (!isObject(options))
  13940. throw new Error("options is invalid");
  13941. var origin = options.origin;
  13942. var mutate = options.mutate;
  13943. if (!geojson)
  13944. throw new Error("geojson required");
  13945. if (typeof factor !== "number" || factor === 0)
  13946. throw new Error("invalid factor");
  13947. var originIsPoint = Array.isArray(origin) || typeof origin === "object";
  13948. if (mutate !== true)
  13949. geojson = es_default5(geojson);
  13950. if (geojson.type === "FeatureCollection" && !originIsPoint) {
  13951. featureEach(geojson, function(feature2, index2) {
  13952. geojson.features[index2] = scale(feature2, factor, origin);
  13953. });
  13954. return geojson;
  13955. }
  13956. return scale(geojson, factor, origin);
  13957. }
  13958. function scale(feature2, factor, origin) {
  13959. var isPoint = getType(feature2) === "Point";
  13960. origin = defineOrigin(feature2, origin);
  13961. if (factor === 1 || isPoint)
  13962. return feature2;
  13963. coordEach(feature2, function(coord) {
  13964. var originalDistance = es_default28(origin, coord);
  13965. var bearing2 = es_default48(origin, coord);
  13966. var newDistance = originalDistance * factor;
  13967. var newCoord = getCoords(es_default49(origin, newDistance, bearing2));
  13968. coord[0] = newCoord[0];
  13969. coord[1] = newCoord[1];
  13970. if (coord.length === 3)
  13971. coord[2] *= factor;
  13972. });
  13973. return feature2;
  13974. }
  13975. function defineOrigin(geojson, origin) {
  13976. if (origin === void 0 || origin === null)
  13977. origin = "centroid";
  13978. if (Array.isArray(origin) || typeof origin === "object")
  13979. return getCoord(origin);
  13980. var bbox3 = geojson.bbox ? geojson.bbox : es_default(geojson);
  13981. var west = bbox3[0];
  13982. var south = bbox3[1];
  13983. var east = bbox3[2];
  13984. var north = bbox3[3];
  13985. switch (origin) {
  13986. case "sw":
  13987. case "southwest":
  13988. case "westsouth":
  13989. case "bottomleft":
  13990. return point([west, south]);
  13991. case "se":
  13992. case "southeast":
  13993. case "eastsouth":
  13994. case "bottomright":
  13995. return point([east, south]);
  13996. case "nw":
  13997. case "northwest":
  13998. case "westnorth":
  13999. case "topleft":
  14000. return point([west, north]);
  14001. case "ne":
  14002. case "northeast":
  14003. case "eastnorth":
  14004. case "topright":
  14005. return point([east, north]);
  14006. case "center":
  14007. return es_default18(geojson);
  14008. case void 0:
  14009. case null:
  14010. case "centroid":
  14011. return es_default19(geojson);
  14012. default:
  14013. throw new Error("invalid origin");
  14014. }
  14015. }
  14016. var es_default54 = transformScale;
  14017. // node_modules/@turf/transform-translate/dist/es/index.js
  14018. function transformTranslate(geojson, distance11, direction, options) {
  14019. options = options || {};
  14020. if (!isObject(options))
  14021. throw new Error("options is invalid");
  14022. var units = options.units;
  14023. var zTranslation = options.zTranslation;
  14024. var mutate = options.mutate;
  14025. if (!geojson)
  14026. throw new Error("geojson is required");
  14027. if (distance11 === void 0 || distance11 === null || isNaN(distance11))
  14028. throw new Error("distance is required");
  14029. if (zTranslation && typeof zTranslation !== "number" && isNaN(zTranslation))
  14030. throw new Error("zTranslation is not a number");
  14031. zTranslation = zTranslation !== void 0 ? zTranslation : 0;
  14032. if (distance11 === 0 && zTranslation === 0)
  14033. return geojson;
  14034. if (direction === void 0 || direction === null || isNaN(direction))
  14035. throw new Error("direction is required");
  14036. if (distance11 < 0) {
  14037. distance11 = -distance11;
  14038. direction = direction + 180;
  14039. }
  14040. if (mutate === false || mutate === void 0)
  14041. geojson = es_default5(geojson);
  14042. coordEach(geojson, function(pointCoords) {
  14043. var newCoords = getCoords(
  14044. es_default49(pointCoords, distance11, direction, { units })
  14045. );
  14046. pointCoords[0] = newCoords[0];
  14047. pointCoords[1] = newCoords[1];
  14048. if (zTranslation && pointCoords.length === 3)
  14049. pointCoords[2] += zTranslation;
  14050. });
  14051. return geojson;
  14052. }
  14053. var es_default55 = transformTranslate;
  14054. // node_modules/@turf/line-offset/dist/es/index.js
  14055. function ab(segment) {
  14056. var start = segment[0];
  14057. var end = segment[1];
  14058. return [end[0] - start[0], end[1] - start[1]];
  14059. }
  14060. function crossProduct(v1, v2) {
  14061. return v1[0] * v2[1] - v2[0] * v1[1];
  14062. }
  14063. function add(v1, v2) {
  14064. return [v1[0] + v2[0], v1[1] + v2[1]];
  14065. }
  14066. function sub(v1, v2) {
  14067. return [v1[0] - v2[0], v1[1] - v2[1]];
  14068. }
  14069. function scalarMult(s, v) {
  14070. return [s * v[0], s * v[1]];
  14071. }
  14072. function intersectSegments(a, b) {
  14073. var p = a[0];
  14074. var r = ab(a);
  14075. var q = b[0];
  14076. var s = ab(b);
  14077. var cross = crossProduct(r, s);
  14078. var qmp = sub(q, p);
  14079. var numerator = crossProduct(qmp, s);
  14080. var t = numerator / cross;
  14081. var intersection12 = add(p, scalarMult(t, r));
  14082. return intersection12;
  14083. }
  14084. function isParallel(a, b) {
  14085. var r = ab(a);
  14086. var s = ab(b);
  14087. return crossProduct(r, s) === 0;
  14088. }
  14089. function intersection(a, b) {
  14090. if (isParallel(a, b))
  14091. return false;
  14092. return intersectSegments(a, b);
  14093. }
  14094. function lineOffset(geojson, distance11, options) {
  14095. options = options || {};
  14096. if (!isObject(options))
  14097. throw new Error("options is invalid");
  14098. var units = options.units;
  14099. if (!geojson)
  14100. throw new Error("geojson is required");
  14101. if (distance11 === void 0 || distance11 === null || isNaN(distance11))
  14102. throw new Error("distance is required");
  14103. var type = getType(geojson);
  14104. var properties = geojson.properties;
  14105. switch (type) {
  14106. case "LineString":
  14107. return lineOffsetFeature(geojson, distance11, units);
  14108. case "MultiLineString":
  14109. var coords = [];
  14110. flattenEach(geojson, function(feature2) {
  14111. coords.push(
  14112. lineOffsetFeature(feature2, distance11, units).geometry.coordinates
  14113. );
  14114. });
  14115. return multiLineString(coords, properties);
  14116. default:
  14117. throw new Error("geometry " + type + " is not supported");
  14118. }
  14119. }
  14120. function lineOffsetFeature(line, distance11, units) {
  14121. var segments = [];
  14122. var offsetDegrees = lengthToDegrees(distance11, units);
  14123. var coords = getCoords(line);
  14124. var finalCoords = [];
  14125. coords.forEach(function(currentCoords, index2) {
  14126. if (index2 !== coords.length - 1) {
  14127. var segment = processSegment(
  14128. currentCoords,
  14129. coords[index2 + 1],
  14130. offsetDegrees
  14131. );
  14132. segments.push(segment);
  14133. if (index2 > 0) {
  14134. var seg2Coords = segments[index2 - 1];
  14135. var intersects7 = intersection(segment, seg2Coords);
  14136. if (intersects7 !== false) {
  14137. seg2Coords[1] = intersects7;
  14138. segment[0] = intersects7;
  14139. }
  14140. finalCoords.push(seg2Coords[0]);
  14141. if (index2 === coords.length - 2) {
  14142. finalCoords.push(segment[0]);
  14143. finalCoords.push(segment[1]);
  14144. }
  14145. }
  14146. if (coords.length === 2) {
  14147. finalCoords.push(segment[0]);
  14148. finalCoords.push(segment[1]);
  14149. }
  14150. }
  14151. });
  14152. return lineString(finalCoords, line.properties);
  14153. }
  14154. function processSegment(point1, point22, offset) {
  14155. var L = Math.sqrt(
  14156. (point1[0] - point22[0]) * (point1[0] - point22[0]) + (point1[1] - point22[1]) * (point1[1] - point22[1])
  14157. );
  14158. var out1x = point1[0] + offset * (point22[1] - point1[1]) / L;
  14159. var out2x = point22[0] + offset * (point22[1] - point1[1]) / L;
  14160. var out1y = point1[1] + offset * (point1[0] - point22[0]) / L;
  14161. var out2y = point22[1] + offset * (point1[0] - point22[0]) / L;
  14162. return [
  14163. [out1x, out1y],
  14164. [out2x, out2y]
  14165. ];
  14166. }
  14167. var es_default56 = lineOffset;
  14168. // node_modules/@turf/polygonize/dist/es/lib/util.js
  14169. function mathSign(x2) {
  14170. return (x2 > 0) - (x2 < 0) || +x2;
  14171. }
  14172. function orientationIndex(p1, p2, q) {
  14173. var dx1 = p2[0] - p1[0], dy1 = p2[1] - p1[1], dx2 = q[0] - p2[0], dy2 = q[1] - p2[1];
  14174. return mathSign(dx1 * dy2 - dx2 * dy1);
  14175. }
  14176. function envelopeIsEqual(env1, env2) {
  14177. var envX1 = env1.geometry.coordinates[0].map(function(c) {
  14178. return c[0];
  14179. }), envY1 = env1.geometry.coordinates[0].map(function(c) {
  14180. return c[1];
  14181. }), envX2 = env2.geometry.coordinates[0].map(function(c) {
  14182. return c[0];
  14183. }), envY2 = env2.geometry.coordinates[0].map(function(c) {
  14184. return c[1];
  14185. });
  14186. return Math.max.apply(null, envX1) === Math.max.apply(null, envX2) && Math.max.apply(null, envY1) === Math.max.apply(null, envY2) && Math.min.apply(null, envX1) === Math.min.apply(null, envX2) && Math.min.apply(null, envY1) === Math.min.apply(null, envY2);
  14187. }
  14188. function envelopeContains(self2, env) {
  14189. return env.geometry.coordinates[0].every(function(c) {
  14190. return booleanPointInPolygon(point(c), self2);
  14191. });
  14192. }
  14193. function coordinatesEqual(coord1, coord2) {
  14194. return coord1[0] === coord2[0] && coord1[1] === coord2[1];
  14195. }
  14196. // node_modules/@turf/polygonize/dist/es/lib/Node.js
  14197. var Node = function() {
  14198. function Node6(coordinates) {
  14199. this.id = Node6.buildId(coordinates);
  14200. this.coordinates = coordinates;
  14201. this.innerEdges = [];
  14202. this.outerEdges = [];
  14203. this.outerEdgesSorted = false;
  14204. }
  14205. Node6.buildId = function(coordinates) {
  14206. return coordinates.join(",");
  14207. };
  14208. Node6.prototype.removeInnerEdge = function(edge) {
  14209. this.innerEdges = this.innerEdges.filter(function(e) {
  14210. return e.from.id !== edge.from.id;
  14211. });
  14212. };
  14213. Node6.prototype.removeOuterEdge = function(edge) {
  14214. this.outerEdges = this.outerEdges.filter(function(e) {
  14215. return e.to.id !== edge.to.id;
  14216. });
  14217. };
  14218. Node6.prototype.addOuterEdge = function(edge) {
  14219. this.outerEdges.push(edge);
  14220. this.outerEdgesSorted = false;
  14221. };
  14222. Node6.prototype.sortOuterEdges = function() {
  14223. var _this = this;
  14224. if (!this.outerEdgesSorted) {
  14225. this.outerEdges.sort(function(a, b) {
  14226. var aNode = a.to, bNode = b.to;
  14227. if (aNode.coordinates[0] - _this.coordinates[0] >= 0 && bNode.coordinates[0] - _this.coordinates[0] < 0)
  14228. return 1;
  14229. if (aNode.coordinates[0] - _this.coordinates[0] < 0 && bNode.coordinates[0] - _this.coordinates[0] >= 0)
  14230. return -1;
  14231. if (aNode.coordinates[0] - _this.coordinates[0] === 0 && bNode.coordinates[0] - _this.coordinates[0] === 0) {
  14232. if (aNode.coordinates[1] - _this.coordinates[1] >= 0 || bNode.coordinates[1] - _this.coordinates[1] >= 0)
  14233. return aNode.coordinates[1] - bNode.coordinates[1];
  14234. return bNode.coordinates[1] - aNode.coordinates[1];
  14235. }
  14236. var det2 = orientationIndex(_this.coordinates, aNode.coordinates, bNode.coordinates);
  14237. if (det2 < 0)
  14238. return 1;
  14239. if (det2 > 0)
  14240. return -1;
  14241. var d1 = Math.pow(aNode.coordinates[0] - _this.coordinates[0], 2) + Math.pow(aNode.coordinates[1] - _this.coordinates[1], 2), d2 = Math.pow(bNode.coordinates[0] - _this.coordinates[0], 2) + Math.pow(bNode.coordinates[1] - _this.coordinates[1], 2);
  14242. return d1 - d2;
  14243. });
  14244. this.outerEdgesSorted = true;
  14245. }
  14246. };
  14247. Node6.prototype.getOuterEdges = function() {
  14248. this.sortOuterEdges();
  14249. return this.outerEdges;
  14250. };
  14251. Node6.prototype.getOuterEdge = function(i) {
  14252. this.sortOuterEdges();
  14253. return this.outerEdges[i];
  14254. };
  14255. Node6.prototype.addInnerEdge = function(edge) {
  14256. this.innerEdges.push(edge);
  14257. };
  14258. return Node6;
  14259. }();
  14260. var Node_default = Node;
  14261. // node_modules/@turf/polygonize/dist/es/lib/Edge.js
  14262. var Edge = function() {
  14263. function Edge3(from, to) {
  14264. this.from = from;
  14265. this.to = to;
  14266. this.next = void 0;
  14267. this.label = void 0;
  14268. this.symetric = void 0;
  14269. this.ring = void 0;
  14270. this.from.addOuterEdge(this);
  14271. this.to.addInnerEdge(this);
  14272. }
  14273. Edge3.prototype.getSymetric = function() {
  14274. if (!this.symetric) {
  14275. this.symetric = new Edge3(this.to, this.from);
  14276. this.symetric.symetric = this;
  14277. }
  14278. return this.symetric;
  14279. };
  14280. Edge3.prototype.deleteEdge = function() {
  14281. this.from.removeOuterEdge(this);
  14282. this.to.removeInnerEdge(this);
  14283. };
  14284. Edge3.prototype.isEqual = function(edge) {
  14285. return this.from.id === edge.from.id && this.to.id === edge.to.id;
  14286. };
  14287. Edge3.prototype.toString = function() {
  14288. return "Edge { " + this.from.id + " -> " + this.to.id + " }";
  14289. };
  14290. Edge3.prototype.toLineString = function() {
  14291. return lineString([this.from.coordinates, this.to.coordinates]);
  14292. };
  14293. Edge3.prototype.compareTo = function(edge) {
  14294. return orientationIndex(edge.from.coordinates, edge.to.coordinates, this.to.coordinates);
  14295. };
  14296. return Edge3;
  14297. }();
  14298. var Edge_default = Edge;
  14299. // node_modules/@turf/polygonize/dist/es/lib/EdgeRing.js
  14300. var EdgeRing = function() {
  14301. function EdgeRing4() {
  14302. this.edges = [];
  14303. this.polygon = void 0;
  14304. this.envelope = void 0;
  14305. }
  14306. EdgeRing4.prototype.push = function(edge) {
  14307. this.edges.push(edge);
  14308. this.polygon = this.envelope = void 0;
  14309. };
  14310. EdgeRing4.prototype.get = function(i) {
  14311. return this.edges[i];
  14312. };
  14313. Object.defineProperty(EdgeRing4.prototype, "length", {
  14314. get: function() {
  14315. return this.edges.length;
  14316. },
  14317. enumerable: true,
  14318. configurable: true
  14319. });
  14320. EdgeRing4.prototype.forEach = function(f) {
  14321. this.edges.forEach(f);
  14322. };
  14323. EdgeRing4.prototype.map = function(f) {
  14324. return this.edges.map(f);
  14325. };
  14326. EdgeRing4.prototype.some = function(f) {
  14327. return this.edges.some(f);
  14328. };
  14329. EdgeRing4.prototype.isValid = function() {
  14330. return true;
  14331. };
  14332. EdgeRing4.prototype.isHole = function() {
  14333. var _this = this;
  14334. var hiIndex = this.edges.reduce(function(high, edge, i) {
  14335. if (edge.from.coordinates[1] > _this.edges[high].from.coordinates[1])
  14336. high = i;
  14337. return high;
  14338. }, 0), iPrev = (hiIndex === 0 ? this.length : hiIndex) - 1, iNext = (hiIndex + 1) % this.length, disc = orientationIndex(this.edges[iPrev].from.coordinates, this.edges[hiIndex].from.coordinates, this.edges[iNext].from.coordinates);
  14339. if (disc === 0)
  14340. return this.edges[iPrev].from.coordinates[0] > this.edges[iNext].from.coordinates[0];
  14341. return disc > 0;
  14342. };
  14343. EdgeRing4.prototype.toMultiPoint = function() {
  14344. return multiPoint(this.edges.map(function(edge) {
  14345. return edge.from.coordinates;
  14346. }));
  14347. };
  14348. EdgeRing4.prototype.toPolygon = function() {
  14349. if (this.polygon)
  14350. return this.polygon;
  14351. var coordinates = this.edges.map(function(edge) {
  14352. return edge.from.coordinates;
  14353. });
  14354. coordinates.push(this.edges[0].from.coordinates);
  14355. return this.polygon = polygon([coordinates]);
  14356. };
  14357. EdgeRing4.prototype.getEnvelope = function() {
  14358. if (this.envelope)
  14359. return this.envelope;
  14360. return this.envelope = es_default14(this.toPolygon());
  14361. };
  14362. EdgeRing4.findEdgeRingContaining = function(testEdgeRing, shellList) {
  14363. var testEnvelope = testEdgeRing.getEnvelope();
  14364. var minEnvelope, minShell;
  14365. shellList.forEach(function(shell) {
  14366. var tryEnvelope = shell.getEnvelope();
  14367. if (minShell)
  14368. minEnvelope = minShell.getEnvelope();
  14369. if (envelopeIsEqual(tryEnvelope, testEnvelope))
  14370. return;
  14371. if (envelopeContains(tryEnvelope, testEnvelope)) {
  14372. var testEdgeRingCoordinates = testEdgeRing.map(function(edge) {
  14373. return edge.from.coordinates;
  14374. });
  14375. var testPoint = void 0;
  14376. var _loop_1 = function(pt2) {
  14377. if (!shell.some(function(edge) {
  14378. return coordinatesEqual(pt2, edge.from.coordinates);
  14379. })) {
  14380. testPoint = pt2;
  14381. }
  14382. };
  14383. for (var _i = 0, testEdgeRingCoordinates_1 = testEdgeRingCoordinates; _i < testEdgeRingCoordinates_1.length; _i++) {
  14384. var pt = testEdgeRingCoordinates_1[_i];
  14385. _loop_1(pt);
  14386. }
  14387. if (testPoint && shell.inside(point(testPoint))) {
  14388. if (!minShell || envelopeContains(minEnvelope, tryEnvelope))
  14389. minShell = shell;
  14390. }
  14391. }
  14392. });
  14393. return minShell;
  14394. };
  14395. EdgeRing4.prototype.inside = function(pt) {
  14396. return booleanPointInPolygon(pt, this.toPolygon());
  14397. };
  14398. return EdgeRing4;
  14399. }();
  14400. var EdgeRing_default = EdgeRing;
  14401. // node_modules/@turf/polygonize/dist/es/lib/Graph.js
  14402. function validateGeoJson(geoJson) {
  14403. if (!geoJson)
  14404. throw new Error("No geojson passed");
  14405. if (geoJson.type !== "FeatureCollection" && geoJson.type !== "GeometryCollection" && geoJson.type !== "MultiLineString" && geoJson.type !== "LineString" && geoJson.type !== "Feature")
  14406. throw new Error("Invalid input type '" + geoJson.type + "'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature");
  14407. }
  14408. var Graph = function() {
  14409. function Graph3() {
  14410. this.edges = [];
  14411. this.nodes = {};
  14412. }
  14413. Graph3.fromGeoJson = function(geoJson) {
  14414. validateGeoJson(geoJson);
  14415. var graph = new Graph3();
  14416. flattenEach(geoJson, function(feature2) {
  14417. featureOf(feature2, "LineString", "Graph::fromGeoJson");
  14418. coordReduce(feature2, function(prev, cur) {
  14419. if (prev) {
  14420. var start = graph.getNode(prev), end = graph.getNode(cur);
  14421. graph.addEdge(start, end);
  14422. }
  14423. return cur;
  14424. });
  14425. });
  14426. return graph;
  14427. };
  14428. Graph3.prototype.getNode = function(coordinates) {
  14429. var id = Node_default.buildId(coordinates);
  14430. var node = this.nodes[id];
  14431. if (!node)
  14432. node = this.nodes[id] = new Node_default(coordinates);
  14433. return node;
  14434. };
  14435. Graph3.prototype.addEdge = function(from, to) {
  14436. var edge = new Edge_default(from, to), symetricEdge = edge.getSymetric();
  14437. this.edges.push(edge);
  14438. this.edges.push(symetricEdge);
  14439. };
  14440. Graph3.prototype.deleteDangles = function() {
  14441. var _this = this;
  14442. Object.keys(this.nodes).map(function(id) {
  14443. return _this.nodes[id];
  14444. }).forEach(function(node) {
  14445. return _this._removeIfDangle(node);
  14446. });
  14447. };
  14448. Graph3.prototype._removeIfDangle = function(node) {
  14449. var _this = this;
  14450. if (node.innerEdges.length <= 1) {
  14451. var outerNodes = node.getOuterEdges().map(function(e) {
  14452. return e.to;
  14453. });
  14454. this.removeNode(node);
  14455. outerNodes.forEach(function(n) {
  14456. return _this._removeIfDangle(n);
  14457. });
  14458. }
  14459. };
  14460. Graph3.prototype.deleteCutEdges = function() {
  14461. var _this = this;
  14462. this._computeNextCWEdges();
  14463. this._findLabeledEdgeRings();
  14464. this.edges.forEach(function(edge) {
  14465. if (edge.label === edge.symetric.label) {
  14466. _this.removeEdge(edge.symetric);
  14467. _this.removeEdge(edge);
  14468. }
  14469. });
  14470. };
  14471. Graph3.prototype._computeNextCWEdges = function(node) {
  14472. var _this = this;
  14473. if (typeof node === "undefined") {
  14474. Object.keys(this.nodes).forEach(function(id) {
  14475. return _this._computeNextCWEdges(_this.nodes[id]);
  14476. });
  14477. } else {
  14478. node.getOuterEdges().forEach(function(edge, i) {
  14479. node.getOuterEdge((i === 0 ? node.getOuterEdges().length : i) - 1).symetric.next = edge;
  14480. });
  14481. }
  14482. };
  14483. Graph3.prototype._computeNextCCWEdges = function(node, label) {
  14484. var edges2 = node.getOuterEdges();
  14485. var firstOutDE, prevInDE;
  14486. for (var i = edges2.length - 1; i >= 0; --i) {
  14487. var de = edges2[i], sym = de.symetric, outDE = void 0, inDE = void 0;
  14488. if (de.label === label)
  14489. outDE = de;
  14490. if (sym.label === label)
  14491. inDE = sym;
  14492. if (!outDE || !inDE)
  14493. continue;
  14494. if (inDE)
  14495. prevInDE = inDE;
  14496. if (outDE) {
  14497. if (prevInDE) {
  14498. prevInDE.next = outDE;
  14499. prevInDE = void 0;
  14500. }
  14501. if (!firstOutDE)
  14502. firstOutDE = outDE;
  14503. }
  14504. }
  14505. if (prevInDE)
  14506. prevInDE.next = firstOutDE;
  14507. };
  14508. Graph3.prototype._findLabeledEdgeRings = function() {
  14509. var edgeRingStarts = [];
  14510. var label = 0;
  14511. this.edges.forEach(function(edge) {
  14512. if (edge.label >= 0)
  14513. return;
  14514. edgeRingStarts.push(edge);
  14515. var e = edge;
  14516. do {
  14517. e.label = label;
  14518. e = e.next;
  14519. } while (!edge.isEqual(e));
  14520. label++;
  14521. });
  14522. return edgeRingStarts;
  14523. };
  14524. Graph3.prototype.getEdgeRings = function() {
  14525. var _this = this;
  14526. this._computeNextCWEdges();
  14527. this.edges.forEach(function(edge) {
  14528. edge.label = void 0;
  14529. });
  14530. this._findLabeledEdgeRings().forEach(function(edge) {
  14531. _this._findIntersectionNodes(edge).forEach(function(node) {
  14532. _this._computeNextCCWEdges(node, edge.label);
  14533. });
  14534. });
  14535. var edgeRingList = [];
  14536. this.edges.forEach(function(edge) {
  14537. if (edge.ring)
  14538. return;
  14539. edgeRingList.push(_this._findEdgeRing(edge));
  14540. });
  14541. return edgeRingList;
  14542. };
  14543. Graph3.prototype._findIntersectionNodes = function(startEdge) {
  14544. var intersectionNodes = [];
  14545. var edge = startEdge;
  14546. var _loop_1 = function() {
  14547. var degree = 0;
  14548. edge.from.getOuterEdges().forEach(function(e) {
  14549. if (e.label === startEdge.label)
  14550. ++degree;
  14551. });
  14552. if (degree > 1)
  14553. intersectionNodes.push(edge.from);
  14554. edge = edge.next;
  14555. };
  14556. do {
  14557. _loop_1();
  14558. } while (!startEdge.isEqual(edge));
  14559. return intersectionNodes;
  14560. };
  14561. Graph3.prototype._findEdgeRing = function(startEdge) {
  14562. var edge = startEdge;
  14563. var edgeRing = new EdgeRing_default();
  14564. do {
  14565. edgeRing.push(edge);
  14566. edge.ring = edgeRing;
  14567. edge = edge.next;
  14568. } while (!startEdge.isEqual(edge));
  14569. return edgeRing;
  14570. };
  14571. Graph3.prototype.removeNode = function(node) {
  14572. var _this = this;
  14573. node.getOuterEdges().forEach(function(edge) {
  14574. return _this.removeEdge(edge);
  14575. });
  14576. node.innerEdges.forEach(function(edge) {
  14577. return _this.removeEdge(edge);
  14578. });
  14579. delete this.nodes[node.id];
  14580. };
  14581. Graph3.prototype.removeEdge = function(edge) {
  14582. this.edges = this.edges.filter(function(e) {
  14583. return !e.isEqual(edge);
  14584. });
  14585. edge.deleteEdge();
  14586. };
  14587. return Graph3;
  14588. }();
  14589. var Graph_default = Graph;
  14590. // node_modules/@turf/polygonize/dist/es/index.js
  14591. function polygonize(geoJson) {
  14592. var graph = Graph_default.fromGeoJson(geoJson);
  14593. graph.deleteDangles();
  14594. graph.deleteCutEdges();
  14595. var holes = [], shells = [];
  14596. graph.getEdgeRings().filter(function(edgeRing) {
  14597. return edgeRing.isValid();
  14598. }).forEach(function(edgeRing) {
  14599. if (edgeRing.isHole())
  14600. holes.push(edgeRing);
  14601. else
  14602. shells.push(edgeRing);
  14603. });
  14604. holes.forEach(function(hole) {
  14605. if (EdgeRing_default.findEdgeRingContaining(hole, shells))
  14606. shells.push(hole);
  14607. });
  14608. return featureCollection(shells.map(function(shell) {
  14609. return shell.toPolygon();
  14610. }));
  14611. }
  14612. // node_modules/@turf/boolean-disjoint/dist/es/index.js
  14613. function booleanDisjoint(feature1, feature2) {
  14614. var bool = true;
  14615. flattenEach(feature1, function(flatten1) {
  14616. flattenEach(feature2, function(flatten2) {
  14617. if (bool === false) {
  14618. return false;
  14619. }
  14620. bool = disjoint(flatten1.geometry, flatten2.geometry);
  14621. });
  14622. });
  14623. return bool;
  14624. }
  14625. function disjoint(geom1, geom2) {
  14626. switch (geom1.type) {
  14627. case "Point":
  14628. switch (geom2.type) {
  14629. case "Point":
  14630. return !compareCoords2(geom1.coordinates, geom2.coordinates);
  14631. case "LineString":
  14632. return !isPointOnLine(geom2, geom1);
  14633. case "Polygon":
  14634. return !booleanPointInPolygon(geom1, geom2);
  14635. }
  14636. break;
  14637. case "LineString":
  14638. switch (geom2.type) {
  14639. case "Point":
  14640. return !isPointOnLine(geom1, geom2);
  14641. case "LineString":
  14642. return !isLineOnLine2(geom1, geom2);
  14643. case "Polygon":
  14644. return !isLineInPoly2(geom2, geom1);
  14645. }
  14646. break;
  14647. case "Polygon":
  14648. switch (geom2.type) {
  14649. case "Point":
  14650. return !booleanPointInPolygon(geom2, geom1);
  14651. case "LineString":
  14652. return !isLineInPoly2(geom1, geom2);
  14653. case "Polygon":
  14654. return !isPolyInPoly2(geom2, geom1);
  14655. }
  14656. }
  14657. return false;
  14658. }
  14659. function isPointOnLine(lineString2, pt) {
  14660. for (var i = 0; i < lineString2.coordinates.length - 1; i++) {
  14661. if (isPointOnLineSegment3(lineString2.coordinates[i], lineString2.coordinates[i + 1], pt.coordinates)) {
  14662. return true;
  14663. }
  14664. }
  14665. return false;
  14666. }
  14667. function isLineOnLine2(lineString1, lineString2) {
  14668. var doLinesIntersect = es_default26(lineString1, lineString2);
  14669. if (doLinesIntersect.features.length > 0) {
  14670. return true;
  14671. }
  14672. return false;
  14673. }
  14674. function isLineInPoly2(polygon4, lineString2) {
  14675. for (var _i = 0, _a = lineString2.coordinates; _i < _a.length; _i++) {
  14676. var coord = _a[_i];
  14677. if (booleanPointInPolygon(coord, polygon4)) {
  14678. return true;
  14679. }
  14680. }
  14681. var doLinesIntersect = es_default26(lineString2, es_default44(polygon4));
  14682. if (doLinesIntersect.features.length > 0) {
  14683. return true;
  14684. }
  14685. return false;
  14686. }
  14687. function isPolyInPoly2(feature1, feature2) {
  14688. for (var _i = 0, _a = feature1.coordinates[0]; _i < _a.length; _i++) {
  14689. var coord1 = _a[_i];
  14690. if (booleanPointInPolygon(coord1, feature2)) {
  14691. return true;
  14692. }
  14693. }
  14694. for (var _b = 0, _c = feature2.coordinates[0]; _b < _c.length; _b++) {
  14695. var coord2 = _c[_b];
  14696. if (booleanPointInPolygon(coord2, feature1)) {
  14697. return true;
  14698. }
  14699. }
  14700. var doLinesIntersect = es_default26(es_default44(feature1), es_default44(feature2));
  14701. if (doLinesIntersect.features.length > 0) {
  14702. return true;
  14703. }
  14704. return false;
  14705. }
  14706. function isPointOnLineSegment3(lineSegmentStart, lineSegmentEnd, pt) {
  14707. var dxc = pt[0] - lineSegmentStart[0];
  14708. var dyc = pt[1] - lineSegmentStart[1];
  14709. var dxl = lineSegmentEnd[0] - lineSegmentStart[0];
  14710. var dyl = lineSegmentEnd[1] - lineSegmentStart[1];
  14711. var cross = dxc * dyl - dyc * dxl;
  14712. if (cross !== 0) {
  14713. return false;
  14714. }
  14715. if (Math.abs(dxl) >= Math.abs(dyl)) {
  14716. if (dxl > 0) {
  14717. return lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0];
  14718. } else {
  14719. return lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];
  14720. }
  14721. } else if (dyl > 0) {
  14722. return lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1];
  14723. } else {
  14724. return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
  14725. }
  14726. }
  14727. function compareCoords2(pair1, pair2) {
  14728. return pair1[0] === pair2[0] && pair1[1] === pair2[1];
  14729. }
  14730. var es_default57 = booleanDisjoint;
  14731. // node_modules/@turf/boolean-contains/dist/es/index.js
  14732. function booleanContains(feature1, feature2) {
  14733. var geom1 = getGeom(feature1);
  14734. var geom2 = getGeom(feature2);
  14735. var type1 = geom1.type;
  14736. var type2 = geom2.type;
  14737. var coords1 = geom1.coordinates;
  14738. var coords2 = geom2.coordinates;
  14739. switch (type1) {
  14740. case "Point":
  14741. switch (type2) {
  14742. case "Point":
  14743. return compareCoords3(coords1, coords2);
  14744. default:
  14745. throw new Error("feature2 " + type2 + " geometry not supported");
  14746. }
  14747. case "MultiPoint":
  14748. switch (type2) {
  14749. case "Point":
  14750. return isPointInMultiPoint2(geom1, geom2);
  14751. case "MultiPoint":
  14752. return isMultiPointInMultiPoint2(geom1, geom2);
  14753. default:
  14754. throw new Error("feature2 " + type2 + " geometry not supported");
  14755. }
  14756. case "LineString":
  14757. switch (type2) {
  14758. case "Point":
  14759. return es_default35(geom2, geom1, { ignoreEndVertices: true });
  14760. case "LineString":
  14761. return isLineOnLine3(geom1, geom2);
  14762. case "MultiPoint":
  14763. return isMultiPointOnLine2(geom1, geom2);
  14764. default:
  14765. throw new Error("feature2 " + type2 + " geometry not supported");
  14766. }
  14767. case "Polygon":
  14768. switch (type2) {
  14769. case "Point":
  14770. return booleanPointInPolygon(geom2, geom1, { ignoreBoundary: true });
  14771. case "LineString":
  14772. return isLineInPoly3(geom1, geom2);
  14773. case "Polygon":
  14774. return isPolyInPoly3(geom1, geom2);
  14775. case "MultiPoint":
  14776. return isMultiPointInPoly2(geom1, geom2);
  14777. default:
  14778. throw new Error("feature2 " + type2 + " geometry not supported");
  14779. }
  14780. default:
  14781. throw new Error("feature1 " + type1 + " geometry not supported");
  14782. }
  14783. }
  14784. function isPointInMultiPoint2(multiPoint2, pt) {
  14785. var i;
  14786. var output = false;
  14787. for (i = 0; i < multiPoint2.coordinates.length; i++) {
  14788. if (compareCoords3(multiPoint2.coordinates[i], pt.coordinates)) {
  14789. output = true;
  14790. break;
  14791. }
  14792. }
  14793. return output;
  14794. }
  14795. function isMultiPointInMultiPoint2(multiPoint1, multiPoint2) {
  14796. for (var _i = 0, _a = multiPoint2.coordinates; _i < _a.length; _i++) {
  14797. var coord2 = _a[_i];
  14798. var matchFound = false;
  14799. for (var _b = 0, _c = multiPoint1.coordinates; _b < _c.length; _b++) {
  14800. var coord1 = _c[_b];
  14801. if (compareCoords3(coord2, coord1)) {
  14802. matchFound = true;
  14803. break;
  14804. }
  14805. }
  14806. if (!matchFound) {
  14807. return false;
  14808. }
  14809. }
  14810. return true;
  14811. }
  14812. function isMultiPointOnLine2(lineString2, multiPoint2) {
  14813. var haveFoundInteriorPoint = false;
  14814. for (var _i = 0, _a = multiPoint2.coordinates; _i < _a.length; _i++) {
  14815. var coord = _a[_i];
  14816. if (es_default35(coord, lineString2, { ignoreEndVertices: true })) {
  14817. haveFoundInteriorPoint = true;
  14818. }
  14819. if (!es_default35(coord, lineString2)) {
  14820. return false;
  14821. }
  14822. }
  14823. if (haveFoundInteriorPoint) {
  14824. return true;
  14825. }
  14826. return false;
  14827. }
  14828. function isMultiPointInPoly2(polygon4, multiPoint2) {
  14829. for (var _i = 0, _a = multiPoint2.coordinates; _i < _a.length; _i++) {
  14830. var coord = _a[_i];
  14831. if (!booleanPointInPolygon(coord, polygon4, { ignoreBoundary: true })) {
  14832. return false;
  14833. }
  14834. }
  14835. return true;
  14836. }
  14837. function isLineOnLine3(lineString1, lineString2) {
  14838. var haveFoundInteriorPoint = false;
  14839. for (var _i = 0, _a = lineString2.coordinates; _i < _a.length; _i++) {
  14840. var coords = _a[_i];
  14841. if (es_default35({ type: "Point", coordinates: coords }, lineString1, {
  14842. ignoreEndVertices: true
  14843. })) {
  14844. haveFoundInteriorPoint = true;
  14845. }
  14846. if (!es_default35({ type: "Point", coordinates: coords }, lineString1, {
  14847. ignoreEndVertices: false
  14848. })) {
  14849. return false;
  14850. }
  14851. }
  14852. return haveFoundInteriorPoint;
  14853. }
  14854. function isLineInPoly3(polygon4, linestring3) {
  14855. var output = false;
  14856. var i = 0;
  14857. var polyBbox = es_default(polygon4);
  14858. var lineBbox = es_default(linestring3);
  14859. if (!doBBoxOverlap2(polyBbox, lineBbox)) {
  14860. return false;
  14861. }
  14862. for (i; i < linestring3.coordinates.length - 1; i++) {
  14863. var midPoint3 = getMidpoint2(linestring3.coordinates[i], linestring3.coordinates[i + 1]);
  14864. if (booleanPointInPolygon({ type: "Point", coordinates: midPoint3 }, polygon4, {
  14865. ignoreBoundary: true
  14866. })) {
  14867. output = true;
  14868. break;
  14869. }
  14870. }
  14871. return output;
  14872. }
  14873. function isPolyInPoly3(feature1, feature2) {
  14874. if (feature1.type === "Feature" && feature1.geometry === null) {
  14875. return false;
  14876. }
  14877. if (feature2.type === "Feature" && feature2.geometry === null) {
  14878. return false;
  14879. }
  14880. var poly1Bbox = es_default(feature1);
  14881. var poly2Bbox = es_default(feature2);
  14882. if (!doBBoxOverlap2(poly1Bbox, poly2Bbox)) {
  14883. return false;
  14884. }
  14885. var coords = getGeom(feature2).coordinates;
  14886. for (var _i = 0, coords_1 = coords; _i < coords_1.length; _i++) {
  14887. var ring = coords_1[_i];
  14888. for (var _a = 0, ring_1 = ring; _a < ring_1.length; _a++) {
  14889. var coord = ring_1[_a];
  14890. if (!booleanPointInPolygon(coord, feature1)) {
  14891. return false;
  14892. }
  14893. }
  14894. }
  14895. return true;
  14896. }
  14897. function doBBoxOverlap2(bbox1, bbox22) {
  14898. if (bbox1[0] > bbox22[0]) {
  14899. return false;
  14900. }
  14901. if (bbox1[2] < bbox22[2]) {
  14902. return false;
  14903. }
  14904. if (bbox1[1] > bbox22[1]) {
  14905. return false;
  14906. }
  14907. if (bbox1[3] < bbox22[3]) {
  14908. return false;
  14909. }
  14910. return true;
  14911. }
  14912. function compareCoords3(pair1, pair2) {
  14913. return pair1[0] === pair2[0] && pair1[1] === pair2[1];
  14914. }
  14915. function getMidpoint2(pair1, pair2) {
  14916. return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];
  14917. }
  14918. // node_modules/@turf/boolean-crosses/dist/es/index.js
  14919. function booleanCrosses(feature1, feature2) {
  14920. var geom1 = getGeom(feature1);
  14921. var geom2 = getGeom(feature2);
  14922. var type1 = geom1.type;
  14923. var type2 = geom2.type;
  14924. switch (type1) {
  14925. case "MultiPoint":
  14926. switch (type2) {
  14927. case "LineString":
  14928. return doMultiPointAndLineStringCross(geom1, geom2);
  14929. case "Polygon":
  14930. return doesMultiPointCrossPoly(geom1, geom2);
  14931. default:
  14932. throw new Error("feature2 " + type2 + " geometry not supported");
  14933. }
  14934. case "LineString":
  14935. switch (type2) {
  14936. case "MultiPoint":
  14937. return doMultiPointAndLineStringCross(geom2, geom1);
  14938. case "LineString":
  14939. return doLineStringsCross(geom1, geom2);
  14940. case "Polygon":
  14941. return doLineStringAndPolygonCross(geom1, geom2);
  14942. default:
  14943. throw new Error("feature2 " + type2 + " geometry not supported");
  14944. }
  14945. case "Polygon":
  14946. switch (type2) {
  14947. case "MultiPoint":
  14948. return doesMultiPointCrossPoly(geom2, geom1);
  14949. case "LineString":
  14950. return doLineStringAndPolygonCross(geom2, geom1);
  14951. default:
  14952. throw new Error("feature2 " + type2 + " geometry not supported");
  14953. }
  14954. default:
  14955. throw new Error("feature1 " + type1 + " geometry not supported");
  14956. }
  14957. }
  14958. function doMultiPointAndLineStringCross(multiPoint2, lineString2) {
  14959. var foundIntPoint = false;
  14960. var foundExtPoint = false;
  14961. var pointLength = multiPoint2.coordinates.length;
  14962. var i = 0;
  14963. while (i < pointLength && !foundIntPoint && !foundExtPoint) {
  14964. for (var i2 = 0; i2 < lineString2.coordinates.length - 1; i2++) {
  14965. var incEndVertices = true;
  14966. if (i2 === 0 || i2 === lineString2.coordinates.length - 2) {
  14967. incEndVertices = false;
  14968. }
  14969. if (isPointOnLineSegment4(lineString2.coordinates[i2], lineString2.coordinates[i2 + 1], multiPoint2.coordinates[i], incEndVertices)) {
  14970. foundIntPoint = true;
  14971. } else {
  14972. foundExtPoint = true;
  14973. }
  14974. }
  14975. i++;
  14976. }
  14977. return foundIntPoint && foundExtPoint;
  14978. }
  14979. function doLineStringsCross(lineString1, lineString2) {
  14980. var doLinesIntersect = es_default26(lineString1, lineString2);
  14981. if (doLinesIntersect.features.length > 0) {
  14982. for (var i = 0; i < lineString1.coordinates.length - 1; i++) {
  14983. for (var i2 = 0; i2 < lineString2.coordinates.length - 1; i2++) {
  14984. var incEndVertices = true;
  14985. if (i2 === 0 || i2 === lineString2.coordinates.length - 2) {
  14986. incEndVertices = false;
  14987. }
  14988. if (isPointOnLineSegment4(lineString1.coordinates[i], lineString1.coordinates[i + 1], lineString2.coordinates[i2], incEndVertices)) {
  14989. return true;
  14990. }
  14991. }
  14992. }
  14993. }
  14994. return false;
  14995. }
  14996. function doLineStringAndPolygonCross(lineString2, polygon4) {
  14997. var line = polygonToLine(polygon4);
  14998. var doLinesIntersect = es_default26(lineString2, line);
  14999. if (doLinesIntersect.features.length > 0) {
  15000. return true;
  15001. }
  15002. return false;
  15003. }
  15004. function doesMultiPointCrossPoly(multiPoint2, polygon4) {
  15005. var foundIntPoint = false;
  15006. var foundExtPoint = false;
  15007. var pointLength = multiPoint2.coordinates.length;
  15008. for (var i = 0; i < pointLength && (!foundIntPoint || !foundExtPoint); i++) {
  15009. if (booleanPointInPolygon(point(multiPoint2.coordinates[i]), polygon4)) {
  15010. foundIntPoint = true;
  15011. } else {
  15012. foundExtPoint = true;
  15013. }
  15014. }
  15015. return foundExtPoint && foundIntPoint;
  15016. }
  15017. function isPointOnLineSegment4(lineSegmentStart, lineSegmentEnd, pt, incEnd) {
  15018. var dxc = pt[0] - lineSegmentStart[0];
  15019. var dyc = pt[1] - lineSegmentStart[1];
  15020. var dxl = lineSegmentEnd[0] - lineSegmentStart[0];
  15021. var dyl = lineSegmentEnd[1] - lineSegmentStart[1];
  15022. var cross = dxc * dyl - dyc * dxl;
  15023. if (cross !== 0) {
  15024. return false;
  15025. }
  15026. if (incEnd) {
  15027. if (Math.abs(dxl) >= Math.abs(dyl)) {
  15028. return dxl > 0 ? lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0] : lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];
  15029. }
  15030. return dyl > 0 ? lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1] : lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
  15031. } else {
  15032. if (Math.abs(dxl) >= Math.abs(dyl)) {
  15033. return dxl > 0 ? lineSegmentStart[0] < pt[0] && pt[0] < lineSegmentEnd[0] : lineSegmentEnd[0] < pt[0] && pt[0] < lineSegmentStart[0];
  15034. }
  15035. return dyl > 0 ? lineSegmentStart[1] < pt[1] && pt[1] < lineSegmentEnd[1] : lineSegmentEnd[1] < pt[1] && pt[1] < lineSegmentStart[1];
  15036. }
  15037. }
  15038. var es_default58 = booleanCrosses;
  15039. // node_modules/@turf/boolean-overlap/dist/es/index.js
  15040. var import_geojson_equality = __toESM(require_geojson_equality());
  15041. function booleanOverlap(feature1, feature2) {
  15042. var geom1 = getGeom(feature1);
  15043. var geom2 = getGeom(feature2);
  15044. var type1 = geom1.type;
  15045. var type2 = geom2.type;
  15046. if (type1 === "MultiPoint" && type2 !== "MultiPoint" || (type1 === "LineString" || type1 === "MultiLineString") && type2 !== "LineString" && type2 !== "MultiLineString" || (type1 === "Polygon" || type1 === "MultiPolygon") && type2 !== "Polygon" && type2 !== "MultiPolygon") {
  15047. throw new Error("features must be of the same type");
  15048. }
  15049. if (type1 === "Point")
  15050. throw new Error("Point geometry not supported");
  15051. var equality = new import_geojson_equality.default({ precision: 6 });
  15052. if (equality.compare(feature1, feature2))
  15053. return false;
  15054. var overlap2 = 0;
  15055. switch (type1) {
  15056. case "MultiPoint":
  15057. for (var i = 0; i < geom1.coordinates.length; i++) {
  15058. for (var j = 0; j < geom2.coordinates.length; j++) {
  15059. var coord1 = geom1.coordinates[i];
  15060. var coord2 = geom2.coordinates[j];
  15061. if (coord1[0] === coord2[0] && coord1[1] === coord2[1]) {
  15062. return true;
  15063. }
  15064. }
  15065. }
  15066. return false;
  15067. case "LineString":
  15068. case "MultiLineString":
  15069. segmentEach(feature1, function(segment1) {
  15070. segmentEach(feature2, function(segment2) {
  15071. if (es_default46(segment1, segment2).features.length)
  15072. overlap2++;
  15073. });
  15074. });
  15075. break;
  15076. case "Polygon":
  15077. case "MultiPolygon":
  15078. segmentEach(feature1, function(segment1) {
  15079. segmentEach(feature2, function(segment2) {
  15080. if (es_default26(segment1, segment2).features.length)
  15081. overlap2++;
  15082. });
  15083. });
  15084. break;
  15085. }
  15086. return overlap2 > 0;
  15087. }
  15088. // node_modules/@turf/boolean-equal/dist/es/index.js
  15089. var import_geojson_equality2 = __toESM(require_geojson_equality());
  15090. function booleanEqual(feature1, feature2) {
  15091. var type1 = getGeom(feature1).type;
  15092. var type2 = getGeom(feature2).type;
  15093. if (type1 !== type2)
  15094. return false;
  15095. var equality = new import_geojson_equality2.default({ precision: 6 });
  15096. return equality.compare(es_default9(feature1), es_default9(feature2));
  15097. }
  15098. var es_default59 = booleanEqual;
  15099. // node_modules/@turf/boolean-intersects/dist/es/index.js
  15100. function booleanIntersects(feature1, feature2) {
  15101. var bool = false;
  15102. flattenEach(feature1, function(flatten1) {
  15103. flattenEach(feature2, function(flatten2) {
  15104. if (bool === true) {
  15105. return true;
  15106. }
  15107. bool = !es_default57(flatten1.geometry, flatten2.geometry);
  15108. });
  15109. });
  15110. return bool;
  15111. }
  15112. // node_modules/@turf/clusters-dbscan/dist/es/index.js
  15113. var import_density_clustering = __toESM(require_lib());
  15114. function clustersDbscan(points2, maxDistance, options) {
  15115. if (options === void 0) {
  15116. options = {};
  15117. }
  15118. if (options.mutate !== true)
  15119. points2 = es_default5(points2);
  15120. options.minPoints = options.minPoints || 3;
  15121. var dbscan = new import_density_clustering.default.DBSCAN();
  15122. var clusteredIds = dbscan.run(coordAll(points2), convertLength(maxDistance, options.units), options.minPoints, es_default4);
  15123. var clusterId = -1;
  15124. clusteredIds.forEach(function(clusterIds) {
  15125. clusterId++;
  15126. clusterIds.forEach(function(idx) {
  15127. var clusterPoint = points2.features[idx];
  15128. if (!clusterPoint.properties)
  15129. clusterPoint.properties = {};
  15130. clusterPoint.properties.cluster = clusterId;
  15131. clusterPoint.properties.dbscan = "core";
  15132. });
  15133. });
  15134. dbscan.noise.forEach(function(noiseId) {
  15135. var noisePoint = points2.features[noiseId];
  15136. if (!noisePoint.properties)
  15137. noisePoint.properties = {};
  15138. if (noisePoint.properties.cluster)
  15139. noisePoint.properties.dbscan = "edge";
  15140. else
  15141. noisePoint.properties.dbscan = "noise";
  15142. });
  15143. return points2;
  15144. }
  15145. var es_default60 = clustersDbscan;
  15146. // node_modules/@turf/clusters-kmeans/dist/es/index.js
  15147. var import_skmeans = __toESM(require_main());
  15148. function clustersKmeans(points2, options) {
  15149. if (options === void 0) {
  15150. options = {};
  15151. }
  15152. var count2 = points2.features.length;
  15153. options.numberOfClusters = options.numberOfClusters || Math.round(Math.sqrt(count2 / 2));
  15154. if (options.numberOfClusters > count2)
  15155. options.numberOfClusters = count2;
  15156. if (options.mutate !== true)
  15157. points2 = es_default5(points2);
  15158. var data = coordAll(points2);
  15159. var initialCentroids = data.slice(0, options.numberOfClusters);
  15160. var skmeansResult = (0, import_skmeans.default)(data, options.numberOfClusters, initialCentroids);
  15161. var centroids = {};
  15162. skmeansResult.centroids.forEach(function(coord, idx) {
  15163. centroids[idx] = coord;
  15164. });
  15165. featureEach(points2, function(point4, index2) {
  15166. var clusterId = skmeansResult.idxs[index2];
  15167. point4.properties.cluster = clusterId;
  15168. point4.properties.centroid = centroids[clusterId];
  15169. });
  15170. return points2;
  15171. }
  15172. var es_default61 = clustersKmeans;
  15173. // node_modules/@turf/boolean-parallel/dist/es/index.js
  15174. function booleanParallel(line1, line2) {
  15175. if (!line1)
  15176. throw new Error("line1 is required");
  15177. if (!line2)
  15178. throw new Error("line2 is required");
  15179. var type1 = getType2(line1, "line1");
  15180. if (type1 !== "LineString")
  15181. throw new Error("line1 must be a LineString");
  15182. var type2 = getType2(line2, "line2");
  15183. if (type2 !== "LineString")
  15184. throw new Error("line2 must be a LineString");
  15185. var segments1 = es_default25(es_default9(line1)).features;
  15186. var segments2 = es_default25(es_default9(line2)).features;
  15187. for (var i = 0; i < segments1.length; i++) {
  15188. var segment1 = segments1[i].geometry.coordinates;
  15189. if (!segments2[i])
  15190. break;
  15191. var segment2 = segments2[i].geometry.coordinates;
  15192. if (!isParallel2(segment1, segment2))
  15193. return false;
  15194. }
  15195. return true;
  15196. }
  15197. function isParallel2(segment1, segment2) {
  15198. var slope1 = bearingToAzimuth(es_default48(segment1[0], segment1[1]));
  15199. var slope2 = bearingToAzimuth(es_default48(segment2[0], segment2[1]));
  15200. return slope1 === slope2;
  15201. }
  15202. function getType2(geojson, name) {
  15203. if (geojson.geometry && geojson.geometry.type)
  15204. return geojson.geometry.type;
  15205. if (geojson.type)
  15206. return geojson.type;
  15207. throw new Error("Invalid GeoJSON object for " + name);
  15208. }
  15209. var es_default62 = booleanParallel;
  15210. // node_modules/@turf/shortest-path/dist/es/index.js
  15211. function pathTo(node) {
  15212. var curr = node, path = [];
  15213. while (curr.parent) {
  15214. path.unshift(curr);
  15215. curr = curr.parent;
  15216. }
  15217. return path;
  15218. }
  15219. function getHeap() {
  15220. return new BinaryHeap(function(node) {
  15221. return node.f;
  15222. });
  15223. }
  15224. var astar = {
  15225. search: function(graph, start, end, options) {
  15226. graph.cleanDirty();
  15227. options = options || {};
  15228. var heuristic = options.heuristic || astar.heuristics.manhattan, closest = options.closest || false;
  15229. var openHeap = getHeap(), closestNode = start;
  15230. start.h = heuristic(start, end);
  15231. openHeap.push(start);
  15232. while (openHeap.size() > 0) {
  15233. var currentNode = openHeap.pop();
  15234. if (currentNode === end) {
  15235. return pathTo(currentNode);
  15236. }
  15237. currentNode.closed = true;
  15238. var neighbors = graph.neighbors(currentNode);
  15239. for (var i = 0, il = neighbors.length; i < il; ++i) {
  15240. var neighbor = neighbors[i];
  15241. if (neighbor.closed || neighbor.isWall()) {
  15242. continue;
  15243. }
  15244. var gScore = currentNode.g + neighbor.getCost(currentNode), beenVisited = neighbor.visited;
  15245. if (!beenVisited || gScore < neighbor.g) {
  15246. neighbor.visited = true;
  15247. neighbor.parent = currentNode;
  15248. neighbor.h = neighbor.h || heuristic(neighbor, end);
  15249. neighbor.g = gScore;
  15250. neighbor.f = neighbor.g + neighbor.h;
  15251. graph.markDirty(neighbor);
  15252. if (closest) {
  15253. if (neighbor.h < closestNode.h || neighbor.h === closestNode.h && neighbor.g < closestNode.g) {
  15254. closestNode = neighbor;
  15255. }
  15256. }
  15257. if (!beenVisited) {
  15258. openHeap.push(neighbor);
  15259. } else {
  15260. openHeap.rescoreElement(neighbor);
  15261. }
  15262. }
  15263. }
  15264. }
  15265. if (closest) {
  15266. return pathTo(closestNode);
  15267. }
  15268. return [];
  15269. },
  15270. heuristics: {
  15271. manhattan: function(pos0, pos1) {
  15272. var d1 = Math.abs(pos1.x - pos0.x);
  15273. var d2 = Math.abs(pos1.y - pos0.y);
  15274. return d1 + d2;
  15275. },
  15276. diagonal: function(pos0, pos1) {
  15277. var D = 1;
  15278. var D2 = Math.sqrt(2);
  15279. var d1 = Math.abs(pos1.x - pos0.x);
  15280. var d2 = Math.abs(pos1.y - pos0.y);
  15281. return D * (d1 + d2) + (D2 - 2 * D) * Math.min(d1, d2);
  15282. }
  15283. },
  15284. cleanNode: function(node) {
  15285. node.f = 0;
  15286. node.g = 0;
  15287. node.h = 0;
  15288. node.visited = false;
  15289. node.closed = false;
  15290. node.parent = null;
  15291. }
  15292. };
  15293. function Graph2(gridIn, options) {
  15294. options = options || {};
  15295. this.nodes = [];
  15296. this.diagonal = !!options.diagonal;
  15297. this.grid = [];
  15298. for (var x2 = 0; x2 < gridIn.length; x2++) {
  15299. this.grid[x2] = [];
  15300. for (var y2 = 0, row = gridIn[x2]; y2 < row.length; y2++) {
  15301. var node = new GridNode(x2, y2, row[y2]);
  15302. this.grid[x2][y2] = node;
  15303. this.nodes.push(node);
  15304. }
  15305. }
  15306. this.init();
  15307. }
  15308. Graph2.prototype.init = function() {
  15309. this.dirtyNodes = [];
  15310. for (var i = 0; i < this.nodes.length; i++) {
  15311. astar.cleanNode(this.nodes[i]);
  15312. }
  15313. };
  15314. Graph2.prototype.cleanDirty = function() {
  15315. for (var i = 0; i < this.dirtyNodes.length; i++) {
  15316. astar.cleanNode(this.dirtyNodes[i]);
  15317. }
  15318. this.dirtyNodes = [];
  15319. };
  15320. Graph2.prototype.markDirty = function(node) {
  15321. this.dirtyNodes.push(node);
  15322. };
  15323. Graph2.prototype.neighbors = function(node) {
  15324. var ret = [], x2 = node.x, y2 = node.y, grid = this.grid;
  15325. if (grid[x2 - 1] && grid[x2 - 1][y2]) {
  15326. ret.push(grid[x2 - 1][y2]);
  15327. }
  15328. if (grid[x2 + 1] && grid[x2 + 1][y2]) {
  15329. ret.push(grid[x2 + 1][y2]);
  15330. }
  15331. if (grid[x2] && grid[x2][y2 - 1]) {
  15332. ret.push(grid[x2][y2 - 1]);
  15333. }
  15334. if (grid[x2] && grid[x2][y2 + 1]) {
  15335. ret.push(grid[x2][y2 + 1]);
  15336. }
  15337. if (this.diagonal) {
  15338. if (grid[x2 - 1] && grid[x2 - 1][y2 - 1]) {
  15339. ret.push(grid[x2 - 1][y2 - 1]);
  15340. }
  15341. if (grid[x2 + 1] && grid[x2 + 1][y2 - 1]) {
  15342. ret.push(grid[x2 + 1][y2 - 1]);
  15343. }
  15344. if (grid[x2 - 1] && grid[x2 - 1][y2 + 1]) {
  15345. ret.push(grid[x2 - 1][y2 + 1]);
  15346. }
  15347. if (grid[x2 + 1] && grid[x2 + 1][y2 + 1]) {
  15348. ret.push(grid[x2 + 1][y2 + 1]);
  15349. }
  15350. }
  15351. return ret;
  15352. };
  15353. Graph2.prototype.toString = function() {
  15354. var graphString = [], nodes = this.grid, rowDebug, row, y2, l;
  15355. for (var x2 = 0, len = nodes.length; x2 < len; x2++) {
  15356. rowDebug = [];
  15357. row = nodes[x2];
  15358. for (y2 = 0, l = row.length; y2 < l; y2++) {
  15359. rowDebug.push(row[y2].weight);
  15360. }
  15361. graphString.push(rowDebug.join(" "));
  15362. }
  15363. return graphString.join("\n");
  15364. };
  15365. function GridNode(x2, y2, weight) {
  15366. this.x = x2;
  15367. this.y = y2;
  15368. this.weight = weight;
  15369. }
  15370. GridNode.prototype.toString = function() {
  15371. return "[" + this.x + " " + this.y + "]";
  15372. };
  15373. GridNode.prototype.getCost = function(fromNeighbor) {
  15374. if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) {
  15375. return this.weight * 1.41421;
  15376. }
  15377. return this.weight;
  15378. };
  15379. GridNode.prototype.isWall = function() {
  15380. return this.weight === 0;
  15381. };
  15382. function BinaryHeap(scoreFunction) {
  15383. this.content = [];
  15384. this.scoreFunction = scoreFunction;
  15385. }
  15386. BinaryHeap.prototype = {
  15387. push: function(element) {
  15388. this.content.push(element);
  15389. this.sinkDown(this.content.length - 1);
  15390. },
  15391. pop: function() {
  15392. var result = this.content[0];
  15393. var end = this.content.pop();
  15394. if (this.content.length > 0) {
  15395. this.content[0] = end;
  15396. this.bubbleUp(0);
  15397. }
  15398. return result;
  15399. },
  15400. remove: function(node) {
  15401. var i = this.content.indexOf(node);
  15402. var end = this.content.pop();
  15403. if (i !== this.content.length - 1) {
  15404. this.content[i] = end;
  15405. if (this.scoreFunction(end) < this.scoreFunction(node)) {
  15406. this.sinkDown(i);
  15407. } else {
  15408. this.bubbleUp(i);
  15409. }
  15410. }
  15411. },
  15412. size: function() {
  15413. return this.content.length;
  15414. },
  15415. rescoreElement: function(node) {
  15416. this.sinkDown(this.content.indexOf(node));
  15417. },
  15418. sinkDown: function(n) {
  15419. var element = this.content[n];
  15420. while (n > 0) {
  15421. var parentN = (n + 1 >> 1) - 1, parent = this.content[parentN];
  15422. if (this.scoreFunction(element) < this.scoreFunction(parent)) {
  15423. this.content[parentN] = element;
  15424. this.content[n] = parent;
  15425. n = parentN;
  15426. } else {
  15427. break;
  15428. }
  15429. }
  15430. },
  15431. bubbleUp: function(n) {
  15432. var length4 = this.content.length, element = this.content[n], elemScore = this.scoreFunction(element);
  15433. while (true) {
  15434. var child2N = n + 1 << 1, child1N = child2N - 1;
  15435. var swap2 = null, child1Score;
  15436. if (child1N < length4) {
  15437. var child1 = this.content[child1N];
  15438. child1Score = this.scoreFunction(child1);
  15439. if (child1Score < elemScore) {
  15440. swap2 = child1N;
  15441. }
  15442. }
  15443. if (child2N < length4) {
  15444. var child2 = this.content[child2N], child2Score = this.scoreFunction(child2);
  15445. if (child2Score < (swap2 === null ? elemScore : child1Score)) {
  15446. swap2 = child2N;
  15447. }
  15448. }
  15449. if (swap2 !== null) {
  15450. this.content[n] = this.content[swap2];
  15451. this.content[swap2] = element;
  15452. n = swap2;
  15453. } else {
  15454. break;
  15455. }
  15456. }
  15457. }
  15458. };
  15459. function shortestPath(start, end, options) {
  15460. options = options || {};
  15461. if (!isObject(options))
  15462. throw new Error("options is invalid");
  15463. var resolution = options.resolution;
  15464. var minDistance = options.minDistance;
  15465. var obstacles = options.obstacles || featureCollection([]);
  15466. if (!start)
  15467. throw new Error("start is required");
  15468. if (!end)
  15469. throw new Error("end is required");
  15470. if (resolution && !isNumber(resolution) || resolution <= 0)
  15471. throw new Error("options.resolution must be a number, greater than 0");
  15472. if (minDistance)
  15473. throw new Error("options.minDistance is not yet implemented");
  15474. var startCoord = getCoord(start);
  15475. var endCoord = getCoord(end);
  15476. start = point(startCoord);
  15477. end = point(endCoord);
  15478. switch (getType(obstacles)) {
  15479. case "FeatureCollection":
  15480. if (obstacles.features.length === 0)
  15481. return lineString([startCoord, endCoord]);
  15482. break;
  15483. case "Polygon":
  15484. obstacles = featureCollection([feature(getGeom(obstacles))]);
  15485. break;
  15486. default:
  15487. throw new Error("invalid obstacles");
  15488. }
  15489. var collection = obstacles;
  15490. collection.features.push(start);
  15491. collection.features.push(end);
  15492. var box = es_default(es_default54(bboxPolygon(es_default(collection)), 1.15));
  15493. if (!resolution) {
  15494. var width = es_default4([box[0], box[1]], [box[2], box[1]], options);
  15495. resolution = width / 100;
  15496. }
  15497. collection.features.pop();
  15498. collection.features.pop();
  15499. var west = box[0];
  15500. var south = box[1];
  15501. var east = box[2];
  15502. var north = box[3];
  15503. var xFraction = resolution / es_default4([west, south], [east, south], options);
  15504. var cellWidth = xFraction * (east - west);
  15505. var yFraction = resolution / es_default4([west, south], [west, north], options);
  15506. var cellHeight = yFraction * (north - south);
  15507. var bboxHorizontalSide = east - west;
  15508. var bboxVerticalSide = north - south;
  15509. var columns = Math.floor(bboxHorizontalSide / cellWidth);
  15510. var rows = Math.floor(bboxVerticalSide / cellHeight);
  15511. var deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;
  15512. var deltaY = (bboxVerticalSide - rows * cellHeight) / 2;
  15513. var pointMatrix = [];
  15514. var matrix = [];
  15515. var closestToStart = [];
  15516. var closestToEnd = [];
  15517. var minDistStart = Infinity;
  15518. var minDistEnd = Infinity;
  15519. var currentY = north - deltaY;
  15520. var r = 0;
  15521. while (currentY >= south) {
  15522. var matrixRow = [];
  15523. var pointMatrixRow = [];
  15524. var currentX = west + deltaX;
  15525. var c = 0;
  15526. while (currentX <= east) {
  15527. var pt = point([currentX, currentY]);
  15528. var isInsideObstacle = isInside2(pt, obstacles);
  15529. matrixRow.push(isInsideObstacle ? 0 : 1);
  15530. pointMatrixRow.push(currentX + "|" + currentY);
  15531. var distStart = es_default4(pt, start);
  15532. if (!isInsideObstacle && distStart < minDistStart) {
  15533. minDistStart = distStart;
  15534. closestToStart = { x: c, y: r };
  15535. }
  15536. var distEnd = es_default4(pt, end);
  15537. if (!isInsideObstacle && distEnd < minDistEnd) {
  15538. minDistEnd = distEnd;
  15539. closestToEnd = { x: c, y: r };
  15540. }
  15541. currentX += cellWidth;
  15542. c++;
  15543. }
  15544. matrix.push(matrixRow);
  15545. pointMatrix.push(pointMatrixRow);
  15546. currentY -= cellHeight;
  15547. r++;
  15548. }
  15549. var graph = new Graph2(matrix, { diagonal: true });
  15550. var startOnMatrix = graph.grid[closestToStart.y][closestToStart.x];
  15551. var endOnMatrix = graph.grid[closestToEnd.y][closestToEnd.x];
  15552. var result = astar.search(graph, startOnMatrix, endOnMatrix);
  15553. var path = [startCoord];
  15554. result.forEach(function(coord) {
  15555. var coords = pointMatrix[coord.x][coord.y].split("|");
  15556. path.push([+coords[0], +coords[1]]);
  15557. });
  15558. path.push(endCoord);
  15559. return es_default9(lineString(path));
  15560. }
  15561. function isInside2(pt, polygons2) {
  15562. for (var i = 0; i < polygons2.features.length; i++) {
  15563. if (booleanPointInPolygon(pt, polygons2.features[i])) {
  15564. return true;
  15565. }
  15566. }
  15567. return false;
  15568. }
  15569. var es_default63 = shortestPath;
  15570. // node_modules/d3-voronoi/src/constant.js
  15571. function constant_default(x2) {
  15572. return function() {
  15573. return x2;
  15574. };
  15575. }
  15576. // node_modules/d3-voronoi/src/point.js
  15577. function x(d) {
  15578. return d[0];
  15579. }
  15580. function y(d) {
  15581. return d[1];
  15582. }
  15583. // node_modules/d3-voronoi/src/RedBlackTree.js
  15584. function RedBlackTree() {
  15585. this._ = null;
  15586. }
  15587. function RedBlackNode(node) {
  15588. node.U = node.C = node.L = node.R = node.P = node.N = null;
  15589. }
  15590. RedBlackTree.prototype = {
  15591. constructor: RedBlackTree,
  15592. insert: function(after, node) {
  15593. var parent, grandpa, uncle;
  15594. if (after) {
  15595. node.P = after;
  15596. node.N = after.N;
  15597. if (after.N)
  15598. after.N.P = node;
  15599. after.N = node;
  15600. if (after.R) {
  15601. after = after.R;
  15602. while (after.L)
  15603. after = after.L;
  15604. after.L = node;
  15605. } else {
  15606. after.R = node;
  15607. }
  15608. parent = after;
  15609. } else if (this._) {
  15610. after = RedBlackFirst(this._);
  15611. node.P = null;
  15612. node.N = after;
  15613. after.P = after.L = node;
  15614. parent = after;
  15615. } else {
  15616. node.P = node.N = null;
  15617. this._ = node;
  15618. parent = null;
  15619. }
  15620. node.L = node.R = null;
  15621. node.U = parent;
  15622. node.C = true;
  15623. after = node;
  15624. while (parent && parent.C) {
  15625. grandpa = parent.U;
  15626. if (parent === grandpa.L) {
  15627. uncle = grandpa.R;
  15628. if (uncle && uncle.C) {
  15629. parent.C = uncle.C = false;
  15630. grandpa.C = true;
  15631. after = grandpa;
  15632. } else {
  15633. if (after === parent.R) {
  15634. RedBlackRotateLeft(this, parent);
  15635. after = parent;
  15636. parent = after.U;
  15637. }
  15638. parent.C = false;
  15639. grandpa.C = true;
  15640. RedBlackRotateRight(this, grandpa);
  15641. }
  15642. } else {
  15643. uncle = grandpa.L;
  15644. if (uncle && uncle.C) {
  15645. parent.C = uncle.C = false;
  15646. grandpa.C = true;
  15647. after = grandpa;
  15648. } else {
  15649. if (after === parent.L) {
  15650. RedBlackRotateRight(this, parent);
  15651. after = parent;
  15652. parent = after.U;
  15653. }
  15654. parent.C = false;
  15655. grandpa.C = true;
  15656. RedBlackRotateLeft(this, grandpa);
  15657. }
  15658. }
  15659. parent = after.U;
  15660. }
  15661. this._.C = false;
  15662. },
  15663. remove: function(node) {
  15664. if (node.N)
  15665. node.N.P = node.P;
  15666. if (node.P)
  15667. node.P.N = node.N;
  15668. node.N = node.P = null;
  15669. var parent = node.U, sibling, left = node.L, right = node.R, next3, red;
  15670. if (!left)
  15671. next3 = right;
  15672. else if (!right)
  15673. next3 = left;
  15674. else
  15675. next3 = RedBlackFirst(right);
  15676. if (parent) {
  15677. if (parent.L === node)
  15678. parent.L = next3;
  15679. else
  15680. parent.R = next3;
  15681. } else {
  15682. this._ = next3;
  15683. }
  15684. if (left && right) {
  15685. red = next3.C;
  15686. next3.C = node.C;
  15687. next3.L = left;
  15688. left.U = next3;
  15689. if (next3 !== right) {
  15690. parent = next3.U;
  15691. next3.U = node.U;
  15692. node = next3.R;
  15693. parent.L = node;
  15694. next3.R = right;
  15695. right.U = next3;
  15696. } else {
  15697. next3.U = parent;
  15698. parent = next3;
  15699. node = next3.R;
  15700. }
  15701. } else {
  15702. red = node.C;
  15703. node = next3;
  15704. }
  15705. if (node)
  15706. node.U = parent;
  15707. if (red)
  15708. return;
  15709. if (node && node.C) {
  15710. node.C = false;
  15711. return;
  15712. }
  15713. do {
  15714. if (node === this._)
  15715. break;
  15716. if (node === parent.L) {
  15717. sibling = parent.R;
  15718. if (sibling.C) {
  15719. sibling.C = false;
  15720. parent.C = true;
  15721. RedBlackRotateLeft(this, parent);
  15722. sibling = parent.R;
  15723. }
  15724. if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
  15725. if (!sibling.R || !sibling.R.C) {
  15726. sibling.L.C = false;
  15727. sibling.C = true;
  15728. RedBlackRotateRight(this, sibling);
  15729. sibling = parent.R;
  15730. }
  15731. sibling.C = parent.C;
  15732. parent.C = sibling.R.C = false;
  15733. RedBlackRotateLeft(this, parent);
  15734. node = this._;
  15735. break;
  15736. }
  15737. } else {
  15738. sibling = parent.L;
  15739. if (sibling.C) {
  15740. sibling.C = false;
  15741. parent.C = true;
  15742. RedBlackRotateRight(this, parent);
  15743. sibling = parent.L;
  15744. }
  15745. if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
  15746. if (!sibling.L || !sibling.L.C) {
  15747. sibling.R.C = false;
  15748. sibling.C = true;
  15749. RedBlackRotateLeft(this, sibling);
  15750. sibling = parent.L;
  15751. }
  15752. sibling.C = parent.C;
  15753. parent.C = sibling.L.C = false;
  15754. RedBlackRotateRight(this, parent);
  15755. node = this._;
  15756. break;
  15757. }
  15758. }
  15759. sibling.C = true;
  15760. node = parent;
  15761. parent = parent.U;
  15762. } while (!node.C);
  15763. if (node)
  15764. node.C = false;
  15765. }
  15766. };
  15767. function RedBlackRotateLeft(tree, node) {
  15768. var p = node, q = node.R, parent = p.U;
  15769. if (parent) {
  15770. if (parent.L === p)
  15771. parent.L = q;
  15772. else
  15773. parent.R = q;
  15774. } else {
  15775. tree._ = q;
  15776. }
  15777. q.U = parent;
  15778. p.U = q;
  15779. p.R = q.L;
  15780. if (p.R)
  15781. p.R.U = p;
  15782. q.L = p;
  15783. }
  15784. function RedBlackRotateRight(tree, node) {
  15785. var p = node, q = node.L, parent = p.U;
  15786. if (parent) {
  15787. if (parent.L === p)
  15788. parent.L = q;
  15789. else
  15790. parent.R = q;
  15791. } else {
  15792. tree._ = q;
  15793. }
  15794. q.U = parent;
  15795. p.U = q;
  15796. p.L = q.R;
  15797. if (p.L)
  15798. p.L.U = p;
  15799. q.R = p;
  15800. }
  15801. function RedBlackFirst(node) {
  15802. while (node.L)
  15803. node = node.L;
  15804. return node;
  15805. }
  15806. var RedBlackTree_default = RedBlackTree;
  15807. // node_modules/d3-voronoi/src/Edge.js
  15808. function createEdge(left, right, v0, v1) {
  15809. var edge = [null, null], index2 = edges.push(edge) - 1;
  15810. edge.left = left;
  15811. edge.right = right;
  15812. if (v0)
  15813. setEdgeEnd(edge, left, right, v0);
  15814. if (v1)
  15815. setEdgeEnd(edge, right, left, v1);
  15816. cells[left.index].halfedges.push(index2);
  15817. cells[right.index].halfedges.push(index2);
  15818. return edge;
  15819. }
  15820. function createBorderEdge(left, v0, v1) {
  15821. var edge = [v0, v1];
  15822. edge.left = left;
  15823. return edge;
  15824. }
  15825. function setEdgeEnd(edge, left, right, vertex) {
  15826. if (!edge[0] && !edge[1]) {
  15827. edge[0] = vertex;
  15828. edge.left = left;
  15829. edge.right = right;
  15830. } else if (edge.left === right) {
  15831. edge[1] = vertex;
  15832. } else {
  15833. edge[0] = vertex;
  15834. }
  15835. }
  15836. function clipEdge(edge, x02, y02, x12, y12) {
  15837. var a = edge[0], b = edge[1], ax = a[0], ay = a[1], bx = b[0], by = b[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r;
  15838. r = x02 - ax;
  15839. if (!dx && r > 0)
  15840. return;
  15841. r /= dx;
  15842. if (dx < 0) {
  15843. if (r < t0)
  15844. return;
  15845. if (r < t1)
  15846. t1 = r;
  15847. } else if (dx > 0) {
  15848. if (r > t1)
  15849. return;
  15850. if (r > t0)
  15851. t0 = r;
  15852. }
  15853. r = x12 - ax;
  15854. if (!dx && r < 0)
  15855. return;
  15856. r /= dx;
  15857. if (dx < 0) {
  15858. if (r > t1)
  15859. return;
  15860. if (r > t0)
  15861. t0 = r;
  15862. } else if (dx > 0) {
  15863. if (r < t0)
  15864. return;
  15865. if (r < t1)
  15866. t1 = r;
  15867. }
  15868. r = y02 - ay;
  15869. if (!dy && r > 0)
  15870. return;
  15871. r /= dy;
  15872. if (dy < 0) {
  15873. if (r < t0)
  15874. return;
  15875. if (r < t1)
  15876. t1 = r;
  15877. } else if (dy > 0) {
  15878. if (r > t1)
  15879. return;
  15880. if (r > t0)
  15881. t0 = r;
  15882. }
  15883. r = y12 - ay;
  15884. if (!dy && r < 0)
  15885. return;
  15886. r /= dy;
  15887. if (dy < 0) {
  15888. if (r > t1)
  15889. return;
  15890. if (r > t0)
  15891. t0 = r;
  15892. } else if (dy > 0) {
  15893. if (r < t0)
  15894. return;
  15895. if (r < t1)
  15896. t1 = r;
  15897. }
  15898. if (!(t0 > 0) && !(t1 < 1))
  15899. return true;
  15900. if (t0 > 0)
  15901. edge[0] = [ax + t0 * dx, ay + t0 * dy];
  15902. if (t1 < 1)
  15903. edge[1] = [ax + t1 * dx, ay + t1 * dy];
  15904. return true;
  15905. }
  15906. function connectEdge(edge, x02, y02, x12, y12) {
  15907. var v1 = edge[1];
  15908. if (v1)
  15909. return true;
  15910. var v0 = edge[0], left = edge.left, right = edge.right, lx = left[0], ly = left[1], rx = right[0], ry = right[1], fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb;
  15911. if (ry === ly) {
  15912. if (fx < x02 || fx >= x12)
  15913. return;
  15914. if (lx > rx) {
  15915. if (!v0)
  15916. v0 = [fx, y02];
  15917. else if (v0[1] >= y12)
  15918. return;
  15919. v1 = [fx, y12];
  15920. } else {
  15921. if (!v0)
  15922. v0 = [fx, y12];
  15923. else if (v0[1] < y02)
  15924. return;
  15925. v1 = [fx, y02];
  15926. }
  15927. } else {
  15928. fm = (lx - rx) / (ry - ly);
  15929. fb = fy - fm * fx;
  15930. if (fm < -1 || fm > 1) {
  15931. if (lx > rx) {
  15932. if (!v0)
  15933. v0 = [(y02 - fb) / fm, y02];
  15934. else if (v0[1] >= y12)
  15935. return;
  15936. v1 = [(y12 - fb) / fm, y12];
  15937. } else {
  15938. if (!v0)
  15939. v0 = [(y12 - fb) / fm, y12];
  15940. else if (v0[1] < y02)
  15941. return;
  15942. v1 = [(y02 - fb) / fm, y02];
  15943. }
  15944. } else {
  15945. if (ly < ry) {
  15946. if (!v0)
  15947. v0 = [x02, fm * x02 + fb];
  15948. else if (v0[0] >= x12)
  15949. return;
  15950. v1 = [x12, fm * x12 + fb];
  15951. } else {
  15952. if (!v0)
  15953. v0 = [x12, fm * x12 + fb];
  15954. else if (v0[0] < x02)
  15955. return;
  15956. v1 = [x02, fm * x02 + fb];
  15957. }
  15958. }
  15959. }
  15960. edge[0] = v0;
  15961. edge[1] = v1;
  15962. return true;
  15963. }
  15964. function clipEdges(x02, y02, x12, y12) {
  15965. var i = edges.length, edge;
  15966. while (i--) {
  15967. if (!connectEdge(edge = edges[i], x02, y02, x12, y12) || !clipEdge(edge, x02, y02, x12, y12) || !(Math.abs(edge[0][0] - edge[1][0]) > epsilon || Math.abs(edge[0][1] - edge[1][1]) > epsilon)) {
  15968. delete edges[i];
  15969. }
  15970. }
  15971. }
  15972. // node_modules/d3-voronoi/src/Cell.js
  15973. function createCell(site) {
  15974. return cells[site.index] = {
  15975. site,
  15976. halfedges: []
  15977. };
  15978. }
  15979. function cellHalfedgeAngle(cell, edge) {
  15980. var site = cell.site, va = edge.left, vb = edge.right;
  15981. if (site === vb)
  15982. vb = va, va = site;
  15983. if (vb)
  15984. return Math.atan2(vb[1] - va[1], vb[0] - va[0]);
  15985. if (site === va)
  15986. va = edge[1], vb = edge[0];
  15987. else
  15988. va = edge[0], vb = edge[1];
  15989. return Math.atan2(va[0] - vb[0], vb[1] - va[1]);
  15990. }
  15991. function cellHalfedgeStart(cell, edge) {
  15992. return edge[+(edge.left !== cell.site)];
  15993. }
  15994. function cellHalfedgeEnd(cell, edge) {
  15995. return edge[+(edge.left === cell.site)];
  15996. }
  15997. function sortCellHalfedges() {
  15998. for (var i = 0, n = cells.length, cell, halfedges, j, m; i < n; ++i) {
  15999. if ((cell = cells[i]) && (m = (halfedges = cell.halfedges).length)) {
  16000. var index2 = new Array(m), array2 = new Array(m);
  16001. for (j = 0; j < m; ++j)
  16002. index2[j] = j, array2[j] = cellHalfedgeAngle(cell, edges[halfedges[j]]);
  16003. index2.sort(function(i2, j2) {
  16004. return array2[j2] - array2[i2];
  16005. });
  16006. for (j = 0; j < m; ++j)
  16007. array2[j] = halfedges[index2[j]];
  16008. for (j = 0; j < m; ++j)
  16009. halfedges[j] = array2[j];
  16010. }
  16011. }
  16012. }
  16013. function clipCells(x02, y02, x12, y12) {
  16014. var nCells = cells.length, iCell, cell, site, iHalfedge, halfedges, nHalfedges, start, startX, startY, end, endX, endY, cover = true;
  16015. for (iCell = 0; iCell < nCells; ++iCell) {
  16016. if (cell = cells[iCell]) {
  16017. site = cell.site;
  16018. halfedges = cell.halfedges;
  16019. iHalfedge = halfedges.length;
  16020. while (iHalfedge--) {
  16021. if (!edges[halfedges[iHalfedge]]) {
  16022. halfedges.splice(iHalfedge, 1);
  16023. }
  16024. }
  16025. iHalfedge = 0, nHalfedges = halfedges.length;
  16026. while (iHalfedge < nHalfedges) {
  16027. end = cellHalfedgeEnd(cell, edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1];
  16028. start = cellHalfedgeStart(cell, edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1];
  16029. if (Math.abs(endX - startX) > epsilon || Math.abs(endY - startY) > epsilon) {
  16030. halfedges.splice(iHalfedge, 0, edges.push(createBorderEdge(
  16031. site,
  16032. end,
  16033. Math.abs(endX - x02) < epsilon && y12 - endY > epsilon ? [x02, Math.abs(startX - x02) < epsilon ? startY : y12] : Math.abs(endY - y12) < epsilon && x12 - endX > epsilon ? [Math.abs(startY - y12) < epsilon ? startX : x12, y12] : Math.abs(endX - x12) < epsilon && endY - y02 > epsilon ? [x12, Math.abs(startX - x12) < epsilon ? startY : y02] : Math.abs(endY - y02) < epsilon && endX - x02 > epsilon ? [Math.abs(startY - y02) < epsilon ? startX : x02, y02] : null
  16034. )) - 1);
  16035. ++nHalfedges;
  16036. }
  16037. }
  16038. if (nHalfedges)
  16039. cover = false;
  16040. }
  16041. }
  16042. if (cover) {
  16043. var dx, dy, d2, dc = Infinity;
  16044. for (iCell = 0, cover = null; iCell < nCells; ++iCell) {
  16045. if (cell = cells[iCell]) {
  16046. site = cell.site;
  16047. dx = site[0] - x02;
  16048. dy = site[1] - y02;
  16049. d2 = dx * dx + dy * dy;
  16050. if (d2 < dc)
  16051. dc = d2, cover = cell;
  16052. }
  16053. }
  16054. if (cover) {
  16055. var v00 = [x02, y02], v01 = [x02, y12], v11 = [x12, y12], v10 = [x12, y02];
  16056. cover.halfedges.push(
  16057. edges.push(createBorderEdge(site = cover.site, v00, v01)) - 1,
  16058. edges.push(createBorderEdge(site, v01, v11)) - 1,
  16059. edges.push(createBorderEdge(site, v11, v10)) - 1,
  16060. edges.push(createBorderEdge(site, v10, v00)) - 1
  16061. );
  16062. }
  16063. }
  16064. for (iCell = 0; iCell < nCells; ++iCell) {
  16065. if (cell = cells[iCell]) {
  16066. if (!cell.halfedges.length) {
  16067. delete cells[iCell];
  16068. }
  16069. }
  16070. }
  16071. }
  16072. // node_modules/d3-voronoi/src/Circle.js
  16073. var circlePool = [];
  16074. var firstCircle;
  16075. function Circle() {
  16076. RedBlackNode(this);
  16077. this.x = this.y = this.arc = this.site = this.cy = null;
  16078. }
  16079. function attachCircle(arc) {
  16080. var lArc = arc.P, rArc = arc.N;
  16081. if (!lArc || !rArc)
  16082. return;
  16083. var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;
  16084. if (lSite === rSite)
  16085. return;
  16086. var bx = cSite[0], by = cSite[1], ax = lSite[0] - bx, ay = lSite[1] - by, cx = rSite[0] - bx, cy = rSite[1] - by;
  16087. var d = 2 * (ax * cy - ay * cx);
  16088. if (d >= -epsilon2)
  16089. return;
  16090. var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x2 = (cy * ha - ay * hc) / d, y2 = (ax * hc - cx * ha) / d;
  16091. var circle3 = circlePool.pop() || new Circle();
  16092. circle3.arc = arc;
  16093. circle3.site = cSite;
  16094. circle3.x = x2 + bx;
  16095. circle3.y = (circle3.cy = y2 + by) + Math.sqrt(x2 * x2 + y2 * y2);
  16096. arc.circle = circle3;
  16097. var before = null, node = circles._;
  16098. while (node) {
  16099. if (circle3.y < node.y || circle3.y === node.y && circle3.x <= node.x) {
  16100. if (node.L)
  16101. node = node.L;
  16102. else {
  16103. before = node.P;
  16104. break;
  16105. }
  16106. } else {
  16107. if (node.R)
  16108. node = node.R;
  16109. else {
  16110. before = node;
  16111. break;
  16112. }
  16113. }
  16114. }
  16115. circles.insert(before, circle3);
  16116. if (!before)
  16117. firstCircle = circle3;
  16118. }
  16119. function detachCircle(arc) {
  16120. var circle3 = arc.circle;
  16121. if (circle3) {
  16122. if (!circle3.P)
  16123. firstCircle = circle3.N;
  16124. circles.remove(circle3);
  16125. circlePool.push(circle3);
  16126. RedBlackNode(circle3);
  16127. arc.circle = null;
  16128. }
  16129. }
  16130. // node_modules/d3-voronoi/src/Beach.js
  16131. var beachPool = [];
  16132. function Beach() {
  16133. RedBlackNode(this);
  16134. this.edge = this.site = this.circle = null;
  16135. }
  16136. function createBeach(site) {
  16137. var beach = beachPool.pop() || new Beach();
  16138. beach.site = site;
  16139. return beach;
  16140. }
  16141. function detachBeach(beach) {
  16142. detachCircle(beach);
  16143. beaches.remove(beach);
  16144. beachPool.push(beach);
  16145. RedBlackNode(beach);
  16146. }
  16147. function removeBeach(beach) {
  16148. var circle3 = beach.circle, x2 = circle3.x, y2 = circle3.cy, vertex = [x2, y2], previous = beach.P, next3 = beach.N, disappearing = [beach];
  16149. detachBeach(beach);
  16150. var lArc = previous;
  16151. while (lArc.circle && Math.abs(x2 - lArc.circle.x) < epsilon && Math.abs(y2 - lArc.circle.cy) < epsilon) {
  16152. previous = lArc.P;
  16153. disappearing.unshift(lArc);
  16154. detachBeach(lArc);
  16155. lArc = previous;
  16156. }
  16157. disappearing.unshift(lArc);
  16158. detachCircle(lArc);
  16159. var rArc = next3;
  16160. while (rArc.circle && Math.abs(x2 - rArc.circle.x) < epsilon && Math.abs(y2 - rArc.circle.cy) < epsilon) {
  16161. next3 = rArc.N;
  16162. disappearing.push(rArc);
  16163. detachBeach(rArc);
  16164. rArc = next3;
  16165. }
  16166. disappearing.push(rArc);
  16167. detachCircle(rArc);
  16168. var nArcs = disappearing.length, iArc;
  16169. for (iArc = 1; iArc < nArcs; ++iArc) {
  16170. rArc = disappearing[iArc];
  16171. lArc = disappearing[iArc - 1];
  16172. setEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
  16173. }
  16174. lArc = disappearing[0];
  16175. rArc = disappearing[nArcs - 1];
  16176. rArc.edge = createEdge(lArc.site, rArc.site, null, vertex);
  16177. attachCircle(lArc);
  16178. attachCircle(rArc);
  16179. }
  16180. function addBeach(site) {
  16181. var x2 = site[0], directrix = site[1], lArc, rArc, dxl, dxr, node = beaches._;
  16182. while (node) {
  16183. dxl = leftBreakPoint(node, directrix) - x2;
  16184. if (dxl > epsilon)
  16185. node = node.L;
  16186. else {
  16187. dxr = x2 - rightBreakPoint(node, directrix);
  16188. if (dxr > epsilon) {
  16189. if (!node.R) {
  16190. lArc = node;
  16191. break;
  16192. }
  16193. node = node.R;
  16194. } else {
  16195. if (dxl > -epsilon) {
  16196. lArc = node.P;
  16197. rArc = node;
  16198. } else if (dxr > -epsilon) {
  16199. lArc = node;
  16200. rArc = node.N;
  16201. } else {
  16202. lArc = rArc = node;
  16203. }
  16204. break;
  16205. }
  16206. }
  16207. }
  16208. createCell(site);
  16209. var newArc = createBeach(site);
  16210. beaches.insert(lArc, newArc);
  16211. if (!lArc && !rArc)
  16212. return;
  16213. if (lArc === rArc) {
  16214. detachCircle(lArc);
  16215. rArc = createBeach(lArc.site);
  16216. beaches.insert(newArc, rArc);
  16217. newArc.edge = rArc.edge = createEdge(lArc.site, newArc.site);
  16218. attachCircle(lArc);
  16219. attachCircle(rArc);
  16220. return;
  16221. }
  16222. if (!rArc) {
  16223. newArc.edge = createEdge(lArc.site, newArc.site);
  16224. return;
  16225. }
  16226. detachCircle(lArc);
  16227. detachCircle(rArc);
  16228. var lSite = lArc.site, ax = lSite[0], ay = lSite[1], bx = site[0] - ax, by = site[1] - ay, rSite = rArc.site, cx = rSite[0] - ax, cy = rSite[1] - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay];
  16229. setEdgeEnd(rArc.edge, lSite, rSite, vertex);
  16230. newArc.edge = createEdge(lSite, site, null, vertex);
  16231. rArc.edge = createEdge(site, rSite, null, vertex);
  16232. attachCircle(lArc);
  16233. attachCircle(rArc);
  16234. }
  16235. function leftBreakPoint(arc, directrix) {
  16236. var site = arc.site, rfocx = site[0], rfocy = site[1], pby2 = rfocy - directrix;
  16237. if (!pby2)
  16238. return rfocx;
  16239. var lArc = arc.P;
  16240. if (!lArc)
  16241. return -Infinity;
  16242. site = lArc.site;
  16243. var lfocx = site[0], lfocy = site[1], plby2 = lfocy - directrix;
  16244. if (!plby2)
  16245. return lfocx;
  16246. var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;
  16247. if (aby2)
  16248. return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
  16249. return (rfocx + lfocx) / 2;
  16250. }
  16251. function rightBreakPoint(arc, directrix) {
  16252. var rArc = arc.N;
  16253. if (rArc)
  16254. return leftBreakPoint(rArc, directrix);
  16255. var site = arc.site;
  16256. return site[1] === directrix ? site[0] : Infinity;
  16257. }
  16258. // node_modules/d3-voronoi/src/Diagram.js
  16259. var epsilon = 1e-6;
  16260. var epsilon2 = 1e-12;
  16261. var beaches;
  16262. var cells;
  16263. var circles;
  16264. var edges;
  16265. function triangleArea(a, b, c) {
  16266. return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
  16267. }
  16268. function lexicographic(a, b) {
  16269. return b[1] - a[1] || b[0] - a[0];
  16270. }
  16271. function Diagram(sites, extent) {
  16272. var site = sites.sort(lexicographic).pop(), x2, y2, circle3;
  16273. edges = [];
  16274. cells = new Array(sites.length);
  16275. beaches = new RedBlackTree_default();
  16276. circles = new RedBlackTree_default();
  16277. while (true) {
  16278. circle3 = firstCircle;
  16279. if (site && (!circle3 || site[1] < circle3.y || site[1] === circle3.y && site[0] < circle3.x)) {
  16280. if (site[0] !== x2 || site[1] !== y2) {
  16281. addBeach(site);
  16282. x2 = site[0], y2 = site[1];
  16283. }
  16284. site = sites.pop();
  16285. } else if (circle3) {
  16286. removeBeach(circle3.arc);
  16287. } else {
  16288. break;
  16289. }
  16290. }
  16291. sortCellHalfedges();
  16292. if (extent) {
  16293. var x02 = +extent[0][0], y02 = +extent[0][1], x12 = +extent[1][0], y12 = +extent[1][1];
  16294. clipEdges(x02, y02, x12, y12);
  16295. clipCells(x02, y02, x12, y12);
  16296. }
  16297. this.edges = edges;
  16298. this.cells = cells;
  16299. beaches = circles = edges = cells = null;
  16300. }
  16301. Diagram.prototype = {
  16302. constructor: Diagram,
  16303. polygons: function() {
  16304. var edges2 = this.edges;
  16305. return this.cells.map(function(cell) {
  16306. var polygon4 = cell.halfedges.map(function(i) {
  16307. return cellHalfedgeStart(cell, edges2[i]);
  16308. });
  16309. polygon4.data = cell.site.data;
  16310. return polygon4;
  16311. });
  16312. },
  16313. triangles: function() {
  16314. var triangles = [], edges2 = this.edges;
  16315. this.cells.forEach(function(cell, i) {
  16316. if (!(m = (halfedges = cell.halfedges).length))
  16317. return;
  16318. var site = cell.site, halfedges, j = -1, m, s0, e1 = edges2[halfedges[m - 1]], s1 = e1.left === site ? e1.right : e1.left;
  16319. while (++j < m) {
  16320. s0 = s1;
  16321. e1 = edges2[halfedges[j]];
  16322. s1 = e1.left === site ? e1.right : e1.left;
  16323. if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
  16324. triangles.push([site.data, s0.data, s1.data]);
  16325. }
  16326. }
  16327. });
  16328. return triangles;
  16329. },
  16330. links: function() {
  16331. return this.edges.filter(function(edge) {
  16332. return edge.right;
  16333. }).map(function(edge) {
  16334. return {
  16335. source: edge.left.data,
  16336. target: edge.right.data
  16337. };
  16338. });
  16339. },
  16340. find: function(x2, y2, radius) {
  16341. var that = this, i0, i1 = that._found || 0, n = that.cells.length, cell;
  16342. while (!(cell = that.cells[i1]))
  16343. if (++i1 >= n)
  16344. return null;
  16345. var dx = x2 - cell.site[0], dy = y2 - cell.site[1], d2 = dx * dx + dy * dy;
  16346. do {
  16347. cell = that.cells[i0 = i1], i1 = null;
  16348. cell.halfedges.forEach(function(e) {
  16349. var edge = that.edges[e], v = edge.left;
  16350. if ((v === cell.site || !v) && !(v = edge.right))
  16351. return;
  16352. var vx = x2 - v[0], vy = y2 - v[1], v2 = vx * vx + vy * vy;
  16353. if (v2 < d2)
  16354. d2 = v2, i1 = v.index;
  16355. });
  16356. } while (i1 !== null);
  16357. that._found = i0;
  16358. return radius == null || d2 <= radius * radius ? cell.site : null;
  16359. }
  16360. };
  16361. // node_modules/d3-voronoi/src/voronoi.js
  16362. function voronoi_default() {
  16363. var x2 = x, y2 = y, extent = null;
  16364. function voronoi2(data) {
  16365. return new Diagram(data.map(function(d, i) {
  16366. var s = [Math.round(x2(d, i, data) / epsilon) * epsilon, Math.round(y2(d, i, data) / epsilon) * epsilon];
  16367. s.index = i;
  16368. s.data = d;
  16369. return s;
  16370. }), extent);
  16371. }
  16372. voronoi2.polygons = function(data) {
  16373. return voronoi2(data).polygons();
  16374. };
  16375. voronoi2.links = function(data) {
  16376. return voronoi2(data).links();
  16377. };
  16378. voronoi2.triangles = function(data) {
  16379. return voronoi2(data).triangles();
  16380. };
  16381. voronoi2.x = function(_) {
  16382. return arguments.length ? (x2 = typeof _ === "function" ? _ : constant_default(+_), voronoi2) : x2;
  16383. };
  16384. voronoi2.y = function(_) {
  16385. return arguments.length ? (y2 = typeof _ === "function" ? _ : constant_default(+_), voronoi2) : y2;
  16386. };
  16387. voronoi2.extent = function(_) {
  16388. return arguments.length ? (extent = _ == null ? null : [[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]], voronoi2) : extent && [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]];
  16389. };
  16390. voronoi2.size = function(_) {
  16391. return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi2) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
  16392. };
  16393. return voronoi2;
  16394. }
  16395. // node_modules/@turf/voronoi/dist/es/index.js
  16396. function coordsToPolygon(coords) {
  16397. coords = coords.slice();
  16398. coords.push(coords[0]);
  16399. return polygon([coords]);
  16400. }
  16401. function voronoi(points2, options) {
  16402. options = options || {};
  16403. if (!isObject(options))
  16404. throw new Error("options is invalid");
  16405. var bbox3 = options.bbox || [-180, -85, 180, 85];
  16406. if (!points2)
  16407. throw new Error("points is required");
  16408. if (!Array.isArray(bbox3))
  16409. throw new Error("bbox is invalid");
  16410. collectionOf(points2, "Point", "points");
  16411. return featureCollection(
  16412. voronoi_default().x(function(feature2) {
  16413. return feature2.geometry.coordinates[0];
  16414. }).y(function(feature2) {
  16415. return feature2.geometry.coordinates[1];
  16416. }).extent([
  16417. [bbox3[0], bbox3[1]],
  16418. [bbox3[2], bbox3[3]]
  16419. ]).polygons(points2.features).map(coordsToPolygon)
  16420. );
  16421. }
  16422. var es_default64 = voronoi;
  16423. // node_modules/@turf/ellipse/dist/es/index.js
  16424. function ellipse(center2, xSemiAxis, ySemiAxis, options) {
  16425. options = options || {};
  16426. var steps = options.steps || 64;
  16427. var units = options.units || "kilometers";
  16428. var angle4 = options.angle || 0;
  16429. var pivot = options.pivot || center2;
  16430. var properties = options.properties || center2.properties || {};
  16431. if (!center2)
  16432. throw new Error("center is required");
  16433. if (!xSemiAxis)
  16434. throw new Error("xSemiAxis is required");
  16435. if (!ySemiAxis)
  16436. throw new Error("ySemiAxis is required");
  16437. if (!isObject(options))
  16438. throw new Error("options must be an object");
  16439. if (!isNumber(steps))
  16440. throw new Error("steps must be a number");
  16441. if (!isNumber(angle4))
  16442. throw new Error("angle must be a number");
  16443. var centerCoords = getCoord(center2);
  16444. if (units === "degrees") {
  16445. var angleRad = degreesToRadians(angle4);
  16446. } else {
  16447. xSemiAxis = es_default49(center2, xSemiAxis, 90, { units });
  16448. ySemiAxis = es_default49(center2, ySemiAxis, 0, { units });
  16449. xSemiAxis = getCoord(xSemiAxis)[0] - centerCoords[0];
  16450. ySemiAxis = getCoord(ySemiAxis)[1] - centerCoords[1];
  16451. }
  16452. var coordinates = [];
  16453. for (var i = 0; i < steps; i += 1) {
  16454. var stepAngle = i * -360 / steps;
  16455. var x2 = xSemiAxis * ySemiAxis / Math.sqrt(
  16456. Math.pow(ySemiAxis, 2) + Math.pow(xSemiAxis, 2) * Math.pow(getTanDeg(stepAngle), 2)
  16457. );
  16458. var y2 = xSemiAxis * ySemiAxis / Math.sqrt(
  16459. Math.pow(xSemiAxis, 2) + Math.pow(ySemiAxis, 2) / Math.pow(getTanDeg(stepAngle), 2)
  16460. );
  16461. if (stepAngle < -90 && stepAngle >= -270)
  16462. x2 = -x2;
  16463. if (stepAngle < -180 && stepAngle >= -360)
  16464. y2 = -y2;
  16465. if (units === "degrees") {
  16466. var newx = x2 * Math.cos(angleRad) + y2 * Math.sin(angleRad);
  16467. var newy = y2 * Math.cos(angleRad) - x2 * Math.sin(angleRad);
  16468. x2 = newx;
  16469. y2 = newy;
  16470. }
  16471. coordinates.push([x2 + centerCoords[0], y2 + centerCoords[1]]);
  16472. }
  16473. coordinates.push(coordinates[0]);
  16474. if (units === "degrees") {
  16475. return polygon([coordinates], properties);
  16476. } else {
  16477. return es_default53(polygon([coordinates], properties), angle4, {
  16478. pivot
  16479. });
  16480. }
  16481. }
  16482. function getTanDeg(deg) {
  16483. var rad2 = deg * Math.PI / 180;
  16484. return Math.tan(rad2);
  16485. }
  16486. var es_default65 = ellipse;
  16487. // node_modules/@turf/center-mean/dist/es/index.js
  16488. function centerMean(geojson, options) {
  16489. if (options === void 0) {
  16490. options = {};
  16491. }
  16492. var sumXs = 0;
  16493. var sumYs = 0;
  16494. var sumNs = 0;
  16495. geomEach(geojson, function(geom, featureIndex, properties) {
  16496. var weight = options.weight ? properties === null || properties === void 0 ? void 0 : properties[options.weight] : void 0;
  16497. weight = weight === void 0 || weight === null ? 1 : weight;
  16498. if (!isNumber(weight))
  16499. throw new Error("weight value must be a number for feature index " + featureIndex);
  16500. weight = Number(weight);
  16501. if (weight > 0) {
  16502. coordEach(geom, function(coord) {
  16503. sumXs += coord[0] * weight;
  16504. sumYs += coord[1] * weight;
  16505. sumNs += weight;
  16506. });
  16507. }
  16508. });
  16509. return point([sumXs / sumNs, sumYs / sumNs], options.properties, options);
  16510. }
  16511. var es_default66 = centerMean;
  16512. // node_modules/@turf/center-median/dist/es/index.js
  16513. function centerMedian(features, options) {
  16514. if (options === void 0) {
  16515. options = {};
  16516. }
  16517. options = options || {};
  16518. if (!isObject(options))
  16519. throw new Error("options is invalid");
  16520. var counter = options.counter || 10;
  16521. if (!isNumber(counter))
  16522. throw new Error("counter must be a number");
  16523. var weightTerm = options.weight;
  16524. var meanCenter = es_default66(features, { weight: options.weight });
  16525. var centroids = featureCollection([]);
  16526. featureEach(features, function(feature2) {
  16527. var _a;
  16528. centroids.features.push(es_default19(feature2, {
  16529. properties: { weight: (_a = feature2.properties) === null || _a === void 0 ? void 0 : _a[weightTerm] }
  16530. }));
  16531. });
  16532. var properties = {
  16533. tolerance: options.tolerance,
  16534. medianCandidates: []
  16535. };
  16536. return findMedian(meanCenter.geometry.coordinates, [0, 0], centroids, properties, counter);
  16537. }
  16538. function findMedian(candidateMedian, previousCandidate, centroids, properties, counter) {
  16539. var tolerance = properties.tolerance || 1e-3;
  16540. var candidateXsum = 0;
  16541. var candidateYsum = 0;
  16542. var kSum = 0;
  16543. var centroidCount = 0;
  16544. featureEach(centroids, function(theCentroid) {
  16545. var _a;
  16546. var weightValue = (_a = theCentroid.properties) === null || _a === void 0 ? void 0 : _a.weight;
  16547. var weight = weightValue === void 0 || weightValue === null ? 1 : weightValue;
  16548. weight = Number(weight);
  16549. if (!isNumber(weight))
  16550. throw new Error("weight value must be a number");
  16551. if (weight > 0) {
  16552. centroidCount += 1;
  16553. var distanceFromCandidate = weight * es_default4(theCentroid, candidateMedian);
  16554. if (distanceFromCandidate === 0)
  16555. distanceFromCandidate = 1;
  16556. var k = weight / distanceFromCandidate;
  16557. candidateXsum += theCentroid.geometry.coordinates[0] * k;
  16558. candidateYsum += theCentroid.geometry.coordinates[1] * k;
  16559. kSum += k;
  16560. }
  16561. });
  16562. if (centroidCount < 1)
  16563. throw new Error("no features to measure");
  16564. var candidateX = candidateXsum / kSum;
  16565. var candidateY = candidateYsum / kSum;
  16566. if (centroidCount === 1 || counter === 0 || Math.abs(candidateX - previousCandidate[0]) < tolerance && Math.abs(candidateY - previousCandidate[1]) < tolerance) {
  16567. return point([candidateX, candidateY], {
  16568. medianCandidates: properties.medianCandidates
  16569. });
  16570. } else {
  16571. properties.medianCandidates.push([candidateX, candidateY]);
  16572. return findMedian([candidateX, candidateY], candidateMedian, centroids, properties, counter - 1);
  16573. }
  16574. }
  16575. var es_default67 = centerMedian;
  16576. // node_modules/@turf/standard-deviational-ellipse/dist/es/index.js
  16577. function standardDeviationalEllipse(points2, options) {
  16578. options = options || {};
  16579. if (!isObject(options))
  16580. throw new Error("options is invalid");
  16581. var steps = options.steps || 64;
  16582. var weightTerm = options.weight;
  16583. var properties = options.properties || {};
  16584. if (!isNumber(steps))
  16585. throw new Error("steps must be a number");
  16586. if (!isObject(properties))
  16587. throw new Error("properties must be a number");
  16588. var numberOfFeatures = coordAll(points2).length;
  16589. var meanCenter = es_default66(points2, { weight: weightTerm });
  16590. var xDeviationSquaredSum = 0;
  16591. var yDeviationSquaredSum = 0;
  16592. var xyDeviationSum = 0;
  16593. featureEach(points2, function(point4) {
  16594. var weight = point4.properties[weightTerm] || 1;
  16595. var deviation = getDeviations(getCoords(point4), getCoords(meanCenter));
  16596. xDeviationSquaredSum += Math.pow(deviation.x, 2) * weight;
  16597. yDeviationSquaredSum += Math.pow(deviation.y, 2) * weight;
  16598. xyDeviationSum += deviation.x * deviation.y * weight;
  16599. });
  16600. var bigA = xDeviationSquaredSum - yDeviationSquaredSum;
  16601. var bigB = Math.sqrt(Math.pow(bigA, 2) + 4 * Math.pow(xyDeviationSum, 2));
  16602. var bigC = 2 * xyDeviationSum;
  16603. var theta = Math.atan((bigA + bigB) / bigC);
  16604. var thetaDeg = theta * 180 / Math.PI;
  16605. var sigmaXsum = 0;
  16606. var sigmaYsum = 0;
  16607. var weightsum = 0;
  16608. featureEach(points2, function(point4) {
  16609. var weight = point4.properties[weightTerm] || 1;
  16610. var deviation = getDeviations(getCoords(point4), getCoords(meanCenter));
  16611. sigmaXsum += Math.pow(
  16612. deviation.x * Math.cos(theta) - deviation.y * Math.sin(theta),
  16613. 2
  16614. ) * weight;
  16615. sigmaYsum += Math.pow(
  16616. deviation.x * Math.sin(theta) + deviation.y * Math.cos(theta),
  16617. 2
  16618. ) * weight;
  16619. weightsum += weight;
  16620. });
  16621. var sigmaX = Math.sqrt(2 * sigmaXsum / weightsum);
  16622. var sigmaY = Math.sqrt(2 * sigmaYsum / weightsum);
  16623. var theEllipse = es_default65(meanCenter, sigmaX, sigmaY, {
  16624. units: "degrees",
  16625. angle: thetaDeg,
  16626. steps,
  16627. properties
  16628. });
  16629. var pointsWithinEllipse = es_default3(
  16630. points2,
  16631. featureCollection([theEllipse])
  16632. );
  16633. var standardDeviationalEllipseProperties = {
  16634. meanCenterCoordinates: getCoords(meanCenter),
  16635. semiMajorAxis: sigmaX,
  16636. semiMinorAxis: sigmaY,
  16637. numberOfFeatures,
  16638. angle: thetaDeg,
  16639. percentageWithinEllipse: 100 * coordAll(pointsWithinEllipse).length / numberOfFeatures
  16640. };
  16641. theEllipse.properties.standardDeviationalEllipse = standardDeviationalEllipseProperties;
  16642. return theEllipse;
  16643. }
  16644. function getDeviations(coordinates, center2) {
  16645. return {
  16646. x: coordinates[0] - center2[0],
  16647. y: coordinates[1] - center2[1]
  16648. };
  16649. }
  16650. var es_default68 = standardDeviationalEllipse;
  16651. // node_modules/@turf/angle/dist/es/index.js
  16652. function angle(startPoint, midPoint3, endPoint, options) {
  16653. if (options === void 0) {
  16654. options = {};
  16655. }
  16656. if (!isObject(options)) {
  16657. throw new Error("options is invalid");
  16658. }
  16659. if (!startPoint) {
  16660. throw new Error("startPoint is required");
  16661. }
  16662. if (!midPoint3) {
  16663. throw new Error("midPoint is required");
  16664. }
  16665. if (!endPoint) {
  16666. throw new Error("endPoint is required");
  16667. }
  16668. var A = startPoint;
  16669. var O = midPoint3;
  16670. var B2 = endPoint;
  16671. var azimuthAO = bearingToAzimuth(options.mercator !== true ? bearing(A, O) : es_default48(A, O));
  16672. var azimuthBO = bearingToAzimuth(options.mercator !== true ? bearing(B2, O) : es_default48(B2, O));
  16673. var angleAO = Math.abs(azimuthAO - azimuthBO);
  16674. if (options.explementary === true) {
  16675. return 360 - angleAO;
  16676. }
  16677. return angleAO;
  16678. }
  16679. var es_default69 = angle;
  16680. // node_modules/@turf/polygon-smooth/dist/es/index.js
  16681. function polygonSmooth(inputPolys, options) {
  16682. var outPolys = [];
  16683. var iterations = options.iterations || 1;
  16684. if (!inputPolys)
  16685. throw new Error("inputPolys is required");
  16686. geomEach(inputPolys, function(geom, geomIndex, properties) {
  16687. var outCoords;
  16688. var poly;
  16689. var tempOutput;
  16690. switch (geom.type) {
  16691. case "Polygon":
  16692. outCoords = [[]];
  16693. for (var i = 0; i < iterations; i++) {
  16694. tempOutput = [[]];
  16695. poly = geom;
  16696. if (i > 0)
  16697. poly = polygon(outCoords).geometry;
  16698. processPolygon3(poly, tempOutput);
  16699. outCoords = tempOutput.slice(0);
  16700. }
  16701. outPolys.push(polygon(outCoords, properties));
  16702. break;
  16703. case "MultiPolygon":
  16704. outCoords = [[[]]];
  16705. for (var y2 = 0; y2 < iterations; y2++) {
  16706. tempOutput = [[[]]];
  16707. poly = geom;
  16708. if (y2 > 0)
  16709. poly = multiPolygon(outCoords).geometry;
  16710. processMultiPolygon(poly, tempOutput);
  16711. outCoords = tempOutput.slice(0);
  16712. }
  16713. outPolys.push(multiPolygon(outCoords, properties));
  16714. break;
  16715. default:
  16716. throw new Error("geometry is invalid, must be Polygon or MultiPolygon");
  16717. }
  16718. });
  16719. return featureCollection(outPolys);
  16720. }
  16721. function processPolygon3(poly, tempOutput) {
  16722. var prevGeomIndex = 0;
  16723. var subtractCoordIndex = 0;
  16724. coordEach(
  16725. poly,
  16726. function(currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  16727. if (geometryIndex > prevGeomIndex) {
  16728. prevGeomIndex = geometryIndex;
  16729. subtractCoordIndex = coordIndex;
  16730. tempOutput.push([]);
  16731. }
  16732. var realCoordIndex = coordIndex - subtractCoordIndex;
  16733. var p1 = poly.coordinates[geometryIndex][realCoordIndex + 1];
  16734. var p0x = currentCoord[0];
  16735. var p0y = currentCoord[1];
  16736. var p1x = p1[0];
  16737. var p1y = p1[1];
  16738. tempOutput[geometryIndex].push([
  16739. 0.75 * p0x + 0.25 * p1x,
  16740. 0.75 * p0y + 0.25 * p1y
  16741. ]);
  16742. tempOutput[geometryIndex].push([
  16743. 0.25 * p0x + 0.75 * p1x,
  16744. 0.25 * p0y + 0.75 * p1y
  16745. ]);
  16746. },
  16747. true
  16748. );
  16749. tempOutput.forEach(function(ring) {
  16750. ring.push(ring[0]);
  16751. });
  16752. }
  16753. function processMultiPolygon(poly, tempOutput) {
  16754. var prevGeomIndex = 0;
  16755. var subtractCoordIndex = 0;
  16756. var prevMultiIndex = 0;
  16757. coordEach(
  16758. poly,
  16759. function(currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  16760. if (multiFeatureIndex > prevMultiIndex) {
  16761. prevMultiIndex = multiFeatureIndex;
  16762. subtractCoordIndex = coordIndex;
  16763. tempOutput.push([[]]);
  16764. }
  16765. if (geometryIndex > prevGeomIndex) {
  16766. prevGeomIndex = geometryIndex;
  16767. subtractCoordIndex = coordIndex;
  16768. tempOutput[multiFeatureIndex].push([]);
  16769. }
  16770. var realCoordIndex = coordIndex - subtractCoordIndex;
  16771. var p1 = poly.coordinates[multiFeatureIndex][geometryIndex][realCoordIndex + 1];
  16772. var p0x = currentCoord[0];
  16773. var p0y = currentCoord[1];
  16774. var p1x = p1[0];
  16775. var p1y = p1[1];
  16776. tempOutput[multiFeatureIndex][geometryIndex].push([
  16777. 0.75 * p0x + 0.25 * p1x,
  16778. 0.75 * p0y + 0.25 * p1y
  16779. ]);
  16780. tempOutput[multiFeatureIndex][geometryIndex].push([
  16781. 0.25 * p0x + 0.75 * p1x,
  16782. 0.25 * p0y + 0.75 * p1y
  16783. ]);
  16784. },
  16785. true
  16786. );
  16787. tempOutput.forEach(function(poly2) {
  16788. poly2.forEach(function(ring) {
  16789. ring.push(ring[0]);
  16790. });
  16791. });
  16792. }
  16793. var es_default70 = polygonSmooth;
  16794. // node_modules/@turf/distance-weight/dist/es/index.js
  16795. function pNormDistance(feature1, feature2, p) {
  16796. if (p === void 0) {
  16797. p = 2;
  16798. }
  16799. var coordinate1 = getCoord(feature1);
  16800. var coordinate2 = getCoord(feature2);
  16801. var xDiff = coordinate1[0] - coordinate2[0];
  16802. var yDiff = coordinate1[1] - coordinate2[1];
  16803. if (p === 1) {
  16804. return Math.abs(xDiff) + Math.abs(yDiff);
  16805. }
  16806. return Math.pow(Math.pow(xDiff, p) + Math.pow(yDiff, p), 1 / p);
  16807. }
  16808. function distanceWeight(fc, options) {
  16809. options = options || {};
  16810. var threshold = options.threshold || 1e4;
  16811. var p = options.p || 2;
  16812. var binary = options.binary || false;
  16813. var alpha = options.alpha || -1;
  16814. var rowTransform = options.standardization || false;
  16815. var features = [];
  16816. featureEach(fc, function(feature2) {
  16817. features.push(es_default19(feature2));
  16818. });
  16819. var weights = [];
  16820. for (var i = 0; i < features.length; i++) {
  16821. weights[i] = [];
  16822. }
  16823. for (var i = 0; i < features.length; i++) {
  16824. for (var j = i; j < features.length; j++) {
  16825. if (i === j) {
  16826. weights[i][j] = 0;
  16827. }
  16828. var dis = pNormDistance(features[i], features[j], p);
  16829. weights[i][j] = dis;
  16830. weights[j][i] = dis;
  16831. }
  16832. }
  16833. for (var i = 0; i < features.length; i++) {
  16834. for (var j = 0; j < features.length; j++) {
  16835. var dis = weights[i][j];
  16836. if (dis === 0) {
  16837. continue;
  16838. }
  16839. if (binary) {
  16840. if (dis <= threshold) {
  16841. weights[i][j] = 1;
  16842. } else {
  16843. weights[i][j] = 0;
  16844. }
  16845. } else {
  16846. if (dis <= threshold) {
  16847. weights[i][j] = Math.pow(dis, alpha);
  16848. } else {
  16849. weights[i][j] = 0;
  16850. }
  16851. }
  16852. }
  16853. }
  16854. if (rowTransform) {
  16855. for (var i = 0; i < features.length; i++) {
  16856. var rowSum = weights[i].reduce(function(sum2, currentVal) {
  16857. return sum2 + currentVal;
  16858. }, 0);
  16859. for (var j = 0; j < features.length; j++) {
  16860. weights[i][j] = weights[i][j] / rowSum;
  16861. }
  16862. }
  16863. }
  16864. return weights;
  16865. }
  16866. // node_modules/@turf/moran-index/dist/es/index.js
  16867. function es_default71(fc, options) {
  16868. var inputField = options.inputField;
  16869. var threshold = options.threshold || 1e5;
  16870. var p = options.p || 2;
  16871. var binary = options.binary || false;
  16872. var alpha = options.alpha || -1;
  16873. var standardization = options.standardization || true;
  16874. var weight = distanceWeight(fc, {
  16875. alpha,
  16876. binary,
  16877. p,
  16878. standardization,
  16879. threshold
  16880. });
  16881. var y2 = [];
  16882. featureEach(fc, function(feature2) {
  16883. var feaProperties = feature2.properties || {};
  16884. y2.push(feaProperties[inputField]);
  16885. });
  16886. var yMean = mean(y2);
  16887. var yVar = variance(y2);
  16888. var weightSum = 0;
  16889. var s0 = 0;
  16890. var s1 = 0;
  16891. var s2 = 0;
  16892. var n = weight.length;
  16893. for (var i = 0; i < n; i++) {
  16894. var subS2 = 0;
  16895. for (var j = 0; j < n; j++) {
  16896. weightSum += weight[i][j] * (y2[i] - yMean) * (y2[j] - yMean);
  16897. s0 += weight[i][j];
  16898. s1 += Math.pow(weight[i][j] + weight[j][i], 2);
  16899. subS2 += weight[i][j] + weight[j][i];
  16900. }
  16901. s2 += Math.pow(subS2, 2);
  16902. }
  16903. s1 = 0.5 * s1;
  16904. var moranIndex = weightSum / s0 / yVar;
  16905. var expectedMoranIndex = -1 / (n - 1);
  16906. var vNum = n * n * s1 - n * s2 + 3 * (s0 * s0);
  16907. var vDen = (n - 1) * (n + 1) * (s0 * s0);
  16908. var vNorm = vNum / vDen - expectedMoranIndex * expectedMoranIndex;
  16909. var stdNorm = Math.sqrt(vNorm);
  16910. var zNorm = (moranIndex - expectedMoranIndex) / stdNorm;
  16911. return {
  16912. expectedMoranIndex,
  16913. moranIndex,
  16914. stdNorm,
  16915. zNorm
  16916. };
  16917. }
  16918. function mean(y2) {
  16919. var sum2 = 0;
  16920. for (var _i = 0, y_1 = y2; _i < y_1.length; _i++) {
  16921. var item = y_1[_i];
  16922. sum2 += item;
  16923. }
  16924. return sum2 / y2.length;
  16925. }
  16926. function variance(y2) {
  16927. var yMean = mean(y2);
  16928. var sum2 = 0;
  16929. for (var _i = 0, y_2 = y2; _i < y_2.length; _i++) {
  16930. var item = y_2[_i];
  16931. sum2 += Math.pow(item - yMean, 2);
  16932. }
  16933. return sum2 / y2.length;
  16934. }
  16935. // node_modules/@turf/projection/dist/es/index.js
  16936. var es_exports4 = {};
  16937. __export(es_exports4, {
  16938. toMercator: () => toMercator,
  16939. toWgs84: () => toWgs84
  16940. });
  16941. function toMercator(geojson, options) {
  16942. if (options === void 0) {
  16943. options = {};
  16944. }
  16945. return convert(geojson, "mercator", options);
  16946. }
  16947. function toWgs84(geojson, options) {
  16948. if (options === void 0) {
  16949. options = {};
  16950. }
  16951. return convert(geojson, "wgs84", options);
  16952. }
  16953. function convert(geojson, projection2, options) {
  16954. if (options === void 0) {
  16955. options = {};
  16956. }
  16957. options = options || {};
  16958. var mutate = options.mutate;
  16959. if (!geojson)
  16960. throw new Error("geojson is required");
  16961. if (Array.isArray(geojson) && isNumber(geojson[0]))
  16962. geojson = projection2 === "mercator" ? convertToMercator(geojson) : convertToWgs84(geojson);
  16963. else {
  16964. if (mutate !== true)
  16965. geojson = es_default5(geojson);
  16966. coordEach(geojson, function(coord) {
  16967. var newCoord = projection2 === "mercator" ? convertToMercator(coord) : convertToWgs84(coord);
  16968. coord[0] = newCoord[0];
  16969. coord[1] = newCoord[1];
  16970. });
  16971. }
  16972. return geojson;
  16973. }
  16974. function convertToMercator(lonLat) {
  16975. var D2R2 = Math.PI / 180, A = 6378137, MAXEXTENT = 20037508342789244e-9;
  16976. var adjusted = Math.abs(lonLat[0]) <= 180 ? lonLat[0] : lonLat[0] - sign(lonLat[0]) * 360;
  16977. var xy = [
  16978. A * adjusted * D2R2,
  16979. A * Math.log(Math.tan(Math.PI * 0.25 + 0.5 * lonLat[1] * D2R2))
  16980. ];
  16981. if (xy[0] > MAXEXTENT)
  16982. xy[0] = MAXEXTENT;
  16983. if (xy[0] < -MAXEXTENT)
  16984. xy[0] = -MAXEXTENT;
  16985. if (xy[1] > MAXEXTENT)
  16986. xy[1] = MAXEXTENT;
  16987. if (xy[1] < -MAXEXTENT)
  16988. xy[1] = -MAXEXTENT;
  16989. return xy;
  16990. }
  16991. function convertToWgs84(xy) {
  16992. var R2D2 = 180 / Math.PI;
  16993. var A = 6378137;
  16994. return [
  16995. xy[0] * R2D2 / A,
  16996. (Math.PI * 0.5 - 2 * Math.atan(Math.exp(-xy[1] / A))) * R2D2
  16997. ];
  16998. }
  16999. function sign(x2) {
  17000. return x2 < 0 ? -1 : x2 > 0 ? 1 : 0;
  17001. }
  17002. // node_modules/@turf/random/dist/es/index.js
  17003. var es_exports5 = {};
  17004. __export(es_exports5, {
  17005. randomLineString: () => randomLineString,
  17006. randomPoint: () => randomPoint,
  17007. randomPolygon: () => randomPolygon,
  17008. randomPosition: () => randomPosition
  17009. });
  17010. var __spreadArrays = function() {
  17011. for (var s = 0, i = 0, il = arguments.length; i < il; i++)
  17012. s += arguments[i].length;
  17013. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  17014. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  17015. r[k] = a[j];
  17016. return r;
  17017. };
  17018. function randomPosition(bbox3) {
  17019. if (Array.isArray(bbox3)) {
  17020. return coordInBBox(bbox3);
  17021. }
  17022. if (bbox3 && bbox3.bbox) {
  17023. return coordInBBox(bbox3.bbox);
  17024. }
  17025. return [lon(), lat()];
  17026. }
  17027. function randomPoint(count2, options) {
  17028. if (options === void 0) {
  17029. options = {};
  17030. }
  17031. if (count2 === void 0 || count2 === null) {
  17032. count2 = 1;
  17033. }
  17034. var features = [];
  17035. for (var i = 0; i < count2; i++) {
  17036. features.push(point(randomPosition(options.bbox)));
  17037. }
  17038. return featureCollection(features);
  17039. }
  17040. function randomPolygon(count2, options) {
  17041. if (options === void 0) {
  17042. options = {};
  17043. }
  17044. if (count2 === void 0 || count2 === null) {
  17045. count2 = 1;
  17046. }
  17047. if (!isNumber(options.num_vertices) || options.num_vertices === void 0) {
  17048. options.num_vertices = 10;
  17049. }
  17050. if (!isNumber(options.max_radial_length) || options.max_radial_length === void 0) {
  17051. options.max_radial_length = 10;
  17052. }
  17053. var features = [];
  17054. var _loop_1 = function(i2) {
  17055. var vertices = [];
  17056. var circleOffsets = __spreadArrays(Array(options.num_vertices + 1)).map(Math.random);
  17057. circleOffsets.forEach(function(cur, index2, arr) {
  17058. arr[index2] = index2 > 0 ? cur + arr[index2 - 1] : cur;
  17059. });
  17060. circleOffsets.forEach(function(cur) {
  17061. cur = cur * 2 * Math.PI / circleOffsets[circleOffsets.length - 1];
  17062. var radialScaler = Math.random();
  17063. vertices.push([
  17064. radialScaler * (options.max_radial_length || 10) * Math.sin(cur),
  17065. radialScaler * (options.max_radial_length || 10) * Math.cos(cur)
  17066. ]);
  17067. });
  17068. vertices[vertices.length - 1] = vertices[0];
  17069. vertices = vertices.map(vertexToCoordinate(randomPosition(options.bbox)));
  17070. features.push(polygon([vertices]));
  17071. };
  17072. for (var i = 0; i < count2; i++) {
  17073. _loop_1(i);
  17074. }
  17075. return featureCollection(features);
  17076. }
  17077. function randomLineString(count2, options) {
  17078. if (options === void 0) {
  17079. options = {};
  17080. }
  17081. options = options || {};
  17082. if (!isObject(options)) {
  17083. throw new Error("options is invalid");
  17084. }
  17085. var bbox3 = options.bbox;
  17086. var num_vertices = options.num_vertices;
  17087. var max_length = options.max_length;
  17088. var max_rotation = options.max_rotation;
  17089. if (count2 === void 0 || count2 === null) {
  17090. count2 = 1;
  17091. }
  17092. if (!isNumber(num_vertices) || num_vertices === void 0 || num_vertices < 2) {
  17093. num_vertices = 10;
  17094. }
  17095. if (!isNumber(max_length) || max_length === void 0) {
  17096. max_length = 1e-4;
  17097. }
  17098. if (!isNumber(max_rotation) || max_rotation === void 0) {
  17099. max_rotation = Math.PI / 8;
  17100. }
  17101. var features = [];
  17102. for (var i = 0; i < count2; i++) {
  17103. var startingPoint = randomPosition(bbox3);
  17104. var vertices = [startingPoint];
  17105. for (var j = 0; j < num_vertices - 1; j++) {
  17106. var priorAngle = j === 0 ? Math.random() * 2 * Math.PI : Math.tan((vertices[j][1] - vertices[j - 1][1]) / (vertices[j][0] - vertices[j - 1][0]));
  17107. var angle4 = priorAngle + (Math.random() - 0.5) * max_rotation * 2;
  17108. var distance11 = Math.random() * max_length;
  17109. vertices.push([
  17110. vertices[j][0] + distance11 * Math.cos(angle4),
  17111. vertices[j][1] + distance11 * Math.sin(angle4)
  17112. ]);
  17113. }
  17114. features.push(lineString(vertices));
  17115. }
  17116. return featureCollection(features);
  17117. }
  17118. function vertexToCoordinate(hub) {
  17119. return function(cur) {
  17120. return [cur[0] + hub[0], cur[1] + hub[1]];
  17121. };
  17122. }
  17123. function rnd() {
  17124. return Math.random() - 0.5;
  17125. }
  17126. function lon() {
  17127. return rnd() * 360;
  17128. }
  17129. function lat() {
  17130. return rnd() * 180;
  17131. }
  17132. function coordInBBox(bbox3) {
  17133. return [
  17134. Math.random() * (bbox3[2] - bbox3[0]) + bbox3[0],
  17135. Math.random() * (bbox3[3] - bbox3[1]) + bbox3[1]
  17136. ];
  17137. }
  17138. // node_modules/@turf/clusters/dist/es/index.js
  17139. var es_exports6 = {};
  17140. __export(es_exports6, {
  17141. applyFilter: () => applyFilter,
  17142. clusterEach: () => clusterEach,
  17143. clusterReduce: () => clusterReduce,
  17144. createBins: () => createBins,
  17145. filterProperties: () => filterProperties,
  17146. getCluster: () => getCluster,
  17147. propertiesContainsFilter: () => propertiesContainsFilter
  17148. });
  17149. function getCluster(geojson, filter17) {
  17150. if (!geojson)
  17151. throw new Error("geojson is required");
  17152. if (geojson.type !== "FeatureCollection")
  17153. throw new Error("geojson must be a FeatureCollection");
  17154. if (filter17 === void 0 || filter17 === null)
  17155. throw new Error("filter is required");
  17156. var features = [];
  17157. featureEach(geojson, function(feature2) {
  17158. if (applyFilter(feature2.properties, filter17))
  17159. features.push(feature2);
  17160. });
  17161. return featureCollection(features);
  17162. }
  17163. function clusterEach(geojson, property, callback) {
  17164. if (!geojson)
  17165. throw new Error("geojson is required");
  17166. if (geojson.type !== "FeatureCollection")
  17167. throw new Error("geojson must be a FeatureCollection");
  17168. if (property === void 0 || property === null)
  17169. throw new Error("property is required");
  17170. var bins = createBins(geojson, property);
  17171. var values3 = Object.keys(bins);
  17172. for (var index2 = 0; index2 < values3.length; index2++) {
  17173. var value = values3[index2];
  17174. var bin = bins[value];
  17175. var features = [];
  17176. for (var i = 0; i < bin.length; i++) {
  17177. features.push(geojson.features[bin[i]]);
  17178. }
  17179. callback(featureCollection(features), value, index2);
  17180. }
  17181. }
  17182. function clusterReduce(geojson, property, callback, initialValue) {
  17183. var previousValue = initialValue;
  17184. clusterEach(geojson, property, function(cluster, clusterValue, currentIndex) {
  17185. if (currentIndex === 0 && initialValue === void 0)
  17186. previousValue = cluster;
  17187. else
  17188. previousValue = callback(previousValue, cluster, clusterValue, currentIndex);
  17189. });
  17190. return previousValue;
  17191. }
  17192. function createBins(geojson, property) {
  17193. var bins = {};
  17194. featureEach(geojson, function(feature2, i) {
  17195. var properties = feature2.properties || {};
  17196. if (Object.prototype.hasOwnProperty.call(properties, String(property))) {
  17197. var value = properties[property];
  17198. if (Object.prototype.hasOwnProperty.call(bins, value))
  17199. bins[value].push(i);
  17200. else
  17201. bins[value] = [i];
  17202. }
  17203. });
  17204. return bins;
  17205. }
  17206. function applyFilter(properties, filter17) {
  17207. if (properties === void 0)
  17208. return false;
  17209. var filterType = typeof filter17;
  17210. if (filterType === "number" || filterType === "string")
  17211. return Object.prototype.hasOwnProperty.call(properties, filter17);
  17212. else if (Array.isArray(filter17)) {
  17213. for (var i = 0; i < filter17.length; i++) {
  17214. if (!applyFilter(properties, filter17[i]))
  17215. return false;
  17216. }
  17217. return true;
  17218. } else {
  17219. return propertiesContainsFilter(properties, filter17);
  17220. }
  17221. }
  17222. function propertiesContainsFilter(properties, filter17) {
  17223. var keys = Object.keys(filter17);
  17224. for (var i = 0; i < keys.length; i++) {
  17225. var key = keys[i];
  17226. if (properties[key] !== filter17[key])
  17227. return false;
  17228. }
  17229. return true;
  17230. }
  17231. function filterProperties(properties, keys) {
  17232. if (!keys)
  17233. return {};
  17234. if (!keys.length)
  17235. return {};
  17236. var newProperties = {};
  17237. for (var i = 0; i < keys.length; i++) {
  17238. var key = keys[i];
  17239. if (Object.prototype.hasOwnProperty.call(properties, key))
  17240. newProperties[key] = properties[key];
  17241. }
  17242. return newProperties;
  17243. }
  17244. // node_modules/splaytree/dist/splay.esm.js
  17245. function __generator(thisArg, body) {
  17246. var _ = { label: 0, sent: function() {
  17247. if (t[0] & 1)
  17248. throw t[1];
  17249. return t[1];
  17250. }, trys: [], ops: [] }, f, y2, t, g;
  17251. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
  17252. return this;
  17253. }), g;
  17254. function verb(n) {
  17255. return function(v) {
  17256. return step([n, v]);
  17257. };
  17258. }
  17259. function step(op) {
  17260. if (f)
  17261. throw new TypeError("Generator is already executing.");
  17262. while (_)
  17263. try {
  17264. if (f = 1, y2 && (t = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t = y2["return"]) && t.call(y2), 0) : y2.next) && !(t = t.call(y2, op[1])).done)
  17265. return t;
  17266. if (y2 = 0, t)
  17267. op = [op[0] & 2, t.value];
  17268. switch (op[0]) {
  17269. case 0:
  17270. case 1:
  17271. t = op;
  17272. break;
  17273. case 4:
  17274. _.label++;
  17275. return { value: op[1], done: false };
  17276. case 5:
  17277. _.label++;
  17278. y2 = op[1];
  17279. op = [0];
  17280. continue;
  17281. case 7:
  17282. op = _.ops.pop();
  17283. _.trys.pop();
  17284. continue;
  17285. default:
  17286. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  17287. _ = 0;
  17288. continue;
  17289. }
  17290. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  17291. _.label = op[1];
  17292. break;
  17293. }
  17294. if (op[0] === 6 && _.label < t[1]) {
  17295. _.label = t[1];
  17296. t = op;
  17297. break;
  17298. }
  17299. if (t && _.label < t[2]) {
  17300. _.label = t[2];
  17301. _.ops.push(op);
  17302. break;
  17303. }
  17304. if (t[2])
  17305. _.ops.pop();
  17306. _.trys.pop();
  17307. continue;
  17308. }
  17309. op = body.call(thisArg, _);
  17310. } catch (e) {
  17311. op = [6, e];
  17312. y2 = 0;
  17313. } finally {
  17314. f = t = 0;
  17315. }
  17316. if (op[0] & 5)
  17317. throw op[1];
  17318. return { value: op[0] ? op[1] : void 0, done: true };
  17319. }
  17320. }
  17321. var Node4 = function() {
  17322. function Node6(key, data) {
  17323. this.next = null;
  17324. this.key = key;
  17325. this.data = data;
  17326. this.left = null;
  17327. this.right = null;
  17328. }
  17329. return Node6;
  17330. }();
  17331. function DEFAULT_COMPARE(a, b) {
  17332. return a > b ? 1 : a < b ? -1 : 0;
  17333. }
  17334. function splay(i, t, comparator) {
  17335. var N = new Node4(null, null);
  17336. var l = N;
  17337. var r = N;
  17338. while (true) {
  17339. var cmp3 = comparator(i, t.key);
  17340. if (cmp3 < 0) {
  17341. if (t.left === null)
  17342. break;
  17343. if (comparator(i, t.left.key) < 0) {
  17344. var y2 = t.left;
  17345. t.left = y2.right;
  17346. y2.right = t;
  17347. t = y2;
  17348. if (t.left === null)
  17349. break;
  17350. }
  17351. r.left = t;
  17352. r = t;
  17353. t = t.left;
  17354. } else if (cmp3 > 0) {
  17355. if (t.right === null)
  17356. break;
  17357. if (comparator(i, t.right.key) > 0) {
  17358. var y2 = t.right;
  17359. t.right = y2.left;
  17360. y2.left = t;
  17361. t = y2;
  17362. if (t.right === null)
  17363. break;
  17364. }
  17365. l.right = t;
  17366. l = t;
  17367. t = t.right;
  17368. } else
  17369. break;
  17370. }
  17371. l.right = t.left;
  17372. r.left = t.right;
  17373. t.left = N.right;
  17374. t.right = N.left;
  17375. return t;
  17376. }
  17377. function insert(i, data, t, comparator) {
  17378. var node = new Node4(i, data);
  17379. if (t === null) {
  17380. node.left = node.right = null;
  17381. return node;
  17382. }
  17383. t = splay(i, t, comparator);
  17384. var cmp3 = comparator(i, t.key);
  17385. if (cmp3 < 0) {
  17386. node.left = t.left;
  17387. node.right = t;
  17388. t.left = null;
  17389. } else if (cmp3 >= 0) {
  17390. node.right = t.right;
  17391. node.left = t;
  17392. t.right = null;
  17393. }
  17394. return node;
  17395. }
  17396. function split(key, v, comparator) {
  17397. var left = null;
  17398. var right = null;
  17399. if (v) {
  17400. v = splay(key, v, comparator);
  17401. var cmp3 = comparator(v.key, key);
  17402. if (cmp3 === 0) {
  17403. left = v.left;
  17404. right = v.right;
  17405. } else if (cmp3 < 0) {
  17406. right = v.right;
  17407. v.right = null;
  17408. left = v;
  17409. } else {
  17410. left = v.left;
  17411. v.left = null;
  17412. right = v;
  17413. }
  17414. }
  17415. return { left, right };
  17416. }
  17417. function merge(left, right, comparator) {
  17418. if (right === null)
  17419. return left;
  17420. if (left === null)
  17421. return right;
  17422. right = splay(left.key, right, comparator);
  17423. right.left = left;
  17424. return right;
  17425. }
  17426. function printRow(root, prefix, isTail, out, printNode2) {
  17427. if (root) {
  17428. out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode2(root) + "\n");
  17429. var indent = prefix + (isTail ? " " : "\u2502 ");
  17430. if (root.left)
  17431. printRow(root.left, indent, false, out, printNode2);
  17432. if (root.right)
  17433. printRow(root.right, indent, true, out, printNode2);
  17434. }
  17435. }
  17436. var Tree = function() {
  17437. function Tree2(comparator) {
  17438. if (comparator === void 0) {
  17439. comparator = DEFAULT_COMPARE;
  17440. }
  17441. this._root = null;
  17442. this._size = 0;
  17443. this._comparator = comparator;
  17444. }
  17445. Tree2.prototype.insert = function(key, data) {
  17446. this._size++;
  17447. return this._root = insert(key, data, this._root, this._comparator);
  17448. };
  17449. Tree2.prototype.add = function(key, data) {
  17450. var node = new Node4(key, data);
  17451. if (this._root === null) {
  17452. node.left = node.right = null;
  17453. this._size++;
  17454. this._root = node;
  17455. }
  17456. var comparator = this._comparator;
  17457. var t = splay(key, this._root, comparator);
  17458. var cmp3 = comparator(key, t.key);
  17459. if (cmp3 === 0)
  17460. this._root = t;
  17461. else {
  17462. if (cmp3 < 0) {
  17463. node.left = t.left;
  17464. node.right = t;
  17465. t.left = null;
  17466. } else if (cmp3 > 0) {
  17467. node.right = t.right;
  17468. node.left = t;
  17469. t.right = null;
  17470. }
  17471. this._size++;
  17472. this._root = node;
  17473. }
  17474. return this._root;
  17475. };
  17476. Tree2.prototype.remove = function(key) {
  17477. this._root = this._remove(key, this._root, this._comparator);
  17478. };
  17479. Tree2.prototype._remove = function(i, t, comparator) {
  17480. var x2;
  17481. if (t === null)
  17482. return null;
  17483. t = splay(i, t, comparator);
  17484. var cmp3 = comparator(i, t.key);
  17485. if (cmp3 === 0) {
  17486. if (t.left === null) {
  17487. x2 = t.right;
  17488. } else {
  17489. x2 = splay(i, t.left, comparator);
  17490. x2.right = t.right;
  17491. }
  17492. this._size--;
  17493. return x2;
  17494. }
  17495. return t;
  17496. };
  17497. Tree2.prototype.pop = function() {
  17498. var node = this._root;
  17499. if (node) {
  17500. while (node.left)
  17501. node = node.left;
  17502. this._root = splay(node.key, this._root, this._comparator);
  17503. this._root = this._remove(node.key, this._root, this._comparator);
  17504. return { key: node.key, data: node.data };
  17505. }
  17506. return null;
  17507. };
  17508. Tree2.prototype.findStatic = function(key) {
  17509. var current = this._root;
  17510. var compare10 = this._comparator;
  17511. while (current) {
  17512. var cmp3 = compare10(key, current.key);
  17513. if (cmp3 === 0)
  17514. return current;
  17515. else if (cmp3 < 0)
  17516. current = current.left;
  17517. else
  17518. current = current.right;
  17519. }
  17520. return null;
  17521. };
  17522. Tree2.prototype.find = function(key) {
  17523. if (this._root) {
  17524. this._root = splay(key, this._root, this._comparator);
  17525. if (this._comparator(key, this._root.key) !== 0)
  17526. return null;
  17527. }
  17528. return this._root;
  17529. };
  17530. Tree2.prototype.contains = function(key) {
  17531. var current = this._root;
  17532. var compare10 = this._comparator;
  17533. while (current) {
  17534. var cmp3 = compare10(key, current.key);
  17535. if (cmp3 === 0)
  17536. return true;
  17537. else if (cmp3 < 0)
  17538. current = current.left;
  17539. else
  17540. current = current.right;
  17541. }
  17542. return false;
  17543. };
  17544. Tree2.prototype.forEach = function(visitor, ctx) {
  17545. var current = this._root;
  17546. var Q = [];
  17547. var done = false;
  17548. while (!done) {
  17549. if (current !== null) {
  17550. Q.push(current);
  17551. current = current.left;
  17552. } else {
  17553. if (Q.length !== 0) {
  17554. current = Q.pop();
  17555. visitor.call(ctx, current);
  17556. current = current.right;
  17557. } else
  17558. done = true;
  17559. }
  17560. }
  17561. return this;
  17562. };
  17563. Tree2.prototype.range = function(low, high, fn, ctx) {
  17564. var Q = [];
  17565. var compare10 = this._comparator;
  17566. var node = this._root;
  17567. var cmp3;
  17568. while (Q.length !== 0 || node) {
  17569. if (node) {
  17570. Q.push(node);
  17571. node = node.left;
  17572. } else {
  17573. node = Q.pop();
  17574. cmp3 = compare10(node.key, high);
  17575. if (cmp3 > 0) {
  17576. break;
  17577. } else if (compare10(node.key, low) >= 0) {
  17578. if (fn.call(ctx, node))
  17579. return this;
  17580. }
  17581. node = node.right;
  17582. }
  17583. }
  17584. return this;
  17585. };
  17586. Tree2.prototype.keys = function() {
  17587. var keys = [];
  17588. this.forEach(function(_a) {
  17589. var key = _a.key;
  17590. return keys.push(key);
  17591. });
  17592. return keys;
  17593. };
  17594. Tree2.prototype.values = function() {
  17595. var values3 = [];
  17596. this.forEach(function(_a) {
  17597. var data = _a.data;
  17598. return values3.push(data);
  17599. });
  17600. return values3;
  17601. };
  17602. Tree2.prototype.min = function() {
  17603. if (this._root)
  17604. return this.minNode(this._root).key;
  17605. return null;
  17606. };
  17607. Tree2.prototype.max = function() {
  17608. if (this._root)
  17609. return this.maxNode(this._root).key;
  17610. return null;
  17611. };
  17612. Tree2.prototype.minNode = function(t) {
  17613. if (t === void 0) {
  17614. t = this._root;
  17615. }
  17616. if (t)
  17617. while (t.left)
  17618. t = t.left;
  17619. return t;
  17620. };
  17621. Tree2.prototype.maxNode = function(t) {
  17622. if (t === void 0) {
  17623. t = this._root;
  17624. }
  17625. if (t)
  17626. while (t.right)
  17627. t = t.right;
  17628. return t;
  17629. };
  17630. Tree2.prototype.at = function(index2) {
  17631. var current = this._root;
  17632. var done = false;
  17633. var i = 0;
  17634. var Q = [];
  17635. while (!done) {
  17636. if (current) {
  17637. Q.push(current);
  17638. current = current.left;
  17639. } else {
  17640. if (Q.length > 0) {
  17641. current = Q.pop();
  17642. if (i === index2)
  17643. return current;
  17644. i++;
  17645. current = current.right;
  17646. } else
  17647. done = true;
  17648. }
  17649. }
  17650. return null;
  17651. };
  17652. Tree2.prototype.next = function(d) {
  17653. var root = this._root;
  17654. var successor = null;
  17655. if (d.right) {
  17656. successor = d.right;
  17657. while (successor.left)
  17658. successor = successor.left;
  17659. return successor;
  17660. }
  17661. var comparator = this._comparator;
  17662. while (root) {
  17663. var cmp3 = comparator(d.key, root.key);
  17664. if (cmp3 === 0)
  17665. break;
  17666. else if (cmp3 < 0) {
  17667. successor = root;
  17668. root = root.left;
  17669. } else
  17670. root = root.right;
  17671. }
  17672. return successor;
  17673. };
  17674. Tree2.prototype.prev = function(d) {
  17675. var root = this._root;
  17676. var predecessor = null;
  17677. if (d.left !== null) {
  17678. predecessor = d.left;
  17679. while (predecessor.right)
  17680. predecessor = predecessor.right;
  17681. return predecessor;
  17682. }
  17683. var comparator = this._comparator;
  17684. while (root) {
  17685. var cmp3 = comparator(d.key, root.key);
  17686. if (cmp3 === 0)
  17687. break;
  17688. else if (cmp3 < 0)
  17689. root = root.left;
  17690. else {
  17691. predecessor = root;
  17692. root = root.right;
  17693. }
  17694. }
  17695. return predecessor;
  17696. };
  17697. Tree2.prototype.clear = function() {
  17698. this._root = null;
  17699. this._size = 0;
  17700. return this;
  17701. };
  17702. Tree2.prototype.toList = function() {
  17703. return toList(this._root);
  17704. };
  17705. Tree2.prototype.load = function(keys, values3, presort) {
  17706. if (values3 === void 0) {
  17707. values3 = [];
  17708. }
  17709. if (presort === void 0) {
  17710. presort = false;
  17711. }
  17712. var size11 = keys.length;
  17713. var comparator = this._comparator;
  17714. if (presort)
  17715. sort(keys, values3, 0, size11 - 1, comparator);
  17716. if (this._root === null) {
  17717. this._root = loadRecursive(keys, values3, 0, size11);
  17718. this._size = size11;
  17719. } else {
  17720. var mergedList = mergeLists(this.toList(), createList(keys, values3), comparator);
  17721. size11 = this._size + size11;
  17722. this._root = sortedListToBST({ head: mergedList }, 0, size11);
  17723. }
  17724. return this;
  17725. };
  17726. Tree2.prototype.isEmpty = function() {
  17727. return this._root === null;
  17728. };
  17729. Object.defineProperty(Tree2.prototype, "size", {
  17730. get: function() {
  17731. return this._size;
  17732. },
  17733. enumerable: true,
  17734. configurable: true
  17735. });
  17736. Object.defineProperty(Tree2.prototype, "root", {
  17737. get: function() {
  17738. return this._root;
  17739. },
  17740. enumerable: true,
  17741. configurable: true
  17742. });
  17743. Tree2.prototype.toString = function(printNode2) {
  17744. if (printNode2 === void 0) {
  17745. printNode2 = function(n) {
  17746. return String(n.key);
  17747. };
  17748. }
  17749. var out = [];
  17750. printRow(this._root, "", true, function(v) {
  17751. return out.push(v);
  17752. }, printNode2);
  17753. return out.join("");
  17754. };
  17755. Tree2.prototype.update = function(key, newKey, newData) {
  17756. var comparator = this._comparator;
  17757. var _a = split(key, this._root, comparator), left = _a.left, right = _a.right;
  17758. if (comparator(key, newKey) < 0) {
  17759. right = insert(newKey, newData, right, comparator);
  17760. } else {
  17761. left = insert(newKey, newData, left, comparator);
  17762. }
  17763. this._root = merge(left, right, comparator);
  17764. };
  17765. Tree2.prototype.split = function(key) {
  17766. return split(key, this._root, this._comparator);
  17767. };
  17768. Tree2.prototype[Symbol.iterator] = function() {
  17769. var n;
  17770. return __generator(this, function(_a) {
  17771. switch (_a.label) {
  17772. case 0:
  17773. n = this.minNode();
  17774. _a.label = 1;
  17775. case 1:
  17776. if (!n)
  17777. return [3, 3];
  17778. return [4, n];
  17779. case 2:
  17780. _a.sent();
  17781. n = this.next(n);
  17782. return [3, 1];
  17783. case 3:
  17784. return [2];
  17785. }
  17786. });
  17787. };
  17788. return Tree2;
  17789. }();
  17790. function loadRecursive(keys, values3, start, end) {
  17791. var size11 = end - start;
  17792. if (size11 > 0) {
  17793. var middle = start + Math.floor(size11 / 2);
  17794. var key = keys[middle];
  17795. var data = values3[middle];
  17796. var node = new Node4(key, data);
  17797. node.left = loadRecursive(keys, values3, start, middle);
  17798. node.right = loadRecursive(keys, values3, middle + 1, end);
  17799. return node;
  17800. }
  17801. return null;
  17802. }
  17803. function createList(keys, values3) {
  17804. var head = new Node4(null, null);
  17805. var p = head;
  17806. for (var i = 0; i < keys.length; i++) {
  17807. p = p.next = new Node4(keys[i], values3[i]);
  17808. }
  17809. p.next = null;
  17810. return head.next;
  17811. }
  17812. function toList(root) {
  17813. var current = root;
  17814. var Q = [];
  17815. var done = false;
  17816. var head = new Node4(null, null);
  17817. var p = head;
  17818. while (!done) {
  17819. if (current) {
  17820. Q.push(current);
  17821. current = current.left;
  17822. } else {
  17823. if (Q.length > 0) {
  17824. current = p = p.next = Q.pop();
  17825. current = current.right;
  17826. } else
  17827. done = true;
  17828. }
  17829. }
  17830. p.next = null;
  17831. return head.next;
  17832. }
  17833. function sortedListToBST(list, start, end) {
  17834. var size11 = end - start;
  17835. if (size11 > 0) {
  17836. var middle = start + Math.floor(size11 / 2);
  17837. var left = sortedListToBST(list, start, middle);
  17838. var root = list.head;
  17839. root.left = left;
  17840. list.head = list.head.next;
  17841. root.right = sortedListToBST(list, middle + 1, end);
  17842. return root;
  17843. }
  17844. return null;
  17845. }
  17846. function mergeLists(l1, l2, compare10) {
  17847. var head = new Node4(null, null);
  17848. var p = head;
  17849. var p1 = l1;
  17850. var p2 = l2;
  17851. while (p1 !== null && p2 !== null) {
  17852. if (compare10(p1.key, p2.key) < 0) {
  17853. p.next = p1;
  17854. p1 = p1.next;
  17855. } else {
  17856. p.next = p2;
  17857. p2 = p2.next;
  17858. }
  17859. p = p.next;
  17860. }
  17861. if (p1 !== null) {
  17862. p.next = p1;
  17863. } else if (p2 !== null) {
  17864. p.next = p2;
  17865. }
  17866. return head.next;
  17867. }
  17868. function sort(keys, values3, left, right, compare10) {
  17869. if (left >= right)
  17870. return;
  17871. var pivot = keys[left + right >> 1];
  17872. var i = left - 1;
  17873. var j = right + 1;
  17874. while (true) {
  17875. do
  17876. i++;
  17877. while (compare10(keys[i], pivot) < 0);
  17878. do
  17879. j--;
  17880. while (compare10(keys[j], pivot) > 0);
  17881. if (i >= j)
  17882. break;
  17883. var tmp = keys[i];
  17884. keys[i] = keys[j];
  17885. keys[j] = tmp;
  17886. tmp = values3[i];
  17887. values3[i] = values3[j];
  17888. values3[j] = tmp;
  17889. }
  17890. sort(keys, values3, left, j, compare10);
  17891. sort(keys, values3, j + 1, right, compare10);
  17892. }
  17893. var splay_esm_default = Tree;
  17894. // node_modules/polygon-clipping/dist/polygon-clipping.esm.js
  17895. function _classCallCheck(instance2, Constructor) {
  17896. if (!(instance2 instanceof Constructor)) {
  17897. throw new TypeError("Cannot call a class as a function");
  17898. }
  17899. }
  17900. function _defineProperties(target, props) {
  17901. for (var i = 0; i < props.length; i++) {
  17902. var descriptor = props[i];
  17903. descriptor.enumerable = descriptor.enumerable || false;
  17904. descriptor.configurable = true;
  17905. if ("value" in descriptor)
  17906. descriptor.writable = true;
  17907. Object.defineProperty(target, descriptor.key, descriptor);
  17908. }
  17909. }
  17910. function _createClass(Constructor, protoProps, staticProps) {
  17911. if (protoProps)
  17912. _defineProperties(Constructor.prototype, protoProps);
  17913. if (staticProps)
  17914. _defineProperties(Constructor, staticProps);
  17915. return Constructor;
  17916. }
  17917. var isInBbox = function isInBbox2(bbox3, point4) {
  17918. return bbox3.ll.x <= point4.x && point4.x <= bbox3.ur.x && bbox3.ll.y <= point4.y && point4.y <= bbox3.ur.y;
  17919. };
  17920. var getBboxOverlap = function getBboxOverlap2(b1, b2) {
  17921. if (b2.ur.x < b1.ll.x || b1.ur.x < b2.ll.x || b2.ur.y < b1.ll.y || b1.ur.y < b2.ll.y)
  17922. return null;
  17923. var lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
  17924. var upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;
  17925. var lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
  17926. var upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;
  17927. return {
  17928. ll: {
  17929. x: lowerX,
  17930. y: lowerY
  17931. },
  17932. ur: {
  17933. x: upperX,
  17934. y: upperY
  17935. }
  17936. };
  17937. };
  17938. var epsilon3 = Number.EPSILON;
  17939. if (epsilon3 === void 0)
  17940. epsilon3 = Math.pow(2, -52);
  17941. var EPSILON_SQ = epsilon3 * epsilon3;
  17942. var cmp = function cmp2(a, b) {
  17943. if (-epsilon3 < a && a < epsilon3) {
  17944. if (-epsilon3 < b && b < epsilon3) {
  17945. return 0;
  17946. }
  17947. }
  17948. var ab2 = a - b;
  17949. if (ab2 * ab2 < EPSILON_SQ * a * b) {
  17950. return 0;
  17951. }
  17952. return a < b ? -1 : 1;
  17953. };
  17954. var PtRounder = function() {
  17955. function PtRounder2() {
  17956. _classCallCheck(this, PtRounder2);
  17957. this.reset();
  17958. }
  17959. _createClass(PtRounder2, [{
  17960. key: "reset",
  17961. value: function reset() {
  17962. this.xRounder = new CoordRounder();
  17963. this.yRounder = new CoordRounder();
  17964. }
  17965. }, {
  17966. key: "round",
  17967. value: function round2(x2, y2) {
  17968. return {
  17969. x: this.xRounder.round(x2),
  17970. y: this.yRounder.round(y2)
  17971. };
  17972. }
  17973. }]);
  17974. return PtRounder2;
  17975. }();
  17976. var CoordRounder = function() {
  17977. function CoordRounder2() {
  17978. _classCallCheck(this, CoordRounder2);
  17979. this.tree = new splay_esm_default();
  17980. this.round(0);
  17981. }
  17982. _createClass(CoordRounder2, [{
  17983. key: "round",
  17984. value: function round2(coord) {
  17985. var node = this.tree.add(coord);
  17986. var prevNode = this.tree.prev(node);
  17987. if (prevNode !== null && cmp(node.key, prevNode.key) === 0) {
  17988. this.tree.remove(coord);
  17989. return prevNode.key;
  17990. }
  17991. var nextNode = this.tree.next(node);
  17992. if (nextNode !== null && cmp(node.key, nextNode.key) === 0) {
  17993. this.tree.remove(coord);
  17994. return nextNode.key;
  17995. }
  17996. return coord;
  17997. }
  17998. }]);
  17999. return CoordRounder2;
  18000. }();
  18001. var rounder = new PtRounder();
  18002. var crossProduct2 = function crossProduct3(a, b) {
  18003. return a.x * b.y - a.y * b.x;
  18004. };
  18005. var dotProduct = function dotProduct2(a, b) {
  18006. return a.x * b.x + a.y * b.y;
  18007. };
  18008. var compareVectorAngles = function compareVectorAngles2(basePt, endPt1, endPt2) {
  18009. var v1 = {
  18010. x: endPt1.x - basePt.x,
  18011. y: endPt1.y - basePt.y
  18012. };
  18013. var v2 = {
  18014. x: endPt2.x - basePt.x,
  18015. y: endPt2.y - basePt.y
  18016. };
  18017. var kross = crossProduct2(v1, v2);
  18018. return cmp(kross, 0);
  18019. };
  18020. var length2 = function length3(v) {
  18021. return Math.sqrt(dotProduct(v, v));
  18022. };
  18023. var sineOfAngle = function sineOfAngle2(pShared, pBase, pAngle) {
  18024. var vBase = {
  18025. x: pBase.x - pShared.x,
  18026. y: pBase.y - pShared.y
  18027. };
  18028. var vAngle = {
  18029. x: pAngle.x - pShared.x,
  18030. y: pAngle.y - pShared.y
  18031. };
  18032. return crossProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
  18033. };
  18034. var cosineOfAngle = function cosineOfAngle2(pShared, pBase, pAngle) {
  18035. var vBase = {
  18036. x: pBase.x - pShared.x,
  18037. y: pBase.y - pShared.y
  18038. };
  18039. var vAngle = {
  18040. x: pAngle.x - pShared.x,
  18041. y: pAngle.y - pShared.y
  18042. };
  18043. return dotProduct(vAngle, vBase) / length2(vAngle) / length2(vBase);
  18044. };
  18045. var horizontalIntersection = function horizontalIntersection2(pt, v, y2) {
  18046. if (v.y === 0)
  18047. return null;
  18048. return {
  18049. x: pt.x + v.x / v.y * (y2 - pt.y),
  18050. y: y2
  18051. };
  18052. };
  18053. var verticalIntersection = function verticalIntersection2(pt, v, x2) {
  18054. if (v.x === 0)
  18055. return null;
  18056. return {
  18057. x: x2,
  18058. y: pt.y + v.y / v.x * (x2 - pt.x)
  18059. };
  18060. };
  18061. var intersection2 = function intersection3(pt1, v1, pt2, v2) {
  18062. if (v1.x === 0)
  18063. return verticalIntersection(pt2, v2, pt1.x);
  18064. if (v2.x === 0)
  18065. return verticalIntersection(pt1, v1, pt2.x);
  18066. if (v1.y === 0)
  18067. return horizontalIntersection(pt2, v2, pt1.y);
  18068. if (v2.y === 0)
  18069. return horizontalIntersection(pt1, v1, pt2.y);
  18070. var kross = crossProduct2(v1, v2);
  18071. if (kross == 0)
  18072. return null;
  18073. var ve = {
  18074. x: pt2.x - pt1.x,
  18075. y: pt2.y - pt1.y
  18076. };
  18077. var d1 = crossProduct2(ve, v1) / kross;
  18078. var d2 = crossProduct2(ve, v2) / kross;
  18079. var x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x;
  18080. var y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y;
  18081. var x3 = (x12 + x2) / 2;
  18082. var y3 = (y12 + y2) / 2;
  18083. return {
  18084. x: x3,
  18085. y: y3
  18086. };
  18087. };
  18088. var SweepEvent = function() {
  18089. _createClass(SweepEvent2, null, [{
  18090. key: "compare",
  18091. value: function compare10(a, b) {
  18092. var ptCmp = SweepEvent2.comparePoints(a.point, b.point);
  18093. if (ptCmp !== 0)
  18094. return ptCmp;
  18095. if (a.point !== b.point)
  18096. a.link(b);
  18097. if (a.isLeft !== b.isLeft)
  18098. return a.isLeft ? 1 : -1;
  18099. return Segment.compare(a.segment, b.segment);
  18100. }
  18101. }, {
  18102. key: "comparePoints",
  18103. value: function comparePoints(aPt, bPt) {
  18104. if (aPt.x < bPt.x)
  18105. return -1;
  18106. if (aPt.x > bPt.x)
  18107. return 1;
  18108. if (aPt.y < bPt.y)
  18109. return -1;
  18110. if (aPt.y > bPt.y)
  18111. return 1;
  18112. return 0;
  18113. }
  18114. }]);
  18115. function SweepEvent2(point4, isLeft2) {
  18116. _classCallCheck(this, SweepEvent2);
  18117. if (point4.events === void 0)
  18118. point4.events = [this];
  18119. else
  18120. point4.events.push(this);
  18121. this.point = point4;
  18122. this.isLeft = isLeft2;
  18123. }
  18124. _createClass(SweepEvent2, [{
  18125. key: "link",
  18126. value: function link2(other) {
  18127. if (other.point === this.point) {
  18128. throw new Error("Tried to link already linked events");
  18129. }
  18130. var otherEvents = other.point.events;
  18131. for (var i = 0, iMax = otherEvents.length; i < iMax; i++) {
  18132. var evt = otherEvents[i];
  18133. this.point.events.push(evt);
  18134. evt.point = this.point;
  18135. }
  18136. this.checkForConsuming();
  18137. }
  18138. }, {
  18139. key: "checkForConsuming",
  18140. value: function checkForConsuming() {
  18141. var numEvents = this.point.events.length;
  18142. for (var i = 0; i < numEvents; i++) {
  18143. var evt1 = this.point.events[i];
  18144. if (evt1.segment.consumedBy !== void 0)
  18145. continue;
  18146. for (var j = i + 1; j < numEvents; j++) {
  18147. var evt2 = this.point.events[j];
  18148. if (evt2.consumedBy !== void 0)
  18149. continue;
  18150. if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
  18151. continue;
  18152. evt1.segment.consume(evt2.segment);
  18153. }
  18154. }
  18155. }
  18156. }, {
  18157. key: "getAvailableLinkedEvents",
  18158. value: function getAvailableLinkedEvents() {
  18159. var events = [];
  18160. for (var i = 0, iMax = this.point.events.length; i < iMax; i++) {
  18161. var evt = this.point.events[i];
  18162. if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
  18163. events.push(evt);
  18164. }
  18165. }
  18166. return events;
  18167. }
  18168. }, {
  18169. key: "getLeftmostComparator",
  18170. value: function getLeftmostComparator(baseEvent) {
  18171. var _this = this;
  18172. var cache = /* @__PURE__ */ new Map();
  18173. var fillCache = function fillCache2(linkedEvent) {
  18174. var nextEvent = linkedEvent.otherSE;
  18175. cache.set(linkedEvent, {
  18176. sine: sineOfAngle(_this.point, baseEvent.point, nextEvent.point),
  18177. cosine: cosineOfAngle(_this.point, baseEvent.point, nextEvent.point)
  18178. });
  18179. };
  18180. return function(a, b) {
  18181. if (!cache.has(a))
  18182. fillCache(a);
  18183. if (!cache.has(b))
  18184. fillCache(b);
  18185. var _cache$get = cache.get(a), asine = _cache$get.sine, acosine = _cache$get.cosine;
  18186. var _cache$get2 = cache.get(b), bsine = _cache$get2.sine, bcosine = _cache$get2.cosine;
  18187. if (asine >= 0 && bsine >= 0) {
  18188. if (acosine < bcosine)
  18189. return 1;
  18190. if (acosine > bcosine)
  18191. return -1;
  18192. return 0;
  18193. }
  18194. if (asine < 0 && bsine < 0) {
  18195. if (acosine < bcosine)
  18196. return -1;
  18197. if (acosine > bcosine)
  18198. return 1;
  18199. return 0;
  18200. }
  18201. if (bsine < asine)
  18202. return -1;
  18203. if (bsine > asine)
  18204. return 1;
  18205. return 0;
  18206. };
  18207. }
  18208. }]);
  18209. return SweepEvent2;
  18210. }();
  18211. var segmentId = 0;
  18212. var Segment = function() {
  18213. _createClass(Segment2, null, [{
  18214. key: "compare",
  18215. value: function compare10(a, b) {
  18216. var alx = a.leftSE.point.x;
  18217. var blx = b.leftSE.point.x;
  18218. var arx = a.rightSE.point.x;
  18219. var brx = b.rightSE.point.x;
  18220. if (brx < alx)
  18221. return 1;
  18222. if (arx < blx)
  18223. return -1;
  18224. var aly = a.leftSE.point.y;
  18225. var bly = b.leftSE.point.y;
  18226. var ary = a.rightSE.point.y;
  18227. var bry = b.rightSE.point.y;
  18228. if (alx < blx) {
  18229. if (bly < aly && bly < ary)
  18230. return 1;
  18231. if (bly > aly && bly > ary)
  18232. return -1;
  18233. var aCmpBLeft = a.comparePoint(b.leftSE.point);
  18234. if (aCmpBLeft < 0)
  18235. return 1;
  18236. if (aCmpBLeft > 0)
  18237. return -1;
  18238. var bCmpARight = b.comparePoint(a.rightSE.point);
  18239. if (bCmpARight !== 0)
  18240. return bCmpARight;
  18241. return -1;
  18242. }
  18243. if (alx > blx) {
  18244. if (aly < bly && aly < bry)
  18245. return -1;
  18246. if (aly > bly && aly > bry)
  18247. return 1;
  18248. var bCmpALeft = b.comparePoint(a.leftSE.point);
  18249. if (bCmpALeft !== 0)
  18250. return bCmpALeft;
  18251. var aCmpBRight = a.comparePoint(b.rightSE.point);
  18252. if (aCmpBRight < 0)
  18253. return 1;
  18254. if (aCmpBRight > 0)
  18255. return -1;
  18256. return 1;
  18257. }
  18258. if (aly < bly)
  18259. return -1;
  18260. if (aly > bly)
  18261. return 1;
  18262. if (arx < brx) {
  18263. var _bCmpARight = b.comparePoint(a.rightSE.point);
  18264. if (_bCmpARight !== 0)
  18265. return _bCmpARight;
  18266. }
  18267. if (arx > brx) {
  18268. var _aCmpBRight = a.comparePoint(b.rightSE.point);
  18269. if (_aCmpBRight < 0)
  18270. return 1;
  18271. if (_aCmpBRight > 0)
  18272. return -1;
  18273. }
  18274. if (arx !== brx) {
  18275. var ay = ary - aly;
  18276. var ax = arx - alx;
  18277. var by = bry - bly;
  18278. var bx = brx - blx;
  18279. if (ay > ax && by < bx)
  18280. return 1;
  18281. if (ay < ax && by > bx)
  18282. return -1;
  18283. }
  18284. if (arx > brx)
  18285. return 1;
  18286. if (arx < brx)
  18287. return -1;
  18288. if (ary < bry)
  18289. return -1;
  18290. if (ary > bry)
  18291. return 1;
  18292. if (a.id < b.id)
  18293. return -1;
  18294. if (a.id > b.id)
  18295. return 1;
  18296. return 0;
  18297. }
  18298. }]);
  18299. function Segment2(leftSE, rightSE, rings, windings) {
  18300. _classCallCheck(this, Segment2);
  18301. this.id = ++segmentId;
  18302. this.leftSE = leftSE;
  18303. leftSE.segment = this;
  18304. leftSE.otherSE = rightSE;
  18305. this.rightSE = rightSE;
  18306. rightSE.segment = this;
  18307. rightSE.otherSE = leftSE;
  18308. this.rings = rings;
  18309. this.windings = windings;
  18310. }
  18311. _createClass(Segment2, [{
  18312. key: "replaceRightSE",
  18313. value: function replaceRightSE(newRightSE) {
  18314. this.rightSE = newRightSE;
  18315. this.rightSE.segment = this;
  18316. this.rightSE.otherSE = this.leftSE;
  18317. this.leftSE.otherSE = this.rightSE;
  18318. }
  18319. }, {
  18320. key: "bbox",
  18321. value: function bbox3() {
  18322. var y12 = this.leftSE.point.y;
  18323. var y2 = this.rightSE.point.y;
  18324. return {
  18325. ll: {
  18326. x: this.leftSE.point.x,
  18327. y: y12 < y2 ? y12 : y2
  18328. },
  18329. ur: {
  18330. x: this.rightSE.point.x,
  18331. y: y12 > y2 ? y12 : y2
  18332. }
  18333. };
  18334. }
  18335. }, {
  18336. key: "vector",
  18337. value: function vector() {
  18338. return {
  18339. x: this.rightSE.point.x - this.leftSE.point.x,
  18340. y: this.rightSE.point.y - this.leftSE.point.y
  18341. };
  18342. }
  18343. }, {
  18344. key: "isAnEndpoint",
  18345. value: function isAnEndpoint(pt) {
  18346. return pt.x === this.leftSE.point.x && pt.y === this.leftSE.point.y || pt.x === this.rightSE.point.x && pt.y === this.rightSE.point.y;
  18347. }
  18348. }, {
  18349. key: "comparePoint",
  18350. value: function comparePoint(point4) {
  18351. if (this.isAnEndpoint(point4))
  18352. return 0;
  18353. var lPt = this.leftSE.point;
  18354. var rPt = this.rightSE.point;
  18355. var v = this.vector();
  18356. if (lPt.x === rPt.x) {
  18357. if (point4.x === lPt.x)
  18358. return 0;
  18359. return point4.x < lPt.x ? 1 : -1;
  18360. }
  18361. var yDist = (point4.y - lPt.y) / v.y;
  18362. var xFromYDist = lPt.x + yDist * v.x;
  18363. if (point4.x === xFromYDist)
  18364. return 0;
  18365. var xDist = (point4.x - lPt.x) / v.x;
  18366. var yFromXDist = lPt.y + xDist * v.y;
  18367. if (point4.y === yFromXDist)
  18368. return 0;
  18369. return point4.y < yFromXDist ? -1 : 1;
  18370. }
  18371. }, {
  18372. key: "getIntersection",
  18373. value: function getIntersection2(other) {
  18374. var tBbox = this.bbox();
  18375. var oBbox = other.bbox();
  18376. var bboxOverlap = getBboxOverlap(tBbox, oBbox);
  18377. if (bboxOverlap === null)
  18378. return null;
  18379. var tlp = this.leftSE.point;
  18380. var trp = this.rightSE.point;
  18381. var olp = other.leftSE.point;
  18382. var orp = other.rightSE.point;
  18383. var touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
  18384. var touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0;
  18385. var touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
  18386. var touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0;
  18387. if (touchesThisLSE && touchesOtherLSE) {
  18388. if (touchesThisRSE && !touchesOtherRSE)
  18389. return trp;
  18390. if (!touchesThisRSE && touchesOtherRSE)
  18391. return orp;
  18392. return null;
  18393. }
  18394. if (touchesThisLSE) {
  18395. if (touchesOtherRSE) {
  18396. if (tlp.x === orp.x && tlp.y === orp.y)
  18397. return null;
  18398. }
  18399. return tlp;
  18400. }
  18401. if (touchesOtherLSE) {
  18402. if (touchesThisRSE) {
  18403. if (trp.x === olp.x && trp.y === olp.y)
  18404. return null;
  18405. }
  18406. return olp;
  18407. }
  18408. if (touchesThisRSE && touchesOtherRSE)
  18409. return null;
  18410. if (touchesThisRSE)
  18411. return trp;
  18412. if (touchesOtherRSE)
  18413. return orp;
  18414. var pt = intersection2(tlp, this.vector(), olp, other.vector());
  18415. if (pt === null)
  18416. return null;
  18417. if (!isInBbox(bboxOverlap, pt))
  18418. return null;
  18419. return rounder.round(pt.x, pt.y);
  18420. }
  18421. }, {
  18422. key: "split",
  18423. value: function split3(point4) {
  18424. var newEvents = [];
  18425. var alreadyLinked = point4.events !== void 0;
  18426. var newLeftSE = new SweepEvent(point4, true);
  18427. var newRightSE = new SweepEvent(point4, false);
  18428. var oldRightSE = this.rightSE;
  18429. this.replaceRightSE(newRightSE);
  18430. newEvents.push(newRightSE);
  18431. newEvents.push(newLeftSE);
  18432. var newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
  18433. if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
  18434. newSeg.swapEvents();
  18435. }
  18436. if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
  18437. this.swapEvents();
  18438. }
  18439. if (alreadyLinked) {
  18440. newLeftSE.checkForConsuming();
  18441. newRightSE.checkForConsuming();
  18442. }
  18443. return newEvents;
  18444. }
  18445. }, {
  18446. key: "swapEvents",
  18447. value: function swapEvents() {
  18448. var tmpEvt = this.rightSE;
  18449. this.rightSE = this.leftSE;
  18450. this.leftSE = tmpEvt;
  18451. this.leftSE.isLeft = true;
  18452. this.rightSE.isLeft = false;
  18453. for (var i = 0, iMax = this.windings.length; i < iMax; i++) {
  18454. this.windings[i] *= -1;
  18455. }
  18456. }
  18457. }, {
  18458. key: "consume",
  18459. value: function consume(other) {
  18460. var consumer = this;
  18461. var consumee = other;
  18462. while (consumer.consumedBy) {
  18463. consumer = consumer.consumedBy;
  18464. }
  18465. while (consumee.consumedBy) {
  18466. consumee = consumee.consumedBy;
  18467. }
  18468. var cmp3 = Segment2.compare(consumer, consumee);
  18469. if (cmp3 === 0)
  18470. return;
  18471. if (cmp3 > 0) {
  18472. var tmp = consumer;
  18473. consumer = consumee;
  18474. consumee = tmp;
  18475. }
  18476. if (consumer.prev === consumee) {
  18477. var _tmp = consumer;
  18478. consumer = consumee;
  18479. consumee = _tmp;
  18480. }
  18481. for (var i = 0, iMax = consumee.rings.length; i < iMax; i++) {
  18482. var ring = consumee.rings[i];
  18483. var winding = consumee.windings[i];
  18484. var index2 = consumer.rings.indexOf(ring);
  18485. if (index2 === -1) {
  18486. consumer.rings.push(ring);
  18487. consumer.windings.push(winding);
  18488. } else
  18489. consumer.windings[index2] += winding;
  18490. }
  18491. consumee.rings = null;
  18492. consumee.windings = null;
  18493. consumee.consumedBy = consumer;
  18494. consumee.leftSE.consumedBy = consumer.leftSE;
  18495. consumee.rightSE.consumedBy = consumer.rightSE;
  18496. }
  18497. }, {
  18498. key: "prevInResult",
  18499. value: function prevInResult() {
  18500. if (this._prevInResult !== void 0)
  18501. return this._prevInResult;
  18502. if (!this.prev)
  18503. this._prevInResult = null;
  18504. else if (this.prev.isInResult())
  18505. this._prevInResult = this.prev;
  18506. else
  18507. this._prevInResult = this.prev.prevInResult();
  18508. return this._prevInResult;
  18509. }
  18510. }, {
  18511. key: "beforeState",
  18512. value: function beforeState() {
  18513. if (this._beforeState !== void 0)
  18514. return this._beforeState;
  18515. if (!this.prev)
  18516. this._beforeState = {
  18517. rings: [],
  18518. windings: [],
  18519. multiPolys: []
  18520. };
  18521. else {
  18522. var seg = this.prev.consumedBy || this.prev;
  18523. this._beforeState = seg.afterState();
  18524. }
  18525. return this._beforeState;
  18526. }
  18527. }, {
  18528. key: "afterState",
  18529. value: function afterState() {
  18530. if (this._afterState !== void 0)
  18531. return this._afterState;
  18532. var beforeState = this.beforeState();
  18533. this._afterState = {
  18534. rings: beforeState.rings.slice(0),
  18535. windings: beforeState.windings.slice(0),
  18536. multiPolys: []
  18537. };
  18538. var ringsAfter = this._afterState.rings;
  18539. var windingsAfter = this._afterState.windings;
  18540. var mpsAfter = this._afterState.multiPolys;
  18541. for (var i = 0, iMax = this.rings.length; i < iMax; i++) {
  18542. var ring = this.rings[i];
  18543. var winding = this.windings[i];
  18544. var index2 = ringsAfter.indexOf(ring);
  18545. if (index2 === -1) {
  18546. ringsAfter.push(ring);
  18547. windingsAfter.push(winding);
  18548. } else
  18549. windingsAfter[index2] += winding;
  18550. }
  18551. var polysAfter = [];
  18552. var polysExclude = [];
  18553. for (var _i = 0, _iMax = ringsAfter.length; _i < _iMax; _i++) {
  18554. if (windingsAfter[_i] === 0)
  18555. continue;
  18556. var _ring = ringsAfter[_i];
  18557. var poly = _ring.poly;
  18558. if (polysExclude.indexOf(poly) !== -1)
  18559. continue;
  18560. if (_ring.isExterior)
  18561. polysAfter.push(poly);
  18562. else {
  18563. if (polysExclude.indexOf(poly) === -1)
  18564. polysExclude.push(poly);
  18565. var _index = polysAfter.indexOf(_ring.poly);
  18566. if (_index !== -1)
  18567. polysAfter.splice(_index, 1);
  18568. }
  18569. }
  18570. for (var _i2 = 0, _iMax2 = polysAfter.length; _i2 < _iMax2; _i2++) {
  18571. var mp = polysAfter[_i2].multiPoly;
  18572. if (mpsAfter.indexOf(mp) === -1)
  18573. mpsAfter.push(mp);
  18574. }
  18575. return this._afterState;
  18576. }
  18577. }, {
  18578. key: "isInResult",
  18579. value: function isInResult2() {
  18580. if (this.consumedBy)
  18581. return false;
  18582. if (this._isInResult !== void 0)
  18583. return this._isInResult;
  18584. var mpsBefore = this.beforeState().multiPolys;
  18585. var mpsAfter = this.afterState().multiPolys;
  18586. switch (operation.type) {
  18587. case "union": {
  18588. var noBefores = mpsBefore.length === 0;
  18589. var noAfters = mpsAfter.length === 0;
  18590. this._isInResult = noBefores !== noAfters;
  18591. break;
  18592. }
  18593. case "intersection": {
  18594. var least;
  18595. var most;
  18596. if (mpsBefore.length < mpsAfter.length) {
  18597. least = mpsBefore.length;
  18598. most = mpsAfter.length;
  18599. } else {
  18600. least = mpsAfter.length;
  18601. most = mpsBefore.length;
  18602. }
  18603. this._isInResult = most === operation.numMultiPolys && least < most;
  18604. break;
  18605. }
  18606. case "xor": {
  18607. var diff2 = Math.abs(mpsBefore.length - mpsAfter.length);
  18608. this._isInResult = diff2 % 2 === 1;
  18609. break;
  18610. }
  18611. case "difference": {
  18612. var isJustSubject = function isJustSubject2(mps) {
  18613. return mps.length === 1 && mps[0].isSubject;
  18614. };
  18615. this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
  18616. break;
  18617. }
  18618. default:
  18619. throw new Error("Unrecognized operation type found ".concat(operation.type));
  18620. }
  18621. return this._isInResult;
  18622. }
  18623. }], [{
  18624. key: "fromRing",
  18625. value: function fromRing(pt1, pt2, ring) {
  18626. var leftPt, rightPt, winding;
  18627. var cmpPts = SweepEvent.comparePoints(pt1, pt2);
  18628. if (cmpPts < 0) {
  18629. leftPt = pt1;
  18630. rightPt = pt2;
  18631. winding = 1;
  18632. } else if (cmpPts > 0) {
  18633. leftPt = pt2;
  18634. rightPt = pt1;
  18635. winding = -1;
  18636. } else
  18637. throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
  18638. var leftSE = new SweepEvent(leftPt, true);
  18639. var rightSE = new SweepEvent(rightPt, false);
  18640. return new Segment2(leftSE, rightSE, [ring], [winding]);
  18641. }
  18642. }]);
  18643. return Segment2;
  18644. }();
  18645. var RingIn = function() {
  18646. function RingIn2(geomRing, poly, isExterior) {
  18647. _classCallCheck(this, RingIn2);
  18648. if (!Array.isArray(geomRing) || geomRing.length === 0) {
  18649. throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
  18650. }
  18651. this.poly = poly;
  18652. this.isExterior = isExterior;
  18653. this.segments = [];
  18654. if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
  18655. throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
  18656. }
  18657. var firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
  18658. this.bbox = {
  18659. ll: {
  18660. x: firstPoint.x,
  18661. y: firstPoint.y
  18662. },
  18663. ur: {
  18664. x: firstPoint.x,
  18665. y: firstPoint.y
  18666. }
  18667. };
  18668. var prevPoint = firstPoint;
  18669. for (var i = 1, iMax = geomRing.length; i < iMax; i++) {
  18670. if (typeof geomRing[i][0] !== "number" || typeof geomRing[i][1] !== "number") {
  18671. throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
  18672. }
  18673. var point4 = rounder.round(geomRing[i][0], geomRing[i][1]);
  18674. if (point4.x === prevPoint.x && point4.y === prevPoint.y)
  18675. continue;
  18676. this.segments.push(Segment.fromRing(prevPoint, point4, this));
  18677. if (point4.x < this.bbox.ll.x)
  18678. this.bbox.ll.x = point4.x;
  18679. if (point4.y < this.bbox.ll.y)
  18680. this.bbox.ll.y = point4.y;
  18681. if (point4.x > this.bbox.ur.x)
  18682. this.bbox.ur.x = point4.x;
  18683. if (point4.y > this.bbox.ur.y)
  18684. this.bbox.ur.y = point4.y;
  18685. prevPoint = point4;
  18686. }
  18687. if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) {
  18688. this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
  18689. }
  18690. }
  18691. _createClass(RingIn2, [{
  18692. key: "getSweepEvents",
  18693. value: function getSweepEvents() {
  18694. var sweepEvents = [];
  18695. for (var i = 0, iMax = this.segments.length; i < iMax; i++) {
  18696. var segment = this.segments[i];
  18697. sweepEvents.push(segment.leftSE);
  18698. sweepEvents.push(segment.rightSE);
  18699. }
  18700. return sweepEvents;
  18701. }
  18702. }]);
  18703. return RingIn2;
  18704. }();
  18705. var PolyIn = function() {
  18706. function PolyIn2(geomPoly, multiPoly) {
  18707. _classCallCheck(this, PolyIn2);
  18708. if (!Array.isArray(geomPoly)) {
  18709. throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
  18710. }
  18711. this.exteriorRing = new RingIn(geomPoly[0], this, true);
  18712. this.bbox = {
  18713. ll: {
  18714. x: this.exteriorRing.bbox.ll.x,
  18715. y: this.exteriorRing.bbox.ll.y
  18716. },
  18717. ur: {
  18718. x: this.exteriorRing.bbox.ur.x,
  18719. y: this.exteriorRing.bbox.ur.y
  18720. }
  18721. };
  18722. this.interiorRings = [];
  18723. for (var i = 1, iMax = geomPoly.length; i < iMax; i++) {
  18724. var ring = new RingIn(geomPoly[i], this, false);
  18725. if (ring.bbox.ll.x < this.bbox.ll.x)
  18726. this.bbox.ll.x = ring.bbox.ll.x;
  18727. if (ring.bbox.ll.y < this.bbox.ll.y)
  18728. this.bbox.ll.y = ring.bbox.ll.y;
  18729. if (ring.bbox.ur.x > this.bbox.ur.x)
  18730. this.bbox.ur.x = ring.bbox.ur.x;
  18731. if (ring.bbox.ur.y > this.bbox.ur.y)
  18732. this.bbox.ur.y = ring.bbox.ur.y;
  18733. this.interiorRings.push(ring);
  18734. }
  18735. this.multiPoly = multiPoly;
  18736. }
  18737. _createClass(PolyIn2, [{
  18738. key: "getSweepEvents",
  18739. value: function getSweepEvents() {
  18740. var sweepEvents = this.exteriorRing.getSweepEvents();
  18741. for (var i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
  18742. var ringSweepEvents = this.interiorRings[i].getSweepEvents();
  18743. for (var j = 0, jMax = ringSweepEvents.length; j < jMax; j++) {
  18744. sweepEvents.push(ringSweepEvents[j]);
  18745. }
  18746. }
  18747. return sweepEvents;
  18748. }
  18749. }]);
  18750. return PolyIn2;
  18751. }();
  18752. var MultiPolyIn = function() {
  18753. function MultiPolyIn2(geom, isSubject) {
  18754. _classCallCheck(this, MultiPolyIn2);
  18755. if (!Array.isArray(geom)) {
  18756. throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
  18757. }
  18758. try {
  18759. if (typeof geom[0][0][0] === "number")
  18760. geom = [geom];
  18761. } catch (ex) {
  18762. }
  18763. this.polys = [];
  18764. this.bbox = {
  18765. ll: {
  18766. x: Number.POSITIVE_INFINITY,
  18767. y: Number.POSITIVE_INFINITY
  18768. },
  18769. ur: {
  18770. x: Number.NEGATIVE_INFINITY,
  18771. y: Number.NEGATIVE_INFINITY
  18772. }
  18773. };
  18774. for (var i = 0, iMax = geom.length; i < iMax; i++) {
  18775. var poly = new PolyIn(geom[i], this);
  18776. if (poly.bbox.ll.x < this.bbox.ll.x)
  18777. this.bbox.ll.x = poly.bbox.ll.x;
  18778. if (poly.bbox.ll.y < this.bbox.ll.y)
  18779. this.bbox.ll.y = poly.bbox.ll.y;
  18780. if (poly.bbox.ur.x > this.bbox.ur.x)
  18781. this.bbox.ur.x = poly.bbox.ur.x;
  18782. if (poly.bbox.ur.y > this.bbox.ur.y)
  18783. this.bbox.ur.y = poly.bbox.ur.y;
  18784. this.polys.push(poly);
  18785. }
  18786. this.isSubject = isSubject;
  18787. }
  18788. _createClass(MultiPolyIn2, [{
  18789. key: "getSweepEvents",
  18790. value: function getSweepEvents() {
  18791. var sweepEvents = [];
  18792. for (var i = 0, iMax = this.polys.length; i < iMax; i++) {
  18793. var polySweepEvents = this.polys[i].getSweepEvents();
  18794. for (var j = 0, jMax = polySweepEvents.length; j < jMax; j++) {
  18795. sweepEvents.push(polySweepEvents[j]);
  18796. }
  18797. }
  18798. return sweepEvents;
  18799. }
  18800. }]);
  18801. return MultiPolyIn2;
  18802. }();
  18803. var RingOut = function() {
  18804. _createClass(RingOut2, null, [{
  18805. key: "factory",
  18806. value: function factory(allSegments) {
  18807. var ringsOut = [];
  18808. for (var i = 0, iMax = allSegments.length; i < iMax; i++) {
  18809. var segment = allSegments[i];
  18810. if (!segment.isInResult() || segment.ringOut)
  18811. continue;
  18812. var prevEvent = null;
  18813. var event = segment.leftSE;
  18814. var nextEvent = segment.rightSE;
  18815. var events = [event];
  18816. var startingPoint = event.point;
  18817. var intersectionLEs = [];
  18818. while (true) {
  18819. prevEvent = event;
  18820. event = nextEvent;
  18821. events.push(event);
  18822. if (event.point === startingPoint)
  18823. break;
  18824. while (true) {
  18825. var availableLEs = event.getAvailableLinkedEvents();
  18826. if (availableLEs.length === 0) {
  18827. var firstPt = events[0].point;
  18828. var lastPt = events[events.length - 1].point;
  18829. throw new Error("Unable to complete output ring starting at [".concat(firstPt.x, ",") + " ".concat(firstPt.y, "]. Last matching segment found ends at") + " [".concat(lastPt.x, ", ").concat(lastPt.y, "]."));
  18830. }
  18831. if (availableLEs.length === 1) {
  18832. nextEvent = availableLEs[0].otherSE;
  18833. break;
  18834. }
  18835. var indexLE = null;
  18836. for (var j = 0, jMax = intersectionLEs.length; j < jMax; j++) {
  18837. if (intersectionLEs[j].point === event.point) {
  18838. indexLE = j;
  18839. break;
  18840. }
  18841. }
  18842. if (indexLE !== null) {
  18843. var intersectionLE = intersectionLEs.splice(indexLE)[0];
  18844. var ringEvents = events.splice(intersectionLE.index);
  18845. ringEvents.unshift(ringEvents[0].otherSE);
  18846. ringsOut.push(new RingOut2(ringEvents.reverse()));
  18847. continue;
  18848. }
  18849. intersectionLEs.push({
  18850. index: events.length,
  18851. point: event.point
  18852. });
  18853. var comparator = event.getLeftmostComparator(prevEvent);
  18854. nextEvent = availableLEs.sort(comparator)[0].otherSE;
  18855. break;
  18856. }
  18857. }
  18858. ringsOut.push(new RingOut2(events));
  18859. }
  18860. return ringsOut;
  18861. }
  18862. }]);
  18863. function RingOut2(events) {
  18864. _classCallCheck(this, RingOut2);
  18865. this.events = events;
  18866. for (var i = 0, iMax = events.length; i < iMax; i++) {
  18867. events[i].segment.ringOut = this;
  18868. }
  18869. this.poly = null;
  18870. }
  18871. _createClass(RingOut2, [{
  18872. key: "getGeom",
  18873. value: function getGeom2() {
  18874. var prevPt = this.events[0].point;
  18875. var points2 = [prevPt];
  18876. for (var i = 1, iMax = this.events.length - 1; i < iMax; i++) {
  18877. var _pt = this.events[i].point;
  18878. var _nextPt = this.events[i + 1].point;
  18879. if (compareVectorAngles(_pt, prevPt, _nextPt) === 0)
  18880. continue;
  18881. points2.push(_pt);
  18882. prevPt = _pt;
  18883. }
  18884. if (points2.length === 1)
  18885. return null;
  18886. var pt = points2[0];
  18887. var nextPt = points2[1];
  18888. if (compareVectorAngles(pt, prevPt, nextPt) === 0)
  18889. points2.shift();
  18890. points2.push(points2[0]);
  18891. var step = this.isExteriorRing() ? 1 : -1;
  18892. var iStart = this.isExteriorRing() ? 0 : points2.length - 1;
  18893. var iEnd = this.isExteriorRing() ? points2.length : -1;
  18894. var orderedPoints = [];
  18895. for (var _i = iStart; _i != iEnd; _i += step) {
  18896. orderedPoints.push([points2[_i].x, points2[_i].y]);
  18897. }
  18898. return orderedPoints;
  18899. }
  18900. }, {
  18901. key: "isExteriorRing",
  18902. value: function isExteriorRing() {
  18903. if (this._isExteriorRing === void 0) {
  18904. var enclosing = this.enclosingRing();
  18905. this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
  18906. }
  18907. return this._isExteriorRing;
  18908. }
  18909. }, {
  18910. key: "enclosingRing",
  18911. value: function enclosingRing() {
  18912. if (this._enclosingRing === void 0) {
  18913. this._enclosingRing = this._calcEnclosingRing();
  18914. }
  18915. return this._enclosingRing;
  18916. }
  18917. }, {
  18918. key: "_calcEnclosingRing",
  18919. value: function _calcEnclosingRing() {
  18920. var leftMostEvt = this.events[0];
  18921. for (var i = 1, iMax = this.events.length; i < iMax; i++) {
  18922. var evt = this.events[i];
  18923. if (SweepEvent.compare(leftMostEvt, evt) > 0)
  18924. leftMostEvt = evt;
  18925. }
  18926. var prevSeg = leftMostEvt.segment.prevInResult();
  18927. var prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
  18928. while (true) {
  18929. if (!prevSeg)
  18930. return null;
  18931. if (!prevPrevSeg)
  18932. return prevSeg.ringOut;
  18933. if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
  18934. if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) {
  18935. return prevSeg.ringOut;
  18936. } else
  18937. return prevSeg.ringOut.enclosingRing();
  18938. }
  18939. prevSeg = prevPrevSeg.prevInResult();
  18940. prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
  18941. }
  18942. }
  18943. }]);
  18944. return RingOut2;
  18945. }();
  18946. var PolyOut = function() {
  18947. function PolyOut2(exteriorRing) {
  18948. _classCallCheck(this, PolyOut2);
  18949. this.exteriorRing = exteriorRing;
  18950. exteriorRing.poly = this;
  18951. this.interiorRings = [];
  18952. }
  18953. _createClass(PolyOut2, [{
  18954. key: "addInterior",
  18955. value: function addInterior(ring) {
  18956. this.interiorRings.push(ring);
  18957. ring.poly = this;
  18958. }
  18959. }, {
  18960. key: "getGeom",
  18961. value: function getGeom2() {
  18962. var geom = [this.exteriorRing.getGeom()];
  18963. if (geom[0] === null)
  18964. return null;
  18965. for (var i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
  18966. var ringGeom = this.interiorRings[i].getGeom();
  18967. if (ringGeom === null)
  18968. continue;
  18969. geom.push(ringGeom);
  18970. }
  18971. return geom;
  18972. }
  18973. }]);
  18974. return PolyOut2;
  18975. }();
  18976. var MultiPolyOut = function() {
  18977. function MultiPolyOut2(rings) {
  18978. _classCallCheck(this, MultiPolyOut2);
  18979. this.rings = rings;
  18980. this.polys = this._composePolys(rings);
  18981. }
  18982. _createClass(MultiPolyOut2, [{
  18983. key: "getGeom",
  18984. value: function getGeom2() {
  18985. var geom = [];
  18986. for (var i = 0, iMax = this.polys.length; i < iMax; i++) {
  18987. var polyGeom = this.polys[i].getGeom();
  18988. if (polyGeom === null)
  18989. continue;
  18990. geom.push(polyGeom);
  18991. }
  18992. return geom;
  18993. }
  18994. }, {
  18995. key: "_composePolys",
  18996. value: function _composePolys(rings) {
  18997. var polys = [];
  18998. for (var i = 0, iMax = rings.length; i < iMax; i++) {
  18999. var ring = rings[i];
  19000. if (ring.poly)
  19001. continue;
  19002. if (ring.isExteriorRing())
  19003. polys.push(new PolyOut(ring));
  19004. else {
  19005. var enclosingRing = ring.enclosingRing();
  19006. if (!enclosingRing.poly)
  19007. polys.push(new PolyOut(enclosingRing));
  19008. enclosingRing.poly.addInterior(ring);
  19009. }
  19010. }
  19011. return polys;
  19012. }
  19013. }]);
  19014. return MultiPolyOut2;
  19015. }();
  19016. var SweepLine = function() {
  19017. function SweepLine2(queue) {
  19018. var comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment.compare;
  19019. _classCallCheck(this, SweepLine2);
  19020. this.queue = queue;
  19021. this.tree = new splay_esm_default(comparator);
  19022. this.segments = [];
  19023. }
  19024. _createClass(SweepLine2, [{
  19025. key: "process",
  19026. value: function process2(event) {
  19027. var segment = event.segment;
  19028. var newEvents = [];
  19029. if (event.consumedBy) {
  19030. if (event.isLeft)
  19031. this.queue.remove(event.otherSE);
  19032. else
  19033. this.tree.remove(segment);
  19034. return newEvents;
  19035. }
  19036. var node = event.isLeft ? this.tree.insert(segment) : this.tree.find(segment);
  19037. if (!node)
  19038. throw new Error("Unable to find segment #".concat(segment.id, " ") + "[".concat(segment.leftSE.point.x, ", ").concat(segment.leftSE.point.y, "] -> ") + "[".concat(segment.rightSE.point.x, ", ").concat(segment.rightSE.point.y, "] ") + "in SweepLine tree. Please submit a bug report.");
  19039. var prevNode = node;
  19040. var nextNode = node;
  19041. var prevSeg = void 0;
  19042. var nextSeg = void 0;
  19043. while (prevSeg === void 0) {
  19044. prevNode = this.tree.prev(prevNode);
  19045. if (prevNode === null)
  19046. prevSeg = null;
  19047. else if (prevNode.key.consumedBy === void 0)
  19048. prevSeg = prevNode.key;
  19049. }
  19050. while (nextSeg === void 0) {
  19051. nextNode = this.tree.next(nextNode);
  19052. if (nextNode === null)
  19053. nextSeg = null;
  19054. else if (nextNode.key.consumedBy === void 0)
  19055. nextSeg = nextNode.key;
  19056. }
  19057. if (event.isLeft) {
  19058. var prevMySplitter = null;
  19059. if (prevSeg) {
  19060. var prevInter = prevSeg.getIntersection(segment);
  19061. if (prevInter !== null) {
  19062. if (!segment.isAnEndpoint(prevInter))
  19063. prevMySplitter = prevInter;
  19064. if (!prevSeg.isAnEndpoint(prevInter)) {
  19065. var newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
  19066. for (var i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
  19067. newEvents.push(newEventsFromSplit[i]);
  19068. }
  19069. }
  19070. }
  19071. }
  19072. var nextMySplitter = null;
  19073. if (nextSeg) {
  19074. var nextInter = nextSeg.getIntersection(segment);
  19075. if (nextInter !== null) {
  19076. if (!segment.isAnEndpoint(nextInter))
  19077. nextMySplitter = nextInter;
  19078. if (!nextSeg.isAnEndpoint(nextInter)) {
  19079. var _newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
  19080. for (var _i = 0, _iMax = _newEventsFromSplit.length; _i < _iMax; _i++) {
  19081. newEvents.push(_newEventsFromSplit[_i]);
  19082. }
  19083. }
  19084. }
  19085. }
  19086. if (prevMySplitter !== null || nextMySplitter !== null) {
  19087. var mySplitter = null;
  19088. if (prevMySplitter === null)
  19089. mySplitter = nextMySplitter;
  19090. else if (nextMySplitter === null)
  19091. mySplitter = prevMySplitter;
  19092. else {
  19093. var cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter);
  19094. mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
  19095. }
  19096. this.queue.remove(segment.rightSE);
  19097. newEvents.push(segment.rightSE);
  19098. var _newEventsFromSplit2 = segment.split(mySplitter);
  19099. for (var _i2 = 0, _iMax2 = _newEventsFromSplit2.length; _i2 < _iMax2; _i2++) {
  19100. newEvents.push(_newEventsFromSplit2[_i2]);
  19101. }
  19102. }
  19103. if (newEvents.length > 0) {
  19104. this.tree.remove(segment);
  19105. newEvents.push(event);
  19106. } else {
  19107. this.segments.push(segment);
  19108. segment.prev = prevSeg;
  19109. }
  19110. } else {
  19111. if (prevSeg && nextSeg) {
  19112. var inter = prevSeg.getIntersection(nextSeg);
  19113. if (inter !== null) {
  19114. if (!prevSeg.isAnEndpoint(inter)) {
  19115. var _newEventsFromSplit3 = this._splitSafely(prevSeg, inter);
  19116. for (var _i3 = 0, _iMax3 = _newEventsFromSplit3.length; _i3 < _iMax3; _i3++) {
  19117. newEvents.push(_newEventsFromSplit3[_i3]);
  19118. }
  19119. }
  19120. if (!nextSeg.isAnEndpoint(inter)) {
  19121. var _newEventsFromSplit4 = this._splitSafely(nextSeg, inter);
  19122. for (var _i4 = 0, _iMax4 = _newEventsFromSplit4.length; _i4 < _iMax4; _i4++) {
  19123. newEvents.push(_newEventsFromSplit4[_i4]);
  19124. }
  19125. }
  19126. }
  19127. }
  19128. this.tree.remove(segment);
  19129. }
  19130. return newEvents;
  19131. }
  19132. }, {
  19133. key: "_splitSafely",
  19134. value: function _splitSafely(seg, pt) {
  19135. this.tree.remove(seg);
  19136. var rightSE = seg.rightSE;
  19137. this.queue.remove(rightSE);
  19138. var newEvents = seg.split(pt);
  19139. newEvents.push(rightSE);
  19140. if (seg.consumedBy === void 0)
  19141. this.tree.insert(seg);
  19142. return newEvents;
  19143. }
  19144. }]);
  19145. return SweepLine2;
  19146. }();
  19147. var POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6;
  19148. var POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
  19149. var Operation = function() {
  19150. function Operation2() {
  19151. _classCallCheck(this, Operation2);
  19152. }
  19153. _createClass(Operation2, [{
  19154. key: "run",
  19155. value: function run(type, geom, moreGeoms) {
  19156. operation.type = type;
  19157. rounder.reset();
  19158. var multipolys = [new MultiPolyIn(geom, true)];
  19159. for (var i = 0, iMax = moreGeoms.length; i < iMax; i++) {
  19160. multipolys.push(new MultiPolyIn(moreGeoms[i], false));
  19161. }
  19162. operation.numMultiPolys = multipolys.length;
  19163. if (operation.type === "difference") {
  19164. var subject = multipolys[0];
  19165. var _i = 1;
  19166. while (_i < multipolys.length) {
  19167. if (getBboxOverlap(multipolys[_i].bbox, subject.bbox) !== null)
  19168. _i++;
  19169. else
  19170. multipolys.splice(_i, 1);
  19171. }
  19172. }
  19173. if (operation.type === "intersection") {
  19174. for (var _i2 = 0, _iMax = multipolys.length; _i2 < _iMax; _i2++) {
  19175. var mpA = multipolys[_i2];
  19176. for (var j = _i2 + 1, jMax = multipolys.length; j < jMax; j++) {
  19177. if (getBboxOverlap(mpA.bbox, multipolys[j].bbox) === null)
  19178. return [];
  19179. }
  19180. }
  19181. }
  19182. var queue = new splay_esm_default(SweepEvent.compare);
  19183. for (var _i3 = 0, _iMax2 = multipolys.length; _i3 < _iMax2; _i3++) {
  19184. var sweepEvents = multipolys[_i3].getSweepEvents();
  19185. for (var _j = 0, _jMax = sweepEvents.length; _j < _jMax; _j++) {
  19186. queue.insert(sweepEvents[_j]);
  19187. if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
  19188. throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");
  19189. }
  19190. }
  19191. }
  19192. var sweepLine = new SweepLine(queue);
  19193. var prevQueueSize = queue.size;
  19194. var node = queue.pop();
  19195. while (node) {
  19196. var evt = node.key;
  19197. if (queue.size === prevQueueSize) {
  19198. var seg = evt.segment;
  19199. throw new Error("Unable to pop() ".concat(evt.isLeft ? "left" : "right", " SweepEvent ") + "[".concat(evt.point.x, ", ").concat(evt.point.y, "] from segment #").concat(seg.id, " ") + "[".concat(seg.leftSE.point.x, ", ").concat(seg.leftSE.point.y, "] -> ") + "[".concat(seg.rightSE.point.x, ", ").concat(seg.rightSE.point.y, "] from queue. ") + "Please file a bug report.");
  19200. }
  19201. if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
  19202. throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");
  19203. }
  19204. if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) {
  19205. throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");
  19206. }
  19207. var newEvents = sweepLine.process(evt);
  19208. for (var _i4 = 0, _iMax3 = newEvents.length; _i4 < _iMax3; _i4++) {
  19209. var _evt = newEvents[_i4];
  19210. if (_evt.consumedBy === void 0)
  19211. queue.insert(_evt);
  19212. }
  19213. prevQueueSize = queue.size;
  19214. node = queue.pop();
  19215. }
  19216. rounder.reset();
  19217. var ringsOut = RingOut.factory(sweepLine.segments);
  19218. var result = new MultiPolyOut(ringsOut);
  19219. return result.getGeom();
  19220. }
  19221. }]);
  19222. return Operation2;
  19223. }();
  19224. var operation = new Operation();
  19225. var union = function union2(geom) {
  19226. for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  19227. moreGeoms[_key - 1] = arguments[_key];
  19228. }
  19229. return operation.run("union", geom, moreGeoms);
  19230. };
  19231. var intersection$1 = function intersection4(geom) {
  19232. for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  19233. moreGeoms[_key2 - 1] = arguments[_key2];
  19234. }
  19235. return operation.run("intersection", geom, moreGeoms);
  19236. };
  19237. var xor = function xor2(geom) {
  19238. for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  19239. moreGeoms[_key3 - 1] = arguments[_key3];
  19240. }
  19241. return operation.run("xor", geom, moreGeoms);
  19242. };
  19243. var difference = function difference2(subjectGeom) {
  19244. for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  19245. clippingGeoms[_key4 - 1] = arguments[_key4];
  19246. }
  19247. return operation.run("difference", subjectGeom, clippingGeoms);
  19248. };
  19249. var index = {
  19250. union,
  19251. intersection: intersection$1,
  19252. xor,
  19253. difference
  19254. };
  19255. var polygon_clipping_esm_default = index;
  19256. // node_modules/@turf/difference/dist/es/index.js
  19257. function difference3(polygon1, polygon22) {
  19258. var geom1 = getGeom(polygon1);
  19259. var geom2 = getGeom(polygon22);
  19260. var properties = polygon1.properties || {};
  19261. var differenced = polygon_clipping_esm_default.difference(
  19262. geom1.coordinates,
  19263. geom2.coordinates
  19264. );
  19265. if (differenced.length === 0)
  19266. return null;
  19267. if (differenced.length === 1)
  19268. return polygon(differenced[0], properties);
  19269. return multiPolygon(differenced, properties);
  19270. }
  19271. var es_default72 = difference3;
  19272. // node_modules/turf-jsts/jsts.mjs
  19273. if (!("fill" in Array.prototype)) {
  19274. Object.defineProperty(Array.prototype, "fill", {
  19275. configurable: true,
  19276. value: function fill(value) {
  19277. if (this === void 0 || this === null) {
  19278. throw new TypeError(this + " is not an object");
  19279. }
  19280. var arrayLike = Object(this);
  19281. var length4 = Math.max(Math.min(arrayLike.length, 9007199254740991), 0) || 0;
  19282. var relativeStart = 1 in arguments ? parseInt(Number(arguments[1]), 10) || 0 : 0;
  19283. relativeStart = relativeStart < 0 ? Math.max(length4 + relativeStart, 0) : Math.min(relativeStart, length4);
  19284. var relativeEnd = 2 in arguments && arguments[2] !== void 0 ? parseInt(Number(arguments[2]), 10) || 0 : length4;
  19285. relativeEnd = relativeEnd < 0 ? Math.max(length4 + arguments[2], 0) : Math.min(relativeEnd, length4);
  19286. while (relativeStart < relativeEnd) {
  19287. arrayLike[relativeStart] = value;
  19288. ++relativeStart;
  19289. }
  19290. return arrayLike;
  19291. },
  19292. writable: true
  19293. });
  19294. }
  19295. Number.isFinite = Number.isFinite || function(value) {
  19296. return typeof value === "number" && isFinite(value);
  19297. };
  19298. Number.isInteger = Number.isInteger || function(val) {
  19299. return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
  19300. };
  19301. Number.parseFloat = Number.parseFloat || parseFloat;
  19302. Number.isNaN = Number.isNaN || function(value) {
  19303. return value !== value;
  19304. };
  19305. Math.trunc = Math.trunc || function(x2) {
  19306. return x2 < 0 ? Math.ceil(x2) : Math.floor(x2);
  19307. };
  19308. var NumberUtil = function NumberUtil2() {
  19309. };
  19310. NumberUtil.prototype.interfaces_ = function interfaces_() {
  19311. return [];
  19312. };
  19313. NumberUtil.prototype.getClass = function getClass() {
  19314. return NumberUtil;
  19315. };
  19316. NumberUtil.prototype.equalsWithTolerance = function equalsWithTolerance(x12, x2, tolerance) {
  19317. return Math.abs(x12 - x2) <= tolerance;
  19318. };
  19319. var IllegalArgumentException = function(Error2) {
  19320. function IllegalArgumentException2(message) {
  19321. Error2.call(this, message);
  19322. this.name = "IllegalArgumentException";
  19323. this.message = message;
  19324. this.stack = new Error2().stack;
  19325. }
  19326. if (Error2)
  19327. IllegalArgumentException2.__proto__ = Error2;
  19328. IllegalArgumentException2.prototype = Object.create(Error2 && Error2.prototype);
  19329. IllegalArgumentException2.prototype.constructor = IllegalArgumentException2;
  19330. return IllegalArgumentException2;
  19331. }(Error);
  19332. var Double = function Double2() {
  19333. };
  19334. var staticAccessors$1 = { MAX_VALUE: { configurable: true } };
  19335. Double.isNaN = function isNaN2(n) {
  19336. return Number.isNaN(n);
  19337. };
  19338. Double.doubleToLongBits = function doubleToLongBits(n) {
  19339. return n;
  19340. };
  19341. Double.longBitsToDouble = function longBitsToDouble(n) {
  19342. return n;
  19343. };
  19344. Double.isInfinite = function isInfinite(n) {
  19345. return !Number.isFinite(n);
  19346. };
  19347. staticAccessors$1.MAX_VALUE.get = function() {
  19348. return Number.MAX_VALUE;
  19349. };
  19350. Object.defineProperties(Double, staticAccessors$1);
  19351. var Comparable = function Comparable2() {
  19352. };
  19353. var Clonable = function Clonable2() {
  19354. };
  19355. var Comparator = function Comparator2() {
  19356. };
  19357. function Serializable() {
  19358. }
  19359. var Coordinate = function Coordinate2() {
  19360. this.x = null;
  19361. this.y = null;
  19362. this.z = null;
  19363. if (arguments.length === 0) {
  19364. this.x = 0;
  19365. this.y = 0;
  19366. this.z = Coordinate2.NULL_ORDINATE;
  19367. } else if (arguments.length === 1) {
  19368. var c = arguments[0];
  19369. this.x = c.x;
  19370. this.y = c.y;
  19371. this.z = c.z;
  19372. } else if (arguments.length === 2) {
  19373. this.x = arguments[0];
  19374. this.y = arguments[1];
  19375. this.z = Coordinate2.NULL_ORDINATE;
  19376. } else if (arguments.length === 3) {
  19377. this.x = arguments[0];
  19378. this.y = arguments[1];
  19379. this.z = arguments[2];
  19380. }
  19381. };
  19382. var staticAccessors = { DimensionalComparator: { configurable: true }, serialVersionUID: { configurable: true }, NULL_ORDINATE: { configurable: true }, X: { configurable: true }, Y: { configurable: true }, Z: { configurable: true } };
  19383. Coordinate.prototype.setOrdinate = function setOrdinate(ordinateIndex, value) {
  19384. switch (ordinateIndex) {
  19385. case Coordinate.X:
  19386. this.x = value;
  19387. break;
  19388. case Coordinate.Y:
  19389. this.y = value;
  19390. break;
  19391. case Coordinate.Z:
  19392. this.z = value;
  19393. break;
  19394. default:
  19395. throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex);
  19396. }
  19397. };
  19398. Coordinate.prototype.equals2D = function equals2D() {
  19399. if (arguments.length === 1) {
  19400. var other = arguments[0];
  19401. if (this.x !== other.x) {
  19402. return false;
  19403. }
  19404. if (this.y !== other.y) {
  19405. return false;
  19406. }
  19407. return true;
  19408. } else if (arguments.length === 2) {
  19409. var c = arguments[0];
  19410. var tolerance = arguments[1];
  19411. if (!NumberUtil.equalsWithTolerance(this.x, c.x, tolerance)) {
  19412. return false;
  19413. }
  19414. if (!NumberUtil.equalsWithTolerance(this.y, c.y, tolerance)) {
  19415. return false;
  19416. }
  19417. return true;
  19418. }
  19419. };
  19420. Coordinate.prototype.getOrdinate = function getOrdinate(ordinateIndex) {
  19421. switch (ordinateIndex) {
  19422. case Coordinate.X:
  19423. return this.x;
  19424. case Coordinate.Y:
  19425. return this.y;
  19426. case Coordinate.Z:
  19427. return this.z;
  19428. default:
  19429. }
  19430. throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex);
  19431. };
  19432. Coordinate.prototype.equals3D = function equals3D(other) {
  19433. return this.x === other.x && this.y === other.y && ((this.z === other.z || Double.isNaN(this.z)) && Double.isNaN(other.z));
  19434. };
  19435. Coordinate.prototype.equals = function equals2(other) {
  19436. if (!(other instanceof Coordinate)) {
  19437. return false;
  19438. }
  19439. return this.equals2D(other);
  19440. };
  19441. Coordinate.prototype.equalInZ = function equalInZ(c, tolerance) {
  19442. return NumberUtil.equalsWithTolerance(this.z, c.z, tolerance);
  19443. };
  19444. Coordinate.prototype.compareTo = function compareTo(o) {
  19445. var other = o;
  19446. if (this.x < other.x) {
  19447. return -1;
  19448. }
  19449. if (this.x > other.x) {
  19450. return 1;
  19451. }
  19452. if (this.y < other.y) {
  19453. return -1;
  19454. }
  19455. if (this.y > other.y) {
  19456. return 1;
  19457. }
  19458. return 0;
  19459. };
  19460. Coordinate.prototype.clone = function clone2() {
  19461. };
  19462. Coordinate.prototype.copy = function copy() {
  19463. return new Coordinate(this);
  19464. };
  19465. Coordinate.prototype.toString = function toString() {
  19466. return "(" + this.x + ", " + this.y + ", " + this.z + ")";
  19467. };
  19468. Coordinate.prototype.distance3D = function distance3D(c) {
  19469. var dx = this.x - c.x;
  19470. var dy = this.y - c.y;
  19471. var dz = this.z - c.z;
  19472. return Math.sqrt(dx * dx + dy * dy + dz * dz);
  19473. };
  19474. Coordinate.prototype.distance = function distance2(c) {
  19475. var dx = this.x - c.x;
  19476. var dy = this.y - c.y;
  19477. return Math.sqrt(dx * dx + dy * dy);
  19478. };
  19479. Coordinate.prototype.hashCode = function hashCode() {
  19480. var result = 17;
  19481. result = 37 * result + Coordinate.hashCode(this.x);
  19482. result = 37 * result + Coordinate.hashCode(this.y);
  19483. return result;
  19484. };
  19485. Coordinate.prototype.setCoordinate = function setCoordinate(other) {
  19486. this.x = other.x;
  19487. this.y = other.y;
  19488. this.z = other.z;
  19489. };
  19490. Coordinate.prototype.interfaces_ = function interfaces_2() {
  19491. return [Comparable, Clonable, Serializable];
  19492. };
  19493. Coordinate.prototype.getClass = function getClass2() {
  19494. return Coordinate;
  19495. };
  19496. Coordinate.hashCode = function hashCode2() {
  19497. if (arguments.length === 1) {
  19498. var x2 = arguments[0];
  19499. var f = Double.doubleToLongBits(x2);
  19500. return Math.trunc((f ^ f) >>> 32);
  19501. }
  19502. };
  19503. staticAccessors.DimensionalComparator.get = function() {
  19504. return DimensionalComparator;
  19505. };
  19506. staticAccessors.serialVersionUID.get = function() {
  19507. return 6683108902428367e3;
  19508. };
  19509. staticAccessors.NULL_ORDINATE.get = function() {
  19510. return Double.NaN;
  19511. };
  19512. staticAccessors.X.get = function() {
  19513. return 0;
  19514. };
  19515. staticAccessors.Y.get = function() {
  19516. return 1;
  19517. };
  19518. staticAccessors.Z.get = function() {
  19519. return 2;
  19520. };
  19521. Object.defineProperties(Coordinate, staticAccessors);
  19522. var DimensionalComparator = function DimensionalComparator2(dimensionsToTest) {
  19523. this._dimensionsToTest = 2;
  19524. if (arguments.length === 0) {
  19525. } else if (arguments.length === 1) {
  19526. var dimensionsToTest$1 = arguments[0];
  19527. if (dimensionsToTest$1 !== 2 && dimensionsToTest$1 !== 3) {
  19528. throw new IllegalArgumentException("only 2 or 3 dimensions may be specified");
  19529. }
  19530. this._dimensionsToTest = dimensionsToTest$1;
  19531. }
  19532. };
  19533. DimensionalComparator.prototype.compare = function compare(o1, o2) {
  19534. var c1 = o1;
  19535. var c2 = o2;
  19536. var compX = DimensionalComparator.compare(c1.x, c2.x);
  19537. if (compX !== 0) {
  19538. return compX;
  19539. }
  19540. var compY = DimensionalComparator.compare(c1.y, c2.y);
  19541. if (compY !== 0) {
  19542. return compY;
  19543. }
  19544. if (this._dimensionsToTest <= 2) {
  19545. return 0;
  19546. }
  19547. var compZ = DimensionalComparator.compare(c1.z, c2.z);
  19548. return compZ;
  19549. };
  19550. DimensionalComparator.prototype.interfaces_ = function interfaces_3() {
  19551. return [Comparator];
  19552. };
  19553. DimensionalComparator.prototype.getClass = function getClass3() {
  19554. return DimensionalComparator;
  19555. };
  19556. DimensionalComparator.compare = function compare2(a, b) {
  19557. if (a < b) {
  19558. return -1;
  19559. }
  19560. if (a > b) {
  19561. return 1;
  19562. }
  19563. if (Double.isNaN(a)) {
  19564. if (Double.isNaN(b)) {
  19565. return 0;
  19566. }
  19567. return -1;
  19568. }
  19569. if (Double.isNaN(b)) {
  19570. return 1;
  19571. }
  19572. return 0;
  19573. };
  19574. var CoordinateSequenceFactory = function CoordinateSequenceFactory2() {
  19575. };
  19576. CoordinateSequenceFactory.prototype.create = function create() {
  19577. };
  19578. CoordinateSequenceFactory.prototype.interfaces_ = function interfaces_4() {
  19579. return [];
  19580. };
  19581. CoordinateSequenceFactory.prototype.getClass = function getClass4() {
  19582. return CoordinateSequenceFactory;
  19583. };
  19584. var Location = function Location2() {
  19585. };
  19586. var staticAccessors$4 = { INTERIOR: { configurable: true }, BOUNDARY: { configurable: true }, EXTERIOR: { configurable: true }, NONE: { configurable: true } };
  19587. Location.prototype.interfaces_ = function interfaces_5() {
  19588. return [];
  19589. };
  19590. Location.prototype.getClass = function getClass5() {
  19591. return Location;
  19592. };
  19593. Location.toLocationSymbol = function toLocationSymbol(locationValue) {
  19594. switch (locationValue) {
  19595. case Location.EXTERIOR:
  19596. return "e";
  19597. case Location.BOUNDARY:
  19598. return "b";
  19599. case Location.INTERIOR:
  19600. return "i";
  19601. case Location.NONE:
  19602. return "-";
  19603. default:
  19604. }
  19605. throw new IllegalArgumentException("Unknown location value: " + locationValue);
  19606. };
  19607. staticAccessors$4.INTERIOR.get = function() {
  19608. return 0;
  19609. };
  19610. staticAccessors$4.BOUNDARY.get = function() {
  19611. return 1;
  19612. };
  19613. staticAccessors$4.EXTERIOR.get = function() {
  19614. return 2;
  19615. };
  19616. staticAccessors$4.NONE.get = function() {
  19617. return -1;
  19618. };
  19619. Object.defineProperties(Location, staticAccessors$4);
  19620. var hasInterface = function(o, i) {
  19621. return o.interfaces_ && o.interfaces_().indexOf(i) > -1;
  19622. };
  19623. var MathUtil = function MathUtil2() {
  19624. };
  19625. var staticAccessors$5 = { LOG_10: { configurable: true } };
  19626. MathUtil.prototype.interfaces_ = function interfaces_6() {
  19627. return [];
  19628. };
  19629. MathUtil.prototype.getClass = function getClass6() {
  19630. return MathUtil;
  19631. };
  19632. MathUtil.log10 = function log10(x2) {
  19633. var ln = Math.log(x2);
  19634. if (Double.isInfinite(ln)) {
  19635. return ln;
  19636. }
  19637. if (Double.isNaN(ln)) {
  19638. return ln;
  19639. }
  19640. return ln / MathUtil.LOG_10;
  19641. };
  19642. MathUtil.min = function min(v1, v2, v3, v4) {
  19643. var min4 = v1;
  19644. if (v2 < min4) {
  19645. min4 = v2;
  19646. }
  19647. if (v3 < min4) {
  19648. min4 = v3;
  19649. }
  19650. if (v4 < min4) {
  19651. min4 = v4;
  19652. }
  19653. return min4;
  19654. };
  19655. MathUtil.clamp = function clamp() {
  19656. if (typeof arguments[2] === "number" && (typeof arguments[0] === "number" && typeof arguments[1] === "number")) {
  19657. var x2 = arguments[0];
  19658. var min4 = arguments[1];
  19659. var max3 = arguments[2];
  19660. if (x2 < min4) {
  19661. return min4;
  19662. }
  19663. if (x2 > max3) {
  19664. return max3;
  19665. }
  19666. return x2;
  19667. } else if (Number.isInteger(arguments[2]) && (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1]))) {
  19668. var x$1 = arguments[0];
  19669. var min$1 = arguments[1];
  19670. var max$1 = arguments[2];
  19671. if (x$1 < min$1) {
  19672. return min$1;
  19673. }
  19674. if (x$1 > max$1) {
  19675. return max$1;
  19676. }
  19677. return x$1;
  19678. }
  19679. };
  19680. MathUtil.wrap = function wrap(index2, max3) {
  19681. if (index2 < 0) {
  19682. return max3 - -index2 % max3;
  19683. }
  19684. return index2 % max3;
  19685. };
  19686. MathUtil.max = function max() {
  19687. if (arguments.length === 3) {
  19688. var v1 = arguments[0];
  19689. var v2 = arguments[1];
  19690. var v3 = arguments[2];
  19691. var max3 = v1;
  19692. if (v2 > max3) {
  19693. max3 = v2;
  19694. }
  19695. if (v3 > max3) {
  19696. max3 = v3;
  19697. }
  19698. return max3;
  19699. } else if (arguments.length === 4) {
  19700. var v1$1 = arguments[0];
  19701. var v2$1 = arguments[1];
  19702. var v3$1 = arguments[2];
  19703. var v4 = arguments[3];
  19704. var max$1 = v1$1;
  19705. if (v2$1 > max$1) {
  19706. max$1 = v2$1;
  19707. }
  19708. if (v3$1 > max$1) {
  19709. max$1 = v3$1;
  19710. }
  19711. if (v4 > max$1) {
  19712. max$1 = v4;
  19713. }
  19714. return max$1;
  19715. }
  19716. };
  19717. MathUtil.average = function average(x12, x2) {
  19718. return (x12 + x2) / 2;
  19719. };
  19720. staticAccessors$5.LOG_10.get = function() {
  19721. return Math.log(10);
  19722. };
  19723. Object.defineProperties(MathUtil, staticAccessors$5);
  19724. var StringBuffer = function StringBuffer2(str) {
  19725. this.str = str;
  19726. };
  19727. StringBuffer.prototype.append = function append(e) {
  19728. this.str += e;
  19729. };
  19730. StringBuffer.prototype.setCharAt = function setCharAt(i, c) {
  19731. this.str = this.str.substr(0, i) + c + this.str.substr(i + 1);
  19732. };
  19733. StringBuffer.prototype.toString = function toString2(e) {
  19734. return this.str;
  19735. };
  19736. var Integer = function Integer2(value) {
  19737. this.value = value;
  19738. };
  19739. Integer.prototype.intValue = function intValue() {
  19740. return this.value;
  19741. };
  19742. Integer.prototype.compareTo = function compareTo2(o) {
  19743. if (this.value < o) {
  19744. return -1;
  19745. }
  19746. if (this.value > o) {
  19747. return 1;
  19748. }
  19749. return 0;
  19750. };
  19751. Integer.isNaN = function isNaN3(n) {
  19752. return Number.isNaN(n);
  19753. };
  19754. var Character = function Character2() {
  19755. };
  19756. Character.isWhitespace = function isWhitespace(c) {
  19757. return c <= 32 && c >= 0 || c === 127;
  19758. };
  19759. Character.toUpperCase = function toUpperCase(c) {
  19760. return c.toUpperCase();
  19761. };
  19762. var DD = function DD2() {
  19763. this._hi = 0;
  19764. this._lo = 0;
  19765. if (arguments.length === 0) {
  19766. this.init(0);
  19767. } else if (arguments.length === 1) {
  19768. if (typeof arguments[0] === "number") {
  19769. var x2 = arguments[0];
  19770. this.init(x2);
  19771. } else if (arguments[0] instanceof DD2) {
  19772. var dd = arguments[0];
  19773. this.init(dd);
  19774. } else if (typeof arguments[0] === "string") {
  19775. var str = arguments[0];
  19776. DD2.call(this, DD2.parse(str));
  19777. }
  19778. } else if (arguments.length === 2) {
  19779. var hi = arguments[0];
  19780. var lo = arguments[1];
  19781. this.init(hi, lo);
  19782. }
  19783. };
  19784. var staticAccessors$7 = { PI: { configurable: true }, TWO_PI: { configurable: true }, PI_2: { configurable: true }, E: { configurable: true }, NaN: { configurable: true }, EPS: { configurable: true }, SPLIT: { configurable: true }, MAX_PRINT_DIGITS: { configurable: true }, TEN: { configurable: true }, ONE: { configurable: true }, SCI_NOT_EXPONENT_CHAR: { configurable: true }, SCI_NOT_ZERO: { configurable: true } };
  19785. DD.prototype.le = function le(y2) {
  19786. return (this._hi < y2._hi || this._hi === y2._hi) && this._lo <= y2._lo;
  19787. };
  19788. DD.prototype.extractSignificantDigits = function extractSignificantDigits(insertDecimalPoint, magnitude2) {
  19789. var y2 = this.abs();
  19790. var mag = DD.magnitude(y2._hi);
  19791. var scale4 = DD.TEN.pow(mag);
  19792. y2 = y2.divide(scale4);
  19793. if (y2.gt(DD.TEN)) {
  19794. y2 = y2.divide(DD.TEN);
  19795. mag += 1;
  19796. } else if (y2.lt(DD.ONE)) {
  19797. y2 = y2.multiply(DD.TEN);
  19798. mag -= 1;
  19799. }
  19800. var decimalPointPos = mag + 1;
  19801. var buf = new StringBuffer();
  19802. var numDigits = DD.MAX_PRINT_DIGITS - 1;
  19803. for (var i = 0; i <= numDigits; i++) {
  19804. if (insertDecimalPoint && i === decimalPointPos) {
  19805. buf.append(".");
  19806. }
  19807. var digit = Math.trunc(y2._hi);
  19808. if (digit < 0) {
  19809. break;
  19810. }
  19811. var rebiasBy10 = false;
  19812. var digitChar = 0;
  19813. if (digit > 9) {
  19814. rebiasBy10 = true;
  19815. digitChar = "9";
  19816. } else {
  19817. digitChar = "0" + digit;
  19818. }
  19819. buf.append(digitChar);
  19820. y2 = y2.subtract(DD.valueOf(digit)).multiply(DD.TEN);
  19821. if (rebiasBy10) {
  19822. y2.selfAdd(DD.TEN);
  19823. }
  19824. var continueExtractingDigits = true;
  19825. var remMag = DD.magnitude(y2._hi);
  19826. if (remMag < 0 && Math.abs(remMag) >= numDigits - i) {
  19827. continueExtractingDigits = false;
  19828. }
  19829. if (!continueExtractingDigits) {
  19830. break;
  19831. }
  19832. }
  19833. magnitude2[0] = mag;
  19834. return buf.toString();
  19835. };
  19836. DD.prototype.sqr = function sqr() {
  19837. return this.multiply(this);
  19838. };
  19839. DD.prototype.doubleValue = function doubleValue() {
  19840. return this._hi + this._lo;
  19841. };
  19842. DD.prototype.subtract = function subtract() {
  19843. if (arguments[0] instanceof DD) {
  19844. var y2 = arguments[0];
  19845. return this.add(y2.negate());
  19846. } else if (typeof arguments[0] === "number") {
  19847. var y$1 = arguments[0];
  19848. return this.add(-y$1);
  19849. }
  19850. };
  19851. DD.prototype.equals = function equals3() {
  19852. if (arguments.length === 1) {
  19853. var y2 = arguments[0];
  19854. return this._hi === y2._hi && this._lo === y2._lo;
  19855. }
  19856. };
  19857. DD.prototype.isZero = function isZero() {
  19858. return this._hi === 0 && this._lo === 0;
  19859. };
  19860. DD.prototype.selfSubtract = function selfSubtract() {
  19861. if (arguments[0] instanceof DD) {
  19862. var y2 = arguments[0];
  19863. if (this.isNaN()) {
  19864. return this;
  19865. }
  19866. return this.selfAdd(-y2._hi, -y2._lo);
  19867. } else if (typeof arguments[0] === "number") {
  19868. var y$1 = arguments[0];
  19869. if (this.isNaN()) {
  19870. return this;
  19871. }
  19872. return this.selfAdd(-y$1, 0);
  19873. }
  19874. };
  19875. DD.prototype.getSpecialNumberString = function getSpecialNumberString() {
  19876. if (this.isZero()) {
  19877. return "0.0";
  19878. }
  19879. if (this.isNaN()) {
  19880. return "NaN ";
  19881. }
  19882. return null;
  19883. };
  19884. DD.prototype.min = function min2(x2) {
  19885. if (this.le(x2)) {
  19886. return this;
  19887. } else {
  19888. return x2;
  19889. }
  19890. };
  19891. DD.prototype.selfDivide = function selfDivide() {
  19892. if (arguments.length === 1) {
  19893. if (arguments[0] instanceof DD) {
  19894. var y2 = arguments[0];
  19895. return this.selfDivide(y2._hi, y2._lo);
  19896. } else if (typeof arguments[0] === "number") {
  19897. var y$1 = arguments[0];
  19898. return this.selfDivide(y$1, 0);
  19899. }
  19900. } else if (arguments.length === 2) {
  19901. var yhi = arguments[0];
  19902. var ylo = arguments[1];
  19903. var hc = null;
  19904. var tc = null;
  19905. var hy = null;
  19906. var ty = null;
  19907. var C = null;
  19908. var c = null;
  19909. var U = null;
  19910. var u = null;
  19911. C = this._hi / yhi;
  19912. c = DD.SPLIT * C;
  19913. hc = c - C;
  19914. u = DD.SPLIT * yhi;
  19915. hc = c - hc;
  19916. tc = C - hc;
  19917. hy = u - yhi;
  19918. U = C * yhi;
  19919. hy = u - hy;
  19920. ty = yhi - hy;
  19921. u = hc * hy - U + hc * ty + tc * hy + tc * ty;
  19922. c = (this._hi - U - u + this._lo - C * ylo) / yhi;
  19923. u = C + c;
  19924. this._hi = u;
  19925. this._lo = C - u + c;
  19926. return this;
  19927. }
  19928. };
  19929. DD.prototype.dump = function dump() {
  19930. return "DD<" + this._hi + ", " + this._lo + ">";
  19931. };
  19932. DD.prototype.divide = function divide() {
  19933. if (arguments[0] instanceof DD) {
  19934. var y2 = arguments[0];
  19935. var hc = null;
  19936. var tc = null;
  19937. var hy = null;
  19938. var ty = null;
  19939. var C = null;
  19940. var c = null;
  19941. var U = null;
  19942. var u = null;
  19943. C = this._hi / y2._hi;
  19944. c = DD.SPLIT * C;
  19945. hc = c - C;
  19946. u = DD.SPLIT * y2._hi;
  19947. hc = c - hc;
  19948. tc = C - hc;
  19949. hy = u - y2._hi;
  19950. U = C * y2._hi;
  19951. hy = u - hy;
  19952. ty = y2._hi - hy;
  19953. u = hc * hy - U + hc * ty + tc * hy + tc * ty;
  19954. c = (this._hi - U - u + this._lo - C * y2._lo) / y2._hi;
  19955. u = C + c;
  19956. var zhi = u;
  19957. var zlo = C - u + c;
  19958. return new DD(zhi, zlo);
  19959. } else if (typeof arguments[0] === "number") {
  19960. var y$1 = arguments[0];
  19961. if (Double.isNaN(y$1)) {
  19962. return DD.createNaN();
  19963. }
  19964. return DD.copy(this).selfDivide(y$1, 0);
  19965. }
  19966. };
  19967. DD.prototype.ge = function ge(y2) {
  19968. return (this._hi > y2._hi || this._hi === y2._hi) && this._lo >= y2._lo;
  19969. };
  19970. DD.prototype.pow = function pow(exp2) {
  19971. if (exp2 === 0) {
  19972. return DD.valueOf(1);
  19973. }
  19974. var r = new DD(this);
  19975. var s = DD.valueOf(1);
  19976. var n = Math.abs(exp2);
  19977. if (n > 1) {
  19978. while (n > 0) {
  19979. if (n % 2 === 1) {
  19980. s.selfMultiply(r);
  19981. }
  19982. n /= 2;
  19983. if (n > 0) {
  19984. r = r.sqr();
  19985. }
  19986. }
  19987. } else {
  19988. s = r;
  19989. }
  19990. if (exp2 < 0) {
  19991. return s.reciprocal();
  19992. }
  19993. return s;
  19994. };
  19995. DD.prototype.ceil = function ceil() {
  19996. if (this.isNaN()) {
  19997. return DD.NaN;
  19998. }
  19999. var fhi = Math.ceil(this._hi);
  20000. var flo = 0;
  20001. if (fhi === this._hi) {
  20002. flo = Math.ceil(this._lo);
  20003. }
  20004. return new DD(fhi, flo);
  20005. };
  20006. DD.prototype.compareTo = function compareTo3(o) {
  20007. var other = o;
  20008. if (this._hi < other._hi) {
  20009. return -1;
  20010. }
  20011. if (this._hi > other._hi) {
  20012. return 1;
  20013. }
  20014. if (this._lo < other._lo) {
  20015. return -1;
  20016. }
  20017. if (this._lo > other._lo) {
  20018. return 1;
  20019. }
  20020. return 0;
  20021. };
  20022. DD.prototype.rint = function rint() {
  20023. if (this.isNaN()) {
  20024. return this;
  20025. }
  20026. var plus5 = this.add(0.5);
  20027. return plus5.floor();
  20028. };
  20029. DD.prototype.setValue = function setValue() {
  20030. if (arguments[0] instanceof DD) {
  20031. var value = arguments[0];
  20032. this.init(value);
  20033. return this;
  20034. } else if (typeof arguments[0] === "number") {
  20035. var value$1 = arguments[0];
  20036. this.init(value$1);
  20037. return this;
  20038. }
  20039. };
  20040. DD.prototype.max = function max2(x2) {
  20041. if (this.ge(x2)) {
  20042. return this;
  20043. } else {
  20044. return x2;
  20045. }
  20046. };
  20047. DD.prototype.sqrt = function sqrt() {
  20048. if (this.isZero()) {
  20049. return DD.valueOf(0);
  20050. }
  20051. if (this.isNegative()) {
  20052. return DD.NaN;
  20053. }
  20054. var x2 = 1 / Math.sqrt(this._hi);
  20055. var ax = this._hi * x2;
  20056. var axdd = DD.valueOf(ax);
  20057. var diffSq = this.subtract(axdd.sqr());
  20058. var d2 = diffSq._hi * (x2 * 0.5);
  20059. return axdd.add(d2);
  20060. };
  20061. DD.prototype.selfAdd = function selfAdd() {
  20062. if (arguments.length === 1) {
  20063. if (arguments[0] instanceof DD) {
  20064. var y2 = arguments[0];
  20065. return this.selfAdd(y2._hi, y2._lo);
  20066. } else if (typeof arguments[0] === "number") {
  20067. var y$1 = arguments[0];
  20068. var H = null;
  20069. var h = null;
  20070. var S = null;
  20071. var s = null;
  20072. var e = null;
  20073. var f = null;
  20074. S = this._hi + y$1;
  20075. e = S - this._hi;
  20076. s = S - e;
  20077. s = y$1 - e + (this._hi - s);
  20078. f = s + this._lo;
  20079. H = S + f;
  20080. h = f + (S - H);
  20081. this._hi = H + h;
  20082. this._lo = h + (H - this._hi);
  20083. return this;
  20084. }
  20085. } else if (arguments.length === 2) {
  20086. var yhi = arguments[0];
  20087. var ylo = arguments[1];
  20088. var H$1 = null;
  20089. var h$1 = null;
  20090. var T = null;
  20091. var t = null;
  20092. var S$1 = null;
  20093. var s$1 = null;
  20094. var e$1 = null;
  20095. var f$1 = null;
  20096. S$1 = this._hi + yhi;
  20097. T = this._lo + ylo;
  20098. e$1 = S$1 - this._hi;
  20099. f$1 = T - this._lo;
  20100. s$1 = S$1 - e$1;
  20101. t = T - f$1;
  20102. s$1 = yhi - e$1 + (this._hi - s$1);
  20103. t = ylo - f$1 + (this._lo - t);
  20104. e$1 = s$1 + T;
  20105. H$1 = S$1 + e$1;
  20106. h$1 = e$1 + (S$1 - H$1);
  20107. e$1 = t + h$1;
  20108. var zhi = H$1 + e$1;
  20109. var zlo = e$1 + (H$1 - zhi);
  20110. this._hi = zhi;
  20111. this._lo = zlo;
  20112. return this;
  20113. }
  20114. };
  20115. DD.prototype.selfMultiply = function selfMultiply() {
  20116. if (arguments.length === 1) {
  20117. if (arguments[0] instanceof DD) {
  20118. var y2 = arguments[0];
  20119. return this.selfMultiply(y2._hi, y2._lo);
  20120. } else if (typeof arguments[0] === "number") {
  20121. var y$1 = arguments[0];
  20122. return this.selfMultiply(y$1, 0);
  20123. }
  20124. } else if (arguments.length === 2) {
  20125. var yhi = arguments[0];
  20126. var ylo = arguments[1];
  20127. var hx = null;
  20128. var tx = null;
  20129. var hy = null;
  20130. var ty = null;
  20131. var C = null;
  20132. var c = null;
  20133. C = DD.SPLIT * this._hi;
  20134. hx = C - this._hi;
  20135. c = DD.SPLIT * yhi;
  20136. hx = C - hx;
  20137. tx = this._hi - hx;
  20138. hy = c - yhi;
  20139. C = this._hi * yhi;
  20140. hy = c - hy;
  20141. ty = yhi - hy;
  20142. c = hx * hy - C + hx * ty + tx * hy + tx * ty + (this._hi * ylo + this._lo * yhi);
  20143. var zhi = C + c;
  20144. hx = C - zhi;
  20145. var zlo = c + hx;
  20146. this._hi = zhi;
  20147. this._lo = zlo;
  20148. return this;
  20149. }
  20150. };
  20151. DD.prototype.selfSqr = function selfSqr() {
  20152. return this.selfMultiply(this);
  20153. };
  20154. DD.prototype.floor = function floor() {
  20155. if (this.isNaN()) {
  20156. return DD.NaN;
  20157. }
  20158. var fhi = Math.floor(this._hi);
  20159. var flo = 0;
  20160. if (fhi === this._hi) {
  20161. flo = Math.floor(this._lo);
  20162. }
  20163. return new DD(fhi, flo);
  20164. };
  20165. DD.prototype.negate = function negate() {
  20166. if (this.isNaN()) {
  20167. return this;
  20168. }
  20169. return new DD(-this._hi, -this._lo);
  20170. };
  20171. DD.prototype.clone = function clone3() {
  20172. };
  20173. DD.prototype.multiply = function multiply() {
  20174. if (arguments[0] instanceof DD) {
  20175. var y2 = arguments[0];
  20176. if (y2.isNaN()) {
  20177. return DD.createNaN();
  20178. }
  20179. return DD.copy(this).selfMultiply(y2);
  20180. } else if (typeof arguments[0] === "number") {
  20181. var y$1 = arguments[0];
  20182. if (Double.isNaN(y$1)) {
  20183. return DD.createNaN();
  20184. }
  20185. return DD.copy(this).selfMultiply(y$1, 0);
  20186. }
  20187. };
  20188. DD.prototype.isNaN = function isNaN4() {
  20189. return Double.isNaN(this._hi);
  20190. };
  20191. DD.prototype.intValue = function intValue2() {
  20192. return Math.trunc(this._hi);
  20193. };
  20194. DD.prototype.toString = function toString3() {
  20195. var mag = DD.magnitude(this._hi);
  20196. if (mag >= -3 && mag <= 20) {
  20197. return this.toStandardNotation();
  20198. }
  20199. return this.toSciNotation();
  20200. };
  20201. DD.prototype.toStandardNotation = function toStandardNotation() {
  20202. var specialStr = this.getSpecialNumberString();
  20203. if (specialStr !== null) {
  20204. return specialStr;
  20205. }
  20206. var magnitude2 = new Array(1).fill(null);
  20207. var sigDigits = this.extractSignificantDigits(true, magnitude2);
  20208. var decimalPointPos = magnitude2[0] + 1;
  20209. var num = sigDigits;
  20210. if (sigDigits.charAt(0) === ".") {
  20211. num = "0" + sigDigits;
  20212. } else if (decimalPointPos < 0) {
  20213. num = "0." + DD.stringOfChar("0", -decimalPointPos) + sigDigits;
  20214. } else if (sigDigits.indexOf(".") === -1) {
  20215. var numZeroes = decimalPointPos - sigDigits.length;
  20216. var zeroes = DD.stringOfChar("0", numZeroes);
  20217. num = sigDigits + zeroes + ".0";
  20218. }
  20219. if (this.isNegative()) {
  20220. return "-" + num;
  20221. }
  20222. return num;
  20223. };
  20224. DD.prototype.reciprocal = function reciprocal() {
  20225. var hc = null;
  20226. var tc = null;
  20227. var hy = null;
  20228. var ty = null;
  20229. var C = null;
  20230. var c = null;
  20231. var U = null;
  20232. var u = null;
  20233. C = 1 / this._hi;
  20234. c = DD.SPLIT * C;
  20235. hc = c - C;
  20236. u = DD.SPLIT * this._hi;
  20237. hc = c - hc;
  20238. tc = C - hc;
  20239. hy = u - this._hi;
  20240. U = C * this._hi;
  20241. hy = u - hy;
  20242. ty = this._hi - hy;
  20243. u = hc * hy - U + hc * ty + tc * hy + tc * ty;
  20244. c = (1 - U - u - C * this._lo) / this._hi;
  20245. var zhi = C + c;
  20246. var zlo = C - zhi + c;
  20247. return new DD(zhi, zlo);
  20248. };
  20249. DD.prototype.toSciNotation = function toSciNotation() {
  20250. if (this.isZero()) {
  20251. return DD.SCI_NOT_ZERO;
  20252. }
  20253. var specialStr = this.getSpecialNumberString();
  20254. if (specialStr !== null) {
  20255. return specialStr;
  20256. }
  20257. var magnitude2 = new Array(1).fill(null);
  20258. var digits = this.extractSignificantDigits(false, magnitude2);
  20259. var expStr = DD.SCI_NOT_EXPONENT_CHAR + magnitude2[0];
  20260. if (digits.charAt(0) === "0") {
  20261. throw new Error("Found leading zero: " + digits);
  20262. }
  20263. var trailingDigits = "";
  20264. if (digits.length > 1) {
  20265. trailingDigits = digits.substring(1);
  20266. }
  20267. var digitsWithDecimal = digits.charAt(0) + "." + trailingDigits;
  20268. if (this.isNegative()) {
  20269. return "-" + digitsWithDecimal + expStr;
  20270. }
  20271. return digitsWithDecimal + expStr;
  20272. };
  20273. DD.prototype.abs = function abs() {
  20274. if (this.isNaN()) {
  20275. return DD.NaN;
  20276. }
  20277. if (this.isNegative()) {
  20278. return this.negate();
  20279. }
  20280. return new DD(this);
  20281. };
  20282. DD.prototype.isPositive = function isPositive() {
  20283. return (this._hi > 0 || this._hi === 0) && this._lo > 0;
  20284. };
  20285. DD.prototype.lt = function lt(y2) {
  20286. return (this._hi < y2._hi || this._hi === y2._hi) && this._lo < y2._lo;
  20287. };
  20288. DD.prototype.add = function add2() {
  20289. if (arguments[0] instanceof DD) {
  20290. var y2 = arguments[0];
  20291. return DD.copy(this).selfAdd(y2);
  20292. } else if (typeof arguments[0] === "number") {
  20293. var y$1 = arguments[0];
  20294. return DD.copy(this).selfAdd(y$1);
  20295. }
  20296. };
  20297. DD.prototype.init = function init() {
  20298. if (arguments.length === 1) {
  20299. if (typeof arguments[0] === "number") {
  20300. var x2 = arguments[0];
  20301. this._hi = x2;
  20302. this._lo = 0;
  20303. } else if (arguments[0] instanceof DD) {
  20304. var dd = arguments[0];
  20305. this._hi = dd._hi;
  20306. this._lo = dd._lo;
  20307. }
  20308. } else if (arguments.length === 2) {
  20309. var hi = arguments[0];
  20310. var lo = arguments[1];
  20311. this._hi = hi;
  20312. this._lo = lo;
  20313. }
  20314. };
  20315. DD.prototype.gt = function gt(y2) {
  20316. return (this._hi > y2._hi || this._hi === y2._hi) && this._lo > y2._lo;
  20317. };
  20318. DD.prototype.isNegative = function isNegative() {
  20319. return (this._hi < 0 || this._hi === 0) && this._lo < 0;
  20320. };
  20321. DD.prototype.trunc = function trunc() {
  20322. if (this.isNaN()) {
  20323. return DD.NaN;
  20324. }
  20325. if (this.isPositive()) {
  20326. return this.floor();
  20327. } else {
  20328. return this.ceil();
  20329. }
  20330. };
  20331. DD.prototype.signum = function signum() {
  20332. if (this._hi > 0) {
  20333. return 1;
  20334. }
  20335. if (this._hi < 0) {
  20336. return -1;
  20337. }
  20338. if (this._lo > 0) {
  20339. return 1;
  20340. }
  20341. if (this._lo < 0) {
  20342. return -1;
  20343. }
  20344. return 0;
  20345. };
  20346. DD.prototype.interfaces_ = function interfaces_7() {
  20347. return [Serializable, Comparable, Clonable];
  20348. };
  20349. DD.prototype.getClass = function getClass7() {
  20350. return DD;
  20351. };
  20352. DD.sqr = function sqr2(x2) {
  20353. return DD.valueOf(x2).selfMultiply(x2);
  20354. };
  20355. DD.valueOf = function valueOf() {
  20356. if (typeof arguments[0] === "string") {
  20357. var str = arguments[0];
  20358. return DD.parse(str);
  20359. } else if (typeof arguments[0] === "number") {
  20360. var x2 = arguments[0];
  20361. return new DD(x2);
  20362. }
  20363. };
  20364. DD.sqrt = function sqrt2(x2) {
  20365. return DD.valueOf(x2).sqrt();
  20366. };
  20367. DD.parse = function parse(str) {
  20368. var i = 0;
  20369. var strlen = str.length;
  20370. while (Character.isWhitespace(str.charAt(i))) {
  20371. i++;
  20372. }
  20373. var isNegative2 = false;
  20374. if (i < strlen) {
  20375. var signCh = str.charAt(i);
  20376. if (signCh === "-" || signCh === "+") {
  20377. i++;
  20378. if (signCh === "-") {
  20379. isNegative2 = true;
  20380. }
  20381. }
  20382. }
  20383. var val = new DD();
  20384. var numDigits = 0;
  20385. var numBeforeDec = 0;
  20386. var exp2 = 0;
  20387. while (true) {
  20388. if (i >= strlen) {
  20389. break;
  20390. }
  20391. var ch = str.charAt(i);
  20392. i++;
  20393. if (Character.isDigit(ch)) {
  20394. var d = ch - "0";
  20395. val.selfMultiply(DD.TEN);
  20396. val.selfAdd(d);
  20397. numDigits++;
  20398. continue;
  20399. }
  20400. if (ch === ".") {
  20401. numBeforeDec = numDigits;
  20402. continue;
  20403. }
  20404. if (ch === "e" || ch === "E") {
  20405. var expStr = str.substring(i);
  20406. try {
  20407. exp2 = Integer.parseInt(expStr);
  20408. } catch (ex) {
  20409. if (ex instanceof Error) {
  20410. throw new Error("Invalid exponent " + expStr + " in string " + str);
  20411. } else {
  20412. throw ex;
  20413. }
  20414. } finally {
  20415. }
  20416. break;
  20417. }
  20418. throw new Error("Unexpected character '" + ch + "' at position " + i + " in string " + str);
  20419. }
  20420. var val2 = val;
  20421. var numDecPlaces = numDigits - numBeforeDec - exp2;
  20422. if (numDecPlaces === 0) {
  20423. val2 = val;
  20424. } else if (numDecPlaces > 0) {
  20425. var scale4 = DD.TEN.pow(numDecPlaces);
  20426. val2 = val.divide(scale4);
  20427. } else if (numDecPlaces < 0) {
  20428. var scale$1 = DD.TEN.pow(-numDecPlaces);
  20429. val2 = val.multiply(scale$1);
  20430. }
  20431. if (isNegative2) {
  20432. return val2.negate();
  20433. }
  20434. return val2;
  20435. };
  20436. DD.createNaN = function createNaN() {
  20437. return new DD(Double.NaN, Double.NaN);
  20438. };
  20439. DD.copy = function copy2(dd) {
  20440. return new DD(dd);
  20441. };
  20442. DD.magnitude = function magnitude(x2) {
  20443. var xAbs = Math.abs(x2);
  20444. var xLog10 = Math.log(xAbs) / Math.log(10);
  20445. var xMag = Math.trunc(Math.floor(xLog10));
  20446. var xApprox = Math.pow(10, xMag);
  20447. if (xApprox * 10 <= xAbs) {
  20448. xMag += 1;
  20449. }
  20450. return xMag;
  20451. };
  20452. DD.stringOfChar = function stringOfChar(ch, len) {
  20453. var buf = new StringBuffer();
  20454. for (var i = 0; i < len; i++) {
  20455. buf.append(ch);
  20456. }
  20457. return buf.toString();
  20458. };
  20459. staticAccessors$7.PI.get = function() {
  20460. return new DD(3.141592653589793, 12246467991473532e-32);
  20461. };
  20462. staticAccessors$7.TWO_PI.get = function() {
  20463. return new DD(6.283185307179586, 24492935982947064e-32);
  20464. };
  20465. staticAccessors$7.PI_2.get = function() {
  20466. return new DD(1.5707963267948966, 6123233995736766e-32);
  20467. };
  20468. staticAccessors$7.E.get = function() {
  20469. return new DD(2.718281828459045, 14456468917292502e-32);
  20470. };
  20471. staticAccessors$7.NaN.get = function() {
  20472. return new DD(Double.NaN, Double.NaN);
  20473. };
  20474. staticAccessors$7.EPS.get = function() {
  20475. return 123259516440783e-46;
  20476. };
  20477. staticAccessors$7.SPLIT.get = function() {
  20478. return 134217729;
  20479. };
  20480. staticAccessors$7.MAX_PRINT_DIGITS.get = function() {
  20481. return 32;
  20482. };
  20483. staticAccessors$7.TEN.get = function() {
  20484. return DD.valueOf(10);
  20485. };
  20486. staticAccessors$7.ONE.get = function() {
  20487. return DD.valueOf(1);
  20488. };
  20489. staticAccessors$7.SCI_NOT_EXPONENT_CHAR.get = function() {
  20490. return "E";
  20491. };
  20492. staticAccessors$7.SCI_NOT_ZERO.get = function() {
  20493. return "0.0E0";
  20494. };
  20495. Object.defineProperties(DD, staticAccessors$7);
  20496. var CGAlgorithmsDD = function CGAlgorithmsDD2() {
  20497. };
  20498. var staticAccessors$6 = { DP_SAFE_EPSILON: { configurable: true } };
  20499. CGAlgorithmsDD.prototype.interfaces_ = function interfaces_8() {
  20500. return [];
  20501. };
  20502. CGAlgorithmsDD.prototype.getClass = function getClass8() {
  20503. return CGAlgorithmsDD;
  20504. };
  20505. CGAlgorithmsDD.orientationIndex = function orientationIndex2(p1, p2, q) {
  20506. var index2 = CGAlgorithmsDD.orientationIndexFilter(p1, p2, q);
  20507. if (index2 <= 1) {
  20508. return index2;
  20509. }
  20510. var dx1 = DD.valueOf(p2.x).selfAdd(-p1.x);
  20511. var dy1 = DD.valueOf(p2.y).selfAdd(-p1.y);
  20512. var dx2 = DD.valueOf(q.x).selfAdd(-p2.x);
  20513. var dy2 = DD.valueOf(q.y).selfAdd(-p2.y);
  20514. return dx1.selfMultiply(dy2).selfSubtract(dy1.selfMultiply(dx2)).signum();
  20515. };
  20516. CGAlgorithmsDD.signOfDet2x2 = function signOfDet2x2(x12, y12, x2, y2) {
  20517. var det2 = x12.multiply(y2).selfSubtract(y12.multiply(x2));
  20518. return det2.signum();
  20519. };
  20520. CGAlgorithmsDD.intersection = function intersection5(p1, p2, q1, q2) {
  20521. var denom1 = DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(DD.valueOf(p2.x).selfSubtract(p1.x));
  20522. var denom2 = DD.valueOf(q2.x).selfSubtract(q1.x).selfMultiply(DD.valueOf(p2.y).selfSubtract(p1.y));
  20523. var denom = denom1.subtract(denom2);
  20524. var numx1 = DD.valueOf(q2.x).selfSubtract(q1.x).selfMultiply(DD.valueOf(p1.y).selfSubtract(q1.y));
  20525. var numx2 = DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(DD.valueOf(p1.x).selfSubtract(q1.x));
  20526. var numx = numx1.subtract(numx2);
  20527. var fracP = numx.selfDivide(denom).doubleValue();
  20528. var x2 = DD.valueOf(p1.x).selfAdd(DD.valueOf(p2.x).selfSubtract(p1.x).selfMultiply(fracP)).doubleValue();
  20529. var numy1 = DD.valueOf(p2.x).selfSubtract(p1.x).selfMultiply(DD.valueOf(p1.y).selfSubtract(q1.y));
  20530. var numy2 = DD.valueOf(p2.y).selfSubtract(p1.y).selfMultiply(DD.valueOf(p1.x).selfSubtract(q1.x));
  20531. var numy = numy1.subtract(numy2);
  20532. var fracQ = numy.selfDivide(denom).doubleValue();
  20533. var y2 = DD.valueOf(q1.y).selfAdd(DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(fracQ)).doubleValue();
  20534. return new Coordinate(x2, y2);
  20535. };
  20536. CGAlgorithmsDD.orientationIndexFilter = function orientationIndexFilter(pa, pb, pc) {
  20537. var detsum = null;
  20538. var detleft = (pa.x - pc.x) * (pb.y - pc.y);
  20539. var detright = (pa.y - pc.y) * (pb.x - pc.x);
  20540. var det2 = detleft - detright;
  20541. if (detleft > 0) {
  20542. if (detright <= 0) {
  20543. return CGAlgorithmsDD.signum(det2);
  20544. } else {
  20545. detsum = detleft + detright;
  20546. }
  20547. } else if (detleft < 0) {
  20548. if (detright >= 0) {
  20549. return CGAlgorithmsDD.signum(det2);
  20550. } else {
  20551. detsum = -detleft - detright;
  20552. }
  20553. } else {
  20554. return CGAlgorithmsDD.signum(det2);
  20555. }
  20556. var errbound = CGAlgorithmsDD.DP_SAFE_EPSILON * detsum;
  20557. if (det2 >= errbound || -det2 >= errbound) {
  20558. return CGAlgorithmsDD.signum(det2);
  20559. }
  20560. return 2;
  20561. };
  20562. CGAlgorithmsDD.signum = function signum2(x2) {
  20563. if (x2 > 0) {
  20564. return 1;
  20565. }
  20566. if (x2 < 0) {
  20567. return -1;
  20568. }
  20569. return 0;
  20570. };
  20571. staticAccessors$6.DP_SAFE_EPSILON.get = function() {
  20572. return 1e-15;
  20573. };
  20574. Object.defineProperties(CGAlgorithmsDD, staticAccessors$6);
  20575. var CoordinateSequence = function CoordinateSequence2() {
  20576. };
  20577. var staticAccessors$8 = { X: { configurable: true }, Y: { configurable: true }, Z: { configurable: true }, M: { configurable: true } };
  20578. staticAccessors$8.X.get = function() {
  20579. return 0;
  20580. };
  20581. staticAccessors$8.Y.get = function() {
  20582. return 1;
  20583. };
  20584. staticAccessors$8.Z.get = function() {
  20585. return 2;
  20586. };
  20587. staticAccessors$8.M.get = function() {
  20588. return 3;
  20589. };
  20590. CoordinateSequence.prototype.setOrdinate = function setOrdinate2(index2, ordinateIndex, value) {
  20591. };
  20592. CoordinateSequence.prototype.size = function size() {
  20593. };
  20594. CoordinateSequence.prototype.getOrdinate = function getOrdinate2(index2, ordinateIndex) {
  20595. };
  20596. CoordinateSequence.prototype.getCoordinate = function getCoordinate() {
  20597. };
  20598. CoordinateSequence.prototype.getCoordinateCopy = function getCoordinateCopy(i) {
  20599. };
  20600. CoordinateSequence.prototype.getDimension = function getDimension() {
  20601. };
  20602. CoordinateSequence.prototype.getX = function getX(index2) {
  20603. };
  20604. CoordinateSequence.prototype.clone = function clone4() {
  20605. };
  20606. CoordinateSequence.prototype.expandEnvelope = function expandEnvelope(env) {
  20607. };
  20608. CoordinateSequence.prototype.copy = function copy3() {
  20609. };
  20610. CoordinateSequence.prototype.getY = function getY(index2) {
  20611. };
  20612. CoordinateSequence.prototype.toCoordinateArray = function toCoordinateArray() {
  20613. };
  20614. CoordinateSequence.prototype.interfaces_ = function interfaces_9() {
  20615. return [Clonable];
  20616. };
  20617. CoordinateSequence.prototype.getClass = function getClass9() {
  20618. return CoordinateSequence;
  20619. };
  20620. Object.defineProperties(CoordinateSequence, staticAccessors$8);
  20621. var Exception = function Exception2() {
  20622. };
  20623. var NotRepresentableException = function(Exception$$1) {
  20624. function NotRepresentableException2() {
  20625. Exception$$1.call(this, "Projective point not representable on the Cartesian plane.");
  20626. }
  20627. if (Exception$$1)
  20628. NotRepresentableException2.__proto__ = Exception$$1;
  20629. NotRepresentableException2.prototype = Object.create(Exception$$1 && Exception$$1.prototype);
  20630. NotRepresentableException2.prototype.constructor = NotRepresentableException2;
  20631. NotRepresentableException2.prototype.interfaces_ = function interfaces_170() {
  20632. return [];
  20633. };
  20634. NotRepresentableException2.prototype.getClass = function getClass169() {
  20635. return NotRepresentableException2;
  20636. };
  20637. return NotRepresentableException2;
  20638. }(Exception);
  20639. var System = function System2() {
  20640. };
  20641. System.arraycopy = function arraycopy(src, srcPos, dest, destPos, len) {
  20642. var c = 0;
  20643. for (var i = srcPos; i < srcPos + len; i++) {
  20644. dest[destPos + c] = src[i];
  20645. c++;
  20646. }
  20647. };
  20648. System.getProperty = function getProperty(name) {
  20649. return {
  20650. "line.separator": "\n"
  20651. }[name];
  20652. };
  20653. var HCoordinate = function HCoordinate2() {
  20654. this.x = null;
  20655. this.y = null;
  20656. this.w = null;
  20657. if (arguments.length === 0) {
  20658. this.x = 0;
  20659. this.y = 0;
  20660. this.w = 1;
  20661. } else if (arguments.length === 1) {
  20662. var p = arguments[0];
  20663. this.x = p.x;
  20664. this.y = p.y;
  20665. this.w = 1;
  20666. } else if (arguments.length === 2) {
  20667. if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
  20668. var _x = arguments[0];
  20669. var _y = arguments[1];
  20670. this.x = _x;
  20671. this.y = _y;
  20672. this.w = 1;
  20673. } else if (arguments[0] instanceof HCoordinate2 && arguments[1] instanceof HCoordinate2) {
  20674. var p1 = arguments[0];
  20675. var p2 = arguments[1];
  20676. this.x = p1.y * p2.w - p2.y * p1.w;
  20677. this.y = p2.x * p1.w - p1.x * p2.w;
  20678. this.w = p1.x * p2.y - p2.x * p1.y;
  20679. } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Coordinate) {
  20680. var p1$1 = arguments[0];
  20681. var p2$1 = arguments[1];
  20682. this.x = p1$1.y - p2$1.y;
  20683. this.y = p2$1.x - p1$1.x;
  20684. this.w = p1$1.x * p2$1.y - p2$1.x * p1$1.y;
  20685. }
  20686. } else if (arguments.length === 3) {
  20687. var _x$1 = arguments[0];
  20688. var _y$1 = arguments[1];
  20689. var _w = arguments[2];
  20690. this.x = _x$1;
  20691. this.y = _y$1;
  20692. this.w = _w;
  20693. } else if (arguments.length === 4) {
  20694. var p1$2 = arguments[0];
  20695. var p2$2 = arguments[1];
  20696. var q1 = arguments[2];
  20697. var q2 = arguments[3];
  20698. var px = p1$2.y - p2$2.y;
  20699. var py = p2$2.x - p1$2.x;
  20700. var pw = p1$2.x * p2$2.y - p2$2.x * p1$2.y;
  20701. var qx = q1.y - q2.y;
  20702. var qy = q2.x - q1.x;
  20703. var qw = q1.x * q2.y - q2.x * q1.y;
  20704. this.x = py * qw - qy * pw;
  20705. this.y = qx * pw - px * qw;
  20706. this.w = px * qy - qx * py;
  20707. }
  20708. };
  20709. HCoordinate.prototype.getY = function getY2() {
  20710. var a = this.y / this.w;
  20711. if (Double.isNaN(a) || Double.isInfinite(a)) {
  20712. throw new NotRepresentableException();
  20713. }
  20714. return a;
  20715. };
  20716. HCoordinate.prototype.getX = function getX2() {
  20717. var a = this.x / this.w;
  20718. if (Double.isNaN(a) || Double.isInfinite(a)) {
  20719. throw new NotRepresentableException();
  20720. }
  20721. return a;
  20722. };
  20723. HCoordinate.prototype.getCoordinate = function getCoordinate2() {
  20724. var p = new Coordinate();
  20725. p.x = this.getX();
  20726. p.y = this.getY();
  20727. return p;
  20728. };
  20729. HCoordinate.prototype.interfaces_ = function interfaces_10() {
  20730. return [];
  20731. };
  20732. HCoordinate.prototype.getClass = function getClass10() {
  20733. return HCoordinate;
  20734. };
  20735. HCoordinate.intersection = function intersection6(p1, p2, q1, q2) {
  20736. var px = p1.y - p2.y;
  20737. var py = p2.x - p1.x;
  20738. var pw = p1.x * p2.y - p2.x * p1.y;
  20739. var qx = q1.y - q2.y;
  20740. var qy = q2.x - q1.x;
  20741. var qw = q1.x * q2.y - q2.x * q1.y;
  20742. var x2 = py * qw - qy * pw;
  20743. var y2 = qx * pw - px * qw;
  20744. var w = px * qy - qx * py;
  20745. var xInt = x2 / w;
  20746. var yInt = y2 / w;
  20747. if (Double.isNaN(xInt) || (Double.isInfinite(xInt) || Double.isNaN(yInt)) || Double.isInfinite(yInt)) {
  20748. throw new NotRepresentableException();
  20749. }
  20750. return new Coordinate(xInt, yInt);
  20751. };
  20752. var Envelope = function Envelope2() {
  20753. this._minx = null;
  20754. this._maxx = null;
  20755. this._miny = null;
  20756. this._maxy = null;
  20757. if (arguments.length === 0) {
  20758. this.init();
  20759. } else if (arguments.length === 1) {
  20760. if (arguments[0] instanceof Coordinate) {
  20761. var p = arguments[0];
  20762. this.init(p.x, p.x, p.y, p.y);
  20763. } else if (arguments[0] instanceof Envelope2) {
  20764. var env = arguments[0];
  20765. this.init(env);
  20766. }
  20767. } else if (arguments.length === 2) {
  20768. var p1 = arguments[0];
  20769. var p2 = arguments[1];
  20770. this.init(p1.x, p2.x, p1.y, p2.y);
  20771. } else if (arguments.length === 4) {
  20772. var x12 = arguments[0];
  20773. var x2 = arguments[1];
  20774. var y12 = arguments[2];
  20775. var y2 = arguments[3];
  20776. this.init(x12, x2, y12, y2);
  20777. }
  20778. };
  20779. var staticAccessors$9 = { serialVersionUID: { configurable: true } };
  20780. Envelope.prototype.getArea = function getArea() {
  20781. return this.getWidth() * this.getHeight();
  20782. };
  20783. Envelope.prototype.equals = function equals4(other) {
  20784. if (!(other instanceof Envelope)) {
  20785. return false;
  20786. }
  20787. var otherEnvelope = other;
  20788. if (this.isNull()) {
  20789. return otherEnvelope.isNull();
  20790. }
  20791. return this._maxx === otherEnvelope.getMaxX() && this._maxy === otherEnvelope.getMaxY() && this._minx === otherEnvelope.getMinX() && this._miny === otherEnvelope.getMinY();
  20792. };
  20793. Envelope.prototype.intersection = function intersection7(env) {
  20794. if (this.isNull() || env.isNull() || !this.intersects(env)) {
  20795. return new Envelope();
  20796. }
  20797. var intMinX = this._minx > env._minx ? this._minx : env._minx;
  20798. var intMinY = this._miny > env._miny ? this._miny : env._miny;
  20799. var intMaxX = this._maxx < env._maxx ? this._maxx : env._maxx;
  20800. var intMaxY = this._maxy < env._maxy ? this._maxy : env._maxy;
  20801. return new Envelope(intMinX, intMaxX, intMinY, intMaxY);
  20802. };
  20803. Envelope.prototype.isNull = function isNull() {
  20804. return this._maxx < this._minx;
  20805. };
  20806. Envelope.prototype.getMaxX = function getMaxX() {
  20807. return this._maxx;
  20808. };
  20809. Envelope.prototype.covers = function covers() {
  20810. if (arguments.length === 1) {
  20811. if (arguments[0] instanceof Coordinate) {
  20812. var p = arguments[0];
  20813. return this.covers(p.x, p.y);
  20814. } else if (arguments[0] instanceof Envelope) {
  20815. var other = arguments[0];
  20816. if (this.isNull() || other.isNull()) {
  20817. return false;
  20818. }
  20819. return other.getMinX() >= this._minx && other.getMaxX() <= this._maxx && other.getMinY() >= this._miny && other.getMaxY() <= this._maxy;
  20820. }
  20821. } else if (arguments.length === 2) {
  20822. var x2 = arguments[0];
  20823. var y2 = arguments[1];
  20824. if (this.isNull()) {
  20825. return false;
  20826. }
  20827. return x2 >= this._minx && x2 <= this._maxx && y2 >= this._miny && y2 <= this._maxy;
  20828. }
  20829. };
  20830. Envelope.prototype.intersects = function intersects2() {
  20831. if (arguments.length === 1) {
  20832. if (arguments[0] instanceof Envelope) {
  20833. var other = arguments[0];
  20834. if (this.isNull() || other.isNull()) {
  20835. return false;
  20836. }
  20837. return !(other._minx > this._maxx || other._maxx < this._minx || other._miny > this._maxy || other._maxy < this._miny);
  20838. } else if (arguments[0] instanceof Coordinate) {
  20839. var p = arguments[0];
  20840. return this.intersects(p.x, p.y);
  20841. }
  20842. } else if (arguments.length === 2) {
  20843. var x2 = arguments[0];
  20844. var y2 = arguments[1];
  20845. if (this.isNull()) {
  20846. return false;
  20847. }
  20848. return !(x2 > this._maxx || x2 < this._minx || y2 > this._maxy || y2 < this._miny);
  20849. }
  20850. };
  20851. Envelope.prototype.getMinY = function getMinY() {
  20852. return this._miny;
  20853. };
  20854. Envelope.prototype.getMinX = function getMinX() {
  20855. return this._minx;
  20856. };
  20857. Envelope.prototype.expandToInclude = function expandToInclude() {
  20858. if (arguments.length === 1) {
  20859. if (arguments[0] instanceof Coordinate) {
  20860. var p = arguments[0];
  20861. this.expandToInclude(p.x, p.y);
  20862. } else if (arguments[0] instanceof Envelope) {
  20863. var other = arguments[0];
  20864. if (other.isNull()) {
  20865. return null;
  20866. }
  20867. if (this.isNull()) {
  20868. this._minx = other.getMinX();
  20869. this._maxx = other.getMaxX();
  20870. this._miny = other.getMinY();
  20871. this._maxy = other.getMaxY();
  20872. } else {
  20873. if (other._minx < this._minx) {
  20874. this._minx = other._minx;
  20875. }
  20876. if (other._maxx > this._maxx) {
  20877. this._maxx = other._maxx;
  20878. }
  20879. if (other._miny < this._miny) {
  20880. this._miny = other._miny;
  20881. }
  20882. if (other._maxy > this._maxy) {
  20883. this._maxy = other._maxy;
  20884. }
  20885. }
  20886. }
  20887. } else if (arguments.length === 2) {
  20888. var x2 = arguments[0];
  20889. var y2 = arguments[1];
  20890. if (this.isNull()) {
  20891. this._minx = x2;
  20892. this._maxx = x2;
  20893. this._miny = y2;
  20894. this._maxy = y2;
  20895. } else {
  20896. if (x2 < this._minx) {
  20897. this._minx = x2;
  20898. }
  20899. if (x2 > this._maxx) {
  20900. this._maxx = x2;
  20901. }
  20902. if (y2 < this._miny) {
  20903. this._miny = y2;
  20904. }
  20905. if (y2 > this._maxy) {
  20906. this._maxy = y2;
  20907. }
  20908. }
  20909. }
  20910. };
  20911. Envelope.prototype.minExtent = function minExtent() {
  20912. if (this.isNull()) {
  20913. return 0;
  20914. }
  20915. var w = this.getWidth();
  20916. var h = this.getHeight();
  20917. if (w < h) {
  20918. return w;
  20919. }
  20920. return h;
  20921. };
  20922. Envelope.prototype.getWidth = function getWidth() {
  20923. if (this.isNull()) {
  20924. return 0;
  20925. }
  20926. return this._maxx - this._minx;
  20927. };
  20928. Envelope.prototype.compareTo = function compareTo4(o) {
  20929. var env = o;
  20930. if (this.isNull()) {
  20931. if (env.isNull()) {
  20932. return 0;
  20933. }
  20934. return -1;
  20935. } else {
  20936. if (env.isNull()) {
  20937. return 1;
  20938. }
  20939. }
  20940. if (this._minx < env._minx) {
  20941. return -1;
  20942. }
  20943. if (this._minx > env._minx) {
  20944. return 1;
  20945. }
  20946. if (this._miny < env._miny) {
  20947. return -1;
  20948. }
  20949. if (this._miny > env._miny) {
  20950. return 1;
  20951. }
  20952. if (this._maxx < env._maxx) {
  20953. return -1;
  20954. }
  20955. if (this._maxx > env._maxx) {
  20956. return 1;
  20957. }
  20958. if (this._maxy < env._maxy) {
  20959. return -1;
  20960. }
  20961. if (this._maxy > env._maxy) {
  20962. return 1;
  20963. }
  20964. return 0;
  20965. };
  20966. Envelope.prototype.translate = function translate(transX, transY) {
  20967. if (this.isNull()) {
  20968. return null;
  20969. }
  20970. this.init(this.getMinX() + transX, this.getMaxX() + transX, this.getMinY() + transY, this.getMaxY() + transY);
  20971. };
  20972. Envelope.prototype.toString = function toString4() {
  20973. return "Env[" + this._minx + " : " + this._maxx + ", " + this._miny + " : " + this._maxy + "]";
  20974. };
  20975. Envelope.prototype.setToNull = function setToNull() {
  20976. this._minx = 0;
  20977. this._maxx = -1;
  20978. this._miny = 0;
  20979. this._maxy = -1;
  20980. };
  20981. Envelope.prototype.getHeight = function getHeight() {
  20982. if (this.isNull()) {
  20983. return 0;
  20984. }
  20985. return this._maxy - this._miny;
  20986. };
  20987. Envelope.prototype.maxExtent = function maxExtent() {
  20988. if (this.isNull()) {
  20989. return 0;
  20990. }
  20991. var w = this.getWidth();
  20992. var h = this.getHeight();
  20993. if (w > h) {
  20994. return w;
  20995. }
  20996. return h;
  20997. };
  20998. Envelope.prototype.expandBy = function expandBy() {
  20999. if (arguments.length === 1) {
  21000. var distance11 = arguments[0];
  21001. this.expandBy(distance11, distance11);
  21002. } else if (arguments.length === 2) {
  21003. var deltaX = arguments[0];
  21004. var deltaY = arguments[1];
  21005. if (this.isNull()) {
  21006. return null;
  21007. }
  21008. this._minx -= deltaX;
  21009. this._maxx += deltaX;
  21010. this._miny -= deltaY;
  21011. this._maxy += deltaY;
  21012. if (this._minx > this._maxx || this._miny > this._maxy) {
  21013. this.setToNull();
  21014. }
  21015. }
  21016. };
  21017. Envelope.prototype.contains = function contains() {
  21018. if (arguments.length === 1) {
  21019. if (arguments[0] instanceof Envelope) {
  21020. var other = arguments[0];
  21021. return this.covers(other);
  21022. } else if (arguments[0] instanceof Coordinate) {
  21023. var p = arguments[0];
  21024. return this.covers(p);
  21025. }
  21026. } else if (arguments.length === 2) {
  21027. var x2 = arguments[0];
  21028. var y2 = arguments[1];
  21029. return this.covers(x2, y2);
  21030. }
  21031. };
  21032. Envelope.prototype.centre = function centre() {
  21033. if (this.isNull()) {
  21034. return null;
  21035. }
  21036. return new Coordinate((this.getMinX() + this.getMaxX()) / 2, (this.getMinY() + this.getMaxY()) / 2);
  21037. };
  21038. Envelope.prototype.init = function init2() {
  21039. if (arguments.length === 0) {
  21040. this.setToNull();
  21041. } else if (arguments.length === 1) {
  21042. if (arguments[0] instanceof Coordinate) {
  21043. var p = arguments[0];
  21044. this.init(p.x, p.x, p.y, p.y);
  21045. } else if (arguments[0] instanceof Envelope) {
  21046. var env = arguments[0];
  21047. this._minx = env._minx;
  21048. this._maxx = env._maxx;
  21049. this._miny = env._miny;
  21050. this._maxy = env._maxy;
  21051. }
  21052. } else if (arguments.length === 2) {
  21053. var p1 = arguments[0];
  21054. var p2 = arguments[1];
  21055. this.init(p1.x, p2.x, p1.y, p2.y);
  21056. } else if (arguments.length === 4) {
  21057. var x12 = arguments[0];
  21058. var x2 = arguments[1];
  21059. var y12 = arguments[2];
  21060. var y2 = arguments[3];
  21061. if (x12 < x2) {
  21062. this._minx = x12;
  21063. this._maxx = x2;
  21064. } else {
  21065. this._minx = x2;
  21066. this._maxx = x12;
  21067. }
  21068. if (y12 < y2) {
  21069. this._miny = y12;
  21070. this._maxy = y2;
  21071. } else {
  21072. this._miny = y2;
  21073. this._maxy = y12;
  21074. }
  21075. }
  21076. };
  21077. Envelope.prototype.getMaxY = function getMaxY() {
  21078. return this._maxy;
  21079. };
  21080. Envelope.prototype.distance = function distance3(env) {
  21081. if (this.intersects(env)) {
  21082. return 0;
  21083. }
  21084. var dx = 0;
  21085. if (this._maxx < env._minx) {
  21086. dx = env._minx - this._maxx;
  21087. } else if (this._minx > env._maxx) {
  21088. dx = this._minx - env._maxx;
  21089. }
  21090. var dy = 0;
  21091. if (this._maxy < env._miny) {
  21092. dy = env._miny - this._maxy;
  21093. } else if (this._miny > env._maxy) {
  21094. dy = this._miny - env._maxy;
  21095. }
  21096. if (dx === 0) {
  21097. return dy;
  21098. }
  21099. if (dy === 0) {
  21100. return dx;
  21101. }
  21102. return Math.sqrt(dx * dx + dy * dy);
  21103. };
  21104. Envelope.prototype.hashCode = function hashCode3() {
  21105. var result = 17;
  21106. result = 37 * result + Coordinate.hashCode(this._minx);
  21107. result = 37 * result + Coordinate.hashCode(this._maxx);
  21108. result = 37 * result + Coordinate.hashCode(this._miny);
  21109. result = 37 * result + Coordinate.hashCode(this._maxy);
  21110. return result;
  21111. };
  21112. Envelope.prototype.interfaces_ = function interfaces_11() {
  21113. return [Comparable, Serializable];
  21114. };
  21115. Envelope.prototype.getClass = function getClass11() {
  21116. return Envelope;
  21117. };
  21118. Envelope.intersects = function intersects3() {
  21119. if (arguments.length === 3) {
  21120. var p1 = arguments[0];
  21121. var p2 = arguments[1];
  21122. var q = arguments[2];
  21123. if (q.x >= (p1.x < p2.x ? p1.x : p2.x) && q.x <= (p1.x > p2.x ? p1.x : p2.x) && (q.y >= (p1.y < p2.y ? p1.y : p2.y) && q.y <= (p1.y > p2.y ? p1.y : p2.y))) {
  21124. return true;
  21125. }
  21126. return false;
  21127. } else if (arguments.length === 4) {
  21128. var p1$1 = arguments[0];
  21129. var p2$1 = arguments[1];
  21130. var q1 = arguments[2];
  21131. var q2 = arguments[3];
  21132. var minq = Math.min(q1.x, q2.x);
  21133. var maxq = Math.max(q1.x, q2.x);
  21134. var minp = Math.min(p1$1.x, p2$1.x);
  21135. var maxp = Math.max(p1$1.x, p2$1.x);
  21136. if (minp > maxq) {
  21137. return false;
  21138. }
  21139. if (maxp < minq) {
  21140. return false;
  21141. }
  21142. minq = Math.min(q1.y, q2.y);
  21143. maxq = Math.max(q1.y, q2.y);
  21144. minp = Math.min(p1$1.y, p2$1.y);
  21145. maxp = Math.max(p1$1.y, p2$1.y);
  21146. if (minp > maxq) {
  21147. return false;
  21148. }
  21149. if (maxp < minq) {
  21150. return false;
  21151. }
  21152. return true;
  21153. }
  21154. };
  21155. staticAccessors$9.serialVersionUID.get = function() {
  21156. return 5873921885273102e3;
  21157. };
  21158. Object.defineProperties(Envelope, staticAccessors$9);
  21159. var regExes = {
  21160. "typeStr": /^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,
  21161. "emptyTypeStr": /^\s*(\w+)\s*EMPTY\s*$/,
  21162. "spaces": /\s+/,
  21163. "parenComma": /\)\s*,\s*\(/,
  21164. "doubleParenComma": /\)\s*\)\s*,\s*\(\s*\(/,
  21165. "trimParens": /^\s*\(?(.*?)\)?\s*$/
  21166. };
  21167. var WKTParser = function WKTParser2(geometryFactory) {
  21168. this.geometryFactory = geometryFactory || new GeometryFactory();
  21169. };
  21170. WKTParser.prototype.read = function read(wkt) {
  21171. var geometry2, type, str;
  21172. wkt = wkt.replace(/[\n\r]/g, " ");
  21173. var matches = regExes.typeStr.exec(wkt);
  21174. if (wkt.search("EMPTY") !== -1) {
  21175. matches = regExes.emptyTypeStr.exec(wkt);
  21176. matches[2] = void 0;
  21177. }
  21178. if (matches) {
  21179. type = matches[1].toLowerCase();
  21180. str = matches[2];
  21181. if (parse$1[type]) {
  21182. geometry2 = parse$1[type].apply(this, [str]);
  21183. }
  21184. }
  21185. if (geometry2 === void 0) {
  21186. throw new Error("Could not parse WKT " + wkt);
  21187. }
  21188. return geometry2;
  21189. };
  21190. WKTParser.prototype.write = function write(geometry2) {
  21191. return this.extractGeometry(geometry2);
  21192. };
  21193. WKTParser.prototype.extractGeometry = function extractGeometry(geometry2) {
  21194. var type = geometry2.getGeometryType().toLowerCase();
  21195. if (!extract$1[type]) {
  21196. return null;
  21197. }
  21198. var wktType = type.toUpperCase();
  21199. var data;
  21200. if (geometry2.isEmpty()) {
  21201. data = wktType + " EMPTY";
  21202. } else {
  21203. data = wktType + "(" + extract$1[type].apply(this, [geometry2]) + ")";
  21204. }
  21205. return data;
  21206. };
  21207. var extract$1 = {
  21208. coordinate: function coordinate(coordinate$1) {
  21209. return coordinate$1.x + " " + coordinate$1.y;
  21210. },
  21211. point: function point2(point$1) {
  21212. return extract$1.coordinate.call(this, point$1._coordinates._coordinates[0]);
  21213. },
  21214. multipoint: function multipoint(multipoint$1) {
  21215. var this$1 = this;
  21216. var array2 = [];
  21217. for (var i = 0, len = multipoint$1._geometries.length; i < len; ++i) {
  21218. array2.push("(" + extract$1.point.apply(this$1, [multipoint$1._geometries[i]]) + ")");
  21219. }
  21220. return array2.join(",");
  21221. },
  21222. linestring: function linestring(linestring$1) {
  21223. var this$1 = this;
  21224. var array2 = [];
  21225. for (var i = 0, len = linestring$1._points._coordinates.length; i < len; ++i) {
  21226. array2.push(extract$1.coordinate.apply(this$1, [linestring$1._points._coordinates[i]]));
  21227. }
  21228. return array2.join(",");
  21229. },
  21230. linearring: function linearring(linearring$1) {
  21231. var this$1 = this;
  21232. var array2 = [];
  21233. for (var i = 0, len = linearring$1._points._coordinates.length; i < len; ++i) {
  21234. array2.push(extract$1.coordinate.apply(this$1, [linearring$1._points._coordinates[i]]));
  21235. }
  21236. return array2.join(",");
  21237. },
  21238. multilinestring: function multilinestring(multilinestring$1) {
  21239. var this$1 = this;
  21240. var array2 = [];
  21241. for (var i = 0, len = multilinestring$1._geometries.length; i < len; ++i) {
  21242. array2.push("(" + extract$1.linestring.apply(this$1, [multilinestring$1._geometries[i]]) + ")");
  21243. }
  21244. return array2.join(",");
  21245. },
  21246. polygon: function polygon2(polygon$1) {
  21247. var this$1 = this;
  21248. var array2 = [];
  21249. array2.push("(" + extract$1.linestring.apply(this, [polygon$1._shell]) + ")");
  21250. for (var i = 0, len = polygon$1._holes.length; i < len; ++i) {
  21251. array2.push("(" + extract$1.linestring.apply(this$1, [polygon$1._holes[i]]) + ")");
  21252. }
  21253. return array2.join(",");
  21254. },
  21255. multipolygon: function multipolygon(multipolygon$1) {
  21256. var this$1 = this;
  21257. var array2 = [];
  21258. for (var i = 0, len = multipolygon$1._geometries.length; i < len; ++i) {
  21259. array2.push("(" + extract$1.polygon.apply(this$1, [multipolygon$1._geometries[i]]) + ")");
  21260. }
  21261. return array2.join(",");
  21262. },
  21263. geometrycollection: function geometrycollection(collection) {
  21264. var this$1 = this;
  21265. var array2 = [];
  21266. for (var i = 0, len = collection._geometries.length; i < len; ++i) {
  21267. array2.push(this$1.extractGeometry(collection._geometries[i]));
  21268. }
  21269. return array2.join(",");
  21270. }
  21271. };
  21272. var parse$1 = {
  21273. point: function point3(str) {
  21274. if (str === void 0) {
  21275. return this.geometryFactory.createPoint();
  21276. }
  21277. var coords = str.trim().split(regExes.spaces);
  21278. return this.geometryFactory.createPoint(new Coordinate(
  21279. Number.parseFloat(coords[0]),
  21280. Number.parseFloat(coords[1])
  21281. ));
  21282. },
  21283. multipoint: function multipoint2(str) {
  21284. var this$1 = this;
  21285. if (str === void 0) {
  21286. return this.geometryFactory.createMultiPoint();
  21287. }
  21288. var point4;
  21289. var points2 = str.trim().split(",");
  21290. var components = [];
  21291. for (var i = 0, len = points2.length; i < len; ++i) {
  21292. point4 = points2[i].replace(regExes.trimParens, "$1");
  21293. components.push(parse$1.point.apply(this$1, [point4]));
  21294. }
  21295. return this.geometryFactory.createMultiPoint(components);
  21296. },
  21297. linestring: function linestring2(str) {
  21298. if (str === void 0) {
  21299. return this.geometryFactory.createLineString();
  21300. }
  21301. var points2 = str.trim().split(",");
  21302. var components = [];
  21303. var coords;
  21304. for (var i = 0, len = points2.length; i < len; ++i) {
  21305. coords = points2[i].trim().split(regExes.spaces);
  21306. components.push(new Coordinate(Number.parseFloat(coords[0]), Number.parseFloat(coords[1])));
  21307. }
  21308. return this.geometryFactory.createLineString(components);
  21309. },
  21310. linearring: function linearring2(str) {
  21311. if (str === void 0) {
  21312. return this.geometryFactory.createLinearRing();
  21313. }
  21314. var points2 = str.trim().split(",");
  21315. var components = [];
  21316. var coords;
  21317. for (var i = 0, len = points2.length; i < len; ++i) {
  21318. coords = points2[i].trim().split(regExes.spaces);
  21319. components.push(new Coordinate(Number.parseFloat(coords[0]), Number.parseFloat(coords[1])));
  21320. }
  21321. return this.geometryFactory.createLinearRing(components);
  21322. },
  21323. multilinestring: function multilinestring2(str) {
  21324. var this$1 = this;
  21325. if (str === void 0) {
  21326. return this.geometryFactory.createMultiLineString();
  21327. }
  21328. var line;
  21329. var lines = str.trim().split(regExes.parenComma);
  21330. var components = [];
  21331. for (var i = 0, len = lines.length; i < len; ++i) {
  21332. line = lines[i].replace(regExes.trimParens, "$1");
  21333. components.push(parse$1.linestring.apply(this$1, [line]));
  21334. }
  21335. return this.geometryFactory.createMultiLineString(components);
  21336. },
  21337. polygon: function polygon3(str) {
  21338. var this$1 = this;
  21339. if (str === void 0) {
  21340. return this.geometryFactory.createPolygon();
  21341. }
  21342. var ring, linestring3, linearring3;
  21343. var rings = str.trim().split(regExes.parenComma);
  21344. var shell;
  21345. var holes = [];
  21346. for (var i = 0, len = rings.length; i < len; ++i) {
  21347. ring = rings[i].replace(regExes.trimParens, "$1");
  21348. linestring3 = parse$1.linestring.apply(this$1, [ring]);
  21349. linearring3 = this$1.geometryFactory.createLinearRing(linestring3._points);
  21350. if (i === 0) {
  21351. shell = linearring3;
  21352. } else {
  21353. holes.push(linearring3);
  21354. }
  21355. }
  21356. return this.geometryFactory.createPolygon(shell, holes);
  21357. },
  21358. multipolygon: function multipolygon2(str) {
  21359. var this$1 = this;
  21360. if (str === void 0) {
  21361. return this.geometryFactory.createMultiPolygon();
  21362. }
  21363. var polygon4;
  21364. var polygons2 = str.trim().split(regExes.doubleParenComma);
  21365. var components = [];
  21366. for (var i = 0, len = polygons2.length; i < len; ++i) {
  21367. polygon4 = polygons2[i].replace(regExes.trimParens, "$1");
  21368. components.push(parse$1.polygon.apply(this$1, [polygon4]));
  21369. }
  21370. return this.geometryFactory.createMultiPolygon(components);
  21371. },
  21372. geometrycollection: function geometrycollection2(str) {
  21373. var this$1 = this;
  21374. if (str === void 0) {
  21375. return this.geometryFactory.createGeometryCollection();
  21376. }
  21377. str = str.replace(/,\s*([A-Za-z])/g, "|$1");
  21378. var wktArray = str.trim().split("|");
  21379. var components = [];
  21380. for (var i = 0, len = wktArray.length; i < len; ++i) {
  21381. components.push(this$1.read(wktArray[i]));
  21382. }
  21383. return this.geometryFactory.createGeometryCollection(components);
  21384. }
  21385. };
  21386. var WKTWriter = function WKTWriter2(geometryFactory) {
  21387. this.parser = new WKTParser(geometryFactory);
  21388. };
  21389. WKTWriter.prototype.write = function write2(geometry2) {
  21390. return this.parser.write(geometry2);
  21391. };
  21392. WKTWriter.toLineString = function toLineString(p0, p1) {
  21393. if (arguments.length !== 2) {
  21394. throw new Error("Not implemented");
  21395. }
  21396. return "LINESTRING ( " + p0.x + " " + p0.y + ", " + p1.x + " " + p1.y + " )";
  21397. };
  21398. var RuntimeException = function(Error2) {
  21399. function RuntimeException2(message) {
  21400. Error2.call(this, message);
  21401. this.name = "RuntimeException";
  21402. this.message = message;
  21403. this.stack = new Error2().stack;
  21404. }
  21405. if (Error2)
  21406. RuntimeException2.__proto__ = Error2;
  21407. RuntimeException2.prototype = Object.create(Error2 && Error2.prototype);
  21408. RuntimeException2.prototype.constructor = RuntimeException2;
  21409. return RuntimeException2;
  21410. }(Error);
  21411. var AssertionFailedException = function(RuntimeException$$1) {
  21412. function AssertionFailedException2() {
  21413. RuntimeException$$1.call(this);
  21414. if (arguments.length === 0) {
  21415. RuntimeException$$1.call(this);
  21416. } else if (arguments.length === 1) {
  21417. var message = arguments[0];
  21418. RuntimeException$$1.call(this, message);
  21419. }
  21420. }
  21421. if (RuntimeException$$1)
  21422. AssertionFailedException2.__proto__ = RuntimeException$$1;
  21423. AssertionFailedException2.prototype = Object.create(RuntimeException$$1 && RuntimeException$$1.prototype);
  21424. AssertionFailedException2.prototype.constructor = AssertionFailedException2;
  21425. AssertionFailedException2.prototype.interfaces_ = function interfaces_170() {
  21426. return [];
  21427. };
  21428. AssertionFailedException2.prototype.getClass = function getClass169() {
  21429. return AssertionFailedException2;
  21430. };
  21431. return AssertionFailedException2;
  21432. }(RuntimeException);
  21433. var Assert = function Assert2() {
  21434. };
  21435. Assert.prototype.interfaces_ = function interfaces_12() {
  21436. return [];
  21437. };
  21438. Assert.prototype.getClass = function getClass12() {
  21439. return Assert;
  21440. };
  21441. Assert.shouldNeverReachHere = function shouldNeverReachHere() {
  21442. if (arguments.length === 0) {
  21443. Assert.shouldNeverReachHere(null);
  21444. } else if (arguments.length === 1) {
  21445. var message = arguments[0];
  21446. throw new AssertionFailedException("Should never reach here" + (message !== null ? ": " + message : ""));
  21447. }
  21448. };
  21449. Assert.isTrue = function isTrue() {
  21450. var assertion;
  21451. var message;
  21452. if (arguments.length === 1) {
  21453. assertion = arguments[0];
  21454. Assert.isTrue(assertion, null);
  21455. } else if (arguments.length === 2) {
  21456. assertion = arguments[0];
  21457. message = arguments[1];
  21458. if (!assertion) {
  21459. if (message === null) {
  21460. throw new AssertionFailedException();
  21461. } else {
  21462. throw new AssertionFailedException(message);
  21463. }
  21464. }
  21465. }
  21466. };
  21467. Assert.equals = function equals5() {
  21468. var expectedValue;
  21469. var actualValue;
  21470. var message;
  21471. if (arguments.length === 2) {
  21472. expectedValue = arguments[0];
  21473. actualValue = arguments[1];
  21474. Assert.equals(expectedValue, actualValue, null);
  21475. } else if (arguments.length === 3) {
  21476. expectedValue = arguments[0];
  21477. actualValue = arguments[1];
  21478. message = arguments[2];
  21479. if (!actualValue.equals(expectedValue)) {
  21480. throw new AssertionFailedException("Expected " + expectedValue + " but encountered " + actualValue + (message !== null ? ": " + message : ""));
  21481. }
  21482. }
  21483. };
  21484. var LineIntersector = function LineIntersector2() {
  21485. this._result = null;
  21486. this._inputLines = Array(2).fill().map(function() {
  21487. return Array(2);
  21488. });
  21489. this._intPt = new Array(2).fill(null);
  21490. this._intLineIndex = null;
  21491. this._isProper = null;
  21492. this._pa = null;
  21493. this._pb = null;
  21494. this._precisionModel = null;
  21495. this._intPt[0] = new Coordinate();
  21496. this._intPt[1] = new Coordinate();
  21497. this._pa = this._intPt[0];
  21498. this._pb = this._intPt[1];
  21499. this._result = 0;
  21500. };
  21501. var staticAccessors$10 = { DONT_INTERSECT: { configurable: true }, DO_INTERSECT: { configurable: true }, COLLINEAR: { configurable: true }, NO_INTERSECTION: { configurable: true }, POINT_INTERSECTION: { configurable: true }, COLLINEAR_INTERSECTION: { configurable: true } };
  21502. LineIntersector.prototype.getIndexAlongSegment = function getIndexAlongSegment(segmentIndex, intIndex) {
  21503. this.computeIntLineIndex();
  21504. return this._intLineIndex[segmentIndex][intIndex];
  21505. };
  21506. LineIntersector.prototype.getTopologySummary = function getTopologySummary() {
  21507. var catBuf = new StringBuffer();
  21508. if (this.isEndPoint()) {
  21509. catBuf.append(" endpoint");
  21510. }
  21511. if (this._isProper) {
  21512. catBuf.append(" proper");
  21513. }
  21514. if (this.isCollinear()) {
  21515. catBuf.append(" collinear");
  21516. }
  21517. return catBuf.toString();
  21518. };
  21519. LineIntersector.prototype.computeIntersection = function computeIntersection(p1, p2, p3, p4) {
  21520. this._inputLines[0][0] = p1;
  21521. this._inputLines[0][1] = p2;
  21522. this._inputLines[1][0] = p3;
  21523. this._inputLines[1][1] = p4;
  21524. this._result = this.computeIntersect(p1, p2, p3, p4);
  21525. };
  21526. LineIntersector.prototype.getIntersectionNum = function getIntersectionNum() {
  21527. return this._result;
  21528. };
  21529. LineIntersector.prototype.computeIntLineIndex = function computeIntLineIndex() {
  21530. if (arguments.length === 0) {
  21531. if (this._intLineIndex === null) {
  21532. this._intLineIndex = Array(2).fill().map(function() {
  21533. return Array(2);
  21534. });
  21535. this.computeIntLineIndex(0);
  21536. this.computeIntLineIndex(1);
  21537. }
  21538. } else if (arguments.length === 1) {
  21539. var segmentIndex = arguments[0];
  21540. var dist0 = this.getEdgeDistance(segmentIndex, 0);
  21541. var dist1 = this.getEdgeDistance(segmentIndex, 1);
  21542. if (dist0 > dist1) {
  21543. this._intLineIndex[segmentIndex][0] = 0;
  21544. this._intLineIndex[segmentIndex][1] = 1;
  21545. } else {
  21546. this._intLineIndex[segmentIndex][0] = 1;
  21547. this._intLineIndex[segmentIndex][1] = 0;
  21548. }
  21549. }
  21550. };
  21551. LineIntersector.prototype.isProper = function isProper() {
  21552. return this.hasIntersection() && this._isProper;
  21553. };
  21554. LineIntersector.prototype.setPrecisionModel = function setPrecisionModel(precisionModel) {
  21555. this._precisionModel = precisionModel;
  21556. };
  21557. LineIntersector.prototype.isInteriorIntersection = function isInteriorIntersection() {
  21558. var this$1 = this;
  21559. if (arguments.length === 0) {
  21560. if (this.isInteriorIntersection(0)) {
  21561. return true;
  21562. }
  21563. if (this.isInteriorIntersection(1)) {
  21564. return true;
  21565. }
  21566. return false;
  21567. } else if (arguments.length === 1) {
  21568. var inputLineIndex = arguments[0];
  21569. for (var i = 0; i < this._result; i++) {
  21570. if (!(this$1._intPt[i].equals2D(this$1._inputLines[inputLineIndex][0]) || this$1._intPt[i].equals2D(this$1._inputLines[inputLineIndex][1]))) {
  21571. return true;
  21572. }
  21573. }
  21574. return false;
  21575. }
  21576. };
  21577. LineIntersector.prototype.getIntersection = function getIntersection(intIndex) {
  21578. return this._intPt[intIndex];
  21579. };
  21580. LineIntersector.prototype.isEndPoint = function isEndPoint() {
  21581. return this.hasIntersection() && !this._isProper;
  21582. };
  21583. LineIntersector.prototype.hasIntersection = function hasIntersection() {
  21584. return this._result !== LineIntersector.NO_INTERSECTION;
  21585. };
  21586. LineIntersector.prototype.getEdgeDistance = function getEdgeDistance(segmentIndex, intIndex) {
  21587. var dist = LineIntersector.computeEdgeDistance(this._intPt[intIndex], this._inputLines[segmentIndex][0], this._inputLines[segmentIndex][1]);
  21588. return dist;
  21589. };
  21590. LineIntersector.prototype.isCollinear = function isCollinear() {
  21591. return this._result === LineIntersector.COLLINEAR_INTERSECTION;
  21592. };
  21593. LineIntersector.prototype.toString = function toString5() {
  21594. return WKTWriter.toLineString(this._inputLines[0][0], this._inputLines[0][1]) + " - " + WKTWriter.toLineString(this._inputLines[1][0], this._inputLines[1][1]) + this.getTopologySummary();
  21595. };
  21596. LineIntersector.prototype.getEndpoint = function getEndpoint(segmentIndex, ptIndex) {
  21597. return this._inputLines[segmentIndex][ptIndex];
  21598. };
  21599. LineIntersector.prototype.isIntersection = function isIntersection(pt) {
  21600. var this$1 = this;
  21601. for (var i = 0; i < this._result; i++) {
  21602. if (this$1._intPt[i].equals2D(pt)) {
  21603. return true;
  21604. }
  21605. }
  21606. return false;
  21607. };
  21608. LineIntersector.prototype.getIntersectionAlongSegment = function getIntersectionAlongSegment(segmentIndex, intIndex) {
  21609. this.computeIntLineIndex();
  21610. return this._intPt[this._intLineIndex[segmentIndex][intIndex]];
  21611. };
  21612. LineIntersector.prototype.interfaces_ = function interfaces_13() {
  21613. return [];
  21614. };
  21615. LineIntersector.prototype.getClass = function getClass13() {
  21616. return LineIntersector;
  21617. };
  21618. LineIntersector.computeEdgeDistance = function computeEdgeDistance(p, p0, p1) {
  21619. var dx = Math.abs(p1.x - p0.x);
  21620. var dy = Math.abs(p1.y - p0.y);
  21621. var dist = -1;
  21622. if (p.equals(p0)) {
  21623. dist = 0;
  21624. } else if (p.equals(p1)) {
  21625. if (dx > dy) {
  21626. dist = dx;
  21627. } else {
  21628. dist = dy;
  21629. }
  21630. } else {
  21631. var pdx = Math.abs(p.x - p0.x);
  21632. var pdy = Math.abs(p.y - p0.y);
  21633. if (dx > dy) {
  21634. dist = pdx;
  21635. } else {
  21636. dist = pdy;
  21637. }
  21638. if (dist === 0 && !p.equals(p0)) {
  21639. dist = Math.max(pdx, pdy);
  21640. }
  21641. }
  21642. Assert.isTrue(!(dist === 0 && !p.equals(p0)), "Bad distance calculation");
  21643. return dist;
  21644. };
  21645. LineIntersector.nonRobustComputeEdgeDistance = function nonRobustComputeEdgeDistance(p, p1, p2) {
  21646. var dx = p.x - p1.x;
  21647. var dy = p.y - p1.y;
  21648. var dist = Math.sqrt(dx * dx + dy * dy);
  21649. Assert.isTrue(!(dist === 0 && !p.equals(p1)), "Invalid distance calculation");
  21650. return dist;
  21651. };
  21652. staticAccessors$10.DONT_INTERSECT.get = function() {
  21653. return 0;
  21654. };
  21655. staticAccessors$10.DO_INTERSECT.get = function() {
  21656. return 1;
  21657. };
  21658. staticAccessors$10.COLLINEAR.get = function() {
  21659. return 2;
  21660. };
  21661. staticAccessors$10.NO_INTERSECTION.get = function() {
  21662. return 0;
  21663. };
  21664. staticAccessors$10.POINT_INTERSECTION.get = function() {
  21665. return 1;
  21666. };
  21667. staticAccessors$10.COLLINEAR_INTERSECTION.get = function() {
  21668. return 2;
  21669. };
  21670. Object.defineProperties(LineIntersector, staticAccessors$10);
  21671. var RobustLineIntersector = function(LineIntersector$$1) {
  21672. function RobustLineIntersector2() {
  21673. LineIntersector$$1.apply(this, arguments);
  21674. }
  21675. if (LineIntersector$$1)
  21676. RobustLineIntersector2.__proto__ = LineIntersector$$1;
  21677. RobustLineIntersector2.prototype = Object.create(LineIntersector$$1 && LineIntersector$$1.prototype);
  21678. RobustLineIntersector2.prototype.constructor = RobustLineIntersector2;
  21679. RobustLineIntersector2.prototype.isInSegmentEnvelopes = function isInSegmentEnvelopes(intPt) {
  21680. var env0 = new Envelope(this._inputLines[0][0], this._inputLines[0][1]);
  21681. var env1 = new Envelope(this._inputLines[1][0], this._inputLines[1][1]);
  21682. return env0.contains(intPt) && env1.contains(intPt);
  21683. };
  21684. RobustLineIntersector2.prototype.computeIntersection = function computeIntersection2() {
  21685. if (arguments.length === 3) {
  21686. var p = arguments[0];
  21687. var p1 = arguments[1];
  21688. var p2 = arguments[2];
  21689. this._isProper = false;
  21690. if (Envelope.intersects(p1, p2, p)) {
  21691. if (CGAlgorithms.orientationIndex(p1, p2, p) === 0 && CGAlgorithms.orientationIndex(p2, p1, p) === 0) {
  21692. this._isProper = true;
  21693. if (p.equals(p1) || p.equals(p2)) {
  21694. this._isProper = false;
  21695. }
  21696. this._result = LineIntersector$$1.POINT_INTERSECTION;
  21697. return null;
  21698. }
  21699. }
  21700. this._result = LineIntersector$$1.NO_INTERSECTION;
  21701. } else {
  21702. return LineIntersector$$1.prototype.computeIntersection.apply(this, arguments);
  21703. }
  21704. };
  21705. RobustLineIntersector2.prototype.normalizeToMinimum = function normalizeToMinimum(n1, n2, n3, n4, normPt) {
  21706. normPt.x = this.smallestInAbsValue(n1.x, n2.x, n3.x, n4.x);
  21707. normPt.y = this.smallestInAbsValue(n1.y, n2.y, n3.y, n4.y);
  21708. n1.x -= normPt.x;
  21709. n1.y -= normPt.y;
  21710. n2.x -= normPt.x;
  21711. n2.y -= normPt.y;
  21712. n3.x -= normPt.x;
  21713. n3.y -= normPt.y;
  21714. n4.x -= normPt.x;
  21715. n4.y -= normPt.y;
  21716. };
  21717. RobustLineIntersector2.prototype.safeHCoordinateIntersection = function safeHCoordinateIntersection(p1, p2, q1, q2) {
  21718. var intPt = null;
  21719. try {
  21720. intPt = HCoordinate.intersection(p1, p2, q1, q2);
  21721. } catch (e) {
  21722. if (e instanceof NotRepresentableException) {
  21723. intPt = RobustLineIntersector2.nearestEndpoint(p1, p2, q1, q2);
  21724. } else {
  21725. throw e;
  21726. }
  21727. } finally {
  21728. }
  21729. return intPt;
  21730. };
  21731. RobustLineIntersector2.prototype.intersection = function intersection12(p1, p2, q1, q2) {
  21732. var intPt = this.intersectionWithNormalization(p1, p2, q1, q2);
  21733. if (!this.isInSegmentEnvelopes(intPt)) {
  21734. intPt = new Coordinate(RobustLineIntersector2.nearestEndpoint(p1, p2, q1, q2));
  21735. }
  21736. if (this._precisionModel !== null) {
  21737. this._precisionModel.makePrecise(intPt);
  21738. }
  21739. return intPt;
  21740. };
  21741. RobustLineIntersector2.prototype.smallestInAbsValue = function smallestInAbsValue(x12, x2, x3, x4) {
  21742. var x5 = x12;
  21743. var xabs = Math.abs(x5);
  21744. if (Math.abs(x2) < xabs) {
  21745. x5 = x2;
  21746. xabs = Math.abs(x2);
  21747. }
  21748. if (Math.abs(x3) < xabs) {
  21749. x5 = x3;
  21750. xabs = Math.abs(x3);
  21751. }
  21752. if (Math.abs(x4) < xabs) {
  21753. x5 = x4;
  21754. }
  21755. return x5;
  21756. };
  21757. RobustLineIntersector2.prototype.checkDD = function checkDD(p1, p2, q1, q2, intPt) {
  21758. var intPtDD = CGAlgorithmsDD.intersection(p1, p2, q1, q2);
  21759. var isIn = this.isInSegmentEnvelopes(intPtDD);
  21760. System.out.println("DD in env = " + isIn + " --------------------- " + intPtDD);
  21761. if (intPt.distance(intPtDD) > 1e-4) {
  21762. System.out.println("Distance = " + intPt.distance(intPtDD));
  21763. }
  21764. };
  21765. RobustLineIntersector2.prototype.intersectionWithNormalization = function intersectionWithNormalization(p1, p2, q1, q2) {
  21766. var n1 = new Coordinate(p1);
  21767. var n2 = new Coordinate(p2);
  21768. var n3 = new Coordinate(q1);
  21769. var n4 = new Coordinate(q2);
  21770. var normPt = new Coordinate();
  21771. this.normalizeToEnvCentre(n1, n2, n3, n4, normPt);
  21772. var intPt = this.safeHCoordinateIntersection(n1, n2, n3, n4);
  21773. intPt.x += normPt.x;
  21774. intPt.y += normPt.y;
  21775. return intPt;
  21776. };
  21777. RobustLineIntersector2.prototype.computeCollinearIntersection = function computeCollinearIntersection(p1, p2, q1, q2) {
  21778. var p1q1p2 = Envelope.intersects(p1, p2, q1);
  21779. var p1q2p2 = Envelope.intersects(p1, p2, q2);
  21780. var q1p1q2 = Envelope.intersects(q1, q2, p1);
  21781. var q1p2q2 = Envelope.intersects(q1, q2, p2);
  21782. if (p1q1p2 && p1q2p2) {
  21783. this._intPt[0] = q1;
  21784. this._intPt[1] = q2;
  21785. return LineIntersector$$1.COLLINEAR_INTERSECTION;
  21786. }
  21787. if (q1p1q2 && q1p2q2) {
  21788. this._intPt[0] = p1;
  21789. this._intPt[1] = p2;
  21790. return LineIntersector$$1.COLLINEAR_INTERSECTION;
  21791. }
  21792. if (p1q1p2 && q1p1q2) {
  21793. this._intPt[0] = q1;
  21794. this._intPt[1] = p1;
  21795. return q1.equals(p1) && !p1q2p2 && !q1p2q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION;
  21796. }
  21797. if (p1q1p2 && q1p2q2) {
  21798. this._intPt[0] = q1;
  21799. this._intPt[1] = p2;
  21800. return q1.equals(p2) && !p1q2p2 && !q1p1q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION;
  21801. }
  21802. if (p1q2p2 && q1p1q2) {
  21803. this._intPt[0] = q2;
  21804. this._intPt[1] = p1;
  21805. return q2.equals(p1) && !p1q1p2 && !q1p2q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION;
  21806. }
  21807. if (p1q2p2 && q1p2q2) {
  21808. this._intPt[0] = q2;
  21809. this._intPt[1] = p2;
  21810. return q2.equals(p2) && !p1q1p2 && !q1p1q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION;
  21811. }
  21812. return LineIntersector$$1.NO_INTERSECTION;
  21813. };
  21814. RobustLineIntersector2.prototype.normalizeToEnvCentre = function normalizeToEnvCentre(n00, n01, n10, n11, normPt) {
  21815. var minX0 = n00.x < n01.x ? n00.x : n01.x;
  21816. var minY0 = n00.y < n01.y ? n00.y : n01.y;
  21817. var maxX0 = n00.x > n01.x ? n00.x : n01.x;
  21818. var maxY0 = n00.y > n01.y ? n00.y : n01.y;
  21819. var minX1 = n10.x < n11.x ? n10.x : n11.x;
  21820. var minY1 = n10.y < n11.y ? n10.y : n11.y;
  21821. var maxX1 = n10.x > n11.x ? n10.x : n11.x;
  21822. var maxY1 = n10.y > n11.y ? n10.y : n11.y;
  21823. var intMinX = minX0 > minX1 ? minX0 : minX1;
  21824. var intMaxX = maxX0 < maxX1 ? maxX0 : maxX1;
  21825. var intMinY = minY0 > minY1 ? minY0 : minY1;
  21826. var intMaxY = maxY0 < maxY1 ? maxY0 : maxY1;
  21827. var intMidX = (intMinX + intMaxX) / 2;
  21828. var intMidY = (intMinY + intMaxY) / 2;
  21829. normPt.x = intMidX;
  21830. normPt.y = intMidY;
  21831. n00.x -= normPt.x;
  21832. n00.y -= normPt.y;
  21833. n01.x -= normPt.x;
  21834. n01.y -= normPt.y;
  21835. n10.x -= normPt.x;
  21836. n10.y -= normPt.y;
  21837. n11.x -= normPt.x;
  21838. n11.y -= normPt.y;
  21839. };
  21840. RobustLineIntersector2.prototype.computeIntersect = function computeIntersect(p1, p2, q1, q2) {
  21841. this._isProper = false;
  21842. if (!Envelope.intersects(p1, p2, q1, q2)) {
  21843. return LineIntersector$$1.NO_INTERSECTION;
  21844. }
  21845. var Pq1 = CGAlgorithms.orientationIndex(p1, p2, q1);
  21846. var Pq2 = CGAlgorithms.orientationIndex(p1, p2, q2);
  21847. if (Pq1 > 0 && Pq2 > 0 || Pq1 < 0 && Pq2 < 0) {
  21848. return LineIntersector$$1.NO_INTERSECTION;
  21849. }
  21850. var Qp1 = CGAlgorithms.orientationIndex(q1, q2, p1);
  21851. var Qp2 = CGAlgorithms.orientationIndex(q1, q2, p2);
  21852. if (Qp1 > 0 && Qp2 > 0 || Qp1 < 0 && Qp2 < 0) {
  21853. return LineIntersector$$1.NO_INTERSECTION;
  21854. }
  21855. var collinear = Pq1 === 0 && Pq2 === 0 && Qp1 === 0 && Qp2 === 0;
  21856. if (collinear) {
  21857. return this.computeCollinearIntersection(p1, p2, q1, q2);
  21858. }
  21859. if (Pq1 === 0 || Pq2 === 0 || Qp1 === 0 || Qp2 === 0) {
  21860. this._isProper = false;
  21861. if (p1.equals2D(q1) || p1.equals2D(q2)) {
  21862. this._intPt[0] = p1;
  21863. } else if (p2.equals2D(q1) || p2.equals2D(q2)) {
  21864. this._intPt[0] = p2;
  21865. } else if (Pq1 === 0) {
  21866. this._intPt[0] = new Coordinate(q1);
  21867. } else if (Pq2 === 0) {
  21868. this._intPt[0] = new Coordinate(q2);
  21869. } else if (Qp1 === 0) {
  21870. this._intPt[0] = new Coordinate(p1);
  21871. } else if (Qp2 === 0) {
  21872. this._intPt[0] = new Coordinate(p2);
  21873. }
  21874. } else {
  21875. this._isProper = true;
  21876. this._intPt[0] = this.intersection(p1, p2, q1, q2);
  21877. }
  21878. return LineIntersector$$1.POINT_INTERSECTION;
  21879. };
  21880. RobustLineIntersector2.prototype.interfaces_ = function interfaces_170() {
  21881. return [];
  21882. };
  21883. RobustLineIntersector2.prototype.getClass = function getClass169() {
  21884. return RobustLineIntersector2;
  21885. };
  21886. RobustLineIntersector2.nearestEndpoint = function nearestEndpoint(p1, p2, q1, q2) {
  21887. var nearestPt = p1;
  21888. var minDist = CGAlgorithms.distancePointLine(p1, q1, q2);
  21889. var dist = CGAlgorithms.distancePointLine(p2, q1, q2);
  21890. if (dist < minDist) {
  21891. minDist = dist;
  21892. nearestPt = p2;
  21893. }
  21894. dist = CGAlgorithms.distancePointLine(q1, p1, p2);
  21895. if (dist < minDist) {
  21896. minDist = dist;
  21897. nearestPt = q1;
  21898. }
  21899. dist = CGAlgorithms.distancePointLine(q2, p1, p2);
  21900. if (dist < minDist) {
  21901. minDist = dist;
  21902. nearestPt = q2;
  21903. }
  21904. return nearestPt;
  21905. };
  21906. return RobustLineIntersector2;
  21907. }(LineIntersector);
  21908. var RobustDeterminant = function RobustDeterminant2() {
  21909. };
  21910. RobustDeterminant.prototype.interfaces_ = function interfaces_14() {
  21911. return [];
  21912. };
  21913. RobustDeterminant.prototype.getClass = function getClass14() {
  21914. return RobustDeterminant;
  21915. };
  21916. RobustDeterminant.orientationIndex = function orientationIndex3(p1, p2, q) {
  21917. var dx1 = p2.x - p1.x;
  21918. var dy1 = p2.y - p1.y;
  21919. var dx2 = q.x - p2.x;
  21920. var dy2 = q.y - p2.y;
  21921. return RobustDeterminant.signOfDet2x2(dx1, dy1, dx2, dy2);
  21922. };
  21923. RobustDeterminant.signOfDet2x2 = function signOfDet2x22(x12, y12, x2, y2) {
  21924. var sign3 = null;
  21925. var swap2 = null;
  21926. var k = null;
  21927. sign3 = 1;
  21928. if (x12 === 0 || y2 === 0) {
  21929. if (y12 === 0 || x2 === 0) {
  21930. return 0;
  21931. } else if (y12 > 0) {
  21932. if (x2 > 0) {
  21933. return -sign3;
  21934. } else {
  21935. return sign3;
  21936. }
  21937. } else {
  21938. if (x2 > 0) {
  21939. return sign3;
  21940. } else {
  21941. return -sign3;
  21942. }
  21943. }
  21944. }
  21945. if (y12 === 0 || x2 === 0) {
  21946. if (y2 > 0) {
  21947. if (x12 > 0) {
  21948. return sign3;
  21949. } else {
  21950. return -sign3;
  21951. }
  21952. } else {
  21953. if (x12 > 0) {
  21954. return -sign3;
  21955. } else {
  21956. return sign3;
  21957. }
  21958. }
  21959. }
  21960. if (y12 > 0) {
  21961. if (y2 > 0) {
  21962. if (y12 <= y2) {
  21963. } else {
  21964. sign3 = -sign3;
  21965. swap2 = x12;
  21966. x12 = x2;
  21967. x2 = swap2;
  21968. swap2 = y12;
  21969. y12 = y2;
  21970. y2 = swap2;
  21971. }
  21972. } else {
  21973. if (y12 <= -y2) {
  21974. sign3 = -sign3;
  21975. x2 = -x2;
  21976. y2 = -y2;
  21977. } else {
  21978. swap2 = x12;
  21979. x12 = -x2;
  21980. x2 = swap2;
  21981. swap2 = y12;
  21982. y12 = -y2;
  21983. y2 = swap2;
  21984. }
  21985. }
  21986. } else {
  21987. if (y2 > 0) {
  21988. if (-y12 <= y2) {
  21989. sign3 = -sign3;
  21990. x12 = -x12;
  21991. y12 = -y12;
  21992. } else {
  21993. swap2 = -x12;
  21994. x12 = x2;
  21995. x2 = swap2;
  21996. swap2 = -y12;
  21997. y12 = y2;
  21998. y2 = swap2;
  21999. }
  22000. } else {
  22001. if (y12 >= y2) {
  22002. x12 = -x12;
  22003. y12 = -y12;
  22004. x2 = -x2;
  22005. y2 = -y2;
  22006. } else {
  22007. sign3 = -sign3;
  22008. swap2 = -x12;
  22009. x12 = -x2;
  22010. x2 = swap2;
  22011. swap2 = -y12;
  22012. y12 = -y2;
  22013. y2 = swap2;
  22014. }
  22015. }
  22016. }
  22017. if (x12 > 0) {
  22018. if (x2 > 0) {
  22019. if (x12 <= x2) {
  22020. } else {
  22021. return sign3;
  22022. }
  22023. } else {
  22024. return sign3;
  22025. }
  22026. } else {
  22027. if (x2 > 0) {
  22028. return -sign3;
  22029. } else {
  22030. if (x12 >= x2) {
  22031. sign3 = -sign3;
  22032. x12 = -x12;
  22033. x2 = -x2;
  22034. } else {
  22035. return -sign3;
  22036. }
  22037. }
  22038. }
  22039. while (true) {
  22040. k = Math.floor(x2 / x12);
  22041. x2 = x2 - k * x12;
  22042. y2 = y2 - k * y12;
  22043. if (y2 < 0) {
  22044. return -sign3;
  22045. }
  22046. if (y2 > y12) {
  22047. return sign3;
  22048. }
  22049. if (x12 > x2 + x2) {
  22050. if (y12 < y2 + y2) {
  22051. return sign3;
  22052. }
  22053. } else {
  22054. if (y12 > y2 + y2) {
  22055. return -sign3;
  22056. } else {
  22057. x2 = x12 - x2;
  22058. y2 = y12 - y2;
  22059. sign3 = -sign3;
  22060. }
  22061. }
  22062. if (y2 === 0) {
  22063. if (x2 === 0) {
  22064. return 0;
  22065. } else {
  22066. return -sign3;
  22067. }
  22068. }
  22069. if (x2 === 0) {
  22070. return sign3;
  22071. }
  22072. k = Math.floor(x12 / x2);
  22073. x12 = x12 - k * x2;
  22074. y12 = y12 - k * y2;
  22075. if (y12 < 0) {
  22076. return sign3;
  22077. }
  22078. if (y12 > y2) {
  22079. return -sign3;
  22080. }
  22081. if (x2 > x12 + x12) {
  22082. if (y2 < y12 + y12) {
  22083. return -sign3;
  22084. }
  22085. } else {
  22086. if (y2 > y12 + y12) {
  22087. return sign3;
  22088. } else {
  22089. x12 = x2 - x12;
  22090. y12 = y2 - y12;
  22091. sign3 = -sign3;
  22092. }
  22093. }
  22094. if (y12 === 0) {
  22095. if (x12 === 0) {
  22096. return 0;
  22097. } else {
  22098. return sign3;
  22099. }
  22100. }
  22101. if (x12 === 0) {
  22102. return -sign3;
  22103. }
  22104. }
  22105. };
  22106. var RayCrossingCounter = function RayCrossingCounter2() {
  22107. this._p = null;
  22108. this._crossingCount = 0;
  22109. this._isPointOnSegment = false;
  22110. var p = arguments[0];
  22111. this._p = p;
  22112. };
  22113. RayCrossingCounter.prototype.countSegment = function countSegment(p1, p2) {
  22114. if (p1.x < this._p.x && p2.x < this._p.x) {
  22115. return null;
  22116. }
  22117. if (this._p.x === p2.x && this._p.y === p2.y) {
  22118. this._isPointOnSegment = true;
  22119. return null;
  22120. }
  22121. if (p1.y === this._p.y && p2.y === this._p.y) {
  22122. var minx = p1.x;
  22123. var maxx = p2.x;
  22124. if (minx > maxx) {
  22125. minx = p2.x;
  22126. maxx = p1.x;
  22127. }
  22128. if (this._p.x >= minx && this._p.x <= maxx) {
  22129. this._isPointOnSegment = true;
  22130. }
  22131. return null;
  22132. }
  22133. if (p1.y > this._p.y && p2.y <= this._p.y || p2.y > this._p.y && p1.y <= this._p.y) {
  22134. var x12 = p1.x - this._p.x;
  22135. var y12 = p1.y - this._p.y;
  22136. var x2 = p2.x - this._p.x;
  22137. var y2 = p2.y - this._p.y;
  22138. var xIntSign = RobustDeterminant.signOfDet2x2(x12, y12, x2, y2);
  22139. if (xIntSign === 0) {
  22140. this._isPointOnSegment = true;
  22141. return null;
  22142. }
  22143. if (y2 < y12) {
  22144. xIntSign = -xIntSign;
  22145. }
  22146. if (xIntSign > 0) {
  22147. this._crossingCount++;
  22148. }
  22149. }
  22150. };
  22151. RayCrossingCounter.prototype.isPointInPolygon = function isPointInPolygon() {
  22152. return this.getLocation() !== Location.EXTERIOR;
  22153. };
  22154. RayCrossingCounter.prototype.getLocation = function getLocation() {
  22155. if (this._isPointOnSegment) {
  22156. return Location.BOUNDARY;
  22157. }
  22158. if (this._crossingCount % 2 === 1) {
  22159. return Location.INTERIOR;
  22160. }
  22161. return Location.EXTERIOR;
  22162. };
  22163. RayCrossingCounter.prototype.isOnSegment = function isOnSegment() {
  22164. return this._isPointOnSegment;
  22165. };
  22166. RayCrossingCounter.prototype.interfaces_ = function interfaces_15() {
  22167. return [];
  22168. };
  22169. RayCrossingCounter.prototype.getClass = function getClass15() {
  22170. return RayCrossingCounter;
  22171. };
  22172. RayCrossingCounter.locatePointInRing = function locatePointInRing() {
  22173. if (arguments[0] instanceof Coordinate && hasInterface(arguments[1], CoordinateSequence)) {
  22174. var p = arguments[0];
  22175. var ring = arguments[1];
  22176. var counter = new RayCrossingCounter(p);
  22177. var p1 = new Coordinate();
  22178. var p2 = new Coordinate();
  22179. for (var i = 1; i < ring.size(); i++) {
  22180. ring.getCoordinate(i, p1);
  22181. ring.getCoordinate(i - 1, p2);
  22182. counter.countSegment(p1, p2);
  22183. if (counter.isOnSegment()) {
  22184. return counter.getLocation();
  22185. }
  22186. }
  22187. return counter.getLocation();
  22188. } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Array) {
  22189. var p$1 = arguments[0];
  22190. var ring$1 = arguments[1];
  22191. var counter$1 = new RayCrossingCounter(p$1);
  22192. for (var i$1 = 1; i$1 < ring$1.length; i$1++) {
  22193. var p1$1 = ring$1[i$1];
  22194. var p2$1 = ring$1[i$1 - 1];
  22195. counter$1.countSegment(p1$1, p2$1);
  22196. if (counter$1.isOnSegment()) {
  22197. return counter$1.getLocation();
  22198. }
  22199. }
  22200. return counter$1.getLocation();
  22201. }
  22202. };
  22203. var CGAlgorithms = function CGAlgorithms2() {
  22204. };
  22205. var staticAccessors$3 = { CLOCKWISE: { configurable: true }, RIGHT: { configurable: true }, COUNTERCLOCKWISE: { configurable: true }, LEFT: { configurable: true }, COLLINEAR: { configurable: true }, STRAIGHT: { configurable: true } };
  22206. CGAlgorithms.prototype.interfaces_ = function interfaces_16() {
  22207. return [];
  22208. };
  22209. CGAlgorithms.prototype.getClass = function getClass16() {
  22210. return CGAlgorithms;
  22211. };
  22212. CGAlgorithms.orientationIndex = function orientationIndex4(p1, p2, q) {
  22213. return CGAlgorithmsDD.orientationIndex(p1, p2, q);
  22214. };
  22215. CGAlgorithms.signedArea = function signedArea() {
  22216. if (arguments[0] instanceof Array) {
  22217. var ring = arguments[0];
  22218. if (ring.length < 3) {
  22219. return 0;
  22220. }
  22221. var sum2 = 0;
  22222. var x02 = ring[0].x;
  22223. for (var i = 1; i < ring.length - 1; i++) {
  22224. var x2 = ring[i].x - x02;
  22225. var y12 = ring[i + 1].y;
  22226. var y2 = ring[i - 1].y;
  22227. sum2 += x2 * (y2 - y12);
  22228. }
  22229. return sum2 / 2;
  22230. } else if (hasInterface(arguments[0], CoordinateSequence)) {
  22231. var ring$1 = arguments[0];
  22232. var n = ring$1.size();
  22233. if (n < 3) {
  22234. return 0;
  22235. }
  22236. var p0 = new Coordinate();
  22237. var p1 = new Coordinate();
  22238. var p2 = new Coordinate();
  22239. ring$1.getCoordinate(0, p1);
  22240. ring$1.getCoordinate(1, p2);
  22241. var x0$1 = p1.x;
  22242. p2.x -= x0$1;
  22243. var sum$1 = 0;
  22244. for (var i$1 = 1; i$1 < n - 1; i$1++) {
  22245. p0.y = p1.y;
  22246. p1.x = p2.x;
  22247. p1.y = p2.y;
  22248. ring$1.getCoordinate(i$1 + 1, p2);
  22249. p2.x -= x0$1;
  22250. sum$1 += p1.x * (p0.y - p2.y);
  22251. }
  22252. return sum$1 / 2;
  22253. }
  22254. };
  22255. CGAlgorithms.distanceLineLine = function distanceLineLine(A, B2, C, D) {
  22256. if (A.equals(B2)) {
  22257. return CGAlgorithms.distancePointLine(A, C, D);
  22258. }
  22259. if (C.equals(D)) {
  22260. return CGAlgorithms.distancePointLine(D, A, B2);
  22261. }
  22262. var noIntersection = false;
  22263. if (!Envelope.intersects(A, B2, C, D)) {
  22264. noIntersection = true;
  22265. } else {
  22266. var denom = (B2.x - A.x) * (D.y - C.y) - (B2.y - A.y) * (D.x - C.x);
  22267. if (denom === 0) {
  22268. noIntersection = true;
  22269. } else {
  22270. var rNumb = (A.y - C.y) * (D.x - C.x) - (A.x - C.x) * (D.y - C.y);
  22271. var sNum = (A.y - C.y) * (B2.x - A.x) - (A.x - C.x) * (B2.y - A.y);
  22272. var s = sNum / denom;
  22273. var r = rNumb / denom;
  22274. if (r < 0 || r > 1 || s < 0 || s > 1) {
  22275. noIntersection = true;
  22276. }
  22277. }
  22278. }
  22279. if (noIntersection) {
  22280. return MathUtil.min(CGAlgorithms.distancePointLine(A, C, D), CGAlgorithms.distancePointLine(B2, C, D), CGAlgorithms.distancePointLine(C, A, B2), CGAlgorithms.distancePointLine(D, A, B2));
  22281. }
  22282. return 0;
  22283. };
  22284. CGAlgorithms.isPointInRing = function isPointInRing(p, ring) {
  22285. return CGAlgorithms.locatePointInRing(p, ring) !== Location.EXTERIOR;
  22286. };
  22287. CGAlgorithms.computeLength = function computeLength(pts) {
  22288. var n = pts.size();
  22289. if (n <= 1) {
  22290. return 0;
  22291. }
  22292. var len = 0;
  22293. var p = new Coordinate();
  22294. pts.getCoordinate(0, p);
  22295. var x02 = p.x;
  22296. var y02 = p.y;
  22297. for (var i = 1; i < n; i++) {
  22298. pts.getCoordinate(i, p);
  22299. var x12 = p.x;
  22300. var y12 = p.y;
  22301. var dx = x12 - x02;
  22302. var dy = y12 - y02;
  22303. len += Math.sqrt(dx * dx + dy * dy);
  22304. x02 = x12;
  22305. y02 = y12;
  22306. }
  22307. return len;
  22308. };
  22309. CGAlgorithms.isCCW = function isCCW(ring) {
  22310. var nPts = ring.length - 1;
  22311. if (nPts < 3) {
  22312. throw new IllegalArgumentException("Ring has fewer than 4 points, so orientation cannot be determined");
  22313. }
  22314. var hiPt = ring[0];
  22315. var hiIndex = 0;
  22316. for (var i = 1; i <= nPts; i++) {
  22317. var p = ring[i];
  22318. if (p.y > hiPt.y) {
  22319. hiPt = p;
  22320. hiIndex = i;
  22321. }
  22322. }
  22323. var iPrev = hiIndex;
  22324. do {
  22325. iPrev = iPrev - 1;
  22326. if (iPrev < 0) {
  22327. iPrev = nPts;
  22328. }
  22329. } while (ring[iPrev].equals2D(hiPt) && iPrev !== hiIndex);
  22330. var iNext = hiIndex;
  22331. do {
  22332. iNext = (iNext + 1) % nPts;
  22333. } while (ring[iNext].equals2D(hiPt) && iNext !== hiIndex);
  22334. var prev = ring[iPrev];
  22335. var next3 = ring[iNext];
  22336. if (prev.equals2D(hiPt) || next3.equals2D(hiPt) || prev.equals2D(next3)) {
  22337. return false;
  22338. }
  22339. var disc = CGAlgorithms.computeOrientation(prev, hiPt, next3);
  22340. var isCCW2 = false;
  22341. if (disc === 0) {
  22342. isCCW2 = prev.x > next3.x;
  22343. } else {
  22344. isCCW2 = disc > 0;
  22345. }
  22346. return isCCW2;
  22347. };
  22348. CGAlgorithms.locatePointInRing = function locatePointInRing2(p, ring) {
  22349. return RayCrossingCounter.locatePointInRing(p, ring);
  22350. };
  22351. CGAlgorithms.distancePointLinePerpendicular = function distancePointLinePerpendicular(p, A, B2) {
  22352. var len2 = (B2.x - A.x) * (B2.x - A.x) + (B2.y - A.y) * (B2.y - A.y);
  22353. var s = ((A.y - p.y) * (B2.x - A.x) - (A.x - p.x) * (B2.y - A.y)) / len2;
  22354. return Math.abs(s) * Math.sqrt(len2);
  22355. };
  22356. CGAlgorithms.computeOrientation = function computeOrientation(p1, p2, q) {
  22357. return CGAlgorithms.orientationIndex(p1, p2, q);
  22358. };
  22359. CGAlgorithms.distancePointLine = function distancePointLine() {
  22360. if (arguments.length === 2) {
  22361. var p = arguments[0];
  22362. var line = arguments[1];
  22363. if (line.length === 0) {
  22364. throw new IllegalArgumentException("Line array must contain at least one vertex");
  22365. }
  22366. var minDistance = p.distance(line[0]);
  22367. for (var i = 0; i < line.length - 1; i++) {
  22368. var dist = CGAlgorithms.distancePointLine(p, line[i], line[i + 1]);
  22369. if (dist < minDistance) {
  22370. minDistance = dist;
  22371. }
  22372. }
  22373. return minDistance;
  22374. } else if (arguments.length === 3) {
  22375. var p$1 = arguments[0];
  22376. var A = arguments[1];
  22377. var B2 = arguments[2];
  22378. if (A.x === B2.x && A.y === B2.y) {
  22379. return p$1.distance(A);
  22380. }
  22381. var len2 = (B2.x - A.x) * (B2.x - A.x) + (B2.y - A.y) * (B2.y - A.y);
  22382. var r = ((p$1.x - A.x) * (B2.x - A.x) + (p$1.y - A.y) * (B2.y - A.y)) / len2;
  22383. if (r <= 0) {
  22384. return p$1.distance(A);
  22385. }
  22386. if (r >= 1) {
  22387. return p$1.distance(B2);
  22388. }
  22389. var s = ((A.y - p$1.y) * (B2.x - A.x) - (A.x - p$1.x) * (B2.y - A.y)) / len2;
  22390. return Math.abs(s) * Math.sqrt(len2);
  22391. }
  22392. };
  22393. CGAlgorithms.isOnLine = function isOnLine(p, pt) {
  22394. var lineIntersector = new RobustLineIntersector();
  22395. for (var i = 1; i < pt.length; i++) {
  22396. var p0 = pt[i - 1];
  22397. var p1 = pt[i];
  22398. lineIntersector.computeIntersection(p, p0, p1);
  22399. if (lineIntersector.hasIntersection()) {
  22400. return true;
  22401. }
  22402. }
  22403. return false;
  22404. };
  22405. staticAccessors$3.CLOCKWISE.get = function() {
  22406. return -1;
  22407. };
  22408. staticAccessors$3.RIGHT.get = function() {
  22409. return CGAlgorithms.CLOCKWISE;
  22410. };
  22411. staticAccessors$3.COUNTERCLOCKWISE.get = function() {
  22412. return 1;
  22413. };
  22414. staticAccessors$3.LEFT.get = function() {
  22415. return CGAlgorithms.COUNTERCLOCKWISE;
  22416. };
  22417. staticAccessors$3.COLLINEAR.get = function() {
  22418. return 0;
  22419. };
  22420. staticAccessors$3.STRAIGHT.get = function() {
  22421. return CGAlgorithms.COLLINEAR;
  22422. };
  22423. Object.defineProperties(CGAlgorithms, staticAccessors$3);
  22424. var GeometryComponentFilter = function GeometryComponentFilter2() {
  22425. };
  22426. GeometryComponentFilter.prototype.filter = function filter(geom) {
  22427. };
  22428. GeometryComponentFilter.prototype.interfaces_ = function interfaces_17() {
  22429. return [];
  22430. };
  22431. GeometryComponentFilter.prototype.getClass = function getClass17() {
  22432. return GeometryComponentFilter;
  22433. };
  22434. var Geometry = function Geometry2() {
  22435. var factory = arguments[0];
  22436. this._envelope = null;
  22437. this._factory = null;
  22438. this._SRID = null;
  22439. this._userData = null;
  22440. this._factory = factory;
  22441. this._SRID = factory.getSRID();
  22442. };
  22443. var staticAccessors$11 = { serialVersionUID: { configurable: true }, SORTINDEX_POINT: { configurable: true }, SORTINDEX_MULTIPOINT: { configurable: true }, SORTINDEX_LINESTRING: { configurable: true }, SORTINDEX_LINEARRING: { configurable: true }, SORTINDEX_MULTILINESTRING: { configurable: true }, SORTINDEX_POLYGON: { configurable: true }, SORTINDEX_MULTIPOLYGON: { configurable: true }, SORTINDEX_GEOMETRYCOLLECTION: { configurable: true }, geometryChangedFilter: { configurable: true } };
  22444. Geometry.prototype.isGeometryCollection = function isGeometryCollection() {
  22445. return this.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION;
  22446. };
  22447. Geometry.prototype.getFactory = function getFactory() {
  22448. return this._factory;
  22449. };
  22450. Geometry.prototype.getGeometryN = function getGeometryN(n) {
  22451. return this;
  22452. };
  22453. Geometry.prototype.getArea = function getArea2() {
  22454. return 0;
  22455. };
  22456. Geometry.prototype.isRectangle = function isRectangle() {
  22457. return false;
  22458. };
  22459. Geometry.prototype.equals = function equals6() {
  22460. if (arguments[0] instanceof Geometry) {
  22461. var g$1 = arguments[0];
  22462. if (g$1 === null) {
  22463. return false;
  22464. }
  22465. return this.equalsTopo(g$1);
  22466. } else if (arguments[0] instanceof Object) {
  22467. var o = arguments[0];
  22468. if (!(o instanceof Geometry)) {
  22469. return false;
  22470. }
  22471. var g = o;
  22472. return this.equalsExact(g);
  22473. }
  22474. };
  22475. Geometry.prototype.equalsExact = function equalsExact(other) {
  22476. return this === other || this.equalsExact(other, 0);
  22477. };
  22478. Geometry.prototype.geometryChanged = function geometryChanged() {
  22479. this.apply(Geometry.geometryChangedFilter);
  22480. };
  22481. Geometry.prototype.geometryChangedAction = function geometryChangedAction() {
  22482. this._envelope = null;
  22483. };
  22484. Geometry.prototype.equalsNorm = function equalsNorm(g) {
  22485. if (g === null) {
  22486. return false;
  22487. }
  22488. return this.norm().equalsExact(g.norm());
  22489. };
  22490. Geometry.prototype.getLength = function getLength() {
  22491. return 0;
  22492. };
  22493. Geometry.prototype.getNumGeometries = function getNumGeometries() {
  22494. return 1;
  22495. };
  22496. Geometry.prototype.compareTo = function compareTo5() {
  22497. if (arguments.length === 1) {
  22498. var o = arguments[0];
  22499. var other = o;
  22500. if (this.getSortIndex() !== other.getSortIndex()) {
  22501. return this.getSortIndex() - other.getSortIndex();
  22502. }
  22503. if (this.isEmpty() && other.isEmpty()) {
  22504. return 0;
  22505. }
  22506. if (this.isEmpty()) {
  22507. return -1;
  22508. }
  22509. if (other.isEmpty()) {
  22510. return 1;
  22511. }
  22512. return this.compareToSameClass(o);
  22513. } else if (arguments.length === 2) {
  22514. var other$1 = arguments[0];
  22515. var comp = arguments[1];
  22516. if (this.getSortIndex() !== other$1.getSortIndex()) {
  22517. return this.getSortIndex() - other$1.getSortIndex();
  22518. }
  22519. if (this.isEmpty() && other$1.isEmpty()) {
  22520. return 0;
  22521. }
  22522. if (this.isEmpty()) {
  22523. return -1;
  22524. }
  22525. if (other$1.isEmpty()) {
  22526. return 1;
  22527. }
  22528. return this.compareToSameClass(other$1, comp);
  22529. }
  22530. };
  22531. Geometry.prototype.getUserData = function getUserData() {
  22532. return this._userData;
  22533. };
  22534. Geometry.prototype.getSRID = function getSRID() {
  22535. return this._SRID;
  22536. };
  22537. Geometry.prototype.getEnvelope = function getEnvelope() {
  22538. return this.getFactory().toGeometry(this.getEnvelopeInternal());
  22539. };
  22540. Geometry.prototype.checkNotGeometryCollection = function checkNotGeometryCollection(g) {
  22541. if (g.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION) {
  22542. throw new IllegalArgumentException("This method does not support GeometryCollection arguments");
  22543. }
  22544. };
  22545. Geometry.prototype.equal = function equal2(a, b, tolerance) {
  22546. if (tolerance === 0) {
  22547. return a.equals(b);
  22548. }
  22549. return a.distance(b) <= tolerance;
  22550. };
  22551. Geometry.prototype.norm = function norm() {
  22552. var copy7 = this.copy();
  22553. copy7.normalize();
  22554. return copy7;
  22555. };
  22556. Geometry.prototype.getPrecisionModel = function getPrecisionModel() {
  22557. return this._factory.getPrecisionModel();
  22558. };
  22559. Geometry.prototype.getEnvelopeInternal = function getEnvelopeInternal() {
  22560. if (this._envelope === null) {
  22561. this._envelope = this.computeEnvelopeInternal();
  22562. }
  22563. return new Envelope(this._envelope);
  22564. };
  22565. Geometry.prototype.setSRID = function setSRID(SRID) {
  22566. this._SRID = SRID;
  22567. };
  22568. Geometry.prototype.setUserData = function setUserData(userData) {
  22569. this._userData = userData;
  22570. };
  22571. Geometry.prototype.compare = function compare3(a, b) {
  22572. var i = a.iterator();
  22573. var j = b.iterator();
  22574. while (i.hasNext() && j.hasNext()) {
  22575. var aElement = i.next();
  22576. var bElement = j.next();
  22577. var comparison = aElement.compareTo(bElement);
  22578. if (comparison !== 0) {
  22579. return comparison;
  22580. }
  22581. }
  22582. if (i.hasNext()) {
  22583. return 1;
  22584. }
  22585. if (j.hasNext()) {
  22586. return -1;
  22587. }
  22588. return 0;
  22589. };
  22590. Geometry.prototype.hashCode = function hashCode4() {
  22591. return this.getEnvelopeInternal().hashCode();
  22592. };
  22593. Geometry.prototype.isGeometryCollectionOrDerived = function isGeometryCollectionOrDerived() {
  22594. if (this.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION || this.getSortIndex() === Geometry.SORTINDEX_MULTIPOINT || this.getSortIndex() === Geometry.SORTINDEX_MULTILINESTRING || this.getSortIndex() === Geometry.SORTINDEX_MULTIPOLYGON) {
  22595. return true;
  22596. }
  22597. return false;
  22598. };
  22599. Geometry.prototype.interfaces_ = function interfaces_18() {
  22600. return [Clonable, Comparable, Serializable];
  22601. };
  22602. Geometry.prototype.getClass = function getClass18() {
  22603. return Geometry;
  22604. };
  22605. Geometry.hasNonEmptyElements = function hasNonEmptyElements(geometries) {
  22606. for (var i = 0; i < geometries.length; i++) {
  22607. if (!geometries[i].isEmpty()) {
  22608. return true;
  22609. }
  22610. }
  22611. return false;
  22612. };
  22613. Geometry.hasNullElements = function hasNullElements(array2) {
  22614. for (var i = 0; i < array2.length; i++) {
  22615. if (array2[i] === null) {
  22616. return true;
  22617. }
  22618. }
  22619. return false;
  22620. };
  22621. staticAccessors$11.serialVersionUID.get = function() {
  22622. return 8763622679187377e3;
  22623. };
  22624. staticAccessors$11.SORTINDEX_POINT.get = function() {
  22625. return 0;
  22626. };
  22627. staticAccessors$11.SORTINDEX_MULTIPOINT.get = function() {
  22628. return 1;
  22629. };
  22630. staticAccessors$11.SORTINDEX_LINESTRING.get = function() {
  22631. return 2;
  22632. };
  22633. staticAccessors$11.SORTINDEX_LINEARRING.get = function() {
  22634. return 3;
  22635. };
  22636. staticAccessors$11.SORTINDEX_MULTILINESTRING.get = function() {
  22637. return 4;
  22638. };
  22639. staticAccessors$11.SORTINDEX_POLYGON.get = function() {
  22640. return 5;
  22641. };
  22642. staticAccessors$11.SORTINDEX_MULTIPOLYGON.get = function() {
  22643. return 6;
  22644. };
  22645. staticAccessors$11.SORTINDEX_GEOMETRYCOLLECTION.get = function() {
  22646. return 7;
  22647. };
  22648. staticAccessors$11.geometryChangedFilter.get = function() {
  22649. return geometryChangedFilter;
  22650. };
  22651. Object.defineProperties(Geometry, staticAccessors$11);
  22652. var geometryChangedFilter = function geometryChangedFilter2() {
  22653. };
  22654. geometryChangedFilter.interfaces_ = function interfaces_19() {
  22655. return [GeometryComponentFilter];
  22656. };
  22657. geometryChangedFilter.filter = function filter2(geom) {
  22658. geom.geometryChangedAction();
  22659. };
  22660. var CoordinateFilter = function CoordinateFilter2() {
  22661. };
  22662. CoordinateFilter.prototype.filter = function filter3(coord) {
  22663. };
  22664. CoordinateFilter.prototype.interfaces_ = function interfaces_20() {
  22665. return [];
  22666. };
  22667. CoordinateFilter.prototype.getClass = function getClass19() {
  22668. return CoordinateFilter;
  22669. };
  22670. var BoundaryNodeRule = function BoundaryNodeRule2() {
  22671. };
  22672. var staticAccessors$12 = { Mod2BoundaryNodeRule: { configurable: true }, EndPointBoundaryNodeRule: { configurable: true }, MultiValentEndPointBoundaryNodeRule: { configurable: true }, MonoValentEndPointBoundaryNodeRule: { configurable: true }, MOD2_BOUNDARY_RULE: { configurable: true }, ENDPOINT_BOUNDARY_RULE: { configurable: true }, MULTIVALENT_ENDPOINT_BOUNDARY_RULE: { configurable: true }, MONOVALENT_ENDPOINT_BOUNDARY_RULE: { configurable: true }, OGC_SFS_BOUNDARY_RULE: { configurable: true } };
  22673. BoundaryNodeRule.prototype.isInBoundary = function isInBoundary(boundaryCount) {
  22674. };
  22675. BoundaryNodeRule.prototype.interfaces_ = function interfaces_21() {
  22676. return [];
  22677. };
  22678. BoundaryNodeRule.prototype.getClass = function getClass20() {
  22679. return BoundaryNodeRule;
  22680. };
  22681. staticAccessors$12.Mod2BoundaryNodeRule.get = function() {
  22682. return Mod2BoundaryNodeRule;
  22683. };
  22684. staticAccessors$12.EndPointBoundaryNodeRule.get = function() {
  22685. return EndPointBoundaryNodeRule;
  22686. };
  22687. staticAccessors$12.MultiValentEndPointBoundaryNodeRule.get = function() {
  22688. return MultiValentEndPointBoundaryNodeRule;
  22689. };
  22690. staticAccessors$12.MonoValentEndPointBoundaryNodeRule.get = function() {
  22691. return MonoValentEndPointBoundaryNodeRule;
  22692. };
  22693. staticAccessors$12.MOD2_BOUNDARY_RULE.get = function() {
  22694. return new Mod2BoundaryNodeRule();
  22695. };
  22696. staticAccessors$12.ENDPOINT_BOUNDARY_RULE.get = function() {
  22697. return new EndPointBoundaryNodeRule();
  22698. };
  22699. staticAccessors$12.MULTIVALENT_ENDPOINT_BOUNDARY_RULE.get = function() {
  22700. return new MultiValentEndPointBoundaryNodeRule();
  22701. };
  22702. staticAccessors$12.MONOVALENT_ENDPOINT_BOUNDARY_RULE.get = function() {
  22703. return new MonoValentEndPointBoundaryNodeRule();
  22704. };
  22705. staticAccessors$12.OGC_SFS_BOUNDARY_RULE.get = function() {
  22706. return BoundaryNodeRule.MOD2_BOUNDARY_RULE;
  22707. };
  22708. Object.defineProperties(BoundaryNodeRule, staticAccessors$12);
  22709. var Mod2BoundaryNodeRule = function Mod2BoundaryNodeRule2() {
  22710. };
  22711. Mod2BoundaryNodeRule.prototype.isInBoundary = function isInBoundary2(boundaryCount) {
  22712. return boundaryCount % 2 === 1;
  22713. };
  22714. Mod2BoundaryNodeRule.prototype.interfaces_ = function interfaces_22() {
  22715. return [BoundaryNodeRule];
  22716. };
  22717. Mod2BoundaryNodeRule.prototype.getClass = function getClass21() {
  22718. return Mod2BoundaryNodeRule;
  22719. };
  22720. var EndPointBoundaryNodeRule = function EndPointBoundaryNodeRule2() {
  22721. };
  22722. EndPointBoundaryNodeRule.prototype.isInBoundary = function isInBoundary3(boundaryCount) {
  22723. return boundaryCount > 0;
  22724. };
  22725. EndPointBoundaryNodeRule.prototype.interfaces_ = function interfaces_23() {
  22726. return [BoundaryNodeRule];
  22727. };
  22728. EndPointBoundaryNodeRule.prototype.getClass = function getClass22() {
  22729. return EndPointBoundaryNodeRule;
  22730. };
  22731. var MultiValentEndPointBoundaryNodeRule = function MultiValentEndPointBoundaryNodeRule2() {
  22732. };
  22733. MultiValentEndPointBoundaryNodeRule.prototype.isInBoundary = function isInBoundary4(boundaryCount) {
  22734. return boundaryCount > 1;
  22735. };
  22736. MultiValentEndPointBoundaryNodeRule.prototype.interfaces_ = function interfaces_24() {
  22737. return [BoundaryNodeRule];
  22738. };
  22739. MultiValentEndPointBoundaryNodeRule.prototype.getClass = function getClass23() {
  22740. return MultiValentEndPointBoundaryNodeRule;
  22741. };
  22742. var MonoValentEndPointBoundaryNodeRule = function MonoValentEndPointBoundaryNodeRule2() {
  22743. };
  22744. MonoValentEndPointBoundaryNodeRule.prototype.isInBoundary = function isInBoundary5(boundaryCount) {
  22745. return boundaryCount === 1;
  22746. };
  22747. MonoValentEndPointBoundaryNodeRule.prototype.interfaces_ = function interfaces_25() {
  22748. return [BoundaryNodeRule];
  22749. };
  22750. MonoValentEndPointBoundaryNodeRule.prototype.getClass = function getClass24() {
  22751. return MonoValentEndPointBoundaryNodeRule;
  22752. };
  22753. var Collection = function Collection2() {
  22754. };
  22755. Collection.prototype.add = function add3() {
  22756. };
  22757. Collection.prototype.addAll = function addAll() {
  22758. };
  22759. Collection.prototype.isEmpty = function isEmpty() {
  22760. };
  22761. Collection.prototype.iterator = function iterator() {
  22762. };
  22763. Collection.prototype.size = function size2() {
  22764. };
  22765. Collection.prototype.toArray = function toArray() {
  22766. };
  22767. Collection.prototype.remove = function remove() {
  22768. };
  22769. function IndexOutOfBoundsException(message) {
  22770. this.message = message || "";
  22771. }
  22772. IndexOutOfBoundsException.prototype = new Error();
  22773. IndexOutOfBoundsException.prototype.name = "IndexOutOfBoundsException";
  22774. var Iterator = function Iterator2() {
  22775. };
  22776. Iterator.prototype.hasNext = function hasNext() {
  22777. };
  22778. Iterator.prototype.next = function next() {
  22779. };
  22780. Iterator.prototype.remove = function remove2() {
  22781. };
  22782. var List = function(Collection$$1) {
  22783. function List2() {
  22784. Collection$$1.apply(this, arguments);
  22785. }
  22786. if (Collection$$1)
  22787. List2.__proto__ = Collection$$1;
  22788. List2.prototype = Object.create(Collection$$1 && Collection$$1.prototype);
  22789. List2.prototype.constructor = List2;
  22790. List2.prototype.get = function get4() {
  22791. };
  22792. List2.prototype.set = function set() {
  22793. };
  22794. List2.prototype.isEmpty = function isEmpty6() {
  22795. };
  22796. return List2;
  22797. }(Collection);
  22798. function NoSuchElementException(message) {
  22799. this.message = message || "";
  22800. }
  22801. NoSuchElementException.prototype = new Error();
  22802. NoSuchElementException.prototype.name = "NoSuchElementException";
  22803. var ArrayList = function(List$$1) {
  22804. function ArrayList2() {
  22805. List$$1.call(this);
  22806. this.array_ = [];
  22807. if (arguments[0] instanceof Collection) {
  22808. this.addAll(arguments[0]);
  22809. }
  22810. }
  22811. if (List$$1)
  22812. ArrayList2.__proto__ = List$$1;
  22813. ArrayList2.prototype = Object.create(List$$1 && List$$1.prototype);
  22814. ArrayList2.prototype.constructor = ArrayList2;
  22815. ArrayList2.prototype.ensureCapacity = function ensureCapacity() {
  22816. };
  22817. ArrayList2.prototype.interfaces_ = function interfaces_170() {
  22818. return [List$$1, Collection];
  22819. };
  22820. ArrayList2.prototype.add = function add17(e) {
  22821. if (arguments.length === 1) {
  22822. this.array_.push(e);
  22823. } else {
  22824. this.array_.splice(arguments[0], arguments[1]);
  22825. }
  22826. return true;
  22827. };
  22828. ArrayList2.prototype.clear = function clear2() {
  22829. this.array_ = [];
  22830. };
  22831. ArrayList2.prototype.addAll = function addAll3(c) {
  22832. var this$1 = this;
  22833. for (var i = c.iterator(); i.hasNext(); ) {
  22834. this$1.add(i.next());
  22835. }
  22836. return true;
  22837. };
  22838. ArrayList2.prototype.set = function set(index2, element) {
  22839. var oldElement = this.array_[index2];
  22840. this.array_[index2] = element;
  22841. return oldElement;
  22842. };
  22843. ArrayList2.prototype.iterator = function iterator7() {
  22844. return new Iterator_(this);
  22845. };
  22846. ArrayList2.prototype.get = function get4(index2) {
  22847. if (index2 < 0 || index2 >= this.size()) {
  22848. throw new IndexOutOfBoundsException();
  22849. }
  22850. return this.array_[index2];
  22851. };
  22852. ArrayList2.prototype.isEmpty = function isEmpty6() {
  22853. return this.array_.length === 0;
  22854. };
  22855. ArrayList2.prototype.size = function size11() {
  22856. return this.array_.length;
  22857. };
  22858. ArrayList2.prototype.toArray = function toArray2() {
  22859. var this$1 = this;
  22860. var array2 = [];
  22861. for (var i = 0, len = this.array_.length; i < len; i++) {
  22862. array2.push(this$1.array_[i]);
  22863. }
  22864. return array2;
  22865. };
  22866. ArrayList2.prototype.remove = function remove6(o) {
  22867. var this$1 = this;
  22868. var found = false;
  22869. for (var i = 0, len = this.array_.length; i < len; i++) {
  22870. if (this$1.array_[i] === o) {
  22871. this$1.array_.splice(i, 1);
  22872. found = true;
  22873. break;
  22874. }
  22875. }
  22876. return found;
  22877. };
  22878. return ArrayList2;
  22879. }(List);
  22880. var Iterator_ = function(Iterator$$1) {
  22881. function Iterator_2(arrayList) {
  22882. Iterator$$1.call(this);
  22883. this.arrayList_ = arrayList;
  22884. this.position_ = 0;
  22885. }
  22886. if (Iterator$$1)
  22887. Iterator_2.__proto__ = Iterator$$1;
  22888. Iterator_2.prototype = Object.create(Iterator$$1 && Iterator$$1.prototype);
  22889. Iterator_2.prototype.constructor = Iterator_2;
  22890. Iterator_2.prototype.next = function next3() {
  22891. if (this.position_ === this.arrayList_.size()) {
  22892. throw new NoSuchElementException();
  22893. }
  22894. return this.arrayList_.get(this.position_++);
  22895. };
  22896. Iterator_2.prototype.hasNext = function hasNext3() {
  22897. if (this.position_ < this.arrayList_.size()) {
  22898. return true;
  22899. } else {
  22900. return false;
  22901. }
  22902. };
  22903. Iterator_2.prototype.set = function set(element) {
  22904. return this.arrayList_.set(this.position_ - 1, element);
  22905. };
  22906. Iterator_2.prototype.remove = function remove6() {
  22907. this.arrayList_.remove(this.arrayList_.get(this.position_));
  22908. };
  22909. return Iterator_2;
  22910. }(Iterator);
  22911. var CoordinateList = function(ArrayList$$1) {
  22912. function CoordinateList2() {
  22913. ArrayList$$1.call(this);
  22914. if (arguments.length === 0) {
  22915. } else if (arguments.length === 1) {
  22916. var coord = arguments[0];
  22917. this.ensureCapacity(coord.length);
  22918. this.add(coord, true);
  22919. } else if (arguments.length === 2) {
  22920. var coord$1 = arguments[0];
  22921. var allowRepeated = arguments[1];
  22922. this.ensureCapacity(coord$1.length);
  22923. this.add(coord$1, allowRepeated);
  22924. }
  22925. }
  22926. if (ArrayList$$1)
  22927. CoordinateList2.__proto__ = ArrayList$$1;
  22928. CoordinateList2.prototype = Object.create(ArrayList$$1 && ArrayList$$1.prototype);
  22929. CoordinateList2.prototype.constructor = CoordinateList2;
  22930. var staticAccessors2 = { coordArrayType: { configurable: true } };
  22931. staticAccessors2.coordArrayType.get = function() {
  22932. return new Array(0).fill(null);
  22933. };
  22934. CoordinateList2.prototype.getCoordinate = function getCoordinate18(i) {
  22935. return this.get(i);
  22936. };
  22937. CoordinateList2.prototype.addAll = function addAll3() {
  22938. var this$1 = this;
  22939. if (arguments.length === 2) {
  22940. var coll = arguments[0];
  22941. var allowRepeated = arguments[1];
  22942. var isChanged = false;
  22943. for (var i = coll.iterator(); i.hasNext(); ) {
  22944. this$1.add(i.next(), allowRepeated);
  22945. isChanged = true;
  22946. }
  22947. return isChanged;
  22948. } else {
  22949. return ArrayList$$1.prototype.addAll.apply(this, arguments);
  22950. }
  22951. };
  22952. CoordinateList2.prototype.clone = function clone6() {
  22953. var this$1 = this;
  22954. var clone7 = ArrayList$$1.prototype.clone.call(this);
  22955. for (var i = 0; i < this.size(); i++) {
  22956. clone7.add(i, this$1.get(i).copy());
  22957. }
  22958. return clone7;
  22959. };
  22960. CoordinateList2.prototype.toCoordinateArray = function toCoordinateArray4() {
  22961. return this.toArray(CoordinateList2.coordArrayType);
  22962. };
  22963. CoordinateList2.prototype.add = function add17() {
  22964. var this$1 = this;
  22965. if (arguments.length === 1) {
  22966. var coord = arguments[0];
  22967. ArrayList$$1.prototype.add.call(this, coord);
  22968. } else if (arguments.length === 2) {
  22969. if (arguments[0] instanceof Array && typeof arguments[1] === "boolean") {
  22970. var coord$1 = arguments[0];
  22971. var allowRepeated = arguments[1];
  22972. this.add(coord$1, allowRepeated, true);
  22973. return true;
  22974. } else if (arguments[0] instanceof Coordinate && typeof arguments[1] === "boolean") {
  22975. var coord$2 = arguments[0];
  22976. var allowRepeated$1 = arguments[1];
  22977. if (!allowRepeated$1) {
  22978. if (this.size() >= 1) {
  22979. var last = this.get(this.size() - 1);
  22980. if (last.equals2D(coord$2)) {
  22981. return null;
  22982. }
  22983. }
  22984. }
  22985. ArrayList$$1.prototype.add.call(this, coord$2);
  22986. } else if (arguments[0] instanceof Object && typeof arguments[1] === "boolean") {
  22987. var obj = arguments[0];
  22988. var allowRepeated$2 = arguments[1];
  22989. this.add(obj, allowRepeated$2);
  22990. return true;
  22991. }
  22992. } else if (arguments.length === 3) {
  22993. if (typeof arguments[2] === "boolean" && (arguments[0] instanceof Array && typeof arguments[1] === "boolean")) {
  22994. var coord$3 = arguments[0];
  22995. var allowRepeated$3 = arguments[1];
  22996. var direction = arguments[2];
  22997. if (direction) {
  22998. for (var i$1 = 0; i$1 < coord$3.length; i$1++) {
  22999. this$1.add(coord$3[i$1], allowRepeated$3);
  23000. }
  23001. } else {
  23002. for (var i$2 = coord$3.length - 1; i$2 >= 0; i$2--) {
  23003. this$1.add(coord$3[i$2], allowRepeated$3);
  23004. }
  23005. }
  23006. return true;
  23007. } else if (typeof arguments[2] === "boolean" && (Number.isInteger(arguments[0]) && arguments[1] instanceof Coordinate)) {
  23008. var i$3 = arguments[0];
  23009. var coord$4 = arguments[1];
  23010. var allowRepeated$4 = arguments[2];
  23011. if (!allowRepeated$4) {
  23012. var size11 = this.size();
  23013. if (size11 > 0) {
  23014. if (i$3 > 0) {
  23015. var prev = this.get(i$3 - 1);
  23016. if (prev.equals2D(coord$4)) {
  23017. return null;
  23018. }
  23019. }
  23020. if (i$3 < size11) {
  23021. var next3 = this.get(i$3);
  23022. if (next3.equals2D(coord$4)) {
  23023. return null;
  23024. }
  23025. }
  23026. }
  23027. }
  23028. ArrayList$$1.prototype.add.call(this, i$3, coord$4);
  23029. }
  23030. } else if (arguments.length === 4) {
  23031. var coord$5 = arguments[0];
  23032. var allowRepeated$5 = arguments[1];
  23033. var start = arguments[2];
  23034. var end = arguments[3];
  23035. var inc = 1;
  23036. if (start > end) {
  23037. inc = -1;
  23038. }
  23039. for (var i = start; i !== end; i += inc) {
  23040. this$1.add(coord$5[i], allowRepeated$5);
  23041. }
  23042. return true;
  23043. }
  23044. };
  23045. CoordinateList2.prototype.closeRing = function closeRing3() {
  23046. if (this.size() > 0) {
  23047. this.add(new Coordinate(this.get(0)), false);
  23048. }
  23049. };
  23050. CoordinateList2.prototype.interfaces_ = function interfaces_170() {
  23051. return [];
  23052. };
  23053. CoordinateList2.prototype.getClass = function getClass169() {
  23054. return CoordinateList2;
  23055. };
  23056. Object.defineProperties(CoordinateList2, staticAccessors2);
  23057. return CoordinateList2;
  23058. }(ArrayList);
  23059. var CoordinateArrays = function CoordinateArrays2() {
  23060. };
  23061. var staticAccessors$13 = { ForwardComparator: { configurable: true }, BidirectionalComparator: { configurable: true }, coordArrayType: { configurable: true } };
  23062. staticAccessors$13.ForwardComparator.get = function() {
  23063. return ForwardComparator;
  23064. };
  23065. staticAccessors$13.BidirectionalComparator.get = function() {
  23066. return BidirectionalComparator;
  23067. };
  23068. staticAccessors$13.coordArrayType.get = function() {
  23069. return new Array(0).fill(null);
  23070. };
  23071. CoordinateArrays.prototype.interfaces_ = function interfaces_26() {
  23072. return [];
  23073. };
  23074. CoordinateArrays.prototype.getClass = function getClass25() {
  23075. return CoordinateArrays;
  23076. };
  23077. CoordinateArrays.isRing = function isRing(pts) {
  23078. if (pts.length < 4) {
  23079. return false;
  23080. }
  23081. if (!pts[0].equals2D(pts[pts.length - 1])) {
  23082. return false;
  23083. }
  23084. return true;
  23085. };
  23086. CoordinateArrays.ptNotInList = function ptNotInList(testPts, pts) {
  23087. for (var i = 0; i < testPts.length; i++) {
  23088. var testPt = testPts[i];
  23089. if (CoordinateArrays.indexOf(testPt, pts) < 0) {
  23090. return testPt;
  23091. }
  23092. }
  23093. return null;
  23094. };
  23095. CoordinateArrays.scroll = function scroll(coordinates, firstCoordinate) {
  23096. var i = CoordinateArrays.indexOf(firstCoordinate, coordinates);
  23097. if (i < 0) {
  23098. return null;
  23099. }
  23100. var newCoordinates = new Array(coordinates.length).fill(null);
  23101. System.arraycopy(coordinates, i, newCoordinates, 0, coordinates.length - i);
  23102. System.arraycopy(coordinates, 0, newCoordinates, coordinates.length - i, i);
  23103. System.arraycopy(newCoordinates, 0, coordinates, 0, coordinates.length);
  23104. };
  23105. CoordinateArrays.equals = function equals7() {
  23106. if (arguments.length === 2) {
  23107. var coord1 = arguments[0];
  23108. var coord2 = arguments[1];
  23109. if (coord1 === coord2) {
  23110. return true;
  23111. }
  23112. if (coord1 === null || coord2 === null) {
  23113. return false;
  23114. }
  23115. if (coord1.length !== coord2.length) {
  23116. return false;
  23117. }
  23118. for (var i = 0; i < coord1.length; i++) {
  23119. if (!coord1[i].equals(coord2[i])) {
  23120. return false;
  23121. }
  23122. }
  23123. return true;
  23124. } else if (arguments.length === 3) {
  23125. var coord1$1 = arguments[0];
  23126. var coord2$1 = arguments[1];
  23127. var coordinateComparator = arguments[2];
  23128. if (coord1$1 === coord2$1) {
  23129. return true;
  23130. }
  23131. if (coord1$1 === null || coord2$1 === null) {
  23132. return false;
  23133. }
  23134. if (coord1$1.length !== coord2$1.length) {
  23135. return false;
  23136. }
  23137. for (var i$1 = 0; i$1 < coord1$1.length; i$1++) {
  23138. if (coordinateComparator.compare(coord1$1[i$1], coord2$1[i$1]) !== 0) {
  23139. return false;
  23140. }
  23141. }
  23142. return true;
  23143. }
  23144. };
  23145. CoordinateArrays.intersection = function intersection8(coordinates, env) {
  23146. var coordList = new CoordinateList();
  23147. for (var i = 0; i < coordinates.length; i++) {
  23148. if (env.intersects(coordinates[i])) {
  23149. coordList.add(coordinates[i], true);
  23150. }
  23151. }
  23152. return coordList.toCoordinateArray();
  23153. };
  23154. CoordinateArrays.hasRepeatedPoints = function hasRepeatedPoints(coord) {
  23155. for (var i = 1; i < coord.length; i++) {
  23156. if (coord[i - 1].equals(coord[i])) {
  23157. return true;
  23158. }
  23159. }
  23160. return false;
  23161. };
  23162. CoordinateArrays.removeRepeatedPoints = function removeRepeatedPoints(coord) {
  23163. if (!CoordinateArrays.hasRepeatedPoints(coord)) {
  23164. return coord;
  23165. }
  23166. var coordList = new CoordinateList(coord, false);
  23167. return coordList.toCoordinateArray();
  23168. };
  23169. CoordinateArrays.reverse = function reverse2(coord) {
  23170. var last = coord.length - 1;
  23171. var mid = Math.trunc(last / 2);
  23172. for (var i = 0; i <= mid; i++) {
  23173. var tmp = coord[i];
  23174. coord[i] = coord[last - i];
  23175. coord[last - i] = tmp;
  23176. }
  23177. };
  23178. CoordinateArrays.removeNull = function removeNull(coord) {
  23179. var nonNull = 0;
  23180. for (var i = 0; i < coord.length; i++) {
  23181. if (coord[i] !== null) {
  23182. nonNull++;
  23183. }
  23184. }
  23185. var newCoord = new Array(nonNull).fill(null);
  23186. if (nonNull === 0) {
  23187. return newCoord;
  23188. }
  23189. var j = 0;
  23190. for (var i$1 = 0; i$1 < coord.length; i$1++) {
  23191. if (coord[i$1] !== null) {
  23192. newCoord[j++] = coord[i$1];
  23193. }
  23194. }
  23195. return newCoord;
  23196. };
  23197. CoordinateArrays.copyDeep = function copyDeep() {
  23198. if (arguments.length === 1) {
  23199. var coordinates = arguments[0];
  23200. var copy7 = new Array(coordinates.length).fill(null);
  23201. for (var i = 0; i < coordinates.length; i++) {
  23202. copy7[i] = new Coordinate(coordinates[i]);
  23203. }
  23204. return copy7;
  23205. } else if (arguments.length === 5) {
  23206. var src = arguments[0];
  23207. var srcStart = arguments[1];
  23208. var dest = arguments[2];
  23209. var destStart = arguments[3];
  23210. var length4 = arguments[4];
  23211. for (var i$1 = 0; i$1 < length4; i$1++) {
  23212. dest[destStart + i$1] = new Coordinate(src[srcStart + i$1]);
  23213. }
  23214. }
  23215. };
  23216. CoordinateArrays.isEqualReversed = function isEqualReversed(pts1, pts2) {
  23217. for (var i = 0; i < pts1.length; i++) {
  23218. var p1 = pts1[i];
  23219. var p2 = pts2[pts1.length - i - 1];
  23220. if (p1.compareTo(p2) !== 0) {
  23221. return false;
  23222. }
  23223. }
  23224. return true;
  23225. };
  23226. CoordinateArrays.envelope = function envelope2(coordinates) {
  23227. var env = new Envelope();
  23228. for (var i = 0; i < coordinates.length; i++) {
  23229. env.expandToInclude(coordinates[i]);
  23230. }
  23231. return env;
  23232. };
  23233. CoordinateArrays.toCoordinateArray = function toCoordinateArray2(coordList) {
  23234. return coordList.toArray(CoordinateArrays.coordArrayType);
  23235. };
  23236. CoordinateArrays.atLeastNCoordinatesOrNothing = function atLeastNCoordinatesOrNothing(n, c) {
  23237. return c.length >= n ? c : [];
  23238. };
  23239. CoordinateArrays.indexOf = function indexOf(coordinate2, coordinates) {
  23240. for (var i = 0; i < coordinates.length; i++) {
  23241. if (coordinate2.equals(coordinates[i])) {
  23242. return i;
  23243. }
  23244. }
  23245. return -1;
  23246. };
  23247. CoordinateArrays.increasingDirection = function increasingDirection(pts) {
  23248. for (var i = 0; i < Math.trunc(pts.length / 2); i++) {
  23249. var j = pts.length - 1 - i;
  23250. var comp = pts[i].compareTo(pts[j]);
  23251. if (comp !== 0) {
  23252. return comp;
  23253. }
  23254. }
  23255. return 1;
  23256. };
  23257. CoordinateArrays.compare = function compare4(pts1, pts2) {
  23258. var i = 0;
  23259. while (i < pts1.length && i < pts2.length) {
  23260. var compare10 = pts1[i].compareTo(pts2[i]);
  23261. if (compare10 !== 0) {
  23262. return compare10;
  23263. }
  23264. i++;
  23265. }
  23266. if (i < pts2.length) {
  23267. return -1;
  23268. }
  23269. if (i < pts1.length) {
  23270. return 1;
  23271. }
  23272. return 0;
  23273. };
  23274. CoordinateArrays.minCoordinate = function minCoordinate(coordinates) {
  23275. var minCoord = null;
  23276. for (var i = 0; i < coordinates.length; i++) {
  23277. if (minCoord === null || minCoord.compareTo(coordinates[i]) > 0) {
  23278. minCoord = coordinates[i];
  23279. }
  23280. }
  23281. return minCoord;
  23282. };
  23283. CoordinateArrays.extract = function extract(pts, start, end) {
  23284. start = MathUtil.clamp(start, 0, pts.length);
  23285. end = MathUtil.clamp(end, -1, pts.length);
  23286. var npts = end - start + 1;
  23287. if (end < 0) {
  23288. npts = 0;
  23289. }
  23290. if (start >= pts.length) {
  23291. npts = 0;
  23292. }
  23293. if (end < start) {
  23294. npts = 0;
  23295. }
  23296. var extractPts = new Array(npts).fill(null);
  23297. if (npts === 0) {
  23298. return extractPts;
  23299. }
  23300. var iPts = 0;
  23301. for (var i = start; i <= end; i++) {
  23302. extractPts[iPts++] = pts[i];
  23303. }
  23304. return extractPts;
  23305. };
  23306. Object.defineProperties(CoordinateArrays, staticAccessors$13);
  23307. var ForwardComparator = function ForwardComparator2() {
  23308. };
  23309. ForwardComparator.prototype.compare = function compare5(o1, o2) {
  23310. var pts1 = o1;
  23311. var pts2 = o2;
  23312. return CoordinateArrays.compare(pts1, pts2);
  23313. };
  23314. ForwardComparator.prototype.interfaces_ = function interfaces_27() {
  23315. return [Comparator];
  23316. };
  23317. ForwardComparator.prototype.getClass = function getClass26() {
  23318. return ForwardComparator;
  23319. };
  23320. var BidirectionalComparator = function BidirectionalComparator2() {
  23321. };
  23322. BidirectionalComparator.prototype.compare = function compare6(o1, o2) {
  23323. var pts1 = o1;
  23324. var pts2 = o2;
  23325. if (pts1.length < pts2.length) {
  23326. return -1;
  23327. }
  23328. if (pts1.length > pts2.length) {
  23329. return 1;
  23330. }
  23331. if (pts1.length === 0) {
  23332. return 0;
  23333. }
  23334. var forwardComp = CoordinateArrays.compare(pts1, pts2);
  23335. var isEqualRev = CoordinateArrays.isEqualReversed(pts1, pts2);
  23336. if (isEqualRev) {
  23337. return 0;
  23338. }
  23339. return forwardComp;
  23340. };
  23341. BidirectionalComparator.prototype.OLDcompare = function OLDcompare(o1, o2) {
  23342. var pts1 = o1;
  23343. var pts2 = o2;
  23344. if (pts1.length < pts2.length) {
  23345. return -1;
  23346. }
  23347. if (pts1.length > pts2.length) {
  23348. return 1;
  23349. }
  23350. if (pts1.length === 0) {
  23351. return 0;
  23352. }
  23353. var dir1 = CoordinateArrays.increasingDirection(pts1);
  23354. var dir2 = CoordinateArrays.increasingDirection(pts2);
  23355. var i1 = dir1 > 0 ? 0 : pts1.length - 1;
  23356. var i2 = dir2 > 0 ? 0 : pts1.length - 1;
  23357. for (var i = 0; i < pts1.length; i++) {
  23358. var comparePt = pts1[i1].compareTo(pts2[i2]);
  23359. if (comparePt !== 0) {
  23360. return comparePt;
  23361. }
  23362. i1 += dir1;
  23363. i2 += dir2;
  23364. }
  23365. return 0;
  23366. };
  23367. BidirectionalComparator.prototype.interfaces_ = function interfaces_28() {
  23368. return [Comparator];
  23369. };
  23370. BidirectionalComparator.prototype.getClass = function getClass27() {
  23371. return BidirectionalComparator;
  23372. };
  23373. var Map$1 = function Map2() {
  23374. };
  23375. Map$1.prototype.get = function get() {
  23376. };
  23377. Map$1.prototype.put = function put() {
  23378. };
  23379. Map$1.prototype.size = function size3() {
  23380. };
  23381. Map$1.prototype.values = function values() {
  23382. };
  23383. Map$1.prototype.entrySet = function entrySet() {
  23384. };
  23385. var SortedMap = function(Map3) {
  23386. function SortedMap2() {
  23387. Map3.apply(this, arguments);
  23388. }
  23389. if (Map3)
  23390. SortedMap2.__proto__ = Map3;
  23391. SortedMap2.prototype = Object.create(Map3 && Map3.prototype);
  23392. SortedMap2.prototype.constructor = SortedMap2;
  23393. return SortedMap2;
  23394. }(Map$1);
  23395. function OperationNotSupported(message) {
  23396. this.message = message || "";
  23397. }
  23398. OperationNotSupported.prototype = new Error();
  23399. OperationNotSupported.prototype.name = "OperationNotSupported";
  23400. function Set2() {
  23401. }
  23402. Set2.prototype = new Collection();
  23403. Set2.prototype.contains = function() {
  23404. };
  23405. var HashSet = function(Set$$1) {
  23406. function HashSet2() {
  23407. Set$$1.call(this);
  23408. this.array_ = [];
  23409. if (arguments[0] instanceof Collection) {
  23410. this.addAll(arguments[0]);
  23411. }
  23412. }
  23413. if (Set$$1)
  23414. HashSet2.__proto__ = Set$$1;
  23415. HashSet2.prototype = Object.create(Set$$1 && Set$$1.prototype);
  23416. HashSet2.prototype.constructor = HashSet2;
  23417. HashSet2.prototype.contains = function contains2(o) {
  23418. var this$1 = this;
  23419. for (var i = 0, len = this.array_.length; i < len; i++) {
  23420. var e = this$1.array_[i];
  23421. if (e === o) {
  23422. return true;
  23423. }
  23424. }
  23425. return false;
  23426. };
  23427. HashSet2.prototype.add = function add17(o) {
  23428. if (this.contains(o)) {
  23429. return false;
  23430. }
  23431. this.array_.push(o);
  23432. return true;
  23433. };
  23434. HashSet2.prototype.addAll = function addAll3(c) {
  23435. var this$1 = this;
  23436. for (var i = c.iterator(); i.hasNext(); ) {
  23437. this$1.add(i.next());
  23438. }
  23439. return true;
  23440. };
  23441. HashSet2.prototype.remove = function remove6(o) {
  23442. throw new Error();
  23443. };
  23444. HashSet2.prototype.size = function size11() {
  23445. return this.array_.length;
  23446. };
  23447. HashSet2.prototype.isEmpty = function isEmpty6() {
  23448. return this.array_.length === 0;
  23449. };
  23450. HashSet2.prototype.toArray = function toArray2() {
  23451. var this$1 = this;
  23452. var array2 = [];
  23453. for (var i = 0, len = this.array_.length; i < len; i++) {
  23454. array2.push(this$1.array_[i]);
  23455. }
  23456. return array2;
  23457. };
  23458. HashSet2.prototype.iterator = function iterator7() {
  23459. return new Iterator_$1(this);
  23460. };
  23461. return HashSet2;
  23462. }(Set2);
  23463. var Iterator_$1 = function(Iterator$$1) {
  23464. function Iterator_2(hashSet) {
  23465. Iterator$$1.call(this);
  23466. this.hashSet_ = hashSet;
  23467. this.position_ = 0;
  23468. }
  23469. if (Iterator$$1)
  23470. Iterator_2.__proto__ = Iterator$$1;
  23471. Iterator_2.prototype = Object.create(Iterator$$1 && Iterator$$1.prototype);
  23472. Iterator_2.prototype.constructor = Iterator_2;
  23473. Iterator_2.prototype.next = function next3() {
  23474. if (this.position_ === this.hashSet_.size()) {
  23475. throw new NoSuchElementException();
  23476. }
  23477. return this.hashSet_.array_[this.position_++];
  23478. };
  23479. Iterator_2.prototype.hasNext = function hasNext3() {
  23480. if (this.position_ < this.hashSet_.size()) {
  23481. return true;
  23482. } else {
  23483. return false;
  23484. }
  23485. };
  23486. Iterator_2.prototype.remove = function remove6() {
  23487. throw new OperationNotSupported();
  23488. };
  23489. return Iterator_2;
  23490. }(Iterator);
  23491. var BLACK = 0;
  23492. var RED = 1;
  23493. function colorOf(p) {
  23494. return p === null ? BLACK : p.color;
  23495. }
  23496. function parentOf(p) {
  23497. return p === null ? null : p.parent;
  23498. }
  23499. function setColor(p, c) {
  23500. if (p !== null) {
  23501. p.color = c;
  23502. }
  23503. }
  23504. function leftOf(p) {
  23505. return p === null ? null : p.left;
  23506. }
  23507. function rightOf(p) {
  23508. return p === null ? null : p.right;
  23509. }
  23510. function TreeMap() {
  23511. this.root_ = null;
  23512. this.size_ = 0;
  23513. }
  23514. TreeMap.prototype = new SortedMap();
  23515. TreeMap.prototype.get = function(key) {
  23516. var p = this.root_;
  23517. while (p !== null) {
  23518. var cmp3 = key["compareTo"](p.key);
  23519. if (cmp3 < 0) {
  23520. p = p.left;
  23521. } else if (cmp3 > 0) {
  23522. p = p.right;
  23523. } else {
  23524. return p.value;
  23525. }
  23526. }
  23527. return null;
  23528. };
  23529. TreeMap.prototype.put = function(key, value) {
  23530. if (this.root_ === null) {
  23531. this.root_ = {
  23532. key,
  23533. value,
  23534. left: null,
  23535. right: null,
  23536. parent: null,
  23537. color: BLACK,
  23538. getValue: function getValue() {
  23539. return this.value;
  23540. },
  23541. getKey: function getKey() {
  23542. return this.key;
  23543. }
  23544. };
  23545. this.size_ = 1;
  23546. return null;
  23547. }
  23548. var t = this.root_;
  23549. var parent;
  23550. var cmp3;
  23551. do {
  23552. parent = t;
  23553. cmp3 = key["compareTo"](t.key);
  23554. if (cmp3 < 0) {
  23555. t = t.left;
  23556. } else if (cmp3 > 0) {
  23557. t = t.right;
  23558. } else {
  23559. var oldValue = t.value;
  23560. t.value = value;
  23561. return oldValue;
  23562. }
  23563. } while (t !== null);
  23564. var e = {
  23565. key,
  23566. left: null,
  23567. right: null,
  23568. value,
  23569. parent,
  23570. color: BLACK,
  23571. getValue: function getValue() {
  23572. return this.value;
  23573. },
  23574. getKey: function getKey() {
  23575. return this.key;
  23576. }
  23577. };
  23578. if (cmp3 < 0) {
  23579. parent.left = e;
  23580. } else {
  23581. parent.right = e;
  23582. }
  23583. this.fixAfterInsertion(e);
  23584. this.size_++;
  23585. return null;
  23586. };
  23587. TreeMap.prototype.fixAfterInsertion = function(x2) {
  23588. var this$1 = this;
  23589. x2.color = RED;
  23590. while (x2 != null && x2 !== this.root_ && x2.parent.color === RED) {
  23591. if (parentOf(x2) === leftOf(parentOf(parentOf(x2)))) {
  23592. var y2 = rightOf(parentOf(parentOf(x2)));
  23593. if (colorOf(y2) === RED) {
  23594. setColor(parentOf(x2), BLACK);
  23595. setColor(y2, BLACK);
  23596. setColor(parentOf(parentOf(x2)), RED);
  23597. x2 = parentOf(parentOf(x2));
  23598. } else {
  23599. if (x2 === rightOf(parentOf(x2))) {
  23600. x2 = parentOf(x2);
  23601. this$1.rotateLeft(x2);
  23602. }
  23603. setColor(parentOf(x2), BLACK);
  23604. setColor(parentOf(parentOf(x2)), RED);
  23605. this$1.rotateRight(parentOf(parentOf(x2)));
  23606. }
  23607. } else {
  23608. var y$1 = leftOf(parentOf(parentOf(x2)));
  23609. if (colorOf(y$1) === RED) {
  23610. setColor(parentOf(x2), BLACK);
  23611. setColor(y$1, BLACK);
  23612. setColor(parentOf(parentOf(x2)), RED);
  23613. x2 = parentOf(parentOf(x2));
  23614. } else {
  23615. if (x2 === leftOf(parentOf(x2))) {
  23616. x2 = parentOf(x2);
  23617. this$1.rotateRight(x2);
  23618. }
  23619. setColor(parentOf(x2), BLACK);
  23620. setColor(parentOf(parentOf(x2)), RED);
  23621. this$1.rotateLeft(parentOf(parentOf(x2)));
  23622. }
  23623. }
  23624. }
  23625. this.root_.color = BLACK;
  23626. };
  23627. TreeMap.prototype.values = function() {
  23628. var arrayList = new ArrayList();
  23629. var p = this.getFirstEntry();
  23630. if (p !== null) {
  23631. arrayList.add(p.value);
  23632. while ((p = TreeMap.successor(p)) !== null) {
  23633. arrayList.add(p.value);
  23634. }
  23635. }
  23636. return arrayList;
  23637. };
  23638. TreeMap.prototype.entrySet = function() {
  23639. var hashSet = new HashSet();
  23640. var p = this.getFirstEntry();
  23641. if (p !== null) {
  23642. hashSet.add(p);
  23643. while ((p = TreeMap.successor(p)) !== null) {
  23644. hashSet.add(p);
  23645. }
  23646. }
  23647. return hashSet;
  23648. };
  23649. TreeMap.prototype.rotateLeft = function(p) {
  23650. if (p != null) {
  23651. var r = p.right;
  23652. p.right = r.left;
  23653. if (r.left != null) {
  23654. r.left.parent = p;
  23655. }
  23656. r.parent = p.parent;
  23657. if (p.parent === null) {
  23658. this.root_ = r;
  23659. } else if (p.parent.left === p) {
  23660. p.parent.left = r;
  23661. } else {
  23662. p.parent.right = r;
  23663. }
  23664. r.left = p;
  23665. p.parent = r;
  23666. }
  23667. };
  23668. TreeMap.prototype.rotateRight = function(p) {
  23669. if (p != null) {
  23670. var l = p.left;
  23671. p.left = l.right;
  23672. if (l.right != null) {
  23673. l.right.parent = p;
  23674. }
  23675. l.parent = p.parent;
  23676. if (p.parent === null) {
  23677. this.root_ = l;
  23678. } else if (p.parent.right === p) {
  23679. p.parent.right = l;
  23680. } else {
  23681. p.parent.left = l;
  23682. }
  23683. l.right = p;
  23684. p.parent = l;
  23685. }
  23686. };
  23687. TreeMap.prototype.getFirstEntry = function() {
  23688. var p = this.root_;
  23689. if (p != null) {
  23690. while (p.left != null) {
  23691. p = p.left;
  23692. }
  23693. }
  23694. return p;
  23695. };
  23696. TreeMap.successor = function(t) {
  23697. if (t === null) {
  23698. return null;
  23699. } else if (t.right !== null) {
  23700. var p = t.right;
  23701. while (p.left !== null) {
  23702. p = p.left;
  23703. }
  23704. return p;
  23705. } else {
  23706. var p$1 = t.parent;
  23707. var ch = t;
  23708. while (p$1 !== null && ch === p$1.right) {
  23709. ch = p$1;
  23710. p$1 = p$1.parent;
  23711. }
  23712. return p$1;
  23713. }
  23714. };
  23715. TreeMap.prototype.size = function() {
  23716. return this.size_;
  23717. };
  23718. var Lineal = function Lineal2() {
  23719. };
  23720. Lineal.prototype.interfaces_ = function interfaces_29() {
  23721. return [];
  23722. };
  23723. Lineal.prototype.getClass = function getClass28() {
  23724. return Lineal;
  23725. };
  23726. function SortedSet() {
  23727. }
  23728. SortedSet.prototype = new Set2();
  23729. function TreeSet() {
  23730. this.array_ = [];
  23731. if (arguments[0] instanceof Collection) {
  23732. this.addAll(arguments[0]);
  23733. }
  23734. }
  23735. TreeSet.prototype = new SortedSet();
  23736. TreeSet.prototype.contains = function(o) {
  23737. var this$1 = this;
  23738. for (var i = 0, len = this.array_.length; i < len; i++) {
  23739. var e = this$1.array_[i];
  23740. if (e["compareTo"](o) === 0) {
  23741. return true;
  23742. }
  23743. }
  23744. return false;
  23745. };
  23746. TreeSet.prototype.add = function(o) {
  23747. var this$1 = this;
  23748. if (this.contains(o)) {
  23749. return false;
  23750. }
  23751. for (var i = 0, len = this.array_.length; i < len; i++) {
  23752. var e = this$1.array_[i];
  23753. if (e["compareTo"](o) === 1) {
  23754. this$1.array_.splice(i, 0, o);
  23755. return true;
  23756. }
  23757. }
  23758. this.array_.push(o);
  23759. return true;
  23760. };
  23761. TreeSet.prototype.addAll = function(c) {
  23762. var this$1 = this;
  23763. for (var i = c.iterator(); i.hasNext(); ) {
  23764. this$1.add(i.next());
  23765. }
  23766. return true;
  23767. };
  23768. TreeSet.prototype.remove = function(e) {
  23769. throw new OperationNotSupported();
  23770. };
  23771. TreeSet.prototype.size = function() {
  23772. return this.array_.length;
  23773. };
  23774. TreeSet.prototype.isEmpty = function() {
  23775. return this.array_.length === 0;
  23776. };
  23777. TreeSet.prototype.toArray = function() {
  23778. var this$1 = this;
  23779. var array2 = [];
  23780. for (var i = 0, len = this.array_.length; i < len; i++) {
  23781. array2.push(this$1.array_[i]);
  23782. }
  23783. return array2;
  23784. };
  23785. TreeSet.prototype.iterator = function() {
  23786. return new Iterator_$2(this);
  23787. };
  23788. var Iterator_$2 = function(treeSet) {
  23789. this.treeSet_ = treeSet;
  23790. this.position_ = 0;
  23791. };
  23792. Iterator_$2.prototype.next = function() {
  23793. if (this.position_ === this.treeSet_.size()) {
  23794. throw new NoSuchElementException();
  23795. }
  23796. return this.treeSet_.array_[this.position_++];
  23797. };
  23798. Iterator_$2.prototype.hasNext = function() {
  23799. if (this.position_ < this.treeSet_.size()) {
  23800. return true;
  23801. } else {
  23802. return false;
  23803. }
  23804. };
  23805. Iterator_$2.prototype.remove = function() {
  23806. throw new OperationNotSupported();
  23807. };
  23808. var Arrays = function Arrays2() {
  23809. };
  23810. Arrays.sort = function sort2() {
  23811. var a = arguments[0];
  23812. var i;
  23813. var t;
  23814. var comparator;
  23815. var compare10;
  23816. if (arguments.length === 1) {
  23817. compare10 = function(a2, b) {
  23818. return a2.compareTo(b);
  23819. };
  23820. a.sort(compare10);
  23821. } else if (arguments.length === 2) {
  23822. comparator = arguments[1];
  23823. compare10 = function(a2, b) {
  23824. return comparator["compare"](a2, b);
  23825. };
  23826. a.sort(compare10);
  23827. } else if (arguments.length === 3) {
  23828. t = a.slice(arguments[1], arguments[2]);
  23829. t.sort();
  23830. var r = a.slice(0, arguments[1]).concat(t, a.slice(arguments[2], a.length));
  23831. a.splice(0, a.length);
  23832. for (i = 0; i < r.length; i++) {
  23833. a.push(r[i]);
  23834. }
  23835. } else if (arguments.length === 4) {
  23836. t = a.slice(arguments[1], arguments[2]);
  23837. comparator = arguments[3];
  23838. compare10 = function(a2, b) {
  23839. return comparator["compare"](a2, b);
  23840. };
  23841. t.sort(compare10);
  23842. r = a.slice(0, arguments[1]).concat(t, a.slice(arguments[2], a.length));
  23843. a.splice(0, a.length);
  23844. for (i = 0; i < r.length; i++) {
  23845. a.push(r[i]);
  23846. }
  23847. }
  23848. };
  23849. Arrays.asList = function asList(array2) {
  23850. var arrayList = new ArrayList();
  23851. for (var i = 0, len = array2.length; i < len; i++) {
  23852. arrayList.add(array2[i]);
  23853. }
  23854. return arrayList;
  23855. };
  23856. var Dimension = function Dimension2() {
  23857. };
  23858. var staticAccessors$14 = { P: { configurable: true }, L: { configurable: true }, A: { configurable: true }, FALSE: { configurable: true }, TRUE: { configurable: true }, DONTCARE: { configurable: true }, SYM_FALSE: { configurable: true }, SYM_TRUE: { configurable: true }, SYM_DONTCARE: { configurable: true }, SYM_P: { configurable: true }, SYM_L: { configurable: true }, SYM_A: { configurable: true } };
  23859. staticAccessors$14.P.get = function() {
  23860. return 0;
  23861. };
  23862. staticAccessors$14.L.get = function() {
  23863. return 1;
  23864. };
  23865. staticAccessors$14.A.get = function() {
  23866. return 2;
  23867. };
  23868. staticAccessors$14.FALSE.get = function() {
  23869. return -1;
  23870. };
  23871. staticAccessors$14.TRUE.get = function() {
  23872. return -2;
  23873. };
  23874. staticAccessors$14.DONTCARE.get = function() {
  23875. return -3;
  23876. };
  23877. staticAccessors$14.SYM_FALSE.get = function() {
  23878. return "F";
  23879. };
  23880. staticAccessors$14.SYM_TRUE.get = function() {
  23881. return "T";
  23882. };
  23883. staticAccessors$14.SYM_DONTCARE.get = function() {
  23884. return "*";
  23885. };
  23886. staticAccessors$14.SYM_P.get = function() {
  23887. return "0";
  23888. };
  23889. staticAccessors$14.SYM_L.get = function() {
  23890. return "1";
  23891. };
  23892. staticAccessors$14.SYM_A.get = function() {
  23893. return "2";
  23894. };
  23895. Dimension.prototype.interfaces_ = function interfaces_30() {
  23896. return [];
  23897. };
  23898. Dimension.prototype.getClass = function getClass29() {
  23899. return Dimension;
  23900. };
  23901. Dimension.toDimensionSymbol = function toDimensionSymbol(dimensionValue) {
  23902. switch (dimensionValue) {
  23903. case Dimension.FALSE:
  23904. return Dimension.SYM_FALSE;
  23905. case Dimension.TRUE:
  23906. return Dimension.SYM_TRUE;
  23907. case Dimension.DONTCARE:
  23908. return Dimension.SYM_DONTCARE;
  23909. case Dimension.P:
  23910. return Dimension.SYM_P;
  23911. case Dimension.L:
  23912. return Dimension.SYM_L;
  23913. case Dimension.A:
  23914. return Dimension.SYM_A;
  23915. default:
  23916. }
  23917. throw new IllegalArgumentException("Unknown dimension value: " + dimensionValue);
  23918. };
  23919. Dimension.toDimensionValue = function toDimensionValue(dimensionSymbol) {
  23920. switch (Character.toUpperCase(dimensionSymbol)) {
  23921. case Dimension.SYM_FALSE:
  23922. return Dimension.FALSE;
  23923. case Dimension.SYM_TRUE:
  23924. return Dimension.TRUE;
  23925. case Dimension.SYM_DONTCARE:
  23926. return Dimension.DONTCARE;
  23927. case Dimension.SYM_P:
  23928. return Dimension.P;
  23929. case Dimension.SYM_L:
  23930. return Dimension.L;
  23931. case Dimension.SYM_A:
  23932. return Dimension.A;
  23933. default:
  23934. }
  23935. throw new IllegalArgumentException("Unknown dimension symbol: " + dimensionSymbol);
  23936. };
  23937. Object.defineProperties(Dimension, staticAccessors$14);
  23938. var GeometryFilter = function GeometryFilter2() {
  23939. };
  23940. GeometryFilter.prototype.filter = function filter4(geom) {
  23941. };
  23942. GeometryFilter.prototype.interfaces_ = function interfaces_31() {
  23943. return [];
  23944. };
  23945. GeometryFilter.prototype.getClass = function getClass30() {
  23946. return GeometryFilter;
  23947. };
  23948. var CoordinateSequenceFilter = function CoordinateSequenceFilter2() {
  23949. };
  23950. CoordinateSequenceFilter.prototype.filter = function filter5(seq, i) {
  23951. };
  23952. CoordinateSequenceFilter.prototype.isDone = function isDone() {
  23953. };
  23954. CoordinateSequenceFilter.prototype.isGeometryChanged = function isGeometryChanged() {
  23955. };
  23956. CoordinateSequenceFilter.prototype.interfaces_ = function interfaces_32() {
  23957. return [];
  23958. };
  23959. CoordinateSequenceFilter.prototype.getClass = function getClass31() {
  23960. return CoordinateSequenceFilter;
  23961. };
  23962. var GeometryCollection = function(Geometry$$1) {
  23963. function GeometryCollection2(geometries, factory) {
  23964. Geometry$$1.call(this, factory);
  23965. this._geometries = geometries || [];
  23966. if (Geometry$$1.hasNullElements(this._geometries)) {
  23967. throw new IllegalArgumentException("geometries must not contain null elements");
  23968. }
  23969. }
  23970. if (Geometry$$1)
  23971. GeometryCollection2.__proto__ = Geometry$$1;
  23972. GeometryCollection2.prototype = Object.create(Geometry$$1 && Geometry$$1.prototype);
  23973. GeometryCollection2.prototype.constructor = GeometryCollection2;
  23974. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  23975. GeometryCollection2.prototype.computeEnvelopeInternal = function computeEnvelopeInternal() {
  23976. var this$1 = this;
  23977. var envelope3 = new Envelope();
  23978. for (var i = 0; i < this._geometries.length; i++) {
  23979. envelope3.expandToInclude(this$1._geometries[i].getEnvelopeInternal());
  23980. }
  23981. return envelope3;
  23982. };
  23983. GeometryCollection2.prototype.getGeometryN = function getGeometryN2(n) {
  23984. return this._geometries[n];
  23985. };
  23986. GeometryCollection2.prototype.getSortIndex = function getSortIndex() {
  23987. return Geometry$$1.SORTINDEX_GEOMETRYCOLLECTION;
  23988. };
  23989. GeometryCollection2.prototype.getCoordinates = function getCoordinates11() {
  23990. var this$1 = this;
  23991. var coordinates = new Array(this.getNumPoints()).fill(null);
  23992. var k = -1;
  23993. for (var i = 0; i < this._geometries.length; i++) {
  23994. var childCoordinates = this$1._geometries[i].getCoordinates();
  23995. for (var j = 0; j < childCoordinates.length; j++) {
  23996. k++;
  23997. coordinates[k] = childCoordinates[j];
  23998. }
  23999. }
  24000. return coordinates;
  24001. };
  24002. GeometryCollection2.prototype.getArea = function getArea3() {
  24003. var this$1 = this;
  24004. var area5 = 0;
  24005. for (var i = 0; i < this._geometries.length; i++) {
  24006. area5 += this$1._geometries[i].getArea();
  24007. }
  24008. return area5;
  24009. };
  24010. GeometryCollection2.prototype.equalsExact = function equalsExact2() {
  24011. var this$1 = this;
  24012. if (arguments.length === 2) {
  24013. var other = arguments[0];
  24014. var tolerance = arguments[1];
  24015. if (!this.isEquivalentClass(other)) {
  24016. return false;
  24017. }
  24018. var otherCollection = other;
  24019. if (this._geometries.length !== otherCollection._geometries.length) {
  24020. return false;
  24021. }
  24022. for (var i = 0; i < this._geometries.length; i++) {
  24023. if (!this$1._geometries[i].equalsExact(otherCollection._geometries[i], tolerance)) {
  24024. return false;
  24025. }
  24026. }
  24027. return true;
  24028. } else {
  24029. return Geometry$$1.prototype.equalsExact.apply(this, arguments);
  24030. }
  24031. };
  24032. GeometryCollection2.prototype.normalize = function normalize6() {
  24033. var this$1 = this;
  24034. for (var i = 0; i < this._geometries.length; i++) {
  24035. this$1._geometries[i].normalize();
  24036. }
  24037. Arrays.sort(this._geometries);
  24038. };
  24039. GeometryCollection2.prototype.getCoordinate = function getCoordinate18() {
  24040. if (this.isEmpty()) {
  24041. return null;
  24042. }
  24043. return this._geometries[0].getCoordinate();
  24044. };
  24045. GeometryCollection2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  24046. var this$1 = this;
  24047. var dimension = Dimension.FALSE;
  24048. for (var i = 0; i < this._geometries.length; i++) {
  24049. dimension = Math.max(dimension, this$1._geometries[i].getBoundaryDimension());
  24050. }
  24051. return dimension;
  24052. };
  24053. GeometryCollection2.prototype.getDimension = function getDimension3() {
  24054. var this$1 = this;
  24055. var dimension = Dimension.FALSE;
  24056. for (var i = 0; i < this._geometries.length; i++) {
  24057. dimension = Math.max(dimension, this$1._geometries[i].getDimension());
  24058. }
  24059. return dimension;
  24060. };
  24061. GeometryCollection2.prototype.getLength = function getLength3() {
  24062. var this$1 = this;
  24063. var sum2 = 0;
  24064. for (var i = 0; i < this._geometries.length; i++) {
  24065. sum2 += this$1._geometries[i].getLength();
  24066. }
  24067. return sum2;
  24068. };
  24069. GeometryCollection2.prototype.getNumPoints = function getNumPoints() {
  24070. var this$1 = this;
  24071. var numPoints = 0;
  24072. for (var i = 0; i < this._geometries.length; i++) {
  24073. numPoints += this$1._geometries[i].getNumPoints();
  24074. }
  24075. return numPoints;
  24076. };
  24077. GeometryCollection2.prototype.getNumGeometries = function getNumGeometries2() {
  24078. return this._geometries.length;
  24079. };
  24080. GeometryCollection2.prototype.reverse = function reverse5() {
  24081. var this$1 = this;
  24082. var n = this._geometries.length;
  24083. var revGeoms = new Array(n).fill(null);
  24084. for (var i = 0; i < this._geometries.length; i++) {
  24085. revGeoms[i] = this$1._geometries[i].reverse();
  24086. }
  24087. return this.getFactory().createGeometryCollection(revGeoms);
  24088. };
  24089. GeometryCollection2.prototype.compareToSameClass = function compareToSameClass() {
  24090. var this$1 = this;
  24091. if (arguments.length === 1) {
  24092. var o = arguments[0];
  24093. var theseElements = new TreeSet(Arrays.asList(this._geometries));
  24094. var otherElements = new TreeSet(Arrays.asList(o._geometries));
  24095. return this.compare(theseElements, otherElements);
  24096. } else if (arguments.length === 2) {
  24097. var o$1 = arguments[0];
  24098. var comp = arguments[1];
  24099. var gc = o$1;
  24100. var n1 = this.getNumGeometries();
  24101. var n2 = gc.getNumGeometries();
  24102. var i = 0;
  24103. while (i < n1 && i < n2) {
  24104. var thisGeom = this$1.getGeometryN(i);
  24105. var otherGeom = gc.getGeometryN(i);
  24106. var holeComp = thisGeom.compareToSameClass(otherGeom, comp);
  24107. if (holeComp !== 0) {
  24108. return holeComp;
  24109. }
  24110. i++;
  24111. }
  24112. if (i < n1) {
  24113. return 1;
  24114. }
  24115. if (i < n2) {
  24116. return -1;
  24117. }
  24118. return 0;
  24119. }
  24120. };
  24121. GeometryCollection2.prototype.apply = function apply() {
  24122. var this$1 = this;
  24123. if (hasInterface(arguments[0], CoordinateFilter)) {
  24124. var filter17 = arguments[0];
  24125. for (var i = 0; i < this._geometries.length; i++) {
  24126. this$1._geometries[i].apply(filter17);
  24127. }
  24128. } else if (hasInterface(arguments[0], CoordinateSequenceFilter)) {
  24129. var filter$1 = arguments[0];
  24130. if (this._geometries.length === 0) {
  24131. return null;
  24132. }
  24133. for (var i$1 = 0; i$1 < this._geometries.length; i$1++) {
  24134. this$1._geometries[i$1].apply(filter$1);
  24135. if (filter$1.isDone()) {
  24136. break;
  24137. }
  24138. }
  24139. if (filter$1.isGeometryChanged()) {
  24140. this.geometryChanged();
  24141. }
  24142. } else if (hasInterface(arguments[0], GeometryFilter)) {
  24143. var filter$2 = arguments[0];
  24144. filter$2.filter(this);
  24145. for (var i$2 = 0; i$2 < this._geometries.length; i$2++) {
  24146. this$1._geometries[i$2].apply(filter$2);
  24147. }
  24148. } else if (hasInterface(arguments[0], GeometryComponentFilter)) {
  24149. var filter$3 = arguments[0];
  24150. filter$3.filter(this);
  24151. for (var i$3 = 0; i$3 < this._geometries.length; i$3++) {
  24152. this$1._geometries[i$3].apply(filter$3);
  24153. }
  24154. }
  24155. };
  24156. GeometryCollection2.prototype.getBoundary = function getBoundary3() {
  24157. this.checkNotGeometryCollection(this);
  24158. Assert.shouldNeverReachHere();
  24159. return null;
  24160. };
  24161. GeometryCollection2.prototype.clone = function clone6() {
  24162. var this$1 = this;
  24163. var gc = Geometry$$1.prototype.clone.call(this);
  24164. gc._geometries = new Array(this._geometries.length).fill(null);
  24165. for (var i = 0; i < this._geometries.length; i++) {
  24166. gc._geometries[i] = this$1._geometries[i].clone();
  24167. }
  24168. return gc;
  24169. };
  24170. GeometryCollection2.prototype.getGeometryType = function getGeometryType() {
  24171. return "GeometryCollection";
  24172. };
  24173. GeometryCollection2.prototype.copy = function copy7() {
  24174. var this$1 = this;
  24175. var geometries = new Array(this._geometries.length).fill(null);
  24176. for (var i = 0; i < geometries.length; i++) {
  24177. geometries[i] = this$1._geometries[i].copy();
  24178. }
  24179. return new GeometryCollection2(geometries, this._factory);
  24180. };
  24181. GeometryCollection2.prototype.isEmpty = function isEmpty6() {
  24182. var this$1 = this;
  24183. for (var i = 0; i < this._geometries.length; i++) {
  24184. if (!this$1._geometries[i].isEmpty()) {
  24185. return false;
  24186. }
  24187. }
  24188. return true;
  24189. };
  24190. GeometryCollection2.prototype.interfaces_ = function interfaces_170() {
  24191. return [];
  24192. };
  24193. GeometryCollection2.prototype.getClass = function getClass169() {
  24194. return GeometryCollection2;
  24195. };
  24196. staticAccessors2.serialVersionUID.get = function() {
  24197. return -5694727726395021e3;
  24198. };
  24199. Object.defineProperties(GeometryCollection2, staticAccessors2);
  24200. return GeometryCollection2;
  24201. }(Geometry);
  24202. var MultiLineString = function(GeometryCollection$$1) {
  24203. function MultiLineString2() {
  24204. GeometryCollection$$1.apply(this, arguments);
  24205. }
  24206. if (GeometryCollection$$1)
  24207. MultiLineString2.__proto__ = GeometryCollection$$1;
  24208. MultiLineString2.prototype = Object.create(GeometryCollection$$1 && GeometryCollection$$1.prototype);
  24209. MultiLineString2.prototype.constructor = MultiLineString2;
  24210. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  24211. MultiLineString2.prototype.getSortIndex = function getSortIndex() {
  24212. return Geometry.SORTINDEX_MULTILINESTRING;
  24213. };
  24214. MultiLineString2.prototype.equalsExact = function equalsExact2() {
  24215. if (arguments.length === 2) {
  24216. var other = arguments[0];
  24217. var tolerance = arguments[1];
  24218. if (!this.isEquivalentClass(other)) {
  24219. return false;
  24220. }
  24221. return GeometryCollection$$1.prototype.equalsExact.call(this, other, tolerance);
  24222. } else {
  24223. return GeometryCollection$$1.prototype.equalsExact.apply(this, arguments);
  24224. }
  24225. };
  24226. MultiLineString2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  24227. if (this.isClosed()) {
  24228. return Dimension.FALSE;
  24229. }
  24230. return 0;
  24231. };
  24232. MultiLineString2.prototype.isClosed = function isClosed5() {
  24233. var this$1 = this;
  24234. if (this.isEmpty()) {
  24235. return false;
  24236. }
  24237. for (var i = 0; i < this._geometries.length; i++) {
  24238. if (!this$1._geometries[i].isClosed()) {
  24239. return false;
  24240. }
  24241. }
  24242. return true;
  24243. };
  24244. MultiLineString2.prototype.getDimension = function getDimension3() {
  24245. return 1;
  24246. };
  24247. MultiLineString2.prototype.reverse = function reverse5() {
  24248. var this$1 = this;
  24249. var nLines = this._geometries.length;
  24250. var revLines = new Array(nLines).fill(null);
  24251. for (var i = 0; i < this._geometries.length; i++) {
  24252. revLines[nLines - 1 - i] = this$1._geometries[i].reverse();
  24253. }
  24254. return this.getFactory().createMultiLineString(revLines);
  24255. };
  24256. MultiLineString2.prototype.getBoundary = function getBoundary3() {
  24257. return new BoundaryOp(this).getBoundary();
  24258. };
  24259. MultiLineString2.prototype.getGeometryType = function getGeometryType() {
  24260. return "MultiLineString";
  24261. };
  24262. MultiLineString2.prototype.copy = function copy7() {
  24263. var this$1 = this;
  24264. var lineStrings2 = new Array(this._geometries.length).fill(null);
  24265. for (var i = 0; i < lineStrings2.length; i++) {
  24266. lineStrings2[i] = this$1._geometries[i].copy();
  24267. }
  24268. return new MultiLineString2(lineStrings2, this._factory);
  24269. };
  24270. MultiLineString2.prototype.interfaces_ = function interfaces_170() {
  24271. return [Lineal];
  24272. };
  24273. MultiLineString2.prototype.getClass = function getClass169() {
  24274. return MultiLineString2;
  24275. };
  24276. staticAccessors2.serialVersionUID.get = function() {
  24277. return 8166665132445434e3;
  24278. };
  24279. Object.defineProperties(MultiLineString2, staticAccessors2);
  24280. return MultiLineString2;
  24281. }(GeometryCollection);
  24282. var BoundaryOp = function BoundaryOp2() {
  24283. this._geom = null;
  24284. this._geomFact = null;
  24285. this._bnRule = null;
  24286. this._endpointMap = null;
  24287. if (arguments.length === 1) {
  24288. var geom = arguments[0];
  24289. var bnRule = BoundaryNodeRule.MOD2_BOUNDARY_RULE;
  24290. this._geom = geom;
  24291. this._geomFact = geom.getFactory();
  24292. this._bnRule = bnRule;
  24293. } else if (arguments.length === 2) {
  24294. var geom$1 = arguments[0];
  24295. var bnRule$1 = arguments[1];
  24296. this._geom = geom$1;
  24297. this._geomFact = geom$1.getFactory();
  24298. this._bnRule = bnRule$1;
  24299. }
  24300. };
  24301. BoundaryOp.prototype.boundaryMultiLineString = function boundaryMultiLineString(mLine) {
  24302. if (this._geom.isEmpty()) {
  24303. return this.getEmptyMultiPoint();
  24304. }
  24305. var bdyPts = this.computeBoundaryCoordinates(mLine);
  24306. if (bdyPts.length === 1) {
  24307. return this._geomFact.createPoint(bdyPts[0]);
  24308. }
  24309. return this._geomFact.createMultiPointFromCoords(bdyPts);
  24310. };
  24311. BoundaryOp.prototype.getBoundary = function getBoundary() {
  24312. if (this._geom instanceof LineString2) {
  24313. return this.boundaryLineString(this._geom);
  24314. }
  24315. if (this._geom instanceof MultiLineString) {
  24316. return this.boundaryMultiLineString(this._geom);
  24317. }
  24318. return this._geom.getBoundary();
  24319. };
  24320. BoundaryOp.prototype.boundaryLineString = function boundaryLineString(line) {
  24321. if (this._geom.isEmpty()) {
  24322. return this.getEmptyMultiPoint();
  24323. }
  24324. if (line.isClosed()) {
  24325. var closedEndpointOnBoundary = this._bnRule.isInBoundary(2);
  24326. if (closedEndpointOnBoundary) {
  24327. return line.getStartPoint();
  24328. } else {
  24329. return this._geomFact.createMultiPoint();
  24330. }
  24331. }
  24332. return this._geomFact.createMultiPoint([line.getStartPoint(), line.getEndPoint()]);
  24333. };
  24334. BoundaryOp.prototype.getEmptyMultiPoint = function getEmptyMultiPoint() {
  24335. return this._geomFact.createMultiPoint();
  24336. };
  24337. BoundaryOp.prototype.computeBoundaryCoordinates = function computeBoundaryCoordinates(mLine) {
  24338. var this$1 = this;
  24339. var bdyPts = new ArrayList();
  24340. this._endpointMap = new TreeMap();
  24341. for (var i = 0; i < mLine.getNumGeometries(); i++) {
  24342. var line = mLine.getGeometryN(i);
  24343. if (line.getNumPoints() === 0) {
  24344. continue;
  24345. }
  24346. this$1.addEndpoint(line.getCoordinateN(0));
  24347. this$1.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
  24348. }
  24349. for (var it = this._endpointMap.entrySet().iterator(); it.hasNext(); ) {
  24350. var entry = it.next();
  24351. var counter = entry.getValue();
  24352. var valence = counter.count;
  24353. if (this$1._bnRule.isInBoundary(valence)) {
  24354. bdyPts.add(entry.getKey());
  24355. }
  24356. }
  24357. return CoordinateArrays.toCoordinateArray(bdyPts);
  24358. };
  24359. BoundaryOp.prototype.addEndpoint = function addEndpoint(pt) {
  24360. var counter = this._endpointMap.get(pt);
  24361. if (counter === null) {
  24362. counter = new Counter();
  24363. this._endpointMap.put(pt, counter);
  24364. }
  24365. counter.count++;
  24366. };
  24367. BoundaryOp.prototype.interfaces_ = function interfaces_33() {
  24368. return [];
  24369. };
  24370. BoundaryOp.prototype.getClass = function getClass32() {
  24371. return BoundaryOp;
  24372. };
  24373. BoundaryOp.getBoundary = function getBoundary2() {
  24374. if (arguments.length === 1) {
  24375. var g = arguments[0];
  24376. var bop = new BoundaryOp(g);
  24377. return bop.getBoundary();
  24378. } else if (arguments.length === 2) {
  24379. var g$1 = arguments[0];
  24380. var bnRule = arguments[1];
  24381. var bop$1 = new BoundaryOp(g$1, bnRule);
  24382. return bop$1.getBoundary();
  24383. }
  24384. };
  24385. var Counter = function Counter2() {
  24386. this.count = null;
  24387. };
  24388. Counter.prototype.interfaces_ = function interfaces_34() {
  24389. return [];
  24390. };
  24391. Counter.prototype.getClass = function getClass33() {
  24392. return Counter;
  24393. };
  24394. function PrintStream() {
  24395. }
  24396. function StringReader() {
  24397. }
  24398. var DecimalFormat = function DecimalFormat2() {
  24399. };
  24400. function ByteArrayOutputStream() {
  24401. }
  24402. function IOException() {
  24403. }
  24404. function LineNumberReader() {
  24405. }
  24406. var StringUtil = function StringUtil2() {
  24407. };
  24408. var staticAccessors$15 = { NEWLINE: { configurable: true }, SIMPLE_ORDINATE_FORMAT: { configurable: true } };
  24409. StringUtil.prototype.interfaces_ = function interfaces_35() {
  24410. return [];
  24411. };
  24412. StringUtil.prototype.getClass = function getClass34() {
  24413. return StringUtil;
  24414. };
  24415. StringUtil.chars = function chars(c, n) {
  24416. var ch = new Array(n).fill(null);
  24417. for (var i = 0; i < n; i++) {
  24418. ch[i] = c;
  24419. }
  24420. return String(ch);
  24421. };
  24422. StringUtil.getStackTrace = function getStackTrace() {
  24423. if (arguments.length === 1) {
  24424. var t = arguments[0];
  24425. var os = new ByteArrayOutputStream();
  24426. var ps = new PrintStream(os);
  24427. t.printStackTrace(ps);
  24428. return os.toString();
  24429. } else if (arguments.length === 2) {
  24430. var t$1 = arguments[0];
  24431. var depth2 = arguments[1];
  24432. var stackTrace = "";
  24433. var stringReader = new StringReader(StringUtil.getStackTrace(t$1));
  24434. var lineNumberReader = new LineNumberReader(stringReader);
  24435. for (var i = 0; i < depth2; i++) {
  24436. try {
  24437. stackTrace += lineNumberReader.readLine() + StringUtil.NEWLINE;
  24438. } catch (e) {
  24439. if (e instanceof IOException) {
  24440. Assert.shouldNeverReachHere();
  24441. } else {
  24442. throw e;
  24443. }
  24444. } finally {
  24445. }
  24446. }
  24447. return stackTrace;
  24448. }
  24449. };
  24450. StringUtil.split = function split2(s, separator) {
  24451. var separatorlen = separator.length;
  24452. var tokenList = new ArrayList();
  24453. var tmpString = "" + s;
  24454. var pos = tmpString.indexOf(separator);
  24455. while (pos >= 0) {
  24456. var token = tmpString.substring(0, pos);
  24457. tokenList.add(token);
  24458. tmpString = tmpString.substring(pos + separatorlen);
  24459. pos = tmpString.indexOf(separator);
  24460. }
  24461. if (tmpString.length > 0) {
  24462. tokenList.add(tmpString);
  24463. }
  24464. var res = new Array(tokenList.size()).fill(null);
  24465. for (var i = 0; i < res.length; i++) {
  24466. res[i] = tokenList.get(i);
  24467. }
  24468. return res;
  24469. };
  24470. StringUtil.toString = function toString6() {
  24471. if (arguments.length === 1) {
  24472. var d = arguments[0];
  24473. return StringUtil.SIMPLE_ORDINATE_FORMAT.format(d);
  24474. }
  24475. };
  24476. StringUtil.spaces = function spaces(n) {
  24477. return StringUtil.chars(" ", n);
  24478. };
  24479. staticAccessors$15.NEWLINE.get = function() {
  24480. return System.getProperty("line.separator");
  24481. };
  24482. staticAccessors$15.SIMPLE_ORDINATE_FORMAT.get = function() {
  24483. return new DecimalFormat("0.#");
  24484. };
  24485. Object.defineProperties(StringUtil, staticAccessors$15);
  24486. var CoordinateSequences = function CoordinateSequences2() {
  24487. };
  24488. CoordinateSequences.prototype.interfaces_ = function interfaces_36() {
  24489. return [];
  24490. };
  24491. CoordinateSequences.prototype.getClass = function getClass35() {
  24492. return CoordinateSequences;
  24493. };
  24494. CoordinateSequences.copyCoord = function copyCoord(src, srcPos, dest, destPos) {
  24495. var minDim = Math.min(src.getDimension(), dest.getDimension());
  24496. for (var dim = 0; dim < minDim; dim++) {
  24497. dest.setOrdinate(destPos, dim, src.getOrdinate(srcPos, dim));
  24498. }
  24499. };
  24500. CoordinateSequences.isRing = function isRing2(seq) {
  24501. var n = seq.size();
  24502. if (n === 0) {
  24503. return true;
  24504. }
  24505. if (n <= 3) {
  24506. return false;
  24507. }
  24508. return seq.getOrdinate(0, CoordinateSequence.X) === seq.getOrdinate(n - 1, CoordinateSequence.X) && seq.getOrdinate(0, CoordinateSequence.Y) === seq.getOrdinate(n - 1, CoordinateSequence.Y);
  24509. };
  24510. CoordinateSequences.isEqual = function isEqual(cs1, cs2) {
  24511. var cs1Size = cs1.size();
  24512. var cs2Size = cs2.size();
  24513. if (cs1Size !== cs2Size) {
  24514. return false;
  24515. }
  24516. var dim = Math.min(cs1.getDimension(), cs2.getDimension());
  24517. for (var i = 0; i < cs1Size; i++) {
  24518. for (var d = 0; d < dim; d++) {
  24519. var v1 = cs1.getOrdinate(i, d);
  24520. var v2 = cs2.getOrdinate(i, d);
  24521. if (cs1.getOrdinate(i, d) === cs2.getOrdinate(i, d)) {
  24522. continue;
  24523. }
  24524. if (Double.isNaN(v1) && Double.isNaN(v2)) {
  24525. continue;
  24526. }
  24527. return false;
  24528. }
  24529. }
  24530. return true;
  24531. };
  24532. CoordinateSequences.extend = function extend(fact, seq, size11) {
  24533. var newseq = fact.create(size11, seq.getDimension());
  24534. var n = seq.size();
  24535. CoordinateSequences.copy(seq, 0, newseq, 0, n);
  24536. if (n > 0) {
  24537. for (var i = n; i < size11; i++) {
  24538. CoordinateSequences.copy(seq, n - 1, newseq, i, 1);
  24539. }
  24540. }
  24541. return newseq;
  24542. };
  24543. CoordinateSequences.reverse = function reverse3(seq) {
  24544. var last = seq.size() - 1;
  24545. var mid = Math.trunc(last / 2);
  24546. for (var i = 0; i <= mid; i++) {
  24547. CoordinateSequences.swap(seq, i, last - i);
  24548. }
  24549. };
  24550. CoordinateSequences.swap = function swap(seq, i, j) {
  24551. if (i === j) {
  24552. return null;
  24553. }
  24554. for (var dim = 0; dim < seq.getDimension(); dim++) {
  24555. var tmp = seq.getOrdinate(i, dim);
  24556. seq.setOrdinate(i, dim, seq.getOrdinate(j, dim));
  24557. seq.setOrdinate(j, dim, tmp);
  24558. }
  24559. };
  24560. CoordinateSequences.copy = function copy4(src, srcPos, dest, destPos, length4) {
  24561. for (var i = 0; i < length4; i++) {
  24562. CoordinateSequences.copyCoord(src, srcPos + i, dest, destPos + i);
  24563. }
  24564. };
  24565. CoordinateSequences.toString = function toString7() {
  24566. if (arguments.length === 1) {
  24567. var cs = arguments[0];
  24568. var size11 = cs.size();
  24569. if (size11 === 0) {
  24570. return "()";
  24571. }
  24572. var dim = cs.getDimension();
  24573. var buf = new StringBuffer();
  24574. buf.append("(");
  24575. for (var i = 0; i < size11; i++) {
  24576. if (i > 0) {
  24577. buf.append(" ");
  24578. }
  24579. for (var d = 0; d < dim; d++) {
  24580. if (d > 0) {
  24581. buf.append(",");
  24582. }
  24583. buf.append(StringUtil.toString(cs.getOrdinate(i, d)));
  24584. }
  24585. }
  24586. buf.append(")");
  24587. return buf.toString();
  24588. }
  24589. };
  24590. CoordinateSequences.ensureValidRing = function ensureValidRing(fact, seq) {
  24591. var n = seq.size();
  24592. if (n === 0) {
  24593. return seq;
  24594. }
  24595. if (n <= 3) {
  24596. return CoordinateSequences.createClosedRing(fact, seq, 4);
  24597. }
  24598. var isClosed5 = seq.getOrdinate(0, CoordinateSequence.X) === seq.getOrdinate(n - 1, CoordinateSequence.X) && seq.getOrdinate(0, CoordinateSequence.Y) === seq.getOrdinate(n - 1, CoordinateSequence.Y);
  24599. if (isClosed5) {
  24600. return seq;
  24601. }
  24602. return CoordinateSequences.createClosedRing(fact, seq, n + 1);
  24603. };
  24604. CoordinateSequences.createClosedRing = function createClosedRing(fact, seq, size11) {
  24605. var newseq = fact.create(size11, seq.getDimension());
  24606. var n = seq.size();
  24607. CoordinateSequences.copy(seq, 0, newseq, 0, n);
  24608. for (var i = n; i < size11; i++) {
  24609. CoordinateSequences.copy(seq, 0, newseq, i, 1);
  24610. }
  24611. return newseq;
  24612. };
  24613. var LineString2 = function(Geometry$$1) {
  24614. function LineString3(points2, factory) {
  24615. Geometry$$1.call(this, factory);
  24616. this._points = null;
  24617. this.init(points2);
  24618. }
  24619. if (Geometry$$1)
  24620. LineString3.__proto__ = Geometry$$1;
  24621. LineString3.prototype = Object.create(Geometry$$1 && Geometry$$1.prototype);
  24622. LineString3.prototype.constructor = LineString3;
  24623. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  24624. LineString3.prototype.computeEnvelopeInternal = function computeEnvelopeInternal() {
  24625. if (this.isEmpty()) {
  24626. return new Envelope();
  24627. }
  24628. return this._points.expandEnvelope(new Envelope());
  24629. };
  24630. LineString3.prototype.isRing = function isRing3() {
  24631. return this.isClosed() && this.isSimple();
  24632. };
  24633. LineString3.prototype.getSortIndex = function getSortIndex() {
  24634. return Geometry$$1.SORTINDEX_LINESTRING;
  24635. };
  24636. LineString3.prototype.getCoordinates = function getCoordinates11() {
  24637. return this._points.toCoordinateArray();
  24638. };
  24639. LineString3.prototype.equalsExact = function equalsExact2() {
  24640. var this$1 = this;
  24641. if (arguments.length === 2) {
  24642. var other = arguments[0];
  24643. var tolerance = arguments[1];
  24644. if (!this.isEquivalentClass(other)) {
  24645. return false;
  24646. }
  24647. var otherLineString = other;
  24648. if (this._points.size() !== otherLineString._points.size()) {
  24649. return false;
  24650. }
  24651. for (var i = 0; i < this._points.size(); i++) {
  24652. if (!this$1.equal(this$1._points.getCoordinate(i), otherLineString._points.getCoordinate(i), tolerance)) {
  24653. return false;
  24654. }
  24655. }
  24656. return true;
  24657. } else {
  24658. return Geometry$$1.prototype.equalsExact.apply(this, arguments);
  24659. }
  24660. };
  24661. LineString3.prototype.normalize = function normalize6() {
  24662. var this$1 = this;
  24663. for (var i = 0; i < Math.trunc(this._points.size() / 2); i++) {
  24664. var j = this$1._points.size() - 1 - i;
  24665. if (!this$1._points.getCoordinate(i).equals(this$1._points.getCoordinate(j))) {
  24666. if (this$1._points.getCoordinate(i).compareTo(this$1._points.getCoordinate(j)) > 0) {
  24667. CoordinateSequences.reverse(this$1._points);
  24668. }
  24669. return null;
  24670. }
  24671. }
  24672. };
  24673. LineString3.prototype.getCoordinate = function getCoordinate18() {
  24674. if (this.isEmpty()) {
  24675. return null;
  24676. }
  24677. return this._points.getCoordinate(0);
  24678. };
  24679. LineString3.prototype.getBoundaryDimension = function getBoundaryDimension() {
  24680. if (this.isClosed()) {
  24681. return Dimension.FALSE;
  24682. }
  24683. return 0;
  24684. };
  24685. LineString3.prototype.isClosed = function isClosed5() {
  24686. if (this.isEmpty()) {
  24687. return false;
  24688. }
  24689. return this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints() - 1));
  24690. };
  24691. LineString3.prototype.getEndPoint = function getEndPoint() {
  24692. if (this.isEmpty()) {
  24693. return null;
  24694. }
  24695. return this.getPointN(this.getNumPoints() - 1);
  24696. };
  24697. LineString3.prototype.getDimension = function getDimension3() {
  24698. return 1;
  24699. };
  24700. LineString3.prototype.getLength = function getLength3() {
  24701. return CGAlgorithms.computeLength(this._points);
  24702. };
  24703. LineString3.prototype.getNumPoints = function getNumPoints() {
  24704. return this._points.size();
  24705. };
  24706. LineString3.prototype.reverse = function reverse5() {
  24707. var seq = this._points.copy();
  24708. CoordinateSequences.reverse(seq);
  24709. var revLine = this.getFactory().createLineString(seq);
  24710. return revLine;
  24711. };
  24712. LineString3.prototype.compareToSameClass = function compareToSameClass() {
  24713. var this$1 = this;
  24714. if (arguments.length === 1) {
  24715. var o = arguments[0];
  24716. var line = o;
  24717. var i = 0;
  24718. var j = 0;
  24719. while (i < this._points.size() && j < line._points.size()) {
  24720. var comparison = this$1._points.getCoordinate(i).compareTo(line._points.getCoordinate(j));
  24721. if (comparison !== 0) {
  24722. return comparison;
  24723. }
  24724. i++;
  24725. j++;
  24726. }
  24727. if (i < this._points.size()) {
  24728. return 1;
  24729. }
  24730. if (j < line._points.size()) {
  24731. return -1;
  24732. }
  24733. return 0;
  24734. } else if (arguments.length === 2) {
  24735. var o$1 = arguments[0];
  24736. var comp = arguments[1];
  24737. var line$1 = o$1;
  24738. return comp.compare(this._points, line$1._points);
  24739. }
  24740. };
  24741. LineString3.prototype.apply = function apply() {
  24742. var this$1 = this;
  24743. if (hasInterface(arguments[0], CoordinateFilter)) {
  24744. var filter17 = arguments[0];
  24745. for (var i = 0; i < this._points.size(); i++) {
  24746. filter17.filter(this$1._points.getCoordinate(i));
  24747. }
  24748. } else if (hasInterface(arguments[0], CoordinateSequenceFilter)) {
  24749. var filter$1 = arguments[0];
  24750. if (this._points.size() === 0) {
  24751. return null;
  24752. }
  24753. for (var i$1 = 0; i$1 < this._points.size(); i$1++) {
  24754. filter$1.filter(this$1._points, i$1);
  24755. if (filter$1.isDone()) {
  24756. break;
  24757. }
  24758. }
  24759. if (filter$1.isGeometryChanged()) {
  24760. this.geometryChanged();
  24761. }
  24762. } else if (hasInterface(arguments[0], GeometryFilter)) {
  24763. var filter$2 = arguments[0];
  24764. filter$2.filter(this);
  24765. } else if (hasInterface(arguments[0], GeometryComponentFilter)) {
  24766. var filter$3 = arguments[0];
  24767. filter$3.filter(this);
  24768. }
  24769. };
  24770. LineString3.prototype.getBoundary = function getBoundary3() {
  24771. return new BoundaryOp(this).getBoundary();
  24772. };
  24773. LineString3.prototype.isEquivalentClass = function isEquivalentClass(other) {
  24774. return other instanceof LineString3;
  24775. };
  24776. LineString3.prototype.clone = function clone6() {
  24777. var ls = Geometry$$1.prototype.clone.call(this);
  24778. ls._points = this._points.clone();
  24779. return ls;
  24780. };
  24781. LineString3.prototype.getCoordinateN = function getCoordinateN(n) {
  24782. return this._points.getCoordinate(n);
  24783. };
  24784. LineString3.prototype.getGeometryType = function getGeometryType() {
  24785. return "LineString";
  24786. };
  24787. LineString3.prototype.copy = function copy7() {
  24788. return new LineString3(this._points.copy(), this._factory);
  24789. };
  24790. LineString3.prototype.getCoordinateSequence = function getCoordinateSequence() {
  24791. return this._points;
  24792. };
  24793. LineString3.prototype.isEmpty = function isEmpty6() {
  24794. return this._points.size() === 0;
  24795. };
  24796. LineString3.prototype.init = function init8(points2) {
  24797. if (points2 === null) {
  24798. points2 = this.getFactory().getCoordinateSequenceFactory().create([]);
  24799. }
  24800. if (points2.size() === 1) {
  24801. throw new IllegalArgumentException("Invalid number of points in LineString (found " + points2.size() + " - must be 0 or >= 2)");
  24802. }
  24803. this._points = points2;
  24804. };
  24805. LineString3.prototype.isCoordinate = function isCoordinate(pt) {
  24806. var this$1 = this;
  24807. for (var i = 0; i < this._points.size(); i++) {
  24808. if (this$1._points.getCoordinate(i).equals(pt)) {
  24809. return true;
  24810. }
  24811. }
  24812. return false;
  24813. };
  24814. LineString3.prototype.getStartPoint = function getStartPoint() {
  24815. if (this.isEmpty()) {
  24816. return null;
  24817. }
  24818. return this.getPointN(0);
  24819. };
  24820. LineString3.prototype.getPointN = function getPointN(n) {
  24821. return this.getFactory().createPoint(this._points.getCoordinate(n));
  24822. };
  24823. LineString3.prototype.interfaces_ = function interfaces_170() {
  24824. return [Lineal];
  24825. };
  24826. LineString3.prototype.getClass = function getClass169() {
  24827. return LineString3;
  24828. };
  24829. staticAccessors2.serialVersionUID.get = function() {
  24830. return 3110669828065365500;
  24831. };
  24832. Object.defineProperties(LineString3, staticAccessors2);
  24833. return LineString3;
  24834. }(Geometry);
  24835. var Puntal = function Puntal2() {
  24836. };
  24837. Puntal.prototype.interfaces_ = function interfaces_37() {
  24838. return [];
  24839. };
  24840. Puntal.prototype.getClass = function getClass36() {
  24841. return Puntal;
  24842. };
  24843. var Point = function(Geometry$$1) {
  24844. function Point2(coordinates, factory) {
  24845. Geometry$$1.call(this, factory);
  24846. this._coordinates = coordinates || null;
  24847. this.init(this._coordinates);
  24848. }
  24849. if (Geometry$$1)
  24850. Point2.__proto__ = Geometry$$1;
  24851. Point2.prototype = Object.create(Geometry$$1 && Geometry$$1.prototype);
  24852. Point2.prototype.constructor = Point2;
  24853. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  24854. Point2.prototype.computeEnvelopeInternal = function computeEnvelopeInternal() {
  24855. if (this.isEmpty()) {
  24856. return new Envelope();
  24857. }
  24858. var env = new Envelope();
  24859. env.expandToInclude(this._coordinates.getX(0), this._coordinates.getY(0));
  24860. return env;
  24861. };
  24862. Point2.prototype.getSortIndex = function getSortIndex() {
  24863. return Geometry$$1.SORTINDEX_POINT;
  24864. };
  24865. Point2.prototype.getCoordinates = function getCoordinates11() {
  24866. return this.isEmpty() ? [] : [this.getCoordinate()];
  24867. };
  24868. Point2.prototype.equalsExact = function equalsExact2() {
  24869. if (arguments.length === 2) {
  24870. var other = arguments[0];
  24871. var tolerance = arguments[1];
  24872. if (!this.isEquivalentClass(other)) {
  24873. return false;
  24874. }
  24875. if (this.isEmpty() && other.isEmpty()) {
  24876. return true;
  24877. }
  24878. if (this.isEmpty() !== other.isEmpty()) {
  24879. return false;
  24880. }
  24881. return this.equal(other.getCoordinate(), this.getCoordinate(), tolerance);
  24882. } else {
  24883. return Geometry$$1.prototype.equalsExact.apply(this, arguments);
  24884. }
  24885. };
  24886. Point2.prototype.normalize = function normalize6() {
  24887. };
  24888. Point2.prototype.getCoordinate = function getCoordinate18() {
  24889. return this._coordinates.size() !== 0 ? this._coordinates.getCoordinate(0) : null;
  24890. };
  24891. Point2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  24892. return Dimension.FALSE;
  24893. };
  24894. Point2.prototype.getDimension = function getDimension3() {
  24895. return 0;
  24896. };
  24897. Point2.prototype.getNumPoints = function getNumPoints() {
  24898. return this.isEmpty() ? 0 : 1;
  24899. };
  24900. Point2.prototype.reverse = function reverse5() {
  24901. return this.copy();
  24902. };
  24903. Point2.prototype.getX = function getX4() {
  24904. if (this.getCoordinate() === null) {
  24905. throw new Error("getX called on empty Point");
  24906. }
  24907. return this.getCoordinate().x;
  24908. };
  24909. Point2.prototype.compareToSameClass = function compareToSameClass() {
  24910. if (arguments.length === 1) {
  24911. var other = arguments[0];
  24912. var point$1 = other;
  24913. return this.getCoordinate().compareTo(point$1.getCoordinate());
  24914. } else if (arguments.length === 2) {
  24915. var other$1 = arguments[0];
  24916. var comp = arguments[1];
  24917. var point4 = other$1;
  24918. return comp.compare(this._coordinates, point4._coordinates);
  24919. }
  24920. };
  24921. Point2.prototype.apply = function apply() {
  24922. if (hasInterface(arguments[0], CoordinateFilter)) {
  24923. var filter17 = arguments[0];
  24924. if (this.isEmpty()) {
  24925. return null;
  24926. }
  24927. filter17.filter(this.getCoordinate());
  24928. } else if (hasInterface(arguments[0], CoordinateSequenceFilter)) {
  24929. var filter$1 = arguments[0];
  24930. if (this.isEmpty()) {
  24931. return null;
  24932. }
  24933. filter$1.filter(this._coordinates, 0);
  24934. if (filter$1.isGeometryChanged()) {
  24935. this.geometryChanged();
  24936. }
  24937. } else if (hasInterface(arguments[0], GeometryFilter)) {
  24938. var filter$2 = arguments[0];
  24939. filter$2.filter(this);
  24940. } else if (hasInterface(arguments[0], GeometryComponentFilter)) {
  24941. var filter$3 = arguments[0];
  24942. filter$3.filter(this);
  24943. }
  24944. };
  24945. Point2.prototype.getBoundary = function getBoundary3() {
  24946. return this.getFactory().createGeometryCollection(null);
  24947. };
  24948. Point2.prototype.clone = function clone6() {
  24949. var p = Geometry$$1.prototype.clone.call(this);
  24950. p._coordinates = this._coordinates.clone();
  24951. return p;
  24952. };
  24953. Point2.prototype.getGeometryType = function getGeometryType() {
  24954. return "Point";
  24955. };
  24956. Point2.prototype.copy = function copy7() {
  24957. return new Point2(this._coordinates.copy(), this._factory);
  24958. };
  24959. Point2.prototype.getCoordinateSequence = function getCoordinateSequence() {
  24960. return this._coordinates;
  24961. };
  24962. Point2.prototype.getY = function getY4() {
  24963. if (this.getCoordinate() === null) {
  24964. throw new Error("getY called on empty Point");
  24965. }
  24966. return this.getCoordinate().y;
  24967. };
  24968. Point2.prototype.isEmpty = function isEmpty6() {
  24969. return this._coordinates.size() === 0;
  24970. };
  24971. Point2.prototype.init = function init8(coordinates) {
  24972. if (coordinates === null) {
  24973. coordinates = this.getFactory().getCoordinateSequenceFactory().create([]);
  24974. }
  24975. Assert.isTrue(coordinates.size() <= 1);
  24976. this._coordinates = coordinates;
  24977. };
  24978. Point2.prototype.isSimple = function isSimple() {
  24979. return true;
  24980. };
  24981. Point2.prototype.interfaces_ = function interfaces_170() {
  24982. return [Puntal];
  24983. };
  24984. Point2.prototype.getClass = function getClass169() {
  24985. return Point2;
  24986. };
  24987. staticAccessors2.serialVersionUID.get = function() {
  24988. return 4902022702746615e3;
  24989. };
  24990. Object.defineProperties(Point2, staticAccessors2);
  24991. return Point2;
  24992. }(Geometry);
  24993. var Polygonal = function Polygonal2() {
  24994. };
  24995. Polygonal.prototype.interfaces_ = function interfaces_38() {
  24996. return [];
  24997. };
  24998. Polygonal.prototype.getClass = function getClass37() {
  24999. return Polygonal;
  25000. };
  25001. var Polygon = function(Geometry$$1) {
  25002. function Polygon2(shell, holes, factory) {
  25003. Geometry$$1.call(this, factory);
  25004. this._shell = null;
  25005. this._holes = null;
  25006. if (shell === null) {
  25007. shell = this.getFactory().createLinearRing();
  25008. }
  25009. if (holes === null) {
  25010. holes = [];
  25011. }
  25012. if (Geometry$$1.hasNullElements(holes)) {
  25013. throw new IllegalArgumentException("holes must not contain null elements");
  25014. }
  25015. if (shell.isEmpty() && Geometry$$1.hasNonEmptyElements(holes)) {
  25016. throw new IllegalArgumentException("shell is empty but holes are not");
  25017. }
  25018. this._shell = shell;
  25019. this._holes = holes;
  25020. }
  25021. if (Geometry$$1)
  25022. Polygon2.__proto__ = Geometry$$1;
  25023. Polygon2.prototype = Object.create(Geometry$$1 && Geometry$$1.prototype);
  25024. Polygon2.prototype.constructor = Polygon2;
  25025. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  25026. Polygon2.prototype.computeEnvelopeInternal = function computeEnvelopeInternal() {
  25027. return this._shell.getEnvelopeInternal();
  25028. };
  25029. Polygon2.prototype.getSortIndex = function getSortIndex() {
  25030. return Geometry$$1.SORTINDEX_POLYGON;
  25031. };
  25032. Polygon2.prototype.getCoordinates = function getCoordinates11() {
  25033. var this$1 = this;
  25034. if (this.isEmpty()) {
  25035. return [];
  25036. }
  25037. var coordinates = new Array(this.getNumPoints()).fill(null);
  25038. var k = -1;
  25039. var shellCoordinates = this._shell.getCoordinates();
  25040. for (var x2 = 0; x2 < shellCoordinates.length; x2++) {
  25041. k++;
  25042. coordinates[k] = shellCoordinates[x2];
  25043. }
  25044. for (var i = 0; i < this._holes.length; i++) {
  25045. var childCoordinates = this$1._holes[i].getCoordinates();
  25046. for (var j = 0; j < childCoordinates.length; j++) {
  25047. k++;
  25048. coordinates[k] = childCoordinates[j];
  25049. }
  25050. }
  25051. return coordinates;
  25052. };
  25053. Polygon2.prototype.getArea = function getArea3() {
  25054. var this$1 = this;
  25055. var area5 = 0;
  25056. area5 += Math.abs(CGAlgorithms.signedArea(this._shell.getCoordinateSequence()));
  25057. for (var i = 0; i < this._holes.length; i++) {
  25058. area5 -= Math.abs(CGAlgorithms.signedArea(this$1._holes[i].getCoordinateSequence()));
  25059. }
  25060. return area5;
  25061. };
  25062. Polygon2.prototype.isRectangle = function isRectangle2() {
  25063. if (this.getNumInteriorRing() !== 0) {
  25064. return false;
  25065. }
  25066. if (this._shell === null) {
  25067. return false;
  25068. }
  25069. if (this._shell.getNumPoints() !== 5) {
  25070. return false;
  25071. }
  25072. var seq = this._shell.getCoordinateSequence();
  25073. var env = this.getEnvelopeInternal();
  25074. for (var i = 0; i < 5; i++) {
  25075. var x2 = seq.getX(i);
  25076. if (!(x2 === env.getMinX() || x2 === env.getMaxX())) {
  25077. return false;
  25078. }
  25079. var y2 = seq.getY(i);
  25080. if (!(y2 === env.getMinY() || y2 === env.getMaxY())) {
  25081. return false;
  25082. }
  25083. }
  25084. var prevX = seq.getX(0);
  25085. var prevY = seq.getY(0);
  25086. for (var i$1 = 1; i$1 <= 4; i$1++) {
  25087. var x$1 = seq.getX(i$1);
  25088. var y$1 = seq.getY(i$1);
  25089. var xChanged = x$1 !== prevX;
  25090. var yChanged = y$1 !== prevY;
  25091. if (xChanged === yChanged) {
  25092. return false;
  25093. }
  25094. prevX = x$1;
  25095. prevY = y$1;
  25096. }
  25097. return true;
  25098. };
  25099. Polygon2.prototype.equalsExact = function equalsExact2() {
  25100. var this$1 = this;
  25101. if (arguments.length === 2) {
  25102. var other = arguments[0];
  25103. var tolerance = arguments[1];
  25104. if (!this.isEquivalentClass(other)) {
  25105. return false;
  25106. }
  25107. var otherPolygon = other;
  25108. var thisShell = this._shell;
  25109. var otherPolygonShell = otherPolygon._shell;
  25110. if (!thisShell.equalsExact(otherPolygonShell, tolerance)) {
  25111. return false;
  25112. }
  25113. if (this._holes.length !== otherPolygon._holes.length) {
  25114. return false;
  25115. }
  25116. for (var i = 0; i < this._holes.length; i++) {
  25117. if (!this$1._holes[i].equalsExact(otherPolygon._holes[i], tolerance)) {
  25118. return false;
  25119. }
  25120. }
  25121. return true;
  25122. } else {
  25123. return Geometry$$1.prototype.equalsExact.apply(this, arguments);
  25124. }
  25125. };
  25126. Polygon2.prototype.normalize = function normalize6() {
  25127. var this$1 = this;
  25128. if (arguments.length === 0) {
  25129. this.normalize(this._shell, true);
  25130. for (var i = 0; i < this._holes.length; i++) {
  25131. this$1.normalize(this$1._holes[i], false);
  25132. }
  25133. Arrays.sort(this._holes);
  25134. } else if (arguments.length === 2) {
  25135. var ring = arguments[0];
  25136. var clockwise = arguments[1];
  25137. if (ring.isEmpty()) {
  25138. return null;
  25139. }
  25140. var uniqueCoordinates = new Array(ring.getCoordinates().length - 1).fill(null);
  25141. System.arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length);
  25142. var minCoordinate2 = CoordinateArrays.minCoordinate(ring.getCoordinates());
  25143. CoordinateArrays.scroll(uniqueCoordinates, minCoordinate2);
  25144. System.arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length);
  25145. ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0];
  25146. if (CGAlgorithms.isCCW(ring.getCoordinates()) === clockwise) {
  25147. CoordinateArrays.reverse(ring.getCoordinates());
  25148. }
  25149. }
  25150. };
  25151. Polygon2.prototype.getCoordinate = function getCoordinate18() {
  25152. return this._shell.getCoordinate();
  25153. };
  25154. Polygon2.prototype.getNumInteriorRing = function getNumInteriorRing() {
  25155. return this._holes.length;
  25156. };
  25157. Polygon2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  25158. return 1;
  25159. };
  25160. Polygon2.prototype.getDimension = function getDimension3() {
  25161. return 2;
  25162. };
  25163. Polygon2.prototype.getLength = function getLength3() {
  25164. var this$1 = this;
  25165. var len = 0;
  25166. len += this._shell.getLength();
  25167. for (var i = 0; i < this._holes.length; i++) {
  25168. len += this$1._holes[i].getLength();
  25169. }
  25170. return len;
  25171. };
  25172. Polygon2.prototype.getNumPoints = function getNumPoints() {
  25173. var this$1 = this;
  25174. var numPoints = this._shell.getNumPoints();
  25175. for (var i = 0; i < this._holes.length; i++) {
  25176. numPoints += this$1._holes[i].getNumPoints();
  25177. }
  25178. return numPoints;
  25179. };
  25180. Polygon2.prototype.reverse = function reverse5() {
  25181. var this$1 = this;
  25182. var poly = this.copy();
  25183. poly._shell = this._shell.copy().reverse();
  25184. poly._holes = new Array(this._holes.length).fill(null);
  25185. for (var i = 0; i < this._holes.length; i++) {
  25186. poly._holes[i] = this$1._holes[i].copy().reverse();
  25187. }
  25188. return poly;
  25189. };
  25190. Polygon2.prototype.convexHull = function convexHull() {
  25191. return this.getExteriorRing().convexHull();
  25192. };
  25193. Polygon2.prototype.compareToSameClass = function compareToSameClass() {
  25194. var this$1 = this;
  25195. if (arguments.length === 1) {
  25196. var o = arguments[0];
  25197. var thisShell = this._shell;
  25198. var otherShell = o._shell;
  25199. return thisShell.compareToSameClass(otherShell);
  25200. } else if (arguments.length === 2) {
  25201. var o$1 = arguments[0];
  25202. var comp = arguments[1];
  25203. var poly = o$1;
  25204. var thisShell$1 = this._shell;
  25205. var otherShell$1 = poly._shell;
  25206. var shellComp = thisShell$1.compareToSameClass(otherShell$1, comp);
  25207. if (shellComp !== 0) {
  25208. return shellComp;
  25209. }
  25210. var nHole1 = this.getNumInteriorRing();
  25211. var nHole2 = poly.getNumInteriorRing();
  25212. var i = 0;
  25213. while (i < nHole1 && i < nHole2) {
  25214. var thisHole = this$1.getInteriorRingN(i);
  25215. var otherHole = poly.getInteriorRingN(i);
  25216. var holeComp = thisHole.compareToSameClass(otherHole, comp);
  25217. if (holeComp !== 0) {
  25218. return holeComp;
  25219. }
  25220. i++;
  25221. }
  25222. if (i < nHole1) {
  25223. return 1;
  25224. }
  25225. if (i < nHole2) {
  25226. return -1;
  25227. }
  25228. return 0;
  25229. }
  25230. };
  25231. Polygon2.prototype.apply = function apply(filter17) {
  25232. var this$1 = this;
  25233. if (hasInterface(filter17, CoordinateFilter)) {
  25234. this._shell.apply(filter17);
  25235. for (var i$1 = 0; i$1 < this._holes.length; i$1++) {
  25236. this$1._holes[i$1].apply(filter17);
  25237. }
  25238. } else if (hasInterface(filter17, CoordinateSequenceFilter)) {
  25239. this._shell.apply(filter17);
  25240. if (!filter17.isDone()) {
  25241. for (var i$2 = 0; i$2 < this._holes.length; i$2++) {
  25242. this$1._holes[i$2].apply(filter17);
  25243. if (filter17.isDone()) {
  25244. break;
  25245. }
  25246. }
  25247. }
  25248. if (filter17.isGeometryChanged()) {
  25249. this.geometryChanged();
  25250. }
  25251. } else if (hasInterface(filter17, GeometryFilter)) {
  25252. filter17.filter(this);
  25253. } else if (hasInterface(filter17, GeometryComponentFilter)) {
  25254. filter17.filter(this);
  25255. this._shell.apply(filter17);
  25256. for (var i = 0; i < this._holes.length; i++) {
  25257. this$1._holes[i].apply(filter17);
  25258. }
  25259. }
  25260. };
  25261. Polygon2.prototype.getBoundary = function getBoundary3() {
  25262. var this$1 = this;
  25263. if (this.isEmpty()) {
  25264. return this.getFactory().createMultiLineString();
  25265. }
  25266. var rings = new Array(this._holes.length + 1).fill(null);
  25267. rings[0] = this._shell;
  25268. for (var i = 0; i < this._holes.length; i++) {
  25269. rings[i + 1] = this$1._holes[i];
  25270. }
  25271. if (rings.length <= 1) {
  25272. return this.getFactory().createLinearRing(rings[0].getCoordinateSequence());
  25273. }
  25274. return this.getFactory().createMultiLineString(rings);
  25275. };
  25276. Polygon2.prototype.clone = function clone6() {
  25277. var this$1 = this;
  25278. var poly = Geometry$$1.prototype.clone.call(this);
  25279. poly._shell = this._shell.clone();
  25280. poly._holes = new Array(this._holes.length).fill(null);
  25281. for (var i = 0; i < this._holes.length; i++) {
  25282. poly._holes[i] = this$1._holes[i].clone();
  25283. }
  25284. return poly;
  25285. };
  25286. Polygon2.prototype.getGeometryType = function getGeometryType() {
  25287. return "Polygon";
  25288. };
  25289. Polygon2.prototype.copy = function copy7() {
  25290. var this$1 = this;
  25291. var shell = this._shell.copy();
  25292. var holes = new Array(this._holes.length).fill(null);
  25293. for (var i = 0; i < holes.length; i++) {
  25294. holes[i] = this$1._holes[i].copy();
  25295. }
  25296. return new Polygon2(shell, holes, this._factory);
  25297. };
  25298. Polygon2.prototype.getExteriorRing = function getExteriorRing() {
  25299. return this._shell;
  25300. };
  25301. Polygon2.prototype.isEmpty = function isEmpty6() {
  25302. return this._shell.isEmpty();
  25303. };
  25304. Polygon2.prototype.getInteriorRingN = function getInteriorRingN(n) {
  25305. return this._holes[n];
  25306. };
  25307. Polygon2.prototype.interfaces_ = function interfaces_170() {
  25308. return [Polygonal];
  25309. };
  25310. Polygon2.prototype.getClass = function getClass169() {
  25311. return Polygon2;
  25312. };
  25313. staticAccessors2.serialVersionUID.get = function() {
  25314. return -3494792200821764600;
  25315. };
  25316. Object.defineProperties(Polygon2, staticAccessors2);
  25317. return Polygon2;
  25318. }(Geometry);
  25319. var MultiPoint = function(GeometryCollection$$1) {
  25320. function MultiPoint2() {
  25321. GeometryCollection$$1.apply(this, arguments);
  25322. }
  25323. if (GeometryCollection$$1)
  25324. MultiPoint2.__proto__ = GeometryCollection$$1;
  25325. MultiPoint2.prototype = Object.create(GeometryCollection$$1 && GeometryCollection$$1.prototype);
  25326. MultiPoint2.prototype.constructor = MultiPoint2;
  25327. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  25328. MultiPoint2.prototype.getSortIndex = function getSortIndex() {
  25329. return Geometry.SORTINDEX_MULTIPOINT;
  25330. };
  25331. MultiPoint2.prototype.isValid = function isValid7() {
  25332. return true;
  25333. };
  25334. MultiPoint2.prototype.equalsExact = function equalsExact2() {
  25335. if (arguments.length === 2) {
  25336. var other = arguments[0];
  25337. var tolerance = arguments[1];
  25338. if (!this.isEquivalentClass(other)) {
  25339. return false;
  25340. }
  25341. return GeometryCollection$$1.prototype.equalsExact.call(this, other, tolerance);
  25342. } else {
  25343. return GeometryCollection$$1.prototype.equalsExact.apply(this, arguments);
  25344. }
  25345. };
  25346. MultiPoint2.prototype.getCoordinate = function getCoordinate18() {
  25347. if (arguments.length === 1) {
  25348. var n = arguments[0];
  25349. return this._geometries[n].getCoordinate();
  25350. } else {
  25351. return GeometryCollection$$1.prototype.getCoordinate.apply(this, arguments);
  25352. }
  25353. };
  25354. MultiPoint2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  25355. return Dimension.FALSE;
  25356. };
  25357. MultiPoint2.prototype.getDimension = function getDimension3() {
  25358. return 0;
  25359. };
  25360. MultiPoint2.prototype.getBoundary = function getBoundary3() {
  25361. return this.getFactory().createGeometryCollection(null);
  25362. };
  25363. MultiPoint2.prototype.getGeometryType = function getGeometryType() {
  25364. return "MultiPoint";
  25365. };
  25366. MultiPoint2.prototype.copy = function copy7() {
  25367. var this$1 = this;
  25368. var points2 = new Array(this._geometries.length).fill(null);
  25369. for (var i = 0; i < points2.length; i++) {
  25370. points2[i] = this$1._geometries[i].copy();
  25371. }
  25372. return new MultiPoint2(points2, this._factory);
  25373. };
  25374. MultiPoint2.prototype.interfaces_ = function interfaces_170() {
  25375. return [Puntal];
  25376. };
  25377. MultiPoint2.prototype.getClass = function getClass169() {
  25378. return MultiPoint2;
  25379. };
  25380. staticAccessors2.serialVersionUID.get = function() {
  25381. return -8048474874175356e3;
  25382. };
  25383. Object.defineProperties(MultiPoint2, staticAccessors2);
  25384. return MultiPoint2;
  25385. }(GeometryCollection);
  25386. var LinearRing = function(LineString$$1) {
  25387. function LinearRing2(points2, factory) {
  25388. if (points2 instanceof Coordinate && factory instanceof GeometryFactory) {
  25389. points2 = factory.getCoordinateSequenceFactory().create(points2);
  25390. }
  25391. LineString$$1.call(this, points2, factory);
  25392. this.validateConstruction();
  25393. }
  25394. if (LineString$$1)
  25395. LinearRing2.__proto__ = LineString$$1;
  25396. LinearRing2.prototype = Object.create(LineString$$1 && LineString$$1.prototype);
  25397. LinearRing2.prototype.constructor = LinearRing2;
  25398. var staticAccessors2 = { MINIMUM_VALID_SIZE: { configurable: true }, serialVersionUID: { configurable: true } };
  25399. LinearRing2.prototype.getSortIndex = function getSortIndex() {
  25400. return Geometry.SORTINDEX_LINEARRING;
  25401. };
  25402. LinearRing2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  25403. return Dimension.FALSE;
  25404. };
  25405. LinearRing2.prototype.isClosed = function isClosed5() {
  25406. if (this.isEmpty()) {
  25407. return true;
  25408. }
  25409. return LineString$$1.prototype.isClosed.call(this);
  25410. };
  25411. LinearRing2.prototype.reverse = function reverse5() {
  25412. var seq = this._points.copy();
  25413. CoordinateSequences.reverse(seq);
  25414. var rev = this.getFactory().createLinearRing(seq);
  25415. return rev;
  25416. };
  25417. LinearRing2.prototype.validateConstruction = function validateConstruction() {
  25418. if (!this.isEmpty() && !LineString$$1.prototype.isClosed.call(this)) {
  25419. throw new IllegalArgumentException("Points of LinearRing do not form a closed linestring");
  25420. }
  25421. if (this.getCoordinateSequence().size() >= 1 && this.getCoordinateSequence().size() < LinearRing2.MINIMUM_VALID_SIZE) {
  25422. throw new IllegalArgumentException("Invalid number of points in LinearRing (found " + this.getCoordinateSequence().size() + " - must be 0 or >= 4)");
  25423. }
  25424. };
  25425. LinearRing2.prototype.getGeometryType = function getGeometryType() {
  25426. return "LinearRing";
  25427. };
  25428. LinearRing2.prototype.copy = function copy7() {
  25429. return new LinearRing2(this._points.copy(), this._factory);
  25430. };
  25431. LinearRing2.prototype.interfaces_ = function interfaces_170() {
  25432. return [];
  25433. };
  25434. LinearRing2.prototype.getClass = function getClass169() {
  25435. return LinearRing2;
  25436. };
  25437. staticAccessors2.MINIMUM_VALID_SIZE.get = function() {
  25438. return 4;
  25439. };
  25440. staticAccessors2.serialVersionUID.get = function() {
  25441. return -4261142084085851600;
  25442. };
  25443. Object.defineProperties(LinearRing2, staticAccessors2);
  25444. return LinearRing2;
  25445. }(LineString2);
  25446. var MultiPolygon = function(GeometryCollection$$1) {
  25447. function MultiPolygon2() {
  25448. GeometryCollection$$1.apply(this, arguments);
  25449. }
  25450. if (GeometryCollection$$1)
  25451. MultiPolygon2.__proto__ = GeometryCollection$$1;
  25452. MultiPolygon2.prototype = Object.create(GeometryCollection$$1 && GeometryCollection$$1.prototype);
  25453. MultiPolygon2.prototype.constructor = MultiPolygon2;
  25454. var staticAccessors2 = { serialVersionUID: { configurable: true } };
  25455. MultiPolygon2.prototype.getSortIndex = function getSortIndex() {
  25456. return Geometry.SORTINDEX_MULTIPOLYGON;
  25457. };
  25458. MultiPolygon2.prototype.equalsExact = function equalsExact2() {
  25459. if (arguments.length === 2) {
  25460. var other = arguments[0];
  25461. var tolerance = arguments[1];
  25462. if (!this.isEquivalentClass(other)) {
  25463. return false;
  25464. }
  25465. return GeometryCollection$$1.prototype.equalsExact.call(this, other, tolerance);
  25466. } else {
  25467. return GeometryCollection$$1.prototype.equalsExact.apply(this, arguments);
  25468. }
  25469. };
  25470. MultiPolygon2.prototype.getBoundaryDimension = function getBoundaryDimension() {
  25471. return 1;
  25472. };
  25473. MultiPolygon2.prototype.getDimension = function getDimension3() {
  25474. return 2;
  25475. };
  25476. MultiPolygon2.prototype.reverse = function reverse5() {
  25477. var this$1 = this;
  25478. var n = this._geometries.length;
  25479. var revGeoms = new Array(n).fill(null);
  25480. for (var i = 0; i < this._geometries.length; i++) {
  25481. revGeoms[i] = this$1._geometries[i].reverse();
  25482. }
  25483. return this.getFactory().createMultiPolygon(revGeoms);
  25484. };
  25485. MultiPolygon2.prototype.getBoundary = function getBoundary3() {
  25486. var this$1 = this;
  25487. if (this.isEmpty()) {
  25488. return this.getFactory().createMultiLineString();
  25489. }
  25490. var allRings = new ArrayList();
  25491. for (var i = 0; i < this._geometries.length; i++) {
  25492. var polygon4 = this$1._geometries[i];
  25493. var rings = polygon4.getBoundary();
  25494. for (var j = 0; j < rings.getNumGeometries(); j++) {
  25495. allRings.add(rings.getGeometryN(j));
  25496. }
  25497. }
  25498. var allRingsArray = new Array(allRings.size()).fill(null);
  25499. return this.getFactory().createMultiLineString(allRings.toArray(allRingsArray));
  25500. };
  25501. MultiPolygon2.prototype.getGeometryType = function getGeometryType() {
  25502. return "MultiPolygon";
  25503. };
  25504. MultiPolygon2.prototype.copy = function copy7() {
  25505. var this$1 = this;
  25506. var polygons2 = new Array(this._geometries.length).fill(null);
  25507. for (var i = 0; i < polygons2.length; i++) {
  25508. polygons2[i] = this$1._geometries[i].copy();
  25509. }
  25510. return new MultiPolygon2(polygons2, this._factory);
  25511. };
  25512. MultiPolygon2.prototype.interfaces_ = function interfaces_170() {
  25513. return [Polygonal];
  25514. };
  25515. MultiPolygon2.prototype.getClass = function getClass169() {
  25516. return MultiPolygon2;
  25517. };
  25518. staticAccessors2.serialVersionUID.get = function() {
  25519. return -551033529766975900;
  25520. };
  25521. Object.defineProperties(MultiPolygon2, staticAccessors2);
  25522. return MultiPolygon2;
  25523. }(GeometryCollection);
  25524. var GeometryEditor = function GeometryEditor2(factory) {
  25525. this._factory = factory || null;
  25526. this._isUserDataCopied = false;
  25527. };
  25528. var staticAccessors$16 = { NoOpGeometryOperation: { configurable: true }, CoordinateOperation: { configurable: true }, CoordinateSequenceOperation: { configurable: true } };
  25529. GeometryEditor.prototype.setCopyUserData = function setCopyUserData(isUserDataCopied) {
  25530. this._isUserDataCopied = isUserDataCopied;
  25531. };
  25532. GeometryEditor.prototype.edit = function edit(geometry2, operation2) {
  25533. if (geometry2 === null) {
  25534. return null;
  25535. }
  25536. var result = this.editInternal(geometry2, operation2);
  25537. if (this._isUserDataCopied) {
  25538. result.setUserData(geometry2.getUserData());
  25539. }
  25540. return result;
  25541. };
  25542. GeometryEditor.prototype.editInternal = function editInternal(geometry2, operation2) {
  25543. if (this._factory === null) {
  25544. this._factory = geometry2.getFactory();
  25545. }
  25546. if (geometry2 instanceof GeometryCollection) {
  25547. return this.editGeometryCollection(geometry2, operation2);
  25548. }
  25549. if (geometry2 instanceof Polygon) {
  25550. return this.editPolygon(geometry2, operation2);
  25551. }
  25552. if (geometry2 instanceof Point) {
  25553. return operation2.edit(geometry2, this._factory);
  25554. }
  25555. if (geometry2 instanceof LineString2) {
  25556. return operation2.edit(geometry2, this._factory);
  25557. }
  25558. Assert.shouldNeverReachHere("Unsupported Geometry class: " + geometry2.getClass().getName());
  25559. return null;
  25560. };
  25561. GeometryEditor.prototype.editGeometryCollection = function editGeometryCollection(collection, operation2) {
  25562. var this$1 = this;
  25563. var collectionForType = operation2.edit(collection, this._factory);
  25564. var geometries = new ArrayList();
  25565. for (var i = 0; i < collectionForType.getNumGeometries(); i++) {
  25566. var geometry2 = this$1.edit(collectionForType.getGeometryN(i), operation2);
  25567. if (geometry2 === null || geometry2.isEmpty()) {
  25568. continue;
  25569. }
  25570. geometries.add(geometry2);
  25571. }
  25572. if (collectionForType.getClass() === MultiPoint) {
  25573. return this._factory.createMultiPoint(geometries.toArray([]));
  25574. }
  25575. if (collectionForType.getClass() === MultiLineString) {
  25576. return this._factory.createMultiLineString(geometries.toArray([]));
  25577. }
  25578. if (collectionForType.getClass() === MultiPolygon) {
  25579. return this._factory.createMultiPolygon(geometries.toArray([]));
  25580. }
  25581. return this._factory.createGeometryCollection(geometries.toArray([]));
  25582. };
  25583. GeometryEditor.prototype.editPolygon = function editPolygon(polygon4, operation2) {
  25584. var this$1 = this;
  25585. var newPolygon = operation2.edit(polygon4, this._factory);
  25586. if (newPolygon === null) {
  25587. newPolygon = this._factory.createPolygon(null);
  25588. }
  25589. if (newPolygon.isEmpty()) {
  25590. return newPolygon;
  25591. }
  25592. var shell = this.edit(newPolygon.getExteriorRing(), operation2);
  25593. if (shell === null || shell.isEmpty()) {
  25594. return this._factory.createPolygon();
  25595. }
  25596. var holes = new ArrayList();
  25597. for (var i = 0; i < newPolygon.getNumInteriorRing(); i++) {
  25598. var hole = this$1.edit(newPolygon.getInteriorRingN(i), operation2);
  25599. if (hole === null || hole.isEmpty()) {
  25600. continue;
  25601. }
  25602. holes.add(hole);
  25603. }
  25604. return this._factory.createPolygon(shell, holes.toArray([]));
  25605. };
  25606. GeometryEditor.prototype.interfaces_ = function interfaces_39() {
  25607. return [];
  25608. };
  25609. GeometryEditor.prototype.getClass = function getClass38() {
  25610. return GeometryEditor;
  25611. };
  25612. GeometryEditor.GeometryEditorOperation = function GeometryEditorOperation() {
  25613. };
  25614. staticAccessors$16.NoOpGeometryOperation.get = function() {
  25615. return NoOpGeometryOperation;
  25616. };
  25617. staticAccessors$16.CoordinateOperation.get = function() {
  25618. return CoordinateOperation;
  25619. };
  25620. staticAccessors$16.CoordinateSequenceOperation.get = function() {
  25621. return CoordinateSequenceOperation;
  25622. };
  25623. Object.defineProperties(GeometryEditor, staticAccessors$16);
  25624. var NoOpGeometryOperation = function NoOpGeometryOperation2() {
  25625. };
  25626. NoOpGeometryOperation.prototype.edit = function edit2(geometry2, factory) {
  25627. return geometry2;
  25628. };
  25629. NoOpGeometryOperation.prototype.interfaces_ = function interfaces_40() {
  25630. return [GeometryEditor.GeometryEditorOperation];
  25631. };
  25632. NoOpGeometryOperation.prototype.getClass = function getClass39() {
  25633. return NoOpGeometryOperation;
  25634. };
  25635. var CoordinateOperation = function CoordinateOperation2() {
  25636. };
  25637. CoordinateOperation.prototype.edit = function edit3(geometry2, factory) {
  25638. var coords = this.editCoordinates(geometry2.getCoordinates(), geometry2);
  25639. if (coords === null) {
  25640. return geometry2;
  25641. }
  25642. if (geometry2 instanceof LinearRing) {
  25643. return factory.createLinearRing(coords);
  25644. }
  25645. if (geometry2 instanceof LineString2) {
  25646. return factory.createLineString(coords);
  25647. }
  25648. if (geometry2 instanceof Point) {
  25649. if (coords.length > 0) {
  25650. return factory.createPoint(coords[0]);
  25651. } else {
  25652. return factory.createPoint();
  25653. }
  25654. }
  25655. return geometry2;
  25656. };
  25657. CoordinateOperation.prototype.interfaces_ = function interfaces_41() {
  25658. return [GeometryEditor.GeometryEditorOperation];
  25659. };
  25660. CoordinateOperation.prototype.getClass = function getClass40() {
  25661. return CoordinateOperation;
  25662. };
  25663. var CoordinateSequenceOperation = function CoordinateSequenceOperation2() {
  25664. };
  25665. CoordinateSequenceOperation.prototype.edit = function edit4(geometry2, factory) {
  25666. if (geometry2 instanceof LinearRing) {
  25667. return factory.createLinearRing(this.edit(geometry2.getCoordinateSequence(), geometry2));
  25668. }
  25669. if (geometry2 instanceof LineString2) {
  25670. return factory.createLineString(this.edit(geometry2.getCoordinateSequence(), geometry2));
  25671. }
  25672. if (geometry2 instanceof Point) {
  25673. return factory.createPoint(this.edit(geometry2.getCoordinateSequence(), geometry2));
  25674. }
  25675. return geometry2;
  25676. };
  25677. CoordinateSequenceOperation.prototype.interfaces_ = function interfaces_42() {
  25678. return [GeometryEditor.GeometryEditorOperation];
  25679. };
  25680. CoordinateSequenceOperation.prototype.getClass = function getClass41() {
  25681. return CoordinateSequenceOperation;
  25682. };
  25683. var CoordinateArraySequence = function CoordinateArraySequence2() {
  25684. var this$1 = this;
  25685. this._dimension = 3;
  25686. this._coordinates = null;
  25687. if (arguments.length === 1) {
  25688. if (arguments[0] instanceof Array) {
  25689. this._coordinates = arguments[0];
  25690. this._dimension = 3;
  25691. } else if (Number.isInteger(arguments[0])) {
  25692. var size11 = arguments[0];
  25693. this._coordinates = new Array(size11).fill(null);
  25694. for (var i = 0; i < size11; i++) {
  25695. this$1._coordinates[i] = new Coordinate();
  25696. }
  25697. } else if (hasInterface(arguments[0], CoordinateSequence)) {
  25698. var coordSeq = arguments[0];
  25699. if (coordSeq === null) {
  25700. this._coordinates = new Array(0).fill(null);
  25701. return null;
  25702. }
  25703. this._dimension = coordSeq.getDimension();
  25704. this._coordinates = new Array(coordSeq.size()).fill(null);
  25705. for (var i$1 = 0; i$1 < this._coordinates.length; i$1++) {
  25706. this$1._coordinates[i$1] = coordSeq.getCoordinateCopy(i$1);
  25707. }
  25708. }
  25709. } else if (arguments.length === 2) {
  25710. if (arguments[0] instanceof Array && Number.isInteger(arguments[1])) {
  25711. var coordinates = arguments[0];
  25712. var dimension = arguments[1];
  25713. this._coordinates = coordinates;
  25714. this._dimension = dimension;
  25715. if (coordinates === null) {
  25716. this._coordinates = new Array(0).fill(null);
  25717. }
  25718. } else if (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1])) {
  25719. var size$1 = arguments[0];
  25720. var dimension$1 = arguments[1];
  25721. this._coordinates = new Array(size$1).fill(null);
  25722. this._dimension = dimension$1;
  25723. for (var i$2 = 0; i$2 < size$1; i$2++) {
  25724. this$1._coordinates[i$2] = new Coordinate();
  25725. }
  25726. }
  25727. }
  25728. };
  25729. var staticAccessors$18 = { serialVersionUID: { configurable: true } };
  25730. CoordinateArraySequence.prototype.setOrdinate = function setOrdinate3(index2, ordinateIndex, value) {
  25731. switch (ordinateIndex) {
  25732. case CoordinateSequence.X:
  25733. this._coordinates[index2].x = value;
  25734. break;
  25735. case CoordinateSequence.Y:
  25736. this._coordinates[index2].y = value;
  25737. break;
  25738. case CoordinateSequence.Z:
  25739. this._coordinates[index2].z = value;
  25740. break;
  25741. default:
  25742. throw new IllegalArgumentException("invalid ordinateIndex");
  25743. }
  25744. };
  25745. CoordinateArraySequence.prototype.size = function size4() {
  25746. return this._coordinates.length;
  25747. };
  25748. CoordinateArraySequence.prototype.getOrdinate = function getOrdinate3(index2, ordinateIndex) {
  25749. switch (ordinateIndex) {
  25750. case CoordinateSequence.X:
  25751. return this._coordinates[index2].x;
  25752. case CoordinateSequence.Y:
  25753. return this._coordinates[index2].y;
  25754. case CoordinateSequence.Z:
  25755. return this._coordinates[index2].z;
  25756. default:
  25757. }
  25758. return Double.NaN;
  25759. };
  25760. CoordinateArraySequence.prototype.getCoordinate = function getCoordinate3() {
  25761. if (arguments.length === 1) {
  25762. var i = arguments[0];
  25763. return this._coordinates[i];
  25764. } else if (arguments.length === 2) {
  25765. var index2 = arguments[0];
  25766. var coord = arguments[1];
  25767. coord.x = this._coordinates[index2].x;
  25768. coord.y = this._coordinates[index2].y;
  25769. coord.z = this._coordinates[index2].z;
  25770. }
  25771. };
  25772. CoordinateArraySequence.prototype.getCoordinateCopy = function getCoordinateCopy2(i) {
  25773. return new Coordinate(this._coordinates[i]);
  25774. };
  25775. CoordinateArraySequence.prototype.getDimension = function getDimension2() {
  25776. return this._dimension;
  25777. };
  25778. CoordinateArraySequence.prototype.getX = function getX3(index2) {
  25779. return this._coordinates[index2].x;
  25780. };
  25781. CoordinateArraySequence.prototype.clone = function clone5() {
  25782. var this$1 = this;
  25783. var cloneCoordinates = new Array(this.size()).fill(null);
  25784. for (var i = 0; i < this._coordinates.length; i++) {
  25785. cloneCoordinates[i] = this$1._coordinates[i].clone();
  25786. }
  25787. return new CoordinateArraySequence(cloneCoordinates, this._dimension);
  25788. };
  25789. CoordinateArraySequence.prototype.expandEnvelope = function expandEnvelope2(env) {
  25790. var this$1 = this;
  25791. for (var i = 0; i < this._coordinates.length; i++) {
  25792. env.expandToInclude(this$1._coordinates[i]);
  25793. }
  25794. return env;
  25795. };
  25796. CoordinateArraySequence.prototype.copy = function copy5() {
  25797. var this$1 = this;
  25798. var cloneCoordinates = new Array(this.size()).fill(null);
  25799. for (var i = 0; i < this._coordinates.length; i++) {
  25800. cloneCoordinates[i] = this$1._coordinates[i].copy();
  25801. }
  25802. return new CoordinateArraySequence(cloneCoordinates, this._dimension);
  25803. };
  25804. CoordinateArraySequence.prototype.toString = function toString8() {
  25805. var this$1 = this;
  25806. if (this._coordinates.length > 0) {
  25807. var strBuf = new StringBuffer(17 * this._coordinates.length);
  25808. strBuf.append("(");
  25809. strBuf.append(this._coordinates[0]);
  25810. for (var i = 1; i < this._coordinates.length; i++) {
  25811. strBuf.append(", ");
  25812. strBuf.append(this$1._coordinates[i]);
  25813. }
  25814. strBuf.append(")");
  25815. return strBuf.toString();
  25816. } else {
  25817. return "()";
  25818. }
  25819. };
  25820. CoordinateArraySequence.prototype.getY = function getY3(index2) {
  25821. return this._coordinates[index2].y;
  25822. };
  25823. CoordinateArraySequence.prototype.toCoordinateArray = function toCoordinateArray3() {
  25824. return this._coordinates;
  25825. };
  25826. CoordinateArraySequence.prototype.interfaces_ = function interfaces_43() {
  25827. return [CoordinateSequence, Serializable];
  25828. };
  25829. CoordinateArraySequence.prototype.getClass = function getClass42() {
  25830. return CoordinateArraySequence;
  25831. };
  25832. staticAccessors$18.serialVersionUID.get = function() {
  25833. return -915438501601840600;
  25834. };
  25835. Object.defineProperties(CoordinateArraySequence, staticAccessors$18);
  25836. var CoordinateArraySequenceFactory = function CoordinateArraySequenceFactory2() {
  25837. };
  25838. var staticAccessors$17 = { serialVersionUID: { configurable: true }, instanceObject: { configurable: true } };
  25839. CoordinateArraySequenceFactory.prototype.readResolve = function readResolve() {
  25840. return CoordinateArraySequenceFactory.instance();
  25841. };
  25842. CoordinateArraySequenceFactory.prototype.create = function create2() {
  25843. if (arguments.length === 1) {
  25844. if (arguments[0] instanceof Array) {
  25845. var coordinates = arguments[0];
  25846. return new CoordinateArraySequence(coordinates);
  25847. } else if (hasInterface(arguments[0], CoordinateSequence)) {
  25848. var coordSeq = arguments[0];
  25849. return new CoordinateArraySequence(coordSeq);
  25850. }
  25851. } else if (arguments.length === 2) {
  25852. var size11 = arguments[0];
  25853. var dimension = arguments[1];
  25854. if (dimension > 3) {
  25855. dimension = 3;
  25856. }
  25857. if (dimension < 2) {
  25858. return new CoordinateArraySequence(size11);
  25859. }
  25860. return new CoordinateArraySequence(size11, dimension);
  25861. }
  25862. };
  25863. CoordinateArraySequenceFactory.prototype.interfaces_ = function interfaces_44() {
  25864. return [CoordinateSequenceFactory, Serializable];
  25865. };
  25866. CoordinateArraySequenceFactory.prototype.getClass = function getClass43() {
  25867. return CoordinateArraySequenceFactory;
  25868. };
  25869. CoordinateArraySequenceFactory.instance = function instance() {
  25870. return CoordinateArraySequenceFactory.instanceObject;
  25871. };
  25872. staticAccessors$17.serialVersionUID.get = function() {
  25873. return -4099577099607551500;
  25874. };
  25875. staticAccessors$17.instanceObject.get = function() {
  25876. return new CoordinateArraySequenceFactory();
  25877. };
  25878. Object.defineProperties(CoordinateArraySequenceFactory, staticAccessors$17);
  25879. var HashMap = function(MapInterface) {
  25880. function HashMap2() {
  25881. MapInterface.call(this);
  25882. this.map_ = /* @__PURE__ */ new Map();
  25883. }
  25884. if (MapInterface)
  25885. HashMap2.__proto__ = MapInterface;
  25886. HashMap2.prototype = Object.create(MapInterface && MapInterface.prototype);
  25887. HashMap2.prototype.constructor = HashMap2;
  25888. HashMap2.prototype.get = function get4(key) {
  25889. return this.map_.get(key) || null;
  25890. };
  25891. HashMap2.prototype.put = function put2(key, value) {
  25892. this.map_.set(key, value);
  25893. return value;
  25894. };
  25895. HashMap2.prototype.values = function values3() {
  25896. var arrayList = new ArrayList();
  25897. var it = this.map_.values();
  25898. var o = it.next();
  25899. while (!o.done) {
  25900. arrayList.add(o.value);
  25901. o = it.next();
  25902. }
  25903. return arrayList;
  25904. };
  25905. HashMap2.prototype.entrySet = function entrySet2() {
  25906. var hashSet = new HashSet();
  25907. this.map_.entries().forEach(function(entry) {
  25908. return hashSet.add(entry);
  25909. });
  25910. return hashSet;
  25911. };
  25912. HashMap2.prototype.size = function size11() {
  25913. return this.map_.size();
  25914. };
  25915. return HashMap2;
  25916. }(Map$1);
  25917. var PrecisionModel = function PrecisionModel2() {
  25918. this._modelType = null;
  25919. this._scale = null;
  25920. if (arguments.length === 0) {
  25921. this._modelType = PrecisionModel2.FLOATING;
  25922. } else if (arguments.length === 1) {
  25923. if (arguments[0] instanceof Type) {
  25924. var modelType = arguments[0];
  25925. this._modelType = modelType;
  25926. if (modelType === PrecisionModel2.FIXED) {
  25927. this.setScale(1);
  25928. }
  25929. } else if (typeof arguments[0] === "number") {
  25930. var scale4 = arguments[0];
  25931. this._modelType = PrecisionModel2.FIXED;
  25932. this.setScale(scale4);
  25933. } else if (arguments[0] instanceof PrecisionModel2) {
  25934. var pm = arguments[0];
  25935. this._modelType = pm._modelType;
  25936. this._scale = pm._scale;
  25937. }
  25938. }
  25939. };
  25940. var staticAccessors$19 = { serialVersionUID: { configurable: true }, maximumPreciseValue: { configurable: true } };
  25941. PrecisionModel.prototype.equals = function equals8(other) {
  25942. if (!(other instanceof PrecisionModel)) {
  25943. return false;
  25944. }
  25945. var otherPrecisionModel = other;
  25946. return this._modelType === otherPrecisionModel._modelType && this._scale === otherPrecisionModel._scale;
  25947. };
  25948. PrecisionModel.prototype.compareTo = function compareTo6(o) {
  25949. var other = o;
  25950. var sigDigits = this.getMaximumSignificantDigits();
  25951. var otherSigDigits = other.getMaximumSignificantDigits();
  25952. return new Integer(sigDigits).compareTo(new Integer(otherSigDigits));
  25953. };
  25954. PrecisionModel.prototype.getScale = function getScale() {
  25955. return this._scale;
  25956. };
  25957. PrecisionModel.prototype.isFloating = function isFloating() {
  25958. return this._modelType === PrecisionModel.FLOATING || this._modelType === PrecisionModel.FLOATING_SINGLE;
  25959. };
  25960. PrecisionModel.prototype.getType = function getType3() {
  25961. return this._modelType;
  25962. };
  25963. PrecisionModel.prototype.toString = function toString9() {
  25964. var description = "UNKNOWN";
  25965. if (this._modelType === PrecisionModel.FLOATING) {
  25966. description = "Floating";
  25967. } else if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
  25968. description = "Floating-Single";
  25969. } else if (this._modelType === PrecisionModel.FIXED) {
  25970. description = "Fixed (Scale=" + this.getScale() + ")";
  25971. }
  25972. return description;
  25973. };
  25974. PrecisionModel.prototype.makePrecise = function makePrecise() {
  25975. if (typeof arguments[0] === "number") {
  25976. var val = arguments[0];
  25977. if (Double.isNaN(val)) {
  25978. return val;
  25979. }
  25980. if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
  25981. var floatSingleVal = val;
  25982. return floatSingleVal;
  25983. }
  25984. if (this._modelType === PrecisionModel.FIXED) {
  25985. return Math.round(val * this._scale) / this._scale;
  25986. }
  25987. return val;
  25988. } else if (arguments[0] instanceof Coordinate) {
  25989. var coord = arguments[0];
  25990. if (this._modelType === PrecisionModel.FLOATING) {
  25991. return null;
  25992. }
  25993. coord.x = this.makePrecise(coord.x);
  25994. coord.y = this.makePrecise(coord.y);
  25995. }
  25996. };
  25997. PrecisionModel.prototype.getMaximumSignificantDigits = function getMaximumSignificantDigits() {
  25998. var maxSigDigits = 16;
  25999. if (this._modelType === PrecisionModel.FLOATING) {
  26000. maxSigDigits = 16;
  26001. } else if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
  26002. maxSigDigits = 6;
  26003. } else if (this._modelType === PrecisionModel.FIXED) {
  26004. maxSigDigits = 1 + Math.trunc(Math.ceil(Math.log(this.getScale()) / Math.log(10)));
  26005. }
  26006. return maxSigDigits;
  26007. };
  26008. PrecisionModel.prototype.setScale = function setScale(scale4) {
  26009. this._scale = Math.abs(scale4);
  26010. };
  26011. PrecisionModel.prototype.interfaces_ = function interfaces_45() {
  26012. return [Serializable, Comparable];
  26013. };
  26014. PrecisionModel.prototype.getClass = function getClass44() {
  26015. return PrecisionModel;
  26016. };
  26017. PrecisionModel.mostPrecise = function mostPrecise(pm1, pm2) {
  26018. if (pm1.compareTo(pm2) >= 0) {
  26019. return pm1;
  26020. }
  26021. return pm2;
  26022. };
  26023. staticAccessors$19.serialVersionUID.get = function() {
  26024. return 7777263578777804e3;
  26025. };
  26026. staticAccessors$19.maximumPreciseValue.get = function() {
  26027. return 9007199254740992;
  26028. };
  26029. Object.defineProperties(PrecisionModel, staticAccessors$19);
  26030. var Type = function Type2(name) {
  26031. this._name = name || null;
  26032. Type2.nameToTypeMap.put(name, this);
  26033. };
  26034. var staticAccessors$1$1 = { serialVersionUID: { configurable: true }, nameToTypeMap: { configurable: true } };
  26035. Type.prototype.readResolve = function readResolve2() {
  26036. return Type.nameToTypeMap.get(this._name);
  26037. };
  26038. Type.prototype.toString = function toString10() {
  26039. return this._name;
  26040. };
  26041. Type.prototype.interfaces_ = function interfaces_46() {
  26042. return [Serializable];
  26043. };
  26044. Type.prototype.getClass = function getClass45() {
  26045. return Type;
  26046. };
  26047. staticAccessors$1$1.serialVersionUID.get = function() {
  26048. return -552860263173159e4;
  26049. };
  26050. staticAccessors$1$1.nameToTypeMap.get = function() {
  26051. return new HashMap();
  26052. };
  26053. Object.defineProperties(Type, staticAccessors$1$1);
  26054. PrecisionModel.Type = Type;
  26055. PrecisionModel.FIXED = new Type("FIXED");
  26056. PrecisionModel.FLOATING = new Type("FLOATING");
  26057. PrecisionModel.FLOATING_SINGLE = new Type("FLOATING SINGLE");
  26058. var GeometryFactory = function GeometryFactory2() {
  26059. this._precisionModel = new PrecisionModel();
  26060. this._SRID = 0;
  26061. this._coordinateSequenceFactory = GeometryFactory2.getDefaultCoordinateSequenceFactory();
  26062. if (arguments.length === 0) {
  26063. } else if (arguments.length === 1) {
  26064. if (hasInterface(arguments[0], CoordinateSequenceFactory)) {
  26065. this._coordinateSequenceFactory = arguments[0];
  26066. } else if (arguments[0] instanceof PrecisionModel) {
  26067. this._precisionModel = arguments[0];
  26068. }
  26069. } else if (arguments.length === 2) {
  26070. this._precisionModel = arguments[0];
  26071. this._SRID = arguments[1];
  26072. } else if (arguments.length === 3) {
  26073. this._precisionModel = arguments[0];
  26074. this._SRID = arguments[1];
  26075. this._coordinateSequenceFactory = arguments[2];
  26076. }
  26077. };
  26078. var staticAccessors$2 = { serialVersionUID: { configurable: true } };
  26079. GeometryFactory.prototype.toGeometry = function toGeometry(envelope3) {
  26080. if (envelope3.isNull()) {
  26081. return this.createPoint(null);
  26082. }
  26083. if (envelope3.getMinX() === envelope3.getMaxX() && envelope3.getMinY() === envelope3.getMaxY()) {
  26084. return this.createPoint(new Coordinate(envelope3.getMinX(), envelope3.getMinY()));
  26085. }
  26086. if (envelope3.getMinX() === envelope3.getMaxX() || envelope3.getMinY() === envelope3.getMaxY()) {
  26087. return this.createLineString([new Coordinate(envelope3.getMinX(), envelope3.getMinY()), new Coordinate(envelope3.getMaxX(), envelope3.getMaxY())]);
  26088. }
  26089. return this.createPolygon(this.createLinearRing([new Coordinate(envelope3.getMinX(), envelope3.getMinY()), new Coordinate(envelope3.getMinX(), envelope3.getMaxY()), new Coordinate(envelope3.getMaxX(), envelope3.getMaxY()), new Coordinate(envelope3.getMaxX(), envelope3.getMinY()), new Coordinate(envelope3.getMinX(), envelope3.getMinY())]), null);
  26090. };
  26091. GeometryFactory.prototype.createLineString = function createLineString(coordinates) {
  26092. if (!coordinates) {
  26093. return new LineString2(this.getCoordinateSequenceFactory().create([]), this);
  26094. } else if (coordinates instanceof Array) {
  26095. return new LineString2(this.getCoordinateSequenceFactory().create(coordinates), this);
  26096. } else if (hasInterface(coordinates, CoordinateSequence)) {
  26097. return new LineString2(coordinates, this);
  26098. }
  26099. };
  26100. GeometryFactory.prototype.createMultiLineString = function createMultiLineString() {
  26101. if (arguments.length === 0) {
  26102. return new MultiLineString(null, this);
  26103. } else if (arguments.length === 1) {
  26104. var lineStrings2 = arguments[0];
  26105. return new MultiLineString(lineStrings2, this);
  26106. }
  26107. };
  26108. GeometryFactory.prototype.buildGeometry = function buildGeometry(geomList) {
  26109. var geomClass = null;
  26110. var isHeterogeneous = false;
  26111. var hasGeometryCollection = false;
  26112. for (var i = geomList.iterator(); i.hasNext(); ) {
  26113. var geom = i.next();
  26114. var partClass = geom.getClass();
  26115. if (geomClass === null) {
  26116. geomClass = partClass;
  26117. }
  26118. if (partClass !== geomClass) {
  26119. isHeterogeneous = true;
  26120. }
  26121. if (geom.isGeometryCollectionOrDerived()) {
  26122. hasGeometryCollection = true;
  26123. }
  26124. }
  26125. if (geomClass === null) {
  26126. return this.createGeometryCollection();
  26127. }
  26128. if (isHeterogeneous || hasGeometryCollection) {
  26129. return this.createGeometryCollection(GeometryFactory.toGeometryArray(geomList));
  26130. }
  26131. var geom0 = geomList.iterator().next();
  26132. var isCollection = geomList.size() > 1;
  26133. if (isCollection) {
  26134. if (geom0 instanceof Polygon) {
  26135. return this.createMultiPolygon(GeometryFactory.toPolygonArray(geomList));
  26136. } else if (geom0 instanceof LineString2) {
  26137. return this.createMultiLineString(GeometryFactory.toLineStringArray(geomList));
  26138. } else if (geom0 instanceof Point) {
  26139. return this.createMultiPoint(GeometryFactory.toPointArray(geomList));
  26140. }
  26141. Assert.shouldNeverReachHere("Unhandled class: " + geom0.getClass().getName());
  26142. }
  26143. return geom0;
  26144. };
  26145. GeometryFactory.prototype.createMultiPointFromCoords = function createMultiPointFromCoords(coordinates) {
  26146. return this.createMultiPoint(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
  26147. };
  26148. GeometryFactory.prototype.createPoint = function createPoint() {
  26149. if (arguments.length === 0) {
  26150. return this.createPoint(this.getCoordinateSequenceFactory().create([]));
  26151. } else if (arguments.length === 1) {
  26152. if (arguments[0] instanceof Coordinate) {
  26153. var coordinate2 = arguments[0];
  26154. return this.createPoint(coordinate2 !== null ? this.getCoordinateSequenceFactory().create([coordinate2]) : null);
  26155. } else if (hasInterface(arguments[0], CoordinateSequence)) {
  26156. var coordinates = arguments[0];
  26157. return new Point(coordinates, this);
  26158. }
  26159. }
  26160. };
  26161. GeometryFactory.prototype.getCoordinateSequenceFactory = function getCoordinateSequenceFactory() {
  26162. return this._coordinateSequenceFactory;
  26163. };
  26164. GeometryFactory.prototype.createPolygon = function createPolygon() {
  26165. if (arguments.length === 0) {
  26166. return new Polygon(null, null, this);
  26167. } else if (arguments.length === 1) {
  26168. if (hasInterface(arguments[0], CoordinateSequence)) {
  26169. var coordinates = arguments[0];
  26170. return this.createPolygon(this.createLinearRing(coordinates));
  26171. } else if (arguments[0] instanceof Array) {
  26172. var coordinates$1 = arguments[0];
  26173. return this.createPolygon(this.createLinearRing(coordinates$1));
  26174. } else if (arguments[0] instanceof LinearRing) {
  26175. var shell = arguments[0];
  26176. return this.createPolygon(shell, null);
  26177. }
  26178. } else if (arguments.length === 2) {
  26179. var shell$1 = arguments[0];
  26180. var holes = arguments[1];
  26181. return new Polygon(shell$1, holes, this);
  26182. }
  26183. };
  26184. GeometryFactory.prototype.getSRID = function getSRID2() {
  26185. return this._SRID;
  26186. };
  26187. GeometryFactory.prototype.createGeometryCollection = function createGeometryCollection() {
  26188. if (arguments.length === 0) {
  26189. return new GeometryCollection(null, this);
  26190. } else if (arguments.length === 1) {
  26191. var geometries = arguments[0];
  26192. return new GeometryCollection(geometries, this);
  26193. }
  26194. };
  26195. GeometryFactory.prototype.createGeometry = function createGeometry(g) {
  26196. var editor = new GeometryEditor(this);
  26197. return editor.edit(g, {
  26198. edit: function() {
  26199. if (arguments.length === 2) {
  26200. var coordSeq = arguments[0];
  26201. return this._coordinateSequenceFactory.create(coordSeq);
  26202. }
  26203. }
  26204. });
  26205. };
  26206. GeometryFactory.prototype.getPrecisionModel = function getPrecisionModel2() {
  26207. return this._precisionModel;
  26208. };
  26209. GeometryFactory.prototype.createLinearRing = function createLinearRing() {
  26210. if (arguments.length === 0) {
  26211. return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));
  26212. } else if (arguments.length === 1) {
  26213. if (arguments[0] instanceof Array) {
  26214. var coordinates = arguments[0];
  26215. return this.createLinearRing(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
  26216. } else if (hasInterface(arguments[0], CoordinateSequence)) {
  26217. var coordinates$1 = arguments[0];
  26218. return new LinearRing(coordinates$1, this);
  26219. }
  26220. }
  26221. };
  26222. GeometryFactory.prototype.createMultiPolygon = function createMultiPolygon() {
  26223. if (arguments.length === 0) {
  26224. return new MultiPolygon(null, this);
  26225. } else if (arguments.length === 1) {
  26226. var polygons2 = arguments[0];
  26227. return new MultiPolygon(polygons2, this);
  26228. }
  26229. };
  26230. GeometryFactory.prototype.createMultiPoint = function createMultiPoint() {
  26231. var this$1 = this;
  26232. if (arguments.length === 0) {
  26233. return new MultiPoint(null, this);
  26234. } else if (arguments.length === 1) {
  26235. if (arguments[0] instanceof Array) {
  26236. var point4 = arguments[0];
  26237. return new MultiPoint(point4, this);
  26238. } else if (arguments[0] instanceof Array) {
  26239. var coordinates = arguments[0];
  26240. return this.createMultiPoint(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
  26241. } else if (hasInterface(arguments[0], CoordinateSequence)) {
  26242. var coordinates$1 = arguments[0];
  26243. if (coordinates$1 === null) {
  26244. return this.createMultiPoint(new Array(0).fill(null));
  26245. }
  26246. var points2 = new Array(coordinates$1.size()).fill(null);
  26247. for (var i = 0; i < coordinates$1.size(); i++) {
  26248. var ptSeq = this$1.getCoordinateSequenceFactory().create(1, coordinates$1.getDimension());
  26249. CoordinateSequences.copy(coordinates$1, i, ptSeq, 0, 1);
  26250. points2[i] = this$1.createPoint(ptSeq);
  26251. }
  26252. return this.createMultiPoint(points2);
  26253. }
  26254. }
  26255. };
  26256. GeometryFactory.prototype.interfaces_ = function interfaces_47() {
  26257. return [Serializable];
  26258. };
  26259. GeometryFactory.prototype.getClass = function getClass46() {
  26260. return GeometryFactory;
  26261. };
  26262. GeometryFactory.toMultiPolygonArray = function toMultiPolygonArray(multiPolygons) {
  26263. var multiPolygonArray = new Array(multiPolygons.size()).fill(null);
  26264. return multiPolygons.toArray(multiPolygonArray);
  26265. };
  26266. GeometryFactory.toGeometryArray = function toGeometryArray(geometries) {
  26267. if (geometries === null) {
  26268. return null;
  26269. }
  26270. var geometryArray = new Array(geometries.size()).fill(null);
  26271. return geometries.toArray(geometryArray);
  26272. };
  26273. GeometryFactory.getDefaultCoordinateSequenceFactory = function getDefaultCoordinateSequenceFactory() {
  26274. return CoordinateArraySequenceFactory.instance();
  26275. };
  26276. GeometryFactory.toMultiLineStringArray = function toMultiLineStringArray(multiLineStrings) {
  26277. var multiLineStringArray = new Array(multiLineStrings.size()).fill(null);
  26278. return multiLineStrings.toArray(multiLineStringArray);
  26279. };
  26280. GeometryFactory.toLineStringArray = function toLineStringArray(lineStrings2) {
  26281. var lineStringArray = new Array(lineStrings2.size()).fill(null);
  26282. return lineStrings2.toArray(lineStringArray);
  26283. };
  26284. GeometryFactory.toMultiPointArray = function toMultiPointArray(multiPoints) {
  26285. var multiPointArray = new Array(multiPoints.size()).fill(null);
  26286. return multiPoints.toArray(multiPointArray);
  26287. };
  26288. GeometryFactory.toLinearRingArray = function toLinearRingArray(linearRings) {
  26289. var linearRingArray = new Array(linearRings.size()).fill(null);
  26290. return linearRings.toArray(linearRingArray);
  26291. };
  26292. GeometryFactory.toPointArray = function toPointArray(points2) {
  26293. var pointArray = new Array(points2.size()).fill(null);
  26294. return points2.toArray(pointArray);
  26295. };
  26296. GeometryFactory.toPolygonArray = function toPolygonArray(polygons2) {
  26297. var polygonArray = new Array(polygons2.size()).fill(null);
  26298. return polygons2.toArray(polygonArray);
  26299. };
  26300. GeometryFactory.createPointFromInternalCoord = function createPointFromInternalCoord(coord, exemplar) {
  26301. exemplar.getPrecisionModel().makePrecise(coord);
  26302. return exemplar.getFactory().createPoint(coord);
  26303. };
  26304. staticAccessors$2.serialVersionUID.get = function() {
  26305. return -6820524753094096e3;
  26306. };
  26307. Object.defineProperties(GeometryFactory, staticAccessors$2);
  26308. var geometryTypes = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"];
  26309. var GeoJSONParser = function GeoJSONParser2(geometryFactory) {
  26310. this.geometryFactory = geometryFactory || new GeometryFactory();
  26311. };
  26312. GeoJSONParser.prototype.read = function read2(json) {
  26313. var obj;
  26314. if (typeof json === "string") {
  26315. obj = JSON.parse(json);
  26316. } else {
  26317. obj = json;
  26318. }
  26319. var type = obj.type;
  26320. if (!parse2[type]) {
  26321. throw new Error("Unknown GeoJSON type: " + obj.type);
  26322. }
  26323. if (geometryTypes.indexOf(type) !== -1) {
  26324. return parse2[type].apply(this, [obj.coordinates]);
  26325. } else if (type === "GeometryCollection") {
  26326. return parse2[type].apply(this, [obj.geometries]);
  26327. }
  26328. return parse2[type].apply(this, [obj]);
  26329. };
  26330. GeoJSONParser.prototype.write = function write3(geometry2) {
  26331. var type = geometry2.getGeometryType();
  26332. if (!extract2[type]) {
  26333. throw new Error("Geometry is not supported");
  26334. }
  26335. return extract2[type].apply(this, [geometry2]);
  26336. };
  26337. var parse2 = {
  26338. Feature: function(obj) {
  26339. var feature2 = {};
  26340. for (var key in obj) {
  26341. feature2[key] = obj[key];
  26342. }
  26343. if (obj.geometry) {
  26344. var type = obj.geometry.type;
  26345. if (!parse2[type]) {
  26346. throw new Error("Unknown GeoJSON type: " + obj.type);
  26347. }
  26348. feature2.geometry = this.read(obj.geometry);
  26349. }
  26350. if (obj.bbox) {
  26351. feature2.bbox = parse2.bbox.apply(this, [obj.bbox]);
  26352. }
  26353. return feature2;
  26354. },
  26355. FeatureCollection: function(obj) {
  26356. var this$1 = this;
  26357. var featureCollection2 = {};
  26358. if (obj.features) {
  26359. featureCollection2.features = [];
  26360. for (var i = 0; i < obj.features.length; ++i) {
  26361. featureCollection2.features.push(this$1.read(obj.features[i]));
  26362. }
  26363. }
  26364. if (obj.bbox) {
  26365. featureCollection2.bbox = this.parse.bbox.apply(this, [obj.bbox]);
  26366. }
  26367. return featureCollection2;
  26368. },
  26369. coordinates: function(array2) {
  26370. var coordinates = [];
  26371. for (var i = 0; i < array2.length; ++i) {
  26372. var sub2 = array2[i];
  26373. coordinates.push(new Coordinate(sub2[0], sub2[1]));
  26374. }
  26375. return coordinates;
  26376. },
  26377. bbox: function(array2) {
  26378. return this.geometryFactory.createLinearRing([
  26379. new Coordinate(array2[0], array2[1]),
  26380. new Coordinate(array2[2], array2[1]),
  26381. new Coordinate(array2[2], array2[3]),
  26382. new Coordinate(array2[0], array2[3]),
  26383. new Coordinate(array2[0], array2[1])
  26384. ]);
  26385. },
  26386. Point: function(array2) {
  26387. var coordinate2 = new Coordinate(array2[0], array2[1]);
  26388. return this.geometryFactory.createPoint(coordinate2);
  26389. },
  26390. MultiPoint: function(array2) {
  26391. var this$1 = this;
  26392. var points2 = [];
  26393. for (var i = 0; i < array2.length; ++i) {
  26394. points2.push(parse2.Point.apply(this$1, [array2[i]]));
  26395. }
  26396. return this.geometryFactory.createMultiPoint(points2);
  26397. },
  26398. LineString: function(array2) {
  26399. var coordinates = parse2.coordinates.apply(this, [array2]);
  26400. return this.geometryFactory.createLineString(coordinates);
  26401. },
  26402. MultiLineString: function(array2) {
  26403. var this$1 = this;
  26404. var lineStrings2 = [];
  26405. for (var i = 0; i < array2.length; ++i) {
  26406. lineStrings2.push(parse2.LineString.apply(this$1, [array2[i]]));
  26407. }
  26408. return this.geometryFactory.createMultiLineString(lineStrings2);
  26409. },
  26410. Polygon: function(array2) {
  26411. var this$1 = this;
  26412. var shellCoordinates = parse2.coordinates.apply(this, [array2[0]]);
  26413. var shell = this.geometryFactory.createLinearRing(shellCoordinates);
  26414. var holes = [];
  26415. for (var i = 1; i < array2.length; ++i) {
  26416. var hole = array2[i];
  26417. var coordinates = parse2.coordinates.apply(this$1, [hole]);
  26418. var linearRing = this$1.geometryFactory.createLinearRing(coordinates);
  26419. holes.push(linearRing);
  26420. }
  26421. return this.geometryFactory.createPolygon(shell, holes);
  26422. },
  26423. MultiPolygon: function(array2) {
  26424. var this$1 = this;
  26425. var polygons2 = [];
  26426. for (var i = 0; i < array2.length; ++i) {
  26427. var polygon4 = array2[i];
  26428. polygons2.push(parse2.Polygon.apply(this$1, [polygon4]));
  26429. }
  26430. return this.geometryFactory.createMultiPolygon(polygons2);
  26431. },
  26432. GeometryCollection: function(array2) {
  26433. var this$1 = this;
  26434. var geometries = [];
  26435. for (var i = 0; i < array2.length; ++i) {
  26436. var geometry2 = array2[i];
  26437. geometries.push(this$1.read(geometry2));
  26438. }
  26439. return this.geometryFactory.createGeometryCollection(geometries);
  26440. }
  26441. };
  26442. var extract2 = {
  26443. coordinate: function(coordinate2) {
  26444. return [coordinate2.x, coordinate2.y];
  26445. },
  26446. Point: function(point4) {
  26447. var array2 = extract2.coordinate.apply(this, [point4.getCoordinate()]);
  26448. return {
  26449. type: "Point",
  26450. coordinates: array2
  26451. };
  26452. },
  26453. MultiPoint: function(multipoint3) {
  26454. var this$1 = this;
  26455. var array2 = [];
  26456. for (var i = 0; i < multipoint3._geometries.length; ++i) {
  26457. var point4 = multipoint3._geometries[i];
  26458. var geoJson = extract2.Point.apply(this$1, [point4]);
  26459. array2.push(geoJson.coordinates);
  26460. }
  26461. return {
  26462. type: "MultiPoint",
  26463. coordinates: array2
  26464. };
  26465. },
  26466. LineString: function(linestring3) {
  26467. var this$1 = this;
  26468. var array2 = [];
  26469. var coordinates = linestring3.getCoordinates();
  26470. for (var i = 0; i < coordinates.length; ++i) {
  26471. var coordinate2 = coordinates[i];
  26472. array2.push(extract2.coordinate.apply(this$1, [coordinate2]));
  26473. }
  26474. return {
  26475. type: "LineString",
  26476. coordinates: array2
  26477. };
  26478. },
  26479. MultiLineString: function(multilinestring3) {
  26480. var this$1 = this;
  26481. var array2 = [];
  26482. for (var i = 0; i < multilinestring3._geometries.length; ++i) {
  26483. var linestring3 = multilinestring3._geometries[i];
  26484. var geoJson = extract2.LineString.apply(this$1, [linestring3]);
  26485. array2.push(geoJson.coordinates);
  26486. }
  26487. return {
  26488. type: "MultiLineString",
  26489. coordinates: array2
  26490. };
  26491. },
  26492. Polygon: function(polygon4) {
  26493. var this$1 = this;
  26494. var array2 = [];
  26495. var shellGeoJson = extract2.LineString.apply(this, [polygon4._shell]);
  26496. array2.push(shellGeoJson.coordinates);
  26497. for (var i = 0; i < polygon4._holes.length; ++i) {
  26498. var hole = polygon4._holes[i];
  26499. var holeGeoJson = extract2.LineString.apply(this$1, [hole]);
  26500. array2.push(holeGeoJson.coordinates);
  26501. }
  26502. return {
  26503. type: "Polygon",
  26504. coordinates: array2
  26505. };
  26506. },
  26507. MultiPolygon: function(multipolygon3) {
  26508. var this$1 = this;
  26509. var array2 = [];
  26510. for (var i = 0; i < multipolygon3._geometries.length; ++i) {
  26511. var polygon4 = multipolygon3._geometries[i];
  26512. var geoJson = extract2.Polygon.apply(this$1, [polygon4]);
  26513. array2.push(geoJson.coordinates);
  26514. }
  26515. return {
  26516. type: "MultiPolygon",
  26517. coordinates: array2
  26518. };
  26519. },
  26520. GeometryCollection: function(collection) {
  26521. var this$1 = this;
  26522. var array2 = [];
  26523. for (var i = 0; i < collection._geometries.length; ++i) {
  26524. var geometry2 = collection._geometries[i];
  26525. var type = geometry2.getGeometryType();
  26526. array2.push(extract2[type].apply(this$1, [geometry2]));
  26527. }
  26528. return {
  26529. type: "GeometryCollection",
  26530. geometries: array2
  26531. };
  26532. }
  26533. };
  26534. var GeoJSONReader = function GeoJSONReader2(geometryFactory) {
  26535. this.geometryFactory = geometryFactory || new GeometryFactory();
  26536. this.precisionModel = this.geometryFactory.getPrecisionModel();
  26537. this.parser = new GeoJSONParser(this.geometryFactory);
  26538. };
  26539. GeoJSONReader.prototype.read = function read3(geoJson) {
  26540. var geometry2 = this.parser.read(geoJson);
  26541. if (this.precisionModel.getType() === PrecisionModel.FIXED) {
  26542. this.reducePrecision(geometry2);
  26543. }
  26544. return geometry2;
  26545. };
  26546. GeoJSONReader.prototype.reducePrecision = function reducePrecision(geometry2) {
  26547. var this$1 = this;
  26548. var i, len;
  26549. if (geometry2.coordinate) {
  26550. this.precisionModel.makePrecise(geometry2.coordinate);
  26551. } else if (geometry2.points) {
  26552. for (i = 0, len = geometry2.points.length; i < len; i++) {
  26553. this$1.precisionModel.makePrecise(geometry2.points[i]);
  26554. }
  26555. } else if (geometry2.geometries) {
  26556. for (i = 0, len = geometry2.geometries.length; i < len; i++) {
  26557. this$1.reducePrecision(geometry2.geometries[i]);
  26558. }
  26559. }
  26560. };
  26561. var GeoJSONWriter = function GeoJSONWriter2() {
  26562. this.parser = new GeoJSONParser(this.geometryFactory);
  26563. };
  26564. GeoJSONWriter.prototype.write = function write4(geometry2) {
  26565. return this.parser.write(geometry2);
  26566. };
  26567. var Position = function Position2() {
  26568. };
  26569. var staticAccessors$20 = { ON: { configurable: true }, LEFT: { configurable: true }, RIGHT: { configurable: true } };
  26570. Position.prototype.interfaces_ = function interfaces_48() {
  26571. return [];
  26572. };
  26573. Position.prototype.getClass = function getClass47() {
  26574. return Position;
  26575. };
  26576. Position.opposite = function opposite(position) {
  26577. if (position === Position.LEFT) {
  26578. return Position.RIGHT;
  26579. }
  26580. if (position === Position.RIGHT) {
  26581. return Position.LEFT;
  26582. }
  26583. return position;
  26584. };
  26585. staticAccessors$20.ON.get = function() {
  26586. return 0;
  26587. };
  26588. staticAccessors$20.LEFT.get = function() {
  26589. return 1;
  26590. };
  26591. staticAccessors$20.RIGHT.get = function() {
  26592. return 2;
  26593. };
  26594. Object.defineProperties(Position, staticAccessors$20);
  26595. function EmptyStackException(message) {
  26596. this.message = message || "";
  26597. }
  26598. EmptyStackException.prototype = new Error();
  26599. EmptyStackException.prototype.name = "EmptyStackException";
  26600. function Stack() {
  26601. this.array_ = [];
  26602. }
  26603. Stack.prototype = new List();
  26604. Stack.prototype.add = function(e) {
  26605. this.array_.push(e);
  26606. return true;
  26607. };
  26608. Stack.prototype.get = function(index2) {
  26609. if (index2 < 0 || index2 >= this.size()) {
  26610. throw new Error();
  26611. }
  26612. return this.array_[index2];
  26613. };
  26614. Stack.prototype.push = function(e) {
  26615. this.array_.push(e);
  26616. return e;
  26617. };
  26618. Stack.prototype.pop = function(e) {
  26619. if (this.array_.length === 0) {
  26620. throw new EmptyStackException();
  26621. }
  26622. return this.array_.pop();
  26623. };
  26624. Stack.prototype.peek = function() {
  26625. if (this.array_.length === 0) {
  26626. throw new EmptyStackException();
  26627. }
  26628. return this.array_[this.array_.length - 1];
  26629. };
  26630. Stack.prototype.empty = function() {
  26631. if (this.array_.length === 0) {
  26632. return true;
  26633. } else {
  26634. return false;
  26635. }
  26636. };
  26637. Stack.prototype.isEmpty = function() {
  26638. return this.empty();
  26639. };
  26640. Stack.prototype.search = function(o) {
  26641. return this.array_.indexOf(o);
  26642. };
  26643. Stack.prototype.size = function() {
  26644. return this.array_.length;
  26645. };
  26646. Stack.prototype.toArray = function() {
  26647. var this$1 = this;
  26648. var array2 = [];
  26649. for (var i = 0, len = this.array_.length; i < len; i++) {
  26650. array2.push(this$1.array_[i]);
  26651. }
  26652. return array2;
  26653. };
  26654. var RightmostEdgeFinder = function RightmostEdgeFinder2() {
  26655. this._minIndex = -1;
  26656. this._minCoord = null;
  26657. this._minDe = null;
  26658. this._orientedDe = null;
  26659. };
  26660. RightmostEdgeFinder.prototype.getCoordinate = function getCoordinate4() {
  26661. return this._minCoord;
  26662. };
  26663. RightmostEdgeFinder.prototype.getRightmostSide = function getRightmostSide(de, index2) {
  26664. var side = this.getRightmostSideOfSegment(de, index2);
  26665. if (side < 0) {
  26666. side = this.getRightmostSideOfSegment(de, index2 - 1);
  26667. }
  26668. if (side < 0) {
  26669. this._minCoord = null;
  26670. this.checkForRightmostCoordinate(de);
  26671. }
  26672. return side;
  26673. };
  26674. RightmostEdgeFinder.prototype.findRightmostEdgeAtVertex = function findRightmostEdgeAtVertex() {
  26675. var pts = this._minDe.getEdge().getCoordinates();
  26676. Assert.isTrue(this._minIndex > 0 && this._minIndex < pts.length, "rightmost point expected to be interior vertex of edge");
  26677. var pPrev = pts[this._minIndex - 1];
  26678. var pNext = pts[this._minIndex + 1];
  26679. var orientation2 = CGAlgorithms.computeOrientation(this._minCoord, pNext, pPrev);
  26680. var usePrev = false;
  26681. if (pPrev.y < this._minCoord.y && pNext.y < this._minCoord.y && orientation2 === CGAlgorithms.COUNTERCLOCKWISE) {
  26682. usePrev = true;
  26683. } else if (pPrev.y > this._minCoord.y && pNext.y > this._minCoord.y && orientation2 === CGAlgorithms.CLOCKWISE) {
  26684. usePrev = true;
  26685. }
  26686. if (usePrev) {
  26687. this._minIndex = this._minIndex - 1;
  26688. }
  26689. };
  26690. RightmostEdgeFinder.prototype.getRightmostSideOfSegment = function getRightmostSideOfSegment(de, i) {
  26691. var e = de.getEdge();
  26692. var coord = e.getCoordinates();
  26693. if (i < 0 || i + 1 >= coord.length) {
  26694. return -1;
  26695. }
  26696. if (coord[i].y === coord[i + 1].y) {
  26697. return -1;
  26698. }
  26699. var pos = Position.LEFT;
  26700. if (coord[i].y < coord[i + 1].y) {
  26701. pos = Position.RIGHT;
  26702. }
  26703. return pos;
  26704. };
  26705. RightmostEdgeFinder.prototype.getEdge = function getEdge() {
  26706. return this._orientedDe;
  26707. };
  26708. RightmostEdgeFinder.prototype.checkForRightmostCoordinate = function checkForRightmostCoordinate(de) {
  26709. var this$1 = this;
  26710. var coord = de.getEdge().getCoordinates();
  26711. for (var i = 0; i < coord.length - 1; i++) {
  26712. if (this$1._minCoord === null || coord[i].x > this$1._minCoord.x) {
  26713. this$1._minDe = de;
  26714. this$1._minIndex = i;
  26715. this$1._minCoord = coord[i];
  26716. }
  26717. }
  26718. };
  26719. RightmostEdgeFinder.prototype.findRightmostEdgeAtNode = function findRightmostEdgeAtNode() {
  26720. var node = this._minDe.getNode();
  26721. var star = node.getEdges();
  26722. this._minDe = star.getRightmostEdge();
  26723. if (!this._minDe.isForward()) {
  26724. this._minDe = this._minDe.getSym();
  26725. this._minIndex = this._minDe.getEdge().getCoordinates().length - 1;
  26726. }
  26727. };
  26728. RightmostEdgeFinder.prototype.findEdge = function findEdge(dirEdgeList) {
  26729. var this$1 = this;
  26730. for (var i = dirEdgeList.iterator(); i.hasNext(); ) {
  26731. var de = i.next();
  26732. if (!de.isForward()) {
  26733. continue;
  26734. }
  26735. this$1.checkForRightmostCoordinate(de);
  26736. }
  26737. Assert.isTrue(this._minIndex !== 0 || this._minCoord.equals(this._minDe.getCoordinate()), "inconsistency in rightmost processing");
  26738. if (this._minIndex === 0) {
  26739. this.findRightmostEdgeAtNode();
  26740. } else {
  26741. this.findRightmostEdgeAtVertex();
  26742. }
  26743. this._orientedDe = this._minDe;
  26744. var rightmostSide = this.getRightmostSide(this._minDe, this._minIndex);
  26745. if (rightmostSide === Position.LEFT) {
  26746. this._orientedDe = this._minDe.getSym();
  26747. }
  26748. };
  26749. RightmostEdgeFinder.prototype.interfaces_ = function interfaces_49() {
  26750. return [];
  26751. };
  26752. RightmostEdgeFinder.prototype.getClass = function getClass48() {
  26753. return RightmostEdgeFinder;
  26754. };
  26755. var TopologyException = function(RuntimeException$$1) {
  26756. function TopologyException2(msg, pt) {
  26757. RuntimeException$$1.call(this, TopologyException2.msgWithCoord(msg, pt));
  26758. this.pt = pt ? new Coordinate(pt) : null;
  26759. this.name = "TopologyException";
  26760. }
  26761. if (RuntimeException$$1)
  26762. TopologyException2.__proto__ = RuntimeException$$1;
  26763. TopologyException2.prototype = Object.create(RuntimeException$$1 && RuntimeException$$1.prototype);
  26764. TopologyException2.prototype.constructor = TopologyException2;
  26765. TopologyException2.prototype.getCoordinate = function getCoordinate18() {
  26766. return this.pt;
  26767. };
  26768. TopologyException2.prototype.interfaces_ = function interfaces_170() {
  26769. return [];
  26770. };
  26771. TopologyException2.prototype.getClass = function getClass169() {
  26772. return TopologyException2;
  26773. };
  26774. TopologyException2.msgWithCoord = function msgWithCoord(msg, pt) {
  26775. if (!pt) {
  26776. return msg + " [ " + pt + " ]";
  26777. }
  26778. return msg;
  26779. };
  26780. return TopologyException2;
  26781. }(RuntimeException);
  26782. var LinkedList = function LinkedList2() {
  26783. this.array_ = [];
  26784. };
  26785. LinkedList.prototype.addLast = function addLast(e) {
  26786. this.array_.push(e);
  26787. };
  26788. LinkedList.prototype.removeFirst = function removeFirst() {
  26789. return this.array_.shift();
  26790. };
  26791. LinkedList.prototype.isEmpty = function isEmpty2() {
  26792. return this.array_.length === 0;
  26793. };
  26794. var BufferSubgraph = function BufferSubgraph2() {
  26795. this._finder = null;
  26796. this._dirEdgeList = new ArrayList();
  26797. this._nodes = new ArrayList();
  26798. this._rightMostCoord = null;
  26799. this._env = null;
  26800. this._finder = new RightmostEdgeFinder();
  26801. };
  26802. BufferSubgraph.prototype.clearVisitedEdges = function clearVisitedEdges() {
  26803. for (var it = this._dirEdgeList.iterator(); it.hasNext(); ) {
  26804. var de = it.next();
  26805. de.setVisited(false);
  26806. }
  26807. };
  26808. BufferSubgraph.prototype.getRightmostCoordinate = function getRightmostCoordinate() {
  26809. return this._rightMostCoord;
  26810. };
  26811. BufferSubgraph.prototype.computeNodeDepth = function computeNodeDepth(n) {
  26812. var this$1 = this;
  26813. var startEdge = null;
  26814. for (var i = n.getEdges().iterator(); i.hasNext(); ) {
  26815. var de = i.next();
  26816. if (de.isVisited() || de.getSym().isVisited()) {
  26817. startEdge = de;
  26818. break;
  26819. }
  26820. }
  26821. if (startEdge === null) {
  26822. throw new TopologyException("unable to find edge to compute depths at " + n.getCoordinate());
  26823. }
  26824. n.getEdges().computeDepths(startEdge);
  26825. for (var i$1 = n.getEdges().iterator(); i$1.hasNext(); ) {
  26826. var de$1 = i$1.next();
  26827. de$1.setVisited(true);
  26828. this$1.copySymDepths(de$1);
  26829. }
  26830. };
  26831. BufferSubgraph.prototype.computeDepth = function computeDepth(outsideDepth) {
  26832. this.clearVisitedEdges();
  26833. var de = this._finder.getEdge();
  26834. de.setEdgeDepths(Position.RIGHT, outsideDepth);
  26835. this.copySymDepths(de);
  26836. this.computeDepths(de);
  26837. };
  26838. BufferSubgraph.prototype.create = function create3(node) {
  26839. this.addReachable(node);
  26840. this._finder.findEdge(this._dirEdgeList);
  26841. this._rightMostCoord = this._finder.getCoordinate();
  26842. };
  26843. BufferSubgraph.prototype.findResultEdges = function findResultEdges() {
  26844. for (var it = this._dirEdgeList.iterator(); it.hasNext(); ) {
  26845. var de = it.next();
  26846. if (de.getDepth(Position.RIGHT) >= 1 && de.getDepth(Position.LEFT) <= 0 && !de.isInteriorAreaEdge()) {
  26847. de.setInResult(true);
  26848. }
  26849. }
  26850. };
  26851. BufferSubgraph.prototype.computeDepths = function computeDepths(startEdge) {
  26852. var this$1 = this;
  26853. var nodesVisited = new HashSet();
  26854. var nodeQueue = new LinkedList();
  26855. var startNode = startEdge.getNode();
  26856. nodeQueue.addLast(startNode);
  26857. nodesVisited.add(startNode);
  26858. startEdge.setVisited(true);
  26859. while (!nodeQueue.isEmpty()) {
  26860. var n = nodeQueue.removeFirst();
  26861. nodesVisited.add(n);
  26862. this$1.computeNodeDepth(n);
  26863. for (var i = n.getEdges().iterator(); i.hasNext(); ) {
  26864. var de = i.next();
  26865. var sym = de.getSym();
  26866. if (sym.isVisited()) {
  26867. continue;
  26868. }
  26869. var adjNode = sym.getNode();
  26870. if (!nodesVisited.contains(adjNode)) {
  26871. nodeQueue.addLast(adjNode);
  26872. nodesVisited.add(adjNode);
  26873. }
  26874. }
  26875. }
  26876. };
  26877. BufferSubgraph.prototype.compareTo = function compareTo7(o) {
  26878. var graph = o;
  26879. if (this._rightMostCoord.x < graph._rightMostCoord.x) {
  26880. return -1;
  26881. }
  26882. if (this._rightMostCoord.x > graph._rightMostCoord.x) {
  26883. return 1;
  26884. }
  26885. return 0;
  26886. };
  26887. BufferSubgraph.prototype.getEnvelope = function getEnvelope2() {
  26888. if (this._env === null) {
  26889. var edgeEnv = new Envelope();
  26890. for (var it = this._dirEdgeList.iterator(); it.hasNext(); ) {
  26891. var dirEdge = it.next();
  26892. var pts = dirEdge.getEdge().getCoordinates();
  26893. for (var i = 0; i < pts.length - 1; i++) {
  26894. edgeEnv.expandToInclude(pts[i]);
  26895. }
  26896. }
  26897. this._env = edgeEnv;
  26898. }
  26899. return this._env;
  26900. };
  26901. BufferSubgraph.prototype.addReachable = function addReachable(startNode) {
  26902. var this$1 = this;
  26903. var nodeStack = new Stack();
  26904. nodeStack.add(startNode);
  26905. while (!nodeStack.empty()) {
  26906. var node = nodeStack.pop();
  26907. this$1.add(node, nodeStack);
  26908. }
  26909. };
  26910. BufferSubgraph.prototype.copySymDepths = function copySymDepths(de) {
  26911. var sym = de.getSym();
  26912. sym.setDepth(Position.LEFT, de.getDepth(Position.RIGHT));
  26913. sym.setDepth(Position.RIGHT, de.getDepth(Position.LEFT));
  26914. };
  26915. BufferSubgraph.prototype.add = function add4(node, nodeStack) {
  26916. var this$1 = this;
  26917. node.setVisited(true);
  26918. this._nodes.add(node);
  26919. for (var i = node.getEdges().iterator(); i.hasNext(); ) {
  26920. var de = i.next();
  26921. this$1._dirEdgeList.add(de);
  26922. var sym = de.getSym();
  26923. var symNode = sym.getNode();
  26924. if (!symNode.isVisited()) {
  26925. nodeStack.push(symNode);
  26926. }
  26927. }
  26928. };
  26929. BufferSubgraph.prototype.getNodes = function getNodes() {
  26930. return this._nodes;
  26931. };
  26932. BufferSubgraph.prototype.getDirectedEdges = function getDirectedEdges() {
  26933. return this._dirEdgeList;
  26934. };
  26935. BufferSubgraph.prototype.interfaces_ = function interfaces_50() {
  26936. return [Comparable];
  26937. };
  26938. BufferSubgraph.prototype.getClass = function getClass49() {
  26939. return BufferSubgraph;
  26940. };
  26941. var TopologyLocation = function TopologyLocation2() {
  26942. var this$1 = this;
  26943. this.location = null;
  26944. if (arguments.length === 1) {
  26945. if (arguments[0] instanceof Array) {
  26946. var location = arguments[0];
  26947. this.init(location.length);
  26948. } else if (Number.isInteger(arguments[0])) {
  26949. var on = arguments[0];
  26950. this.init(1);
  26951. this.location[Position.ON] = on;
  26952. } else if (arguments[0] instanceof TopologyLocation2) {
  26953. var gl = arguments[0];
  26954. this.init(gl.location.length);
  26955. if (gl !== null) {
  26956. for (var i = 0; i < this.location.length; i++) {
  26957. this$1.location[i] = gl.location[i];
  26958. }
  26959. }
  26960. }
  26961. } else if (arguments.length === 3) {
  26962. var on$1 = arguments[0];
  26963. var left = arguments[1];
  26964. var right = arguments[2];
  26965. this.init(3);
  26966. this.location[Position.ON] = on$1;
  26967. this.location[Position.LEFT] = left;
  26968. this.location[Position.RIGHT] = right;
  26969. }
  26970. };
  26971. TopologyLocation.prototype.setAllLocations = function setAllLocations(locValue) {
  26972. var this$1 = this;
  26973. for (var i = 0; i < this.location.length; i++) {
  26974. this$1.location[i] = locValue;
  26975. }
  26976. };
  26977. TopologyLocation.prototype.isNull = function isNull2() {
  26978. var this$1 = this;
  26979. for (var i = 0; i < this.location.length; i++) {
  26980. if (this$1.location[i] !== Location.NONE) {
  26981. return false;
  26982. }
  26983. }
  26984. return true;
  26985. };
  26986. TopologyLocation.prototype.setAllLocationsIfNull = function setAllLocationsIfNull(locValue) {
  26987. var this$1 = this;
  26988. for (var i = 0; i < this.location.length; i++) {
  26989. if (this$1.location[i] === Location.NONE) {
  26990. this$1.location[i] = locValue;
  26991. }
  26992. }
  26993. };
  26994. TopologyLocation.prototype.isLine = function isLine() {
  26995. return this.location.length === 1;
  26996. };
  26997. TopologyLocation.prototype.merge = function merge2(gl) {
  26998. var this$1 = this;
  26999. if (gl.location.length > this.location.length) {
  27000. var newLoc = new Array(3).fill(null);
  27001. newLoc[Position.ON] = this.location[Position.ON];
  27002. newLoc[Position.LEFT] = Location.NONE;
  27003. newLoc[Position.RIGHT] = Location.NONE;
  27004. this.location = newLoc;
  27005. }
  27006. for (var i = 0; i < this.location.length; i++) {
  27007. if (this$1.location[i] === Location.NONE && i < gl.location.length) {
  27008. this$1.location[i] = gl.location[i];
  27009. }
  27010. }
  27011. };
  27012. TopologyLocation.prototype.getLocations = function getLocations() {
  27013. return this.location;
  27014. };
  27015. TopologyLocation.prototype.flip = function flip2() {
  27016. if (this.location.length <= 1) {
  27017. return null;
  27018. }
  27019. var temp2 = this.location[Position.LEFT];
  27020. this.location[Position.LEFT] = this.location[Position.RIGHT];
  27021. this.location[Position.RIGHT] = temp2;
  27022. };
  27023. TopologyLocation.prototype.toString = function toString11() {
  27024. var buf = new StringBuffer();
  27025. if (this.location.length > 1) {
  27026. buf.append(Location.toLocationSymbol(this.location[Position.LEFT]));
  27027. }
  27028. buf.append(Location.toLocationSymbol(this.location[Position.ON]));
  27029. if (this.location.length > 1) {
  27030. buf.append(Location.toLocationSymbol(this.location[Position.RIGHT]));
  27031. }
  27032. return buf.toString();
  27033. };
  27034. TopologyLocation.prototype.setLocations = function setLocations(on, left, right) {
  27035. this.location[Position.ON] = on;
  27036. this.location[Position.LEFT] = left;
  27037. this.location[Position.RIGHT] = right;
  27038. };
  27039. TopologyLocation.prototype.get = function get2(posIndex) {
  27040. if (posIndex < this.location.length) {
  27041. return this.location[posIndex];
  27042. }
  27043. return Location.NONE;
  27044. };
  27045. TopologyLocation.prototype.isArea = function isArea() {
  27046. return this.location.length > 1;
  27047. };
  27048. TopologyLocation.prototype.isAnyNull = function isAnyNull() {
  27049. var this$1 = this;
  27050. for (var i = 0; i < this.location.length; i++) {
  27051. if (this$1.location[i] === Location.NONE) {
  27052. return true;
  27053. }
  27054. }
  27055. return false;
  27056. };
  27057. TopologyLocation.prototype.setLocation = function setLocation() {
  27058. if (arguments.length === 1) {
  27059. var locValue = arguments[0];
  27060. this.setLocation(Position.ON, locValue);
  27061. } else if (arguments.length === 2) {
  27062. var locIndex = arguments[0];
  27063. var locValue$1 = arguments[1];
  27064. this.location[locIndex] = locValue$1;
  27065. }
  27066. };
  27067. TopologyLocation.prototype.init = function init3(size11) {
  27068. this.location = new Array(size11).fill(null);
  27069. this.setAllLocations(Location.NONE);
  27070. };
  27071. TopologyLocation.prototype.isEqualOnSide = function isEqualOnSide(le2, locIndex) {
  27072. return this.location[locIndex] === le2.location[locIndex];
  27073. };
  27074. TopologyLocation.prototype.allPositionsEqual = function allPositionsEqual(loc) {
  27075. var this$1 = this;
  27076. for (var i = 0; i < this.location.length; i++) {
  27077. if (this$1.location[i] !== loc) {
  27078. return false;
  27079. }
  27080. }
  27081. return true;
  27082. };
  27083. TopologyLocation.prototype.interfaces_ = function interfaces_51() {
  27084. return [];
  27085. };
  27086. TopologyLocation.prototype.getClass = function getClass50() {
  27087. return TopologyLocation;
  27088. };
  27089. var Label = function Label2() {
  27090. this.elt = new Array(2).fill(null);
  27091. if (arguments.length === 1) {
  27092. if (Number.isInteger(arguments[0])) {
  27093. var onLoc = arguments[0];
  27094. this.elt[0] = new TopologyLocation(onLoc);
  27095. this.elt[1] = new TopologyLocation(onLoc);
  27096. } else if (arguments[0] instanceof Label2) {
  27097. var lbl = arguments[0];
  27098. this.elt[0] = new TopologyLocation(lbl.elt[0]);
  27099. this.elt[1] = new TopologyLocation(lbl.elt[1]);
  27100. }
  27101. } else if (arguments.length === 2) {
  27102. var geomIndex = arguments[0];
  27103. var onLoc$1 = arguments[1];
  27104. this.elt[0] = new TopologyLocation(Location.NONE);
  27105. this.elt[1] = new TopologyLocation(Location.NONE);
  27106. this.elt[geomIndex].setLocation(onLoc$1);
  27107. } else if (arguments.length === 3) {
  27108. var onLoc$2 = arguments[0];
  27109. var leftLoc = arguments[1];
  27110. var rightLoc = arguments[2];
  27111. this.elt[0] = new TopologyLocation(onLoc$2, leftLoc, rightLoc);
  27112. this.elt[1] = new TopologyLocation(onLoc$2, leftLoc, rightLoc);
  27113. } else if (arguments.length === 4) {
  27114. var geomIndex$1 = arguments[0];
  27115. var onLoc$3 = arguments[1];
  27116. var leftLoc$1 = arguments[2];
  27117. var rightLoc$1 = arguments[3];
  27118. this.elt[0] = new TopologyLocation(Location.NONE, Location.NONE, Location.NONE);
  27119. this.elt[1] = new TopologyLocation(Location.NONE, Location.NONE, Location.NONE);
  27120. this.elt[geomIndex$1].setLocations(onLoc$3, leftLoc$1, rightLoc$1);
  27121. }
  27122. };
  27123. Label.prototype.getGeometryCount = function getGeometryCount() {
  27124. var count2 = 0;
  27125. if (!this.elt[0].isNull()) {
  27126. count2++;
  27127. }
  27128. if (!this.elt[1].isNull()) {
  27129. count2++;
  27130. }
  27131. return count2;
  27132. };
  27133. Label.prototype.setAllLocations = function setAllLocations2(geomIndex, location) {
  27134. this.elt[geomIndex].setAllLocations(location);
  27135. };
  27136. Label.prototype.isNull = function isNull3(geomIndex) {
  27137. return this.elt[geomIndex].isNull();
  27138. };
  27139. Label.prototype.setAllLocationsIfNull = function setAllLocationsIfNull2() {
  27140. if (arguments.length === 1) {
  27141. var location = arguments[0];
  27142. this.setAllLocationsIfNull(0, location);
  27143. this.setAllLocationsIfNull(1, location);
  27144. } else if (arguments.length === 2) {
  27145. var geomIndex = arguments[0];
  27146. var location$1 = arguments[1];
  27147. this.elt[geomIndex].setAllLocationsIfNull(location$1);
  27148. }
  27149. };
  27150. Label.prototype.isLine = function isLine2(geomIndex) {
  27151. return this.elt[geomIndex].isLine();
  27152. };
  27153. Label.prototype.merge = function merge3(lbl) {
  27154. var this$1 = this;
  27155. for (var i = 0; i < 2; i++) {
  27156. if (this$1.elt[i] === null && lbl.elt[i] !== null) {
  27157. this$1.elt[i] = new TopologyLocation(lbl.elt[i]);
  27158. } else {
  27159. this$1.elt[i].merge(lbl.elt[i]);
  27160. }
  27161. }
  27162. };
  27163. Label.prototype.flip = function flip3() {
  27164. this.elt[0].flip();
  27165. this.elt[1].flip();
  27166. };
  27167. Label.prototype.getLocation = function getLocation2() {
  27168. if (arguments.length === 1) {
  27169. var geomIndex = arguments[0];
  27170. return this.elt[geomIndex].get(Position.ON);
  27171. } else if (arguments.length === 2) {
  27172. var geomIndex$1 = arguments[0];
  27173. var posIndex = arguments[1];
  27174. return this.elt[geomIndex$1].get(posIndex);
  27175. }
  27176. };
  27177. Label.prototype.toString = function toString12() {
  27178. var buf = new StringBuffer();
  27179. if (this.elt[0] !== null) {
  27180. buf.append("A:");
  27181. buf.append(this.elt[0].toString());
  27182. }
  27183. if (this.elt[1] !== null) {
  27184. buf.append(" B:");
  27185. buf.append(this.elt[1].toString());
  27186. }
  27187. return buf.toString();
  27188. };
  27189. Label.prototype.isArea = function isArea2() {
  27190. if (arguments.length === 0) {
  27191. return this.elt[0].isArea() || this.elt[1].isArea();
  27192. } else if (arguments.length === 1) {
  27193. var geomIndex = arguments[0];
  27194. return this.elt[geomIndex].isArea();
  27195. }
  27196. };
  27197. Label.prototype.isAnyNull = function isAnyNull2(geomIndex) {
  27198. return this.elt[geomIndex].isAnyNull();
  27199. };
  27200. Label.prototype.setLocation = function setLocation2() {
  27201. if (arguments.length === 2) {
  27202. var geomIndex = arguments[0];
  27203. var location = arguments[1];
  27204. this.elt[geomIndex].setLocation(Position.ON, location);
  27205. } else if (arguments.length === 3) {
  27206. var geomIndex$1 = arguments[0];
  27207. var posIndex = arguments[1];
  27208. var location$1 = arguments[2];
  27209. this.elt[geomIndex$1].setLocation(posIndex, location$1);
  27210. }
  27211. };
  27212. Label.prototype.isEqualOnSide = function isEqualOnSide2(lbl, side) {
  27213. return this.elt[0].isEqualOnSide(lbl.elt[0], side) && this.elt[1].isEqualOnSide(lbl.elt[1], side);
  27214. };
  27215. Label.prototype.allPositionsEqual = function allPositionsEqual2(geomIndex, loc) {
  27216. return this.elt[geomIndex].allPositionsEqual(loc);
  27217. };
  27218. Label.prototype.toLine = function toLine(geomIndex) {
  27219. if (this.elt[geomIndex].isArea()) {
  27220. this.elt[geomIndex] = new TopologyLocation(this.elt[geomIndex].location[0]);
  27221. }
  27222. };
  27223. Label.prototype.interfaces_ = function interfaces_52() {
  27224. return [];
  27225. };
  27226. Label.prototype.getClass = function getClass51() {
  27227. return Label;
  27228. };
  27229. Label.toLineLabel = function toLineLabel(label) {
  27230. var lineLabel = new Label(Location.NONE);
  27231. for (var i = 0; i < 2; i++) {
  27232. lineLabel.setLocation(i, label.getLocation(i));
  27233. }
  27234. return lineLabel;
  27235. };
  27236. var EdgeRing2 = function EdgeRing3() {
  27237. this._startDe = null;
  27238. this._maxNodeDegree = -1;
  27239. this._edges = new ArrayList();
  27240. this._pts = new ArrayList();
  27241. this._label = new Label(Location.NONE);
  27242. this._ring = null;
  27243. this._isHole = null;
  27244. this._shell = null;
  27245. this._holes = new ArrayList();
  27246. this._geometryFactory = null;
  27247. var start = arguments[0];
  27248. var geometryFactory = arguments[1];
  27249. this._geometryFactory = geometryFactory;
  27250. this.computePoints(start);
  27251. this.computeRing();
  27252. };
  27253. EdgeRing2.prototype.computeRing = function computeRing() {
  27254. var this$1 = this;
  27255. if (this._ring !== null) {
  27256. return null;
  27257. }
  27258. var coord = new Array(this._pts.size()).fill(null);
  27259. for (var i = 0; i < this._pts.size(); i++) {
  27260. coord[i] = this$1._pts.get(i);
  27261. }
  27262. this._ring = this._geometryFactory.createLinearRing(coord);
  27263. this._isHole = CGAlgorithms.isCCW(this._ring.getCoordinates());
  27264. };
  27265. EdgeRing2.prototype.isIsolated = function isIsolated() {
  27266. return this._label.getGeometryCount() === 1;
  27267. };
  27268. EdgeRing2.prototype.computePoints = function computePoints(start) {
  27269. var this$1 = this;
  27270. this._startDe = start;
  27271. var de = start;
  27272. var isFirstEdge = true;
  27273. do {
  27274. if (de === null) {
  27275. throw new TopologyException("Found null DirectedEdge");
  27276. }
  27277. if (de.getEdgeRing() === this$1) {
  27278. throw new TopologyException("Directed Edge visited twice during ring-building at " + de.getCoordinate());
  27279. }
  27280. this$1._edges.add(de);
  27281. var label = de.getLabel();
  27282. Assert.isTrue(label.isArea());
  27283. this$1.mergeLabel(label);
  27284. this$1.addPoints(de.getEdge(), de.isForward(), isFirstEdge);
  27285. isFirstEdge = false;
  27286. this$1.setEdgeRing(de, this$1);
  27287. de = this$1.getNext(de);
  27288. } while (de !== this._startDe);
  27289. };
  27290. EdgeRing2.prototype.getLinearRing = function getLinearRing() {
  27291. return this._ring;
  27292. };
  27293. EdgeRing2.prototype.getCoordinate = function getCoordinate5(i) {
  27294. return this._pts.get(i);
  27295. };
  27296. EdgeRing2.prototype.computeMaxNodeDegree = function computeMaxNodeDegree() {
  27297. var this$1 = this;
  27298. this._maxNodeDegree = 0;
  27299. var de = this._startDe;
  27300. do {
  27301. var node = de.getNode();
  27302. var degree = node.getEdges().getOutgoingDegree(this$1);
  27303. if (degree > this$1._maxNodeDegree) {
  27304. this$1._maxNodeDegree = degree;
  27305. }
  27306. de = this$1.getNext(de);
  27307. } while (de !== this._startDe);
  27308. this._maxNodeDegree *= 2;
  27309. };
  27310. EdgeRing2.prototype.addPoints = function addPoints(edge, isForward, isFirstEdge) {
  27311. var this$1 = this;
  27312. var edgePts = edge.getCoordinates();
  27313. if (isForward) {
  27314. var startIndex = 1;
  27315. if (isFirstEdge) {
  27316. startIndex = 0;
  27317. }
  27318. for (var i = startIndex; i < edgePts.length; i++) {
  27319. this$1._pts.add(edgePts[i]);
  27320. }
  27321. } else {
  27322. var startIndex$1 = edgePts.length - 2;
  27323. if (isFirstEdge) {
  27324. startIndex$1 = edgePts.length - 1;
  27325. }
  27326. for (var i$1 = startIndex$1; i$1 >= 0; i$1--) {
  27327. this$1._pts.add(edgePts[i$1]);
  27328. }
  27329. }
  27330. };
  27331. EdgeRing2.prototype.isHole = function isHole() {
  27332. return this._isHole;
  27333. };
  27334. EdgeRing2.prototype.setInResult = function setInResult() {
  27335. var de = this._startDe;
  27336. do {
  27337. de.getEdge().setInResult(true);
  27338. de = de.getNext();
  27339. } while (de !== this._startDe);
  27340. };
  27341. EdgeRing2.prototype.containsPoint = function containsPoint(p) {
  27342. var shell = this.getLinearRing();
  27343. var env = shell.getEnvelopeInternal();
  27344. if (!env.contains(p)) {
  27345. return false;
  27346. }
  27347. if (!CGAlgorithms.isPointInRing(p, shell.getCoordinates())) {
  27348. return false;
  27349. }
  27350. for (var i = this._holes.iterator(); i.hasNext(); ) {
  27351. var hole = i.next();
  27352. if (hole.containsPoint(p)) {
  27353. return false;
  27354. }
  27355. }
  27356. return true;
  27357. };
  27358. EdgeRing2.prototype.addHole = function addHole(ring) {
  27359. this._holes.add(ring);
  27360. };
  27361. EdgeRing2.prototype.isShell = function isShell() {
  27362. return this._shell === null;
  27363. };
  27364. EdgeRing2.prototype.getLabel = function getLabel() {
  27365. return this._label;
  27366. };
  27367. EdgeRing2.prototype.getEdges = function getEdges() {
  27368. return this._edges;
  27369. };
  27370. EdgeRing2.prototype.getMaxNodeDegree = function getMaxNodeDegree() {
  27371. if (this._maxNodeDegree < 0) {
  27372. this.computeMaxNodeDegree();
  27373. }
  27374. return this._maxNodeDegree;
  27375. };
  27376. EdgeRing2.prototype.getShell = function getShell() {
  27377. return this._shell;
  27378. };
  27379. EdgeRing2.prototype.mergeLabel = function mergeLabel() {
  27380. if (arguments.length === 1) {
  27381. var deLabel = arguments[0];
  27382. this.mergeLabel(deLabel, 0);
  27383. this.mergeLabel(deLabel, 1);
  27384. } else if (arguments.length === 2) {
  27385. var deLabel$1 = arguments[0];
  27386. var geomIndex = arguments[1];
  27387. var loc = deLabel$1.getLocation(geomIndex, Position.RIGHT);
  27388. if (loc === Location.NONE) {
  27389. return null;
  27390. }
  27391. if (this._label.getLocation(geomIndex) === Location.NONE) {
  27392. this._label.setLocation(geomIndex, loc);
  27393. return null;
  27394. }
  27395. }
  27396. };
  27397. EdgeRing2.prototype.setShell = function setShell(shell) {
  27398. this._shell = shell;
  27399. if (shell !== null) {
  27400. shell.addHole(this);
  27401. }
  27402. };
  27403. EdgeRing2.prototype.toPolygon = function toPolygon(geometryFactory) {
  27404. var this$1 = this;
  27405. var holeLR = new Array(this._holes.size()).fill(null);
  27406. for (var i = 0; i < this._holes.size(); i++) {
  27407. holeLR[i] = this$1._holes.get(i).getLinearRing();
  27408. }
  27409. var poly = geometryFactory.createPolygon(this.getLinearRing(), holeLR);
  27410. return poly;
  27411. };
  27412. EdgeRing2.prototype.interfaces_ = function interfaces_53() {
  27413. return [];
  27414. };
  27415. EdgeRing2.prototype.getClass = function getClass52() {
  27416. return EdgeRing2;
  27417. };
  27418. var MinimalEdgeRing = function(EdgeRing$$1) {
  27419. function MinimalEdgeRing2() {
  27420. var start = arguments[0];
  27421. var geometryFactory = arguments[1];
  27422. EdgeRing$$1.call(this, start, geometryFactory);
  27423. }
  27424. if (EdgeRing$$1)
  27425. MinimalEdgeRing2.__proto__ = EdgeRing$$1;
  27426. MinimalEdgeRing2.prototype = Object.create(EdgeRing$$1 && EdgeRing$$1.prototype);
  27427. MinimalEdgeRing2.prototype.constructor = MinimalEdgeRing2;
  27428. MinimalEdgeRing2.prototype.setEdgeRing = function setEdgeRing(de, er) {
  27429. de.setMinEdgeRing(er);
  27430. };
  27431. MinimalEdgeRing2.prototype.getNext = function getNext(de) {
  27432. return de.getNextMin();
  27433. };
  27434. MinimalEdgeRing2.prototype.interfaces_ = function interfaces_170() {
  27435. return [];
  27436. };
  27437. MinimalEdgeRing2.prototype.getClass = function getClass169() {
  27438. return MinimalEdgeRing2;
  27439. };
  27440. return MinimalEdgeRing2;
  27441. }(EdgeRing2);
  27442. var MaximalEdgeRing = function(EdgeRing$$1) {
  27443. function MaximalEdgeRing2() {
  27444. var start = arguments[0];
  27445. var geometryFactory = arguments[1];
  27446. EdgeRing$$1.call(this, start, geometryFactory);
  27447. }
  27448. if (EdgeRing$$1)
  27449. MaximalEdgeRing2.__proto__ = EdgeRing$$1;
  27450. MaximalEdgeRing2.prototype = Object.create(EdgeRing$$1 && EdgeRing$$1.prototype);
  27451. MaximalEdgeRing2.prototype.constructor = MaximalEdgeRing2;
  27452. MaximalEdgeRing2.prototype.buildMinimalRings = function buildMinimalRings() {
  27453. var this$1 = this;
  27454. var minEdgeRings = new ArrayList();
  27455. var de = this._startDe;
  27456. do {
  27457. if (de.getMinEdgeRing() === null) {
  27458. var minEr = new MinimalEdgeRing(de, this$1._geometryFactory);
  27459. minEdgeRings.add(minEr);
  27460. }
  27461. de = de.getNext();
  27462. } while (de !== this._startDe);
  27463. return minEdgeRings;
  27464. };
  27465. MaximalEdgeRing2.prototype.setEdgeRing = function setEdgeRing(de, er) {
  27466. de.setEdgeRing(er);
  27467. };
  27468. MaximalEdgeRing2.prototype.linkDirectedEdgesForMinimalEdgeRings = function linkDirectedEdgesForMinimalEdgeRings() {
  27469. var this$1 = this;
  27470. var de = this._startDe;
  27471. do {
  27472. var node = de.getNode();
  27473. node.getEdges().linkMinimalDirectedEdges(this$1);
  27474. de = de.getNext();
  27475. } while (de !== this._startDe);
  27476. };
  27477. MaximalEdgeRing2.prototype.getNext = function getNext(de) {
  27478. return de.getNext();
  27479. };
  27480. MaximalEdgeRing2.prototype.interfaces_ = function interfaces_170() {
  27481. return [];
  27482. };
  27483. MaximalEdgeRing2.prototype.getClass = function getClass169() {
  27484. return MaximalEdgeRing2;
  27485. };
  27486. return MaximalEdgeRing2;
  27487. }(EdgeRing2);
  27488. var GraphComponent = function GraphComponent2() {
  27489. this._label = null;
  27490. this._isInResult = false;
  27491. this._isCovered = false;
  27492. this._isCoveredSet = false;
  27493. this._isVisited = false;
  27494. if (arguments.length === 0) {
  27495. } else if (arguments.length === 1) {
  27496. var label = arguments[0];
  27497. this._label = label;
  27498. }
  27499. };
  27500. GraphComponent.prototype.setVisited = function setVisited(isVisited2) {
  27501. this._isVisited = isVisited2;
  27502. };
  27503. GraphComponent.prototype.setInResult = function setInResult2(isInResult2) {
  27504. this._isInResult = isInResult2;
  27505. };
  27506. GraphComponent.prototype.isCovered = function isCovered() {
  27507. return this._isCovered;
  27508. };
  27509. GraphComponent.prototype.isCoveredSet = function isCoveredSet() {
  27510. return this._isCoveredSet;
  27511. };
  27512. GraphComponent.prototype.setLabel = function setLabel(label) {
  27513. this._label = label;
  27514. };
  27515. GraphComponent.prototype.getLabel = function getLabel2() {
  27516. return this._label;
  27517. };
  27518. GraphComponent.prototype.setCovered = function setCovered(isCovered2) {
  27519. this._isCovered = isCovered2;
  27520. this._isCoveredSet = true;
  27521. };
  27522. GraphComponent.prototype.updateIM = function updateIM(im) {
  27523. Assert.isTrue(this._label.getGeometryCount() >= 2, "found partial label");
  27524. this.computeIM(im);
  27525. };
  27526. GraphComponent.prototype.isInResult = function isInResult() {
  27527. return this._isInResult;
  27528. };
  27529. GraphComponent.prototype.isVisited = function isVisited() {
  27530. return this._isVisited;
  27531. };
  27532. GraphComponent.prototype.interfaces_ = function interfaces_54() {
  27533. return [];
  27534. };
  27535. GraphComponent.prototype.getClass = function getClass53() {
  27536. return GraphComponent;
  27537. };
  27538. var Node5 = function(GraphComponent$$1) {
  27539. function Node6() {
  27540. GraphComponent$$1.call(this);
  27541. this._coord = null;
  27542. this._edges = null;
  27543. var coord = arguments[0];
  27544. var edges2 = arguments[1];
  27545. this._coord = coord;
  27546. this._edges = edges2;
  27547. this._label = new Label(0, Location.NONE);
  27548. }
  27549. if (GraphComponent$$1)
  27550. Node6.__proto__ = GraphComponent$$1;
  27551. Node6.prototype = Object.create(GraphComponent$$1 && GraphComponent$$1.prototype);
  27552. Node6.prototype.constructor = Node6;
  27553. Node6.prototype.isIncidentEdgeInResult = function isIncidentEdgeInResult() {
  27554. for (var it = this.getEdges().getEdges().iterator(); it.hasNext(); ) {
  27555. var de = it.next();
  27556. if (de.getEdge().isInResult()) {
  27557. return true;
  27558. }
  27559. }
  27560. return false;
  27561. };
  27562. Node6.prototype.isIsolated = function isIsolated2() {
  27563. return this._label.getGeometryCount() === 1;
  27564. };
  27565. Node6.prototype.getCoordinate = function getCoordinate18() {
  27566. return this._coord;
  27567. };
  27568. Node6.prototype.print = function print9(out) {
  27569. out.println("node " + this._coord + " lbl: " + this._label);
  27570. };
  27571. Node6.prototype.computeIM = function computeIM(im) {
  27572. };
  27573. Node6.prototype.computeMergedLocation = function computeMergedLocation(label2, eltIndex) {
  27574. var loc = Location.NONE;
  27575. loc = this._label.getLocation(eltIndex);
  27576. if (!label2.isNull(eltIndex)) {
  27577. var nLoc = label2.getLocation(eltIndex);
  27578. if (loc !== Location.BOUNDARY) {
  27579. loc = nLoc;
  27580. }
  27581. }
  27582. return loc;
  27583. };
  27584. Node6.prototype.setLabel = function setLabel2() {
  27585. if (arguments.length === 2) {
  27586. var argIndex = arguments[0];
  27587. var onLocation = arguments[1];
  27588. if (this._label === null) {
  27589. this._label = new Label(argIndex, onLocation);
  27590. } else {
  27591. this._label.setLocation(argIndex, onLocation);
  27592. }
  27593. } else {
  27594. return GraphComponent$$1.prototype.setLabel.apply(this, arguments);
  27595. }
  27596. };
  27597. Node6.prototype.getEdges = function getEdges4() {
  27598. return this._edges;
  27599. };
  27600. Node6.prototype.mergeLabel = function mergeLabel2() {
  27601. var this$1 = this;
  27602. if (arguments[0] instanceof Node6) {
  27603. var n = arguments[0];
  27604. this.mergeLabel(n._label);
  27605. } else if (arguments[0] instanceof Label) {
  27606. var label2 = arguments[0];
  27607. for (var i = 0; i < 2; i++) {
  27608. var loc = this$1.computeMergedLocation(label2, i);
  27609. var thisLoc = this$1._label.getLocation(i);
  27610. if (thisLoc === Location.NONE) {
  27611. this$1._label.setLocation(i, loc);
  27612. }
  27613. }
  27614. }
  27615. };
  27616. Node6.prototype.add = function add17(e) {
  27617. this._edges.insert(e);
  27618. e.setNode(this);
  27619. };
  27620. Node6.prototype.setLabelBoundary = function setLabelBoundary(argIndex) {
  27621. if (this._label === null) {
  27622. return null;
  27623. }
  27624. var loc = Location.NONE;
  27625. if (this._label !== null) {
  27626. loc = this._label.getLocation(argIndex);
  27627. }
  27628. var newLoc = null;
  27629. switch (loc) {
  27630. case Location.BOUNDARY:
  27631. newLoc = Location.INTERIOR;
  27632. break;
  27633. case Location.INTERIOR:
  27634. newLoc = Location.BOUNDARY;
  27635. break;
  27636. default:
  27637. newLoc = Location.BOUNDARY;
  27638. break;
  27639. }
  27640. this._label.setLocation(argIndex, newLoc);
  27641. };
  27642. Node6.prototype.interfaces_ = function interfaces_170() {
  27643. return [];
  27644. };
  27645. Node6.prototype.getClass = function getClass169() {
  27646. return Node6;
  27647. };
  27648. return Node6;
  27649. }(GraphComponent);
  27650. var NodeMap = function NodeMap2() {
  27651. this.nodeMap = new TreeMap();
  27652. this.nodeFact = null;
  27653. var nodeFact = arguments[0];
  27654. this.nodeFact = nodeFact;
  27655. };
  27656. NodeMap.prototype.find = function find(coord) {
  27657. return this.nodeMap.get(coord);
  27658. };
  27659. NodeMap.prototype.addNode = function addNode() {
  27660. if (arguments[0] instanceof Coordinate) {
  27661. var coord = arguments[0];
  27662. var node = this.nodeMap.get(coord);
  27663. if (node === null) {
  27664. node = this.nodeFact.createNode(coord);
  27665. this.nodeMap.put(coord, node);
  27666. }
  27667. return node;
  27668. } else if (arguments[0] instanceof Node5) {
  27669. var n = arguments[0];
  27670. var node$1 = this.nodeMap.get(n.getCoordinate());
  27671. if (node$1 === null) {
  27672. this.nodeMap.put(n.getCoordinate(), n);
  27673. return n;
  27674. }
  27675. node$1.mergeLabel(n);
  27676. return node$1;
  27677. }
  27678. };
  27679. NodeMap.prototype.print = function print(out) {
  27680. for (var it = this.iterator(); it.hasNext(); ) {
  27681. var n = it.next();
  27682. n.print(out);
  27683. }
  27684. };
  27685. NodeMap.prototype.iterator = function iterator2() {
  27686. return this.nodeMap.values().iterator();
  27687. };
  27688. NodeMap.prototype.values = function values2() {
  27689. return this.nodeMap.values();
  27690. };
  27691. NodeMap.prototype.getBoundaryNodes = function getBoundaryNodes(geomIndex) {
  27692. var bdyNodes = new ArrayList();
  27693. for (var i = this.iterator(); i.hasNext(); ) {
  27694. var node = i.next();
  27695. if (node.getLabel().getLocation(geomIndex) === Location.BOUNDARY) {
  27696. bdyNodes.add(node);
  27697. }
  27698. }
  27699. return bdyNodes;
  27700. };
  27701. NodeMap.prototype.add = function add5(e) {
  27702. var p = e.getCoordinate();
  27703. var n = this.addNode(p);
  27704. n.add(e);
  27705. };
  27706. NodeMap.prototype.interfaces_ = function interfaces_55() {
  27707. return [];
  27708. };
  27709. NodeMap.prototype.getClass = function getClass54() {
  27710. return NodeMap;
  27711. };
  27712. var Quadrant = function Quadrant2() {
  27713. };
  27714. var staticAccessors$21 = { NE: { configurable: true }, NW: { configurable: true }, SW: { configurable: true }, SE: { configurable: true } };
  27715. Quadrant.prototype.interfaces_ = function interfaces_56() {
  27716. return [];
  27717. };
  27718. Quadrant.prototype.getClass = function getClass55() {
  27719. return Quadrant;
  27720. };
  27721. Quadrant.isNorthern = function isNorthern(quad) {
  27722. return quad === Quadrant.NE || quad === Quadrant.NW;
  27723. };
  27724. Quadrant.isOpposite = function isOpposite(quad1, quad2) {
  27725. if (quad1 === quad2) {
  27726. return false;
  27727. }
  27728. var diff2 = (quad1 - quad2 + 4) % 4;
  27729. if (diff2 === 2) {
  27730. return true;
  27731. }
  27732. return false;
  27733. };
  27734. Quadrant.commonHalfPlane = function commonHalfPlane(quad1, quad2) {
  27735. if (quad1 === quad2) {
  27736. return quad1;
  27737. }
  27738. var diff2 = (quad1 - quad2 + 4) % 4;
  27739. if (diff2 === 2) {
  27740. return -1;
  27741. }
  27742. var min4 = quad1 < quad2 ? quad1 : quad2;
  27743. var max3 = quad1 > quad2 ? quad1 : quad2;
  27744. if (min4 === 0 && max3 === 3) {
  27745. return 3;
  27746. }
  27747. return min4;
  27748. };
  27749. Quadrant.isInHalfPlane = function isInHalfPlane(quad, halfPlane) {
  27750. if (halfPlane === Quadrant.SE) {
  27751. return quad === Quadrant.SE || quad === Quadrant.SW;
  27752. }
  27753. return quad === halfPlane || quad === halfPlane + 1;
  27754. };
  27755. Quadrant.quadrant = function quadrant() {
  27756. if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
  27757. var dx = arguments[0];
  27758. var dy = arguments[1];
  27759. if (dx === 0 && dy === 0) {
  27760. throw new IllegalArgumentException("Cannot compute the quadrant for point ( " + dx + ", " + dy + " )");
  27761. }
  27762. if (dx >= 0) {
  27763. if (dy >= 0) {
  27764. return Quadrant.NE;
  27765. } else {
  27766. return Quadrant.SE;
  27767. }
  27768. } else {
  27769. if (dy >= 0) {
  27770. return Quadrant.NW;
  27771. } else {
  27772. return Quadrant.SW;
  27773. }
  27774. }
  27775. } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Coordinate) {
  27776. var p0 = arguments[0];
  27777. var p1 = arguments[1];
  27778. if (p1.x === p0.x && p1.y === p0.y) {
  27779. throw new IllegalArgumentException("Cannot compute the quadrant for two identical points " + p0);
  27780. }
  27781. if (p1.x >= p0.x) {
  27782. if (p1.y >= p0.y) {
  27783. return Quadrant.NE;
  27784. } else {
  27785. return Quadrant.SE;
  27786. }
  27787. } else {
  27788. if (p1.y >= p0.y) {
  27789. return Quadrant.NW;
  27790. } else {
  27791. return Quadrant.SW;
  27792. }
  27793. }
  27794. }
  27795. };
  27796. staticAccessors$21.NE.get = function() {
  27797. return 0;
  27798. };
  27799. staticAccessors$21.NW.get = function() {
  27800. return 1;
  27801. };
  27802. staticAccessors$21.SW.get = function() {
  27803. return 2;
  27804. };
  27805. staticAccessors$21.SE.get = function() {
  27806. return 3;
  27807. };
  27808. Object.defineProperties(Quadrant, staticAccessors$21);
  27809. var EdgeEnd = function EdgeEnd2() {
  27810. this._edge = null;
  27811. this._label = null;
  27812. this._node = null;
  27813. this._p0 = null;
  27814. this._p1 = null;
  27815. this._dx = null;
  27816. this._dy = null;
  27817. this._quadrant = null;
  27818. if (arguments.length === 1) {
  27819. var edge = arguments[0];
  27820. this._edge = edge;
  27821. } else if (arguments.length === 3) {
  27822. var edge$1 = arguments[0];
  27823. var p0 = arguments[1];
  27824. var p1 = arguments[2];
  27825. var label = null;
  27826. this._edge = edge$1;
  27827. this.init(p0, p1);
  27828. this._label = label;
  27829. } else if (arguments.length === 4) {
  27830. var edge$2 = arguments[0];
  27831. var p0$1 = arguments[1];
  27832. var p1$1 = arguments[2];
  27833. var label$1 = arguments[3];
  27834. this._edge = edge$2;
  27835. this.init(p0$1, p1$1);
  27836. this._label = label$1;
  27837. }
  27838. };
  27839. EdgeEnd.prototype.compareDirection = function compareDirection(e) {
  27840. if (this._dx === e._dx && this._dy === e._dy) {
  27841. return 0;
  27842. }
  27843. if (this._quadrant > e._quadrant) {
  27844. return 1;
  27845. }
  27846. if (this._quadrant < e._quadrant) {
  27847. return -1;
  27848. }
  27849. return CGAlgorithms.computeOrientation(e._p0, e._p1, this._p1);
  27850. };
  27851. EdgeEnd.prototype.getDy = function getDy() {
  27852. return this._dy;
  27853. };
  27854. EdgeEnd.prototype.getCoordinate = function getCoordinate6() {
  27855. return this._p0;
  27856. };
  27857. EdgeEnd.prototype.setNode = function setNode(node) {
  27858. this._node = node;
  27859. };
  27860. EdgeEnd.prototype.print = function print2(out) {
  27861. var angle4 = Math.atan2(this._dy, this._dx);
  27862. var className = this.getClass().getName();
  27863. var lastDotPos = className.lastIndexOf(".");
  27864. var name = className.substring(lastDotPos + 1);
  27865. out.print(" " + name + ": " + this._p0 + " - " + this._p1 + " " + this._quadrant + ":" + angle4 + " " + this._label);
  27866. };
  27867. EdgeEnd.prototype.compareTo = function compareTo8(obj) {
  27868. var e = obj;
  27869. return this.compareDirection(e);
  27870. };
  27871. EdgeEnd.prototype.getDirectedCoordinate = function getDirectedCoordinate() {
  27872. return this._p1;
  27873. };
  27874. EdgeEnd.prototype.getDx = function getDx() {
  27875. return this._dx;
  27876. };
  27877. EdgeEnd.prototype.getLabel = function getLabel3() {
  27878. return this._label;
  27879. };
  27880. EdgeEnd.prototype.getEdge = function getEdge2() {
  27881. return this._edge;
  27882. };
  27883. EdgeEnd.prototype.getQuadrant = function getQuadrant() {
  27884. return this._quadrant;
  27885. };
  27886. EdgeEnd.prototype.getNode = function getNode() {
  27887. return this._node;
  27888. };
  27889. EdgeEnd.prototype.toString = function toString13() {
  27890. var angle4 = Math.atan2(this._dy, this._dx);
  27891. var className = this.getClass().getName();
  27892. var lastDotPos = className.lastIndexOf(".");
  27893. var name = className.substring(lastDotPos + 1);
  27894. return " " + name + ": " + this._p0 + " - " + this._p1 + " " + this._quadrant + ":" + angle4 + " " + this._label;
  27895. };
  27896. EdgeEnd.prototype.computeLabel = function computeLabel(boundaryNodeRule) {
  27897. };
  27898. EdgeEnd.prototype.init = function init4(p0, p1) {
  27899. this._p0 = p0;
  27900. this._p1 = p1;
  27901. this._dx = p1.x - p0.x;
  27902. this._dy = p1.y - p0.y;
  27903. this._quadrant = Quadrant.quadrant(this._dx, this._dy);
  27904. Assert.isTrue(!(this._dx === 0 && this._dy === 0), "EdgeEnd with identical endpoints found");
  27905. };
  27906. EdgeEnd.prototype.interfaces_ = function interfaces_57() {
  27907. return [Comparable];
  27908. };
  27909. EdgeEnd.prototype.getClass = function getClass56() {
  27910. return EdgeEnd;
  27911. };
  27912. var DirectedEdge = function(EdgeEnd$$1) {
  27913. function DirectedEdge2() {
  27914. var edge = arguments[0];
  27915. var isForward = arguments[1];
  27916. EdgeEnd$$1.call(this, edge);
  27917. this._isForward = null;
  27918. this._isInResult = false;
  27919. this._isVisited = false;
  27920. this._sym = null;
  27921. this._next = null;
  27922. this._nextMin = null;
  27923. this._edgeRing = null;
  27924. this._minEdgeRing = null;
  27925. this._depth = [0, -999, -999];
  27926. this._isForward = isForward;
  27927. if (isForward) {
  27928. this.init(edge.getCoordinate(0), edge.getCoordinate(1));
  27929. } else {
  27930. var n = edge.getNumPoints() - 1;
  27931. this.init(edge.getCoordinate(n), edge.getCoordinate(n - 1));
  27932. }
  27933. this.computeDirectedLabel();
  27934. }
  27935. if (EdgeEnd$$1)
  27936. DirectedEdge2.__proto__ = EdgeEnd$$1;
  27937. DirectedEdge2.prototype = Object.create(EdgeEnd$$1 && EdgeEnd$$1.prototype);
  27938. DirectedEdge2.prototype.constructor = DirectedEdge2;
  27939. DirectedEdge2.prototype.getNextMin = function getNextMin() {
  27940. return this._nextMin;
  27941. };
  27942. DirectedEdge2.prototype.getDepth = function getDepth3(position) {
  27943. return this._depth[position];
  27944. };
  27945. DirectedEdge2.prototype.setVisited = function setVisited2(isVisited2) {
  27946. this._isVisited = isVisited2;
  27947. };
  27948. DirectedEdge2.prototype.computeDirectedLabel = function computeDirectedLabel() {
  27949. this._label = new Label(this._edge.getLabel());
  27950. if (!this._isForward) {
  27951. this._label.flip();
  27952. }
  27953. };
  27954. DirectedEdge2.prototype.getNext = function getNext() {
  27955. return this._next;
  27956. };
  27957. DirectedEdge2.prototype.setDepth = function setDepth2(position, depthVal) {
  27958. if (this._depth[position] !== -999) {
  27959. if (this._depth[position] !== depthVal) {
  27960. throw new TopologyException("assigned depths do not match", this.getCoordinate());
  27961. }
  27962. }
  27963. this._depth[position] = depthVal;
  27964. };
  27965. DirectedEdge2.prototype.isInteriorAreaEdge = function isInteriorAreaEdge() {
  27966. var this$1 = this;
  27967. var isInteriorAreaEdge2 = true;
  27968. for (var i = 0; i < 2; i++) {
  27969. if (!(this$1._label.isArea(i) && this$1._label.getLocation(i, Position.LEFT) === Location.INTERIOR && this$1._label.getLocation(i, Position.RIGHT) === Location.INTERIOR)) {
  27970. isInteriorAreaEdge2 = false;
  27971. }
  27972. }
  27973. return isInteriorAreaEdge2;
  27974. };
  27975. DirectedEdge2.prototype.setNextMin = function setNextMin(nextMin) {
  27976. this._nextMin = nextMin;
  27977. };
  27978. DirectedEdge2.prototype.print = function print9(out) {
  27979. EdgeEnd$$1.prototype.print.call(this, out);
  27980. out.print(" " + this._depth[Position.LEFT] + "/" + this._depth[Position.RIGHT]);
  27981. out.print(" (" + this.getDepthDelta() + ")");
  27982. if (this._isInResult) {
  27983. out.print(" inResult");
  27984. }
  27985. };
  27986. DirectedEdge2.prototype.setMinEdgeRing = function setMinEdgeRing(minEdgeRing) {
  27987. this._minEdgeRing = minEdgeRing;
  27988. };
  27989. DirectedEdge2.prototype.isLineEdge = function isLineEdge() {
  27990. var isLine3 = this._label.isLine(0) || this._label.isLine(1);
  27991. var isExteriorIfArea0 = !this._label.isArea(0) || this._label.allPositionsEqual(0, Location.EXTERIOR);
  27992. var isExteriorIfArea1 = !this._label.isArea(1) || this._label.allPositionsEqual(1, Location.EXTERIOR);
  27993. return isLine3 && isExteriorIfArea0 && isExteriorIfArea1;
  27994. };
  27995. DirectedEdge2.prototype.setEdgeRing = function setEdgeRing(edgeRing) {
  27996. this._edgeRing = edgeRing;
  27997. };
  27998. DirectedEdge2.prototype.getMinEdgeRing = function getMinEdgeRing() {
  27999. return this._minEdgeRing;
  28000. };
  28001. DirectedEdge2.prototype.getDepthDelta = function getDepthDelta() {
  28002. var depthDelta2 = this._edge.getDepthDelta();
  28003. if (!this._isForward) {
  28004. depthDelta2 = -depthDelta2;
  28005. }
  28006. return depthDelta2;
  28007. };
  28008. DirectedEdge2.prototype.setInResult = function setInResult3(isInResult2) {
  28009. this._isInResult = isInResult2;
  28010. };
  28011. DirectedEdge2.prototype.getSym = function getSym() {
  28012. return this._sym;
  28013. };
  28014. DirectedEdge2.prototype.isForward = function isForward() {
  28015. return this._isForward;
  28016. };
  28017. DirectedEdge2.prototype.getEdge = function getEdge4() {
  28018. return this._edge;
  28019. };
  28020. DirectedEdge2.prototype.printEdge = function printEdge(out) {
  28021. this.print(out);
  28022. out.print(" ");
  28023. if (this._isForward) {
  28024. this._edge.print(out);
  28025. } else {
  28026. this._edge.printReverse(out);
  28027. }
  28028. };
  28029. DirectedEdge2.prototype.setSym = function setSym(de) {
  28030. this._sym = de;
  28031. };
  28032. DirectedEdge2.prototype.setVisitedEdge = function setVisitedEdge(isVisited2) {
  28033. this.setVisited(isVisited2);
  28034. this._sym.setVisited(isVisited2);
  28035. };
  28036. DirectedEdge2.prototype.setEdgeDepths = function setEdgeDepths(position, depth2) {
  28037. var depthDelta2 = this.getEdge().getDepthDelta();
  28038. if (!this._isForward) {
  28039. depthDelta2 = -depthDelta2;
  28040. }
  28041. var directionFactor = 1;
  28042. if (position === Position.LEFT) {
  28043. directionFactor = -1;
  28044. }
  28045. var oppositePos = Position.opposite(position);
  28046. var delta = depthDelta2 * directionFactor;
  28047. var oppositeDepth = depth2 + delta;
  28048. this.setDepth(position, depth2);
  28049. this.setDepth(oppositePos, oppositeDepth);
  28050. };
  28051. DirectedEdge2.prototype.getEdgeRing = function getEdgeRing() {
  28052. return this._edgeRing;
  28053. };
  28054. DirectedEdge2.prototype.isInResult = function isInResult2() {
  28055. return this._isInResult;
  28056. };
  28057. DirectedEdge2.prototype.setNext = function setNext(next3) {
  28058. this._next = next3;
  28059. };
  28060. DirectedEdge2.prototype.isVisited = function isVisited2() {
  28061. return this._isVisited;
  28062. };
  28063. DirectedEdge2.prototype.interfaces_ = function interfaces_170() {
  28064. return [];
  28065. };
  28066. DirectedEdge2.prototype.getClass = function getClass169() {
  28067. return DirectedEdge2;
  28068. };
  28069. DirectedEdge2.depthFactor = function depthFactor(currLocation, nextLocation) {
  28070. if (currLocation === Location.EXTERIOR && nextLocation === Location.INTERIOR) {
  28071. return 1;
  28072. } else if (currLocation === Location.INTERIOR && nextLocation === Location.EXTERIOR) {
  28073. return -1;
  28074. }
  28075. return 0;
  28076. };
  28077. return DirectedEdge2;
  28078. }(EdgeEnd);
  28079. var NodeFactory = function NodeFactory2() {
  28080. };
  28081. NodeFactory.prototype.createNode = function createNode(coord) {
  28082. return new Node5(coord, null);
  28083. };
  28084. NodeFactory.prototype.interfaces_ = function interfaces_58() {
  28085. return [];
  28086. };
  28087. NodeFactory.prototype.getClass = function getClass57() {
  28088. return NodeFactory;
  28089. };
  28090. var PlanarGraph = function PlanarGraph2() {
  28091. this._edges = new ArrayList();
  28092. this._nodes = null;
  28093. this._edgeEndList = new ArrayList();
  28094. if (arguments.length === 0) {
  28095. this._nodes = new NodeMap(new NodeFactory());
  28096. } else if (arguments.length === 1) {
  28097. var nodeFact = arguments[0];
  28098. this._nodes = new NodeMap(nodeFact);
  28099. }
  28100. };
  28101. PlanarGraph.prototype.printEdges = function printEdges(out) {
  28102. var this$1 = this;
  28103. out.println("Edges:");
  28104. for (var i = 0; i < this._edges.size(); i++) {
  28105. out.println("edge " + i + ":");
  28106. var e = this$1._edges.get(i);
  28107. e.print(out);
  28108. e.eiList.print(out);
  28109. }
  28110. };
  28111. PlanarGraph.prototype.find = function find2(coord) {
  28112. return this._nodes.find(coord);
  28113. };
  28114. PlanarGraph.prototype.addNode = function addNode2() {
  28115. if (arguments[0] instanceof Node5) {
  28116. var node = arguments[0];
  28117. return this._nodes.addNode(node);
  28118. } else if (arguments[0] instanceof Coordinate) {
  28119. var coord = arguments[0];
  28120. return this._nodes.addNode(coord);
  28121. }
  28122. };
  28123. PlanarGraph.prototype.getNodeIterator = function getNodeIterator() {
  28124. return this._nodes.iterator();
  28125. };
  28126. PlanarGraph.prototype.linkResultDirectedEdges = function linkResultDirectedEdges() {
  28127. for (var nodeit = this._nodes.iterator(); nodeit.hasNext(); ) {
  28128. var node = nodeit.next();
  28129. node.getEdges().linkResultDirectedEdges();
  28130. }
  28131. };
  28132. PlanarGraph.prototype.debugPrintln = function debugPrintln(o) {
  28133. System.out.println(o);
  28134. };
  28135. PlanarGraph.prototype.isBoundaryNode = function isBoundaryNode(geomIndex, coord) {
  28136. var node = this._nodes.find(coord);
  28137. if (node === null) {
  28138. return false;
  28139. }
  28140. var label = node.getLabel();
  28141. if (label !== null && label.getLocation(geomIndex) === Location.BOUNDARY) {
  28142. return true;
  28143. }
  28144. return false;
  28145. };
  28146. PlanarGraph.prototype.linkAllDirectedEdges = function linkAllDirectedEdges() {
  28147. for (var nodeit = this._nodes.iterator(); nodeit.hasNext(); ) {
  28148. var node = nodeit.next();
  28149. node.getEdges().linkAllDirectedEdges();
  28150. }
  28151. };
  28152. PlanarGraph.prototype.matchInSameDirection = function matchInSameDirection(p0, p1, ep0, ep1) {
  28153. if (!p0.equals(ep0)) {
  28154. return false;
  28155. }
  28156. if (CGAlgorithms.computeOrientation(p0, p1, ep1) === CGAlgorithms.COLLINEAR && Quadrant.quadrant(p0, p1) === Quadrant.quadrant(ep0, ep1)) {
  28157. return true;
  28158. }
  28159. return false;
  28160. };
  28161. PlanarGraph.prototype.getEdgeEnds = function getEdgeEnds() {
  28162. return this._edgeEndList;
  28163. };
  28164. PlanarGraph.prototype.debugPrint = function debugPrint(o) {
  28165. System.out.print(o);
  28166. };
  28167. PlanarGraph.prototype.getEdgeIterator = function getEdgeIterator() {
  28168. return this._edges.iterator();
  28169. };
  28170. PlanarGraph.prototype.findEdgeInSameDirection = function findEdgeInSameDirection(p0, p1) {
  28171. var this$1 = this;
  28172. for (var i = 0; i < this._edges.size(); i++) {
  28173. var e = this$1._edges.get(i);
  28174. var eCoord = e.getCoordinates();
  28175. if (this$1.matchInSameDirection(p0, p1, eCoord[0], eCoord[1])) {
  28176. return e;
  28177. }
  28178. if (this$1.matchInSameDirection(p0, p1, eCoord[eCoord.length - 1], eCoord[eCoord.length - 2])) {
  28179. return e;
  28180. }
  28181. }
  28182. return null;
  28183. };
  28184. PlanarGraph.prototype.insertEdge = function insertEdge(e) {
  28185. this._edges.add(e);
  28186. };
  28187. PlanarGraph.prototype.findEdgeEnd = function findEdgeEnd(e) {
  28188. for (var i = this.getEdgeEnds().iterator(); i.hasNext(); ) {
  28189. var ee = i.next();
  28190. if (ee.getEdge() === e) {
  28191. return ee;
  28192. }
  28193. }
  28194. return null;
  28195. };
  28196. PlanarGraph.prototype.addEdges = function addEdges(edgesToAdd) {
  28197. var this$1 = this;
  28198. for (var it = edgesToAdd.iterator(); it.hasNext(); ) {
  28199. var e = it.next();
  28200. this$1._edges.add(e);
  28201. var de1 = new DirectedEdge(e, true);
  28202. var de2 = new DirectedEdge(e, false);
  28203. de1.setSym(de2);
  28204. de2.setSym(de1);
  28205. this$1.add(de1);
  28206. this$1.add(de2);
  28207. }
  28208. };
  28209. PlanarGraph.prototype.add = function add6(e) {
  28210. this._nodes.add(e);
  28211. this._edgeEndList.add(e);
  28212. };
  28213. PlanarGraph.prototype.getNodes = function getNodes2() {
  28214. return this._nodes.values();
  28215. };
  28216. PlanarGraph.prototype.findEdge = function findEdge2(p0, p1) {
  28217. var this$1 = this;
  28218. for (var i = 0; i < this._edges.size(); i++) {
  28219. var e = this$1._edges.get(i);
  28220. var eCoord = e.getCoordinates();
  28221. if (p0.equals(eCoord[0]) && p1.equals(eCoord[1])) {
  28222. return e;
  28223. }
  28224. }
  28225. return null;
  28226. };
  28227. PlanarGraph.prototype.interfaces_ = function interfaces_59() {
  28228. return [];
  28229. };
  28230. PlanarGraph.prototype.getClass = function getClass58() {
  28231. return PlanarGraph;
  28232. };
  28233. PlanarGraph.linkResultDirectedEdges = function linkResultDirectedEdges2(nodes) {
  28234. for (var nodeit = nodes.iterator(); nodeit.hasNext(); ) {
  28235. var node = nodeit.next();
  28236. node.getEdges().linkResultDirectedEdges();
  28237. }
  28238. };
  28239. var PolygonBuilder = function PolygonBuilder2() {
  28240. this._geometryFactory = null;
  28241. this._shellList = new ArrayList();
  28242. var geometryFactory = arguments[0];
  28243. this._geometryFactory = geometryFactory;
  28244. };
  28245. PolygonBuilder.prototype.sortShellsAndHoles = function sortShellsAndHoles(edgeRings, shellList, freeHoleList) {
  28246. for (var it = edgeRings.iterator(); it.hasNext(); ) {
  28247. var er = it.next();
  28248. if (er.isHole()) {
  28249. freeHoleList.add(er);
  28250. } else {
  28251. shellList.add(er);
  28252. }
  28253. }
  28254. };
  28255. PolygonBuilder.prototype.computePolygons = function computePolygons(shellList) {
  28256. var this$1 = this;
  28257. var resultPolyList = new ArrayList();
  28258. for (var it = shellList.iterator(); it.hasNext(); ) {
  28259. var er = it.next();
  28260. var poly = er.toPolygon(this$1._geometryFactory);
  28261. resultPolyList.add(poly);
  28262. }
  28263. return resultPolyList;
  28264. };
  28265. PolygonBuilder.prototype.placeFreeHoles = function placeFreeHoles(shellList, freeHoleList) {
  28266. var this$1 = this;
  28267. for (var it = freeHoleList.iterator(); it.hasNext(); ) {
  28268. var hole = it.next();
  28269. if (hole.getShell() === null) {
  28270. var shell = this$1.findEdgeRingContaining(hole, shellList);
  28271. if (shell === null) {
  28272. throw new TopologyException("unable to assign hole to a shell", hole.getCoordinate(0));
  28273. }
  28274. hole.setShell(shell);
  28275. }
  28276. }
  28277. };
  28278. PolygonBuilder.prototype.buildMinimalEdgeRings = function buildMinimalEdgeRings(maxEdgeRings, shellList, freeHoleList) {
  28279. var this$1 = this;
  28280. var edgeRings = new ArrayList();
  28281. for (var it = maxEdgeRings.iterator(); it.hasNext(); ) {
  28282. var er = it.next();
  28283. if (er.getMaxNodeDegree() > 2) {
  28284. er.linkDirectedEdgesForMinimalEdgeRings();
  28285. var minEdgeRings = er.buildMinimalRings();
  28286. var shell = this$1.findShell(minEdgeRings);
  28287. if (shell !== null) {
  28288. this$1.placePolygonHoles(shell, minEdgeRings);
  28289. shellList.add(shell);
  28290. } else {
  28291. freeHoleList.addAll(minEdgeRings);
  28292. }
  28293. } else {
  28294. edgeRings.add(er);
  28295. }
  28296. }
  28297. return edgeRings;
  28298. };
  28299. PolygonBuilder.prototype.containsPoint = function containsPoint2(p) {
  28300. for (var it = this._shellList.iterator(); it.hasNext(); ) {
  28301. var er = it.next();
  28302. if (er.containsPoint(p)) {
  28303. return true;
  28304. }
  28305. }
  28306. return false;
  28307. };
  28308. PolygonBuilder.prototype.buildMaximalEdgeRings = function buildMaximalEdgeRings(dirEdges) {
  28309. var this$1 = this;
  28310. var maxEdgeRings = new ArrayList();
  28311. for (var it = dirEdges.iterator(); it.hasNext(); ) {
  28312. var de = it.next();
  28313. if (de.isInResult() && de.getLabel().isArea()) {
  28314. if (de.getEdgeRing() === null) {
  28315. var er = new MaximalEdgeRing(de, this$1._geometryFactory);
  28316. maxEdgeRings.add(er);
  28317. er.setInResult();
  28318. }
  28319. }
  28320. }
  28321. return maxEdgeRings;
  28322. };
  28323. PolygonBuilder.prototype.placePolygonHoles = function placePolygonHoles(shell, minEdgeRings) {
  28324. for (var it = minEdgeRings.iterator(); it.hasNext(); ) {
  28325. var er = it.next();
  28326. if (er.isHole()) {
  28327. er.setShell(shell);
  28328. }
  28329. }
  28330. };
  28331. PolygonBuilder.prototype.getPolygons = function getPolygons() {
  28332. var resultPolyList = this.computePolygons(this._shellList);
  28333. return resultPolyList;
  28334. };
  28335. PolygonBuilder.prototype.findEdgeRingContaining = function findEdgeRingContaining(testEr, shellList) {
  28336. var testRing = testEr.getLinearRing();
  28337. var testEnv = testRing.getEnvelopeInternal();
  28338. var testPt = testRing.getCoordinateN(0);
  28339. var minShell = null;
  28340. var minEnv = null;
  28341. for (var it = shellList.iterator(); it.hasNext(); ) {
  28342. var tryShell = it.next();
  28343. var tryRing = tryShell.getLinearRing();
  28344. var tryEnv = tryRing.getEnvelopeInternal();
  28345. if (minShell !== null) {
  28346. minEnv = minShell.getLinearRing().getEnvelopeInternal();
  28347. }
  28348. var isContained = false;
  28349. if (tryEnv.contains(testEnv) && CGAlgorithms.isPointInRing(testPt, tryRing.getCoordinates())) {
  28350. isContained = true;
  28351. }
  28352. if (isContained) {
  28353. if (minShell === null || minEnv.contains(tryEnv)) {
  28354. minShell = tryShell;
  28355. }
  28356. }
  28357. }
  28358. return minShell;
  28359. };
  28360. PolygonBuilder.prototype.findShell = function findShell(minEdgeRings) {
  28361. var shellCount = 0;
  28362. var shell = null;
  28363. for (var it = minEdgeRings.iterator(); it.hasNext(); ) {
  28364. var er = it.next();
  28365. if (!er.isHole()) {
  28366. shell = er;
  28367. shellCount++;
  28368. }
  28369. }
  28370. Assert.isTrue(shellCount <= 1, "found two shells in MinimalEdgeRing list");
  28371. return shell;
  28372. };
  28373. PolygonBuilder.prototype.add = function add7() {
  28374. if (arguments.length === 1) {
  28375. var graph = arguments[0];
  28376. this.add(graph.getEdgeEnds(), graph.getNodes());
  28377. } else if (arguments.length === 2) {
  28378. var dirEdges = arguments[0];
  28379. var nodes = arguments[1];
  28380. PlanarGraph.linkResultDirectedEdges(nodes);
  28381. var maxEdgeRings = this.buildMaximalEdgeRings(dirEdges);
  28382. var freeHoleList = new ArrayList();
  28383. var edgeRings = this.buildMinimalEdgeRings(maxEdgeRings, this._shellList, freeHoleList);
  28384. this.sortShellsAndHoles(edgeRings, this._shellList, freeHoleList);
  28385. this.placeFreeHoles(this._shellList, freeHoleList);
  28386. }
  28387. };
  28388. PolygonBuilder.prototype.interfaces_ = function interfaces_60() {
  28389. return [];
  28390. };
  28391. PolygonBuilder.prototype.getClass = function getClass59() {
  28392. return PolygonBuilder;
  28393. };
  28394. var Boundable = function Boundable2() {
  28395. };
  28396. Boundable.prototype.getBounds = function getBounds() {
  28397. };
  28398. Boundable.prototype.interfaces_ = function interfaces_61() {
  28399. return [];
  28400. };
  28401. Boundable.prototype.getClass = function getClass60() {
  28402. return Boundable;
  28403. };
  28404. var ItemBoundable = function ItemBoundable2() {
  28405. this._bounds = null;
  28406. this._item = null;
  28407. var bounds = arguments[0];
  28408. var item = arguments[1];
  28409. this._bounds = bounds;
  28410. this._item = item;
  28411. };
  28412. ItemBoundable.prototype.getItem = function getItem() {
  28413. return this._item;
  28414. };
  28415. ItemBoundable.prototype.getBounds = function getBounds2() {
  28416. return this._bounds;
  28417. };
  28418. ItemBoundable.prototype.interfaces_ = function interfaces_62() {
  28419. return [Boundable, Serializable];
  28420. };
  28421. ItemBoundable.prototype.getClass = function getClass61() {
  28422. return ItemBoundable;
  28423. };
  28424. var PriorityQueue = function PriorityQueue2() {
  28425. this._size = null;
  28426. this._items = null;
  28427. this._size = 0;
  28428. this._items = new ArrayList();
  28429. this._items.add(null);
  28430. };
  28431. PriorityQueue.prototype.poll = function poll() {
  28432. if (this.isEmpty()) {
  28433. return null;
  28434. }
  28435. var minItem = this._items.get(1);
  28436. this._items.set(1, this._items.get(this._size));
  28437. this._size -= 1;
  28438. this.reorder(1);
  28439. return minItem;
  28440. };
  28441. PriorityQueue.prototype.size = function size5() {
  28442. return this._size;
  28443. };
  28444. PriorityQueue.prototype.reorder = function reorder(hole) {
  28445. var this$1 = this;
  28446. var child = null;
  28447. var tmp = this._items.get(hole);
  28448. for (; hole * 2 <= this._size; hole = child) {
  28449. child = hole * 2;
  28450. if (child !== this$1._size && this$1._items.get(child + 1).compareTo(this$1._items.get(child)) < 0) {
  28451. child++;
  28452. }
  28453. if (this$1._items.get(child).compareTo(tmp) < 0) {
  28454. this$1._items.set(hole, this$1._items.get(child));
  28455. } else {
  28456. break;
  28457. }
  28458. }
  28459. this._items.set(hole, tmp);
  28460. };
  28461. PriorityQueue.prototype.clear = function clear() {
  28462. this._size = 0;
  28463. this._items.clear();
  28464. };
  28465. PriorityQueue.prototype.isEmpty = function isEmpty3() {
  28466. return this._size === 0;
  28467. };
  28468. PriorityQueue.prototype.add = function add8(x2) {
  28469. var this$1 = this;
  28470. this._items.add(null);
  28471. this._size += 1;
  28472. var hole = this._size;
  28473. this._items.set(0, x2);
  28474. for (; x2.compareTo(this._items.get(Math.trunc(hole / 2))) < 0; hole /= 2) {
  28475. this$1._items.set(hole, this$1._items.get(Math.trunc(hole / 2)));
  28476. }
  28477. this._items.set(hole, x2);
  28478. };
  28479. PriorityQueue.prototype.interfaces_ = function interfaces_63() {
  28480. return [];
  28481. };
  28482. PriorityQueue.prototype.getClass = function getClass62() {
  28483. return PriorityQueue;
  28484. };
  28485. var ItemVisitor = function ItemVisitor2() {
  28486. };
  28487. ItemVisitor.prototype.visitItem = function visitItem(item) {
  28488. };
  28489. ItemVisitor.prototype.interfaces_ = function interfaces_64() {
  28490. return [];
  28491. };
  28492. ItemVisitor.prototype.getClass = function getClass63() {
  28493. return ItemVisitor;
  28494. };
  28495. var SpatialIndex = function SpatialIndex2() {
  28496. };
  28497. SpatialIndex.prototype.insert = function insert2(itemEnv, item) {
  28498. };
  28499. SpatialIndex.prototype.remove = function remove3(itemEnv, item) {
  28500. };
  28501. SpatialIndex.prototype.query = function query() {
  28502. };
  28503. SpatialIndex.prototype.interfaces_ = function interfaces_65() {
  28504. return [];
  28505. };
  28506. SpatialIndex.prototype.getClass = function getClass64() {
  28507. return SpatialIndex;
  28508. };
  28509. var AbstractNode = function AbstractNode2() {
  28510. this._childBoundables = new ArrayList();
  28511. this._bounds = null;
  28512. this._level = null;
  28513. if (arguments.length === 0) {
  28514. } else if (arguments.length === 1) {
  28515. var level = arguments[0];
  28516. this._level = level;
  28517. }
  28518. };
  28519. var staticAccessors$22 = { serialVersionUID: { configurable: true } };
  28520. AbstractNode.prototype.getLevel = function getLevel() {
  28521. return this._level;
  28522. };
  28523. AbstractNode.prototype.size = function size6() {
  28524. return this._childBoundables.size();
  28525. };
  28526. AbstractNode.prototype.getChildBoundables = function getChildBoundables() {
  28527. return this._childBoundables;
  28528. };
  28529. AbstractNode.prototype.addChildBoundable = function addChildBoundable(childBoundable) {
  28530. Assert.isTrue(this._bounds === null);
  28531. this._childBoundables.add(childBoundable);
  28532. };
  28533. AbstractNode.prototype.isEmpty = function isEmpty4() {
  28534. return this._childBoundables.isEmpty();
  28535. };
  28536. AbstractNode.prototype.getBounds = function getBounds3() {
  28537. if (this._bounds === null) {
  28538. this._bounds = this.computeBounds();
  28539. }
  28540. return this._bounds;
  28541. };
  28542. AbstractNode.prototype.interfaces_ = function interfaces_66() {
  28543. return [Boundable, Serializable];
  28544. };
  28545. AbstractNode.prototype.getClass = function getClass65() {
  28546. return AbstractNode;
  28547. };
  28548. staticAccessors$22.serialVersionUID.get = function() {
  28549. return 6493722185909574e3;
  28550. };
  28551. Object.defineProperties(AbstractNode, staticAccessors$22);
  28552. var Collections = function Collections2() {
  28553. };
  28554. Collections.reverseOrder = function reverseOrder() {
  28555. return {
  28556. compare: function compare10(a, b) {
  28557. return b.compareTo(a);
  28558. }
  28559. };
  28560. };
  28561. Collections.min = function min3(l) {
  28562. Collections.sort(l);
  28563. return l.get(0);
  28564. };
  28565. Collections.sort = function sort3(l, c) {
  28566. var a = l.toArray();
  28567. if (c) {
  28568. Arrays.sort(a, c);
  28569. } else {
  28570. Arrays.sort(a);
  28571. }
  28572. var i = l.iterator();
  28573. for (var pos = 0, alen = a.length; pos < alen; pos++) {
  28574. i.next();
  28575. i.set(a[pos]);
  28576. }
  28577. };
  28578. Collections.singletonList = function singletonList(o) {
  28579. var arrayList = new ArrayList();
  28580. arrayList.add(o);
  28581. return arrayList;
  28582. };
  28583. var BoundablePair = function BoundablePair2() {
  28584. this._boundable1 = null;
  28585. this._boundable2 = null;
  28586. this._distance = null;
  28587. this._itemDistance = null;
  28588. var boundable1 = arguments[0];
  28589. var boundable2 = arguments[1];
  28590. var itemDistance = arguments[2];
  28591. this._boundable1 = boundable1;
  28592. this._boundable2 = boundable2;
  28593. this._itemDistance = itemDistance;
  28594. this._distance = this.distance();
  28595. };
  28596. BoundablePair.prototype.expandToQueue = function expandToQueue(priQ, minDistance) {
  28597. var isComp1 = BoundablePair.isComposite(this._boundable1);
  28598. var isComp2 = BoundablePair.isComposite(this._boundable2);
  28599. if (isComp1 && isComp2) {
  28600. if (BoundablePair.area(this._boundable1) > BoundablePair.area(this._boundable2)) {
  28601. this.expand(this._boundable1, this._boundable2, priQ, minDistance);
  28602. return null;
  28603. } else {
  28604. this.expand(this._boundable2, this._boundable1, priQ, minDistance);
  28605. return null;
  28606. }
  28607. } else if (isComp1) {
  28608. this.expand(this._boundable1, this._boundable2, priQ, minDistance);
  28609. return null;
  28610. } else if (isComp2) {
  28611. this.expand(this._boundable2, this._boundable1, priQ, minDistance);
  28612. return null;
  28613. }
  28614. throw new IllegalArgumentException("neither boundable is composite");
  28615. };
  28616. BoundablePair.prototype.isLeaves = function isLeaves() {
  28617. return !(BoundablePair.isComposite(this._boundable1) || BoundablePair.isComposite(this._boundable2));
  28618. };
  28619. BoundablePair.prototype.compareTo = function compareTo9(o) {
  28620. var nd = o;
  28621. if (this._distance < nd._distance) {
  28622. return -1;
  28623. }
  28624. if (this._distance > nd._distance) {
  28625. return 1;
  28626. }
  28627. return 0;
  28628. };
  28629. BoundablePair.prototype.expand = function expand(bndComposite, bndOther, priQ, minDistance) {
  28630. var this$1 = this;
  28631. var children = bndComposite.getChildBoundables();
  28632. for (var i = children.iterator(); i.hasNext(); ) {
  28633. var child = i.next();
  28634. var bp = new BoundablePair(child, bndOther, this$1._itemDistance);
  28635. if (bp.getDistance() < minDistance) {
  28636. priQ.add(bp);
  28637. }
  28638. }
  28639. };
  28640. BoundablePair.prototype.getBoundable = function getBoundable(i) {
  28641. if (i === 0) {
  28642. return this._boundable1;
  28643. }
  28644. return this._boundable2;
  28645. };
  28646. BoundablePair.prototype.getDistance = function getDistance() {
  28647. return this._distance;
  28648. };
  28649. BoundablePair.prototype.distance = function distance4() {
  28650. if (this.isLeaves()) {
  28651. return this._itemDistance.distance(this._boundable1, this._boundable2);
  28652. }
  28653. return this._boundable1.getBounds().distance(this._boundable2.getBounds());
  28654. };
  28655. BoundablePair.prototype.interfaces_ = function interfaces_67() {
  28656. return [Comparable];
  28657. };
  28658. BoundablePair.prototype.getClass = function getClass66() {
  28659. return BoundablePair;
  28660. };
  28661. BoundablePair.area = function area2(b) {
  28662. return b.getBounds().getArea();
  28663. };
  28664. BoundablePair.isComposite = function isComposite(item) {
  28665. return item instanceof AbstractNode;
  28666. };
  28667. var AbstractSTRtree = function AbstractSTRtree2() {
  28668. this._root = null;
  28669. this._built = false;
  28670. this._itemBoundables = new ArrayList();
  28671. this._nodeCapacity = null;
  28672. if (arguments.length === 0) {
  28673. var nodeCapacity = AbstractSTRtree2.DEFAULT_NODE_CAPACITY;
  28674. this._nodeCapacity = nodeCapacity;
  28675. } else if (arguments.length === 1) {
  28676. var nodeCapacity$1 = arguments[0];
  28677. Assert.isTrue(nodeCapacity$1 > 1, "Node capacity must be greater than 1");
  28678. this._nodeCapacity = nodeCapacity$1;
  28679. }
  28680. };
  28681. var staticAccessors$23 = { IntersectsOp: { configurable: true }, serialVersionUID: { configurable: true }, DEFAULT_NODE_CAPACITY: { configurable: true } };
  28682. AbstractSTRtree.prototype.getNodeCapacity = function getNodeCapacity() {
  28683. return this._nodeCapacity;
  28684. };
  28685. AbstractSTRtree.prototype.lastNode = function lastNode(nodes) {
  28686. return nodes.get(nodes.size() - 1);
  28687. };
  28688. AbstractSTRtree.prototype.size = function size7() {
  28689. var this$1 = this;
  28690. if (arguments.length === 0) {
  28691. if (this.isEmpty()) {
  28692. return 0;
  28693. }
  28694. this.build();
  28695. return this.size(this._root);
  28696. } else if (arguments.length === 1) {
  28697. var node = arguments[0];
  28698. var size11 = 0;
  28699. for (var i = node.getChildBoundables().iterator(); i.hasNext(); ) {
  28700. var childBoundable = i.next();
  28701. if (childBoundable instanceof AbstractNode) {
  28702. size11 += this$1.size(childBoundable);
  28703. } else if (childBoundable instanceof ItemBoundable) {
  28704. size11 += 1;
  28705. }
  28706. }
  28707. return size11;
  28708. }
  28709. };
  28710. AbstractSTRtree.prototype.removeItem = function removeItem(node, item) {
  28711. var childToRemove = null;
  28712. for (var i = node.getChildBoundables().iterator(); i.hasNext(); ) {
  28713. var childBoundable = i.next();
  28714. if (childBoundable instanceof ItemBoundable) {
  28715. if (childBoundable.getItem() === item) {
  28716. childToRemove = childBoundable;
  28717. }
  28718. }
  28719. }
  28720. if (childToRemove !== null) {
  28721. node.getChildBoundables().remove(childToRemove);
  28722. return true;
  28723. }
  28724. return false;
  28725. };
  28726. AbstractSTRtree.prototype.itemsTree = function itemsTree() {
  28727. var this$1 = this;
  28728. if (arguments.length === 0) {
  28729. this.build();
  28730. var valuesTree = this.itemsTree(this._root);
  28731. if (valuesTree === null) {
  28732. return new ArrayList();
  28733. }
  28734. return valuesTree;
  28735. } else if (arguments.length === 1) {
  28736. var node = arguments[0];
  28737. var valuesTreeForNode = new ArrayList();
  28738. for (var i = node.getChildBoundables().iterator(); i.hasNext(); ) {
  28739. var childBoundable = i.next();
  28740. if (childBoundable instanceof AbstractNode) {
  28741. var valuesTreeForChild = this$1.itemsTree(childBoundable);
  28742. if (valuesTreeForChild !== null) {
  28743. valuesTreeForNode.add(valuesTreeForChild);
  28744. }
  28745. } else if (childBoundable instanceof ItemBoundable) {
  28746. valuesTreeForNode.add(childBoundable.getItem());
  28747. } else {
  28748. Assert.shouldNeverReachHere();
  28749. }
  28750. }
  28751. if (valuesTreeForNode.size() <= 0) {
  28752. return null;
  28753. }
  28754. return valuesTreeForNode;
  28755. }
  28756. };
  28757. AbstractSTRtree.prototype.insert = function insert3(bounds, item) {
  28758. Assert.isTrue(!this._built, "Cannot insert items into an STR packed R-tree after it has been built.");
  28759. this._itemBoundables.add(new ItemBoundable(bounds, item));
  28760. };
  28761. AbstractSTRtree.prototype.boundablesAtLevel = function boundablesAtLevel() {
  28762. var this$1 = this;
  28763. if (arguments.length === 1) {
  28764. var level = arguments[0];
  28765. var boundables = new ArrayList();
  28766. this.boundablesAtLevel(level, this._root, boundables);
  28767. return boundables;
  28768. } else if (arguments.length === 3) {
  28769. var level$1 = arguments[0];
  28770. var top = arguments[1];
  28771. var boundables$1 = arguments[2];
  28772. Assert.isTrue(level$1 > -2);
  28773. if (top.getLevel() === level$1) {
  28774. boundables$1.add(top);
  28775. return null;
  28776. }
  28777. for (var i = top.getChildBoundables().iterator(); i.hasNext(); ) {
  28778. var boundable = i.next();
  28779. if (boundable instanceof AbstractNode) {
  28780. this$1.boundablesAtLevel(level$1, boundable, boundables$1);
  28781. } else {
  28782. Assert.isTrue(boundable instanceof ItemBoundable);
  28783. if (level$1 === -1) {
  28784. boundables$1.add(boundable);
  28785. }
  28786. }
  28787. }
  28788. return null;
  28789. }
  28790. };
  28791. AbstractSTRtree.prototype.query = function query2() {
  28792. var this$1 = this;
  28793. if (arguments.length === 1) {
  28794. var searchBounds = arguments[0];
  28795. this.build();
  28796. var matches = new ArrayList();
  28797. if (this.isEmpty()) {
  28798. return matches;
  28799. }
  28800. if (this.getIntersectsOp().intersects(this._root.getBounds(), searchBounds)) {
  28801. this.query(searchBounds, this._root, matches);
  28802. }
  28803. return matches;
  28804. } else if (arguments.length === 2) {
  28805. var searchBounds$1 = arguments[0];
  28806. var visitor = arguments[1];
  28807. this.build();
  28808. if (this.isEmpty()) {
  28809. return null;
  28810. }
  28811. if (this.getIntersectsOp().intersects(this._root.getBounds(), searchBounds$1)) {
  28812. this.query(searchBounds$1, this._root, visitor);
  28813. }
  28814. } else if (arguments.length === 3) {
  28815. if (hasInterface(arguments[2], ItemVisitor) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
  28816. var searchBounds$2 = arguments[0];
  28817. var node = arguments[1];
  28818. var visitor$1 = arguments[2];
  28819. var childBoundables = node.getChildBoundables();
  28820. for (var i = 0; i < childBoundables.size(); i++) {
  28821. var childBoundable = childBoundables.get(i);
  28822. if (!this$1.getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds$2)) {
  28823. continue;
  28824. }
  28825. if (childBoundable instanceof AbstractNode) {
  28826. this$1.query(searchBounds$2, childBoundable, visitor$1);
  28827. } else if (childBoundable instanceof ItemBoundable) {
  28828. visitor$1.visitItem(childBoundable.getItem());
  28829. } else {
  28830. Assert.shouldNeverReachHere();
  28831. }
  28832. }
  28833. } else if (hasInterface(arguments[2], List) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
  28834. var searchBounds$3 = arguments[0];
  28835. var node$1 = arguments[1];
  28836. var matches$1 = arguments[2];
  28837. var childBoundables$1 = node$1.getChildBoundables();
  28838. for (var i$1 = 0; i$1 < childBoundables$1.size(); i$1++) {
  28839. var childBoundable$1 = childBoundables$1.get(i$1);
  28840. if (!this$1.getIntersectsOp().intersects(childBoundable$1.getBounds(), searchBounds$3)) {
  28841. continue;
  28842. }
  28843. if (childBoundable$1 instanceof AbstractNode) {
  28844. this$1.query(searchBounds$3, childBoundable$1, matches$1);
  28845. } else if (childBoundable$1 instanceof ItemBoundable) {
  28846. matches$1.add(childBoundable$1.getItem());
  28847. } else {
  28848. Assert.shouldNeverReachHere();
  28849. }
  28850. }
  28851. }
  28852. }
  28853. };
  28854. AbstractSTRtree.prototype.build = function build() {
  28855. if (this._built) {
  28856. return null;
  28857. }
  28858. this._root = this._itemBoundables.isEmpty() ? this.createNode(0) : this.createHigherLevels(this._itemBoundables, -1);
  28859. this._itemBoundables = null;
  28860. this._built = true;
  28861. };
  28862. AbstractSTRtree.prototype.getRoot = function getRoot() {
  28863. this.build();
  28864. return this._root;
  28865. };
  28866. AbstractSTRtree.prototype.remove = function remove4() {
  28867. var this$1 = this;
  28868. if (arguments.length === 2) {
  28869. var searchBounds = arguments[0];
  28870. var item = arguments[1];
  28871. this.build();
  28872. if (this.getIntersectsOp().intersects(this._root.getBounds(), searchBounds)) {
  28873. return this.remove(searchBounds, this._root, item);
  28874. }
  28875. return false;
  28876. } else if (arguments.length === 3) {
  28877. var searchBounds$1 = arguments[0];
  28878. var node = arguments[1];
  28879. var item$1 = arguments[2];
  28880. var found = this.removeItem(node, item$1);
  28881. if (found) {
  28882. return true;
  28883. }
  28884. var childToPrune = null;
  28885. for (var i = node.getChildBoundables().iterator(); i.hasNext(); ) {
  28886. var childBoundable = i.next();
  28887. if (!this$1.getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds$1)) {
  28888. continue;
  28889. }
  28890. if (childBoundable instanceof AbstractNode) {
  28891. found = this$1.remove(searchBounds$1, childBoundable, item$1);
  28892. if (found) {
  28893. childToPrune = childBoundable;
  28894. break;
  28895. }
  28896. }
  28897. }
  28898. if (childToPrune !== null) {
  28899. if (childToPrune.getChildBoundables().isEmpty()) {
  28900. node.getChildBoundables().remove(childToPrune);
  28901. }
  28902. }
  28903. return found;
  28904. }
  28905. };
  28906. AbstractSTRtree.prototype.createHigherLevels = function createHigherLevels(boundablesOfALevel, level) {
  28907. Assert.isTrue(!boundablesOfALevel.isEmpty());
  28908. var parentBoundables = this.createParentBoundables(boundablesOfALevel, level + 1);
  28909. if (parentBoundables.size() === 1) {
  28910. return parentBoundables.get(0);
  28911. }
  28912. return this.createHigherLevels(parentBoundables, level + 1);
  28913. };
  28914. AbstractSTRtree.prototype.depth = function depth() {
  28915. var this$1 = this;
  28916. if (arguments.length === 0) {
  28917. if (this.isEmpty()) {
  28918. return 0;
  28919. }
  28920. this.build();
  28921. return this.depth(this._root);
  28922. } else if (arguments.length === 1) {
  28923. var node = arguments[0];
  28924. var maxChildDepth = 0;
  28925. for (var i = node.getChildBoundables().iterator(); i.hasNext(); ) {
  28926. var childBoundable = i.next();
  28927. if (childBoundable instanceof AbstractNode) {
  28928. var childDepth = this$1.depth(childBoundable);
  28929. if (childDepth > maxChildDepth) {
  28930. maxChildDepth = childDepth;
  28931. }
  28932. }
  28933. }
  28934. return maxChildDepth + 1;
  28935. }
  28936. };
  28937. AbstractSTRtree.prototype.createParentBoundables = function createParentBoundables(childBoundables, newLevel) {
  28938. var this$1 = this;
  28939. Assert.isTrue(!childBoundables.isEmpty());
  28940. var parentBoundables = new ArrayList();
  28941. parentBoundables.add(this.createNode(newLevel));
  28942. var sortedChildBoundables = new ArrayList(childBoundables);
  28943. Collections.sort(sortedChildBoundables, this.getComparator());
  28944. for (var i = sortedChildBoundables.iterator(); i.hasNext(); ) {
  28945. var childBoundable = i.next();
  28946. if (this$1.lastNode(parentBoundables).getChildBoundables().size() === this$1.getNodeCapacity()) {
  28947. parentBoundables.add(this$1.createNode(newLevel));
  28948. }
  28949. this$1.lastNode(parentBoundables).addChildBoundable(childBoundable);
  28950. }
  28951. return parentBoundables;
  28952. };
  28953. AbstractSTRtree.prototype.isEmpty = function isEmpty5() {
  28954. if (!this._built) {
  28955. return this._itemBoundables.isEmpty();
  28956. }
  28957. return this._root.isEmpty();
  28958. };
  28959. AbstractSTRtree.prototype.interfaces_ = function interfaces_68() {
  28960. return [Serializable];
  28961. };
  28962. AbstractSTRtree.prototype.getClass = function getClass67() {
  28963. return AbstractSTRtree;
  28964. };
  28965. AbstractSTRtree.compareDoubles = function compareDoubles(a, b) {
  28966. return a > b ? 1 : a < b ? -1 : 0;
  28967. };
  28968. staticAccessors$23.IntersectsOp.get = function() {
  28969. return IntersectsOp;
  28970. };
  28971. staticAccessors$23.serialVersionUID.get = function() {
  28972. return -3886435814360241e3;
  28973. };
  28974. staticAccessors$23.DEFAULT_NODE_CAPACITY.get = function() {
  28975. return 10;
  28976. };
  28977. Object.defineProperties(AbstractSTRtree, staticAccessors$23);
  28978. var IntersectsOp = function IntersectsOp2() {
  28979. };
  28980. var ItemDistance = function ItemDistance2() {
  28981. };
  28982. ItemDistance.prototype.distance = function distance5(item1, item2) {
  28983. };
  28984. ItemDistance.prototype.interfaces_ = function interfaces_69() {
  28985. return [];
  28986. };
  28987. ItemDistance.prototype.getClass = function getClass68() {
  28988. return ItemDistance;
  28989. };
  28990. var STRtree = function(AbstractSTRtree$$1) {
  28991. function STRtree2(nodeCapacity) {
  28992. nodeCapacity = nodeCapacity || STRtree2.DEFAULT_NODE_CAPACITY;
  28993. AbstractSTRtree$$1.call(this, nodeCapacity);
  28994. }
  28995. if (AbstractSTRtree$$1)
  28996. STRtree2.__proto__ = AbstractSTRtree$$1;
  28997. STRtree2.prototype = Object.create(AbstractSTRtree$$1 && AbstractSTRtree$$1.prototype);
  28998. STRtree2.prototype.constructor = STRtree2;
  28999. var staticAccessors2 = { STRtreeNode: { configurable: true }, serialVersionUID: { configurable: true }, xComparator: { configurable: true }, yComparator: { configurable: true }, intersectsOp: { configurable: true }, DEFAULT_NODE_CAPACITY: { configurable: true } };
  29000. STRtree2.prototype.createParentBoundablesFromVerticalSlices = function createParentBoundablesFromVerticalSlices(verticalSlices, newLevel) {
  29001. var this$1 = this;
  29002. Assert.isTrue(verticalSlices.length > 0);
  29003. var parentBoundables = new ArrayList();
  29004. for (var i = 0; i < verticalSlices.length; i++) {
  29005. parentBoundables.addAll(this$1.createParentBoundablesFromVerticalSlice(verticalSlices[i], newLevel));
  29006. }
  29007. return parentBoundables;
  29008. };
  29009. STRtree2.prototype.createNode = function createNode2(level) {
  29010. return new STRtreeNode(level);
  29011. };
  29012. STRtree2.prototype.size = function size11() {
  29013. if (arguments.length === 0) {
  29014. return AbstractSTRtree$$1.prototype.size.call(this);
  29015. } else {
  29016. return AbstractSTRtree$$1.prototype.size.apply(this, arguments);
  29017. }
  29018. };
  29019. STRtree2.prototype.insert = function insert5() {
  29020. if (arguments.length === 2) {
  29021. var itemEnv = arguments[0];
  29022. var item = arguments[1];
  29023. if (itemEnv.isNull()) {
  29024. return null;
  29025. }
  29026. AbstractSTRtree$$1.prototype.insert.call(this, itemEnv, item);
  29027. } else {
  29028. return AbstractSTRtree$$1.prototype.insert.apply(this, arguments);
  29029. }
  29030. };
  29031. STRtree2.prototype.getIntersectsOp = function getIntersectsOp() {
  29032. return STRtree2.intersectsOp;
  29033. };
  29034. STRtree2.prototype.verticalSlices = function verticalSlices(childBoundables, sliceCount) {
  29035. var sliceCapacity = Math.trunc(Math.ceil(childBoundables.size() / sliceCount));
  29036. var slices = new Array(sliceCount).fill(null);
  29037. var i = childBoundables.iterator();
  29038. for (var j = 0; j < sliceCount; j++) {
  29039. slices[j] = new ArrayList();
  29040. var boundablesAddedToSlice = 0;
  29041. while (i.hasNext() && boundablesAddedToSlice < sliceCapacity) {
  29042. var childBoundable = i.next();
  29043. slices[j].add(childBoundable);
  29044. boundablesAddedToSlice++;
  29045. }
  29046. }
  29047. return slices;
  29048. };
  29049. STRtree2.prototype.query = function query5() {
  29050. if (arguments.length === 1) {
  29051. var searchEnv = arguments[0];
  29052. return AbstractSTRtree$$1.prototype.query.call(this, searchEnv);
  29053. } else if (arguments.length === 2) {
  29054. var searchEnv$1 = arguments[0];
  29055. var visitor = arguments[1];
  29056. AbstractSTRtree$$1.prototype.query.call(this, searchEnv$1, visitor);
  29057. } else if (arguments.length === 3) {
  29058. if (hasInterface(arguments[2], ItemVisitor) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
  29059. var searchBounds = arguments[0];
  29060. var node = arguments[1];
  29061. var visitor$1 = arguments[2];
  29062. AbstractSTRtree$$1.prototype.query.call(this, searchBounds, node, visitor$1);
  29063. } else if (hasInterface(arguments[2], List) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
  29064. var searchBounds$1 = arguments[0];
  29065. var node$1 = arguments[1];
  29066. var matches = arguments[2];
  29067. AbstractSTRtree$$1.prototype.query.call(this, searchBounds$1, node$1, matches);
  29068. }
  29069. }
  29070. };
  29071. STRtree2.prototype.getComparator = function getComparator() {
  29072. return STRtree2.yComparator;
  29073. };
  29074. STRtree2.prototype.createParentBoundablesFromVerticalSlice = function createParentBoundablesFromVerticalSlice(childBoundables, newLevel) {
  29075. return AbstractSTRtree$$1.prototype.createParentBoundables.call(this, childBoundables, newLevel);
  29076. };
  29077. STRtree2.prototype.remove = function remove6() {
  29078. if (arguments.length === 2) {
  29079. var itemEnv = arguments[0];
  29080. var item = arguments[1];
  29081. return AbstractSTRtree$$1.prototype.remove.call(this, itemEnv, item);
  29082. } else {
  29083. return AbstractSTRtree$$1.prototype.remove.apply(this, arguments);
  29084. }
  29085. };
  29086. STRtree2.prototype.depth = function depth2() {
  29087. if (arguments.length === 0) {
  29088. return AbstractSTRtree$$1.prototype.depth.call(this);
  29089. } else {
  29090. return AbstractSTRtree$$1.prototype.depth.apply(this, arguments);
  29091. }
  29092. };
  29093. STRtree2.prototype.createParentBoundables = function createParentBoundables2(childBoundables, newLevel) {
  29094. Assert.isTrue(!childBoundables.isEmpty());
  29095. var minLeafCount = Math.trunc(Math.ceil(childBoundables.size() / this.getNodeCapacity()));
  29096. var sortedChildBoundables = new ArrayList(childBoundables);
  29097. Collections.sort(sortedChildBoundables, STRtree2.xComparator);
  29098. var verticalSlices = this.verticalSlices(sortedChildBoundables, Math.trunc(Math.ceil(Math.sqrt(minLeafCount))));
  29099. return this.createParentBoundablesFromVerticalSlices(verticalSlices, newLevel);
  29100. };
  29101. STRtree2.prototype.nearestNeighbour = function nearestNeighbour() {
  29102. if (arguments.length === 1) {
  29103. if (hasInterface(arguments[0], ItemDistance)) {
  29104. var itemDist = arguments[0];
  29105. var bp = new BoundablePair(this.getRoot(), this.getRoot(), itemDist);
  29106. return this.nearestNeighbour(bp);
  29107. } else if (arguments[0] instanceof BoundablePair) {
  29108. var initBndPair = arguments[0];
  29109. return this.nearestNeighbour(initBndPair, Double.POSITIVE_INFINITY);
  29110. }
  29111. } else if (arguments.length === 2) {
  29112. if (arguments[0] instanceof STRtree2 && hasInterface(arguments[1], ItemDistance)) {
  29113. var tree = arguments[0];
  29114. var itemDist$1 = arguments[1];
  29115. var bp$1 = new BoundablePair(this.getRoot(), tree.getRoot(), itemDist$1);
  29116. return this.nearestNeighbour(bp$1);
  29117. } else if (arguments[0] instanceof BoundablePair && typeof arguments[1] === "number") {
  29118. var initBndPair$1 = arguments[0];
  29119. var maxDistance = arguments[1];
  29120. var distanceLowerBound = maxDistance;
  29121. var minPair = null;
  29122. var priQ = new PriorityQueue();
  29123. priQ.add(initBndPair$1);
  29124. while (!priQ.isEmpty() && distanceLowerBound > 0) {
  29125. var bndPair = priQ.poll();
  29126. var currentDistance = bndPair.getDistance();
  29127. if (currentDistance >= distanceLowerBound) {
  29128. break;
  29129. }
  29130. if (bndPair.isLeaves()) {
  29131. distanceLowerBound = currentDistance;
  29132. minPair = bndPair;
  29133. } else {
  29134. bndPair.expandToQueue(priQ, distanceLowerBound);
  29135. }
  29136. }
  29137. return [minPair.getBoundable(0).getItem(), minPair.getBoundable(1).getItem()];
  29138. }
  29139. } else if (arguments.length === 3) {
  29140. var env = arguments[0];
  29141. var item = arguments[1];
  29142. var itemDist$2 = arguments[2];
  29143. var bnd = new ItemBoundable(env, item);
  29144. var bp$2 = new BoundablePair(this.getRoot(), bnd, itemDist$2);
  29145. return this.nearestNeighbour(bp$2)[0];
  29146. }
  29147. };
  29148. STRtree2.prototype.interfaces_ = function interfaces_170() {
  29149. return [SpatialIndex, Serializable];
  29150. };
  29151. STRtree2.prototype.getClass = function getClass169() {
  29152. return STRtree2;
  29153. };
  29154. STRtree2.centreX = function centreX(e) {
  29155. return STRtree2.avg(e.getMinX(), e.getMaxX());
  29156. };
  29157. STRtree2.avg = function avg(a, b) {
  29158. return (a + b) / 2;
  29159. };
  29160. STRtree2.centreY = function centreY(e) {
  29161. return STRtree2.avg(e.getMinY(), e.getMaxY());
  29162. };
  29163. staticAccessors2.STRtreeNode.get = function() {
  29164. return STRtreeNode;
  29165. };
  29166. staticAccessors2.serialVersionUID.get = function() {
  29167. return 259274702368956900;
  29168. };
  29169. staticAccessors2.xComparator.get = function() {
  29170. return {
  29171. interfaces_: function() {
  29172. return [Comparator];
  29173. },
  29174. compare: function(o1, o2) {
  29175. return AbstractSTRtree$$1.compareDoubles(STRtree2.centreX(o1.getBounds()), STRtree2.centreX(o2.getBounds()));
  29176. }
  29177. };
  29178. };
  29179. staticAccessors2.yComparator.get = function() {
  29180. return {
  29181. interfaces_: function() {
  29182. return [Comparator];
  29183. },
  29184. compare: function(o1, o2) {
  29185. return AbstractSTRtree$$1.compareDoubles(STRtree2.centreY(o1.getBounds()), STRtree2.centreY(o2.getBounds()));
  29186. }
  29187. };
  29188. };
  29189. staticAccessors2.intersectsOp.get = function() {
  29190. return {
  29191. interfaces_: function() {
  29192. return [AbstractSTRtree$$1.IntersectsOp];
  29193. },
  29194. intersects: function(aBounds, bBounds) {
  29195. return aBounds.intersects(bBounds);
  29196. }
  29197. };
  29198. };
  29199. staticAccessors2.DEFAULT_NODE_CAPACITY.get = function() {
  29200. return 10;
  29201. };
  29202. Object.defineProperties(STRtree2, staticAccessors2);
  29203. return STRtree2;
  29204. }(AbstractSTRtree);
  29205. var STRtreeNode = function(AbstractNode$$1) {
  29206. function STRtreeNode2() {
  29207. var level = arguments[0];
  29208. AbstractNode$$1.call(this, level);
  29209. }
  29210. if (AbstractNode$$1)
  29211. STRtreeNode2.__proto__ = AbstractNode$$1;
  29212. STRtreeNode2.prototype = Object.create(AbstractNode$$1 && AbstractNode$$1.prototype);
  29213. STRtreeNode2.prototype.constructor = STRtreeNode2;
  29214. STRtreeNode2.prototype.computeBounds = function computeBounds() {
  29215. var bounds = null;
  29216. for (var i = this.getChildBoundables().iterator(); i.hasNext(); ) {
  29217. var childBoundable = i.next();
  29218. if (bounds === null) {
  29219. bounds = new Envelope(childBoundable.getBounds());
  29220. } else {
  29221. bounds.expandToInclude(childBoundable.getBounds());
  29222. }
  29223. }
  29224. return bounds;
  29225. };
  29226. STRtreeNode2.prototype.interfaces_ = function interfaces_170() {
  29227. return [];
  29228. };
  29229. STRtreeNode2.prototype.getClass = function getClass169() {
  29230. return STRtreeNode2;
  29231. };
  29232. return STRtreeNode2;
  29233. }(AbstractNode);
  29234. var SegmentPointComparator = function SegmentPointComparator2() {
  29235. };
  29236. SegmentPointComparator.prototype.interfaces_ = function interfaces_70() {
  29237. return [];
  29238. };
  29239. SegmentPointComparator.prototype.getClass = function getClass69() {
  29240. return SegmentPointComparator;
  29241. };
  29242. SegmentPointComparator.relativeSign = function relativeSign(x02, x12) {
  29243. if (x02 < x12) {
  29244. return -1;
  29245. }
  29246. if (x02 > x12) {
  29247. return 1;
  29248. }
  29249. return 0;
  29250. };
  29251. SegmentPointComparator.compare = function compare7(octant2, p0, p1) {
  29252. if (p0.equals2D(p1)) {
  29253. return 0;
  29254. }
  29255. var xSign = SegmentPointComparator.relativeSign(p0.x, p1.x);
  29256. var ySign = SegmentPointComparator.relativeSign(p0.y, p1.y);
  29257. switch (octant2) {
  29258. case 0:
  29259. return SegmentPointComparator.compareValue(xSign, ySign);
  29260. case 1:
  29261. return SegmentPointComparator.compareValue(ySign, xSign);
  29262. case 2:
  29263. return SegmentPointComparator.compareValue(ySign, -xSign);
  29264. case 3:
  29265. return SegmentPointComparator.compareValue(-xSign, ySign);
  29266. case 4:
  29267. return SegmentPointComparator.compareValue(-xSign, -ySign);
  29268. case 5:
  29269. return SegmentPointComparator.compareValue(-ySign, -xSign);
  29270. case 6:
  29271. return SegmentPointComparator.compareValue(-ySign, xSign);
  29272. case 7:
  29273. return SegmentPointComparator.compareValue(xSign, -ySign);
  29274. default:
  29275. }
  29276. Assert.shouldNeverReachHere("invalid octant value");
  29277. return 0;
  29278. };
  29279. SegmentPointComparator.compareValue = function compareValue(compareSign0, compareSign1) {
  29280. if (compareSign0 < 0) {
  29281. return -1;
  29282. }
  29283. if (compareSign0 > 0) {
  29284. return 1;
  29285. }
  29286. if (compareSign1 < 0) {
  29287. return -1;
  29288. }
  29289. if (compareSign1 > 0) {
  29290. return 1;
  29291. }
  29292. return 0;
  29293. };
  29294. var SegmentNode = function SegmentNode2() {
  29295. this._segString = null;
  29296. this.coord = null;
  29297. this.segmentIndex = null;
  29298. this._segmentOctant = null;
  29299. this._isInterior = null;
  29300. var segString = arguments[0];
  29301. var coord = arguments[1];
  29302. var segmentIndex = arguments[2];
  29303. var segmentOctant = arguments[3];
  29304. this._segString = segString;
  29305. this.coord = new Coordinate(coord);
  29306. this.segmentIndex = segmentIndex;
  29307. this._segmentOctant = segmentOctant;
  29308. this._isInterior = !coord.equals2D(segString.getCoordinate(segmentIndex));
  29309. };
  29310. SegmentNode.prototype.getCoordinate = function getCoordinate7() {
  29311. return this.coord;
  29312. };
  29313. SegmentNode.prototype.print = function print3(out) {
  29314. out.print(this.coord);
  29315. out.print(" seg # = " + this.segmentIndex);
  29316. };
  29317. SegmentNode.prototype.compareTo = function compareTo10(obj) {
  29318. var other = obj;
  29319. if (this.segmentIndex < other.segmentIndex) {
  29320. return -1;
  29321. }
  29322. if (this.segmentIndex > other.segmentIndex) {
  29323. return 1;
  29324. }
  29325. if (this.coord.equals2D(other.coord)) {
  29326. return 0;
  29327. }
  29328. return SegmentPointComparator.compare(this._segmentOctant, this.coord, other.coord);
  29329. };
  29330. SegmentNode.prototype.isEndPoint = function isEndPoint2(maxSegmentIndex) {
  29331. if (this.segmentIndex === 0 && !this._isInterior) {
  29332. return true;
  29333. }
  29334. if (this.segmentIndex === maxSegmentIndex) {
  29335. return true;
  29336. }
  29337. return false;
  29338. };
  29339. SegmentNode.prototype.isInterior = function isInterior() {
  29340. return this._isInterior;
  29341. };
  29342. SegmentNode.prototype.interfaces_ = function interfaces_71() {
  29343. return [Comparable];
  29344. };
  29345. SegmentNode.prototype.getClass = function getClass70() {
  29346. return SegmentNode;
  29347. };
  29348. var SegmentNodeList = function SegmentNodeList2() {
  29349. this._nodeMap = new TreeMap();
  29350. this._edge = null;
  29351. var edge = arguments[0];
  29352. this._edge = edge;
  29353. };
  29354. SegmentNodeList.prototype.getSplitCoordinates = function getSplitCoordinates() {
  29355. var this$1 = this;
  29356. var coordList = new CoordinateList();
  29357. this.addEndpoints();
  29358. var it = this.iterator();
  29359. var eiPrev = it.next();
  29360. while (it.hasNext()) {
  29361. var ei = it.next();
  29362. this$1.addEdgeCoordinates(eiPrev, ei, coordList);
  29363. eiPrev = ei;
  29364. }
  29365. return coordList.toCoordinateArray();
  29366. };
  29367. SegmentNodeList.prototype.addCollapsedNodes = function addCollapsedNodes() {
  29368. var this$1 = this;
  29369. var collapsedVertexIndexes = new ArrayList();
  29370. this.findCollapsesFromInsertedNodes(collapsedVertexIndexes);
  29371. this.findCollapsesFromExistingVertices(collapsedVertexIndexes);
  29372. for (var it = collapsedVertexIndexes.iterator(); it.hasNext(); ) {
  29373. var vertexIndex = it.next().intValue();
  29374. this$1.add(this$1._edge.getCoordinate(vertexIndex), vertexIndex);
  29375. }
  29376. };
  29377. SegmentNodeList.prototype.print = function print4(out) {
  29378. out.println("Intersections:");
  29379. for (var it = this.iterator(); it.hasNext(); ) {
  29380. var ei = it.next();
  29381. ei.print(out);
  29382. }
  29383. };
  29384. SegmentNodeList.prototype.findCollapsesFromExistingVertices = function findCollapsesFromExistingVertices(collapsedVertexIndexes) {
  29385. var this$1 = this;
  29386. for (var i = 0; i < this._edge.size() - 2; i++) {
  29387. var p0 = this$1._edge.getCoordinate(i);
  29388. var p2 = this$1._edge.getCoordinate(i + 2);
  29389. if (p0.equals2D(p2)) {
  29390. collapsedVertexIndexes.add(new Integer(i + 1));
  29391. }
  29392. }
  29393. };
  29394. SegmentNodeList.prototype.addEdgeCoordinates = function addEdgeCoordinates(ei0, ei1, coordList) {
  29395. var this$1 = this;
  29396. var lastSegStartPt = this._edge.getCoordinate(ei1.segmentIndex);
  29397. var useIntPt1 = ei1.isInterior() || !ei1.coord.equals2D(lastSegStartPt);
  29398. coordList.add(new Coordinate(ei0.coord), false);
  29399. for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
  29400. coordList.add(this$1._edge.getCoordinate(i));
  29401. }
  29402. if (useIntPt1) {
  29403. coordList.add(new Coordinate(ei1.coord));
  29404. }
  29405. };
  29406. SegmentNodeList.prototype.iterator = function iterator3() {
  29407. return this._nodeMap.values().iterator();
  29408. };
  29409. SegmentNodeList.prototype.addSplitEdges = function addSplitEdges(edgeList) {
  29410. var this$1 = this;
  29411. this.addEndpoints();
  29412. this.addCollapsedNodes();
  29413. var it = this.iterator();
  29414. var eiPrev = it.next();
  29415. while (it.hasNext()) {
  29416. var ei = it.next();
  29417. var newEdge = this$1.createSplitEdge(eiPrev, ei);
  29418. edgeList.add(newEdge);
  29419. eiPrev = ei;
  29420. }
  29421. };
  29422. SegmentNodeList.prototype.findCollapseIndex = function findCollapseIndex(ei0, ei1, collapsedVertexIndex) {
  29423. if (!ei0.coord.equals2D(ei1.coord)) {
  29424. return false;
  29425. }
  29426. var numVerticesBetween = ei1.segmentIndex - ei0.segmentIndex;
  29427. if (!ei1.isInterior()) {
  29428. numVerticesBetween--;
  29429. }
  29430. if (numVerticesBetween === 1) {
  29431. collapsedVertexIndex[0] = ei0.segmentIndex + 1;
  29432. return true;
  29433. }
  29434. return false;
  29435. };
  29436. SegmentNodeList.prototype.findCollapsesFromInsertedNodes = function findCollapsesFromInsertedNodes(collapsedVertexIndexes) {
  29437. var this$1 = this;
  29438. var collapsedVertexIndex = new Array(1).fill(null);
  29439. var it = this.iterator();
  29440. var eiPrev = it.next();
  29441. while (it.hasNext()) {
  29442. var ei = it.next();
  29443. var isCollapsed = this$1.findCollapseIndex(eiPrev, ei, collapsedVertexIndex);
  29444. if (isCollapsed) {
  29445. collapsedVertexIndexes.add(new Integer(collapsedVertexIndex[0]));
  29446. }
  29447. eiPrev = ei;
  29448. }
  29449. };
  29450. SegmentNodeList.prototype.getEdge = function getEdge3() {
  29451. return this._edge;
  29452. };
  29453. SegmentNodeList.prototype.addEndpoints = function addEndpoints() {
  29454. var maxSegIndex = this._edge.size() - 1;
  29455. this.add(this._edge.getCoordinate(0), 0);
  29456. this.add(this._edge.getCoordinate(maxSegIndex), maxSegIndex);
  29457. };
  29458. SegmentNodeList.prototype.createSplitEdge = function createSplitEdge(ei0, ei1) {
  29459. var this$1 = this;
  29460. var npts = ei1.segmentIndex - ei0.segmentIndex + 2;
  29461. var lastSegStartPt = this._edge.getCoordinate(ei1.segmentIndex);
  29462. var useIntPt1 = ei1.isInterior() || !ei1.coord.equals2D(lastSegStartPt);
  29463. if (!useIntPt1) {
  29464. npts--;
  29465. }
  29466. var pts = new Array(npts).fill(null);
  29467. var ipt = 0;
  29468. pts[ipt++] = new Coordinate(ei0.coord);
  29469. for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
  29470. pts[ipt++] = this$1._edge.getCoordinate(i);
  29471. }
  29472. if (useIntPt1) {
  29473. pts[ipt] = new Coordinate(ei1.coord);
  29474. }
  29475. return new NodedSegmentString(pts, this._edge.getData());
  29476. };
  29477. SegmentNodeList.prototype.add = function add9(intPt, segmentIndex) {
  29478. var eiNew = new SegmentNode(this._edge, intPt, segmentIndex, this._edge.getSegmentOctant(segmentIndex));
  29479. var ei = this._nodeMap.get(eiNew);
  29480. if (ei !== null) {
  29481. Assert.isTrue(ei.coord.equals2D(intPt), "Found equal nodes with different coordinates");
  29482. return ei;
  29483. }
  29484. this._nodeMap.put(eiNew, eiNew);
  29485. return eiNew;
  29486. };
  29487. SegmentNodeList.prototype.checkSplitEdgesCorrectness = function checkSplitEdgesCorrectness(splitEdges) {
  29488. var edgePts = this._edge.getCoordinates();
  29489. var split0 = splitEdges.get(0);
  29490. var pt0 = split0.getCoordinate(0);
  29491. if (!pt0.equals2D(edgePts[0])) {
  29492. throw new RuntimeException("bad split edge start point at " + pt0);
  29493. }
  29494. var splitn = splitEdges.get(splitEdges.size() - 1);
  29495. var splitnPts = splitn.getCoordinates();
  29496. var ptn = splitnPts[splitnPts.length - 1];
  29497. if (!ptn.equals2D(edgePts[edgePts.length - 1])) {
  29498. throw new RuntimeException("bad split edge end point at " + ptn);
  29499. }
  29500. };
  29501. SegmentNodeList.prototype.interfaces_ = function interfaces_72() {
  29502. return [];
  29503. };
  29504. SegmentNodeList.prototype.getClass = function getClass71() {
  29505. return SegmentNodeList;
  29506. };
  29507. var Octant = function Octant2() {
  29508. };
  29509. Octant.prototype.interfaces_ = function interfaces_73() {
  29510. return [];
  29511. };
  29512. Octant.prototype.getClass = function getClass72() {
  29513. return Octant;
  29514. };
  29515. Octant.octant = function octant() {
  29516. if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
  29517. var dx = arguments[0];
  29518. var dy = arguments[1];
  29519. if (dx === 0 && dy === 0) {
  29520. throw new IllegalArgumentException("Cannot compute the octant for point ( " + dx + ", " + dy + " )");
  29521. }
  29522. var adx = Math.abs(dx);
  29523. var ady = Math.abs(dy);
  29524. if (dx >= 0) {
  29525. if (dy >= 0) {
  29526. if (adx >= ady) {
  29527. return 0;
  29528. } else {
  29529. return 1;
  29530. }
  29531. } else {
  29532. if (adx >= ady) {
  29533. return 7;
  29534. } else {
  29535. return 6;
  29536. }
  29537. }
  29538. } else {
  29539. if (dy >= 0) {
  29540. if (adx >= ady) {
  29541. return 3;
  29542. } else {
  29543. return 2;
  29544. }
  29545. } else {
  29546. if (adx >= ady) {
  29547. return 4;
  29548. } else {
  29549. return 5;
  29550. }
  29551. }
  29552. }
  29553. } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Coordinate) {
  29554. var p0 = arguments[0];
  29555. var p1 = arguments[1];
  29556. var dx$1 = p1.x - p0.x;
  29557. var dy$1 = p1.y - p0.y;
  29558. if (dx$1 === 0 && dy$1 === 0) {
  29559. throw new IllegalArgumentException("Cannot compute the octant for two identical points " + p0);
  29560. }
  29561. return Octant.octant(dx$1, dy$1);
  29562. }
  29563. };
  29564. var SegmentString = function SegmentString2() {
  29565. };
  29566. SegmentString.prototype.getCoordinates = function getCoordinates() {
  29567. };
  29568. SegmentString.prototype.size = function size8() {
  29569. };
  29570. SegmentString.prototype.getCoordinate = function getCoordinate8(i) {
  29571. };
  29572. SegmentString.prototype.isClosed = function isClosed() {
  29573. };
  29574. SegmentString.prototype.setData = function setData(data) {
  29575. };
  29576. SegmentString.prototype.getData = function getData() {
  29577. };
  29578. SegmentString.prototype.interfaces_ = function interfaces_74() {
  29579. return [];
  29580. };
  29581. SegmentString.prototype.getClass = function getClass73() {
  29582. return SegmentString;
  29583. };
  29584. var NodableSegmentString = function NodableSegmentString2() {
  29585. };
  29586. NodableSegmentString.prototype.addIntersection = function addIntersection(intPt, segmentIndex) {
  29587. };
  29588. NodableSegmentString.prototype.interfaces_ = function interfaces_75() {
  29589. return [SegmentString];
  29590. };
  29591. NodableSegmentString.prototype.getClass = function getClass74() {
  29592. return NodableSegmentString;
  29593. };
  29594. var NodedSegmentString = function NodedSegmentString2() {
  29595. this._nodeList = new SegmentNodeList(this);
  29596. this._pts = null;
  29597. this._data = null;
  29598. var pts = arguments[0];
  29599. var data = arguments[1];
  29600. this._pts = pts;
  29601. this._data = data;
  29602. };
  29603. NodedSegmentString.prototype.getCoordinates = function getCoordinates2() {
  29604. return this._pts;
  29605. };
  29606. NodedSegmentString.prototype.size = function size9() {
  29607. return this._pts.length;
  29608. };
  29609. NodedSegmentString.prototype.getCoordinate = function getCoordinate9(i) {
  29610. return this._pts[i];
  29611. };
  29612. NodedSegmentString.prototype.isClosed = function isClosed2() {
  29613. return this._pts[0].equals(this._pts[this._pts.length - 1]);
  29614. };
  29615. NodedSegmentString.prototype.getSegmentOctant = function getSegmentOctant(index2) {
  29616. if (index2 === this._pts.length - 1) {
  29617. return -1;
  29618. }
  29619. return this.safeOctant(this.getCoordinate(index2), this.getCoordinate(index2 + 1));
  29620. };
  29621. NodedSegmentString.prototype.setData = function setData2(data) {
  29622. this._data = data;
  29623. };
  29624. NodedSegmentString.prototype.safeOctant = function safeOctant(p0, p1) {
  29625. if (p0.equals2D(p1)) {
  29626. return 0;
  29627. }
  29628. return Octant.octant(p0, p1);
  29629. };
  29630. NodedSegmentString.prototype.getData = function getData2() {
  29631. return this._data;
  29632. };
  29633. NodedSegmentString.prototype.addIntersection = function addIntersection2() {
  29634. if (arguments.length === 2) {
  29635. var intPt$1 = arguments[0];
  29636. var segmentIndex = arguments[1];
  29637. this.addIntersectionNode(intPt$1, segmentIndex);
  29638. } else if (arguments.length === 4) {
  29639. var li = arguments[0];
  29640. var segmentIndex$1 = arguments[1];
  29641. var intIndex = arguments[3];
  29642. var intPt = new Coordinate(li.getIntersection(intIndex));
  29643. this.addIntersection(intPt, segmentIndex$1);
  29644. }
  29645. };
  29646. NodedSegmentString.prototype.toString = function toString14() {
  29647. return WKTWriter.toLineString(new CoordinateArraySequence(this._pts));
  29648. };
  29649. NodedSegmentString.prototype.getNodeList = function getNodeList() {
  29650. return this._nodeList;
  29651. };
  29652. NodedSegmentString.prototype.addIntersectionNode = function addIntersectionNode(intPt, segmentIndex) {
  29653. var normalizedSegmentIndex = segmentIndex;
  29654. var nextSegIndex = normalizedSegmentIndex + 1;
  29655. if (nextSegIndex < this._pts.length) {
  29656. var nextPt = this._pts[nextSegIndex];
  29657. if (intPt.equals2D(nextPt)) {
  29658. normalizedSegmentIndex = nextSegIndex;
  29659. }
  29660. }
  29661. var ei = this._nodeList.add(intPt, normalizedSegmentIndex);
  29662. return ei;
  29663. };
  29664. NodedSegmentString.prototype.addIntersections = function addIntersections(li, segmentIndex, geomIndex) {
  29665. var this$1 = this;
  29666. for (var i = 0; i < li.getIntersectionNum(); i++) {
  29667. this$1.addIntersection(li, segmentIndex, geomIndex, i);
  29668. }
  29669. };
  29670. NodedSegmentString.prototype.interfaces_ = function interfaces_76() {
  29671. return [NodableSegmentString];
  29672. };
  29673. NodedSegmentString.prototype.getClass = function getClass75() {
  29674. return NodedSegmentString;
  29675. };
  29676. NodedSegmentString.getNodedSubstrings = function getNodedSubstrings() {
  29677. if (arguments.length === 1) {
  29678. var segStrings = arguments[0];
  29679. var resultEdgelist = new ArrayList();
  29680. NodedSegmentString.getNodedSubstrings(segStrings, resultEdgelist);
  29681. return resultEdgelist;
  29682. } else if (arguments.length === 2) {
  29683. var segStrings$1 = arguments[0];
  29684. var resultEdgelist$1 = arguments[1];
  29685. for (var i = segStrings$1.iterator(); i.hasNext(); ) {
  29686. var ss = i.next();
  29687. ss.getNodeList().addSplitEdges(resultEdgelist$1);
  29688. }
  29689. }
  29690. };
  29691. var LineSegment = function LineSegment2() {
  29692. this.p0 = null;
  29693. this.p1 = null;
  29694. if (arguments.length === 0) {
  29695. this.p0 = new Coordinate();
  29696. this.p1 = new Coordinate();
  29697. } else if (arguments.length === 1) {
  29698. var ls = arguments[0];
  29699. this.p0 = new Coordinate(ls.p0);
  29700. this.p1 = new Coordinate(ls.p1);
  29701. } else if (arguments.length === 2) {
  29702. this.p0 = arguments[0];
  29703. this.p1 = arguments[1];
  29704. } else if (arguments.length === 4) {
  29705. var x02 = arguments[0];
  29706. var y02 = arguments[1];
  29707. var x12 = arguments[2];
  29708. var y12 = arguments[3];
  29709. this.p0 = new Coordinate(x02, y02);
  29710. this.p1 = new Coordinate(x12, y12);
  29711. }
  29712. };
  29713. var staticAccessors$24 = { serialVersionUID: { configurable: true } };
  29714. LineSegment.prototype.minX = function minX() {
  29715. return Math.min(this.p0.x, this.p1.x);
  29716. };
  29717. LineSegment.prototype.orientationIndex = function orientationIndex5() {
  29718. if (arguments[0] instanceof LineSegment) {
  29719. var seg = arguments[0];
  29720. var orient0 = CGAlgorithms.orientationIndex(this.p0, this.p1, seg.p0);
  29721. var orient1 = CGAlgorithms.orientationIndex(this.p0, this.p1, seg.p1);
  29722. if (orient0 >= 0 && orient1 >= 0) {
  29723. return Math.max(orient0, orient1);
  29724. }
  29725. if (orient0 <= 0 && orient1 <= 0) {
  29726. return Math.max(orient0, orient1);
  29727. }
  29728. return 0;
  29729. } else if (arguments[0] instanceof Coordinate) {
  29730. var p = arguments[0];
  29731. return CGAlgorithms.orientationIndex(this.p0, this.p1, p);
  29732. }
  29733. };
  29734. LineSegment.prototype.toGeometry = function toGeometry2(geomFactory) {
  29735. return geomFactory.createLineString([this.p0, this.p1]);
  29736. };
  29737. LineSegment.prototype.isVertical = function isVertical() {
  29738. return this.p0.x === this.p1.x;
  29739. };
  29740. LineSegment.prototype.equals = function equals9(o) {
  29741. if (!(o instanceof LineSegment)) {
  29742. return false;
  29743. }
  29744. var other = o;
  29745. return this.p0.equals(other.p0) && this.p1.equals(other.p1);
  29746. };
  29747. LineSegment.prototype.intersection = function intersection9(line) {
  29748. var li = new RobustLineIntersector();
  29749. li.computeIntersection(this.p0, this.p1, line.p0, line.p1);
  29750. if (li.hasIntersection()) {
  29751. return li.getIntersection(0);
  29752. }
  29753. return null;
  29754. };
  29755. LineSegment.prototype.project = function project() {
  29756. if (arguments[0] instanceof Coordinate) {
  29757. var p = arguments[0];
  29758. if (p.equals(this.p0) || p.equals(this.p1)) {
  29759. return new Coordinate(p);
  29760. }
  29761. var r = this.projectionFactor(p);
  29762. var coord = new Coordinate();
  29763. coord.x = this.p0.x + r * (this.p1.x - this.p0.x);
  29764. coord.y = this.p0.y + r * (this.p1.y - this.p0.y);
  29765. return coord;
  29766. } else if (arguments[0] instanceof LineSegment) {
  29767. var seg = arguments[0];
  29768. var pf0 = this.projectionFactor(seg.p0);
  29769. var pf1 = this.projectionFactor(seg.p1);
  29770. if (pf0 >= 1 && pf1 >= 1) {
  29771. return null;
  29772. }
  29773. if (pf0 <= 0 && pf1 <= 0) {
  29774. return null;
  29775. }
  29776. var newp0 = this.project(seg.p0);
  29777. if (pf0 < 0) {
  29778. newp0 = this.p0;
  29779. }
  29780. if (pf0 > 1) {
  29781. newp0 = this.p1;
  29782. }
  29783. var newp1 = this.project(seg.p1);
  29784. if (pf1 < 0) {
  29785. newp1 = this.p0;
  29786. }
  29787. if (pf1 > 1) {
  29788. newp1 = this.p1;
  29789. }
  29790. return new LineSegment(newp0, newp1);
  29791. }
  29792. };
  29793. LineSegment.prototype.normalize = function normalize3() {
  29794. if (this.p1.compareTo(this.p0) < 0) {
  29795. this.reverse();
  29796. }
  29797. };
  29798. LineSegment.prototype.angle = function angle2() {
  29799. return Math.atan2(this.p1.y - this.p0.y, this.p1.x - this.p0.x);
  29800. };
  29801. LineSegment.prototype.getCoordinate = function getCoordinate10(i) {
  29802. if (i === 0) {
  29803. return this.p0;
  29804. }
  29805. return this.p1;
  29806. };
  29807. LineSegment.prototype.distancePerpendicular = function distancePerpendicular(p) {
  29808. return CGAlgorithms.distancePointLinePerpendicular(p, this.p0, this.p1);
  29809. };
  29810. LineSegment.prototype.minY = function minY() {
  29811. return Math.min(this.p0.y, this.p1.y);
  29812. };
  29813. LineSegment.prototype.midPoint = function midPoint() {
  29814. return LineSegment.midPoint(this.p0, this.p1);
  29815. };
  29816. LineSegment.prototype.projectionFactor = function projectionFactor(p) {
  29817. if (p.equals(this.p0)) {
  29818. return 0;
  29819. }
  29820. if (p.equals(this.p1)) {
  29821. return 1;
  29822. }
  29823. var dx = this.p1.x - this.p0.x;
  29824. var dy = this.p1.y - this.p0.y;
  29825. var len = dx * dx + dy * dy;
  29826. if (len <= 0) {
  29827. return Double.NaN;
  29828. }
  29829. var r = ((p.x - this.p0.x) * dx + (p.y - this.p0.y) * dy) / len;
  29830. return r;
  29831. };
  29832. LineSegment.prototype.closestPoints = function closestPoints(line) {
  29833. var intPt = this.intersection(line);
  29834. if (intPt !== null) {
  29835. return [intPt, intPt];
  29836. }
  29837. var closestPt = new Array(2).fill(null);
  29838. var minDistance = Double.MAX_VALUE;
  29839. var dist = null;
  29840. var close00 = this.closestPoint(line.p0);
  29841. minDistance = close00.distance(line.p0);
  29842. closestPt[0] = close00;
  29843. closestPt[1] = line.p0;
  29844. var close01 = this.closestPoint(line.p1);
  29845. dist = close01.distance(line.p1);
  29846. if (dist < minDistance) {
  29847. minDistance = dist;
  29848. closestPt[0] = close01;
  29849. closestPt[1] = line.p1;
  29850. }
  29851. var close10 = line.closestPoint(this.p0);
  29852. dist = close10.distance(this.p0);
  29853. if (dist < minDistance) {
  29854. minDistance = dist;
  29855. closestPt[0] = this.p0;
  29856. closestPt[1] = close10;
  29857. }
  29858. var close11 = line.closestPoint(this.p1);
  29859. dist = close11.distance(this.p1);
  29860. if (dist < minDistance) {
  29861. minDistance = dist;
  29862. closestPt[0] = this.p1;
  29863. closestPt[1] = close11;
  29864. }
  29865. return closestPt;
  29866. };
  29867. LineSegment.prototype.closestPoint = function closestPoint(p) {
  29868. var factor = this.projectionFactor(p);
  29869. if (factor > 0 && factor < 1) {
  29870. return this.project(p);
  29871. }
  29872. var dist0 = this.p0.distance(p);
  29873. var dist1 = this.p1.distance(p);
  29874. if (dist0 < dist1) {
  29875. return this.p0;
  29876. }
  29877. return this.p1;
  29878. };
  29879. LineSegment.prototype.maxX = function maxX() {
  29880. return Math.max(this.p0.x, this.p1.x);
  29881. };
  29882. LineSegment.prototype.getLength = function getLength2() {
  29883. return this.p0.distance(this.p1);
  29884. };
  29885. LineSegment.prototype.compareTo = function compareTo11(o) {
  29886. var other = o;
  29887. var comp0 = this.p0.compareTo(other.p0);
  29888. if (comp0 !== 0) {
  29889. return comp0;
  29890. }
  29891. return this.p1.compareTo(other.p1);
  29892. };
  29893. LineSegment.prototype.reverse = function reverse4() {
  29894. var temp2 = this.p0;
  29895. this.p0 = this.p1;
  29896. this.p1 = temp2;
  29897. };
  29898. LineSegment.prototype.equalsTopo = function equalsTopo(other) {
  29899. return this.p0.equals(other.p0) && (this.p1.equals(other.p1) || this.p0.equals(other.p1)) && this.p1.equals(other.p0);
  29900. };
  29901. LineSegment.prototype.lineIntersection = function lineIntersection(line) {
  29902. try {
  29903. var intPt = HCoordinate.intersection(this.p0, this.p1, line.p0, line.p1);
  29904. return intPt;
  29905. } catch (ex) {
  29906. if (ex instanceof NotRepresentableException) {
  29907. } else {
  29908. throw ex;
  29909. }
  29910. } finally {
  29911. }
  29912. return null;
  29913. };
  29914. LineSegment.prototype.maxY = function maxY() {
  29915. return Math.max(this.p0.y, this.p1.y);
  29916. };
  29917. LineSegment.prototype.pointAlongOffset = function pointAlongOffset(segmentLengthFraction, offsetDistance) {
  29918. var segx = this.p0.x + segmentLengthFraction * (this.p1.x - this.p0.x);
  29919. var segy = this.p0.y + segmentLengthFraction * (this.p1.y - this.p0.y);
  29920. var dx = this.p1.x - this.p0.x;
  29921. var dy = this.p1.y - this.p0.y;
  29922. var len = Math.sqrt(dx * dx + dy * dy);
  29923. var ux = 0;
  29924. var uy = 0;
  29925. if (offsetDistance !== 0) {
  29926. if (len <= 0) {
  29927. throw new Error("Cannot compute offset from zero-length line segment");
  29928. }
  29929. ux = offsetDistance * dx / len;
  29930. uy = offsetDistance * dy / len;
  29931. }
  29932. var offsetx = segx - uy;
  29933. var offsety = segy + ux;
  29934. var coord = new Coordinate(offsetx, offsety);
  29935. return coord;
  29936. };
  29937. LineSegment.prototype.setCoordinates = function setCoordinates() {
  29938. if (arguments.length === 1) {
  29939. var ls = arguments[0];
  29940. this.setCoordinates(ls.p0, ls.p1);
  29941. } else if (arguments.length === 2) {
  29942. var p0 = arguments[0];
  29943. var p1 = arguments[1];
  29944. this.p0.x = p0.x;
  29945. this.p0.y = p0.y;
  29946. this.p1.x = p1.x;
  29947. this.p1.y = p1.y;
  29948. }
  29949. };
  29950. LineSegment.prototype.segmentFraction = function segmentFraction(inputPt) {
  29951. var segFrac = this.projectionFactor(inputPt);
  29952. if (segFrac < 0) {
  29953. segFrac = 0;
  29954. } else if (segFrac > 1 || Double.isNaN(segFrac)) {
  29955. segFrac = 1;
  29956. }
  29957. return segFrac;
  29958. };
  29959. LineSegment.prototype.toString = function toString15() {
  29960. return "LINESTRING( " + this.p0.x + " " + this.p0.y + ", " + this.p1.x + " " + this.p1.y + ")";
  29961. };
  29962. LineSegment.prototype.isHorizontal = function isHorizontal() {
  29963. return this.p0.y === this.p1.y;
  29964. };
  29965. LineSegment.prototype.distance = function distance6() {
  29966. if (arguments[0] instanceof LineSegment) {
  29967. var ls = arguments[0];
  29968. return CGAlgorithms.distanceLineLine(this.p0, this.p1, ls.p0, ls.p1);
  29969. } else if (arguments[0] instanceof Coordinate) {
  29970. var p = arguments[0];
  29971. return CGAlgorithms.distancePointLine(p, this.p0, this.p1);
  29972. }
  29973. };
  29974. LineSegment.prototype.pointAlong = function pointAlong(segmentLengthFraction) {
  29975. var coord = new Coordinate();
  29976. coord.x = this.p0.x + segmentLengthFraction * (this.p1.x - this.p0.x);
  29977. coord.y = this.p0.y + segmentLengthFraction * (this.p1.y - this.p0.y);
  29978. return coord;
  29979. };
  29980. LineSegment.prototype.hashCode = function hashCode5() {
  29981. var bits0 = Double.doubleToLongBits(this.p0.x);
  29982. bits0 ^= Double.doubleToLongBits(this.p0.y) * 31;
  29983. var hash0 = Math.trunc(bits0) ^ Math.trunc(bits0 >> 32);
  29984. var bits1 = Double.doubleToLongBits(this.p1.x);
  29985. bits1 ^= Double.doubleToLongBits(this.p1.y) * 31;
  29986. var hash1 = Math.trunc(bits1) ^ Math.trunc(bits1 >> 32);
  29987. return hash0 ^ hash1;
  29988. };
  29989. LineSegment.prototype.interfaces_ = function interfaces_77() {
  29990. return [Comparable, Serializable];
  29991. };
  29992. LineSegment.prototype.getClass = function getClass76() {
  29993. return LineSegment;
  29994. };
  29995. LineSegment.midPoint = function midPoint2(p0, p1) {
  29996. return new Coordinate((p0.x + p1.x) / 2, (p0.y + p1.y) / 2);
  29997. };
  29998. staticAccessors$24.serialVersionUID.get = function() {
  29999. return 3252005833466256400;
  30000. };
  30001. Object.defineProperties(LineSegment, staticAccessors$24);
  30002. var MonotoneChainOverlapAction = function MonotoneChainOverlapAction2() {
  30003. this.tempEnv1 = new Envelope();
  30004. this.tempEnv2 = new Envelope();
  30005. this._overlapSeg1 = new LineSegment();
  30006. this._overlapSeg2 = new LineSegment();
  30007. };
  30008. MonotoneChainOverlapAction.prototype.overlap = function overlap() {
  30009. if (arguments.length === 2) {
  30010. } else if (arguments.length === 4) {
  30011. var mc1 = arguments[0];
  30012. var start1 = arguments[1];
  30013. var mc2 = arguments[2];
  30014. var start2 = arguments[3];
  30015. mc1.getLineSegment(start1, this._overlapSeg1);
  30016. mc2.getLineSegment(start2, this._overlapSeg2);
  30017. this.overlap(this._overlapSeg1, this._overlapSeg2);
  30018. }
  30019. };
  30020. MonotoneChainOverlapAction.prototype.interfaces_ = function interfaces_78() {
  30021. return [];
  30022. };
  30023. MonotoneChainOverlapAction.prototype.getClass = function getClass77() {
  30024. return MonotoneChainOverlapAction;
  30025. };
  30026. var MonotoneChain = function MonotoneChain2() {
  30027. this._pts = null;
  30028. this._start = null;
  30029. this._end = null;
  30030. this._env = null;
  30031. this._context = null;
  30032. this._id = null;
  30033. var pts = arguments[0];
  30034. var start = arguments[1];
  30035. var end = arguments[2];
  30036. var context = arguments[3];
  30037. this._pts = pts;
  30038. this._start = start;
  30039. this._end = end;
  30040. this._context = context;
  30041. };
  30042. MonotoneChain.prototype.getLineSegment = function getLineSegment(index2, ls) {
  30043. ls.p0 = this._pts[index2];
  30044. ls.p1 = this._pts[index2 + 1];
  30045. };
  30046. MonotoneChain.prototype.computeSelect = function computeSelect(searchEnv, start0, end0, mcs) {
  30047. var p0 = this._pts[start0];
  30048. var p1 = this._pts[end0];
  30049. mcs.tempEnv1.init(p0, p1);
  30050. if (end0 - start0 === 1) {
  30051. mcs.select(this, start0);
  30052. return null;
  30053. }
  30054. if (!searchEnv.intersects(mcs.tempEnv1)) {
  30055. return null;
  30056. }
  30057. var mid = Math.trunc((start0 + end0) / 2);
  30058. if (start0 < mid) {
  30059. this.computeSelect(searchEnv, start0, mid, mcs);
  30060. }
  30061. if (mid < end0) {
  30062. this.computeSelect(searchEnv, mid, end0, mcs);
  30063. }
  30064. };
  30065. MonotoneChain.prototype.getCoordinates = function getCoordinates3() {
  30066. var this$1 = this;
  30067. var coord = new Array(this._end - this._start + 1).fill(null);
  30068. var index2 = 0;
  30069. for (var i = this._start; i <= this._end; i++) {
  30070. coord[index2++] = this$1._pts[i];
  30071. }
  30072. return coord;
  30073. };
  30074. MonotoneChain.prototype.computeOverlaps = function computeOverlaps(mc, mco) {
  30075. this.computeOverlapsInternal(this._start, this._end, mc, mc._start, mc._end, mco);
  30076. };
  30077. MonotoneChain.prototype.setId = function setId(id) {
  30078. this._id = id;
  30079. };
  30080. MonotoneChain.prototype.select = function select(searchEnv, mcs) {
  30081. this.computeSelect(searchEnv, this._start, this._end, mcs);
  30082. };
  30083. MonotoneChain.prototype.getEnvelope = function getEnvelope3() {
  30084. if (this._env === null) {
  30085. var p0 = this._pts[this._start];
  30086. var p1 = this._pts[this._end];
  30087. this._env = new Envelope(p0, p1);
  30088. }
  30089. return this._env;
  30090. };
  30091. MonotoneChain.prototype.getEndIndex = function getEndIndex() {
  30092. return this._end;
  30093. };
  30094. MonotoneChain.prototype.getStartIndex = function getStartIndex() {
  30095. return this._start;
  30096. };
  30097. MonotoneChain.prototype.getContext = function getContext() {
  30098. return this._context;
  30099. };
  30100. MonotoneChain.prototype.getId = function getId() {
  30101. return this._id;
  30102. };
  30103. MonotoneChain.prototype.computeOverlapsInternal = function computeOverlapsInternal(start0, end0, mc, start1, end1, mco) {
  30104. var p002 = this._pts[start0];
  30105. var p012 = this._pts[end0];
  30106. var p102 = mc._pts[start1];
  30107. var p112 = mc._pts[end1];
  30108. if (end0 - start0 === 1 && end1 - start1 === 1) {
  30109. mco.overlap(this, start0, mc, start1);
  30110. return null;
  30111. }
  30112. mco.tempEnv1.init(p002, p012);
  30113. mco.tempEnv2.init(p102, p112);
  30114. if (!mco.tempEnv1.intersects(mco.tempEnv2)) {
  30115. return null;
  30116. }
  30117. var mid0 = Math.trunc((start0 + end0) / 2);
  30118. var mid1 = Math.trunc((start1 + end1) / 2);
  30119. if (start0 < mid0) {
  30120. if (start1 < mid1) {
  30121. this.computeOverlapsInternal(start0, mid0, mc, start1, mid1, mco);
  30122. }
  30123. if (mid1 < end1) {
  30124. this.computeOverlapsInternal(start0, mid0, mc, mid1, end1, mco);
  30125. }
  30126. }
  30127. if (mid0 < end0) {
  30128. if (start1 < mid1) {
  30129. this.computeOverlapsInternal(mid0, end0, mc, start1, mid1, mco);
  30130. }
  30131. if (mid1 < end1) {
  30132. this.computeOverlapsInternal(mid0, end0, mc, mid1, end1, mco);
  30133. }
  30134. }
  30135. };
  30136. MonotoneChain.prototype.interfaces_ = function interfaces_79() {
  30137. return [];
  30138. };
  30139. MonotoneChain.prototype.getClass = function getClass78() {
  30140. return MonotoneChain;
  30141. };
  30142. var MonotoneChainBuilder = function MonotoneChainBuilder2() {
  30143. };
  30144. MonotoneChainBuilder.prototype.interfaces_ = function interfaces_80() {
  30145. return [];
  30146. };
  30147. MonotoneChainBuilder.prototype.getClass = function getClass79() {
  30148. return MonotoneChainBuilder;
  30149. };
  30150. MonotoneChainBuilder.getChainStartIndices = function getChainStartIndices(pts) {
  30151. var start = 0;
  30152. var startIndexList = new ArrayList();
  30153. startIndexList.add(new Integer(start));
  30154. do {
  30155. var last = MonotoneChainBuilder.findChainEnd(pts, start);
  30156. startIndexList.add(new Integer(last));
  30157. start = last;
  30158. } while (start < pts.length - 1);
  30159. var startIndex = MonotoneChainBuilder.toIntArray(startIndexList);
  30160. return startIndex;
  30161. };
  30162. MonotoneChainBuilder.findChainEnd = function findChainEnd(pts, start) {
  30163. var safeStart = start;
  30164. while (safeStart < pts.length - 1 && pts[safeStart].equals2D(pts[safeStart + 1])) {
  30165. safeStart++;
  30166. }
  30167. if (safeStart >= pts.length - 1) {
  30168. return pts.length - 1;
  30169. }
  30170. var chainQuad = Quadrant.quadrant(pts[safeStart], pts[safeStart + 1]);
  30171. var last = start + 1;
  30172. while (last < pts.length) {
  30173. if (!pts[last - 1].equals2D(pts[last])) {
  30174. var quad = Quadrant.quadrant(pts[last - 1], pts[last]);
  30175. if (quad !== chainQuad) {
  30176. break;
  30177. }
  30178. }
  30179. last++;
  30180. }
  30181. return last - 1;
  30182. };
  30183. MonotoneChainBuilder.getChains = function getChains() {
  30184. if (arguments.length === 1) {
  30185. var pts = arguments[0];
  30186. return MonotoneChainBuilder.getChains(pts, null);
  30187. } else if (arguments.length === 2) {
  30188. var pts$1 = arguments[0];
  30189. var context = arguments[1];
  30190. var mcList = new ArrayList();
  30191. var startIndex = MonotoneChainBuilder.getChainStartIndices(pts$1);
  30192. for (var i = 0; i < startIndex.length - 1; i++) {
  30193. var mc = new MonotoneChain(pts$1, startIndex[i], startIndex[i + 1], context);
  30194. mcList.add(mc);
  30195. }
  30196. return mcList;
  30197. }
  30198. };
  30199. MonotoneChainBuilder.toIntArray = function toIntArray(list) {
  30200. var array2 = new Array(list.size()).fill(null);
  30201. for (var i = 0; i < array2.length; i++) {
  30202. array2[i] = list.get(i).intValue();
  30203. }
  30204. return array2;
  30205. };
  30206. var Noder = function Noder2() {
  30207. };
  30208. Noder.prototype.computeNodes = function computeNodes(segStrings) {
  30209. };
  30210. Noder.prototype.getNodedSubstrings = function getNodedSubstrings2() {
  30211. };
  30212. Noder.prototype.interfaces_ = function interfaces_81() {
  30213. return [];
  30214. };
  30215. Noder.prototype.getClass = function getClass80() {
  30216. return Noder;
  30217. };
  30218. var SinglePassNoder = function SinglePassNoder2() {
  30219. this._segInt = null;
  30220. if (arguments.length === 0) {
  30221. } else if (arguments.length === 1) {
  30222. var segInt = arguments[0];
  30223. this.setSegmentIntersector(segInt);
  30224. }
  30225. };
  30226. SinglePassNoder.prototype.setSegmentIntersector = function setSegmentIntersector(segInt) {
  30227. this._segInt = segInt;
  30228. };
  30229. SinglePassNoder.prototype.interfaces_ = function interfaces_82() {
  30230. return [Noder];
  30231. };
  30232. SinglePassNoder.prototype.getClass = function getClass81() {
  30233. return SinglePassNoder;
  30234. };
  30235. var MCIndexNoder = function(SinglePassNoder$$1) {
  30236. function MCIndexNoder2(si) {
  30237. if (si) {
  30238. SinglePassNoder$$1.call(this, si);
  30239. } else {
  30240. SinglePassNoder$$1.call(this);
  30241. }
  30242. this._monoChains = new ArrayList();
  30243. this._index = new STRtree();
  30244. this._idCounter = 0;
  30245. this._nodedSegStrings = null;
  30246. this._nOverlaps = 0;
  30247. }
  30248. if (SinglePassNoder$$1)
  30249. MCIndexNoder2.__proto__ = SinglePassNoder$$1;
  30250. MCIndexNoder2.prototype = Object.create(SinglePassNoder$$1 && SinglePassNoder$$1.prototype);
  30251. MCIndexNoder2.prototype.constructor = MCIndexNoder2;
  30252. var staticAccessors2 = { SegmentOverlapAction: { configurable: true } };
  30253. MCIndexNoder2.prototype.getMonotoneChains = function getMonotoneChains() {
  30254. return this._monoChains;
  30255. };
  30256. MCIndexNoder2.prototype.getNodedSubstrings = function getNodedSubstrings5() {
  30257. return NodedSegmentString.getNodedSubstrings(this._nodedSegStrings);
  30258. };
  30259. MCIndexNoder2.prototype.getIndex = function getIndex() {
  30260. return this._index;
  30261. };
  30262. MCIndexNoder2.prototype.add = function add17(segStr) {
  30263. var this$1 = this;
  30264. var segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(), segStr);
  30265. for (var i = segChains.iterator(); i.hasNext(); ) {
  30266. var mc = i.next();
  30267. mc.setId(this$1._idCounter++);
  30268. this$1._index.insert(mc.getEnvelope(), mc);
  30269. this$1._monoChains.add(mc);
  30270. }
  30271. };
  30272. MCIndexNoder2.prototype.computeNodes = function computeNodes4(inputSegStrings) {
  30273. var this$1 = this;
  30274. this._nodedSegStrings = inputSegStrings;
  30275. for (var i = inputSegStrings.iterator(); i.hasNext(); ) {
  30276. this$1.add(i.next());
  30277. }
  30278. this.intersectChains();
  30279. };
  30280. MCIndexNoder2.prototype.intersectChains = function intersectChains() {
  30281. var this$1 = this;
  30282. var overlapAction = new SegmentOverlapAction(this._segInt);
  30283. for (var i = this._monoChains.iterator(); i.hasNext(); ) {
  30284. var queryChain = i.next();
  30285. var overlapChains = this$1._index.query(queryChain.getEnvelope());
  30286. for (var j = overlapChains.iterator(); j.hasNext(); ) {
  30287. var testChain = j.next();
  30288. if (testChain.getId() > queryChain.getId()) {
  30289. queryChain.computeOverlaps(testChain, overlapAction);
  30290. this$1._nOverlaps++;
  30291. }
  30292. if (this$1._segInt.isDone()) {
  30293. return null;
  30294. }
  30295. }
  30296. }
  30297. };
  30298. MCIndexNoder2.prototype.interfaces_ = function interfaces_170() {
  30299. return [];
  30300. };
  30301. MCIndexNoder2.prototype.getClass = function getClass169() {
  30302. return MCIndexNoder2;
  30303. };
  30304. staticAccessors2.SegmentOverlapAction.get = function() {
  30305. return SegmentOverlapAction;
  30306. };
  30307. Object.defineProperties(MCIndexNoder2, staticAccessors2);
  30308. return MCIndexNoder2;
  30309. }(SinglePassNoder);
  30310. var SegmentOverlapAction = function(MonotoneChainOverlapAction$$1) {
  30311. function SegmentOverlapAction2() {
  30312. MonotoneChainOverlapAction$$1.call(this);
  30313. this._si = null;
  30314. var si = arguments[0];
  30315. this._si = si;
  30316. }
  30317. if (MonotoneChainOverlapAction$$1)
  30318. SegmentOverlapAction2.__proto__ = MonotoneChainOverlapAction$$1;
  30319. SegmentOverlapAction2.prototype = Object.create(MonotoneChainOverlapAction$$1 && MonotoneChainOverlapAction$$1.prototype);
  30320. SegmentOverlapAction2.prototype.constructor = SegmentOverlapAction2;
  30321. SegmentOverlapAction2.prototype.overlap = function overlap2() {
  30322. if (arguments.length === 4) {
  30323. var mc1 = arguments[0];
  30324. var start1 = arguments[1];
  30325. var mc2 = arguments[2];
  30326. var start2 = arguments[3];
  30327. var ss1 = mc1.getContext();
  30328. var ss2 = mc2.getContext();
  30329. this._si.processIntersections(ss1, start1, ss2, start2);
  30330. } else {
  30331. return MonotoneChainOverlapAction$$1.prototype.overlap.apply(this, arguments);
  30332. }
  30333. };
  30334. SegmentOverlapAction2.prototype.interfaces_ = function interfaces_170() {
  30335. return [];
  30336. };
  30337. SegmentOverlapAction2.prototype.getClass = function getClass169() {
  30338. return SegmentOverlapAction2;
  30339. };
  30340. return SegmentOverlapAction2;
  30341. }(MonotoneChainOverlapAction);
  30342. var BufferParameters = function BufferParameters2() {
  30343. this._quadrantSegments = BufferParameters2.DEFAULT_QUADRANT_SEGMENTS;
  30344. this._endCapStyle = BufferParameters2.CAP_ROUND;
  30345. this._joinStyle = BufferParameters2.JOIN_ROUND;
  30346. this._mitreLimit = BufferParameters2.DEFAULT_MITRE_LIMIT;
  30347. this._isSingleSided = false;
  30348. this._simplifyFactor = BufferParameters2.DEFAULT_SIMPLIFY_FACTOR;
  30349. if (arguments.length === 0) {
  30350. } else if (arguments.length === 1) {
  30351. var quadrantSegments = arguments[0];
  30352. this.setQuadrantSegments(quadrantSegments);
  30353. } else if (arguments.length === 2) {
  30354. var quadrantSegments$1 = arguments[0];
  30355. var endCapStyle = arguments[1];
  30356. this.setQuadrantSegments(quadrantSegments$1);
  30357. this.setEndCapStyle(endCapStyle);
  30358. } else if (arguments.length === 4) {
  30359. var quadrantSegments$2 = arguments[0];
  30360. var endCapStyle$1 = arguments[1];
  30361. var joinStyle = arguments[2];
  30362. var mitreLimit = arguments[3];
  30363. this.setQuadrantSegments(quadrantSegments$2);
  30364. this.setEndCapStyle(endCapStyle$1);
  30365. this.setJoinStyle(joinStyle);
  30366. this.setMitreLimit(mitreLimit);
  30367. }
  30368. };
  30369. var staticAccessors$25 = { CAP_ROUND: { configurable: true }, CAP_FLAT: { configurable: true }, CAP_SQUARE: { configurable: true }, JOIN_ROUND: { configurable: true }, JOIN_MITRE: { configurable: true }, JOIN_BEVEL: { configurable: true }, DEFAULT_QUADRANT_SEGMENTS: { configurable: true }, DEFAULT_MITRE_LIMIT: { configurable: true }, DEFAULT_SIMPLIFY_FACTOR: { configurable: true } };
  30370. BufferParameters.prototype.getEndCapStyle = function getEndCapStyle() {
  30371. return this._endCapStyle;
  30372. };
  30373. BufferParameters.prototype.isSingleSided = function isSingleSided() {
  30374. return this._isSingleSided;
  30375. };
  30376. BufferParameters.prototype.setQuadrantSegments = function setQuadrantSegments(quadSegs) {
  30377. this._quadrantSegments = quadSegs;
  30378. if (this._quadrantSegments === 0) {
  30379. this._joinStyle = BufferParameters.JOIN_BEVEL;
  30380. }
  30381. if (this._quadrantSegments < 0) {
  30382. this._joinStyle = BufferParameters.JOIN_MITRE;
  30383. this._mitreLimit = Math.abs(this._quadrantSegments);
  30384. }
  30385. if (quadSegs <= 0) {
  30386. this._quadrantSegments = 1;
  30387. }
  30388. if (this._joinStyle !== BufferParameters.JOIN_ROUND) {
  30389. this._quadrantSegments = BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
  30390. }
  30391. };
  30392. BufferParameters.prototype.getJoinStyle = function getJoinStyle() {
  30393. return this._joinStyle;
  30394. };
  30395. BufferParameters.prototype.setJoinStyle = function setJoinStyle(joinStyle) {
  30396. this._joinStyle = joinStyle;
  30397. };
  30398. BufferParameters.prototype.setSimplifyFactor = function setSimplifyFactor(simplifyFactor) {
  30399. this._simplifyFactor = simplifyFactor < 0 ? 0 : simplifyFactor;
  30400. };
  30401. BufferParameters.prototype.getSimplifyFactor = function getSimplifyFactor() {
  30402. return this._simplifyFactor;
  30403. };
  30404. BufferParameters.prototype.getQuadrantSegments = function getQuadrantSegments() {
  30405. return this._quadrantSegments;
  30406. };
  30407. BufferParameters.prototype.setEndCapStyle = function setEndCapStyle(endCapStyle) {
  30408. this._endCapStyle = endCapStyle;
  30409. };
  30410. BufferParameters.prototype.getMitreLimit = function getMitreLimit() {
  30411. return this._mitreLimit;
  30412. };
  30413. BufferParameters.prototype.setMitreLimit = function setMitreLimit(mitreLimit) {
  30414. this._mitreLimit = mitreLimit;
  30415. };
  30416. BufferParameters.prototype.setSingleSided = function setSingleSided(isSingleSided2) {
  30417. this._isSingleSided = isSingleSided2;
  30418. };
  30419. BufferParameters.prototype.interfaces_ = function interfaces_83() {
  30420. return [];
  30421. };
  30422. BufferParameters.prototype.getClass = function getClass82() {
  30423. return BufferParameters;
  30424. };
  30425. BufferParameters.bufferDistanceError = function bufferDistanceError(quadSegs) {
  30426. var alpha = Math.PI / 2 / quadSegs;
  30427. return 1 - Math.cos(alpha / 2);
  30428. };
  30429. staticAccessors$25.CAP_ROUND.get = function() {
  30430. return 1;
  30431. };
  30432. staticAccessors$25.CAP_FLAT.get = function() {
  30433. return 2;
  30434. };
  30435. staticAccessors$25.CAP_SQUARE.get = function() {
  30436. return 3;
  30437. };
  30438. staticAccessors$25.JOIN_ROUND.get = function() {
  30439. return 1;
  30440. };
  30441. staticAccessors$25.JOIN_MITRE.get = function() {
  30442. return 2;
  30443. };
  30444. staticAccessors$25.JOIN_BEVEL.get = function() {
  30445. return 3;
  30446. };
  30447. staticAccessors$25.DEFAULT_QUADRANT_SEGMENTS.get = function() {
  30448. return 8;
  30449. };
  30450. staticAccessors$25.DEFAULT_MITRE_LIMIT.get = function() {
  30451. return 5;
  30452. };
  30453. staticAccessors$25.DEFAULT_SIMPLIFY_FACTOR.get = function() {
  30454. return 0.01;
  30455. };
  30456. Object.defineProperties(BufferParameters, staticAccessors$25);
  30457. var BufferInputLineSimplifier = function BufferInputLineSimplifier2(inputLine) {
  30458. this._distanceTol = null;
  30459. this._isDeleted = null;
  30460. this._angleOrientation = CGAlgorithms.COUNTERCLOCKWISE;
  30461. this._inputLine = inputLine || null;
  30462. };
  30463. var staticAccessors$26 = { INIT: { configurable: true }, DELETE: { configurable: true }, KEEP: { configurable: true }, NUM_PTS_TO_CHECK: { configurable: true } };
  30464. BufferInputLineSimplifier.prototype.isDeletable = function isDeletable(i0, i1, i2, distanceTol) {
  30465. var p0 = this._inputLine[i0];
  30466. var p1 = this._inputLine[i1];
  30467. var p2 = this._inputLine[i2];
  30468. if (!this.isConcave(p0, p1, p2)) {
  30469. return false;
  30470. }
  30471. if (!this.isShallow(p0, p1, p2, distanceTol)) {
  30472. return false;
  30473. }
  30474. return this.isShallowSampled(p0, p1, i0, i2, distanceTol);
  30475. };
  30476. BufferInputLineSimplifier.prototype.deleteShallowConcavities = function deleteShallowConcavities() {
  30477. var this$1 = this;
  30478. var index2 = 1;
  30479. var midIndex = this.findNextNonDeletedIndex(index2);
  30480. var lastIndex = this.findNextNonDeletedIndex(midIndex);
  30481. var isChanged = false;
  30482. while (lastIndex < this._inputLine.length) {
  30483. var isMiddleVertexDeleted = false;
  30484. if (this$1.isDeletable(index2, midIndex, lastIndex, this$1._distanceTol)) {
  30485. this$1._isDeleted[midIndex] = BufferInputLineSimplifier.DELETE;
  30486. isMiddleVertexDeleted = true;
  30487. isChanged = true;
  30488. }
  30489. if (isMiddleVertexDeleted) {
  30490. index2 = lastIndex;
  30491. } else {
  30492. index2 = midIndex;
  30493. }
  30494. midIndex = this$1.findNextNonDeletedIndex(index2);
  30495. lastIndex = this$1.findNextNonDeletedIndex(midIndex);
  30496. }
  30497. return isChanged;
  30498. };
  30499. BufferInputLineSimplifier.prototype.isShallowConcavity = function isShallowConcavity(p0, p1, p2, distanceTol) {
  30500. var orientation2 = CGAlgorithms.computeOrientation(p0, p1, p2);
  30501. var isAngleToSimplify = orientation2 === this._angleOrientation;
  30502. if (!isAngleToSimplify) {
  30503. return false;
  30504. }
  30505. var dist = CGAlgorithms.distancePointLine(p1, p0, p2);
  30506. return dist < distanceTol;
  30507. };
  30508. BufferInputLineSimplifier.prototype.isShallowSampled = function isShallowSampled(p0, p2, i0, i2, distanceTol) {
  30509. var this$1 = this;
  30510. var inc = Math.trunc((i2 - i0) / BufferInputLineSimplifier.NUM_PTS_TO_CHECK);
  30511. if (inc <= 0) {
  30512. inc = 1;
  30513. }
  30514. for (var i = i0; i < i2; i += inc) {
  30515. if (!this$1.isShallow(p0, p2, this$1._inputLine[i], distanceTol)) {
  30516. return false;
  30517. }
  30518. }
  30519. return true;
  30520. };
  30521. BufferInputLineSimplifier.prototype.isConcave = function isConcave(p0, p1, p2) {
  30522. var orientation2 = CGAlgorithms.computeOrientation(p0, p1, p2);
  30523. var isConcave2 = orientation2 === this._angleOrientation;
  30524. return isConcave2;
  30525. };
  30526. BufferInputLineSimplifier.prototype.simplify = function simplify2(distanceTol) {
  30527. var this$1 = this;
  30528. this._distanceTol = Math.abs(distanceTol);
  30529. if (distanceTol < 0) {
  30530. this._angleOrientation = CGAlgorithms.CLOCKWISE;
  30531. }
  30532. this._isDeleted = new Array(this._inputLine.length).fill(null);
  30533. var isChanged = false;
  30534. do {
  30535. isChanged = this$1.deleteShallowConcavities();
  30536. } while (isChanged);
  30537. return this.collapseLine();
  30538. };
  30539. BufferInputLineSimplifier.prototype.findNextNonDeletedIndex = function findNextNonDeletedIndex(index2) {
  30540. var next3 = index2 + 1;
  30541. while (next3 < this._inputLine.length && this._isDeleted[next3] === BufferInputLineSimplifier.DELETE) {
  30542. next3++;
  30543. }
  30544. return next3;
  30545. };
  30546. BufferInputLineSimplifier.prototype.isShallow = function isShallow(p0, p1, p2, distanceTol) {
  30547. var dist = CGAlgorithms.distancePointLine(p1, p0, p2);
  30548. return dist < distanceTol;
  30549. };
  30550. BufferInputLineSimplifier.prototype.collapseLine = function collapseLine() {
  30551. var this$1 = this;
  30552. var coordList = new CoordinateList();
  30553. for (var i = 0; i < this._inputLine.length; i++) {
  30554. if (this$1._isDeleted[i] !== BufferInputLineSimplifier.DELETE) {
  30555. coordList.add(this$1._inputLine[i]);
  30556. }
  30557. }
  30558. return coordList.toCoordinateArray();
  30559. };
  30560. BufferInputLineSimplifier.prototype.interfaces_ = function interfaces_84() {
  30561. return [];
  30562. };
  30563. BufferInputLineSimplifier.prototype.getClass = function getClass83() {
  30564. return BufferInputLineSimplifier;
  30565. };
  30566. BufferInputLineSimplifier.simplify = function simplify3(inputLine, distanceTol) {
  30567. var simp = new BufferInputLineSimplifier(inputLine);
  30568. return simp.simplify(distanceTol);
  30569. };
  30570. staticAccessors$26.INIT.get = function() {
  30571. return 0;
  30572. };
  30573. staticAccessors$26.DELETE.get = function() {
  30574. return 1;
  30575. };
  30576. staticAccessors$26.KEEP.get = function() {
  30577. return 1;
  30578. };
  30579. staticAccessors$26.NUM_PTS_TO_CHECK.get = function() {
  30580. return 10;
  30581. };
  30582. Object.defineProperties(BufferInputLineSimplifier, staticAccessors$26);
  30583. var OffsetSegmentString = function OffsetSegmentString2() {
  30584. this._ptList = null;
  30585. this._precisionModel = null;
  30586. this._minimimVertexDistance = 0;
  30587. this._ptList = new ArrayList();
  30588. };
  30589. var staticAccessors$28 = { COORDINATE_ARRAY_TYPE: { configurable: true } };
  30590. OffsetSegmentString.prototype.getCoordinates = function getCoordinates4() {
  30591. var coord = this._ptList.toArray(OffsetSegmentString.COORDINATE_ARRAY_TYPE);
  30592. return coord;
  30593. };
  30594. OffsetSegmentString.prototype.setPrecisionModel = function setPrecisionModel2(precisionModel) {
  30595. this._precisionModel = precisionModel;
  30596. };
  30597. OffsetSegmentString.prototype.addPt = function addPt(pt) {
  30598. var bufPt = new Coordinate(pt);
  30599. this._precisionModel.makePrecise(bufPt);
  30600. if (this.isRedundant(bufPt)) {
  30601. return null;
  30602. }
  30603. this._ptList.add(bufPt);
  30604. };
  30605. OffsetSegmentString.prototype.revere = function revere() {
  30606. };
  30607. OffsetSegmentString.prototype.addPts = function addPts(pt, isForward) {
  30608. var this$1 = this;
  30609. if (isForward) {
  30610. for (var i = 0; i < pt.length; i++) {
  30611. this$1.addPt(pt[i]);
  30612. }
  30613. } else {
  30614. for (var i$1 = pt.length - 1; i$1 >= 0; i$1--) {
  30615. this$1.addPt(pt[i$1]);
  30616. }
  30617. }
  30618. };
  30619. OffsetSegmentString.prototype.isRedundant = function isRedundant(pt) {
  30620. if (this._ptList.size() < 1) {
  30621. return false;
  30622. }
  30623. var lastPt = this._ptList.get(this._ptList.size() - 1);
  30624. var ptDist = pt.distance(lastPt);
  30625. if (ptDist < this._minimimVertexDistance) {
  30626. return true;
  30627. }
  30628. return false;
  30629. };
  30630. OffsetSegmentString.prototype.toString = function toString16() {
  30631. var fact = new GeometryFactory();
  30632. var line = fact.createLineString(this.getCoordinates());
  30633. return line.toString();
  30634. };
  30635. OffsetSegmentString.prototype.closeRing = function closeRing() {
  30636. if (this._ptList.size() < 1) {
  30637. return null;
  30638. }
  30639. var startPt = new Coordinate(this._ptList.get(0));
  30640. var lastPt = this._ptList.get(this._ptList.size() - 1);
  30641. if (startPt.equals(lastPt)) {
  30642. return null;
  30643. }
  30644. this._ptList.add(startPt);
  30645. };
  30646. OffsetSegmentString.prototype.setMinimumVertexDistance = function setMinimumVertexDistance(minimimVertexDistance) {
  30647. this._minimimVertexDistance = minimimVertexDistance;
  30648. };
  30649. OffsetSegmentString.prototype.interfaces_ = function interfaces_85() {
  30650. return [];
  30651. };
  30652. OffsetSegmentString.prototype.getClass = function getClass84() {
  30653. return OffsetSegmentString;
  30654. };
  30655. staticAccessors$28.COORDINATE_ARRAY_TYPE.get = function() {
  30656. return new Array(0).fill(null);
  30657. };
  30658. Object.defineProperties(OffsetSegmentString, staticAccessors$28);
  30659. var Angle = function Angle2() {
  30660. };
  30661. var staticAccessors$29 = { PI_TIMES_2: { configurable: true }, PI_OVER_2: { configurable: true }, PI_OVER_4: { configurable: true }, COUNTERCLOCKWISE: { configurable: true }, CLOCKWISE: { configurable: true }, NONE: { configurable: true } };
  30662. Angle.prototype.interfaces_ = function interfaces_86() {
  30663. return [];
  30664. };
  30665. Angle.prototype.getClass = function getClass85() {
  30666. return Angle;
  30667. };
  30668. Angle.toDegrees = function toDegrees(radians2) {
  30669. return radians2 * 180 / Math.PI;
  30670. };
  30671. Angle.normalize = function normalize4(angle4) {
  30672. while (angle4 > Math.PI) {
  30673. angle4 -= Angle.PI_TIMES_2;
  30674. }
  30675. while (angle4 <= -Math.PI) {
  30676. angle4 += Angle.PI_TIMES_2;
  30677. }
  30678. return angle4;
  30679. };
  30680. Angle.angle = function angle3() {
  30681. if (arguments.length === 1) {
  30682. var p = arguments[0];
  30683. return Math.atan2(p.y, p.x);
  30684. } else if (arguments.length === 2) {
  30685. var p0 = arguments[0];
  30686. var p1 = arguments[1];
  30687. var dx = p1.x - p0.x;
  30688. var dy = p1.y - p0.y;
  30689. return Math.atan2(dy, dx);
  30690. }
  30691. };
  30692. Angle.isAcute = function isAcute(p0, p1, p2) {
  30693. var dx0 = p0.x - p1.x;
  30694. var dy0 = p0.y - p1.y;
  30695. var dx1 = p2.x - p1.x;
  30696. var dy1 = p2.y - p1.y;
  30697. var dotprod = dx0 * dx1 + dy0 * dy1;
  30698. return dotprod > 0;
  30699. };
  30700. Angle.isObtuse = function isObtuse(p0, p1, p2) {
  30701. var dx0 = p0.x - p1.x;
  30702. var dy0 = p0.y - p1.y;
  30703. var dx1 = p2.x - p1.x;
  30704. var dy1 = p2.y - p1.y;
  30705. var dotprod = dx0 * dx1 + dy0 * dy1;
  30706. return dotprod < 0;
  30707. };
  30708. Angle.interiorAngle = function interiorAngle(p0, p1, p2) {
  30709. var anglePrev = Angle.angle(p1, p0);
  30710. var angleNext = Angle.angle(p1, p2);
  30711. return Math.abs(angleNext - anglePrev);
  30712. };
  30713. Angle.normalizePositive = function normalizePositive(angle4) {
  30714. if (angle4 < 0) {
  30715. while (angle4 < 0) {
  30716. angle4 += Angle.PI_TIMES_2;
  30717. }
  30718. if (angle4 >= Angle.PI_TIMES_2) {
  30719. angle4 = 0;
  30720. }
  30721. } else {
  30722. while (angle4 >= Angle.PI_TIMES_2) {
  30723. angle4 -= Angle.PI_TIMES_2;
  30724. }
  30725. if (angle4 < 0) {
  30726. angle4 = 0;
  30727. }
  30728. }
  30729. return angle4;
  30730. };
  30731. Angle.angleBetween = function angleBetween(tip1, tail, tip2) {
  30732. var a1 = Angle.angle(tail, tip1);
  30733. var a2 = Angle.angle(tail, tip2);
  30734. return Angle.diff(a1, a2);
  30735. };
  30736. Angle.diff = function diff(ang1, ang2) {
  30737. var delAngle = null;
  30738. if (ang1 < ang2) {
  30739. delAngle = ang2 - ang1;
  30740. } else {
  30741. delAngle = ang1 - ang2;
  30742. }
  30743. if (delAngle > Math.PI) {
  30744. delAngle = 2 * Math.PI - delAngle;
  30745. }
  30746. return delAngle;
  30747. };
  30748. Angle.toRadians = function toRadians(angleDegrees) {
  30749. return angleDegrees * Math.PI / 180;
  30750. };
  30751. Angle.getTurn = function getTurn(ang1, ang2) {
  30752. var crossproduct = Math.sin(ang2 - ang1);
  30753. if (crossproduct > 0) {
  30754. return Angle.COUNTERCLOCKWISE;
  30755. }
  30756. if (crossproduct < 0) {
  30757. return Angle.CLOCKWISE;
  30758. }
  30759. return Angle.NONE;
  30760. };
  30761. Angle.angleBetweenOriented = function angleBetweenOriented(tip1, tail, tip2) {
  30762. var a1 = Angle.angle(tail, tip1);
  30763. var a2 = Angle.angle(tail, tip2);
  30764. var angDel = a2 - a1;
  30765. if (angDel <= -Math.PI) {
  30766. return angDel + Angle.PI_TIMES_2;
  30767. }
  30768. if (angDel > Math.PI) {
  30769. return angDel - Angle.PI_TIMES_2;
  30770. }
  30771. return angDel;
  30772. };
  30773. staticAccessors$29.PI_TIMES_2.get = function() {
  30774. return 2 * Math.PI;
  30775. };
  30776. staticAccessors$29.PI_OVER_2.get = function() {
  30777. return Math.PI / 2;
  30778. };
  30779. staticAccessors$29.PI_OVER_4.get = function() {
  30780. return Math.PI / 4;
  30781. };
  30782. staticAccessors$29.COUNTERCLOCKWISE.get = function() {
  30783. return CGAlgorithms.COUNTERCLOCKWISE;
  30784. };
  30785. staticAccessors$29.CLOCKWISE.get = function() {
  30786. return CGAlgorithms.CLOCKWISE;
  30787. };
  30788. staticAccessors$29.NONE.get = function() {
  30789. return CGAlgorithms.COLLINEAR;
  30790. };
  30791. Object.defineProperties(Angle, staticAccessors$29);
  30792. var OffsetSegmentGenerator = function OffsetSegmentGenerator2() {
  30793. this._maxCurveSegmentError = 0;
  30794. this._filletAngleQuantum = null;
  30795. this._closingSegLengthFactor = 1;
  30796. this._segList = null;
  30797. this._distance = 0;
  30798. this._precisionModel = null;
  30799. this._bufParams = null;
  30800. this._li = null;
  30801. this._s0 = null;
  30802. this._s1 = null;
  30803. this._s2 = null;
  30804. this._seg0 = new LineSegment();
  30805. this._seg1 = new LineSegment();
  30806. this._offset0 = new LineSegment();
  30807. this._offset1 = new LineSegment();
  30808. this._side = 0;
  30809. this._hasNarrowConcaveAngle = false;
  30810. var precisionModel = arguments[0];
  30811. var bufParams = arguments[1];
  30812. var distance11 = arguments[2];
  30813. this._precisionModel = precisionModel;
  30814. this._bufParams = bufParams;
  30815. this._li = new RobustLineIntersector();
  30816. this._filletAngleQuantum = Math.PI / 2 / bufParams.getQuadrantSegments();
  30817. if (bufParams.getQuadrantSegments() >= 8 && bufParams.getJoinStyle() === BufferParameters.JOIN_ROUND) {
  30818. this._closingSegLengthFactor = OffsetSegmentGenerator2.MAX_CLOSING_SEG_LEN_FACTOR;
  30819. }
  30820. this.init(distance11);
  30821. };
  30822. var staticAccessors$27 = { OFFSET_SEGMENT_SEPARATION_FACTOR: { configurable: true }, INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR: { configurable: true }, CURVE_VERTEX_SNAP_DISTANCE_FACTOR: { configurable: true }, MAX_CLOSING_SEG_LEN_FACTOR: { configurable: true } };
  30823. OffsetSegmentGenerator.prototype.addNextSegment = function addNextSegment(p, addStartPoint) {
  30824. this._s0 = this._s1;
  30825. this._s1 = this._s2;
  30826. this._s2 = p;
  30827. this._seg0.setCoordinates(this._s0, this._s1);
  30828. this.computeOffsetSegment(this._seg0, this._side, this._distance, this._offset0);
  30829. this._seg1.setCoordinates(this._s1, this._s2);
  30830. this.computeOffsetSegment(this._seg1, this._side, this._distance, this._offset1);
  30831. if (this._s1.equals(this._s2)) {
  30832. return null;
  30833. }
  30834. var orientation2 = CGAlgorithms.computeOrientation(this._s0, this._s1, this._s2);
  30835. var outsideTurn = orientation2 === CGAlgorithms.CLOCKWISE && this._side === Position.LEFT || orientation2 === CGAlgorithms.COUNTERCLOCKWISE && this._side === Position.RIGHT;
  30836. if (orientation2 === 0) {
  30837. this.addCollinear(addStartPoint);
  30838. } else if (outsideTurn) {
  30839. this.addOutsideTurn(orientation2, addStartPoint);
  30840. } else {
  30841. this.addInsideTurn(orientation2, addStartPoint);
  30842. }
  30843. };
  30844. OffsetSegmentGenerator.prototype.addLineEndCap = function addLineEndCap(p0, p1) {
  30845. var seg = new LineSegment(p0, p1);
  30846. var offsetL = new LineSegment();
  30847. this.computeOffsetSegment(seg, Position.LEFT, this._distance, offsetL);
  30848. var offsetR = new LineSegment();
  30849. this.computeOffsetSegment(seg, Position.RIGHT, this._distance, offsetR);
  30850. var dx = p1.x - p0.x;
  30851. var dy = p1.y - p0.y;
  30852. var angle4 = Math.atan2(dy, dx);
  30853. switch (this._bufParams.getEndCapStyle()) {
  30854. case BufferParameters.CAP_ROUND:
  30855. this._segList.addPt(offsetL.p1);
  30856. this.addFilletArc(p1, angle4 + Math.PI / 2, angle4 - Math.PI / 2, CGAlgorithms.CLOCKWISE, this._distance);
  30857. this._segList.addPt(offsetR.p1);
  30858. break;
  30859. case BufferParameters.CAP_FLAT:
  30860. this._segList.addPt(offsetL.p1);
  30861. this._segList.addPt(offsetR.p1);
  30862. break;
  30863. case BufferParameters.CAP_SQUARE:
  30864. var squareCapSideOffset = new Coordinate();
  30865. squareCapSideOffset.x = Math.abs(this._distance) * Math.cos(angle4);
  30866. squareCapSideOffset.y = Math.abs(this._distance) * Math.sin(angle4);
  30867. var squareCapLOffset = new Coordinate(offsetL.p1.x + squareCapSideOffset.x, offsetL.p1.y + squareCapSideOffset.y);
  30868. var squareCapROffset = new Coordinate(offsetR.p1.x + squareCapSideOffset.x, offsetR.p1.y + squareCapSideOffset.y);
  30869. this._segList.addPt(squareCapLOffset);
  30870. this._segList.addPt(squareCapROffset);
  30871. break;
  30872. default:
  30873. }
  30874. };
  30875. OffsetSegmentGenerator.prototype.getCoordinates = function getCoordinates5() {
  30876. var pts = this._segList.getCoordinates();
  30877. return pts;
  30878. };
  30879. OffsetSegmentGenerator.prototype.addMitreJoin = function addMitreJoin(p, offset0, offset1, distance11) {
  30880. var isMitreWithinLimit = true;
  30881. var intPt = null;
  30882. try {
  30883. intPt = HCoordinate.intersection(offset0.p0, offset0.p1, offset1.p0, offset1.p1);
  30884. var mitreRatio = distance11 <= 0 ? 1 : intPt.distance(p) / Math.abs(distance11);
  30885. if (mitreRatio > this._bufParams.getMitreLimit()) {
  30886. isMitreWithinLimit = false;
  30887. }
  30888. } catch (ex) {
  30889. if (ex instanceof NotRepresentableException) {
  30890. intPt = new Coordinate(0, 0);
  30891. isMitreWithinLimit = false;
  30892. } else {
  30893. throw ex;
  30894. }
  30895. } finally {
  30896. }
  30897. if (isMitreWithinLimit) {
  30898. this._segList.addPt(intPt);
  30899. } else {
  30900. this.addLimitedMitreJoin(offset0, offset1, distance11, this._bufParams.getMitreLimit());
  30901. }
  30902. };
  30903. OffsetSegmentGenerator.prototype.addFilletCorner = function addFilletCorner(p, p0, p1, direction, radius) {
  30904. var dx0 = p0.x - p.x;
  30905. var dy0 = p0.y - p.y;
  30906. var startAngle = Math.atan2(dy0, dx0);
  30907. var dx1 = p1.x - p.x;
  30908. var dy1 = p1.y - p.y;
  30909. var endAngle = Math.atan2(dy1, dx1);
  30910. if (direction === CGAlgorithms.CLOCKWISE) {
  30911. if (startAngle <= endAngle) {
  30912. startAngle += 2 * Math.PI;
  30913. }
  30914. } else {
  30915. if (startAngle >= endAngle) {
  30916. startAngle -= 2 * Math.PI;
  30917. }
  30918. }
  30919. this._segList.addPt(p0);
  30920. this.addFilletArc(p, startAngle, endAngle, direction, radius);
  30921. this._segList.addPt(p1);
  30922. };
  30923. OffsetSegmentGenerator.prototype.addOutsideTurn = function addOutsideTurn(orientation2, addStartPoint) {
  30924. if (this._offset0.p1.distance(this._offset1.p0) < this._distance * OffsetSegmentGenerator.OFFSET_SEGMENT_SEPARATION_FACTOR) {
  30925. this._segList.addPt(this._offset0.p1);
  30926. return null;
  30927. }
  30928. if (this._bufParams.getJoinStyle() === BufferParameters.JOIN_MITRE) {
  30929. this.addMitreJoin(this._s1, this._offset0, this._offset1, this._distance);
  30930. } else if (this._bufParams.getJoinStyle() === BufferParameters.JOIN_BEVEL) {
  30931. this.addBevelJoin(this._offset0, this._offset1);
  30932. } else {
  30933. if (addStartPoint) {
  30934. this._segList.addPt(this._offset0.p1);
  30935. }
  30936. this.addFilletCorner(this._s1, this._offset0.p1, this._offset1.p0, orientation2, this._distance);
  30937. this._segList.addPt(this._offset1.p0);
  30938. }
  30939. };
  30940. OffsetSegmentGenerator.prototype.createSquare = function createSquare(p) {
  30941. this._segList.addPt(new Coordinate(p.x + this._distance, p.y + this._distance));
  30942. this._segList.addPt(new Coordinate(p.x + this._distance, p.y - this._distance));
  30943. this._segList.addPt(new Coordinate(p.x - this._distance, p.y - this._distance));
  30944. this._segList.addPt(new Coordinate(p.x - this._distance, p.y + this._distance));
  30945. this._segList.closeRing();
  30946. };
  30947. OffsetSegmentGenerator.prototype.addSegments = function addSegments(pt, isForward) {
  30948. this._segList.addPts(pt, isForward);
  30949. };
  30950. OffsetSegmentGenerator.prototype.addFirstSegment = function addFirstSegment() {
  30951. this._segList.addPt(this._offset1.p0);
  30952. };
  30953. OffsetSegmentGenerator.prototype.addLastSegment = function addLastSegment() {
  30954. this._segList.addPt(this._offset1.p1);
  30955. };
  30956. OffsetSegmentGenerator.prototype.initSideSegments = function initSideSegments(s1, s2, side) {
  30957. this._s1 = s1;
  30958. this._s2 = s2;
  30959. this._side = side;
  30960. this._seg1.setCoordinates(s1, s2);
  30961. this.computeOffsetSegment(this._seg1, side, this._distance, this._offset1);
  30962. };
  30963. OffsetSegmentGenerator.prototype.addLimitedMitreJoin = function addLimitedMitreJoin(offset0, offset1, distance11, mitreLimit) {
  30964. var basePt = this._seg0.p1;
  30965. var ang0 = Angle.angle(basePt, this._seg0.p0);
  30966. var angDiff = Angle.angleBetweenOriented(this._seg0.p0, basePt, this._seg1.p1);
  30967. var angDiffHalf = angDiff / 2;
  30968. var midAng = Angle.normalize(ang0 + angDiffHalf);
  30969. var mitreMidAng = Angle.normalize(midAng + Math.PI);
  30970. var mitreDist = mitreLimit * distance11;
  30971. var bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
  30972. var bevelHalfLen = distance11 - bevelDelta;
  30973. var bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
  30974. var bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
  30975. var bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
  30976. var mitreMidLine = new LineSegment(basePt, bevelMidPt);
  30977. var bevelEndLeft = mitreMidLine.pointAlongOffset(1, bevelHalfLen);
  30978. var bevelEndRight = mitreMidLine.pointAlongOffset(1, -bevelHalfLen);
  30979. if (this._side === Position.LEFT) {
  30980. this._segList.addPt(bevelEndLeft);
  30981. this._segList.addPt(bevelEndRight);
  30982. } else {
  30983. this._segList.addPt(bevelEndRight);
  30984. this._segList.addPt(bevelEndLeft);
  30985. }
  30986. };
  30987. OffsetSegmentGenerator.prototype.computeOffsetSegment = function computeOffsetSegment(seg, side, distance11, offset) {
  30988. var sideSign = side === Position.LEFT ? 1 : -1;
  30989. var dx = seg.p1.x - seg.p0.x;
  30990. var dy = seg.p1.y - seg.p0.y;
  30991. var len = Math.sqrt(dx * dx + dy * dy);
  30992. var ux = sideSign * distance11 * dx / len;
  30993. var uy = sideSign * distance11 * dy / len;
  30994. offset.p0.x = seg.p0.x - uy;
  30995. offset.p0.y = seg.p0.y + ux;
  30996. offset.p1.x = seg.p1.x - uy;
  30997. offset.p1.y = seg.p1.y + ux;
  30998. };
  30999. OffsetSegmentGenerator.prototype.addFilletArc = function addFilletArc(p, startAngle, endAngle, direction, radius) {
  31000. var this$1 = this;
  31001. var directionFactor = direction === CGAlgorithms.CLOCKWISE ? -1 : 1;
  31002. var totalAngle = Math.abs(startAngle - endAngle);
  31003. var nSegs = Math.trunc(totalAngle / this._filletAngleQuantum + 0.5);
  31004. if (nSegs < 1) {
  31005. return null;
  31006. }
  31007. var initAngle = 0;
  31008. var currAngleInc = totalAngle / nSegs;
  31009. var currAngle = initAngle;
  31010. var pt = new Coordinate();
  31011. while (currAngle < totalAngle) {
  31012. var angle4 = startAngle + directionFactor * currAngle;
  31013. pt.x = p.x + radius * Math.cos(angle4);
  31014. pt.y = p.y + radius * Math.sin(angle4);
  31015. this$1._segList.addPt(pt);
  31016. currAngle += currAngleInc;
  31017. }
  31018. };
  31019. OffsetSegmentGenerator.prototype.addInsideTurn = function addInsideTurn(orientation2, addStartPoint) {
  31020. this._li.computeIntersection(this._offset0.p0, this._offset0.p1, this._offset1.p0, this._offset1.p1);
  31021. if (this._li.hasIntersection()) {
  31022. this._segList.addPt(this._li.getIntersection(0));
  31023. } else {
  31024. this._hasNarrowConcaveAngle = true;
  31025. if (this._offset0.p1.distance(this._offset1.p0) < this._distance * OffsetSegmentGenerator.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR) {
  31026. this._segList.addPt(this._offset0.p1);
  31027. } else {
  31028. this._segList.addPt(this._offset0.p1);
  31029. if (this._closingSegLengthFactor > 0) {
  31030. var mid0 = new Coordinate((this._closingSegLengthFactor * this._offset0.p1.x + this._s1.x) / (this._closingSegLengthFactor + 1), (this._closingSegLengthFactor * this._offset0.p1.y + this._s1.y) / (this._closingSegLengthFactor + 1));
  31031. this._segList.addPt(mid0);
  31032. var mid1 = new Coordinate((this._closingSegLengthFactor * this._offset1.p0.x + this._s1.x) / (this._closingSegLengthFactor + 1), (this._closingSegLengthFactor * this._offset1.p0.y + this._s1.y) / (this._closingSegLengthFactor + 1));
  31033. this._segList.addPt(mid1);
  31034. } else {
  31035. this._segList.addPt(this._s1);
  31036. }
  31037. this._segList.addPt(this._offset1.p0);
  31038. }
  31039. }
  31040. };
  31041. OffsetSegmentGenerator.prototype.createCircle = function createCircle(p) {
  31042. var pt = new Coordinate(p.x + this._distance, p.y);
  31043. this._segList.addPt(pt);
  31044. this.addFilletArc(p, 0, 2 * Math.PI, -1, this._distance);
  31045. this._segList.closeRing();
  31046. };
  31047. OffsetSegmentGenerator.prototype.addBevelJoin = function addBevelJoin(offset0, offset1) {
  31048. this._segList.addPt(offset0.p1);
  31049. this._segList.addPt(offset1.p0);
  31050. };
  31051. OffsetSegmentGenerator.prototype.init = function init5(distance11) {
  31052. this._distance = distance11;
  31053. this._maxCurveSegmentError = distance11 * (1 - Math.cos(this._filletAngleQuantum / 2));
  31054. this._segList = new OffsetSegmentString();
  31055. this._segList.setPrecisionModel(this._precisionModel);
  31056. this._segList.setMinimumVertexDistance(distance11 * OffsetSegmentGenerator.CURVE_VERTEX_SNAP_DISTANCE_FACTOR);
  31057. };
  31058. OffsetSegmentGenerator.prototype.addCollinear = function addCollinear(addStartPoint) {
  31059. this._li.computeIntersection(this._s0, this._s1, this._s1, this._s2);
  31060. var numInt = this._li.getIntersectionNum();
  31061. if (numInt >= 2) {
  31062. if (this._bufParams.getJoinStyle() === BufferParameters.JOIN_BEVEL || this._bufParams.getJoinStyle() === BufferParameters.JOIN_MITRE) {
  31063. if (addStartPoint) {
  31064. this._segList.addPt(this._offset0.p1);
  31065. }
  31066. this._segList.addPt(this._offset1.p0);
  31067. } else {
  31068. this.addFilletCorner(this._s1, this._offset0.p1, this._offset1.p0, CGAlgorithms.CLOCKWISE, this._distance);
  31069. }
  31070. }
  31071. };
  31072. OffsetSegmentGenerator.prototype.closeRing = function closeRing2() {
  31073. this._segList.closeRing();
  31074. };
  31075. OffsetSegmentGenerator.prototype.hasNarrowConcaveAngle = function hasNarrowConcaveAngle() {
  31076. return this._hasNarrowConcaveAngle;
  31077. };
  31078. OffsetSegmentGenerator.prototype.interfaces_ = function interfaces_87() {
  31079. return [];
  31080. };
  31081. OffsetSegmentGenerator.prototype.getClass = function getClass86() {
  31082. return OffsetSegmentGenerator;
  31083. };
  31084. staticAccessors$27.OFFSET_SEGMENT_SEPARATION_FACTOR.get = function() {
  31085. return 1e-3;
  31086. };
  31087. staticAccessors$27.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get = function() {
  31088. return 1e-3;
  31089. };
  31090. staticAccessors$27.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get = function() {
  31091. return 1e-6;
  31092. };
  31093. staticAccessors$27.MAX_CLOSING_SEG_LEN_FACTOR.get = function() {
  31094. return 80;
  31095. };
  31096. Object.defineProperties(OffsetSegmentGenerator, staticAccessors$27);
  31097. var OffsetCurveBuilder = function OffsetCurveBuilder2() {
  31098. this._distance = 0;
  31099. this._precisionModel = null;
  31100. this._bufParams = null;
  31101. var precisionModel = arguments[0];
  31102. var bufParams = arguments[1];
  31103. this._precisionModel = precisionModel;
  31104. this._bufParams = bufParams;
  31105. };
  31106. OffsetCurveBuilder.prototype.getOffsetCurve = function getOffsetCurve(inputPts, distance11) {
  31107. this._distance = distance11;
  31108. if (distance11 === 0) {
  31109. return null;
  31110. }
  31111. var isRightSide = distance11 < 0;
  31112. var posDistance = Math.abs(distance11);
  31113. var segGen = this.getSegGen(posDistance);
  31114. if (inputPts.length <= 1) {
  31115. this.computePointCurve(inputPts[0], segGen);
  31116. } else {
  31117. this.computeOffsetCurve(inputPts, isRightSide, segGen);
  31118. }
  31119. var curvePts = segGen.getCoordinates();
  31120. if (isRightSide) {
  31121. CoordinateArrays.reverse(curvePts);
  31122. }
  31123. return curvePts;
  31124. };
  31125. OffsetCurveBuilder.prototype.computeSingleSidedBufferCurve = function computeSingleSidedBufferCurve(inputPts, isRightSide, segGen) {
  31126. var distTol = this.simplifyTolerance(this._distance);
  31127. if (isRightSide) {
  31128. segGen.addSegments(inputPts, true);
  31129. var simp2 = BufferInputLineSimplifier.simplify(inputPts, -distTol);
  31130. var n2 = simp2.length - 1;
  31131. segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
  31132. segGen.addFirstSegment();
  31133. for (var i = n2 - 2; i >= 0; i--) {
  31134. segGen.addNextSegment(simp2[i], true);
  31135. }
  31136. } else {
  31137. segGen.addSegments(inputPts, false);
  31138. var simp1 = BufferInputLineSimplifier.simplify(inputPts, distTol);
  31139. var n1 = simp1.length - 1;
  31140. segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
  31141. segGen.addFirstSegment();
  31142. for (var i$1 = 2; i$1 <= n1; i$1++) {
  31143. segGen.addNextSegment(simp1[i$1], true);
  31144. }
  31145. }
  31146. segGen.addLastSegment();
  31147. segGen.closeRing();
  31148. };
  31149. OffsetCurveBuilder.prototype.computeRingBufferCurve = function computeRingBufferCurve(inputPts, side, segGen) {
  31150. var distTol = this.simplifyTolerance(this._distance);
  31151. if (side === Position.RIGHT) {
  31152. distTol = -distTol;
  31153. }
  31154. var simp = BufferInputLineSimplifier.simplify(inputPts, distTol);
  31155. var n = simp.length - 1;
  31156. segGen.initSideSegments(simp[n - 1], simp[0], side);
  31157. for (var i = 1; i <= n; i++) {
  31158. var addStartPoint = i !== 1;
  31159. segGen.addNextSegment(simp[i], addStartPoint);
  31160. }
  31161. segGen.closeRing();
  31162. };
  31163. OffsetCurveBuilder.prototype.computeLineBufferCurve = function computeLineBufferCurve(inputPts, segGen) {
  31164. var distTol = this.simplifyTolerance(this._distance);
  31165. var simp1 = BufferInputLineSimplifier.simplify(inputPts, distTol);
  31166. var n1 = simp1.length - 1;
  31167. segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
  31168. for (var i = 2; i <= n1; i++) {
  31169. segGen.addNextSegment(simp1[i], true);
  31170. }
  31171. segGen.addLastSegment();
  31172. segGen.addLineEndCap(simp1[n1 - 1], simp1[n1]);
  31173. var simp2 = BufferInputLineSimplifier.simplify(inputPts, -distTol);
  31174. var n2 = simp2.length - 1;
  31175. segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
  31176. for (var i$1 = n2 - 2; i$1 >= 0; i$1--) {
  31177. segGen.addNextSegment(simp2[i$1], true);
  31178. }
  31179. segGen.addLastSegment();
  31180. segGen.addLineEndCap(simp2[1], simp2[0]);
  31181. segGen.closeRing();
  31182. };
  31183. OffsetCurveBuilder.prototype.computePointCurve = function computePointCurve(pt, segGen) {
  31184. switch (this._bufParams.getEndCapStyle()) {
  31185. case BufferParameters.CAP_ROUND:
  31186. segGen.createCircle(pt);
  31187. break;
  31188. case BufferParameters.CAP_SQUARE:
  31189. segGen.createSquare(pt);
  31190. break;
  31191. default:
  31192. }
  31193. };
  31194. OffsetCurveBuilder.prototype.getLineCurve = function getLineCurve(inputPts, distance11) {
  31195. this._distance = distance11;
  31196. if (distance11 < 0 && !this._bufParams.isSingleSided()) {
  31197. return null;
  31198. }
  31199. if (distance11 === 0) {
  31200. return null;
  31201. }
  31202. var posDistance = Math.abs(distance11);
  31203. var segGen = this.getSegGen(posDistance);
  31204. if (inputPts.length <= 1) {
  31205. this.computePointCurve(inputPts[0], segGen);
  31206. } else {
  31207. if (this._bufParams.isSingleSided()) {
  31208. var isRightSide = distance11 < 0;
  31209. this.computeSingleSidedBufferCurve(inputPts, isRightSide, segGen);
  31210. } else {
  31211. this.computeLineBufferCurve(inputPts, segGen);
  31212. }
  31213. }
  31214. var lineCoord = segGen.getCoordinates();
  31215. return lineCoord;
  31216. };
  31217. OffsetCurveBuilder.prototype.getBufferParameters = function getBufferParameters() {
  31218. return this._bufParams;
  31219. };
  31220. OffsetCurveBuilder.prototype.simplifyTolerance = function simplifyTolerance(bufDistance) {
  31221. return bufDistance * this._bufParams.getSimplifyFactor();
  31222. };
  31223. OffsetCurveBuilder.prototype.getRingCurve = function getRingCurve(inputPts, side, distance11) {
  31224. this._distance = distance11;
  31225. if (inputPts.length <= 2) {
  31226. return this.getLineCurve(inputPts, distance11);
  31227. }
  31228. if (distance11 === 0) {
  31229. return OffsetCurveBuilder.copyCoordinates(inputPts);
  31230. }
  31231. var segGen = this.getSegGen(distance11);
  31232. this.computeRingBufferCurve(inputPts, side, segGen);
  31233. return segGen.getCoordinates();
  31234. };
  31235. OffsetCurveBuilder.prototype.computeOffsetCurve = function computeOffsetCurve(inputPts, isRightSide, segGen) {
  31236. var distTol = this.simplifyTolerance(this._distance);
  31237. if (isRightSide) {
  31238. var simp2 = BufferInputLineSimplifier.simplify(inputPts, -distTol);
  31239. var n2 = simp2.length - 1;
  31240. segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
  31241. segGen.addFirstSegment();
  31242. for (var i = n2 - 2; i >= 0; i--) {
  31243. segGen.addNextSegment(simp2[i], true);
  31244. }
  31245. } else {
  31246. var simp1 = BufferInputLineSimplifier.simplify(inputPts, distTol);
  31247. var n1 = simp1.length - 1;
  31248. segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
  31249. segGen.addFirstSegment();
  31250. for (var i$1 = 2; i$1 <= n1; i$1++) {
  31251. segGen.addNextSegment(simp1[i$1], true);
  31252. }
  31253. }
  31254. segGen.addLastSegment();
  31255. };
  31256. OffsetCurveBuilder.prototype.getSegGen = function getSegGen(distance11) {
  31257. return new OffsetSegmentGenerator(this._precisionModel, this._bufParams, distance11);
  31258. };
  31259. OffsetCurveBuilder.prototype.interfaces_ = function interfaces_88() {
  31260. return [];
  31261. };
  31262. OffsetCurveBuilder.prototype.getClass = function getClass87() {
  31263. return OffsetCurveBuilder;
  31264. };
  31265. OffsetCurveBuilder.copyCoordinates = function copyCoordinates(pts) {
  31266. var copy7 = new Array(pts.length).fill(null);
  31267. for (var i = 0; i < copy7.length; i++) {
  31268. copy7[i] = new Coordinate(pts[i]);
  31269. }
  31270. return copy7;
  31271. };
  31272. var SubgraphDepthLocater = function SubgraphDepthLocater2() {
  31273. this._subgraphs = null;
  31274. this._seg = new LineSegment();
  31275. this._cga = new CGAlgorithms();
  31276. var subgraphs = arguments[0];
  31277. this._subgraphs = subgraphs;
  31278. };
  31279. var staticAccessors$30 = { DepthSegment: { configurable: true } };
  31280. SubgraphDepthLocater.prototype.findStabbedSegments = function findStabbedSegments() {
  31281. var this$1 = this;
  31282. if (arguments.length === 1) {
  31283. var stabbingRayLeftPt = arguments[0];
  31284. var stabbedSegments = new ArrayList();
  31285. for (var i = this._subgraphs.iterator(); i.hasNext(); ) {
  31286. var bsg = i.next();
  31287. var env = bsg.getEnvelope();
  31288. if (stabbingRayLeftPt.y < env.getMinY() || stabbingRayLeftPt.y > env.getMaxY()) {
  31289. continue;
  31290. }
  31291. this$1.findStabbedSegments(stabbingRayLeftPt, bsg.getDirectedEdges(), stabbedSegments);
  31292. }
  31293. return stabbedSegments;
  31294. } else if (arguments.length === 3) {
  31295. if (hasInterface(arguments[2], List) && (arguments[0] instanceof Coordinate && arguments[1] instanceof DirectedEdge)) {
  31296. var stabbingRayLeftPt$1 = arguments[0];
  31297. var dirEdge = arguments[1];
  31298. var stabbedSegments$1 = arguments[2];
  31299. var pts = dirEdge.getEdge().getCoordinates();
  31300. for (var i$1 = 0; i$1 < pts.length - 1; i$1++) {
  31301. this$1._seg.p0 = pts[i$1];
  31302. this$1._seg.p1 = pts[i$1 + 1];
  31303. if (this$1._seg.p0.y > this$1._seg.p1.y) {
  31304. this$1._seg.reverse();
  31305. }
  31306. var maxx = Math.max(this$1._seg.p0.x, this$1._seg.p1.x);
  31307. if (maxx < stabbingRayLeftPt$1.x) {
  31308. continue;
  31309. }
  31310. if (this$1._seg.isHorizontal()) {
  31311. continue;
  31312. }
  31313. if (stabbingRayLeftPt$1.y < this$1._seg.p0.y || stabbingRayLeftPt$1.y > this$1._seg.p1.y) {
  31314. continue;
  31315. }
  31316. if (CGAlgorithms.computeOrientation(this$1._seg.p0, this$1._seg.p1, stabbingRayLeftPt$1) === CGAlgorithms.RIGHT) {
  31317. continue;
  31318. }
  31319. var depth2 = dirEdge.getDepth(Position.LEFT);
  31320. if (!this$1._seg.p0.equals(pts[i$1])) {
  31321. depth2 = dirEdge.getDepth(Position.RIGHT);
  31322. }
  31323. var ds = new DepthSegment(this$1._seg, depth2);
  31324. stabbedSegments$1.add(ds);
  31325. }
  31326. } else if (hasInterface(arguments[2], List) && (arguments[0] instanceof Coordinate && hasInterface(arguments[1], List))) {
  31327. var stabbingRayLeftPt$2 = arguments[0];
  31328. var dirEdges = arguments[1];
  31329. var stabbedSegments$2 = arguments[2];
  31330. for (var i$2 = dirEdges.iterator(); i$2.hasNext(); ) {
  31331. var de = i$2.next();
  31332. if (!de.isForward()) {
  31333. continue;
  31334. }
  31335. this$1.findStabbedSegments(stabbingRayLeftPt$2, de, stabbedSegments$2);
  31336. }
  31337. }
  31338. }
  31339. };
  31340. SubgraphDepthLocater.prototype.getDepth = function getDepth(p) {
  31341. var stabbedSegments = this.findStabbedSegments(p);
  31342. if (stabbedSegments.size() === 0) {
  31343. return 0;
  31344. }
  31345. var ds = Collections.min(stabbedSegments);
  31346. return ds._leftDepth;
  31347. };
  31348. SubgraphDepthLocater.prototype.interfaces_ = function interfaces_89() {
  31349. return [];
  31350. };
  31351. SubgraphDepthLocater.prototype.getClass = function getClass88() {
  31352. return SubgraphDepthLocater;
  31353. };
  31354. staticAccessors$30.DepthSegment.get = function() {
  31355. return DepthSegment;
  31356. };
  31357. Object.defineProperties(SubgraphDepthLocater, staticAccessors$30);
  31358. var DepthSegment = function DepthSegment2() {
  31359. this._upwardSeg = null;
  31360. this._leftDepth = null;
  31361. var seg = arguments[0];
  31362. var depth2 = arguments[1];
  31363. this._upwardSeg = new LineSegment(seg);
  31364. this._leftDepth = depth2;
  31365. };
  31366. DepthSegment.prototype.compareTo = function compareTo12(obj) {
  31367. var other = obj;
  31368. if (this._upwardSeg.minX() >= other._upwardSeg.maxX()) {
  31369. return 1;
  31370. }
  31371. if (this._upwardSeg.maxX() <= other._upwardSeg.minX()) {
  31372. return -1;
  31373. }
  31374. var orientIndex = this._upwardSeg.orientationIndex(other._upwardSeg);
  31375. if (orientIndex !== 0) {
  31376. return orientIndex;
  31377. }
  31378. orientIndex = -1 * other._upwardSeg.orientationIndex(this._upwardSeg);
  31379. if (orientIndex !== 0) {
  31380. return orientIndex;
  31381. }
  31382. return this._upwardSeg.compareTo(other._upwardSeg);
  31383. };
  31384. DepthSegment.prototype.compareX = function compareX(seg0, seg1) {
  31385. var compare0 = seg0.p0.compareTo(seg1.p0);
  31386. if (compare0 !== 0) {
  31387. return compare0;
  31388. }
  31389. return seg0.p1.compareTo(seg1.p1);
  31390. };
  31391. DepthSegment.prototype.toString = function toString17() {
  31392. return this._upwardSeg.toString();
  31393. };
  31394. DepthSegment.prototype.interfaces_ = function interfaces_90() {
  31395. return [Comparable];
  31396. };
  31397. DepthSegment.prototype.getClass = function getClass89() {
  31398. return DepthSegment;
  31399. };
  31400. var Triangle2 = function Triangle3(p0, p1, p2) {
  31401. this.p0 = p0 || null;
  31402. this.p1 = p1 || null;
  31403. this.p2 = p2 || null;
  31404. };
  31405. Triangle2.prototype.area = function area3() {
  31406. return Triangle2.area(this.p0, this.p1, this.p2);
  31407. };
  31408. Triangle2.prototype.signedArea = function signedArea2() {
  31409. return Triangle2.signedArea(this.p0, this.p1, this.p2);
  31410. };
  31411. Triangle2.prototype.interpolateZ = function interpolateZ(p) {
  31412. if (p === null) {
  31413. throw new IllegalArgumentException("Supplied point is null.");
  31414. }
  31415. return Triangle2.interpolateZ(p, this.p0, this.p1, this.p2);
  31416. };
  31417. Triangle2.prototype.longestSideLength = function longestSideLength() {
  31418. return Triangle2.longestSideLength(this.p0, this.p1, this.p2);
  31419. };
  31420. Triangle2.prototype.isAcute = function isAcute2() {
  31421. return Triangle2.isAcute(this.p0, this.p1, this.p2);
  31422. };
  31423. Triangle2.prototype.circumcentre = function circumcentre() {
  31424. return Triangle2.circumcentre(this.p0, this.p1, this.p2);
  31425. };
  31426. Triangle2.prototype.area3D = function area3D() {
  31427. return Triangle2.area3D(this.p0, this.p1, this.p2);
  31428. };
  31429. Triangle2.prototype.centroid = function centroid2() {
  31430. return Triangle2.centroid(this.p0, this.p1, this.p2);
  31431. };
  31432. Triangle2.prototype.inCentre = function inCentre() {
  31433. return Triangle2.inCentre(this.p0, this.p1, this.p2);
  31434. };
  31435. Triangle2.prototype.interfaces_ = function interfaces_91() {
  31436. return [];
  31437. };
  31438. Triangle2.prototype.getClass = function getClass90() {
  31439. return Triangle2;
  31440. };
  31441. Triangle2.area = function area4(a, b, c) {
  31442. return Math.abs(((c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y)) / 2);
  31443. };
  31444. Triangle2.signedArea = function signedArea3(a, b, c) {
  31445. return ((c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y)) / 2;
  31446. };
  31447. Triangle2.det = function det(m00, m01, m10, m11) {
  31448. return m00 * m11 - m01 * m10;
  31449. };
  31450. Triangle2.interpolateZ = function interpolateZ2(p, v0, v1, v2) {
  31451. var x02 = v0.x;
  31452. var y02 = v0.y;
  31453. var a = v1.x - x02;
  31454. var b = v2.x - x02;
  31455. var c = v1.y - y02;
  31456. var d = v2.y - y02;
  31457. var det2 = a * d - b * c;
  31458. var dx = p.x - x02;
  31459. var dy = p.y - y02;
  31460. var t = (d * dx - b * dy) / det2;
  31461. var u = (-c * dx + a * dy) / det2;
  31462. var z = v0.z + t * (v1.z - v0.z) + u * (v2.z - v0.z);
  31463. return z;
  31464. };
  31465. Triangle2.longestSideLength = function longestSideLength2(a, b, c) {
  31466. var lenAB = a.distance(b);
  31467. var lenBC = b.distance(c);
  31468. var lenCA = c.distance(a);
  31469. var maxLen = lenAB;
  31470. if (lenBC > maxLen) {
  31471. maxLen = lenBC;
  31472. }
  31473. if (lenCA > maxLen) {
  31474. maxLen = lenCA;
  31475. }
  31476. return maxLen;
  31477. };
  31478. Triangle2.isAcute = function isAcute3(a, b, c) {
  31479. if (!Angle.isAcute(a, b, c)) {
  31480. return false;
  31481. }
  31482. if (!Angle.isAcute(b, c, a)) {
  31483. return false;
  31484. }
  31485. if (!Angle.isAcute(c, a, b)) {
  31486. return false;
  31487. }
  31488. return true;
  31489. };
  31490. Triangle2.circumcentre = function circumcentre2(a, b, c) {
  31491. var cx = c.x;
  31492. var cy = c.y;
  31493. var ax = a.x - cx;
  31494. var ay = a.y - cy;
  31495. var bx = b.x - cx;
  31496. var by = b.y - cy;
  31497. var denom = 2 * Triangle2.det(ax, ay, bx, by);
  31498. var numx = Triangle2.det(ay, ax * ax + ay * ay, by, bx * bx + by * by);
  31499. var numy = Triangle2.det(ax, ax * ax + ay * ay, bx, bx * bx + by * by);
  31500. var ccx = cx - numx / denom;
  31501. var ccy = cy + numy / denom;
  31502. return new Coordinate(ccx, ccy);
  31503. };
  31504. Triangle2.perpendicularBisector = function perpendicularBisector(a, b) {
  31505. var dx = b.x - a.x;
  31506. var dy = b.y - a.y;
  31507. var l1 = new HCoordinate(a.x + dx / 2, a.y + dy / 2, 1);
  31508. var l2 = new HCoordinate(a.x - dy + dx / 2, a.y + dx + dy / 2, 1);
  31509. return new HCoordinate(l1, l2);
  31510. };
  31511. Triangle2.angleBisector = function angleBisector(a, b, c) {
  31512. var len0 = b.distance(a);
  31513. var len2 = b.distance(c);
  31514. var frac = len0 / (len0 + len2);
  31515. var dx = c.x - a.x;
  31516. var dy = c.y - a.y;
  31517. var splitPt = new Coordinate(a.x + frac * dx, a.y + frac * dy);
  31518. return splitPt;
  31519. };
  31520. Triangle2.area3D = function area3D2(a, b, c) {
  31521. var ux = b.x - a.x;
  31522. var uy = b.y - a.y;
  31523. var uz = b.z - a.z;
  31524. var vx = c.x - a.x;
  31525. var vy = c.y - a.y;
  31526. var vz = c.z - a.z;
  31527. var crossx = uy * vz - uz * vy;
  31528. var crossy = uz * vx - ux * vz;
  31529. var crossz = ux * vy - uy * vx;
  31530. var absSq = crossx * crossx + crossy * crossy + crossz * crossz;
  31531. var area3D3 = Math.sqrt(absSq) / 2;
  31532. return area3D3;
  31533. };
  31534. Triangle2.centroid = function centroid3(a, b, c) {
  31535. var x2 = (a.x + b.x + c.x) / 3;
  31536. var y2 = (a.y + b.y + c.y) / 3;
  31537. return new Coordinate(x2, y2);
  31538. };
  31539. Triangle2.inCentre = function inCentre2(a, b, c) {
  31540. var len0 = b.distance(c);
  31541. var len1 = a.distance(c);
  31542. var len2 = a.distance(b);
  31543. var circum = len0 + len1 + len2;
  31544. var inCentreX = (len0 * a.x + len1 * b.x + len2 * c.x) / circum;
  31545. var inCentreY = (len0 * a.y + len1 * b.y + len2 * c.y) / circum;
  31546. return new Coordinate(inCentreX, inCentreY);
  31547. };
  31548. var OffsetCurveSetBuilder = function OffsetCurveSetBuilder2() {
  31549. this._inputGeom = null;
  31550. this._distance = null;
  31551. this._curveBuilder = null;
  31552. this._curveList = new ArrayList();
  31553. var inputGeom = arguments[0];
  31554. var distance11 = arguments[1];
  31555. var curveBuilder = arguments[2];
  31556. this._inputGeom = inputGeom;
  31557. this._distance = distance11;
  31558. this._curveBuilder = curveBuilder;
  31559. };
  31560. OffsetCurveSetBuilder.prototype.addPoint = function addPoint(p) {
  31561. if (this._distance <= 0) {
  31562. return null;
  31563. }
  31564. var coord = p.getCoordinates();
  31565. var curve = this._curveBuilder.getLineCurve(coord, this._distance);
  31566. this.addCurve(curve, Location.EXTERIOR, Location.INTERIOR);
  31567. };
  31568. OffsetCurveSetBuilder.prototype.addPolygon = function addPolygon(p) {
  31569. var this$1 = this;
  31570. var offsetDistance = this._distance;
  31571. var offsetSide = Position.LEFT;
  31572. if (this._distance < 0) {
  31573. offsetDistance = -this._distance;
  31574. offsetSide = Position.RIGHT;
  31575. }
  31576. var shell = p.getExteriorRing();
  31577. var shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates());
  31578. if (this._distance < 0 && this.isErodedCompletely(shell, this._distance)) {
  31579. return null;
  31580. }
  31581. if (this._distance <= 0 && shellCoord.length < 3) {
  31582. return null;
  31583. }
  31584. this.addPolygonRing(shellCoord, offsetDistance, offsetSide, Location.EXTERIOR, Location.INTERIOR);
  31585. for (var i = 0; i < p.getNumInteriorRing(); i++) {
  31586. var hole = p.getInteriorRingN(i);
  31587. var holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());
  31588. if (this$1._distance > 0 && this$1.isErodedCompletely(hole, -this$1._distance)) {
  31589. continue;
  31590. }
  31591. this$1.addPolygonRing(holeCoord, offsetDistance, Position.opposite(offsetSide), Location.INTERIOR, Location.EXTERIOR);
  31592. }
  31593. };
  31594. OffsetCurveSetBuilder.prototype.isTriangleErodedCompletely = function isTriangleErodedCompletely(triangleCoord, bufferDistance) {
  31595. var tri = new Triangle2(triangleCoord[0], triangleCoord[1], triangleCoord[2]);
  31596. var inCentre3 = tri.inCentre();
  31597. var distToCentre = CGAlgorithms.distancePointLine(inCentre3, tri.p0, tri.p1);
  31598. return distToCentre < Math.abs(bufferDistance);
  31599. };
  31600. OffsetCurveSetBuilder.prototype.addLineString = function addLineString(line) {
  31601. if (this._distance <= 0 && !this._curveBuilder.getBufferParameters().isSingleSided()) {
  31602. return null;
  31603. }
  31604. var coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
  31605. var curve = this._curveBuilder.getLineCurve(coord, this._distance);
  31606. this.addCurve(curve, Location.EXTERIOR, Location.INTERIOR);
  31607. };
  31608. OffsetCurveSetBuilder.prototype.addCurve = function addCurve(coord, leftLoc, rightLoc) {
  31609. if (coord === null || coord.length < 2) {
  31610. return null;
  31611. }
  31612. var e = new NodedSegmentString(coord, new Label(0, Location.BOUNDARY, leftLoc, rightLoc));
  31613. this._curveList.add(e);
  31614. };
  31615. OffsetCurveSetBuilder.prototype.getCurves = function getCurves() {
  31616. this.add(this._inputGeom);
  31617. return this._curveList;
  31618. };
  31619. OffsetCurveSetBuilder.prototype.addPolygonRing = function addPolygonRing(coord, offsetDistance, side, cwLeftLoc, cwRightLoc) {
  31620. if (offsetDistance === 0 && coord.length < LinearRing.MINIMUM_VALID_SIZE) {
  31621. return null;
  31622. }
  31623. var leftLoc = cwLeftLoc;
  31624. var rightLoc = cwRightLoc;
  31625. if (coord.length >= LinearRing.MINIMUM_VALID_SIZE && CGAlgorithms.isCCW(coord)) {
  31626. leftLoc = cwRightLoc;
  31627. rightLoc = cwLeftLoc;
  31628. side = Position.opposite(side);
  31629. }
  31630. var curve = this._curveBuilder.getRingCurve(coord, side, offsetDistance);
  31631. this.addCurve(curve, leftLoc, rightLoc);
  31632. };
  31633. OffsetCurveSetBuilder.prototype.add = function add10(g) {
  31634. if (g.isEmpty()) {
  31635. return null;
  31636. }
  31637. if (g instanceof Polygon) {
  31638. this.addPolygon(g);
  31639. } else if (g instanceof LineString2) {
  31640. this.addLineString(g);
  31641. } else if (g instanceof Point) {
  31642. this.addPoint(g);
  31643. } else if (g instanceof MultiPoint) {
  31644. this.addCollection(g);
  31645. } else if (g instanceof MultiLineString) {
  31646. this.addCollection(g);
  31647. } else if (g instanceof MultiPolygon) {
  31648. this.addCollection(g);
  31649. } else if (g instanceof GeometryCollection) {
  31650. this.addCollection(g);
  31651. }
  31652. };
  31653. OffsetCurveSetBuilder.prototype.isErodedCompletely = function isErodedCompletely(ring, bufferDistance) {
  31654. var ringCoord = ring.getCoordinates();
  31655. if (ringCoord.length < 4) {
  31656. return bufferDistance < 0;
  31657. }
  31658. if (ringCoord.length === 4) {
  31659. return this.isTriangleErodedCompletely(ringCoord, bufferDistance);
  31660. }
  31661. var env = ring.getEnvelopeInternal();
  31662. var envMinDimension = Math.min(env.getHeight(), env.getWidth());
  31663. if (bufferDistance < 0 && 2 * Math.abs(bufferDistance) > envMinDimension) {
  31664. return true;
  31665. }
  31666. return false;
  31667. };
  31668. OffsetCurveSetBuilder.prototype.addCollection = function addCollection(gc) {
  31669. var this$1 = this;
  31670. for (var i = 0; i < gc.getNumGeometries(); i++) {
  31671. var g = gc.getGeometryN(i);
  31672. this$1.add(g);
  31673. }
  31674. };
  31675. OffsetCurveSetBuilder.prototype.interfaces_ = function interfaces_92() {
  31676. return [];
  31677. };
  31678. OffsetCurveSetBuilder.prototype.getClass = function getClass91() {
  31679. return OffsetCurveSetBuilder;
  31680. };
  31681. var PointOnGeometryLocator = function PointOnGeometryLocator2() {
  31682. };
  31683. PointOnGeometryLocator.prototype.locate = function locate(p) {
  31684. };
  31685. PointOnGeometryLocator.prototype.interfaces_ = function interfaces_93() {
  31686. return [];
  31687. };
  31688. PointOnGeometryLocator.prototype.getClass = function getClass92() {
  31689. return PointOnGeometryLocator;
  31690. };
  31691. var GeometryCollectionIterator = function GeometryCollectionIterator2() {
  31692. this._parent = null;
  31693. this._atStart = null;
  31694. this._max = null;
  31695. this._index = null;
  31696. this._subcollectionIterator = null;
  31697. var parent = arguments[0];
  31698. this._parent = parent;
  31699. this._atStart = true;
  31700. this._index = 0;
  31701. this._max = parent.getNumGeometries();
  31702. };
  31703. GeometryCollectionIterator.prototype.next = function next2() {
  31704. if (this._atStart) {
  31705. this._atStart = false;
  31706. if (GeometryCollectionIterator.isAtomic(this._parent)) {
  31707. this._index++;
  31708. }
  31709. return this._parent;
  31710. }
  31711. if (this._subcollectionIterator !== null) {
  31712. if (this._subcollectionIterator.hasNext()) {
  31713. return this._subcollectionIterator.next();
  31714. } else {
  31715. this._subcollectionIterator = null;
  31716. }
  31717. }
  31718. if (this._index >= this._max) {
  31719. throw new NoSuchElementException();
  31720. }
  31721. var obj = this._parent.getGeometryN(this._index++);
  31722. if (obj instanceof GeometryCollection) {
  31723. this._subcollectionIterator = new GeometryCollectionIterator(obj);
  31724. return this._subcollectionIterator.next();
  31725. }
  31726. return obj;
  31727. };
  31728. GeometryCollectionIterator.prototype.remove = function remove5() {
  31729. throw new Error(this.getClass().getName());
  31730. };
  31731. GeometryCollectionIterator.prototype.hasNext = function hasNext2() {
  31732. if (this._atStart) {
  31733. return true;
  31734. }
  31735. if (this._subcollectionIterator !== null) {
  31736. if (this._subcollectionIterator.hasNext()) {
  31737. return true;
  31738. }
  31739. this._subcollectionIterator = null;
  31740. }
  31741. if (this._index >= this._max) {
  31742. return false;
  31743. }
  31744. return true;
  31745. };
  31746. GeometryCollectionIterator.prototype.interfaces_ = function interfaces_94() {
  31747. return [Iterator];
  31748. };
  31749. GeometryCollectionIterator.prototype.getClass = function getClass93() {
  31750. return GeometryCollectionIterator;
  31751. };
  31752. GeometryCollectionIterator.isAtomic = function isAtomic(geom) {
  31753. return !(geom instanceof GeometryCollection);
  31754. };
  31755. var SimplePointInAreaLocator = function SimplePointInAreaLocator2() {
  31756. this._geom = null;
  31757. var geom = arguments[0];
  31758. this._geom = geom;
  31759. };
  31760. SimplePointInAreaLocator.prototype.locate = function locate2(p) {
  31761. return SimplePointInAreaLocator.locate(p, this._geom);
  31762. };
  31763. SimplePointInAreaLocator.prototype.interfaces_ = function interfaces_95() {
  31764. return [PointOnGeometryLocator];
  31765. };
  31766. SimplePointInAreaLocator.prototype.getClass = function getClass94() {
  31767. return SimplePointInAreaLocator;
  31768. };
  31769. SimplePointInAreaLocator.isPointInRing = function isPointInRing2(p, ring) {
  31770. if (!ring.getEnvelopeInternal().intersects(p)) {
  31771. return false;
  31772. }
  31773. return CGAlgorithms.isPointInRing(p, ring.getCoordinates());
  31774. };
  31775. SimplePointInAreaLocator.containsPointInPolygon = function containsPointInPolygon(p, poly) {
  31776. if (poly.isEmpty()) {
  31777. return false;
  31778. }
  31779. var shell = poly.getExteriorRing();
  31780. if (!SimplePointInAreaLocator.isPointInRing(p, shell)) {
  31781. return false;
  31782. }
  31783. for (var i = 0; i < poly.getNumInteriorRing(); i++) {
  31784. var hole = poly.getInteriorRingN(i);
  31785. if (SimplePointInAreaLocator.isPointInRing(p, hole)) {
  31786. return false;
  31787. }
  31788. }
  31789. return true;
  31790. };
  31791. SimplePointInAreaLocator.containsPoint = function containsPoint3(p, geom) {
  31792. if (geom instanceof Polygon) {
  31793. return SimplePointInAreaLocator.containsPointInPolygon(p, geom);
  31794. } else if (geom instanceof GeometryCollection) {
  31795. var geomi = new GeometryCollectionIterator(geom);
  31796. while (geomi.hasNext()) {
  31797. var g2 = geomi.next();
  31798. if (g2 !== geom) {
  31799. if (SimplePointInAreaLocator.containsPoint(p, g2)) {
  31800. return true;
  31801. }
  31802. }
  31803. }
  31804. }
  31805. return false;
  31806. };
  31807. SimplePointInAreaLocator.locate = function locate3(p, geom) {
  31808. if (geom.isEmpty()) {
  31809. return Location.EXTERIOR;
  31810. }
  31811. if (SimplePointInAreaLocator.containsPoint(p, geom)) {
  31812. return Location.INTERIOR;
  31813. }
  31814. return Location.EXTERIOR;
  31815. };
  31816. var EdgeEndStar = function EdgeEndStar2() {
  31817. this._edgeMap = new TreeMap();
  31818. this._edgeList = null;
  31819. this._ptInAreaLocation = [Location.NONE, Location.NONE];
  31820. };
  31821. EdgeEndStar.prototype.getNextCW = function getNextCW(ee) {
  31822. this.getEdges();
  31823. var i = this._edgeList.indexOf(ee);
  31824. var iNextCW = i - 1;
  31825. if (i === 0) {
  31826. iNextCW = this._edgeList.size() - 1;
  31827. }
  31828. return this._edgeList.get(iNextCW);
  31829. };
  31830. EdgeEndStar.prototype.propagateSideLabels = function propagateSideLabels(geomIndex) {
  31831. var startLoc = Location.NONE;
  31832. for (var it = this.iterator(); it.hasNext(); ) {
  31833. var e = it.next();
  31834. var label = e.getLabel();
  31835. if (label.isArea(geomIndex) && label.getLocation(geomIndex, Position.LEFT) !== Location.NONE) {
  31836. startLoc = label.getLocation(geomIndex, Position.LEFT);
  31837. }
  31838. }
  31839. if (startLoc === Location.NONE) {
  31840. return null;
  31841. }
  31842. var currLoc = startLoc;
  31843. for (var it$1 = this.iterator(); it$1.hasNext(); ) {
  31844. var e$1 = it$1.next();
  31845. var label$1 = e$1.getLabel();
  31846. if (label$1.getLocation(geomIndex, Position.ON) === Location.NONE) {
  31847. label$1.setLocation(geomIndex, Position.ON, currLoc);
  31848. }
  31849. if (label$1.isArea(geomIndex)) {
  31850. var leftLoc = label$1.getLocation(geomIndex, Position.LEFT);
  31851. var rightLoc = label$1.getLocation(geomIndex, Position.RIGHT);
  31852. if (rightLoc !== Location.NONE) {
  31853. if (rightLoc !== currLoc) {
  31854. throw new TopologyException("side location conflict", e$1.getCoordinate());
  31855. }
  31856. if (leftLoc === Location.NONE) {
  31857. Assert.shouldNeverReachHere("found single null side (at " + e$1.getCoordinate() + ")");
  31858. }
  31859. currLoc = leftLoc;
  31860. } else {
  31861. Assert.isTrue(label$1.getLocation(geomIndex, Position.LEFT) === Location.NONE, "found single null side");
  31862. label$1.setLocation(geomIndex, Position.RIGHT, currLoc);
  31863. label$1.setLocation(geomIndex, Position.LEFT, currLoc);
  31864. }
  31865. }
  31866. }
  31867. };
  31868. EdgeEndStar.prototype.getCoordinate = function getCoordinate11() {
  31869. var it = this.iterator();
  31870. if (!it.hasNext()) {
  31871. return null;
  31872. }
  31873. var e = it.next();
  31874. return e.getCoordinate();
  31875. };
  31876. EdgeEndStar.prototype.print = function print5(out) {
  31877. System.out.println("EdgeEndStar: " + this.getCoordinate());
  31878. for (var it = this.iterator(); it.hasNext(); ) {
  31879. var e = it.next();
  31880. e.print(out);
  31881. }
  31882. };
  31883. EdgeEndStar.prototype.isAreaLabelsConsistent = function isAreaLabelsConsistent(geomGraph) {
  31884. this.computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
  31885. return this.checkAreaLabelsConsistent(0);
  31886. };
  31887. EdgeEndStar.prototype.checkAreaLabelsConsistent = function checkAreaLabelsConsistent(geomIndex) {
  31888. var edges2 = this.getEdges();
  31889. if (edges2.size() <= 0) {
  31890. return true;
  31891. }
  31892. var lastEdgeIndex = edges2.size() - 1;
  31893. var startLabel = edges2.get(lastEdgeIndex).getLabel();
  31894. var startLoc = startLabel.getLocation(geomIndex, Position.LEFT);
  31895. Assert.isTrue(startLoc !== Location.NONE, "Found unlabelled area edge");
  31896. var currLoc = startLoc;
  31897. for (var it = this.iterator(); it.hasNext(); ) {
  31898. var e = it.next();
  31899. var label = e.getLabel();
  31900. Assert.isTrue(label.isArea(geomIndex), "Found non-area edge");
  31901. var leftLoc = label.getLocation(geomIndex, Position.LEFT);
  31902. var rightLoc = label.getLocation(geomIndex, Position.RIGHT);
  31903. if (leftLoc === rightLoc) {
  31904. return false;
  31905. }
  31906. if (rightLoc !== currLoc) {
  31907. return false;
  31908. }
  31909. currLoc = leftLoc;
  31910. }
  31911. return true;
  31912. };
  31913. EdgeEndStar.prototype.findIndex = function findIndex(eSearch) {
  31914. var this$1 = this;
  31915. this.iterator();
  31916. for (var i = 0; i < this._edgeList.size(); i++) {
  31917. var e = this$1._edgeList.get(i);
  31918. if (e === eSearch) {
  31919. return i;
  31920. }
  31921. }
  31922. return -1;
  31923. };
  31924. EdgeEndStar.prototype.iterator = function iterator4() {
  31925. return this.getEdges().iterator();
  31926. };
  31927. EdgeEndStar.prototype.getEdges = function getEdges2() {
  31928. if (this._edgeList === null) {
  31929. this._edgeList = new ArrayList(this._edgeMap.values());
  31930. }
  31931. return this._edgeList;
  31932. };
  31933. EdgeEndStar.prototype.getLocation = function getLocation3(geomIndex, p, geom) {
  31934. if (this._ptInAreaLocation[geomIndex] === Location.NONE) {
  31935. this._ptInAreaLocation[geomIndex] = SimplePointInAreaLocator.locate(p, geom[geomIndex].getGeometry());
  31936. }
  31937. return this._ptInAreaLocation[geomIndex];
  31938. };
  31939. EdgeEndStar.prototype.toString = function toString18() {
  31940. var buf = new StringBuffer();
  31941. buf.append("EdgeEndStar: " + this.getCoordinate());
  31942. buf.append("\n");
  31943. for (var it = this.iterator(); it.hasNext(); ) {
  31944. var e = it.next();
  31945. buf.append(e);
  31946. buf.append("\n");
  31947. }
  31948. return buf.toString();
  31949. };
  31950. EdgeEndStar.prototype.computeEdgeEndLabels = function computeEdgeEndLabels(boundaryNodeRule) {
  31951. for (var it = this.iterator(); it.hasNext(); ) {
  31952. var ee = it.next();
  31953. ee.computeLabel(boundaryNodeRule);
  31954. }
  31955. };
  31956. EdgeEndStar.prototype.computeLabelling = function computeLabelling(geomGraph) {
  31957. var this$1 = this;
  31958. this.computeEdgeEndLabels(geomGraph[0].getBoundaryNodeRule());
  31959. this.propagateSideLabels(0);
  31960. this.propagateSideLabels(1);
  31961. var hasDimensionalCollapseEdge = [false, false];
  31962. for (var it = this.iterator(); it.hasNext(); ) {
  31963. var e = it.next();
  31964. var label = e.getLabel();
  31965. for (var geomi = 0; geomi < 2; geomi++) {
  31966. if (label.isLine(geomi) && label.getLocation(geomi) === Location.BOUNDARY) {
  31967. hasDimensionalCollapseEdge[geomi] = true;
  31968. }
  31969. }
  31970. }
  31971. for (var it$1 = this.iterator(); it$1.hasNext(); ) {
  31972. var e$1 = it$1.next();
  31973. var label$1 = e$1.getLabel();
  31974. for (var geomi$1 = 0; geomi$1 < 2; geomi$1++) {
  31975. if (label$1.isAnyNull(geomi$1)) {
  31976. var loc = Location.NONE;
  31977. if (hasDimensionalCollapseEdge[geomi$1]) {
  31978. loc = Location.EXTERIOR;
  31979. } else {
  31980. var p = e$1.getCoordinate();
  31981. loc = this$1.getLocation(geomi$1, p, geomGraph);
  31982. }
  31983. label$1.setAllLocationsIfNull(geomi$1, loc);
  31984. }
  31985. }
  31986. }
  31987. };
  31988. EdgeEndStar.prototype.getDegree = function getDegree() {
  31989. return this._edgeMap.size();
  31990. };
  31991. EdgeEndStar.prototype.insertEdgeEnd = function insertEdgeEnd(e, obj) {
  31992. this._edgeMap.put(e, obj);
  31993. this._edgeList = null;
  31994. };
  31995. EdgeEndStar.prototype.interfaces_ = function interfaces_96() {
  31996. return [];
  31997. };
  31998. EdgeEndStar.prototype.getClass = function getClass95() {
  31999. return EdgeEndStar;
  32000. };
  32001. var DirectedEdgeStar = function(EdgeEndStar$$1) {
  32002. function DirectedEdgeStar2() {
  32003. EdgeEndStar$$1.call(this);
  32004. this._resultAreaEdgeList = null;
  32005. this._label = null;
  32006. this._SCANNING_FOR_INCOMING = 1;
  32007. this._LINKING_TO_OUTGOING = 2;
  32008. }
  32009. if (EdgeEndStar$$1)
  32010. DirectedEdgeStar2.__proto__ = EdgeEndStar$$1;
  32011. DirectedEdgeStar2.prototype = Object.create(EdgeEndStar$$1 && EdgeEndStar$$1.prototype);
  32012. DirectedEdgeStar2.prototype.constructor = DirectedEdgeStar2;
  32013. DirectedEdgeStar2.prototype.linkResultDirectedEdges = function linkResultDirectedEdges3() {
  32014. var this$1 = this;
  32015. this.getResultAreaEdges();
  32016. var firstOut = null;
  32017. var incoming = null;
  32018. var state = this._SCANNING_FOR_INCOMING;
  32019. for (var i = 0; i < this._resultAreaEdgeList.size(); i++) {
  32020. var nextOut = this$1._resultAreaEdgeList.get(i);
  32021. var nextIn = nextOut.getSym();
  32022. if (!nextOut.getLabel().isArea()) {
  32023. continue;
  32024. }
  32025. if (firstOut === null && nextOut.isInResult()) {
  32026. firstOut = nextOut;
  32027. }
  32028. switch (state) {
  32029. case this$1._SCANNING_FOR_INCOMING:
  32030. if (!nextIn.isInResult()) {
  32031. continue;
  32032. }
  32033. incoming = nextIn;
  32034. state = this$1._LINKING_TO_OUTGOING;
  32035. break;
  32036. case this$1._LINKING_TO_OUTGOING:
  32037. if (!nextOut.isInResult()) {
  32038. continue;
  32039. }
  32040. incoming.setNext(nextOut);
  32041. state = this$1._SCANNING_FOR_INCOMING;
  32042. break;
  32043. default:
  32044. }
  32045. }
  32046. if (state === this._LINKING_TO_OUTGOING) {
  32047. if (firstOut === null) {
  32048. throw new TopologyException("no outgoing dirEdge found", this.getCoordinate());
  32049. }
  32050. Assert.isTrue(firstOut.isInResult(), "unable to link last incoming dirEdge");
  32051. incoming.setNext(firstOut);
  32052. }
  32053. };
  32054. DirectedEdgeStar2.prototype.insert = function insert5(ee) {
  32055. var de = ee;
  32056. this.insertEdgeEnd(de, de);
  32057. };
  32058. DirectedEdgeStar2.prototype.getRightmostEdge = function getRightmostEdge() {
  32059. var edges2 = this.getEdges();
  32060. var size11 = edges2.size();
  32061. if (size11 < 1) {
  32062. return null;
  32063. }
  32064. var de0 = edges2.get(0);
  32065. if (size11 === 1) {
  32066. return de0;
  32067. }
  32068. var deLast = edges2.get(size11 - 1);
  32069. var quad0 = de0.getQuadrant();
  32070. var quad1 = deLast.getQuadrant();
  32071. if (Quadrant.isNorthern(quad0) && Quadrant.isNorthern(quad1)) {
  32072. return de0;
  32073. } else if (!Quadrant.isNorthern(quad0) && !Quadrant.isNorthern(quad1)) {
  32074. return deLast;
  32075. } else {
  32076. if (de0.getDy() !== 0) {
  32077. return de0;
  32078. } else if (deLast.getDy() !== 0) {
  32079. return deLast;
  32080. }
  32081. }
  32082. Assert.shouldNeverReachHere("found two horizontal edges incident on node");
  32083. return null;
  32084. };
  32085. DirectedEdgeStar2.prototype.print = function print9(out) {
  32086. System.out.println("DirectedEdgeStar: " + this.getCoordinate());
  32087. for (var it = this.iterator(); it.hasNext(); ) {
  32088. var de = it.next();
  32089. out.print("out ");
  32090. de.print(out);
  32091. out.println();
  32092. out.print("in ");
  32093. de.getSym().print(out);
  32094. out.println();
  32095. }
  32096. };
  32097. DirectedEdgeStar2.prototype.getResultAreaEdges = function getResultAreaEdges() {
  32098. var this$1 = this;
  32099. if (this._resultAreaEdgeList !== null) {
  32100. return this._resultAreaEdgeList;
  32101. }
  32102. this._resultAreaEdgeList = new ArrayList();
  32103. for (var it = this.iterator(); it.hasNext(); ) {
  32104. var de = it.next();
  32105. if (de.isInResult() || de.getSym().isInResult()) {
  32106. this$1._resultAreaEdgeList.add(de);
  32107. }
  32108. }
  32109. return this._resultAreaEdgeList;
  32110. };
  32111. DirectedEdgeStar2.prototype.updateLabelling = function updateLabelling(nodeLabel) {
  32112. for (var it = this.iterator(); it.hasNext(); ) {
  32113. var de = it.next();
  32114. var label = de.getLabel();
  32115. label.setAllLocationsIfNull(0, nodeLabel.getLocation(0));
  32116. label.setAllLocationsIfNull(1, nodeLabel.getLocation(1));
  32117. }
  32118. };
  32119. DirectedEdgeStar2.prototype.linkAllDirectedEdges = function linkAllDirectedEdges2() {
  32120. var this$1 = this;
  32121. this.getEdges();
  32122. var prevOut = null;
  32123. var firstIn = null;
  32124. for (var i = this._edgeList.size() - 1; i >= 0; i--) {
  32125. var nextOut = this$1._edgeList.get(i);
  32126. var nextIn = nextOut.getSym();
  32127. if (firstIn === null) {
  32128. firstIn = nextIn;
  32129. }
  32130. if (prevOut !== null) {
  32131. nextIn.setNext(prevOut);
  32132. }
  32133. prevOut = nextOut;
  32134. }
  32135. firstIn.setNext(prevOut);
  32136. };
  32137. DirectedEdgeStar2.prototype.computeDepths = function computeDepths2() {
  32138. var this$1 = this;
  32139. if (arguments.length === 1) {
  32140. var de = arguments[0];
  32141. var edgeIndex = this.findIndex(de);
  32142. var startDepth = de.getDepth(Position.LEFT);
  32143. var targetLastDepth = de.getDepth(Position.RIGHT);
  32144. var nextDepth = this.computeDepths(edgeIndex + 1, this._edgeList.size(), startDepth);
  32145. var lastDepth = this.computeDepths(0, edgeIndex, nextDepth);
  32146. if (lastDepth !== targetLastDepth) {
  32147. throw new TopologyException("depth mismatch at " + de.getCoordinate());
  32148. }
  32149. } else if (arguments.length === 3) {
  32150. var startIndex = arguments[0];
  32151. var endIndex = arguments[1];
  32152. var startDepth$1 = arguments[2];
  32153. var currDepth = startDepth$1;
  32154. for (var i = startIndex; i < endIndex; i++) {
  32155. var nextDe = this$1._edgeList.get(i);
  32156. nextDe.setEdgeDepths(Position.RIGHT, currDepth);
  32157. currDepth = nextDe.getDepth(Position.LEFT);
  32158. }
  32159. return currDepth;
  32160. }
  32161. };
  32162. DirectedEdgeStar2.prototype.mergeSymLabels = function mergeSymLabels() {
  32163. for (var it = this.iterator(); it.hasNext(); ) {
  32164. var de = it.next();
  32165. var label = de.getLabel();
  32166. label.merge(de.getSym().getLabel());
  32167. }
  32168. };
  32169. DirectedEdgeStar2.prototype.linkMinimalDirectedEdges = function linkMinimalDirectedEdges(er) {
  32170. var this$1 = this;
  32171. var firstOut = null;
  32172. var incoming = null;
  32173. var state = this._SCANNING_FOR_INCOMING;
  32174. for (var i = this._resultAreaEdgeList.size() - 1; i >= 0; i--) {
  32175. var nextOut = this$1._resultAreaEdgeList.get(i);
  32176. var nextIn = nextOut.getSym();
  32177. if (firstOut === null && nextOut.getEdgeRing() === er) {
  32178. firstOut = nextOut;
  32179. }
  32180. switch (state) {
  32181. case this$1._SCANNING_FOR_INCOMING:
  32182. if (nextIn.getEdgeRing() !== er) {
  32183. continue;
  32184. }
  32185. incoming = nextIn;
  32186. state = this$1._LINKING_TO_OUTGOING;
  32187. break;
  32188. case this$1._LINKING_TO_OUTGOING:
  32189. if (nextOut.getEdgeRing() !== er) {
  32190. continue;
  32191. }
  32192. incoming.setNextMin(nextOut);
  32193. state = this$1._SCANNING_FOR_INCOMING;
  32194. break;
  32195. default:
  32196. }
  32197. }
  32198. if (state === this._LINKING_TO_OUTGOING) {
  32199. Assert.isTrue(firstOut !== null, "found null for first outgoing dirEdge");
  32200. Assert.isTrue(firstOut.getEdgeRing() === er, "unable to link last incoming dirEdge");
  32201. incoming.setNextMin(firstOut);
  32202. }
  32203. };
  32204. DirectedEdgeStar2.prototype.getOutgoingDegree = function getOutgoingDegree() {
  32205. if (arguments.length === 0) {
  32206. var degree = 0;
  32207. for (var it = this.iterator(); it.hasNext(); ) {
  32208. var de = it.next();
  32209. if (de.isInResult()) {
  32210. degree++;
  32211. }
  32212. }
  32213. return degree;
  32214. } else if (arguments.length === 1) {
  32215. var er = arguments[0];
  32216. var degree$1 = 0;
  32217. for (var it$1 = this.iterator(); it$1.hasNext(); ) {
  32218. var de$1 = it$1.next();
  32219. if (de$1.getEdgeRing() === er) {
  32220. degree$1++;
  32221. }
  32222. }
  32223. return degree$1;
  32224. }
  32225. };
  32226. DirectedEdgeStar2.prototype.getLabel = function getLabel4() {
  32227. return this._label;
  32228. };
  32229. DirectedEdgeStar2.prototype.findCoveredLineEdges = function findCoveredLineEdges2() {
  32230. var startLoc = Location.NONE;
  32231. for (var it = this.iterator(); it.hasNext(); ) {
  32232. var nextOut = it.next();
  32233. var nextIn = nextOut.getSym();
  32234. if (!nextOut.isLineEdge()) {
  32235. if (nextOut.isInResult()) {
  32236. startLoc = Location.INTERIOR;
  32237. break;
  32238. }
  32239. if (nextIn.isInResult()) {
  32240. startLoc = Location.EXTERIOR;
  32241. break;
  32242. }
  32243. }
  32244. }
  32245. if (startLoc === Location.NONE) {
  32246. return null;
  32247. }
  32248. var currLoc = startLoc;
  32249. for (var it$1 = this.iterator(); it$1.hasNext(); ) {
  32250. var nextOut$1 = it$1.next();
  32251. var nextIn$1 = nextOut$1.getSym();
  32252. if (nextOut$1.isLineEdge()) {
  32253. nextOut$1.getEdge().setCovered(currLoc === Location.INTERIOR);
  32254. } else {
  32255. if (nextOut$1.isInResult()) {
  32256. currLoc = Location.EXTERIOR;
  32257. }
  32258. if (nextIn$1.isInResult()) {
  32259. currLoc = Location.INTERIOR;
  32260. }
  32261. }
  32262. }
  32263. };
  32264. DirectedEdgeStar2.prototype.computeLabelling = function computeLabelling2(geom) {
  32265. var this$1 = this;
  32266. EdgeEndStar$$1.prototype.computeLabelling.call(this, geom);
  32267. this._label = new Label(Location.NONE);
  32268. for (var it = this.iterator(); it.hasNext(); ) {
  32269. var ee = it.next();
  32270. var e = ee.getEdge();
  32271. var eLabel = e.getLabel();
  32272. for (var i = 0; i < 2; i++) {
  32273. var eLoc = eLabel.getLocation(i);
  32274. if (eLoc === Location.INTERIOR || eLoc === Location.BOUNDARY) {
  32275. this$1._label.setLocation(i, Location.INTERIOR);
  32276. }
  32277. }
  32278. }
  32279. };
  32280. DirectedEdgeStar2.prototype.interfaces_ = function interfaces_170() {
  32281. return [];
  32282. };
  32283. DirectedEdgeStar2.prototype.getClass = function getClass169() {
  32284. return DirectedEdgeStar2;
  32285. };
  32286. return DirectedEdgeStar2;
  32287. }(EdgeEndStar);
  32288. var OverlayNodeFactory = function(NodeFactory$$1) {
  32289. function OverlayNodeFactory2() {
  32290. NodeFactory$$1.apply(this, arguments);
  32291. }
  32292. if (NodeFactory$$1)
  32293. OverlayNodeFactory2.__proto__ = NodeFactory$$1;
  32294. OverlayNodeFactory2.prototype = Object.create(NodeFactory$$1 && NodeFactory$$1.prototype);
  32295. OverlayNodeFactory2.prototype.constructor = OverlayNodeFactory2;
  32296. OverlayNodeFactory2.prototype.createNode = function createNode2(coord) {
  32297. return new Node5(coord, new DirectedEdgeStar());
  32298. };
  32299. OverlayNodeFactory2.prototype.interfaces_ = function interfaces_170() {
  32300. return [];
  32301. };
  32302. OverlayNodeFactory2.prototype.getClass = function getClass169() {
  32303. return OverlayNodeFactory2;
  32304. };
  32305. return OverlayNodeFactory2;
  32306. }(NodeFactory);
  32307. var OrientedCoordinateArray = function OrientedCoordinateArray2() {
  32308. this._pts = null;
  32309. this._orientation = null;
  32310. var pts = arguments[0];
  32311. this._pts = pts;
  32312. this._orientation = OrientedCoordinateArray2.orientation(pts);
  32313. };
  32314. OrientedCoordinateArray.prototype.compareTo = function compareTo13(o1) {
  32315. var oca = o1;
  32316. var comp = OrientedCoordinateArray.compareOriented(this._pts, this._orientation, oca._pts, oca._orientation);
  32317. return comp;
  32318. };
  32319. OrientedCoordinateArray.prototype.interfaces_ = function interfaces_97() {
  32320. return [Comparable];
  32321. };
  32322. OrientedCoordinateArray.prototype.getClass = function getClass96() {
  32323. return OrientedCoordinateArray;
  32324. };
  32325. OrientedCoordinateArray.orientation = function orientation(pts) {
  32326. return CoordinateArrays.increasingDirection(pts) === 1;
  32327. };
  32328. OrientedCoordinateArray.compareOriented = function compareOriented(pts1, orientation1, pts2, orientation2) {
  32329. var dir1 = orientation1 ? 1 : -1;
  32330. var dir2 = orientation2 ? 1 : -1;
  32331. var limit1 = orientation1 ? pts1.length : -1;
  32332. var limit2 = orientation2 ? pts2.length : -1;
  32333. var i1 = orientation1 ? 0 : pts1.length - 1;
  32334. var i2 = orientation2 ? 0 : pts2.length - 1;
  32335. while (true) {
  32336. var compPt = pts1[i1].compareTo(pts2[i2]);
  32337. if (compPt !== 0) {
  32338. return compPt;
  32339. }
  32340. i1 += dir1;
  32341. i2 += dir2;
  32342. var done1 = i1 === limit1;
  32343. var done2 = i2 === limit2;
  32344. if (done1 && !done2) {
  32345. return -1;
  32346. }
  32347. if (!done1 && done2) {
  32348. return 1;
  32349. }
  32350. if (done1 && done2) {
  32351. return 0;
  32352. }
  32353. }
  32354. };
  32355. var EdgeList = function EdgeList2() {
  32356. this._edges = new ArrayList();
  32357. this._ocaMap = new TreeMap();
  32358. };
  32359. EdgeList.prototype.print = function print6(out) {
  32360. var this$1 = this;
  32361. out.print("MULTILINESTRING ( ");
  32362. for (var j = 0; j < this._edges.size(); j++) {
  32363. var e = this$1._edges.get(j);
  32364. if (j > 0) {
  32365. out.print(",");
  32366. }
  32367. out.print("(");
  32368. var pts = e.getCoordinates();
  32369. for (var i = 0; i < pts.length; i++) {
  32370. if (i > 0) {
  32371. out.print(",");
  32372. }
  32373. out.print(pts[i].x + " " + pts[i].y);
  32374. }
  32375. out.println(")");
  32376. }
  32377. out.print(") ");
  32378. };
  32379. EdgeList.prototype.addAll = function addAll2(edgeColl) {
  32380. var this$1 = this;
  32381. for (var i = edgeColl.iterator(); i.hasNext(); ) {
  32382. this$1.add(i.next());
  32383. }
  32384. };
  32385. EdgeList.prototype.findEdgeIndex = function findEdgeIndex(e) {
  32386. var this$1 = this;
  32387. for (var i = 0; i < this._edges.size(); i++) {
  32388. if (this$1._edges.get(i).equals(e)) {
  32389. return i;
  32390. }
  32391. }
  32392. return -1;
  32393. };
  32394. EdgeList.prototype.iterator = function iterator5() {
  32395. return this._edges.iterator();
  32396. };
  32397. EdgeList.prototype.getEdges = function getEdges3() {
  32398. return this._edges;
  32399. };
  32400. EdgeList.prototype.get = function get3(i) {
  32401. return this._edges.get(i);
  32402. };
  32403. EdgeList.prototype.findEqualEdge = function findEqualEdge(e) {
  32404. var oca = new OrientedCoordinateArray(e.getCoordinates());
  32405. var matchEdge = this._ocaMap.get(oca);
  32406. return matchEdge;
  32407. };
  32408. EdgeList.prototype.add = function add11(e) {
  32409. this._edges.add(e);
  32410. var oca = new OrientedCoordinateArray(e.getCoordinates());
  32411. this._ocaMap.put(oca, e);
  32412. };
  32413. EdgeList.prototype.interfaces_ = function interfaces_98() {
  32414. return [];
  32415. };
  32416. EdgeList.prototype.getClass = function getClass97() {
  32417. return EdgeList;
  32418. };
  32419. var SegmentIntersector = function SegmentIntersector2() {
  32420. };
  32421. SegmentIntersector.prototype.processIntersections = function processIntersections(e0, segIndex0, e1, segIndex1) {
  32422. };
  32423. SegmentIntersector.prototype.isDone = function isDone2() {
  32424. };
  32425. SegmentIntersector.prototype.interfaces_ = function interfaces_99() {
  32426. return [];
  32427. };
  32428. SegmentIntersector.prototype.getClass = function getClass98() {
  32429. return SegmentIntersector;
  32430. };
  32431. var IntersectionAdder = function IntersectionAdder2() {
  32432. this._hasIntersection = false;
  32433. this._hasProper = false;
  32434. this._hasProperInterior = false;
  32435. this._hasInterior = false;
  32436. this._properIntersectionPoint = null;
  32437. this._li = null;
  32438. this._isSelfIntersection = null;
  32439. this.numIntersections = 0;
  32440. this.numInteriorIntersections = 0;
  32441. this.numProperIntersections = 0;
  32442. this.numTests = 0;
  32443. var li = arguments[0];
  32444. this._li = li;
  32445. };
  32446. IntersectionAdder.prototype.isTrivialIntersection = function isTrivialIntersection(e0, segIndex0, e1, segIndex1) {
  32447. if (e0 === e1) {
  32448. if (this._li.getIntersectionNum() === 1) {
  32449. if (IntersectionAdder.isAdjacentSegments(segIndex0, segIndex1)) {
  32450. return true;
  32451. }
  32452. if (e0.isClosed()) {
  32453. var maxSegIndex = e0.size() - 1;
  32454. if (segIndex0 === 0 && segIndex1 === maxSegIndex || segIndex1 === 0 && segIndex0 === maxSegIndex) {
  32455. return true;
  32456. }
  32457. }
  32458. }
  32459. }
  32460. return false;
  32461. };
  32462. IntersectionAdder.prototype.getProperIntersectionPoint = function getProperIntersectionPoint() {
  32463. return this._properIntersectionPoint;
  32464. };
  32465. IntersectionAdder.prototype.hasProperInteriorIntersection = function hasProperInteriorIntersection() {
  32466. return this._hasProperInterior;
  32467. };
  32468. IntersectionAdder.prototype.getLineIntersector = function getLineIntersector() {
  32469. return this._li;
  32470. };
  32471. IntersectionAdder.prototype.hasProperIntersection = function hasProperIntersection() {
  32472. return this._hasProper;
  32473. };
  32474. IntersectionAdder.prototype.processIntersections = function processIntersections2(e0, segIndex0, e1, segIndex1) {
  32475. if (e0 === e1 && segIndex0 === segIndex1) {
  32476. return null;
  32477. }
  32478. this.numTests++;
  32479. var p002 = e0.getCoordinates()[segIndex0];
  32480. var p012 = e0.getCoordinates()[segIndex0 + 1];
  32481. var p102 = e1.getCoordinates()[segIndex1];
  32482. var p112 = e1.getCoordinates()[segIndex1 + 1];
  32483. this._li.computeIntersection(p002, p012, p102, p112);
  32484. if (this._li.hasIntersection()) {
  32485. this.numIntersections++;
  32486. if (this._li.isInteriorIntersection()) {
  32487. this.numInteriorIntersections++;
  32488. this._hasInterior = true;
  32489. }
  32490. if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
  32491. this._hasIntersection = true;
  32492. e0.addIntersections(this._li, segIndex0, 0);
  32493. e1.addIntersections(this._li, segIndex1, 1);
  32494. if (this._li.isProper()) {
  32495. this.numProperIntersections++;
  32496. this._hasProper = true;
  32497. this._hasProperInterior = true;
  32498. }
  32499. }
  32500. }
  32501. };
  32502. IntersectionAdder.prototype.hasIntersection = function hasIntersection2() {
  32503. return this._hasIntersection;
  32504. };
  32505. IntersectionAdder.prototype.isDone = function isDone3() {
  32506. return false;
  32507. };
  32508. IntersectionAdder.prototype.hasInteriorIntersection = function hasInteriorIntersection() {
  32509. return this._hasInterior;
  32510. };
  32511. IntersectionAdder.prototype.interfaces_ = function interfaces_100() {
  32512. return [SegmentIntersector];
  32513. };
  32514. IntersectionAdder.prototype.getClass = function getClass99() {
  32515. return IntersectionAdder;
  32516. };
  32517. IntersectionAdder.isAdjacentSegments = function isAdjacentSegments(i1, i2) {
  32518. return Math.abs(i1 - i2) === 1;
  32519. };
  32520. var EdgeIntersection = function EdgeIntersection2() {
  32521. this.coord = null;
  32522. this.segmentIndex = null;
  32523. this.dist = null;
  32524. var coord = arguments[0];
  32525. var segmentIndex = arguments[1];
  32526. var dist = arguments[2];
  32527. this.coord = new Coordinate(coord);
  32528. this.segmentIndex = segmentIndex;
  32529. this.dist = dist;
  32530. };
  32531. EdgeIntersection.prototype.getSegmentIndex = function getSegmentIndex() {
  32532. return this.segmentIndex;
  32533. };
  32534. EdgeIntersection.prototype.getCoordinate = function getCoordinate12() {
  32535. return this.coord;
  32536. };
  32537. EdgeIntersection.prototype.print = function print7(out) {
  32538. out.print(this.coord);
  32539. out.print(" seg # = " + this.segmentIndex);
  32540. out.println(" dist = " + this.dist);
  32541. };
  32542. EdgeIntersection.prototype.compareTo = function compareTo14(obj) {
  32543. var other = obj;
  32544. return this.compare(other.segmentIndex, other.dist);
  32545. };
  32546. EdgeIntersection.prototype.isEndPoint = function isEndPoint3(maxSegmentIndex) {
  32547. if (this.segmentIndex === 0 && this.dist === 0) {
  32548. return true;
  32549. }
  32550. if (this.segmentIndex === maxSegmentIndex) {
  32551. return true;
  32552. }
  32553. return false;
  32554. };
  32555. EdgeIntersection.prototype.toString = function toString19() {
  32556. return this.coord + " seg # = " + this.segmentIndex + " dist = " + this.dist;
  32557. };
  32558. EdgeIntersection.prototype.getDistance = function getDistance2() {
  32559. return this.dist;
  32560. };
  32561. EdgeIntersection.prototype.compare = function compare8(segmentIndex, dist) {
  32562. if (this.segmentIndex < segmentIndex) {
  32563. return -1;
  32564. }
  32565. if (this.segmentIndex > segmentIndex) {
  32566. return 1;
  32567. }
  32568. if (this.dist < dist) {
  32569. return -1;
  32570. }
  32571. if (this.dist > dist) {
  32572. return 1;
  32573. }
  32574. return 0;
  32575. };
  32576. EdgeIntersection.prototype.interfaces_ = function interfaces_101() {
  32577. return [Comparable];
  32578. };
  32579. EdgeIntersection.prototype.getClass = function getClass100() {
  32580. return EdgeIntersection;
  32581. };
  32582. var EdgeIntersectionList = function EdgeIntersectionList2() {
  32583. this._nodeMap = new TreeMap();
  32584. this.edge = null;
  32585. var edge = arguments[0];
  32586. this.edge = edge;
  32587. };
  32588. EdgeIntersectionList.prototype.print = function print8(out) {
  32589. out.println("Intersections:");
  32590. for (var it = this.iterator(); it.hasNext(); ) {
  32591. var ei = it.next();
  32592. ei.print(out);
  32593. }
  32594. };
  32595. EdgeIntersectionList.prototype.iterator = function iterator6() {
  32596. return this._nodeMap.values().iterator();
  32597. };
  32598. EdgeIntersectionList.prototype.addSplitEdges = function addSplitEdges2(edgeList) {
  32599. var this$1 = this;
  32600. this.addEndpoints();
  32601. var it = this.iterator();
  32602. var eiPrev = it.next();
  32603. while (it.hasNext()) {
  32604. var ei = it.next();
  32605. var newEdge = this$1.createSplitEdge(eiPrev, ei);
  32606. edgeList.add(newEdge);
  32607. eiPrev = ei;
  32608. }
  32609. };
  32610. EdgeIntersectionList.prototype.addEndpoints = function addEndpoints2() {
  32611. var maxSegIndex = this.edge.pts.length - 1;
  32612. this.add(this.edge.pts[0], 0, 0);
  32613. this.add(this.edge.pts[maxSegIndex], maxSegIndex, 0);
  32614. };
  32615. EdgeIntersectionList.prototype.createSplitEdge = function createSplitEdge2(ei0, ei1) {
  32616. var this$1 = this;
  32617. var npts = ei1.segmentIndex - ei0.segmentIndex + 2;
  32618. var lastSegStartPt = this.edge.pts[ei1.segmentIndex];
  32619. var useIntPt1 = ei1.dist > 0 || !ei1.coord.equals2D(lastSegStartPt);
  32620. if (!useIntPt1) {
  32621. npts--;
  32622. }
  32623. var pts = new Array(npts).fill(null);
  32624. var ipt = 0;
  32625. pts[ipt++] = new Coordinate(ei0.coord);
  32626. for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
  32627. pts[ipt++] = this$1.edge.pts[i];
  32628. }
  32629. if (useIntPt1) {
  32630. pts[ipt] = ei1.coord;
  32631. }
  32632. return new Edge2(pts, new Label(this.edge._label));
  32633. };
  32634. EdgeIntersectionList.prototype.add = function add12(intPt, segmentIndex, dist) {
  32635. var eiNew = new EdgeIntersection(intPt, segmentIndex, dist);
  32636. var ei = this._nodeMap.get(eiNew);
  32637. if (ei !== null) {
  32638. return ei;
  32639. }
  32640. this._nodeMap.put(eiNew, eiNew);
  32641. return eiNew;
  32642. };
  32643. EdgeIntersectionList.prototype.isIntersection = function isIntersection2(pt) {
  32644. for (var it = this.iterator(); it.hasNext(); ) {
  32645. var ei = it.next();
  32646. if (ei.coord.equals(pt)) {
  32647. return true;
  32648. }
  32649. }
  32650. return false;
  32651. };
  32652. EdgeIntersectionList.prototype.interfaces_ = function interfaces_102() {
  32653. return [];
  32654. };
  32655. EdgeIntersectionList.prototype.getClass = function getClass101() {
  32656. return EdgeIntersectionList;
  32657. };
  32658. var MonotoneChainIndexer = function MonotoneChainIndexer2() {
  32659. };
  32660. MonotoneChainIndexer.prototype.getChainStartIndices = function getChainStartIndices2(pts) {
  32661. var this$1 = this;
  32662. var start = 0;
  32663. var startIndexList = new ArrayList();
  32664. startIndexList.add(new Integer(start));
  32665. do {
  32666. var last = this$1.findChainEnd(pts, start);
  32667. startIndexList.add(new Integer(last));
  32668. start = last;
  32669. } while (start < pts.length - 1);
  32670. var startIndex = MonotoneChainIndexer.toIntArray(startIndexList);
  32671. return startIndex;
  32672. };
  32673. MonotoneChainIndexer.prototype.findChainEnd = function findChainEnd2(pts, start) {
  32674. var chainQuad = Quadrant.quadrant(pts[start], pts[start + 1]);
  32675. var last = start + 1;
  32676. while (last < pts.length) {
  32677. var quad = Quadrant.quadrant(pts[last - 1], pts[last]);
  32678. if (quad !== chainQuad) {
  32679. break;
  32680. }
  32681. last++;
  32682. }
  32683. return last - 1;
  32684. };
  32685. MonotoneChainIndexer.prototype.interfaces_ = function interfaces_103() {
  32686. return [];
  32687. };
  32688. MonotoneChainIndexer.prototype.getClass = function getClass102() {
  32689. return MonotoneChainIndexer;
  32690. };
  32691. MonotoneChainIndexer.toIntArray = function toIntArray2(list) {
  32692. var array2 = new Array(list.size()).fill(null);
  32693. for (var i = 0; i < array2.length; i++) {
  32694. array2[i] = list.get(i).intValue();
  32695. }
  32696. return array2;
  32697. };
  32698. var MonotoneChainEdge = function MonotoneChainEdge2() {
  32699. this.e = null;
  32700. this.pts = null;
  32701. this.startIndex = null;
  32702. this.env1 = new Envelope();
  32703. this.env2 = new Envelope();
  32704. var e = arguments[0];
  32705. this.e = e;
  32706. this.pts = e.getCoordinates();
  32707. var mcb = new MonotoneChainIndexer();
  32708. this.startIndex = mcb.getChainStartIndices(this.pts);
  32709. };
  32710. MonotoneChainEdge.prototype.getCoordinates = function getCoordinates6() {
  32711. return this.pts;
  32712. };
  32713. MonotoneChainEdge.prototype.getMaxX = function getMaxX2(chainIndex) {
  32714. var x12 = this.pts[this.startIndex[chainIndex]].x;
  32715. var x2 = this.pts[this.startIndex[chainIndex + 1]].x;
  32716. return x12 > x2 ? x12 : x2;
  32717. };
  32718. MonotoneChainEdge.prototype.getMinX = function getMinX2(chainIndex) {
  32719. var x12 = this.pts[this.startIndex[chainIndex]].x;
  32720. var x2 = this.pts[this.startIndex[chainIndex + 1]].x;
  32721. return x12 < x2 ? x12 : x2;
  32722. };
  32723. MonotoneChainEdge.prototype.computeIntersectsForChain = function computeIntersectsForChain() {
  32724. if (arguments.length === 4) {
  32725. var chainIndex0 = arguments[0];
  32726. var mce = arguments[1];
  32727. var chainIndex1 = arguments[2];
  32728. var si = arguments[3];
  32729. this.computeIntersectsForChain(this.startIndex[chainIndex0], this.startIndex[chainIndex0 + 1], mce, mce.startIndex[chainIndex1], mce.startIndex[chainIndex1 + 1], si);
  32730. } else if (arguments.length === 6) {
  32731. var start0 = arguments[0];
  32732. var end0 = arguments[1];
  32733. var mce$1 = arguments[2];
  32734. var start1 = arguments[3];
  32735. var end1 = arguments[4];
  32736. var ei = arguments[5];
  32737. var p002 = this.pts[start0];
  32738. var p012 = this.pts[end0];
  32739. var p102 = mce$1.pts[start1];
  32740. var p112 = mce$1.pts[end1];
  32741. if (end0 - start0 === 1 && end1 - start1 === 1) {
  32742. ei.addIntersections(this.e, start0, mce$1.e, start1);
  32743. return null;
  32744. }
  32745. this.env1.init(p002, p012);
  32746. this.env2.init(p102, p112);
  32747. if (!this.env1.intersects(this.env2)) {
  32748. return null;
  32749. }
  32750. var mid0 = Math.trunc((start0 + end0) / 2);
  32751. var mid1 = Math.trunc((start1 + end1) / 2);
  32752. if (start0 < mid0) {
  32753. if (start1 < mid1) {
  32754. this.computeIntersectsForChain(start0, mid0, mce$1, start1, mid1, ei);
  32755. }
  32756. if (mid1 < end1) {
  32757. this.computeIntersectsForChain(start0, mid0, mce$1, mid1, end1, ei);
  32758. }
  32759. }
  32760. if (mid0 < end0) {
  32761. if (start1 < mid1) {
  32762. this.computeIntersectsForChain(mid0, end0, mce$1, start1, mid1, ei);
  32763. }
  32764. if (mid1 < end1) {
  32765. this.computeIntersectsForChain(mid0, end0, mce$1, mid1, end1, ei);
  32766. }
  32767. }
  32768. }
  32769. };
  32770. MonotoneChainEdge.prototype.getStartIndexes = function getStartIndexes() {
  32771. return this.startIndex;
  32772. };
  32773. MonotoneChainEdge.prototype.computeIntersects = function computeIntersects(mce, si) {
  32774. var this$1 = this;
  32775. for (var i = 0; i < this.startIndex.length - 1; i++) {
  32776. for (var j = 0; j < mce.startIndex.length - 1; j++) {
  32777. this$1.computeIntersectsForChain(i, mce, j, si);
  32778. }
  32779. }
  32780. };
  32781. MonotoneChainEdge.prototype.interfaces_ = function interfaces_104() {
  32782. return [];
  32783. };
  32784. MonotoneChainEdge.prototype.getClass = function getClass103() {
  32785. return MonotoneChainEdge;
  32786. };
  32787. var Depth = function Depth2() {
  32788. var this$1 = this;
  32789. this._depth = Array(2).fill().map(function() {
  32790. return Array(3);
  32791. });
  32792. for (var i = 0; i < 2; i++) {
  32793. for (var j = 0; j < 3; j++) {
  32794. this$1._depth[i][j] = Depth2.NULL_VALUE;
  32795. }
  32796. }
  32797. };
  32798. var staticAccessors$31 = { NULL_VALUE: { configurable: true } };
  32799. Depth.prototype.getDepth = function getDepth2(geomIndex, posIndex) {
  32800. return this._depth[geomIndex][posIndex];
  32801. };
  32802. Depth.prototype.setDepth = function setDepth(geomIndex, posIndex, depthValue) {
  32803. this._depth[geomIndex][posIndex] = depthValue;
  32804. };
  32805. Depth.prototype.isNull = function isNull4() {
  32806. var this$1 = this;
  32807. if (arguments.length === 0) {
  32808. for (var i = 0; i < 2; i++) {
  32809. for (var j = 0; j < 3; j++) {
  32810. if (this$1._depth[i][j] !== Depth.NULL_VALUE) {
  32811. return false;
  32812. }
  32813. }
  32814. }
  32815. return true;
  32816. } else if (arguments.length === 1) {
  32817. var geomIndex = arguments[0];
  32818. return this._depth[geomIndex][1] === Depth.NULL_VALUE;
  32819. } else if (arguments.length === 2) {
  32820. var geomIndex$1 = arguments[0];
  32821. var posIndex = arguments[1];
  32822. return this._depth[geomIndex$1][posIndex] === Depth.NULL_VALUE;
  32823. }
  32824. };
  32825. Depth.prototype.normalize = function normalize5() {
  32826. var this$1 = this;
  32827. for (var i = 0; i < 2; i++) {
  32828. if (!this$1.isNull(i)) {
  32829. var minDepth = this$1._depth[i][1];
  32830. if (this$1._depth[i][2] < minDepth) {
  32831. minDepth = this$1._depth[i][2];
  32832. }
  32833. if (minDepth < 0) {
  32834. minDepth = 0;
  32835. }
  32836. for (var j = 1; j < 3; j++) {
  32837. var newValue = 0;
  32838. if (this$1._depth[i][j] > minDepth) {
  32839. newValue = 1;
  32840. }
  32841. this$1._depth[i][j] = newValue;
  32842. }
  32843. }
  32844. }
  32845. };
  32846. Depth.prototype.getDelta = function getDelta(geomIndex) {
  32847. return this._depth[geomIndex][Position.RIGHT] - this._depth[geomIndex][Position.LEFT];
  32848. };
  32849. Depth.prototype.getLocation = function getLocation4(geomIndex, posIndex) {
  32850. if (this._depth[geomIndex][posIndex] <= 0) {
  32851. return Location.EXTERIOR;
  32852. }
  32853. return Location.INTERIOR;
  32854. };
  32855. Depth.prototype.toString = function toString20() {
  32856. return "A: " + this._depth[0][1] + "," + this._depth[0][2] + " B: " + this._depth[1][1] + "," + this._depth[1][2];
  32857. };
  32858. Depth.prototype.add = function add13() {
  32859. var this$1 = this;
  32860. if (arguments.length === 1) {
  32861. var lbl = arguments[0];
  32862. for (var i = 0; i < 2; i++) {
  32863. for (var j = 1; j < 3; j++) {
  32864. var loc = lbl.getLocation(i, j);
  32865. if (loc === Location.EXTERIOR || loc === Location.INTERIOR) {
  32866. if (this$1.isNull(i, j)) {
  32867. this$1._depth[i][j] = Depth.depthAtLocation(loc);
  32868. } else {
  32869. this$1._depth[i][j] += Depth.depthAtLocation(loc);
  32870. }
  32871. }
  32872. }
  32873. }
  32874. } else if (arguments.length === 3) {
  32875. var geomIndex = arguments[0];
  32876. var posIndex = arguments[1];
  32877. var location = arguments[2];
  32878. if (location === Location.INTERIOR) {
  32879. this._depth[geomIndex][posIndex]++;
  32880. }
  32881. }
  32882. };
  32883. Depth.prototype.interfaces_ = function interfaces_105() {
  32884. return [];
  32885. };
  32886. Depth.prototype.getClass = function getClass104() {
  32887. return Depth;
  32888. };
  32889. Depth.depthAtLocation = function depthAtLocation(location) {
  32890. if (location === Location.EXTERIOR) {
  32891. return 0;
  32892. }
  32893. if (location === Location.INTERIOR) {
  32894. return 1;
  32895. }
  32896. return Depth.NULL_VALUE;
  32897. };
  32898. staticAccessors$31.NULL_VALUE.get = function() {
  32899. return -1;
  32900. };
  32901. Object.defineProperties(Depth, staticAccessors$31);
  32902. var Edge2 = function(GraphComponent$$1) {
  32903. function Edge3() {
  32904. GraphComponent$$1.call(this);
  32905. this.pts = null;
  32906. this._env = null;
  32907. this.eiList = new EdgeIntersectionList(this);
  32908. this._name = null;
  32909. this._mce = null;
  32910. this._isIsolated = true;
  32911. this._depth = new Depth();
  32912. this._depthDelta = 0;
  32913. if (arguments.length === 1) {
  32914. var pts = arguments[0];
  32915. Edge3.call(this, pts, null);
  32916. } else if (arguments.length === 2) {
  32917. var pts$1 = arguments[0];
  32918. var label = arguments[1];
  32919. this.pts = pts$1;
  32920. this._label = label;
  32921. }
  32922. }
  32923. if (GraphComponent$$1)
  32924. Edge3.__proto__ = GraphComponent$$1;
  32925. Edge3.prototype = Object.create(GraphComponent$$1 && GraphComponent$$1.prototype);
  32926. Edge3.prototype.constructor = Edge3;
  32927. Edge3.prototype.getDepth = function getDepth3() {
  32928. return this._depth;
  32929. };
  32930. Edge3.prototype.getCollapsedEdge = function getCollapsedEdge() {
  32931. var newPts = new Array(2).fill(null);
  32932. newPts[0] = this.pts[0];
  32933. newPts[1] = this.pts[1];
  32934. var newe = new Edge3(newPts, Label.toLineLabel(this._label));
  32935. return newe;
  32936. };
  32937. Edge3.prototype.isIsolated = function isIsolated2() {
  32938. return this._isIsolated;
  32939. };
  32940. Edge3.prototype.getCoordinates = function getCoordinates11() {
  32941. return this.pts;
  32942. };
  32943. Edge3.prototype.setIsolated = function setIsolated(isIsolated2) {
  32944. this._isIsolated = isIsolated2;
  32945. };
  32946. Edge3.prototype.setName = function setName(name) {
  32947. this._name = name;
  32948. };
  32949. Edge3.prototype.equals = function equals10(o) {
  32950. var this$1 = this;
  32951. if (!(o instanceof Edge3)) {
  32952. return false;
  32953. }
  32954. var e = o;
  32955. if (this.pts.length !== e.pts.length) {
  32956. return false;
  32957. }
  32958. var isEqualForward = true;
  32959. var isEqualReverse = true;
  32960. var iRev = this.pts.length;
  32961. for (var i = 0; i < this.pts.length; i++) {
  32962. if (!this$1.pts[i].equals2D(e.pts[i])) {
  32963. isEqualForward = false;
  32964. }
  32965. if (!this$1.pts[i].equals2D(e.pts[--iRev])) {
  32966. isEqualReverse = false;
  32967. }
  32968. if (!isEqualForward && !isEqualReverse) {
  32969. return false;
  32970. }
  32971. }
  32972. return true;
  32973. };
  32974. Edge3.prototype.getCoordinate = function getCoordinate18() {
  32975. if (arguments.length === 0) {
  32976. if (this.pts.length > 0) {
  32977. return this.pts[0];
  32978. }
  32979. return null;
  32980. } else if (arguments.length === 1) {
  32981. var i = arguments[0];
  32982. return this.pts[i];
  32983. }
  32984. };
  32985. Edge3.prototype.print = function print9(out) {
  32986. var this$1 = this;
  32987. out.print("edge " + this._name + ": ");
  32988. out.print("LINESTRING (");
  32989. for (var i = 0; i < this.pts.length; i++) {
  32990. if (i > 0) {
  32991. out.print(",");
  32992. }
  32993. out.print(this$1.pts[i].x + " " + this$1.pts[i].y);
  32994. }
  32995. out.print(") " + this._label + " " + this._depthDelta);
  32996. };
  32997. Edge3.prototype.computeIM = function computeIM(im) {
  32998. Edge3.updateIM(this._label, im);
  32999. };
  33000. Edge3.prototype.isCollapsed = function isCollapsed() {
  33001. if (!this._label.isArea()) {
  33002. return false;
  33003. }
  33004. if (this.pts.length !== 3) {
  33005. return false;
  33006. }
  33007. if (this.pts[0].equals(this.pts[2])) {
  33008. return true;
  33009. }
  33010. return false;
  33011. };
  33012. Edge3.prototype.isClosed = function isClosed5() {
  33013. return this.pts[0].equals(this.pts[this.pts.length - 1]);
  33014. };
  33015. Edge3.prototype.getMaximumSegmentIndex = function getMaximumSegmentIndex() {
  33016. return this.pts.length - 1;
  33017. };
  33018. Edge3.prototype.getDepthDelta = function getDepthDelta() {
  33019. return this._depthDelta;
  33020. };
  33021. Edge3.prototype.getNumPoints = function getNumPoints() {
  33022. return this.pts.length;
  33023. };
  33024. Edge3.prototype.printReverse = function printReverse(out) {
  33025. var this$1 = this;
  33026. out.print("edge " + this._name + ": ");
  33027. for (var i = this.pts.length - 1; i >= 0; i--) {
  33028. out.print(this$1.pts[i] + " ");
  33029. }
  33030. out.println("");
  33031. };
  33032. Edge3.prototype.getMonotoneChainEdge = function getMonotoneChainEdge() {
  33033. if (this._mce === null) {
  33034. this._mce = new MonotoneChainEdge(this);
  33035. }
  33036. return this._mce;
  33037. };
  33038. Edge3.prototype.getEnvelope = function getEnvelope4() {
  33039. var this$1 = this;
  33040. if (this._env === null) {
  33041. this._env = new Envelope();
  33042. for (var i = 0; i < this.pts.length; i++) {
  33043. this$1._env.expandToInclude(this$1.pts[i]);
  33044. }
  33045. }
  33046. return this._env;
  33047. };
  33048. Edge3.prototype.addIntersection = function addIntersection3(li, segmentIndex, geomIndex, intIndex) {
  33049. var intPt = new Coordinate(li.getIntersection(intIndex));
  33050. var normalizedSegmentIndex = segmentIndex;
  33051. var dist = li.getEdgeDistance(geomIndex, intIndex);
  33052. var nextSegIndex = normalizedSegmentIndex + 1;
  33053. if (nextSegIndex < this.pts.length) {
  33054. var nextPt = this.pts[nextSegIndex];
  33055. if (intPt.equals2D(nextPt)) {
  33056. normalizedSegmentIndex = nextSegIndex;
  33057. dist = 0;
  33058. }
  33059. }
  33060. this.eiList.add(intPt, normalizedSegmentIndex, dist);
  33061. };
  33062. Edge3.prototype.toString = function toString25() {
  33063. var this$1 = this;
  33064. var buf = new StringBuffer();
  33065. buf.append("edge " + this._name + ": ");
  33066. buf.append("LINESTRING (");
  33067. for (var i = 0; i < this.pts.length; i++) {
  33068. if (i > 0) {
  33069. buf.append(",");
  33070. }
  33071. buf.append(this$1.pts[i].x + " " + this$1.pts[i].y);
  33072. }
  33073. buf.append(") " + this._label + " " + this._depthDelta);
  33074. return buf.toString();
  33075. };
  33076. Edge3.prototype.isPointwiseEqual = function isPointwiseEqual(e) {
  33077. var this$1 = this;
  33078. if (this.pts.length !== e.pts.length) {
  33079. return false;
  33080. }
  33081. for (var i = 0; i < this.pts.length; i++) {
  33082. if (!this$1.pts[i].equals2D(e.pts[i])) {
  33083. return false;
  33084. }
  33085. }
  33086. return true;
  33087. };
  33088. Edge3.prototype.setDepthDelta = function setDepthDelta(depthDelta2) {
  33089. this._depthDelta = depthDelta2;
  33090. };
  33091. Edge3.prototype.getEdgeIntersectionList = function getEdgeIntersectionList() {
  33092. return this.eiList;
  33093. };
  33094. Edge3.prototype.addIntersections = function addIntersections3(li, segmentIndex, geomIndex) {
  33095. var this$1 = this;
  33096. for (var i = 0; i < li.getIntersectionNum(); i++) {
  33097. this$1.addIntersection(li, segmentIndex, geomIndex, i);
  33098. }
  33099. };
  33100. Edge3.prototype.interfaces_ = function interfaces_170() {
  33101. return [];
  33102. };
  33103. Edge3.prototype.getClass = function getClass169() {
  33104. return Edge3;
  33105. };
  33106. Edge3.updateIM = function updateIM2() {
  33107. if (arguments.length === 2) {
  33108. var label = arguments[0];
  33109. var im = arguments[1];
  33110. im.setAtLeastIfValid(label.getLocation(0, Position.ON), label.getLocation(1, Position.ON), 1);
  33111. if (label.isArea()) {
  33112. im.setAtLeastIfValid(label.getLocation(0, Position.LEFT), label.getLocation(1, Position.LEFT), 2);
  33113. im.setAtLeastIfValid(label.getLocation(0, Position.RIGHT), label.getLocation(1, Position.RIGHT), 2);
  33114. }
  33115. } else {
  33116. return GraphComponent$$1.prototype.updateIM.apply(this, arguments);
  33117. }
  33118. };
  33119. return Edge3;
  33120. }(GraphComponent);
  33121. var BufferBuilder = function BufferBuilder2(bufParams) {
  33122. this._workingPrecisionModel = null;
  33123. this._workingNoder = null;
  33124. this._geomFact = null;
  33125. this._graph = null;
  33126. this._edgeList = new EdgeList();
  33127. this._bufParams = bufParams || null;
  33128. };
  33129. BufferBuilder.prototype.setWorkingPrecisionModel = function setWorkingPrecisionModel(pm) {
  33130. this._workingPrecisionModel = pm;
  33131. };
  33132. BufferBuilder.prototype.insertUniqueEdge = function insertUniqueEdge(e) {
  33133. var existingEdge = this._edgeList.findEqualEdge(e);
  33134. if (existingEdge !== null) {
  33135. var existingLabel = existingEdge.getLabel();
  33136. var labelToMerge = e.getLabel();
  33137. if (!existingEdge.isPointwiseEqual(e)) {
  33138. labelToMerge = new Label(e.getLabel());
  33139. labelToMerge.flip();
  33140. }
  33141. existingLabel.merge(labelToMerge);
  33142. var mergeDelta = BufferBuilder.depthDelta(labelToMerge);
  33143. var existingDelta = existingEdge.getDepthDelta();
  33144. var newDelta = existingDelta + mergeDelta;
  33145. existingEdge.setDepthDelta(newDelta);
  33146. } else {
  33147. this._edgeList.add(e);
  33148. e.setDepthDelta(BufferBuilder.depthDelta(e.getLabel()));
  33149. }
  33150. };
  33151. BufferBuilder.prototype.buildSubgraphs = function buildSubgraphs(subgraphList, polyBuilder) {
  33152. var processedGraphs = new ArrayList();
  33153. for (var i = subgraphList.iterator(); i.hasNext(); ) {
  33154. var subgraph = i.next();
  33155. var p = subgraph.getRightmostCoordinate();
  33156. var locater = new SubgraphDepthLocater(processedGraphs);
  33157. var outsideDepth = locater.getDepth(p);
  33158. subgraph.computeDepth(outsideDepth);
  33159. subgraph.findResultEdges();
  33160. processedGraphs.add(subgraph);
  33161. polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes());
  33162. }
  33163. };
  33164. BufferBuilder.prototype.createSubgraphs = function createSubgraphs(graph) {
  33165. var subgraphList = new ArrayList();
  33166. for (var i = graph.getNodes().iterator(); i.hasNext(); ) {
  33167. var node = i.next();
  33168. if (!node.isVisited()) {
  33169. var subgraph = new BufferSubgraph();
  33170. subgraph.create(node);
  33171. subgraphList.add(subgraph);
  33172. }
  33173. }
  33174. Collections.sort(subgraphList, Collections.reverseOrder());
  33175. return subgraphList;
  33176. };
  33177. BufferBuilder.prototype.createEmptyResultGeometry = function createEmptyResultGeometry() {
  33178. var emptyGeom = this._geomFact.createPolygon();
  33179. return emptyGeom;
  33180. };
  33181. BufferBuilder.prototype.getNoder = function getNoder(precisionModel) {
  33182. if (this._workingNoder !== null) {
  33183. return this._workingNoder;
  33184. }
  33185. var noder = new MCIndexNoder();
  33186. var li = new RobustLineIntersector();
  33187. li.setPrecisionModel(precisionModel);
  33188. noder.setSegmentIntersector(new IntersectionAdder(li));
  33189. return noder;
  33190. };
  33191. BufferBuilder.prototype.buffer = function buffer2(g, distance11) {
  33192. var precisionModel = this._workingPrecisionModel;
  33193. if (precisionModel === null) {
  33194. precisionModel = g.getPrecisionModel();
  33195. }
  33196. this._geomFact = g.getFactory();
  33197. var curveBuilder = new OffsetCurveBuilder(precisionModel, this._bufParams);
  33198. var curveSetBuilder = new OffsetCurveSetBuilder(g, distance11, curveBuilder);
  33199. var bufferSegStrList = curveSetBuilder.getCurves();
  33200. if (bufferSegStrList.size() <= 0) {
  33201. return this.createEmptyResultGeometry();
  33202. }
  33203. this.computeNodedEdges(bufferSegStrList, precisionModel);
  33204. this._graph = new PlanarGraph(new OverlayNodeFactory());
  33205. this._graph.addEdges(this._edgeList.getEdges());
  33206. var subgraphList = this.createSubgraphs(this._graph);
  33207. var polyBuilder = new PolygonBuilder(this._geomFact);
  33208. this.buildSubgraphs(subgraphList, polyBuilder);
  33209. var resultPolyList = polyBuilder.getPolygons();
  33210. if (resultPolyList.size() <= 0) {
  33211. return this.createEmptyResultGeometry();
  33212. }
  33213. var resultGeom = this._geomFact.buildGeometry(resultPolyList);
  33214. return resultGeom;
  33215. };
  33216. BufferBuilder.prototype.computeNodedEdges = function computeNodedEdges(bufferSegStrList, precisionModel) {
  33217. var this$1 = this;
  33218. var noder = this.getNoder(precisionModel);
  33219. noder.computeNodes(bufferSegStrList);
  33220. var nodedSegStrings = noder.getNodedSubstrings();
  33221. for (var i = nodedSegStrings.iterator(); i.hasNext(); ) {
  33222. var segStr = i.next();
  33223. var pts = segStr.getCoordinates();
  33224. if (pts.length === 2 && pts[0].equals2D(pts[1])) {
  33225. continue;
  33226. }
  33227. var oldLabel = segStr.getData();
  33228. var edge = new Edge2(segStr.getCoordinates(), new Label(oldLabel));
  33229. this$1.insertUniqueEdge(edge);
  33230. }
  33231. };
  33232. BufferBuilder.prototype.setNoder = function setNoder(noder) {
  33233. this._workingNoder = noder;
  33234. };
  33235. BufferBuilder.prototype.interfaces_ = function interfaces_106() {
  33236. return [];
  33237. };
  33238. BufferBuilder.prototype.getClass = function getClass105() {
  33239. return BufferBuilder;
  33240. };
  33241. BufferBuilder.depthDelta = function depthDelta(label) {
  33242. var lLoc = label.getLocation(0, Position.LEFT);
  33243. var rLoc = label.getLocation(0, Position.RIGHT);
  33244. if (lLoc === Location.INTERIOR && rLoc === Location.EXTERIOR) {
  33245. return 1;
  33246. } else if (lLoc === Location.EXTERIOR && rLoc === Location.INTERIOR) {
  33247. return -1;
  33248. }
  33249. return 0;
  33250. };
  33251. BufferBuilder.convertSegStrings = function convertSegStrings(it) {
  33252. var fact = new GeometryFactory();
  33253. var lines = new ArrayList();
  33254. while (it.hasNext()) {
  33255. var ss = it.next();
  33256. var line = fact.createLineString(ss.getCoordinates());
  33257. lines.add(line);
  33258. }
  33259. return fact.buildGeometry(lines);
  33260. };
  33261. var ScaledNoder = function ScaledNoder2() {
  33262. this._noder = null;
  33263. this._scaleFactor = null;
  33264. this._offsetX = null;
  33265. this._offsetY = null;
  33266. this._isScaled = false;
  33267. if (arguments.length === 2) {
  33268. var noder = arguments[0];
  33269. var scaleFactor = arguments[1];
  33270. this._noder = noder;
  33271. this._scaleFactor = scaleFactor;
  33272. this._offsetX = 0;
  33273. this._offsetY = 0;
  33274. this._isScaled = !this.isIntegerPrecision();
  33275. } else if (arguments.length === 4) {
  33276. var noder$1 = arguments[0];
  33277. var scaleFactor$1 = arguments[1];
  33278. var offsetX = arguments[2];
  33279. var offsetY = arguments[3];
  33280. this._noder = noder$1;
  33281. this._scaleFactor = scaleFactor$1;
  33282. this._offsetX = offsetX;
  33283. this._offsetY = offsetY;
  33284. this._isScaled = !this.isIntegerPrecision();
  33285. }
  33286. };
  33287. ScaledNoder.prototype.rescale = function rescale() {
  33288. var this$1 = this;
  33289. if (hasInterface(arguments[0], Collection)) {
  33290. var segStrings = arguments[0];
  33291. for (var i = segStrings.iterator(); i.hasNext(); ) {
  33292. var ss = i.next();
  33293. this$1.rescale(ss.getCoordinates());
  33294. }
  33295. } else if (arguments[0] instanceof Array) {
  33296. var pts = arguments[0];
  33297. for (var i$1 = 0; i$1 < pts.length; i$1++) {
  33298. pts[i$1].x = pts[i$1].x / this$1._scaleFactor + this$1._offsetX;
  33299. pts[i$1].y = pts[i$1].y / this$1._scaleFactor + this$1._offsetY;
  33300. }
  33301. if (pts.length === 2 && pts[0].equals2D(pts[1])) {
  33302. System.out.println(pts);
  33303. }
  33304. }
  33305. };
  33306. ScaledNoder.prototype.scale = function scale2() {
  33307. var this$1 = this;
  33308. if (hasInterface(arguments[0], Collection)) {
  33309. var segStrings = arguments[0];
  33310. var nodedSegmentStrings = new ArrayList();
  33311. for (var i = segStrings.iterator(); i.hasNext(); ) {
  33312. var ss = i.next();
  33313. nodedSegmentStrings.add(new NodedSegmentString(this$1.scale(ss.getCoordinates()), ss.getData()));
  33314. }
  33315. return nodedSegmentStrings;
  33316. } else if (arguments[0] instanceof Array) {
  33317. var pts = arguments[0];
  33318. var roundPts = new Array(pts.length).fill(null);
  33319. for (var i$1 = 0; i$1 < pts.length; i$1++) {
  33320. roundPts[i$1] = new Coordinate(Math.round((pts[i$1].x - this$1._offsetX) * this$1._scaleFactor), Math.round((pts[i$1].y - this$1._offsetY) * this$1._scaleFactor), pts[i$1].z);
  33321. }
  33322. var roundPtsNoDup = CoordinateArrays.removeRepeatedPoints(roundPts);
  33323. return roundPtsNoDup;
  33324. }
  33325. };
  33326. ScaledNoder.prototype.isIntegerPrecision = function isIntegerPrecision() {
  33327. return this._scaleFactor === 1;
  33328. };
  33329. ScaledNoder.prototype.getNodedSubstrings = function getNodedSubstrings3() {
  33330. var splitSS = this._noder.getNodedSubstrings();
  33331. if (this._isScaled) {
  33332. this.rescale(splitSS);
  33333. }
  33334. return splitSS;
  33335. };
  33336. ScaledNoder.prototype.computeNodes = function computeNodes2(inputSegStrings) {
  33337. var intSegStrings = inputSegStrings;
  33338. if (this._isScaled) {
  33339. intSegStrings = this.scale(inputSegStrings);
  33340. }
  33341. this._noder.computeNodes(intSegStrings);
  33342. };
  33343. ScaledNoder.prototype.interfaces_ = function interfaces_107() {
  33344. return [Noder];
  33345. };
  33346. ScaledNoder.prototype.getClass = function getClass106() {
  33347. return ScaledNoder;
  33348. };
  33349. var NodingValidator = function NodingValidator2() {
  33350. this._li = new RobustLineIntersector();
  33351. this._segStrings = null;
  33352. var segStrings = arguments[0];
  33353. this._segStrings = segStrings;
  33354. };
  33355. var staticAccessors$33 = { fact: { configurable: true } };
  33356. NodingValidator.prototype.checkEndPtVertexIntersections = function checkEndPtVertexIntersections() {
  33357. var this$1 = this;
  33358. if (arguments.length === 0) {
  33359. for (var i = this._segStrings.iterator(); i.hasNext(); ) {
  33360. var ss = i.next();
  33361. var pts = ss.getCoordinates();
  33362. this$1.checkEndPtVertexIntersections(pts[0], this$1._segStrings);
  33363. this$1.checkEndPtVertexIntersections(pts[pts.length - 1], this$1._segStrings);
  33364. }
  33365. } else if (arguments.length === 2) {
  33366. var testPt = arguments[0];
  33367. var segStrings = arguments[1];
  33368. for (var i$1 = segStrings.iterator(); i$1.hasNext(); ) {
  33369. var ss$1 = i$1.next();
  33370. var pts$1 = ss$1.getCoordinates();
  33371. for (var j = 1; j < pts$1.length - 1; j++) {
  33372. if (pts$1[j].equals(testPt)) {
  33373. throw new RuntimeException("found endpt/interior pt intersection at index " + j + " :pt " + testPt);
  33374. }
  33375. }
  33376. }
  33377. }
  33378. };
  33379. NodingValidator.prototype.checkInteriorIntersections = function checkInteriorIntersections() {
  33380. var this$1 = this;
  33381. if (arguments.length === 0) {
  33382. for (var i = this._segStrings.iterator(); i.hasNext(); ) {
  33383. var ss0 = i.next();
  33384. for (var j = this._segStrings.iterator(); j.hasNext(); ) {
  33385. var ss1 = j.next();
  33386. this$1.checkInteriorIntersections(ss0, ss1);
  33387. }
  33388. }
  33389. } else if (arguments.length === 2) {
  33390. var ss0$1 = arguments[0];
  33391. var ss1$1 = arguments[1];
  33392. var pts0 = ss0$1.getCoordinates();
  33393. var pts1 = ss1$1.getCoordinates();
  33394. for (var i0 = 0; i0 < pts0.length - 1; i0++) {
  33395. for (var i1 = 0; i1 < pts1.length - 1; i1++) {
  33396. this$1.checkInteriorIntersections(ss0$1, i0, ss1$1, i1);
  33397. }
  33398. }
  33399. } else if (arguments.length === 4) {
  33400. var e0 = arguments[0];
  33401. var segIndex0 = arguments[1];
  33402. var e1 = arguments[2];
  33403. var segIndex1 = arguments[3];
  33404. if (e0 === e1 && segIndex0 === segIndex1) {
  33405. return null;
  33406. }
  33407. var p002 = e0.getCoordinates()[segIndex0];
  33408. var p012 = e0.getCoordinates()[segIndex0 + 1];
  33409. var p102 = e1.getCoordinates()[segIndex1];
  33410. var p112 = e1.getCoordinates()[segIndex1 + 1];
  33411. this._li.computeIntersection(p002, p012, p102, p112);
  33412. if (this._li.hasIntersection()) {
  33413. if (this._li.isProper() || this.hasInteriorIntersection(this._li, p002, p012) || this.hasInteriorIntersection(this._li, p102, p112)) {
  33414. throw new RuntimeException("found non-noded intersection at " + p002 + "-" + p012 + " and " + p102 + "-" + p112);
  33415. }
  33416. }
  33417. }
  33418. };
  33419. NodingValidator.prototype.checkValid = function checkValid() {
  33420. this.checkEndPtVertexIntersections();
  33421. this.checkInteriorIntersections();
  33422. this.checkCollapses();
  33423. };
  33424. NodingValidator.prototype.checkCollapses = function checkCollapses() {
  33425. var this$1 = this;
  33426. if (arguments.length === 0) {
  33427. for (var i = this._segStrings.iterator(); i.hasNext(); ) {
  33428. var ss = i.next();
  33429. this$1.checkCollapses(ss);
  33430. }
  33431. } else if (arguments.length === 1) {
  33432. var ss$1 = arguments[0];
  33433. var pts = ss$1.getCoordinates();
  33434. for (var i$1 = 0; i$1 < pts.length - 2; i$1++) {
  33435. this$1.checkCollapse(pts[i$1], pts[i$1 + 1], pts[i$1 + 2]);
  33436. }
  33437. }
  33438. };
  33439. NodingValidator.prototype.hasInteriorIntersection = function hasInteriorIntersection2(li, p0, p1) {
  33440. for (var i = 0; i < li.getIntersectionNum(); i++) {
  33441. var intPt = li.getIntersection(i);
  33442. if (!(intPt.equals(p0) || intPt.equals(p1))) {
  33443. return true;
  33444. }
  33445. }
  33446. return false;
  33447. };
  33448. NodingValidator.prototype.checkCollapse = function checkCollapse(p0, p1, p2) {
  33449. if (p0.equals(p2)) {
  33450. throw new RuntimeException("found non-noded collapse at " + NodingValidator.fact.createLineString([p0, p1, p2]));
  33451. }
  33452. };
  33453. NodingValidator.prototype.interfaces_ = function interfaces_108() {
  33454. return [];
  33455. };
  33456. NodingValidator.prototype.getClass = function getClass107() {
  33457. return NodingValidator;
  33458. };
  33459. staticAccessors$33.fact.get = function() {
  33460. return new GeometryFactory();
  33461. };
  33462. Object.defineProperties(NodingValidator, staticAccessors$33);
  33463. var HotPixel = function HotPixel2() {
  33464. this._li = null;
  33465. this._pt = null;
  33466. this._originalPt = null;
  33467. this._ptScaled = null;
  33468. this._p0Scaled = null;
  33469. this._p1Scaled = null;
  33470. this._scaleFactor = null;
  33471. this._minx = null;
  33472. this._maxx = null;
  33473. this._miny = null;
  33474. this._maxy = null;
  33475. this._corner = new Array(4).fill(null);
  33476. this._safeEnv = null;
  33477. var pt = arguments[0];
  33478. var scaleFactor = arguments[1];
  33479. var li = arguments[2];
  33480. this._originalPt = pt;
  33481. this._pt = pt;
  33482. this._scaleFactor = scaleFactor;
  33483. this._li = li;
  33484. if (scaleFactor <= 0) {
  33485. throw new IllegalArgumentException("Scale factor must be non-zero");
  33486. }
  33487. if (scaleFactor !== 1) {
  33488. this._pt = new Coordinate(this.scale(pt.x), this.scale(pt.y));
  33489. this._p0Scaled = new Coordinate();
  33490. this._p1Scaled = new Coordinate();
  33491. }
  33492. this.initCorners(this._pt);
  33493. };
  33494. var staticAccessors$34 = { SAFE_ENV_EXPANSION_FACTOR: { configurable: true } };
  33495. HotPixel.prototype.intersectsScaled = function intersectsScaled(p0, p1) {
  33496. var segMinx = Math.min(p0.x, p1.x);
  33497. var segMaxx = Math.max(p0.x, p1.x);
  33498. var segMiny = Math.min(p0.y, p1.y);
  33499. var segMaxy = Math.max(p0.y, p1.y);
  33500. var isOutsidePixelEnv = this._maxx < segMinx || this._minx > segMaxx || this._maxy < segMiny || this._miny > segMaxy;
  33501. if (isOutsidePixelEnv) {
  33502. return false;
  33503. }
  33504. var intersects7 = this.intersectsToleranceSquare(p0, p1);
  33505. Assert.isTrue(!(isOutsidePixelEnv && intersects7), "Found bad envelope test");
  33506. return intersects7;
  33507. };
  33508. HotPixel.prototype.initCorners = function initCorners(pt) {
  33509. var tolerance = 0.5;
  33510. this._minx = pt.x - tolerance;
  33511. this._maxx = pt.x + tolerance;
  33512. this._miny = pt.y - tolerance;
  33513. this._maxy = pt.y + tolerance;
  33514. this._corner[0] = new Coordinate(this._maxx, this._maxy);
  33515. this._corner[1] = new Coordinate(this._minx, this._maxy);
  33516. this._corner[2] = new Coordinate(this._minx, this._miny);
  33517. this._corner[3] = new Coordinate(this._maxx, this._miny);
  33518. };
  33519. HotPixel.prototype.intersects = function intersects4(p0, p1) {
  33520. if (this._scaleFactor === 1) {
  33521. return this.intersectsScaled(p0, p1);
  33522. }
  33523. this.copyScaled(p0, this._p0Scaled);
  33524. this.copyScaled(p1, this._p1Scaled);
  33525. return this.intersectsScaled(this._p0Scaled, this._p1Scaled);
  33526. };
  33527. HotPixel.prototype.scale = function scale3(val) {
  33528. return Math.round(val * this._scaleFactor);
  33529. };
  33530. HotPixel.prototype.getCoordinate = function getCoordinate13() {
  33531. return this._originalPt;
  33532. };
  33533. HotPixel.prototype.copyScaled = function copyScaled(p, pScaled) {
  33534. pScaled.x = this.scale(p.x);
  33535. pScaled.y = this.scale(p.y);
  33536. };
  33537. HotPixel.prototype.getSafeEnvelope = function getSafeEnvelope() {
  33538. if (this._safeEnv === null) {
  33539. var safeTolerance = HotPixel.SAFE_ENV_EXPANSION_FACTOR / this._scaleFactor;
  33540. this._safeEnv = new Envelope(this._originalPt.x - safeTolerance, this._originalPt.x + safeTolerance, this._originalPt.y - safeTolerance, this._originalPt.y + safeTolerance);
  33541. }
  33542. return this._safeEnv;
  33543. };
  33544. HotPixel.prototype.intersectsPixelClosure = function intersectsPixelClosure(p0, p1) {
  33545. this._li.computeIntersection(p0, p1, this._corner[0], this._corner[1]);
  33546. if (this._li.hasIntersection()) {
  33547. return true;
  33548. }
  33549. this._li.computeIntersection(p0, p1, this._corner[1], this._corner[2]);
  33550. if (this._li.hasIntersection()) {
  33551. return true;
  33552. }
  33553. this._li.computeIntersection(p0, p1, this._corner[2], this._corner[3]);
  33554. if (this._li.hasIntersection()) {
  33555. return true;
  33556. }
  33557. this._li.computeIntersection(p0, p1, this._corner[3], this._corner[0]);
  33558. if (this._li.hasIntersection()) {
  33559. return true;
  33560. }
  33561. return false;
  33562. };
  33563. HotPixel.prototype.intersectsToleranceSquare = function intersectsToleranceSquare(p0, p1) {
  33564. var intersectsLeft = false;
  33565. var intersectsBottom = false;
  33566. this._li.computeIntersection(p0, p1, this._corner[0], this._corner[1]);
  33567. if (this._li.isProper()) {
  33568. return true;
  33569. }
  33570. this._li.computeIntersection(p0, p1, this._corner[1], this._corner[2]);
  33571. if (this._li.isProper()) {
  33572. return true;
  33573. }
  33574. if (this._li.hasIntersection()) {
  33575. intersectsLeft = true;
  33576. }
  33577. this._li.computeIntersection(p0, p1, this._corner[2], this._corner[3]);
  33578. if (this._li.isProper()) {
  33579. return true;
  33580. }
  33581. if (this._li.hasIntersection()) {
  33582. intersectsBottom = true;
  33583. }
  33584. this._li.computeIntersection(p0, p1, this._corner[3], this._corner[0]);
  33585. if (this._li.isProper()) {
  33586. return true;
  33587. }
  33588. if (intersectsLeft && intersectsBottom) {
  33589. return true;
  33590. }
  33591. if (p0.equals(this._pt)) {
  33592. return true;
  33593. }
  33594. if (p1.equals(this._pt)) {
  33595. return true;
  33596. }
  33597. return false;
  33598. };
  33599. HotPixel.prototype.addSnappedNode = function addSnappedNode(segStr, segIndex) {
  33600. var p0 = segStr.getCoordinate(segIndex);
  33601. var p1 = segStr.getCoordinate(segIndex + 1);
  33602. if (this.intersects(p0, p1)) {
  33603. segStr.addIntersection(this.getCoordinate(), segIndex);
  33604. return true;
  33605. }
  33606. return false;
  33607. };
  33608. HotPixel.prototype.interfaces_ = function interfaces_109() {
  33609. return [];
  33610. };
  33611. HotPixel.prototype.getClass = function getClass108() {
  33612. return HotPixel;
  33613. };
  33614. staticAccessors$34.SAFE_ENV_EXPANSION_FACTOR.get = function() {
  33615. return 0.75;
  33616. };
  33617. Object.defineProperties(HotPixel, staticAccessors$34);
  33618. var MonotoneChainSelectAction = function MonotoneChainSelectAction2() {
  33619. this.tempEnv1 = new Envelope();
  33620. this.selectedSegment = new LineSegment();
  33621. };
  33622. MonotoneChainSelectAction.prototype.select = function select2() {
  33623. if (arguments.length === 1) {
  33624. } else if (arguments.length === 2) {
  33625. var mc = arguments[0];
  33626. var startIndex = arguments[1];
  33627. mc.getLineSegment(startIndex, this.selectedSegment);
  33628. this.select(this.selectedSegment);
  33629. }
  33630. };
  33631. MonotoneChainSelectAction.prototype.interfaces_ = function interfaces_110() {
  33632. return [];
  33633. };
  33634. MonotoneChainSelectAction.prototype.getClass = function getClass109() {
  33635. return MonotoneChainSelectAction;
  33636. };
  33637. var MCIndexPointSnapper = function MCIndexPointSnapper2() {
  33638. this._index = null;
  33639. var index2 = arguments[0];
  33640. this._index = index2;
  33641. };
  33642. var staticAccessors$35 = { HotPixelSnapAction: { configurable: true } };
  33643. MCIndexPointSnapper.prototype.snap = function snap() {
  33644. if (arguments.length === 1) {
  33645. var hotPixel = arguments[0];
  33646. return this.snap(hotPixel, null, -1);
  33647. } else if (arguments.length === 3) {
  33648. var hotPixel$1 = arguments[0];
  33649. var parentEdge = arguments[1];
  33650. var hotPixelVertexIndex = arguments[2];
  33651. var pixelEnv = hotPixel$1.getSafeEnvelope();
  33652. var hotPixelSnapAction = new HotPixelSnapAction(hotPixel$1, parentEdge, hotPixelVertexIndex);
  33653. this._index.query(pixelEnv, {
  33654. interfaces_: function() {
  33655. return [ItemVisitor];
  33656. },
  33657. visitItem: function(item) {
  33658. var testChain = item;
  33659. testChain.select(pixelEnv, hotPixelSnapAction);
  33660. }
  33661. });
  33662. return hotPixelSnapAction.isNodeAdded();
  33663. }
  33664. };
  33665. MCIndexPointSnapper.prototype.interfaces_ = function interfaces_111() {
  33666. return [];
  33667. };
  33668. MCIndexPointSnapper.prototype.getClass = function getClass110() {
  33669. return MCIndexPointSnapper;
  33670. };
  33671. staticAccessors$35.HotPixelSnapAction.get = function() {
  33672. return HotPixelSnapAction;
  33673. };
  33674. Object.defineProperties(MCIndexPointSnapper, staticAccessors$35);
  33675. var HotPixelSnapAction = function(MonotoneChainSelectAction$$1) {
  33676. function HotPixelSnapAction2() {
  33677. MonotoneChainSelectAction$$1.call(this);
  33678. this._hotPixel = null;
  33679. this._parentEdge = null;
  33680. this._hotPixelVertexIndex = null;
  33681. this._isNodeAdded = false;
  33682. var hotPixel = arguments[0];
  33683. var parentEdge = arguments[1];
  33684. var hotPixelVertexIndex = arguments[2];
  33685. this._hotPixel = hotPixel;
  33686. this._parentEdge = parentEdge;
  33687. this._hotPixelVertexIndex = hotPixelVertexIndex;
  33688. }
  33689. if (MonotoneChainSelectAction$$1)
  33690. HotPixelSnapAction2.__proto__ = MonotoneChainSelectAction$$1;
  33691. HotPixelSnapAction2.prototype = Object.create(MonotoneChainSelectAction$$1 && MonotoneChainSelectAction$$1.prototype);
  33692. HotPixelSnapAction2.prototype.constructor = HotPixelSnapAction2;
  33693. HotPixelSnapAction2.prototype.isNodeAdded = function isNodeAdded() {
  33694. return this._isNodeAdded;
  33695. };
  33696. HotPixelSnapAction2.prototype.select = function select3() {
  33697. if (arguments.length === 2) {
  33698. var mc = arguments[0];
  33699. var startIndex = arguments[1];
  33700. var ss = mc.getContext();
  33701. if (this._parentEdge !== null) {
  33702. if (ss === this._parentEdge && startIndex === this._hotPixelVertexIndex) {
  33703. return null;
  33704. }
  33705. }
  33706. this._isNodeAdded = this._hotPixel.addSnappedNode(ss, startIndex);
  33707. } else {
  33708. return MonotoneChainSelectAction$$1.prototype.select.apply(this, arguments);
  33709. }
  33710. };
  33711. HotPixelSnapAction2.prototype.interfaces_ = function interfaces_170() {
  33712. return [];
  33713. };
  33714. HotPixelSnapAction2.prototype.getClass = function getClass169() {
  33715. return HotPixelSnapAction2;
  33716. };
  33717. return HotPixelSnapAction2;
  33718. }(MonotoneChainSelectAction);
  33719. var InteriorIntersectionFinderAdder = function InteriorIntersectionFinderAdder2() {
  33720. this._li = null;
  33721. this._interiorIntersections = null;
  33722. var li = arguments[0];
  33723. this._li = li;
  33724. this._interiorIntersections = new ArrayList();
  33725. };
  33726. InteriorIntersectionFinderAdder.prototype.processIntersections = function processIntersections3(e0, segIndex0, e1, segIndex1) {
  33727. var this$1 = this;
  33728. if (e0 === e1 && segIndex0 === segIndex1) {
  33729. return null;
  33730. }
  33731. var p002 = e0.getCoordinates()[segIndex0];
  33732. var p012 = e0.getCoordinates()[segIndex0 + 1];
  33733. var p102 = e1.getCoordinates()[segIndex1];
  33734. var p112 = e1.getCoordinates()[segIndex1 + 1];
  33735. this._li.computeIntersection(p002, p012, p102, p112);
  33736. if (this._li.hasIntersection()) {
  33737. if (this._li.isInteriorIntersection()) {
  33738. for (var intIndex = 0; intIndex < this._li.getIntersectionNum(); intIndex++) {
  33739. this$1._interiorIntersections.add(this$1._li.getIntersection(intIndex));
  33740. }
  33741. e0.addIntersections(this._li, segIndex0, 0);
  33742. e1.addIntersections(this._li, segIndex1, 1);
  33743. }
  33744. }
  33745. };
  33746. InteriorIntersectionFinderAdder.prototype.isDone = function isDone4() {
  33747. return false;
  33748. };
  33749. InteriorIntersectionFinderAdder.prototype.getInteriorIntersections = function getInteriorIntersections() {
  33750. return this._interiorIntersections;
  33751. };
  33752. InteriorIntersectionFinderAdder.prototype.interfaces_ = function interfaces_112() {
  33753. return [SegmentIntersector];
  33754. };
  33755. InteriorIntersectionFinderAdder.prototype.getClass = function getClass111() {
  33756. return InteriorIntersectionFinderAdder;
  33757. };
  33758. var MCIndexSnapRounder = function MCIndexSnapRounder2() {
  33759. this._pm = null;
  33760. this._li = null;
  33761. this._scaleFactor = null;
  33762. this._noder = null;
  33763. this._pointSnapper = null;
  33764. this._nodedSegStrings = null;
  33765. var pm = arguments[0];
  33766. this._pm = pm;
  33767. this._li = new RobustLineIntersector();
  33768. this._li.setPrecisionModel(pm);
  33769. this._scaleFactor = pm.getScale();
  33770. };
  33771. MCIndexSnapRounder.prototype.checkCorrectness = function checkCorrectness(inputSegmentStrings) {
  33772. var resultSegStrings = NodedSegmentString.getNodedSubstrings(inputSegmentStrings);
  33773. var nv = new NodingValidator(resultSegStrings);
  33774. try {
  33775. nv.checkValid();
  33776. } catch (ex) {
  33777. if (ex instanceof Exception) {
  33778. ex.printStackTrace();
  33779. } else {
  33780. throw ex;
  33781. }
  33782. } finally {
  33783. }
  33784. };
  33785. MCIndexSnapRounder.prototype.getNodedSubstrings = function getNodedSubstrings4() {
  33786. return NodedSegmentString.getNodedSubstrings(this._nodedSegStrings);
  33787. };
  33788. MCIndexSnapRounder.prototype.snapRound = function snapRound(segStrings, li) {
  33789. var intersections = this.findInteriorIntersections(segStrings, li);
  33790. this.computeIntersectionSnaps(intersections);
  33791. this.computeVertexSnaps(segStrings);
  33792. };
  33793. MCIndexSnapRounder.prototype.findInteriorIntersections = function findInteriorIntersections(segStrings, li) {
  33794. var intFinderAdder = new InteriorIntersectionFinderAdder(li);
  33795. this._noder.setSegmentIntersector(intFinderAdder);
  33796. this._noder.computeNodes(segStrings);
  33797. return intFinderAdder.getInteriorIntersections();
  33798. };
  33799. MCIndexSnapRounder.prototype.computeVertexSnaps = function computeVertexSnaps() {
  33800. var this$1 = this;
  33801. if (hasInterface(arguments[0], Collection)) {
  33802. var edges2 = arguments[0];
  33803. for (var i0 = edges2.iterator(); i0.hasNext(); ) {
  33804. var edge0 = i0.next();
  33805. this$1.computeVertexSnaps(edge0);
  33806. }
  33807. } else if (arguments[0] instanceof NodedSegmentString) {
  33808. var e = arguments[0];
  33809. var pts0 = e.getCoordinates();
  33810. for (var i = 0; i < pts0.length; i++) {
  33811. var hotPixel = new HotPixel(pts0[i], this$1._scaleFactor, this$1._li);
  33812. var isNodeAdded = this$1._pointSnapper.snap(hotPixel, e, i);
  33813. if (isNodeAdded) {
  33814. e.addIntersection(pts0[i], i);
  33815. }
  33816. }
  33817. }
  33818. };
  33819. MCIndexSnapRounder.prototype.computeNodes = function computeNodes3(inputSegmentStrings) {
  33820. this._nodedSegStrings = inputSegmentStrings;
  33821. this._noder = new MCIndexNoder();
  33822. this._pointSnapper = new MCIndexPointSnapper(this._noder.getIndex());
  33823. this.snapRound(inputSegmentStrings, this._li);
  33824. };
  33825. MCIndexSnapRounder.prototype.computeIntersectionSnaps = function computeIntersectionSnaps(snapPts) {
  33826. var this$1 = this;
  33827. for (var it = snapPts.iterator(); it.hasNext(); ) {
  33828. var snapPt = it.next();
  33829. var hotPixel = new HotPixel(snapPt, this$1._scaleFactor, this$1._li);
  33830. this$1._pointSnapper.snap(hotPixel);
  33831. }
  33832. };
  33833. MCIndexSnapRounder.prototype.interfaces_ = function interfaces_113() {
  33834. return [Noder];
  33835. };
  33836. MCIndexSnapRounder.prototype.getClass = function getClass112() {
  33837. return MCIndexSnapRounder;
  33838. };
  33839. var BufferOp = function BufferOp2() {
  33840. this._argGeom = null;
  33841. this._distance = null;
  33842. this._bufParams = new BufferParameters();
  33843. this._resultGeometry = null;
  33844. this._saveException = null;
  33845. if (arguments.length === 1) {
  33846. var g = arguments[0];
  33847. this._argGeom = g;
  33848. } else if (arguments.length === 2) {
  33849. var g$1 = arguments[0];
  33850. var bufParams = arguments[1];
  33851. this._argGeom = g$1;
  33852. this._bufParams = bufParams;
  33853. }
  33854. };
  33855. var staticAccessors$32 = { CAP_ROUND: { configurable: true }, CAP_BUTT: { configurable: true }, CAP_FLAT: { configurable: true }, CAP_SQUARE: { configurable: true }, MAX_PRECISION_DIGITS: { configurable: true } };
  33856. BufferOp.prototype.bufferFixedPrecision = function bufferFixedPrecision(fixedPM) {
  33857. var noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1)), fixedPM.getScale());
  33858. var bufBuilder = new BufferBuilder(this._bufParams);
  33859. bufBuilder.setWorkingPrecisionModel(fixedPM);
  33860. bufBuilder.setNoder(noder);
  33861. this._resultGeometry = bufBuilder.buffer(this._argGeom, this._distance);
  33862. };
  33863. BufferOp.prototype.bufferReducedPrecision = function bufferReducedPrecision() {
  33864. var this$1 = this;
  33865. if (arguments.length === 0) {
  33866. for (var precDigits = BufferOp.MAX_PRECISION_DIGITS; precDigits >= 0; precDigits--) {
  33867. try {
  33868. this$1.bufferReducedPrecision(precDigits);
  33869. } catch (ex) {
  33870. if (ex instanceof TopologyException) {
  33871. this$1._saveException = ex;
  33872. } else {
  33873. throw ex;
  33874. }
  33875. } finally {
  33876. }
  33877. if (this$1._resultGeometry !== null) {
  33878. return null;
  33879. }
  33880. }
  33881. throw this._saveException;
  33882. } else if (arguments.length === 1) {
  33883. var precisionDigits = arguments[0];
  33884. var sizeBasedScaleFactor = BufferOp.precisionScaleFactor(this._argGeom, this._distance, precisionDigits);
  33885. var fixedPM = new PrecisionModel(sizeBasedScaleFactor);
  33886. this.bufferFixedPrecision(fixedPM);
  33887. }
  33888. };
  33889. BufferOp.prototype.computeGeometry = function computeGeometry() {
  33890. this.bufferOriginalPrecision();
  33891. if (this._resultGeometry !== null) {
  33892. return null;
  33893. }
  33894. var argPM = this._argGeom.getFactory().getPrecisionModel();
  33895. if (argPM.getType() === PrecisionModel.FIXED) {
  33896. this.bufferFixedPrecision(argPM);
  33897. } else {
  33898. this.bufferReducedPrecision();
  33899. }
  33900. };
  33901. BufferOp.prototype.setQuadrantSegments = function setQuadrantSegments2(quadrantSegments) {
  33902. this._bufParams.setQuadrantSegments(quadrantSegments);
  33903. };
  33904. BufferOp.prototype.bufferOriginalPrecision = function bufferOriginalPrecision() {
  33905. try {
  33906. var bufBuilder = new BufferBuilder(this._bufParams);
  33907. this._resultGeometry = bufBuilder.buffer(this._argGeom, this._distance);
  33908. } catch (ex) {
  33909. if (ex instanceof RuntimeException) {
  33910. this._saveException = ex;
  33911. } else {
  33912. throw ex;
  33913. }
  33914. } finally {
  33915. }
  33916. };
  33917. BufferOp.prototype.getResultGeometry = function getResultGeometry(distance11) {
  33918. this._distance = distance11;
  33919. this.computeGeometry();
  33920. return this._resultGeometry;
  33921. };
  33922. BufferOp.prototype.setEndCapStyle = function setEndCapStyle2(endCapStyle) {
  33923. this._bufParams.setEndCapStyle(endCapStyle);
  33924. };
  33925. BufferOp.prototype.interfaces_ = function interfaces_114() {
  33926. return [];
  33927. };
  33928. BufferOp.prototype.getClass = function getClass113() {
  33929. return BufferOp;
  33930. };
  33931. BufferOp.bufferOp = function bufferOp() {
  33932. if (arguments.length === 2) {
  33933. var g = arguments[0];
  33934. var distance11 = arguments[1];
  33935. var gBuf = new BufferOp(g);
  33936. var geomBuf = gBuf.getResultGeometry(distance11);
  33937. return geomBuf;
  33938. } else if (arguments.length === 3) {
  33939. if (Number.isInteger(arguments[2]) && (arguments[0] instanceof Geometry && typeof arguments[1] === "number")) {
  33940. var g$1 = arguments[0];
  33941. var distance$1 = arguments[1];
  33942. var quadrantSegments = arguments[2];
  33943. var bufOp = new BufferOp(g$1);
  33944. bufOp.setQuadrantSegments(quadrantSegments);
  33945. var geomBuf$1 = bufOp.getResultGeometry(distance$1);
  33946. return geomBuf$1;
  33947. } else if (arguments[2] instanceof BufferParameters && (arguments[0] instanceof Geometry && typeof arguments[1] === "number")) {
  33948. var g$2 = arguments[0];
  33949. var distance$2 = arguments[1];
  33950. var params = arguments[2];
  33951. var bufOp$1 = new BufferOp(g$2, params);
  33952. var geomBuf$2 = bufOp$1.getResultGeometry(distance$2);
  33953. return geomBuf$2;
  33954. }
  33955. } else if (arguments.length === 4) {
  33956. var g$3 = arguments[0];
  33957. var distance$3 = arguments[1];
  33958. var quadrantSegments$1 = arguments[2];
  33959. var endCapStyle = arguments[3];
  33960. var bufOp$2 = new BufferOp(g$3);
  33961. bufOp$2.setQuadrantSegments(quadrantSegments$1);
  33962. bufOp$2.setEndCapStyle(endCapStyle);
  33963. var geomBuf$3 = bufOp$2.getResultGeometry(distance$3);
  33964. return geomBuf$3;
  33965. }
  33966. };
  33967. BufferOp.precisionScaleFactor = function precisionScaleFactor(g, distance11, maxPrecisionDigits) {
  33968. var env = g.getEnvelopeInternal();
  33969. var envMax = MathUtil.max(Math.abs(env.getMaxX()), Math.abs(env.getMaxY()), Math.abs(env.getMinX()), Math.abs(env.getMinY()));
  33970. var expandByDistance = distance11 > 0 ? distance11 : 0;
  33971. var bufEnvMax = envMax + 2 * expandByDistance;
  33972. var bufEnvPrecisionDigits = Math.trunc(Math.log(bufEnvMax) / Math.log(10) + 1);
  33973. var minUnitLog10 = maxPrecisionDigits - bufEnvPrecisionDigits;
  33974. var scaleFactor = Math.pow(10, minUnitLog10);
  33975. return scaleFactor;
  33976. };
  33977. staticAccessors$32.CAP_ROUND.get = function() {
  33978. return BufferParameters.CAP_ROUND;
  33979. };
  33980. staticAccessors$32.CAP_BUTT.get = function() {
  33981. return BufferParameters.CAP_FLAT;
  33982. };
  33983. staticAccessors$32.CAP_FLAT.get = function() {
  33984. return BufferParameters.CAP_FLAT;
  33985. };
  33986. staticAccessors$32.CAP_SQUARE.get = function() {
  33987. return BufferParameters.CAP_SQUARE;
  33988. };
  33989. staticAccessors$32.MAX_PRECISION_DIGITS.get = function() {
  33990. return 12;
  33991. };
  33992. Object.defineProperties(BufferOp, staticAccessors$32);
  33993. var PointPairDistance = function PointPairDistance2() {
  33994. this._pt = [new Coordinate(), new Coordinate()];
  33995. this._distance = Double.NaN;
  33996. this._isNull = true;
  33997. };
  33998. PointPairDistance.prototype.getCoordinates = function getCoordinates7() {
  33999. return this._pt;
  34000. };
  34001. PointPairDistance.prototype.getCoordinate = function getCoordinate14(i) {
  34002. return this._pt[i];
  34003. };
  34004. PointPairDistance.prototype.setMinimum = function setMinimum() {
  34005. if (arguments.length === 1) {
  34006. var ptDist = arguments[0];
  34007. this.setMinimum(ptDist._pt[0], ptDist._pt[1]);
  34008. } else if (arguments.length === 2) {
  34009. var p0 = arguments[0];
  34010. var p1 = arguments[1];
  34011. if (this._isNull) {
  34012. this.initialize(p0, p1);
  34013. return null;
  34014. }
  34015. var dist = p0.distance(p1);
  34016. if (dist < this._distance) {
  34017. this.initialize(p0, p1, dist);
  34018. }
  34019. }
  34020. };
  34021. PointPairDistance.prototype.initialize = function initialize() {
  34022. if (arguments.length === 0) {
  34023. this._isNull = true;
  34024. } else if (arguments.length === 2) {
  34025. var p0 = arguments[0];
  34026. var p1 = arguments[1];
  34027. this._pt[0].setCoordinate(p0);
  34028. this._pt[1].setCoordinate(p1);
  34029. this._distance = p0.distance(p1);
  34030. this._isNull = false;
  34031. } else if (arguments.length === 3) {
  34032. var p0$1 = arguments[0];
  34033. var p1$1 = arguments[1];
  34034. var distance11 = arguments[2];
  34035. this._pt[0].setCoordinate(p0$1);
  34036. this._pt[1].setCoordinate(p1$1);
  34037. this._distance = distance11;
  34038. this._isNull = false;
  34039. }
  34040. };
  34041. PointPairDistance.prototype.getDistance = function getDistance3() {
  34042. return this._distance;
  34043. };
  34044. PointPairDistance.prototype.setMaximum = function setMaximum() {
  34045. if (arguments.length === 1) {
  34046. var ptDist = arguments[0];
  34047. this.setMaximum(ptDist._pt[0], ptDist._pt[1]);
  34048. } else if (arguments.length === 2) {
  34049. var p0 = arguments[0];
  34050. var p1 = arguments[1];
  34051. if (this._isNull) {
  34052. this.initialize(p0, p1);
  34053. return null;
  34054. }
  34055. var dist = p0.distance(p1);
  34056. if (dist > this._distance) {
  34057. this.initialize(p0, p1, dist);
  34058. }
  34059. }
  34060. };
  34061. PointPairDistance.prototype.interfaces_ = function interfaces_115() {
  34062. return [];
  34063. };
  34064. PointPairDistance.prototype.getClass = function getClass114() {
  34065. return PointPairDistance;
  34066. };
  34067. var DistanceToPointFinder = function DistanceToPointFinder2() {
  34068. };
  34069. DistanceToPointFinder.prototype.interfaces_ = function interfaces_116() {
  34070. return [];
  34071. };
  34072. DistanceToPointFinder.prototype.getClass = function getClass115() {
  34073. return DistanceToPointFinder;
  34074. };
  34075. DistanceToPointFinder.computeDistance = function computeDistance() {
  34076. if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof LineString2 && arguments[1] instanceof Coordinate)) {
  34077. var line = arguments[0];
  34078. var pt = arguments[1];
  34079. var ptDist = arguments[2];
  34080. var coords = line.getCoordinates();
  34081. var tempSegment = new LineSegment();
  34082. for (var i = 0; i < coords.length - 1; i++) {
  34083. tempSegment.setCoordinates(coords[i], coords[i + 1]);
  34084. var closestPt = tempSegment.closestPoint(pt);
  34085. ptDist.setMinimum(closestPt, pt);
  34086. }
  34087. } else if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof Polygon && arguments[1] instanceof Coordinate)) {
  34088. var poly = arguments[0];
  34089. var pt$1 = arguments[1];
  34090. var ptDist$1 = arguments[2];
  34091. DistanceToPointFinder.computeDistance(poly.getExteriorRing(), pt$1, ptDist$1);
  34092. for (var i$1 = 0; i$1 < poly.getNumInteriorRing(); i$1++) {
  34093. DistanceToPointFinder.computeDistance(poly.getInteriorRingN(i$1), pt$1, ptDist$1);
  34094. }
  34095. } else if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof Geometry && arguments[1] instanceof Coordinate)) {
  34096. var geom = arguments[0];
  34097. var pt$2 = arguments[1];
  34098. var ptDist$2 = arguments[2];
  34099. if (geom instanceof LineString2) {
  34100. DistanceToPointFinder.computeDistance(geom, pt$2, ptDist$2);
  34101. } else if (geom instanceof Polygon) {
  34102. DistanceToPointFinder.computeDistance(geom, pt$2, ptDist$2);
  34103. } else if (geom instanceof GeometryCollection) {
  34104. var gc = geom;
  34105. for (var i$2 = 0; i$2 < gc.getNumGeometries(); i$2++) {
  34106. var g = gc.getGeometryN(i$2);
  34107. DistanceToPointFinder.computeDistance(g, pt$2, ptDist$2);
  34108. }
  34109. } else {
  34110. ptDist$2.setMinimum(geom.getCoordinate(), pt$2);
  34111. }
  34112. } else if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof LineSegment && arguments[1] instanceof Coordinate)) {
  34113. var segment = arguments[0];
  34114. var pt$3 = arguments[1];
  34115. var ptDist$3 = arguments[2];
  34116. var closestPt$1 = segment.closestPoint(pt$3);
  34117. ptDist$3.setMinimum(closestPt$1, pt$3);
  34118. }
  34119. };
  34120. var BufferCurveMaximumDistanceFinder = function BufferCurveMaximumDistanceFinder2(inputGeom) {
  34121. this._maxPtDist = new PointPairDistance();
  34122. this._inputGeom = inputGeom || null;
  34123. };
  34124. var staticAccessors$36 = { MaxPointDistanceFilter: { configurable: true }, MaxMidpointDistanceFilter: { configurable: true } };
  34125. BufferCurveMaximumDistanceFinder.prototype.computeMaxMidpointDistance = function computeMaxMidpointDistance(curve) {
  34126. var distFilter = new MaxMidpointDistanceFilter(this._inputGeom);
  34127. curve.apply(distFilter);
  34128. this._maxPtDist.setMaximum(distFilter.getMaxPointDistance());
  34129. };
  34130. BufferCurveMaximumDistanceFinder.prototype.computeMaxVertexDistance = function computeMaxVertexDistance(curve) {
  34131. var distFilter = new MaxPointDistanceFilter(this._inputGeom);
  34132. curve.apply(distFilter);
  34133. this._maxPtDist.setMaximum(distFilter.getMaxPointDistance());
  34134. };
  34135. BufferCurveMaximumDistanceFinder.prototype.findDistance = function findDistance(bufferCurve) {
  34136. this.computeMaxVertexDistance(bufferCurve);
  34137. this.computeMaxMidpointDistance(bufferCurve);
  34138. return this._maxPtDist.getDistance();
  34139. };
  34140. BufferCurveMaximumDistanceFinder.prototype.getDistancePoints = function getDistancePoints() {
  34141. return this._maxPtDist;
  34142. };
  34143. BufferCurveMaximumDistanceFinder.prototype.interfaces_ = function interfaces_117() {
  34144. return [];
  34145. };
  34146. BufferCurveMaximumDistanceFinder.prototype.getClass = function getClass116() {
  34147. return BufferCurveMaximumDistanceFinder;
  34148. };
  34149. staticAccessors$36.MaxPointDistanceFilter.get = function() {
  34150. return MaxPointDistanceFilter;
  34151. };
  34152. staticAccessors$36.MaxMidpointDistanceFilter.get = function() {
  34153. return MaxMidpointDistanceFilter;
  34154. };
  34155. Object.defineProperties(BufferCurveMaximumDistanceFinder, staticAccessors$36);
  34156. var MaxPointDistanceFilter = function MaxPointDistanceFilter2(geom) {
  34157. this._maxPtDist = new PointPairDistance();
  34158. this._minPtDist = new PointPairDistance();
  34159. this._geom = geom || null;
  34160. };
  34161. MaxPointDistanceFilter.prototype.filter = function filter6(pt) {
  34162. this._minPtDist.initialize();
  34163. DistanceToPointFinder.computeDistance(this._geom, pt, this._minPtDist);
  34164. this._maxPtDist.setMaximum(this._minPtDist);
  34165. };
  34166. MaxPointDistanceFilter.prototype.getMaxPointDistance = function getMaxPointDistance() {
  34167. return this._maxPtDist;
  34168. };
  34169. MaxPointDistanceFilter.prototype.interfaces_ = function interfaces_118() {
  34170. return [CoordinateFilter];
  34171. };
  34172. MaxPointDistanceFilter.prototype.getClass = function getClass117() {
  34173. return MaxPointDistanceFilter;
  34174. };
  34175. var MaxMidpointDistanceFilter = function MaxMidpointDistanceFilter2(geom) {
  34176. this._maxPtDist = new PointPairDistance();
  34177. this._minPtDist = new PointPairDistance();
  34178. this._geom = geom || null;
  34179. };
  34180. MaxMidpointDistanceFilter.prototype.filter = function filter7(seq, index2) {
  34181. if (index2 === 0) {
  34182. return null;
  34183. }
  34184. var p0 = seq.getCoordinate(index2 - 1);
  34185. var p1 = seq.getCoordinate(index2);
  34186. var midPt = new Coordinate((p0.x + p1.x) / 2, (p0.y + p1.y) / 2);
  34187. this._minPtDist.initialize();
  34188. DistanceToPointFinder.computeDistance(this._geom, midPt, this._minPtDist);
  34189. this._maxPtDist.setMaximum(this._minPtDist);
  34190. };
  34191. MaxMidpointDistanceFilter.prototype.isDone = function isDone5() {
  34192. return false;
  34193. };
  34194. MaxMidpointDistanceFilter.prototype.isGeometryChanged = function isGeometryChanged2() {
  34195. return false;
  34196. };
  34197. MaxMidpointDistanceFilter.prototype.getMaxPointDistance = function getMaxPointDistance2() {
  34198. return this._maxPtDist;
  34199. };
  34200. MaxMidpointDistanceFilter.prototype.interfaces_ = function interfaces_119() {
  34201. return [CoordinateSequenceFilter];
  34202. };
  34203. MaxMidpointDistanceFilter.prototype.getClass = function getClass118() {
  34204. return MaxMidpointDistanceFilter;
  34205. };
  34206. var PolygonExtracter = function PolygonExtracter2(comps) {
  34207. this._comps = comps || null;
  34208. };
  34209. PolygonExtracter.prototype.filter = function filter8(geom) {
  34210. if (geom instanceof Polygon) {
  34211. this._comps.add(geom);
  34212. }
  34213. };
  34214. PolygonExtracter.prototype.interfaces_ = function interfaces_120() {
  34215. return [GeometryFilter];
  34216. };
  34217. PolygonExtracter.prototype.getClass = function getClass119() {
  34218. return PolygonExtracter;
  34219. };
  34220. PolygonExtracter.getPolygons = function getPolygons2() {
  34221. if (arguments.length === 1) {
  34222. var geom = arguments[0];
  34223. return PolygonExtracter.getPolygons(geom, new ArrayList());
  34224. } else if (arguments.length === 2) {
  34225. var geom$1 = arguments[0];
  34226. var list = arguments[1];
  34227. if (geom$1 instanceof Polygon) {
  34228. list.add(geom$1);
  34229. } else if (geom$1 instanceof GeometryCollection) {
  34230. geom$1.apply(new PolygonExtracter(list));
  34231. }
  34232. return list;
  34233. }
  34234. };
  34235. var LinearComponentExtracter = function LinearComponentExtracter2() {
  34236. this._lines = null;
  34237. this._isForcedToLineString = false;
  34238. if (arguments.length === 1) {
  34239. var lines = arguments[0];
  34240. this._lines = lines;
  34241. } else if (arguments.length === 2) {
  34242. var lines$1 = arguments[0];
  34243. var isForcedToLineString = arguments[1];
  34244. this._lines = lines$1;
  34245. this._isForcedToLineString = isForcedToLineString;
  34246. }
  34247. };
  34248. LinearComponentExtracter.prototype.filter = function filter9(geom) {
  34249. if (this._isForcedToLineString && geom instanceof LinearRing) {
  34250. var line = geom.getFactory().createLineString(geom.getCoordinateSequence());
  34251. this._lines.add(line);
  34252. return null;
  34253. }
  34254. if (geom instanceof LineString2) {
  34255. this._lines.add(geom);
  34256. }
  34257. };
  34258. LinearComponentExtracter.prototype.setForceToLineString = function setForceToLineString(isForcedToLineString) {
  34259. this._isForcedToLineString = isForcedToLineString;
  34260. };
  34261. LinearComponentExtracter.prototype.interfaces_ = function interfaces_121() {
  34262. return [GeometryComponentFilter];
  34263. };
  34264. LinearComponentExtracter.prototype.getClass = function getClass120() {
  34265. return LinearComponentExtracter;
  34266. };
  34267. LinearComponentExtracter.getGeometry = function getGeometry() {
  34268. if (arguments.length === 1) {
  34269. var geom = arguments[0];
  34270. return geom.getFactory().buildGeometry(LinearComponentExtracter.getLines(geom));
  34271. } else if (arguments.length === 2) {
  34272. var geom$1 = arguments[0];
  34273. var forceToLineString = arguments[1];
  34274. return geom$1.getFactory().buildGeometry(LinearComponentExtracter.getLines(geom$1, forceToLineString));
  34275. }
  34276. };
  34277. LinearComponentExtracter.getLines = function getLines() {
  34278. if (arguments.length === 1) {
  34279. var geom = arguments[0];
  34280. return LinearComponentExtracter.getLines(geom, false);
  34281. } else if (arguments.length === 2) {
  34282. if (hasInterface(arguments[0], Collection) && hasInterface(arguments[1], Collection)) {
  34283. var geoms = arguments[0];
  34284. var lines$1 = arguments[1];
  34285. for (var i = geoms.iterator(); i.hasNext(); ) {
  34286. var g = i.next();
  34287. LinearComponentExtracter.getLines(g, lines$1);
  34288. }
  34289. return lines$1;
  34290. } else if (arguments[0] instanceof Geometry && typeof arguments[1] === "boolean") {
  34291. var geom$1 = arguments[0];
  34292. var forceToLineString = arguments[1];
  34293. var lines = new ArrayList();
  34294. geom$1.apply(new LinearComponentExtracter(lines, forceToLineString));
  34295. return lines;
  34296. } else if (arguments[0] instanceof Geometry && hasInterface(arguments[1], Collection)) {
  34297. var geom$2 = arguments[0];
  34298. var lines$2 = arguments[1];
  34299. if (geom$2 instanceof LineString2) {
  34300. lines$2.add(geom$2);
  34301. } else {
  34302. geom$2.apply(new LinearComponentExtracter(lines$2));
  34303. }
  34304. return lines$2;
  34305. }
  34306. } else if (arguments.length === 3) {
  34307. if (typeof arguments[2] === "boolean" && (hasInterface(arguments[0], Collection) && hasInterface(arguments[1], Collection))) {
  34308. var geoms$1 = arguments[0];
  34309. var lines$3 = arguments[1];
  34310. var forceToLineString$1 = arguments[2];
  34311. for (var i$1 = geoms$1.iterator(); i$1.hasNext(); ) {
  34312. var g$1 = i$1.next();
  34313. LinearComponentExtracter.getLines(g$1, lines$3, forceToLineString$1);
  34314. }
  34315. return lines$3;
  34316. } else if (typeof arguments[2] === "boolean" && (arguments[0] instanceof Geometry && hasInterface(arguments[1], Collection))) {
  34317. var geom$3 = arguments[0];
  34318. var lines$4 = arguments[1];
  34319. var forceToLineString$2 = arguments[2];
  34320. geom$3.apply(new LinearComponentExtracter(lines$4, forceToLineString$2));
  34321. return lines$4;
  34322. }
  34323. }
  34324. };
  34325. var PointLocator = function PointLocator2() {
  34326. this._boundaryRule = BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
  34327. this._isIn = null;
  34328. this._numBoundaries = null;
  34329. if (arguments.length === 0) {
  34330. } else if (arguments.length === 1) {
  34331. var boundaryRule = arguments[0];
  34332. if (boundaryRule === null) {
  34333. throw new IllegalArgumentException("Rule must be non-null");
  34334. }
  34335. this._boundaryRule = boundaryRule;
  34336. }
  34337. };
  34338. PointLocator.prototype.locateInternal = function locateInternal() {
  34339. var this$1 = this;
  34340. if (arguments[0] instanceof Coordinate && arguments[1] instanceof Polygon) {
  34341. var p = arguments[0];
  34342. var poly = arguments[1];
  34343. if (poly.isEmpty()) {
  34344. return Location.EXTERIOR;
  34345. }
  34346. var shell = poly.getExteriorRing();
  34347. var shellLoc = this.locateInPolygonRing(p, shell);
  34348. if (shellLoc === Location.EXTERIOR) {
  34349. return Location.EXTERIOR;
  34350. }
  34351. if (shellLoc === Location.BOUNDARY) {
  34352. return Location.BOUNDARY;
  34353. }
  34354. for (var i = 0; i < poly.getNumInteriorRing(); i++) {
  34355. var hole = poly.getInteriorRingN(i);
  34356. var holeLoc = this$1.locateInPolygonRing(p, hole);
  34357. if (holeLoc === Location.INTERIOR) {
  34358. return Location.EXTERIOR;
  34359. }
  34360. if (holeLoc === Location.BOUNDARY) {
  34361. return Location.BOUNDARY;
  34362. }
  34363. }
  34364. return Location.INTERIOR;
  34365. } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof LineString2) {
  34366. var p$1 = arguments[0];
  34367. var l = arguments[1];
  34368. if (!l.getEnvelopeInternal().intersects(p$1)) {
  34369. return Location.EXTERIOR;
  34370. }
  34371. var pt = l.getCoordinates();
  34372. if (!l.isClosed()) {
  34373. if (p$1.equals(pt[0]) || p$1.equals(pt[pt.length - 1])) {
  34374. return Location.BOUNDARY;
  34375. }
  34376. }
  34377. if (CGAlgorithms.isOnLine(p$1, pt)) {
  34378. return Location.INTERIOR;
  34379. }
  34380. return Location.EXTERIOR;
  34381. } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Point) {
  34382. var p$2 = arguments[0];
  34383. var pt$1 = arguments[1];
  34384. var ptCoord = pt$1.getCoordinate();
  34385. if (ptCoord.equals2D(p$2)) {
  34386. return Location.INTERIOR;
  34387. }
  34388. return Location.EXTERIOR;
  34389. }
  34390. };
  34391. PointLocator.prototype.locateInPolygonRing = function locateInPolygonRing(p, ring) {
  34392. if (!ring.getEnvelopeInternal().intersects(p)) {
  34393. return Location.EXTERIOR;
  34394. }
  34395. return CGAlgorithms.locatePointInRing(p, ring.getCoordinates());
  34396. };
  34397. PointLocator.prototype.intersects = function intersects5(p, geom) {
  34398. return this.locate(p, geom) !== Location.EXTERIOR;
  34399. };
  34400. PointLocator.prototype.updateLocationInfo = function updateLocationInfo(loc) {
  34401. if (loc === Location.INTERIOR) {
  34402. this._isIn = true;
  34403. }
  34404. if (loc === Location.BOUNDARY) {
  34405. this._numBoundaries++;
  34406. }
  34407. };
  34408. PointLocator.prototype.computeLocation = function computeLocation(p, geom) {
  34409. var this$1 = this;
  34410. if (geom instanceof Point) {
  34411. this.updateLocationInfo(this.locateInternal(p, geom));
  34412. }
  34413. if (geom instanceof LineString2) {
  34414. this.updateLocationInfo(this.locateInternal(p, geom));
  34415. } else if (geom instanceof Polygon) {
  34416. this.updateLocationInfo(this.locateInternal(p, geom));
  34417. } else if (geom instanceof MultiLineString) {
  34418. var ml = geom;
  34419. for (var i = 0; i < ml.getNumGeometries(); i++) {
  34420. var l = ml.getGeometryN(i);
  34421. this$1.updateLocationInfo(this$1.locateInternal(p, l));
  34422. }
  34423. } else if (geom instanceof MultiPolygon) {
  34424. var mpoly = geom;
  34425. for (var i$1 = 0; i$1 < mpoly.getNumGeometries(); i$1++) {
  34426. var poly = mpoly.getGeometryN(i$1);
  34427. this$1.updateLocationInfo(this$1.locateInternal(p, poly));
  34428. }
  34429. } else if (geom instanceof GeometryCollection) {
  34430. var geomi = new GeometryCollectionIterator(geom);
  34431. while (geomi.hasNext()) {
  34432. var g2 = geomi.next();
  34433. if (g2 !== geom) {
  34434. this$1.computeLocation(p, g2);
  34435. }
  34436. }
  34437. }
  34438. };
  34439. PointLocator.prototype.locate = function locate4(p, geom) {
  34440. if (geom.isEmpty()) {
  34441. return Location.EXTERIOR;
  34442. }
  34443. if (geom instanceof LineString2) {
  34444. return this.locateInternal(p, geom);
  34445. } else if (geom instanceof Polygon) {
  34446. return this.locateInternal(p, geom);
  34447. }
  34448. this._isIn = false;
  34449. this._numBoundaries = 0;
  34450. this.computeLocation(p, geom);
  34451. if (this._boundaryRule.isInBoundary(this._numBoundaries)) {
  34452. return Location.BOUNDARY;
  34453. }
  34454. if (this._numBoundaries > 0 || this._isIn) {
  34455. return Location.INTERIOR;
  34456. }
  34457. return Location.EXTERIOR;
  34458. };
  34459. PointLocator.prototype.interfaces_ = function interfaces_122() {
  34460. return [];
  34461. };
  34462. PointLocator.prototype.getClass = function getClass121() {
  34463. return PointLocator;
  34464. };
  34465. var GeometryLocation = function GeometryLocation2() {
  34466. this._component = null;
  34467. this._segIndex = null;
  34468. this._pt = null;
  34469. if (arguments.length === 2) {
  34470. var component = arguments[0];
  34471. var pt = arguments[1];
  34472. GeometryLocation2.call(this, component, GeometryLocation2.INSIDE_AREA, pt);
  34473. } else if (arguments.length === 3) {
  34474. var component$1 = arguments[0];
  34475. var segIndex = arguments[1];
  34476. var pt$1 = arguments[2];
  34477. this._component = component$1;
  34478. this._segIndex = segIndex;
  34479. this._pt = pt$1;
  34480. }
  34481. };
  34482. var staticAccessors$38 = { INSIDE_AREA: { configurable: true } };
  34483. GeometryLocation.prototype.isInsideArea = function isInsideArea() {
  34484. return this._segIndex === GeometryLocation.INSIDE_AREA;
  34485. };
  34486. GeometryLocation.prototype.getCoordinate = function getCoordinate15() {
  34487. return this._pt;
  34488. };
  34489. GeometryLocation.prototype.getGeometryComponent = function getGeometryComponent() {
  34490. return this._component;
  34491. };
  34492. GeometryLocation.prototype.getSegmentIndex = function getSegmentIndex2() {
  34493. return this._segIndex;
  34494. };
  34495. GeometryLocation.prototype.interfaces_ = function interfaces_123() {
  34496. return [];
  34497. };
  34498. GeometryLocation.prototype.getClass = function getClass122() {
  34499. return GeometryLocation;
  34500. };
  34501. staticAccessors$38.INSIDE_AREA.get = function() {
  34502. return -1;
  34503. };
  34504. Object.defineProperties(GeometryLocation, staticAccessors$38);
  34505. var PointExtracter = function PointExtracter2(pts) {
  34506. this._pts = pts || null;
  34507. };
  34508. PointExtracter.prototype.filter = function filter10(geom) {
  34509. if (geom instanceof Point) {
  34510. this._pts.add(geom);
  34511. }
  34512. };
  34513. PointExtracter.prototype.interfaces_ = function interfaces_124() {
  34514. return [GeometryFilter];
  34515. };
  34516. PointExtracter.prototype.getClass = function getClass123() {
  34517. return PointExtracter;
  34518. };
  34519. PointExtracter.getPoints = function getPoints() {
  34520. if (arguments.length === 1) {
  34521. var geom = arguments[0];
  34522. if (geom instanceof Point) {
  34523. return Collections.singletonList(geom);
  34524. }
  34525. return PointExtracter.getPoints(geom, new ArrayList());
  34526. } else if (arguments.length === 2) {
  34527. var geom$1 = arguments[0];
  34528. var list = arguments[1];
  34529. if (geom$1 instanceof Point) {
  34530. list.add(geom$1);
  34531. } else if (geom$1 instanceof GeometryCollection) {
  34532. geom$1.apply(new PointExtracter(list));
  34533. }
  34534. return list;
  34535. }
  34536. };
  34537. var ConnectedElementLocationFilter = function ConnectedElementLocationFilter2() {
  34538. this._locations = null;
  34539. var locations = arguments[0];
  34540. this._locations = locations;
  34541. };
  34542. ConnectedElementLocationFilter.prototype.filter = function filter11(geom) {
  34543. if (geom instanceof Point || geom instanceof LineString2 || geom instanceof Polygon) {
  34544. this._locations.add(new GeometryLocation(geom, 0, geom.getCoordinate()));
  34545. }
  34546. };
  34547. ConnectedElementLocationFilter.prototype.interfaces_ = function interfaces_125() {
  34548. return [GeometryFilter];
  34549. };
  34550. ConnectedElementLocationFilter.prototype.getClass = function getClass124() {
  34551. return ConnectedElementLocationFilter;
  34552. };
  34553. ConnectedElementLocationFilter.getLocations = function getLocations2(geom) {
  34554. var locations = new ArrayList();
  34555. geom.apply(new ConnectedElementLocationFilter(locations));
  34556. return locations;
  34557. };
  34558. var DistanceOp = function DistanceOp2() {
  34559. this._geom = null;
  34560. this._terminateDistance = 0;
  34561. this._ptLocator = new PointLocator();
  34562. this._minDistanceLocation = null;
  34563. this._minDistance = Double.MAX_VALUE;
  34564. if (arguments.length === 2) {
  34565. var g0 = arguments[0];
  34566. var g1 = arguments[1];
  34567. this._geom = [g0, g1];
  34568. this._terminateDistance = 0;
  34569. } else if (arguments.length === 3) {
  34570. var g0$1 = arguments[0];
  34571. var g1$1 = arguments[1];
  34572. var terminateDistance = arguments[2];
  34573. this._geom = new Array(2).fill(null);
  34574. this._geom[0] = g0$1;
  34575. this._geom[1] = g1$1;
  34576. this._terminateDistance = terminateDistance;
  34577. }
  34578. };
  34579. DistanceOp.prototype.computeContainmentDistance = function computeContainmentDistance() {
  34580. var this$1 = this;
  34581. if (arguments.length === 0) {
  34582. var locPtPoly = new Array(2).fill(null);
  34583. this.computeContainmentDistance(0, locPtPoly);
  34584. if (this._minDistance <= this._terminateDistance) {
  34585. return null;
  34586. }
  34587. this.computeContainmentDistance(1, locPtPoly);
  34588. } else if (arguments.length === 2) {
  34589. var polyGeomIndex = arguments[0];
  34590. var locPtPoly$1 = arguments[1];
  34591. var locationsIndex = 1 - polyGeomIndex;
  34592. var polys = PolygonExtracter.getPolygons(this._geom[polyGeomIndex]);
  34593. if (polys.size() > 0) {
  34594. var insideLocs = ConnectedElementLocationFilter.getLocations(this._geom[locationsIndex]);
  34595. this.computeContainmentDistance(insideLocs, polys, locPtPoly$1);
  34596. if (this._minDistance <= this._terminateDistance) {
  34597. this._minDistanceLocation[locationsIndex] = locPtPoly$1[0];
  34598. this._minDistanceLocation[polyGeomIndex] = locPtPoly$1[1];
  34599. return null;
  34600. }
  34601. }
  34602. } else if (arguments.length === 3) {
  34603. if (arguments[2] instanceof Array && (hasInterface(arguments[0], List) && hasInterface(arguments[1], List))) {
  34604. var locs = arguments[0];
  34605. var polys$1 = arguments[1];
  34606. var locPtPoly$2 = arguments[2];
  34607. for (var i = 0; i < locs.size(); i++) {
  34608. var loc = locs.get(i);
  34609. for (var j = 0; j < polys$1.size(); j++) {
  34610. this$1.computeContainmentDistance(loc, polys$1.get(j), locPtPoly$2);
  34611. if (this$1._minDistance <= this$1._terminateDistance) {
  34612. return null;
  34613. }
  34614. }
  34615. }
  34616. } else if (arguments[2] instanceof Array && (arguments[0] instanceof GeometryLocation && arguments[1] instanceof Polygon)) {
  34617. var ptLoc = arguments[0];
  34618. var poly = arguments[1];
  34619. var locPtPoly$3 = arguments[2];
  34620. var pt = ptLoc.getCoordinate();
  34621. if (Location.EXTERIOR !== this._ptLocator.locate(pt, poly)) {
  34622. this._minDistance = 0;
  34623. locPtPoly$3[0] = ptLoc;
  34624. locPtPoly$3[1] = new GeometryLocation(poly, pt);
  34625. return null;
  34626. }
  34627. }
  34628. }
  34629. };
  34630. DistanceOp.prototype.computeMinDistanceLinesPoints = function computeMinDistanceLinesPoints(lines, points2, locGeom) {
  34631. var this$1 = this;
  34632. for (var i = 0; i < lines.size(); i++) {
  34633. var line = lines.get(i);
  34634. for (var j = 0; j < points2.size(); j++) {
  34635. var pt = points2.get(j);
  34636. this$1.computeMinDistance(line, pt, locGeom);
  34637. if (this$1._minDistance <= this$1._terminateDistance) {
  34638. return null;
  34639. }
  34640. }
  34641. }
  34642. };
  34643. DistanceOp.prototype.computeFacetDistance = function computeFacetDistance() {
  34644. var locGeom = new Array(2).fill(null);
  34645. var lines0 = LinearComponentExtracter.getLines(this._geom[0]);
  34646. var lines1 = LinearComponentExtracter.getLines(this._geom[1]);
  34647. var pts0 = PointExtracter.getPoints(this._geom[0]);
  34648. var pts1 = PointExtracter.getPoints(this._geom[1]);
  34649. this.computeMinDistanceLines(lines0, lines1, locGeom);
  34650. this.updateMinDistance(locGeom, false);
  34651. if (this._minDistance <= this._terminateDistance) {
  34652. return null;
  34653. }
  34654. locGeom[0] = null;
  34655. locGeom[1] = null;
  34656. this.computeMinDistanceLinesPoints(lines0, pts1, locGeom);
  34657. this.updateMinDistance(locGeom, false);
  34658. if (this._minDistance <= this._terminateDistance) {
  34659. return null;
  34660. }
  34661. locGeom[0] = null;
  34662. locGeom[1] = null;
  34663. this.computeMinDistanceLinesPoints(lines1, pts0, locGeom);
  34664. this.updateMinDistance(locGeom, true);
  34665. if (this._minDistance <= this._terminateDistance) {
  34666. return null;
  34667. }
  34668. locGeom[0] = null;
  34669. locGeom[1] = null;
  34670. this.computeMinDistancePoints(pts0, pts1, locGeom);
  34671. this.updateMinDistance(locGeom, false);
  34672. };
  34673. DistanceOp.prototype.nearestLocations = function nearestLocations() {
  34674. this.computeMinDistance();
  34675. return this._minDistanceLocation;
  34676. };
  34677. DistanceOp.prototype.updateMinDistance = function updateMinDistance(locGeom, flip4) {
  34678. if (locGeom[0] === null) {
  34679. return null;
  34680. }
  34681. if (flip4) {
  34682. this._minDistanceLocation[0] = locGeom[1];
  34683. this._minDistanceLocation[1] = locGeom[0];
  34684. } else {
  34685. this._minDistanceLocation[0] = locGeom[0];
  34686. this._minDistanceLocation[1] = locGeom[1];
  34687. }
  34688. };
  34689. DistanceOp.prototype.nearestPoints = function nearestPoints() {
  34690. this.computeMinDistance();
  34691. var nearestPts = [this._minDistanceLocation[0].getCoordinate(), this._minDistanceLocation[1].getCoordinate()];
  34692. return nearestPts;
  34693. };
  34694. DistanceOp.prototype.computeMinDistance = function computeMinDistance() {
  34695. var this$1 = this;
  34696. if (arguments.length === 0) {
  34697. if (this._minDistanceLocation !== null) {
  34698. return null;
  34699. }
  34700. this._minDistanceLocation = new Array(2).fill(null);
  34701. this.computeContainmentDistance();
  34702. if (this._minDistance <= this._terminateDistance) {
  34703. return null;
  34704. }
  34705. this.computeFacetDistance();
  34706. } else if (arguments.length === 3) {
  34707. if (arguments[2] instanceof Array && (arguments[0] instanceof LineString2 && arguments[1] instanceof Point)) {
  34708. var line = arguments[0];
  34709. var pt = arguments[1];
  34710. var locGeom = arguments[2];
  34711. if (line.getEnvelopeInternal().distance(pt.getEnvelopeInternal()) > this._minDistance) {
  34712. return null;
  34713. }
  34714. var coord0 = line.getCoordinates();
  34715. var coord = pt.getCoordinate();
  34716. for (var i = 0; i < coord0.length - 1; i++) {
  34717. var dist = CGAlgorithms.distancePointLine(coord, coord0[i], coord0[i + 1]);
  34718. if (dist < this$1._minDistance) {
  34719. this$1._minDistance = dist;
  34720. var seg = new LineSegment(coord0[i], coord0[i + 1]);
  34721. var segClosestPoint = seg.closestPoint(coord);
  34722. locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
  34723. locGeom[1] = new GeometryLocation(pt, 0, coord);
  34724. }
  34725. if (this$1._minDistance <= this$1._terminateDistance) {
  34726. return null;
  34727. }
  34728. }
  34729. } else if (arguments[2] instanceof Array && (arguments[0] instanceof LineString2 && arguments[1] instanceof LineString2)) {
  34730. var line0 = arguments[0];
  34731. var line1 = arguments[1];
  34732. var locGeom$1 = arguments[2];
  34733. if (line0.getEnvelopeInternal().distance(line1.getEnvelopeInternal()) > this._minDistance) {
  34734. return null;
  34735. }
  34736. var coord0$1 = line0.getCoordinates();
  34737. var coord1 = line1.getCoordinates();
  34738. for (var i$1 = 0; i$1 < coord0$1.length - 1; i$1++) {
  34739. for (var j = 0; j < coord1.length - 1; j++) {
  34740. var dist$1 = CGAlgorithms.distanceLineLine(coord0$1[i$1], coord0$1[i$1 + 1], coord1[j], coord1[j + 1]);
  34741. if (dist$1 < this$1._minDistance) {
  34742. this$1._minDistance = dist$1;
  34743. var seg0 = new LineSegment(coord0$1[i$1], coord0$1[i$1 + 1]);
  34744. var seg1 = new LineSegment(coord1[j], coord1[j + 1]);
  34745. var closestPt = seg0.closestPoints(seg1);
  34746. locGeom$1[0] = new GeometryLocation(line0, i$1, closestPt[0]);
  34747. locGeom$1[1] = new GeometryLocation(line1, j, closestPt[1]);
  34748. }
  34749. if (this$1._minDistance <= this$1._terminateDistance) {
  34750. return null;
  34751. }
  34752. }
  34753. }
  34754. }
  34755. }
  34756. };
  34757. DistanceOp.prototype.computeMinDistancePoints = function computeMinDistancePoints(points0, points1, locGeom) {
  34758. var this$1 = this;
  34759. for (var i = 0; i < points0.size(); i++) {
  34760. var pt0 = points0.get(i);
  34761. for (var j = 0; j < points1.size(); j++) {
  34762. var pt1 = points1.get(j);
  34763. var dist = pt0.getCoordinate().distance(pt1.getCoordinate());
  34764. if (dist < this$1._minDistance) {
  34765. this$1._minDistance = dist;
  34766. locGeom[0] = new GeometryLocation(pt0, 0, pt0.getCoordinate());
  34767. locGeom[1] = new GeometryLocation(pt1, 0, pt1.getCoordinate());
  34768. }
  34769. if (this$1._minDistance <= this$1._terminateDistance) {
  34770. return null;
  34771. }
  34772. }
  34773. }
  34774. };
  34775. DistanceOp.prototype.distance = function distance7() {
  34776. if (this._geom[0] === null || this._geom[1] === null) {
  34777. throw new IllegalArgumentException("null geometries are not supported");
  34778. }
  34779. if (this._geom[0].isEmpty() || this._geom[1].isEmpty()) {
  34780. return 0;
  34781. }
  34782. this.computeMinDistance();
  34783. return this._minDistance;
  34784. };
  34785. DistanceOp.prototype.computeMinDistanceLines = function computeMinDistanceLines(lines0, lines1, locGeom) {
  34786. var this$1 = this;
  34787. for (var i = 0; i < lines0.size(); i++) {
  34788. var line0 = lines0.get(i);
  34789. for (var j = 0; j < lines1.size(); j++) {
  34790. var line1 = lines1.get(j);
  34791. this$1.computeMinDistance(line0, line1, locGeom);
  34792. if (this$1._minDistance <= this$1._terminateDistance) {
  34793. return null;
  34794. }
  34795. }
  34796. }
  34797. };
  34798. DistanceOp.prototype.interfaces_ = function interfaces_126() {
  34799. return [];
  34800. };
  34801. DistanceOp.prototype.getClass = function getClass125() {
  34802. return DistanceOp;
  34803. };
  34804. DistanceOp.distance = function distance8(g0, g1) {
  34805. var distOp = new DistanceOp(g0, g1);
  34806. return distOp.distance();
  34807. };
  34808. DistanceOp.isWithinDistance = function isWithinDistance(g0, g1, distance11) {
  34809. var distOp = new DistanceOp(g0, g1, distance11);
  34810. return distOp.distance() <= distance11;
  34811. };
  34812. DistanceOp.nearestPoints = function nearestPoints2(g0, g1) {
  34813. var distOp = new DistanceOp(g0, g1);
  34814. return distOp.nearestPoints();
  34815. };
  34816. var PointPairDistance$2 = function PointPairDistance3() {
  34817. this._pt = [new Coordinate(), new Coordinate()];
  34818. this._distance = Double.NaN;
  34819. this._isNull = true;
  34820. };
  34821. PointPairDistance$2.prototype.getCoordinates = function getCoordinates8() {
  34822. return this._pt;
  34823. };
  34824. PointPairDistance$2.prototype.getCoordinate = function getCoordinate16(i) {
  34825. return this._pt[i];
  34826. };
  34827. PointPairDistance$2.prototype.setMinimum = function setMinimum2() {
  34828. if (arguments.length === 1) {
  34829. var ptDist = arguments[0];
  34830. this.setMinimum(ptDist._pt[0], ptDist._pt[1]);
  34831. } else if (arguments.length === 2) {
  34832. var p0 = arguments[0];
  34833. var p1 = arguments[1];
  34834. if (this._isNull) {
  34835. this.initialize(p0, p1);
  34836. return null;
  34837. }
  34838. var dist = p0.distance(p1);
  34839. if (dist < this._distance) {
  34840. this.initialize(p0, p1, dist);
  34841. }
  34842. }
  34843. };
  34844. PointPairDistance$2.prototype.initialize = function initialize2() {
  34845. if (arguments.length === 0) {
  34846. this._isNull = true;
  34847. } else if (arguments.length === 2) {
  34848. var p0 = arguments[0];
  34849. var p1 = arguments[1];
  34850. this._pt[0].setCoordinate(p0);
  34851. this._pt[1].setCoordinate(p1);
  34852. this._distance = p0.distance(p1);
  34853. this._isNull = false;
  34854. } else if (arguments.length === 3) {
  34855. var p0$1 = arguments[0];
  34856. var p1$1 = arguments[1];
  34857. var distance11 = arguments[2];
  34858. this._pt[0].setCoordinate(p0$1);
  34859. this._pt[1].setCoordinate(p1$1);
  34860. this._distance = distance11;
  34861. this._isNull = false;
  34862. }
  34863. };
  34864. PointPairDistance$2.prototype.toString = function toString21() {
  34865. return WKTWriter.toLineString(this._pt[0], this._pt[1]);
  34866. };
  34867. PointPairDistance$2.prototype.getDistance = function getDistance4() {
  34868. return this._distance;
  34869. };
  34870. PointPairDistance$2.prototype.setMaximum = function setMaximum2() {
  34871. if (arguments.length === 1) {
  34872. var ptDist = arguments[0];
  34873. this.setMaximum(ptDist._pt[0], ptDist._pt[1]);
  34874. } else if (arguments.length === 2) {
  34875. var p0 = arguments[0];
  34876. var p1 = arguments[1];
  34877. if (this._isNull) {
  34878. this.initialize(p0, p1);
  34879. return null;
  34880. }
  34881. var dist = p0.distance(p1);
  34882. if (dist > this._distance) {
  34883. this.initialize(p0, p1, dist);
  34884. }
  34885. }
  34886. };
  34887. PointPairDistance$2.prototype.interfaces_ = function interfaces_127() {
  34888. return [];
  34889. };
  34890. PointPairDistance$2.prototype.getClass = function getClass126() {
  34891. return PointPairDistance$2;
  34892. };
  34893. var DistanceToPoint = function DistanceToPoint2() {
  34894. };
  34895. DistanceToPoint.prototype.interfaces_ = function interfaces_128() {
  34896. return [];
  34897. };
  34898. DistanceToPoint.prototype.getClass = function getClass127() {
  34899. return DistanceToPoint;
  34900. };
  34901. DistanceToPoint.computeDistance = function computeDistance2() {
  34902. if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof LineString2 && arguments[1] instanceof Coordinate)) {
  34903. var line = arguments[0];
  34904. var pt = arguments[1];
  34905. var ptDist = arguments[2];
  34906. var tempSegment = new LineSegment();
  34907. var coords = line.getCoordinates();
  34908. for (var i = 0; i < coords.length - 1; i++) {
  34909. tempSegment.setCoordinates(coords[i], coords[i + 1]);
  34910. var closestPt = tempSegment.closestPoint(pt);
  34911. ptDist.setMinimum(closestPt, pt);
  34912. }
  34913. } else if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof Polygon && arguments[1] instanceof Coordinate)) {
  34914. var poly = arguments[0];
  34915. var pt$1 = arguments[1];
  34916. var ptDist$1 = arguments[2];
  34917. DistanceToPoint.computeDistance(poly.getExteriorRing(), pt$1, ptDist$1);
  34918. for (var i$1 = 0; i$1 < poly.getNumInteriorRing(); i$1++) {
  34919. DistanceToPoint.computeDistance(poly.getInteriorRingN(i$1), pt$1, ptDist$1);
  34920. }
  34921. } else if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof Geometry && arguments[1] instanceof Coordinate)) {
  34922. var geom = arguments[0];
  34923. var pt$2 = arguments[1];
  34924. var ptDist$2 = arguments[2];
  34925. if (geom instanceof LineString2) {
  34926. DistanceToPoint.computeDistance(geom, pt$2, ptDist$2);
  34927. } else if (geom instanceof Polygon) {
  34928. DistanceToPoint.computeDistance(geom, pt$2, ptDist$2);
  34929. } else if (geom instanceof GeometryCollection) {
  34930. var gc = geom;
  34931. for (var i$2 = 0; i$2 < gc.getNumGeometries(); i$2++) {
  34932. var g = gc.getGeometryN(i$2);
  34933. DistanceToPoint.computeDistance(g, pt$2, ptDist$2);
  34934. }
  34935. } else {
  34936. ptDist$2.setMinimum(geom.getCoordinate(), pt$2);
  34937. }
  34938. } else if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof LineSegment && arguments[1] instanceof Coordinate)) {
  34939. var segment = arguments[0];
  34940. var pt$3 = arguments[1];
  34941. var ptDist$3 = arguments[2];
  34942. var closestPt$1 = segment.closestPoint(pt$3);
  34943. ptDist$3.setMinimum(closestPt$1, pt$3);
  34944. }
  34945. };
  34946. var DiscreteHausdorffDistance = function DiscreteHausdorffDistance2() {
  34947. this._g0 = null;
  34948. this._g1 = null;
  34949. this._ptDist = new PointPairDistance$2();
  34950. this._densifyFrac = 0;
  34951. var g0 = arguments[0];
  34952. var g1 = arguments[1];
  34953. this._g0 = g0;
  34954. this._g1 = g1;
  34955. };
  34956. var staticAccessors$39 = { MaxPointDistanceFilter: { configurable: true }, MaxDensifiedByFractionDistanceFilter: { configurable: true } };
  34957. DiscreteHausdorffDistance.prototype.getCoordinates = function getCoordinates9() {
  34958. return this._ptDist.getCoordinates();
  34959. };
  34960. DiscreteHausdorffDistance.prototype.setDensifyFraction = function setDensifyFraction(densifyFrac) {
  34961. if (densifyFrac > 1 || densifyFrac <= 0) {
  34962. throw new IllegalArgumentException("Fraction is not in range (0.0 - 1.0]");
  34963. }
  34964. this._densifyFrac = densifyFrac;
  34965. };
  34966. DiscreteHausdorffDistance.prototype.compute = function compute(g0, g1) {
  34967. this.computeOrientedDistance(g0, g1, this._ptDist);
  34968. this.computeOrientedDistance(g1, g0, this._ptDist);
  34969. };
  34970. DiscreteHausdorffDistance.prototype.distance = function distance9() {
  34971. this.compute(this._g0, this._g1);
  34972. return this._ptDist.getDistance();
  34973. };
  34974. DiscreteHausdorffDistance.prototype.computeOrientedDistance = function computeOrientedDistance(discreteGeom, geom, ptDist) {
  34975. var distFilter = new MaxPointDistanceFilter$1(geom);
  34976. discreteGeom.apply(distFilter);
  34977. ptDist.setMaximum(distFilter.getMaxPointDistance());
  34978. if (this._densifyFrac > 0) {
  34979. var fracFilter = new MaxDensifiedByFractionDistanceFilter(geom, this._densifyFrac);
  34980. discreteGeom.apply(fracFilter);
  34981. ptDist.setMaximum(fracFilter.getMaxPointDistance());
  34982. }
  34983. };
  34984. DiscreteHausdorffDistance.prototype.orientedDistance = function orientedDistance() {
  34985. this.computeOrientedDistance(this._g0, this._g1, this._ptDist);
  34986. return this._ptDist.getDistance();
  34987. };
  34988. DiscreteHausdorffDistance.prototype.interfaces_ = function interfaces_129() {
  34989. return [];
  34990. };
  34991. DiscreteHausdorffDistance.prototype.getClass = function getClass128() {
  34992. return DiscreteHausdorffDistance;
  34993. };
  34994. DiscreteHausdorffDistance.distance = function distance10() {
  34995. if (arguments.length === 2) {
  34996. var g0 = arguments[0];
  34997. var g1 = arguments[1];
  34998. var dist = new DiscreteHausdorffDistance(g0, g1);
  34999. return dist.distance();
  35000. } else if (arguments.length === 3) {
  35001. var g0$1 = arguments[0];
  35002. var g1$1 = arguments[1];
  35003. var densifyFrac = arguments[2];
  35004. var dist$1 = new DiscreteHausdorffDistance(g0$1, g1$1);
  35005. dist$1.setDensifyFraction(densifyFrac);
  35006. return dist$1.distance();
  35007. }
  35008. };
  35009. staticAccessors$39.MaxPointDistanceFilter.get = function() {
  35010. return MaxPointDistanceFilter$1;
  35011. };
  35012. staticAccessors$39.MaxDensifiedByFractionDistanceFilter.get = function() {
  35013. return MaxDensifiedByFractionDistanceFilter;
  35014. };
  35015. Object.defineProperties(DiscreteHausdorffDistance, staticAccessors$39);
  35016. var MaxPointDistanceFilter$1 = function MaxPointDistanceFilter3() {
  35017. this._maxPtDist = new PointPairDistance$2();
  35018. this._minPtDist = new PointPairDistance$2();
  35019. this._euclideanDist = new DistanceToPoint();
  35020. this._geom = null;
  35021. var geom = arguments[0];
  35022. this._geom = geom;
  35023. };
  35024. MaxPointDistanceFilter$1.prototype.filter = function filter12(pt) {
  35025. this._minPtDist.initialize();
  35026. DistanceToPoint.computeDistance(this._geom, pt, this._minPtDist);
  35027. this._maxPtDist.setMaximum(this._minPtDist);
  35028. };
  35029. MaxPointDistanceFilter$1.prototype.getMaxPointDistance = function getMaxPointDistance3() {
  35030. return this._maxPtDist;
  35031. };
  35032. MaxPointDistanceFilter$1.prototype.interfaces_ = function interfaces_130() {
  35033. return [CoordinateFilter];
  35034. };
  35035. MaxPointDistanceFilter$1.prototype.getClass = function getClass129() {
  35036. return MaxPointDistanceFilter$1;
  35037. };
  35038. var MaxDensifiedByFractionDistanceFilter = function MaxDensifiedByFractionDistanceFilter2() {
  35039. this._maxPtDist = new PointPairDistance$2();
  35040. this._minPtDist = new PointPairDistance$2();
  35041. this._geom = null;
  35042. this._numSubSegs = 0;
  35043. var geom = arguments[0];
  35044. var fraction = arguments[1];
  35045. this._geom = geom;
  35046. this._numSubSegs = Math.trunc(Math.round(1 / fraction));
  35047. };
  35048. MaxDensifiedByFractionDistanceFilter.prototype.filter = function filter13(seq, index2) {
  35049. var this$1 = this;
  35050. if (index2 === 0) {
  35051. return null;
  35052. }
  35053. var p0 = seq.getCoordinate(index2 - 1);
  35054. var p1 = seq.getCoordinate(index2);
  35055. var delx = (p1.x - p0.x) / this._numSubSegs;
  35056. var dely = (p1.y - p0.y) / this._numSubSegs;
  35057. for (var i = 0; i < this._numSubSegs; i++) {
  35058. var x2 = p0.x + i * delx;
  35059. var y2 = p0.y + i * dely;
  35060. var pt = new Coordinate(x2, y2);
  35061. this$1._minPtDist.initialize();
  35062. DistanceToPoint.computeDistance(this$1._geom, pt, this$1._minPtDist);
  35063. this$1._maxPtDist.setMaximum(this$1._minPtDist);
  35064. }
  35065. };
  35066. MaxDensifiedByFractionDistanceFilter.prototype.isDone = function isDone6() {
  35067. return false;
  35068. };
  35069. MaxDensifiedByFractionDistanceFilter.prototype.isGeometryChanged = function isGeometryChanged3() {
  35070. return false;
  35071. };
  35072. MaxDensifiedByFractionDistanceFilter.prototype.getMaxPointDistance = function getMaxPointDistance4() {
  35073. return this._maxPtDist;
  35074. };
  35075. MaxDensifiedByFractionDistanceFilter.prototype.interfaces_ = function interfaces_131() {
  35076. return [CoordinateSequenceFilter];
  35077. };
  35078. MaxDensifiedByFractionDistanceFilter.prototype.getClass = function getClass130() {
  35079. return MaxDensifiedByFractionDistanceFilter;
  35080. };
  35081. var BufferDistanceValidator = function BufferDistanceValidator2(input, bufDistance, result) {
  35082. this._minValidDistance = null;
  35083. this._maxValidDistance = null;
  35084. this._minDistanceFound = null;
  35085. this._maxDistanceFound = null;
  35086. this._isValid = true;
  35087. this._errMsg = null;
  35088. this._errorLocation = null;
  35089. this._errorIndicator = null;
  35090. this._input = input || null;
  35091. this._bufDistance = bufDistance || null;
  35092. this._result = result || null;
  35093. };
  35094. var staticAccessors$37 = { VERBOSE: { configurable: true }, MAX_DISTANCE_DIFF_FRAC: { configurable: true } };
  35095. BufferDistanceValidator.prototype.checkMaximumDistance = function checkMaximumDistance(input, bufCurve, maxDist) {
  35096. var haus = new DiscreteHausdorffDistance(bufCurve, input);
  35097. haus.setDensifyFraction(0.25);
  35098. this._maxDistanceFound = haus.orientedDistance();
  35099. if (this._maxDistanceFound > maxDist) {
  35100. this._isValid = false;
  35101. var pts = haus.getCoordinates();
  35102. this._errorLocation = pts[1];
  35103. this._errorIndicator = input.getFactory().createLineString(pts);
  35104. this._errMsg = "Distance between buffer curve and input is too large (" + this._maxDistanceFound + " at " + WKTWriter.toLineString(pts[0], pts[1]) + ")";
  35105. }
  35106. };
  35107. BufferDistanceValidator.prototype.isValid = function isValid() {
  35108. var posDistance = Math.abs(this._bufDistance);
  35109. var distDelta = BufferDistanceValidator.MAX_DISTANCE_DIFF_FRAC * posDistance;
  35110. this._minValidDistance = posDistance - distDelta;
  35111. this._maxValidDistance = posDistance + distDelta;
  35112. if (this._input.isEmpty() || this._result.isEmpty()) {
  35113. return true;
  35114. }
  35115. if (this._bufDistance > 0) {
  35116. this.checkPositiveValid();
  35117. } else {
  35118. this.checkNegativeValid();
  35119. }
  35120. if (BufferDistanceValidator.VERBOSE) {
  35121. System.out.println("Min Dist= " + this._minDistanceFound + " err= " + (1 - this._minDistanceFound / this._bufDistance) + " Max Dist= " + this._maxDistanceFound + " err= " + (this._maxDistanceFound / this._bufDistance - 1));
  35122. }
  35123. return this._isValid;
  35124. };
  35125. BufferDistanceValidator.prototype.checkNegativeValid = function checkNegativeValid() {
  35126. if (!(this._input instanceof Polygon || this._input instanceof MultiPolygon || this._input instanceof GeometryCollection)) {
  35127. return null;
  35128. }
  35129. var inputCurve = this.getPolygonLines(this._input);
  35130. this.checkMinimumDistance(inputCurve, this._result, this._minValidDistance);
  35131. if (!this._isValid) {
  35132. return null;
  35133. }
  35134. this.checkMaximumDistance(inputCurve, this._result, this._maxValidDistance);
  35135. };
  35136. BufferDistanceValidator.prototype.getErrorIndicator = function getErrorIndicator() {
  35137. return this._errorIndicator;
  35138. };
  35139. BufferDistanceValidator.prototype.checkMinimumDistance = function checkMinimumDistance(g1, g2, minDist) {
  35140. var distOp = new DistanceOp(g1, g2, minDist);
  35141. this._minDistanceFound = distOp.distance();
  35142. if (this._minDistanceFound < minDist) {
  35143. this._isValid = false;
  35144. var pts = distOp.nearestPoints();
  35145. this._errorLocation = distOp.nearestPoints()[1];
  35146. this._errorIndicator = g1.getFactory().createLineString(pts);
  35147. this._errMsg = "Distance between buffer curve and input is too small (" + this._minDistanceFound + " at " + WKTWriter.toLineString(pts[0], pts[1]) + " )";
  35148. }
  35149. };
  35150. BufferDistanceValidator.prototype.checkPositiveValid = function checkPositiveValid() {
  35151. var bufCurve = this._result.getBoundary();
  35152. this.checkMinimumDistance(this._input, bufCurve, this._minValidDistance);
  35153. if (!this._isValid) {
  35154. return null;
  35155. }
  35156. this.checkMaximumDistance(this._input, bufCurve, this._maxValidDistance);
  35157. };
  35158. BufferDistanceValidator.prototype.getErrorLocation = function getErrorLocation() {
  35159. return this._errorLocation;
  35160. };
  35161. BufferDistanceValidator.prototype.getPolygonLines = function getPolygonLines(g) {
  35162. var lines = new ArrayList();
  35163. var lineExtracter = new LinearComponentExtracter(lines);
  35164. var polys = PolygonExtracter.getPolygons(g);
  35165. for (var i = polys.iterator(); i.hasNext(); ) {
  35166. var poly = i.next();
  35167. poly.apply(lineExtracter);
  35168. }
  35169. return g.getFactory().buildGeometry(lines);
  35170. };
  35171. BufferDistanceValidator.prototype.getErrorMessage = function getErrorMessage() {
  35172. return this._errMsg;
  35173. };
  35174. BufferDistanceValidator.prototype.interfaces_ = function interfaces_132() {
  35175. return [];
  35176. };
  35177. BufferDistanceValidator.prototype.getClass = function getClass131() {
  35178. return BufferDistanceValidator;
  35179. };
  35180. staticAccessors$37.VERBOSE.get = function() {
  35181. return false;
  35182. };
  35183. staticAccessors$37.MAX_DISTANCE_DIFF_FRAC.get = function() {
  35184. return 0.012;
  35185. };
  35186. Object.defineProperties(BufferDistanceValidator, staticAccessors$37);
  35187. var BufferResultValidator = function BufferResultValidator2(input, distance11, result) {
  35188. this._isValid = true;
  35189. this._errorMsg = null;
  35190. this._errorLocation = null;
  35191. this._errorIndicator = null;
  35192. this._input = input || null;
  35193. this._distance = distance11 || null;
  35194. this._result = result || null;
  35195. };
  35196. var staticAccessors$40 = { VERBOSE: { configurable: true }, MAX_ENV_DIFF_FRAC: { configurable: true } };
  35197. BufferResultValidator.prototype.isValid = function isValid2() {
  35198. this.checkPolygonal();
  35199. if (!this._isValid) {
  35200. return this._isValid;
  35201. }
  35202. this.checkExpectedEmpty();
  35203. if (!this._isValid) {
  35204. return this._isValid;
  35205. }
  35206. this.checkEnvelope();
  35207. if (!this._isValid) {
  35208. return this._isValid;
  35209. }
  35210. this.checkArea();
  35211. if (!this._isValid) {
  35212. return this._isValid;
  35213. }
  35214. this.checkDistance();
  35215. return this._isValid;
  35216. };
  35217. BufferResultValidator.prototype.checkEnvelope = function checkEnvelope() {
  35218. if (this._distance < 0) {
  35219. return null;
  35220. }
  35221. var padding = this._distance * BufferResultValidator.MAX_ENV_DIFF_FRAC;
  35222. if (padding === 0) {
  35223. padding = 1e-3;
  35224. }
  35225. var expectedEnv = new Envelope(this._input.getEnvelopeInternal());
  35226. expectedEnv.expandBy(this._distance);
  35227. var bufEnv = new Envelope(this._result.getEnvelopeInternal());
  35228. bufEnv.expandBy(padding);
  35229. if (!bufEnv.contains(expectedEnv)) {
  35230. this._isValid = false;
  35231. this._errorMsg = "Buffer envelope is incorrect";
  35232. this._errorIndicator = this._input.getFactory().toGeometry(bufEnv);
  35233. }
  35234. this.report("Envelope");
  35235. };
  35236. BufferResultValidator.prototype.checkDistance = function checkDistance() {
  35237. var distValid = new BufferDistanceValidator(this._input, this._distance, this._result);
  35238. if (!distValid.isValid()) {
  35239. this._isValid = false;
  35240. this._errorMsg = distValid.getErrorMessage();
  35241. this._errorLocation = distValid.getErrorLocation();
  35242. this._errorIndicator = distValid.getErrorIndicator();
  35243. }
  35244. this.report("Distance");
  35245. };
  35246. BufferResultValidator.prototype.checkArea = function checkArea() {
  35247. var inputArea = this._input.getArea();
  35248. var resultArea = this._result.getArea();
  35249. if (this._distance > 0 && inputArea > resultArea) {
  35250. this._isValid = false;
  35251. this._errorMsg = "Area of positive buffer is smaller than input";
  35252. this._errorIndicator = this._result;
  35253. }
  35254. if (this._distance < 0 && inputArea < resultArea) {
  35255. this._isValid = false;
  35256. this._errorMsg = "Area of negative buffer is larger than input";
  35257. this._errorIndicator = this._result;
  35258. }
  35259. this.report("Area");
  35260. };
  35261. BufferResultValidator.prototype.checkPolygonal = function checkPolygonal() {
  35262. if (!(this._result instanceof Polygon || this._result instanceof MultiPolygon)) {
  35263. this._isValid = false;
  35264. }
  35265. this._errorMsg = "Result is not polygonal";
  35266. this._errorIndicator = this._result;
  35267. this.report("Polygonal");
  35268. };
  35269. BufferResultValidator.prototype.getErrorIndicator = function getErrorIndicator2() {
  35270. return this._errorIndicator;
  35271. };
  35272. BufferResultValidator.prototype.getErrorLocation = function getErrorLocation2() {
  35273. return this._errorLocation;
  35274. };
  35275. BufferResultValidator.prototype.checkExpectedEmpty = function checkExpectedEmpty() {
  35276. if (this._input.getDimension() >= 2) {
  35277. return null;
  35278. }
  35279. if (this._distance > 0) {
  35280. return null;
  35281. }
  35282. if (!this._result.isEmpty()) {
  35283. this._isValid = false;
  35284. this._errorMsg = "Result is non-empty";
  35285. this._errorIndicator = this._result;
  35286. }
  35287. this.report("ExpectedEmpty");
  35288. };
  35289. BufferResultValidator.prototype.report = function report(checkName) {
  35290. if (!BufferResultValidator.VERBOSE) {
  35291. return null;
  35292. }
  35293. System.out.println("Check " + checkName + ": " + (this._isValid ? "passed" : "FAILED"));
  35294. };
  35295. BufferResultValidator.prototype.getErrorMessage = function getErrorMessage2() {
  35296. return this._errorMsg;
  35297. };
  35298. BufferResultValidator.prototype.interfaces_ = function interfaces_133() {
  35299. return [];
  35300. };
  35301. BufferResultValidator.prototype.getClass = function getClass132() {
  35302. return BufferResultValidator;
  35303. };
  35304. BufferResultValidator.isValidMsg = function isValidMsg(g, distance11, result) {
  35305. var validator = new BufferResultValidator(g, distance11, result);
  35306. if (!validator.isValid()) {
  35307. return validator.getErrorMessage();
  35308. }
  35309. return null;
  35310. };
  35311. BufferResultValidator.isValid = function isValid3(g, distance11, result) {
  35312. var validator = new BufferResultValidator(g, distance11, result);
  35313. if (validator.isValid()) {
  35314. return true;
  35315. }
  35316. return false;
  35317. };
  35318. staticAccessors$40.VERBOSE.get = function() {
  35319. return false;
  35320. };
  35321. staticAccessors$40.MAX_ENV_DIFF_FRAC.get = function() {
  35322. return 0.012;
  35323. };
  35324. Object.defineProperties(BufferResultValidator, staticAccessors$40);
  35325. var BasicSegmentString = function BasicSegmentString2() {
  35326. this._pts = null;
  35327. this._data = null;
  35328. var pts = arguments[0];
  35329. var data = arguments[1];
  35330. this._pts = pts;
  35331. this._data = data;
  35332. };
  35333. BasicSegmentString.prototype.getCoordinates = function getCoordinates10() {
  35334. return this._pts;
  35335. };
  35336. BasicSegmentString.prototype.size = function size10() {
  35337. return this._pts.length;
  35338. };
  35339. BasicSegmentString.prototype.getCoordinate = function getCoordinate17(i) {
  35340. return this._pts[i];
  35341. };
  35342. BasicSegmentString.prototype.isClosed = function isClosed3() {
  35343. return this._pts[0].equals(this._pts[this._pts.length - 1]);
  35344. };
  35345. BasicSegmentString.prototype.getSegmentOctant = function getSegmentOctant2(index2) {
  35346. if (index2 === this._pts.length - 1) {
  35347. return -1;
  35348. }
  35349. return Octant.octant(this.getCoordinate(index2), this.getCoordinate(index2 + 1));
  35350. };
  35351. BasicSegmentString.prototype.setData = function setData3(data) {
  35352. this._data = data;
  35353. };
  35354. BasicSegmentString.prototype.getData = function getData3() {
  35355. return this._data;
  35356. };
  35357. BasicSegmentString.prototype.toString = function toString22() {
  35358. return WKTWriter.toLineString(new CoordinateArraySequence(this._pts));
  35359. };
  35360. BasicSegmentString.prototype.interfaces_ = function interfaces_134() {
  35361. return [SegmentString];
  35362. };
  35363. BasicSegmentString.prototype.getClass = function getClass133() {
  35364. return BasicSegmentString;
  35365. };
  35366. var InteriorIntersectionFinder = function InteriorIntersectionFinder2() {
  35367. this._findAllIntersections = false;
  35368. this._isCheckEndSegmentsOnly = false;
  35369. this._li = null;
  35370. this._interiorIntersection = null;
  35371. this._intSegments = null;
  35372. this._intersections = new ArrayList();
  35373. this._intersectionCount = 0;
  35374. this._keepIntersections = true;
  35375. var li = arguments[0];
  35376. this._li = li;
  35377. this._interiorIntersection = null;
  35378. };
  35379. InteriorIntersectionFinder.prototype.getInteriorIntersection = function getInteriorIntersection() {
  35380. return this._interiorIntersection;
  35381. };
  35382. InteriorIntersectionFinder.prototype.setCheckEndSegmentsOnly = function setCheckEndSegmentsOnly(isCheckEndSegmentsOnly) {
  35383. this._isCheckEndSegmentsOnly = isCheckEndSegmentsOnly;
  35384. };
  35385. InteriorIntersectionFinder.prototype.getIntersectionSegments = function getIntersectionSegments() {
  35386. return this._intSegments;
  35387. };
  35388. InteriorIntersectionFinder.prototype.count = function count() {
  35389. return this._intersectionCount;
  35390. };
  35391. InteriorIntersectionFinder.prototype.getIntersections = function getIntersections() {
  35392. return this._intersections;
  35393. };
  35394. InteriorIntersectionFinder.prototype.setFindAllIntersections = function setFindAllIntersections(findAllIntersections) {
  35395. this._findAllIntersections = findAllIntersections;
  35396. };
  35397. InteriorIntersectionFinder.prototype.setKeepIntersections = function setKeepIntersections(keepIntersections) {
  35398. this._keepIntersections = keepIntersections;
  35399. };
  35400. InteriorIntersectionFinder.prototype.processIntersections = function processIntersections4(e0, segIndex0, e1, segIndex1) {
  35401. if (!this._findAllIntersections && this.hasIntersection()) {
  35402. return null;
  35403. }
  35404. if (e0 === e1 && segIndex0 === segIndex1) {
  35405. return null;
  35406. }
  35407. if (this._isCheckEndSegmentsOnly) {
  35408. var isEndSegPresent = this.isEndSegment(e0, segIndex0) || this.isEndSegment(e1, segIndex1);
  35409. if (!isEndSegPresent) {
  35410. return null;
  35411. }
  35412. }
  35413. var p002 = e0.getCoordinates()[segIndex0];
  35414. var p012 = e0.getCoordinates()[segIndex0 + 1];
  35415. var p102 = e1.getCoordinates()[segIndex1];
  35416. var p112 = e1.getCoordinates()[segIndex1 + 1];
  35417. this._li.computeIntersection(p002, p012, p102, p112);
  35418. if (this._li.hasIntersection()) {
  35419. if (this._li.isInteriorIntersection()) {
  35420. this._intSegments = new Array(4).fill(null);
  35421. this._intSegments[0] = p002;
  35422. this._intSegments[1] = p012;
  35423. this._intSegments[2] = p102;
  35424. this._intSegments[3] = p112;
  35425. this._interiorIntersection = this._li.getIntersection(0);
  35426. if (this._keepIntersections) {
  35427. this._intersections.add(this._interiorIntersection);
  35428. }
  35429. this._intersectionCount++;
  35430. }
  35431. }
  35432. };
  35433. InteriorIntersectionFinder.prototype.isEndSegment = function isEndSegment(segStr, index2) {
  35434. if (index2 === 0) {
  35435. return true;
  35436. }
  35437. if (index2 >= segStr.size() - 2) {
  35438. return true;
  35439. }
  35440. return false;
  35441. };
  35442. InteriorIntersectionFinder.prototype.hasIntersection = function hasIntersection3() {
  35443. return this._interiorIntersection !== null;
  35444. };
  35445. InteriorIntersectionFinder.prototype.isDone = function isDone7() {
  35446. if (this._findAllIntersections) {
  35447. return false;
  35448. }
  35449. return this._interiorIntersection !== null;
  35450. };
  35451. InteriorIntersectionFinder.prototype.interfaces_ = function interfaces_135() {
  35452. return [SegmentIntersector];
  35453. };
  35454. InteriorIntersectionFinder.prototype.getClass = function getClass134() {
  35455. return InteriorIntersectionFinder;
  35456. };
  35457. InteriorIntersectionFinder.createAllIntersectionsFinder = function createAllIntersectionsFinder(li) {
  35458. var finder = new InteriorIntersectionFinder(li);
  35459. finder.setFindAllIntersections(true);
  35460. return finder;
  35461. };
  35462. InteriorIntersectionFinder.createAnyIntersectionFinder = function createAnyIntersectionFinder(li) {
  35463. return new InteriorIntersectionFinder(li);
  35464. };
  35465. InteriorIntersectionFinder.createIntersectionCounter = function createIntersectionCounter(li) {
  35466. var finder = new InteriorIntersectionFinder(li);
  35467. finder.setFindAllIntersections(true);
  35468. finder.setKeepIntersections(false);
  35469. return finder;
  35470. };
  35471. var FastNodingValidator = function FastNodingValidator2() {
  35472. this._li = new RobustLineIntersector();
  35473. this._segStrings = null;
  35474. this._findAllIntersections = false;
  35475. this._segInt = null;
  35476. this._isValid = true;
  35477. var segStrings = arguments[0];
  35478. this._segStrings = segStrings;
  35479. };
  35480. FastNodingValidator.prototype.execute = function execute() {
  35481. if (this._segInt !== null) {
  35482. return null;
  35483. }
  35484. this.checkInteriorIntersections();
  35485. };
  35486. FastNodingValidator.prototype.getIntersections = function getIntersections2() {
  35487. return this._segInt.getIntersections();
  35488. };
  35489. FastNodingValidator.prototype.isValid = function isValid4() {
  35490. this.execute();
  35491. return this._isValid;
  35492. };
  35493. FastNodingValidator.prototype.setFindAllIntersections = function setFindAllIntersections2(findAllIntersections) {
  35494. this._findAllIntersections = findAllIntersections;
  35495. };
  35496. FastNodingValidator.prototype.checkInteriorIntersections = function checkInteriorIntersections2() {
  35497. this._isValid = true;
  35498. this._segInt = new InteriorIntersectionFinder(this._li);
  35499. this._segInt.setFindAllIntersections(this._findAllIntersections);
  35500. var noder = new MCIndexNoder();
  35501. noder.setSegmentIntersector(this._segInt);
  35502. noder.computeNodes(this._segStrings);
  35503. if (this._segInt.hasIntersection()) {
  35504. this._isValid = false;
  35505. return null;
  35506. }
  35507. };
  35508. FastNodingValidator.prototype.checkValid = function checkValid2() {
  35509. this.execute();
  35510. if (!this._isValid) {
  35511. throw new TopologyException(this.getErrorMessage(), this._segInt.getInteriorIntersection());
  35512. }
  35513. };
  35514. FastNodingValidator.prototype.getErrorMessage = function getErrorMessage3() {
  35515. if (this._isValid) {
  35516. return "no intersections found";
  35517. }
  35518. var intSegs = this._segInt.getIntersectionSegments();
  35519. return "found non-noded intersection between " + WKTWriter.toLineString(intSegs[0], intSegs[1]) + " and " + WKTWriter.toLineString(intSegs[2], intSegs[3]);
  35520. };
  35521. FastNodingValidator.prototype.interfaces_ = function interfaces_136() {
  35522. return [];
  35523. };
  35524. FastNodingValidator.prototype.getClass = function getClass135() {
  35525. return FastNodingValidator;
  35526. };
  35527. FastNodingValidator.computeIntersections = function computeIntersections(segStrings) {
  35528. var nv = new FastNodingValidator(segStrings);
  35529. nv.setFindAllIntersections(true);
  35530. nv.isValid();
  35531. return nv.getIntersections();
  35532. };
  35533. var EdgeNodingValidator = function EdgeNodingValidator2() {
  35534. this._nv = null;
  35535. var edges2 = arguments[0];
  35536. this._nv = new FastNodingValidator(EdgeNodingValidator2.toSegmentStrings(edges2));
  35537. };
  35538. EdgeNodingValidator.prototype.checkValid = function checkValid3() {
  35539. this._nv.checkValid();
  35540. };
  35541. EdgeNodingValidator.prototype.interfaces_ = function interfaces_137() {
  35542. return [];
  35543. };
  35544. EdgeNodingValidator.prototype.getClass = function getClass136() {
  35545. return EdgeNodingValidator;
  35546. };
  35547. EdgeNodingValidator.toSegmentStrings = function toSegmentStrings(edges2) {
  35548. var segStrings = new ArrayList();
  35549. for (var i = edges2.iterator(); i.hasNext(); ) {
  35550. var e = i.next();
  35551. segStrings.add(new BasicSegmentString(e.getCoordinates(), e));
  35552. }
  35553. return segStrings;
  35554. };
  35555. EdgeNodingValidator.checkValid = function checkValid4(edges2) {
  35556. var validator = new EdgeNodingValidator(edges2);
  35557. validator.checkValid();
  35558. };
  35559. var GeometryCollectionMapper = function GeometryCollectionMapper2(mapOp) {
  35560. this._mapOp = mapOp;
  35561. };
  35562. GeometryCollectionMapper.prototype.map = function map(gc) {
  35563. var this$1 = this;
  35564. var mapped = new ArrayList();
  35565. for (var i = 0; i < gc.getNumGeometries(); i++) {
  35566. var g = this$1._mapOp.map(gc.getGeometryN(i));
  35567. if (!g.isEmpty()) {
  35568. mapped.add(g);
  35569. }
  35570. }
  35571. return gc.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(mapped));
  35572. };
  35573. GeometryCollectionMapper.prototype.interfaces_ = function interfaces_138() {
  35574. return [];
  35575. };
  35576. GeometryCollectionMapper.prototype.getClass = function getClass137() {
  35577. return GeometryCollectionMapper;
  35578. };
  35579. GeometryCollectionMapper.map = function map2(gc, op) {
  35580. var mapper = new GeometryCollectionMapper(op);
  35581. return mapper.map(gc);
  35582. };
  35583. var LineBuilder = function LineBuilder2() {
  35584. this._op = null;
  35585. this._geometryFactory = null;
  35586. this._ptLocator = null;
  35587. this._lineEdgesList = new ArrayList();
  35588. this._resultLineList = new ArrayList();
  35589. var op = arguments[0];
  35590. var geometryFactory = arguments[1];
  35591. var ptLocator = arguments[2];
  35592. this._op = op;
  35593. this._geometryFactory = geometryFactory;
  35594. this._ptLocator = ptLocator;
  35595. };
  35596. LineBuilder.prototype.collectLines = function collectLines(opCode) {
  35597. var this$1 = this;
  35598. for (var it = this._op.getGraph().getEdgeEnds().iterator(); it.hasNext(); ) {
  35599. var de = it.next();
  35600. this$1.collectLineEdge(de, opCode, this$1._lineEdgesList);
  35601. this$1.collectBoundaryTouchEdge(de, opCode, this$1._lineEdgesList);
  35602. }
  35603. };
  35604. LineBuilder.prototype.labelIsolatedLine = function labelIsolatedLine(e, targetIndex) {
  35605. var loc = this._ptLocator.locate(e.getCoordinate(), this._op.getArgGeometry(targetIndex));
  35606. e.getLabel().setLocation(targetIndex, loc);
  35607. };
  35608. LineBuilder.prototype.build = function build2(opCode) {
  35609. this.findCoveredLineEdges();
  35610. this.collectLines(opCode);
  35611. this.buildLines(opCode);
  35612. return this._resultLineList;
  35613. };
  35614. LineBuilder.prototype.collectLineEdge = function collectLineEdge(de, opCode, edges2) {
  35615. var label = de.getLabel();
  35616. var e = de.getEdge();
  35617. if (de.isLineEdge()) {
  35618. if (!de.isVisited() && OverlayOp.isResultOfOp(label, opCode) && !e.isCovered()) {
  35619. edges2.add(e);
  35620. de.setVisitedEdge(true);
  35621. }
  35622. }
  35623. };
  35624. LineBuilder.prototype.findCoveredLineEdges = function findCoveredLineEdges() {
  35625. var this$1 = this;
  35626. for (var nodeit = this._op.getGraph().getNodes().iterator(); nodeit.hasNext(); ) {
  35627. var node = nodeit.next();
  35628. node.getEdges().findCoveredLineEdges();
  35629. }
  35630. for (var it = this._op.getGraph().getEdgeEnds().iterator(); it.hasNext(); ) {
  35631. var de = it.next();
  35632. var e = de.getEdge();
  35633. if (de.isLineEdge() && !e.isCoveredSet()) {
  35634. var isCovered2 = this$1._op.isCoveredByA(de.getCoordinate());
  35635. e.setCovered(isCovered2);
  35636. }
  35637. }
  35638. };
  35639. LineBuilder.prototype.labelIsolatedLines = function labelIsolatedLines(edgesList) {
  35640. var this$1 = this;
  35641. for (var it = edgesList.iterator(); it.hasNext(); ) {
  35642. var e = it.next();
  35643. var label = e.getLabel();
  35644. if (e.isIsolated()) {
  35645. if (label.isNull(0)) {
  35646. this$1.labelIsolatedLine(e, 0);
  35647. } else {
  35648. this$1.labelIsolatedLine(e, 1);
  35649. }
  35650. }
  35651. }
  35652. };
  35653. LineBuilder.prototype.buildLines = function buildLines(opCode) {
  35654. var this$1 = this;
  35655. for (var it = this._lineEdgesList.iterator(); it.hasNext(); ) {
  35656. var e = it.next();
  35657. var line = this$1._geometryFactory.createLineString(e.getCoordinates());
  35658. this$1._resultLineList.add(line);
  35659. e.setInResult(true);
  35660. }
  35661. };
  35662. LineBuilder.prototype.collectBoundaryTouchEdge = function collectBoundaryTouchEdge(de, opCode, edges2) {
  35663. var label = de.getLabel();
  35664. if (de.isLineEdge()) {
  35665. return null;
  35666. }
  35667. if (de.isVisited()) {
  35668. return null;
  35669. }
  35670. if (de.isInteriorAreaEdge()) {
  35671. return null;
  35672. }
  35673. if (de.getEdge().isInResult()) {
  35674. return null;
  35675. }
  35676. Assert.isTrue(!(de.isInResult() || de.getSym().isInResult()) || !de.getEdge().isInResult());
  35677. if (OverlayOp.isResultOfOp(label, opCode) && opCode === OverlayOp.INTERSECTION) {
  35678. edges2.add(de.getEdge());
  35679. de.setVisitedEdge(true);
  35680. }
  35681. };
  35682. LineBuilder.prototype.interfaces_ = function interfaces_139() {
  35683. return [];
  35684. };
  35685. LineBuilder.prototype.getClass = function getClass138() {
  35686. return LineBuilder;
  35687. };
  35688. var PointBuilder = function PointBuilder2() {
  35689. this._op = null;
  35690. this._geometryFactory = null;
  35691. this._resultPointList = new ArrayList();
  35692. var op = arguments[0];
  35693. var geometryFactory = arguments[1];
  35694. this._op = op;
  35695. this._geometryFactory = geometryFactory;
  35696. };
  35697. PointBuilder.prototype.filterCoveredNodeToPoint = function filterCoveredNodeToPoint(n) {
  35698. var coord = n.getCoordinate();
  35699. if (!this._op.isCoveredByLA(coord)) {
  35700. var pt = this._geometryFactory.createPoint(coord);
  35701. this._resultPointList.add(pt);
  35702. }
  35703. };
  35704. PointBuilder.prototype.extractNonCoveredResultNodes = function extractNonCoveredResultNodes(opCode) {
  35705. var this$1 = this;
  35706. for (var nodeit = this._op.getGraph().getNodes().iterator(); nodeit.hasNext(); ) {
  35707. var n = nodeit.next();
  35708. if (n.isInResult()) {
  35709. continue;
  35710. }
  35711. if (n.isIncidentEdgeInResult()) {
  35712. continue;
  35713. }
  35714. if (n.getEdges().getDegree() === 0 || opCode === OverlayOp.INTERSECTION) {
  35715. var label = n.getLabel();
  35716. if (OverlayOp.isResultOfOp(label, opCode)) {
  35717. this$1.filterCoveredNodeToPoint(n);
  35718. }
  35719. }
  35720. }
  35721. };
  35722. PointBuilder.prototype.build = function build3(opCode) {
  35723. this.extractNonCoveredResultNodes(opCode);
  35724. return this._resultPointList;
  35725. };
  35726. PointBuilder.prototype.interfaces_ = function interfaces_140() {
  35727. return [];
  35728. };
  35729. PointBuilder.prototype.getClass = function getClass139() {
  35730. return PointBuilder;
  35731. };
  35732. var GeometryTransformer = function GeometryTransformer2() {
  35733. this._inputGeom = null;
  35734. this._factory = null;
  35735. this._pruneEmptyGeometry = true;
  35736. this._preserveGeometryCollectionType = true;
  35737. this._preserveCollections = false;
  35738. this._preserveType = false;
  35739. };
  35740. GeometryTransformer.prototype.transformPoint = function transformPoint(geom, parent) {
  35741. return this._factory.createPoint(this.transformCoordinates(geom.getCoordinateSequence(), geom));
  35742. };
  35743. GeometryTransformer.prototype.transformPolygon = function transformPolygon(geom, parent) {
  35744. var this$1 = this;
  35745. var isAllValidLinearRings = true;
  35746. var shell = this.transformLinearRing(geom.getExteriorRing(), geom);
  35747. if (shell === null || !(shell instanceof LinearRing) || shell.isEmpty()) {
  35748. isAllValidLinearRings = false;
  35749. }
  35750. var holes = new ArrayList();
  35751. for (var i = 0; i < geom.getNumInteriorRing(); i++) {
  35752. var hole = this$1.transformLinearRing(geom.getInteriorRingN(i), geom);
  35753. if (hole === null || hole.isEmpty()) {
  35754. continue;
  35755. }
  35756. if (!(hole instanceof LinearRing)) {
  35757. isAllValidLinearRings = false;
  35758. }
  35759. holes.add(hole);
  35760. }
  35761. if (isAllValidLinearRings) {
  35762. return this._factory.createPolygon(shell, holes.toArray([]));
  35763. } else {
  35764. var components = new ArrayList();
  35765. if (shell !== null) {
  35766. components.add(shell);
  35767. }
  35768. components.addAll(holes);
  35769. return this._factory.buildGeometry(components);
  35770. }
  35771. };
  35772. GeometryTransformer.prototype.createCoordinateSequence = function createCoordinateSequence(coords) {
  35773. return this._factory.getCoordinateSequenceFactory().create(coords);
  35774. };
  35775. GeometryTransformer.prototype.getInputGeometry = function getInputGeometry() {
  35776. return this._inputGeom;
  35777. };
  35778. GeometryTransformer.prototype.transformMultiLineString = function transformMultiLineString(geom, parent) {
  35779. var this$1 = this;
  35780. var transGeomList = new ArrayList();
  35781. for (var i = 0; i < geom.getNumGeometries(); i++) {
  35782. var transformGeom = this$1.transformLineString(geom.getGeometryN(i), geom);
  35783. if (transformGeom === null) {
  35784. continue;
  35785. }
  35786. if (transformGeom.isEmpty()) {
  35787. continue;
  35788. }
  35789. transGeomList.add(transformGeom);
  35790. }
  35791. return this._factory.buildGeometry(transGeomList);
  35792. };
  35793. GeometryTransformer.prototype.transformCoordinates = function transformCoordinates(coords, parent) {
  35794. return this.copy(coords);
  35795. };
  35796. GeometryTransformer.prototype.transformLineString = function transformLineString(geom, parent) {
  35797. return this._factory.createLineString(this.transformCoordinates(geom.getCoordinateSequence(), geom));
  35798. };
  35799. GeometryTransformer.prototype.transformMultiPoint = function transformMultiPoint(geom, parent) {
  35800. var this$1 = this;
  35801. var transGeomList = new ArrayList();
  35802. for (var i = 0; i < geom.getNumGeometries(); i++) {
  35803. var transformGeom = this$1.transformPoint(geom.getGeometryN(i), geom);
  35804. if (transformGeom === null) {
  35805. continue;
  35806. }
  35807. if (transformGeom.isEmpty()) {
  35808. continue;
  35809. }
  35810. transGeomList.add(transformGeom);
  35811. }
  35812. return this._factory.buildGeometry(transGeomList);
  35813. };
  35814. GeometryTransformer.prototype.transformMultiPolygon = function transformMultiPolygon(geom, parent) {
  35815. var this$1 = this;
  35816. var transGeomList = new ArrayList();
  35817. for (var i = 0; i < geom.getNumGeometries(); i++) {
  35818. var transformGeom = this$1.transformPolygon(geom.getGeometryN(i), geom);
  35819. if (transformGeom === null) {
  35820. continue;
  35821. }
  35822. if (transformGeom.isEmpty()) {
  35823. continue;
  35824. }
  35825. transGeomList.add(transformGeom);
  35826. }
  35827. return this._factory.buildGeometry(transGeomList);
  35828. };
  35829. GeometryTransformer.prototype.copy = function copy6(seq) {
  35830. return seq.copy();
  35831. };
  35832. GeometryTransformer.prototype.transformGeometryCollection = function transformGeometryCollection(geom, parent) {
  35833. var this$1 = this;
  35834. var transGeomList = new ArrayList();
  35835. for (var i = 0; i < geom.getNumGeometries(); i++) {
  35836. var transformGeom = this$1.transform(geom.getGeometryN(i));
  35837. if (transformGeom === null) {
  35838. continue;
  35839. }
  35840. if (this$1._pruneEmptyGeometry && transformGeom.isEmpty()) {
  35841. continue;
  35842. }
  35843. transGeomList.add(transformGeom);
  35844. }
  35845. if (this._preserveGeometryCollectionType) {
  35846. return this._factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList));
  35847. }
  35848. return this._factory.buildGeometry(transGeomList);
  35849. };
  35850. GeometryTransformer.prototype.transform = function transform(inputGeom) {
  35851. this._inputGeom = inputGeom;
  35852. this._factory = inputGeom.getFactory();
  35853. if (inputGeom instanceof Point) {
  35854. return this.transformPoint(inputGeom, null);
  35855. }
  35856. if (inputGeom instanceof MultiPoint) {
  35857. return this.transformMultiPoint(inputGeom, null);
  35858. }
  35859. if (inputGeom instanceof LinearRing) {
  35860. return this.transformLinearRing(inputGeom, null);
  35861. }
  35862. if (inputGeom instanceof LineString2) {
  35863. return this.transformLineString(inputGeom, null);
  35864. }
  35865. if (inputGeom instanceof MultiLineString) {
  35866. return this.transformMultiLineString(inputGeom, null);
  35867. }
  35868. if (inputGeom instanceof Polygon) {
  35869. return this.transformPolygon(inputGeom, null);
  35870. }
  35871. if (inputGeom instanceof MultiPolygon) {
  35872. return this.transformMultiPolygon(inputGeom, null);
  35873. }
  35874. if (inputGeom instanceof GeometryCollection) {
  35875. return this.transformGeometryCollection(inputGeom, null);
  35876. }
  35877. throw new IllegalArgumentException("Unknown Geometry subtype: " + inputGeom.getClass().getName());
  35878. };
  35879. GeometryTransformer.prototype.transformLinearRing = function transformLinearRing(geom, parent) {
  35880. var seq = this.transformCoordinates(geom.getCoordinateSequence(), geom);
  35881. if (seq === null) {
  35882. return this._factory.createLinearRing(null);
  35883. }
  35884. var seqSize = seq.size();
  35885. if (seqSize > 0 && seqSize < 4 && !this._preserveType) {
  35886. return this._factory.createLineString(seq);
  35887. }
  35888. return this._factory.createLinearRing(seq);
  35889. };
  35890. GeometryTransformer.prototype.interfaces_ = function interfaces_141() {
  35891. return [];
  35892. };
  35893. GeometryTransformer.prototype.getClass = function getClass140() {
  35894. return GeometryTransformer;
  35895. };
  35896. var LineStringSnapper = function LineStringSnapper2() {
  35897. this._snapTolerance = 0;
  35898. this._srcPts = null;
  35899. this._seg = new LineSegment();
  35900. this._allowSnappingToSourceVertices = false;
  35901. this._isClosed = false;
  35902. if (arguments[0] instanceof LineString2 && typeof arguments[1] === "number") {
  35903. var srcLine = arguments[0];
  35904. var snapTolerance = arguments[1];
  35905. LineStringSnapper2.call(this, srcLine.getCoordinates(), snapTolerance);
  35906. } else if (arguments[0] instanceof Array && typeof arguments[1] === "number") {
  35907. var srcPts = arguments[0];
  35908. var snapTolerance$1 = arguments[1];
  35909. this._srcPts = srcPts;
  35910. this._isClosed = LineStringSnapper2.isClosed(srcPts);
  35911. this._snapTolerance = snapTolerance$1;
  35912. }
  35913. };
  35914. LineStringSnapper.prototype.snapVertices = function snapVertices(srcCoords, snapPts) {
  35915. var this$1 = this;
  35916. var end = this._isClosed ? srcCoords.size() - 1 : srcCoords.size();
  35917. for (var i = 0; i < end; i++) {
  35918. var srcPt = srcCoords.get(i);
  35919. var snapVert = this$1.findSnapForVertex(srcPt, snapPts);
  35920. if (snapVert !== null) {
  35921. srcCoords.set(i, new Coordinate(snapVert));
  35922. if (i === 0 && this$1._isClosed) {
  35923. srcCoords.set(srcCoords.size() - 1, new Coordinate(snapVert));
  35924. }
  35925. }
  35926. }
  35927. };
  35928. LineStringSnapper.prototype.findSnapForVertex = function findSnapForVertex(pt, snapPts) {
  35929. var this$1 = this;
  35930. for (var i = 0; i < snapPts.length; i++) {
  35931. if (pt.equals2D(snapPts[i])) {
  35932. return null;
  35933. }
  35934. if (pt.distance(snapPts[i]) < this$1._snapTolerance) {
  35935. return snapPts[i];
  35936. }
  35937. }
  35938. return null;
  35939. };
  35940. LineStringSnapper.prototype.snapTo = function snapTo(snapPts) {
  35941. var coordList = new CoordinateList(this._srcPts);
  35942. this.snapVertices(coordList, snapPts);
  35943. this.snapSegments(coordList, snapPts);
  35944. var newPts = coordList.toCoordinateArray();
  35945. return newPts;
  35946. };
  35947. LineStringSnapper.prototype.snapSegments = function snapSegments(srcCoords, snapPts) {
  35948. var this$1 = this;
  35949. if (snapPts.length === 0) {
  35950. return null;
  35951. }
  35952. var distinctPtCount = snapPts.length;
  35953. if (snapPts[0].equals2D(snapPts[snapPts.length - 1])) {
  35954. distinctPtCount = snapPts.length - 1;
  35955. }
  35956. for (var i = 0; i < distinctPtCount; i++) {
  35957. var snapPt = snapPts[i];
  35958. var index2 = this$1.findSegmentIndexToSnap(snapPt, srcCoords);
  35959. if (index2 >= 0) {
  35960. srcCoords.add(index2 + 1, new Coordinate(snapPt), false);
  35961. }
  35962. }
  35963. };
  35964. LineStringSnapper.prototype.findSegmentIndexToSnap = function findSegmentIndexToSnap(snapPt, srcCoords) {
  35965. var this$1 = this;
  35966. var minDist = Double.MAX_VALUE;
  35967. var snapIndex = -1;
  35968. for (var i = 0; i < srcCoords.size() - 1; i++) {
  35969. this$1._seg.p0 = srcCoords.get(i);
  35970. this$1._seg.p1 = srcCoords.get(i + 1);
  35971. if (this$1._seg.p0.equals2D(snapPt) || this$1._seg.p1.equals2D(snapPt)) {
  35972. if (this$1._allowSnappingToSourceVertices) {
  35973. continue;
  35974. } else {
  35975. return -1;
  35976. }
  35977. }
  35978. var dist = this$1._seg.distance(snapPt);
  35979. if (dist < this$1._snapTolerance && dist < minDist) {
  35980. minDist = dist;
  35981. snapIndex = i;
  35982. }
  35983. }
  35984. return snapIndex;
  35985. };
  35986. LineStringSnapper.prototype.setAllowSnappingToSourceVertices = function setAllowSnappingToSourceVertices(allowSnappingToSourceVertices) {
  35987. this._allowSnappingToSourceVertices = allowSnappingToSourceVertices;
  35988. };
  35989. LineStringSnapper.prototype.interfaces_ = function interfaces_142() {
  35990. return [];
  35991. };
  35992. LineStringSnapper.prototype.getClass = function getClass141() {
  35993. return LineStringSnapper;
  35994. };
  35995. LineStringSnapper.isClosed = function isClosed4(pts) {
  35996. if (pts.length <= 1) {
  35997. return false;
  35998. }
  35999. return pts[0].equals2D(pts[pts.length - 1]);
  36000. };
  36001. var GeometrySnapper = function GeometrySnapper2(srcGeom) {
  36002. this._srcGeom = srcGeom || null;
  36003. };
  36004. var staticAccessors$41 = { SNAP_PRECISION_FACTOR: { configurable: true } };
  36005. GeometrySnapper.prototype.snapTo = function snapTo2(snapGeom, snapTolerance) {
  36006. var snapPts = this.extractTargetCoordinates(snapGeom);
  36007. var snapTrans = new SnapTransformer(snapTolerance, snapPts);
  36008. return snapTrans.transform(this._srcGeom);
  36009. };
  36010. GeometrySnapper.prototype.snapToSelf = function snapToSelf(snapTolerance, cleanResult) {
  36011. var snapPts = this.extractTargetCoordinates(this._srcGeom);
  36012. var snapTrans = new SnapTransformer(snapTolerance, snapPts, true);
  36013. var snappedGeom = snapTrans.transform(this._srcGeom);
  36014. var result = snappedGeom;
  36015. if (cleanResult && hasInterface(result, Polygonal)) {
  36016. result = snappedGeom.buffer(0);
  36017. }
  36018. return result;
  36019. };
  36020. GeometrySnapper.prototype.computeSnapTolerance = function computeSnapTolerance(ringPts) {
  36021. var minSegLen = this.computeMinimumSegmentLength(ringPts);
  36022. var snapTol = minSegLen / 10;
  36023. return snapTol;
  36024. };
  36025. GeometrySnapper.prototype.extractTargetCoordinates = function extractTargetCoordinates(g) {
  36026. var ptSet = new TreeSet();
  36027. var pts = g.getCoordinates();
  36028. for (var i = 0; i < pts.length; i++) {
  36029. ptSet.add(pts[i]);
  36030. }
  36031. return ptSet.toArray(new Array(0).fill(null));
  36032. };
  36033. GeometrySnapper.prototype.computeMinimumSegmentLength = function computeMinimumSegmentLength(pts) {
  36034. var minSegLen = Double.MAX_VALUE;
  36035. for (var i = 0; i < pts.length - 1; i++) {
  36036. var segLen = pts[i].distance(pts[i + 1]);
  36037. if (segLen < minSegLen) {
  36038. minSegLen = segLen;
  36039. }
  36040. }
  36041. return minSegLen;
  36042. };
  36043. GeometrySnapper.prototype.interfaces_ = function interfaces_143() {
  36044. return [];
  36045. };
  36046. GeometrySnapper.prototype.getClass = function getClass142() {
  36047. return GeometrySnapper;
  36048. };
  36049. GeometrySnapper.snap = function snap2(g0, g1, snapTolerance) {
  36050. var snapGeom = new Array(2).fill(null);
  36051. var snapper0 = new GeometrySnapper(g0);
  36052. snapGeom[0] = snapper0.snapTo(g1, snapTolerance);
  36053. var snapper1 = new GeometrySnapper(g1);
  36054. snapGeom[1] = snapper1.snapTo(snapGeom[0], snapTolerance);
  36055. return snapGeom;
  36056. };
  36057. GeometrySnapper.computeOverlaySnapTolerance = function computeOverlaySnapTolerance() {
  36058. if (arguments.length === 1) {
  36059. var g = arguments[0];
  36060. var snapTolerance = GeometrySnapper.computeSizeBasedSnapTolerance(g);
  36061. var pm = g.getPrecisionModel();
  36062. if (pm.getType() === PrecisionModel.FIXED) {
  36063. var fixedSnapTol = 1 / pm.getScale() * 2 / 1.415;
  36064. if (fixedSnapTol > snapTolerance) {
  36065. snapTolerance = fixedSnapTol;
  36066. }
  36067. }
  36068. return snapTolerance;
  36069. } else if (arguments.length === 2) {
  36070. var g0 = arguments[0];
  36071. var g1 = arguments[1];
  36072. return Math.min(GeometrySnapper.computeOverlaySnapTolerance(g0), GeometrySnapper.computeOverlaySnapTolerance(g1));
  36073. }
  36074. };
  36075. GeometrySnapper.computeSizeBasedSnapTolerance = function computeSizeBasedSnapTolerance(g) {
  36076. var env = g.getEnvelopeInternal();
  36077. var minDimension = Math.min(env.getHeight(), env.getWidth());
  36078. var snapTol = minDimension * GeometrySnapper.SNAP_PRECISION_FACTOR;
  36079. return snapTol;
  36080. };
  36081. GeometrySnapper.snapToSelf = function snapToSelf2(geom, snapTolerance, cleanResult) {
  36082. var snapper0 = new GeometrySnapper(geom);
  36083. return snapper0.snapToSelf(snapTolerance, cleanResult);
  36084. };
  36085. staticAccessors$41.SNAP_PRECISION_FACTOR.get = function() {
  36086. return 1e-9;
  36087. };
  36088. Object.defineProperties(GeometrySnapper, staticAccessors$41);
  36089. var SnapTransformer = function(GeometryTransformer$$1) {
  36090. function SnapTransformer2(snapTolerance, snapPts, isSelfSnap) {
  36091. GeometryTransformer$$1.call(this);
  36092. this._snapTolerance = snapTolerance || null;
  36093. this._snapPts = snapPts || null;
  36094. this._isSelfSnap = isSelfSnap !== void 0 ? isSelfSnap : false;
  36095. }
  36096. if (GeometryTransformer$$1)
  36097. SnapTransformer2.__proto__ = GeometryTransformer$$1;
  36098. SnapTransformer2.prototype = Object.create(GeometryTransformer$$1 && GeometryTransformer$$1.prototype);
  36099. SnapTransformer2.prototype.constructor = SnapTransformer2;
  36100. SnapTransformer2.prototype.snapLine = function snapLine(srcPts, snapPts) {
  36101. var snapper = new LineStringSnapper(srcPts, this._snapTolerance);
  36102. snapper.setAllowSnappingToSourceVertices(this._isSelfSnap);
  36103. return snapper.snapTo(snapPts);
  36104. };
  36105. SnapTransformer2.prototype.transformCoordinates = function transformCoordinates2(coords, parent) {
  36106. var srcPts = coords.toCoordinateArray();
  36107. var newPts = this.snapLine(srcPts, this._snapPts);
  36108. return this._factory.getCoordinateSequenceFactory().create(newPts);
  36109. };
  36110. SnapTransformer2.prototype.interfaces_ = function interfaces_170() {
  36111. return [];
  36112. };
  36113. SnapTransformer2.prototype.getClass = function getClass169() {
  36114. return SnapTransformer2;
  36115. };
  36116. return SnapTransformer2;
  36117. }(GeometryTransformer);
  36118. var CommonBits = function CommonBits2() {
  36119. this._isFirst = true;
  36120. this._commonMantissaBitsCount = 53;
  36121. this._commonBits = 0;
  36122. this._commonSignExp = null;
  36123. };
  36124. CommonBits.prototype.getCommon = function getCommon() {
  36125. return Double.longBitsToDouble(this._commonBits);
  36126. };
  36127. CommonBits.prototype.add = function add14(num) {
  36128. var numBits = Double.doubleToLongBits(num);
  36129. if (this._isFirst) {
  36130. this._commonBits = numBits;
  36131. this._commonSignExp = CommonBits.signExpBits(this._commonBits);
  36132. this._isFirst = false;
  36133. return null;
  36134. }
  36135. var numSignExp = CommonBits.signExpBits(numBits);
  36136. if (numSignExp !== this._commonSignExp) {
  36137. this._commonBits = 0;
  36138. return null;
  36139. }
  36140. this._commonMantissaBitsCount = CommonBits.numCommonMostSigMantissaBits(this._commonBits, numBits);
  36141. this._commonBits = CommonBits.zeroLowerBits(this._commonBits, 64 - (12 + this._commonMantissaBitsCount));
  36142. };
  36143. CommonBits.prototype.toString = function toString23() {
  36144. if (arguments.length === 1) {
  36145. var bits = arguments[0];
  36146. var x2 = Double.longBitsToDouble(bits);
  36147. var numStr = Double.toBinaryString(bits);
  36148. var padStr = "0000000000000000000000000000000000000000000000000000000000000000" + numStr;
  36149. var bitStr = padStr.substring(padStr.length - 64);
  36150. var str = bitStr.substring(0, 1) + " " + bitStr.substring(1, 12) + "(exp) " + bitStr.substring(12) + " [ " + x2 + " ]";
  36151. return str;
  36152. }
  36153. };
  36154. CommonBits.prototype.interfaces_ = function interfaces_144() {
  36155. return [];
  36156. };
  36157. CommonBits.prototype.getClass = function getClass143() {
  36158. return CommonBits;
  36159. };
  36160. CommonBits.getBit = function getBit(bits, i) {
  36161. var mask2 = 1 << i;
  36162. return (bits & mask2) !== 0 ? 1 : 0;
  36163. };
  36164. CommonBits.signExpBits = function signExpBits(num) {
  36165. return num >> 52;
  36166. };
  36167. CommonBits.zeroLowerBits = function zeroLowerBits(bits, nBits) {
  36168. var invMask = (1 << nBits) - 1;
  36169. var mask2 = ~invMask;
  36170. var zeroed = bits & mask2;
  36171. return zeroed;
  36172. };
  36173. CommonBits.numCommonMostSigMantissaBits = function numCommonMostSigMantissaBits(num1, num2) {
  36174. var count2 = 0;
  36175. for (var i = 52; i >= 0; i--) {
  36176. if (CommonBits.getBit(num1, i) !== CommonBits.getBit(num2, i)) {
  36177. return count2;
  36178. }
  36179. count2++;
  36180. }
  36181. return 52;
  36182. };
  36183. var CommonBitsRemover = function CommonBitsRemover2() {
  36184. this._commonCoord = null;
  36185. this._ccFilter = new CommonCoordinateFilter();
  36186. };
  36187. var staticAccessors$42 = { CommonCoordinateFilter: { configurable: true }, Translater: { configurable: true } };
  36188. CommonBitsRemover.prototype.addCommonBits = function addCommonBits(geom) {
  36189. var trans = new Translater(this._commonCoord);
  36190. geom.apply(trans);
  36191. geom.geometryChanged();
  36192. };
  36193. CommonBitsRemover.prototype.removeCommonBits = function removeCommonBits(geom) {
  36194. if (this._commonCoord.x === 0 && this._commonCoord.y === 0) {
  36195. return geom;
  36196. }
  36197. var invCoord = new Coordinate(this._commonCoord);
  36198. invCoord.x = -invCoord.x;
  36199. invCoord.y = -invCoord.y;
  36200. var trans = new Translater(invCoord);
  36201. geom.apply(trans);
  36202. geom.geometryChanged();
  36203. return geom;
  36204. };
  36205. CommonBitsRemover.prototype.getCommonCoordinate = function getCommonCoordinate() {
  36206. return this._commonCoord;
  36207. };
  36208. CommonBitsRemover.prototype.add = function add15(geom) {
  36209. geom.apply(this._ccFilter);
  36210. this._commonCoord = this._ccFilter.getCommonCoordinate();
  36211. };
  36212. CommonBitsRemover.prototype.interfaces_ = function interfaces_145() {
  36213. return [];
  36214. };
  36215. CommonBitsRemover.prototype.getClass = function getClass144() {
  36216. return CommonBitsRemover;
  36217. };
  36218. staticAccessors$42.CommonCoordinateFilter.get = function() {
  36219. return CommonCoordinateFilter;
  36220. };
  36221. staticAccessors$42.Translater.get = function() {
  36222. return Translater;
  36223. };
  36224. Object.defineProperties(CommonBitsRemover, staticAccessors$42);
  36225. var CommonCoordinateFilter = function CommonCoordinateFilter2() {
  36226. this._commonBitsX = new CommonBits();
  36227. this._commonBitsY = new CommonBits();
  36228. };
  36229. CommonCoordinateFilter.prototype.filter = function filter14(coord) {
  36230. this._commonBitsX.add(coord.x);
  36231. this._commonBitsY.add(coord.y);
  36232. };
  36233. CommonCoordinateFilter.prototype.getCommonCoordinate = function getCommonCoordinate2() {
  36234. return new Coordinate(this._commonBitsX.getCommon(), this._commonBitsY.getCommon());
  36235. };
  36236. CommonCoordinateFilter.prototype.interfaces_ = function interfaces_146() {
  36237. return [CoordinateFilter];
  36238. };
  36239. CommonCoordinateFilter.prototype.getClass = function getClass145() {
  36240. return CommonCoordinateFilter;
  36241. };
  36242. var Translater = function Translater2() {
  36243. this.trans = null;
  36244. var trans = arguments[0];
  36245. this.trans = trans;
  36246. };
  36247. Translater.prototype.filter = function filter15(seq, i) {
  36248. var xp = seq.getOrdinate(i, 0) + this.trans.x;
  36249. var yp = seq.getOrdinate(i, 1) + this.trans.y;
  36250. seq.setOrdinate(i, 0, xp);
  36251. seq.setOrdinate(i, 1, yp);
  36252. };
  36253. Translater.prototype.isDone = function isDone8() {
  36254. return false;
  36255. };
  36256. Translater.prototype.isGeometryChanged = function isGeometryChanged4() {
  36257. return true;
  36258. };
  36259. Translater.prototype.interfaces_ = function interfaces_147() {
  36260. return [CoordinateSequenceFilter];
  36261. };
  36262. Translater.prototype.getClass = function getClass146() {
  36263. return Translater;
  36264. };
  36265. var SnapOverlayOp = function SnapOverlayOp2(g1, g2) {
  36266. this._geom = new Array(2).fill(null);
  36267. this._snapTolerance = null;
  36268. this._cbr = null;
  36269. this._geom[0] = g1;
  36270. this._geom[1] = g2;
  36271. this.computeSnapTolerance();
  36272. };
  36273. SnapOverlayOp.prototype.selfSnap = function selfSnap(geom) {
  36274. var snapper0 = new GeometrySnapper(geom);
  36275. var snapGeom = snapper0.snapTo(geom, this._snapTolerance);
  36276. return snapGeom;
  36277. };
  36278. SnapOverlayOp.prototype.removeCommonBits = function removeCommonBits2(geom) {
  36279. this._cbr = new CommonBitsRemover();
  36280. this._cbr.add(geom[0]);
  36281. this._cbr.add(geom[1]);
  36282. var remGeom = new Array(2).fill(null);
  36283. remGeom[0] = this._cbr.removeCommonBits(geom[0].copy());
  36284. remGeom[1] = this._cbr.removeCommonBits(geom[1].copy());
  36285. return remGeom;
  36286. };
  36287. SnapOverlayOp.prototype.prepareResult = function prepareResult(geom) {
  36288. this._cbr.addCommonBits(geom);
  36289. return geom;
  36290. };
  36291. SnapOverlayOp.prototype.getResultGeometry = function getResultGeometry2(opCode) {
  36292. var prepGeom = this.snap(this._geom);
  36293. var result = OverlayOp.overlayOp(prepGeom[0], prepGeom[1], opCode);
  36294. return this.prepareResult(result);
  36295. };
  36296. SnapOverlayOp.prototype.checkValid = function checkValid5(g) {
  36297. if (!g.isValid()) {
  36298. System.out.println("Snapped geometry is invalid");
  36299. }
  36300. };
  36301. SnapOverlayOp.prototype.computeSnapTolerance = function computeSnapTolerance2() {
  36302. this._snapTolerance = GeometrySnapper.computeOverlaySnapTolerance(this._geom[0], this._geom[1]);
  36303. };
  36304. SnapOverlayOp.prototype.snap = function snap3(geom) {
  36305. var remGeom = this.removeCommonBits(geom);
  36306. var snapGeom = GeometrySnapper.snap(remGeom[0], remGeom[1], this._snapTolerance);
  36307. return snapGeom;
  36308. };
  36309. SnapOverlayOp.prototype.interfaces_ = function interfaces_148() {
  36310. return [];
  36311. };
  36312. SnapOverlayOp.prototype.getClass = function getClass147() {
  36313. return SnapOverlayOp;
  36314. };
  36315. SnapOverlayOp.overlayOp = function overlayOp(g0, g1, opCode) {
  36316. var op = new SnapOverlayOp(g0, g1);
  36317. return op.getResultGeometry(opCode);
  36318. };
  36319. SnapOverlayOp.union = function union3(g0, g1) {
  36320. return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.UNION);
  36321. };
  36322. SnapOverlayOp.intersection = function intersection10(g0, g1) {
  36323. return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.INTERSECTION);
  36324. };
  36325. SnapOverlayOp.symDifference = function symDifference(g0, g1) {
  36326. return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.SYMDIFFERENCE);
  36327. };
  36328. SnapOverlayOp.difference = function difference4(g0, g1) {
  36329. return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.DIFFERENCE);
  36330. };
  36331. var SnapIfNeededOverlayOp = function SnapIfNeededOverlayOp2(g1, g2) {
  36332. this._geom = new Array(2).fill(null);
  36333. this._geom[0] = g1;
  36334. this._geom[1] = g2;
  36335. };
  36336. SnapIfNeededOverlayOp.prototype.getResultGeometry = function getResultGeometry3(opCode) {
  36337. var result = null;
  36338. var isSuccess = false;
  36339. var savedException = null;
  36340. try {
  36341. result = OverlayOp.overlayOp(this._geom[0], this._geom[1], opCode);
  36342. var isValid7 = true;
  36343. if (isValid7) {
  36344. isSuccess = true;
  36345. }
  36346. } catch (ex) {
  36347. if (ex instanceof RuntimeException) {
  36348. savedException = ex;
  36349. } else {
  36350. throw ex;
  36351. }
  36352. } finally {
  36353. }
  36354. if (!isSuccess) {
  36355. try {
  36356. result = SnapOverlayOp.overlayOp(this._geom[0], this._geom[1], opCode);
  36357. } catch (ex) {
  36358. if (ex instanceof RuntimeException) {
  36359. throw savedException;
  36360. } else {
  36361. throw ex;
  36362. }
  36363. } finally {
  36364. }
  36365. }
  36366. return result;
  36367. };
  36368. SnapIfNeededOverlayOp.prototype.interfaces_ = function interfaces_149() {
  36369. return [];
  36370. };
  36371. SnapIfNeededOverlayOp.prototype.getClass = function getClass148() {
  36372. return SnapIfNeededOverlayOp;
  36373. };
  36374. SnapIfNeededOverlayOp.overlayOp = function overlayOp2(g0, g1, opCode) {
  36375. var op = new SnapIfNeededOverlayOp(g0, g1);
  36376. return op.getResultGeometry(opCode);
  36377. };
  36378. SnapIfNeededOverlayOp.union = function union4(g0, g1) {
  36379. return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.UNION);
  36380. };
  36381. SnapIfNeededOverlayOp.intersection = function intersection11(g0, g1) {
  36382. return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.INTERSECTION);
  36383. };
  36384. SnapIfNeededOverlayOp.symDifference = function symDifference2(g0, g1) {
  36385. return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.SYMDIFFERENCE);
  36386. };
  36387. SnapIfNeededOverlayOp.difference = function difference5(g0, g1) {
  36388. return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.DIFFERENCE);
  36389. };
  36390. var MonotoneChain$2 = function MonotoneChain3() {
  36391. this.mce = null;
  36392. this.chainIndex = null;
  36393. var mce = arguments[0];
  36394. var chainIndex = arguments[1];
  36395. this.mce = mce;
  36396. this.chainIndex = chainIndex;
  36397. };
  36398. MonotoneChain$2.prototype.computeIntersections = function computeIntersections2(mc, si) {
  36399. this.mce.computeIntersectsForChain(this.chainIndex, mc.mce, mc.chainIndex, si);
  36400. };
  36401. MonotoneChain$2.prototype.interfaces_ = function interfaces_150() {
  36402. return [];
  36403. };
  36404. MonotoneChain$2.prototype.getClass = function getClass149() {
  36405. return MonotoneChain$2;
  36406. };
  36407. var SweepLineEvent = function SweepLineEvent2() {
  36408. this._label = null;
  36409. this._xValue = null;
  36410. this._eventType = null;
  36411. this._insertEvent = null;
  36412. this._deleteEventIndex = null;
  36413. this._obj = null;
  36414. if (arguments.length === 2) {
  36415. var x2 = arguments[0];
  36416. var insertEvent = arguments[1];
  36417. this._eventType = SweepLineEvent2.DELETE;
  36418. this._xValue = x2;
  36419. this._insertEvent = insertEvent;
  36420. } else if (arguments.length === 3) {
  36421. var label = arguments[0];
  36422. var x$1 = arguments[1];
  36423. var obj = arguments[2];
  36424. this._eventType = SweepLineEvent2.INSERT;
  36425. this._label = label;
  36426. this._xValue = x$1;
  36427. this._obj = obj;
  36428. }
  36429. };
  36430. var staticAccessors$43 = { INSERT: { configurable: true }, DELETE: { configurable: true } };
  36431. SweepLineEvent.prototype.isDelete = function isDelete() {
  36432. return this._eventType === SweepLineEvent.DELETE;
  36433. };
  36434. SweepLineEvent.prototype.setDeleteEventIndex = function setDeleteEventIndex(deleteEventIndex) {
  36435. this._deleteEventIndex = deleteEventIndex;
  36436. };
  36437. SweepLineEvent.prototype.getObject = function getObject() {
  36438. return this._obj;
  36439. };
  36440. SweepLineEvent.prototype.compareTo = function compareTo15(o) {
  36441. var pe = o;
  36442. if (this._xValue < pe._xValue) {
  36443. return -1;
  36444. }
  36445. if (this._xValue > pe._xValue) {
  36446. return 1;
  36447. }
  36448. if (this._eventType < pe._eventType) {
  36449. return -1;
  36450. }
  36451. if (this._eventType > pe._eventType) {
  36452. return 1;
  36453. }
  36454. return 0;
  36455. };
  36456. SweepLineEvent.prototype.getInsertEvent = function getInsertEvent() {
  36457. return this._insertEvent;
  36458. };
  36459. SweepLineEvent.prototype.isInsert = function isInsert() {
  36460. return this._eventType === SweepLineEvent.INSERT;
  36461. };
  36462. SweepLineEvent.prototype.isSameLabel = function isSameLabel(ev) {
  36463. if (this._label === null) {
  36464. return false;
  36465. }
  36466. return this._label === ev._label;
  36467. };
  36468. SweepLineEvent.prototype.getDeleteEventIndex = function getDeleteEventIndex() {
  36469. return this._deleteEventIndex;
  36470. };
  36471. SweepLineEvent.prototype.interfaces_ = function interfaces_151() {
  36472. return [Comparable];
  36473. };
  36474. SweepLineEvent.prototype.getClass = function getClass150() {
  36475. return SweepLineEvent;
  36476. };
  36477. staticAccessors$43.INSERT.get = function() {
  36478. return 1;
  36479. };
  36480. staticAccessors$43.DELETE.get = function() {
  36481. return 2;
  36482. };
  36483. Object.defineProperties(SweepLineEvent, staticAccessors$43);
  36484. var EdgeSetIntersector = function EdgeSetIntersector2() {
  36485. };
  36486. EdgeSetIntersector.prototype.interfaces_ = function interfaces_152() {
  36487. return [];
  36488. };
  36489. EdgeSetIntersector.prototype.getClass = function getClass151() {
  36490. return EdgeSetIntersector;
  36491. };
  36492. var SegmentIntersector$2 = function SegmentIntersector3() {
  36493. this._hasIntersection = false;
  36494. this._hasProper = false;
  36495. this._hasProperInterior = false;
  36496. this._properIntersectionPoint = null;
  36497. this._li = null;
  36498. this._includeProper = null;
  36499. this._recordIsolated = null;
  36500. this._isSelfIntersection = null;
  36501. this._numIntersections = 0;
  36502. this.numTests = 0;
  36503. this._bdyNodes = null;
  36504. this._isDone = false;
  36505. this._isDoneWhenProperInt = false;
  36506. var li = arguments[0];
  36507. var includeProper = arguments[1];
  36508. var recordIsolated = arguments[2];
  36509. this._li = li;
  36510. this._includeProper = includeProper;
  36511. this._recordIsolated = recordIsolated;
  36512. };
  36513. SegmentIntersector$2.prototype.isTrivialIntersection = function isTrivialIntersection2(e0, segIndex0, e1, segIndex1) {
  36514. if (e0 === e1) {
  36515. if (this._li.getIntersectionNum() === 1) {
  36516. if (SegmentIntersector$2.isAdjacentSegments(segIndex0, segIndex1)) {
  36517. return true;
  36518. }
  36519. if (e0.isClosed()) {
  36520. var maxSegIndex = e0.getNumPoints() - 1;
  36521. if (segIndex0 === 0 && segIndex1 === maxSegIndex || segIndex1 === 0 && segIndex0 === maxSegIndex) {
  36522. return true;
  36523. }
  36524. }
  36525. }
  36526. }
  36527. return false;
  36528. };
  36529. SegmentIntersector$2.prototype.getProperIntersectionPoint = function getProperIntersectionPoint2() {
  36530. return this._properIntersectionPoint;
  36531. };
  36532. SegmentIntersector$2.prototype.setIsDoneIfProperInt = function setIsDoneIfProperInt(isDoneWhenProperInt) {
  36533. this._isDoneWhenProperInt = isDoneWhenProperInt;
  36534. };
  36535. SegmentIntersector$2.prototype.hasProperInteriorIntersection = function hasProperInteriorIntersection2() {
  36536. return this._hasProperInterior;
  36537. };
  36538. SegmentIntersector$2.prototype.isBoundaryPointInternal = function isBoundaryPointInternal(li, bdyNodes) {
  36539. for (var i = bdyNodes.iterator(); i.hasNext(); ) {
  36540. var node = i.next();
  36541. var pt = node.getCoordinate();
  36542. if (li.isIntersection(pt)) {
  36543. return true;
  36544. }
  36545. }
  36546. return false;
  36547. };
  36548. SegmentIntersector$2.prototype.hasProperIntersection = function hasProperIntersection2() {
  36549. return this._hasProper;
  36550. };
  36551. SegmentIntersector$2.prototype.hasIntersection = function hasIntersection4() {
  36552. return this._hasIntersection;
  36553. };
  36554. SegmentIntersector$2.prototype.isDone = function isDone9() {
  36555. return this._isDone;
  36556. };
  36557. SegmentIntersector$2.prototype.isBoundaryPoint = function isBoundaryPoint(li, bdyNodes) {
  36558. if (bdyNodes === null) {
  36559. return false;
  36560. }
  36561. if (this.isBoundaryPointInternal(li, bdyNodes[0])) {
  36562. return true;
  36563. }
  36564. if (this.isBoundaryPointInternal(li, bdyNodes[1])) {
  36565. return true;
  36566. }
  36567. return false;
  36568. };
  36569. SegmentIntersector$2.prototype.setBoundaryNodes = function setBoundaryNodes(bdyNodes0, bdyNodes1) {
  36570. this._bdyNodes = new Array(2).fill(null);
  36571. this._bdyNodes[0] = bdyNodes0;
  36572. this._bdyNodes[1] = bdyNodes1;
  36573. };
  36574. SegmentIntersector$2.prototype.addIntersections = function addIntersections2(e0, segIndex0, e1, segIndex1) {
  36575. if (e0 === e1 && segIndex0 === segIndex1) {
  36576. return null;
  36577. }
  36578. this.numTests++;
  36579. var p002 = e0.getCoordinates()[segIndex0];
  36580. var p012 = e0.getCoordinates()[segIndex0 + 1];
  36581. var p102 = e1.getCoordinates()[segIndex1];
  36582. var p112 = e1.getCoordinates()[segIndex1 + 1];
  36583. this._li.computeIntersection(p002, p012, p102, p112);
  36584. if (this._li.hasIntersection()) {
  36585. if (this._recordIsolated) {
  36586. e0.setIsolated(false);
  36587. e1.setIsolated(false);
  36588. }
  36589. this._numIntersections++;
  36590. if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
  36591. this._hasIntersection = true;
  36592. if (this._includeProper || !this._li.isProper()) {
  36593. e0.addIntersections(this._li, segIndex0, 0);
  36594. e1.addIntersections(this._li, segIndex1, 1);
  36595. }
  36596. if (this._li.isProper()) {
  36597. this._properIntersectionPoint = this._li.getIntersection(0).copy();
  36598. this._hasProper = true;
  36599. if (this._isDoneWhenProperInt) {
  36600. this._isDone = true;
  36601. }
  36602. if (!this.isBoundaryPoint(this._li, this._bdyNodes)) {
  36603. this._hasProperInterior = true;
  36604. }
  36605. }
  36606. }
  36607. }
  36608. };
  36609. SegmentIntersector$2.prototype.interfaces_ = function interfaces_153() {
  36610. return [];
  36611. };
  36612. SegmentIntersector$2.prototype.getClass = function getClass152() {
  36613. return SegmentIntersector$2;
  36614. };
  36615. SegmentIntersector$2.isAdjacentSegments = function isAdjacentSegments2(i1, i2) {
  36616. return Math.abs(i1 - i2) === 1;
  36617. };
  36618. var SimpleMCSweepLineIntersector = function(EdgeSetIntersector$$1) {
  36619. function SimpleMCSweepLineIntersector2() {
  36620. EdgeSetIntersector$$1.call(this);
  36621. this.events = new ArrayList();
  36622. this.nOverlaps = null;
  36623. }
  36624. if (EdgeSetIntersector$$1)
  36625. SimpleMCSweepLineIntersector2.__proto__ = EdgeSetIntersector$$1;
  36626. SimpleMCSweepLineIntersector2.prototype = Object.create(EdgeSetIntersector$$1 && EdgeSetIntersector$$1.prototype);
  36627. SimpleMCSweepLineIntersector2.prototype.constructor = SimpleMCSweepLineIntersector2;
  36628. SimpleMCSweepLineIntersector2.prototype.prepareEvents = function prepareEvents() {
  36629. var this$1 = this;
  36630. Collections.sort(this.events);
  36631. for (var i = 0; i < this.events.size(); i++) {
  36632. var ev = this$1.events.get(i);
  36633. if (ev.isDelete()) {
  36634. ev.getInsertEvent().setDeleteEventIndex(i);
  36635. }
  36636. }
  36637. };
  36638. SimpleMCSweepLineIntersector2.prototype.computeIntersections = function computeIntersections3() {
  36639. var this$1 = this;
  36640. if (arguments.length === 1) {
  36641. var si = arguments[0];
  36642. this.nOverlaps = 0;
  36643. this.prepareEvents();
  36644. for (var i = 0; i < this.events.size(); i++) {
  36645. var ev = this$1.events.get(i);
  36646. if (ev.isInsert()) {
  36647. this$1.processOverlaps(i, ev.getDeleteEventIndex(), ev, si);
  36648. }
  36649. if (si.isDone()) {
  36650. break;
  36651. }
  36652. }
  36653. } else if (arguments.length === 3) {
  36654. if (arguments[2] instanceof SegmentIntersector$2 && (hasInterface(arguments[0], List) && hasInterface(arguments[1], List))) {
  36655. var edges0 = arguments[0];
  36656. var edges1 = arguments[1];
  36657. var si$1 = arguments[2];
  36658. this.addEdges(edges0, edges0);
  36659. this.addEdges(edges1, edges1);
  36660. this.computeIntersections(si$1);
  36661. } else if (typeof arguments[2] === "boolean" && (hasInterface(arguments[0], List) && arguments[1] instanceof SegmentIntersector$2)) {
  36662. var edges2 = arguments[0];
  36663. var si$2 = arguments[1];
  36664. var testAllSegments = arguments[2];
  36665. if (testAllSegments) {
  36666. this.addEdges(edges2, null);
  36667. } else {
  36668. this.addEdges(edges2);
  36669. }
  36670. this.computeIntersections(si$2);
  36671. }
  36672. }
  36673. };
  36674. SimpleMCSweepLineIntersector2.prototype.addEdge = function addEdge(edge, edgeSet) {
  36675. var this$1 = this;
  36676. var mce = edge.getMonotoneChainEdge();
  36677. var startIndex = mce.getStartIndexes();
  36678. for (var i = 0; i < startIndex.length - 1; i++) {
  36679. var mc = new MonotoneChain$2(mce, i);
  36680. var insertEvent = new SweepLineEvent(edgeSet, mce.getMinX(i), mc);
  36681. this$1.events.add(insertEvent);
  36682. this$1.events.add(new SweepLineEvent(mce.getMaxX(i), insertEvent));
  36683. }
  36684. };
  36685. SimpleMCSweepLineIntersector2.prototype.processOverlaps = function processOverlaps(start, end, ev0, si) {
  36686. var this$1 = this;
  36687. var mc0 = ev0.getObject();
  36688. for (var i = start; i < end; i++) {
  36689. var ev1 = this$1.events.get(i);
  36690. if (ev1.isInsert()) {
  36691. var mc1 = ev1.getObject();
  36692. if (!ev0.isSameLabel(ev1)) {
  36693. mc0.computeIntersections(mc1, si);
  36694. this$1.nOverlaps++;
  36695. }
  36696. }
  36697. }
  36698. };
  36699. SimpleMCSweepLineIntersector2.prototype.addEdges = function addEdges2() {
  36700. var this$1 = this;
  36701. if (arguments.length === 1) {
  36702. var edges2 = arguments[0];
  36703. for (var i = edges2.iterator(); i.hasNext(); ) {
  36704. var edge = i.next();
  36705. this$1.addEdge(edge, edge);
  36706. }
  36707. } else if (arguments.length === 2) {
  36708. var edges$1 = arguments[0];
  36709. var edgeSet = arguments[1];
  36710. for (var i$1 = edges$1.iterator(); i$1.hasNext(); ) {
  36711. var edge$1 = i$1.next();
  36712. this$1.addEdge(edge$1, edgeSet);
  36713. }
  36714. }
  36715. };
  36716. SimpleMCSweepLineIntersector2.prototype.interfaces_ = function interfaces_170() {
  36717. return [];
  36718. };
  36719. SimpleMCSweepLineIntersector2.prototype.getClass = function getClass169() {
  36720. return SimpleMCSweepLineIntersector2;
  36721. };
  36722. return SimpleMCSweepLineIntersector2;
  36723. }(EdgeSetIntersector);
  36724. var IntervalRTreeNode = function IntervalRTreeNode2() {
  36725. this._min = Double.POSITIVE_INFINITY;
  36726. this._max = Double.NEGATIVE_INFINITY;
  36727. };
  36728. var staticAccessors$45 = { NodeComparator: { configurable: true } };
  36729. IntervalRTreeNode.prototype.getMin = function getMin() {
  36730. return this._min;
  36731. };
  36732. IntervalRTreeNode.prototype.intersects = function intersects6(queryMin, queryMax) {
  36733. if (this._min > queryMax || this._max < queryMin) {
  36734. return false;
  36735. }
  36736. return true;
  36737. };
  36738. IntervalRTreeNode.prototype.getMax = function getMax() {
  36739. return this._max;
  36740. };
  36741. IntervalRTreeNode.prototype.toString = function toString24() {
  36742. return WKTWriter.toLineString(new Coordinate(this._min, 0), new Coordinate(this._max, 0));
  36743. };
  36744. IntervalRTreeNode.prototype.interfaces_ = function interfaces_154() {
  36745. return [];
  36746. };
  36747. IntervalRTreeNode.prototype.getClass = function getClass153() {
  36748. return IntervalRTreeNode;
  36749. };
  36750. staticAccessors$45.NodeComparator.get = function() {
  36751. return NodeComparator;
  36752. };
  36753. Object.defineProperties(IntervalRTreeNode, staticAccessors$45);
  36754. var NodeComparator = function NodeComparator2() {
  36755. };
  36756. NodeComparator.prototype.compare = function compare9(o1, o2) {
  36757. var n1 = o1;
  36758. var n2 = o2;
  36759. var mid1 = (n1._min + n1._max) / 2;
  36760. var mid2 = (n2._min + n2._max) / 2;
  36761. if (mid1 < mid2) {
  36762. return -1;
  36763. }
  36764. if (mid1 > mid2) {
  36765. return 1;
  36766. }
  36767. return 0;
  36768. };
  36769. NodeComparator.prototype.interfaces_ = function interfaces_155() {
  36770. return [Comparator];
  36771. };
  36772. NodeComparator.prototype.getClass = function getClass154() {
  36773. return NodeComparator;
  36774. };
  36775. var IntervalRTreeLeafNode = function(IntervalRTreeNode$$1) {
  36776. function IntervalRTreeLeafNode2() {
  36777. IntervalRTreeNode$$1.call(this);
  36778. this._item = null;
  36779. var min4 = arguments[0];
  36780. var max3 = arguments[1];
  36781. var item = arguments[2];
  36782. this._min = min4;
  36783. this._max = max3;
  36784. this._item = item;
  36785. }
  36786. if (IntervalRTreeNode$$1)
  36787. IntervalRTreeLeafNode2.__proto__ = IntervalRTreeNode$$1;
  36788. IntervalRTreeLeafNode2.prototype = Object.create(IntervalRTreeNode$$1 && IntervalRTreeNode$$1.prototype);
  36789. IntervalRTreeLeafNode2.prototype.constructor = IntervalRTreeLeafNode2;
  36790. IntervalRTreeLeafNode2.prototype.query = function query5(queryMin, queryMax, visitor) {
  36791. if (!this.intersects(queryMin, queryMax)) {
  36792. return null;
  36793. }
  36794. visitor.visitItem(this._item);
  36795. };
  36796. IntervalRTreeLeafNode2.prototype.interfaces_ = function interfaces_170() {
  36797. return [];
  36798. };
  36799. IntervalRTreeLeafNode2.prototype.getClass = function getClass169() {
  36800. return IntervalRTreeLeafNode2;
  36801. };
  36802. return IntervalRTreeLeafNode2;
  36803. }(IntervalRTreeNode);
  36804. var IntervalRTreeBranchNode = function(IntervalRTreeNode$$1) {
  36805. function IntervalRTreeBranchNode2() {
  36806. IntervalRTreeNode$$1.call(this);
  36807. this._node1 = null;
  36808. this._node2 = null;
  36809. var n1 = arguments[0];
  36810. var n2 = arguments[1];
  36811. this._node1 = n1;
  36812. this._node2 = n2;
  36813. this.buildExtent(this._node1, this._node2);
  36814. }
  36815. if (IntervalRTreeNode$$1)
  36816. IntervalRTreeBranchNode2.__proto__ = IntervalRTreeNode$$1;
  36817. IntervalRTreeBranchNode2.prototype = Object.create(IntervalRTreeNode$$1 && IntervalRTreeNode$$1.prototype);
  36818. IntervalRTreeBranchNode2.prototype.constructor = IntervalRTreeBranchNode2;
  36819. IntervalRTreeBranchNode2.prototype.buildExtent = function buildExtent(n1, n2) {
  36820. this._min = Math.min(n1._min, n2._min);
  36821. this._max = Math.max(n1._max, n2._max);
  36822. };
  36823. IntervalRTreeBranchNode2.prototype.query = function query5(queryMin, queryMax, visitor) {
  36824. if (!this.intersects(queryMin, queryMax)) {
  36825. return null;
  36826. }
  36827. if (this._node1 !== null) {
  36828. this._node1.query(queryMin, queryMax, visitor);
  36829. }
  36830. if (this._node2 !== null) {
  36831. this._node2.query(queryMin, queryMax, visitor);
  36832. }
  36833. };
  36834. IntervalRTreeBranchNode2.prototype.interfaces_ = function interfaces_170() {
  36835. return [];
  36836. };
  36837. IntervalRTreeBranchNode2.prototype.getClass = function getClass169() {
  36838. return IntervalRTreeBranchNode2;
  36839. };
  36840. return IntervalRTreeBranchNode2;
  36841. }(IntervalRTreeNode);
  36842. var SortedPackedIntervalRTree = function SortedPackedIntervalRTree2() {
  36843. this._leaves = new ArrayList();
  36844. this._root = null;
  36845. this._level = 0;
  36846. };
  36847. SortedPackedIntervalRTree.prototype.buildTree = function buildTree() {
  36848. var this$1 = this;
  36849. Collections.sort(this._leaves, new IntervalRTreeNode.NodeComparator());
  36850. var src = this._leaves;
  36851. var temp2 = null;
  36852. var dest = new ArrayList();
  36853. while (true) {
  36854. this$1.buildLevel(src, dest);
  36855. if (dest.size() === 1) {
  36856. return dest.get(0);
  36857. }
  36858. temp2 = src;
  36859. src = dest;
  36860. dest = temp2;
  36861. }
  36862. };
  36863. SortedPackedIntervalRTree.prototype.insert = function insert4(min4, max3, item) {
  36864. if (this._root !== null) {
  36865. throw new Error("Index cannot be added to once it has been queried");
  36866. }
  36867. this._leaves.add(new IntervalRTreeLeafNode(min4, max3, item));
  36868. };
  36869. SortedPackedIntervalRTree.prototype.query = function query3(min4, max3, visitor) {
  36870. this.init();
  36871. this._root.query(min4, max3, visitor);
  36872. };
  36873. SortedPackedIntervalRTree.prototype.buildRoot = function buildRoot() {
  36874. if (this._root !== null) {
  36875. return null;
  36876. }
  36877. this._root = this.buildTree();
  36878. };
  36879. SortedPackedIntervalRTree.prototype.printNode = function printNode(node) {
  36880. System.out.println(WKTWriter.toLineString(new Coordinate(node._min, this._level), new Coordinate(node._max, this._level)));
  36881. };
  36882. SortedPackedIntervalRTree.prototype.init = function init6() {
  36883. if (this._root !== null) {
  36884. return null;
  36885. }
  36886. this.buildRoot();
  36887. };
  36888. SortedPackedIntervalRTree.prototype.buildLevel = function buildLevel(src, dest) {
  36889. this._level++;
  36890. dest.clear();
  36891. for (var i = 0; i < src.size(); i += 2) {
  36892. var n1 = src.get(i);
  36893. var n2 = i + 1 < src.size() ? src.get(i) : null;
  36894. if (n2 === null) {
  36895. dest.add(n1);
  36896. } else {
  36897. var node = new IntervalRTreeBranchNode(src.get(i), src.get(i + 1));
  36898. dest.add(node);
  36899. }
  36900. }
  36901. };
  36902. SortedPackedIntervalRTree.prototype.interfaces_ = function interfaces_156() {
  36903. return [];
  36904. };
  36905. SortedPackedIntervalRTree.prototype.getClass = function getClass155() {
  36906. return SortedPackedIntervalRTree;
  36907. };
  36908. var ArrayListVisitor = function ArrayListVisitor2() {
  36909. this._items = new ArrayList();
  36910. };
  36911. ArrayListVisitor.prototype.visitItem = function visitItem2(item) {
  36912. this._items.add(item);
  36913. };
  36914. ArrayListVisitor.prototype.getItems = function getItems() {
  36915. return this._items;
  36916. };
  36917. ArrayListVisitor.prototype.interfaces_ = function interfaces_157() {
  36918. return [ItemVisitor];
  36919. };
  36920. ArrayListVisitor.prototype.getClass = function getClass156() {
  36921. return ArrayListVisitor;
  36922. };
  36923. var IndexedPointInAreaLocator = function IndexedPointInAreaLocator2() {
  36924. this._index = null;
  36925. var g = arguments[0];
  36926. if (!hasInterface(g, Polygonal)) {
  36927. throw new IllegalArgumentException("Argument must be Polygonal");
  36928. }
  36929. this._index = new IntervalIndexedGeometry(g);
  36930. };
  36931. var staticAccessors$44 = { SegmentVisitor: { configurable: true }, IntervalIndexedGeometry: { configurable: true } };
  36932. IndexedPointInAreaLocator.prototype.locate = function locate5(p) {
  36933. var rcc = new RayCrossingCounter(p);
  36934. var visitor = new SegmentVisitor(rcc);
  36935. this._index.query(p.y, p.y, visitor);
  36936. return rcc.getLocation();
  36937. };
  36938. IndexedPointInAreaLocator.prototype.interfaces_ = function interfaces_158() {
  36939. return [PointOnGeometryLocator];
  36940. };
  36941. IndexedPointInAreaLocator.prototype.getClass = function getClass157() {
  36942. return IndexedPointInAreaLocator;
  36943. };
  36944. staticAccessors$44.SegmentVisitor.get = function() {
  36945. return SegmentVisitor;
  36946. };
  36947. staticAccessors$44.IntervalIndexedGeometry.get = function() {
  36948. return IntervalIndexedGeometry;
  36949. };
  36950. Object.defineProperties(IndexedPointInAreaLocator, staticAccessors$44);
  36951. var SegmentVisitor = function SegmentVisitor2() {
  36952. this._counter = null;
  36953. var counter = arguments[0];
  36954. this._counter = counter;
  36955. };
  36956. SegmentVisitor.prototype.visitItem = function visitItem3(item) {
  36957. var seg = item;
  36958. this._counter.countSegment(seg.getCoordinate(0), seg.getCoordinate(1));
  36959. };
  36960. SegmentVisitor.prototype.interfaces_ = function interfaces_159() {
  36961. return [ItemVisitor];
  36962. };
  36963. SegmentVisitor.prototype.getClass = function getClass158() {
  36964. return SegmentVisitor;
  36965. };
  36966. var IntervalIndexedGeometry = function IntervalIndexedGeometry2() {
  36967. this._index = new SortedPackedIntervalRTree();
  36968. var geom = arguments[0];
  36969. this.init(geom);
  36970. };
  36971. IntervalIndexedGeometry.prototype.init = function init7(geom) {
  36972. var this$1 = this;
  36973. var lines = LinearComponentExtracter.getLines(geom);
  36974. for (var i = lines.iterator(); i.hasNext(); ) {
  36975. var line = i.next();
  36976. var pts = line.getCoordinates();
  36977. this$1.addLine(pts);
  36978. }
  36979. };
  36980. IntervalIndexedGeometry.prototype.addLine = function addLine(pts) {
  36981. var this$1 = this;
  36982. for (var i = 1; i < pts.length; i++) {
  36983. var seg = new LineSegment(pts[i - 1], pts[i]);
  36984. var min4 = Math.min(seg.p0.y, seg.p1.y);
  36985. var max3 = Math.max(seg.p0.y, seg.p1.y);
  36986. this$1._index.insert(min4, max3, seg);
  36987. }
  36988. };
  36989. IntervalIndexedGeometry.prototype.query = function query4() {
  36990. if (arguments.length === 2) {
  36991. var min4 = arguments[0];
  36992. var max3 = arguments[1];
  36993. var visitor = new ArrayListVisitor();
  36994. this._index.query(min4, max3, visitor);
  36995. return visitor.getItems();
  36996. } else if (arguments.length === 3) {
  36997. var min$1 = arguments[0];
  36998. var max$1 = arguments[1];
  36999. var visitor$1 = arguments[2];
  37000. this._index.query(min$1, max$1, visitor$1);
  37001. }
  37002. };
  37003. IntervalIndexedGeometry.prototype.interfaces_ = function interfaces_160() {
  37004. return [];
  37005. };
  37006. IntervalIndexedGeometry.prototype.getClass = function getClass159() {
  37007. return IntervalIndexedGeometry;
  37008. };
  37009. var GeometryGraph = function(PlanarGraph$$1) {
  37010. function GeometryGraph2() {
  37011. PlanarGraph$$1.call(this);
  37012. this._parentGeom = null;
  37013. this._lineEdgeMap = new HashMap();
  37014. this._boundaryNodeRule = null;
  37015. this._useBoundaryDeterminationRule = true;
  37016. this._argIndex = null;
  37017. this._boundaryNodes = null;
  37018. this._hasTooFewPoints = false;
  37019. this._invalidPoint = null;
  37020. this._areaPtLocator = null;
  37021. this._ptLocator = new PointLocator();
  37022. if (arguments.length === 2) {
  37023. var argIndex = arguments[0];
  37024. var parentGeom = arguments[1];
  37025. var boundaryNodeRule = BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
  37026. this._argIndex = argIndex;
  37027. this._parentGeom = parentGeom;
  37028. this._boundaryNodeRule = boundaryNodeRule;
  37029. if (parentGeom !== null) {
  37030. this.add(parentGeom);
  37031. }
  37032. } else if (arguments.length === 3) {
  37033. var argIndex$1 = arguments[0];
  37034. var parentGeom$1 = arguments[1];
  37035. var boundaryNodeRule$1 = arguments[2];
  37036. this._argIndex = argIndex$1;
  37037. this._parentGeom = parentGeom$1;
  37038. this._boundaryNodeRule = boundaryNodeRule$1;
  37039. if (parentGeom$1 !== null) {
  37040. this.add(parentGeom$1);
  37041. }
  37042. }
  37043. }
  37044. if (PlanarGraph$$1)
  37045. GeometryGraph2.__proto__ = PlanarGraph$$1;
  37046. GeometryGraph2.prototype = Object.create(PlanarGraph$$1 && PlanarGraph$$1.prototype);
  37047. GeometryGraph2.prototype.constructor = GeometryGraph2;
  37048. GeometryGraph2.prototype.insertBoundaryPoint = function insertBoundaryPoint(argIndex, coord) {
  37049. var n = this._nodes.addNode(coord);
  37050. var lbl = n.getLabel();
  37051. var boundaryCount = 1;
  37052. var loc = Location.NONE;
  37053. loc = lbl.getLocation(argIndex, Position.ON);
  37054. if (loc === Location.BOUNDARY) {
  37055. boundaryCount++;
  37056. }
  37057. var newLoc = GeometryGraph2.determineBoundary(this._boundaryNodeRule, boundaryCount);
  37058. lbl.setLocation(argIndex, newLoc);
  37059. };
  37060. GeometryGraph2.prototype.computeSelfNodes = function computeSelfNodes() {
  37061. if (arguments.length === 2) {
  37062. var li = arguments[0];
  37063. var computeRingSelfNodes = arguments[1];
  37064. return this.computeSelfNodes(li, computeRingSelfNodes, false);
  37065. } else if (arguments.length === 3) {
  37066. var li$1 = arguments[0];
  37067. var computeRingSelfNodes$1 = arguments[1];
  37068. var isDoneIfProperInt = arguments[2];
  37069. var si = new SegmentIntersector$2(li$1, true, false);
  37070. si.setIsDoneIfProperInt(isDoneIfProperInt);
  37071. var esi = this.createEdgeSetIntersector();
  37072. var isRings = this._parentGeom instanceof LinearRing || this._parentGeom instanceof Polygon || this._parentGeom instanceof MultiPolygon;
  37073. var computeAllSegments = computeRingSelfNodes$1 || !isRings;
  37074. esi.computeIntersections(this._edges, si, computeAllSegments);
  37075. this.addSelfIntersectionNodes(this._argIndex);
  37076. return si;
  37077. }
  37078. };
  37079. GeometryGraph2.prototype.computeSplitEdges = function computeSplitEdges(edgelist) {
  37080. for (var i = this._edges.iterator(); i.hasNext(); ) {
  37081. var e = i.next();
  37082. e.eiList.addSplitEdges(edgelist);
  37083. }
  37084. };
  37085. GeometryGraph2.prototype.computeEdgeIntersections = function computeEdgeIntersections(g, li, includeProper) {
  37086. var si = new SegmentIntersector$2(li, includeProper, true);
  37087. si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());
  37088. var esi = this.createEdgeSetIntersector();
  37089. esi.computeIntersections(this._edges, g._edges, si);
  37090. return si;
  37091. };
  37092. GeometryGraph2.prototype.getGeometry = function getGeometry3() {
  37093. return this._parentGeom;
  37094. };
  37095. GeometryGraph2.prototype.getBoundaryNodeRule = function getBoundaryNodeRule() {
  37096. return this._boundaryNodeRule;
  37097. };
  37098. GeometryGraph2.prototype.hasTooFewPoints = function hasTooFewPoints() {
  37099. return this._hasTooFewPoints;
  37100. };
  37101. GeometryGraph2.prototype.addPoint = function addPoint2() {
  37102. if (arguments[0] instanceof Point) {
  37103. var p = arguments[0];
  37104. var coord = p.getCoordinate();
  37105. this.insertPoint(this._argIndex, coord, Location.INTERIOR);
  37106. } else if (arguments[0] instanceof Coordinate) {
  37107. var pt = arguments[0];
  37108. this.insertPoint(this._argIndex, pt, Location.INTERIOR);
  37109. }
  37110. };
  37111. GeometryGraph2.prototype.addPolygon = function addPolygon2(p) {
  37112. var this$1 = this;
  37113. this.addPolygonRing(p.getExteriorRing(), Location.EXTERIOR, Location.INTERIOR);
  37114. for (var i = 0; i < p.getNumInteriorRing(); i++) {
  37115. var hole = p.getInteriorRingN(i);
  37116. this$1.addPolygonRing(hole, Location.INTERIOR, Location.EXTERIOR);
  37117. }
  37118. };
  37119. GeometryGraph2.prototype.addEdge = function addEdge(e) {
  37120. this.insertEdge(e);
  37121. var coord = e.getCoordinates();
  37122. this.insertPoint(this._argIndex, coord[0], Location.BOUNDARY);
  37123. this.insertPoint(this._argIndex, coord[coord.length - 1], Location.BOUNDARY);
  37124. };
  37125. GeometryGraph2.prototype.addLineString = function addLineString2(line) {
  37126. var coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
  37127. if (coord.length < 2) {
  37128. this._hasTooFewPoints = true;
  37129. this._invalidPoint = coord[0];
  37130. return null;
  37131. }
  37132. var e = new Edge2(coord, new Label(this._argIndex, Location.INTERIOR));
  37133. this._lineEdgeMap.put(line, e);
  37134. this.insertEdge(e);
  37135. Assert.isTrue(coord.length >= 2, "found LineString with single point");
  37136. this.insertBoundaryPoint(this._argIndex, coord[0]);
  37137. this.insertBoundaryPoint(this._argIndex, coord[coord.length - 1]);
  37138. };
  37139. GeometryGraph2.prototype.getInvalidPoint = function getInvalidPoint() {
  37140. return this._invalidPoint;
  37141. };
  37142. GeometryGraph2.prototype.getBoundaryPoints = function getBoundaryPoints() {
  37143. var coll = this.getBoundaryNodes();
  37144. var pts = new Array(coll.size()).fill(null);
  37145. var i = 0;
  37146. for (var it = coll.iterator(); it.hasNext(); ) {
  37147. var node = it.next();
  37148. pts[i++] = node.getCoordinate().copy();
  37149. }
  37150. return pts;
  37151. };
  37152. GeometryGraph2.prototype.getBoundaryNodes = function getBoundaryNodes2() {
  37153. if (this._boundaryNodes === null) {
  37154. this._boundaryNodes = this._nodes.getBoundaryNodes(this._argIndex);
  37155. }
  37156. return this._boundaryNodes;
  37157. };
  37158. GeometryGraph2.prototype.addSelfIntersectionNode = function addSelfIntersectionNode(argIndex, coord, loc) {
  37159. if (this.isBoundaryNode(argIndex, coord)) {
  37160. return null;
  37161. }
  37162. if (loc === Location.BOUNDARY && this._useBoundaryDeterminationRule) {
  37163. this.insertBoundaryPoint(argIndex, coord);
  37164. } else {
  37165. this.insertPoint(argIndex, coord, loc);
  37166. }
  37167. };
  37168. GeometryGraph2.prototype.addPolygonRing = function addPolygonRing2(lr, cwLeft, cwRight) {
  37169. if (lr.isEmpty()) {
  37170. return null;
  37171. }
  37172. var coord = CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());
  37173. if (coord.length < 4) {
  37174. this._hasTooFewPoints = true;
  37175. this._invalidPoint = coord[0];
  37176. return null;
  37177. }
  37178. var left = cwLeft;
  37179. var right = cwRight;
  37180. if (CGAlgorithms.isCCW(coord)) {
  37181. left = cwRight;
  37182. right = cwLeft;
  37183. }
  37184. var e = new Edge2(coord, new Label(this._argIndex, Location.BOUNDARY, left, right));
  37185. this._lineEdgeMap.put(lr, e);
  37186. this.insertEdge(e);
  37187. this.insertPoint(this._argIndex, coord[0], Location.BOUNDARY);
  37188. };
  37189. GeometryGraph2.prototype.insertPoint = function insertPoint(argIndex, coord, onLocation) {
  37190. var n = this._nodes.addNode(coord);
  37191. var lbl = n.getLabel();
  37192. if (lbl === null) {
  37193. n._label = new Label(argIndex, onLocation);
  37194. } else {
  37195. lbl.setLocation(argIndex, onLocation);
  37196. }
  37197. };
  37198. GeometryGraph2.prototype.createEdgeSetIntersector = function createEdgeSetIntersector() {
  37199. return new SimpleMCSweepLineIntersector();
  37200. };
  37201. GeometryGraph2.prototype.addSelfIntersectionNodes = function addSelfIntersectionNodes(argIndex) {
  37202. var this$1 = this;
  37203. for (var i = this._edges.iterator(); i.hasNext(); ) {
  37204. var e = i.next();
  37205. var eLoc = e.getLabel().getLocation(argIndex);
  37206. for (var eiIt = e.eiList.iterator(); eiIt.hasNext(); ) {
  37207. var ei = eiIt.next();
  37208. this$1.addSelfIntersectionNode(argIndex, ei.coord, eLoc);
  37209. }
  37210. }
  37211. };
  37212. GeometryGraph2.prototype.add = function add17() {
  37213. if (arguments.length === 1) {
  37214. var g = arguments[0];
  37215. if (g.isEmpty()) {
  37216. return null;
  37217. }
  37218. if (g instanceof MultiPolygon) {
  37219. this._useBoundaryDeterminationRule = false;
  37220. }
  37221. if (g instanceof Polygon) {
  37222. this.addPolygon(g);
  37223. } else if (g instanceof LineString2) {
  37224. this.addLineString(g);
  37225. } else if (g instanceof Point) {
  37226. this.addPoint(g);
  37227. } else if (g instanceof MultiPoint) {
  37228. this.addCollection(g);
  37229. } else if (g instanceof MultiLineString) {
  37230. this.addCollection(g);
  37231. } else if (g instanceof MultiPolygon) {
  37232. this.addCollection(g);
  37233. } else if (g instanceof GeometryCollection) {
  37234. this.addCollection(g);
  37235. } else {
  37236. throw new Error(g.getClass().getName());
  37237. }
  37238. } else {
  37239. return PlanarGraph$$1.prototype.add.apply(this, arguments);
  37240. }
  37241. };
  37242. GeometryGraph2.prototype.addCollection = function addCollection2(gc) {
  37243. var this$1 = this;
  37244. for (var i = 0; i < gc.getNumGeometries(); i++) {
  37245. var g = gc.getGeometryN(i);
  37246. this$1.add(g);
  37247. }
  37248. };
  37249. GeometryGraph2.prototype.locate = function locate6(pt) {
  37250. if (hasInterface(this._parentGeom, Polygonal) && this._parentGeom.getNumGeometries() > 50) {
  37251. if (this._areaPtLocator === null) {
  37252. this._areaPtLocator = new IndexedPointInAreaLocator(this._parentGeom);
  37253. }
  37254. return this._areaPtLocator.locate(pt);
  37255. }
  37256. return this._ptLocator.locate(pt, this._parentGeom);
  37257. };
  37258. GeometryGraph2.prototype.findEdge = function findEdge3() {
  37259. if (arguments.length === 1) {
  37260. var line = arguments[0];
  37261. return this._lineEdgeMap.get(line);
  37262. } else {
  37263. return PlanarGraph$$1.prototype.findEdge.apply(this, arguments);
  37264. }
  37265. };
  37266. GeometryGraph2.prototype.interfaces_ = function interfaces_170() {
  37267. return [];
  37268. };
  37269. GeometryGraph2.prototype.getClass = function getClass169() {
  37270. return GeometryGraph2;
  37271. };
  37272. GeometryGraph2.determineBoundary = function determineBoundary(boundaryNodeRule, boundaryCount) {
  37273. return boundaryNodeRule.isInBoundary(boundaryCount) ? Location.BOUNDARY : Location.INTERIOR;
  37274. };
  37275. return GeometryGraph2;
  37276. }(PlanarGraph);
  37277. var GeometryGraphOp = function GeometryGraphOp2() {
  37278. this._li = new RobustLineIntersector();
  37279. this._resultPrecisionModel = null;
  37280. this._arg = null;
  37281. if (arguments.length === 1) {
  37282. var g0 = arguments[0];
  37283. this.setComputationPrecision(g0.getPrecisionModel());
  37284. this._arg = new Array(1).fill(null);
  37285. this._arg[0] = new GeometryGraph(0, g0);
  37286. } else if (arguments.length === 2) {
  37287. var g0$1 = arguments[0];
  37288. var g1 = arguments[1];
  37289. var boundaryNodeRule = BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
  37290. if (g0$1.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0) {
  37291. this.setComputationPrecision(g0$1.getPrecisionModel());
  37292. } else {
  37293. this.setComputationPrecision(g1.getPrecisionModel());
  37294. }
  37295. this._arg = new Array(2).fill(null);
  37296. this._arg[0] = new GeometryGraph(0, g0$1, boundaryNodeRule);
  37297. this._arg[1] = new GeometryGraph(1, g1, boundaryNodeRule);
  37298. } else if (arguments.length === 3) {
  37299. var g0$2 = arguments[0];
  37300. var g1$1 = arguments[1];
  37301. var boundaryNodeRule$1 = arguments[2];
  37302. if (g0$2.getPrecisionModel().compareTo(g1$1.getPrecisionModel()) >= 0) {
  37303. this.setComputationPrecision(g0$2.getPrecisionModel());
  37304. } else {
  37305. this.setComputationPrecision(g1$1.getPrecisionModel());
  37306. }
  37307. this._arg = new Array(2).fill(null);
  37308. this._arg[0] = new GeometryGraph(0, g0$2, boundaryNodeRule$1);
  37309. this._arg[1] = new GeometryGraph(1, g1$1, boundaryNodeRule$1);
  37310. }
  37311. };
  37312. GeometryGraphOp.prototype.getArgGeometry = function getArgGeometry(i) {
  37313. return this._arg[i].getGeometry();
  37314. };
  37315. GeometryGraphOp.prototype.setComputationPrecision = function setComputationPrecision(pm) {
  37316. this._resultPrecisionModel = pm;
  37317. this._li.setPrecisionModel(this._resultPrecisionModel);
  37318. };
  37319. GeometryGraphOp.prototype.interfaces_ = function interfaces_161() {
  37320. return [];
  37321. };
  37322. GeometryGraphOp.prototype.getClass = function getClass160() {
  37323. return GeometryGraphOp;
  37324. };
  37325. var GeometryMapper = function GeometryMapper2() {
  37326. };
  37327. GeometryMapper.prototype.interfaces_ = function interfaces_162() {
  37328. return [];
  37329. };
  37330. GeometryMapper.prototype.getClass = function getClass161() {
  37331. return GeometryMapper;
  37332. };
  37333. GeometryMapper.map = function map3() {
  37334. if (arguments[0] instanceof Geometry && hasInterface(arguments[1], GeometryMapper.MapOp)) {
  37335. var geom = arguments[0];
  37336. var op = arguments[1];
  37337. var mapped = new ArrayList();
  37338. for (var i = 0; i < geom.getNumGeometries(); i++) {
  37339. var g = op.map(geom.getGeometryN(i));
  37340. if (g !== null) {
  37341. mapped.add(g);
  37342. }
  37343. }
  37344. return geom.getFactory().buildGeometry(mapped);
  37345. } else if (hasInterface(arguments[0], Collection) && hasInterface(arguments[1], GeometryMapper.MapOp)) {
  37346. var geoms = arguments[0];
  37347. var op$1 = arguments[1];
  37348. var mapped$1 = new ArrayList();
  37349. for (var i$1 = geoms.iterator(); i$1.hasNext(); ) {
  37350. var g$1 = i$1.next();
  37351. var gr = op$1.map(g$1);
  37352. if (gr !== null) {
  37353. mapped$1.add(gr);
  37354. }
  37355. }
  37356. return mapped$1;
  37357. }
  37358. };
  37359. GeometryMapper.MapOp = function MapOp() {
  37360. };
  37361. var OverlayOp = function(GeometryGraphOp3) {
  37362. function OverlayOp2() {
  37363. var g0 = arguments[0];
  37364. var g1 = arguments[1];
  37365. GeometryGraphOp3.call(this, g0, g1);
  37366. this._ptLocator = new PointLocator();
  37367. this._geomFact = null;
  37368. this._resultGeom = null;
  37369. this._graph = null;
  37370. this._edgeList = new EdgeList();
  37371. this._resultPolyList = new ArrayList();
  37372. this._resultLineList = new ArrayList();
  37373. this._resultPointList = new ArrayList();
  37374. this._graph = new PlanarGraph(new OverlayNodeFactory());
  37375. this._geomFact = g0.getFactory();
  37376. }
  37377. if (GeometryGraphOp3)
  37378. OverlayOp2.__proto__ = GeometryGraphOp3;
  37379. OverlayOp2.prototype = Object.create(GeometryGraphOp3 && GeometryGraphOp3.prototype);
  37380. OverlayOp2.prototype.constructor = OverlayOp2;
  37381. OverlayOp2.prototype.insertUniqueEdge = function insertUniqueEdge2(e) {
  37382. var existingEdge = this._edgeList.findEqualEdge(e);
  37383. if (existingEdge !== null) {
  37384. var existingLabel = existingEdge.getLabel();
  37385. var labelToMerge = e.getLabel();
  37386. if (!existingEdge.isPointwiseEqual(e)) {
  37387. labelToMerge = new Label(e.getLabel());
  37388. labelToMerge.flip();
  37389. }
  37390. var depth2 = existingEdge.getDepth();
  37391. if (depth2.isNull()) {
  37392. depth2.add(existingLabel);
  37393. }
  37394. depth2.add(labelToMerge);
  37395. existingLabel.merge(labelToMerge);
  37396. } else {
  37397. this._edgeList.add(e);
  37398. }
  37399. };
  37400. OverlayOp2.prototype.getGraph = function getGraph() {
  37401. return this._graph;
  37402. };
  37403. OverlayOp2.prototype.cancelDuplicateResultEdges = function cancelDuplicateResultEdges() {
  37404. for (var it = this._graph.getEdgeEnds().iterator(); it.hasNext(); ) {
  37405. var de = it.next();
  37406. var sym = de.getSym();
  37407. if (de.isInResult() && sym.isInResult()) {
  37408. de.setInResult(false);
  37409. sym.setInResult(false);
  37410. }
  37411. }
  37412. };
  37413. OverlayOp2.prototype.isCoveredByLA = function isCoveredByLA(coord) {
  37414. if (this.isCovered(coord, this._resultLineList)) {
  37415. return true;
  37416. }
  37417. if (this.isCovered(coord, this._resultPolyList)) {
  37418. return true;
  37419. }
  37420. return false;
  37421. };
  37422. OverlayOp2.prototype.computeGeometry = function computeGeometry2(resultPointList, resultLineList, resultPolyList, opcode) {
  37423. var geomList = new ArrayList();
  37424. geomList.addAll(resultPointList);
  37425. geomList.addAll(resultLineList);
  37426. geomList.addAll(resultPolyList);
  37427. if (geomList.isEmpty()) {
  37428. return OverlayOp2.createEmptyResult(opcode, this._arg[0].getGeometry(), this._arg[1].getGeometry(), this._geomFact);
  37429. }
  37430. return this._geomFact.buildGeometry(geomList);
  37431. };
  37432. OverlayOp2.prototype.mergeSymLabels = function mergeSymLabels() {
  37433. for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext(); ) {
  37434. var node = nodeit.next();
  37435. node.getEdges().mergeSymLabels();
  37436. }
  37437. };
  37438. OverlayOp2.prototype.isCovered = function isCovered2(coord, geomList) {
  37439. var this$1 = this;
  37440. for (var it = geomList.iterator(); it.hasNext(); ) {
  37441. var geom = it.next();
  37442. var loc = this$1._ptLocator.locate(coord, geom);
  37443. if (loc !== Location.EXTERIOR) {
  37444. return true;
  37445. }
  37446. }
  37447. return false;
  37448. };
  37449. OverlayOp2.prototype.replaceCollapsedEdges = function replaceCollapsedEdges() {
  37450. var newEdges = new ArrayList();
  37451. for (var it = this._edgeList.iterator(); it.hasNext(); ) {
  37452. var e = it.next();
  37453. if (e.isCollapsed()) {
  37454. it.remove();
  37455. newEdges.add(e.getCollapsedEdge());
  37456. }
  37457. }
  37458. this._edgeList.addAll(newEdges);
  37459. };
  37460. OverlayOp2.prototype.updateNodeLabelling = function updateNodeLabelling() {
  37461. for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext(); ) {
  37462. var node = nodeit.next();
  37463. var lbl = node.getEdges().getLabel();
  37464. node.getLabel().merge(lbl);
  37465. }
  37466. };
  37467. OverlayOp2.prototype.getResultGeometry = function getResultGeometry4(overlayOpCode) {
  37468. this.computeOverlay(overlayOpCode);
  37469. return this._resultGeom;
  37470. };
  37471. OverlayOp2.prototype.insertUniqueEdges = function insertUniqueEdges(edges2) {
  37472. var this$1 = this;
  37473. for (var i = edges2.iterator(); i.hasNext(); ) {
  37474. var e = i.next();
  37475. this$1.insertUniqueEdge(e);
  37476. }
  37477. };
  37478. OverlayOp2.prototype.computeOverlay = function computeOverlay(opCode) {
  37479. this.copyPoints(0);
  37480. this.copyPoints(1);
  37481. this._arg[0].computeSelfNodes(this._li, false);
  37482. this._arg[1].computeSelfNodes(this._li, false);
  37483. this._arg[0].computeEdgeIntersections(this._arg[1], this._li, true);
  37484. var baseSplitEdges = new ArrayList();
  37485. this._arg[0].computeSplitEdges(baseSplitEdges);
  37486. this._arg[1].computeSplitEdges(baseSplitEdges);
  37487. this.insertUniqueEdges(baseSplitEdges);
  37488. this.computeLabelsFromDepths();
  37489. this.replaceCollapsedEdges();
  37490. EdgeNodingValidator.checkValid(this._edgeList.getEdges());
  37491. this._graph.addEdges(this._edgeList.getEdges());
  37492. this.computeLabelling();
  37493. this.labelIncompleteNodes();
  37494. this.findResultAreaEdges(opCode);
  37495. this.cancelDuplicateResultEdges();
  37496. var polyBuilder = new PolygonBuilder(this._geomFact);
  37497. polyBuilder.add(this._graph);
  37498. this._resultPolyList = polyBuilder.getPolygons();
  37499. var lineBuilder = new LineBuilder(this, this._geomFact, this._ptLocator);
  37500. this._resultLineList = lineBuilder.build(opCode);
  37501. var pointBuilder = new PointBuilder(this, this._geomFact, this._ptLocator);
  37502. this._resultPointList = pointBuilder.build(opCode);
  37503. this._resultGeom = this.computeGeometry(this._resultPointList, this._resultLineList, this._resultPolyList, opCode);
  37504. };
  37505. OverlayOp2.prototype.labelIncompleteNode = function labelIncompleteNode(n, targetIndex) {
  37506. var loc = this._ptLocator.locate(n.getCoordinate(), this._arg[targetIndex].getGeometry());
  37507. n.getLabel().setLocation(targetIndex, loc);
  37508. };
  37509. OverlayOp2.prototype.copyPoints = function copyPoints(argIndex) {
  37510. var this$1 = this;
  37511. for (var i = this._arg[argIndex].getNodeIterator(); i.hasNext(); ) {
  37512. var graphNode = i.next();
  37513. var newNode = this$1._graph.addNode(graphNode.getCoordinate());
  37514. newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
  37515. }
  37516. };
  37517. OverlayOp2.prototype.findResultAreaEdges = function findResultAreaEdges(opCode) {
  37518. for (var it = this._graph.getEdgeEnds().iterator(); it.hasNext(); ) {
  37519. var de = it.next();
  37520. var label = de.getLabel();
  37521. if (label.isArea() && !de.isInteriorAreaEdge() && OverlayOp2.isResultOfOp(label.getLocation(0, Position.RIGHT), label.getLocation(1, Position.RIGHT), opCode)) {
  37522. de.setInResult(true);
  37523. }
  37524. }
  37525. };
  37526. OverlayOp2.prototype.computeLabelsFromDepths = function computeLabelsFromDepths() {
  37527. for (var it = this._edgeList.iterator(); it.hasNext(); ) {
  37528. var e = it.next();
  37529. var lbl = e.getLabel();
  37530. var depth2 = e.getDepth();
  37531. if (!depth2.isNull()) {
  37532. depth2.normalize();
  37533. for (var i = 0; i < 2; i++) {
  37534. if (!lbl.isNull(i) && lbl.isArea() && !depth2.isNull(i)) {
  37535. if (depth2.getDelta(i) === 0) {
  37536. lbl.toLine(i);
  37537. } else {
  37538. Assert.isTrue(!depth2.isNull(i, Position.LEFT), "depth of LEFT side has not been initialized");
  37539. lbl.setLocation(i, Position.LEFT, depth2.getLocation(i, Position.LEFT));
  37540. Assert.isTrue(!depth2.isNull(i, Position.RIGHT), "depth of RIGHT side has not been initialized");
  37541. lbl.setLocation(i, Position.RIGHT, depth2.getLocation(i, Position.RIGHT));
  37542. }
  37543. }
  37544. }
  37545. }
  37546. }
  37547. };
  37548. OverlayOp2.prototype.computeLabelling = function computeLabelling2() {
  37549. var this$1 = this;
  37550. for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext(); ) {
  37551. var node = nodeit.next();
  37552. node.getEdges().computeLabelling(this$1._arg);
  37553. }
  37554. this.mergeSymLabels();
  37555. this.updateNodeLabelling();
  37556. };
  37557. OverlayOp2.prototype.labelIncompleteNodes = function labelIncompleteNodes() {
  37558. var this$1 = this;
  37559. for (var ni = this._graph.getNodes().iterator(); ni.hasNext(); ) {
  37560. var n = ni.next();
  37561. var label = n.getLabel();
  37562. if (n.isIsolated()) {
  37563. if (label.isNull(0)) {
  37564. this$1.labelIncompleteNode(n, 0);
  37565. } else {
  37566. this$1.labelIncompleteNode(n, 1);
  37567. }
  37568. }
  37569. n.getEdges().updateLabelling(label);
  37570. }
  37571. };
  37572. OverlayOp2.prototype.isCoveredByA = function isCoveredByA(coord) {
  37573. if (this.isCovered(coord, this._resultPolyList)) {
  37574. return true;
  37575. }
  37576. return false;
  37577. };
  37578. OverlayOp2.prototype.interfaces_ = function interfaces_170() {
  37579. return [];
  37580. };
  37581. OverlayOp2.prototype.getClass = function getClass169() {
  37582. return OverlayOp2;
  37583. };
  37584. return OverlayOp2;
  37585. }(GeometryGraphOp);
  37586. OverlayOp.overlayOp = function(geom0, geom1, opCode) {
  37587. var gov = new OverlayOp(geom0, geom1);
  37588. var geomOv = gov.getResultGeometry(opCode);
  37589. return geomOv;
  37590. };
  37591. OverlayOp.intersection = function(g, other) {
  37592. if (g.isEmpty() || other.isEmpty()) {
  37593. return OverlayOp.createEmptyResult(OverlayOp.INTERSECTION, g, other, g.getFactory());
  37594. }
  37595. if (g.isGeometryCollection()) {
  37596. var g2 = other;
  37597. return GeometryCollectionMapper.map(g, {
  37598. interfaces_: function() {
  37599. return [GeometryMapper.MapOp];
  37600. },
  37601. map: function(g3) {
  37602. return g3.intersection(g2);
  37603. }
  37604. });
  37605. }
  37606. g.checkNotGeometryCollection(g);
  37607. g.checkNotGeometryCollection(other);
  37608. return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.INTERSECTION);
  37609. };
  37610. OverlayOp.symDifference = function(g, other) {
  37611. if (g.isEmpty() || other.isEmpty()) {
  37612. if (g.isEmpty() && other.isEmpty()) {
  37613. return OverlayOp.createEmptyResult(OverlayOp.SYMDIFFERENCE, g, other, g.getFactory());
  37614. }
  37615. if (g.isEmpty()) {
  37616. return other.copy();
  37617. }
  37618. if (other.isEmpty()) {
  37619. return g.copy();
  37620. }
  37621. }
  37622. g.checkNotGeometryCollection(g);
  37623. g.checkNotGeometryCollection(other);
  37624. return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.SYMDIFFERENCE);
  37625. };
  37626. OverlayOp.resultDimension = function(opCode, g0, g1) {
  37627. var dim0 = g0.getDimension();
  37628. var dim1 = g1.getDimension();
  37629. var resultDimension = -1;
  37630. switch (opCode) {
  37631. case OverlayOp.INTERSECTION:
  37632. resultDimension = Math.min(dim0, dim1);
  37633. break;
  37634. case OverlayOp.UNION:
  37635. resultDimension = Math.max(dim0, dim1);
  37636. break;
  37637. case OverlayOp.DIFFERENCE:
  37638. resultDimension = dim0;
  37639. break;
  37640. case OverlayOp.SYMDIFFERENCE:
  37641. resultDimension = Math.max(dim0, dim1);
  37642. break;
  37643. default:
  37644. }
  37645. return resultDimension;
  37646. };
  37647. OverlayOp.createEmptyResult = function(overlayOpCode, a, b, geomFact) {
  37648. var result = null;
  37649. switch (OverlayOp.resultDimension(overlayOpCode, a, b)) {
  37650. case -1:
  37651. result = geomFact.createGeometryCollection(new Array(0).fill(null));
  37652. break;
  37653. case 0:
  37654. result = geomFact.createPoint();
  37655. break;
  37656. case 1:
  37657. result = geomFact.createLineString();
  37658. break;
  37659. case 2:
  37660. result = geomFact.createPolygon();
  37661. break;
  37662. default:
  37663. }
  37664. return result;
  37665. };
  37666. OverlayOp.difference = function(g, other) {
  37667. if (g.isEmpty()) {
  37668. return OverlayOp.createEmptyResult(OverlayOp.DIFFERENCE, g, other, g.getFactory());
  37669. }
  37670. if (other.isEmpty()) {
  37671. return g.copy();
  37672. }
  37673. g.checkNotGeometryCollection(g);
  37674. g.checkNotGeometryCollection(other);
  37675. return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.DIFFERENCE);
  37676. };
  37677. OverlayOp.isResultOfOp = function() {
  37678. if (arguments.length === 2) {
  37679. var label = arguments[0];
  37680. var opCode = arguments[1];
  37681. var loc0 = label.getLocation(0);
  37682. var loc1 = label.getLocation(1);
  37683. return OverlayOp.isResultOfOp(loc0, loc1, opCode);
  37684. } else if (arguments.length === 3) {
  37685. var loc0$1 = arguments[0];
  37686. var loc1$1 = arguments[1];
  37687. var overlayOpCode = arguments[2];
  37688. if (loc0$1 === Location.BOUNDARY) {
  37689. loc0$1 = Location.INTERIOR;
  37690. }
  37691. if (loc1$1 === Location.BOUNDARY) {
  37692. loc1$1 = Location.INTERIOR;
  37693. }
  37694. switch (overlayOpCode) {
  37695. case OverlayOp.INTERSECTION:
  37696. return loc0$1 === Location.INTERIOR && loc1$1 === Location.INTERIOR;
  37697. case OverlayOp.UNION:
  37698. return loc0$1 === Location.INTERIOR || loc1$1 === Location.INTERIOR;
  37699. case OverlayOp.DIFFERENCE:
  37700. return loc0$1 === Location.INTERIOR && loc1$1 !== Location.INTERIOR;
  37701. case OverlayOp.SYMDIFFERENCE:
  37702. return loc0$1 === Location.INTERIOR && loc1$1 !== Location.INTERIOR || loc0$1 !== Location.INTERIOR && loc1$1 === Location.INTERIOR;
  37703. default:
  37704. }
  37705. return false;
  37706. }
  37707. };
  37708. OverlayOp.INTERSECTION = 1;
  37709. OverlayOp.UNION = 2;
  37710. OverlayOp.DIFFERENCE = 3;
  37711. OverlayOp.SYMDIFFERENCE = 4;
  37712. var FuzzyPointLocator = function FuzzyPointLocator2() {
  37713. this._g = null;
  37714. this._boundaryDistanceTolerance = null;
  37715. this._linework = null;
  37716. this._ptLocator = new PointLocator();
  37717. this._seg = new LineSegment();
  37718. var g = arguments[0];
  37719. var boundaryDistanceTolerance = arguments[1];
  37720. this._g = g;
  37721. this._boundaryDistanceTolerance = boundaryDistanceTolerance;
  37722. this._linework = this.extractLinework(g);
  37723. };
  37724. FuzzyPointLocator.prototype.isWithinToleranceOfBoundary = function isWithinToleranceOfBoundary(pt) {
  37725. var this$1 = this;
  37726. for (var i = 0; i < this._linework.getNumGeometries(); i++) {
  37727. var line = this$1._linework.getGeometryN(i);
  37728. var seq = line.getCoordinateSequence();
  37729. for (var j = 0; j < seq.size() - 1; j++) {
  37730. seq.getCoordinate(j, this$1._seg.p0);
  37731. seq.getCoordinate(j + 1, this$1._seg.p1);
  37732. var dist = this$1._seg.distance(pt);
  37733. if (dist <= this$1._boundaryDistanceTolerance) {
  37734. return true;
  37735. }
  37736. }
  37737. }
  37738. return false;
  37739. };
  37740. FuzzyPointLocator.prototype.getLocation = function getLocation5(pt) {
  37741. if (this.isWithinToleranceOfBoundary(pt)) {
  37742. return Location.BOUNDARY;
  37743. }
  37744. return this._ptLocator.locate(pt, this._g);
  37745. };
  37746. FuzzyPointLocator.prototype.extractLinework = function extractLinework(g) {
  37747. var extracter = new PolygonalLineworkExtracter();
  37748. g.apply(extracter);
  37749. var linework = extracter.getLinework();
  37750. var lines = GeometryFactory.toLineStringArray(linework);
  37751. return g.getFactory().createMultiLineString(lines);
  37752. };
  37753. FuzzyPointLocator.prototype.interfaces_ = function interfaces_163() {
  37754. return [];
  37755. };
  37756. FuzzyPointLocator.prototype.getClass = function getClass162() {
  37757. return FuzzyPointLocator;
  37758. };
  37759. var PolygonalLineworkExtracter = function PolygonalLineworkExtracter2() {
  37760. this._linework = null;
  37761. this._linework = new ArrayList();
  37762. };
  37763. PolygonalLineworkExtracter.prototype.getLinework = function getLinework() {
  37764. return this._linework;
  37765. };
  37766. PolygonalLineworkExtracter.prototype.filter = function filter16(g) {
  37767. var this$1 = this;
  37768. if (g instanceof Polygon) {
  37769. var poly = g;
  37770. this._linework.add(poly.getExteriorRing());
  37771. for (var i = 0; i < poly.getNumInteriorRing(); i++) {
  37772. this$1._linework.add(poly.getInteriorRingN(i));
  37773. }
  37774. }
  37775. };
  37776. PolygonalLineworkExtracter.prototype.interfaces_ = function interfaces_164() {
  37777. return [GeometryFilter];
  37778. };
  37779. PolygonalLineworkExtracter.prototype.getClass = function getClass163() {
  37780. return PolygonalLineworkExtracter;
  37781. };
  37782. var OffsetPointGenerator = function OffsetPointGenerator2() {
  37783. this._g = null;
  37784. this._doLeft = true;
  37785. this._doRight = true;
  37786. var g = arguments[0];
  37787. this._g = g;
  37788. };
  37789. OffsetPointGenerator.prototype.extractPoints = function extractPoints(line, offsetDistance, offsetPts) {
  37790. var this$1 = this;
  37791. var pts = line.getCoordinates();
  37792. for (var i = 0; i < pts.length - 1; i++) {
  37793. this$1.computeOffsetPoints(pts[i], pts[i + 1], offsetDistance, offsetPts);
  37794. }
  37795. };
  37796. OffsetPointGenerator.prototype.setSidesToGenerate = function setSidesToGenerate(doLeft, doRight) {
  37797. this._doLeft = doLeft;
  37798. this._doRight = doRight;
  37799. };
  37800. OffsetPointGenerator.prototype.getPoints = function getPoints2(offsetDistance) {
  37801. var this$1 = this;
  37802. var offsetPts = new ArrayList();
  37803. var lines = LinearComponentExtracter.getLines(this._g);
  37804. for (var i = lines.iterator(); i.hasNext(); ) {
  37805. var line = i.next();
  37806. this$1.extractPoints(line, offsetDistance, offsetPts);
  37807. }
  37808. return offsetPts;
  37809. };
  37810. OffsetPointGenerator.prototype.computeOffsetPoints = function computeOffsetPoints(p0, p1, offsetDistance, offsetPts) {
  37811. var dx = p1.x - p0.x;
  37812. var dy = p1.y - p0.y;
  37813. var len = Math.sqrt(dx * dx + dy * dy);
  37814. var ux = offsetDistance * dx / len;
  37815. var uy = offsetDistance * dy / len;
  37816. var midX = (p1.x + p0.x) / 2;
  37817. var midY = (p1.y + p0.y) / 2;
  37818. if (this._doLeft) {
  37819. var offsetLeft = new Coordinate(midX - uy, midY + ux);
  37820. offsetPts.add(offsetLeft);
  37821. }
  37822. if (this._doRight) {
  37823. var offsetRight = new Coordinate(midX + uy, midY - ux);
  37824. offsetPts.add(offsetRight);
  37825. }
  37826. };
  37827. OffsetPointGenerator.prototype.interfaces_ = function interfaces_165() {
  37828. return [];
  37829. };
  37830. OffsetPointGenerator.prototype.getClass = function getClass164() {
  37831. return OffsetPointGenerator;
  37832. };
  37833. var OverlayResultValidator = function OverlayResultValidator2() {
  37834. this._geom = null;
  37835. this._locFinder = null;
  37836. this._location = new Array(3).fill(null);
  37837. this._invalidLocation = null;
  37838. this._boundaryDistanceTolerance = OverlayResultValidator2.TOLERANCE;
  37839. this._testCoords = new ArrayList();
  37840. var a = arguments[0];
  37841. var b = arguments[1];
  37842. var result = arguments[2];
  37843. this._boundaryDistanceTolerance = OverlayResultValidator2.computeBoundaryDistanceTolerance(a, b);
  37844. this._geom = [a, b, result];
  37845. this._locFinder = [new FuzzyPointLocator(this._geom[0], this._boundaryDistanceTolerance), new FuzzyPointLocator(this._geom[1], this._boundaryDistanceTolerance), new FuzzyPointLocator(this._geom[2], this._boundaryDistanceTolerance)];
  37846. };
  37847. var staticAccessors$46 = { TOLERANCE: { configurable: true } };
  37848. OverlayResultValidator.prototype.reportResult = function reportResult(overlayOp3, location, expectedInterior) {
  37849. System.out.println("Overlay result invalid - A:" + Location.toLocationSymbol(location[0]) + " B:" + Location.toLocationSymbol(location[1]) + " expected:" + (expectedInterior ? "i" : "e") + " actual:" + Location.toLocationSymbol(location[2]));
  37850. };
  37851. OverlayResultValidator.prototype.isValid = function isValid5(overlayOp3) {
  37852. this.addTestPts(this._geom[0]);
  37853. this.addTestPts(this._geom[1]);
  37854. var isValid7 = this.checkValid(overlayOp3);
  37855. return isValid7;
  37856. };
  37857. OverlayResultValidator.prototype.checkValid = function checkValid6() {
  37858. var this$1 = this;
  37859. if (arguments.length === 1) {
  37860. var overlayOp3 = arguments[0];
  37861. for (var i = 0; i < this._testCoords.size(); i++) {
  37862. var pt = this$1._testCoords.get(i);
  37863. if (!this$1.checkValid(overlayOp3, pt)) {
  37864. this$1._invalidLocation = pt;
  37865. return false;
  37866. }
  37867. }
  37868. return true;
  37869. } else if (arguments.length === 2) {
  37870. var overlayOp$1 = arguments[0];
  37871. var pt$1 = arguments[1];
  37872. this._location[0] = this._locFinder[0].getLocation(pt$1);
  37873. this._location[1] = this._locFinder[1].getLocation(pt$1);
  37874. this._location[2] = this._locFinder[2].getLocation(pt$1);
  37875. if (OverlayResultValidator.hasLocation(this._location, Location.BOUNDARY)) {
  37876. return true;
  37877. }
  37878. return this.isValidResult(overlayOp$1, this._location);
  37879. }
  37880. };
  37881. OverlayResultValidator.prototype.addTestPts = function addTestPts(g) {
  37882. var ptGen = new OffsetPointGenerator(g);
  37883. this._testCoords.addAll(ptGen.getPoints(5 * this._boundaryDistanceTolerance));
  37884. };
  37885. OverlayResultValidator.prototype.isValidResult = function isValidResult(overlayOp3, location) {
  37886. var expectedInterior = OverlayOp.isResultOfOp(location[0], location[1], overlayOp3);
  37887. var resultInInterior = location[2] === Location.INTERIOR;
  37888. var isValid7 = !(expectedInterior ^ resultInInterior);
  37889. if (!isValid7) {
  37890. this.reportResult(overlayOp3, location, expectedInterior);
  37891. }
  37892. return isValid7;
  37893. };
  37894. OverlayResultValidator.prototype.getInvalidLocation = function getInvalidLocation() {
  37895. return this._invalidLocation;
  37896. };
  37897. OverlayResultValidator.prototype.interfaces_ = function interfaces_166() {
  37898. return [];
  37899. };
  37900. OverlayResultValidator.prototype.getClass = function getClass165() {
  37901. return OverlayResultValidator;
  37902. };
  37903. OverlayResultValidator.hasLocation = function hasLocation(location, loc) {
  37904. for (var i = 0; i < 3; i++) {
  37905. if (location[i] === loc) {
  37906. return true;
  37907. }
  37908. }
  37909. return false;
  37910. };
  37911. OverlayResultValidator.computeBoundaryDistanceTolerance = function computeBoundaryDistanceTolerance(g0, g1) {
  37912. return Math.min(GeometrySnapper.computeSizeBasedSnapTolerance(g0), GeometrySnapper.computeSizeBasedSnapTolerance(g1));
  37913. };
  37914. OverlayResultValidator.isValid = function isValid6(a, b, overlayOp3, result) {
  37915. var validator = new OverlayResultValidator(a, b, result);
  37916. return validator.isValid(overlayOp3);
  37917. };
  37918. staticAccessors$46.TOLERANCE.get = function() {
  37919. return 1e-6;
  37920. };
  37921. Object.defineProperties(OverlayResultValidator, staticAccessors$46);
  37922. var GeometryCombiner = function GeometryCombiner2(geoms) {
  37923. this._geomFactory = null;
  37924. this._skipEmpty = false;
  37925. this._inputGeoms = null;
  37926. this._geomFactory = GeometryCombiner2.extractFactory(geoms);
  37927. this._inputGeoms = geoms;
  37928. };
  37929. GeometryCombiner.prototype.extractElements = function extractElements(geom, elems) {
  37930. var this$1 = this;
  37931. if (geom === null) {
  37932. return null;
  37933. }
  37934. for (var i = 0; i < geom.getNumGeometries(); i++) {
  37935. var elemGeom = geom.getGeometryN(i);
  37936. if (this$1._skipEmpty && elemGeom.isEmpty()) {
  37937. continue;
  37938. }
  37939. elems.add(elemGeom);
  37940. }
  37941. };
  37942. GeometryCombiner.prototype.combine = function combine2() {
  37943. var this$1 = this;
  37944. var elems = new ArrayList();
  37945. for (var i = this._inputGeoms.iterator(); i.hasNext(); ) {
  37946. var g = i.next();
  37947. this$1.extractElements(g, elems);
  37948. }
  37949. if (elems.size() === 0) {
  37950. if (this._geomFactory !== null) {
  37951. return this._geomFactory.createGeometryCollection(null);
  37952. }
  37953. return null;
  37954. }
  37955. return this._geomFactory.buildGeometry(elems);
  37956. };
  37957. GeometryCombiner.prototype.interfaces_ = function interfaces_167() {
  37958. return [];
  37959. };
  37960. GeometryCombiner.prototype.getClass = function getClass166() {
  37961. return GeometryCombiner;
  37962. };
  37963. GeometryCombiner.combine = function combine3() {
  37964. if (arguments.length === 1) {
  37965. var geoms = arguments[0];
  37966. var combiner = new GeometryCombiner(geoms);
  37967. return combiner.combine();
  37968. } else if (arguments.length === 2) {
  37969. var g0 = arguments[0];
  37970. var g1 = arguments[1];
  37971. var combiner$1 = new GeometryCombiner(GeometryCombiner.createList(g0, g1));
  37972. return combiner$1.combine();
  37973. } else if (arguments.length === 3) {
  37974. var g0$1 = arguments[0];
  37975. var g1$1 = arguments[1];
  37976. var g2 = arguments[2];
  37977. var combiner$2 = new GeometryCombiner(GeometryCombiner.createList(g0$1, g1$1, g2));
  37978. return combiner$2.combine();
  37979. }
  37980. };
  37981. GeometryCombiner.extractFactory = function extractFactory(geoms) {
  37982. if (geoms.isEmpty()) {
  37983. return null;
  37984. }
  37985. return geoms.iterator().next().getFactory();
  37986. };
  37987. GeometryCombiner.createList = function createList2() {
  37988. if (arguments.length === 2) {
  37989. var obj0 = arguments[0];
  37990. var obj1 = arguments[1];
  37991. var list = new ArrayList();
  37992. list.add(obj0);
  37993. list.add(obj1);
  37994. return list;
  37995. } else if (arguments.length === 3) {
  37996. var obj0$1 = arguments[0];
  37997. var obj1$1 = arguments[1];
  37998. var obj2 = arguments[2];
  37999. var list$1 = new ArrayList();
  38000. list$1.add(obj0$1);
  38001. list$1.add(obj1$1);
  38002. list$1.add(obj2);
  38003. return list$1;
  38004. }
  38005. };
  38006. var CascadedPolygonUnion = function CascadedPolygonUnion2() {
  38007. this._inputPolys = null;
  38008. this._geomFactory = null;
  38009. var polys = arguments[0];
  38010. this._inputPolys = polys;
  38011. if (this._inputPolys === null) {
  38012. this._inputPolys = new ArrayList();
  38013. }
  38014. };
  38015. var staticAccessors$47 = { STRTREE_NODE_CAPACITY: { configurable: true } };
  38016. CascadedPolygonUnion.prototype.reduceToGeometries = function reduceToGeometries(geomTree) {
  38017. var this$1 = this;
  38018. var geoms = new ArrayList();
  38019. for (var i = geomTree.iterator(); i.hasNext(); ) {
  38020. var o = i.next();
  38021. var geom = null;
  38022. if (hasInterface(o, List)) {
  38023. geom = this$1.unionTree(o);
  38024. } else if (o instanceof Geometry) {
  38025. geom = o;
  38026. }
  38027. geoms.add(geom);
  38028. }
  38029. return geoms;
  38030. };
  38031. CascadedPolygonUnion.prototype.extractByEnvelope = function extractByEnvelope(env, geom, disjointGeoms) {
  38032. var intersectingGeoms = new ArrayList();
  38033. for (var i = 0; i < geom.getNumGeometries(); i++) {
  38034. var elem = geom.getGeometryN(i);
  38035. if (elem.getEnvelopeInternal().intersects(env)) {
  38036. intersectingGeoms.add(elem);
  38037. } else {
  38038. disjointGeoms.add(elem);
  38039. }
  38040. }
  38041. return this._geomFactory.buildGeometry(intersectingGeoms);
  38042. };
  38043. CascadedPolygonUnion.prototype.unionOptimized = function unionOptimized(g0, g1) {
  38044. var g0Env = g0.getEnvelopeInternal();
  38045. var g1Env = g1.getEnvelopeInternal();
  38046. if (!g0Env.intersects(g1Env)) {
  38047. var combo = GeometryCombiner.combine(g0, g1);
  38048. return combo;
  38049. }
  38050. if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) {
  38051. return this.unionActual(g0, g1);
  38052. }
  38053. var commonEnv = g0Env.intersection(g1Env);
  38054. return this.unionUsingEnvelopeIntersection(g0, g1, commonEnv);
  38055. };
  38056. CascadedPolygonUnion.prototype.union = function union5() {
  38057. if (this._inputPolys === null) {
  38058. throw new Error("union() method cannot be called twice");
  38059. }
  38060. if (this._inputPolys.isEmpty()) {
  38061. return null;
  38062. }
  38063. this._geomFactory = this._inputPolys.iterator().next().getFactory();
  38064. var index2 = new STRtree(CascadedPolygonUnion.STRTREE_NODE_CAPACITY);
  38065. for (var i = this._inputPolys.iterator(); i.hasNext(); ) {
  38066. var item = i.next();
  38067. index2.insert(item.getEnvelopeInternal(), item);
  38068. }
  38069. this._inputPolys = null;
  38070. var itemTree = index2.itemsTree();
  38071. var unionAll = this.unionTree(itemTree);
  38072. return unionAll;
  38073. };
  38074. CascadedPolygonUnion.prototype.binaryUnion = function binaryUnion() {
  38075. if (arguments.length === 1) {
  38076. var geoms = arguments[0];
  38077. return this.binaryUnion(geoms, 0, geoms.size());
  38078. } else if (arguments.length === 3) {
  38079. var geoms$1 = arguments[0];
  38080. var start = arguments[1];
  38081. var end = arguments[2];
  38082. if (end - start <= 1) {
  38083. var g0 = CascadedPolygonUnion.getGeometry(geoms$1, start);
  38084. return this.unionSafe(g0, null);
  38085. } else if (end - start === 2) {
  38086. return this.unionSafe(CascadedPolygonUnion.getGeometry(geoms$1, start), CascadedPolygonUnion.getGeometry(geoms$1, start + 1));
  38087. } else {
  38088. var mid = Math.trunc((end + start) / 2);
  38089. var g0$1 = this.binaryUnion(geoms$1, start, mid);
  38090. var g1 = this.binaryUnion(geoms$1, mid, end);
  38091. return this.unionSafe(g0$1, g1);
  38092. }
  38093. }
  38094. };
  38095. CascadedPolygonUnion.prototype.repeatedUnion = function repeatedUnion(geoms) {
  38096. var union9 = null;
  38097. for (var i = geoms.iterator(); i.hasNext(); ) {
  38098. var g = i.next();
  38099. if (union9 === null) {
  38100. union9 = g.copy();
  38101. } else {
  38102. union9 = union9.union(g);
  38103. }
  38104. }
  38105. return union9;
  38106. };
  38107. CascadedPolygonUnion.prototype.unionSafe = function unionSafe(g0, g1) {
  38108. if (g0 === null && g1 === null) {
  38109. return null;
  38110. }
  38111. if (g0 === null) {
  38112. return g1.copy();
  38113. }
  38114. if (g1 === null) {
  38115. return g0.copy();
  38116. }
  38117. return this.unionOptimized(g0, g1);
  38118. };
  38119. CascadedPolygonUnion.prototype.unionActual = function unionActual(g0, g1) {
  38120. return CascadedPolygonUnion.restrictToPolygons(g0.union(g1));
  38121. };
  38122. CascadedPolygonUnion.prototype.unionTree = function unionTree(geomTree) {
  38123. var geoms = this.reduceToGeometries(geomTree);
  38124. var union9 = this.binaryUnion(geoms);
  38125. return union9;
  38126. };
  38127. CascadedPolygonUnion.prototype.unionUsingEnvelopeIntersection = function unionUsingEnvelopeIntersection(g0, g1, common) {
  38128. var disjointPolys = new ArrayList();
  38129. var g0Int = this.extractByEnvelope(common, g0, disjointPolys);
  38130. var g1Int = this.extractByEnvelope(common, g1, disjointPolys);
  38131. var union9 = this.unionActual(g0Int, g1Int);
  38132. disjointPolys.add(union9);
  38133. var overallUnion = GeometryCombiner.combine(disjointPolys);
  38134. return overallUnion;
  38135. };
  38136. CascadedPolygonUnion.prototype.bufferUnion = function bufferUnion() {
  38137. if (arguments.length === 1) {
  38138. var geoms = arguments[0];
  38139. var factory = geoms.get(0).getFactory();
  38140. var gColl = factory.buildGeometry(geoms);
  38141. var unionAll = gColl.buffer(0);
  38142. return unionAll;
  38143. } else if (arguments.length === 2) {
  38144. var g0 = arguments[0];
  38145. var g1 = arguments[1];
  38146. var factory$1 = g0.getFactory();
  38147. var gColl$1 = factory$1.createGeometryCollection([g0, g1]);
  38148. var unionAll$1 = gColl$1.buffer(0);
  38149. return unionAll$1;
  38150. }
  38151. };
  38152. CascadedPolygonUnion.prototype.interfaces_ = function interfaces_168() {
  38153. return [];
  38154. };
  38155. CascadedPolygonUnion.prototype.getClass = function getClass167() {
  38156. return CascadedPolygonUnion;
  38157. };
  38158. CascadedPolygonUnion.restrictToPolygons = function restrictToPolygons(g) {
  38159. if (hasInterface(g, Polygonal)) {
  38160. return g;
  38161. }
  38162. var polygons2 = PolygonExtracter.getPolygons(g);
  38163. if (polygons2.size() === 1) {
  38164. return polygons2.get(0);
  38165. }
  38166. return g.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons2));
  38167. };
  38168. CascadedPolygonUnion.getGeometry = function getGeometry2(list, index2) {
  38169. if (index2 >= list.size()) {
  38170. return null;
  38171. }
  38172. return list.get(index2);
  38173. };
  38174. CascadedPolygonUnion.union = function union6(polys) {
  38175. var op = new CascadedPolygonUnion(polys);
  38176. return op.union();
  38177. };
  38178. staticAccessors$47.STRTREE_NODE_CAPACITY.get = function() {
  38179. return 4;
  38180. };
  38181. Object.defineProperties(CascadedPolygonUnion, staticAccessors$47);
  38182. var UnionOp = function UnionOp2() {
  38183. };
  38184. UnionOp.prototype.interfaces_ = function interfaces_169() {
  38185. return [];
  38186. };
  38187. UnionOp.prototype.getClass = function getClass168() {
  38188. return UnionOp;
  38189. };
  38190. UnionOp.union = function union7(g, other) {
  38191. if (g.isEmpty() || other.isEmpty()) {
  38192. if (g.isEmpty() && other.isEmpty()) {
  38193. return OverlayOp.createEmptyResult(OverlayOp.UNION, g, other, g.getFactory());
  38194. }
  38195. if (g.isEmpty()) {
  38196. return other.copy();
  38197. }
  38198. if (other.isEmpty()) {
  38199. return g.copy();
  38200. }
  38201. }
  38202. g.checkNotGeometryCollection(g);
  38203. g.checkNotGeometryCollection(other);
  38204. return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.UNION);
  38205. };
  38206. // node_modules/d3-geo/src/adder.js
  38207. function adder_default() {
  38208. return new Adder();
  38209. }
  38210. function Adder() {
  38211. this.reset();
  38212. }
  38213. Adder.prototype = {
  38214. constructor: Adder,
  38215. reset: function() {
  38216. this.s = this.t = 0;
  38217. },
  38218. add: function(y2) {
  38219. add16(temp, y2, this.t);
  38220. add16(this, temp.s, this.s);
  38221. if (this.s)
  38222. this.t += temp.t;
  38223. else
  38224. this.s = temp.t;
  38225. },
  38226. valueOf: function() {
  38227. return this.s;
  38228. }
  38229. };
  38230. var temp = new Adder();
  38231. function add16(adder, a, b) {
  38232. var x2 = adder.s = a + b, bv = x2 - a, av = x2 - bv;
  38233. adder.t = a - av + (b - bv);
  38234. }
  38235. // node_modules/d3-geo/src/math.js
  38236. var epsilon4 = 1e-6;
  38237. var pi = Math.PI;
  38238. var halfPi = pi / 2;
  38239. var quarterPi = pi / 4;
  38240. var tau = pi * 2;
  38241. var degrees = 180 / pi;
  38242. var radians = pi / 180;
  38243. var abs2 = Math.abs;
  38244. var atan = Math.atan;
  38245. var atan2 = Math.atan2;
  38246. var cos = Math.cos;
  38247. var exp = Math.exp;
  38248. var log = Math.log;
  38249. var sin = Math.sin;
  38250. var sqrt3 = Math.sqrt;
  38251. var tan = Math.tan;
  38252. function acos(x2) {
  38253. return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
  38254. }
  38255. function asin(x2) {
  38256. return x2 > 1 ? halfPi : x2 < -1 ? -halfPi : Math.asin(x2);
  38257. }
  38258. // node_modules/d3-geo/src/noop.js
  38259. function noop() {
  38260. }
  38261. // node_modules/d3-geo/src/stream.js
  38262. function streamGeometry(geometry2, stream) {
  38263. if (geometry2 && streamGeometryType.hasOwnProperty(geometry2.type)) {
  38264. streamGeometryType[geometry2.type](geometry2, stream);
  38265. }
  38266. }
  38267. var streamObjectType = {
  38268. Feature: function(object, stream) {
  38269. streamGeometry(object.geometry, stream);
  38270. },
  38271. FeatureCollection: function(object, stream) {
  38272. var features = object.features, i = -1, n = features.length;
  38273. while (++i < n)
  38274. streamGeometry(features[i].geometry, stream);
  38275. }
  38276. };
  38277. var streamGeometryType = {
  38278. Sphere: function(object, stream) {
  38279. stream.sphere();
  38280. },
  38281. Point: function(object, stream) {
  38282. object = object.coordinates;
  38283. stream.point(object[0], object[1], object[2]);
  38284. },
  38285. MultiPoint: function(object, stream) {
  38286. var coordinates = object.coordinates, i = -1, n = coordinates.length;
  38287. while (++i < n)
  38288. object = coordinates[i], stream.point(object[0], object[1], object[2]);
  38289. },
  38290. LineString: function(object, stream) {
  38291. streamLine(object.coordinates, stream, 0);
  38292. },
  38293. MultiLineString: function(object, stream) {
  38294. var coordinates = object.coordinates, i = -1, n = coordinates.length;
  38295. while (++i < n)
  38296. streamLine(coordinates[i], stream, 0);
  38297. },
  38298. Polygon: function(object, stream) {
  38299. streamPolygon(object.coordinates, stream);
  38300. },
  38301. MultiPolygon: function(object, stream) {
  38302. var coordinates = object.coordinates, i = -1, n = coordinates.length;
  38303. while (++i < n)
  38304. streamPolygon(coordinates[i], stream);
  38305. },
  38306. GeometryCollection: function(object, stream) {
  38307. var geometries = object.geometries, i = -1, n = geometries.length;
  38308. while (++i < n)
  38309. streamGeometry(geometries[i], stream);
  38310. }
  38311. };
  38312. function streamLine(coordinates, stream, closed) {
  38313. var i = -1, n = coordinates.length - closed, coordinate2;
  38314. stream.lineStart();
  38315. while (++i < n)
  38316. coordinate2 = coordinates[i], stream.point(coordinate2[0], coordinate2[1], coordinate2[2]);
  38317. stream.lineEnd();
  38318. }
  38319. function streamPolygon(coordinates, stream) {
  38320. var i = -1, n = coordinates.length;
  38321. stream.polygonStart();
  38322. while (++i < n)
  38323. streamLine(coordinates[i], stream, 1);
  38324. stream.polygonEnd();
  38325. }
  38326. function stream_default(object, stream) {
  38327. if (object && streamObjectType.hasOwnProperty(object.type)) {
  38328. streamObjectType[object.type](object, stream);
  38329. } else {
  38330. streamGeometry(object, stream);
  38331. }
  38332. }
  38333. // node_modules/d3-geo/src/area.js
  38334. var areaRingSum = adder_default();
  38335. var areaSum = adder_default();
  38336. // node_modules/d3-geo/src/cartesian.js
  38337. function spherical(cartesian2) {
  38338. return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
  38339. }
  38340. function cartesian(spherical2) {
  38341. var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
  38342. return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
  38343. }
  38344. function cartesianDot(a, b) {
  38345. return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  38346. }
  38347. function cartesianCross(a, b) {
  38348. return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
  38349. }
  38350. function cartesianAddInPlace(a, b) {
  38351. a[0] += b[0], a[1] += b[1], a[2] += b[2];
  38352. }
  38353. function cartesianScale(vector, k) {
  38354. return [vector[0] * k, vector[1] * k, vector[2] * k];
  38355. }
  38356. function cartesianNormalizeInPlace(d) {
  38357. var l = sqrt3(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
  38358. d[0] /= l, d[1] /= l, d[2] /= l;
  38359. }
  38360. // node_modules/d3-geo/src/bounds.js
  38361. var deltaSum = adder_default();
  38362. // node_modules/d3-geo/src/compose.js
  38363. function compose_default(a, b) {
  38364. function compose(x2, y2) {
  38365. return x2 = a(x2, y2), b(x2[0], x2[1]);
  38366. }
  38367. if (a.invert && b.invert)
  38368. compose.invert = function(x2, y2) {
  38369. return x2 = b.invert(x2, y2), x2 && a.invert(x2[0], x2[1]);
  38370. };
  38371. return compose;
  38372. }
  38373. // node_modules/d3-geo/src/rotation.js
  38374. function rotationIdentity(lambda, phi) {
  38375. return [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
  38376. }
  38377. rotationIdentity.invert = rotationIdentity;
  38378. function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
  38379. return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
  38380. }
  38381. function forwardRotationLambda(deltaLambda) {
  38382. return function(lambda, phi) {
  38383. return lambda += deltaLambda, [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
  38384. };
  38385. }
  38386. function rotationLambda(deltaLambda) {
  38387. var rotation = forwardRotationLambda(deltaLambda);
  38388. rotation.invert = forwardRotationLambda(-deltaLambda);
  38389. return rotation;
  38390. }
  38391. function rotationPhiGamma(deltaPhi, deltaGamma) {
  38392. var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
  38393. function rotation(lambda, phi) {
  38394. var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z = sin(phi), k = z * cosDeltaPhi + x2 * sinDeltaPhi;
  38395. return [
  38396. atan2(y2 * cosDeltaGamma - k * sinDeltaGamma, x2 * cosDeltaPhi - z * sinDeltaPhi),
  38397. asin(k * cosDeltaGamma + y2 * sinDeltaGamma)
  38398. ];
  38399. }
  38400. rotation.invert = function(lambda, phi) {
  38401. var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z = sin(phi), k = z * cosDeltaGamma - y2 * sinDeltaGamma;
  38402. return [
  38403. atan2(y2 * cosDeltaGamma + z * sinDeltaGamma, x2 * cosDeltaPhi + k * sinDeltaPhi),
  38404. asin(k * cosDeltaPhi - x2 * sinDeltaPhi)
  38405. ];
  38406. };
  38407. return rotation;
  38408. }
  38409. // node_modules/d3-geo/src/circle.js
  38410. function circleStream(stream, radius, delta, direction, t0, t1) {
  38411. if (!delta)
  38412. return;
  38413. var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
  38414. if (t0 == null) {
  38415. t0 = radius + direction * tau;
  38416. t1 = radius - step / 2;
  38417. } else {
  38418. t0 = circleRadius(cosRadius, t0);
  38419. t1 = circleRadius(cosRadius, t1);
  38420. if (direction > 0 ? t0 < t1 : t0 > t1)
  38421. t0 += direction * tau;
  38422. }
  38423. for (var point4, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
  38424. point4 = spherical([cosRadius, -sinRadius * cos(t), -sinRadius * sin(t)]);
  38425. stream.point(point4[0], point4[1]);
  38426. }
  38427. }
  38428. function circleRadius(cosRadius, point4) {
  38429. point4 = cartesian(point4), point4[0] -= cosRadius;
  38430. cartesianNormalizeInPlace(point4);
  38431. var radius = acos(-point4[1]);
  38432. return ((-point4[2] < 0 ? -radius : radius) + tau - epsilon4) % tau;
  38433. }
  38434. // node_modules/d3-geo/src/clip/buffer.js
  38435. function buffer_default() {
  38436. var lines = [], line;
  38437. return {
  38438. point: function(x2, y2) {
  38439. line.push([x2, y2]);
  38440. },
  38441. lineStart: function() {
  38442. lines.push(line = []);
  38443. },
  38444. lineEnd: noop,
  38445. rejoin: function() {
  38446. if (lines.length > 1)
  38447. lines.push(lines.pop().concat(lines.shift()));
  38448. },
  38449. result: function() {
  38450. var result = lines;
  38451. lines = [];
  38452. line = null;
  38453. return result;
  38454. }
  38455. };
  38456. }
  38457. // node_modules/d3-geo/src/clip/line.js
  38458. function line_default(a, b, x02, y02, x12, y12) {
  38459. var ax = a[0], ay = a[1], bx = b[0], by = b[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r;
  38460. r = x02 - ax;
  38461. if (!dx && r > 0)
  38462. return;
  38463. r /= dx;
  38464. if (dx < 0) {
  38465. if (r < t0)
  38466. return;
  38467. if (r < t1)
  38468. t1 = r;
  38469. } else if (dx > 0) {
  38470. if (r > t1)
  38471. return;
  38472. if (r > t0)
  38473. t0 = r;
  38474. }
  38475. r = x12 - ax;
  38476. if (!dx && r < 0)
  38477. return;
  38478. r /= dx;
  38479. if (dx < 0) {
  38480. if (r > t1)
  38481. return;
  38482. if (r > t0)
  38483. t0 = r;
  38484. } else if (dx > 0) {
  38485. if (r < t0)
  38486. return;
  38487. if (r < t1)
  38488. t1 = r;
  38489. }
  38490. r = y02 - ay;
  38491. if (!dy && r > 0)
  38492. return;
  38493. r /= dy;
  38494. if (dy < 0) {
  38495. if (r < t0)
  38496. return;
  38497. if (r < t1)
  38498. t1 = r;
  38499. } else if (dy > 0) {
  38500. if (r > t1)
  38501. return;
  38502. if (r > t0)
  38503. t0 = r;
  38504. }
  38505. r = y12 - ay;
  38506. if (!dy && r < 0)
  38507. return;
  38508. r /= dy;
  38509. if (dy < 0) {
  38510. if (r > t1)
  38511. return;
  38512. if (r > t0)
  38513. t0 = r;
  38514. } else if (dy > 0) {
  38515. if (r < t0)
  38516. return;
  38517. if (r < t1)
  38518. t1 = r;
  38519. }
  38520. if (t0 > 0)
  38521. a[0] = ax + t0 * dx, a[1] = ay + t0 * dy;
  38522. if (t1 < 1)
  38523. b[0] = ax + t1 * dx, b[1] = ay + t1 * dy;
  38524. return true;
  38525. }
  38526. // node_modules/d3-geo/src/pointEqual.js
  38527. function pointEqual_default(a, b) {
  38528. return abs2(a[0] - b[0]) < epsilon4 && abs2(a[1] - b[1]) < epsilon4;
  38529. }
  38530. // node_modules/d3-geo/src/clip/polygon.js
  38531. function Intersection(point4, points2, other, entry) {
  38532. this.x = point4;
  38533. this.z = points2;
  38534. this.o = other;
  38535. this.e = entry;
  38536. this.v = false;
  38537. this.n = this.p = null;
  38538. }
  38539. function polygon_default(segments, compareIntersection2, startInside, interpolate2, stream) {
  38540. var subject = [], clip = [], i, n;
  38541. segments.forEach(function(segment) {
  38542. if ((n2 = segment.length - 1) <= 0)
  38543. return;
  38544. var n2, p0 = segment[0], p1 = segment[n2], x2;
  38545. if (pointEqual_default(p0, p1)) {
  38546. stream.lineStart();
  38547. for (i = 0; i < n2; ++i)
  38548. stream.point((p0 = segment[i])[0], p0[1]);
  38549. stream.lineEnd();
  38550. return;
  38551. }
  38552. subject.push(x2 = new Intersection(p0, segment, null, true));
  38553. clip.push(x2.o = new Intersection(p0, null, x2, false));
  38554. subject.push(x2 = new Intersection(p1, segment, null, false));
  38555. clip.push(x2.o = new Intersection(p1, null, x2, true));
  38556. });
  38557. if (!subject.length)
  38558. return;
  38559. clip.sort(compareIntersection2);
  38560. link(subject);
  38561. link(clip);
  38562. for (i = 0, n = clip.length; i < n; ++i) {
  38563. clip[i].e = startInside = !startInside;
  38564. }
  38565. var start = subject[0], points2, point4;
  38566. while (1) {
  38567. var current = start, isSubject = true;
  38568. while (current.v)
  38569. if ((current = current.n) === start)
  38570. return;
  38571. points2 = current.z;
  38572. stream.lineStart();
  38573. do {
  38574. current.v = current.o.v = true;
  38575. if (current.e) {
  38576. if (isSubject) {
  38577. for (i = 0, n = points2.length; i < n; ++i)
  38578. stream.point((point4 = points2[i])[0], point4[1]);
  38579. } else {
  38580. interpolate2(current.x, current.n.x, 1, stream);
  38581. }
  38582. current = current.n;
  38583. } else {
  38584. if (isSubject) {
  38585. points2 = current.p.z;
  38586. for (i = points2.length - 1; i >= 0; --i)
  38587. stream.point((point4 = points2[i])[0], point4[1]);
  38588. } else {
  38589. interpolate2(current.x, current.p.x, -1, stream);
  38590. }
  38591. current = current.p;
  38592. }
  38593. current = current.o;
  38594. points2 = current.z;
  38595. isSubject = !isSubject;
  38596. } while (!current.v);
  38597. stream.lineEnd();
  38598. }
  38599. }
  38600. function link(array2) {
  38601. if (!(n = array2.length))
  38602. return;
  38603. var n, i = 0, a = array2[0], b;
  38604. while (++i < n) {
  38605. a.n = b = array2[i];
  38606. b.p = a;
  38607. a = b;
  38608. }
  38609. a.n = b = array2[0];
  38610. b.p = a;
  38611. }
  38612. // node_modules/d3-array/src/ascending.js
  38613. function ascending_default(a, b) {
  38614. return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
  38615. }
  38616. // node_modules/d3-array/src/bisector.js
  38617. function bisector_default(compare10) {
  38618. if (compare10.length === 1)
  38619. compare10 = ascendingComparator(compare10);
  38620. return {
  38621. left: function(a, x2, lo, hi) {
  38622. if (lo == null)
  38623. lo = 0;
  38624. if (hi == null)
  38625. hi = a.length;
  38626. while (lo < hi) {
  38627. var mid = lo + hi >>> 1;
  38628. if (compare10(a[mid], x2) < 0)
  38629. lo = mid + 1;
  38630. else
  38631. hi = mid;
  38632. }
  38633. return lo;
  38634. },
  38635. right: function(a, x2, lo, hi) {
  38636. if (lo == null)
  38637. lo = 0;
  38638. if (hi == null)
  38639. hi = a.length;
  38640. while (lo < hi) {
  38641. var mid = lo + hi >>> 1;
  38642. if (compare10(a[mid], x2) > 0)
  38643. hi = mid;
  38644. else
  38645. lo = mid + 1;
  38646. }
  38647. return lo;
  38648. }
  38649. };
  38650. }
  38651. function ascendingComparator(f) {
  38652. return function(d, x2) {
  38653. return ascending_default(f(d), x2);
  38654. };
  38655. }
  38656. // node_modules/d3-array/src/bisect.js
  38657. var ascendingBisect = bisector_default(ascending_default);
  38658. var bisectRight = ascendingBisect.right;
  38659. var bisectLeft = ascendingBisect.left;
  38660. // node_modules/d3-array/src/array.js
  38661. var array = Array.prototype;
  38662. var slice = array.slice;
  38663. var map4 = array.map;
  38664. // node_modules/d3-array/src/ticks.js
  38665. var e10 = Math.sqrt(50);
  38666. var e5 = Math.sqrt(10);
  38667. var e2 = Math.sqrt(2);
  38668. // node_modules/d3-array/src/merge.js
  38669. function merge_default2(arrays) {
  38670. var n = arrays.length, m, i = -1, j = 0, merged, array2;
  38671. while (++i < n)
  38672. j += arrays[i].length;
  38673. merged = new Array(j);
  38674. while (--n >= 0) {
  38675. array2 = arrays[n];
  38676. m = array2.length;
  38677. while (--m >= 0) {
  38678. merged[--j] = array2[m];
  38679. }
  38680. }
  38681. return merged;
  38682. }
  38683. // node_modules/d3-geo/src/clip/extent.js
  38684. var clipMax = 1e9;
  38685. var clipMin = -clipMax;
  38686. function clipExtent(x02, y02, x12, y12) {
  38687. function visible(x2, y2) {
  38688. return x02 <= x2 && x2 <= x12 && y02 <= y2 && y2 <= y12;
  38689. }
  38690. function interpolate2(from, to, direction, stream) {
  38691. var a = 0, a1 = 0;
  38692. if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
  38693. do
  38694. stream.point(a === 0 || a === 3 ? x02 : x12, a > 1 ? y12 : y02);
  38695. while ((a = (a + direction + 4) % 4) !== a1);
  38696. } else {
  38697. stream.point(to[0], to[1]);
  38698. }
  38699. }
  38700. function corner(p, direction) {
  38701. return abs2(p[0] - x02) < epsilon4 ? direction > 0 ? 0 : 3 : abs2(p[0] - x12) < epsilon4 ? direction > 0 ? 2 : 1 : abs2(p[1] - y02) < epsilon4 ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;
  38702. }
  38703. function compareIntersection2(a, b) {
  38704. return comparePoint(a.x, b.x);
  38705. }
  38706. function comparePoint(a, b) {
  38707. var ca = corner(a, 1), cb = corner(b, 1);
  38708. return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];
  38709. }
  38710. return function(stream) {
  38711. var activeStream = stream, bufferStream = buffer_default(), segments, polygon4, ring, x__, y__, v__, x_, y_, v_, first, clean;
  38712. var clipStream = {
  38713. point: point4,
  38714. lineStart,
  38715. lineEnd,
  38716. polygonStart,
  38717. polygonEnd
  38718. };
  38719. function point4(x2, y2) {
  38720. if (visible(x2, y2))
  38721. activeStream.point(x2, y2);
  38722. }
  38723. function polygonInside() {
  38724. var winding = 0;
  38725. for (var i = 0, n = polygon4.length; i < n; ++i) {
  38726. for (var ring2 = polygon4[i], j = 1, m = ring2.length, point5 = ring2[0], a0, a1, b0 = point5[0], b1 = point5[1]; j < m; ++j) {
  38727. a0 = b0, a1 = b1, point5 = ring2[j], b0 = point5[0], b1 = point5[1];
  38728. if (a1 <= y12) {
  38729. if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x02 - a0))
  38730. ++winding;
  38731. } else {
  38732. if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x02 - a0))
  38733. --winding;
  38734. }
  38735. }
  38736. }
  38737. return winding;
  38738. }
  38739. function polygonStart() {
  38740. activeStream = bufferStream, segments = [], polygon4 = [], clean = true;
  38741. }
  38742. function polygonEnd() {
  38743. var startInside = polygonInside(), cleanInside = clean && startInside, visible2 = (segments = merge_default2(segments)).length;
  38744. if (cleanInside || visible2) {
  38745. stream.polygonStart();
  38746. if (cleanInside) {
  38747. stream.lineStart();
  38748. interpolate2(null, null, 1, stream);
  38749. stream.lineEnd();
  38750. }
  38751. if (visible2) {
  38752. polygon_default(segments, compareIntersection2, startInside, interpolate2, stream);
  38753. }
  38754. stream.polygonEnd();
  38755. }
  38756. activeStream = stream, segments = polygon4 = ring = null;
  38757. }
  38758. function lineStart() {
  38759. clipStream.point = linePoint;
  38760. if (polygon4)
  38761. polygon4.push(ring = []);
  38762. first = true;
  38763. v_ = false;
  38764. x_ = y_ = NaN;
  38765. }
  38766. function lineEnd() {
  38767. if (segments) {
  38768. linePoint(x__, y__);
  38769. if (v__ && v_)
  38770. bufferStream.rejoin();
  38771. segments.push(bufferStream.result());
  38772. }
  38773. clipStream.point = point4;
  38774. if (v_)
  38775. activeStream.lineEnd();
  38776. }
  38777. function linePoint(x2, y2) {
  38778. var v = visible(x2, y2);
  38779. if (polygon4)
  38780. ring.push([x2, y2]);
  38781. if (first) {
  38782. x__ = x2, y__ = y2, v__ = v;
  38783. first = false;
  38784. if (v) {
  38785. activeStream.lineStart();
  38786. activeStream.point(x2, y2);
  38787. }
  38788. } else {
  38789. if (v && v_)
  38790. activeStream.point(x2, y2);
  38791. else {
  38792. var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], b = [x2 = Math.max(clipMin, Math.min(clipMax, x2)), y2 = Math.max(clipMin, Math.min(clipMax, y2))];
  38793. if (line_default(a, b, x02, y02, x12, y12)) {
  38794. if (!v_) {
  38795. activeStream.lineStart();
  38796. activeStream.point(a[0], a[1]);
  38797. }
  38798. activeStream.point(b[0], b[1]);
  38799. if (!v)
  38800. activeStream.lineEnd();
  38801. clean = false;
  38802. } else if (v) {
  38803. activeStream.lineStart();
  38804. activeStream.point(x2, y2);
  38805. clean = false;
  38806. }
  38807. }
  38808. }
  38809. x_ = x2, y_ = y2, v_ = v;
  38810. }
  38811. return clipStream;
  38812. };
  38813. }
  38814. // node_modules/d3-geo/src/polygonContains.js
  38815. var sum = adder_default();
  38816. function polygonContains_default(polygon4, point4) {
  38817. var lambda = point4[0], phi = point4[1], normal = [sin(lambda), -cos(lambda), 0], angle4 = 0, winding = 0;
  38818. sum.reset();
  38819. for (var i = 0, n = polygon4.length; i < n; ++i) {
  38820. if (!(m = (ring = polygon4[i]).length))
  38821. continue;
  38822. var ring, m, point0 = ring[m - 1], lambda0 = point0[0], phi0 = point0[1] / 2 + quarterPi, sinPhi0 = sin(phi0), cosPhi0 = cos(phi0);
  38823. for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
  38824. var point1 = ring[j], lambda1 = point1[0], phi1 = point1[1] / 2 + quarterPi, sinPhi1 = sin(phi1), cosPhi1 = cos(phi1), delta = lambda1 - lambda0, sign3 = delta >= 0 ? 1 : -1, absDelta = sign3 * delta, antimeridian = absDelta > pi, k = sinPhi0 * sinPhi1;
  38825. sum.add(atan2(k * sign3 * sin(absDelta), cosPhi0 * cosPhi1 + k * cos(absDelta)));
  38826. angle4 += antimeridian ? delta + sign3 * tau : delta;
  38827. if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
  38828. var arc = cartesianCross(cartesian(point0), cartesian(point1));
  38829. cartesianNormalizeInPlace(arc);
  38830. var intersection12 = cartesianCross(normal, arc);
  38831. cartesianNormalizeInPlace(intersection12);
  38832. var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection12[2]);
  38833. if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
  38834. winding += antimeridian ^ delta >= 0 ? 1 : -1;
  38835. }
  38836. }
  38837. }
  38838. }
  38839. return (angle4 < -epsilon4 || angle4 < epsilon4 && sum < -epsilon4) ^ winding & 1;
  38840. }
  38841. // node_modules/d3-geo/src/length.js
  38842. var lengthSum = adder_default();
  38843. // node_modules/d3-geo/src/identity.js
  38844. function identity_default2(x2) {
  38845. return x2;
  38846. }
  38847. // node_modules/d3-geo/src/path/area.js
  38848. var areaSum2 = adder_default();
  38849. var areaRingSum2 = adder_default();
  38850. // node_modules/d3-geo/src/path/bounds.js
  38851. var x0 = Infinity;
  38852. var y0 = x0;
  38853. var x1 = -x0;
  38854. var y1 = x1;
  38855. var boundsStream = {
  38856. point: boundsPoint,
  38857. lineStart: noop,
  38858. lineEnd: noop,
  38859. polygonStart: noop,
  38860. polygonEnd: noop,
  38861. result: function() {
  38862. var bounds = [[x0, y0], [x1, y1]];
  38863. x1 = y1 = -(y0 = x0 = Infinity);
  38864. return bounds;
  38865. }
  38866. };
  38867. function boundsPoint(x2, y2) {
  38868. if (x2 < x0)
  38869. x0 = x2;
  38870. if (x2 > x1)
  38871. x1 = x2;
  38872. if (y2 < y0)
  38873. y0 = y2;
  38874. if (y2 > y1)
  38875. y1 = y2;
  38876. }
  38877. var bounds_default2 = boundsStream;
  38878. // node_modules/d3-geo/src/path/context.js
  38879. function PathContext(context) {
  38880. this._context = context;
  38881. }
  38882. PathContext.prototype = {
  38883. _radius: 4.5,
  38884. pointRadius: function(_) {
  38885. return this._radius = _, this;
  38886. },
  38887. polygonStart: function() {
  38888. this._line = 0;
  38889. },
  38890. polygonEnd: function() {
  38891. this._line = NaN;
  38892. },
  38893. lineStart: function() {
  38894. this._point = 0;
  38895. },
  38896. lineEnd: function() {
  38897. if (this._line === 0)
  38898. this._context.closePath();
  38899. this._point = NaN;
  38900. },
  38901. point: function(x2, y2) {
  38902. switch (this._point) {
  38903. case 0: {
  38904. this._context.moveTo(x2, y2);
  38905. this._point = 1;
  38906. break;
  38907. }
  38908. case 1: {
  38909. this._context.lineTo(x2, y2);
  38910. break;
  38911. }
  38912. default: {
  38913. this._context.moveTo(x2 + this._radius, y2);
  38914. this._context.arc(x2, y2, this._radius, 0, tau);
  38915. break;
  38916. }
  38917. }
  38918. },
  38919. result: noop
  38920. };
  38921. // node_modules/d3-geo/src/path/measure.js
  38922. var lengthSum2 = adder_default();
  38923. // node_modules/d3-geo/src/path/string.js
  38924. function PathString() {
  38925. this._string = [];
  38926. }
  38927. PathString.prototype = {
  38928. _radius: 4.5,
  38929. _circle: circle2(4.5),
  38930. pointRadius: function(_) {
  38931. if ((_ = +_) !== this._radius)
  38932. this._radius = _, this._circle = null;
  38933. return this;
  38934. },
  38935. polygonStart: function() {
  38936. this._line = 0;
  38937. },
  38938. polygonEnd: function() {
  38939. this._line = NaN;
  38940. },
  38941. lineStart: function() {
  38942. this._point = 0;
  38943. },
  38944. lineEnd: function() {
  38945. if (this._line === 0)
  38946. this._string.push("Z");
  38947. this._point = NaN;
  38948. },
  38949. point: function(x2, y2) {
  38950. switch (this._point) {
  38951. case 0: {
  38952. this._string.push("M", x2, ",", y2);
  38953. this._point = 1;
  38954. break;
  38955. }
  38956. case 1: {
  38957. this._string.push("L", x2, ",", y2);
  38958. break;
  38959. }
  38960. default: {
  38961. if (this._circle == null)
  38962. this._circle = circle2(this._radius);
  38963. this._string.push("M", x2, ",", y2, this._circle);
  38964. break;
  38965. }
  38966. }
  38967. },
  38968. result: function() {
  38969. if (this._string.length) {
  38970. var result = this._string.join("");
  38971. this._string = [];
  38972. return result;
  38973. } else {
  38974. return null;
  38975. }
  38976. }
  38977. };
  38978. function circle2(radius) {
  38979. return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
  38980. }
  38981. // node_modules/d3-geo/src/clip/index.js
  38982. function clip_default(pointVisible, clipLine, interpolate2, start) {
  38983. return function(rotate, sink) {
  38984. var line = clipLine(sink), rotatedStart = rotate.invert(start[0], start[1]), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon4, segments, ring;
  38985. var clip = {
  38986. point: point4,
  38987. lineStart,
  38988. lineEnd,
  38989. polygonStart: function() {
  38990. clip.point = pointRing;
  38991. clip.lineStart = ringStart;
  38992. clip.lineEnd = ringEnd;
  38993. segments = [];
  38994. polygon4 = [];
  38995. },
  38996. polygonEnd: function() {
  38997. clip.point = point4;
  38998. clip.lineStart = lineStart;
  38999. clip.lineEnd = lineEnd;
  39000. segments = merge_default2(segments);
  39001. var startInside = polygonContains_default(polygon4, rotatedStart);
  39002. if (segments.length) {
  39003. if (!polygonStarted)
  39004. sink.polygonStart(), polygonStarted = true;
  39005. polygon_default(segments, compareIntersection, startInside, interpolate2, sink);
  39006. } else if (startInside) {
  39007. if (!polygonStarted)
  39008. sink.polygonStart(), polygonStarted = true;
  39009. sink.lineStart();
  39010. interpolate2(null, null, 1, sink);
  39011. sink.lineEnd();
  39012. }
  39013. if (polygonStarted)
  39014. sink.polygonEnd(), polygonStarted = false;
  39015. segments = polygon4 = null;
  39016. },
  39017. sphere: function() {
  39018. sink.polygonStart();
  39019. sink.lineStart();
  39020. interpolate2(null, null, 1, sink);
  39021. sink.lineEnd();
  39022. sink.polygonEnd();
  39023. }
  39024. };
  39025. function point4(lambda, phi) {
  39026. var point5 = rotate(lambda, phi);
  39027. if (pointVisible(lambda = point5[0], phi = point5[1]))
  39028. sink.point(lambda, phi);
  39029. }
  39030. function pointLine(lambda, phi) {
  39031. var point5 = rotate(lambda, phi);
  39032. line.point(point5[0], point5[1]);
  39033. }
  39034. function lineStart() {
  39035. clip.point = pointLine;
  39036. line.lineStart();
  39037. }
  39038. function lineEnd() {
  39039. clip.point = point4;
  39040. line.lineEnd();
  39041. }
  39042. function pointRing(lambda, phi) {
  39043. ring.push([lambda, phi]);
  39044. var point5 = rotate(lambda, phi);
  39045. ringSink.point(point5[0], point5[1]);
  39046. }
  39047. function ringStart() {
  39048. ringSink.lineStart();
  39049. ring = [];
  39050. }
  39051. function ringEnd() {
  39052. pointRing(ring[0][0], ring[0][1]);
  39053. ringSink.lineEnd();
  39054. var clean = ringSink.clean(), ringSegments = ringBuffer.result(), i, n = ringSegments.length, m, segment, point5;
  39055. ring.pop();
  39056. polygon4.push(ring);
  39057. ring = null;
  39058. if (!n)
  39059. return;
  39060. if (clean & 1) {
  39061. segment = ringSegments[0];
  39062. if ((m = segment.length - 1) > 0) {
  39063. if (!polygonStarted)
  39064. sink.polygonStart(), polygonStarted = true;
  39065. sink.lineStart();
  39066. for (i = 0; i < m; ++i)
  39067. sink.point((point5 = segment[i])[0], point5[1]);
  39068. sink.lineEnd();
  39069. }
  39070. return;
  39071. }
  39072. if (n > 1 && clean & 2)
  39073. ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
  39074. segments.push(ringSegments.filter(validSegment));
  39075. }
  39076. return clip;
  39077. };
  39078. }
  39079. function validSegment(segment) {
  39080. return segment.length > 1;
  39081. }
  39082. function compareIntersection(a, b) {
  39083. return ((a = a.x)[0] < 0 ? a[1] - halfPi - epsilon4 : halfPi - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfPi - epsilon4 : halfPi - b[1]);
  39084. }
  39085. // node_modules/d3-geo/src/clip/antimeridian.js
  39086. var antimeridian_default = clip_default(
  39087. function() {
  39088. return true;
  39089. },
  39090. clipAntimeridianLine,
  39091. clipAntimeridianInterpolate,
  39092. [-pi, -halfPi]
  39093. );
  39094. function clipAntimeridianLine(stream) {
  39095. var lambda0 = NaN, phi0 = NaN, sign0 = NaN, clean;
  39096. return {
  39097. lineStart: function() {
  39098. stream.lineStart();
  39099. clean = 1;
  39100. },
  39101. point: function(lambda1, phi1) {
  39102. var sign1 = lambda1 > 0 ? pi : -pi, delta = abs2(lambda1 - lambda0);
  39103. if (abs2(delta - pi) < epsilon4) {
  39104. stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi : -halfPi);
  39105. stream.point(sign0, phi0);
  39106. stream.lineEnd();
  39107. stream.lineStart();
  39108. stream.point(sign1, phi0);
  39109. stream.point(lambda1, phi0);
  39110. clean = 0;
  39111. } else if (sign0 !== sign1 && delta >= pi) {
  39112. if (abs2(lambda0 - sign0) < epsilon4)
  39113. lambda0 -= sign0 * epsilon4;
  39114. if (abs2(lambda1 - sign1) < epsilon4)
  39115. lambda1 -= sign1 * epsilon4;
  39116. phi0 = clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1);
  39117. stream.point(sign0, phi0);
  39118. stream.lineEnd();
  39119. stream.lineStart();
  39120. stream.point(sign1, phi0);
  39121. clean = 0;
  39122. }
  39123. stream.point(lambda0 = lambda1, phi0 = phi1);
  39124. sign0 = sign1;
  39125. },
  39126. lineEnd: function() {
  39127. stream.lineEnd();
  39128. lambda0 = phi0 = NaN;
  39129. },
  39130. clean: function() {
  39131. return 2 - clean;
  39132. }
  39133. };
  39134. }
  39135. function clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) {
  39136. var cosPhi0, cosPhi1, sinLambda0Lambda1 = sin(lambda0 - lambda1);
  39137. return abs2(sinLambda0Lambda1) > epsilon4 ? atan((sin(phi0) * (cosPhi1 = cos(phi1)) * sin(lambda1) - sin(phi1) * (cosPhi0 = cos(phi0)) * sin(lambda0)) / (cosPhi0 * cosPhi1 * sinLambda0Lambda1)) : (phi0 + phi1) / 2;
  39138. }
  39139. function clipAntimeridianInterpolate(from, to, direction, stream) {
  39140. var phi;
  39141. if (from == null) {
  39142. phi = direction * halfPi;
  39143. stream.point(-pi, phi);
  39144. stream.point(0, phi);
  39145. stream.point(pi, phi);
  39146. stream.point(pi, 0);
  39147. stream.point(pi, -phi);
  39148. stream.point(0, -phi);
  39149. stream.point(-pi, -phi);
  39150. stream.point(-pi, 0);
  39151. stream.point(-pi, phi);
  39152. } else if (abs2(from[0] - to[0]) > epsilon4) {
  39153. var lambda = from[0] < to[0] ? pi : -pi;
  39154. phi = direction * lambda / 2;
  39155. stream.point(-lambda, phi);
  39156. stream.point(0, phi);
  39157. stream.point(lambda, phi);
  39158. } else {
  39159. stream.point(to[0], to[1]);
  39160. }
  39161. }
  39162. // node_modules/d3-geo/src/clip/circle.js
  39163. function circle_default(radius, delta) {
  39164. var cr = cos(radius), smallRadius = cr > 0, notHemisphere = abs2(cr) > epsilon4;
  39165. function interpolate2(from, to, direction, stream) {
  39166. circleStream(stream, radius, delta, direction, from, to);
  39167. }
  39168. function visible(lambda, phi) {
  39169. return cos(lambda) * cos(phi) > cr;
  39170. }
  39171. function clipLine(stream) {
  39172. var point0, c0, v0, v00, clean;
  39173. return {
  39174. lineStart: function() {
  39175. v00 = v0 = false;
  39176. clean = 1;
  39177. },
  39178. point: function(lambda, phi) {
  39179. var point1 = [lambda, phi], point22, v = visible(lambda, phi), c = smallRadius ? v ? 0 : code(lambda, phi) : v ? code(lambda + (lambda < 0 ? pi : -pi), phi) : 0;
  39180. if (!point0 && (v00 = v0 = v))
  39181. stream.lineStart();
  39182. if (v !== v0) {
  39183. point22 = intersect4(point0, point1);
  39184. if (!point22 || pointEqual_default(point0, point22) || pointEqual_default(point1, point22)) {
  39185. point1[0] += epsilon4;
  39186. point1[1] += epsilon4;
  39187. v = visible(point1[0], point1[1]);
  39188. }
  39189. }
  39190. if (v !== v0) {
  39191. clean = 0;
  39192. if (v) {
  39193. stream.lineStart();
  39194. point22 = intersect4(point1, point0);
  39195. stream.point(point22[0], point22[1]);
  39196. } else {
  39197. point22 = intersect4(point0, point1);
  39198. stream.point(point22[0], point22[1]);
  39199. stream.lineEnd();
  39200. }
  39201. point0 = point22;
  39202. } else if (notHemisphere && point0 && smallRadius ^ v) {
  39203. var t;
  39204. if (!(c & c0) && (t = intersect4(point1, point0, true))) {
  39205. clean = 0;
  39206. if (smallRadius) {
  39207. stream.lineStart();
  39208. stream.point(t[0][0], t[0][1]);
  39209. stream.point(t[1][0], t[1][1]);
  39210. stream.lineEnd();
  39211. } else {
  39212. stream.point(t[1][0], t[1][1]);
  39213. stream.lineEnd();
  39214. stream.lineStart();
  39215. stream.point(t[0][0], t[0][1]);
  39216. }
  39217. }
  39218. }
  39219. if (v && (!point0 || !pointEqual_default(point0, point1))) {
  39220. stream.point(point1[0], point1[1]);
  39221. }
  39222. point0 = point1, v0 = v, c0 = c;
  39223. },
  39224. lineEnd: function() {
  39225. if (v0)
  39226. stream.lineEnd();
  39227. point0 = null;
  39228. },
  39229. clean: function() {
  39230. return clean | (v00 && v0) << 1;
  39231. }
  39232. };
  39233. }
  39234. function intersect4(a, b, two) {
  39235. var pa = cartesian(a), pb = cartesian(b);
  39236. var n1 = [1, 0, 0], n2 = cartesianCross(pa, pb), n2n2 = cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
  39237. if (!determinant)
  39238. return !two && a;
  39239. var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n2), A = cartesianScale(n1, c1), B2 = cartesianScale(n2, c2);
  39240. cartesianAddInPlace(A, B2);
  39241. var u = n1xn2, w = cartesianDot(A, u), uu = cartesianDot(u, u), t2 = w * w - uu * (cartesianDot(A, A) - 1);
  39242. if (t2 < 0)
  39243. return;
  39244. var t = sqrt3(t2), q = cartesianScale(u, (-w - t) / uu);
  39245. cartesianAddInPlace(q, A);
  39246. q = spherical(q);
  39247. if (!two)
  39248. return q;
  39249. var lambda0 = a[0], lambda1 = b[0], phi0 = a[1], phi1 = b[1], z;
  39250. if (lambda1 < lambda0)
  39251. z = lambda0, lambda0 = lambda1, lambda1 = z;
  39252. var delta2 = lambda1 - lambda0, polar = abs2(delta2 - pi) < epsilon4, meridian = polar || delta2 < epsilon4;
  39253. if (!polar && phi1 < phi0)
  39254. z = phi0, phi0 = phi1, phi1 = z;
  39255. if (meridian ? polar ? phi0 + phi1 > 0 ^ q[1] < (abs2(q[0] - lambda0) < epsilon4 ? phi0 : phi1) : phi0 <= q[1] && q[1] <= phi1 : delta2 > pi ^ (lambda0 <= q[0] && q[0] <= lambda1)) {
  39256. var q1 = cartesianScale(u, (-w + t) / uu);
  39257. cartesianAddInPlace(q1, A);
  39258. return [q, spherical(q1)];
  39259. }
  39260. }
  39261. function code(lambda, phi) {
  39262. var r = smallRadius ? radius : pi - radius, code2 = 0;
  39263. if (lambda < -r)
  39264. code2 |= 1;
  39265. else if (lambda > r)
  39266. code2 |= 2;
  39267. if (phi < -r)
  39268. code2 |= 4;
  39269. else if (phi > r)
  39270. code2 |= 8;
  39271. return code2;
  39272. }
  39273. return clip_default(visible, clipLine, interpolate2, smallRadius ? [0, -radius] : [-pi, radius - pi]);
  39274. }
  39275. // node_modules/d3-geo/src/transform.js
  39276. function transformer(methods) {
  39277. return function(stream) {
  39278. var s = new TransformStream();
  39279. for (var key in methods)
  39280. s[key] = methods[key];
  39281. s.stream = stream;
  39282. return s;
  39283. };
  39284. }
  39285. function TransformStream() {
  39286. }
  39287. TransformStream.prototype = {
  39288. constructor: TransformStream,
  39289. point: function(x2, y2) {
  39290. this.stream.point(x2, y2);
  39291. },
  39292. sphere: function() {
  39293. this.stream.sphere();
  39294. },
  39295. lineStart: function() {
  39296. this.stream.lineStart();
  39297. },
  39298. lineEnd: function() {
  39299. this.stream.lineEnd();
  39300. },
  39301. polygonStart: function() {
  39302. this.stream.polygonStart();
  39303. },
  39304. polygonEnd: function() {
  39305. this.stream.polygonEnd();
  39306. }
  39307. };
  39308. // node_modules/d3-geo/src/projection/fit.js
  39309. function fitExtent(projection2, extent, object) {
  39310. var w = extent[1][0] - extent[0][0], h = extent[1][1] - extent[0][1], clip = projection2.clipExtent && projection2.clipExtent();
  39311. projection2.scale(150).translate([0, 0]);
  39312. if (clip != null)
  39313. projection2.clipExtent(null);
  39314. stream_default(object, projection2.stream(bounds_default2));
  39315. var b = bounds_default2.result(), k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x2 = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, y2 = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
  39316. if (clip != null)
  39317. projection2.clipExtent(clip);
  39318. return projection2.scale(k * 150).translate([x2, y2]);
  39319. }
  39320. function fitSize(projection2, size11, object) {
  39321. return fitExtent(projection2, [[0, 0], size11], object);
  39322. }
  39323. // node_modules/d3-geo/src/projection/resample.js
  39324. var maxDepth = 16;
  39325. var cosMinDistance = cos(30 * radians);
  39326. function resample_default(project2, delta2) {
  39327. return +delta2 ? resample(project2, delta2) : resampleNone(project2);
  39328. }
  39329. function resampleNone(project2) {
  39330. return transformer({
  39331. point: function(x2, y2) {
  39332. x2 = project2(x2, y2);
  39333. this.stream.point(x2[0], x2[1]);
  39334. }
  39335. });
  39336. }
  39337. function resample(project2, delta2) {
  39338. function resampleLineTo(x02, y02, lambda0, a0, b0, c0, x12, y12, lambda1, a1, b1, c1, depth2, stream) {
  39339. var dx = x12 - x02, dy = y12 - y02, d2 = dx * dx + dy * dy;
  39340. if (d2 > 4 * delta2 && depth2--) {
  39341. var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = sqrt3(a * a + b * b + c * c), phi2 = asin(c /= m), lambda2 = abs2(abs2(c) - 1) < epsilon4 || abs2(lambda0 - lambda1) < epsilon4 ? (lambda0 + lambda1) / 2 : atan2(b, a), p = project2(lambda2, phi2), x2 = p[0], y2 = p[1], dx2 = x2 - x02, dy2 = y2 - y02, dz = dy * dx2 - dx * dy2;
  39342. if (dz * dz / d2 > delta2 || abs2((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
  39343. resampleLineTo(x02, y02, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth2, stream);
  39344. stream.point(x2, y2);
  39345. resampleLineTo(x2, y2, lambda2, a, b, c, x12, y12, lambda1, a1, b1, c1, depth2, stream);
  39346. }
  39347. }
  39348. }
  39349. return function(stream) {
  39350. var lambda00, x00, y00, a00, b00, c00, lambda0, x02, y02, a0, b0, c0;
  39351. var resampleStream = {
  39352. point: point4,
  39353. lineStart,
  39354. lineEnd,
  39355. polygonStart: function() {
  39356. stream.polygonStart();
  39357. resampleStream.lineStart = ringStart;
  39358. },
  39359. polygonEnd: function() {
  39360. stream.polygonEnd();
  39361. resampleStream.lineStart = lineStart;
  39362. }
  39363. };
  39364. function point4(x2, y2) {
  39365. x2 = project2(x2, y2);
  39366. stream.point(x2[0], x2[1]);
  39367. }
  39368. function lineStart() {
  39369. x02 = NaN;
  39370. resampleStream.point = linePoint;
  39371. stream.lineStart();
  39372. }
  39373. function linePoint(lambda, phi) {
  39374. var c = cartesian([lambda, phi]), p = project2(lambda, phi);
  39375. resampleLineTo(x02, y02, lambda0, a0, b0, c0, x02 = p[0], y02 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
  39376. stream.point(x02, y02);
  39377. }
  39378. function lineEnd() {
  39379. resampleStream.point = point4;
  39380. stream.lineEnd();
  39381. }
  39382. function ringStart() {
  39383. lineStart();
  39384. resampleStream.point = ringPoint;
  39385. resampleStream.lineEnd = ringEnd;
  39386. }
  39387. function ringPoint(lambda, phi) {
  39388. linePoint(lambda00 = lambda, phi), x00 = x02, y00 = y02, a00 = a0, b00 = b0, c00 = c0;
  39389. resampleStream.point = linePoint;
  39390. }
  39391. function ringEnd() {
  39392. resampleLineTo(x02, y02, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream);
  39393. resampleStream.lineEnd = lineEnd;
  39394. lineEnd();
  39395. }
  39396. return resampleStream;
  39397. };
  39398. }
  39399. // node_modules/d3-geo/src/projection/index.js
  39400. var transformRadians = transformer({
  39401. point: function(x2, y2) {
  39402. this.stream.point(x2 * radians, y2 * radians);
  39403. }
  39404. });
  39405. function projection(project2) {
  39406. return projectionMutator(function() {
  39407. return project2;
  39408. })();
  39409. }
  39410. function projectionMutator(projectAt) {
  39411. var project2, k = 150, x2 = 480, y2 = 250, dx, dy, lambda = 0, phi = 0, deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, projectRotate, theta = null, preclip = antimeridian_default, x02 = null, y02, x12, y12, postclip = identity_default2, delta2 = 0.5, projectResample = resample_default(projectTransform, delta2), cache, cacheStream;
  39412. function projection2(point4) {
  39413. point4 = projectRotate(point4[0] * radians, point4[1] * radians);
  39414. return [point4[0] * k + dx, dy - point4[1] * k];
  39415. }
  39416. function invert(point4) {
  39417. point4 = projectRotate.invert((point4[0] - dx) / k, (dy - point4[1]) / k);
  39418. return point4 && [point4[0] * degrees, point4[1] * degrees];
  39419. }
  39420. function projectTransform(x3, y3) {
  39421. return x3 = project2(x3, y3), [x3[0] * k + dx, dy - x3[1] * k];
  39422. }
  39423. projection2.stream = function(stream) {
  39424. return cache && cacheStream === stream ? cache : cache = transformRadians(preclip(rotate, projectResample(postclip(cacheStream = stream))));
  39425. };
  39426. projection2.clipAngle = function(_) {
  39427. return arguments.length ? (preclip = +_ ? circle_default(theta = _ * radians, 6 * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
  39428. };
  39429. projection2.clipExtent = function(_) {
  39430. return arguments.length ? (postclip = _ == null ? (x02 = y02 = x12 = y12 = null, identity_default2) : clipExtent(x02 = +_[0][0], y02 = +_[0][1], x12 = +_[1][0], y12 = +_[1][1]), reset()) : x02 == null ? null : [[x02, y02], [x12, y12]];
  39431. };
  39432. projection2.scale = function(_) {
  39433. return arguments.length ? (k = +_, recenter()) : k;
  39434. };
  39435. projection2.translate = function(_) {
  39436. return arguments.length ? (x2 = +_[0], y2 = +_[1], recenter()) : [x2, y2];
  39437. };
  39438. projection2.center = function(_) {
  39439. return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
  39440. };
  39441. projection2.rotate = function(_) {
  39442. return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees];
  39443. };
  39444. projection2.precision = function(_) {
  39445. return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _ * _), reset()) : sqrt3(delta2);
  39446. };
  39447. projection2.fitExtent = function(extent, object) {
  39448. return fitExtent(projection2, extent, object);
  39449. };
  39450. projection2.fitSize = function(size11, object) {
  39451. return fitSize(projection2, size11, object);
  39452. };
  39453. function recenter() {
  39454. projectRotate = compose_default(rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma), project2);
  39455. var center2 = project2(lambda, phi);
  39456. dx = x2 - center2[0] * k;
  39457. dy = y2 + center2[1] * k;
  39458. return reset();
  39459. }
  39460. function reset() {
  39461. cache = cacheStream = null;
  39462. return projection2;
  39463. }
  39464. return function() {
  39465. project2 = projectAt.apply(this, arguments);
  39466. projection2.invert = project2.invert && invert;
  39467. return recenter();
  39468. };
  39469. }
  39470. // node_modules/d3-geo/src/projection/azimuthal.js
  39471. function azimuthalRaw(scale4) {
  39472. return function(x2, y2) {
  39473. var cx = cos(x2), cy = cos(y2), k = scale4(cx * cy);
  39474. return [
  39475. k * cy * sin(x2),
  39476. k * sin(y2)
  39477. ];
  39478. };
  39479. }
  39480. function azimuthalInvert(angle4) {
  39481. return function(x2, y2) {
  39482. var z = sqrt3(x2 * x2 + y2 * y2), c = angle4(z), sc = sin(c), cc = cos(c);
  39483. return [
  39484. atan2(x2 * sc, z * cc),
  39485. asin(z && y2 * sc / z)
  39486. ];
  39487. };
  39488. }
  39489. // node_modules/d3-geo/src/projection/azimuthalEqualArea.js
  39490. var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) {
  39491. return sqrt3(2 / (1 + cxcy));
  39492. });
  39493. azimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) {
  39494. return 2 * asin(z / 2);
  39495. });
  39496. // node_modules/d3-geo/src/projection/azimuthalEquidistant.js
  39497. var azimuthalEquidistantRaw = azimuthalRaw(function(c) {
  39498. return (c = acos(c)) && c / sin(c);
  39499. });
  39500. azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) {
  39501. return z;
  39502. });
  39503. function azimuthalEquidistant_default() {
  39504. return projection(azimuthalEquidistantRaw).scale(79.4188).clipAngle(180 - 1e-3);
  39505. }
  39506. // node_modules/d3-geo/src/projection/mercator.js
  39507. function mercatorRaw(lambda, phi) {
  39508. return [lambda, log(tan((halfPi + phi) / 2))];
  39509. }
  39510. mercatorRaw.invert = function(x2, y2) {
  39511. return [x2, 2 * atan(exp(y2)) - halfPi];
  39512. };
  39513. // node_modules/d3-geo/src/projection/equirectangular.js
  39514. function equirectangularRaw(lambda, phi) {
  39515. return [lambda, phi];
  39516. }
  39517. equirectangularRaw.invert = equirectangularRaw;
  39518. // node_modules/d3-geo/src/projection/gnomonic.js
  39519. function gnomonicRaw(x2, y2) {
  39520. var cy = cos(y2), k = cos(x2) * cy;
  39521. return [cy * sin(x2) / k, sin(y2) / k];
  39522. }
  39523. gnomonicRaw.invert = azimuthalInvert(atan);
  39524. // node_modules/d3-geo/src/projection/naturalEarth1.js
  39525. function naturalEarth1Raw(lambda, phi) {
  39526. var phi2 = phi * phi, phi4 = phi2 * phi2;
  39527. return [
  39528. lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (3971e-6 * phi2 - 1529e-6 * phi4))),
  39529. phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 5916e-6 * phi4)))
  39530. ];
  39531. }
  39532. naturalEarth1Raw.invert = function(x2, y2) {
  39533. var phi = y2, i = 25, delta;
  39534. do {
  39535. var phi2 = phi * phi, phi4 = phi2 * phi2;
  39536. phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 5916e-6 * phi4))) - y2) / (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 5916e-6 * 11 * phi4)));
  39537. } while (abs2(delta) > epsilon4 && --i > 0);
  39538. return [
  39539. x2 / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (3971e-6 - 1529e-6 * phi2)))),
  39540. phi
  39541. ];
  39542. };
  39543. // node_modules/d3-geo/src/projection/orthographic.js
  39544. function orthographicRaw(x2, y2) {
  39545. return [cos(y2) * sin(x2), sin(y2)];
  39546. }
  39547. orthographicRaw.invert = azimuthalInvert(asin);
  39548. // node_modules/d3-geo/src/projection/stereographic.js
  39549. function stereographicRaw(x2, y2) {
  39550. var cy = cos(y2), k = 1 + cos(x2) * cy;
  39551. return [cy * sin(x2) / k, sin(y2) / k];
  39552. }
  39553. stereographicRaw.invert = azimuthalInvert(function(z) {
  39554. return 2 * atan(z);
  39555. });
  39556. // node_modules/d3-geo/src/projection/transverseMercator.js
  39557. function transverseMercatorRaw(lambda, phi) {
  39558. return [log(tan((halfPi + phi) / 2)), -lambda];
  39559. }
  39560. transverseMercatorRaw.invert = function(x2, y2) {
  39561. return [-y2, 2 * atan(exp(x2)) - halfPi];
  39562. };
  39563. // node_modules/@turf/buffer/dist/es/index.js
  39564. function buffer3(geojson, radius, options) {
  39565. options = options || {};
  39566. var units = options.units || "kilometers";
  39567. var steps = options.steps || 8;
  39568. if (!geojson)
  39569. throw new Error("geojson is required");
  39570. if (typeof options !== "object")
  39571. throw new Error("options must be an object");
  39572. if (typeof steps !== "number")
  39573. throw new Error("steps must be an number");
  39574. if (radius === void 0)
  39575. throw new Error("radius is required");
  39576. if (steps <= 0)
  39577. throw new Error("steps must be greater than 0");
  39578. var results = [];
  39579. switch (geojson.type) {
  39580. case "GeometryCollection":
  39581. geomEach(geojson, function(geometry2) {
  39582. var buffered = bufferFeature(geometry2, radius, units, steps);
  39583. if (buffered)
  39584. results.push(buffered);
  39585. });
  39586. return featureCollection(results);
  39587. case "FeatureCollection":
  39588. featureEach(geojson, function(feature2) {
  39589. var multiBuffered = bufferFeature(feature2, radius, units, steps);
  39590. if (multiBuffered) {
  39591. featureEach(multiBuffered, function(buffered) {
  39592. if (buffered)
  39593. results.push(buffered);
  39594. });
  39595. }
  39596. });
  39597. return featureCollection(results);
  39598. }
  39599. return bufferFeature(geojson, radius, units, steps);
  39600. }
  39601. function bufferFeature(geojson, radius, units, steps) {
  39602. var properties = geojson.properties || {};
  39603. var geometry2 = geojson.type === "Feature" ? geojson.geometry : geojson;
  39604. if (geometry2.type === "GeometryCollection") {
  39605. var results = [];
  39606. geomEach(geojson, function(geometry3) {
  39607. var buffered2 = bufferFeature(geometry3, radius, units, steps);
  39608. if (buffered2)
  39609. results.push(buffered2);
  39610. });
  39611. return featureCollection(results);
  39612. }
  39613. var projection2 = defineProjection(geometry2);
  39614. var projected = {
  39615. type: geometry2.type,
  39616. coordinates: projectCoords(geometry2.coordinates, projection2)
  39617. };
  39618. var reader = new GeoJSONReader();
  39619. var geom = reader.read(projected);
  39620. var distance11 = radiansToLength(lengthToRadians(radius, units), "meters");
  39621. var buffered = BufferOp.bufferOp(geom, distance11, steps);
  39622. var writer = new GeoJSONWriter();
  39623. buffered = writer.write(buffered);
  39624. if (coordsIsNaN(buffered.coordinates))
  39625. return void 0;
  39626. var result = {
  39627. type: buffered.type,
  39628. coordinates: unprojectCoords(buffered.coordinates, projection2)
  39629. };
  39630. return feature(result, properties);
  39631. }
  39632. function coordsIsNaN(coords) {
  39633. if (Array.isArray(coords[0]))
  39634. return coordsIsNaN(coords[0]);
  39635. return isNaN(coords[0]);
  39636. }
  39637. function projectCoords(coords, proj) {
  39638. if (typeof coords[0] !== "object")
  39639. return proj(coords);
  39640. return coords.map(function(coord) {
  39641. return projectCoords(coord, proj);
  39642. });
  39643. }
  39644. function unprojectCoords(coords, proj) {
  39645. if (typeof coords[0] !== "object")
  39646. return proj.invert(coords);
  39647. return coords.map(function(coord) {
  39648. return unprojectCoords(coord, proj);
  39649. });
  39650. }
  39651. function defineProjection(geojson) {
  39652. var coords = es_default18(geojson).geometry.coordinates;
  39653. var rotation = [-coords[0], -coords[1]];
  39654. return azimuthalEquidistant_default().rotate(rotation).scale(earthRadius);
  39655. }
  39656. var es_default73 = buffer3;
  39657. // node_modules/@turf/union/dist/es/index.js
  39658. function union8(poly1, poly2, options) {
  39659. if (options === void 0) {
  39660. options = {};
  39661. }
  39662. var geom1 = getGeom(poly1);
  39663. var geom2 = getGeom(poly2);
  39664. var unioned = polygon_clipping_esm_default.union(geom1.coordinates, geom2.coordinates);
  39665. if (unioned.length === 0)
  39666. return null;
  39667. if (unioned.length === 1)
  39668. return polygon(unioned[0], options.properties);
  39669. else
  39670. return multiPolygon(unioned, options.properties);
  39671. }
  39672. var es_default74 = union8;
  39673. // node_modules/@turf/intersect/dist/es/index.js
  39674. function intersect3(poly1, poly2, options) {
  39675. if (options === void 0) {
  39676. options = {};
  39677. }
  39678. var geom1 = getGeom(poly1);
  39679. var geom2 = getGeom(poly2);
  39680. var intersection12 = polygon_clipping_esm_default.intersection(geom1.coordinates, geom2.coordinates);
  39681. if (intersection12.length === 0)
  39682. return null;
  39683. if (intersection12.length === 1)
  39684. return polygon(intersection12[0], options.properties);
  39685. return multiPolygon(intersection12, options.properties);
  39686. }
  39687. // node_modules/@turf/dissolve/dist/es/index.js
  39688. function dissolve2(fc, options) {
  39689. options = options || {};
  39690. if (!isObject(options))
  39691. throw new Error("options is invalid");
  39692. var propertyName = options.propertyName;
  39693. collectionOf(fc, "Polygon", "dissolve");
  39694. var outFeatures = [];
  39695. if (!options.propertyName) {
  39696. return es_default39(
  39697. multiPolygon(
  39698. polygon_clipping_esm_default.union.apply(
  39699. null,
  39700. fc.features.map(function(f) {
  39701. return f.geometry.coordinates;
  39702. })
  39703. )
  39704. )
  39705. );
  39706. } else {
  39707. var uniquePropertyVals = {};
  39708. featureEach(fc, function(feature2) {
  39709. if (!Object.prototype.hasOwnProperty.call(
  39710. uniquePropertyVals,
  39711. feature2.properties[propertyName]
  39712. )) {
  39713. uniquePropertyVals[feature2.properties[propertyName]] = [];
  39714. }
  39715. uniquePropertyVals[feature2.properties[propertyName]].push(feature2);
  39716. });
  39717. var vals = Object.keys(uniquePropertyVals);
  39718. for (var i = 0; i < vals.length; i++) {
  39719. var mp = multiPolygon(
  39720. polygon_clipping_esm_default.union.apply(
  39721. null,
  39722. uniquePropertyVals[vals[i]].map(function(f) {
  39723. return f.geometry.coordinates;
  39724. })
  39725. )
  39726. );
  39727. mp.properties[propertyName] = vals[i];
  39728. outFeatures.push(mp);
  39729. }
  39730. }
  39731. return es_default39(featureCollection(outFeatures));
  39732. }
  39733. var es_default75 = dissolve2;
  39734. // node_modules/@turf/hex-grid/dist/es/index.js
  39735. function hexGrid(bbox3, cellSide, options) {
  39736. if (options === void 0) {
  39737. options = {};
  39738. }
  39739. var clonedProperties = JSON.stringify(options.properties || {});
  39740. var west = bbox3[0], south = bbox3[1], east = bbox3[2], north = bbox3[3];
  39741. var centerY = (south + north) / 2;
  39742. var centerX = (west + east) / 2;
  39743. var xFraction = cellSide * 2 / es_default4([west, centerY], [east, centerY], options);
  39744. var cellWidth = xFraction * (east - west);
  39745. var yFraction = cellSide * 2 / es_default4([centerX, south], [centerX, north], options);
  39746. var cellHeight = yFraction * (north - south);
  39747. var radius = cellWidth / 2;
  39748. var hex_width = radius * 2;
  39749. var hex_height = Math.sqrt(3) / 2 * cellHeight;
  39750. var box_width = east - west;
  39751. var box_height = north - south;
  39752. var x_interval = 3 / 4 * hex_width;
  39753. var y_interval = hex_height;
  39754. var x_span = (box_width - hex_width) / (hex_width - radius / 2);
  39755. var x_count = Math.floor(x_span);
  39756. var x_adjust = (x_count * x_interval - radius / 2 - box_width) / 2 - radius / 2 + x_interval / 2;
  39757. var y_count = Math.floor((box_height - hex_height) / hex_height);
  39758. var y_adjust = (box_height - y_count * hex_height) / 2;
  39759. var hasOffsetY = y_count * hex_height - box_height > hex_height / 2;
  39760. if (hasOffsetY) {
  39761. y_adjust -= hex_height / 4;
  39762. }
  39763. var cosines = [];
  39764. var sines = [];
  39765. for (var i = 0; i < 6; i++) {
  39766. var angle4 = 2 * Math.PI / 6 * i;
  39767. cosines.push(Math.cos(angle4));
  39768. sines.push(Math.sin(angle4));
  39769. }
  39770. var results = [];
  39771. for (var x2 = 0; x2 <= x_count; x2++) {
  39772. for (var y2 = 0; y2 <= y_count; y2++) {
  39773. var isOdd = x2 % 2 === 1;
  39774. if (y2 === 0 && isOdd)
  39775. continue;
  39776. if (y2 === 0 && hasOffsetY)
  39777. continue;
  39778. var center_x = x2 * x_interval + west - x_adjust;
  39779. var center_y = y2 * y_interval + south + y_adjust;
  39780. if (isOdd) {
  39781. center_y -= hex_height / 2;
  39782. }
  39783. if (options.triangles === true) {
  39784. hexTriangles([center_x, center_y], cellWidth / 2, cellHeight / 2, JSON.parse(clonedProperties), cosines, sines).forEach(function(triangle) {
  39785. if (options.mask) {
  39786. if (intersect3(options.mask, triangle))
  39787. results.push(triangle);
  39788. } else {
  39789. results.push(triangle);
  39790. }
  39791. });
  39792. } else {
  39793. var hex = hexagon([center_x, center_y], cellWidth / 2, cellHeight / 2, JSON.parse(clonedProperties), cosines, sines);
  39794. if (options.mask) {
  39795. if (intersect3(options.mask, hex))
  39796. results.push(hex);
  39797. } else {
  39798. results.push(hex);
  39799. }
  39800. }
  39801. }
  39802. }
  39803. return featureCollection(results);
  39804. }
  39805. function hexagon(center2, rx, ry, properties, cosines, sines) {
  39806. var vertices = [];
  39807. for (var i = 0; i < 6; i++) {
  39808. var x2 = center2[0] + rx * cosines[i];
  39809. var y2 = center2[1] + ry * sines[i];
  39810. vertices.push([x2, y2]);
  39811. }
  39812. vertices.push(vertices[0].slice());
  39813. return polygon([vertices], properties);
  39814. }
  39815. function hexTriangles(center2, rx, ry, properties, cosines, sines) {
  39816. var triangles = [];
  39817. for (var i = 0; i < 6; i++) {
  39818. var vertices = [];
  39819. vertices.push(center2);
  39820. vertices.push([center2[0] + rx * cosines[i], center2[1] + ry * sines[i]]);
  39821. vertices.push([
  39822. center2[0] + rx * cosines[(i + 1) % 6],
  39823. center2[1] + ry * sines[(i + 1) % 6]
  39824. ]);
  39825. vertices.push(center2);
  39826. triangles.push(polygon([vertices], properties));
  39827. }
  39828. return triangles;
  39829. }
  39830. var es_default76 = hexGrid;
  39831. // node_modules/@turf/mask/dist/es/index.js
  39832. function mask(polygon4, mask2) {
  39833. var maskPolygon = createMask(mask2);
  39834. var polygonOuters = null;
  39835. if (polygon4.type === "FeatureCollection")
  39836. polygonOuters = unionFc(polygon4);
  39837. else
  39838. polygonOuters = createGeomFromPolygonClippingOutput(
  39839. polygon_clipping_esm_default.union(polygon4.geometry.coordinates)
  39840. );
  39841. polygonOuters.geometry.coordinates.forEach(function(contour) {
  39842. maskPolygon.geometry.coordinates.push(contour[0]);
  39843. });
  39844. return maskPolygon;
  39845. }
  39846. function unionFc(fc) {
  39847. var unioned = fc.features.length === 2 ? polygon_clipping_esm_default.union(
  39848. fc.features[0].geometry.coordinates,
  39849. fc.features[1].geometry.coordinates
  39850. ) : polygon_clipping_esm_default.union.apply(
  39851. polygon_clipping_esm_default,
  39852. fc.features.map(function(f) {
  39853. return f.geometry.coordinates;
  39854. })
  39855. );
  39856. return createGeomFromPolygonClippingOutput(unioned);
  39857. }
  39858. function createGeomFromPolygonClippingOutput(unioned) {
  39859. return multiPolygon(unioned);
  39860. }
  39861. function createMask(mask2) {
  39862. var world = [
  39863. [
  39864. [180, 90],
  39865. [-180, 90],
  39866. [-180, -90],
  39867. [180, -90],
  39868. [180, 90]
  39869. ]
  39870. ];
  39871. var coordinates = mask2 && mask2.geometry.coordinates || world;
  39872. return polygon(coordinates);
  39873. }
  39874. var es_default77 = mask;
  39875. // node_modules/@turf/rectangle-grid/dist/es/index.js
  39876. function rectangleGrid(bbox3, cellWidth, cellHeight, options) {
  39877. if (options === void 0) {
  39878. options = {};
  39879. }
  39880. var results = [];
  39881. var west = bbox3[0];
  39882. var south = bbox3[1];
  39883. var east = bbox3[2];
  39884. var north = bbox3[3];
  39885. var xFraction = cellWidth / es_default4([west, south], [east, south], options);
  39886. var cellWidthDeg = xFraction * (east - west);
  39887. var yFraction = cellHeight / es_default4([west, south], [west, north], options);
  39888. var cellHeightDeg = yFraction * (north - south);
  39889. var bboxWidth = east - west;
  39890. var bboxHeight = north - south;
  39891. var columns = Math.floor(bboxWidth / cellWidthDeg);
  39892. var rows = Math.floor(bboxHeight / cellHeightDeg);
  39893. var deltaX = (bboxWidth - columns * cellWidthDeg) / 2;
  39894. var deltaY = (bboxHeight - rows * cellHeightDeg) / 2;
  39895. var currentX = west + deltaX;
  39896. for (var column = 0; column < columns; column++) {
  39897. var currentY = south + deltaY;
  39898. for (var row = 0; row < rows; row++) {
  39899. var cellPoly = polygon([
  39900. [
  39901. [currentX, currentY],
  39902. [currentX, currentY + cellHeightDeg],
  39903. [currentX + cellWidthDeg, currentY + cellHeightDeg],
  39904. [currentX + cellWidthDeg, currentY],
  39905. [currentX, currentY]
  39906. ]
  39907. ], options.properties);
  39908. if (options.mask) {
  39909. if (booleanIntersects(options.mask, cellPoly)) {
  39910. results.push(cellPoly);
  39911. }
  39912. } else {
  39913. results.push(cellPoly);
  39914. }
  39915. currentY += cellHeightDeg;
  39916. }
  39917. currentX += cellWidthDeg;
  39918. }
  39919. return featureCollection(results);
  39920. }
  39921. var es_default78 = rectangleGrid;
  39922. // node_modules/@turf/square-grid/dist/es/index.js
  39923. function squareGrid(bbox3, cellSide, options) {
  39924. if (options === void 0) {
  39925. options = {};
  39926. }
  39927. return es_default78(bbox3, cellSide, cellSide, options);
  39928. }
  39929. // node_modules/@turf/triangle-grid/dist/es/index.js
  39930. function triangleGrid(bbox3, cellSide, options) {
  39931. if (options === void 0) {
  39932. options = {};
  39933. }
  39934. var results = [];
  39935. var xFraction = cellSide / es_default4([bbox3[0], bbox3[1]], [bbox3[2], bbox3[1]], options);
  39936. var cellWidth = xFraction * (bbox3[2] - bbox3[0]);
  39937. var yFraction = cellSide / es_default4([bbox3[0], bbox3[1]], [bbox3[0], bbox3[3]], options);
  39938. var cellHeight = yFraction * (bbox3[3] - bbox3[1]);
  39939. var xi = 0;
  39940. var currentX = bbox3[0];
  39941. while (currentX <= bbox3[2]) {
  39942. var yi = 0;
  39943. var currentY = bbox3[1];
  39944. while (currentY <= bbox3[3]) {
  39945. var cellTriangle1 = null;
  39946. var cellTriangle2 = null;
  39947. if (xi % 2 === 0 && yi % 2 === 0) {
  39948. cellTriangle1 = polygon([
  39949. [
  39950. [currentX, currentY],
  39951. [currentX, currentY + cellHeight],
  39952. [currentX + cellWidth, currentY],
  39953. [currentX, currentY]
  39954. ]
  39955. ], options.properties);
  39956. cellTriangle2 = polygon([
  39957. [
  39958. [currentX, currentY + cellHeight],
  39959. [currentX + cellWidth, currentY + cellHeight],
  39960. [currentX + cellWidth, currentY],
  39961. [currentX, currentY + cellHeight]
  39962. ]
  39963. ], options.properties);
  39964. } else if (xi % 2 === 0 && yi % 2 === 1) {
  39965. cellTriangle1 = polygon([
  39966. [
  39967. [currentX, currentY],
  39968. [currentX + cellWidth, currentY + cellHeight],
  39969. [currentX + cellWidth, currentY],
  39970. [currentX, currentY]
  39971. ]
  39972. ], options.properties);
  39973. cellTriangle2 = polygon([
  39974. [
  39975. [currentX, currentY],
  39976. [currentX, currentY + cellHeight],
  39977. [currentX + cellWidth, currentY + cellHeight],
  39978. [currentX, currentY]
  39979. ]
  39980. ], options.properties);
  39981. } else if (yi % 2 === 0 && xi % 2 === 1) {
  39982. cellTriangle1 = polygon([
  39983. [
  39984. [currentX, currentY],
  39985. [currentX, currentY + cellHeight],
  39986. [currentX + cellWidth, currentY + cellHeight],
  39987. [currentX, currentY]
  39988. ]
  39989. ], options.properties);
  39990. cellTriangle2 = polygon([
  39991. [
  39992. [currentX, currentY],
  39993. [currentX + cellWidth, currentY + cellHeight],
  39994. [currentX + cellWidth, currentY],
  39995. [currentX, currentY]
  39996. ]
  39997. ], options.properties);
  39998. } else if (yi % 2 === 1 && xi % 2 === 1) {
  39999. cellTriangle1 = polygon([
  40000. [
  40001. [currentX, currentY],
  40002. [currentX, currentY + cellHeight],
  40003. [currentX + cellWidth, currentY],
  40004. [currentX, currentY]
  40005. ]
  40006. ], options.properties);
  40007. cellTriangle2 = polygon([
  40008. [
  40009. [currentX, currentY + cellHeight],
  40010. [currentX + cellWidth, currentY + cellHeight],
  40011. [currentX + cellWidth, currentY],
  40012. [currentX, currentY + cellHeight]
  40013. ]
  40014. ], options.properties);
  40015. }
  40016. if (options.mask) {
  40017. if (intersect3(options.mask, cellTriangle1))
  40018. results.push(cellTriangle1);
  40019. if (intersect3(options.mask, cellTriangle2))
  40020. results.push(cellTriangle2);
  40021. } else {
  40022. results.push(cellTriangle1);
  40023. results.push(cellTriangle2);
  40024. }
  40025. currentY += cellHeight;
  40026. yi++;
  40027. }
  40028. xi++;
  40029. currentX += cellWidth;
  40030. }
  40031. return featureCollection(results);
  40032. }
  40033. var es_default79 = triangleGrid;
  40034. // node_modules/@turf/interpolate/dist/es/index.js
  40035. function interpolate(points2, cellSize, options) {
  40036. options = options || {};
  40037. if (typeof options !== "object")
  40038. throw new Error("options is invalid");
  40039. var gridType = options.gridType;
  40040. var property = options.property;
  40041. var weight = options.weight;
  40042. if (!points2)
  40043. throw new Error("points is required");
  40044. collectionOf(points2, "Point", "input must contain Points");
  40045. if (!cellSize)
  40046. throw new Error("cellSize is required");
  40047. if (weight !== void 0 && typeof weight !== "number")
  40048. throw new Error("weight must be a number");
  40049. property = property || "elevation";
  40050. gridType = gridType || "square";
  40051. weight = weight || 1;
  40052. var box = es_default(points2);
  40053. var grid;
  40054. switch (gridType) {
  40055. case "point":
  40056. case "points":
  40057. grid = es_default37(box, cellSize, options);
  40058. break;
  40059. case "square":
  40060. case "squares":
  40061. grid = squareGrid(box, cellSize, options);
  40062. break;
  40063. case "hex":
  40064. case "hexes":
  40065. grid = es_default76(box, cellSize, options);
  40066. break;
  40067. case "triangle":
  40068. case "triangles":
  40069. grid = es_default79(box, cellSize, options);
  40070. break;
  40071. default:
  40072. throw new Error("invalid gridType");
  40073. }
  40074. var results = [];
  40075. featureEach(grid, function(gridFeature) {
  40076. var zw = 0;
  40077. var sw = 0;
  40078. featureEach(points2, function(point4) {
  40079. var gridPoint = gridType === "point" ? gridFeature : es_default19(gridFeature);
  40080. var d = es_default4(gridPoint, point4, options);
  40081. var zValue;
  40082. if (property !== void 0)
  40083. zValue = point4.properties[property];
  40084. if (zValue === void 0)
  40085. zValue = point4.geometry.coordinates[2];
  40086. if (zValue === void 0)
  40087. throw new Error("zValue is missing");
  40088. if (d === 0)
  40089. zw = zValue;
  40090. var w = 1 / Math.pow(d, weight);
  40091. sw += w;
  40092. zw += w * zValue;
  40093. });
  40094. var newFeature = es_default5(gridFeature);
  40095. newFeature.properties[property] = zw / sw;
  40096. results.push(newFeature);
  40097. });
  40098. return featureCollection(results);
  40099. }
  40100. var es_default80 = interpolate;
  40101. export {
  40102. along,
  40103. es_default69 as angle,
  40104. applyFilter,
  40105. area,
  40106. areaFactors,
  40107. es_default as bbox,
  40108. bboxClip,
  40109. bboxPolygon,
  40110. bearing,
  40111. bearingToAzimuth as bearingToAngle,
  40112. bearingToAzimuth,
  40113. es_default11 as bezier,
  40114. es_default11 as bezierSpline,
  40115. booleanClockwise,
  40116. booleanContains,
  40117. es_default58 as booleanCrosses,
  40118. es_default57 as booleanDisjoint,
  40119. es_default59 as booleanEqual,
  40120. booleanIntersects,
  40121. booleanOverlap,
  40122. es_default62 as booleanParallel,
  40123. booleanPointInPolygon,
  40124. es_default35 as booleanPointOnLine,
  40125. es_default36 as booleanWithin,
  40126. es_default73 as buffer,
  40127. es_default18 as center,
  40128. es_default66 as centerMean,
  40129. es_default67 as centerMedian,
  40130. es_default20 as centerOfMass,
  40131. es_default19 as centroid,
  40132. es_default16 as circle,
  40133. es_default9 as cleanCoords,
  40134. es_default5 as clone,
  40135. clusterEach,
  40136. clusterReduce,
  40137. es_exports6 as clusters,
  40138. es_default60 as clustersDbscan,
  40139. es_default61 as clustersKmeans,
  40140. es_default7 as collect,
  40141. collectionOf,
  40142. es_default21 as combine,
  40143. es_default6 as concave,
  40144. containsNumber,
  40145. convertArea,
  40146. convertLength as convertDistance,
  40147. convertLength,
  40148. convex,
  40149. coordAll,
  40150. coordEach,
  40151. coordReduce,
  40152. createBins,
  40153. degreesToRadians as degrees2radians,
  40154. degreesToRadians,
  40155. destination,
  40156. es_default72 as difference,
  40157. es_default75 as dissolve,
  40158. es_default4 as distance,
  40159. lengthToDegrees as distanceToDegrees,
  40160. lengthToRadians as distanceToRadians,
  40161. distanceWeight,
  40162. earthRadius,
  40163. es_default65 as ellipse,
  40164. es_default14 as envelope,
  40165. es_default22 as explode,
  40166. factors,
  40167. feature,
  40168. featureCollection,
  40169. featureEach,
  40170. featureOf,
  40171. featureReduce,
  40172. filterProperties,
  40173. findPoint,
  40174. findSegment,
  40175. es_default39 as flatten,
  40176. flattenEach,
  40177. flattenReduce,
  40178. es_default8 as flip,
  40179. geojsonType,
  40180. geomEach,
  40181. geomReduce,
  40182. geometry,
  40183. geometryCollection,
  40184. getCluster,
  40185. getCoord,
  40186. getCoords,
  40187. getGeom,
  40188. getType,
  40189. es_default42 as greatCircle,
  40190. es_exports as helpers,
  40191. es_default76 as hexGrid,
  40192. booleanPointInPolygon as inside,
  40193. es_default80 as interpolate,
  40194. intersect3 as intersect,
  40195. es_exports3 as invariant,
  40196. isNumber,
  40197. isObject,
  40198. es_default52 as isobands,
  40199. es_default2 as isolines,
  40200. kinks,
  40201. length,
  40202. lengthToDegrees,
  40203. lengthToRadians,
  40204. lineArc,
  40205. es_default40 as lineChunk,
  40206. length as lineDistance,
  40207. lineEach,
  40208. es_default26 as lineIntersect,
  40209. es_default56 as lineOffset,
  40210. es_default46 as lineOverlap,
  40211. lineReduce,
  40212. es_default25 as lineSegment,
  40213. es_default33 as lineSlice,
  40214. es_default34 as lineSliceAlong,
  40215. es_default43 as lineSplit,
  40216. lineString,
  40217. es_default45 as lineStringToPolygon,
  40218. lineStrings,
  40219. es_default45 as lineToPolygon,
  40220. es_default77 as mask,
  40221. es_exports2 as meta,
  40222. es_default17 as midpoint,
  40223. es_default71 as moranIndex,
  40224. multiLineString,
  40225. multiPoint,
  40226. multiPolygon,
  40227. es_default24 as nearest,
  40228. es_default24 as nearestPoint,
  40229. es_default27 as nearestPointOnLine,
  40230. es_default30 as nearestPointToLine,
  40231. es_default31 as planepoint,
  40232. point,
  40233. es_default37 as pointGrid,
  40234. es_default32 as pointOnFeature,
  40235. es_default27 as pointOnLine,
  40236. es_default32 as pointOnSurface,
  40237. es_default29 as pointToLineDistance,
  40238. points,
  40239. es_default3 as pointsWithinPolygon,
  40240. polygon,
  40241. es_default70 as polygonSmooth,
  40242. es_default50 as polygonTangents,
  40243. es_default44 as polygonToLine,
  40244. es_default44 as polygonToLineString,
  40245. polygonize,
  40246. polygons,
  40247. es_exports4 as projection,
  40248. propEach,
  40249. propReduce,
  40250. propertiesContainsFilter,
  40251. radiansToDegrees as radians2degrees,
  40252. radiansToDegrees,
  40253. radiansToLength as radiansToDistance,
  40254. radiansToLength,
  40255. es_exports5 as random,
  40256. randomLineString,
  40257. randomPoint,
  40258. randomPolygon,
  40259. randomPosition,
  40260. es_default51 as rewind,
  40261. es_default48 as rhumbBearing,
  40262. es_default49 as rhumbDestination,
  40263. es_default28 as rhumbDistance,
  40264. round,
  40265. es_default13 as sample,
  40266. es_default47 as sector,
  40267. segmentEach,
  40268. segmentReduce,
  40269. es_default63 as shortestPath,
  40270. es_default10 as simplify,
  40271. es_default15 as square,
  40272. squareGrid,
  40273. es_default68 as standardDeviationalEllipse,
  40274. es_default12 as tag,
  40275. es_default23 as tesselate,
  40276. tin,
  40277. toMercator,
  40278. toWgs84,
  40279. es_default53 as transformRotate,
  40280. es_default54 as transformScale,
  40281. es_default55 as transformTranslate,
  40282. es_default79 as triangleGrid,
  40283. es_default38 as truncate,
  40284. es_default74 as union,
  40285. unitsFactors,
  40286. es_default41 as unkinkPolygon,
  40287. validateBBox,
  40288. validateId,
  40289. es_default64 as voronoi,
  40290. es_default3 as within
  40291. };
  40292. /*
  40293. object-assign
  40294. (c) Sindre Sorhus
  40295. @license MIT
  40296. */
  40297. /*!
  40298. * @license GNU Affero General Public License.
  40299. * Copyright (c) 2015, 2015 Ronny Lorenz <ronny@tbi.univie.ac.at>
  40300. * v. 1.2.0
  40301. * https://github.com/RaumZeit/MarchingSquares.js
  40302. *
  40303. * MarchingSquaresJS is free software: you can redistribute it and/or modify
  40304. * it under the terms of the GNU Affero General Public License as published by
  40305. * the Free Software Foundation, either version 3 of the License, or
  40306. * (at your option) any later version.
  40307. *
  40308. * MarchingSquaresJS is distributed in the hope that it will be useful,
  40309. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40310. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40311. * GNU Affero General Public License for more details.
  40312. *
  40313. * As additional permission under GNU Affero General Public License version 3
  40314. * section 7, third-party projects (personal or commercial) may distribute,
  40315. * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the
  40316. * requirement that said third-party project for that reason alone becomes
  40317. * subject to any requirement of the GNU Affero General Public License version 3.
  40318. * Any modifications to MarchingSquaresJS, however, must be shared with the public
  40319. * and made available.
  40320. *
  40321. * In summary this:
  40322. * - allows you to use MarchingSquaresJS at no cost
  40323. * - allows you to use MarchingSquaresJS for both personal and commercial purposes
  40324. * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any
  40325. * license as long as this license notice is included
  40326. * - enables you to keep the source code of your program that uses MarchingSquaresJS
  40327. * undisclosed
  40328. * - forces you to share any modifications you have made to MarchingSquaresJS,
  40329. * e.g. bug-fixes
  40330. *
  40331. * You should have received a copy of the GNU Affero General Public License
  40332. * along with MarchingSquaresJS. If not, see <http://www.gnu.org/licenses/>.
  40333. */
  40334. /*! *****************************************************************************
  40335. Copyright (c) Microsoft Corporation. All rights reserved.
  40336. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  40337. this file except in compliance with the License. You may obtain a copy of the
  40338. License at http://www.apache.org/licenses/LICENSE-2.0
  40339. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40340. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  40341. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  40342. MERCHANTABLITY OR NON-INFRINGEMENT.
  40343. See the Apache Version 2.0 License for specific language governing permissions
  40344. and limitations under the License.
  40345. ***************************************************************************** */
  40346. /**
  40347. * @license GNU Affero General Public License.
  40348. * Copyright (c) 2015, 2015 Ronny Lorenz <ronny@tbi.univie.ac.at>
  40349. * v. 1.2.0
  40350. * https://github.com/RaumZeit/MarchingSquares.js
  40351. *
  40352. * MarchingSquaresJS is free software: you can redistribute it and/or modify
  40353. * it under the terms of the GNU Affero General Public License as published by
  40354. * the Free Software Foundation, either version 3 of the License, or
  40355. * (at your option) any later version.
  40356. *
  40357. * MarchingSquaresJS is distributed in the hope that it will be useful,
  40358. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40359. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40360. * GNU Affero General Public License for more details.
  40361. *
  40362. * As additional permission under GNU Affero General Public License version 3
  40363. * section 7, third-party projects (personal or commercial) may distribute,
  40364. * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the
  40365. * requirement that said third-party project for that reason alone becomes
  40366. * subject to any requirement of the GNU Affero General Public License version 3.
  40367. * Any modifications to MarchingSquaresJS, however, must be shared with the public
  40368. * and made available.
  40369. *
  40370. * In summary this:
  40371. * - allows you to use MarchingSquaresJS at no cost
  40372. * - allows you to use MarchingSquaresJS for both personal and commercial purposes
  40373. * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any
  40374. * license as long as this license notice is included
  40375. * - enables you to keep the source code of your program that uses MarchingSquaresJS
  40376. * undisclosed
  40377. * - forces you to share any modifications you have made to MarchingSquaresJS,
  40378. * e.g. bug-fixes
  40379. *
  40380. * You should have received a copy of the GNU Affero General Public License
  40381. * along with MarchingSquaresJS. If not, see <http://www.gnu.org/licenses/>.
  40382. */
  40383. /**
  40384. * splaytree v3.1.1
  40385. * Fast Splay tree for Node and browser
  40386. *
  40387. * @author Alexander Milevski <info@w8r.name>
  40388. * @license MIT
  40389. * @preserve
  40390. */
  40391. //# sourceMappingURL=@turf_turf.js.map