12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967 |
- (function() {
- window.GeoGlobe = window.GeoGlobe || {};
- GeoGlobe.LngLatBounds = {};
- GeoGlobe.LngLat = {};
- GeoGlobe.Point = mapboxgl.Point;
- GeoGlobe.BoxHandler = mapboxgl.BoxHandler;
- GeoGlobe.Class = {};
- GeoGlobe.Layer = {};
- GeoGlobe.Source = {};
- GeoGlobe.Event = {};
- GeoGlobe.Control = {};
- GeoGlobe.Marker = {};
- GeoGlobe.Popup = {};
- GeoGlobe.Filter = {};
- GeoGlobe.Format = {};
- GeoGlobe.Analysis = {};
- GeoGlobe.Protocol = {};
- GeoGlobe.Query = {};
- GeoGlobe.Statistic = {};
- GeoGlobe.LayerGroup = {};
- GeoGlobe.Protocol = {};
- GeoGlobe.Service = {};
- GeoGlobe.DynamicFeature = {};
- GeoGlobe.DynamicTrace = {};
- GeoGlobe.DSS = {};
- GeoGlobe.Widget = {};
- GeoGlobe.imagesPath = "";
- GeoGlobe.VERSION_NUMBER = "GeoGlobeJSAPI 2020 -- $Version: 1.3.2 build-20020312 $"
- })();
- GeoGlobe.Class = function() {
- var a = arguments.length,
- b = arguments[0],
- c = arguments[a - 1],
- d = typeof c.initialize == "function" ? c.initialize : function() {
- b.prototype.initialize.apply(this, arguments)
- };
- a > 1 ? [d, b].concat(Array.prototype.slice.call(arguments).slice(1, a - 1), c) : d.prototype = c;
- return d
- };
- GeoGlobe.Class4OL = function() {
- var a = arguments.length,
- b = arguments[0],
- c = arguments[a - 1],
- d = typeof c.initialize == "function" ? c.initialize : function() {
- b.prototype.initialize.apply(this, arguments)
- };
- a > 1 ? (a = [d, b].concat(Array.prototype.slice.call(arguments).slice(1, a - 1), c), GeoGlobe.inherit.apply(null, a)) : d.prototype = c;
- return d
- };
- GeoGlobe.inherit = function(a, b) {
- var c = function() {};
- c.prototype = b.prototype;
- a.prototype = new c;
- var d, e, c = 2;
- for (d = arguments.length; c < d; c++) {
- e = arguments[c];
- if (typeof e === "function") e = e.prototype;
- GeoGlobe.Util.extend(a.prototype, e)
- }
- };
- GeoGlobe.Util = GeoGlobe.Util || {};
- GeoGlobe.Util.extend = function(a, b) {
- a = a || {};
- if (b) {
- for (var c in b) {
- var d = b[c];
- d !== void 0 && (a[c] = d)
- }
- if (!(typeof window.Event == "function" && b instanceof window.Event) && b.hasOwnProperty && b.hasOwnProperty("toString")) a.toString = b.toString
- }
- return a
- };
- GeoGlobe.Util.deepExtend = function(a) {
- for (var b = 1; b < arguments.length; b++)
- for (var c in arguments[b])
- if (arguments[b].hasOwnProperty(c)) switch (GeoGlobe.Util.getType(arguments[b][c])) {
- case "array":
- a.hasOwnProperty(c) && GeoGlobe.Util.getType(a[c]) === "array" ? GeoGlobe.Util.deepExtend(a[c], arguments[b][c]) : a[c] = GeoGlobe.Util.deepExtend([], arguments[b][c]);
- break;
- case "object":
- a.hasOwnProperty(c) && GeoGlobe.Util.getType(a[c]) === "object" ? GeoGlobe.Util.deepExtend(a[c], arguments[b][c]) : a[c] = GeoGlobe.Util.deepExtend({},
- arguments[b][c]);
- break;
- default:
- a[c] = arguments[b][c]
- }
- return a
- };
- GeoGlobe.Serializable = GeoGlobe.Class({
- initialize: function() {},
- serialize: function() {
- throw "please extend this method";
- },
- CLASS_NAME: "GeoGlobe.Serializable"
- });
- (function() {
- function a(a) {
- for (var b = 0; b < a.length; b++)
- if (a[b] in c) return a[b];
- return a[0]
- }
- function b(a) {
- a.preventDefault();
- a.stopPropagation();
- window.removeEventListener("click", b, !0)
- }
- GeoGlobe.DOM = GeoGlobe.DOM || {};
- GeoGlobe.DOM.create = function(a, b, c) {
- a = window.document.createElement(a);
- if (b) a.className = b;
- c && c.appendChild(a);
- return a
- };
- var c = window.document.documentElement.style,
- d = a(["userSelect", "MozUserSelect", "WebkitUserSelect", "msUserSelect"]),
- e;
- GeoGlobe.DOM.disableDrag = function() {
- d && (e = c[d], c[d] =
- "none")
- };
- GeoGlobe.DOM.enableDrag = function() {
- d && (c[d] = e)
- };
- var f = a(["transform", "WebkitTransform"]);
- GeoGlobe.DOM.setTransform = function(a, b) {
- a.style[f] = b
- };
- GeoGlobe.DOM.suppressClick = function() {
- window.addEventListener("click", b, !0);
- window.setTimeout(function() {
- window.removeEventListener("click", b, !0)
- }, 0)
- };
- GeoGlobe.DOM.mousePos = function(a, b) {
- var c = a.getBoundingClientRect(),
- b = b.touches ? b.touches[0] : b;
- return new mapboxgl.Point(b.clientX - c.left - a.clientLeft, b.clientY - c.top - a.clientTop)
- };
- GeoGlobe.DOM.touchPos =
- function(a, b) {
- for (var c = a.getBoundingClientRect(), d = [], e = b.type === "touchend" ? b.changedTouches : b.touches, f = 0; f < e.length; f++) d.push(new mapboxgl.Point(e[f].clientX - c.left - a.clientLeft, e[f].clientY - c.top - a.clientTop));
- return d
- };
- GeoGlobe.DOM.remove = function(a) {
- a.parentNode && a.parentNode.removeChild(a)
- }
- })();
- GeoGlobe.Util = GeoGlobe.Util || {};
- GeoGlobe.Util.getElement = function() {
- for (var a = [], b = 0, c = arguments.length; b < c; b++) {
- var d = arguments[b];
- typeof d == "string" && (d = document.getElementById(d));
- if (arguments.length == 1) return d;
- a.push(d)
- }
- return a
- };
- GeoGlobe.Util.isElement = function(a) {
- return !!(a && a.nodeType === 1)
- };
- GeoGlobe.Util.isArray = function(a) {
- return Object.prototype.toString.call(a) === "[object Array]"
- };
- GeoGlobe.Util.removeItem = function(a, b) {
- for (var c = a.length - 1; c >= 0; c--) a[c] == b && a.splice(c, 1);
- return a
- };
- GeoGlobe.Util.indexOf = function(a, b) {
- if (typeof a.indexOf == "function") return a.indexOf(b);
- else {
- for (var c = 0, d = a.length; c < d; c++)
- if (a[c] == b) return c;
- return -1
- }
- };
- GeoGlobe.Util.dotless = /\./g;
- GeoGlobe.IMAGE_RELOAD_ATTEMPTS = 0;
- GeoGlobe.Util.alphaHackNeeded = null;
- GeoGlobe.Util.alphaHack = function() {
- if (GeoGlobe.Util.alphaHackNeeded == null) {
- var a = navigator.appVersion.split("MSIE"),
- a = parseFloat(a[1]),
- b = !1;
- try {
- b = !!document.body.filters
- } catch (c) {}
- GeoGlobe.Util.alphaHackNeeded = b && a >= 5.5 && a < 7
- }
- return GeoGlobe.Util.alphaHackNeeded
- };
- GeoGlobe.Util.upperCaseObject = function(a) {
- var b = {},
- c;
- for (c in a) b[c.toUpperCase()] = a[c];
- return b
- };
- GeoGlobe.Util.applyDefaults = function(a, b) {
- var a = a || {},
- c = typeof window.Event == "function" && b instanceof window.Event,
- d;
- for (d in b)
- if (a[d] === void 0 || !c && b.hasOwnProperty && b.hasOwnProperty(d) && !a.hasOwnProperty(d)) a[d] = b[d];
- if (!c && b && b.hasOwnProperty && b.hasOwnProperty("toString") && !a.hasOwnProperty("toString")) a.toString = b.toString;
- return a
- };
- GeoGlobe.Util.getParameterString = function(a, b) {
- var b = b !== void 0 ? !!b : !1,
- c = [],
- d;
- for (d in a) {
- var e = a[d];
- if (e != null && typeof e != "function") {
- if (typeof e == "object" && e.constructor == Array) {
- for (var f = [], g, h = 0, j = e.length; h < j; h++) g = e[h], f.push(encodeURIComponent(g === null || g === void 0 ? "" : g));
- e = f.join(",")
- } else e = encodeURIComponent(e);
- b ? c.push(encodeURIComponent(d) + "=" + e) : c.push(d.toUpperCase() + "=" + decodeURIComponent(e))
- }
- }
- return c.join("&")
- };
- GeoGlobe.Util.urlAppend = function(a, b) {
- var c = a;
- if (b) {
- var d = (a + " ").split(/[?&]/);
- c += d.pop() === " " ? b : d.length ? "&" + b : "?" + b
- }
- return c
- };
- GeoGlobe.Util.getImagesLocation = function() {
- return GeoGlobe.ImgPath || GeoGlobe._getScriptLocation() + "img/"
- };
- GeoGlobe.Util.getImageLocation = function(a) {
- return GeoGlobe.Util.getImagesLocation() + a
- };
- GeoGlobe.Util.Try = function() {
- for (var a = null, b = 0, c = arguments.length; b < c; b++) {
- var d = arguments[b];
- try {
- a = d();
- break
- } catch (e) {}
- }
- return a
- };
- GeoGlobe.Util.getXmlNodeValue = function(a) {
- var b = null;
- GeoGlobe.Util.Try(function() {
- b = a.text;
- if (!b) b = a.textContent;
- if (!b) b = a.firstChild.nodeValue
- }, function() {
- b = a.textContent
- });
- return b
- };
- GeoGlobe.Util.mouseLeft = function(a, b) {
- for (var c = a.relatedTarget ? a.relatedTarget : a.toElement; c != b && c != null;) c = c.parentNode;
- return c != b
- };
- GeoGlobe.Util.DEFAULT_PRECISION = 14;
- GeoGlobe.Util.toFloat = function(a, b) {
- if (b == null) b = GeoGlobe.Util.DEFAULT_PRECISION;
- typeof a !== "number" && (a = parseFloat(a));
- return b === 0 ? a : parseFloat(a.toPrecision(b))
- };
- GeoGlobe.Util.rad = function(a) {
- return a * Math.PI / 180
- };
- GeoGlobe.Util.deg = function(a) {
- return a * 180 / Math.PI
- };
- GeoGlobe.Util.VincentyConstants = {
- a: 6378137,
- b: 6356752.3142,
- f: 1 / 298.257223563
- };
- GeoGlobe.Util.distVincenty = function(a, b) {
- for (var c = GeoGlobe.Util.VincentyConstants, d = c.a, e = c.b, c = c.f, f = GeoGlobe.Util.rad(b.lng - a.lng), g = Math.atan((1 - c) * Math.tan(GeoGlobe.Util.rad(a.lat))), h = Math.atan((1 - c) * Math.tan(GeoGlobe.Util.rad(b.lat))), j = Math.sin(g), g = Math.cos(g), l = Math.sin(h), h = Math.cos(h), m = f, n = 2 * Math.PI, p = 20; Math.abs(m - n) > 1.0E-12 && --p > 0;) {
- var q = Math.sin(m),
- o = Math.cos(m),
- s = Math.sqrt(h * q * h * q + (g * l - j * h * o) * (g * l - j * h * o));
- if (s == 0) return 0;
- var o = j * l + g * h * o,
- r = Math.atan2(s, o),
- t = Math.asin(g * h * q / s),
- u =
- Math.cos(t) * Math.cos(t),
- q = o - 2 * j * l / u,
- v = c / 16 * u * (4 + c * (4 - 3 * u)),
- n = m,
- m = f + (1 - v) * c * Math.sin(t) * (r + v * s * (q + v * o * (-1 + 2 * q * q)))
- }
- if (p == 0) return NaN;
- d = u * (d * d - e * e) / (e * e);
- c = d / 1024 * (256 + d * (-128 + d * (74 - 47 * d)));
- return (e * (1 + d / 16384 * (4096 + d * (-768 + d * (320 - 175 * d)))) * (r - c * s * (q + c / 4 * (o * (-1 + 2 * q * q) - c / 6 * q * (-3 + 4 * s * s) * (-3 + 4 * q * q))))).toFixed(3) / 1E3
- };
- GeoGlobe.Util.destinationVincenty = function(a, b, c) {
- for (var d = GeoGlobe.Util, e = d.VincentyConstants, f = e.a, g = e.b, e = e.f, h = a.lng, j = a.lat, a = d.rad(b), b = Math.sin(a), a = Math.cos(a), l = (1 - e) * Math.tan(d.rad(j)), j = 1 / Math.sqrt(1 + l * l), m = l * j, n = Math.atan2(l, a), l = j * b, p = 1 - l * l, f = p * (f * f - g * g) / (g * g), q = 1 + f / 16384 * (4096 + f * (-768 + f * (320 - 175 * f))), o = f / 1024 * (256 + f * (-128 + f * (74 - 47 * f))), f = c / (g * q), s = 2 * Math.PI; Math.abs(f - s) > 1.0E-12;) var r = Math.cos(2 * n + f),
- t = Math.sin(f),
- u = Math.cos(f),
- v = o * t * (r + o / 4 * (u * (-1 + 2 * r * r) - o / 6 * r * (-3 + 4 * t * t) * (-3 + 4 * r * r))),
- s = f,
- f = c / (g * q) + v;
- c = m * t - j * u * a;
- c = Math.atan2(m * u + j * t * a, (1 - e) * Math.sqrt(l * l + c * c));
- g = e / 16 * p * (4 + e * (4 - 3 * p));
- return new GeoGlobe.LngLat(h + d.deg(Math.atan2(t * b, j * u - m * t * a) - (1 - g) * e * l * (f + g * t * (r + g * u * (-1 + 2 * r * r)))), d.deg(c))
- };
- GeoGlobe.Util.getParameters = function(a, b) {
- var b = b || {},
- a = a === null || a === void 0 ? window.location.href : a,
- c = "";
- if (GeoGlobe.String.contains(a, "?")) var d = a.indexOf("?") + 1,
- c = GeoGlobe.String.contains(a, "#") ? a.indexOf("#") : a.length,
- c = a.substring(d, c);
- for (var d = {}, c = c.split(/[&;]/), e = 0, f = c.length; e < f; ++e) {
- var g = c[e].split("=");
- if (g[0]) {
- var h = g[0];
- try {
- h = decodeURIComponent(h)
- } catch (j) {
- h = unescape(h)
- }
- g = (g[1] || "").replace(/\+/g, " ");
- try {
- g = decodeURIComponent(g)
- } catch (l) {
- g = unescape(g)
- }
- b.splitArgs !== !1 && (g = g.split(","));
- g.length == 1 && (g = g[0]);
- d[h] = g
- }
- }
- return d
- };
- GeoGlobe.Util.lastSeqID = 0;
- GeoGlobe.Util.createUniqueID = function(a) {
- a = a == null ? "id_" : a.replace(GeoGlobe.Util.dotless, "_");
- GeoGlobe.Util.lastSeqID += 1;
- return a + GeoGlobe.Util.lastSeqID
- };
- GeoGlobe.INCHES_PER_UNIT = {
- inches: 1,
- ft: 12,
- mi: 63360,
- m: 1 / 0.0254,
- km: 39370,
- dd: 4374754,
- yd: 36
- };
- GeoGlobe.INCHES_PER_UNIT["in"] = GeoGlobe.INCHES_PER_UNIT.inches;
- GeoGlobe.INCHES_PER_UNIT.degrees = GeoGlobe.INCHES_PER_UNIT.dd;
- GeoGlobe.INCHES_PER_UNIT.nmi = 1852 * GeoGlobe.INCHES_PER_UNIT.m;
- GeoGlobe.METERS_PER_INCH = 0.0254000508001016;
- GeoGlobe.Util.extend(GeoGlobe.INCHES_PER_UNIT, {
- Inch: GeoGlobe.INCHES_PER_UNIT.inches,
- Meter: 1 / GeoGlobe.METERS_PER_INCH,
- Foot: 0.3048006096012192 / GeoGlobe.METERS_PER_INCH,
- IFoot: 0.3048 / GeoGlobe.METERS_PER_INCH,
- ClarkeFoot: 0.3047972651151 / GeoGlobe.METERS_PER_INCH,
- SearsFoot: 0.30479947153867626 / GeoGlobe.METERS_PER_INCH,
- GoldCoastFoot: 0.3047997101815088 / GeoGlobe.METERS_PER_INCH,
- IInch: 0.0254 / GeoGlobe.METERS_PER_INCH,
- MicroInch: 2.54E-5 / GeoGlobe.METERS_PER_INCH,
- Mil: 2.54E-8 / GeoGlobe.METERS_PER_INCH,
- Centimeter: 0.01 /
- GeoGlobe.METERS_PER_INCH,
- Kilometer: 1E3 / GeoGlobe.METERS_PER_INCH,
- Yard: 0.9144018288036576 / GeoGlobe.METERS_PER_INCH,
- SearsYard: 0.914398414616029 / GeoGlobe.METERS_PER_INCH,
- IndianYard: 0.9143985307444408 / GeoGlobe.METERS_PER_INCH,
- IndianYd37: 0.91439523 / GeoGlobe.METERS_PER_INCH,
- IndianYd62: 0.9143988 / GeoGlobe.METERS_PER_INCH,
- IndianYd75: 0.9143985 / GeoGlobe.METERS_PER_INCH,
- IndianFoot: 0.30479951 / GeoGlobe.METERS_PER_INCH,
- IndianFt37: 0.30479841 / GeoGlobe.METERS_PER_INCH,
- IndianFt62: 0.3047996 / GeoGlobe.METERS_PER_INCH,
- IndianFt75: 0.3047995 /
- GeoGlobe.METERS_PER_INCH,
- Mile: 1609.3472186944373 / GeoGlobe.METERS_PER_INCH,
- IYard: 0.9144 / GeoGlobe.METERS_PER_INCH,
- IMile: 1609.344 / GeoGlobe.METERS_PER_INCH,
- NautM: 1852 / GeoGlobe.METERS_PER_INCH,
- "Lat-66": 110943.31648893273 / GeoGlobe.METERS_PER_INCH,
- "Lat-83": 110946.25736872235 / GeoGlobe.METERS_PER_INCH,
- Decimeter: 0.1 / GeoGlobe.METERS_PER_INCH,
- Millimeter: 0.001 / GeoGlobe.METERS_PER_INCH,
- Dekameter: 10 / GeoGlobe.METERS_PER_INCH,
- Decameter: 10 / GeoGlobe.METERS_PER_INCH,
- Hectometer: 100 / GeoGlobe.METERS_PER_INCH,
- GermanMeter: 1.0000135965 /
- GeoGlobe.METERS_PER_INCH,
- CaGrid: 0.999738 / GeoGlobe.METERS_PER_INCH,
- ClarkeChain: 20.1166194976 / GeoGlobe.METERS_PER_INCH,
- GunterChain: 20.11684023368047 / GeoGlobe.METERS_PER_INCH,
- BenoitChain: 20.116782494375872 / GeoGlobe.METERS_PER_INCH,
- SearsChain: 20.11676512155 / GeoGlobe.METERS_PER_INCH,
- ClarkeLink: 0.201166194976 / GeoGlobe.METERS_PER_INCH,
- GunterLink: 0.2011684023368047 / GeoGlobe.METERS_PER_INCH,
- BenoitLink: 0.20116782494375873 / GeoGlobe.METERS_PER_INCH,
- SearsLink: 0.2011676512155 / GeoGlobe.METERS_PER_INCH,
- Rod: 5.02921005842012 /
- GeoGlobe.METERS_PER_INCH,
- IntnlChain: 20.1168 / GeoGlobe.METERS_PER_INCH,
- IntnlLink: 0.201168 / GeoGlobe.METERS_PER_INCH,
- Perch: 5.02921005842012 / GeoGlobe.METERS_PER_INCH,
- Pole: 5.02921005842012 / GeoGlobe.METERS_PER_INCH,
- Furlong: 201.1684023368046 / GeoGlobe.METERS_PER_INCH,
- Rood: 3.778266898 / GeoGlobe.METERS_PER_INCH,
- CapeFoot: 0.3047972615 / GeoGlobe.METERS_PER_INCH,
- Brealey: 375 / GeoGlobe.METERS_PER_INCH,
- ModAmFt: 0.304812252984506 / GeoGlobe.METERS_PER_INCH,
- Fathom: 1.8288 / GeoGlobe.METERS_PER_INCH,
- "NautM-UK": 1853.184 / GeoGlobe.METERS_PER_INCH,
- "50kilometers": 5E4 / GeoGlobe.METERS_PER_INCH,
- "150kilometers": 15E4 / GeoGlobe.METERS_PER_INCH
- });
- GeoGlobe.Util.extend(GeoGlobe.INCHES_PER_UNIT, {
- mm: GeoGlobe.INCHES_PER_UNIT.Meter / 1E3,
- cm: GeoGlobe.INCHES_PER_UNIT.Meter / 100,
- dm: GeoGlobe.INCHES_PER_UNIT.Meter * 100,
- km: GeoGlobe.INCHES_PER_UNIT.Meter * 1E3,
- kmi: GeoGlobe.INCHES_PER_UNIT.nmi,
- fath: GeoGlobe.INCHES_PER_UNIT.Fathom,
- ch: GeoGlobe.INCHES_PER_UNIT.IntnlChain,
- link: GeoGlobe.INCHES_PER_UNIT.IntnlLink,
- "us-in": GeoGlobe.INCHES_PER_UNIT.inches,
- "us-ft": GeoGlobe.INCHES_PER_UNIT.Foot,
- "us-yd": GeoGlobe.INCHES_PER_UNIT.Yard,
- "us-ch": GeoGlobe.INCHES_PER_UNIT.GunterChain,
- "us-mi": GeoGlobe.INCHES_PER_UNIT.Mile,
- "ind-yd": GeoGlobe.INCHES_PER_UNIT.IndianYd37,
- "ind-ft": GeoGlobe.INCHES_PER_UNIT.IndianFt37,
- "ind-ch": 20.11669506 / GeoGlobe.METERS_PER_INCH
- });
- GeoGlobe.DOTS_PER_INCH = 96;
- GeoGlobe.Util.normalizeScale = function(a) {
- return a > 1 ? 1 / a : a
- };
- GeoGlobe.Util.getResolutionFromScale = function(a, b) {
- var c;
- a && (b == null && (b = "degrees"), c = 1 / (GeoGlobe.Util.normalizeScale(a) * GeoGlobe.INCHES_PER_UNIT[b] * GeoGlobe.DOTS_PER_INCH));
- return c
- };
- GeoGlobe.Util.getScaleFromResolution = function(a, b) {
- b == null && (b = "degrees");
- return a * GeoGlobe.INCHES_PER_UNIT[b] * GeoGlobe.DOTS_PER_INCH
- };
- GeoGlobe.Util.pagePosition = function(a) {
- var b = [0, 0],
- c = GeoGlobe.Util.getViewportElement();
- if (!a || a == window || a == c) return b;
- var d = GeoGlobe.IS_GECKO && document.getBoxObjectFor && GeoGlobe.Element.getStyle(a, "position") == "absolute" && (a.style.top == "" || a.style.left == ""),
- e = null;
- if (a.getBoundingClientRect) a = a.getBoundingClientRect(), e = window.pageYOffset || c.scrollTop, b[0] = a.left + (window.pageXOffset || c.scrollLeft), b[1] = a.top + e;
- else if (document.getBoxObjectFor && !d) a = document.getBoxObjectFor(a), c = document.getBoxObjectFor(c),
- b[0] = a.screenX - c.screenX, b[1] = a.screenY - c.screenY;
- else {
- b[0] = a.offsetLeft;
- b[1] = a.offsetTop;
- e = a.offsetParent;
- if (e != a)
- for (; e;) b[0] += e.offsetLeft, b[1] += e.offsetTop, e = e.offsetParent;
- c = GeoGlobe.BROWSER_NAME;
- if (c == "opera" || c == "safari" && GeoGlobe.Element.getStyle(a, "position") == "absolute") b[1] -= document.body.offsetTop;
- for (e = a.offsetParent; e && e != document.body;) {
- b[0] -= e.scrollLeft;
- if (c != "opera" || e.tagName != "TR") b[1] -= e.scrollTop;
- e = e.offsetParent
- }
- }
- return b
- };
- GeoGlobe.Util.getViewportElement = function() {
- var a = arguments.callee.viewportElement;
- if (a == void 0) a = GeoGlobe.BROWSER_NAME == "msie" && document.compatMode != "CSS1Compat" ? document.body : document.documentElement, arguments.callee.viewportElement = a;
- return a
- };
- GeoGlobe.Util.isEquivalentUrl = function(a, b, c) {
- c = c || {};
- GeoGlobe.Util.applyDefaults(c, {
- ignoreCase: !0,
- ignorePort80: !0,
- ignoreHash: !0,
- splitArgs: !1
- });
- var a = GeoGlobe.Util.createUrlObject(a, c),
- b = GeoGlobe.Util.createUrlObject(b, c),
- d;
- for (d in a)
- if (d !== "args" && a[d] != b[d]) return !1;
- for (d in a.args) {
- if (a.args[d] != b.args[d]) return !1;
- delete b.args[d]
- }
- for (d in b.args) return !1;
- return !0
- };
- GeoGlobe.Util.createUrlObject = function(a, b) {
- b = b || {};
- if (!/^\w+:\/\//.test(a)) {
- var c = window.location,
- d = c.port ? ":" + c.port : "",
- d = c.protocol + "//" + c.host.split(":").shift() + d;
- a.indexOf("/") === 0 ? a = d + a : (c = c.pathname.split("/"), c.pop(), a = d + c.join("/") + "/" + a)
- }
- b.ignoreCase && (a = a.toLowerCase());
- c = document.createElement("a");
- c.href = a;
- d = {};
- d.host = c.host.split(":").shift();
- d.protocol = c.protocol;
- d.port = b.ignorePort80 ? c.port == "80" || c.port == "0" ? "" : c.port : c.port == "" || c.port == "0" ? "80" : c.port;
- d.hash = b.ignoreHash || c.hash ===
- "#" ? "" : c.hash;
- var e = c.search;
- e || (e = a.indexOf("?"), e = e != -1 ? a.substr(e) : "");
- d.args = GeoGlobe.Util.getParameters(e, {
- splitArgs: b.splitArgs
- });
- d.pathname = c.pathname.charAt(0) == "/" ? c.pathname : "/" + c.pathname;
- return d
- };
- GeoGlobe.Util.removeTail = function(a) {
- var b = null,
- b = a.indexOf("?"),
- c = a.indexOf("#");
- return b = b == -1 ? c != -1 ? a.substr(0, c) : a : c != -1 ? a.substr(0, Math.min(b, c)) : a.substr(0, b)
- };
- GeoGlobe.IS_GECKO = function() {
- var a = navigator.userAgent.toLowerCase();
- return a.indexOf("webkit") == -1 && a.indexOf("gecko") != -1
- }();
- GeoGlobe.CANVAS_SUPPORTED = function() {
- var a = document.createElement("canvas");
- return !(!a.getContext || !a.getContext("2d"))
- }();
- GeoGlobe.BROWSER_NAME = function() {
- var a = "",
- b = navigator.userAgent.toLowerCase();
- b.indexOf("opera") != -1 ? a = "opera" : b.indexOf("msie") != -1 ? a = "msie" : b.indexOf("safari") != -1 ? a = "safari" : b.indexOf("mozilla") != -1 && (a = b.indexOf("firefox") != -1 ? "firefox" : "mozilla");
- return a
- }();
- GeoGlobe.Util.getBrowserName = function() {
- return GeoGlobe.BROWSER_NAME
- };
- GeoGlobe.Util.getRenderedDimensions = function(a, b, c) {
- var d, e, f = document.createElement("div");
- f.style.visibility = "hidden";
- for (var g = c && c.containerElement ? c.containerElement : document.body, h = !1, j = null, l = g; l && l.tagName.toLowerCase() != "body";) {
- var m = GeoGlobe.Element.getStyle(l, "position");
- if (m == "absolute") {
- h = !0;
- break
- } else if (m && m != "static") break;
- l = l.parentNode
- }
- if (h && (g.clientHeight === 0 || g.clientWidth === 0)) j = document.createElement("div"), j.style.visibility = "hidden", j.style.position = "absolute", j.style.overflow =
- "visible", j.style.width = document.body.clientWidth + "px", j.style.height = document.body.clientHeight + "px", j.appendChild(f);
- f.style.position = "absolute";
- if (b)
- if (b.w) d = b.w, f.style.width = d + "px";
- else if (b.h) e = b.h, f.style.height = e + "px";
- if (c && c.displayClass) f.className = c.displayClass;
- b = document.createElement("div");
- b.innerHTML = a;
- b.style.overflow = "visible";
- if (b.childNodes) {
- a = 0;
- for (c = b.childNodes.length; a < c; a++)
- if (b.childNodes[a].style) b.childNodes[a].style.overflow = "visible"
- }
- f.appendChild(b);
- j ? g.appendChild(j) :
- g.appendChild(f);
- if (!d) d = parseInt(b.scrollWidth), f.style.width = d + "px";
- e || (e = parseInt(b.scrollHeight));
- f.removeChild(b);
- j ? (j.removeChild(f), g.removeChild(j)) : g.removeChild(f);
- return new GeoGlobe.Size(d, e)
- };
- GeoGlobe.Util.getScrollbarWidth = function() {
- var a = GeoGlobe.Util._scrollbarWidth;
- if (a == null) {
- var b = null,
- c = null,
- b = a = 0,
- b = document.createElement("div");
- b.style.position = "absolute";
- b.style.top = "-1000px";
- b.style.left = "-1000px";
- b.style.width = "100px";
- b.style.height = "50px";
- b.style.overflow = "hidden";
- c = document.createElement("div");
- c.style.width = "100%";
- c.style.height = "200px";
- b.appendChild(c);
- document.body.appendChild(b);
- a = c.offsetWidth;
- b.style.overflow = "scroll";
- b = c.offsetWidth;
- document.body.removeChild(document.body.lastChild);
- GeoGlobe.Util._scrollbarWidth = a - b;
- a = GeoGlobe.Util._scrollbarWidth
- }
- return a
- };
- GeoGlobe.Util.randomStr = function(a) {
- for (var b = "", c = [], d = 0; d < a; d++) c.push(String.fromCharCode(97 + Math.ceil(Math.random() * 25)));
- for (d = 0; d < a; d++) b += c[d];
- return b
- };
- GeoGlobe.Util.globalEval = function(a) {
- a && GeoGlobe.String.trim(a) && (window.execScript || function(a) {
- window.eval.call(window, a)
- })(a)
- };
- GeoGlobe.Util.getResolutionFromScale_DPI = function(a, b, c) {
- var d;
- a && (b == null && (b = "degrees"), d = 1 / (GeoGlobe.Util.normalizeScale(a) * GeoGlobe.INCHES_PER_UNIT[b] * c));
- return d
- };
- GeoGlobe.Util.getScaleFromResolution_DPI = function(a, b, c) {
- b == null && (b = "degrees");
- return a * GeoGlobe.INCHES_PER_UNIT[b] * c
- };
- GeoGlobe.Util.getMapLevelFormResolution = function(a, b) {
- if (!b) return 0;
- var c, d, e = Number.POSITIVE_INFINITY,
- f = a.getResolutions();
- c = 0;
- for (len = f.length; c < len; c++) {
- d = Math.abs(f[c] - b);
- if (d > e) break;
- e = d
- }
- return Math.max(0, c - 1)
- };
- GeoGlobe.Util.getMapLevelFormScale = function(a, b, c, d) {
- b = GeoGlobe.Util.getResolutionFromScale_DPI(b, c ? c : "degrees", d ? d : 96);
- return GeoGlobe.Util.getMapLevelFormResolution(a, b)
- };
- GeoGlobe.Util.delayFun = function(a, b, c) {
- var d;
- return function() {
- var e = this,
- f = arguments,
- g = c && !d;
- clearTimeout(d);
- d = setTimeout(function() {
- d = null;
- c || a.apply(e, f)
- }, b);
- g && a.apply(e, f)
- }
- };
- GeoGlobe.Util.clone = function(a) {
- if (typeof a != "object") return a;
- if (a == null) return a;
- var b = a.constructor == Array ? [] : {},
- c;
- for (c in a) b[c] = GeoGlobe.Util.clone(a[c]);
- return b
- };
- GeoGlobe.Util.getType = function(a) {
- if (a instanceof Element) return "element";
- return {
- "[object Boolean]": "boolean",
- "[object Number]": "number",
- "[object String]": "string",
- "[object Function]": "function",
- "[object Array]": "array",
- "[object Date]": "date",
- "[object RegExp]": "regExp",
- "[object Undefined]": "undefined",
- "[object Null]": "null",
- "[object Object]": "object"
- }[Object.prototype.toString.call(a)]
- };
- GeoGlobe.Util.formatNumberToThousands = function(a, b, c) {
- a = a.toString().replace(/\$|\,/g, "");
- isNaN(a) && (a = "0");
- for (var d = a === (a = Math.abs(a)), a = Math.floor(a * Math.pow(10, b) + 0.50000000001), e = a % Math.pow(10, b), a = Math.floor(a / Math.pow(10, b)).toString(), e = e.toString(); e.length < b;) e = "0" + e;
- if (c)
- for (c = 0; c < Math.floor((a.length - (1 + c)) / 3); c++) a = a.substring(0, a.length - (4 * c + 3)) + "," + a.substring(a.length - (4 * c + 3));
- return b > 0 ? (d ? "" : "-") + a + "." + e : (d ? "" : "-") + a
- };
- GeoGlobe.Util.getFormattedString = function(a, b) {
- var c;
- c = b.replace(/{a}/g, a.a);
- c = c.replace(/{b}/g, a.b);
- if (c.contains("{c"))
- for (var d = c.split("{c"), e = 0, f = 0; f < d.length - 1; f++) e = d[f + 1].split("}")[0], c = c.replace(RegExp("{c" + e + "}", "g"), GeoGlobe.Util.formatNumberToThousands(parseFloat(a.c), e === "" ? 2 : e, !0));
- return c
- };
- GeoGlobe.Util.getGradientImageData = function(a) {
- var b = document.createElement("canvas"),
- c = b.getContext("2d");
- b.width = 1;
- b.height = 256;
- var b = c.createLinearGradient(0, 0, 0, 256),
- d = 1,
- e;
- for (e in a) a.hasOwnProperty(e) && Number(e) > d && (d = Number(e));
- for (e in a) a.hasOwnProperty(e) && b.addColorStop(Number(e) / d, a[e]);
- c.fillStyle = b;
- c.fillRect(0, 0, 1, 256);
- return c.getImageData(0, 0, 1, 256).data
- };
- GeoGlobe.Util.getRgbColor = function(a) {
- var a = a.toLowerCase(),
- b = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
- if (a && b.test(a)) {
- if (a.length === 4) {
- for (var b = "#", c = 1; c < 4; c += 1) b += a.slice(c, c + 1).concat(a.slice(c, c + 1));
- a = b
- }
- b = [];
- for (c = 1; c < 7; c += 2) b.push(parseInt("0x" + a.slice(c, c + 2)));
- return "rgb(" + b.join(",") + ")"
- } else {
- if (a.startsWith("rgba") || a.startsWith("hsla")) return a.substring(0, 3) + a.substring(4, a.lastIndexOf(",")) + ")";
- if (a.startsWith("rgb") || a.startsWith("hsl")) return a;
- return ""
- }
- };
- GeoGlobe.Util.getShadeColor = function(a, b) {
- var a = GeoGlobe.Util.getHexColor(a),
- a = a.substr(1),
- c = parseInt(a, 16),
- d = Math.round(2.55 * b),
- e = (c >> 16) + d,
- f = (c >> 8 & 255) + d,
- c = (c & 255) + d;
- return "#" + (16777216 + (e < 255 ? e < 1 ? 0 : e : 255) * 65536 + (f < 255 ? f < 1 ? 0 : f : 255) * 256 + (c < 255 ? c < 1 ? 0 : c : 255)).toString(16).slice(1)
- };
- GeoGlobe.Util.getHexColor = function(a) {
- a = a.toLowerCase();
- if (/^(rgb|rgba)/.test(a)) {
- for (var b = a.split("(")[1].split(")")[0].split(","), c = "#", d = 0; d < 3; d++) {
- var e = Number(b[d]).toString(16);
- e === "0" && (e += e);
- e.length === 1 && (e = "0" + e);
- c += e
- }
- c.length !== 7 && (c = a);
- return c
- } else if (/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(a))
- if (b = a.replace(/#/, "").split(""), b.length === 6) return a;
- else {
- if (b.length === 3) {
- a = "#";
- for (d = 0; d < b.length; d += 1) a += b[d] + b[d];
- return a
- }
- }
- else return a
- };
- GeoGlobe.Util.transferToLonLat = function(a) {
- return a[1] === -2.3810769323182276E8 ? [a[0] / 2.003750834E7 * 180, -90] : [a[0] / 2.003750834E7 * 180, 180 / Math.PI * (2 * Math.atan(Math.exp(a[1] / 2.003750834E7 * 180 * Math.PI / 180)) - Math.PI / 2)]
- };
- GeoGlobe.Util.transferToMercator = function(a) {
- return a[1] === -90 ? [a[0] * 2.003750834E7 / 180, -2.3810769323182276E8] : [a[0] * 2.003750834E7 / 180, Math.log(Math.tan((90 + a[1]) * Math.PI / 360)) / (Math.PI / 180) * 2.003750834E7 / 180]
- };
- GeoGlobe.Util.formatDate = function(a, b) {
- var c = {
- "M+": a.getMonth() + 1,
- "d+": a.getDate(),
- "h+": a.getHours() % 12 === 0 ? 12 : a.getHours() % 12,
- "H+": a.getHours(),
- "m+": a.getMinutes(),
- "s+": a.getSeconds(),
- "q+": Math.floor((a.getMonth() + 3) / 3),
- S: a.getMilliseconds()
- },
- d = {
- "0": "/u65e5",
- "1": "/u4e00",
- "2": "/u4e8c",
- "3": "/u4e09",
- "4": "/u56db",
- "5": "/u4e94",
- "6": "/u516d"
- };
- /(y+)/.test(b) && (b = b.replace(RegExp.$1, (a.getFullYear() + "").substr(4 - RegExp.$1.length)));
- /(E+)/.test(b) && (b = b.replace(RegExp.$1, (RegExp.$1.length > 1 ? RegExp.$1.length >
- 2 ? "/u661f/u671f" : "/u5468" : "") + d[a.getDay() + ""]));
- for (var e in c) RegExp("(" + e + ")").test(b) && (b = b.replace(RegExp.$1, RegExp.$1.length === 1 ? c[e] : ("00" + c[e]).substr(("" + c[e]).length)));
- return b
- };
- GeoGlobe.Util.pointArrayToSpriteGeoJson = function(a, b, c, d) {
- if (window.turf) {
- c === void 0 && (c = 10);
- d === void 0 && (d = 1);
- var e = {
- type: "FeatureCollection",
- features: []
- };
- if (!a || a && a.units == "degrees") {
- for (var a = [], f = [], g = 0; g < b.length - 1; g++) {
- var h = turf.point(b[g]),
- j = turf.point(b[g + 1]),
- h = turf.distance(h, j, {
- units: "kilometers"
- });
- f.push(h * 1E3)
- }
- g = Math.min.apply(null, f);
- c > g && (c = g);
- for (g = 0; g < b.length - 1; g++) {
- var h = Math.round(f[g] / c),
- j = b[g + 1][0] - b[g][0],
- l = b[g + 1][1] - b[g][1];
- if (h !== 0)
- for (var m = 0; m <= h; m++) a.push([b[g][0] + j /
- h * m, b[g][1] + l / h * m
- ])
- }
- } else {
- a = [];
- f = [];
- for (g = 0; g < b.length - 1; g++) h = turf.point(b[g]), j = turf.point(b[g + 1]), h = Math.sqrt(Math.pow(h[0] - j[0], 2) + Math.pow(h[1] - j[1], 2)), f.push(h);
- g = Math.min.apply(null, f);
- c > g && (c = g);
- for (g = 0; g < b.length - 1; g++)
- if (h = Math.round(f[g] / c), j = b[g + 1][0] - b[g][0], l = b[g + 1][1] - b[g][1], h !== 0)
- for (m = 0; m <= h; m++) a.push([b[g][0] + j / h * m, b[g][1] + l / h * m])
- }
- for (b = 0; b < a.length - 4; b++) c = {
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: [a[b], a[b + 1], a[b + 2], a[b + 3]]
- },
- properties: {
- link_seq: b,
- status: d
- }
- }, e.features.push(c);
- return e
- } else console.error("\u672a\u5f15\u5165turf.js\u5e93\uff01")
- };
- GeoGlobe.Util.pick = function(a, b, c) {
- var d = {};
- if (c === !0)
- for (var e in a) d[e.toUpperCase()] = a[e];
- else d = a;
- a = {};
- for (e = 0; e < b.length; e++) {
- var f = b[e];
- c && (f = f.toUpperCase());
- f in d && (a[f] = d[f])
- }
- return a
- };
- GeoGlobe.Util.pick2 = function(a, b) {
- var c = {},
- d;
- for (d in a) {
- var e = a[d];
- if (d.indexOf(b) === 0) {
- var f = d.slice(b.length),
- f = f[0].toLowerCase() + f.slice(1);
- c[f] = e
- }
- }
- return c
- };
- GeoGlobe.Util.merge2Obj = function(a, b) {
- if (b) {
- if (!a) return b
- } else return a;
- for (var c in b)
- if (b[c] && b[c].constructor == Object) a[c] = GeoGlobe.Util.merge2Obj(a[c], b[c]);
- else if (b[c] && b[c] instanceof Array) {
- if (!a[c] || a[c] instanceof Array) {
- a[c] || (a[c] = []);
- for (var d = 0; d < b[c].length; d++) {
- var e = b[c][d];
- a[c].indexOf(e) === -1 && a[c].push(e)
- }
- }
- } else a[c] = b[c];
- return a
- };
- GeoGlobe.Util.download = function(a, b) {
- var c;
- if (GeoGlobe.Util.getType(a) === "string") {
- c = atob(a.split(",")[1] || a.split(",")[0]);
- for (var d = c.length, e = new Uint8Array(d), f = 0; f < d; f++) e[f] = c.charCodeAt(f);
- a = new Blob([e])
- }
- if (a instanceof Blob) {
- if (a.size === 0) throw "\u6587\u4ef6\u4e0b\u8f7d\uff1a\u7a7a\u6570\u636e\uff01";
- c = URL.createObjectURL(a)
- } else throw "\u4e0d\u652f\u6301\u7684\u6587\u4ef6\u4e0b\u8f7d\uff01";
- window.navigator.msSaveBlob ? (window.navigator.msSaveBlob(c, b), URL.revokeObjectURL(c)) : (d = document.createElement("a"),
- d.style.display = "none", d.href = c, d.download = b, document.body.appendChild(d), d.click(), URL.revokeObjectURL(d.href), document.body.removeChild(d))
- };
- (function(a) {
- typeof exports === "object" && typeof module !== "undefined" ? module.exports = a() : typeof define === "function" && define.amd ? define([], a) : (typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : this).proj4cn = a()
- })(function() {
- return function b(c, d, e) {
- function f(h, l) {
- if (!d[h]) {
- if (!c[h]) {
- var m = typeof require == "function" && require;
- if (!l && m) return m(h, !0);
- if (g) return g(h, !0);
- m = Error("Cannot find module '" + h + "'");
- throw m.code = "MODULE_NOT_FOUND", m;
- }
- m = d[h] = {
- exports: {}
- };
- c[h][0].call(m.exports, function(b) {
- var d = c[h][1][b];
- return f(d ? d : b)
- }, m, m.exports, b, c, d, e)
- }
- return d[h].exports
- }
- for (var g = typeof require == "function" && require, h = 0; h < e.length; h++) f(e[h]);
- return f
- }({
- 1: [function(b, c, d) {
- var c = b("../util").forEachPoint,
- e = b("./gcj-02"),
- f = Math.PI * 3E3 / 180,
- g = d.toGCJ02 = c(function(b, c, d) {
- var e = b[d] - 0.0065,
- g = b[d + 1] - 0.006,
- b = Math.sqrt(e * e + g * g) - 2.0E-5 * Math.sin(g * f),
- e = Math.atan2(g, e) - 3.0E-6 * Math.cos(e * f);
- c[d] = b * Math.cos(e);
- c[d + 1] = b * Math.sin(e);
- return c
- }),
- h = d.fromGCJ02 = c(function(b,
- c, d) {
- var e = b[d],
- g = b[d + 1],
- b = Math.sqrt(e * e + g * g) + 2.0E-5 * Math.sin(g * f),
- e = Math.atan2(g, e) + 3.0E-6 * Math.cos(e * f);
- c[d] = b * Math.cos(e) + 0.0065;
- c[d + 1] = b * Math.sin(e) + 0.006;
- return c
- });
- d.toWGS84 = function(b, c, d) {
- b = g(b, c, d);
- return e.toWGS84(b, b, d)
- };
- d.fromWGS84 = function(b, c, d) {
- b = e.fromWGS84(b, c, d);
- return h(b, b, d)
- }
- }, {
- "../util": 8,
- "./gcj-02": 2
- }],
- 2: [function(b, c, d) {
- function e(b, c) {
- var d, e = b - 105,
- f = c - 35;
- d = -100 + 2 * e + 3 * f + 0.2 * f * f + 0.1 * e * f + 0.2 * Math.sqrt(Math.abs(e));
- d += (20 * Math.sin(6 * e * g) + 20 * Math.sin(2 * e * g)) * 2 / 3;
- d += (20 * Math.sin(f *
- g) + 40 * Math.sin(f / 3 * g)) * 2 / 3;
- d += (160 * Math.sin(f / 12 * g) + 320 * Math.sin(f * g / 30)) * 2 / 3;
- f = b - 105;
- e = c - 35;
- e = 300 + f + 2 * e + 0.1 * f * f + 0.1 * f * e + 0.1 * Math.sqrt(Math.abs(f));
- e += (20 * Math.sin(6 * f * g) + 20 * Math.sin(2 * f * g)) * 2 / 3;
- e += (20 * Math.sin(f * g) + 40 * Math.sin(f / 3 * g)) * 2 / 3;
- e += (150 * Math.sin(f / 12 * g) + 300 * Math.sin(f / 30 * g)) * 2 / 3;
- var f = c / 180 * g,
- o = Math.sin(f),
- o = 1 - j * o * o,
- s = Math.sqrt(o);
- d = d * 180 / (h * (1 - j) / (o * s) * g);
- e = e * 180 / (h / s * Math.cos(f) * g);
- return [e, d]
- }
- function f(b, c) {
- if (b < 72.004 || b > 137.8347) return !0;
- if (c < 0.8293 || c > 55.8271) return !0;
- return !1
- }
- var b =
- b("../util").forEachPoint,
- g = Math.PI,
- h = 6378245,
- j = 0.006693421622965943;
- d.toWGS84 = b(function(b, c, d) {
- var g = b[d],
- b = b[d + 1];
- if (!f(g, b)) {
- var h = e(g, b);
- g -= h[0];
- b -= h[1]
- }
- c[d] = g;
- c[d + 1] = b
- });
- d.fromWGS84 = b(function(b, c, d) {
- var g = b[d],
- b = b[d + 1];
- if (!f(g, b)) {
- var h = e(g, b);
- g += h[0];
- b += h[1]
- }
- c[d] = g;
- c[d + 1] = b
- })
- }, {
- "../util": 8
- }],
- 3: [function(b, c, d) {
- d.bd09 = b("./bd-09");
- d.gcj02 = b("./gcj-02")
- }, {
- "./bd-09": 1,
- "./gcj-02": 2
- }],
- 4: [function(b, c, d) {
- var e = b("./projection/index"),
- f = b("./datum/index");
- d.smerc2bmerc = function(b, c, d) {
- b = e.sphericalMercator.inverse(b,
- c, d);
- b = f.bd09.fromWGS84(b, b, d);
- return e.baiduMercator.forward(b, b, d)
- };
- d.bmerc2smerc = function(b, c, d) {
- b = e.baiduMercator.inverse(b, c, d);
- b = f.bd09.toWGS84(b, b, d);
- return e.sphericalMercator.forward(b, b, d)
- };
- d.bmerc2ll = function(b, c, d) {
- b = e.baiduMercator.inverse(b, c, d);
- return f.bd09.toWGS84(b, b, d)
- };
- d.ll2bmerc = function(b, c, d) {
- b = f.bd09.fromWGS84(b, c, d);
- return e.baiduMercator.forward(b, b, d)
- };
- d.ll2smerc = e.sphericalMercator.forward;
- d.smerc2ll = e.sphericalMercator.inverse;
- d.datum = f;
- d.projection = e;
- d.gcj02towgs84 = function(b,
- c, d) {
- return f.gcj02.toWGS84(b, c, d)
- };
- d.wgs84togcj02 = function(b, c, d) {
- return f.gcj02.fromWGS84(b, c, d)
- }
- }, {
- "./datum/index": 3,
- "./projection/index": 6
- }],
- 5: [function(b, c, d) {
- function e(b, c, d, e) {
- var f = b[d],
- b = b[d + 1],
- g = Math.abs(b) / e[9],
- g = e[2] + e[3] * g + e[4] * g * g + e[5] * g * g * g + e[6] * g * g * g * g + e[7] * g * g * g * g * g + e[8] * g * g * g * g * g * g;
- c[d] = (e[0] + e[1] * Math.abs(f)) * (f < 0 ? -1 : 1);
- c[d + 1] = g * (b < 0 ? -1 : 1)
- }
- var b = b("../util").forEachPoint,
- f = [1.289059486E7, 8362377.87, 5591021, 3481989.83, 1678043.12, 0],
- g = [75, 60, 45, 30, 15, 0],
- h = [
- [1.410526172116255E-8,
- 8.98305509648872E-6, -1.9939833816331, 200.9824383106796, -187.2403703815547, 91.6087516669843, -23.38765649603339, 2.57121317296198, -0.03801003308653, 1.73379812E7
- ],
- [-7.435856389565537E-9, 8.983055097726239E-6, -0.78625201886289, 96.32687599759846, -1.85204757529826, -59.36935905485877, 47.40033549296737, -16.50741931063887, 2.28786674699375, 1.026014486E7],
- [-3.030883460898826E-8, 8.98305509983578E-6, 0.30071316287616, 59.74293618442277, 7.357984074871, -25.38371002664745, 13.45380521110908, -3.29883767235584, 0.32710905363475,
- 6856817.37
- ],
- [-1.981981304930552E-8, 8.983055099779535E-6, 0.03278182852591, 40.31678527705744, 0.65659298677277, -4.44255534477492, 0.85341911805263, 0.12923347998204, -0.04625736007561, 4482777.06],
- [3.09191371068437E-9, 8.983055096812155E-6, 6.995724062E-5, 23.10934304144901, -2.3663490511E-4, -0.6321817810242, -0.00663494467273, 0.03430082397953, -0.00466043876332, 2555164.4],
- [2.890871144776878E-9, 8.983055095805407E-6, -3.068298E-8, 7.47137025468032, -3.53937994E-6, -0.02145144861037, -1.234426596E-5, 1.0322952773E-4, -3.23890364E-6, 826088.5]
- ],
- j = [
- [-0.0015702102444, 111320.7020616939, 1704480524535203, -10338987376042340, 26112667856603880, -35149669176653700, 26595700718403920, -10725012454188240, 1800819912950474, 82.5],
- [8.277824516172526E-4, 111320.7020463578, 6.477955746671607E8, -4.082003173641316E9, 1.077490566351142E10, -1.517187553151559E10, 1.205306533862167E10, -5.124939663577472E9, 9.133119359512032E8, 67.5],
- [0.00337398766765, 111320.7020202162, 4481351.045890365, -2.339375119931662E7, 7.968221547186455E7, -1.159649932797253E8,
- 9.723671115602145E7, -4.366194633752821E7, 8477230.501135234, 52.5
- ],
- [0.00220636496208, 111320.7020209128, 51751.86112841131, 3796837.749470245, 992013.7397791013, -1221952.21711287, 1340652.697009075, -620943.6990984312, 144416.9293806241, 37.5],
- [-3.441963504368392E-4, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5],
- [-3.218135878613132E-4, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292,
- 1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45
- ]
- ];
- d.forward = b(function(b, c, d) {
- for (var f = b[d]; f > 180;) f -= 360;
- for (; f < -180;) f += 360;
- var b = b[d + 1],
- b = Math.max(b, -74),
- b = Math.min(b, 74),
- h = null,
- o;
- for (o = 0; o < g.length; ++o)
- if (b >= g[o]) {
- h = j[o];
- break
- }
- if (h === null)
- for (o = g.length - 1; o >= 0; --o)
- if (b <= -g[o]) {
- h = j[o];
- break
- }
- c[d] = f;
- c[d + 1] = b;
- e(c, c, d, h)
- });
- d.inverse = b(function(b, c, d) {
- for (var g = Math.abs(b[d + 1]), j = null, o = 0; o < f.length; o++)
- if (g >= f[o]) {
- j = h[o];
- break
- }
- e(b, c, d, j)
- })
- }, {
- "../util": 8
- }],
- 6: [function(b, c, d) {
- d.baiduMercator =
- b("./baidu-mercator");
- d.sphericalMercator = b("./spherical-mercator")
- }, {
- "./baidu-mercator": 5,
- "./spherical-mercator": 7
- }],
- 7: [function(b, c, d) {
- var b = b("../util").forEachPoint,
- e = Math.PI / 180;
- d.forward = b(function(b, c, d) {
- var j = Math.sin(Math.max(Math.min(85.0511287798, b[d + 1]), -85.0511287798) * e);
- c[d] = 6378137 * b[d] * e;
- c[d + 1] = 6378137 * Math.log((1 + j) / (1 - j)) / 2
- });
- d.inverse = b(function(b, c, d) {
- c[d] = b[d] / 6378137 / e;
- c[d + 1] = (2 * Math.atan(Math.exp(b[d + 1] / 6378137)) - Math.PI / 2) / e
- })
- }, {
- "../util": 8
- }],
- 8: [function(b, c, d) {
- d.forEachPoint =
- function(b) {
- return function(c, d, h) {
- for (var j = c.length, h = h ? h : 2, d = d ? d : h !== 2 ? c.slice() : Array(j), l = 0; l < j; l += h) b(c, d, l);
- return d
- }
- }
- }, {}]
- }, {}, [4])(4)
- });
- if (GeoGlobe) GeoGlobe.Proj4cn = proj4cn;
- GeoGlobe.ProjAxisOrder = {
- AXIS_ORDER_EN: !0,
- AXIS_ORDER_NE: !1
- };
- GeoGlobe.ProjAxisOrder.AxisOrder = {
- "EPSG:900913": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- WGS84: GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "IGNF:WGS84G": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:4326": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:4490": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:4269": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:2361": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:27700": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:904490": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:4171": GeoGlobe.ProjAxisOrder.AXIS_ORDER_NE,
- "EPSG:32637": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:32638": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:32639": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:32640": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:32641": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:28991": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:28992": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:31300": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:31370": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2176": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2177": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2178": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2179": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2180": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2154": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:3346": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:3857": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN,
- "EPSG:2065": GeoGlobe.ProjAxisOrder.AXIS_ORDER_EN
- };
- GeoGlobe.SpatialReference = GeoGlobe.Class({
- proj: null,
- projCode: null,
- titleRegEx: /\+title=[^\+]*/,
- initialize: function(a, b) {
- GeoGlobe.Util.extend(this, b);
- this.projCode = a;
- if (typeof Proj4js == "object") this.proj = new Proj4js.Proj(a)
- },
- getCode: function() {
- return this.proj ? this.proj.srsCode : this.projCode
- },
- getUnits: function() {
- return this.proj ? this.proj.units : null
- },
- toString: function() {
- return this.getCode()
- },
- equals: function(a) {
- var b = !1;
- a && (a instanceof GeoGlobe.SpatialReference || (a = new GeoGlobe.SpatialReference(a)),
- typeof Proj4js == "object" && this.proj.defData && a.proj.defData ? b = this.proj.defData.replace(this.titleRegEx, "") == a.proj.defData.replace(this.titleRegEx, "") : a.getCode && (b = this.getCode(), a = a.getCode(), b = b == a || !!GeoGlobe.SpatialReference.transforms[b] && GeoGlobe.SpatialReference.transforms[b][a] === GeoGlobe.SpatialReference.nullTransform));
- return b
- },
- destroy: function() {
- delete this.proj;
- delete this.projCode
- },
- CLASS_NAME: "GeoGlobe.SpatialReference"
- });
- GeoGlobe.SpatialReference.transforms = {};
- GeoGlobe.SpatialReference.defaults = {
- "EPSG:4326": {
- units: "degrees",
- maxExtent: [-180, -90, 180, 90],
- yx: !0
- },
- "CRS:84": {
- units: "degrees",
- maxExtent: [-180, -90, 180, 90]
- },
- "EPSG:900913": {
- units: "m",
- maxExtent: [-2.003750834E7, -2.003750834E7, 2.003750834E7, 2.003750834E7]
- }
- };
- GeoGlobe.SpatialReference.addTransform = function(a, b, c) {
- if (c === GeoGlobe.SpatialReference.nullTransform) {
- var d = GeoGlobe.SpatialReference.defaults[a];
- d && !GeoGlobe.SpatialReference.defaults[b] && (GeoGlobe.SpatialReference.defaults[b] = d)
- }
- GeoGlobe.SpatialReference.transforms[a] || (GeoGlobe.SpatialReference.transforms[a] = {});
- GeoGlobe.SpatialReference.transforms[a][b] = c
- };
- GeoGlobe.SpatialReference.transform = function(a, b, c) {
- if (b && c)
- if (b instanceof GeoGlobe.SpatialReference || (b = new GeoGlobe.SpatialReference(b)), c instanceof GeoGlobe.SpatialReference || (c = new GeoGlobe.SpatialReference(c)), b.proj && c.proj) a = Proj4js.transform(b.proj, c.proj, a);
- else {
- var b = b.getCode(),
- c = c.getCode(),
- d = GeoGlobe.SpatialReference.transforms;
- if (d[b] && d[b][c]) d[b][c](a)
- }
- return a
- };
- GeoGlobe.SpatialReference.nullTransform = function(a) {
- return a
- };
- (function() {
- function a(a) {
- a.x = 180 * a.x / d;
- a.y = 180 / Math.PI * (2 * Math.atan(Math.exp(a.y / d * Math.PI)) - Math.PI / 2);
- return a
- }
- function b(a) {
- a.x = a.x * d / 180;
- a.y = Math.max(-2.003750834E7, Math.min(Math.log(Math.tan((90 + a.y) * Math.PI / 360)) / Math.PI * d, 2.003750834E7));
- return a
- }
- function c(c, d) {
- var e = GeoGlobe.SpatialReference.addTransform,
- f = GeoGlobe.SpatialReference.nullTransform,
- g, p, q, o, s;
- g = 0;
- for (p = d.length; g < p; ++g) {
- q = d[g];
- e(c, q, b);
- e(q, c, a);
- for (s = g + 1; s < p; ++s) o = d[s], e(q, o, f), e(o, q, f)
- }
- }
- var d = 2.003750834E7,
- e = ["EPSG:900913",
- "EPSG:3857", "EPSG:102113", "EPSG:102100"
- ],
- f = ["CRS:84", "urn:ogc:def:crs:EPSG:6.6:4326", "EPSG:4326"],
- g;
- for (g = e.length - 1; g >= 0; --g) c(e[g], f);
- for (g = f.length - 1; g >= 0; --g) c(f[g], e)
- })();
- GeoGlobe.String = {
- startsWith: function(a, b) {
- return a.indexOf(b) == 0
- },
- contains: function(a, b) {
- return a.indexOf(b) != -1
- },
- trim: function(a) {
- return a.replace(/^\s\s*/, "").replace(/\s\s*$/, "")
- },
- camelize: function(a) {
- for (var a = a.split("-"), b = a[0], c = 1, d = a.length; c < d; c++) {
- var e = a[c];
- b += e.charAt(0).toUpperCase() + e.substring(1)
- }
- return b
- },
- format: function(a, b, c) {
- b || (b = window);
- return a.replace(GeoGlobe.String.tokenRegEx, function(a, e) {
- for (var f, g = e.split(/\.+/), h = 0; h < g.length; h++) {
- h == 0 && (f = b);
- if (f === void 0) break;
- f = f[g[h]]
- }
- typeof f ==
- "function" && (f = c ? f.apply(null, c) : f());
- return typeof f == "undefined" ? "undefined" : f
- })
- },
- tokenRegEx: /\$\{([\w.]+?)\}/g,
- numberRegEx: /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/,
- isNumeric: function(a) {
- return GeoGlobe.String.numberRegEx.test(a)
- },
- numericIf: function(a, b) {
- var c = a;
- b === !0 && a != null && a.replace && (a = a.replace(/^\s*|\s*$/g, ""));
- return GeoGlobe.String.isNumeric(a) ? parseFloat(a) : c
- }
- };
- GeoGlobe.Number = {
- decimalSeparator: ".",
- thousandsSeparator: ",",
- limitSigDigs: function(a, b) {
- var c = 0;
- b > 0 && (c = parseFloat(a.toPrecision(b)));
- return c
- },
- format: function(a, b, c, d) {
- b = typeof b != "undefined" ? b : 0;
- c = typeof c != "undefined" ? c : GeoGlobe.Number.thousandsSeparator;
- d = typeof d != "undefined" ? d : GeoGlobe.Number.decimalSeparator;
- b != null && (a = parseFloat(a.toFixed(b)));
- var e = a.toString().split(".");
- e.length == 1 && b == null && (b = 0);
- a = e[0];
- if (c)
- for (var f = /(-?[0-9]+)([0-9]{3})/; f.test(a);) a = a.replace(f, "$1" + c + "$2");
- b == 0 ?
- b = a : (c = e.length > 1 ? e[1] : "0", b != null && (c += Array(b - c.length + 1).join("0")), b = a + d + c);
- return b
- },
- zeroPad: function(a, b, c) {
- for (a = a.toString(c || 10); a.length < b;) a = "0" + a;
- return a
- }
- };
- GeoGlobe.Function = {
- bind: function(a, b) {
- var c = Array.prototype.slice.apply(arguments, [2]);
- return function() {
- var d = c.concat(Array.prototype.slice.apply(arguments, [0]));
- return a.apply(b, d)
- }
- },
- bindAsEventListener: function(a, b) {
- return function(c) {
- return a.call(b, c || window.event)
- }
- },
- False: function() {
- return !1
- },
- True: function() {
- return !0
- },
- Void: function() {}
- };
- GeoGlobe.Array = {
- filter: function(a, b, c) {
- var d = [];
- if (Array.prototype.filter) d = a.filter(b, c);
- else {
- var e = a.length;
- if (typeof b != "function") throw new TypeError;
- for (var f = 0; f < e; f++)
- if (f in a) {
- var g = a[f];
- b.call(c, g, f, a) && d.push(g)
- }
- }
- return d
- }
- };
- if (!String.prototype.endsWith) String.prototype.endsWith = function(a, b) {
- var c = this.toString();
- if (typeof b !== "number" || !isFinite(b) || Math.floor(b) !== b || b > c.length) b = c.length;
- b -= a.length;
- c = c.lastIndexOf(a, b);
- return c !== -1 && c === b
- };
- GeoGlobe.Pixel = GeoGlobe.Class4OL({
- x: 0,
- y: 0,
- initialize: function(a, b) {
- this.x = parseFloat(a);
- this.y = parseFloat(b)
- },
- toString: function() {
- return "x=" + this.x + ",y=" + this.y
- },
- clone: function() {
- return new GeoGlobe.Pixel(this.x, this.y)
- },
- equals: function(a) {
- var b = !1;
- a != null && (b = this.x == a.x && this.y == a.y || isNaN(this.x) && isNaN(this.y) && isNaN(a.x) && isNaN(a.y));
- return b
- },
- distanceTo: function(a) {
- return Math.sqrt(Math.pow(this.x - a.x, 2) + Math.pow(this.y - a.y, 2))
- },
- add: function(a, b) {
- if (a == null || b == null) throw new TypeError("Pixel.add cannot receive null values");
- return new GeoGlobe.Pixel(this.x + a, this.y + b)
- },
- offset: function(a) {
- var b = this.clone();
- a && (b = this.add(a.x, a.y));
- return b
- },
- CLASS_NAME: "GeoGlobe.Pixel"
- });
- GeoGlobe.Size = GeoGlobe.Class4OL({
- w: 0,
- h: 0,
- initialize: function(a, b) {
- this.w = parseFloat(a);
- this.h = parseFloat(b)
- },
- toString: function() {
- return "w=" + this.w + ",h=" + this.h
- },
- clone: function() {
- return new GeoGlobe.Size(this.w, this.h)
- },
- equals: function(a) {
- var b = !1;
- a != null && (b = this.w == a.w && this.h == a.h || isNaN(this.w) && isNaN(this.h) && isNaN(a.w) && isNaN(a.h));
- return b
- },
- CLASS_NAME: "GeoGlobe.Size"
- });
- GeoGlobe.Date = {
- dateRegEx: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/,
- toISOString: function() {
- return "toISOString" in Date.prototype ? function(a) {
- return a.toISOString()
- } : function(a) {
- return isNaN(a.getTime()) ? "Invalid Date" : a.getUTCFullYear() + "-" + GeoGlobe.Number.zeroPad(a.getUTCMonth() + 1, 2) + "-" + GeoGlobe.Number.zeroPad(a.getUTCDate(), 2) + "T" + GeoGlobe.Number.zeroPad(a.getUTCHours(), 2) + ":" + GeoGlobe.Number.zeroPad(a.getUTCMinutes(),
- 2) + ":" + GeoGlobe.Number.zeroPad(a.getUTCSeconds(), 2) + "." + GeoGlobe.Number.zeroPad(a.getUTCMilliseconds(), 3) + "Z"
- }
- }(),
- parse: function(a) {
- var b;
- if ((a = a.match(this.dateRegEx)) && (a[1] || a[7])) {
- b = parseInt(a[1], 10) || 0;
- var c = parseInt(a[2], 10) - 1 || 0,
- d = parseInt(a[3], 10) || 1;
- b = new Date(Date.UTC(b, c, d));
- if (c = a[7]) {
- var d = parseInt(a[4], 10),
- e = parseInt(a[5], 10),
- f = parseFloat(a[6]),
- g = f | 0;
- b.setUTCHours(d, e, g, Math.round(1E3 * (f - g)));
- c !== "Z" && (c = parseInt(c, 10), a = parseInt(a[8], 10) || 0, b = new Date(b.getTime() + -1E3 * (60 * c * 60 + a * 60)))
- }
- } else b =
- new Date("invalid");
- return b
- }
- };
- GeoGlobe.Console = {
- log: function() {},
- debug: function() {},
- info: function() {},
- warn: function() {},
- error: function() {},
- userError: function(a) {
- alert(a)
- },
- assert: function() {},
- dir: function() {},
- dirxml: function() {},
- trace: function() {},
- group: function() {},
- groupEnd: function() {},
- time: function() {},
- timeEnd: function() {},
- profile: function() {},
- profileEnd: function() {},
- count: function() {},
- CLASS_NAME: "GeoGlobe.Console"
- };
- (function() {
- for (var a = document.getElementsByTagName("script"), b = 0, c = a.length; b < c; ++b)
- if (a[b].src.indexOf("firebug.js") != -1 && console) {
- GeoGlobe.Util.extend(GeoGlobe.Console, console);
- break
- }
- })();
- GeoGlobe.ProxyHost = "";
- GeoGlobe.timeout = 0;
- if (!GeoGlobe.Request) GeoGlobe.Request = {};
- GeoGlobe.Util.extend(GeoGlobe.Request, {
- DEFAULT_CONFIG: {
- method: "GET",
- url: window.location.href,
- async: !0,
- user: void 0,
- password: void 0,
- params: null,
- proxy: GeoGlobe.ProxyHost,
- timeout: GeoGlobe.timeout,
- headers: {},
- data: null,
- callback: function() {},
- success: null,
- failure: null,
- scope: null
- },
- URL_SPLIT_REGEX: /([^:]*:)\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/,
- makeSameOrigin: function(a, b) {
- var c = a.indexOf("http") !== 0,
- d = !c && a.match(this.URL_SPLIT_REGEX);
- if (d) {
- var e = window.location,
- c = d[1] == e.protocol && d[3] == e.hostname,
- d = d[4],
- e = e.port;
- if (d != 80 && d != "" || e != "80" && e != "") c = c && d == e
- }
- c || b && (a = typeof b == "function" ? b(a) : a.indexOf("cts?") >= 0 ? b + a : b + encodeURIComponent(a));
- return a
- },
- issue: function(a) {
- var b = a.noProxy === !0 ? GeoGlobe.Util.extend(this.DEFAULT_CONFIG, {
- timeout: GeoGlobe.timeout
- }) : GeoGlobe.Util.extend(this.DEFAULT_CONFIG, {
- proxy: GeoGlobe.ProxyHost,
- timeout: GeoGlobe.timeout
- }),
- a = a || {};
- a.headers = a.headers || {};
- a = GeoGlobe.Util.applyDefaults(a, b);
- a.headers = GeoGlobe.Util.applyDefaults(a.headers, b.headers);
- var b = !1,
- c;
- for (c in a.headers) a.headers.hasOwnProperty(c) &&
- c.toLowerCase() === "x-requested-with" && (b = !0);
- b === !1 && (a.headers["X-Requested-With"] = "XMLHttpRequest");
- var d = new GeoGlobe.Request.XMLHttpRequest;
- a.url = encodeURI(a.url);
- var e = GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(a.params || {}, !0)),
- e = GeoGlobe.Request.makeSameOrigin(e, a.proxy);
- d.open(a.method, e, a.async, a.user, a.password);
- for (var f in a.headers);
- var g = this;
- d.onreadystatechange = function() {
- d.readyState == GeoGlobe.Request.XMLHttpRequest.DONE && null !== !1 && g.runCallbacks({
- request: d,
- config: a,
- requestUrl: e
- })
- };
- a.async && d.setTimeout(a.timeout);
- a.async === !1 ? d.send(a.data) : window.setTimeout(function() {
- d.readyState !== 0 && d.send(a.data)
- }, 0);
- return d
- },
- runCallbacks: function(a) {
- var b = a.request,
- a = a.config,
- c = a.scope ? GeoGlobe.Function.bind(a.callback, a.scope) : a.callback,
- d;
- a.success && (d = a.scope ? GeoGlobe.Function.bind(a.success, a.scope) : a.success);
- var e;
- a.failure && (e = a.scope ? GeoGlobe.Function.bind(a.failure, a.scope) : a.failure);
- if (GeoGlobe.Util.createUrlObject(a.url).protocol == "file:" && b.responseText) b.status =
- 200;
- c(b);
- (!b.status || b.status >= 200 && b.status < 300) && d && d(b);
- b.status && (b.status < 200 || b.status >= 300) && e && e(b)
- },
- GET: function(a) {
- a = GeoGlobe.Util.extend(a, {
- method: "GET"
- });
- return GeoGlobe.Request.issue(a)
- },
- POST: function(a) {
- a = GeoGlobe.Util.extend(a, {
- method: "POST"
- });
- a.headers = a.headers ? a.headers : {};
- "CONTENT-TYPE" in GeoGlobe.Util.upperCaseObject(a.headers) || (a.headers["Content-Type"] = "application/xml");
- return GeoGlobe.Request.issue(a)
- },
- PUT: function(a) {
- a = GeoGlobe.Util.extend(a, {
- method: "PUT"
- });
- a.headers = a.headers ?
- a.headers : {};
- "CONTENT-TYPE" in GeoGlobe.Util.upperCaseObject(a.headers) || (a.headers["Content-Type"] = "application/xml");
- return GeoGlobe.Request.issue(a)
- },
- DELETE: function(a) {
- a = GeoGlobe.Util.extend(a, {
- method: "DELETE"
- });
- return GeoGlobe.Request.issue(a)
- },
- HEAD: function(a) {
- a = GeoGlobe.Util.extend(a, {
- method: "HEAD"
- });
- return GeoGlobe.Request.issue(a)
- },
- OPTIONS: function(a) {
- a = GeoGlobe.Util.extend(a, {
- method: "OPTIONS"
- });
- return GeoGlobe.Request.issue(a)
- }
- });
- GeoGlobe.nullHandler = function(a) {
- GeoGlobe.Console.userError(GeoGlobe.i18n("unhandledRequest", {
- statusText: a.statusText
- }))
- };
- GeoGlobe.loadURL = function(a, b, c, d, e) {
- typeof b == "string" && (b = GeoGlobe.Util.getParameters(b));
- return GeoGlobe.Request.GET({
- url: a,
- params: b,
- success: d ? d : GeoGlobe.nullHandler,
- failure: e ? e : GeoGlobe.nullHandler,
- scope: c
- })
- };
- GeoGlobe.Request.setProxyHost = function(a) {
- GeoGlobe.ProxyHost = a
- };
- GeoGlobe.Request.getProxyHost = function() {
- return GeoGlobe.ProxyHost
- };
- GeoGlobe.Request.setTimeout = function(a) {
- GeoGlobe.timeout = a
- };
- GeoGlobe.appendToProxy = function(a) {
- var a = a.split("?"),
- b = GeoGlobe.ProxyHost + encodeURI(encodeURI(a[0]));
- a.length === 2 && (b += "?" + a[1]);
- return b
- };
- GeoGlobe.loadScript = function(a) {
- GeoGlobe.Request.GET({
- url: a,
- async: !1,
- headers: {
- Accept: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"
- },
- success: function(a) {
- GeoGlobe.Util.globalEval(a.responseText)
- },
- failure: function() {
- alert("\u52a0\u8f7d:" + a + " \u5931\u8d25\u3002")
- }
- })
- };
- (function() {
- function a() {
- this._object = f && !j ? new f : new window.ActiveXObject("Microsoft.XMLHTTP");
- this._listeners = []
- }
- function b() {
- return new a
- }
- function c(a) {
- b.onreadystatechange && b.onreadystatechange.apply(a);
- a.dispatchEvent({
- type: "readystatechange",
- bubbles: !1,
- cancelable: !1,
- timeStamp: new Date + 0
- })
- }
- function d(a) {
- try {
- a.responseText = a._object.responseText
- } catch (b) {}
- try {
- var c;
- var d = a._object,
- e = d.responseXML,
- f = d.responseText;
- if (h && f && e && !e.documentElement && d.getResponseHeader("Content-Type").match(/[^\/]+\/[^\+]+\+xml/)) e =
- new window.ActiveXObject("Microsoft.XMLDOM"), e.async = !1, e.validateOnParse = !1, e.loadXML(f);
- c = e && (h && e.parseError != 0 || !e.documentElement || e.documentElement && e.documentElement.tagName == "parsererror") ? null : e;
- a.responseXML = c
- } catch (g) {}
- try {
- a.status = a._object.status
- } catch (j) {}
- try {
- a.statusText = a._object.statusText
- } catch (t) {}
- }
- function e(a) {
- a._object.onreadystatechange = new window.Function
- }
- var f = window.XMLHttpRequest,
- g = !!window.controllers,
- h = window.document.all && !window.opera,
- j = h && window.navigator.userAgent.match(/MSIE 7.0/);
- b.prototype = a.prototype;
- if (g && f.wrapped) b.wrapped = f.wrapped;
- b.UNSENT = 0;
- b.OPENED = 1;
- b.HEADERS_RECEIVED = 2;
- b.LOADING = 3;
- b.DONE = 4;
- b.prototype.readyState = b.UNSENT;
- b.prototype.responseText = "";
- b.prototype.responseXML = null;
- b.prototype.status = 0;
- b.prototype.statusText = "";
- b.prototype.priority = "NORMAL";
- b.prototype.onreadystatechange = null;
- b.onreadystatechange = null;
- b.onopen = null;
- b.onsend = null;
- b.onabort = null;
- b.prototype.open = function(a, f, j, p, q) {
- delete this._headers;
- arguments.length < 3 && (j = !0);
- this._async = j;
- var o = this,
- s = this.readyState,
- r;
- h && j && (r = function() {
- s != b.DONE && (e(o), o.abort())
- }, window.attachEvent("onunload", r));
- b.onopen && b.onopen.apply(this, arguments);
- arguments.length > 4 ? this._object.open(a, f, j, p, q) : arguments.length > 3 ? this._object.open(a, f, j, p) : this._object.open(a, f, j);
- try {
- this._object.responseType = "msxml-document"
- } catch (t) {}
- this.readyState = b.OPENED;
- c(this);
- this._object.onreadystatechange = function() {
- if (!g || j) o.readyState = o._object.readyState, d(o), o._aborted ? o.readyState = b.UNSENT : (o.readyState == b.DONE && (delete o._data,
- e(o), h && j && window.detachEvent("onunload", r)), s != o.readyState && c(o), s = o.readyState)
- }
- };
- b.prototype.setTimeout = function(a) {
- this._object.timeout = a
- };
- b.prototype.send = function(a) {
- b.onsend && b.onsend.apply(this, arguments);
- arguments.length || (a = null);
- a && a.nodeType && (a = window.XMLSerializer ? (new window.XMLSerializer).serializeToString(a) : a.xml, this._headers["Content-Type"] || this._object.setRequestHeader("Content-Type", "application/xml"));
- this._data = a;
- this._object.send(this._data);
- if (g && !this._async) {
- this.readyState =
- b.OPENED;
- for (d(this); this.readyState < b.DONE;)
- if (this.readyState++, c(this), this._aborted) break
- }
- };
- b.prototype.abort = function() {
- b.onabort && b.onabort.apply(this, arguments);
- if (this.readyState > b.UNSENT) this._aborted = !0;
- this._object.abort();
- e(this);
- this.readyState = b.UNSENT;
- delete this._data
- };
- b.prototype.getAllResponseHeaders = function() {
- return this._object.getAllResponseHeaders()
- };
- b.prototype.getResponseHeader = function(a) {
- return this._object.getResponseHeader(a)
- };
- b.prototype.setRequestHeader = function(a, b) {
- if (!this._headers) this._headers = {};
- this._headers[a] = b;
- return this._object.setRequestHeader(a, b)
- };
- b.prototype.addEventListener = function(a, b, c) {
- for (var d = 0, e; e = this._listeners[d]; d++)
- if (e[0] == a && e[1] == b && e[2] == c) return;
- this._listeners.push([a, b, c])
- };
- b.prototype.removeEventListener = function(a, b, c) {
- for (var d = 0, e; e = this._listeners[d]; d++)
- if (e[0] == a && e[1] == b && e[2] == c) break;
- e && this._listeners.splice(d, 1)
- };
- b.prototype.dispatchEvent = function(a) {
- a = {
- type: a.type,
- target: this,
- currentTarget: this,
- eventPhase: 2,
- bubbles: a.bubbles,
- cancelable: a.cancelable,
- timeStamp: a.timeStamp,
- stopPropagation: function() {},
- preventDefault: function() {},
- initEvent: function() {}
- };
- a.type == "readystatechange" && this.onreadystatechange && (this.onreadystatechange.handleEvent || this.onreadystatechange).apply(this, [a]);
- for (var b = 0, c; c = this._listeners[b]; b++) c[0] == a.type && !c[2] && (c[1].handleEvent || c[1]).apply(this, [a])
- };
- b.prototype.toString = function() {
- return "[object XMLHttpRequest]"
- };
- b.toString = function() {
- return "[XMLHttpRequest]"
- };
- if (!window.Function.prototype.apply) window.Function.prototype.apply =
- function(a, b) {
- b || (b = []);
- a.__func = this;
- a.__func(b[0], b[1], b[2], b[3], b[4]);
- delete a.__func
- };
- if (!GeoGlobe.Request) GeoGlobe.Request = {};
- GeoGlobe.Request.XMLHttpRequest = b
- })();
- GeoGlobe.Map = GeoGlobe.Class(mapboxgl.FreeCRSMap, {
- is3Dpitching: !1,
- pitch3Dzoom: 16,
- skipLevelOfZooming: !1,
- units: null,
- initialize: function(a) {
- a = GeoGlobe.Util.extend(GeoGlobe.Util.pick2(a, "is"), a);
- a = GeoGlobe.Util.extend({
- intScrollZoom: !0,
- attributionControl: !1,
- preserveDrawingBuffer: !0
- }, a);
- if (typeof a.style !== "string") a.style = GeoGlobe.Util.merge2Obj({
- version: 8,
- glyphs: "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
- sources: {},
- layers: []
- }, a.style);
- var b = new mapboxgl.FreeCRSMap(a),
- a = GeoGlobe.Util.extend({
- units: "degrees",
- isConstrain: !1,
- is3Dpitching: !1,
- pitch3Dzoom: 16
- }, GeoGlobe.Util.pick(a, ["units", "isConstrain", "is3Dpitching", "pitch3Dzoom"]));
- a.isConstrain === !0 && b.setIsConstrain(a.isConstrain);
- b.pitch3Dzoom = a.pitch3Dzoom;
- b.setIs3DPZoom(a.is3Dpitching);
- if (b.units !== a.units) b.units = a.units;
- return b
- },
- CLASS_NAME: "GeoGlobe.Map"
- });
- mapboxgl.accessToken = "pk.eyJ1IjoiamFrZWpvdWUiLCJhIjoiY2p2M2dneXJ3MTI3ZjQzcDkwcTk0azg3ZyJ9.KpuPwDUSsQKf2Qs7mu7bww";
- mapboxgl.FreeCRSMap.prototype.setGlyphs = function(a) {
- this.style.setGlyphs(a)
- };
- mapboxgl.FreeCRSMap.prototype.loadSprite = function(a, b) {
- this.style.loadSprite(a, b)
- };
- mapboxgl.FreeCRSMap.prototype.removeAllImages = function() {
- var a = this.style.imageManager,
- b;
- for (b in a.images) a.removeImage(b)
- };
- mapboxgl.FreeCRSMap.prototype.setIs3DPZoom = function(a) {
- if (a) this.on("zoom", this.setZoompitch);
- else this.off("zoom", this.setZoompitch)
- };
- mapboxgl.FreeCRSMap.prototype.set3Dzoom = function(a) {
- if (a) this.pitch3Dzoom = a
- };
- mapboxgl.FreeCRSMap.prototype.setZoompitch = function() {
- var a = this.getZoom(),
- b = this.pitch3Dzoom;
- parseInt(a) == b && this.setPitch(60)
- };
- mapboxgl.FreeCRSMap.prototype.setIsConstrain = function(a) {
- this.isConstrain = a;
- this.transform._constraining = !this.isConstrain
- };
- mapboxgl.FreeCRSMap.prototype.addCanvasLayer = function(a) {
- a.addTo(this)
- };
- mapboxgl.FreeCRSMap.prototype.removeCanvasLayer = function(a) {
- a.remove()
- };
- mapboxgl.FreeCRSMap.prototype.getLayer = function(a) {
- var b = this.style.getLayer(a);
- if (!b && this._visuals)
- for (var c = 0; c < this._visuals.length; c++)
- if (b = this._visuals[c].getLayer(a)) break;
- return b
- };
- mapboxgl.FreeCRSMap.prototype.addLayer = function(a, b) {
- a.layerType && ["VTS", "VVTS", "ArcgisVTS"].indexOf(a.layerType) !== -1 && !(a instanceof GeoGlobe.Layer) && (a = new GeoGlobe.Layer(a));
- if (a instanceof GeoGlobe.Layer) a.onAdd(this, b);
- else return this.style.addLayer(a, b), this._update(!0), this
- };
- mapboxgl.FreeCRSMap.prototype.addLayers = function(a, b) {
- if (a.length > 0)
- for (var c = 0; c < a.length; c++) this.addLayer(a[c], b)
- };
- mapboxgl.FreeCRSMap.prototype.moveLayer = function(a, b) {
- var c = this.getLayer(a),
- d = this.getLayer(b);
- if (c)
- if (b && !d) this.fire("error", {
- error: Error("\u56fe\u5c42'" + b + "'\u4e0d\u5b58\u5728\u3002")
- });
- else if (!c._parent && (!d || !d._parent)) return this.style.moveLayer(a, b), this._update(!0), this;
- else if (c._parent && (!d || d._parent))
- if (!d || c._parent.type === d._parent.type) return c._parent.moveLayer(a, b), this;
- else this.fire("error", {
- error: Error("\u6682\u4e0d\u652f\u6301\u4e0d\u540c\u7c7b\u522b\u53ef\u89c6\u5316\u56fe\u5c42\u95f4\u7684\u79fb\u52a8\u3002")
- });
- else this.fire("error", {
- error: Error("\u6682\u4e0d\u652f\u6301mapbox\u56fe\u5c42\u4e0e\u53ef\u89c6\u5316\u56fe\u5c42\u95f4\u7684\u79fb\u52a8\u3002")
- });
- else this.fire("error", {
- error: Error(a ? "\u56fe\u5c42'" + a + "'\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u4e0d\u80fd\u88ab\u79fb\u52a8\u3002" : "\u56fe\u5c42ID\u4e0d\u80fd\u4e3a\u7a7a\u3002")
- })
- };
- mapboxgl.FreeCRSMap.prototype.removeLayer = function(a) {
- if (a instanceof GeoGlobe.Layer) a.onRemove();
- else {
- var b = this.getLayer(a);
- if (b) return b._parent ? b._parent.removeLayer(a) : (this.style.removeLayer(a), this._update(!0)), this;
- else this.fire("error", {
- error: Error(a ? "\u56fe\u5c42'" + a + "'\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u4e0d\u80fd\u88ab\u79fb\u9664\u3002" : "\u56fe\u5c42ID\u4e0d\u80fd\u4e3a\u7a7a\u3002")
- })
- }
- };
- mapboxgl.FreeCRSMap.prototype.removeLayers = function(a) {
- if (a.length > 0)
- for (var b = 0; b < a.length; b++) this.removeLayer(a[b])
- };
- mapboxgl.FreeCRSMap.prototype.removeLayerAndSource = function(a) {
- if (this.getLayer(a)) this.removeLayer(a), this.removeSource(a);
- else throw Error("Layer not found");
- };
- mapboxgl.FreeCRSMap.prototype.removeAllLayers = function() {
- var a = this.style._layers,
- b;
- for (b in a) this.removeLayer(b)
- };
- mapboxgl.FreeCRSMap.prototype.removeAllSources = function() {
- var a = this.style.sourceCaches,
- b;
- for (b in a) this.removeSource(b)
- };
- mapboxgl.FreeCRSMap.prototype.getLayerContainer = function(a) {
- for (var b = 0; b < this.eleContainer.childNodes.length; b++)
- if (a === this.eleContainer.childNodes[b].className) return this.eleContainer.childNodes[b]
- };
- mapboxgl.FreeCRSMap.prototype.moveLayerContainer = function(a, b) {
- if (this.getLayerContainer(a)) {
- var c = [];
- this.eleContainer.childNodes.forEach(function(a) {
- c.push(a.className)
- });
- var d = c.indexOf(a);
- c.splice(d, 1);
- d = b ? c.indexOf(b) : c.length;
- if (b && d === -1) this.fire("error", {
- error: Error('layer_container with id "' + b + '" does not exist on this map.')
- });
- else {
- c.splice(d, 0, a);
- for (d = 0; d < c.length; d++)
- for (var e = 0; e < this.eleContainer.childNodes.length; e++)
- if (c[d] === this.eleContainer.childNodes[e].className) this.eleContainer.childNodes[e].style.zIndex =
- d
- }
- } else this.fire("error", {
- error: Error("The layer_container '" + a + "' does not exist in the map's style and cannot be moved.")
- })
- };
- mapboxgl.FreeCRSMap.prototype.addWidget = function(a, b) {
- a.onAdd(this, b)
- };
- mapboxgl.FreeCRSMap.prototype.removeWidget = function(a) {
- a.onRemove(null)
- };
- mapboxgl.FreeCRSMap.prototype.getResolutions = function() {
- for (var a = [], b = 0; b <= 20; b++) a.push(this.getResolutionForLevel(b));
- return a
- };
- mapboxgl.FreeCRSMap.prototype.getResolutionForLevel = function(a, b) {
- var c = Math.abs(this._tileExtent[2] - this._tileExtent[0]);
- c === 360 && (c = 4.00750166855784E7);
- return c / (b || 256) / Math.pow(2, a)
- };
- mapboxgl.FreeCRSMap.prototype.addLayerGroup = function(a, b, c) {
- if (!GeoGlobe.Util.isArray(a)) throw Error("\u53c2\u6570 ${layerArr} \u7c7b\u578b\u9519\u8bef.");
- a.push({
- id: "GeoGlobe" + b,
- source: {
- type: "geojson",
- data: {
- type: "FeatureCollection",
- features: []
- }
- },
- type: "circle"
- });
- for (var d = this.getStyle().layers, e = 0; e < d.length; e++)
- if (d[e].metadata && d[e].metadata.group === b) return !1;
- mapboxgl.LayerGroup.addGroup(this, b, a, c)
- };
- mapboxgl.FreeCRSMap.prototype.removeLayerGroup = function(a) {
- for (var b = this.getStyle().layers, c = 0; c < b.length; c++) b[c].metadata && b[c].metadata.group === a && this.removeLayer(b[c].id);
- this.removeLayer("GeoGlobe" + a)
- };
- mapboxgl.FreeCRSMap.prototype.removeLayerFromGroup = function(a, b) {
- for (var c = this.getStyle().layers, d = 0; d < c.length; d++) c[d].metadata && c[d].metadata.group === b && c[d].id == a && this.removeLayer(c[d].id)
- };
- mapboxgl.FreeCRSMap.prototype.addLayerToGroup = function(a, b) {
- if (!this.getLayer(a.id))
- for (var c = this.getStyle().layers, d = 0; d < c.length; d++)
- if (c[d].metadata && c[d].metadata.group === b) {
- if (a.layers) {
- var c = a.layers,
- e;
- for (e in c) c[e].metadata = c[e].metadata || {}, c[e].metadata.group = b
- } else a.metadata = a.metadata || {}, a.metadata.group = b;
- this.addLayer(a, "GeoGlobe" + b);
- break
- }
- };
- mapboxgl.FreeCRSMap.prototype.moveGroup = function(a, b) {
- this.getStyle();
- var c = mapboxgl.LayerGroup.getLayersfromGroup(this, a),
- d = mapboxgl.LayerGroup.getLayersfromGroup(this, b);
- if (c.length == 0) this.fire("error", {
- error: Error(a ? "\u56fe\u5c42\u7ec4'" + a + "'\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u4e0d\u80fd\u88ab\u79fb\u52a8\u3002" : "\u56fe\u5c42\u7ec4ID\u4e0d\u80fd\u4e3a\u7a7a\u3002")
- });
- else if (d.length == 0) this.fire("error", {
- error: Error(b ? "\u56fe\u5c42\u7ec4'" + b + "'\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u4e0d\u80fd\u88ab\u79fb\u52a8\u3002" :
- "\u56fe\u5c42\u7ec4ID\u4e0d\u80fd\u4e3a\u7a7a\u3002")
- });
- else
- for (var e = 0; e < c.length; e++) this.moveLayer(c[e].id, d[0].id)
- };
- mapboxgl.FreeCRSMap.prototype.moveLayerInGroup = function(a, b) {
- var c = this.getLayer(a),
- d = this.getLayer(b);
- c ? d ? c.metadata != null && d.metadata != null && c.metadata.group === d.metadata.group ? this.moveLayer(a, b) : this.fire("error", {
- error: Error(a + "\u56fe\u5c42\u548c" + b + "\u56fe\u5c42\u4e0d\u5c5e\u4e8e\u540c\u4e00\u7ec4\u3002")
- }) : this.fire("error", {
- error: Error(b ? "\u56fe\u5c42'" + b + "'\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u4e0d\u80fd\u88ab\u79fb\u52a8\u3002" : "\u56fe\u5c42ID\u4e0d\u80fd\u4e3a\u7a7a\u3002")
- }) : this.fire("error", {
- error: Error(a ? "\u56fe\u5c42'" + a + "'\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u4e0d\u80fd\u88ab\u79fb\u52a8\u3002" : "\u56fe\u5c42ID\u4e0d\u80fd\u4e3a\u7a7a\u3002")
- })
- };
- mapboxgl.FreeCRSMap.prototype.getLayersfromGroup = function(a) {
- for (var b = mapboxgl.LayerGroup.getLayersfromGroup(this, a), c = 0; c < b.length; c++)
- if (b[c].id === "GeoGlobe" + a) {
- b.splice(c, 1);
- break
- }
- return b
- };
- mapboxgl.FreeCRSMap.prototype.clearGroup = function(a) {
- for (var a = this.getLayersfromGroup(a), b = 0; b < a.length; b++) this.removeLayer(a[b].id)
- };
- mapboxgl.FreeCRSMap.prototype.showLayer = function(a) {
- if (!this.getLayer(a)) throw Error(a + " Layer not found");
- this.setLayoutProperty(a, "visibility", "visible")
- };
- mapboxgl.FreeCRSMap.prototype.hideLayer = function(a) {
- if (!this.getLayer(a)) throw Error(a + " Layer not found");
- this.setLayoutProperty(a, "visibility", "none")
- };
- mapboxgl.FreeCRSMap.prototype.setOpacity = function(a, b) {
- var c = this.getLayer(a);
- if (!c) throw Error(a + " Layer not found");
- if (typeof b != "number") throw Error(b + " must be number");
- this.setPaintProperty(a, c.type + "-opacity", b)
- };
- GeoGlobe.LngLatBounds = mapboxgl.LngLatBounds;
- mapboxgl.LngLatBounds.prototype.clone = function() {
- return new mapboxgl.LngLatBounds(this._sw, this._ne)
- };
- mapboxgl.LngLatBounds.prototype.contains = function(a, b, c) {
- c == null && (c = !0);
- if (a == null || b == null) return !1;
- var a = GeoGlobe.Util.toFloat(a),
- b = GeoGlobe.Util.toFloat(b),
- d = !1;
- return d = c ? a >= this._sw.lng && a <= this._ne.lng && b >= this._sw.lat && b <= this._ne.lat : a > this._sw.lng && a < this._ne.lng && b > this._sw.lat && b < this._ne.lat
- };
- mapboxgl.LngLatBounds.prototype.getWidth = function() {
- return this._ne.lng - this._sw.lng
- };
- mapboxgl.LngLatBounds.prototype.containsLonLat = function(a, b) {
- typeof b === "boolean" && (b = {
- inclusive: b
- });
- var b = b || {},
- c = this.contains(a.lng, a.lat, b.inclusive),
- d = b.worldBounds;
- d && !c && (c = d.getWidth(), c = this.containsLonLat({
- lng: a.lng - Math.round((a.lng - (d._sw.lng + d._ne.lng) / 2) / c) * c,
- lat: a.lat
- }, {
- inclusive: b.inclusive
- }));
- return c
- };
- mapboxgl.LngLatBounds.prototype.equals = function(a) {
- var b = !1;
- a != null && (b = this._sw.lng == a._sw.lng && this._ne.lng == a._ne.lng && this._ne.lat == a._ne.lat && this._sw.lat == a._sw.lat);
- return b
- };
- mapboxgl.LngLatBounds.prototype.toBBOX = function(a, b) {
- a == null && (a = 6);
- var c = Math.pow(10, a),
- d = Math.round(this._sw.lng * c) / c,
- e = Math.round(this._sw.lat * c) / c,
- f = Math.round(this._ne.lng * c) / c,
- c = Math.round(this._ne.lat * c) / c;
- return b === !0 ? e + "," + d + "," + c + "," + f : d + "," + e + "," + f + "," + c
- };
- mapboxgl.LngLatBounds.prototype.toGeometry = function() {
- return new GeoGlobe.Geometry.Polygon([new GeoGlobe.Geometry.LinearRing([new GeoGlobe.Geometry.Point(this._sw.lng, this._sw.lat), new GeoGlobe.Geometry.Point(this._ne.lng, this._sw.lat), new GeoGlobe.Geometry.Point(this._ne.lng, this._ne.lat), new GeoGlobe.Geometry.Point(this._sw.lng, this._ne.lat)])])
- };
- mapboxgl.LngLatBounds.prototype.getCenterLonLat = function() {
- if (!this.centerLonLat) this.centerLonLat = new GeoGlobe.LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
- return this.centerLonLat
- };
- mapboxgl.LngLatBounds.prototype.CLASS_NAME = "GeoGlobe.LngLatBounds";
- GeoGlobe.LngLatBounds.fromString = function(a, b) {
- var c = a.split(",");
- return GeoGlobe.LngLatBounds.fromArray(c, b)
- };
- GeoGlobe.LngLatBounds.fromArray = function(a, b) {
- return b === !0 ? new GeoGlobe.LngLatBounds(new GeoGlobe.LngLat(a[1], a[0]), new GeoGlobe.LngLat(a[3], a[2])) : new GeoGlobe.LngLatBounds(new GeoGlobe.LngLat(a[0], a[1]), new GeoGlobe.LngLat(a[2], a[3]))
- };
- GeoGlobe.LngLatBounds.toGeometryByTwoPixel = function(a, b, c) {
- for (var a = [mapboxgl.Point.convert(a), mapboxgl.Point.convert(b)], a = [a[0], new mapboxgl.Point(a[1].x, a[0].y), a[1], new mapboxgl.Point(a[0].x, a[1].y)], b = [], d = 0; d < a.length; d++) {
- var e = c.unproject(a[d]),
- e = new GeoGlobe.Geometry.Point(e.lng, e.lat);
- b.push(e)
- }
- return new GeoGlobe.Geometry.Polygon([new GeoGlobe.Geometry.LinearRing(b)])
- };
- GeoGlobe.LngLat = mapboxgl.LngLat;
- GeoGlobe.Layer = GeoGlobe.Class({
- map: null,
- source_id: null,
- source: null,
- sources: null,
- layer: null,
- layers: null,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- onAdd: function(a, b) {
- if (a)
- if (this.map = a, this.addTo) this.addTo(a, b);
- else {
- this.source_id && this.source && a.addSource(this.source_id, this.source);
- if (this.sources)
- for (var c in this.sources) a.addSource(c, this.sources[c]);
- this.layer && a.addLayer(this.layer, b);
- this.layers && a.addLayers(this.layers, b)
- }
- },
- onRemove: function() {
- var a = this.map;
- if (a)
- if (delete this.map,
- this.destroy) this.destroy();
- else if (this.layer && a.removeLayer(this.layer.id), this.layers && a.removeLayers(this.layers.map(function(a) {
- return a.id
- })), this.source_id && this.source && a.removeSource(this.source_id), this.sources)
- for (var b in this.sources) a.removeSource(b)
- },
- CLASS_NAME: "GeoGlobe.Layer"
- });
- GeoGlobe.Layer.WMTS = GeoGlobe.Class4OL({
- url: null,
- layer: null,
- name: null,
- format: null,
- matrixSet: null,
- style: null,
- zoomOffset: null,
- initialize: function(a) {
- return this._getWMTSLayer(a)
- },
- _getWMTSLayer: function(a) {
- var b = GeoGlobe.Util.pick(a, ["layer", "format", "version", "style"], !0);
- if (a.matrixSet) b.TILEMATRIXSET = a.matrixSet;
- GeoGlobe.Util.applyDefaults(b, {
- service: "WMTS",
- request: "GetTile",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- });
- b = GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(b || {}));
- b = GeoGlobe.appendToProxy(b);
- b.indexOf("tianditu") !== -1 && (b += "&tk=" + (a.token || "e90d56e5a09d1767899ad45846b0cefd"));
- var c = "wmts_" + a.layer + "_" + GeoGlobe.Util.randomStr(8);
- if (!a.zoomOffset) a.zoomOffset = 0;
- if (a.noFadingParent === void 0) a.noFadingParent = !0;
- return {
- id: c,
- type: "raster",
- source: {
- type: "raster",
- tiles: [b],
- tileSize: 256,
- zoomOffset: a.zoomOffset,
- noFadingParent: a.noFadingParent
- }
- }
- },
- CLASS_NAME: "GeoGlobe.Layer.WMTS"
- });
- GeoGlobe.Layer.WMS = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- url: null,
- layer: null,
- format: null,
- version: null,
- width: 256,
- height: 256,
- SRS: null,
- initialize: function(a) {
- if (a.isTile != void 0 && a.isTile === !1) this.layerOption = this._getWMSLayer(a);
- else return this._getWMSTileLayer(a)
- },
- addTo: function(a, b) {
- this.map = a;
- this.move = GeoGlobe.Function.bind(GeoGlobe.Util.delayFun(this.moveend, 300), this);
- this.map.on("moveend", this.move);
- this.width = a.getCanvas().width;
- this.height = a.getCanvas().height;
- var c = a.getBounds(),
- d = c._ne.lng,
- e = c._ne.lat,
- f = c._sw.lng,
- c = c._sw.lat;
- this.layerOption.source.url = this.layerOption.source.url.replace("{bbox}", f + "," + c + "," + d + "," + e).replace("{width}", this.width).replace("{height}", this.height);
- this.layerOption.source.coordinates = [
- [f, e],
- [d, e],
- [d, c],
- [f, c]
- ];
- a.addLayer(this.layerOption, b)
- },
- _getWMSLayer: function(a) {
- a.transparent || a.transparent === !1 ? this.options.transparent = a.transparent : a.transparent = !0;
- this.options = a;
- this.url = a.url;
- var b = this.getParamString({
- SERVICE: "WMS",
- REQUEST: "GetMap",
- VERSION: a.version,
- LAYERS: a.layer,
- styles: a.styles,
- FORMAT: a.format,
- TRANSPARENT: a.transparent,
- BBOX: "{bbox}",
- WIDTH: "{width}",
- HEIGHT: "{height}",
- SRS: a.SRS
- }),
- c = "",
- c = this.url.endsWith("?") || this.url.endsWith("&") ? this.url + b : this.url + "?" + b,
- c = GeoGlobe.appendToProxy(c),
- b = GeoGlobe.Util.randomStr(10),
- d = {
- name: a.layer,
- srs: a.SRS,
- type: "wms",
- isTile: a.isTile,
- format: a.formats
- };
- this.id = "layer_" + a.layer + "_" + b;
- return {
- id: this.id,
- source: {
- type: "image",
- url: c,
- coordinates: []
- },
- metadata: d,
- type: "raster"
- }
- },
- _getWMSTileLayer: function(a) {
- var b = {};
- if (a.layer) b.LAYERS =
- a.layer;
- if (a.format) b.FORMAT = a.format;
- b.TRANSPARENT = a.transparent || a.transparent === !1 ? a.transparent : !0;
- if (a.styles) b.styles = a.styles;
- if (!a.tileSize) a.tileSize = 256;
- b.HEIGHT = a.tileSize;
- b.WIDTH = a.tileSize;
- if (a.version) b.VERSION = a.version;
- if (a.SRS) b.SRS = a.SRS;
- b.BBOX = "{bbox-epsg-3857}";
- GeoGlobe.Util.applyDefaults(b, {
- service: "WMS",
- request: "GetMap"
- });
- var c = {
- name: a.layer,
- srs: a.SRS,
- bbox: a.bbox,
- format: a.format
- },
- d = "wms_" + a.layer + "_" + GeoGlobe.Util.randomStr(8),
- b = GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(b || {})),
- b = GeoGlobe.appendToProxy(b);
- return {
- id: d,
- type: "raster",
- source: {
- type: "raster",
- tiles: [b],
- tileSize: a.tileSize
- },
- metadata: c
- }
- },
- moveend: function() {
- if (this.map.style._layers[this.id] && (this.map.style._layers[this.id].layout && this.map.style._layers[this.id].layout.visibility != "none" || this.map.style._layers[this.id].visibility && this.map.style._layers[this.id].visibility != "none")) {
- var a = this.map.getBounds(),
- b = a._ne.lng,
- c = a._ne.lat,
- d = a._sw.lng,
- e = a._sw.lat,
- a = d + "," + e + "," + b + "," + c;
- this.width = this.map.getCanvas().width;
- this.height = this.map.getCanvas().height;
- var f = GeoGlobe.Util.getParameterString({
- SERVICE: "WMS",
- REQUEST: "GetMap",
- VERSION: this.options.version,
- LAYERS: this.options.layer,
- styles: this.options.styles,
- FORMAT: this.options.format,
- TRANSPARENT: this.options.transparent,
- BBOX: a,
- WIDTH: this.width,
- HEIGHT: this.height,
- SRS: this.options.SRS
- }),
- a = "",
- a = this.url.endsWith("?") || url.endsWith("&") ? this.url + f : this.url + "?" + f,
- a = GeoGlobe.appendToProxy(a),
- b = [
- [d, c],
- [b, c],
- [b, e],
- [d, e]
- ],
- c = this.map.getSource(this.id);
- c.url = a;
- c.options.url =
- a;
- c.coordinates = b;
- c.options.coordinates = b;
- c.isReload = !0;
- c.load()
- }
- },
- clone: function(a) {
- a == null && (a = new GeoGlobe.Layer.WMS(this.id, this.tileSize, this.filter, this.opacity, this.visible, this.name, this.url));
- return a
- },
- getParamString: function(a) {
- var b = [],
- c;
- for (c in a) {
- var d = a[c];
- d != null && typeof d != "function" && b.push(c + "=" + d)
- }
- return b.join("&")
- },
- CLASS_NAME: "GeoGlobe.Layer.WMS"
- });
- GeoGlobe.Layer.VTS = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- url: null,
- layer: null,
- format: null,
- matrixSet: null,
- style: null,
- name: null,
- resolutions: null,
- zoomOffset: null,
- matrixIds: null,
- tileOrigin: null,
- tileFullExtent: null,
- initialize: function(a) {
- this.source_id = "source_vts_" + GeoGlobe.Util.randomStr(6);
- this.layers = this._getVTSLayer(a);
- this.source = {
- type: "vector",
- tiles: [this.url_tmpl]
- }
- },
- _getVTSLayer: function(a) {
- this.url = a.url;
- var b = {};
- if (a.layer) b.LAYER = a.layer;
- if (a.format) b.FORMAT = a.format;
- if (a.matrixSet) b.TILEMATRIXSET =
- a.matrixSet;
- if (a.version) b.VERSION = a.version;
- if (a.tileSize) b.WIDTH = a.tileSize, b.HEIGHT = a.tileSize;
- GeoGlobe.Util.applyDefaults(b, {
- service: "WMTS",
- request: "GetTile",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- });
- var c = GeoGlobe.ProxyHost + GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(b || {}));
- this.url_tmpl = c;
- var d = [],
- e = this;
- this.GetStyle(a.styleName, function(c) {
- var g = c.sprite ? GeoGlobe.ProxyHost + c.sprite : "",
- h = c.glyphs ? GeoGlobe.ProxyHost + c.glyphs : "";
- e.sprite = g;
- e.glyphs = h;
- g = {
- sprite: g,
- glyphs: h,
- styleName: c.name,
- layerIdentifier: b.LAYER,
- matrixSet: b.TILEMATRIXSET,
- format: b.FORMAT,
- bbox: a.tileBBox ? a.tileBBox : "",
- minZoom: a.minZoom ? a.minZoom : "",
- maxZoom: a.maxZoom ? a.maxZoom : ""
- };
- if (c.styleData)
- for (h = 0; h < c.styleData.layers.length; h++) c.styleData.layers[h].metadata = g, c.styleData.layers[h].source = e.source_id, d[h] = c.styleData.layers[h];
- else
- for (h = 0; h < c.layers.length; h++) c.layers[h].source = e.source_id, c.layers[h].metadata = g, d[h] = c.layers[h]
- }, function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- c + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return d
- },
- GetStyle: function(a, b, c) {
- var d = this.url;
- if (a == "" || a == void 0) alert("\u8bf7\u67e5\u770b\u6837\u5f0f\u540d\u79f0\u662f\u5426\u5b58\u5728");
- else {
- var e = {
- REQUEST: "GetStyle",
- SERVICE: "WMTS",
- VERSION: "1.0.0",
- STYLENAME: a
- };
- c || (c = function() {
- this.failFn(e.REQUEST)
- });
- GeoGlobe.Request.GET({
- url: d,
- params: e,
- scope: this,
- async: !1,
- success: function(a) {
- a = a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b(a)
- },
- failure: c
- })
- }
- },
- clone: function(a) {
- a ==
- null && (a = new GeoGlobe.Layer.VTS(this.id, this.tileSize, this.filter, this.opacity, this.visible, this.name, this.url));
- return a
- },
- getMatrix: function() {
- var a;
- if (!this.matrixIds || this.matrixIds.length === 0) a = {
- identifier: this.getIdentifier()
- };
- else if ("scaleDenominator" in this.matrixIds[0])
- for (var b = GeoGlobe.METERS_PER_INCH * GeoGlobe.INCHES_PER_UNIT[this.units] * this.getServerResolution() / 2.8E-4, c = Number.POSITIVE_INFINITY, d, e = 0, f = this.matrixIds.length; e < f; ++e) d = Math.abs(1 - this.matrixIds[e].scaleDenominator / b),
- d < c && (c = d, a = this.matrixIds[e]);
- else a = this.matrixIds[this.getIdentifier()];
- return a
- },
- CLASS_NAME: "GeoGlobe.Layer.VTS"
- });
- GeoGlobe.Layer.ArcgisVTS = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- url: null,
- sprite: null,
- glyphs: null,
- sources: {},
- layers: [],
- initialize: function(a) {
- this.options = GeoGlobe.Util.clone(a);
- this._loadArcgisVTSStyle(this.options)
- },
- _loadArcgisVTSStyle: function(a) {
- var b = this,
- c = a.url;
- this.url = c;
- var d = a.tileSize || 256,
- e = "-" + GeoGlobe.Util.randomStr(6),
- f = function(f) {
- var h = function(a) {
- if (a.sprite) b.sprite = GeoGlobe.ProxyHost + b._getAbsoluteUrl(a.sprite);
- if (a.glyphs) b.glyphs = GeoGlobe.ProxyHost + b._getAbsoluteUrl(a.glyphs);
- b.sources = {};
- for (var c in a.sources) {
- var h = a.sources[c];
- c += e;
- b.sources[c] = {
- type: "vector",
- tiles: [GeoGlobe.ProxyHost + b._getAbsoluteUrl(h.url) + "/tile/{z}/{y}/{x}.pbf"],
- tileSize: d,
- maxzoom: f
- }
- }
- b.layers = a.layers.map(function(a) {
- a.id += e;
- typeof a.source === "string" && (a.source += e);
- return a
- })
- };
- a.style ? h(a.style) : b.GetStyle(c, h, function() {
- b.sources = {};
- b.layers = [];
- alert("ArcGisVST\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- c + "/resources/styles/root.json")
- })
- };
- this.getServerInfo(c, function(b) {
- var c = a.offset,
- b = b.maxLOD,
- b = isNaN(c) ? b : b - c;
- f(b)
- }, function() {
- this.sources = {};
- this.layers = [];
- alert("ArcGisVST\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + c + "?f=pjson")
- })
- },
- getServerInfo: function(a, b, c) {
- var d = this;
- GeoGlobe.Request.GET({
- url: a + "?f=pjson",
- async: !1,
- success: function(a) {
- a =
- a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b.call(d, a)
- },
- failure: c
- })
- },
- GetStyle: function(a, b, c) {
- var d = this;
- GeoGlobe.Request.GET({
- url: a + "/resources/styles/root.json",
- async: !1,
- success: function(a) {
- a = a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b.call(d, a)
- },
- failure: c
- })
- },
- _getAbsoluteUrl: function(a) {
- if (/^(http|https):\/\//.test(a)) return a;
- var b = [this.url, "resources", "styles"];
- a.split("/").forEach(function(a) {
- a !== "" && (a === ".." ? b.pop() : b.push(a))
- });
- return b.join("/")
- },
- clone: function(a) {
- a == null && (a = new GeoGlobe.Layer.ArcgisVTS(this.options));
- return a
- },
- CLASS_NAME: "GeoGlobe.Layer.ArcgisVTS"
- });
- GeoGlobe.Layer.MultidateVTS = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- url: null,
- layer: null,
- format: null,
- matrixSet: null,
- style: null,
- name: null,
- zoomOffset: null,
- matrixIds: null,
- initialize: function(a) {
- this.source_id = "source_MultidateVTS_" + GeoGlobe.Util.randomStr(6);
- this.layers = this._getMultidateVTSLayer(a);
- if (a.format !== "protobuf") return this.layers;
- this.source = {
- type: "vector",
- tiles: [url]
- }
- },
- _getMultidateVTSLayer: function(a) {
- this.url = a.url;
- var b = {};
- if (a.layer) b.LAYER = a.layer;
- if (a.format) b.FORMAT = a.format;
- if (a.matrixSet) b.TILEMATRIXSET =
- a.matrixSet;
- if (a.version) b.VERSION = a.version;
- if (a.format !== "protobuf" && a.styleName) b.STYLENAME = a.styleName;
- if (a.time) b.TIME = a.time;
- if (a.useRecent) b.USERECENT = a.useRecent;
- if (a.tileSize) b.WIDTH = a.tileSize, b.HEIGHT = a.tileSize;
- GeoGlobe.Util.applyDefaults(b, {
- service: "WMTS",
- request: "GetTile",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- });
- var c = GeoGlobe.ProxyHost + GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(b || {}));
- if (b.FORMAT !== "protobuf") return {
- id: "geowmts",
- type: "raster",
- source: {
- type: "raster",
- tiles: [c],
- tileSize: 256
- },
- maxzoom: 22,
- minzoom: 0
- };
- var d = "source_MultidateVTS_" + GeoGlobe.Util.randomStr(6);
- this.source_id = d;
- var e = this,
- f = [];
- this.GetStyle(a.styleName, function(c) {
- var h = "",
- j = "";
- c.sprite && (h = GeoGlobe.ProxyHost + c.sprite);
- c.glyphs ? j = GeoGlobe.ProxyHost + c.glyphs : a.glyphs && (j = GeoGlobe.ProxyHost + a.glyphs + "?SERVICE=FLS&VERSION=1.0&REQUEST=GetFont&FONTNAME={fontstack}&RANGE={range}.pbf");
- e.sprite = h;
- e.glyphs = j;
- h = {
- sprite: h,
- glyphs: j,
- styleName: c.name,
- layerIdentifier: b.LAYER,
- matrixSet: b.TILEMATRIXSET,
- format: b.FORMAT,
- bbox: a.tileBBox ? a.tileBBox : "",
- minZoom: a.minZoom ? a.minZoom : "",
- maxZoom: a.maxZoom ? a.maxZoom : ""
- };
- if (c.styleData)
- for (j = 0; j < c.styleData.layers.length; j++) c.styleData.layers[j].metadata = h, c.styleData.layers[j].source = d, f[j] = c.styleData.layers[j];
- else
- for (j = 0; j < c.layers.length; j++) c.layers[j].source = d, c.layers[j].metadata = h, f[j] = c.layers[j]
- }, function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- c + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return f
- },
- GetStyle: function(a, b, c) {
- var d = this.url;
- if (a == "" || a == void 0) alert("\u8bf7\u67e5\u770b\u6837\u5f0f\u540d\u79f0\u662f\u5426\u5b58\u5728");
- else {
- var e = {
- REQUEST: "GetStyle",
- SERVICE: "WMTS",
- VERSION: "1.0.0",
- STYLENAME: a
- };
- c || (c = function() {
- this.failFn(e.REQUEST)
- });
- GeoGlobe.Request.GET({
- url: d,
- params: e,
- scope: this,
- async: !1,
- success: function(a) {
- a = a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b(a)
- },
- failure: c
- })
- }
- },
- clone: function(a) {
- a ==
- null && (a = new GeoGlobe.Layer.MultidateVTS(this.id, this.tileSize, this.filter, this.opacity, this.visible, this.name, this.url));
- return a
- },
- CLASS_NAME: "GeoGlobe.Layer.MultidateVTS"
- });
- GeoGlobe.Layer.Export = GeoGlobe.Class4OL({
- url: null,
- f: null,
- format: null,
- size: 256,
- transparent: !0,
- initialize: function(a) {
- return this._getExportTileLayer(a)
- },
- _getExportTileLayer: function(a) {
- DEFAULT_PARAMS = {};
- var b = {
- BBOX: "{bbox-epsg-3857}"
- };
- b.format = a.format ? a.format : "image/png";
- b.transparent = a.transparent || a.transparent === !1 ? a.transparent : !0;
- b.f = a.f ? a.f : "image";
- b.size = a.size ? a.size + "," + a.size : "256,256";
- GeoGlobe.Util.applyDefaults(b, DEFAULT_PARAMS);
- var c = {
- url: a.url,
- transparent: b.transparent,
- size: b.size,
- bbox: b.BBOX,
- format: b.format,
- f: b.f
- },
- d = GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(b || {}));
- GeoGlobe.ProxyHost && (d = GeoGlobe.appendToProxy(d));
- return {
- id: a.id ? a.id : "GEO_ARCGIS_EXPORT",
- type: "raster",
- source: {
- type: "raster",
- tiles: [d],
- tileSize: b.size.split(",")[0] * 1
- },
- metadata: c
- }
- },
- CLASS_NAME: "GeoGlobe.Layer.Export"
- });
- GeoGlobe.Layer.GeoTileLayer = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- id: null,
- tileSize: 256,
- url: null,
- minzoom: null,
- maxzoom: null,
- initialize: function(a) {
- this.url = a.url;
- this.extent = a.maxextent;
- var b = this.convertUrl(this.url);
- return {
- id: a.id,
- name: a.name,
- type: a.type,
- source: {
- type: a.type,
- tiles: [b[0] + "?T=" + b[1] + "&X={x}&Y={y}&L={z}"],
- tileSize: a.tileSize
- },
- maxzoom: parseInt(a.maxzoom),
- minzoom: parseInt(a.minzoom),
- paint: {
- "raster-opacity": a.opacity == null ? 1 : a.opacity
- },
- layout: {
- visibility: a.visibility == null ? "visible" : a.visibility
- }
- }
- },
- convertUrl: function(a) {
- var b = [],
- c = a.split("/services/");
- if (c[0] && c[1]) return b.push(c[0] + "/DataServer"), b.push(c[1]), b;
- else alert("\u89e3\u6790\u670d\u52a1\u5730\u5740\u9519\u8bef:" + a)
- },
- selectUrl: function(a, b) {
- return b[a % b.length]
- },
- getDataExtent: function() {
- if (this.maxExtent) return this.maxExtent.clone()
- },
- clone: function(a) {
- return a = new GeoGlobe.Layer.GeoTileLayer(this.name, this.url, this.options)
- },
- CLASS_NAME: "GeoGlobe.Layer.GeoTileLayer"
- });
- GeoGlobe.Layer.GeoWMTSLayer = GeoGlobe.Class4OL(GeoGlobe.Layer.WMTS, {
- time: "9999-01-01 00:00:00",
- userecent: !0,
- initialize: function(a) {
- var b = new GeoGlobe.Layer.WMTS(a);
- b.source.tiles[0] += "&" + GeoGlobe.Util.getParameterString({
- time: a.time,
- userecent: !!a.userecent || !0
- });
- if (a.minzoom) b.minzoom = a.minzoom;
- if (a.maxzoom) b.maxzoom = a.maxzoom;
- return b
- },
- CLASS_NAME: "GeoGlobe.Layer.GeoWMTSLayer"
- });
- GeoGlobe.Layer.RasterLayer = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- initialize: function(a) {
- return a
- },
- CLASS_NAME: "GeoGlobe.Layer.RasterLayer"
- });
- GeoGlobe.Layer.VectorLayer = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- LAYER_TYPE: null,
- initialize: function(a) {
- if ("data" in a) {
- if (a.data instanceof Array) a.data = {
- type: "FeatureCollection",
- features: a.data
- };
- var b = {
- type: "geojson",
- data: a.data
- };
- delete a.data;
- return GeoGlobe.Util.applyDefaults(a, {
- id: this.LAYER_TYPE + "-" + GeoGlobe.Util.randomStr(6),
- type: this.LAYER_TYPE,
- source: b
- })
- } else return a
- },
- CLASS_NAME: "GeoGlobe.Layer.VectorLayer"
- });
- GeoGlobe.Layer.CircleLayer = GeoGlobe.Class4OL(GeoGlobe.Layer.VectorLayer, {
- LAYER_TYPE: "circle",
- initialize: function() {
- return GeoGlobe.Layer.VectorLayer.prototype.initialize.apply(this, arguments)
- },
- CLASS_NAME: "GeoGlobe.Layer.CircleLayer"
- });
- GeoGlobe.Layer.SymbolLayer = GeoGlobe.Class4OL(GeoGlobe.Layer.VectorLayer, {
- LAYER_TYPE: "symbol",
- initialize: function() {
- return GeoGlobe.Layer.VectorLayer.prototype.initialize.apply(this, arguments)
- },
- CLASS_NAME: "GeoGlobe.Layer.SymbolLayer"
- });
- GeoGlobe.Layer.LineLayer = GeoGlobe.Class4OL(GeoGlobe.Layer.VectorLayer, {
- LAYER_TYPE: "line",
- initialize: function() {
- return GeoGlobe.Layer.VectorLayer.prototype.initialize.apply(this, arguments)
- },
- CLASS_NAME: "GeoGlobe.Layer.LineLayer"
- });
- GeoGlobe.Layer.FillLayer = GeoGlobe.Class4OL(GeoGlobe.Layer.VectorLayer, {
- LAYER_TYPE: "fill",
- initialize: function() {
- return GeoGlobe.Layer.VectorLayer.prototype.initialize.apply(this, arguments)
- },
- CLASS_NAME: "GeoGlobe.Layer.FillLayer"
- });
- GeoGlobe.Layer.FillExtrusionLayer = GeoGlobe.Class4OL(GeoGlobe.Layer.VectorLayer, {
- LAYER_TYPE: "fill-extrusion",
- initialize: function() {
- return GeoGlobe.Layer.VectorLayer.prototype.initialize.apply(this, arguments)
- },
- CLASS_NAME: "GeoGlobe.Layer.FillExtrusionLayer"
- });
- GeoGlobe.Layer.FillExtrusionLayer2 = GeoGlobe.Class4OL(GeoGlobe.Layer.VectorLayer, {
- LAYER_TYPE: "fill-extrusion",
- initialize: function(a) {
- this.options = a;
- a.data = this._splitData(a.data || []);
- var b = GeoGlobe.Layer.VectorLayer.prototype.initialize.apply(this, arguments);
- if (!b.paint) b.paint = {};
- GeoGlobe.Util.extend(b.paint, {
- "fill-extrusion-base": ["get", "_base"],
- "fill-extrusion-height": ["get", "_height"],
- "fill-extrusion-color": ["get", "_value"]
- });
- a.isPattern && (b.paint["fill-extrusion-pattern"] = ["get", "_value"]);
- this.layer =
- b
- },
- _splitData: function(a) {
- var b = GeoGlobe.Util.pick(this.options, ["heightProperty", "gradient", "roof"]),
- c = [];
- a instanceof Array ? c = a : a.type === "FeatureCollection" ? c = a.features : a.type === "Feature" && (c = [a]);
- for (var a = [], d = 0; d < c.length; d++) a = a.concat(this._splitFeature(c[d], b.heightProperty || "height", b.gradient, b.roof));
- return a
- },
- _splitFeature: function(a, b, c, d) {
- var e = [],
- f = c.length / 2,
- b = a.properties[b];
- if (d) {
- var g = JSON.parse(JSON.stringify(a));
- GeoGlobe.Util.extend(g.properties, {
- _base: b,
- _height: b + 0.01,
- _value: d
- });
- e.push(g)
- }
- for (d = f - 1; d >= 0; d--) {
- var f = c[d * 2],
- h = c[d * 2 + 1];
- b - f > 0 && (g = JSON.parse(JSON.stringify(a)), GeoGlobe.Util.extend(g.properties, {
- _base: f,
- _height: b,
- _value: h
- }), e.push(g), b = f)
- }
- return e
- },
- setData: function(a) {
- a = {
- type: "FeatureCollection",
- features: this._splitData(a)
- };
- this.layer.source = {
- type: "geojson",
- data: a
- };
- this.map && this.map.getSource(this.layer.id).setData(a)
- },
- CLASS_NAME: "GeoGlobe.Layer.FillExtrusionLayer2"
- });
- GeoGlobe.Layer.BackgroundLayer = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- "background-color": null,
- "background-pattern": null,
- "background-opacity": null,
- initialize: function(a) {
- return a
- },
- CLASS_NAME: "GeoGlobe.Layer.BackgroundLayer"
- });
- GeoGlobe.Layer.ThematicTileLayer = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- map: null,
- version: "1.0.0",
- id: null,
- layerID: null,
- chartID: null,
- maxExtent: null,
- format: "png",
- colorSchemeID: null,
- hasLegend: !1,
- legendType: 0,
- legendPosition: "br",
- hasEdge: !1,
- hasLabel: !1,
- hasBaseMap: !1,
- hasBaseMapLegend: !1,
- baseMapExampleColumnNums: 2,
- initialize: function(a, b) {
- var c = b.box,
- d = c._ne.lng,
- e = c._ne.lat,
- f = c._sw.lng,
- c = c._sw.lat,
- g = b.params;
- this.map = a;
- this.options = b;
- GeoGlobe.Function.bind(this.seturl, this);
- g = this.seturl(g);
- this.layer = {
- id: this.options.id,
- minzoom: b.minzoom ? this.options.minzoom : 0,
- maxzoom: b.maxzoom ? this.options.maxzoom : 20,
- source: {
- type: "image",
- url: this.options.url + "/map/" + this.options.layerID + "/" + this.options.chartID + "/" + f + "/" + c + "/" + d + "/" + e + "/" + this.options.width + "/" + this.options.height + ".png?" + g,
- coordinates: [
- [f, e],
- [d, e],
- [d, c],
- [f, c]
- ]
- },
- type: "raster"
- };
- this.zoome = this.zoomend.bind(this);
- this.drage = this.dragend.bind(this);
- this.map.on("zoomend", this.zoome);
- this.map.on("dragend", this.drage);
- GeoGlobe.Function.bind(this.remove, this);
- return this
- },
- zoomend: function() {
- if (this.map.style._layers[this.options.id] && this.map.style._layers[this.options.id].layout && this.map.style._layers[this.options.id].layout.visibility != "none") {
- var a = this.map.style._layers[this.options.id].metadata,
- b = this.map.style._layers[this.options.id].paint,
- c = this.map.style._layers[this.options.id].layout;
- this.map.removeLayer(this.options.id);
- this.map.removeSource(this.options.id);
- box = this.map.getBounds();
- var d = this.options.params;
- maxx = box._ne.lng;
- maxy = box._ne.lat;
- minx = box._sw.lng;
- miny = box._sw.lat;
- d = this.seturl(d);
- this.options.width = this.map.getCanvas().width;
- this.options.height = this.map.getCanvas().height;
- url = this.options.url + "/map/" + this.options.layerID + "/" + this.options.chartID + "/" + minx + "/" + miny + "/" + maxx + "/" + maxy + "/" + this.options.width + "/" + this.options.height + ".png?" + d;
- layer = {
- id: this.options.id,
- name: this.options.name,
- source: {
- type: "image",
- url: url,
- coordinates: [
- [minx, maxy],
- [maxx, maxy],
- [maxx, miny],
- [minx, miny]
- ]
- },
- type: "raster"
- };
- layer.paint = b;
- layer.layout = c;
- layer.metadata = a;
- this.map.addLayer(layer)
- }
- },
- dragend: function() {
- if (this.map.style._layers[this.options.id] && this.map.style._layers[this.options.id].layout && this.map.style._layers[this.options.id].layout.visibility != "none") {
- var a = this.map.style._layers[this.options.id].metadata,
- b = this.map.style._layers[this.options.id].paint,
- c = this.map.style._layers[this.options.id].layout;
- this.map.removeLayer(this.options.id);
- this.map.removeSource(this.options.id);
- box = this.map.getBounds();
- var d = this.options.params;
- maxx = box._ne.lng;
- maxy = box._ne.lat;
- minx = box._sw.lng;
- miny = box._sw.lat;
- d = this.seturl(d);
- this.options.width = this.map.getCanvas().width;
- this.options.height = this.map.getCanvas().height;
- url = this.options.url + "/map/" + this.options.layerID + "/" + this.options.chartID + "/" + minx + "/" + miny + "/" + maxx + "/" + maxy + "/" + this.options.width + "/" + this.options.height + ".png?" + d;
- layer = {
- id: this.options.id,
- name: this.options.name,
- source: {
- type: "image",
- url: url,
- coordinates: [
- [minx, maxy],
- [maxx, maxy],
- [maxx, miny],
- [minx, miny]
- ]
- },
- type: "raster"
- };
- layer.paint = b;
- layer.layout = c;
- layer.metadata = a;
- this.map.addLayer(layer)
- }
- },
- seturl: function(a) {
- var b = "",
- c;
- for (c in a) a[c] != -1 && (b += c + "=" + a[c] + "&");
- return b = b.substring(0, b.length - 1)
- },
- getCapabilities: function(a, b, c) {
- typeof c != "function" && (c = function() {
- alert("\u4e13\u9898\u56fe\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- var d = this;
- GeoGlobe.Request.GET({
- url: a,
- cache: !1,
- async: !1,
- success: function(a) {
- a = a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b.call(d, a)
- },
- failure: c
- })
- },
- remove: function(a) {
- this.map.off("zoomend", this.zoome);
- this.map.off("dragend", this.drage);
- this.map.removeLayer(a);
- this.map.removeSource(a)
- },
- showLegend: function() {
- var a = this.getLegend({
- layerID: this.layerID,
- chartID: this.chartID,
- colorSchemeID: this.colorSchemeID,
- drawLegend: "ThematicMap",
- legendType: this.legendType
- });
- this.imageLegend || (new GeoGlobe.Marker(a)).setLngLat([lnglat.lng,
- lnglat.lat
- ]).addTo(this.map)
- },
- getLegend: function(a) {
- if (this.url.indexOf("/", this.url.length - 1) != -1) this.url = this.url.substr(0, this.url.length - 1);
- var b;
- b = GeoGlobe.String.format("${url}/legend/${layerID}/${chartID}.${format}?drawLegend=${drawLegend}&legendType=${legendType}", {
- url: this.url,
- layerID: a.layerID,
- chartID: a.chartID,
- format: a.format || "png",
- drawLegend: a.drawLegend,
- legendType: a.legendType
- });
- typeof a.colorSchemeID === "string" && (b += "&ColorSchemeID=" + a.colorSchemeID);
- return b
- },
- setLegendLocation: function(a) {
- var b =
- this.map.getSize();
- switch (this.legendPosition) {
- case "br":
- var c = b.w - this.legendSize.w,
- b = b.h - this.legendSize.h;
- a.style.left = c + "px";
- a.style.top = b + "px";
- break;
- case "bl":
- b = b.h - this.legendSize.h;
- a.style.left = "0px";
- a.style.top = b + "px";
- break;
- case "tl":
- a.style.left = "0px";
- a.style.top = "0px";
- break;
- case "tr":
- c = b.w - this.legendSize.w, a.style.left = c + "px", a.style.top = "0px"
- }
- },
- showBaseMapLegend: function() {
- var a = this.getBaseMapLegend({
- layerID: this.layerID,
- chartID: this.chartID,
- drawLegend: "BaseMap",
- baseMapExampleColumnNums: this.baseMapExampleColumnNums
- });
- this.imageBaseMapLegend || (new GeoGlobe.Marker(a)).setLngLat([lnglat.lng, lnglat.lat]).addTo(this.map)
- },
- getBaseMapLegend: function(a) {
- if (this.url.indexOf("/", this.url.length - 1) != -1) this.url = this.url.substr(0, this.url.length - 1);
- return a = GeoGlobe.String.format("${url}/legend/${layerID}/${chartID}.${format}?drawLegend=${drawLegend}&baseMapExampleColumnNums=${baseMapExampleColumnNums}", {
- url: this.url,
- layerID: a.layerID,
- chartID: a.chartID,
- format: a.format || "png",
- drawLegend: a.drawLegend,
- baseMapExampleColumnNums: a.baseMapExampleColumnNums
- })
- },
- setBaseMapLegendLocation: function(a) {
- var b = this.map.getSize();
- switch (this.baseMapLegendPosition) {
- case "br":
- var c = b.w - this.baseMapLegendSize.w,
- b = b.h - this.baseMapLegendSize.h;
- a.style.left = c + "px";
- a.style.top = b + "px";
- break;
- case "bl":
- b = b.h - this.baseMapLegendSize.h;
- a.style.left = "0px";
- a.style.top = b + "px";
- break;
- case "tl":
- a.style.left = "50px";
- a.style.top = "0px";
- break;
- case "tr":
- c = b.w - this.baseMapLegendSize.w, a.style.left = c + "px", a.style.top = "0px"
- }
- },
- updateHotArea: function(a) {
- a.zoomChanged ? this.vectorLayer.removeAllFeatures() :
- this.vectorLayer.redraw()
- },
- clone: function(a) {
- a == null && (a = new GeoGlobe.Layer.ThematicTileLayer(this.id, this.url, this.params, this.getOptions()));
- return a
- },
- getURL: function(a) {
- var a = this.adjustBounds(a),
- b = this.getImageSize(),
- a = GeoGlobe.String.format("${url}/map/${layerID}/${chartID}/${left}/${bottom}/${right}/${top}/${width}/${height}.${format}?hasLegend=${hasLegend}&legendType=${legendType}&hasEdge=${hasEdge}&hasLabel=${hasLabel}&hasBaseMap=${hasBaseMap}&hasBaseMapLegend=${hasBaseMapLegend}&baseMapExampleColumnNums=${baseMapExampleColumnNums}", {
- url: this.url,
- layerID: this.layerID,
- chartID: this.chartID,
- left: a.left,
- bottom: a.bottom,
- right: a.right,
- top: a.top,
- width: b.w,
- height: b.h,
- format: this.format,
- hasLegend: this.hasLegend,
- legendType: this.legendType,
- hasEdge: this.hasEdge,
- hasLabel: this.hasLabel,
- hasBaseMap: this.hasBaseMap,
- hasBaseMapLegend: this.hasBaseMapLegend,
- baseMapExampleColumnNums: this.baseMapExampleColumnNums
- });
- typeof this.colorSchemeID === "string" && (a += "&ColorSchemeID=" + this.colorSchemeID);
- return a
- },
- CLASS_NAME: "GeoGlobe.Layer.ThematicTileLayer"
- });
- GeoGlobe.CanvasLayer = GeoGlobe.Class4OL({
- map: null,
- context: null,
- initialize: function(a) {
- this.id = GeoGlobe.Util.createUniqueID(this.CLASS_NAME + "_");
- this.options = a
- },
- drawOnMove: null,
- _drawLayer: function() {
- this.clear();
- var a = this._prepareDrawParams();
- a && this.draw.apply(this, a)
- },
- _prepareDrawParams: function() {
- var a = [];
- if (!this._drawContext) this._drawContext = this.prepareToDraw.apply(this, [this.context].concat(a));
- a = [this.context];
- a.push.apply(a, this._drawContext);
- return a
- },
- prepareToDraw: function() {},
- draw: function() {},
- addTo: function(a) {
- this.map = a;
- var b = a.getCanvasContainer();
- this.canvas = document.createElement("canvas");
- this.canvas.id = this.id;
- this.canvas.style.width = a.getCanvas().style.width;
- this.canvas.style.height = a.getCanvas().style.height;
- this.canvas.style.position = "absolute";
- this.canvas.style.display = "none";
- this.canvas.width = a.getCanvas().width;
- this.canvas.height = a.getCanvas().height;
- b.appendChild(this.canvas);
- this.context = this.canvas.getContext("2d");
- this._bindEvent();
- var c = {
- type: "canvas",
- canvas: this.canvas.id,
- animate: !0,
- coordinates: this._boundsToCoordinates(a.getBounds())
- },
- d = {
- id: this.id + "_layer",
- source: this.id,
- type: "raster",
- paint: {
- "raster-opacity": 1
- }
- };
- a.addSource(this.id, c);
- a.addLayer(d);
- this.source = a.getSource(this.id);
- this.layer = a.getLayer(this.id + "_layer");
- b.removeChild(this.canvas);
- this._drawLayer()
- },
- _bindEvent: function() {
- var a = this.map;
- this._move = GeoGlobe.Function.bind(function(a) {
- typeof this.drawOnMove === "function" && this.drawOnMove(a)
- }, this);
- this._moveend = GeoGlobe.Function.bind(function(a) {
- this.source.setCoordinates(this._boundsToCoordinates(a.target.getBounds()));
- this._drawLayer()
- }, this);
- a.on("move", this._move);
- a.on("moveend", this._moveend)
- },
- pause: function() {
- this.source.pause()
- },
- play: function() {
- this.source.play()
- },
- setOpacity: function(a) {
- this.map.setPaintProperty(this.layer.id, "raster-opacity", parseFloat(a))
- },
- clear: function() {
- this.context.clearRect(0, 0, this.canvas.width, this.canvas.height)
- },
- remove: function() {
- this.clear();
- var a = this.map;
- a.off("move", this._move);
- a.off("moveend", this._moveend);
- a.removeSource(this.source.id);
- a.removeLayer(this.layer.id);
- this.map =
- this.canvas = null
- },
- _boundsToCoordinates: function(a) {
- var b = a.toArray(),
- a = b[0][0],
- c = b[0][1],
- d = b[1][0],
- b = b[1][1];
- return [
- [a, b],
- [d, b],
- [d, c],
- [a, c]
- ]
- },
- CLASS_NAME: "GeoGlobe.CanvasLayer"
- });
- GeoGlobe.TDTLayer = GeoGlobe.Class4OL({
- initialize: function(a, b) {
- return this._getLayer(a, b)
- },
- _getLayer: function(a, b) {
- var c = "tdt_" + a + "_" + GeoGlobe.Util.randomStr(8),
- d = GeoGlobe.ProxyHost + this._getUrlTemplateByName(a) + "&tk=" + (b || "e90d56e5a09d1767899ad45846b0cefd");
- return {
- id: c,
- type: "raster",
- source: {
- type: "raster",
- tiles: [d],
- tileSize: 256,
- noFadingParent: !0
- }
- }
- },
- _getUrlTemplateByName: function(a) {
- return "https://t0.tianditu.gov.cn/" + a + "/wmts?" + GeoGlobe.Util.getParameterString(this.tdtParams[a])
- },
- tdtParams: {
- vec_w: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "vec",
- TILEMATRIXSET: "w",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- cva_w: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "cva",
- TILEMATRIXSET: "w",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- vec_c: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "vec",
- TILEMATRIXSET: "c",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- cva_c: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "cva",
- TILEMATRIXSET: "c",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- img_w: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "img",
- TILEMATRIXSET: "w",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- cia_w: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "cia",
- TILEMATRIXSET: "w",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- img_c: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "img",
- TILEMATRIXSET: "c",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- },
- cia_c: {
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- LAYER: "cia",
- TILEMATRIXSET: "c",
- FORMAT: "tiles",
- VERSION: "1.0.0",
- STYLE: "default",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- }
- },
- CLASS_NAME: "GeoGlobe.TDTLayer"
- });
- GeoGlobe.Layer.HotArea = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- url: null,
- layer: null,
- format: null,
- matrixSet: null,
- style: null,
- version: "1.0.0",
- name: null,
- layerid: null,
- hotareaLayers: null,
- hotareaHighlightedLayers: null,
- tileUrls: null,
- initialize: function(a) {
- this.name = a.name ? a.name : null;
- this.url = a.url;
- this.layer = a.layer;
- this.format = a.format;
- this.matrixSet = a.matrixSet;
- this.style = a.style;
- this.layerid = "geoglobe_layer_hotarea_" + GeoGlobe.Util.randomStr(8);
- this.layerOption = {
- id: this.layerid,
- type: "raster",
- source: {
- type: "raster",
- rasterType: "hotarea",
- tiles: [GeoGlobe.appendToProxy(a.url + "?SERVICE=WMTS&REQUEST=GetTile&LAYER=" + this.layer + "&TILEMATRIXSET=" + this.matrixSet + "&FORMAT=" + this.format + "&VERSION=" + this.version + "&STYLE=" + this.style + "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}")],
- tileSize: 256
- },
- paint: {
- "raster-opacity": 1
- },
- metadata: {
- type: "hotarea"
- }
- };
- this.hotareaLayers = [];
- this.hotareaHighlightedLayers = [];
- this.tileUrls = [];
- this.onclick = typeof a.onclick === "function" ? a.onclick : this.onclick
- },
- addTo: function(a) {
- this.map = a;
- a.addLayer(this.layerOption);
- this._bindEvent()
- },
- _bindEvent: function() {
- var a = this.map;
- GeoGlobe.Layer.HotArea["callback_tileJSON_" + this.layerid] = GeoGlobe.Function.bind(this.callback_tile, this);
- var b = GeoGlobe.Function.bind(function(b) {
- for (var d = [
- [b.point.x - 2, b.point.y - 2],
- [b.point.x + 2, b.point.y + 2]
- ], e = [], f = 0; f < this.hotareaLayers.length; f++) e.push(this.hotareaLayers[f].id);
- d = a.queryRenderedFeatures(d, {
- layers: e
- });
- d.length > 0 ? (d = [d[0]], this.map.getCanvas().style.cursor = "pointer") : this.map.getCanvas().style.cursor = "";
- e = d.reduce(function(a,
- b) {
- a.push(b.properties.displayname);
- return a
- }, ["==", "displayname"]);
- e = e.length === 2 ? ["==", "displayname", ""] : e;
- for (f = 0; f < this.hotareaHighlightedLayers.length; f++) a.setFilter(this.hotareaHighlightedLayers[f].id, e);
- if (b.type === "click") b.features = d, this.onclick(b)
- }, this);
- a.on("click", b);
- a.on("mousemove", b);
- b = GeoGlobe.Function.bind(function() {
- for (var b = 0; b < this.hotareaHighlightedLayers.length; b++) a.removeLayer(this.hotareaHighlightedLayers[b].id);
- this.hotareaHighlightedLayers = [];
- for (b = 0; b < this.hotareaLayers.length; b++) a.removeLayer(this.hotareaLayers[b].id),
- a.removeSource(this.hotareaLayers[b].id);
- this.hotareaLayers = [];
- this.tileUrls = []
- }, this);
- a.on("zoomstart", b)
- },
- callback_tile: function(a) {
- for (var b = a.tileUrl, c = !1, d = 0; d < this.tileUrls.length; d++) this.tileUrls[d] === b && (c = !0);
- if (!c) {
- this.tileUrls.push(b);
- b = a.data;
- c = b.features;
- for (d = 0; d < c.length; d++) {
- var e = c[d].properties.picsymid;
- c[d].properties.overPicUrl = this.getPicURL(e, !0);
- c[d].properties.outPicUrl = this.getPicURL(e, !1)
- }
- a = a.map;
- d = GeoGlobe.Util.randomStr(8);
- b = {
- id: "hotarea_id_" + d,
- type: "fill",
- source: {
- type: "geojson",
- data: b
- },
- paint: {
- "fill-color": "#088",
- "fill-opacity": 0
- }
- };
- a.addLayer(b);
- this.hotareaLayers.push(b);
- d = {
- id: "hotarea_highlighted_id_" + d,
- type: "fill",
- source: b.id,
- paint: {
- "fill-outline-color": "#484896",
- "fill-color": "#6e599f",
- "fill-opacity": 0
- },
- filter: ["==", "displayname", ""]
- };
- a.addLayer(d);
- this.hotareaHighlightedLayers.push(d)
- }
- },
- getPicURL: function(a, b) {
- return this.url + "?" + GeoGlobe.Util.getParameterString({
- SERVICE: "WMTS",
- REQUEST: "GetIcon",
- VERSION: this.version,
- LAYER: this.layer,
- PICID: a,
- ISANTI: b
- })
- },
- onclick: function() {},
- CLASS_NAME: "GeoGlobe.Layer.HotArea"
- });
- GeoGlobe.Layer.ClusterLayer = GeoGlobe.Class4OL(GeoGlobe.Layer, {
- initialize: function(a, b) {
- this.options = a;
- this.source_id = "source_cluster_" + GeoGlobe.Util.randomStr(6);
- this.getClusterSource();
- this.getClusterLayers(b)
- },
- getClusterSource: function() {
- var a = GeoGlobe.Util.pick(this.options, ["data", "clusterMaxZoom", "clusterRadius"]);
- this.source = {
- type: "geojson",
- data: a.data,
- cluster: !0,
- clusterMaxZoom: a.clusterMaxZoom || 14,
- clusterRadius: a.clusterRadius || 50
- }
- },
- getClusterLayers: function(a) {
- var a = a || this._getDefaultLayers(),
- b = GeoGlobe.Util.randomStr(6),
- c = this;
- this.layers = a.map(function(a) {
- a.id = b + "-" + (a.id || GeoGlobe.Util.randomStr(4));
- a.source = c.source_id;
- return a
- })
- },
- _getDefaultLayers: function() {
- var a = GeoGlobe.Util.pick(this.options, ["stops", "colors", "radius", "abbreviated"]);
- GeoGlobe.Util.applyDefaults(a, {
- stops: [0, 100, 750],
- colors: ["#51bbd6", "#f1f075", "#f28cb1"],
- radius: [20, 30, 40],
- abbreviated: !1
- });
- return [{
- id: "clusters",
- type: "circle",
- filter: ["has", "point_count"],
- paint: {
- "circle-color": {
- property: "point_count",
- type: "interval",
- stops: a.stops.map(function(b, c) {
- return [b, a.colors[c]]
- })
- },
- "circle-radius": {
- property: "point_count",
- type: "interval",
- stops: a.stops.map(function(b, c) {
- return [b, a.radius[c]]
- })
- }
- }
- }, {
- id: "cluster-count",
- type: "symbol",
- filter: ["has", "point_count"],
- layout: {
- "text-field": a.abbreviated ? "{point_count_abbreviated}" : "{point_count}",
- "text-size": 12
- }
- }, {
- id: "unclustered-point",
- type: "circle",
- filter: ["!has", "point_count"],
- paint: {
- "circle-color": "#fff",
- "circle-radius": 6,
- "circle-stroke-width": 2,
- "circle-stroke-color": "#0f89f5"
- }
- }]
- },
- CLASS_NAME: "GeoGlobe.Layer.ClusterLayer"
- });
- GeoGlobe.Source = GeoGlobe.Class({
- SourceId: null,
- initialize: function() {
- return this
- },
- CLASS_NAME: "GeoGlobe.Source"
- });
- GeoGlobe.Source.GeoJSONSource = GeoGlobe.Class({
- initialize: function(a, b) {
- var c = {};
- c.id = a;
- c.source = b;
- return c
- },
- CLASS_NAME: "GeoGlobe.Source.GeoJSONSource"
- });
- GeoGlobe.Source.RasterSource = GeoGlobe.Class(mapboxgl.FreeCRSMap, {
- initialize: function(a) {
- return {
- id: a.id,
- type: "raster",
- tiles: a.url,
- tileSize: a.tileSize ? a.tileSize : 256,
- zoomOffset: a.zoomOffset ? a.zoomOffset : 0
- }
- },
- CLASS_NAME: "GeoGlobe.Source.RasterSource"
- });
- GeoGlobe.Source.ImageSource = GeoGlobe.Class({
- initialize: function(a, b) {
- var c = {};
- c.id = a;
- c.source = b;
- return c
- },
- CLASS_NAME: "GeoGlobe.Source.ImageSource"
- });
- GeoGlobe.Source.VectorSource = GeoGlobe.Class({
- initialize: function(a) {
- return {
- id: a.id,
- type: a.type,
- tiles: a.url
- }
- },
- CLASS_NAME: "GeoGlobe.Source.VectorSource"
- });
- GeoGlobe.Source.VideoSource = GeoGlobe.Class({
- initialize: function(a, b) {
- var c = {};
- c.id = a;
- c.video = b;
- return c
- },
- CLASS_NAME: "GeoGlobe.Source.VideoSource"
- });
- GeoGlobe.Marker = mapboxgl.Marker;
- GeoGlobe.Popup = mapboxgl.Popup;
- GeoGlobe.Control = mapboxgl.Control || {};
- GeoGlobe.Control.Navigation = mapboxgl.NavigationControl;
- GeoGlobe.Control.Attribution = mapboxgl.AttributionControl;
- GeoGlobe.Control.Scale = GeoGlobe.Class4OL({
- initialize: function(a) {
- this.options = a;
- mapboxgl.util.bindAll(["_onMove"], this)
- },
- getDefaultPosition: function() {
- return "bottom-left"
- },
- _onMove: function() {
- this._updateScale(this._map, this._container, this.options)
- },
- onAdd: function(a) {
- this._map = a;
- this._container = GeoGlobe.DOM.create("div", "mapboxgl-ctrl mapboxgl-ctrl-scale", a.getContainer());
- this._map.on("move", this._onMove);
- this._onMove();
- return this._container
- },
- onRemove: function() {
- this._container.parentNode.removeChild(this._container);
- this._map.off("move", this._onMove);
- this._map = void 0
- },
- _updateScale: function(a, b, c) {
- var d = c && c.maxWidth || 100,
- e = a._container.clientHeight / 2,
- a = this._getDistance(a.unproject([0, e]), a.unproject([d, e]));
- c && c.unit === "imperial" ? (c = 3.2808 * a, c > 5280 ? this._setScale(b, d, c / 5280, "mi") : this._setScale(b, d, c, "ft")) : this._setScale(b, d, a, "m")
- },
- _setScale: function(a, b, c, d) {
- var e = this._getRoundNum(c),
- c = e / c;
- d === "m" && e >= 1E3 && (e /= 1E3, d = "km");
- a.style.width = b * c + "px";
- a.innerHTML = e + d
- },
- _getDistance: function(a, b) {
- var c = null;
- if (this._map.units ===
- "m") c = b.lng - a.lng;
- else var c = Math.PI / 180,
- d = a.lat * c,
- e = b.lat * c,
- c = 6371E3 * Math.acos(Math.min(Math.sin(d) * Math.sin(e) + Math.cos(d) * Math.cos(e) * Math.cos((b.lng - a.lng) * c), 1));
- return c
- },
- _getRoundNum: function(a) {
- var b = Math.pow(10, ("" + Math.floor(a)).length - 1);
- a /= b;
- return b * (a >= 10 ? 10 : a >= 5 ? 5 : a >= 3 ? 3 : a >= 2 ? 2 : 1)
- },
- CLASS_NAME: "GeoGlobe.Control.Scale"
- });
- GeoGlobe.Control.Geolocate = mapboxgl.GeolocateControl;
- GeoGlobe.Control.MapContextMenu = GeoGlobe.Class4OL({
- menuDiv: null,
- className: null,
- contentHTML: null,
- lngLat: null,
- point: null,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getDefaultPosition: function() {
- return "top-left"
- },
- onAdd: function(a) {
- this._map = a;
- this._onContextMenu = GeoGlobe.Function.bind(this._showContextMenu, this);
- this._map.on("contextmenu", this._onContextMenu);
- this._onMouseDown = GeoGlobe.Function.bind(this.hide, this);
- this._map.on("mousedown", this._onMouseDown);
- return this._container = this._createContainer()
- },
- _createContainer: function() {
- var a = window.document.createElement("div");
- a.className = "mapboxgl-ctrl";
- this.className && a.classList.add(this.className);
- a.style.position = "absolute";
- a.style.background = "white";
- a.style.border = "1px solid #adbfe4";
- a.style.zIndex = 2;
- a.innerHTML = this.contentHTML ? this.contentHTML : "";
- this.menuDiv = a;
- this.menuDiv.onmousedown = GeoGlobe.Function.bind(function(a) {
- (a || event).preventDefault();
- event.stopPropagation && event.stopPropagation()
- }, this);
- this.hide();
- return a
- },
- _showContextMenu: function(a) {
- this.lngLat =
- a.lngLat;
- this.point = a.point;
- this.menuDiv.style.left = a.point.x + "px";
- this.menuDiv.style.top = a.point.y + "px";
- this.show()
- },
- onRemove: function() {
- this._container.parentNode.removeChild(this._container);
- this._map.off("contextmenu", this._onContextMenu);
- this._map.off("mousedown", this._onMouseDown);
- this.contentHTML = this._container = this.menuDiv = null;
- this._map = void 0
- },
- show: function() {
- if (this.menuDiv && this.menuDiv.style.display == "none") this.menuDiv.style.display = ""
- },
- hide: function() {
- if (this.menuDiv && this.menuDiv.style.display !=
- "none") this.menuDiv.style.display = "none"
- },
- setContentHTML: function(a) {
- if (a != null) this.contentHTML = a;
- if (this.menuDiv != null && this.contentHTML != null && this.contentHTML != this.menuDiv.innerHTML) this.menuDiv.innerHTML = this.contentHTML
- },
- addItem: function(a) {
- var b = document.createElement("div");
- b.id = a.id;
- b.style.cssText = "padding-bottom: 2px; line-height: 17px; margin: 0px 2px; padding-left: 6px; width:" + a.width + "px; padding-right: 6px; color: #000; font-size: 12px; cursor: pointer; padding-top: 2px;";
- b.innerHTML =
- "<span>" + a.text + "</span>";
- b.onclick = GeoGlobe.Function.bind(function() {
- a.callback({
- target: a,
- control: this,
- map: this._map,
- lngLat: this.lngLat,
- point: this.point
- });
- this.hide()
- }, this);
- b.onmouseover = function() {
- b.style.color = "#6688cc"
- };
- b.onmouseout = function() {
- b.style.color = "#000"
- };
- this.menuDiv.appendChild(b);
- this.setContentHTML(this.menuDiv.innerHTML)
- },
- addSeparator: function() {
- var a = document.createElement("div");
- a.style.cssText = "border-bottom:#adbfe4 1px solid;margin:0px 6px;font-size:0px;padding:1px";
- this.menuDiv.appendChild(a);
- this.setContentHTML(this.menuDiv.innerHTML)
- },
- mousePos: function(a, b) {
- var c = a.getBoundingClientRect();
- return new GeoGlobe.Point(b.clientX - c.left - a.clientLeft, b.clientY - c.top - a.clientTop)
- },
- CLASS_NAME: "GeoGlobe.View2D.Control.MapContextMenu"
- });
- GeoGlobe.MenuItem = GeoGlobe.Class4OL({
- id: null,
- text: null,
- callback: null,
- width: 100,
- initialize: function(a) {
- this.id = GeoGlobe.Util.createUniqueID(this.CLASS_NAME + "_");
- GeoGlobe.Util.extend(this, a)
- },
- setText: function(a) {
- this.text = a
- },
- CLASS_NAME: "GeoGlobe.MenuItem"
- });
- GeoGlobe.Control.MapCesium = GeoGlobe.Class4OL({
- map: null,
- viewer: null,
- isPitchChanged: !1,
- isHeadingChanged: !1,
- _MAPBOX_MOVE: "mapbox is moving",
- _CESIUM_MOVE: "cesium is moving",
- _isMoving: null,
- _handler: null,
- _currentCesiumHeading: 0,
- _currentCesiumPitch: 0,
- initialize: function(a) {
- this.map = a.map ? a.map : this.map;
- this.viewer = a.viewer ? a.viewer : this.viewer;
- this.isPitchChanged = a.isPitchChanged !== void 0 ? a.isPitchChanged : this.isPitchChanged;
- this.isHeadingChanged = a.isHeadingChanged !== void 0 ? a.isHeadingChanged : this.isHeadingChanged;
- this._isMoving = this._MAPBOX_MOVE;
- this._isSync = !1;
- this._currentCesiumHeading = 0;
- this._currentCesiumPitch = -Cesium.Math.PI_OVER_TWO;
- this._handler = new Cesium.ScreenSpaceEventHandler(this.viewer.canvas);
- this._bindEvent();
- this._updateCesium()
- },
- _bindEvent: function() {
- if (this.map && !this._handler.getInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)) {
- var a = this;
- this.map.on("move", function() {
- a._isSync && a._updateCesium()
- });
- this.map.on("mouseover", function() {
- a._isMoving = a._MAPBOX_MOVE
- });
- this._handler.setInputAction(function() {
- a._isMoving =
- a._CESIUM_MOVE;
- a._currentCesiumHeading = a.viewer.camera.heading;
- a._currentCesiumPitch = a.viewer.camera.pitch
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
- this.viewer.canvas.addEventListener("mouseout", function() {
- a._isMoving = a._MAPBOX_MOVE
- });
- this.viewer.scene.preRender.addEventListener(function() {
- a._isSync && a._updateMapbox()
- })
- }
- },
- setEnabled: function(a) {
- this._isSync = a
- },
- _unbindEvent: function() {
- if (this.map) {
- for (var a = 0; a < this.map._listeners.move.length; a++) this.map._listeners.move[a].name && this.map._listeners.move[a].name ===
- "MAPCESIUM_MOVE_EVENT" && this.map._listeners.move.splice(a, 1);
- for (a = 0; a < this.map._listeners.mouseover.length; a++) this.map._listeners.mouseover[a].name && this.map._listeners.mouseover[a].name === "MAPCESIUM_MOVEOVER_EVENT" && this.map._listeners.mouseover.splice(a, 1);
- for (a = 0; a < this.viewer.scene.preRender._listeners.length; a++) this.viewer.scene.preRender._listeners[a].name === "CESIUM_RENDER_EVENT" && this.viewer.scene.preRender._listeners.splice(a, 1);
- this._handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)
- }
- },
- destroy: function() {
- if (this.map) this._unbindEvent(), this.viewer = this._handler = this.map = null
- },
- _calDistanceFromMapboxToCesium: function() {
- return this.map.transform.cameraToCenterDistance * (78271.51696402031 / Math.pow(2, this.map.getZoom() + 1.2))
- },
- _calHeadingFromMapboxToCesium: function() {
- var a = this.map.getBearing();
- return Cesium.Math.toRadians(a)
- },
- _calPitchFromMapboxToCesium: function() {
- var a = this.map.getPitch();
- return Cesium.Math.toRadians(a - 90)
- },
- _calDestinationFromMapboxToCesium: function() {
- var a = new Cesium.Cartographic(Cesium.Math.toRadians(this.map.getCenter().lng),
- Cesium.Math.toRadians(this.map.getCenter().lat));
- return Cesium.Ellipsoid.WGS84.cartographicToCartesian(a)
- },
- _getCenterPoint: function() {
- var a = this.viewer.canvas,
- a = new Cesium.Cartesian2(a.clientWidth / 2, a.clientHeight / 2);
- return this.viewer.scene.globe.pick(this.viewer.camera.getPickRay(a), this.viewer.scene) || this.viewer.camera.pickEllipsoid(a)
- },
- _updateCesium: function() {
- if (this._isMoving !== this._CESIUM_MOVE) {
- var a = this._calDistanceFromMapboxToCesium(),
- b, c;
- c = this.isHeadingChanged ? this._calHeadingFromMapboxToCesium() :
- this._currentCesiumHeading;
- b = this.isPitchChanged ? this._calPitchFromMapboxToCesium() : this._currentCesiumPitch;
- this.viewer.camera.setView({
- destination: this._calDestinationFromMapboxToCesium(),
- orientation: {
- heading: c,
- pitch: b
- }
- });
- this.viewer.camera.moveBackward(a)
- }
- },
- _updateMapbox: function() {
- if (this.viewer && this._isMoving !== this._MAPBOX_MOVE) {
- var a = Cesium.Ellipsoid.WGS84,
- b = 0,
- c = 0,
- c = this._getCenterPoint();
- if (!c) b = this.viewer.scene.globe, c = this.viewer.camera.positionCartographic.clone(), b = b.getHeight(c), c.height =
- b || 0, c = a.cartographicToCartesian(c);
- var b = Cesium.Cartesian3.distance(c, this.viewer.camera.position) / this.map.transform.cameraToCenterDistance,
- b = Math.log2(78271.51696402031 / b) - 1.2,
- d = a.cartesianToCartographic(c),
- d = [Cesium.Math.toDegrees(d.longitude), Cesium.Math.toDegrees(d.latitude)];
- this.map.setZoom(b);
- this.map.setCenter(d);
- if (c) {
- var b = this.viewer.camera.up,
- d = this.viewer.camera.right,
- e = new Cesium.Cartesian3(-c.y, c.x, 0),
- d = Cesium.Cartesian3.angleBetween(d, e),
- b = Cesium.Cartesian3.cross(c, b, new Cesium.Cartesian3).z <
- 0 ? -d : d,
- b = Cesium.Math.toDegrees(b),
- d = this.viewer.camera.position,
- e = new Cesium.Cartesian3;
- a.geocentricSurfaceNormal(c, e);
- a = new Cesium.Cartesian3;
- Cesium.Cartesian3.subtract(d, c, a);
- Cesium.Cartesian3.normalize(a, a);
- a = Math.acos(Cesium.Cartesian3.dot(e, a));
- c = isNaN(a) ? 0 : a
- } else b = Cesium.Math.toDegrees(this.viewer.camera.heading), c = Cesium.Math.PI_OVER_THREE;
- this.isHeadingChanged && this.map.setBearing(b);
- this.isPitchChanged && this.map.setPitch(Cesium.Math.toDegrees(c))
- }
- },
- CLASS_NAME: "GeoGlobe.View2D.Control.MapCesium"
- });
- GeoGlobe.Control.Fullscreen = mapboxgl.FullscreenControl;
- GeoGlobe.Control.Print = GeoGlobe.Class({
- initialize: function() {
- this._printHandler = GeoGlobe.Function.bind(this.printHandler, this)
- },
- getDefaultPosition: function() {
- return "top-right"
- },
- onAdd: function(a) {
- this._map = a;
- this._container = GeoGlobe.DOM.create("div", "mapboxgl-ctrl mapboxgl-ctrl-group");
- GeoGlobe.DOM.create("button", "mapboxgl-ctrl-icon mapboxgl-ctrl-fullscreen", this._container);
- this._container.addEventListener("click", this._printHandler);
- return this._container
- },
- onRemove: function() {
- this._container.removeEventListener("click",
- this._printHandler)
- },
- printHandler: function() {
- GeoGlobe.Util.download(this._map.getCanvas().toDataURL(), "\u5730\u56fe.png")
- },
- CLASS_NAME: "GeoGlobe.Control.Print"
- });
- GeoGlobe.Control.FeaturesSelect = GeoGlobe.Class({
- map: null,
- feature: null,
- flag: !0,
- idArr: [],
- setting: {
- bbox: 0,
- highLight: !0,
- clearBlank: !0,
- highLightStyle: {
- pointColor: "",
- pointRadius: "",
- pointOpacity: "",
- lineColor: "",
- lineWidth: "",
- lineOpacity: "",
- strokeColor: "",
- strokeWidth: "",
- strokeOpacity: "",
- fillColor: "",
- fillOpacity: ""
- }
- },
- callback: {
- onClick: null
- },
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a);
- if (!this.setting.bbox) this.setting.bbox = 0;
- this._bindAll()
- },
- _bindAll: function() {
- var a = this.map,
- b = this;
- a.on("click", function(c) {
- b.idArr.length ||
- a.getStyle().layers.forEach(function(a) {
- b.idArr.push(a.id)
- });
- if (b.flag) {
- var d = b.setting.bbox,
- e = c.point;
- d && (e = [
- [c.point.x - d, c.point.y - d],
- [c.point.x + d, c.point.y + d]
- ]);
- c = a.queryRenderedFeatures(e, {
- layers: b.idArr
- });
- b.setting && b.setting.highLight && c.length ? (b._highLightGeometry(c[0]), b.feature = c[0]) : b.setting.clearBlank && b._removeHighLightGeometry();
- if (b.callback.onClick && typeof b.callback.onClick === "function") b.callback.onClick(c)
- }
- })
- },
- _highLightGeometry: function(a) {
- var b = this.map,
- c = a.geometry,
- d = a.properties,
- e = c.type,
- c = {
- type: "geojson",
- data: {
- type: "FeatureCollection",
- features: [{
- type: "Feature",
- properties: d,
- geometry: c
- }]
- }
- },
- f = "GeoGlobe_Features_Selected_High_Light_" + e,
- g = b.getSource(f),
- h;
- if (e == "Point") this._removeHighLightGeometry("LineString"), this._removeHighLightGeometry("Polygon"), e = {
- id: f,
- type: "circle",
- source: c,
- paint: {
- "circle-color": this.setting.highLightStyle.pointColor || "#D20C0C",
- "circle-opacity": this.setting.highLightStyle.pointOpacity || 1,
- "circle-radius": this.setting.highLightStyle.pointRadius || 5
- }
- };
- else if (e ==
- "LineString") this._removeHighLightGeometry("Point"), this._removeHighLightGeometry("Polygon"), e = {
- id: f,
- type: "line",
- source: c,
- paint: {
- "line-color": this.setting.highLightStyle.lineColor || "#D20C0C",
- "line-opacity": this.setting.highLightStyle.lineOpacity || 1,
- "line-width": this.setting.highLightStyle.lineWidth || 3
- }
- };
- else if (e == "Polygon") {
- if (this._removeHighLightGeometry("Point"), this._removeHighLightGeometry("LineString"), e = {
- id: f,
- type: "fill",
- source: c,
- paint: {
- "fill-color": this.setting.highLightStyle.fillColor ||
- "#D20C0C",
- "fill-opacity": this.setting.highLightStyle.fillOpacity || 0.5
- }
- }, this.setting.highLightStyle.strokeColor || this.setting.highLightStyle.strokeColor) h = {
- id: f + "2",
- type: "line",
- source: f,
- paint: {
- "line-color": this.setting.highLightStyle.strokeColor || "#D20C0C",
- "line-opacity": this.setting.highLightStyle.strokeOpacity || 1,
- "line-width": this.setting.highLightStyle.strokeWidth || 3
- }
- }
- } else throw Error("\u53ea\u652f\u6301Point,LineString,Polygon,\u4e09\u79cd\u7c7b\u578b\u7684\u70b9\u51fb\u9ad8\u4eae");
- g ? g.setData(c.data) :
- (b.addLayer(e), h && b.addLayer(h));
- h = ["any"];
- if (d) {
- for (var j in d) j && h.push(["!=", ["get", j], d[j]]);
- h.length > 1 && b.setFilter(a.layer.id, h)
- }
- },
- _removeHighLightGeometry: function(a) {
- var b = this.map;
- a ? (a = "GeoGlobe_Features_Selected_High_Light_" + a, b.getLayer(a) && (b.removeLayer(a), b.getLayer(a + "2") && b.removeLayer(a + "2"), b.removeSource(a), b.setFilter(this.feature.layer.id, null))) : (this._removeHighLightGeometry("Point"), this._removeHighLightGeometry("LineString"), this._removeHighLightGeometry("Polygon"))
- },
- enable: function() {
- this.flag = !0
- },
- disable: function() {
- this.flag = !1
- },
- CLASS_NAME: "GeoGlobe.Control.FeaturesSelect"
- });
- GeoGlobe.Control.GeoOverview = GeoGlobe.Class({
- getDefaultPosition: function() {
- return "bottom-right"
- },
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- onAdd: function(a) {
- this._container = GeoGlobe.DOM.create("div", "mapboxgl-ctrl mapboxgl-ctrl-group");
- this.map = a;
- var b = this,
- c = [],
- c = b.layers && b.layers.length > 0 ? b.layers : [new GeoGlobe.TDTLayer("vec_c"), new GeoGlobe.TDTLayer("cva_c")];
- document.getElementById(b.map._container.id).insertAdjacentHTML("beforeend", "<div class = 'geoOverview'><div id='geoOverviewMap'></div><button type='button' class='overviewMapTarget'><span>\u00bb</span></button></div>");
- var d = new GeoGlobe.Map({
- mapCRS: b.map._mapCRS,
- container: b.el || "geoOverviewMap",
- zoom: b.map.getZoom() - 5 > 0 ? b.map.getZoom() - 5 : 0,
- center: b.map.getCenter(),
- interactive: !1
- });
- d.on("load", function() {
- for (var e = 0; e < c.length; e++) d.addLayer(c[e]);
- b._toGeoJson();
- e = document.createElement("div");
- e.id = "OverviewMapMarker";
- var f = (new mapboxgl.Marker(e, {
- draggable: !0
- })).setLngLat(a.getCenter()).addTo(d);
- f.on("dragend", function() {
- var a = f.getLngLat();
- b.map.setCenter(a)
- });
- b.map.on("move", function() {
- var c = b.map.getCenter(),
- e = b.map.getZoom() - 5 > 0 ? a.getZoom() - 5 : 0;
- b.map.getBearing();
- b.map.getPitch();
- d.jumpTo({
- center: c,
- zoom: e
- });
- f.setLngLat(c);
- b._toGeoJson()
- })
- });
- b.geoOverviewMap = d;
- b._bindEvent();
- return this._container
- },
- _bindEvent: function() {
- document.getElementsByClassName("overviewMapTarget")[0].onclick = function() {
- var a = document.getElementById("geoOverviewMap"),
- b = document.querySelectorAll(".overviewMapTarget span")[0];
- a.style.display == "none" ? (a.style.display = "block", b.innerHTML = "\u00bb") : (a.style.display = "none", b.innerHTML =
- "\u00ab")
- }
- },
- _toGeoJson: function() {
- var a = this.map.getBounds(),
- b = [];
- b.push([a._ne.lng, a._ne.lat]);
- b.push([a._ne.lng, a._sw.lat]);
- b.push([a._sw.lng, a._sw.lat]);
- b.push([a._sw.lng, a._ne.lat]);
- b.push([a._ne.lng, a._ne.lat]);
- a = (new GeoGlobe.Format.GeoJSONUtil).line(b);
- b = (new GeoGlobe.Format.GeoJSONUtil).polygon([b]);
- this._addOverLayer([a, b])
- },
- _addOverLayer: function(a) {
- this._removeOverLayer();
- this.geoOverviewMap.addSource("geoOverviewMap-polygon-source", a[0]);
- this.geoOverviewMap.addLayer({
- id: "geoOverviewMap-polygon-layer",
- type: "fill",
- source: "geoOverviewMap-polygon-source",
- paint: {
- "fill-color": "#627BC1",
- "fill-opacity": 0.5
- }
- });
- this.geoOverviewMap.addSource("geoOverviewMap-line-source", a[1]);
- this.geoOverviewMap.addLayer({
- id: "geoOverviewMap-line-layer",
- type: "line",
- source: "geoOverviewMap-line-source",
- paint: {
- "line-color": "#2e34c5",
- "line-width": 2,
- "line-dasharray": [3, 2],
- "line-opacity": 0.8
- }
- })
- },
- _removeOverLayer: function() {
- this.geoOverviewMap.getSource("geoOverviewMap-polygon-source") && this.geoOverviewMap.removeLayer("geoOverviewMap-polygon-layer") &&
- this.geoOverviewMap.removeSource("geoOverviewMap-polygon-source");
- this.geoOverviewMap.getSource("geoOverviewMap-line-source") && this.geoOverviewMap.removeLayer("geoOverviewMap-line-layer") && this.geoOverviewMap.removeSource("geoOverviewMap-line-source")
- },
- onRemove: function() {
- this.geoOverviewMap.remove();
- var a = document.getElementsByClassName("geoOverview")[0];
- a && a.parentNode.removeChild(a)
- },
- CLASS_NAME: "GeoGlobe.Control.GeoOverview"
- });
- if (window.MapboxDraw && MapboxDraw) {
- var doubleClickZoom = {
- enable: function(a) {
- setTimeout(function() {
- a.map && a.map.doubleClickZoom && a._ctx && a._ctx.store && a._ctx.store.getInitialConfigValue && a._ctx.store.getInitialConfigValue("doubleClickZoom") && a.map.doubleClickZoom.enable()
- }, 0)
- },
- disable: function(a) {
- setTimeout(function() {
- a.map && a.map.doubleClickZoom && a.map.doubleClickZoom.disable()
- }, 0)
- }
- };
- MapboxDraw.modes.draw_square = {
- onSetup: function() {
- var a = this.newFeature({
- type: "Feature",
- properties: {},
- geometry: {
- type: "Polygon",
- coordinates: [
- []
- ]
- }
- });
- this.addFeature(a);
- this.clearSelectedFeatures();
- doubleClickZoom.disable(this);
- this.updateUIClasses({
- mouse: "add"
- });
- this.setActionableState({
- trash: !0
- });
- return {
- square: a
- }
- },
- onTap: function(a, b) {
- if (a.startPoint) this.onMouseMove(a, b);
- this.onClick(a, b)
- },
- onClick: function(a, b) {
- a.startPoint && a.startPoint[0] !== b.lngLat.lng && a.startPoint[1] !== b.lngLat.lat && (this.updateUIClasses({
- mouse: "pointer"
- }), this.changeMode("simple_select", {
- featuresId: a.square.id
- }));
- a.startPoint = [b.lngLat.lng, b.lngLat.lat]
- },
- onMouseMove: function(a, b) {
- if (a.startPoint) {
- var c = b.lngLat.lng - a.startPoint[0],
- d = b.lngLat.lat - a.startPoint[1],
- e = Math.max(Math.abs(c), Math.abs(d)),
- c = a.startPoint[0] + e * (c > 0 ? 1 : -1),
- d = a.startPoint[1] + e * (d > 0 ? 1 : -1);
- a.square.updateCoordinate("0.0", a.startPoint[0], a.startPoint[1]);
- a.square.updateCoordinate("0.1", c, a.startPoint[1]);
- a.square.updateCoordinate("0.2", c, d);
- a.square.updateCoordinate("0.3", a.startPoint[0], d);
- a.square.updateCoordinate("0.4", a.startPoint[0], a.startPoint[1])
- }
- },
- onKeyUp: function(a, b) {
- if (b.keyCode ===
- 27) return this.changeMode("simple_select")
- },
- onStop: function(a) {
- doubleClickZoom.enable(this);
- this.updateUIClasses({
- mouse: "none"
- });
- this.activateUIButton();
- this.getFeature(a.square.id) !== void 0 && (a.square.removeCoordinate("0.4"), a.square.isValid() ? this.map.fire("draw.create", {
- features: [a.square.toGeoJSON()]
- }) : (this.deleteFeature([a.square.id], {
- silent: !0
- }), this.changeMode("simple_select", {}, {
- silent: !0
- })))
- },
- toDisplayFeatures: function(a, b, c) {
- var d = b.properties.id === a.square.id;
- b.properties.active = d ? "true" :
- "false";
- if (!d) return c(b);
- if (a.startPoint) return c(b)
- },
- onTrash: function(a) {
- this.deleteFeature([a.square.id], {
- silent: !0
- });
- this.changeMode("simple_select")
- }
- };
- var CircleMode = {},
- origon, snapAngle, angle, sides, destination, id;
- CircleMode.onSetup = function(a) {
- destination = {};
- origon = null;
- sides = a.sides || 40;
- sides < 40 && (sides = 40);
- a = this.newFeature({
- type: "Feature",
- geometry: {
- type: "Polygon",
- coordinates: [
- []
- ]
- },
- properties: {}
- });
- this.addFeature(a);
- this.clearSelectedFeatures();
- this.updateUIClasses({
- mouse: "add"
- });
- this.activateUIButton("polygon");
- this.setActionableState({
- trash: !0
- });
- return {
- polygon: a,
- id: a,
- currentVertexPosition: 0
- }
- };
- CircleMode.onClick = function(a, b) {
- origon = {
- x: b.lngLat.lng,
- y: b.lngLat.lat
- };
- if (a.currentVertexPosition > 0 && destination && destination.x == origon.x && destination.y == origon.y) return this.changeMode("simple_select", {
- featureIds: [a.polygon.id]
- });
- angle = Math.PI * (1 / sides - 0.5);
- snapAngle && (angle += snapAngle * (Math.PI / 180));
- var c = getcircle(origon, 0.0439453125, sides, snapAngle);
- this.updateUIClasses({
- mouse: "add"
- });
- this.deleteFeature([a.id], {
- silent: !0
- });
- a.currentVertexPosition++;
- a.polygon.coordinates = [c];
- this.addFeature(a.polygon)
- };
- CircleMode.onMouseMove = function(a, b) {
- if (origon) {
- destination = {
- x: b.lngLat.lng,
- y: b.lngLat.lat
- };
- calculateAngle(destination);
- var c = distanceTo(destination),
- c = getcircle(origon, c, sides, snapAngle);
- this.deleteFeature([id], {
- silent: !0
- });
- a.polygon.coordinates = [c];
- this.addFeature(a.polygon)
- }
- };
- CircleMode.onKeyUp = function(a, b) {
- if (b.keyCode === 27) return this.changeMode("simple_select")
- };
- CircleMode.toDisplayFeatures = function(a,
- b, c) {
- c(b)
- };
- CircleMode.onTrash = function(a) {
- this.deleteFeature([a.polygon.id], {
- silent: !0
- });
- this.changeMode("simple_select")
- };
- var calculateAngle = function(a, b) {
- var c = Math.atan2(a.y - origon.y, a.x - origon.x);
- if (snapAngle && this.snapToggle && !b[this.snapToggle]) {
- var d = Math.PI / 180 * snapAngle;
- angle = Math.round(c / d) * d
- } else angle = c
- },
- distanceTo = function(a, b) {
- var c = !(b && b.edge === !1) && b && b.details,
- d, e, f, g, h;
- e = origon.x;
- f = origon.y;
- g = a.x;
- h = a.y;
- d = Math.sqrt(Math.pow(e - g, 2) + Math.pow(f - h, 2));
- return !c ? d : {
- x0: e,
- y0: f,
- x1: g,
- y1: h,
- distance: d
- }
- },
- getcircle = function(a, b, c, d) {
- var e = Math.PI * (1 / c - 0.5);
- d && (e += d / 180 * Math.PI);
- for (var f, g = [], h = 0; h < c; ++h) f = e + h * 2 * Math.PI / c, d = a.x + b * Math.cos(f), f = a.y + b * Math.sin(f), g.push([d, f]);
- return g
- };
- MapboxDraw.modes.draw_circle = CircleMode;
- MapboxDraw.modes.draw_ellipse = {
- onSetup: function(a) {
- this.eccentricity = a.eccentricity >= 0 && a.eccentricity < 1 ? a.eccentricity : 0.8;
- this.divisions = a.divisions || 60;
- a = this.newFeature({
- type: "Feature",
- properties: {},
- geometry: {
- type: "Polygon",
- coordinates: [
- []
- ]
- }
- });
- this.addFeature(a);
- this.clearSelectedFeatures();
- doubleClickZoom.disable(this);
- this.updateUIClasses({
- mouse: "add"
- });
- this.setActionableState({
- trash: !0
- });
- return {
- ellipse: a
- }
- },
- onTap: function(a, b) {
- if (a.center) this.onMouseMove(a, b);
- this.onClick(a, b)
- },
- onClick: function(a, b) {
- a.center && a.center[0] !== b.lngLat.lng && a.center[1] !== b.lngLat.lat && (this.updateUIClasses({
- mouse: "pointer"
- }), this.changeMode("simple_select", {
- featuresId: a.ellipse.id
- }));
- a.center = [b.lngLat.lng, b.lngLat.lat]
- },
- onMouseMove: function(a, b) {
- if (a.center)
- for (var c = Math.sqrt(Math.pow(b.lngLat.lng -
- a.center[0], 2) + Math.pow(b.lngLat.lat - a.center[1], 2)), d = c * Math.sqrt(1 - Math.pow(this.eccentricity, 2)), e = Math.atan2(b.lngLat.lat - a.center[1], b.lngLat.lng - a.center[0]), f = Math.PI * 2, g = 0, h = this.divisions; g <= h; g++) {
- var j = g / h * f,
- l = a.center[0] + c * Math.cos(j),
- m = a.center[1] + d * Math.sin(j);
- if (e !== 0) {
- var j = Math.cos(e),
- n = Math.sin(e),
- p = l - a.center[0];
- m -= a.center[1];
- l = p * j - m * n + a.center[0];
- m = p * n + m * j + a.center[1]
- }
- a.ellipse.updateCoordinate("0." + g, l, m)
- }
- },
- onKeyUp: function(a, b) {
- if (b.keyCode === 27) return this.changeMode("simple_select")
- },
- onStop: function(a) {
- doubleClickZoom.enable(this);
- this.updateUIClasses({
- mouse: "none"
- });
- this.activateUIButton();
- this.getFeature(a.ellipse.id) !== void 0 && (a.ellipse.isValid() ? this.map.fire("draw.create", {
- features: [a.ellipse.toGeoJSON()]
- }) : (this.deleteFeature([a.ellipse.id], {
- silent: !0
- }), this.changeMode("simple_select", {}, {
- silent: !0
- })))
- },
- toDisplayFeatures: function(a, b, c) {
- var d = b.properties.id === a.ellipse.id;
- b.properties.active = d ? "true" : "false";
- if (!d) return c(b);
- if (a.center) return c(b)
- },
- onTrash: function(a) {
- this.deleteFeature([a.ellipse.id], {
- silent: !0
- });
- this.changeMode("simple_select")
- }
- };
- GeoGlobe.Control.Draw = MapboxDraw
- } else GeoGlobe.Control.Draw = GeoGlobe.Class4OL({
- initialize: function() {
- throw Error("\u8bf7\u5148\u5f15\u5165mapbox-gl-draw\u63d2\u4ef6\uff01");
- },
- CLASS_NAME: "GeoGlobe.Control.Draw"
- });
- GeoGlobe.Control.Measure = window.turf && turf && window.MapboxDraw && MapboxDraw ? GeoGlobe.Class4OL({
- hasTools: !1,
- drawOptions: {
- displayControlsDefault: !1
- },
- initialize: function(a) {
- this.hasTools = a.hasTools;
- if (a.drawOptions && JSON.stringify(a.drawOptions) != "{}") this.drawOptions = a.drawOptions;
- this.areaPopupWindow = this.linePopupWindow = void 0;
- this.isMeasureType = "";
- this.measureMethod = this.measureMethod.bind(this)
- },
- onAdd: function(a) {
- this.map = a;
- this.mapMeasureDrawTool = new GeoGlobe.Control.Draw(this.drawOptions);
- this.map.addControl(this.mapMeasureDrawTool,
- "top-left");
- console.log("mapMeasureDrawTool loaded");
- if (!this.hasTools) return this.container = document.createElement("div");
- this.initMeasureToolControl();
- this.lineButton.addEventListener("click", this.measureFunc("line"));
- this.areaButton.addEventListener("click", this.measureFunc("polygon"));
- return this.container
- },
- measureFunc: function(a) {
- a == "line" ? (this.clearMeasure(), this.isMeasureType = "line", this.map.on("draw.create", this.measureMethod), this.mapMeasureDrawTool.changeMode("draw_line_string")) : (this.clearMeasure(),
- this.isMeasureType = "polygon", this.map.on("draw.create", this.measureMethod), this.mapMeasureDrawTool.changeMode("draw_polygon"))
- },
- clearMeasure: function() {
- this.isMeasureType = "";
- this.mapMeasureDrawTool.deleteAll();
- if (this.linePopupWindow) this.linePopupWindow.remove(), this.linePopupWindow = void 0;
- if (this.areaPopupWindow) this.areaPopupWindow.remove(), this.areaPopupWindow = void 0
- },
- measureMethod: function() {
- var a = this.mapMeasureDrawTool.getAll();
- if (a.features.length > 0)
- if (this.isMeasureType === "line") {
- var b = a.features[0].geometry.coordinates,
- b = b[b.length - 1],
- a = Math.round(turf.lineDistance(a) * 1E3) / 1E3;
- this.linePopupWindow = new mapboxgl.Popup({
- closeButton: !1,
- closeOnClick: !1
- });
- this.linePopupWindow.setLngLat(b).setHTML("<div>\u8ddd\u79bb\uff1a" + a + " (km)</div>").addTo(this.map)
- } else if (this.isMeasureType === "polygon") b = turf.centroid(a).geometry.coordinates, a = Math.round(turf.area(a) / 1E6 * 1E3) / 1E3, this.areaPopupWindow = new mapboxgl.Popup({
- closeButton: !1,
- closeOnClick: !1
- }), this.areaPopupWindow.setLngLat(b).setHTML("<div>\u9762\u79ef\uff1a" + a + " (km\u00b2)</div>").addTo(this.map);
- this.map.off("draw.create", this.measureMethod)
- },
- initMeasureToolControl: function() {
- this.container = document.createElement("div");
- this.container.classList.add("mapboxgl-ctrl");
- this.container.classList.add("mapboxgl-ctrl-group");
- this.lineButton = document.createElement("button");
- this.lineButton.classList.add("mapboxgl-ctrl-measure-line-tool");
- this.lineButton.title = "\u6d4b\u8ddd";
- this.lineButton.innerHTML = "\u6d4b\u8ddd";
- this.container.appendChild(this.lineButton);
- this.areaButton = document.createElement("button");
- this.areaButton.classList.add("mapboxgl-ctrl-measure-area-tool");
- this.areaButton.title = "\u6d4b\u9762";
- this.areaButton.innerHTML = "\u6d4b\u9762";
- this.container.appendChild(this.areaButton)
- },
- onRemove: function() {
- this.container.parentNode.removeChild(this.container);
- this.map = void 0
- },
- CLASS_NAME: "GeoGlobe.Control.Measure"
- }) : GeoGlobe.Class4OL({
- initialize: function() {
- if (!window.MapboxDraw) throw Error("\u8bf7\u5148\u5f15\u5165mapbox-gl-draw\u63d2\u4ef6\uff01");
- if (!window.turf) throw Error("\u8bf7\u5148\u5f15\u5165turf\u63d2\u4ef6\uff01");
- },
- CLASS_NAME: "GeoGlobe.Control.Measure"
- });
- GeoGlobe.Event = mapboxgl.Evented;
- GeoGlobe.Event.MapMouseEvent = mapboxgl.Event;
- GeoGlobe.Event.MapTouchEvent = mapboxgl.Event;
- GeoGlobe.Event.mapDataEvent = mapboxgl.Event;
- GeoGlobe.Event.mapBoxZoomEvent = mapboxgl.Event;
- GeoGlobe.Handler = GeoGlobe.Class({
- initialize: function() {},
- CLASS_NAME: "GeoGlobe.Handler"
- });
- GeoGlobe.BoxHandler3D = GeoGlobe.Class4OL({
- initialize: function(a) {
- this._map = a;
- this._el = a.getCanvasContainer();
- this._container = a.getContainer();
- this._onMouseDown = this._onMouseDown.bind(this);
- this._onMouseMove = this._onMouseMove.bind(this);
- this._onMouseUp = this._onMouseUp.bind(this);
- this._onKeyDown = this._onKeyDown.bind(this)
- },
- isEnabled: function() {
- return !!this._enabled
- },
- isActive: function() {
- return !!this._active
- },
- enable: function() {
- if (!this.isEnabled()) this._el.addEventListener("mousedown", this._onMouseDown, !1), this._enabled = !0
- },
- disable: function() {
- if (this.isEnabled()) this._el.removeEventListener("mousedown", this._onMouseDown), this._enabled = !1
- },
- _onMouseDown: function(a) {
- if (a.button === 0) window.document.addEventListener("mousemove", this._onMouseMove, !1), window.document.addEventListener("keydown", this._onKeyDown, !1), window.document.addEventListener("mouseup", this._onMouseUp, !1), GeoGlobe.DOM.disableDrag(), this._startPos = GeoGlobe.DOM.mousePos(this._el, a), this._active = !0
- },
- _onMouseMove: function(a) {
- var b = this._startPos,
- c = GeoGlobe.DOM.mousePos(this._el, a);
- if (!this._box) this._box = GeoGlobe.DOM.create("canvas", "geoglobe-boxhandler3d", this._container), this._box.style.position = "absolute", this._box.width = this._map.transform.width, this._box.height = this._map.transform.height, this._boxContext = this._box.getContext("2d"), this._boxContext.lineWidth = 2, this._boxContext.globalAlpha = 0.7, this._boxContext.fillStyle = "#a09e9e", this._boxContext.strokeStyle = "#b90909", this._boxContext.setLineDash([2, 2]), this._container.classList.add("mapboxgl-crosshair"),
- this._fireEvent("boxstart", a);
- var d = this._map.unproject(b),
- e = this._map.unproject(c),
- a = this._map.project([d.lng, e.lat]),
- d = this._map.project([e.lng, d.lat]);
- this._boxContext.clearRect(0, 0, this._box.width, this._box.height);
- this._boxContext.beginPath();
- this._boxContext.moveTo(b.x, b.y);
- this._boxContext.lineTo(a.x, a.y);
- this._boxContext.lineTo(c.x, c.y);
- this._boxContext.lineTo(d.x, d.y);
- this._boxContext.closePath();
- this._boxContext.fill();
- this._boxContext.stroke()
- },
- _onMouseUp: function(a) {
- if (a.button === 0) {
- var b =
- this._startPos,
- c = GeoGlobe.DOM.mousePos(this._el, a),
- d = (new GeoGlobe.LngLatBounds).extend(this._map.unproject(b)).extend(this._map.unproject(c)),
- e = [GeoGlobe.Point.convert(b), GeoGlobe.Point.convert(c)],
- e = [e[0], new GeoGlobe.Point(e[1].x, e[0].y), e[1], new GeoGlobe.Point(e[0].x, e[1].y)].map(function(a) {
- return this._map.unproject(a)
- }.bind(this));
- this._finish();
- b.x === c.x && b.y === c.y || this._map.fire("boxend", {
- originalEvent: a,
- boxBounds: d,
- boxLnglats: e,
- startPos: b,
- endPos: c
- })
- }
- },
- _onKeyDown: function(a) {
- a.keyCode ===
- 27 && (this._finish(), this._fireEvent("boxcancel", a))
- },
- _finish: function() {
- this._active = !1;
- window.document.removeEventListener("mousemove", this._onMouseMove, !1);
- window.document.removeEventListener("keydown", this._onKeyDown, !1);
- window.document.removeEventListener("mouseup", this._onMouseUp, !1);
- this._container.classList.remove("mapboxgl-crosshair");
- if (this._box) this._box.parentNode.removeChild(this._box), this._box = null;
- GeoGlobe.DOM.enableDrag()
- },
- _fireEvent: function(a, b) {
- return this._map.fire(a, {
- originalEvent: b
- })
- },
- CLASS_NAME: "GeoGlobe.BoxHandler3D"
- });
- GeoGlobe.Handler.BoxZoomHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- initialize: function(a) {
- return this.handler = a.boxZoom
- },
- CLASS_NAME: "GeoGlobe.Handler.BoxZoomHandler"
- });
- GeoGlobe.Handler.DoubleClickZoomHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- initialize: function(a) {
- return this.handler = a.doubleClickZoom
- },
- CLASS_NAME: "GeoGlobe.Handler.DoubleClickZoomHandler"
- });
- GeoGlobe.Handler.DragPanHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- initialize: function(a) {
- return this.handler = a.dragPan
- },
- CLASS_NAME: "GeoGlobe.Handler.DragPanHandler"
- });
- GeoGlobe.Handler.DragRotateHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- map: null,
- initialize: function(a) {
- return this.handler = a.dragRotate
- },
- isActivate: function() {
- return this.handler.isActive()
- },
- isEnabled: function() {
- return this.handler.isEnabled()
- },
- enable: function() {
- this.handler.enable()
- },
- disable: function() {
- this.handler.disable()
- },
- CLASS_NAME: "GeoGlobe.Handler.DragRotateHandler"
- });
- GeoGlobe.Handler.KeyboardHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- initialize: function(a) {
- return this.handler = a.keyboard
- },
- CLASS_NAME: "GeoGlobe.Handler.KeyboardHandler"
- });
- GeoGlobe.Handler.ScrollZoomHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- initialize: function(a) {
- return this.handler = a.scrollZoom
- },
- CLASS_NAME: "GeoGlobe.Handler.ScrollZoomHandler"
- });
- GeoGlobe.Handler.TouchZoomRotateHandler = GeoGlobe.Class4OL(GeoGlobe.Handler, {
- initialize: function(a) {
- return this.handler = a.touchZoomRotate
- },
- CLASS_NAME: "GeoGlobe.Handler.TouchZoomRotateHandler"
- });
- GeoGlobe.DynamicTrace = GeoGlobe.Class({
- frame_num: 0,
- origons: [0, 0],
- destinations: [0, 0],
- map: null,
- id: null,
- initialize: function(a) {
- this.options = a;
- frame_num = a.frame_num;
- map = a.map;
- id = a.id;
- origins = a.origons;
- destinations = a.destinations;
- num = destinations.length;
- pointid = id + "point";
- routeid1 = id + "route1";
- routeid2 = id + "route2";
- point = {};
- route = {};
- route1 = {};
- route2 = {};
- counter = 0;
- request = null
- },
- autotrace: function(a, b) {
- frame_num || (frame_num = 1E3);
- a && (frame_num = a);
- route = {
- type: "FeatureCollection",
- features: [{
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: [origins[0], destinations[0]]
- }
- }]
- };
- for (var c = 1; c < num; c++) {
- var d = {
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: [origins[c], destinations[c]]
- }
- };
- route.features.push(d)
- }
- point = {
- type: "FeatureCollection",
- features: [{
- type: "Feature",
- geometry: {
- type: "Point",
- coordinates: origins[0]
- }
- }]
- };
- for (c = 1; c < num; c++) d = {
- type: "Feature",
- geometry: {
- type: "Point",
- coordinates: origins[c]
- }
- }, point.features.push(d);
- d = [];
- d.push(turf.lineDistance(route.features[0], "kilometers"));
- for (c = 1; c < num; c++) d.push(turf.lineDistance(route.features[c],
- "kilometers"));
- for (var e = 0; e < num; e++) {
- for (var f = [], c = 0; c < d[e]; c++) {
- var g = turf.along(route.features[e], c / frame_num * d[e], "kilometers");
- f.push(g.geometry.coordinates)
- }
- route.features[e].geometry.coordinates = f
- }
- route1 = {
- type: "FeatureCollection",
- features: []
- };
- for (e = 0; e < num; e++) d = {
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: [origins[e], origins[e]]
- }
- }, route1.features.push(d);
- route2 = {
- type: "FeatureCollection",
- features: []
- };
- for (e = 0; e < num; e++) d = {
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: [origins[e],
- origins[e]
- ]
- }
- }, route2.features.push(d);
- counter = 0;
- map.addSource(routeid1, {
- type: "geojson",
- data: route1
- });
- map.addSource(routeid2, {
- type: "geojson",
- data: route2
- });
- map.addSource(pointid, {
- type: "geojson",
- data: point
- });
- b ? (map.addLayer({
- id: routeid1,
- source: routeid1,
- type: b.line.type,
- paint: b.line.paint
- }), map.addLayer({
- id: routeid2,
- source: routeid2,
- type: b.line.type,
- paint: b.line.paint
- }), map.addLayer({
- id: pointid,
- source: pointid,
- type: b.point.type,
- paint: b.point.paint
- })) : (map.addLayer({
- id: routeid1,
- source: routeid1,
- type: "line",
- paint: {
- "line-width": {
- base: 2,
- stops: [
- [12, 2],
- [22, 180]
- ]
- },
- "line-color": "red"
- }
- }), map.addLayer({
- id: routeid2,
- source: routeid2,
- type: "line",
- paint: {
- "line-width": {
- base: 2,
- stops: [
- [12, 2],
- [22, 180]
- ]
- },
- "line-color": "red"
- }
- }), map.addLayer({
- id: pointid,
- source: pointid,
- type: "circle",
- paint: {
- "circle-radius": {
- base: 2,
- stops: [
- [12, 2],
- [22, 180]
- ]
- },
- "circle-color": "yellow",
- "circle-opacity": 1
- }
- }))
- },
- run: function() {
- for (var a = 0; a < num; a++) point.features[a].geometry.coordinates = route.features[a].geometry.coordinates[counter], route1.features[a].geometry.coordinates.push(route.features[a].geometry.coordinates[counter]),
- route2.features[a].geometry.coordinates.push(route.features[a].geometry.coordinates[counter]), route1.features[a].geometry.coordinates.length > 11 && route1.features[a].geometry.coordinates.shift();
- map.getSource(pointid).setData(point);
- map.getSource(routeid1).setData(route1);
- counter % 10 == 0 && map.getSource(routeid2).setData(route2);
- point.features[0].geometry.coordinates[0] !== destinations[0][0] && (request = requestAnimationFrame(run));
- counter += 1
- },
- reset: function() {
- for (var a = 0; a < num; a++) point.features[a].geometry.coordinates =
- origins[a], route1.features[a].geometry.coordinates = [], route2.features[a].geometry.coordinates = [], route1.features[a].geometry.coordinates.push(origins[a]), route2.features[a].geometry.coordinates.push(origins[a]);
- map.getSource(pointid).setData(point);
- map.getSource(routeid1).setData(route1);
- map.getSource(routeid2).setData(route2);
- counter = 0;
- cancelAnimationFrame(request)
- },
- replay: function() {
- for (var a = 0; a < num; a++) point.features[a].geometry.coordinates = origins[a], route1.features[a].geometry.coordinates = [],
- route2.features[a].geometry.coordinates = [], route1.features[a].geometry.coordinates.push(origins[a]), route2.features[a].geometry.coordinates.push(origins[a]);
- map.getSource(pointid).setData(point);
- map.getSource(routeid1).setData(route1);
- map.getSource(routeid2).setData(route2);
- counter = 0;
- run(counter)
- },
- pause: function() {
- cancelAnimationFrame(request)
- },
- removetrace: function() {
- map.removeLayer(pointid);
- map.removeLayer(routeid1);
- map.removeLayer(routeid2);
- map.removeSource(pointid);
- map.removeSource(routeid1);
- map.removeSource(routeid2)
- },
- CLASS_NAME: "GeoGlobe.DynamicTrace"
- });
- GeoGlobe.DynamicFeature = GeoGlobe.Class({
- data: null,
- map: null,
- style: null,
- isdraw: null,
- id: null,
- property: null,
- initialize: function(a) {
- this.options = a;
- map = a.map;
- feat_data = a.data;
- speed = 500;
- i = 0;
- sourceid = null;
- style = a.style;
- property = style.property;
- val_property = feat_data.features[0].properties[property];
- sourceid = a.id;
- isdraw = a.isdraw;
- color_num = [];
- size_num = [];
- isdraw && (this.setdata(), this.setstyle())
- },
- setdata: function(a) {
- a ? (map.removeSource(sourceid), map.addSource(sourceid, {
- type: "geojson",
- data: a
- })) : map.addSource(sourceid, {
- type: "geojson",
- data: feat_data
- })
- },
- setstyle: function() {
- var a = 0;
- if (style.color) {
- color = style.color;
- for (var b = color[val_property], c = 0; c < b.length; c++) color_num.push([c, b[c]]);
- opacity = style.opacity;
- if (style.size) {
- size = style.size;
- b = size[val_property];
- for (c = 0; c < b.length; c++) size_num.push([c, b[c]])
- } else size_num = [
- [0, 7],
- [1, 5],
- [2, 3]
- ]
- } else opacity = 0.3, color_num = [
- [0, "red"],
- [1, "#FFC0CB"],
- [2, "#FFB6C1"]
- ], size_num = [
- [0, 7],
- [1, 5],
- [2, 3]
- ];
- style.type === "point" ? setInterval(function() {
- i % speed === 0 && (map.addLayer({
- id: sourceid,
- type: "circle",
- source: sourceid,
- paint: {
- "circle-color": {
- stops: [color_num[a]]
- },
- "circle-opacity": opacity,
- "circle-radius": {
- stops: [size_num[a]]
- }
- }
- }), a++, a > 2 && (a = 0));
- i += 5
- }, 1) : style.type === "line" ? setInterval(function() {
- i % speed === 0 && (map.addLayer({
- id: sourceid,
- type: "line",
- source: sourceid,
- paint: {
- "line-color": {
- stops: [color_num[a]]
- },
- "line-opacity": opacity,
- "line-width": {
- stops: [size_num[a]]
- }
- }
- }), a++, a > 2 && (a = 0));
- i += 5
- }, 1) : style.type === "fill" ? setInterval(function() {
- i % speed === 0 && (map.addLayer({
- id: sourceid,
- type: "fill",
- source: sourceid,
- paint: {
- "fill-color": {
- stops: [color_num[a]]
- },
- "fill-opacity": 0.3,
- "fill-outline-color": {
- stops: [color_num[a]]
- }
- }
- }), a++, a > 2 && (a = 0));
- i += 5
- }, 1) : alert("\u8bf7\u786e\u5b9a\u663e\u793a\u7684\u8981\u7d20\u7684\u7c7b\u578b")
- },
- CLASS_NAME: "GeoGlobe.DynamicFeature"
- });
- GeoGlobe.Geometry = GeoGlobe.Class4OL({
- id: null,
- parent: null,
- bounds: null,
- initialize: function() {
- this.id = GeoGlobe.Util.createUniqueID(this.CLASS_NAME + "_")
- },
- destroy: function() {
- this.bounds = this.id = null
- },
- clone: function() {
- return new GeoGlobe.Geometry
- },
- setBounds: function(a) {
- if (a) this.bounds = a.clone()
- },
- clearBounds: function() {
- this.bounds = null;
- this.parent && this.parent.clearBounds()
- },
- extendBounds: function(a) {
- this.getBounds() ? this.bounds.extend(a) : this.setBounds(a)
- },
- getBounds: function() {
- this.bounds == null && this.calculateBounds();
- return this.bounds
- },
- calculateBounds: function() {},
- distanceTo: function() {},
- getVertices: function() {},
- atPoint: function(a, b, c) {
- var d = !1;
- this.getBounds() != null && a != null && (b = b != null ? b : 0, d = c != null ? c : 0, c = new GeoGlobe.LngLat(this.bounds._sw.lng - b, this.bounds._sw.lat - d), b = new GeoGlobe.LngLat(this.bounds._ne.lng + b, this.bounds._ne.lat + d), d = (new GeoGlobe.LngLatBounds(c, b)).containsLonLat(a));
- return d
- },
- getLength: function() {
- return 0
- },
- getArea: function() {
- return 0
- },
- getCentroid: function() {
- return null
- },
- toString: function() {
- return GeoGlobe.Format &&
- GeoGlobe.Format.WKT ? GeoGlobe.Format.WKT.prototype.write(new GeoGlobe.Feature(this)) : Object.prototype.toString.call(this)
- },
- CLASS_NAME: "GeoGlobe.Geometry"
- });
- GeoGlobe.Geometry.fromWKT = function(a) {
- var b;
- if (GeoGlobe.Format && GeoGlobe.Format.WKT) {
- var c = GeoGlobe.Geometry.fromWKT.format;
- if (!c) c = new GeoGlobe.Format.WKT, GeoGlobe.Geometry.fromWKT.format = c;
- a = c.read(a);
- if (a instanceof GeoGlobe.Feature) b = a.geometry;
- else if (GeoGlobe.Util.isArray(a)) {
- b = a.length;
- for (var c = Array(b), d = 0; d < b; ++d) c[d] = a[d].geometry;
- b = new GeoGlobe.Geometry.Collection(c)
- }
- }
- return b
- };
- GeoGlobe.Geometry.segmentsIntersect = function(a, b, c) {
- var d = c && c.point,
- c = c && c.tolerance,
- e = !1,
- f = a.x1 - b.x1,
- g = a.y1 - b.y1,
- h = a.x2 - a.x1,
- j = a.y2 - a.y1,
- l = b.y2 - b.y1,
- m = b.x2 - b.x1,
- n = l * h - m * j,
- l = m * g - l * f,
- g = h * g - j * f;
- n == 0 ? l == 0 && g == 0 && (e = !0) : (f = l / n, n = g / n, f >= 0 && f <= 1 && n >= 0 && n <= 1 && (d ? (h = a.x1 + f * h, n = a.y1 + f * j, e = new GeoGlobe.Geometry.Point(h, n)) : e = !0));
- if (c)
- if (e) {
- if (d) {
- a = [a, b];
- b = 0;
- a: for (; b < 2; ++b) {
- f = a[b];
- for (j = 1; j < 3; ++j)
- if (h = f["x" + j], n = f["y" + j], d = Math.sqrt(Math.pow(h - e.x, 2) + Math.pow(n - e.y, 2)), d < c) {
- e.x = h;
- e.y = n;
- break a
- }
- }
- }
- } else {
- a = [a,
- b
- ];
- b = 0;
- a: for (; b < 2; ++b) {
- h = a[b];
- n = a[(b + 1) % 2];
- for (j = 1; j < 3; ++j)
- if (f = {
- x: h["x" + j],
- y: h["y" + j]
- }, g = GeoGlobe.Geometry.distanceToSegment(f, n), g.distance < c) {
- e = d ? new GeoGlobe.Geometry.Point(f.x, f.y) : !0;
- break a
- }
- }
- }
- return e
- };
- GeoGlobe.Geometry.distanceToSegment = function(a, b) {
- var c = GeoGlobe.Geometry.distanceSquaredToSegment(a, b);
- c.distance = Math.sqrt(c.distance);
- return c
- };
- GeoGlobe.Geometry.distanceSquaredToSegment = function(a, b) {
- var c = a.x,
- d = a.y,
- e = b.x1,
- f = b.y1,
- g = b.x2,
- h = b.y2,
- j = g - e,
- l = h - f,
- m = j == 0 && l == 0 ? 0 : (j * (c - e) + l * (d - f)) / (Math.pow(j, 2) + Math.pow(l, 2));
- m <= 0 || (m >= 1 ? (e = g, f = h) : (e += m * j, f += m * l));
- return {
- distance: Math.pow(e - c, 2) + Math.pow(f - d, 2),
- x: e,
- y: f,
- along: m
- }
- };
- GeoGlobe.Geometry.fromGeoJson = function(a) {
- var b;
- if (GeoGlobe.Format && GeoGlobe.Format.GeoJSON) {
- format = new GeoGlobe.Format.GeoJSON;
- b = null;
- try {
- b = format.parseGeometry(a)
- } catch (c) {
- console.log(c)
- }
- }
- return b
- };
- GeoGlobe.Geometry.Collection = GeoGlobe.Class4OL(GeoGlobe.Geometry, {
- components: null,
- componentTypes: null,
- initialize: function(a) {
- GeoGlobe.Geometry.prototype.initialize.apply(this, arguments);
- this.components = [];
- a != null && this.addComponents(a)
- },
- destroy: function() {
- this.components.length = 0;
- this.components = null;
- GeoGlobe.Geometry.prototype.destroy.apply(this, arguments)
- },
- clone: function() {
- for (var a = eval("new " + this.CLASS_NAME + "()"), b = 0, c = this.components.length; b < c; b++) a.addComponent(this.components[b].clone());
- GeoGlobe.Util.applyDefaults(a, this);
- return a
- },
- getComponentsString: function() {
- for (var a = [], b = 0, c = this.components.length; b < c; b++) a.push(this.components[b].toShortString());
- return a.join(",")
- },
- calculateBounds: function() {
- this.bounds = null;
- var a = new GeoGlobe.LngLatBounds,
- b = this.components;
- if (b)
- for (var c = 0, d = b.length; c < d; c++) a.extend(b[c].getBounds());
- a._sw != null && a._sw != null && a._ne != null && a._ne != null && a._sw.lng != null && a._sw.lat != null && a._ne.lng != null && a._ne.lat != null && this.setBounds(a)
- },
- addComponents: function(a) {
- GeoGlobe.Util.isArray(a) ||
- (a = [a]);
- for (var b = 0, c = a.length; b < c; b++) this.addComponent(a[b])
- },
- addComponent: function(a, b) {
- var c = !1;
- if (a && (this.componentTypes == null || GeoGlobe.Util.indexOf(this.componentTypes, a.CLASS_NAME) > -1)) {
- if (b != null && b < this.components.length) {
- var c = this.components.slice(0, b),
- d = this.components.slice(b, this.components.length);
- c.push(a);
- this.components = c.concat(d)
- } else this.components.push(a);
- a.parent = this;
- this.clearBounds();
- c = !0
- }
- return c
- },
- removeComponents: function(a) {
- var b = !1;
- GeoGlobe.Util.isArray(a) || (a = [a]);
- for (var c = a.length - 1; c >= 0; --c) b = this.removeComponent(a[c]) || b;
- return b
- },
- removeComponent: function(a) {
- GeoGlobe.Util.removeItem(this.components, a);
- this.clearBounds();
- return !0
- },
- getLength: function() {
- for (var a = 0, b = 0, c = this.components.length; b < c; b++) a += this.components[b].getLength();
- return a
- },
- getArea: function() {
- for (var a = 0, b = 0, c = this.components.length; b < c; b++) a += this.components[b].getArea();
- return a
- },
- getGeodesicArea: function(a) {
- for (var b = 0, c = 0, d = this.components.length; c < d; c++) b += this.components[c].getGeodesicArea(a);
- return b
- },
- getCentroid: function(a) {
- if (!a) return this.components.length && this.components[0].getCentroid();
- a = this.components.length;
- if (!a) return !1;
- for (var b = [], c = [], d = 0, e = Number.MAX_VALUE, f, g = 0; g < a; ++g) {
- f = this.components[g];
- var h = f.getArea();
- f = f.getCentroid(!0);
- !isNaN(h) && !isNaN(f.x) && !isNaN(f.y) && (b.push(h), d += h, e = h < e && h > 0 ? h : e, c.push(f))
- }
- a = b.length;
- if (d === 0) {
- for (g = 0; g < a; ++g) b[g] = 1;
- d = b.length
- } else {
- for (g = 0; g < a; ++g) b[g] /= e;
- d /= e
- }
- for (var j = e = 0, g = 0; g < a; ++g) f = c[g], h = b[g], e += f.x * h, j += f.y * h;
- return new GeoGlobe.Geometry.Point(e /
- d, j / d)
- },
- getGeodesicLength: function(a) {
- for (var b = 0, c = 0, d = this.components.length; c < d; c++) b += this.components[c].getGeodesicLength(a);
- return b
- },
- move: function(a, b) {
- for (var c = 0, d = this.components.length; c < d; c++) this.components[c].move(a, b)
- },
- rotate: function(a, b) {
- for (var c = 0, d = this.components.length; c < d; ++c) this.components[c].rotate(a, b)
- },
- resize: function(a, b, c) {
- for (var d = 0; d < this.components.length; ++d) this.components[d].resize(a, b, c);
- return this
- },
- distanceTo: function(a, b) {
- for (var c = !(b && b.edge === !1) && b && b.details,
- d, e, f, g = Number.POSITIVE_INFINITY, h = 0, j = this.components.length; h < j; ++h)
- if (d = this.components[h].distanceTo(a, b), f = c ? d.distance : d, f < g && (g = f, e = d, g == 0)) break;
- return e
- },
- equals: function(a) {
- var b = !0;
- if (!a || !a.CLASS_NAME || this.CLASS_NAME != a.CLASS_NAME) b = !1;
- else if (!GeoGlobe.Util.isArray(a.components) || a.components.length != this.components.length) b = !1;
- else
- for (var c = 0, d = this.components.length; c < d; ++c)
- if (!this.components[c].equals(a.components[c])) {
- b = !1;
- break
- } return b
- },
- transform: function(a, b) {
- if (a && b) {
- for (var c =
- 0, d = this.components.length; c < d; c++) this.components[c].transform(a, b);
- this.bounds = null
- }
- return this
- },
- intersects: function(a) {
- for (var b = !1, c = 0, d = this.components.length; c < d; ++c)
- if (b = a.intersects(this.components[c])) break;
- return b
- },
- getVertices: function(a) {
- for (var b = [], c = 0, d = this.components.length; c < d; ++c) Array.prototype.push.apply(b, this.components[c].getVertices(a));
- return b
- },
- CLASS_NAME: "GeoGlobe.Geometry.Collection"
- });
- GeoGlobe.Geometry.Point = GeoGlobe.Class4OL(GeoGlobe.Geometry, {
- x: null,
- y: null,
- initialize: function(a, b) {
- GeoGlobe.Geometry.prototype.initialize.apply(this, arguments);
- this.x = parseFloat(a);
- this.y = parseFloat(b)
- },
- clone: function(a) {
- a == null && (a = new GeoGlobe.Geometry.Point(this.x, this.y));
- GeoGlobe.Util.applyDefaults(a, this);
- return a
- },
- calculateBounds: function() {
- var a = new GeoGlobe.LngLat(this.x, this.y),
- b = new GeoGlobe.LngLat(this.x, this.y);
- this.bounds = new GeoGlobe.LngLatBounds(a, b)
- },
- distanceTo: function(a, b) {
- var c = !(b && b.edge === !1) && b && b.details,
- d, e, f, g, h;
- a instanceof GeoGlobe.Geometry.Point ? (e = this.x, f = this.y, g = a.x, h = a.y, d = Math.sqrt(Math.pow(e - g, 2) + Math.pow(f - h, 2)), d = !c ? d : {
- x0: e,
- y0: f,
- x1: g,
- y1: h,
- distance: d
- }) : (d = a.distanceTo(this, b), c && (d = {
- x0: d.x1,
- y0: d.y1,
- x1: d.x0,
- y1: d.y0,
- distance: d.distance
- }));
- return d
- },
- equals: function(a) {
- var b = !1;
- a != null && (b = this.x == a.x && this.y == a.y || isNaN(this.x) && isNaN(this.y) && isNaN(a.x) && isNaN(a.y));
- return b
- },
- toShortString: function() {
- return this.x + ", " + this.y
- },
- move: function(a, b) {
- this.x +=
- a;
- this.y += b;
- this.clearBounds()
- },
- rotate: function(a, b) {
- a *= Math.PI / 180;
- var c = this.distanceTo(b),
- d = a + Math.atan2(this.y - b.y, this.x - b.x);
- this.x = b.x + c * Math.cos(d);
- this.y = b.y + c * Math.sin(d);
- this.clearBounds()
- },
- getCentroid: function() {
- return new GeoGlobe.Geometry.Point(this.x, this.y)
- },
- resize: function(a, b, c) {
- this.x = b.x + a * (c == void 0 ? 1 : c) * (this.x - b.x);
- this.y = b.y + a * (this.y - b.y);
- this.clearBounds();
- return this
- },
- intersects: function(a) {
- var b = !1;
- return b = a.CLASS_NAME == "GeoGlobe.Geometry.Point" ? this.equals(a) : a.intersects(this)
- },
- transform: function(a, b) {
- if (a && b) GeoGlobe.SpatialReference.transform(this, a, b), this.bounds = null;
- return this
- },
- getVertices: function() {
- return [this]
- },
- CLASS_NAME: "GeoGlobe.Geometry.Point"
- });
- GeoGlobe.Geometry.MultiPoint = GeoGlobe.Class4OL(GeoGlobe.Geometry.Collection, {
- componentTypes: ["GeoGlobe.Geometry.Point"],
- addPoint: function(a, b) {
- this.addComponent(a, b)
- },
- removePoint: function(a) {
- this.removeComponent(a)
- },
- CLASS_NAME: "GeoGlobe.Geometry.MultiPoint"
- });
- GeoGlobe.Geometry.Curve = GeoGlobe.Class4OL(GeoGlobe.Geometry.MultiPoint, {
- componentTypes: ["GeoGlobe.Geometry.Point"],
- getLength: function() {
- var a = 0;
- if (this.components && this.components.length > 1)
- for (var b = 1, c = this.components.length; b < c; b++) a += this.components[b - 1].distanceTo(this.components[b]);
- return a
- },
- getGeodesicLength: function(a) {
- var b = this;
- if (a) {
- var c = new GeoGlobe.SpatialReference("EPSG:4326");
- c.equals(a) || (b = this.clone().transform(a, c))
- }
- a = 0;
- if (b.components && b.components.length > 1)
- for (var d, e = 1, f = b.components.length; e <
- f; e++) c = b.components[e - 1], d = b.components[e], a += GeoGlobe.Util.distVincenty({
- lng: c.x,
- lat: c.y
- }, {
- lng: d.x,
- lat: d.y
- });
- return a * 1E3
- },
- CLASS_NAME: "GeoGlobe.Geometry.Curve"
- });
- GeoGlobe.Geometry.LineString = GeoGlobe.Class4OL(GeoGlobe.Geometry.Curve, {
- removeComponent: function() {
- var a = this.components && this.components.length > 2;
- a && GeoGlobe.Geometry.Collection.prototype.removeComponent.apply(this, arguments);
- return a
- },
- intersects: function(a) {
- var b = !1,
- c = a.CLASS_NAME;
- if (c == "GeoGlobe.Geometry.LineString" || c == "GeoGlobe.Geometry.LinearRing" || c == "GeoGlobe.Geometry.Point") {
- var d = this.getSortedSegments(),
- a = c == "GeoGlobe.Geometry.Point" ? [{
- x1: a.x,
- y1: a.y,
- x2: a.x,
- y2: a.y
- }] : a.getSortedSegments(),
- e, f, g, h, j, l, m, n = 0,
- p = d.length;
- a: for (; n < p; ++n) {
- c = d[n];
- e = c.x1;
- f = c.x2;
- g = c.y1;
- h = c.y2;
- var q = 0,
- o = a.length;
- for (; q < o; ++q) {
- j = a[q];
- if (j.x1 > f) break;
- if (!(j.x2 < e) && (l = j.y1, m = j.y2, !(Math.min(l, m) > Math.max(g, h)) && !(Math.max(l, m) < Math.min(g, h)) && GeoGlobe.Geometry.segmentsIntersect(c, j))) {
- b = !0;
- break a
- }
- }
- }
- } else b = a.intersects(this);
- return b
- },
- getSortedSegments: function() {
- for (var a = this.components.length - 1, b = Array(a), c, d, e = 0; e < a; ++e) c = this.components[e], d = this.components[e + 1], b[e] = c.x < d.x ? {
- x1: c.x,
- y1: c.y,
- x2: d.x,
- y2: d.y
- } : {
- x1: d.x,
- y1: d.y,
- x2: c.x,
- y2: c.y
- };
- return b.sort(function(a, b) {
- return a.x1 - b.x1
- })
- },
- splitWithSegment: function(a, b) {
- for (var c = !(b && b.edge === !1), d = b && b.tolerance, e = [], f = this.getVertices(), g = [], h = [], j = !1, l, m, n, p = {
- point: !0,
- tolerance: d
- }, q = null, o = 0, s = f.length - 2; o <= s; ++o)
- if (d = f[o], g.push(d.clone()), l = f[o + 1], m = {
- x1: d.x,
- y1: d.y,
- x2: l.x,
- y2: l.y
- }, m = GeoGlobe.Geometry.segmentsIntersect(a, m, p), m instanceof GeoGlobe.Geometry.Point && ((n = m.x === a.x1 && m.y === a.y1 || m.x === a.x2 && m.y === a.y2 || m.equals(d) || m.equals(l) ? !0 : !1) || c)) m.equals(h[h.length -
- 1]) || h.push(m.clone()), !(o === 0 && m.equals(d)) && !m.equals(l) && (j = !0, m.equals(d) || g.push(m), e.push(new GeoGlobe.Geometry.LineString(g)), g = [m.clone()]);
- j && (g.push(l.clone()), e.push(new GeoGlobe.Geometry.LineString(g)));
- if (h.length > 0) var r = a.x1 < a.x2 ? 1 : -1,
- t = a.y1 < a.y2 ? 1 : -1,
- q = {
- lines: e,
- points: h.sort(function(a, b) {
- return r * a.x - r * b.x || t * a.y - t * b.y
- })
- };
- return q
- },
- split: function(a, b) {
- var c = null,
- d = b && b.mutual,
- e, f, g, h;
- if (a instanceof GeoGlobe.Geometry.LineString) {
- var j = this.getVertices(),
- l, m, n, p, q, o = [];
- g = [];
- for (var s =
- 0, r = j.length - 2; s <= r; ++s) {
- l = j[s];
- m = j[s + 1];
- n = {
- x1: l.x,
- y1: l.y,
- x2: m.x,
- y2: m.y
- };
- h = h || [a];
- d && o.push(l.clone());
- for (var t = 0; t < h.length; ++t)
- if (p = h[t].splitWithSegment(n, b))
- if (q = p.lines, q.length > 0 && (q.unshift(t, 1), Array.prototype.splice.apply(h, q), t += q.length - 2), d)
- for (var u = 0, v = p.points.length; u < v; ++u) q = p.points[u], q.equals(l) || (o.push(q), g.push(new GeoGlobe.Geometry.LineString(o)), o = q.equals(m) ? [] : [q.clone()])
- }
- d && g.length > 0 && o.length > 0 && (o.push(m.clone()), g.push(new GeoGlobe.Geometry.LineString(o)))
- } else c =
- a.splitWith(this, b);
- h && h.length > 1 ? f = !0 : h = [];
- g && g.length > 1 ? e = !0 : g = [];
- if (f || e) c = d ? [g, h] : h;
- return c
- },
- splitWith: function(a, b) {
- return a.split(this, b)
- },
- getVertices: function(a) {
- return a === !0 ? [this.components[0], this.components[this.components.length - 1]] : a === !1 ? this.components.slice(1, this.components.length - 1) : this.components.slice()
- },
- distanceTo: function(a, b) {
- var c = !(b && b.edge === !1) && b && b.details,
- d, e = {},
- f = Number.POSITIVE_INFINITY;
- if (a instanceof GeoGlobe.Geometry.Point) {
- for (var g = this.getSortedSegments(),
- h = a.x, j = a.y, l, m = 0, n = g.length; m < n; ++m)
- if (l = g[m], d = GeoGlobe.Geometry.distanceToSegment(a, l), d.distance < f) {
- if (f = d.distance, e = d, f === 0) break
- } else if (l.x2 > h && (j > l.y1 && j < l.y2 || j < l.y1 && j > l.y2)) break;
- e = c ? {
- distance: e.distance,
- x0: e.x,
- y0: e.y,
- x1: h,
- y1: j
- } : e.distance
- } else if (a instanceof GeoGlobe.Geometry.LineString) {
- var g = this.getSortedSegments(),
- h = a.getSortedSegments(),
- p, q, o = h.length,
- s = {
- point: !0
- },
- m = 0,
- n = g.length;
- a: for (; m < n; ++m) {
- j = g[m];
- l = j.x1;
- q = j.y1;
- for (var r = 0; r < o; ++r)
- if (d = h[r], p = GeoGlobe.Geometry.segmentsIntersect(j,
- d, s)) {
- f = 0;
- e = {
- distance: 0,
- x0: p.x,
- y0: p.y,
- x1: p.x,
- y1: p.y
- };
- break a
- } else if (d = GeoGlobe.Geometry.distanceToSegment({
- x: l,
- y: q
- }, d), d.distance < f) f = d.distance, e = {
- distance: f,
- x0: l,
- y0: q,
- x1: d.x,
- y1: d.y
- }
- }
- if (!c) e = e.distance;
- f !== 0 && j && (d = a.distanceTo(new GeoGlobe.Geometry.Point(j.x2, j.y2), b), m = c ? d.distance : d, m < f && (e = c ? {
- distance: f,
- x0: d.x1,
- y0: d.y1,
- x1: d.x0,
- y1: d.y0
- } : m))
- } else e = a.distanceTo(this, b), c && (e = {
- distance: e.distance,
- x0: e.x1,
- y0: e.y1,
- x1: e.x0,
- y1: e.y0
- });
- return e
- },
- simplify: function(a) {
- if (this && this !== null) {
- var b = this.getVertices();
- if (b.length < 3) return this;
- var c = function(a, b, d, j) {
- for (var l = 0, m = 0, n = b, p; n < d; n++) p = Math.abs(0.5 * (a[b].x * a[d].y + a[d].x * a[n].y + a[n].x * a[b].y - a[d].x * a[b].y - a[n].x * a[d].y - a[b].x * a[n].y)) / Math.sqrt(Math.pow(a[b].x - a[d].x, 2) + Math.pow(a[b].y - a[d].y, 2)) * 2, p > l && (l = p, m = n);
- l > j && m != b && (e.push(m), c(a, b, m, j), c(a, m, d, j))
- },
- d = b.length - 1,
- e = [];
- e.push(0);
- for (e.push(d); b[0].equals(b[d]);) d--, e.push(d);
- c(b, 0, d, a);
- a = [];
- e.sort(function(a, b) {
- return a - b
- });
- for (d = 0; d < e.length; d++) a.push(b[e[d]]);
- return new GeoGlobe.Geometry.LineString(a)
- } else return this
- },
- CLASS_NAME: "GeoGlobe.Geometry.LineString"
- });
- GeoGlobe.Geometry.LineString.createCurveLine = function(a) {
- for (var b = [], c = 0; c < a.length - 1; c++) {
- var d = GeoGlobe.Geometry.LineString.getCurveCoordinatesByTwoPoints(a[c], a[c + 1]);
- d && d.length > 0 && (b = b.concat(d))
- }
- return new GeoGlobe.Geometry.LineString(b)
- };
- GeoGlobe.Geometry.LineString.getCurveCoordinatesByTwoPoints = function(a, b) {
- if (!a || !b || !(a instanceof GeoGlobe.Geometry.Point) || !(b instanceof GeoGlobe.Geometry.Point)) return null;
- curveCoordinates = [];
- var c, d, e, f = d = 0;
- if (typeof b == "undefined") typeof curveCoordinates != "undefined" && (curveCoordinates = []);
- else {
- var g = parseFloat(a.y),
- h = parseFloat(b.y),
- j = parseFloat(a.x),
- l = parseFloat(b.x);
- l > j && parseFloat(l - j) > 180 && j < 0 && (j = parseFloat(360 + j));
- j > l && parseFloat(j - l) > 180 && l < 0 && (l = parseFloat(360 + l));
- e = 0;
- h == g ? (c = 0, d =
- j - l) : l == j ? (c = Math.PI / 2, d = g - h) : (c = Math.atan((h - g) / (l - j)), d = (h - g) / Math.sin(c));
- e == 0 && (e = c + Math.PI / 5);
- d /= 2;
- c = d * Math.cos(e) + j;
- e = d * Math.sin(e) + g;
- for (d = 0; d < 31; d++) curveCoordinates.push(new GeoGlobe.Geometry.Point(j * (1 - 2 * f + f * f) + c * (2 * f - 2 * f * f) + l * f * f, g * (1 - 2 * f + f * f) + e * (2 * f - 2 * f * f) + h * f * f)), f += 1 / 30;
- return curveCoordinates
- }
- };
- GeoGlobe.Geometry.LinearRing = GeoGlobe.Class4OL(GeoGlobe.Geometry.LineString, {
- componentTypes: ["GeoGlobe.Geometry.Point"],
- addComponent: function(a, b) {
- var c = !1,
- d = this.components.pop();
- if (b != null || !a.equals(d)) c = GeoGlobe.Geometry.Collection.prototype.addComponent.apply(this, arguments);
- GeoGlobe.Geometry.Collection.prototype.addComponent.apply(this, [this.components[0]]);
- return c
- },
- removeComponent: function() {
- var a = this.components && this.components.length > 3;
- a && (this.components.pop(), GeoGlobe.Geometry.Collection.prototype.removeComponent.apply(this,
- arguments), GeoGlobe.Geometry.Collection.prototype.addComponent.apply(this, [this.components[0]]));
- return a
- },
- move: function(a, b) {
- for (var c = 0, d = this.components.length; c < d - 1; c++) this.components[c].move(a, b)
- },
- rotate: function(a, b) {
- for (var c = 0, d = this.components.length; c < d - 1; ++c) this.components[c].rotate(a, b)
- },
- resize: function(a, b, c) {
- for (var d = 0, e = this.components.length; d < e - 1; ++d) this.components[d].resize(a, b, c);
- return this
- },
- transform: function(a, b) {
- if (a && b) {
- for (var c = 0, d = this.components.length; c < d - 1; c++) this.components[c].transform(a,
- b);
- this.bounds = null
- }
- return this
- },
- getCentroid: function() {
- if (this.components) {
- var a = this.components.length;
- if (a > 0 && a <= 2) return this.components[0].clone();
- else if (a > 2) {
- var b = 0,
- c = 0,
- d = this.components[0].x,
- e = this.components[0].y,
- f = -1 * this.getArea();
- if (f != 0) {
- for (var g = 0; g < a - 1; g++) {
- var h = this.components[g],
- j = this.components[g + 1];
- b += (h.x + j.x - 2 * d) * ((h.x - d) * (j.y - e) - (j.x - d) * (h.y - e));
- c += (h.y + j.y - 2 * e) * ((h.x - d) * (j.y - e) - (j.x - d) * (h.y - e))
- }
- b = d + b / (6 * f);
- a = e + c / (6 * f)
- } else {
- for (g = 0; g < a - 1; g++) b += this.components[g].x, c += this.components[g].y;
- b /= a - 1;
- a = c / (a - 1)
- }
- return new GeoGlobe.Geometry.Point(b, a)
- } else return null
- }
- },
- getArea: function() {
- var a = 0;
- if (this.components && this.components.length > 2) {
- for (var b = a = 0, c = this.components.length; b < c - 1; b++) {
- var d = this.components[b],
- e = this.components[b + 1];
- a += (d.x + e.x) * (e.y - d.y)
- }
- a = -a / 2
- }
- return a
- },
- getGeodesicArea: function(a) {
- var b = this;
- if (a) {
- var c = new GeoGlobe.SpatialReference("EPSG:4326");
- c.equals(a) || (b = this.clone().transform(a, c))
- }
- a = 0;
- c = b.components && b.components.length;
- if (c > 2) {
- for (var d, e, f = 0; f < c - 1; f++) d =
- b.components[f], e = b.components[f + 1], a += GeoGlobe.Util.rad(e.x - d.x) * (2 + Math.sin(GeoGlobe.Util.rad(d.y)) + Math.sin(GeoGlobe.Util.rad(e.y)));
- a = a * 40680631590769 / 2
- }
- return a
- },
- containsPoint: function(a) {
- for (var b = GeoGlobe.Number.limitSigDigs, c = b(a.x, 14), a = b(a.y, 14), d = this.components.length - 1, e, f, g, h, j, l = 0, m = 0; m < d; ++m)
- if (e = this.components[m], g = b(e.x, 14), e = b(e.y, 14), f = this.components[m + 1], h = b(f.x, 14), f = b(f.y, 14), e == f) {
- if (a == e && (g <= h && c >= g && c <= h || g >= h && c <= g && c >= h)) {
- l = -1;
- break
- }
- } else {
- j = b((a - f) * ((h - g) / (f - e)) + h, 14);
- if (j == c && (e < f && a >= e && a <= f || e > f && a <= e && a >= f)) {
- l = -1;
- break
- }
- j <= c || g != h && (j < Math.min(g, h) || j > Math.max(g, h)) || (e < f && a >= e && a < f || e > f && a < e && a >= f) && ++l
- }
- return l == -1 ? 1 : !!(l & 1)
- },
- intersects: function(a) {
- var b = !1;
- if (a.CLASS_NAME == "GeoGlobe.Geometry.Point") b = this.containsPoint(a);
- else if (a.CLASS_NAME == "GeoGlobe.Geometry.LineString") b = a.intersects(this);
- else if (a.CLASS_NAME == "GeoGlobe.Geometry.LinearRing") b = GeoGlobe.Geometry.LineString.prototype.intersects.apply(this, [a]);
- else
- for (var c = 0, d = a.components.length; c <
- d; ++c)
- if (b = a.components[c].intersects(this)) break;
- return b
- },
- getVertices: function(a) {
- return a === !0 ? [] : this.components.slice(0, this.components.length - 1)
- },
- CLASS_NAME: "GeoGlobe.Geometry.LinearRing"
- });
- GeoGlobe.Geometry.Polygon = GeoGlobe.Class4OL(GeoGlobe.Geometry.Collection, {
- componentTypes: ["GeoGlobe.Geometry.LinearRing"],
- getArea: function() {
- var a = 0;
- if (this.components && this.components.length > 0) {
- a += Math.abs(this.components[0].getArea());
- for (var b = 1, c = this.components.length; b < c; b++) a -= Math.abs(this.components[b].getArea())
- }
- return a
- },
- getGeodesicArea: function(a) {
- var b = 0;
- if (this.components && this.components.length > 0) {
- b += Math.abs(this.components[0].getGeodesicArea(a));
- for (var c = 1, d = this.components.length; c <
- d; c++) b -= Math.abs(this.components[c].getGeodesicArea(a))
- }
- return b
- },
- containsPoint: function(a) {
- var b = this.components.length,
- c = !1;
- if (b > 0 && (c = this.components[0].containsPoint(a), c !== 1 && c && b > 1))
- for (var d, e = 1; e < b; ++e)
- if (d = this.components[e].containsPoint(a)) {
- c = d === 1 ? 1 : !1;
- break
- }
- return c
- },
- intersects: function(a) {
- var b = !1,
- c, d;
- if (a.CLASS_NAME == "GeoGlobe.Geometry.Point") b = this.containsPoint(a);
- else if (a.CLASS_NAME == "GeoGlobe.Geometry.LineString" || a.CLASS_NAME == "GeoGlobe.Geometry.LinearRing") {
- c = 0;
- for (d = this.components.length; c <
- d; ++c)
- if (b = a.intersects(this.components[c])) break;
- if (!b) {
- c = 0;
- for (d = a.components.length; c < d; ++c)
- if (b = this.containsPoint(a.components[c])) break
- }
- } else {
- c = 0;
- for (d = a.components.length; c < d; ++c)
- if (b = this.intersects(a.components[c])) break
- }
- if (!b && a.CLASS_NAME == "GeoGlobe.Geometry.Polygon") {
- var e = this.components[0];
- c = 0;
- for (d = e.components.length; c < d; ++c)
- if (b = a.containsPoint(e.components[c])) break
- }
- return b
- },
- distanceTo: function(a, b) {
- return b && b.edge === !1 && this.intersects(a) ? 0 : GeoGlobe.Geometry.Collection.prototype.distanceTo.apply(this, [a, b])
- },
- CLASS_NAME: "GeoGlobe.Geometry.Polygon"
- });
- GeoGlobe.Geometry.Polygon.createRegularPolygon = function(a, b, c, d) {
- var e = Math.PI * (1 / c - 0.5);
- d && (e += d / 180 * Math.PI);
- for (var f, g = [], h = 0; h < c; ++h) f = e + h * 2 * Math.PI / c, d = a.x + b * Math.cos(f), f = a.y + b * Math.sin(f), g.push(new GeoGlobe.Geometry.Point(d, f));
- a = new GeoGlobe.Geometry.LinearRing(g);
- return new GeoGlobe.Geometry.Polygon([a])
- };
- GeoGlobe.Geometry.MultiLineString = GeoGlobe.Class4OL(GeoGlobe.Geometry.Collection, {
- componentTypes: ["GeoGlobe.Geometry.LineString"],
- split: function(a, b) {
- for (var c = null, d = b && b.mutual, e, f, g, h, j = [], l = [a], m = 0, n = this.components.length; m < n; ++m) {
- f = this.components[m];
- g = !1;
- for (var p = 0; p < l.length; ++p)
- if (e = f.split(l[p], b)) {
- if (d) {
- g = e[0];
- for (var q = 0, o = g.length; q < o; ++q) q === 0 && j.length ? j[j.length - 1].addComponent(g[q]) : j.push(new GeoGlobe.Geometry.MultiLineString([g[q]]));
- g = !0;
- e = e[1]
- }
- if (e.length) {
- e.unshift(p, 1);
- Array.prototype.splice.apply(l,
- e);
- break
- }
- }
- g || (j.length ? j[j.length - 1].addComponent(f.clone()) : j = [new GeoGlobe.Geometry.MultiLineString(f.clone())])
- }
- j && j.length > 1 ? g = !0 : j = [];
- l && l.length > 1 ? h = !0 : l = [];
- if (g || h) c = d ? [j, l] : l;
- return c
- },
- splitWith: function(a, b) {
- var c = null,
- d = b && b.mutual,
- e, f, g, h, j, l;
- if (a instanceof GeoGlobe.Geometry.LineString) {
- l = [];
- j = [a];
- for (var m = 0, n = this.components.length; m < n; ++m) {
- g = !1;
- f = this.components[m];
- for (var p = 0; p < j.length; ++p)
- if (e = j[p].split(f, b)) {
- d && (g = e[0], g.length && (g.unshift(p, 1), Array.prototype.splice.apply(j, g),
- p += g.length - 2), e = e[1], e.length === 0 && (e = [f.clone()]));
- g = 0;
- for (var q = e.length; g < q; ++g) g === 0 && l.length ? l[l.length - 1].addComponent(e[g]) : l.push(new GeoGlobe.Geometry.MultiLineString([e[g]]));
- g = !0
- }
- g || (l.length ? l[l.length - 1].addComponent(f.clone()) : l = [new GeoGlobe.Geometry.MultiLineString([f.clone()])])
- }
- } else c = a.split(this);
- j && j.length > 1 ? h = !0 : j = [];
- l && l.length > 1 ? g = !0 : l = [];
- if (h || g) c = d ? [j, l] : l;
- return c
- },
- CLASS_NAME: "GeoGlobe.Geometry.MultiLineString"
- });
- GeoGlobe.Geometry.MultiPolygon = GeoGlobe.Class4OL(GeoGlobe.Geometry.Collection, {
- componentTypes: ["GeoGlobe.Geometry.Polygon"],
- CLASS_NAME: "GeoGlobe.Geometry.MultiPolygon"
- });
- GeoGlobe.State = {
- UNKNOWN: "Unknown",
- INSERT: "Insert",
- UPDATE: "Update",
- DELETE: "Delete"
- };
- GeoGlobe.Feature = GeoGlobe.Class4OL({
- id: null,
- fid: null,
- lonlat: null,
- geometry: null,
- attributes: null,
- data: null,
- bounds: null,
- state: null,
- url: null,
- modified: null,
- initialize: function(a, b) {
- this.data = b != null ? b : {};
- this.id = GeoGlobe.Util.createUniqueID(this.CLASS_NAME + "_");
- this.lonlat = null;
- this.geometry = a ? a : null;
- this.state = null;
- this.attributes = {};
- if (b) this.attributes = GeoGlobe.Util.extend(this.attributes, b)
- },
- destroy: function() {
- this.data = this.lonlat = this.id = this.modified = this.geometry = null
- },
- clone: function() {
- return new GeoGlobe.Feature(this.geometry ?
- this.geometry.clone() : null, this.attributes)
- },
- createMarker: function() {
- return null
- },
- destroyMarker: function() {},
- createPopup: function() {
- return null
- },
- atPoint: function(a, b, c) {
- var d = !1;
- this.geometry && (d = this.geometry.atPoint(a, b, c));
- return d
- },
- destroyPopup: function() {},
- toState: function(a) {
- if (a == GeoGlobe.State.UPDATE) switch (this.state) {
- case GeoGlobe.State.UNKNOWN:
- case GeoGlobe.State.DELETE:
- this.state = a
- } else if (a == GeoGlobe.State.INSERT) switch (this.state) {
- case GeoGlobe.State.UNKNOWN:
- break;
- default:
- this.state =
- a
- } else if (a == GeoGlobe.State.DELETE) switch (this.state) {
- case GeoGlobe.State.UNKNOWN:
- case GeoGlobe.State.UPDATE:
- this.state = a
- } else if (a == GeoGlobe.State.UNKNOWN) this.state = a
- },
- CLASS_NAME: "GeoGlobe.Feature"
- });
- GeoGlobe.Feature.getBoundsByFeatures = function(a) {
- for (var b = a.length, c = Array(b), d = 0; d < b; ++d) c[d] = a[d].geometry;
- a = new GeoGlobe.Geometry.Collection(c);
- a.calculateBounds();
- return a.bounds
- };
- GeoGlobe.Feature.fromGeoJson = function(a) {
- var b;
- GeoGlobe.Format && GeoGlobe.Format.GeoJSON && (format = new GeoGlobe.Format.GeoJSON, b = format.read(a));
- return b
- };
- GeoGlobe.Filter = GeoGlobe.Class4OL({
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- destroy: function() {},
- evaluate: function() {
- return !0
- },
- clone: function() {
- return null
- },
- toString: function() {
- return GeoGlobe.Format && GeoGlobe.Format.CQL ? GeoGlobe.Format.CQL.prototype.write(this) : Object.prototype.toString.call(this)
- },
- CLASS_NAME: "GeoGlobe.Filter"
- });
- GeoGlobe.Filter.FeatureId = GeoGlobe.Class4OL(GeoGlobe.Filter, {
- fids: null,
- type: "FID",
- initialize: function(a) {
- this.fids = [];
- GeoGlobe.Filter.prototype.initialize.apply(this, [a])
- },
- evaluate: function(a) {
- for (var b = 0, c = this.fids.length; b < c; b++)
- if ((a.fid || a.id) == this.fids[b]) return !0;
- return !1
- },
- clone: function() {
- var a = new GeoGlobe.Filter.FeatureId;
- GeoGlobe.Util.extend(a, this);
- a.fids = this.fids.slice();
- return a
- },
- CLASS_NAME: "GeoGlobe.Filter.FeatureId"
- });
- GeoGlobe.Filter.Logical = GeoGlobe.Class4OL(GeoGlobe.Filter, {
- filters: null,
- type: null,
- initialize: function(a) {
- this.filters = [];
- GeoGlobe.Filter.prototype.initialize.apply(this, [a])
- },
- destroy: function() {
- this.filters = null;
- GeoGlobe.Filter.prototype.destroy.apply(this)
- },
- evaluate: function(a) {
- var b, c;
- switch (this.type) {
- case GeoGlobe.Filter.Logical.AND:
- b = 0;
- for (c = this.filters.length; b < c; b++)
- if (this.filters[b].evaluate(a) == !1) return !1;
- return !0;
- case GeoGlobe.Filter.Logical.OR:
- b = 0;
- for (c = this.filters.length; b < c; b++)
- if (this.filters[b].evaluate(a) ==
- !0) return !0;
- return !1;
- case GeoGlobe.Filter.Logical.NOT:
- return !this.filters[0].evaluate(a)
- }
- },
- clone: function() {
- for (var a = [], b = 0, c = this.filters.length; b < c; ++b) a.push(this.filters[b].clone());
- return new GeoGlobe.Filter.Logical({
- type: this.type,
- filters: a
- })
- },
- CLASS_NAME: "GeoGlobe.Filter.Logical"
- });
- GeoGlobe.Filter.Logical.AND = "&&";
- GeoGlobe.Filter.Logical.OR = "||";
- GeoGlobe.Filter.Logical.NOT = "!";
- GeoGlobe.Filter.Comparison = GeoGlobe.Class4OL(GeoGlobe.Filter, {
- type: null,
- property: null,
- value: null,
- matchCase: !0,
- lowerBoundary: null,
- upperBoundary: null,
- initialize: function(a) {
- GeoGlobe.Filter.prototype.initialize.apply(this, [a]);
- if (this.type === GeoGlobe.Filter.Comparison.LIKE && a.matchCase === void 0) this.matchCase = null
- },
- evaluate: function(a) {
- if (a instanceof GeoGlobe.Feature) a = a.attributes;
- var b = !1,
- a = a[this.property];
- if (a === void 0) return !1;
- switch (this.type) {
- case GeoGlobe.Filter.Comparison.EQUAL_TO:
- b = this.value;
- b = !this.matchCase && typeof a == "string" && typeof b == "string" ? a.toUpperCase() == b.toUpperCase() : a == b;
- break;
- case GeoGlobe.Filter.Comparison.NOT_EQUAL_TO:
- b = this.value;
- b = !this.matchCase && typeof a == "string" && typeof b == "string" ? a.toUpperCase() != b.toUpperCase() : a != b;
- break;
- case GeoGlobe.Filter.Comparison.LESS_THAN:
- b = a < this.value;
- break;
- case GeoGlobe.Filter.Comparison.GREATER_THAN:
- b = a > this.value;
- break;
- case GeoGlobe.Filter.Comparison.LESS_THAN_OR_EQUAL_TO:
- b = a <= this.value;
- break;
- case GeoGlobe.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO:
- b =
- a >= this.value;
- break;
- case GeoGlobe.Filter.Comparison.BETWEEN:
- b = a >= this.lowerBoundary && a <= this.upperBoundary;
- break;
- case GeoGlobe.Filter.Comparison.LIKE:
- b = RegExp(this.value, "gi").test(a);
- break;
- case GeoGlobe.Filter.Comparison.IS_NULL:
- b = a === null
- }
- return b
- },
- value2regex: function(a, b, c) {
- if (a == ".") throw Error("'.' is an unsupported wildCard character for GeoGlobe.Filter.Comparison");
- a = a ? a : "*";
- b = b ? b : ".";
- this.value = this.value.replace(RegExp("\\" + (c ? c : "!") + "(.|$)", "g"), "\\$1");
- this.value = this.value.replace(RegExp("\\" +
- b, "g"), ".");
- this.value = this.value.replace(RegExp("\\" + a, "g"), ".*");
- this.value = this.value.replace(RegExp("\\\\.\\*", "g"), "\\" + a);
- return this.value = this.value.replace(RegExp("\\\\\\.", "g"), "\\" + b)
- },
- regex2value: function() {
- var a = this.value,
- a = a.replace(/!/g, "!!"),
- a = a.replace(/(\\)?\\\./g, function(a, c) {
- return c ? a : "!."
- }),
- a = a.replace(/(\\)?\\\*/g, function(a, c) {
- return c ? a : "!*"
- }),
- a = a.replace(/\\\\/g, "\\");
- return a = a.replace(/\.\*/g, "*")
- },
- clone: function() {
- return GeoGlobe.Util.extend(new GeoGlobe.Filter.Comparison,
- this)
- },
- CLASS_NAME: "GeoGlobe.Filter.Comparison"
- });
- GeoGlobe.Filter.Comparison.EQUAL_TO = "==";
- GeoGlobe.Filter.Comparison.NOT_EQUAL_TO = "!=";
- GeoGlobe.Filter.Comparison.LESS_THAN = "<";
- GeoGlobe.Filter.Comparison.GREATER_THAN = ">";
- GeoGlobe.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
- GeoGlobe.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
- GeoGlobe.Filter.Comparison.BETWEEN = "..";
- GeoGlobe.Filter.Comparison.LIKE = "~";
- GeoGlobe.Filter.Comparison.IS_NULL = "NULL";
- GeoGlobe.Filter.Spatial = GeoGlobe.Class4OL(GeoGlobe.Filter, {
- type: null,
- property: null,
- value: null,
- distance: null,
- distanceUnits: null,
- evaluate: function(a) {
- var b = !1;
- switch (this.type) {
- case GeoGlobe.Filter.Spatial.BBOX:
- case GeoGlobe.Filter.Spatial.INTERSECTS:
- if (a.geometry) {
- var c = this.value;
- this.value.CLASS_NAME == "GeoGlobe.LngLatBounds" && (c = this.value.toGeometry());
- a.geometry.intersects(c) && (b = !0)
- }
- break;
- default:
- throw Error("evaluate is not implemented for this filter type.");
- }
- return b
- },
- clone: function() {
- var a =
- GeoGlobe.Util.applyDefaults({
- value: this.value && this.value.clone && this.value.clone()
- }, this);
- return new GeoGlobe.Filter.Spatial(a)
- },
- CLASS_NAME: "GeoGlobe.Filter.Spatial"
- });
- GeoGlobe.Filter.Spatial.BBOX = "BBOX";
- GeoGlobe.Filter.Spatial.INTERSECTS = "INTERSECTS";
- GeoGlobe.Filter.Spatial.DWITHIN = "DWITHIN";
- GeoGlobe.Filter.Spatial.WITHIN = "WITHIN";
- GeoGlobe.Filter.Spatial.CONTAINS = "CONTAINS";
- GeoGlobe.Filter.Function = GeoGlobe.Class4OL(GeoGlobe.Filter, {
- name: null,
- params: null,
- CLASS_NAME: "GeoGlobe.Filter.Function"
- });
- GeoGlobe.Protocol = GeoGlobe.Class4OL({
- format: null,
- options: null,
- autoDestroy: !0,
- defaultFilter: null,
- initialize: function(a) {
- a = a || {};
- GeoGlobe.Util.extend(this, a);
- this.options = a
- },
- mergeWithDefaultFilter: function(a) {
- return a && this.defaultFilter ? new GeoGlobe.Filter.Logical({
- type: GeoGlobe.Filter.Logical.AND,
- filters: [this.defaultFilter, a]
- }) : a || this.defaultFilter || void 0
- },
- destroy: function() {
- this.format = this.options = null
- },
- read: function(a) {
- a = a || {};
- a.filter = this.mergeWithDefaultFilter(a.filter)
- },
- create: function() {},
- update: function() {},
- "delete": function() {},
- commit: function() {},
- abort: function() {},
- createCallback: function(a, b, c) {
- return GeoGlobe.Function.bind(function() {
- a.apply(this, [b, c])
- }, this)
- },
- CLASS_NAME: "GeoGlobe.Protocol"
- });
- GeoGlobe.Protocol.Response = GeoGlobe.Class4OL({
- code: null,
- requestType: null,
- last: !0,
- features: null,
- data: null,
- reqFeatures: null,
- priv: null,
- error: null,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- success: function() {
- return this.code > 0
- },
- CLASS_NAME: "GeoGlobe.Protocol.Response"
- });
- GeoGlobe.Protocol.Response.SUCCESS = 1;
- GeoGlobe.Protocol.Response.FAILURE = 0;
- GeoGlobe.Protocol.HTTP = GeoGlobe.Class4OL(GeoGlobe.Protocol, {
- url: null,
- headers: null,
- params: null,
- callback: null,
- scope: null,
- readWithPOST: !1,
- updateWithPOST: !1,
- deleteWithPOST: !1,
- wildcarded: !1,
- srsInBBOX: !1,
- initialize: function() {
- this.params = {};
- this.headers = {};
- GeoGlobe.Protocol.prototype.initialize.apply(this, arguments);
- if (!this.filterToParams && GeoGlobe.Format.QueryStringFilter) {
- var a = new GeoGlobe.Format.QueryStringFilter({
- wildcarded: this.wildcarded,
- srsInBBOX: this.srsInBBOX
- });
- this.filterToParams = function(b,
- c) {
- return a.write(b, c)
- }
- }
- },
- destroy: function() {
- this.headers = this.params = null;
- GeoGlobe.Protocol.prototype.destroy.apply(this)
- },
- read: function(a) {
- GeoGlobe.Protocol.prototype.read.apply(this, arguments);
- a = a || {};
- a.params = GeoGlobe.Util.applyDefaults(a.params, this.options.params);
- a = GeoGlobe.Util.applyDefaults(a, this.options);
- if (a.filter && this.filterToParams) a.params = this.filterToParams(a.filter, a.params);
- var b = a.readWithPOST !== void 0 ? a.readWithPOST : this.readWithPOST,
- c = new GeoGlobe.Protocol.Response({
- requestType: "read"
- });
- b ? (b = a.headers || {}, b["Content-Type"] = "application/x-www-form-urlencoded", c.priv = GeoGlobe.Request.POST({
- url: a.url,
- callback: this.createCallback(this.handleRead, c, a),
- data: GeoGlobe.Util.getParameterString(a.params, !0),
- headers: b
- })) : c.priv = GeoGlobe.Request.GET({
- url: a.url,
- callback: this.createCallback(this.handleRead, c, a),
- params: a.params,
- headers: a.headers
- });
- return c
- },
- handleRead: function(a, b) {
- this.handleResponse(a, b)
- },
- create: function(a, b) {
- var b = GeoGlobe.Util.applyDefaults(b, this.options),
- c = new GeoGlobe.Protocol.Response({
- reqFeatures: a,
- requestType: "create"
- });
- c.priv = GeoGlobe.Request.POST({
- url: b.url,
- callback: this.createCallback(this.handleCreate, c, b),
- headers: b.headers,
- data: this.format.write(a)
- });
- return c
- },
- handleCreate: function(a, b) {
- this.handleResponse(a, b)
- },
- update: function(a, b) {
- var b = b || {},
- c = b.url || a.url || this.options.url + "/" + a.fid,
- b = GeoGlobe.Util.applyDefaults(b, this.options),
- d = new GeoGlobe.Protocol.Response({
- reqFeatures: a,
- requestType: "update"
- });
- d.priv = GeoGlobe.Request[this.updateWithPOST ? "POST" : "PUT"]({
- url: c,
- callback: this.createCallback(this.handleUpdate,
- d, b),
- headers: b.headers,
- data: this.format.write(a)
- });
- return d
- },
- handleUpdate: function(a, b) {
- this.handleResponse(a, b)
- },
- "delete": function(a, b) {
- var b = b || {},
- c = b.url || a.url || this.options.url + "/" + a.fid,
- b = GeoGlobe.Util.applyDefaults(b, this.options),
- d = new GeoGlobe.Protocol.Response({
- reqFeatures: a,
- requestType: "delete"
- }),
- e = this.deleteWithPOST ? "POST" : "DELETE",
- c = {
- url: c,
- callback: this.createCallback(this.handleDelete, d, b),
- headers: b.headers
- };
- if (this.deleteWithPOST) c.data = this.format.write(a);
- d.priv = GeoGlobe.Request[e](c);
- return d
- },
- handleDelete: function(a, b) {
- this.handleResponse(a, b)
- },
- handleResponse: function(a, b) {
- var c = a.priv;
- if (b.callback) {
- if (c.status >= 200 && c.status < 300) {
- if (a.requestType != "delete") a.features = this.parseFeatures(c);
- a.code = GeoGlobe.Protocol.Response.SUCCESS
- } else a.code = GeoGlobe.Protocol.Response.FAILURE;
- b.callback.call(b.scope, a)
- }
- },
- parseFeatures: function(a) {
- var b = a.responseXML;
- if (!b || !b.documentElement) b = a.responseText;
- if (!b || b.length <= 0) return null;
- return this.format.read(b)
- },
- commit: function(a, b) {
- function c(a) {
- for (var b =
- a.features ? a.features.length : 0, c = Array(b), e = 0; e < b; ++e) c[e] = a.features[e].fid;
- o.insertIds = c;
- d.apply(this, [a])
- }
- function d(a) {
- this.callUserCallback(a, b);
- q = q && a.success();
- f++;
- if (f >= p && b.callback) o.code = q ? GeoGlobe.Protocol.Response.SUCCESS : GeoGlobe.Protocol.Response.FAILURE, b.callback.apply(b.scope, [o])
- }
- var b = GeoGlobe.Util.applyDefaults(b, this.options),
- e = [],
- f = 0,
- g = {};
- g[GeoGlobe.State.INSERT] = [];
- g[GeoGlobe.State.UPDATE] = [];
- g[GeoGlobe.State.DELETE] = [];
- for (var h, j, l = [], m = 0, n = a.length; m < n; ++m)
- if (h = a[m], j = g[h.state]) j.push(h),
- l.push(h);
- var p = (g[GeoGlobe.State.INSERT].length > 0 ? 1 : 0) + g[GeoGlobe.State.UPDATE].length + g[GeoGlobe.State.DELETE].length,
- q = !0,
- o = new GeoGlobe.Protocol.Response({
- reqFeatures: l
- });
- h = g[GeoGlobe.State.INSERT];
- h.length > 0 && e.push(this.create(h, GeoGlobe.Util.applyDefaults({
- callback: c,
- scope: this
- }, b.create)));
- h = g[GeoGlobe.State.UPDATE];
- for (m = h.length - 1; m >= 0; --m) e.push(this.update(h[m], GeoGlobe.Util.applyDefaults({
- callback: d,
- scope: this
- }, b.update)));
- h = g[GeoGlobe.State.DELETE];
- for (m = h.length - 1; m >= 0; --m) e.push(this["delete"](h[m],
- GeoGlobe.Util.applyDefaults({
- callback: d,
- scope: this
- }, b["delete"])));
- return e
- },
- abort: function(a) {
- a && a.priv.abort()
- },
- callUserCallback: function(a, b) {
- var c = b[a.requestType];
- c && c.callback && c.callback.call(c.scope, a)
- },
- CLASS_NAME: "GeoGlobe.Protocol.HTTP"
- });
- GeoGlobe.Protocol.WFS = function(a) {
- var a = GeoGlobe.Util.applyDefaults(a, GeoGlobe.Protocol.WFS.DEFAULTS),
- b = GeoGlobe.Protocol.WFS["v" + a.version.replace(/\./g, "_")];
- if (!b) throw "Unsupported WFS version: " + a.version;
- return new b(a)
- };
- GeoGlobe.Protocol.WFS.DEFAULTS = {
- version: "1.0.0"
- };
- GeoGlobe.Protocol.WFS.v1 = GeoGlobe.Class4OL(GeoGlobe.Protocol, {
- version: null,
- srsName: "EPSG:4326",
- featureType: null,
- featureNS: null,
- geometryName: "the_geom",
- schema: null,
- featurePrefix: "feature",
- formatOptions: null,
- readFormat: null,
- readOptions: null,
- initialize: function(a) {
- GeoGlobe.Protocol.prototype.initialize.apply(this, [a]);
- if (!a.format) this.format = GeoGlobe.Format.WFST(GeoGlobe.Util.extend({
- version: this.version,
- featureType: this.featureType,
- featureNS: this.featureNS,
- featurePrefix: this.featurePrefix,
- geometryName: this.geometryName,
- srsName: this.srsName,
- schema: this.schema
- }, this.formatOptions));
- !a.geometryName && parseFloat(this.format.version) > 1 && this.setGeometryName(null)
- },
- destroy: function() {
- this.options && !this.options.format && this.format.destroy();
- this.format = null;
- GeoGlobe.Protocol.prototype.destroy.apply(this)
- },
- read: function(a) {
- GeoGlobe.Protocol.prototype.read.apply(this, arguments);
- a = GeoGlobe.Util.extend({}, a);
- GeoGlobe.Util.applyDefaults(a, this.options || {});
- var b = new GeoGlobe.Protocol.Response({
- requestType: "read"
- }),
- c = GeoGlobe.Format.XML.prototype.write.apply(this.format, [this.format.writeNode("wfs:GetFeature", a)]);
- b.priv = GeoGlobe.Request.POST({
- url: a.url,
- callback: this.createCallback(this.handleRead, b, a),
- params: a.params,
- headers: a.headers,
- data: c
- });
- return b
- },
- setFeatureType: function(a) {
- this.featureType = a;
- this.format.featureType = a
- },
- setGeometryName: function(a) {
- this.geometryName = a;
- this.format.geometryName = a
- },
- handleRead: function(a, b) {
- b = GeoGlobe.Util.extend({}, b);
- GeoGlobe.Util.applyDefaults(b, this.options);
- if (b.callback) {
- var c = a.priv;
- c.status >= 200 && c.status < 300 ? (c = this.parseResponse(c,
- b.readOptions)) && c.success !== !1 ? (b.readOptions && b.readOptions.output == "object" ? GeoGlobe.Util.extend(a, c) : a.features = c, a.code = GeoGlobe.Protocol.Response.SUCCESS) : (a.code = GeoGlobe.Protocol.Response.FAILURE, a.error = c) : a.code = GeoGlobe.Protocol.Response.FAILURE;
- b.callback.call(b.scope, a)
- }
- },
- parseResponse: function(a, b) {
- var c = a.responseXML;
- if (!c || !c.documentElement) c = a.responseText;
- if (!c || c.length <= 0) return null;
- var d = null;
- try {
- d = this.readFormat !== null ? this.readFormat.read(c) : this.format.read(c, b)
- } catch (e) {
- alert("\u7a0b\u5e8f\u8fd0\u884c\u5f02\u5e38\uff1a" +
- e.name + "\uff0c" + e.message)
- }
- if (!this.featureNS) c = this.readFormat || this.format, this.featureNS = c.featureNS, c.autoConfig = !1, this.geometryName || this.setGeometryName(c.geometryName);
- return d
- },
- commit: function(a, b) {
- b = GeoGlobe.Util.extend({}, b);
- GeoGlobe.Util.applyDefaults(b, this.options);
- var c = new GeoGlobe.Protocol.Response({
- requestType: "commit",
- reqFeatures: a
- });
- c.priv = GeoGlobe.Request.POST({
- url: b.url,
- headers: b.headers,
- data: this.format.write(a, b),
- callback: this.createCallback(this.handleCommit, c, b)
- });
- return c
- },
- handleCommit: function(a, b) {
- if (b.callback) {
- var c = a.priv,
- d = c.responseXML;
- if (!d || !d.documentElement) d = c.responseText;
- c = this.format.read(d) || {};
- a.insertIds = c.insertIds || [];
- c.success ? a.code = GeoGlobe.Protocol.Response.SUCCESS : (a.code = GeoGlobe.Protocol.Response.FAILURE, a.error = c);
- b.callback.call(b.scope, a)
- }
- },
- filterDelete: function(a, b) {
- b = GeoGlobe.Util.extend({}, b);
- GeoGlobe.Util.applyDefaults(b, this.options);
- new GeoGlobe.Protocol.Response({
- requestType: "commit"
- });
- var c = this.format.createElementNSPlus("wfs:Transaction", {
- attributes: {
- service: "WFS",
- version: this.version
- }
- }),
- d = this.format.createElementNSPlus("wfs:Delete", {
- attributes: {
- typeName: (b.featureNS ? this.featurePrefix + ":" : "") + b.featureType
- }
- });
- b.featureNS && d.setAttribute("xmlns:" + this.featurePrefix, b.featureNS);
- var e = this.format.writeNode("ogc:Filter", a);
- d.appendChild(e);
- c.appendChild(d);
- c = GeoGlobe.Format.XML.prototype.write.apply(this.format, [c]);
- return GeoGlobe.Request.POST({
- url: this.url,
- callback: b.callback || function() {},
- data: c
- })
- },
- abort: function(a) {
- a && a.priv.abort()
- },
- CLASS_NAME: "GeoGlobe.Protocol.WFS.v1"
- });
- GeoGlobe.Protocol.WFS.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Protocol.WFS.v1, {
- version: "1.0.0",
- CLASS_NAME: "GeoGlobe.Protocol.WFS.v1_0_0"
- });
- GeoGlobe.Protocol.WFS.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Protocol.WFS.v1, {
- version: "1.1.0",
- initialize: function() {
- GeoGlobe.Protocol.WFS.v1.prototype.initialize.apply(this, arguments);
- if (this.outputFormat && !this.readFormat)
- if (this.outputFormat.toLowerCase() == "gml2") this.readFormat = new GeoGlobe.Format.GML.v2({
- featureType: this.featureType,
- featureNS: this.featureNS,
- geometryName: this.geometryName
- });
- else if (this.outputFormat.toLowerCase() == "json") this.readFormat = new GeoGlobe.Format.GeoJSON
- },
- CLASS_NAME: "GeoGlobe.Protocol.WFS.v1_1_0"
- });
- GeoGlobe.Protocol.CSW = function(a) {
- var a = GeoGlobe.Util.applyDefaults(a, GeoGlobe.Protocol.CSW.DEFAULTS),
- b = GeoGlobe.Protocol.CSW["v" + a.version.replace(/\./g, "_")];
- if (!b) throw "Unsupported CSW version: " + a.version;
- return new b(a)
- };
- GeoGlobe.Protocol.CSW.DEFAULTS = {
- version: "2.0.2"
- };
- GeoGlobe.Protocol.CSW.v2_0_2 = GeoGlobe.Class4OL(GeoGlobe.Protocol, {
- formatOptions: null,
- initialize: function(a) {
- GeoGlobe.Protocol.prototype.initialize.apply(this, [a]);
- if (!a.format) this.format = new GeoGlobe.Format.CSWGetRecords.v2_0_2(GeoGlobe.Util.extend({}, this.formatOptions))
- },
- destroy: function() {
- this.options && !this.options.format && this.format.destroy();
- this.format = null;
- GeoGlobe.Protocol.prototype.destroy.apply(this)
- },
- read: function(a) {
- a = GeoGlobe.Util.extend({}, a);
- GeoGlobe.Util.applyDefaults(a, this.options || {});
- var b = new GeoGlobe.Protocol.Response({
- requestType: "read"
- }),
- c = this.format.write(a.params || a);
- b.priv = GeoGlobe.Request.POST({
- url: a.url,
- callback: this.createCallback(this.handleRead, b, a),
- params: a.params,
- headers: a.headers,
- data: c
- });
- return b
- },
- handleRead: function(a, b) {
- if (b.callback) {
- var c = a.priv;
- c.status >= 200 && c.status < 300 ? (a.data = this.parseData(c), a.code = GeoGlobe.Protocol.Response.SUCCESS) : a.code = GeoGlobe.Protocol.Response.FAILURE;
- b.callback.call(b.scope, a)
- }
- },
- parseData: function(a) {
- var b = a.responseXML;
- if (!b || !b.documentElement) b = a.responseText;
- if (!b || b.length <= 0) return null;
- return this.format.read(b)
- },
- CLASS_NAME: "GeoGlobe.Protocol.CSW.v2_0_2"
- });
- GeoGlobe.Protocol.Script = GeoGlobe.Class4OL(GeoGlobe.Protocol, {
- url: null,
- params: null,
- callback: null,
- callbackTemplate: "GeoGlobe.Protocol.Script.registry.${id}",
- callbackKey: "callback",
- callbackPrefix: "",
- scope: null,
- format: null,
- pendingRequests: null,
- srsInBBOX: !1,
- initialize: function() {
- this.params = {};
- this.pendingRequests = {};
- GeoGlobe.Protocol.prototype.initialize.apply(this, arguments);
- if (!this.format) this.format = new GeoGlobe.Format.GeoJSON;
- if (!this.filterToParams && GeoGlobe.Format.QueryStringFilter) {
- var a = new GeoGlobe.Format.QueryStringFilter({
- srsInBBOX: this.srsInBBOX
- });
- this.filterToParams = function(b, c) {
- return a.write(b, c)
- }
- }
- },
- read: function(a) {
- GeoGlobe.Protocol.prototype.read.apply(this, arguments);
- a = GeoGlobe.Util.applyDefaults(a, this.options);
- a.params = GeoGlobe.Util.applyDefaults(a.params, this.options.params);
- if (a.filter && this.filterToParams) a.params = this.filterToParams(a.filter, a.params);
- var b = new GeoGlobe.Protocol.Response({
- requestType: "read"
- }),
- c = this.createRequest(a.url, a.params, GeoGlobe.Function.bind(function(c) {
- b.data = c;
- this.handleRead(b, a)
- }, this));
- b.priv = c;
- return b
- },
- createRequest: function(a, b, c) {
- var c = GeoGlobe.Protocol.Script.register(c),
- d = GeoGlobe.String.format(this.callbackTemplate, {
- id: c
- }),
- b = GeoGlobe.Util.extend({}, b);
- b[this.callbackKey] = this.callbackPrefix + d;
- a = GeoGlobe.Util.urlAppend(a, GeoGlobe.Util.getParameterString(b, !0));
- b = document.createElement("script");
- b.type = "text/javascript";
- b.src = a;
- b.id = "GeoGlobe_Protocol_Script_" + c;
- this.pendingRequests[b.id] = b;
- document.getElementsByTagName("head")[0].appendChild(b);
- return b
- },
- destroyRequest: function(a) {
- GeoGlobe.Protocol.Script.unregister(a.id.split("_").pop());
- delete this.pendingRequests[a.id];
- a.parentNode && a.parentNode.removeChild(a)
- },
- handleRead: function(a, b) {
- this.handleResponse(a, b)
- },
- handleResponse: function(a, b) {
- if (b.callback) a.data ? (a.features = this.parseFeatures(a.data), a.code = GeoGlobe.Protocol.Response.SUCCESS) : a.code = GeoGlobe.Protocol.Response.FAILURE, this.destroyRequest(a.priv), b.callback.call(b.scope, a)
- },
- parseFeatures: function(a) {
- return this.format.read(a)
- },
- abort: function(a) {
- if (a) this.destroyRequest(a.priv);
- else
- for (var b in this.pendingRequests) this.destroyRequest(this.pendingRequests[b])
- },
- destroy: function() {
- this.abort();
- delete this.params;
- delete this.format;
- GeoGlobe.Protocol.prototype.destroy.apply(this)
- },
- CLASS_NAME: "GeoGlobe.Protocol.Script"
- });
- (function() {
- var a = GeoGlobe.Protocol.Script,
- b = 0;
- a.registry = {};
- a.register = function(c) {
- var d = "c" + ++b;
- a.registry[d] = function() {
- c.apply(this, arguments)
- };
- return d
- };
- a.unregister = function(b) {
- delete a.registry[b]
- }
- })();
- GeoGlobe.Format = GeoGlobe.Class4OL({
- options: null,
- externalProjection: null,
- internalProjection: null,
- data: null,
- keepData: !1,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a);
- this.options = a
- },
- destroy: function() {},
- read: function() {
- throw Error("Read not implemented.");
- },
- write: function() {
- throw Error("Write not implemented.");
- },
- CLASS_NAME: "GeoGlobe.Format"
- });
- GeoGlobe.Format.XML = GeoGlobe.Class4OL(GeoGlobe.Format, {
- namespaces: null,
- namespaceAlias: null,
- defaultPrefix: null,
- readers: {},
- writers: {},
- xmldom: null,
- initialize: function(a) {
- if (window.ActiveXObject) this.xmldom = new ActiveXObject("Microsoft.XMLDOM");
- GeoGlobe.Format.prototype.initialize.apply(this, [a]);
- this.namespaces = GeoGlobe.Util.extend({}, this.namespaces);
- this.namespaceAlias = {};
- for (var b in this.namespaces) this.namespaceAlias[this.namespaces[b]] = b
- },
- destroy: function() {
- this.xmldom = null;
- GeoGlobe.Format.prototype.destroy.apply(this,
- arguments)
- },
- setNamespace: function(a, b) {
- this.namespaces[a] = b;
- this.namespaceAlias[b] = a
- },
- read: function(a) {
- var b = a.indexOf("<");
- b > 0 && (a = a.substring(b));
- b = GeoGlobe.Util.Try(GeoGlobe.Function.bind(function() {
- var b;
- b = window.ActiveXObject && !this.xmldom ? new ActiveXObject("Microsoft.XMLDOM") : this.xmldom;
- b.loadXML(a);
- return b
- }, this), function() {
- return (new DOMParser).parseFromString(a, "text/xml")
- }, function() {
- var b = new XMLHttpRequest;
- b.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(a), !1);
- b.overrideMimeType &&
- b.overrideMimeType("text/xml");
- b.send(null);
- return b.responseXML
- });
- if (this.keepData) this.data = b;
- return b
- },
- write: function(a) {
- if (a.xml) a = a.xml;
- else {
- var b = new XMLSerializer;
- if (a.nodeType == 1) {
- var c = document.implementation.createDocument("", "", null);
- c.importNode && (a = c.importNode(a, !0));
- c.appendChild(a);
- a = b.serializeToString(c)
- } else a = b.serializeToString(a)
- }
- return a
- },
- createElementNS: function(a, b) {
- return this.xmldom ? typeof a == "string" ? this.xmldom.createNode(1, b, a) : this.xmldom.createNode(1, b, "") : document.createElementNS(a,
- b)
- },
- createDocumentFragment: function() {
- return this.xmldom ? this.xmldom.createDocumentFragment() : document.createDocumentFragment()
- },
- createTextNode: function(a) {
- typeof a !== "string" && (a = String(a));
- return this.xmldom ? this.xmldom.createTextNode(a) : document.createTextNode(a)
- },
- getElementsByTagNameNS: function(a, b, c) {
- var d = [];
- if (a.getElementsByTagNameNS) d = a.getElementsByTagNameNS(b, c);
- else
- for (var a = a.getElementsByTagName("*"), e, f, g = 0, h = a.length; g < h; ++g)
- if (e = a[g], f = e.prefix ? e.prefix + ":" + c : c, c == "*" || f == e.nodeName)(b ==
- "*" || b == e.namespaceURI) && d.push(e);
- return d
- },
- getAttributeNodeNS: function(a, b, c) {
- var d = null;
- if (a.getAttributeNodeNS) d = a.getAttributeNodeNS(b, c);
- else
- for (var a = a.attributes, e, f, g = 0, h = a.length; g < h; ++g)
- if (e = a[g], e.namespaceURI == b && (f = e.prefix ? e.prefix + ":" + c : c, f == e.nodeName)) {
- d = e;
- break
- } return d
- },
- getAttributeNS: function(a, b, c) {
- var d = "";
- if (a.getAttributeNS) d = a.getAttributeNS(b, c) || "";
- else if (a = this.getAttributeNodeNS(a, b, c)) d = a.nodeValue;
- return d
- },
- getChildValue: function(a, b) {
- var c = b || "";
- if (a)
- for (var d = a.firstChild; d; d =
- d.nextSibling) switch (d.nodeType) {
- case 3:
- case 4:
- c += d.nodeValue
- }
- return c
- },
- isSimpleContent: function(a) {
- for (var b = !0, a = a.firstChild; a; a = a.nextSibling)
- if (a.nodeType === 1) {
- b = !1;
- break
- }
- return b
- },
- contentType: function(a) {
- for (var b = !1, c = !1, d = GeoGlobe.Format.XML.CONTENT_TYPE.EMPTY, a = a.firstChild; a; a = a.nextSibling) {
- switch (a.nodeType) {
- case 1:
- c = !0;
- break;
- case 8:
- break;
- default:
- b = !0
- }
- if (c && b) break
- }
- if (c && b) d = GeoGlobe.Format.XML.CONTENT_TYPE.MIXED;
- else if (c) return GeoGlobe.Format.XML.CONTENT_TYPE.COMPLEX;
- else if (b) return GeoGlobe.Format.XML.CONTENT_TYPE.SIMPLE;
- return d
- },
- hasAttributeNS: function(a, b, c) {
- var d = !1;
- return d = a.hasAttributeNS ? a.hasAttributeNS(b, c) : !!this.getAttributeNodeNS(a, b, c)
- },
- setAttributeNS: function(a, b, c, d) {
- if (a.setAttributeNS) a.setAttributeNS(b, c, d);
- else if (this.xmldom) b ? (b = a.ownerDocument.createNode(2, c, b), b.nodeValue = d, a.setAttributeNode(b)) : a.setAttribute(c, d);
- else throw "setAttributeNS not implemented";
- },
- createElementNSPlus: function(a, b) {
- var b = b || {},
- c = b.uri || this.namespaces[b.prefix];
- c || (c = a.indexOf(":"), c = this.namespaces[a.substring(0,
- c)]);
- c || (c = this.namespaces[this.defaultPrefix]);
- c = this.createElementNS(c, a);
- b.attributes && this.setAttributes(c, b.attributes);
- var d = b.value;
- d != null && c.appendChild(this.createTextNode(d));
- return c
- },
- setAttributes: function(a, b) {
- var c, d, e;
- for (e in b) b[e] != null && b[e].toString && (c = b[e].toString(), d = this.namespaces[e.substring(0, e.indexOf(":"))] || null, this.setAttributeNS(a, d, e, c))
- },
- readNode: function(a, b) {
- b || (b = {});
- var c = this.readers[a.namespaceURI ? this.namespaceAlias[a.namespaceURI] : this.defaultPrefix];
- if (c) {
- var d =
- a.localName || a.nodeName.split(":").pop();
- (c = c[d] || c["*"]) && c.apply(this, [a, b])
- }
- return b
- },
- readChildNodes: function(a, b) {
- b || (b = {});
- for (var c = a.childNodes, d, e = 0, f = c.length; e < f; ++e) d = c[e], d.nodeType == 1 && this.readNode(d, b);
- return b
- },
- writeNode: function(a, b, c) {
- var d, e = a.indexOf(":");
- e > 0 ? (d = a.substring(0, e), a = a.substring(e + 1)) : d = c ? this.namespaceAlias[c.namespaceURI] : this.defaultPrefix;
- b = this.writers[d][a].apply(this, [b]);
- c && c.appendChild(b);
- return b
- },
- getChildEl: function(a, b, c) {
- return a && this.getThisOrNextEl(a.firstChild,
- b, c)
- },
- getNextEl: function(a, b, c) {
- return a && this.getThisOrNextEl(a.nextSibling, b, c)
- },
- getThisOrNextEl: function(a, b, c) {
- a: for (; a; a = a.nextSibling) switch (a.nodeType) {
- case 1:
- if ((!b || b === (a.localName || a.nodeName.split(":").pop())) && (!c || c === a.namespaceURI)) break a;
- a = null;
- break a;
- case 3:
- if (/^\s*$/.test(a.nodeValue)) break;
- case 4:
- case 6:
- case 12:
- case 10:
- case 11:
- a = null;
- break a
- }
- return a || null
- },
- lookupNamespaceURI: function(a, b) {
- var c = null;
- if (a)
- if (a.lookupNamespaceURI) c = a.lookupNamespaceURI(b);
- else a: switch (a.nodeType) {
- case 1:
- if (a.namespaceURI !==
- null && a.prefix === b) {
- c = a.namespaceURI;
- break a
- }
- if (c = a.attributes.length)
- for (var d, e = 0; e < c; ++e)
- if (d = a.attributes[e], d.prefix === "xmlns" && d.name === "xmlns:" + b) {
- c = d.value || null;
- break a
- } else if (d.name === "xmlns" && b === null) {
- c = d.value || null;
- break a
- }
- c = this.lookupNamespaceURI(a.parentNode, b);
- break a;
- case 2:
- c = this.lookupNamespaceURI(a.ownerElement, b);
- break a;
- case 9:
- c = this.lookupNamespaceURI(a.documentElement, b);
- break a;
- case 6:
- case 12:
- case 10:
- case 11:
- break a;
- default:
- c = this.lookupNamespaceURI(a.parentNode, b)
- }
- return c
- },
- getXMLDoc: function() {
- if (!GeoGlobe.Format.XML.document && !this.xmldom)
- if (document.implementation && document.implementation.createDocument) GeoGlobe.Format.XML.document = document.implementation.createDocument("", "", null);
- else if (!this.xmldom && window.ActiveXObject) this.xmldom = new ActiveXObject("Microsoft.XMLDOM");
- return GeoGlobe.Format.XML.document || this.xmldom
- },
- CLASS_NAME: "GeoGlobe.Format.XML"
- });
- GeoGlobe.Format.XML.CONTENT_TYPE = {
- EMPTY: 0,
- SIMPLE: 1,
- COMPLEX: 2,
- MIXED: 3
- };
- GeoGlobe.Format.XML.lookupNamespaceURI = GeoGlobe.Function.bind(GeoGlobe.Format.XML.prototype.lookupNamespaceURI, GeoGlobe.Format.XML.prototype);
- GeoGlobe.Format.XML.document = null;
- GeoGlobe.Format.XML.VersionedOGC = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- defaultVersion: null,
- version: null,
- profile: null,
- allowFallback: !1,
- name: null,
- stringifyOutput: !1,
- parser: null,
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a]);
- a = this.CLASS_NAME;
- this.name = a.substring(a.lastIndexOf(".") + 1)
- },
- getVersion: function(a, b) {
- var c;
- if (a) {
- if (c = this.version, !c && (c = a.getAttribute("version"), !c)) c = this.defaultVersion
- } else c = b && b.version || this.version || this.defaultVersion;
- return c
- },
- getParser: function(a) {
- var a =
- a || this.defaultVersion,
- b = this.profile ? "_" + this.profile : "";
- if (!this.parser || this.parser.VERSION != a) {
- var c = GeoGlobe.Format[this.name]["v" + a.replace(/\./g, "_") + b];
- if (!c && (b !== "" && this.allowFallback && (b = "", c = GeoGlobe.Format[this.name]["v" + a.replace(/\./g, "_")]), !c)) throw "Can't find a " + this.name + " parser for version " + a + b;
- this.parser = new c(this.options)
- }
- return this.parser
- },
- write: function(a, b) {
- this.parser = this.getParser(this.getVersion(null, b));
- var c = this.parser.write(a, b);
- return this.stringifyOutput ===
- !1 ? c : GeoGlobe.Format.XML.prototype.write.apply(this, [c])
- },
- read: function(a, b) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- var c = this.getVersion(a.documentElement);
- this.parser = this.getParser(c);
- var d = this.parser.read(a, b),
- e = this.parser.errorProperty || null;
- if (e !== null && d[e] === void 0) e = new GeoGlobe.Format.OGCExceptionReport, d.error = e.read(a);
- d.version = c;
- return d
- },
- CLASS_NAME: "GeoGlobe.Format.XML.VersionedOGC"
- });
- GeoGlobe.Format.GML = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- featureNS: "http://mapserver.gis.umn.edu/mapserver",
- featurePrefix: "feature",
- featureName: "featureMember",
- layerName: "features",
- geometryName: "geometry",
- collectionName: "FeatureCollection",
- gmlns: "http://www.opengis.net/gml",
- extractAttributes: !0,
- xy: !0,
- initialize: function(a) {
- this.regExes = {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- };
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- typeof a ==
- "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- for (var a = this.getElementsByTagNameNS(a.documentElement, this.gmlns, this.featureName), b = [], c = 0; c < a.length; c++) {
- var d = this.parseFeature(a[c]);
- d && b.push(d)
- }
- return b
- },
- parseFeature: function(a) {
- for (var b = ["MultiPolygon", "Polygon", "MultiLineString", "LineString", "MultiPoint", "Point", "Envelope"], c, d, e, f = 0; f < b.length; ++f)
- if (c = b[f], d = this.getElementsByTagNameNS(a, this.gmlns, c), d.length > 0) {
- if (e = this.parseGeometry[c.toLowerCase()]) e = e.apply(this, [d[0]]), this.internalProjection && this.externalProjection && e.transform(this.externalProjection, this.internalProjection);
- else throw new TypeError("Unsupported geometry type: " + c);
- break
- }
- var g;
- c = this.getElementsByTagNameNS(a, this.gmlns, "Box");
- for (f = 0; f < c.length; ++f) b = c[f], d = this.parseGeometry.box.apply(this, [b]), b = b.parentNode, (b.localName || b.nodeName.split(":").pop()) === "boundedBy" ? g = d : e = d.toGeometry();
- var h;
- this.extractAttributes && (h = this.parseAttributes(a));
- h = new GeoGlobe.Feature(e, h);
- h.bounds = g;
- h.gml = {
- featureType: a.firstChild.nodeName.split(":")[1],
- featureNS: a.firstChild.namespaceURI,
- featureNSPrefix: a.firstChild.prefix
- };
- for (var a = a.firstChild, j; a;) {
- if (a.nodeType == 1 && (j = a.getAttribute("fid") || a.getAttribute("id"))) break;
- a = a.nextSibling
- }
- h.fid = j;
- return h
- },
- parseGeometry: {
- point: function(a) {
- var b, c;
- c = [];
- b = this.getElementsByTagNameNS(a, this.gmlns, "pos");
- if (b.length > 0) c = b[0].firstChild.nodeValue, c = c.replace(this.regExes.trimSpace, ""), c = c.split(this.regExes.splitSpace);
- if (c.length == 0 && (b = this.getElementsByTagNameNS(a,
- this.gmlns, "coordinates"), b.length > 0)) c = b[0].firstChild.nodeValue, c = c.replace(this.regExes.removeSpace, ""), c = c.split(",");
- c.length == 0 && (b = this.getElementsByTagNameNS(a, this.gmlns, "coord"), b.length > 0 && (a = this.getElementsByTagNameNS(b[0], this.gmlns, "X"), b = this.getElementsByTagNameNS(b[0], this.gmlns, "Y"), a.length > 0 && b.length > 0 && (c = [a[0].firstChild.nodeValue, b[0].firstChild.nodeValue])));
- c.length == 2 && (c[2] = null);
- return this.xy ? new GeoGlobe.Geometry.Point(c[0], c[1], c[2]) : new GeoGlobe.Geometry.Point(c[1],
- c[0], c[2])
- },
- multipoint: function(a) {
- var a = this.getElementsByTagNameNS(a, this.gmlns, "Point"),
- b = [];
- if (a.length > 0)
- for (var c, d = 0; d < a.length; ++d)(c = this.parseGeometry.point.apply(this, [a[d]])) && b.push(c);
- return new GeoGlobe.Geometry.MultiPoint(b)
- },
- linestring: function(a, b) {
- var c, d;
- d = [];
- var e = [];
- c = this.getElementsByTagNameNS(a, this.gmlns, "posList");
- if (c.length > 0) {
- d = this.getChildValue(c[0]);
- d = d.replace(this.regExes.trimSpace, "");
- d = d.split(this.regExes.splitSpace);
- var f = parseInt(c[0].getAttribute("dimension")),
- g, h, j;
- for (c = 0; c < d.length / f; ++c) g = c * f, h = d[g], j = d[g + 1], g = f == 2 ? null : d[g + 2], this.xy ? e.push(new GeoGlobe.Geometry.Point(h, j, g)) : e.push(new GeoGlobe.Geometry.Point(j, h, g))
- }
- if (d.length == 0 && (c = this.getElementsByTagNameNS(a, this.gmlns, "coordinates"), c.length > 0)) {
- d = this.getChildValue(c[0]);
- d = d.replace(this.regExes.trimSpace, "");
- d = d.replace(this.regExes.trimComma, ",");
- f = d.split(this.regExes.splitSpace);
- for (c = 0; c < f.length; ++c) d = f[c].split(","), d.length == 2 && (d[2] = null), this.xy ? e.push(new GeoGlobe.Geometry.Point(d[0],
- d[1], d[2])) : e.push(new GeoGlobe.Geometry.Point(d[1], d[0], d[2]))
- }
- d = null;
- e.length != 0 && (d = b ? new GeoGlobe.Geometry.LinearRing(e) : new GeoGlobe.Geometry.LineString(e));
- return d
- },
- multilinestring: function(a) {
- var a = this.getElementsByTagNameNS(a, this.gmlns, "LineString"),
- b = [];
- if (a.length > 0)
- for (var c, d = 0; d < a.length; ++d)(c = this.parseGeometry.linestring.apply(this, [a[d]])) && b.push(c);
- return new GeoGlobe.Geometry.MultiLineString(b)
- },
- polygon: function(a) {
- var a = this.getElementsByTagNameNS(a, this.gmlns, "LinearRing"),
- b = [];
- if (a.length > 0)
- for (var c, d = 0; d < a.length; ++d)(c = this.parseGeometry.linestring.apply(this, [a[d], !0])) && b.push(c);
- return new GeoGlobe.Geometry.Polygon(b)
- },
- multipolygon: function(a) {
- var a = this.getElementsByTagNameNS(a, this.gmlns, "Polygon"),
- b = [];
- if (a.length > 0)
- for (var c, d = 0; d < a.length; ++d)(c = this.parseGeometry.polygon.apply(this, [a[d]])) && b.push(c);
- return new GeoGlobe.Geometry.MultiPolygon(b)
- },
- envelope: function(a) {
- var b = [],
- c, d, e = this.getElementsByTagNameNS(a, this.gmlns, "lowerCorner");
- if (e.length > 0) {
- c = [];
- if (e.length > 0) c = e[0].firstChild.nodeValue, c = c.replace(this.regExes.trimSpace, ""), c = c.split(this.regExes.splitSpace);
- c.length == 2 && (c[2] = null);
- var f = this.xy ? new GeoGlobe.Geometry.Point(c[0], c[1], c[2]) : new GeoGlobe.Geometry.Point(c[1], c[0], c[2])
- }
- a = this.getElementsByTagNameNS(a, this.gmlns, "upperCorner");
- if (a.length > 0) {
- c = [];
- if (a.length > 0) c = a[0].firstChild.nodeValue, c = c.replace(this.regExes.trimSpace, ""), c = c.split(this.regExes.splitSpace);
- c.length == 2 && (c[2] = null);
- var g = this.xy ? new GeoGlobe.Geometry.Point(c[0],
- c[1], c[2]) : new GeoGlobe.Geometry.Point(c[1], c[0], c[2])
- }
- f && g && (b.push(new GeoGlobe.Geometry.Point(f.x, f.y)), b.push(new GeoGlobe.Geometry.Point(g.x, f.y)), b.push(new GeoGlobe.Geometry.Point(g.x, g.y)), b.push(new GeoGlobe.Geometry.Point(f.x, g.y)), b.push(new GeoGlobe.Geometry.Point(f.x, f.y)), b = new GeoGlobe.Geometry.LinearRing(b), d = new GeoGlobe.Geometry.Polygon([b]));
- return d
- },
- box: function(a) {
- var b = this.getElementsByTagNameNS(a, this.gmlns, "coordinates"),
- c = null,
- a = null;
- if (b.length > 0) b = b[0].firstChild.nodeValue,
- b = b.split(" "), b.length == 2 && (c = b[0].split(","), a = b[1].split(","));
- if (c !== null && a !== null) return c = new GeoGlobe.LngLat(parseFloat(c[0]), parseFloat(c[1])), a = new GeoGlobe.LngLat(parseFloat(a[0]), parseFloat(a[1])), new GeoGlobe.LngLatBounds(c, a)
- }
- },
- parseAttributes: function(a) {
- for (var b = {}, a = a.firstChild, c, d, e; a;) {
- if (a.nodeType == 1) {
- a = a.childNodes;
- for (c = 0; c < a.length; ++c)
- if (d = a[c], d.nodeType == 1)
- if (e = d.childNodes, e.length == 1) {
- if (e = e[0], e.nodeType == 3 || e.nodeType == 4) d = d.prefix ? d.nodeName.split(":")[1] : d.nodeName,
- e = e.nodeValue.replace(this.regExes.trimSpace, ""), b[d] = e
- } else b[d.nodeName.split(":").pop()] = null;
- break
- }
- a = a.nextSibling
- }
- return b
- },
- write: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- for (var b = this.createElementNS("http://www.opengis.net/wfs", "wfs:" + this.collectionName), c = 0; c < a.length; c++) b.appendChild(this.createFeatureXML(a[c]));
- return GeoGlobe.Format.XML.prototype.write.apply(this, [b])
- },
- createFeatureXML: function(a) {
- var b = this.buildGeometryNode(a.geometry),
- c = this.createElementNS(this.featureNS, this.featurePrefix +
- ":" + this.geometryName);
- c.appendChild(b);
- var b = this.createElementNS(this.gmlns, "gml:" + this.featureName),
- d = this.createElementNS(this.featureNS, this.featurePrefix + ":" + this.layerName);
- d.setAttribute("fid", a.fid || a.id);
- d.appendChild(c);
- for (var e in a.attributes) {
- var c = this.createTextNode(a.attributes[e]),
- f = this.createElementNS(this.featureNS, this.featurePrefix + ":" + e.substring(e.lastIndexOf(":") + 1));
- f.appendChild(c);
- d.appendChild(f)
- }
- b.appendChild(d);
- return b
- },
- buildGeometryNode: function(a) {
- this.externalProjection &&
- this.internalProjection && (a = a.clone(), a.transform(this.internalProjection, this.externalProjection));
- var b = a.CLASS_NAME;
- return this.buildGeometry[b.substring(b.lastIndexOf(".") + 1).toLowerCase()].apply(this, [a])
- },
- buildGeometry: {
- point: function(a) {
- var b = this.createElementNS(this.gmlns, "gml:Point");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- },
- multipoint: function(a) {
- for (var b = this.createElementNS(this.gmlns, "gml:MultiPoint"), a = a.components, c, d, e = 0; e < a.length; e++) c = this.createElementNS(this.gmlns,
- "gml:pointMember"), d = this.buildGeometry.point.apply(this, [a[e]]), c.appendChild(d), b.appendChild(c);
- return b
- },
- linestring: function(a) {
- var b = this.createElementNS(this.gmlns, "gml:LineString");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- },
- multilinestring: function(a) {
- for (var b = this.createElementNS(this.gmlns, "gml:MultiLineString"), a = a.components, c, d, e = 0; e < a.length; ++e) c = this.createElementNS(this.gmlns, "gml:lineStringMember"), d = this.buildGeometry.linestring.apply(this, [a[e]]), c.appendChild(d), b.appendChild(c);
- return b
- },
- linearring: function(a) {
- var b = this.createElementNS(this.gmlns, "gml:LinearRing");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- },
- polygon: function(a) {
- for (var b = this.createElementNS(this.gmlns, "gml:Polygon"), a = a.components, c, d, e = 0; e < a.length; ++e) c = e == 0 ? "outerBoundaryIs" : "innerBoundaryIs", c = this.createElementNS(this.gmlns, "gml:" + c), d = this.buildGeometry.linearring.apply(this, [a[e]]), c.appendChild(d), b.appendChild(c);
- return b
- },
- multipolygon: function(a) {
- for (var b = this.createElementNS(this.gmlns,
- "gml:MultiPolygon"), a = a.components, c, d, e = 0; e < a.length; ++e) c = this.createElementNS(this.gmlns, "gml:polygonMember"), d = this.buildGeometry.polygon.apply(this, [a[e]]), c.appendChild(d), b.appendChild(c);
- return b
- },
- lnglatbounds: function(a) {
- var b = this.createElementNS(this.gmlns, "gml:Box");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- }
- },
- buildCoordinatesNode: function(a) {
- var b = this.createElementNS(this.gmlns, "gml:coordinates");
- b.setAttribute("decimal", ".");
- b.setAttribute("cs", ",");
- b.setAttribute("ts", " ");
- var c = [];
- if (a instanceof mapboxgl.LngLatBounds) c.push(a.getWest() + "," + a.getSouth()), c.push(a.getEast() + "," + a.getNorth());
- else
- for (var a = a.components ? a.components : [a], d = 0; d < a.length; d++) c.push(a[d].x + "," + a[d].y);
- c = this.createTextNode(c.join(" "));
- b.appendChild(c);
- return b
- },
- CLASS_NAME: "GeoGlobe.Format.GML"
- });
- if (!GeoGlobe.Format.GML) GeoGlobe.Format.GML = {};
- GeoGlobe.Format.GML.Base = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- gml: "http://www.opengis.net/gml",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance",
- wfs: "http://www.opengis.net/wfs"
- },
- defaultPrefix: "gml",
- schemaLocation: null,
- featureType: null,
- featureNS: null,
- geometryName: "geometry",
- extractAttributes: !0,
- srsName: null,
- xy: !0,
- geometryTypes: null,
- singleFeatureType: null,
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g,
- featureMember: /^(.*:)?featureMembers?$/
- },
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a]);
- this.setGeometryTypes();
- a && a.featureNS && this.setNamespace("feature", a.featureNS);
- this.singleFeatureType = !a || typeof a.featureType === "string"
- },
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = [];
- this.readNode(a, {
- features: b
- }, !0);
- if (b.length == 0) {
- var c = this.getElementsByTagNameNS(a, this.namespaces.gml, "featureMember");
- if (c.length)
- for (var a =
- 0, d = c.length; a < d; ++a) this.readNode(c[a], {
- features: b
- }, !0);
- else c = this.getElementsByTagNameNS(a, this.namespaces.gml, "featureMembers"), c.length && this.readNode(c[0], {
- features: b
- }, !0)
- }
- return b
- },
- readNode: function(a, b, c) {
- if (c === !0 && this.autoConfig === !0) this.featureType = null, delete this.namespaceAlias[this.featureNS], delete this.namespaces.feature, this.featureNS = null;
- if (!this.featureNS && !(a.prefix in this.namespaces) && a.parentNode.namespaceURI == this.namespaces.gml && this.regExes.featureMember.test(a.parentNode.nodeName)) this.featureType =
- a.nodeName.split(":").pop(), this.setNamespace("feature", a.namespaceURI), this.featureNS = a.namespaceURI, this.autoConfig = !0;
- return GeoGlobe.Format.XML.prototype.readNode.apply(this, [a, b])
- },
- readers: {
- gml: {
- _inherit: function() {},
- featureMember: function(a, b) {
- this.readChildNodes(a, b)
- },
- featureMembers: function(a, b) {
- this.readChildNodes(a, b)
- },
- name: function(a, b) {
- b.name = this.getChildValue(a)
- },
- boundedBy: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- if (c.components && c.components.length > 0) b.bounds = c.components[0]
- },
- Point: function(a, b) {
- var c = {
- points: []
- };
- this.readChildNodes(a, c);
- if (!b.components) b.components = [];
- b.components.push(c.points[0])
- },
- coordinates: function(a, b) {
- for (var c = this.getChildValue(a).replace(this.regExes.trimSpace, ""), c = c.replace(this.regExes.trimComma, ","), c = c.split(this.regExes.splitSpace), d, e = c.length, f = Array(e), g = 0; g < e; ++g) d = c[g].split(","), f[g] = this.xy ? new GeoGlobe.Geometry.Point(d[0], d[1], d[2]) : new GeoGlobe.Geometry.Point(d[1], d[0], d[2]);
- b.points = f
- },
- coord: function(a, b) {
- var c = {};
- this.readChildNodes(a,
- c);
- if (!b.points) b.points = [];
- b.points.push(new GeoGlobe.Geometry.Point(c.x, c.y, c.z))
- },
- X: function(a, b) {
- b.x = this.getChildValue(a)
- },
- Y: function(a, b) {
- b.y = this.getChildValue(a)
- },
- Z: function(a, b) {
- b.z = this.getChildValue(a)
- },
- MultiPoint: function(a, b) {
- var c = {
- components: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- b.components = [new GeoGlobe.Geometry.MultiPoint(c.components)]
- },
- pointMember: function(a, b) {
- this.readChildNodes(a, b)
- },
- LineString: function(a, b) {
- var c = {};
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- if (!b.components) b.components = [];
- b.components.push(new GeoGlobe.Geometry.LineString(c.points))
- },
- MultiLineString: function(a, b) {
- var c = {
- components: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- b.components = [new GeoGlobe.Geometry.MultiLineString(c.components)]
- },
- lineStringMember: function(a, b) {
- this.readChildNodes(a, b)
- },
- Polygon: function(a, b) {
- var c = {
- outer: null,
- inner: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- c.inner.unshift(c.outer);
- if (!b.components) b.components = [];
- b.components.push(new GeoGlobe.Geometry.Polygon(c.inner))
- },
- LinearRing: function(a, b) {
- var c = {};
- this.readers.gml._inherit.apply(this, [a, c]);
- this.readChildNodes(a, c);
- b.components = [new GeoGlobe.Geometry.LinearRing(c.points)]
- },
- MultiPolygon: function(a, b) {
- var c = {
- components: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- b.components = [new GeoGlobe.Geometry.MultiPolygon(c.components)]
- },
- polygonMember: function(a, b) {
- this.readChildNodes(a, b)
- },
- GeometryCollection: function(a,
- b) {
- var c = {
- components: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- b.components = [new GeoGlobe.Geometry.Collection(c.components)]
- },
- geometryMember: function(a, b) {
- this.readChildNodes(a, b)
- }
- },
- feature: {
- "*": function(a, b) {
- var c, d = a.localName || a.nodeName.split(":").pop();
- if (b.features)
- if (!this.singleFeatureType && GeoGlobe.Util.indexOf(this.featureType, d) !== -1) c = "_typeName";
- else if (d === this.featureType) c = "_typeName";
- else {
- if (GeoGlobe.Util.isArray(this.featureType_))
- for (var e = 0; e < this.featureType_.length; e++)
- if (this.featureType_[e] ===
- d) {
- c = "_typeName";
- break
- }
- } else a.childNodes.length == 0 || a.childNodes.length == 1 && a.firstChild.nodeType == 3 ? this.extractAttributes && (c = "_attribute") : c = "_geometry";
- c && this.readers.feature[c].apply(this, [a, b])
- },
- _typeName: function(a, b) {
- var c = {
- components: [],
- attributes: {}
- };
- this.readChildNodes(a, c);
- if (c.name) c.attributes.name = c.name;
- var d = new GeoGlobe.Feature(c.components[0], c.attributes);
- if (!this.singleFeatureType) d.type = a.nodeName.split(":").pop(), d.namespace = a.namespaceURI;
- var e = a.getAttribute("fid") || this.getAttributeNS(a,
- this.namespaces.gml, "id");
- if (e) d.fid = e;
- this.internalProjection && this.externalProjection && d.geometry && d.geometry.transform(this.externalProjection, this.internalProjection);
- if (c.bounds) d.bounds = c.bounds;
- b.features.push(d)
- },
- _geometry: function(a, b) {
- if (!this.geometryName) this.geometryName = a.nodeName.split(":").pop();
- this.readChildNodes(a, b)
- },
- _attribute: function(a, b) {
- var c = a.localName || a.nodeName.split(":").pop(),
- d = this.getChildValue(a);
- b.attributes[c] = d
- }
- },
- wfs: {
- FeatureCollection: function(a, b) {
- this.readChildNodes(a,
- b)
- }
- }
- },
- write: function(a) {
- a = this.writeNode("gml:" + (GeoGlobe.Util.isArray(a) ? "featureMembers" : "featureMember"), a);
- this.setAttributeNS(a, this.namespaces.xsi, "xsi:schemaLocation", this.schemaLocation);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [a])
- },
- writers: {
- gml: {
- featureMember: function(a) {
- var b = this.createElementNSPlus("gml:featureMember");
- this.writeNode("feature:_typeName", a, b);
- return b
- },
- MultiPoint: function(a) {
- for (var b = this.createElementNSPlus("gml:MultiPoint"), a = a.components || [a], c = 0, d = a.length; c <
- d; ++c) this.writeNode("pointMember", a[c], b);
- return b
- },
- pointMember: function(a) {
- var b = this.createElementNSPlus("gml:pointMember");
- this.writeNode("Point", a, b);
- return b
- },
- MultiLineString: function(a) {
- for (var b = this.createElementNSPlus("gml:MultiLineString"), a = a.components || [a], c = 0, d = a.length; c < d; ++c) this.writeNode("lineStringMember", a[c], b);
- return b
- },
- lineStringMember: function(a) {
- var b = this.createElementNSPlus("gml:lineStringMember");
- this.writeNode("LineString", a, b);
- return b
- },
- MultiPolygon: function(a) {
- for (var b =
- this.createElementNSPlus("gml:MultiPolygon"), a = a.components || [a], c = 0, d = a.length; c < d; ++c) this.writeNode("polygonMember", a[c], b);
- return b
- },
- polygonMember: function(a) {
- var b = this.createElementNSPlus("gml:polygonMember");
- this.writeNode("Polygon", a, b);
- return b
- },
- GeometryCollection: function(a) {
- for (var b = this.createElementNSPlus("gml:GeometryCollection"), c = 0, d = a.components.length; c < d; ++c) this.writeNode("geometryMember", a.components[c], b);
- return b
- },
- geometryMember: function(a) {
- var b = this.createElementNSPlus("gml:geometryMember"),
- a = this.writeNode("feature:_geometry", a);
- b.appendChild(a.firstChild);
- return b
- }
- },
- feature: {
- _typeName: function(a) {
- var b = this.createElementNSPlus("feature:" + this.featureType, {
- attributes: {
- fid: a.fid
- }
- });
- a.geometry && this.writeNode("feature:_geometry", a.geometry, b);
- for (var c in a.attributes) {
- var d = a.attributes[c];
- d != null && this.writeNode("feature:_attribute", {
- name: c,
- value: d
- }, b)
- }
- return b
- },
- _geometry: function(a) {
- this.externalProjection && this.internalProjection && (a = a.clone().transform(this.internalProjection, this.externalProjection));
- var b = this.createElementNSPlus("feature:" + this.geometryName),
- a = this.writeNode("gml:" + this.geometryTypes[a.CLASS_NAME], a, b);
- this.srsName && a.setAttribute("srsName", this.srsName);
- return b
- },
- _attribute: function(a) {
- return this.createElementNSPlus("feature:" + a.name, {
- value: a.value
- })
- }
- },
- wfs: {
- FeatureCollection: function(a) {
- for (var b = this.createElementNSPlus("wfs:FeatureCollection"), c = 0, d = a.length; c < d; ++c) this.writeNode("gml:featureMember", a[c], b);
- return b
- }
- }
- },
- setGeometryTypes: function() {
- this.geometryTypes = {
- "GeoGlobe.Geometry.Point": "Point",
- "GeoGlobe.Geometry.MultiPoint": "MultiPoint",
- "GeoGlobe.Geometry.LineString": "LineString",
- "GeoGlobe.Geometry.MultiLineString": "MultiLineString",
- "GeoGlobe.Geometry.Polygon": "Polygon",
- "GeoGlobe.Geometry.MultiPolygon": "MultiPolygon",
- "GeoGlobe.Geometry.Collection": "GeometryCollection"
- }
- },
- setFeatureType_: function(a) {
- this.featureType_ = a
- },
- CLASS_NAME: "GeoGlobe.Format.GML.Base"
- });
- GeoGlobe.Format.GML.v2 = GeoGlobe.Class4OL(GeoGlobe.Format.GML.Base, {
- schemaLocation: "http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd",
- initialize: function(a) {
- GeoGlobe.Format.GML.Base.prototype.initialize.apply(this, [a])
- },
- readers: {
- gml: GeoGlobe.Util.applyDefaults({
- outerBoundaryIs: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.outer = c.components[0]
- },
- innerBoundaryIs: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.inner.push(c.components[0])
- },
- Box: function(a, b) {
- var c = {};
- this.readChildNodes(a,
- c);
- if (!b.components) b.components = [];
- var d = c.points[0],
- c = c.points[1],
- d = new GeoGlobe.LngLat(d.x, d.y),
- c = new GeoGlobe.LngLat(c.x, c.y);
- b.components.push(new GeoGlobe.LngLatBounds(d, c))
- }
- }, GeoGlobe.Format.GML.Base.prototype.readers.gml),
- feature: GeoGlobe.Format.GML.Base.prototype.readers.feature,
- wfs: GeoGlobe.Format.GML.Base.prototype.readers.wfs
- },
- write: function(a) {
- a = this.writeNode(GeoGlobe.Util.isArray(a) ? "wfs:FeatureCollection" : "gml:featureMember", a);
- this.setAttributeNS(a, this.namespaces.xsi, "xsi:schemaLocation",
- this.schemaLocation);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [a])
- },
- writers: {
- gml: GeoGlobe.Util.applyDefaults({
- Point: function(a) {
- var b = this.createElementNSPlus("gml:Point");
- this.writeNode("coordinates", [a], b);
- return b
- },
- coordinates: function(a) {
- for (var b = a.length, c = Array(b), d, e = 0; e < b; ++e) d = a[e], c[e] = this.xy ? d.x + "," + d.y : d.y + "," + d.x, d.z != void 0 && (c[e] += "," + d.z);
- return this.createElementNSPlus("gml:coordinates", {
- attributes: {
- decimal: ".",
- cs: ",",
- ts: " "
- },
- value: b == 1 ? c[0] : c.join(" ")
- })
- },
- LineString: function(a) {
- var b =
- this.createElementNSPlus("gml:LineString");
- this.writeNode("coordinates", a.components, b);
- return b
- },
- Polygon: function(a) {
- var b = this.createElementNSPlus("gml:Polygon");
- this.writeNode("outerBoundaryIs", a.components[0], b);
- for (var c = 1; c < a.components.length; ++c) this.writeNode("innerBoundaryIs", a.components[c], b);
- return b
- },
- outerBoundaryIs: function(a) {
- var b = this.createElementNSPlus("gml:outerBoundaryIs");
- this.writeNode("LinearRing", a, b);
- return b
- },
- innerBoundaryIs: function(a) {
- var b = this.createElementNSPlus("gml:innerBoundaryIs");
- this.writeNode("LinearRing", a, b);
- return b
- },
- LinearRing: function(a) {
- var b = this.createElementNSPlus("gml:LinearRing");
- this.writeNode("coordinates", a.components, b);
- return b
- },
- Box: function(a) {
- var b = this.createElementNSPlus("gml:Box");
- this.writeNode("coordinates", [{
- x: a._sw.lng,
- y: a._sw.lat
- }, {
- x: a._ne.lng,
- y: a._ne.lat
- }], b);
- this.srsName && b.setAttribute("srsName", this.srsName);
- return b
- }
- }, GeoGlobe.Format.GML.Base.prototype.writers.gml),
- feature: GeoGlobe.Format.GML.Base.prototype.writers.feature,
- wfs: GeoGlobe.Format.GML.Base.prototype.writers.wfs
- },
- CLASS_NAME: "GeoGlobe.Format.GML.v2"
- });
- GeoGlobe.Format.GML.v3 = GeoGlobe.Class4OL(GeoGlobe.Format.GML.Base, {
- schemaLocation: "http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd",
- curve: !1,
- multiCurve: !0,
- surface: !1,
- multiSurface: !0,
- initialize: function(a) {
- GeoGlobe.Format.GML.Base.prototype.initialize.apply(this, [a])
- },
- readers: {
- gml: GeoGlobe.Util.applyDefaults({
- _inherit: function(a, b, c) {
- if (a = parseInt(a.getAttribute("srsDimension"), 10) || c && c.srsDimension) b.srsDimension = a
- },
- featureMembers: function(a,
- b) {
- this.readChildNodes(a, b)
- },
- Curve: function(a, b) {
- var c = {
- points: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- if (!b.components) b.components = [];
- b.components.push(new GeoGlobe.Geometry.LineString(c.points))
- },
- segments: function(a, b) {
- this.readChildNodes(a, b)
- },
- LineStringSegment: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- c.points && Array.prototype.push.apply(b.points, c.points)
- },
- pos: function(a, b) {
- var c = this.getChildValue(a).replace(this.regExes.trimSpace, "").split(this.regExes.splitSpace),
- c = this.xy ? new GeoGlobe.Geometry.Point(c[0], c[1], c[2]) : new GeoGlobe.Geometry.Point(c[1], c[0], c[2]);
- b.points = [c]
- },
- posList: function(a, b) {
- for (var c = this.getChildValue(a).replace(this.regExes.trimSpace, "").split(this.regExes.splitSpace), d = b.srsDimension || parseInt(a.getAttribute("srsDimension") || a.getAttribute("dimension"), 10) || 2, e, f, g, h = Array(c.length / d), j = 0, l = c.length; j < l; j += d) e = c[j], f = c[j + 1], g = d == 2 ? void 0 : c[j + 2], h[j / d] = this.xy ? new GeoGlobe.Geometry.Point(e, f, g) : new GeoGlobe.Geometry.Point(f, e, g);
- b.points =
- h
- },
- Surface: function(a, b) {
- this.readChildNodes(a, b)
- },
- patches: function(a, b) {
- this.readChildNodes(a, b)
- },
- PolygonPatch: function(a, b) {
- this.readers.gml.Polygon.apply(this, [a, b])
- },
- exterior: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.outer = c.components[0]
- },
- interior: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.inner.push(c.components[0])
- },
- MultiCurve: function(a, b) {
- var c = {
- components: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- if (c.components.length > 0) b.components = [new GeoGlobe.Geometry.MultiLineString(c.components)]
- },
- curveMember: function(a, b) {
- this.readChildNodes(a, b)
- },
- MultiSurface: function(a, b) {
- var c = {
- components: []
- };
- this.readers.gml._inherit.apply(this, [a, c, b]);
- this.readChildNodes(a, c);
- if (c.components.length > 0) b.components = [new GeoGlobe.Geometry.MultiPolygon(c.components)]
- },
- surfaceMember: function(a, b) {
- this.readChildNodes(a, b)
- },
- surfaceMembers: function(a, b) {
- this.readChildNodes(a, b)
- },
- pointMembers: function(a, b) {
- this.readChildNodes(a, b)
- },
- lineStringMembers: function(a, b) {
- this.readChildNodes(a, b)
- },
- polygonMembers: function(a,
- b) {
- this.readChildNodes(a, b)
- },
- geometryMembers: function(a, b) {
- this.readChildNodes(a, b)
- },
- Envelope: function(a, b) {
- var c = {
- points: Array(2)
- };
- this.readChildNodes(a, c);
- if (!b.components) b.components = [];
- var d = c.points[0],
- c = c.points[1],
- d = new GeoGlobe.LngLat(d.x, d.y),
- c = new GeoGlobe.LngLat(c.x, c.y);
- b.components.push(new GeoGlobe.LngLatBounds(d, c))
- },
- lowerCorner: function(a, b) {
- var c = {};
- this.readers.gml.pos.apply(this, [a, c]);
- b.points[0] = c.points[0]
- },
- upperCorner: function(a, b) {
- var c = {};
- this.readers.gml.pos.apply(this, [a, c]);
- b.points[1] = c.points[0]
- }
- }, GeoGlobe.Format.GML.Base.prototype.readers.gml),
- feature: GeoGlobe.Format.GML.Base.prototype.readers.feature,
- wfs: GeoGlobe.Format.GML.Base.prototype.readers.wfs
- },
- write: function(a) {
- a = this.writeNode("gml:" + (GeoGlobe.Util.isArray(a) ? "featureMembers" : "featureMember"), a);
- this.setAttributeNS(a, this.namespaces.xsi, "xsi:schemaLocation", this.schemaLocation);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [a])
- },
- writers: {
- gml: GeoGlobe.Util.applyDefaults({
- featureMembers: function(a) {
- for (var b =
- this.createElementNSPlus("gml:featureMembers"), c = 0, d = a.length; c < d; ++c) this.writeNode("feature:_typeName", a[c], b);
- return b
- },
- Point: function(a) {
- var b = this.createElementNSPlus("gml:Point");
- this.writeNode("pos", a, b);
- return b
- },
- pos: function(a) {
- return this.createElementNSPlus("gml:pos", {
- value: this.xy ? a.x + " " + a.y : a.y + " " + a.x
- })
- },
- LineString: function(a) {
- var b = this.createElementNSPlus("gml:LineString");
- this.writeNode("posList", a.components, b);
- return b
- },
- Curve: function(a) {
- var b = this.createElementNSPlus("gml:Curve");
- this.writeNode("segments", a, b);
- return b
- },
- segments: function(a) {
- var b = this.createElementNSPlus("gml:segments");
- this.writeNode("LineStringSegment", a, b);
- return b
- },
- LineStringSegment: function(a) {
- var b = this.createElementNSPlus("gml:LineStringSegment");
- this.writeNode("posList", a.components, b);
- return b
- },
- posList: function(a) {
- for (var b = a.length, c = Array(b), d, e = 0; e < b; ++e) d = a[e], c[e] = this.xy ? d.x + " " + d.y : d.y + " " + d.x;
- return this.createElementNSPlus("gml:posList", {
- value: c.join(" ")
- })
- },
- Surface: function(a) {
- var b = this.createElementNSPlus("gml:Surface");
- this.writeNode("patches", a, b);
- return b
- },
- patches: function(a) {
- var b = this.createElementNSPlus("gml:patches");
- this.writeNode("PolygonPatch", a, b);
- return b
- },
- PolygonPatch: function(a) {
- var b = this.createElementNSPlus("gml:PolygonPatch", {
- attributes: {
- interpolation: "planar"
- }
- });
- this.writeNode("exterior", a.components[0], b);
- for (var c = 1, d = a.components.length; c < d; ++c) this.writeNode("interior", a.components[c], b);
- return b
- },
- Polygon: function(a) {
- var b = this.createElementNSPlus("gml:Polygon");
- this.writeNode("exterior", a.components[0],
- b);
- for (var c = 1, d = a.components.length; c < d; ++c) this.writeNode("interior", a.components[c], b);
- return b
- },
- exterior: function(a) {
- var b = this.createElementNSPlus("gml:exterior");
- this.writeNode("LinearRing", a, b);
- return b
- },
- interior: function(a) {
- var b = this.createElementNSPlus("gml:interior");
- this.writeNode("LinearRing", a, b);
- return b
- },
- LinearRing: function(a) {
- var b = this.createElementNSPlus("gml:LinearRing");
- this.writeNode("posList", a.components, b);
- return b
- },
- MultiCurve: function(a) {
- for (var b = this.createElementNSPlus("gml:MultiCurve"),
- a = a.components || [a], c = 0, d = a.length; c < d; ++c) this.writeNode("curveMember", a[c], b);
- return b
- },
- curveMember: function(a) {
- var b = this.createElementNSPlus("gml:curveMember");
- this.curve ? this.writeNode("Curve", a, b) : this.writeNode("LineString", a, b);
- return b
- },
- MultiSurface: function(a) {
- for (var b = this.createElementNSPlus("gml:MultiSurface"), a = a.components || [a], c = 0, d = a.length; c < d; ++c) this.writeNode("surfaceMember", a[c], b);
- return b
- },
- surfaceMember: function(a) {
- var b = this.createElementNSPlus("gml:surfaceMember");
- this.surface ?
- this.writeNode("Surface", a, b) : this.writeNode("Polygon", a, b);
- return b
- },
- Envelope: function(a) {
- var b = this.createElementNSPlus("gml:Envelope");
- this.writeNode("lowerCorner", a, b);
- this.writeNode("upperCorner", a, b);
- this.srsName && b.setAttribute("srsName", this.srsName);
- return b
- },
- lowerCorner: function(a) {
- return this.createElementNSPlus("gml:lowerCorner", {
- value: this.xy ? a._sw.lng + " " + a._sw.lat : a._sw.lat + " " + a._sw.lng
- })
- },
- upperCorner: function(a) {
- return this.createElementNSPlus("gml:upperCorner", {
- value: this.xy ? a._ne.lng +
- " " + a._ne.lat : a._ne.lat + " " + a._ne.lng
- })
- }
- }, GeoGlobe.Format.GML.Base.prototype.writers.gml),
- feature: GeoGlobe.Format.GML.Base.prototype.writers.feature,
- wfs: GeoGlobe.Format.GML.Base.prototype.writers.wfs
- },
- setGeometryTypes: function() {
- this.geometryTypes = {
- "GeoGlobe.Geometry.Point": "Point",
- "GeoGlobe.Geometry.MultiPoint": "MultiPoint",
- "GeoGlobe.Geometry.LineString": this.curve === !0 ? "Curve" : "LineString",
- "GeoGlobe.Geometry.MultiLineString": this.multiCurve === !1 ? "MultiLineString" : "MultiCurve",
- "GeoGlobe.Geometry.Polygon": this.surface ===
- !0 ? "Surface" : "Polygon",
- "GeoGlobe.Geometry.MultiPolygon": this.multiSurface === !1 ? "MultiPolygon" : "MultiSurface",
- "GeoGlobe.Geometry.Collection": "GeometryCollection"
- }
- },
- CLASS_NAME: "GeoGlobe.Format.GML.v3"
- });
- GeoGlobe.Format.KML = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- kml: "http://www.opengis.net/kml/2.2",
- gx: "http://www.google.com/kml/ext/2.2"
- },
- kmlns: "http://earth.google.com/kml/2.0",
- placemarksDesc: "No description available",
- foldersName: "GeoGlobe export",
- foldersDesc: "Exported on " + new Date,
- extractAttributes: !0,
- kvpAttributes: !1,
- extractStyles: !1,
- extractTracks: !1,
- trackAttributes: null,
- internalns: null,
- features: null,
- styles: null,
- styleBaseUrl: "",
- fetched: null,
- maxDepth: 0,
- initialize: function(a) {
- this.regExes = {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g,
- kmlColor: /(\w{2})(\w{2})(\w{2})(\w{2})/,
- kmlIconPalette: /root:\/\/icons\/palette-(\d+)(\.\w+)/,
- straightBracket: /\$\[(.*?)\]/g
- };
- this.externalProjection = new GeoGlobe.SpatialReference("EPSG:4326");
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- this.features = [];
- this.styles = {};
- this.fetched = {};
- return this.parseData(a, {
- depth: 0,
- styleBaseUrl: this.styleBaseUrl
- })
- },
- parseData: function(a, b) {
- typeof a == "string" &&
- (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- for (var c = ["Link", "NetworkLink", "Style", "StyleMap", "Placemark"], d = 0, e = c.length; d < e; ++d) {
- var f = c[d],
- g = this.getElementsByTagNameNS(a, "*", f);
- if (g.length != 0) switch (f.toLowerCase()) {
- case "link":
- case "networklink":
- this.parseLinks(g, b);
- break;
- case "style":
- this.extractStyles && this.parseStyles(g, b);
- break;
- case "stylemap":
- this.extractStyles && this.parseStyleMaps(g, b);
- break;
- case "placemark":
- this.parseFeatures(g, b)
- }
- }
- return this.features
- },
- parseLinks: function(a,
- b) {
- if (b.depth >= this.maxDepth) return !1;
- var c = GeoGlobe.Util.extend({}, b);
- c.depth++;
- for (var d = 0, e = a.length; d < e; d++) {
- var f = this.parseProperty(a[d], "*", "href");
- f && !this.fetched[f] && (this.fetched[f] = !0, (f = this.fetchLink(f)) && this.parseData(f, c))
- }
- },
- fetchLink: function(a) {
- if (a = GeoGlobe.Request.GET({
- url: a,
- async: !1
- })) return a.responseText
- },
- parseStyles: function(a, b) {
- for (var c = 0, d = a.length; c < d; c++) {
- var e = this.parseStyle(a[c]);
- e && (this.styles[(b.styleBaseUrl || "") + "#" + e.id] = e)
- }
- },
- parseKmlColor: function(a) {
- var b =
- null;
- a && (a = a.match(this.regExes.kmlColor)) && (b = {
- color: "#" + a[4] + a[3] + a[2],
- opacity: parseInt(a[1], 16) / 255
- });
- return b
- },
- parseStyle: function(a) {
- for (var b = {}, c = ["LineStyle", "PolyStyle", "IconStyle", "BalloonStyle", "LabelStyle"], d, e, f = 0, g = c.length; f < g; ++f)
- if (d = c[f], e = this.getElementsByTagNameNS(a, "*", d)[0]) switch (d.toLowerCase()) {
- case "linestyle":
- d = this.parseProperty(e, "*", "color");
- if (d = this.parseKmlColor(d)) b.strokeColor = d.color, b.strokeOpacity = d.opacity;
- (d = this.parseProperty(e, "*", "width")) && (b.strokeWidth =
- d);
- break;
- case "polystyle":
- d = this.parseProperty(e, "*", "color");
- if (d = this.parseKmlColor(d)) b.fillOpacity = d.opacity, b.fillColor = d.color;
- this.parseProperty(e, "*", "fill") == "0" && (b.fillColor = "none");
- this.parseProperty(e, "*", "outline") == "0" && (b.strokeWidth = "0");
- break;
- case "iconstyle":
- var h = parseFloat(this.parseProperty(e, "*", "scale") || 1);
- d = 32 * h;
- var j = 32 * h,
- l = this.getElementsByTagNameNS(e, "*", "Icon")[0];
- if (l) {
- var m = this.parseProperty(l, "*", "href");
- if (m) {
- var n = this.parseProperty(l, "*", "w"),
- p = this.parseProperty(l,
- "*", "h");
- GeoGlobe.String.startsWith(m, "http://maps.google.com/mapfiles/kml") && !n && !p && (p = n = 64, h /= 2);
- n = n || p;
- p = p || n;
- n && (d = parseInt(n) * h);
- p && (j = parseInt(p) * h);
- if (p = m.match(this.regExes.kmlIconPalette)) n = p[1], p = p[2], m = this.parseProperty(l, "*", "x"), l = this.parseProperty(l, "*", "y"), m = "http://maps.google.com/mapfiles/kml/pal" + n + "/icon" + ((l ? 7 - l / 32 : 7) * 8 + (m ? m / 32 : 0)) + p;
- b.graphicOpacity = 1;
- b.externalGraphic = m
- }
- }
- if (e = this.getElementsByTagNameNS(e, "*", "hotSpot")[0]) m = parseFloat(e.getAttribute("x")), l = parseFloat(e.getAttribute("y")),
- n = e.getAttribute("xunits"), n == "pixels" ? b.graphicXOffset = -m * h : n == "insetPixels" ? b.graphicXOffset = -d + m * h : n == "fraction" && (b.graphicXOffset = -d * m), e = e.getAttribute("yunits"), e == "pixels" ? b.graphicYOffset = -j + l * h + 1 : e == "insetPixels" ? b.graphicYOffset = -(l * h) + 1 : e == "fraction" && (b.graphicYOffset = -j * (1 - l) + 1);
- b.graphicWidth = d;
- b.graphicHeight = j;
- break;
- case "balloonstyle":
- (e = GeoGlobe.Util.getXmlNodeValue(e)) && (b.balloonStyle = e.replace(this.regExes.straightBracket, "${$1}"));
- break;
- case "labelstyle":
- if (d = this.parseProperty(e,
- "*", "color"), d = this.parseKmlColor(d)) b.fontColor = d.color, b.fontOpacity = d.opacity
- }!b.strokeColor && b.fillColor && (b.strokeColor = b.fillColor);
- if ((a = a.getAttribute("id")) && b) b.id = a;
- return b
- },
- parseStyleMaps: function(a, b) {
- for (var c = 0, d = a.length; c < d; c++)
- for (var e = a[c], f = this.getElementsByTagNameNS(e, "*", "Pair"), e = e.getAttribute("id"), g = 0, h = f.length; g < h; g++) {
- var j = f[g],
- l = this.parseProperty(j, "*", "key");
- (j = this.parseProperty(j, "*", "styleUrl")) && l == "normal" && (this.styles[(b.styleBaseUrl || "") + "#" + e] = this.styles[(b.styleBaseUrl ||
- "") + j])
- }
- },
- parseFeatures: function(a, b) {
- for (var c = [], d = 0, e = a.length; d < e; d++) {
- var f = a[d],
- g = this.parseFeature.apply(this, [f]);
- if (g) {
- if (this.extractStyles && g.attributes && g.attributes.styleUrl) g.style = this.getStyle(g.attributes.styleUrl, b);
- if (this.extractStyles) {
- var h = this.getElementsByTagNameNS(f, "*", "Style")[0];
- if (h && (h = this.parseStyle(h))) g.style = GeoGlobe.Util.extend(g.style, h)
- }
- if (this.extractTracks) {
- if ((f = this.getElementsByTagNameNS(f, this.namespaces.gx, "Track")) && f.length > 0) g = {
- features: [],
- feature: g
- },
- this.readNode(f[0], g), g.features.length > 0 && c.push.apply(c, g.features)
- } else c.push(g)
- } else throw "Bad Placemark: " + d;
- }
- this.features = this.features.concat(c)
- },
- readers: {
- kml: {
- when: function(a, b) {
- b.whens.push(GeoGlobe.Date.parse(this.getChildValue(a)))
- },
- _trackPointAttribute: function(a, b) {
- var c = a.nodeName.split(":").pop();
- b.attributes[c].push(this.getChildValue(a))
- }
- },
- gx: {
- Track: function(a, b) {
- var c = {
- whens: [],
- points: [],
- angles: []
- };
- if (this.trackAttributes) {
- var d;
- c.attributes = {};
- for (var e = 0, f = this.trackAttributes.length; e <
- f; ++e)
- if (d = this.trackAttributes[e], c.attributes[d] = [], !(d in this.readers.kml)) this.readers.kml[d] = this.readers.kml._trackPointAttribute
- }
- this.readChildNodes(a, c);
- if (c.whens.length !== c.points.length) throw Error("gx:Track with unequal number of when (" + c.whens.length + ") and gx:coord (" + c.points.length + ") elements.");
- var g = c.angles.length > 0;
- if (g && c.whens.length !== c.angles.length) throw Error("gx:Track with unequal number of when (" + c.whens.length + ") and gx:angles (" + c.angles.length + ") elements.");
- for (var h,
- e = 0, f = c.whens.length; e < f; ++e) {
- h = b.feature.clone();
- h.fid = b.feature.fid || b.feature.id;
- d = c.points[e];
- h.geometry = d;
- if ("z" in d) h.attributes.altitude = d.z;
- this.internalProjection && this.externalProjection && h.geometry.transform(this.externalProjection, this.internalProjection);
- if (this.trackAttributes)
- for (var j = 0, l = this.trackAttributes.length; j < l; ++j) d = this.trackAttributes[j], h.attributes[d] = c.attributes[d][e];
- h.attributes.when = c.whens[e];
- h.attributes.trackId = b.feature.id;
- if (g) d = c.angles[e], h.attributes.heading =
- parseFloat(d[0]), h.attributes.tilt = parseFloat(d[1]), h.attributes.roll = parseFloat(d[2]);
- b.features.push(h)
- }
- },
- coord: function(a, b) {
- var c = this.getChildValue(a).replace(this.regExes.trimSpace, "").split(/\s+/),
- d = new GeoGlobe.Geometry.Point(c[0], c[1]);
- if (c.length > 2) d.z = parseFloat(c[2]);
- b.points.push(d)
- },
- angles: function(a, b) {
- var c = this.getChildValue(a).replace(this.regExes.trimSpace, "").split(/\s+/);
- b.angles.push(c)
- }
- }
- },
- parseFeature: function(a) {
- for (var b = ["MultiGeometry", "Polygon", "LineString", "Point"], c,
- d, e, f = 0, g = b.length; f < g; ++f)
- if (c = b[f], this.internalns = a.namespaceURI ? a.namespaceURI : this.kmlns, d = this.getElementsByTagNameNS(a, this.internalns, c), d.length > 0) {
- if (b = this.parseGeometry[c.toLowerCase()]) e = b.apply(this, [d[0]]), this.internalProjection && this.externalProjection && e.transform(this.externalProjection, this.internalProjection);
- else throw new TypeError("Unsupported geometry type: " + c);
- break
- }
- var h;
- this.extractAttributes && (h = this.parseAttributes(a));
- c = new GeoGlobe.Feature(e, h);
- a = a.getAttribute("id") ||
- a.getAttribute("name");
- if (a != null) c.fid = a;
- return c
- },
- getStyle: function(a, b) {
- var c = GeoGlobe.Util.removeTail(a),
- d = GeoGlobe.Util.extend({}, b);
- d.depth++;
- d.styleBaseUrl = c;
- !this.styles[a] && !GeoGlobe.String.startsWith(a, "#") && d.depth <= this.maxDepth && !this.fetched[c] && (c = this.fetchLink(c)) && this.parseData(c, d);
- return GeoGlobe.Util.extend({}, this.styles[a])
- },
- parseGeometry: {
- point: function(a) {
- var b = this.getElementsByTagNameNS(a, this.internalns, "coordinates"),
- a = [];
- if (b.length > 0) var c = b[0].firstChild.nodeValue,
- c = c.replace(this.regExes.removeSpace, ""),
- a = c.split(",");
- b = null;
- if (a.length > 1) a.length == 2 && (a[2] = null), b = new GeoGlobe.Geometry.Point(a[0], a[1], a[2]);
- else throw "Bad coordinate string: " + c;
- return b
- },
- linestring: function(a, b) {
- var c = this.getElementsByTagNameNS(a, this.internalns, "coordinates"),
- d = null;
- if (c.length > 0) {
- for (var c = this.getChildValue(c[0]), c = c.replace(this.regExes.trimSpace, ""), c = c.replace(this.regExes.trimComma, ","), d = c.split(this.regExes.splitSpace), e = d.length, f = Array(e), g, h, j = 0; j < e; ++j)
- if (g =
- d[j].split(","), h = g.length, h > 1) g.length == 2 && (g[2] = null), f[j] = new GeoGlobe.Geometry.Point(g[0], g[1], g[2]);
- else throw "Bad LineString point coordinates: " + d[j];
- if (e) d = b ? new GeoGlobe.Geometry.LinearRing(f) : new GeoGlobe.Geometry.LineString(f);
- else throw "Bad LineString coordinates: " + c;
- }
- return d
- },
- polygon: function(a) {
- var a = this.getElementsByTagNameNS(a, this.internalns, "LinearRing"),
- b = a.length,
- c = Array(b);
- if (b > 0)
- for (var d = 0, e = a.length; d < e; ++d)
- if (b = this.parseGeometry.linestring.apply(this, [a[d], !0])) c[d] = b;
- else throw "Bad LinearRing geometry: " + d;
- return new GeoGlobe.Geometry.Polygon(c)
- },
- multigeometry: function(a) {
- for (var b, c = [], d = a.childNodes, e = 0, f = d.length; e < f; ++e) a = d[e], a.nodeType == 1 && (b = this.parseGeometry[(a.prefix ? a.nodeName.split(":")[1] : a.nodeName).toLowerCase()]) && c.push(b.apply(this, [a]));
- return new GeoGlobe.Geometry.Collection(c)
- }
- },
- parseAttributes: function(a) {
- var b = {},
- c = a.getElementsByTagName("ExtendedData");
- c.length && (b = this.parseExtendedData(c[0]));
- for (var d, e, f, a = a.childNodes, c = 0, g = a.length; c <
- g; ++c)
- if (d = a[c], d.nodeType == 1 && (e = d.childNodes, e.length >= 1 && e.length <= 3)) {
- switch (e.length) {
- case 1:
- f = e[0];
- break;
- case 2:
- f = e[0];
- e = e[1];
- f = f.nodeType == 3 || f.nodeType == 4 ? f : e;
- break;
- default:
- f = e[1]
- }
- if (f.nodeType == 3 || f.nodeType == 4)
- if (d = d.prefix ? d.nodeName.split(":")[1] : d.nodeName, f = GeoGlobe.Util.getXmlNodeValue(f)) f = f.replace(this.regExes.trimSpace, ""), b[d] = f
- }
- return b
- },
- parseExtendedData: function(a) {
- var b = {},
- c, d, e, f, g = a.getElementsByTagName("Data");
- c = 0;
- for (d = g.length; c < d; c++) {
- e = g[c];
- f = e.getAttribute("name");
- var h = {},
- j = e.getElementsByTagName("value");
- j.length && (h.value = this.getChildValue(j[0]));
- this.kvpAttributes ? b[f] = h.value : (e = e.getElementsByTagName("displayName"), e.length && (h.displayName = this.getChildValue(e[0])), b[f] = h)
- }
- a = a.getElementsByTagName("SimpleData");
- c = 0;
- for (d = a.length; c < d; c++) h = {}, e = a[c], f = e.getAttribute("name"), h.value = this.getChildValue(e), this.kvpAttributes ? b[f] = h.value : (h.displayName = f, b[f] = h);
- return b
- },
- parseProperty: function(a, b, c) {
- var d, a = this.getElementsByTagNameNS(a, b, c);
- try {
- d = GeoGlobe.Util.getXmlNodeValue(a[0])
- } catch (e) {
- d =
- null
- }
- return d
- },
- write: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- for (var b = this.createElementNS(this.kmlns, "kml"), c = this.createFolderXML(), d = 0, e = a.length; d < e; ++d) c.appendChild(this.createPlacemarkXML(a[d]));
- b.appendChild(c);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [b])
- },
- createFolderXML: function() {
- var a = this.createElementNS(this.kmlns, "Folder");
- if (this.foldersName) {
- var b = this.createElementNS(this.kmlns, "name"),
- c = this.createTextNode(this.foldersName);
- b.appendChild(c);
- a.appendChild(b)
- }
- this.foldersDesc &&
- (b = this.createElementNS(this.kmlns, "description"), c = this.createTextNode(this.foldersDesc), b.appendChild(c), a.appendChild(b));
- return a
- },
- createPlacemarkXML: function(a) {
- var b = this.createElementNS(this.kmlns, "name"),
- c = a.style && a.style.label ? a.style.label : a.id;
- b.appendChild(this.createTextNode(a.attributes.name || c));
- var d = this.createElementNS(this.kmlns, "description");
- d.appendChild(this.createTextNode(a.attributes.description || this.placemarksDesc));
- c = this.createElementNS(this.kmlns, "Placemark");
- a.fid !=
- null && c.setAttribute("id", a.fid);
- c.appendChild(b);
- c.appendChild(d);
- b = this.buildGeometryNode(a.geometry);
- c.appendChild(b);
- a.attributes && (a = this.buildExtendedData(a.attributes)) && c.appendChild(a);
- return c
- },
- buildGeometryNode: function(a) {
- var b = a.CLASS_NAME,
- b = this.buildGeometry[b.substring(b.lastIndexOf(".") + 1).toLowerCase()],
- c = null;
- b && (c = b.apply(this, [a]));
- return c
- },
- buildGeometry: {
- point: function(a) {
- var b = this.createElementNS(this.kmlns, "Point");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- },
- multipoint: function(a) {
- return this.buildGeometry.collection.apply(this, [a])
- },
- linestring: function(a) {
- var b = this.createElementNS(this.kmlns, "LineString");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- },
- multilinestring: function(a) {
- return this.buildGeometry.collection.apply(this, [a])
- },
- linearring: function(a) {
- var b = this.createElementNS(this.kmlns, "LinearRing");
- b.appendChild(this.buildCoordinatesNode(a));
- return b
- },
- polygon: function(a) {
- for (var b = this.createElementNS(this.kmlns, "Polygon"), a = a.components, c, d, e = 0, f = a.length; e < f; ++e) c = e == 0 ? "outerBoundaryIs" : "innerBoundaryIs",
- c = this.createElementNS(this.kmlns, c), d = this.buildGeometry.linearring.apply(this, [a[e]]), c.appendChild(d), b.appendChild(c);
- return b
- },
- multipolygon: function(a) {
- return this.buildGeometry.collection.apply(this, [a])
- },
- collection: function(a) {
- for (var b = this.createElementNS(this.kmlns, "MultiGeometry"), c, d = 0, e = a.components.length; d < e; ++d)(c = this.buildGeometryNode.apply(this, [a.components[d]])) && b.appendChild(c);
- return b
- }
- },
- buildCoordinatesNode: function(a) {
- var b = this.createElementNS(this.kmlns, "coordinates"),
- c;
- if (c = a.components) {
- for (var d = c.length, e = Array(d), f = 0; f < d; ++f) a = c[f], e[f] = this.buildCoordinates(a);
- c = e.join(" ")
- } else c = this.buildCoordinates(a);
- c = this.createTextNode(c);
- b.appendChild(c);
- return b
- },
- buildCoordinates: function(a) {
- this.internalProjection && this.externalProjection && (a = a.clone(), a.transform(this.internalProjection, this.externalProjection));
- return a.x + "," + a.y
- },
- buildExtendedData: function(a) {
- var b = this.createElementNS(this.kmlns, "ExtendedData"),
- c;
- for (c in a)
- if (a[c] && c != "name" && c != "description" &&
- c != "styleUrl") {
- var d = this.createElementNS(this.kmlns, "Data");
- d.setAttribute("name", c);
- var e = this.createElementNS(this.kmlns, "value");
- if (typeof a[c] == "object") {
- if (a[c].value && e.appendChild(this.createTextNode(a[c].value)), a[c].displayName) {
- var f = this.createElementNS(this.kmlns, "displayName");
- f.appendChild(this.getXMLDoc().createCDATASection(a[c].displayName));
- d.appendChild(f)
- }
- } else e.appendChild(this.createTextNode(a[c]));
- d.appendChild(e);
- b.appendChild(d)
- }
- return this.isSimpleContent(b) ? null : b
- },
- CLASS_NAME: "GeoGlobe.Format.KML"
- });
- GeoGlobe.Format.OWSCommon = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.0.0",
- getVersion: function(a) {
- var b = this.version;
- if (!b && ((a = a.getAttribute("xmlns:ows")) && a.substring(a.lastIndexOf("/") + 1) === "1.1" && (b = "1.1.0"), !b)) b = this.defaultVersion;
- return b
- },
- CLASS_NAME: "GeoGlobe.Format.OWSCommon"
- });
- GeoGlobe.Format.OWSCommon.v1 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- read: function(a, b) {
- GeoGlobe.Util.applyDefaults(b, this.options);
- var c = {};
- this.readChildNodes(a, c);
- return c
- },
- readers: {
- ows: {
- Exception: function(a, b) {
- var c = {
- code: a.getAttribute("exceptionCode"),
- locator: a.getAttribute("locator"),
- texts: []
- };
- b.exceptions.push(c);
- this.readChildNodes(a, c)
- },
- ExceptionText: function(a, b) {
- var c = this.getChildValue(a);
- b.texts.push(c)
- },
- ServiceIdentification: function(a, b) {
- b.serviceIdentification = {};
- this.readChildNodes(a, b.serviceIdentification)
- },
- Title: function(a, b) {
- b.title = this.getChildValue(a)
- },
- Abstract: function(a, b) {
- b["abstract"] = this.getChildValue(a)
- },
- Keywords: function(a, b) {
- b.keywords = {};
- this.readChildNodes(a, b.keywords)
- },
- Keyword: function(a, b) {
- b[this.getChildValue(a)] = !0
- },
- ServiceType: function(a, b) {
- b.serviceType = {
- codeSpace: a.getAttribute("codeSpace"),
- value: this.getChildValue(a)
- }
- },
- ServiceTypeVersion: function(a, b) {
- b.serviceTypeVersion =
- this.getChildValue(a)
- },
- Fees: function(a, b) {
- b.fees = this.getChildValue(a)
- },
- AccessConstraints: function(a, b) {
- b.accessConstraints = this.getChildValue(a)
- },
- ServiceProvider: function(a, b) {
- b.serviceProvider = {};
- this.readChildNodes(a, b.serviceProvider)
- },
- ProviderName: function(a, b) {
- b.providerName = this.getChildValue(a)
- },
- ProviderSite: function(a, b) {
- b.providerSite = this.getAttributeNS(a, this.namespaces.xlink, "href")
- },
- ServiceContact: function(a, b) {
- b.serviceContact = {};
- this.readChildNodes(a, b.serviceContact)
- },
- IndividualName: function(a,
- b) {
- b.individualName = this.getChildValue(a)
- },
- PositionName: function(a, b) {
- b.positionName = this.getChildValue(a)
- },
- ContactInfo: function(a, b) {
- b.contactInfo = {};
- this.readChildNodes(a, b.contactInfo)
- },
- Phone: function(a, b) {
- b.phone = {};
- this.readChildNodes(a, b.phone)
- },
- Voice: function(a, b) {
- b.voice = this.getChildValue(a)
- },
- Address: function(a, b) {
- b.address = {};
- this.readChildNodes(a, b.address)
- },
- DeliveryPoint: function(a, b) {
- b.deliveryPoint = this.getChildValue(a)
- },
- City: function(a, b) {
- b.city = this.getChildValue(a)
- },
- AdministrativeArea: function(a,
- b) {
- b.administrativeArea = this.getChildValue(a)
- },
- PostalCode: function(a, b) {
- b.postalCode = this.getChildValue(a)
- },
- Country: function(a, b) {
- b.country = this.getChildValue(a)
- },
- ElectronicMailAddress: function(a, b) {
- b.electronicMailAddress = this.getChildValue(a)
- },
- Role: function(a, b) {
- b.role = this.getChildValue(a)
- },
- OperationsMetadata: function(a, b) {
- b.operationsMetadata = {};
- this.readChildNodes(a, b.operationsMetadata)
- },
- Operation: function(a, b) {
- var c = a.getAttribute("name");
- b[c] = {};
- this.readChildNodes(a, b[c])
- },
- DCP: function(a,
- b) {
- b.dcp = {};
- this.readChildNodes(a, b.dcp)
- },
- HTTP: function(a, b) {
- b.http = {};
- this.readChildNodes(a, b.http)
- },
- Get: function(a, b) {
- if (!b.get) b.get = [];
- var c = {
- url: this.getAttributeNS(a, this.namespaces.xlink, "href")
- };
- this.readChildNodes(a, c);
- b.get.push(c)
- },
- Post: function(a, b) {
- if (!b.post) b.post = [];
- var c = {
- url: this.getAttributeNS(a, this.namespaces.xlink, "href")
- };
- this.readChildNodes(a, c);
- b.post.push(c)
- },
- Parameter: function(a, b) {
- if (!b.parameters) b.parameters = {};
- var c = a.getAttribute("name");
- b.parameters[c] = {};
- this.readChildNodes(a,
- b.parameters[c])
- },
- Constraint: function(a, b) {
- if (!b.constraints) b.constraints = {};
- var c = a.getAttribute("name");
- b.constraints[c] = {};
- this.readChildNodes(a, b.constraints[c])
- },
- Value: function(a, b) {
- b[this.getChildValue(a)] = !0
- },
- OutputFormat: function(a, b) {
- b.formats.push({
- value: this.getChildValue(a)
- });
- this.readChildNodes(a, b)
- },
- WGS84BoundingBox: function(a, b) {
- var c = {};
- c.crs = a.getAttribute("crs");
- b.BoundingBox ? b.BoundingBox.push(c) : (b.projection = c.crs, c = b);
- this.readChildNodes(a, c)
- },
- BoundingBox: function(a, b) {
- this.readers.ows.WGS84BoundingBox.apply(this, [a, b])
- },
- LowerCorner: function(a, b) {
- if (a.parentNode.tagName === "ows:BoundingBox") {
- var c = this.getChildValue(a).replace(this.regExes.trimSpace, ""),
- c = c.replace(this.regExes.trimComma, ","),
- c = c.split(this.regExes.splitSpace);
- b.left = c[0];
- b.bottom = c[1]
- }
- },
- UpperCorner: function(a, b) {
- if (a.parentNode.tagName === "ows:BoundingBox") {
- var c = this.getChildValue(a).replace(this.regExes.trimSpace, ""),
- c = c.replace(this.regExes.trimComma, ","),
- c = c.split(this.regExes.splitSpace);
- b.right = c[0];
- b.top = c[1];
- b.bounds = new GeoGlobe.LngLatBounds(new GeoGlobe.LngLat(b.left,
- b.bottom), new GeoGlobe.LngLat(b.right, b.top));
- delete b.left;
- delete b.bottom;
- delete b.right;
- delete b.top
- }
- },
- Language: function(a, b) {
- b.language = this.getChildValue(a)
- }
- }
- },
- writers: {
- ows: {
- BoundingBox: function(a, b) {
- var c = this.createElementNSPlus(b || "ows:BoundingBox", {
- attributes: {
- crs: a.projection
- }
- });
- this.writeNode("ows:LowerCorner", a, c);
- this.writeNode("ows:UpperCorner", a, c);
- return c
- },
- LowerCorner: function(a) {
- return this.createElementNSPlus("ows:LowerCorner", {
- value: a.bounds._sw.lng + " " + a.bounds._sw.lat
- })
- },
- UpperCorner: function(a) {
- return this.createElementNSPlus("ows:UpperCorner", {
- value: a.bounds._ne.lng + " " + a.bounds._ne.lat
- })
- },
- Identifier: function(a) {
- return this.createElementNSPlus("ows:Identifier", {
- value: a
- })
- },
- Title: function(a) {
- return this.createElementNSPlus("ows:Title", {
- value: a
- })
- },
- Abstract: function(a) {
- return this.createElementNSPlus("ows:Abstract", {
- value: a
- })
- },
- OutputFormat: function(a) {
- return this.createElementNSPlus("ows:OutputFormat", {
- value: a
- })
- }
- }
- },
- CLASS_NAME: "GeoGlobe.Format.OWSCommon.v1"
- });
- GeoGlobe.Format.OWSCommon.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.OWSCommon.v1, {
- namespaces: {
- ows: "http://www.opengis.net/ows",
- xlink: "http://www.w3.org/1999/xlink"
- },
- readers: {
- ows: GeoGlobe.Util.applyDefaults({
- ExceptionReport: function(a, b) {
- b.success = !1;
- b.exceptionReport = {
- version: a.getAttribute("version"),
- language: a.getAttribute("language"),
- exceptions: []
- };
- this.readChildNodes(a, b.exceptionReport)
- }
- }, GeoGlobe.Format.OWSCommon.v1.prototype.readers.ows)
- },
- writers: {
- ows: GeoGlobe.Format.OWSCommon.v1.prototype.writers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.OWSCommon.v1_0_0"
- });
- GeoGlobe.Format.OWSCommon.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Format.OWSCommon.v1, {
- namespaces: {
- ows: "http://www.opengis.net/ows/1.1",
- xlink: "http://www.w3.org/1999/xlink"
- },
- readers: {
- ows: GeoGlobe.Util.applyDefaults({
- ExceptionReport: function(a, b) {
- b.exceptionReport = {
- version: a.getAttribute("version"),
- language: a.getAttribute("xml:lang"),
- exceptions: []
- };
- this.readChildNodes(a, b.exceptionReport)
- },
- AllowedValues: function(a, b) {
- b.allowedValues = {};
- this.readChildNodes(a, b.allowedValues)
- },
- AnyValue: function(a, b) {
- b.anyValue = !0
- },
- DataType: function(a, b) {
- b.dataType = this.getChildValue(a)
- },
- Range: function(a, b) {
- b.range = {};
- this.readChildNodes(a, b.range)
- },
- MinimumValue: function(a, b) {
- b.minValue = this.getChildValue(a)
- },
- MaximumValue: function(a, b) {
- b.maxValue = this.getChildValue(a)
- },
- Identifier: function(a, b) {
- b.identifier = this.getChildValue(a)
- },
- SupportedCRS: function(a, b) {
- b.supportedCRS = this.getChildValue(a)
- }
- }, GeoGlobe.Format.OWSCommon.v1.prototype.readers.ows)
- },
- writers: {
- ows: GeoGlobe.Util.applyDefaults({
- Range: function(a) {
- var b = this.createElementNSPlus("ows:Range", {
- attributes: {
- "ows:rangeClosure": a.closure
- }
- });
- this.writeNode("ows:MinimumValue", a.minValue, b);
- this.writeNode("ows:MaximumValue", a.maxValue, b);
- return b
- },
- MinimumValue: function(a) {
- return this.createElementNSPlus("ows:MinimumValue", {
- value: a
- })
- },
- MaximumValue: function(a) {
- return this.createElementNSPlus("ows:MaximumValue", {
- value: a
- })
- },
- Value: function(a) {
- return this.createElementNSPlus("ows:Value", {
- value: a
- })
- }
- }, GeoGlobe.Format.OWSCommon.v1.prototype.writers.ows)
- },
- CLASS_NAME: "GeoGlobe.Format.OWSCommon.v1_1_0"
- });
- GeoGlobe.Format.WFSCapabilities = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.1.0",
- CLASS_NAME: "GeoGlobe.Format.WFSCapabilities"
- });
- GeoGlobe.Format.WFSCapabilities.v1 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- wfs: "http://www.opengis.net/wfs",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance",
- ows: "http://www.opengis.net/ows"
- },
- errorProperty: "featureTypeList",
- defaultPrefix: "wfs",
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- this.readNode(a, b);
- return b
- },
- readers: {
- wfs: {
- WFS_Capabilities: function(a,
- b) {
- this.readChildNodes(a, b)
- },
- FeatureTypeList: function(a, b) {
- b.featureTypeList = {
- featureTypes: []
- };
- this.readChildNodes(a, b.featureTypeList)
- },
- FeatureType: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.featureTypes.push(c)
- },
- Name: function(a, b) {
- var c = this.getChildValue(a);
- b.realName = c;
- if (c && (c = c.split(":"), b.name = c.pop(), c.length > 0)) b.featureNS = this.lookupNamespaceURI(a, c[0])
- },
- Title: function(a, b) {
- var c = this.getChildValue(a);
- if (c) b.title = c
- },
- Abstract: function(a, b) {
- var c = this.getChildValue(a);
- c && (b["abstract"] = c)
- }
- }
- },
- CLASS_NAME: "GeoGlobe.Format.WFSCapabilities.v1"
- });
- GeoGlobe.Format.WFSCapabilities.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.WFSCapabilities.v1, {
- readers: {
- wfs: GeoGlobe.Util.applyDefaults({
- Service: function(a, b) {
- b.service = {};
- this.readChildNodes(a, b.service)
- },
- Fees: function(a, b) {
- var c = this.getChildValue(a);
- if (c && c.toLowerCase() != "none") b.fees = c
- },
- AccessConstraints: function(a, b) {
- var c = this.getChildValue(a);
- if (c && c.toLowerCase() != "none") b.accessConstraints = c
- },
- OnlineResource: function(a, b) {
- var c = this.getChildValue(a);
- if (c && c.toLowerCase() != "none") b.onlineResource =
- c
- },
- Keywords: function(a, b) {
- var c = this.getChildValue(a);
- if (c && c.toLowerCase() != "none") b.keywords = c.split(", ")
- },
- Capability: function(a, b) {
- b.capability = {};
- this.readChildNodes(a, b.capability)
- },
- Request: function(a, b) {
- b.request = {};
- this.readChildNodes(a, b.request)
- },
- GetFeature: function(a, b) {
- b.getfeature = {
- href: {},
- formats: []
- };
- this.readChildNodes(a, b.getfeature)
- },
- ResultFormat: function(a, b) {
- for (var c = a.childNodes, d, e = 0; e < c.length; e++) d = c[e], d.nodeType == 1 && b.formats.push(d.nodeName)
- },
- DCPType: function(a, b) {
- this.readChildNodes(a,
- b)
- },
- HTTP: function(a, b) {
- this.readChildNodes(a, b.href)
- },
- Get: function(a, b) {
- b.get = a.getAttribute("onlineResource")
- },
- Post: function(a, b) {
- b.post = a.getAttribute("onlineResource")
- },
- SRS: function(a, b) {
- var c = this.getChildValue(a);
- if (c) b.srs = c
- },
- LatLongBoundingBox: function(a, b) {
- var c = a.getAttribute("minx"),
- d = a.getAttribute("miny"),
- e = a.getAttribute("maxx"),
- f = a.getAttribute("maxy");
- b.bbox = c + "," + d + "," + e + "," + f
- },
- TemporalFeatureLayer: function(a, b) {
- b.temporalFeatureLayers = [];
- var c = {};
- this.readChildNodes(a, c);
- b.temporalFeatureLayers.push(c)
- },
- Extent: function(a, b) {
- b.defaultTime = a.getAttribute("default");
- var c = this.getChildValue(a).split("/");
- b.time = c
- },
- Dimension: function(a, b) {
- b.defaultTime = a.getAttribute("default");
- var c = this.getChildValue(a).split("/");
- b.time = c
- }
- }, GeoGlobe.Format.WFSCapabilities.v1.prototype.readers.wfs)
- },
- CLASS_NAME: "GeoGlobe.Format.WFSCapabilities.v1_0_0"
- });
- GeoGlobe.Format.WFSCapabilities.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Format.WFSCapabilities.v1, {
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- readers: {
- wfs: GeoGlobe.Util.applyDefaults({
- DefaultSRS: function(a, b) {
- var c = this.getChildValue(a);
- if (c) b.srs = c
- },
- WGS84BoundingBox: function(a, b) {
- var c = this.getChildValue(a.getElementsByTagName("ows:LowerCorner")[0]).split(" "),
- d = this.getChildValue(a.getElementsByTagName("ows:UpperCorner")[0]).split(" ");
- b.bbox = c[0] + "," + c[1] +
- "," + d[0] + "," + d[1]
- },
- TemporalFeatureLayer: function(a, b) {
- b.temporalFeatureLayers = [];
- var c = {};
- this.readChildNodes(a, c);
- b.temporalFeatureLayers.push(c)
- },
- Extent: function(a, b) {
- b.defaultTime = a.getAttribute("default");
- var c = this.getChildValue(a).split("/");
- b.time = c
- },
- Dimension: function(a, b) {
- b.defaultTime = a.getAttribute("default");
- var c = this.getChildValue(a).split("/");
- b.time = c
- }
- }, GeoGlobe.Format.WFSCapabilities.v1.prototype.readers.wfs),
- ows: GeoGlobe.Format.OWSCommon.v1.prototype.readers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.WFSCapabilities.v1_1_0"
- });
- GeoGlobe.Format.WFSDescribeFeatureType = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- regExes: {
- trimSpace: /^\s*|\s*$/g
- },
- namespaces: {
- xsd: "http://www.w3.org/2001/XMLSchema"
- },
- readers: {
- xsd: {
- schema: function(a, b) {
- var c = [],
- d = {},
- e, f;
- this.readChildNodes(a, {
- complexTypes: c,
- customTypes: d
- });
- var g = a.attributes,
- h, j;
- e = 0;
- for (f = g.length; e < f; ++e) h = g[e], j = h.name, j.indexOf("xmlns") === 0 ? this.setNamespace(j.split(":")[1] || "", h.value) : b[j] = h.value;
- b.featureTypes = c;
- b.targetPrefix = this.namespaceAlias[b.targetNamespace];
- e = 0;
- for (f = c.length; e <
- f; ++e)
- if (g = c[e], h = d[g.typeName], d[g.typeName]) g.typeName = h.name
- },
- complexType: function(a, b) {
- var c = {
- typeName: a.getAttribute("name")
- };
- this.readChildNodes(a, c);
- b.complexTypes.push(c)
- },
- complexContent: function(a, b) {
- this.readChildNodes(a, b)
- },
- extension: function(a, b) {
- this.readChildNodes(a, b)
- },
- sequence: function(a, b) {
- var c = {
- elements: []
- };
- this.readChildNodes(a, c);
- b.properties = c.elements
- },
- element: function(a, b) {
- var c;
- if (b.elements) {
- var d = {};
- c = a.attributes;
- for (var e, f = 0, g = c.length; f < g; ++f) e = c[f], d[e.name] = e.value;
- c = d.type || d.ref;
- if (!c) c = {}, this.readChildNodes(a, c), d.restriction = c, d.type = c.base;
- d.localType = (c.base || c).split(":").pop();
- b.elements.push(d);
- this.readChildNodes(a, d)
- }
- b.complexTypes && (c = a.getAttribute("type"), d = c.split(":").pop(), b.customTypes[d] = {
- name: a.getAttribute("name"),
- type: c
- })
- },
- annotation: function(a, b) {
- b.annotation = {};
- this.readChildNodes(a, b.annotation)
- },
- appinfo: function(a, b) {
- if (!b.appinfo) b.appinfo = [];
- b.appinfo.push(this.getChildValue(a))
- },
- documentation: function(a, b) {
- if (!b.documentation) b.documentation = [];
- var c = this.getChildValue(a);
- b.documentation.push({
- lang: a.getAttribute("xml:lang"),
- textContent: c.replace(this.regExes.trimSpace, "")
- })
- },
- simpleType: function(a, b) {
- this.readChildNodes(a, b)
- },
- restriction: function(a, b) {
- b.base = a.getAttribute("base");
- this.readRestriction(a, b)
- }
- }
- },
- readRestriction: function(a, b) {
- for (var c = a.childNodes, d, e, f = 0, g = c.length; f < g; ++f) d = c[f], d.nodeType == 1 && (e = d.nodeName.split(":").pop(), d = d.getAttribute("value"), b[e] ? (typeof b[e] == "string" && (b[e] = [b[e]]), b[e].push(d)) : b[e] = d)
- },
- read: function(a) {
- typeof a ==
- "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- if (a.nodeName.split(":").pop() === "ExceptionReport") {
- var c = new GeoGlobe.Format.OGCExceptionReport;
- b.error = c.read(a)
- } else this.readNode(a, b);
- return b
- },
- CLASS_NAME: "GeoGlobe.Format.WFSDescribeFeatureType"
- });
- GeoGlobe.Format.WKT = GeoGlobe.Class4OL(GeoGlobe.Format, {
- initialize: function(a) {
- this.regExes = {
- typeStr: /^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,
- spaces: /\s+/,
- parenComma: /\)\s*,\s*\(/,
- doubleParenComma: /\)\s*\)\s*,\s*\(\s*\(/,
- trimParens: /^\s*\(?(.*?)\)?\s*$/
- };
- GeoGlobe.Format.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- var b, c, a = a.replace(/[\n\r]/g, " ");
- if (c = this.regExes.typeStr.exec(a))
- if (a = c[1].toLowerCase(), c = c[2], this.parse[a] && (b = this.parse[a].apply(this, [c])), this.internalProjection && this.externalProjection)
- if (b &&
- b.CLASS_NAME == "GeoGlobe.Feature") b.geometry.transform(this.externalProjection, this.internalProjection);
- else if (b && a != "geometrycollection" && typeof b == "object") {
- a = 0;
- for (c = b.length; a < c; a++) b[a].geometry.transform(this.externalProjection, this.internalProjection)
- }
- return b
- },
- write: function(a) {
- var b, c;
- a.constructor == Array ? c = !0 : (a = [a], c = !1);
- var d = [];
- c && d.push("GEOMETRYCOLLECTION(");
- for (var e = 0, f = a.length; e < f; ++e) c && e > 0 && d.push(","), b = a[e].geometry, d.push(this.extractGeometry(b));
- c && d.push(")");
- return d.join("")
- },
- extractGeometry: function(a) {
- var b = a.CLASS_NAME.split(".")[2].toLowerCase();
- if (!this.extract[b]) return null;
- this.internalProjection && this.externalProjection && (a = a.clone(), a.transform(this.internalProjection, this.externalProjection));
- return (b == "collection" ? "GEOMETRYCOLLECTION" : b.toUpperCase()) + "(" + this.extract[b].apply(this, [a]) + ")"
- },
- extract: {
- point: function(a) {
- return a.x + " " + a.y
- },
- multipoint: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push("(" + this.extract.point.apply(this, [a.components[c]]) +
- ")");
- return b.join(",")
- },
- linestring: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extract.point.apply(this, [a.components[c]]));
- return b.join(",")
- },
- multilinestring: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push("(" + this.extract.linestring.apply(this, [a.components[c]]) + ")");
- return b.join(",")
- },
- polygon: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push("(" + this.extract.linestring.apply(this, [a.components[c]]) + ")");
- return b.join(",")
- },
- multipolygon: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push("(" + this.extract.polygon.apply(this, [a.components[c]]) + ")");
- return b.join(",")
- },
- collection: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extractGeometry.apply(this, [a.components[c]]));
- return b.join(",")
- }
- },
- parse: {
- point: function(a) {
- a = GeoGlobe.String.trim(a).split(this.regExes.spaces);
- return new GeoGlobe.Feature(new GeoGlobe.Geometry.Point(a[0], a[1]))
- },
- multipoint: function(a) {
- for (var b = GeoGlobe.String.trim(a).split(","), c = [], d = 0, e = b.length; d <
- e; ++d) a = b[d].replace(this.regExes.trimParens, "$1"), c.push(this.parse.point.apply(this, [a]).geometry);
- return new GeoGlobe.Feature(new GeoGlobe.Geometry.MultiPoint(c))
- },
- linestring: function(a) {
- for (var a = GeoGlobe.String.trim(a).split(","), b = [], c = 0, d = a.length; c < d; ++c) b.push(this.parse.point.apply(this, [a[c]]).geometry);
- return new GeoGlobe.Feature(new GeoGlobe.Geometry.LineString(b))
- },
- multilinestring: function(a) {
- for (var b = GeoGlobe.String.trim(a).split(this.regExes.parenComma), c = [], d = 0, e = b.length; d < e; ++d) a =
- b[d].replace(this.regExes.trimParens, "$1"), c.push(this.parse.linestring.apply(this, [a]).geometry);
- return new GeoGlobe.Feature(new GeoGlobe.Geometry.MultiLineString(c))
- },
- polygon: function(a) {
- for (var b, a = GeoGlobe.String.trim(a).split(this.regExes.parenComma), c = [], d = 0, e = a.length; d < e; ++d) b = a[d].replace(this.regExes.trimParens, "$1"), b = this.parse.linestring.apply(this, [b]).geometry, b = new GeoGlobe.Geometry.LinearRing(b.components), c.push(b);
- return new GeoGlobe.Feature(new GeoGlobe.Geometry.Polygon(c))
- },
- multipolygon: function(a) {
- for (var b =
- GeoGlobe.String.trim(a).split(this.regExes.doubleParenComma), c = [], d = 0, e = b.length; d < e; ++d) a = b[d].replace(this.regExes.trimParens, "$1"), c.push(this.parse.polygon.apply(this, [a]).geometry);
- return new GeoGlobe.Feature(new GeoGlobe.Geometry.MultiPolygon(c))
- },
- geometrycollection: function(a) {
- for (var a = a.replace(/,\s*([A-Za-z])/g, "|$1"), a = GeoGlobe.String.trim(a).split("|"), b = [], c = 0, d = a.length; c < d; ++c) b.push(GeoGlobe.Format.WKT.prototype.read.apply(this, [a[c]]));
- return b
- }
- },
- CLASS_NAME: "GeoGlobe.Format.WKT"
- });
- GeoGlobe.Format.CQL = function() {
- function a(a) {
- function b() {
- var a = e.pop();
- switch (a.type) {
- case "LOGICAL":
- var c = b(),
- g = b();
- return new GeoGlobe.Filter.Logical({
- filters: [g, c],
- type: f[a.text.toUpperCase()]
- });
- case "NOT":
- return a = b(), new GeoGlobe.Filter.Logical({
- filters: [a],
- type: GeoGlobe.Filter.Logical.NOT
- });
- case "BETWEEN":
- return e.pop(), g = b(), a = b(), c = b(), new GeoGlobe.Filter.Comparison({
- property: c,
- lowerBoundary: a,
- upperBoundary: g,
- type: GeoGlobe.Filter.Comparison.BETWEEN
- });
- case "COMPARISON":
- return g = b(), c = b(),
- new GeoGlobe.Filter.Comparison({
- property: c,
- value: g,
- type: d[a.text.toUpperCase()]
- });
- case "IS_NULL":
- return c = b(), new GeoGlobe.Filter.Comparison({
- property: c,
- type: d[a.text.toUpperCase()]
- });
- case "VALUE":
- return (c = a.text.match(/^'(.*)'$/)) ? c[1].replace(/''/g, "'") : Number(a.text);
- case "SPATIAL":
- switch (a.text.toUpperCase()) {
- case "BBOX":
- var a = b(),
- c = b(),
- g = b(),
- h = b(),
- j = b();
- return new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.BBOX,
- property: j,
- value: GeoGlobe.LngLatBounds.fromArray([h, g, c, a])
- });
- case "INTERSECTS":
- return g =
- b(), c = b(), new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.INTERSECTS,
- property: c,
- value: g
- });
- case "WITHIN":
- return g = b(), c = b(), new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.WITHIN,
- property: c,
- value: g
- });
- case "CONTAINS":
- return g = b(), c = b(), new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.CONTAINS,
- property: c,
- value: g
- });
- case "DWITHIN":
- return a = b(), g = b(), c = b(), new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.DWITHIN,
- value: g,
- property: c,
- distance: Number(a)
- })
- }
- case "GEOMETRY":
- return GeoGlobe.Geometry.fromWKT(a.text);
- default:
- return a.text
- }
- }
- for (var c = [], e = []; a.length;) {
- var g = a.shift();
- switch (g.type) {
- case "PROPERTY":
- case "GEOMETRY":
- case "VALUE":
- e.push(g);
- break;
- case "COMPARISON":
- case "BETWEEN":
- case "IS_NULL":
- case "LOGICAL":
- for (var j = h[g.type]; c.length > 0 && h[c[c.length - 1].type] <= j;) e.push(c.pop());
- c.push(g);
- break;
- case "SPATIAL":
- case "NOT":
- case "LPAREN":
- c.push(g);
- break;
- case "RPAREN":
- for (; c.length > 0 && c[c.length - 1].type != "LPAREN";) e.push(c.pop());
- c.pop();
- c.length > 0 && c[c.length - 1].type == "SPATIAL" && e.push(c.pop());
- case "COMMA":
- case "END":
- break;
- default:
- throw Error("Unknown token type " + g.type);
- }
- }
- for (; c.length > 0;) e.push(c.pop());
- a = b();
- if (e.length > 0) {
- a = "Remaining tokens after building AST: \n";
- for (c = e.length - 1; c >= 0; c--) a += e[c].type + ": " + e[c].text + "\n";
- throw Error(a);
- }
- return a
- }
- var b = {
- PROPERTY: /^[_a-zA-Z]\w*/,
- COMPARISON: /^(=|<>|<=|<|>=|>|LIKE)/i,
- IS_NULL: /^IS NULL/i,
- COMMA: /^,/,
- LOGICAL: /^(AND|OR)/i,
- VALUE: /^('([^']|'')*'|\d+(\.\d*)?|\.\d+)/,
- LPAREN: /^\(/,
- RPAREN: /^\)/,
- SPATIAL: /^(BBOX|INTERSECTS|DWITHIN|WITHIN|CONTAINS)/i,
- NOT: /^NOT/i,
- BETWEEN: /^BETWEEN/i,
- GEOMETRY: function(a) {
- var b = /^(POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)/.exec(a);
- if (b) {
- var c = a.length,
- b = a.indexOf("(", b[0].length);
- if (b > -1)
- for (var d = 1; b < c && d > 0;) switch (b++, a.charAt(b)) {
- case "(":
- d++;
- break;
- case ")":
- d--
- }
- return [a.substr(0, b + 1)]
- }
- },
- END: /^$/
- },
- c = {
- LPAREN: ["GEOMETRY", "SPATIAL", "PROPERTY", "VALUE", "LPAREN"],
- RPAREN: ["NOT", "LOGICAL", "END", "RPAREN"],
- PROPERTY: ["COMPARISON", "BETWEEN", "COMMA", "IS_NULL"],
- BETWEEN: ["VALUE"],
- IS_NULL: ["END"],
- COMPARISON: ["VALUE"],
- COMMA: ["GEOMETRY", "VALUE", "PROPERTY"],
- VALUE: ["LOGICAL", "COMMA", "RPAREN", "END"],
- SPATIAL: ["LPAREN"],
- LOGICAL: ["NOT", "VALUE", "SPATIAL", "PROPERTY", "LPAREN"],
- NOT: ["PROPERTY", "LPAREN"],
- GEOMETRY: ["COMMA", "RPAREN"]
- },
- d = {
- "=": GeoGlobe.Filter.Comparison.EQUAL_TO,
- "<>": GeoGlobe.Filter.Comparison.NOT_EQUAL_TO,
- "<": GeoGlobe.Filter.Comparison.LESS_THAN,
- "<=": GeoGlobe.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,
- ">": GeoGlobe.Filter.Comparison.GREATER_THAN,
- ">=": GeoGlobe.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
- LIKE: GeoGlobe.Filter.Comparison.LIKE,
- BETWEEN: GeoGlobe.Filter.Comparison.BETWEEN,
- "IS NULL": GeoGlobe.Filter.Comparison.IS_NULL
- },
- e = {},
- f = {
- AND: GeoGlobe.Filter.Logical.AND,
- OR: GeoGlobe.Filter.Logical.OR
- },
- g = {},
- h = {
- RPAREN: 3,
- LOGICAL: 2,
- COMPARISON: 1
- },
- j;
- for (j in d) d.hasOwnProperty(j) && (e[d[j]] = j);
- for (j in f) f.hasOwnProperty(j) && (g[f[j]] = j);
- return GeoGlobe.Class4OL(GeoGlobe.Format, {
- read: function(d) {
- var e = d,
- d = [],
- f, g = ["NOT", "GEOMETRY", "SPATIAL", "PROPERTY", "LPAREN"];
- do {
- a: {
- f = g;
- for (var h = void 0, g = void 0, j = f.length, h = 0; h < j; h++) {
- var g = f[h],
- s = b[g] instanceof
- RegExp ? b[g].exec(e) : (0, b[g])(e);
- if (s) {
- f = s[0];
- e = e.substr(f.length).replace(/^\s*/, "");
- f = {
- type: g,
- text: f,
- remainder: e
- };
- break a
- }
- }
- d = "ERROR: In parsing: [" + e + "], expected one of: ";
- for (h = 0; h < j; h++) g = f[h],
- d += "\n " + g + ": " + b[g];
- throw Error(d);
- }
- e = f.remainder;g = c[f.type];
- if (f.type != "END" && !g) throw Error("No follows list for " + f.type);d.push(f)
- } while (f.type != "END");
- d = a(d);
- if (this.keepData) this.data = d;
- return d
- },
- write: function(a) {
- if (a instanceof GeoGlobe.Geometry) return a.toString();
- switch (a.CLASS_NAME) {
- case "GeoGlobe.Filter.Spatial":
- switch (a.type) {
- case GeoGlobe.Filter.Spatial.BBOX:
- return "BBOX(" +
- a.property + "," + a.value.toBBOX() + ")";
- case GeoGlobe.Filter.Spatial.DWITHIN:
- return "DWITHIN(" + a.property + ", " + this.write(a.value) + ", " + a.distance + ")";
- case GeoGlobe.Filter.Spatial.WITHIN:
- return "WITHIN(" + a.property + ", " + this.write(a.value) + ")";
- case GeoGlobe.Filter.Spatial.INTERSECTS:
- return "INTERSECTS(" + a.property + ", " + this.write(a.value) + ")";
- case GeoGlobe.Filter.Spatial.CONTAINS:
- return "CONTAINS(" + a.property + ", " + this.write(a.value) + ")";
- default:
- throw Error("Unknown spatial filter type: " + a.type);
- }
- case "GeoGlobe.Filter.Logical":
- if (a.type ==
- GeoGlobe.Filter.Logical.NOT) return "NOT (" + this.write(a.filters[0]) + ")";
- else {
- for (var b = "(", c = !0, d = 0; d < a.filters.length; d++) c ? c = !1 : b += ") " + g[a.type] + " (", b += this.write(a.filters[d]);
- return b + ")"
- }
- case "GeoGlobe.Filter.Comparison":
- return a.type == GeoGlobe.Filter.Comparison.BETWEEN ? a.property + " BETWEEN " + this.write(a.lowerBoundary) + " AND " + this.write(a.upperBoundary) : a.value !== null ? a.property + " " + e[a.type] + " " + this.write(a.value) : a.property + " " + e[a.type];
- case void 0:
- if (typeof a === "string") return "'" + a.replace(/'/g,
- "''") + "'";
- else if (typeof a === "number") return String(a);
- default:
- throw Error("Can't encode: " + a.CLASS_NAME + " " + a);
- }
- },
- CLASS_NAME: "GeoGlobe.Format.CQL"
- })
- }();
- GeoGlobe.Format.Filter = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.0.0",
- CLASS_NAME: "GeoGlobe.Format.Filter"
- });
- GeoGlobe.Format.Filter.v1 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- ogc: "http://www.opengis.net/ogc",
- gml: "http://www.opengis.net/gml",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance"
- },
- defaultPrefix: "ogc",
- schemaLocation: null,
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- var b = {};
- this.readers.ogc.Filter.apply(this, [a, b]);
- return b.filter
- },
- readers: {
- ogc: {
- _expression: function(a) {
- for (var b = "", c = a.firstChild; c; c =
- c.nextSibling) switch (c.nodeType) {
- case 1:
- a = this.readNode(c);
- a.property ? b += "${" + a.property + "}" : a.value !== void 0 && (b += a.value);
- break;
- case 3:
- case 4:
- b += c.nodeValue
- }
- return b
- },
- Filter: function(a, b) {
- var c = {
- fids: [],
- filters: []
- };
- this.readChildNodes(a, c);
- if (c.fids.length > 0) b.filter = new GeoGlobe.Filter.FeatureId({
- fids: c.fids
- });
- else if (c.filters.length > 0) b.filter = c.filters[0]
- },
- FeatureId: function(a, b) {
- var c = a.getAttribute("fid");
- c && b.fids.push(c)
- },
- And: function(a, b) {
- var c = new GeoGlobe.Filter.Logical({
- type: GeoGlobe.Filter.Logical.AND
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- Or: function(a, b) {
- var c = new GeoGlobe.Filter.Logical({
- type: GeoGlobe.Filter.Logical.OR
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- Not: function(a, b) {
- var c = new GeoGlobe.Filter.Logical({
- type: GeoGlobe.Filter.Logical.NOT
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsLessThan: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.LESS_THAN
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsGreaterThan: function(a, b) {
- var c =
- new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.GREATER_THAN
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsLessThanOrEqualTo: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.LESS_THAN_OR_EQUAL_TO
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsGreaterThanOrEqualTo: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsBetween: function(a,
- b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.BETWEEN
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- Literal: function(a, b) {
- b.value = GeoGlobe.String.numericIf(this.getChildValue(a), !0)
- },
- PropertyName: function(a, b) {
- b.property = this.getChildValue(a)
- },
- LowerBoundary: function(a, b) {
- b.lowerBoundary = GeoGlobe.String.numericIf(this.readers.ogc._expression.call(this, a), !0)
- },
- UpperBoundary: function(a, b) {
- b.upperBoundary = GeoGlobe.String.numericIf(this.readers.ogc._expression.call(this, a), !0)
- },
- Intersects: function(a, b) {
- this.readSpatial(a, b, GeoGlobe.Filter.Spatial.INTERSECTS)
- },
- Within: function(a, b) {
- this.readSpatial(a, b, GeoGlobe.Filter.Spatial.WITHIN)
- },
- Contains: function(a, b) {
- this.readSpatial(a, b, GeoGlobe.Filter.Spatial.CONTAINS)
- },
- DWithin: function(a, b) {
- this.readSpatial(a, b, GeoGlobe.Filter.Spatial.DWITHIN)
- },
- Distance: function(a, b) {
- b.distance = parseInt(this.getChildValue(a));
- b.distanceUnits = a.getAttribute("units")
- },
- Function: function() {},
- PropertyIsNull: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.IS_NULL
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- }
- }
- },
- readSpatial: function(a, b, c) {
- c = new GeoGlobe.Filter.Spatial({
- type: c
- });
- this.readChildNodes(a, c);
- c.value = c.components[0];
- delete c.components;
- b.filters.push(c)
- },
- encodeLiteral: function(a) {
- a instanceof Date && (a = GeoGlobe.Date.toISOString(a));
- return a
- },
- writeOgcExpression: function(a, b) {
- a instanceof GeoGlobe.Filter.Function ? this.writeNode("Function", a, b) : this.writeNode("Literal", a, b);
- return b
- },
- write: function(a) {
- return this.writers.ogc.Filter.apply(this, [a])
- },
- writers: {
- ogc: {
- Filter: function(a) {
- var b =
- this.createElementNSPlus("ogc:Filter");
- this.writeNode(this.getFilterType(a), a, b);
- return b
- },
- _featureIds: function(a) {
- for (var b = this.createDocumentFragment(), c = 0, d = a.fids.length; c < d; ++c) this.writeNode("ogc:FeatureId", a.fids[c], b);
- return b
- },
- FeatureId: function(a) {
- return this.createElementNSPlus("ogc:FeatureId", {
- attributes: {
- fid: a
- }
- })
- },
- And: function(a) {
- for (var b = this.createElementNSPlus("ogc:And"), c, d = 0, e = a.filters.length; d < e; ++d) c = a.filters[d], this.writeNode(this.getFilterType(c), c, b);
- return b
- },
- Or: function(a) {
- for (var b =
- this.createElementNSPlus("ogc:Or"), c, d = 0, e = a.filters.length; d < e; ++d) c = a.filters[d], this.writeNode(this.getFilterType(c), c, b);
- return b
- },
- Not: function(a) {
- var b = this.createElementNSPlus("ogc:Not"),
- a = a.filters[0];
- this.writeNode(this.getFilterType(a), a, b);
- return b
- },
- PropertyIsLessThan: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsLessThan");
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsGreaterThan: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsGreaterThan");
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsLessThanOrEqualTo: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsGreaterThanOrEqualTo: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsBetween: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsBetween");
- this.writeNode("PropertyName", a, b);
- this.writeNode("LowerBoundary", a, b);
- this.writeNode("UpperBoundary", a, b);
- return b
- },
- PropertyName: function(a) {
- return this.createElementNSPlus("ogc:PropertyName", {
- value: a.property
- })
- },
- Literal: function(a) {
- return this.createElementNSPlus("ogc:Literal", {
- value: (this.encodeLiteral || GeoGlobe.Format.Filter.v1.prototype.encodeLiteral)(a)
- })
- },
- LowerBoundary: function(a) {
- var b = this.createElementNSPlus("ogc:LowerBoundary");
- this.writeOgcExpression(a.lowerBoundary, b);
- return b
- },
- UpperBoundary: function(a) {
- var b =
- this.createElementNSPlus("ogc:UpperBoundary");
- this.writeNode("Literal", a.upperBoundary, b);
- return b
- },
- INTERSECTS: function(a) {
- return this.writeSpatial(a, "Intersects")
- },
- WITHIN: function(a) {
- return this.writeSpatial(a, "Within")
- },
- CONTAINS: function(a) {
- return this.writeSpatial(a, "Contains")
- },
- DWITHIN: function(a) {
- var b = this.writeSpatial(a, "DWithin");
- this.writeNode("Distance", a, b);
- return b
- },
- Distance: function(a) {
- return this.createElementNSPlus("ogc:Distance", {
- attributes: {
- units: a.distanceUnits
- },
- value: a.distance
- })
- },
- Function: function(a) {
- for (var b = this.createElementNSPlus("ogc:Function", {
- attributes: {
- name: a.name
- }
- }), a = a.params, c = 0, d = a.length; c < d; c++) this.writeOgcExpression(a[c], b);
- return b
- },
- PropertyIsNull: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsNull");
- this.writeNode("PropertyName", a, b);
- return b
- },
- SortBy: function(a) {
- for (var b = this.createElementNSPlus("ogc:SortBy"), c = 0, d = a.length; c < d; c++) this.writeNode("ogc:SortProperty", a[c], b);
- return b
- },
- SortProperty: function(a) {
- var b = this.createElementNSPlus("ogc:SortProperty");
- this.writeNode("ogc:PropertyName", a, b);
- this.writeNode("ogc:SortOrder", a.order == "DESC" ? "DESC" : "ASC", b);
- return b
- },
- SortOrder: function(a) {
- return this.createElementNSPlus("ogc:SortOrder", {
- value: a
- })
- }
- }
- },
- getFilterType: function(a) {
- var b = this.filterMap[a.type];
- if (!b) throw "Filter writing not supported for rule type: " + a.type;
- return b
- },
- filterMap: {
- "&&": "And",
- "||": "Or",
- "!": "Not",
- "==": "PropertyIsEqualTo",
- "!=": "PropertyIsNotEqualTo",
- "<": "PropertyIsLessThan",
- ">": "PropertyIsGreaterThan",
- "<=": "PropertyIsLessThanOrEqualTo",
- ">=": "PropertyIsGreaterThanOrEqualTo",
- "..": "PropertyIsBetween",
- "~": "PropertyIsLike",
- NULL: "PropertyIsNull",
- BBOX: "BBOX",
- DWITHIN: "DWITHIN",
- WITHIN: "WITHIN",
- CONTAINS: "CONTAINS",
- INTERSECTS: "INTERSECTS",
- FID: "_featureIds"
- },
- CLASS_NAME: "GeoGlobe.Format.Filter.v1"
- });
- GeoGlobe.Format.Filter.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.GML.v2, GeoGlobe.Format.Filter.v1, {
- VERSION: "1.0.0",
- schemaLocation: "http://www.opengis.net/ogc/filter/1.0.0/filter.xsd",
- initialize: function(a) {
- GeoGlobe.Format.GML.v2.prototype.initialize.apply(this, [a])
- },
- readers: {
- ogc: GeoGlobe.Util.applyDefaults({
- PropertyIsEqualTo: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.EQUAL_TO
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsNotEqualTo: function(a, b) {
- var c =
- new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.NOT_EQUAL_TO
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsLike: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.LIKE
- });
- this.readChildNodes(a, c);
- var d = a.getAttribute("wildCard"),
- e = a.getAttribute("singleChar"),
- f = a.getAttribute("escape");
- c.value2regex(d, e, f);
- b.filters.push(c)
- }
- }, GeoGlobe.Format.Filter.v1.prototype.readers.ogc),
- gml: GeoGlobe.Format.GML.v2.prototype.readers.gml,
- feature: GeoGlobe.Format.GML.v2.prototype.readers.feature
- },
- writers: {
- ogc: GeoGlobe.Util.applyDefaults({
- PropertyIsEqualTo: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsEqualTo");
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsNotEqualTo: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsLike: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsLike", {
- attributes: {
- wildCard: "*",
- singleChar: ".",
- escape: "!"
- }
- });
- this.writeNode("PropertyName", a, b);
- this.writeNode("Literal", a.regex2value(), b);
- return b
- },
- BBOX: function(a) {
- var b = this.createElementNSPlus("ogc:BBOX");
- a.property && this.writeNode("PropertyName", a, b);
- var c = this.writeNode("gml:Box", a.value, b);
- a.projection && c.setAttribute("srsName", a.projection);
- return b
- }
- }, GeoGlobe.Format.Filter.v1.prototype.writers.ogc),
- gml: GeoGlobe.Format.GML.v2.prototype.writers.gml,
- feature: GeoGlobe.Format.GML.v2.prototype.writers.feature
- },
- writeSpatial: function(a, b) {
- var c = this.createElementNSPlus("ogc:" +
- b);
- this.writeNode("PropertyName", a, c);
- if (a.value instanceof GeoGlobe.Filter.Function) this.writeNode("Function", a.value, c);
- else {
- var d;
- d = a.value instanceof GeoGlobe.Geometry ? this.writeNode("feature:_geometry", a.value).firstChild : this.writeNode("gml:Box", a.value);
- a.projection && d.setAttribute("srsName", a.projection);
- c.appendChild(d)
- }
- return c
- },
- CLASS_NAME: "GeoGlobe.Format.Filter.v1_0_0"
- });
- GeoGlobe.Format.Filter.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Format.GML.v3, GeoGlobe.Format.Filter.v1, {
- VERSION: "1.1.0",
- schemaLocation: "http://www.opengis.net/ogc/filter/1.1.0/filter.xsd",
- initialize: function(a) {
- GeoGlobe.Format.GML.v3.prototype.initialize.apply(this, [a])
- },
- readers: {
- ogc: GeoGlobe.Util.applyDefaults({
- PropertyIsEqualTo: function(a, b) {
- var c = a.getAttribute("matchCase"),
- c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.EQUAL_TO,
- matchCase: !(c === "false" || c === "0")
- });
- this.readChildNodes(a,
- c);
- b.filters.push(c)
- },
- PropertyIsNotEqualTo: function(a, b) {
- var c = a.getAttribute("matchCase"),
- c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.NOT_EQUAL_TO,
- matchCase: !(c === "false" || c === "0")
- });
- this.readChildNodes(a, c);
- b.filters.push(c)
- },
- PropertyIsLike: function(a, b) {
- var c = new GeoGlobe.Filter.Comparison({
- type: GeoGlobe.Filter.Comparison.LIKE
- });
- this.readChildNodes(a, c);
- var d = a.getAttribute("wildCard"),
- e = a.getAttribute("singleChar"),
- f = a.getAttribute("escapeChar");
- c.value2regex(d, e, f);
- b.filters.push(c)
- }
- },
- GeoGlobe.Format.Filter.v1.prototype.readers.ogc),
- gml: GeoGlobe.Format.GML.v3.prototype.readers.gml,
- feature: GeoGlobe.Format.GML.v3.prototype.readers.feature
- },
- writers: {
- ogc: GeoGlobe.Util.applyDefaults({
- PropertyIsEqualTo: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsEqualTo", {
- attributes: {
- matchCase: a.matchCase
- }
- });
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsNotEqualTo: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsNotEqualTo", {
- attributes: {
- matchCase: a.matchCase
- }
- });
- this.writeNode("PropertyName", a, b);
- this.writeOgcExpression(a.value, b);
- return b
- },
- PropertyIsLike: function(a) {
- var b = this.createElementNSPlus("ogc:PropertyIsLike", {
- attributes: {
- matchCase: a.matchCase,
- wildCard: "*",
- singleChar: ".",
- escapeChar: "!"
- }
- });
- this.writeNode("PropertyName", a, b);
- this.writeNode("Literal", a.regex2value(), b);
- return b
- },
- BBOX: function(a) {
- var b = this.createElementNSPlus("ogc:BBOX");
- a.property && this.writeNode("PropertyName", a, b);
- var c = this.writeNode("gml:Envelope", a.value);
- a.projection && c.setAttribute("srsName",
- a.projection);
- b.appendChild(c);
- return b
- },
- SortBy: function(a) {
- for (var b = this.createElementNSPlus("ogc:SortBy"), c = 0, d = a.length; c < d; c++) this.writeNode("ogc:SortProperty", a[c], b);
- return b
- },
- SortProperty: function(a) {
- var b = this.createElementNSPlus("ogc:SortProperty");
- this.writeNode("ogc:PropertyName", a, b);
- this.writeNode("ogc:SortOrder", a.order == "DESC" ? "DESC" : "ASC", b);
- return b
- },
- SortOrder: function(a) {
- return this.createElementNSPlus("ogc:SortOrder", {
- value: a
- })
- }
- }, GeoGlobe.Format.Filter.v1.prototype.writers.ogc),
- gml: GeoGlobe.Format.GML.v3.prototype.writers.gml,
- feature: GeoGlobe.Format.GML.v3.prototype.writers.feature
- },
- writeSpatial: function(a, b) {
- var c = this.createElementNSPlus("ogc:" + b);
- this.writeNode("PropertyName", a, c);
- if (a.value instanceof GeoGlobe.Filter.Function) this.writeNode("Function", a.value, c);
- else {
- var d;
- d = a.value instanceof GeoGlobe.Geometry ? this.writeNode("feature:_geometry", a.value).firstChild : this.writeNode("gml:Envelope", a.value);
- a.projection && d.setAttribute("srsName", a.projection);
- c.appendChild(d)
- }
- return c
- },
- CLASS_NAME: "GeoGlobe.Format.Filter.v1_1_0"
- });
- GeoGlobe.Format.WFST = function(a) {
- var a = GeoGlobe.Util.applyDefaults(a, GeoGlobe.Format.WFST.DEFAULTS),
- b = GeoGlobe.Format.WFST["v" + a.version.replace(/\./g, "_")];
- if (!b) throw "Unsupported WFST version: " + a.version;
- return new b(a)
- };
- GeoGlobe.Format.WFST.DEFAULTS = {
- version: "1.0.0"
- };
- GeoGlobe.Format.WFST.v1 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance",
- wfs: "http://www.opengis.net/wfs",
- gml: "http://www.opengis.net/gml",
- ogc: "http://www.opengis.net/ogc",
- ows: "http://www.opengis.net/ows"
- },
- defaultPrefix: "wfs",
- version: null,
- schemaLocations: null,
- srsName: null,
- extractAttributes: !0,
- xy: !0,
- stateName: null,
- initialize: function(a) {
- this.stateName = {};
- this.stateName[GeoGlobe.State.INSERT] = "wfs:Insert";
- this.stateName[GeoGlobe.State.UPDATE] =
- "wfs:Update";
- this.stateName[GeoGlobe.State.DELETE] = "wfs:Delete";
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- getSrsName: function(a, b) {
- var c = b && b.srsName;
- c || (c = a && a.layer ? a.layer.projection.getCode() : this.srsName);
- return c
- },
- read: function(a, b) {
- b = b || {};
- GeoGlobe.Util.applyDefaults(b, {
- output: "features"
- });
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var c = {};
- a && this.readNode(a, c, !0);
- if (c.features && b.output === "features") c =
- c.features;
- return c
- },
- readers: {
- wfs: {
- FeatureCollection: function(a, b) {
- b.features = [];
- this.readChildNodes(a, b)
- }
- }
- },
- write: function(a, b) {
- var c = this.writeNode("wfs:Transaction", {
- features: a,
- options: b
- }),
- d = this.schemaLocationAttr();
- d && this.setAttributeNS(c, this.namespaces.xsi, "xsi:schemaLocation", d);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [c])
- },
- writers: {
- wfs: {
- GetFeature: function(a) {
- var b = this.createElementNSPlus("wfs:GetFeature", {
- attributes: {
- service: "WFS",
- version: this.version,
- outputFormat: a && a.outputFormat,
- maxFeatures: a && a.maxFeatures,
- resultType: a && a.resultType,
- startPosition: a && a.startPosition,
- "xsi:schemaLocation": this.schemaLocationAttr(a)
- }
- });
- if (typeof this.featureType == "string") this.writeNode("Query", a, b);
- else
- for (var c = 0, d = this.featureType.length; c < d; c++) a.featureType = this.featureType[c], this.writeNode("Query", a, b);
- return b
- },
- Transaction: function(a) {
- var a = a || {},
- b = a.options || {},
- c = this.createElementNSPlus("wfs:Transaction", {
- attributes: {
- service: "WFS",
- version: this.version,
- handle: b.handle
- }
- }),
- d, e = a.features;
- if (e) {
- b.multi === !0 && GeoGlobe.Util.extend(this.geometryTypes, {
- "GeoGlobe.Geometry.Point": "MultiPoint",
- "GeoGlobe.Geometry.LineString": this.multiCurve === !0 ? "MultiCurve" : "MultiLineString",
- "GeoGlobe.Geometry.Polygon": this.multiSurface === !0 ? "MultiSurface" : "MultiPolygon"
- });
- var f, g, a = 0;
- for (d = e.length; a < d; ++a) g = e[a], (f = this.stateName[g.state]) && this.writeNode(f, {
- feature: g,
- options: b
- }, c);
- b.multi === !0 && this.setGeometryTypes()
- }
- if (b.nativeElements) {
- a = 0;
- for (d = b.nativeElements.length; a < d; ++a) this.writeNode("wfs:Native",
- b.nativeElements[a], c)
- }
- return c
- },
- Native: function(a) {
- return this.createElementNSPlus("wfs:Native", {
- attributes: {
- vendorId: a.vendorId,
- safeToIgnore: a.safeToIgnore
- },
- value: a.value
- })
- },
- Insert: function(a) {
- var b = a.feature,
- a = a.options,
- a = this.createElementNSPlus("wfs:Insert", {
- attributes: {
- handle: a && a.handle
- }
- });
- this.srsName = this.getSrsName(b);
- this.writeNode("feature:_typeName", b, a);
- return a
- },
- Update: function(a) {
- var b = a.feature,
- a = a.options,
- a = this.createElementNSPlus("wfs:Update", {
- attributes: {
- handle: a && a.handle,
- typeName: (this.featureNS ?
- this.featurePrefix + ":" : "") + this.featureType
- }
- });
- this.featureNS && a.setAttribute("xmlns:" + this.featurePrefix, this.featureNS);
- var c = b.modified;
- if (this.geometryName !== null && (!c || c.geometry !== void 0)) this.srsName = this.getSrsName(b), this.writeNode("Property", {
- name: this.geometryName,
- value: b.geometry
- }, a);
- for (var d in b.attributes) b.attributes[d] !== void 0 && (!c || !c.attributes || c.attributes && c.attributes[d] !== void 0) && this.writeNode("Property", {
- name: d,
- value: b.attributes[d]
- }, a);
- this.writeNode("ogc:Filter", new GeoGlobe.Filter.FeatureId({
- fids: [b.fid]
- }),
- a);
- return a
- },
- Property: function(a) {
- var b = this.createElementNSPlus("wfs:Property");
- this.writeNode("Name", a.name, b);
- a.value !== null && this.writeNode("Value", a.value, b);
- return b
- },
- Name: function(a) {
- return this.createElementNSPlus("wfs:Name", {
- value: a
- })
- },
- Value: function(a) {
- var b;
- a instanceof GeoGlobe.Geometry ? (b = this.createElementNSPlus("wfs:Value"), a = this.writeNode("feature:_geometry", a).firstChild, b.appendChild(a)) : b = this.createElementNSPlus("wfs:Value", {
- value: a
- });
- return b
- },
- Delete: function(a) {
- var b = a.feature,
- a = a.options,
- a = this.createElementNSPlus("wfs:Delete", {
- attributes: {
- handle: a && a.handle,
- typeName: (this.featureNS ? this.featurePrefix + ":" : "") + this.featureType
- }
- });
- this.featureNS && a.setAttribute("xmlns:" + this.featurePrefix, this.featureNS);
- this.writeNode("ogc:Filter", new GeoGlobe.Filter.FeatureId({
- fids: [b.fid]
- }), a);
- return a
- }
- }
- },
- schemaLocationAttr: function(a) {
- var a = GeoGlobe.Util.extend({
- featurePrefix: this.featurePrefix,
- schema: this.schema
- }, a),
- b = GeoGlobe.Util.extend({}, this.schemaLocations);
- if (a.schema) b[a.featurePrefix] =
- a.schema;
- var a = [],
- c, d;
- for (d in b)(c = this.namespaces[d]) && a.push(c + " " + b[d]);
- return a.join(" ") || void 0
- },
- setFilterProperty: function(a) {
- if (a.filters)
- for (var b = 0, c = a.filters.length; b < c; ++b) GeoGlobe.Format.WFST.v1.prototype.setFilterProperty.call(this, a.filters[b]);
- else if (a instanceof GeoGlobe.Filter.Spatial && !a.property) a.property = this.geometryName
- },
- CLASS_NAME: "GeoGlobe.Format.WFST.v1"
- });
- GeoGlobe.Format.WFST.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.Filter.v1_0_0, GeoGlobe.Format.WFST.v1, {
- version: "1.0.0",
- srsNameInQuery: !1,
- schemaLocations: {
- wfs: "http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"
- },
- initialize: function(a) {
- GeoGlobe.Format.Filter.v1_0_0.prototype.initialize.apply(this, [a]);
- GeoGlobe.Format.WFST.v1.prototype.initialize.apply(this, [a])
- },
- readNode: function() {
- return GeoGlobe.Format.GML.v2.prototype.readNode.apply(this, arguments)
- },
- readers: {
- wfs: GeoGlobe.Util.applyDefaults({
- WFS_TransactionResponse: function(a,
- b) {
- b.insertIds = [];
- b.success = !1;
- this.readChildNodes(a, b)
- },
- InsertResult: function(a, b) {
- var c = {
- fids: []
- };
- this.readChildNodes(a, c);
- b.insertIds = b.insertIds.concat(c.fids)
- },
- TransactionResult: function(a, b) {
- this.readChildNodes(a, b)
- },
- Status: function(a, b) {
- this.readChildNodes(a, b)
- },
- SUCCESS: function(a, b) {
- b.success = !0
- }
- }, GeoGlobe.Format.WFST.v1.prototype.readers.wfs),
- gml: GeoGlobe.Format.GML.v2.prototype.readers.gml,
- feature: GeoGlobe.Format.GML.v2.prototype.readers.feature,
- ogc: GeoGlobe.Format.Filter.v1_0_0.prototype.readers.ogc
- },
- writers: {
- wfs: GeoGlobe.Util.applyDefaults({
- Query: function(a) {
- var a = GeoGlobe.Util.extend({
- featureNS: this.featureNS,
- featurePrefix: this.featurePrefix,
- featureType: this.featureType,
- srsName: this.srsName,
- srsNameInQuery: this.srsNameInQuery
- }, a),
- b = a.featurePrefix,
- c = this.createElementNSPlus("wfs:Query", {
- attributes: {
- typeName: (a.featureNS ? b + ":" : "") + a.featureType,
- time: a && a.time,
- userecent: a && a.userecent
- }
- });
- a.srsNameInQuery && a.srsName && c.setAttribute("srsName", a.srsName);
- a.featureNS && c.setAttribute("xmlns:" + b, a.featureNS);
- if (a.propertyNames)
- for (var b = 0, d = a.propertyNames.length; b < d; b++) this.writeNode("ogc:PropertyName", {
- property: a.propertyNames[b]
- }, c);
- a.filter && (this.setFilterProperty(a.filter), this.writeNode("ogc:Filter", a.filter, c));
- a.sortBy && this.writeNode("ogc:SortBy", a.sortBy, c);
- a.groupBy && this.writeNode("ogc:GroupBy", a.groupBy, c);
- return c
- }
- }, GeoGlobe.Format.WFST.v1.prototype.writers.wfs),
- gml: GeoGlobe.Format.GML.v2.prototype.writers.gml,
- feature: GeoGlobe.Format.GML.v2.prototype.writers.feature,
- ogc: GeoGlobe.Format.Filter.v1_0_0.prototype.writers.ogc
- },
- CLASS_NAME: "GeoGlobe.Format.WFST.v1_0_0"
- });
- GeoGlobe.Format.WFST.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Format.Filter.v1_1_0, GeoGlobe.Format.WFST.v1, {
- version: "1.1.0",
- schemaLocations: {
- wfs: "http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
- },
- initialize: function(a) {
- GeoGlobe.Format.Filter.v1_1_0.prototype.initialize.apply(this, [a]);
- GeoGlobe.Format.WFST.v1.prototype.initialize.apply(this, [a])
- },
- readNode: function() {
- return GeoGlobe.Format.GML.v3.prototype.readNode.apply(this, arguments)
- },
- readers: {
- wfs: GeoGlobe.Util.applyDefaults({
- FeatureCollection: function(a, b) {
- b.numberOfFeatures =
- parseInt(a.getAttribute("numberOfFeatures"));
- GeoGlobe.Format.WFST.v1.prototype.readers.wfs.FeatureCollection.apply(this, arguments)
- },
- TransactionResponse: function(a, b) {
- b.insertIds = [];
- b.success = !1;
- this.readChildNodes(a, b)
- },
- TransactionSummary: function(a, b) {
- b.success = !0
- },
- InsertResults: function(a, b) {
- this.readChildNodes(a, b)
- },
- Feature: function(a, b) {
- var c = {
- fids: []
- };
- this.readChildNodes(a, c);
- b.insertIds.push(c.fids[0])
- }
- }, GeoGlobe.Format.WFST.v1.prototype.readers.wfs),
- gml: GeoGlobe.Format.GML.v3.prototype.readers.gml,
- feature: GeoGlobe.Format.GML.v3.prototype.readers.feature,
- ogc: GeoGlobe.Format.Filter.v1_1_0.prototype.readers.ogc,
- ows: GeoGlobe.Format.OWSCommon.v1_0_0.prototype.readers.ows
- },
- writers: {
- wfs: GeoGlobe.Util.applyDefaults({
- GetFeature: function(a) {
- var b = GeoGlobe.Format.WFST.v1.prototype.writers.wfs.GetFeature.apply(this, arguments);
- a && this.setAttributes(b, {
- resultType: a.resultType,
- startIndex: a.startIndex,
- count: a.count
- });
- return b
- },
- Query: function(a) {
- var a = GeoGlobe.Util.extend({
- featureNS: this.featureNS,
- featurePrefix: this.featurePrefix,
- featureType: this.featureType,
- srsName: this.srsName
- }, a),
- b = a.featurePrefix,
- c = this.createElementNSPlus("wfs:Query", {
- attributes: {
- typeName: (a.featureNS ? b + ":" : "") + a.featureType,
- srsName: a.srsName,
- time: a && a.time,
- userecent: a && a.userecent
- }
- });
- a.featureNS && c.setAttribute("xmlns:" + b, a.featureNS);
- if (a.propertyNames)
- for (var b = 0, d = a.propertyNames.length; b < d; b++) this.writeNode("wfs:PropertyName", {
- property: a.propertyNames[b]
- }, c);
- a.filter && (GeoGlobe.Format.WFST.v1_1_0.prototype.setFilterProperty.call(this, a.filter),
- this.writeNode("ogc:Filter", a.filter, c));
- a.sortBy && this.writeNode("ogc:SortBy", a.sortBy, c);
- a.groupBy && this.writeNode("ogc:GroupBy", a.groupBy, c);
- return c
- },
- PropertyName: function(a) {
- return this.createElementNSPlus("wfs:PropertyName", {
- value: a.property
- })
- }
- }, GeoGlobe.Format.WFST.v1.prototype.writers.wfs),
- gml: GeoGlobe.Format.GML.v3.prototype.writers.gml,
- feature: GeoGlobe.Format.GML.v3.prototype.writers.feature,
- ogc: GeoGlobe.Format.Filter.v1_1_0.prototype.writers.ogc
- },
- CLASS_NAME: "GeoGlobe.Format.WFST.v1_1_0"
- });
- GeoGlobe.Format.JSON = GeoGlobe.Class4OL(GeoGlobe.Format, {
- indent: " ",
- space: " ",
- newline: "\n",
- level: 0,
- pretty: !1,
- nativeJSON: function() {
- return !(!window.JSON || !(typeof JSON.parse == "function" && typeof JSON.stringify == "function"))
- }(),
- read: function(a, b) {
- var c;
- if (this.nativeJSON) c = JSON.parse(a, b);
- else try {
- if (/^[\],:{}\s]*$/.test(a.replace(/\\["\\\/bfnrtu]/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, "")) && (c = eval("(" + a + ")"), typeof b ===
- "function")) {
- var d = function(a, c) {
- if (c && typeof c === "object")
- for (var e in c) c.hasOwnProperty(e) && (c[e] = d(e, c[e]));
- return b(a, c)
- };
- c = d("", c)
- }
- } catch (e) {}
- if (this.keepData) this.data = c;
- return c
- },
- write: function(a, b) {
- this.pretty = !!b;
- var c = null,
- d = typeof a;
- if (this.serialize[d]) try {
- c = !this.pretty && this.nativeJSON ? JSON.stringify(a) : this.serialize[d].apply(this, [a])
- } catch (e) {
- GeoGlobe.Console.error("Trouble serializing: " + e)
- }
- return c
- },
- writeIndent: function() {
- var a = [];
- if (this.pretty)
- for (var b = 0; b < this.level; ++b) a.push(this.indent);
- return a.join("")
- },
- writeNewline: function() {
- return this.pretty ? this.newline : ""
- },
- writeSpace: function() {
- return this.pretty ? this.space : ""
- },
- serialize: {
- object: function(a) {
- if (a == null) return "null";
- if (a.constructor == Date) return this.serialize.date.apply(this, [a]);
- if (a.constructor == Array) return this.serialize.array.apply(this, [a]);
- var b = ["{"];
- this.level += 1;
- var c, d, e, f = !1;
- for (c in a) a.hasOwnProperty(c) && (d = GeoGlobe.Format.JSON.prototype.write.apply(this, [c, this.pretty]), e = GeoGlobe.Format.JSON.prototype.write.apply(this, [a[c], this.pretty]), d != null && e != null && (f && b.push(","), b.push(this.writeNewline(), this.writeIndent(), d, ":", this.writeSpace(), e), f = !0));
- this.level -= 1;
- b.push(this.writeNewline(), this.writeIndent(), "}");
- return b.join("")
- },
- array: function(a) {
- var b, c = ["["];
- this.level += 1;
- for (var d = 0, e = a.length; d < e; ++d) b = GeoGlobe.Format.JSON.prototype.write.apply(this, [a[d], this.pretty]), b != null && (d > 0 && c.push(","), c.push(this.writeNewline(), this.writeIndent(), b));
- this.level -= 1;
- c.push(this.writeNewline(), this.writeIndent(),
- "]");
- return c.join("")
- },
- string: function(a) {
- var b = {
- "\u0008": "\\b",
- "\t": "\\t",
- "\n": "\\n",
- "\u000c": "\\f",
- "\r": "\\r",
- '"': '\\"',
- "\\": "\\\\"
- };
- if (/["\\\x00-\x1f]/.test(a)) return '"' + a.replace(/([\x00-\x1f\\"])/g, function(a, d) {
- var e = b[d];
- if (e) return e;
- e = d.charCodeAt();
- return "\\u00" + Math.floor(e / 16).toString(16) + (e % 16).toString(16)
- }) + '"';
- return '"' + a + '"'
- },
- number: function(a) {
- return isFinite(a) ? String(a) : "null"
- },
- "boolean": function(a) {
- return String(a)
- },
- date: function(a) {
- function b(a) {
- return a < 10 ? "0" + a : a
- }
- return '"' +
- a.getFullYear() + "-" + b(a.getMonth() + 1) + "-" + b(a.getDate()) + "T" + b(a.getHours()) + ":" + b(a.getMinutes()) + ":" + b(a.getSeconds()) + '"'
- }
- },
- CLASS_NAME: "GeoGlobe.Format.JSON"
- });
- GeoGlobe.Format.GeoJSON = GeoGlobe.Class4OL(GeoGlobe.Format.JSON, {
- ignoreExtraDims: !1,
- read: function(a, b, c) {
- var b = b ? b : "FeatureCollection",
- d = null,
- e = null;
- if (e = typeof a == "string" ? GeoGlobe.Format.JSON.prototype.read.apply(this, [a, c]) : a)
- if (typeof e.type != "string") GeoGlobe.Console.error("Bad GeoJSON - no type: " + a);
- else {
- if (this.isValidType(e, b)) switch (b) {
- case "Geometry":
- try {
- d = this.parseGeometry(e)
- } catch (f) {
- GeoGlobe.Console.error(f)
- }
- break;
- case "Feature":
- try {
- d = this.parseFeature(e), d.type = "Feature"
- } catch (g) {
- GeoGlobe.Console.error(g)
- }
- break;
- case "FeatureCollection":
- switch (d = [], e.type) {
- case "Feature":
- try {
- d.push(this.parseFeature(e))
- } catch (h) {
- d = null, GeoGlobe.Console.error(h)
- }
- break;
- case "FeatureCollection":
- a = 0;
- for (b = e.features.length; a < b; ++a) try {
- d.push(this.parseFeature(e.features[a]))
- } catch (j) {
- d = null, GeoGlobe.Console.error(j)
- }
- break;
- default:
- try {
- var l = this.parseGeometry(e);
- d.push(new GeoGlobe.Feature(l))
- } catch (m) {
- d = null, GeoGlobe.Console.error(m)
- }
- }
- }
- }
- else GeoGlobe.Console.error("Bad JSON: " + a);
- return d
- },
- isValidType: function(a, b) {
- var c = !1;
- switch (b) {
- case "Geometry":
- GeoGlobe.Util.indexOf(["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "Box", "GeometryCollection"], a.type) == -1 ? GeoGlobe.Console.error("Unsupported geometry type: " + a.type) : c = !0;
- break;
- case "FeatureCollection":
- c = !0;
- break;
- default:
- a.type == b ? c = !0 : GeoGlobe.Console.error("Cannot convert types from " + a.type + " to " + b)
- }
- return c
- },
- parseFeature: function(a) {
- var b, c, d;
- c = a.properties ? a.properties : {};
- d = a.geometry && a.geometry.bbox || a.bbox;
- try {
- b = this.parseGeometry(a.geometry)
- } catch (e) {
- throw e;
- }
- b = new GeoGlobe.Feature(b, c);
- if (d) b.bounds = GeoGlobe.LngLatBounds.fromArray(d);
- if (a.id) b.fid = a.id;
- return b
- },
- parseGeometry: function(a) {
- if (a == null) return null;
- var b, c = !1;
- if (a.type == "GeometryCollection") {
- if (!GeoGlobe.Util.isArray(a.geometries)) throw "GeometryCollection must have geometries array: " + a;
- b = a.geometries.length;
- for (var c = Array(b), d = 0; d < b; ++d) c[d] = this.parseGeometry.apply(this, [a.geometries[d]]);
- b = new GeoGlobe.Geometry.Collection(c);
- c = !0
- } else {
- if (!GeoGlobe.Util.isArray(a.coordinates)) throw "Geometry must have coordinates array: " +
- a;
- if (!this.parseCoords[a.type.toLowerCase()]) throw "Unsupported geometry type: " + a.type;
- try {
- b = this.parseCoords[a.type.toLowerCase()].apply(this, [a.coordinates])
- } catch (e) {
- throw e;
- }
- }
- this.internalProjection && this.externalProjection && !c && b.transform(this.externalProjection, this.internalProjection);
- return b
- },
- parseCoords: {
- point: function(a) {
- if (this.ignoreExtraDims == !1 && a.length != 2) throw "Only 2D points are supported: " + a;
- return new GeoGlobe.Geometry.Point(a[0], a[1])
- },
- multipoint: function(a) {
- for (var b = [], c =
- null, d = 0, e = a.length; d < e; ++d) {
- try {
- c = this.parseCoords.point.apply(this, [a[d]])
- } catch (f) {
- throw f;
- }
- b.push(c)
- }
- return new GeoGlobe.Geometry.MultiPoint(b)
- },
- linestring: function(a) {
- for (var b = [], c = null, d = 0, e = a.length; d < e; ++d) {
- try {
- c = this.parseCoords.point.apply(this, [a[d]])
- } catch (f) {
- throw f;
- }
- b.push(c)
- }
- return new GeoGlobe.Geometry.LineString(b)
- },
- multilinestring: function(a) {
- for (var b = [], c = null, d = 0, e = a.length; d < e; ++d) {
- try {
- c = this.parseCoords.linestring.apply(this, [a[d]])
- } catch (f) {
- throw f;
- }
- b.push(c)
- }
- return new GeoGlobe.Geometry.MultiLineString(b)
- },
- polygon: function(a) {
- for (var b = [], c, d, e = 0, f = a.length; e < f; ++e) {
- try {
- d = this.parseCoords.linestring.apply(this, [a[e]])
- } catch (g) {
- throw g;
- }
- c = new GeoGlobe.Geometry.LinearRing(d.components);
- b.push(c)
- }
- return new GeoGlobe.Geometry.Polygon(b)
- },
- multipolygon: function(a) {
- for (var b = [], c = null, d = 0, e = a.length; d < e; ++d) {
- try {
- c = this.parseCoords.polygon.apply(this, [a[d]])
- } catch (f) {
- throw f;
- }
- b.push(c)
- }
- return new GeoGlobe.Geometry.MultiPolygon(b)
- },
- box: function(a) {
- if (a.length != 2) throw "GeoJSON box coordinates must have 2 elements";
- return new GeoGlobe.Geometry.Polygon([new GeoGlobe.Geometry.LinearRing([new GeoGlobe.Geometry.Point(a[0][0], a[0][1]), new GeoGlobe.Geometry.Point(a[1][0], a[0][1]), new GeoGlobe.Geometry.Point(a[1][0], a[1][1]), new GeoGlobe.Geometry.Point(a[0][0], a[1][1]), new GeoGlobe.Geometry.Point(a[0][0], a[0][1])])])
- }
- },
- write: function(a, b) {
- var c = {
- type: null
- };
- if (GeoGlobe.Util.isArray(a)) {
- c.type = "FeatureCollection";
- var d = a.length;
- c.features = Array(d);
- for (var e = 0; e < d; ++e) {
- var f = a[e];
- if (!f instanceof GeoGlobe.Feature) throw "FeatureCollection only supports collections of features: " +
- f;
- c.features[e] = this.extract.feature.apply(this, [f])
- }
- } else if (a.CLASS_NAME.indexOf("GeoGlobe.Geometry") == 0) c = this.extract.geometry.apply(this, [a]);
- else if (a instanceof GeoGlobe.Feature && (c = this.extract.feature.apply(this, [a]), a.layer && a.layer.projection)) c.crs = this.createCRSObject(a);
- return GeoGlobe.Format.JSON.prototype.write.apply(this, [c, b])
- },
- createCRSObject: function(a) {
- var a = a.layer.projection.toString(),
- b = {};
- a.match(/epsg:/i) && (a = parseInt(a.substring(a.indexOf(":") + 1)), b = a == 4326 ? {
- type: "name",
- properties: {
- name: "urn:ogc:def:crs:OGC:1.3:CRS84"
- }
- } : {
- type: "name",
- properties: {
- name: "EPSG:" + a
- }
- });
- return b
- },
- extract: {
- feature: function(a) {
- var b = this.extract.geometry.apply(this, [a.geometry]),
- b = {
- type: "Feature",
- properties: a.attributes,
- geometry: b
- };
- if (a.fid != null) b.id = a.fid;
- return b
- },
- geometry: function(a) {
- if (a == null) return null;
- this.internalProjection && this.externalProjection && (a = a.clone(), a.transform(this.internalProjection, this.externalProjection));
- var b = a.CLASS_NAME.split(".")[2],
- a = this.extract[b.toLowerCase()].apply(this, [a]);
- return b == "Collection" ? {
- type: "GeometryCollection",
- geometries: a
- } : {
- type: b,
- coordinates: a
- }
- },
- point: function(a) {
- return [a.x, a.y]
- },
- multipoint: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extract.point.apply(this, [a.components[c]]));
- return b
- },
- linestring: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extract.point.apply(this, [a.components[c]]));
- return b
- },
- multilinestring: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extract.linestring.apply(this, [a.components[c]]));
- return b
- },
- polygon: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extract.linestring.apply(this, [a.components[c]]));
- return b
- },
- multipolygon: function(a) {
- for (var b = [], c = 0, d = a.components.length; c < d; ++c) b.push(this.extract.polygon.apply(this, [a.components[c]]));
- return b
- },
- collection: function(a) {
- for (var b = a.components.length, c = Array(b), d = 0; d < b; ++d) c[d] = this.extract.geometry.apply(this, [a.components[d]]);
- return c
- }
- },
- CLASS_NAME: "GeoGlobe.Format.GeoJSON"
- });
- GeoGlobe.Format.VTS = GeoGlobe.Class4OL({
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getVTSCapabilities: function(a) {
- this.url = a;
- var b = null;
- this.getCapabilities(a, function(a) {
- var d = a.responseXML;
- if (!d || !d.documentElement) d = a.responseText;
- b = (new GeoGlobe.Format.VTSCapabilities.v1_0_0).read(d)
- }, function() {
- alert("VTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return b
- },
- getCapabilities: function(a, b, c) {
- typeof c != "function" && (c = function() {
- alert("VTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- GeoGlobe.Request.GET({
- url: a,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WMTS"
- },
- scope: this,
- async: !1,
- success: function(a) {
- typeof b ==
- "function" && b(a)
- },
- failure: c
- })
- },
- createLayerOption: function(a, b, c) {
- if (!("layer" in c)) throw Error("Missing property 'layer' in configuration.");
- for (var d = b.contents, e, f = 0, g = d.layers.length; f < g; ++f)
- if (d.layers[f].identifier === c.layer) {
- e = d.layers[f];
- break
- }
- if (!e) throw Error("Layer not found");
- f = c.format;
- !f && e.formats && e.formats.length && (f = e.formats[0]);
- var h;
- if (c.matrixSet) h = d.tileMatrixSets[c.matrixSet];
- else if (c.projection)
- for (var f = 0, j = e.tileMatrixSetLinks.length; f < j; f++) {
- if (d.tileMatrixSets[e.tileMatrixSetLinks[f].tileMatrixSet].supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/,
- "$1:$3") === c.projection) {
- h = d.tileMatrixSets[e.tileMatrixSetLinks[f].tileMatrixSet];
- break
- }
- } else e.tileMatrixSetLinks.length >= 1 && (h = d.tileMatrixSets[e.tileMatrixSetLinks[0].tileMatrixSet]);
- if (!h) throw Error("matrixSet not found");
- var l = [];
- c.styleName && c.styleName != "" ? l[0] = c.styleName : this.GetStyleName(function(a) {
- l = a.filter(function(a) {
- if (a.indexOf(e.styles[0].identifier) != -1) return a
- })
- });
- (f = c.requestEncoding) || (f = "KVP");
- f = [];
- g = c.params || {};
- delete c.params;
- for (var j = 0, m = e.dimensions.length; j < m; j++) {
- var n =
- e.dimensions[j];
- f.push(n.identifier);
- g.hasOwnProperty(n.identifier) || (g[n.identifier] = n["default"])
- }
- for (var p = c.projection || h.supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"), q = c.units || (p === "EPSG:4326" ? "degrees" : "m"), o = [], s, r, c = [], m = e.tileMatrixSetLinks, g = function(a) {
- o.push(a * 2.8E-4 / GeoGlobe.METERS_PER_INCH / GeoGlobe.INCHES_PER_UNIT[q]);
- if (!s || s > a) s = a;
- if (!r || r < a) r = a
- }, n = 0, j = m.length; n < j; n++)
- if (f = m[n], f.tileMatrixSet === h.identifier) {
- if (f.tileMatrixSetLimits) {
- for (var j = {}, n = 0, t = h.matrixIds.length; n <
- t; n++) j[h.matrixIds[n].identifier] = h.matrixIds[n];
- n = 0;
- for (t = f.tileMatrixSetLimits.length; n < t; n++) m = j[f.tileMatrixSetLimits[n].tileMatrix], c.push(m), g(m.scaleDenominator)
- } else {
- n = 0;
- for (t = h.matrixIds.length; n < t; n++) g(h.matrixIds[n].scaleDenominator)
- }
- break
- }
- o.sort(function(a, b) {
- return b - a
- });
- var u = "",
- v = {
- layers: [],
- source: {},
- source_id: "",
- url: "",
- url_tmpl: "",
- layerType: "VTS"
- },
- b = GeoGlobe.Util.getParameterString({
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- VERSION: b.version,
- LAYER: e.identifier,
- STYLE: l[0],
- TILEMATRIXSET: h.identifier,
- FORMAT: "protobuf",
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- });
- v.url = a;
- u = a.endsWith("?") || a.endsWith("&") ? GeoGlobe.ProxyHost + a + b : GeoGlobe.ProxyHost + a + "?" + b;
- v.url_tmpl = u;
- GeoGlobe.Util.randomStr(10);
- if (e.bounds) var y = [e.bounds._sw.lng, e.bounds._sw.lat, e.bounds._ne.lng, e.bounds._ne.lat];
- else e.BoundingBox && (y = e.BoundingBox[0].bounds.toBBOX());
- var z = d.tileMatrixSets[e.tileMatrixSetLinks[0].tileMatrixSet].matrixIds[0].identifier;
- this.GetStyle(l[0], function(a) {
- if (a.sprite) {
- var b = GeoGlobe.ProxyHost + a.sprite;
- v.sprite = b
- } else b = "";
- if (a.glyphs) {
- var c = GeoGlobe.ProxyHost + a.glyphs;
- v.glyphs = c
- } else c = "";
- b = {
- name: e.identifier,
- sprite: b,
- glyphs: c,
- styleName: a.styleName,
- srs: p,
- bbox: y,
- format: e.formats,
- zoomoffset: z
- };
- c = "source_vts_" + GeoGlobe.Util.randomStr(6);
- v.source_id = c;
- v.source = {
- type: "vector",
- tiles: [u]
- };
- if (a.styleData)
- for (var d = 0; d < a.styleData.layers.length; d++) a.styleData.layers[d].metadata = b, a.styleData.layers[d].source = c, v.layers[d] = a.styleData.layers[d];
- else
- for (d = 0; d < a.layers.length; d++) a.layers[d].metadata = b,
- a.layers[d].source = c, v.layers[d] = a.layers[d]
- }, function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return v
- },
- createLayer: function(a, b) {
- var c = this.getVTSCapabilities(a),
- b = b ? b : {};
- b.layer = b.layer ? b.layer : c.contents.layers[0].identifier;
- b.styleName = b.styleName ? b.styleName : "";
- return this.createLayerOption(a,
- c, b)
- },
- createLayers: function(a) {
- for (var b = this.getVTSCapabilities(a), c = b.contents.layers, d = [], e = 0; e < c.length; e++) {
- var f = this.createLayerOption(a, b, {
- layer: c[e].identifier
- });
- d.push(f)
- }
- return d
- },
- GetStyleName: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetStyle",
- SERVICE: "WMTS",
- VERSION: "1.0.0"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.Request.GET({
- url: c,
- params: d,
- scope: this,
- async: !1,
- success: function(c) {
- c = c.responseText;
- if (!c) return b(), !1;
- var c = (new GeoGlobe.Format.JSON).read(c),
- d = [];
- if (c.style)
- for (var g =
- 0; g < c.style.length; g++) d.push(c.style[g].styleName);
- else if (c.styleName)
- for (g = 0; g < c.styleName.length; g++) d.push(c.styleName[g]);
- a(d)
- },
- failure: b
- })
- },
- GetStyle: function(a, b, c) {
- var d = this.url;
- if (a == "" || a == void 0) alert("\u8bf7\u67e5\u770b\u6837\u5f0f\u540d\u79f0\u662f\u5426\u5b58\u5728");
- else {
- var e = {
- REQUEST: "GetStyle",
- SERVICE: "WMTS",
- VERSION: "1.0.0",
- STYLENAME: a
- };
- c || (c = function() {
- this.failFn(e.REQUEST)
- });
- GeoGlobe.Request.GET({
- url: d,
- params: e,
- scope: this,
- async: !1,
- success: function(a) {
- a = a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b(a)
- },
- failure: c
- })
- }
- },
- CLASS_NAME: "GeoGlobe.Format.VTS"
- });
- GeoGlobe.Format.WMTS = GeoGlobe.Class4OL({
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getWMTSCapabilities: function(a) {
- var b = null;
- this.getCapabilities(a, function(a) {
- var d = a.responseXML;
- if (!d || !d.documentElement) d = a.responseText;
- b = (new GeoGlobe.Format.WMTSCapabilities.v1_0_0).read(d)
- }, function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a +
- "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return b
- },
- getCapabilities: function(a, b, c) {
- typeof c != "function" && (c = function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- GeoGlobe.Request.GET({
- url: a,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WMTS"
- },
- scope: this,
- async: !1,
- success: function(a) {
- typeof b ==
- "function" && b(a)
- },
- failure: c
- })
- },
- createLayerOption: function(a, b, c) {
- if (!("layer" in c)) throw Error("Missing property 'layer' in configuration.");
- for (var d = b.contents, e, f = 0, g = d.layers.length; f < g; ++f)
- if (d.layers[f].identifier === c.layer) {
- e = d.layers[f];
- break
- }
- if (!e) throw Error("Layer not found");
- var h = c.format;
- !h && e.formats && e.formats.length && (h = e.formats[0]);
- var j;
- if (c.matrixSet) j = d.tileMatrixSets[c.matrixSet];
- else if (c.projection)
- for (var f = 0, l = e.tileMatrixSetLinks.length; f < l; f++) {
- if (d.tileMatrixSets[e.tileMatrixSetLinks[f].tileMatrixSet].supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/,
- "$1:$3") === c.projection) {
- j = d.tileMatrixSets[e.tileMatrixSetLinks[f].tileMatrixSet];
- break
- }
- } else e.tileMatrixSetLinks.length >= 1 && (j = d.tileMatrixSets[e.tileMatrixSetLinks[0].tileMatrixSet]);
- if (!j) throw Error("matrixSet not found");
- for (var m, f = 0, g = e.styles.length; f < g; ++f)
- if (m = e.styles[f], m.isDefault) break;
- (f = c.requestEncoding) || (f = "KVP");
- f = [];
- g = c.params || {};
- delete c.params;
- for (var n = 0, l = e.dimensions.length; n < l; n++) {
- var p = e.dimensions[n];
- f.push(p.identifier);
- g.hasOwnProperty(p.identifier) || (g[p.identifier] =
- p["default"])
- }
- for (var f = c.projection || j.supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"), q = c.units || (f === "EPSG:4326" ? "degrees" : "m"), o = [], s, r, c = [], p = e.tileMatrixSetLinks, n = function(a) {
- o.push(a * 2.8E-4 / GeoGlobe.METERS_PER_INCH / GeoGlobe.INCHES_PER_UNIT[q]);
- if (!s || s > a) s = a;
- if (!r || r < a) r = a
- }, t = 0, l = p.length; t < l; t++)
- if (g = p[t], g.tileMatrixSet === j.identifier) {
- if (g.tileMatrixSetLimits) {
- for (var l = {}, t = 0, u = j.matrixIds.length; t < u; t++) l[j.matrixIds[t].identifier] = j.matrixIds[t];
- t = 0;
- for (u = g.tileMatrixSetLimits.length; t <
- u; t++) p = l[g.tileMatrixSetLimits[t].tileMatrix], c.push(p), n(p.scaleDenominator)
- } else {
- t = 0;
- for (u = j.matrixIds.length; t < u; t++) n(j.matrixIds[t].scaleDenominator)
- }
- break
- }
- o.sort(function(a, b) {
- return b - a
- });
- c = "";
- b = GeoGlobe.Util.getParameterString({
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- VERSION: b.version,
- LAYER: e.identifier,
- STYLE: m.identifier,
- TILEMATRIXSET: j.identifier,
- FORMAT: h,
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- });
- c = a.endsWith("?") || a.endsWith("&") ? GeoGlobe.ProxyHost + a + b : GeoGlobe.ProxyHost + a + "?" + b;
- a = GeoGlobe.Util.randomStr(10);
- if (e.bounds) var v = [e.bounds._sw.lng, e.bounds._sw.lat, e.bounds._ne.lng, e.bounds._ne.lat];
- else e.BoundingBox && (v = e.BoundingBox[0].bounds.toBBOX());
- return {
- id: "layer_" + e.identifier + "_" + a,
- type: "raster",
- source: {
- type: "raster",
- tiles: [c],
- tileSize: 256,
- noFadingParent: !0
- },
- metadata: {
- name: e.identifier,
- srs: f,
- bbox: v,
- format: e.formats,
- zoomoffset: d.tileMatrixSets[e.tileMatrixSetLinks[0].tileMatrixSet].matrixIds[0].identifier
- },
- paint: {
- "raster-opacity": 1
- }
- }
- },
- createLayer: function(a, b) {
- var c = this.getWMTSCapabilities(a);
- return this.createLayerOption(a,
- c, b ? {
- layer: b.layer
- } : {
- layer: c.contents.layers[0].identifier
- })
- },
- createLayers: function(a) {
- for (var b = this.getWMTSCapabilities(a), c = b.contents.layers, d = [], e = 0; e < c.length; e++) {
- var f = this.createLayerOption(a, b, {
- layer: c[e].identifier
- });
- d.push(f)
- }
- return d
- },
- calculationTopTileExtentAndZoomOffset: function(a) {
- var b = {},
- c = null,
- d = 0.0254,
- e = 111E3,
- f = 96,
- g = [],
- h = [];
- a.units = a.units ? a.units : "degrees";
- if (a.hasOwnProperty("inchConvertMeterRatio")) d = a.inchConvertMeterRatio;
- if (a.hasOwnProperty("degreeConvertMeterRatio")) e = a.degreeConvertMeterRatio;
- if (a.hasOwnProperty("dpi")) f = a.dpi;
- var j = Math.ceil(Math.log(Math.max(Number(a.matrixWidth), Number(a.matrixHeight))) / Math.LN2),
- l = Math.pow(2, j);
- if (a.hasOwnProperty("resolution"))
- if (a.resolution !== "") c = a.resolution;
- else {
- alert("\u8bf7\u8f93\u5165resolution\u503c\uff0c\u6216\u8005\u5c06\u8be5\u5c5e\u6027\u6ce8\u91ca");
- return
- }
- else if (a.units == "m" && (c = a.scaleDenominator * d / f), a.units == "degrees" && (c = a.scaleDenominator * d / (f * e)), a.units !== "m" && a.units !== "degrees") {
- alert("\u8bf7\u786e\u5b9a\u5355\u4f4d\u662fm\u8fd8\u662fdegrees");
- return
- }
- g[0] = a.topLeftCorner[0];
- g[3] = a.topLeftCorner[1];
- g[1] = g[3] - a.tileSize * c * l;
- g[2] = g[0] + a.tileSize * c * l;
- d = j - Number(a.identifier);
- h[0] = (g[0] + g[2]) / 2;
- h[1] = (g[1] + g[3]) / 2;
- e = d - 1;
- if ((g[2] - g[0] < 360 || g[3] - g[1] < 360) && a.units == "degrees") e = Math.ceil(Math.log(360 / (a.tileSize * c * l)) / Math.LN2), f = Math.pow(2, e), g[1] = g[3] - a.tileSize * c * l * f, g[2] = g[0] + a.tileSize * c * l * f, h[0] = (g[0] + g[2]) / 2, h[1] = (g[1] + g[3]) / 2, d += e, e = d - 1;
- b.topTileExtent = g;
- b.zoomOffset = d;
- b.centerPoint = h;
- b.proposalZoom = e;
- return b
- },
- CLASS_NAME: "GeoGlobe.Format.WMTS"
- });
- GeoGlobe.Format.WMS = GeoGlobe.Class4OL({
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getWMSCapabilities: function(a) {
- var b = null;
- this.getCapabilities(a, function(a) {
- var d = a.responseXML;
- if (!d || !d.documentElement) d = a.responseText;
- b = (new GeoGlobe.Format.WMSCapabilities.v1_1_1).read(d)
- }, function() {
- alert("WMS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return b
- },
- getCapabilities: function(a, b, c) {
- typeof c != "function" && (c = function() {
- alert("WMS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- GeoGlobe.Request.GET({
- url: a,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WMS",
- VERSION: "1.1.1"
- },
- scope: this,
- async: !1,
- success: function(a) {
- typeof b == "function" && b(a)
- },
- failure: c
- })
- },
- createLayerOption: function(a, b, c) {
- if (!("layer" in c)) throw Error("Missing property 'layer' in configuration.");
- for (var b = b.capability, d, e = 0, f = b.layers.length; e < f; ++e)
- if (b.layers[e].name === c.layer) {
- d = b.layers[e];
- break
- }
- if (!d) throw Error("Layer not found");
- b = c.format;
- if (!b && d.formats && d.formats.length) {
- for (e = 0; e < d.formats.length; e++) d.formats[e] == "image/png" && (b = d.formats[e]);
- b != "image/png" && (b = d.formats[0])
- }
- e = c.styles;
- if (!e && d.styles &&
- d.styles.length) e = d.styles[0].name;
- var f = eval(d.srs),
- g, h;
- for (h in f) g = h;
- h = "";
- h = c.transparent;
- c.isTile ? (c = GeoGlobe.Util.getParameterString({
- SERVICE: "WMS",
- REQUEST: "GetMap",
- VERSION: "1.1.1",
- LAYERS: d.name,
- styles: e,
- FORMAT: b,
- TRANSPARENT: h,
- BBOX: "{bbox-epsg-3857}",
- WIDTH: "256",
- HEIGHT: "256",
- SRS: g
- }), h = a.endsWith("?") || a.endsWith("&") ? a + c : a + "?" + c, h = GeoGlobe.appendToProxy(h), a = GeoGlobe.Util.randomStr(10), d = {
- id: "layer_" + d.name + "_" + a,
- type: "raster",
- source: {
- type: "raster",
- tiles: [h],
- tileSize: 256
- },
- metadata: {
- name: d.name,
- srs: g,
- bbox: d.bbox,
- format: b
- },
- paint: {
- "raster-opacity": 1
- }
- }) : d = new GeoGlobe.Layer.WMS({
- url: a,
- layer: d.name,
- format: b,
- version: "1.1.1",
- SRS: g,
- styles: e,
- bbox: d.bbox,
- isTile: !1
- });
- return d
- },
- createLayer: function(a, b, c) {
- this.url = a;
- var b = b ? b : {},
- c = c === void 0 || c ? !0 : !1,
- d = b && b.transparent === void 0 || b.transparent ? !0 : !1,
- e = this.getWMSCapabilities(a);
- return this.createLayerOption(a, e, {
- layer: b && b.layer ? b.layer : e.capability.layers[0].name,
- transparent: d,
- isTile: c
- })
- },
- createLayers: function(a, b, c) {
- for (var b = b ? b : {}, c = c === void 0 ||
- c ? !0 : !1, b = b && b.transparent === void 0 || b.transparent ? !0 : !1, d = this.getWMSCapabilities(a), e = d.capability.layers, f = [], g = 0; g < e.length; g++) {
- var h = this.createLayerOption(a, d, {
- layer: e[g].name,
- transparent: b,
- isTile: c
- });
- f.push(h)
- }
- return f
- },
- CLASS_NAME: "GeoGlobe.Format.WMS"
- });
- GeoGlobe.Format.WMSCapabilities = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.1.1",
- profile: null,
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities"
- });
- GeoGlobe.Format.WMSCapabilities.v1 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- wms: "http://www.opengis.net/wms",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance"
- },
- defaultPrefix: "wms",
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- var b = a;
- if (a && a.nodeType == 9) a = a.documentElement;
- var c = {};
- this.readNode(a, c);
- if (c.service === void 0) a = new GeoGlobe.Format.OGCExceptionReport, c.error = a.read(b);
- return c
- },
- readers: {
- wms: {
- Service: function(a,
- b) {
- b.service = {};
- this.readChildNodes(a, b.service)
- },
- Name: function(a, b) {
- b.name = this.getChildValue(a)
- },
- Title: function(a, b) {
- b.title = this.getChildValue(a)
- },
- Abstract: function(a, b) {
- b["abstract"] = this.getChildValue(a)
- },
- BoundingBox: function(a) {
- var b = {};
- b.bbox = [parseFloat(a.getAttribute("minx")), parseFloat(a.getAttribute("miny")), parseFloat(a.getAttribute("maxx")), parseFloat(a.getAttribute("maxy"))];
- a = {
- x: parseFloat(a.getAttribute("resx")),
- y: parseFloat(a.getAttribute("resy"))
- };
- if (!isNaN(a.x) || !isNaN(a.y)) b.res =
- a;
- return b
- },
- OnlineResource: function(a, b) {
- b.href = this.getAttributeNS(a, this.namespaces.xlink, "href")
- },
- ContactInformation: function(a, b) {
- b.contactInformation = {};
- this.readChildNodes(a, b.contactInformation)
- },
- ContactPersonPrimary: function(a, b) {
- b.personPrimary = {};
- this.readChildNodes(a, b.personPrimary)
- },
- ContactPerson: function(a, b) {
- b.person = this.getChildValue(a)
- },
- ContactOrganization: function(a, b) {
- b.organization = this.getChildValue(a)
- },
- ContactPosition: function(a, b) {
- b.position = this.getChildValue(a)
- },
- ContactAddress: function(a,
- b) {
- b.contactAddress = {};
- this.readChildNodes(a, b.contactAddress)
- },
- AddressType: function(a, b) {
- b.type = this.getChildValue(a)
- },
- Address: function(a, b) {
- b.address = this.getChildValue(a)
- },
- City: function(a, b) {
- b.city = this.getChildValue(a)
- },
- StateOrProvince: function(a, b) {
- b.stateOrProvince = this.getChildValue(a)
- },
- PostCode: function(a, b) {
- b.postcode = this.getChildValue(a)
- },
- Country: function(a, b) {
- b.country = this.getChildValue(a)
- },
- ContactVoiceTelephone: function(a, b) {
- b.phone = this.getChildValue(a)
- },
- ContactFacsimileTelephone: function(a,
- b) {
- b.fax = this.getChildValue(a)
- },
- ContactElectronicMailAddress: function(a, b) {
- b.email = this.getChildValue(a)
- },
- Fees: function(a, b) {
- var c = this.getChildValue(a);
- if (c && c.toLowerCase() != "none") b.fees = c
- },
- AccessConstraints: function(a, b) {
- var c = this.getChildValue(a);
- if (c && c.toLowerCase() != "none") b.accessConstraints = c
- },
- Capability: function(a, b) {
- b.capability = {
- nestedLayers: [],
- layers: []
- };
- this.readChildNodes(a, b.capability)
- },
- Request: function(a, b) {
- b.request = {};
- this.readChildNodes(a, b.request)
- },
- GetCapabilities: function(a,
- b) {
- b.getcapabilities = {
- formats: []
- };
- this.readChildNodes(a, b.getcapabilities)
- },
- Format: function(a, b) {
- GeoGlobe.Util.isArray(b.formats) ? b.formats.push(this.getChildValue(a)) : b.format = this.getChildValue(a)
- },
- DCPType: function(a, b) {
- this.readChildNodes(a, b)
- },
- HTTP: function(a, b) {
- this.readChildNodes(a, b)
- },
- Get: function(a, b) {
- b.get = {};
- this.readChildNodes(a, b.get);
- if (!b.href) b.href = b.get.href
- },
- Post: function(a, b) {
- b.post = {};
- this.readChildNodes(a, b.post);
- if (!b.href) b.href = b.get.href
- },
- GetMap: function(a, b) {
- b.getmap = {
- formats: []
- };
- this.readChildNodes(a, b.getmap)
- },
- GetFeatureInfo: function(a, b) {
- b.getfeatureinfo = {
- formats: []
- };
- this.readChildNodes(a, b.getfeatureinfo)
- },
- Exception: function(a, b) {
- b.exception = {
- formats: []
- };
- this.readChildNodes(a, b.exception)
- },
- Layer: function(a, b) {
- var c, d;
- b.capability ? (d = b.capability, c = b) : d = b;
- var e = a.getAttributeNode("queryable"),
- f = e && e.specified ? a.getAttribute("queryable") : null,
- g = (e = a.getAttributeNode("cascaded")) && e.specified ? a.getAttribute("cascaded") : null,
- e = (e = a.getAttributeNode("opaque")) && e.specified ?
- a.getAttribute("opaque") : null,
- h = a.getAttribute("noSubsets"),
- j = a.getAttribute("fixedWidth"),
- l = a.getAttribute("fixedHeight"),
- m = c || {},
- n = GeoGlobe.Util.extend;
- c = {
- nestedLayers: [],
- styles: c ? [].concat(c.styles) : [],
- srs: c ? n({}, m.srs) : {},
- metadataURLs: [],
- bbox: c ? n({}, m.bbox) : {},
- llbbox: m.llbbox,
- dimensions: c ? n({}, m.dimensions) : {},
- authorityURLs: c ? n({}, m.authorityURLs) : {},
- identifiers: {},
- keywords: [],
- queryable: f && f !== "" ? f === "1" || f === "true" : m.queryable || !1,
- cascaded: g !== null ? parseInt(g) : m.cascaded || 0,
- opaque: e ? e === "1" ||
- e === "true" : m.opaque || !1,
- noSubsets: h !== null ? h === "1" || h === "true" : m.noSubsets || !1,
- fixedWidth: j != null ? parseInt(j) : m.fixedWidth || 0,
- fixedHeight: l != null ? parseInt(l) : m.fixedHeight || 0,
- minScale: m.minScale,
- maxScale: m.maxScale,
- attribution: m.attribution
- };
- b.nestedLayers.push(c);
- c.capability = d;
- this.readChildNodes(a, c);
- delete c.capability;
- if (c.name) {
- f = c.name.split(":");
- g = d.request;
- e = g.getfeatureinfo;
- if (f.length > 0) c.prefix = f[0];
- d.layers.push(c);
- if (c.formats === void 0) c.formats = g.getmap.formats;
- if (c.infoFormats === void 0 &&
- e) c.infoFormats = e.formats
- }
- },
- Attribution: function(a, b) {
- b.attribution = {};
- this.readChildNodes(a, b.attribution)
- },
- LogoURL: function(a, b) {
- b.logo = {
- width: a.getAttribute("width"),
- height: a.getAttribute("height")
- };
- this.readChildNodes(a, b.logo)
- },
- Style: function(a, b) {
- var c = {};
- b.styles.push(c);
- this.readChildNodes(a, c)
- },
- LegendURL: function(a, b) {
- var c = {
- width: a.getAttribute("width"),
- height: a.getAttribute("height")
- };
- b.legend = c;
- this.readChildNodes(a, c)
- },
- MetadataURL: function(a, b) {
- var c = {
- type: a.getAttribute("type")
- };
- b.metadataURLs.push(c);
- this.readChildNodes(a, c)
- },
- DataURL: function(a, b) {
- b.dataURL = {};
- this.readChildNodes(a, b.dataURL)
- },
- FeatureListURL: function(a, b) {
- b.featureListURL = {};
- this.readChildNodes(a, b.featureListURL)
- },
- AuthorityURL: function(a, b) {
- var c = a.getAttribute("name"),
- d = {};
- this.readChildNodes(a, d);
- b.authorityURLs[c] = d.href
- },
- Identifier: function(a, b) {
- var c = a.getAttribute("authority");
- b.identifiers[c] = this.getChildValue(a)
- },
- KeywordList: function(a, b) {
- this.readChildNodes(a, b)
- },
- SRS: function(a, b) {
- b.srs[this.getChildValue(a)] = !0
- }
- }
- },
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1"
- });
- GeoGlobe.Format.WMSCapabilities.v1_1 = GeoGlobe.Class4OL(GeoGlobe.Format.WMSCapabilities.v1, {
- readers: {
- wms: GeoGlobe.Util.applyDefaults({
- WMT_MS_Capabilities: function(a, b) {
- this.readChildNodes(a, b)
- },
- Keyword: function(a, b) {
- b.keywords && b.keywords.push(this.getChildValue(a))
- },
- DescribeLayer: function(a, b) {
- b.describelayer = {
- formats: []
- };
- this.readChildNodes(a, b.describelayer)
- },
- GetLegendGraphic: function(a, b) {
- b.getlegendgraphic = {
- formats: []
- };
- this.readChildNodes(a, b.getlegendgraphic)
- },
- GetStyles: function(a, b) {
- b.getstyles = {
- formats: []
- };
- this.readChildNodes(a, b.getstyles)
- },
- PutStyles: function(a, b) {
- b.putstyles = {
- formats: []
- };
- this.readChildNodes(a, b.putstyles)
- },
- UserDefinedSymbolization: function(a, b) {
- var c = {
- supportSLD: parseInt(a.getAttribute("SupportSLD")) == 1,
- userLayer: parseInt(a.getAttribute("UserLayer")) == 1,
- userStyle: parseInt(a.getAttribute("UserStyle")) == 1,
- remoteWFS: parseInt(a.getAttribute("RemoteWFS")) == 1
- };
- b.userSymbols = c
- },
- LatLonBoundingBox: function(a, b) {
- b.llbbox = [parseFloat(a.getAttribute("minx")), parseFloat(a.getAttribute("miny")),
- parseFloat(a.getAttribute("maxx")), parseFloat(a.getAttribute("maxy"))
- ]
- },
- BoundingBox: function(a, b) {
- var c = GeoGlobe.Format.WMSCapabilities.v1.prototype.readers.wms.BoundingBox.apply(this, [a, b]);
- c.srs = a.getAttribute("SRS");
- b.bbox[c.srs] = c
- },
- ScaleHint: function(a, b) {
- var c = a.getAttribute("min"),
- d = a.getAttribute("max"),
- e = Math.pow(2, 0.5),
- f = GeoGlobe.INCHES_PER_UNIT.m;
- if (c != 0) b.maxScale = parseFloat((c / e * f * GeoGlobe.DOTS_PER_INCH).toPrecision(13));
- if (d != Number.POSITIVE_INFINITY) b.minScale = parseFloat((d / e * f * GeoGlobe.DOTS_PER_INCH).toPrecision(13))
- },
- Dimension: function(a, b) {
- var c = {
- name: a.getAttribute("name").toLowerCase(),
- units: a.getAttribute("units"),
- unitsymbol: a.getAttribute("unitSymbol")
- };
- b.dimensions[c.name] = c
- },
- Extent: function(a, b) {
- var c = a.getAttribute("name").toLowerCase();
- if (c in b.dimensions) {
- c = b.dimensions[c];
- c.nearestVal = a.getAttribute("nearestValue") === "1";
- c.multipleVal = a.getAttribute("multipleValues") === "1";
- c.current = a.getAttribute("current") === "1";
- c["default"] = a.getAttribute("default") || "";
- var d = this.getChildValue(a);
- c.values = d.split(",")
- }
- }
- },
- GeoGlobe.Format.WMSCapabilities.v1.prototype.readers.wms)
- },
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1_1"
- });
- GeoGlobe.Format.WMSCapabilities.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Format.WMSCapabilities.v1_1, {
- version: "1.1.0",
- readers: {
- wms: GeoGlobe.Util.applyDefaults({
- SRS: function(a, b) {
- for (var c = this.getChildValue(a).split(/ +/), d = 0, e = c.length; d < e; d++) b.srs[c[d]] = !0
- }
- }, GeoGlobe.Format.WMSCapabilities.v1_1.prototype.readers.wms)
- },
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1_1_0"
- });
- GeoGlobe.Format.WMSCapabilities.v1_1_1 = GeoGlobe.Class4OL(GeoGlobe.Format.WMSCapabilities.v1_1, {
- version: "1.1.1",
- readers: {
- wms: GeoGlobe.Util.applyDefaults({
- SRS: function(a, b) {
- b.srs[this.getChildValue(a)] = !0
- }
- }, GeoGlobe.Format.WMSCapabilities.v1_1.prototype.readers.wms)
- },
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1_1_1"
- });
- GeoGlobe.Format.WMSCapabilities.v1_1_1_WMSC = GeoGlobe.Class4OL(GeoGlobe.Format.WMSCapabilities.v1_1_1, {
- version: "1.1.1",
- profile: "WMSC",
- readers: {
- wms: GeoGlobe.Util.applyDefaults({
- VendorSpecificCapabilities: function(a, b) {
- b.vendorSpecific = {
- tileSets: []
- };
- this.readChildNodes(a, b.vendorSpecific)
- },
- TileSet: function(a, b) {
- var c = {
- srs: {},
- bbox: {},
- resolutions: []
- };
- this.readChildNodes(a, c);
- b.tileSets.push(c)
- },
- Resolutions: function(a, b) {
- for (var c = this.getChildValue(a).split(" "), d = 0, e = c.length; d < e; d++) c[d] != "" && b.resolutions.push(parseFloat(c[d]))
- },
- Width: function(a, b) {
- b.width = parseInt(this.getChildValue(a))
- },
- Height: function(a, b) {
- b.height = parseInt(this.getChildValue(a))
- },
- Layers: function(a, b) {
- b.layers = this.getChildValue(a)
- },
- Styles: function(a, b) {
- b.styles = this.getChildValue(a)
- }
- }, GeoGlobe.Format.WMSCapabilities.v1_1_1.prototype.readers.wms)
- },
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1_1_1_WMSC"
- });
- GeoGlobe.Format.WMSCapabilities.v1_3 = GeoGlobe.Class4OL(GeoGlobe.Format.WMSCapabilities.v1, {
- readers: {
- wms: GeoGlobe.Util.applyDefaults({
- WMS_Capabilities: function(a, b) {
- this.readChildNodes(a, b)
- },
- LayerLimit: function(a, b) {
- b.layerLimit = parseInt(this.getChildValue(a))
- },
- MaxWidth: function(a, b) {
- b.maxWidth = parseInt(this.getChildValue(a))
- },
- MaxHeight: function(a, b) {
- b.maxHeight = parseInt(this.getChildValue(a))
- },
- BoundingBox: function(a, b) {
- var c = GeoGlobe.Format.WMSCapabilities.v1.prototype.readers.wms.BoundingBox.apply(this, [a, b]);
- c.srs = a.getAttribute("CRS");
- b.bbox[c.srs] = c
- },
- CRS: function(a, b) {
- this.readers.wms.SRS.apply(this, [a, b])
- },
- EX_GeographicBoundingBox: function(a, b) {
- b.llbbox = [];
- this.readChildNodes(a, b.llbbox)
- },
- westBoundLongitude: function(a, b) {
- b[0] = this.getChildValue(a)
- },
- eastBoundLongitude: function(a, b) {
- b[2] = this.getChildValue(a)
- },
- southBoundLatitude: function(a, b) {
- b[1] = this.getChildValue(a)
- },
- northBoundLatitude: function(a, b) {
- b[3] = this.getChildValue(a)
- },
- MinScaleDenominator: function(a, b) {
- b.maxScale = parseFloat(this.getChildValue(a)).toPrecision(16)
- },
- MaxScaleDenominator: function(a, b) {
- b.minScale = parseFloat(this.getChildValue(a)).toPrecision(16)
- },
- Dimension: function(a, b) {
- var c = {
- name: a.getAttribute("name").toLowerCase(),
- units: a.getAttribute("units"),
- unitsymbol: a.getAttribute("unitSymbol"),
- nearestVal: a.getAttribute("nearestValue") === "1",
- multipleVal: a.getAttribute("multipleValues") === "1",
- "default": a.getAttribute("default") || "",
- current: a.getAttribute("current") === "1",
- values: this.getChildValue(a).split(",")
- };
- b.dimensions[c.name] = c
- },
- Keyword: function(a,
- b) {
- var c = {
- value: this.getChildValue(a),
- vocabulary: a.getAttribute("vocabulary")
- };
- b.keywords && b.keywords.push(c)
- }
- }, GeoGlobe.Format.WMSCapabilities.v1.prototype.readers.wms),
- sld: {
- UserDefinedSymbolization: function(a, b) {
- this.readers.wms.UserDefinedSymbolization.apply(this, [a, b]);
- b.userSymbols.inlineFeature = parseInt(a.getAttribute("InlineFeature")) == 1;
- b.userSymbols.remoteWCS = parseInt(a.getAttribute("RemoteWCS")) == 1
- },
- DescribeLayer: function(a, b) {
- this.readers.wms.DescribeLayer.apply(this, [a, b])
- },
- GetLegendGraphic: function(a,
- b) {
- this.readers.wms.GetLegendGraphic.apply(this, [a, b])
- }
- }
- },
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1_3"
- });
- GeoGlobe.Format.WMSCapabilities.v1_3_0 = GeoGlobe.Class4OL(GeoGlobe.Format.WMSCapabilities.v1_3, {
- version: "1.3.0",
- CLASS_NAME: "GeoGlobe.Format.WMSCapabilities.v1_3_0"
- });
- GeoGlobe.Format.WMSUtil = GeoGlobe.Class4OL({
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getWMSCapabilities: function(a, b) {
- var c = !0,
- d = null;
- this.getCapabilities(a, b, GeoGlobe.Function.bind(function(b) {
- var f = b.responseXML;
- if (!f || !f.documentElement) f = b.responseText;
- f == null || f == "" ? (this.failFn(a), c = !1) : d = (new GeoGlobe.Format.WMSCapabilities).read(f)
- }, this), function() {
- alert("WMS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- if (c) return d
- },
- createLayer: function(a, b) {
- var c = !0,
- d = null;
- this.getCapabilities(a, b, GeoGlobe.Function.bind(function(e) {
- var f = e.responseXML;
- if (!f || !f.documentElement) f = e.responseText;
- f == null || f == "" ? (this.failFn(a), c = !1) : (e = (new GeoGlobe.Format.WMSCapabilities).read(f), d = this._createLayer(a, e, b, "2D"))
- }, this), function() {
- alert("WMS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- if (c) return d
- },
- failFn: function(a) {
- alert("WMS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- },
- getCapabilities: function(a, b, c, d) {
- var e = {
- REQUEST: "GetCapabilities",
- SERVICE: "WMS",
- VERSION: b && b.version ? b.version : "1.1.1"
- };
- typeof d != "function" && (d =
- function() {
- alert("WMS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u7248\u672c\u53f7\uff1a" + e[VERSION] + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- GeoGlobe.Request.GET({
- url: a,
- params: e,
- scope: this,
- async: !1,
- success: function(a) {
- typeof c == "function" && c(a)
- },
- failure: d
- })
- },
- _createLayer: function(a, b, c) {
- c || (c = {});
- var d = b.capability,
- e;
- e = d.layers[0];
- for (var f = 0, g = d.layers.length; f < g; ++f)
- if (d.layers[f].name === c.layer) {
- e = d.layers[f];
- break
- }
- if (!e) throw Error("Layer not found");
- d = c.format;
- !d && e.formats && e.formats.length > 0 && (d = e.formats[0]);
- f = c.transparent;
- if (!f || f == "") f = !0;
- var h;
- if (e.name) h = e.name;
- g = c.version;
- if (!g && b.version) g = b.version;
- b = c.srs;
- if (!b && e.srs)
- for (var j in e.srs) b = j;
- b == "EPSG:-9999" && (b = "EPSG:4326");
- e = GeoGlobe.LngLatBounds.fromArray(e.llbbox);
- j = "SERVICE=WMS&REQUEST=GetMap&VERSION=" + g + "&LAYERS=" + h + "&styles=default&CRS=EPSG:3857&BBOX={bbox-epsg-3857}&WIDTH=256&HEIGHT=256&SRS=" +
- b + "&FORMAT=" + d + "&TRANSPARENT=" + f;
- wmts_url = a.endsWith("?") || a.endsWith("&") ? a + j : a + "?" + j;
- return {
- url: wmts_url,
- version: g,
- name: h,
- projection: b,
- format: d,
- bounds: e,
- transparent: f
- }
- },
- CLASS_NAME: "GeoGlobe.Format.WMSUtil"
- });
- GeoGlobe.Format.VTSCapabilities = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.0.0",
- yx: {
- "urn:ogc:def:crs:EPSG::4326": !0
- },
- createLayer: function(a, b) {
- if (!("layer" in b)) throw Error("Missing property 'layer' in configuration.");
- for (var c = a.contents, d, e = 0, f = c.layers.length; e < f; ++e)
- if (c.layers[e].identifier === b.layer) {
- d = c.layers[e];
- break
- }
- if (!d) throw Error("Layer not found");
- var g = b.format;
- !g && d.formats && d.formats.length && (g = d.formats[0]);
- var h;
- if (b.matrixSet) h = c.tileMatrixSets[b.matrixSet];
- else if (b.projection)
- for (var e = 0, j = d.tileMatrixSetLinks.length; e < j; e++) {
- if (c.tileMatrixSets[d.tileMatrixSetLinks[e].tileMatrixSet].supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3") === b.projection) {
- h = c.tileMatrixSets[d.tileMatrixSetLinks[e].tileMatrixSet];
- break
- }
- } else d.tileMatrixSetLinks.length >= 1 && (h = c.tileMatrixSets[d.tileMatrixSetLinks[0].tileMatrixSet]);
- if (!h) throw Error("matrixSet not found");
- for (var l, e = 0, f = d.styles.length; e < f; ++e)
- if (l = d.styles[e], l.isDefault) break;
- (c = b.requestEncoding) ||
- (c = "KVP");
- var m = [],
- e = b.params || {};
- delete b.params;
- f = 0;
- for (j = d.dimensions.length; f < j; f++) {
- var n = d.dimensions[f];
- m.push(n.identifier);
- e.hasOwnProperty(n.identifier) || (e[n.identifier] = n["default"])
- }
- for (var m = b.projection || h.supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"), p = b.units || (m === "EPSG:4326" ? "degrees" : "m"), q = [], o, s, m = [], n = d.tileMatrixSetLinks, f = function(a) {
- q.push(a * 2.8E-4 / GeoGlobe.METERS_PER_INCH / GeoGlobe.INCHES_PER_UNIT[p]);
- if (!o || o > a) o = a;
- if (!s || s < a) s = a
- }, r = 0, j = n.length; r < j; r++)
- if (e =
- n[r], e.tileMatrixSet === h.identifier) {
- if (e.tileMatrixSetLimits) {
- for (var j = {}, r = 0, t = h.matrixIds.length; r < t; r++) j[h.matrixIds[r].identifier] = h.matrixIds[r];
- r = 0;
- for (t = e.tileMatrixSetLimits.length; r < t; r++) n = j[e.tileMatrixSetLimits[r].tileMatrix], m.push(n), f(n.scaleDenominator)
- } else {
- r = 0;
- for (t = h.matrixIds.length; r < t; r++) f(h.matrixIds[r].scaleDenominator)
- }
- break
- }
- if (c === "REST" && d.resourceUrls) {
- m = [];
- e = 0;
- for (f = d.resourceUrls.length; e < f; ++e) c = d.resourceUrls[e], c.format === g && c.resourceType === "tile" && m.push(c.template)
- } else {
- j =
- a.operationsMetadata.GetTile.dcp.http.get;
- m = [];
- e = 0;
- for (f = j.length; e < f; e++) n = j[e].constraints, (!n || n && n.GetEncoding.allowedValues[c]) && m.push(j[e].url)
- }
- q.sort(function(a, b) {
- return b - a
- });
- c = "";
- g = "SERVICE=WMTS&REQUEST=GetTile&VERSION=" + a.version + "&LAYER=" + d.identifier + "&STYLE=" + l.identifier + "&TILEMATRIXSET=" + h.identifier + "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=" + g;
- c = m[0].endsWith("?") ? m[0] + g : m[0] + "?" + g;
- g = GeoGlobe.Util.applyDefaults(b, {
- id: d.identifier,
- url: [c]
- });
- g = new GeoGlobe.Layer.VTS(g);
- g.matrixSet =
- h;
- g.identifier = d.identifier;
- g.bounds = d.bounds;
- return g
- },
- CLASS_NAME: "GeoGlobe.Format.VTSCapabilities"
- });
- GeoGlobe.Format.VTSCapabilities.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.OWSCommon.v1_1_0, {
- version: "1.0.0",
- namespaces: {
- ows: "http://www.opengis.net/ows/1.1",
- wmts: "http://www.opengis.net/wmts/1.0",
- xlink: "http://www.w3.org/1999/xlink"
- },
- yx: null,
- defaultPrefix: "wmts",
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a]);
- this.options = a;
- a = GeoGlobe.Util.extend({}, GeoGlobe.Format.VTSCapabilities.prototype.yx);
- this.yx = GeoGlobe.Util.extend(a, this.yx)
- },
- read: function(a) {
- typeof a == "string" &&
- (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- this.readNode(a, b);
- b.version = this.version;
- return b
- },
- readers: {
- wmts: {
- Capabilities: function(a, b) {
- this.readChildNodes(a, b)
- },
- Contents: function(a, b) {
- b.contents = {};
- b.contents.layers = [];
- b.contents.tileMatrixSets = {};
- this.readChildNodes(a, b.contents)
- },
- Layer: function(a, b) {
- var c = {
- styles: [],
- formats: [],
- dimensions: [],
- tileMatrixSetLinks: []
- };
- this.readChildNodes(a, c);
- b.layers.push(c)
- },
- Style: function(a, b) {
- var c = {};
- c.isDefault = a.getAttribute("isDefault") === "true";
- this.readChildNodes(a, c);
- b.styles.push(c)
- },
- Format: function(a, b) {
- b.formats.push(this.getChildValue(a))
- },
- TileMatrixSetLink: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.tileMatrixSetLinks.push(c)
- },
- TileMatrixSet: function(a, b) {
- if (b.layers) {
- var c = {
- matrixIds: []
- };
- this.readChildNodes(a, c);
- b.tileMatrixSets[c.identifier] = c
- } else b.tileMatrixSet = this.getChildValue(a)
- },
- TileMatrixSetLimits: function(a, b) {
- b.tileMatrixSetLimits = [];
- this.readChildNodes(a, b)
- },
- TileMatrixLimits: function(a,
- b) {
- var c = {};
- this.readChildNodes(a, c);
- b.tileMatrixSetLimits.push(c)
- },
- MinTileRow: function(a, b) {
- b.minTileRow = parseInt(this.getChildValue(a))
- },
- MaxTileRow: function(a, b) {
- b.maxTileRow = parseInt(this.getChildValue(a))
- },
- MinTileCol: function(a, b) {
- b.minTileCol = parseInt(this.getChildValue(a))
- },
- MaxTileCol: function(a, b) {
- b.maxTileCol = parseInt(this.getChildValue(a))
- },
- TileMatrix: function(a, b) {
- if (b.identifier) {
- var c = {
- supportedCRS: b.supportedCRS
- };
- this.readChildNodes(a, c);
- b.matrixIds.push(c)
- } else b.tileMatrix = this.getChildValue(a)
- },
- ScaleDenominator: function(a, b) {
- b.scaleDenominator = parseFloat(this.getChildValue(a))
- },
- TopLeftCorner: function(a, b) {
- var c = this.getChildValue(a).split(" "),
- d;
- b.supportedCRS && (d = !!this.yx[b.supportedCRS.replace(/urn:ogc:def:crs:(\w+):.+:(\w+)$/, "urn:ogc:def:crs:$1::$2")]);
- b.topLeftCorner = d ? new GeoGlobe.LngLat(c[1], c[0]) : new GeoGlobe.LngLat(c[0], c[1])
- },
- TileWidth: function(a, b) {
- b.tileWidth = parseInt(this.getChildValue(a))
- },
- TileHeight: function(a, b) {
- b.tileHeight = parseInt(this.getChildValue(a))
- },
- MatrixWidth: function(a,
- b) {
- b.matrixWidth = parseInt(this.getChildValue(a))
- },
- MatrixHeight: function(a, b) {
- b.matrixHeight = parseInt(this.getChildValue(a))
- },
- ResourceURL: function(a, b) {
- b.resourceUrl = b.resourceUrl || {};
- var c = a.getAttribute("resourceType");
- if (!b.resourceUrls) b.resourceUrls = [];
- c = b.resourceUrl[c] = {
- format: a.getAttribute("format"),
- template: a.getAttribute("template"),
- resourceType: c
- };
- b.resourceUrls.push(c)
- },
- LegendURL: function(a, b) {
- b.legends = b.legends || [];
- var c = {
- format: a.getAttribute("format"),
- href: a.getAttribute("xlink:href")
- },
- d = a.getAttribute("width"),
- e = a.getAttribute("height"),
- f = a.getAttribute("minScaleDenominator"),
- g = a.getAttribute("maxScaleDenominator");
- if (d !== null) c.width = parseInt(d);
- if (e !== null) c.height = parseInt(e);
- if (f !== null) c.minScaleDenominator = parseInt(f);
- if (g !== null) c.maxScaleDenominator = parseInt(g);
- b.legends.push(c)
- },
- InfoFormat: function(a, b) {
- b.infoFormats = b.infoFormats || [];
- b.infoFormats.push(this.getChildValue(a))
- },
- WSDL: function(a, b) {
- b.wsdl = {};
- b.wsdl.href = a.getAttribute("xlink:href")
- },
- ServiceMetadataURL: function(a,
- b) {
- b.serviceMetadataUrl = {};
- b.serviceMetadataUrl.href = a.getAttribute("xlink:href")
- },
- Dimension: function(a, b) {
- var c = {
- values: []
- };
- this.readChildNodes(a, c);
- b.dimensions.push(c)
- },
- Default: function(a, b) {
- b["default"] = this.getChildValue(a)
- },
- Value: function(a, b) {
- b.values.push(this.getChildValue(a))
- }
- },
- ows: GeoGlobe.Format.OWSCommon.v1_1_0.prototype.readers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.VTSCapabilities.v1_0_0"
- });
- GeoGlobe.Format.WMTSCapabilities = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.0.0",
- yx: {
- "urn:ogc:def:crs:EPSG::4326": !0
- },
- createLayer: function(a, b) {
- if (!("layer" in b)) throw Error("Missing property 'layer' in configuration.");
- for (var c = a.contents, d, e = 0, f = c.layers.length; e < f; ++e)
- if (c.layers[e].identifier === b.layer) {
- d = c.layers[e];
- break
- }
- if (!d) throw Error("Layer not found");
- var g = b.format;
- !g && d.formats && d.formats.length && (g = d.formats[0]);
- var h;
- if (b.matrixSet) h = c.tileMatrixSets[b.matrixSet];
- else if (b.projection)
- for (var e = 0, j = d.tileMatrixSetLinks.length; e < j; e++) {
- if (c.tileMatrixSets[d.tileMatrixSetLinks[e].tileMatrixSet].supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3") === b.projection) {
- h = c.tileMatrixSets[d.tileMatrixSetLinks[e].tileMatrixSet];
- break
- }
- } else d.tileMatrixSetLinks.length >= 1 && (h = c.tileMatrixSets[d.tileMatrixSetLinks[0].tileMatrixSet]);
- if (!h) throw Error("matrixSet not found");
- for (var l, e = 0, f = d.styles.length; e < f; ++e)
- if (l = d.styles[e], l.isDefault) break;
- (c = b.requestEncoding) ||
- (c = "KVP");
- var m = [],
- e = b.params || {};
- delete b.params;
- f = 0;
- for (j = d.dimensions.length; f < j; f++) {
- var n = d.dimensions[f];
- m.push(n.identifier);
- e.hasOwnProperty(n.identifier) || (e[n.identifier] = n["default"])
- }
- for (var m = b.projection || h.supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"), p = b.units || (m === "EPSG:4326" ? "degrees" : "m"), q = [], o, s, m = [], n = d.tileMatrixSetLinks, f = function(a) {
- q.push(a * 2.8E-4 / GeoGlobe.METERS_PER_INCH / GeoGlobe.INCHES_PER_UNIT[p]);
- if (!o || o > a) o = a;
- if (!s || s < a) s = a
- }, r = 0, j = n.length; r < j; r++)
- if (e =
- n[r], e.tileMatrixSet === h.identifier) {
- if (e.tileMatrixSetLimits) {
- for (var j = {}, r = 0, t = h.matrixIds.length; r < t; r++) j[h.matrixIds[r].identifier] = h.matrixIds[r];
- r = 0;
- for (t = e.tileMatrixSetLimits.length; r < t; r++) n = j[e.tileMatrixSetLimits[r].tileMatrix], m.push(n), f(n.scaleDenominator)
- } else {
- r = 0;
- for (t = h.matrixIds.length; r < t; r++) f(h.matrixIds[r].scaleDenominator)
- }
- break
- }
- if (c === "REST" && d.resourceUrls) {
- m = [];
- e = 0;
- for (f = d.resourceUrls.length; e < f; ++e) c = d.resourceUrls[e], c.format === g && c.resourceType === "tile" && m.push(c.template)
- } else {
- j =
- a.operationsMetadata.GetTile.dcp.http.get;
- m = [];
- e = 0;
- for (f = j.length; e < f; e++) n = j[e].constraints, (!n || n && n.GetEncoding.allowedValues[c]) && m.push(j[e].url)
- }
- q.sort(function(a, b) {
- return b - a
- });
- c = "";
- g = "SERVICE=WMTS&REQUEST=GetTile&VERSION=" + a.version + "&LAYER=" + d.identifier + "&STYLE=" + l.identifier + "&TILEMATRIXSET=" + h.identifier + "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=" + g;
- c = m[0].endsWith("?") ? m[0] + g : m[0] + "?" + g;
- g = GeoGlobe.Util.applyDefaults(b, {
- id: d.identifier,
- url: [c]
- });
- g = {
- id: g.id,
- layer: {
- id: g.id,
- type: "raster",
- source: g.id
- },
- source: {
- type: "raster",
- tiles: g.url,
- tileSize: 256
- }
- };
- g.matrixSet = h;
- g.identifier = d.identifier;
- g.bounds = d.bounds;
- return g
- },
- CLASS_NAME: "GeoGlobe.Format.WMTSCapabilities"
- });
- GeoGlobe.Format.WMTSCapabilities.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.OWSCommon.v1_1_0, {
- version: "1.0.0",
- namespaces: {
- ows: "http://www.opengis.net/ows/1.1",
- wmts: "http://www.opengis.net/wmts/1.0",
- xlink: "http://www.w3.org/1999/xlink"
- },
- yx: null,
- defaultPrefix: "wmts",
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a]);
- this.options = a;
- a = GeoGlobe.Util.extend({}, GeoGlobe.Format.WMTSCapabilities.prototype.yx);
- this.yx = GeoGlobe.Util.extend(a, this.yx)
- },
- read: function(a) {
- typeof a == "string" &&
- (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- this.readNode(a, b);
- b.version = this.version;
- return b
- },
- readers: {
- wmts: {
- Capabilities: function(a, b) {
- this.readChildNodes(a, b)
- },
- Contents: function(a, b) {
- b.contents = {};
- b.contents.layers = [];
- b.contents.tileMatrixSets = {};
- this.readChildNodes(a, b.contents)
- },
- Layer: function(a, b) {
- var c = {
- styles: [],
- formats: [],
- dimensions: [],
- tileMatrixSetLinks: []
- };
- this.readChildNodes(a, c);
- b.layers.push(c)
- },
- Style: function(a, b) {
- var c = {};
- c.isDefault = a.getAttribute("isDefault") === "true";
- this.readChildNodes(a, c);
- b.styles.push(c)
- },
- Format: function(a, b) {
- b.formats.push(this.getChildValue(a))
- },
- TileMatrixSetLink: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.tileMatrixSetLinks.push(c)
- },
- TileMatrixSet: function(a, b) {
- if (b.layers) {
- var c = {
- matrixIds: []
- };
- this.readChildNodes(a, c);
- b.tileMatrixSets[c.identifier] = c
- } else b.tileMatrixSet = this.getChildValue(a)
- },
- TileMatrixSetLimits: function(a, b) {
- b.tileMatrixSetLimits = [];
- this.readChildNodes(a, b)
- },
- TileMatrixLimits: function(a,
- b) {
- var c = {};
- this.readChildNodes(a, c);
- b.tileMatrixSetLimits.push(c)
- },
- MinTileRow: function(a, b) {
- b.minTileRow = parseInt(this.getChildValue(a))
- },
- MaxTileRow: function(a, b) {
- b.maxTileRow = parseInt(this.getChildValue(a))
- },
- MinTileCol: function(a, b) {
- b.minTileCol = parseInt(this.getChildValue(a))
- },
- MaxTileCol: function(a, b) {
- b.maxTileCol = parseInt(this.getChildValue(a))
- },
- TileMatrix: function(a, b) {
- if (b.identifier) {
- var c = {
- supportedCRS: b.supportedCRS
- };
- this.readChildNodes(a, c);
- b.matrixIds.push(c)
- } else b.tileMatrix = this.getChildValue(a)
- },
- ScaleDenominator: function(a, b) {
- b.scaleDenominator = parseFloat(this.getChildValue(a))
- },
- TopLeftCorner: function(a, b) {
- var c = this.getChildValue(a).split(" "),
- d;
- b.supportedCRS && (d = !!this.yx[b.supportedCRS.replace(/urn:ogc:def:crs:(\w+):.+:(\w+)$/, "urn:ogc:def:crs:$1::$2")]);
- b.topLeftCorner = d ? new GeoGlobe.LngLat(c[1], c[0]) : new GeoGlobe.LngLat(c[0], c[1])
- },
- TileWidth: function(a, b) {
- b.tileWidth = parseInt(this.getChildValue(a))
- },
- TileHeight: function(a, b) {
- b.tileHeight = parseInt(this.getChildValue(a))
- },
- MatrixWidth: function(a,
- b) {
- b.matrixWidth = parseInt(this.getChildValue(a))
- },
- MatrixHeight: function(a, b) {
- b.matrixHeight = parseInt(this.getChildValue(a))
- },
- ResourceURL: function(a, b) {
- b.resourceUrl = b.resourceUrl || {};
- var c = a.getAttribute("resourceType");
- if (!b.resourceUrls) b.resourceUrls = [];
- c = b.resourceUrl[c] = {
- format: a.getAttribute("format"),
- template: a.getAttribute("template"),
- resourceType: c
- };
- b.resourceUrls.push(c)
- },
- LegendURL: function(a, b) {
- b.legends = b.legends || [];
- var c = {
- format: a.getAttribute("format"),
- href: a.getAttribute("xlink:href")
- },
- d = a.getAttribute("width"),
- e = a.getAttribute("height"),
- f = a.getAttribute("minScaleDenominator"),
- g = a.getAttribute("maxScaleDenominator");
- if (d !== null) c.width = parseInt(d);
- if (e !== null) c.height = parseInt(e);
- if (f !== null) c.minScaleDenominator = parseInt(f);
- if (g !== null) c.maxScaleDenominator = parseInt(g);
- b.legends.push(c)
- },
- InfoFormat: function(a, b) {
- b.infoFormats = b.infoFormats || [];
- b.infoFormats.push(this.getChildValue(a))
- },
- WSDL: function(a, b) {
- b.wsdl = {};
- b.wsdl.href = a.getAttribute("xlink:href")
- },
- ServiceMetadataURL: function(a,
- b) {
- b.serviceMetadataUrl = {};
- b.serviceMetadataUrl.href = a.getAttribute("xlink:href")
- },
- Dimension: function(a, b) {
- var c = {
- values: []
- };
- this.readChildNodes(a, c);
- b.dimensions.push(c)
- },
- Default: function(a, b) {
- b["default"] = this.getChildValue(a)
- },
- Value: function(a, b) {
- b.values.push(this.getChildValue(a))
- }
- },
- ows: GeoGlobe.Format.OWSCommon.v1_1_0.prototype.readers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.WMTSCapabilities.v1_0_0"
- });
- GeoGlobe.Format.WMTSUtil = GeoGlobe.Class4OL({
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getWMTSCapabilities: function(a) {
- var b = null;
- this.getCapabilities(a, function(a) {
- var d = a.responseXML;
- if (!d || !d.documentElement) d = a.responseText;
- b = (new GeoGlobe.Format.WMTSCapabilities.v1_0_0).read(d)
- }, function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return b
- },
- getCapabilities: function(a, b, c) {
- typeof c != "function" && (c = function() {
- alert("WMTS\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + a + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- GeoGlobe.Request.GET({
- url: a,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WMTS"
- },
- scope: this,
- async: !1,
- success: function(a) {
- typeof b ==
- "function" && b(a)
- },
- failure: c
- })
- },
- createLayerOption: function(a, b, c) {
- if (!("layer" in c)) throw Error("Missing property 'layer' in configuration.");
- for (var d = b.contents, e, f = 0, g = d.layers.length; f < g; ++f)
- if (d.layers[f].identifier === c.layer) {
- e = d.layers[f];
- break
- }
- if (!e) throw Error("Layer not found");
- var h = c.format;
- !h && e.formats && e.formats.length && (h = e.formats[0]);
- var j;
- if (c.matrixSet) j = d.tileMatrixSets[c.matrixSet];
- else if (c.projection) {
- f = 0;
- for (g = e.tileMatrixSetLinks.length; f < g; f++)
- if (d.tileMatrixSets[e.tileMatrixSetLinks[f].tileMatrixSet].supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/,
- "$1:$3") === c.projection) {
- j = d.tileMatrixSets[e.tileMatrixSetLinks[f].tileMatrixSet];
- break
- }
- } else e.tileMatrixSetLinks.length >= 1 && (j = d.tileMatrixSets[e.tileMatrixSetLinks[0].tileMatrixSet]);
- if (!j) throw Error("matrixSet not found");
- for (var l, f = 0, g = e.styles.length; f < g; ++f)
- if (l = e.styles[f], l.isDefault) break;
- (d = c.requestEncoding) || (d = "KVP");
- d = [];
- f = c.params || {};
- delete c.params;
- for (var g = 0, m = e.dimensions.length; g < m; g++) {
- var n = e.dimensions[g];
- d.push(n.identifier);
- f.hasOwnProperty(n.identifier) || (f[n.identifier] =
- n["default"])
- }
- for (var d = c.projection || j.supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"), p = c.units || (d === "EPSG:4326" ? "degrees" : "m"), q = [], o, s, c = [], m = e.tileMatrixSetLinks, f = function(a) {
- q.push(a * 2.8E-4 / GeoGlobe.METERS_PER_INCH / GeoGlobe.INCHES_PER_UNIT[p]);
- if (!o || o > a) o = a;
- if (!s || s < a) s = a
- }, n = 0, g = m.length; n < g; n++)
- if (d = m[n], d.tileMatrixSet === j.identifier) {
- if (d.tileMatrixSetLimits) {
- for (var g = {}, n = 0, r = j.matrixIds.length; n < r; n++) g[j.matrixIds[n].identifier] = j.matrixIds[n];
- n = 0;
- for (r = d.tileMatrixSetLimits.length; n <
- r; n++) m = g[d.tileMatrixSetLimits[n].tileMatrix], c.push(m), f(m.scaleDenominator)
- } else {
- n = 0;
- for (r = j.matrixIds.length; n < r; n++) f(j.matrixIds[n].scaleDenominator)
- }
- break
- }
- q.sort(function(a, b) {
- return b - a
- });
- c = "";
- b = GeoGlobe.Util.getParameterString({
- SERVICE: "WMTS",
- REQUEST: "GetTile",
- VERSION: b.version,
- LAYER: e.identifier,
- STYLE: l.identifier,
- TILEMATRIXSET: j.identifier,
- FORMAT: h,
- TILEMATRIX: "{z}",
- TILEROW: "{y}",
- TILECOL: "{x}"
- });
- c = a.endsWith("?") || a.endsWith("&") ? GeoGlobe.ProxyHost + a + b : GeoGlobe.ProxyHost + a + "?" + b;
- a = GeoGlobe.Util.randomStr(10);
- return {
- id: "layer_" + e.identifier + "_" + a,
- type: "raster",
- source: {
- type: "raster",
- tiles: [c],
- tileSize: 256
- },
- paint: {
- "raster-opacity": 1
- }
- }
- },
- createLayer: function(a) {
- var b = this.getWMTSCapabilities(a);
- return this.createLayerOption(a, b, {
- layer: b.contents.layers[0].identifier
- })
- },
- createLayers: function(a) {
- for (var b = this.getWMTSCapabilities(a), c = b.contents.layers, d = [], e = 0; e < c.length; e++) {
- var f = this.createLayerOption(a, b, {
- layer: c[e].identifier
- });
- d.push(f)
- }
- return d
- },
- calculationTopTileExtentAndZoomOffset: function(a) {
- var b = {},
- c = null,
- d = 0.0254,
- e = 111E3,
- f = 96,
- g = [],
- h = [];
- a.units = a.units ? a.units : "degrees";
- if (a.hasOwnProperty("inchConvertMeterRatio")) d = a.inchConvertMeterRatio;
- if (a.hasOwnProperty("degreeConvertMeterRatio")) e = a.degreeConvertMeterRatio;
- if (a.hasOwnProperty("dpi")) f = a.dpi;
- var j = Math.ceil(Math.log(Math.max(Number(a.matrixWidth), Number(a.matrixHeight))) / Math.LN2),
- l = Math.pow(2, j);
- if (a.hasOwnProperty("resolution"))
- if (a.resolution !== "") c = a.resolution;
- else {
- alert("\u8bf7\u8f93\u5165resolution\u503c\uff0c\u6216\u8005\u5c06\u8be5\u5c5e\u6027\u6ce8\u91ca");
- return
- }
- else if (a.units == "m" && (c = a.scaleDenominator * d / f), a.units == "degrees" && (c = a.scaleDenominator * d / (f * e)), a.units !== "m" && a.units !== "degrees") {
- alert("\u8bf7\u786e\u5b9a\u5355\u4f4d\u662fm\u8fd8\u662fdegrees");
- return
- }
- g[0] = a.topLeftCorner[0];
- g[3] = a.topLeftCorner[1];
- g[1] = g[3] - a.tileSize * c * l;
- g[2] = g[0] + a.tileSize * c * l;
- d = j - Number(a.identifier);
- h[0] = (g[0] + g[2]) / 2;
- h[1] = (g[1] + g[3]) / 2;
- e = d - 1;
- if ((g[2] - g[0] < 360 || g[3] - g[1] < 360) && a.units == "degrees") e = Math.ceil(Math.log(360 / (a.tileSize * c * l)) / Math.LN2), f = Math.pow(2,
- e), g[1] = g[3] - a.tileSize * c * l * f, g[2] = g[0] + a.tileSize * c * l * f, h[0] = (g[0] + g[2]) / 2, h[1] = (g[1] + g[3]) / 2, d += e, e = d - 1;
- b.topTileExtent = g;
- b.zoomOffset = d;
- b.centerPoint = h;
- b.proposalZoom = e;
- return b
- },
- CLASS_NAME: "GeoGlobe.Format.WMTSUtil"
- });
- GeoGlobe.Format.WPSCapabilities = GeoGlobe.Class4OL(GeoGlobe.Format.XML.VersionedOGC, {
- defaultVersion: "1.0.0",
- CLASS_NAME: "GeoGlobe.Format.WPSCapabilities"
- });
- GeoGlobe.Format.WPSCapabilities.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- ows: "http://www.opengis.net/ows/1.1",
- wps: "http://www.opengis.net/wps/1.0.0",
- xlink: "http://www.w3.org/1999/xlink"
- },
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- this.readNode(a, b);
- return b
- },
- readers: {
- wps: {
- Capabilities: function(a, b) {
- this.readChildNodes(a, b)
- },
- ProcessOfferings: function(a, b) {
- b.processOfferings = {};
- this.readChildNodes(a, b.processOfferings)
- },
- Process: function(a, b) {
- var c = {
- processVersion: this.getAttributeNS(a, this.namespaces.wps, "processVersion")
- };
- this.readChildNodes(a, c);
- b[c.identifier] = c
- },
- Languages: function(a, b) {
- b.languages = [];
- this.readChildNodes(a, b.languages)
- },
- Default: function(a, b) {
- var c = {
- isDefault: !0
- };
- this.readChildNodes(a, c);
- b.push(c)
- },
- Supported: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.push(c)
- }
- },
- ows: GeoGlobe.Format.OWSCommon.v1_1_0.prototype.readers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.WPSCapabilities.v1_0_0"
- });
- GeoGlobe.Format.WCSGetCoverage = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- ows: "http://www.opengis.net/ows/1.1",
- wcs: "http://www.opengis.net/wcs/1.1",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance"
- },
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- VERSION: "1.1.2",
- schemaLocation: "http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd",
- write: function(a) {
- a = this.writeNode("wcs:GetCoverage",
- a);
- this.setAttributeNS(a, this.namespaces.xsi, "xsi:schemaLocation", this.schemaLocation);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [a])
- },
- writers: {
- wcs: {
- GetCoverage: function(a) {
- var b = this.createElementNSPlus("wcs:GetCoverage", {
- attributes: {
- version: a.version || this.VERSION,
- service: "WCS"
- }
- });
- this.writeNode("ows:Identifier", a.identifier, b);
- this.writeNode("wcs:DomainSubset", a.domainSubset, b);
- this.writeNode("wcs:Output", a.output, b);
- return b
- },
- DomainSubset: function(a) {
- var b = this.createElementNSPlus("wcs:DomainSubset", {});
- this.writeNode("ows:BoundingBox", a.boundingBox, b);
- a.temporalSubset && this.writeNode("wcs:TemporalSubset", a.temporalSubset, b);
- return b
- },
- TemporalSubset: function(a) {
- for (var b = this.createElementNSPlus("wcs:TemporalSubset", {}), c = 0, d = a.timePeriods.length; c < d; ++c) this.writeNode("wcs:TimePeriod", a.timePeriods[c], b);
- return b
- },
- TimePeriod: function(a) {
- var b = this.createElementNSPlus("wcs:TimePeriod", {});
- this.writeNode("wcs:BeginPosition", a.begin, b);
- this.writeNode("wcs:EndPosition", a.end, b);
- a.resolution && this.writeNode("wcs:TimeResolution",
- a.resolution, b);
- return b
- },
- BeginPosition: function(a) {
- return this.createElementNSPlus("wcs:BeginPosition", {
- value: a
- })
- },
- EndPosition: function(a) {
- return this.createElementNSPlus("wcs:EndPosition", {
- value: a
- })
- },
- TimeResolution: function(a) {
- return this.createElementNSPlus("wcs:TimeResolution", {
- value: a
- })
- },
- Output: function(a) {
- var b = this.createElementNSPlus("wcs:Output", {
- attributes: {
- format: a.format,
- store: a.store
- }
- });
- a.gridCRS && this.writeNode("wcs:GridCRS", a.gridCRS, b);
- return b
- },
- GridCRS: function(a) {
- var b = this.createElementNSPlus("wcs:GridCRS", {});
- this.writeNode("wcs:GridBaseCRS", a.baseCRS, b);
- a.type && this.writeNode("wcs:GridType", a.type, b);
- a.origin && this.writeNode("wcs:GridOrigin", a.origin, b);
- this.writeNode("wcs:GridOffsets", a.offsets, b);
- a.CS && this.writeNode("wcs:GridCS", a.CS, b);
- return b
- },
- GridBaseCRS: function(a) {
- return this.createElementNSPlus("wcs:GridBaseCRS", {
- value: a
- })
- },
- GridOrigin: function(a) {
- return this.createElementNSPlus("wcs:GridOrigin", {
- value: a
- })
- },
- GridType: function(a) {
- return this.createElementNSPlus("wcs:GridType", {
- value: a
- })
- },
- GridOffsets: function(a) {
- return this.createElementNSPlus("wcs:GridOffsets", {
- value: a
- })
- },
- GridCS: function(a) {
- return this.createElementNSPlus("wcs:GridCS", {
- value: a
- })
- }
- },
- ows: GeoGlobe.Format.OWSCommon.v1_1_0.prototype.writers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.WCSGetCoverage"
- });
- GeoGlobe.Format.WPSExecute = GeoGlobe.Class4OL(GeoGlobe.Format.XML, GeoGlobe.Format.Filter.v1_1_0, {
- namespaces: {
- ows: "http://www.opengis.net/ows/1.1",
- gml: "http://www.opengis.net/gml",
- wps: "http://www.opengis.net/wps/1.0.0",
- wfs: "http://www.opengis.net/wfs",
- ogc: "http://www.opengis.net/ogc",
- wcs: "http://www.opengis.net/wcs",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance"
- },
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- VERSION: "1.0.0",
- schemaLocation: "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd",
- schemaLocationAttr: function() {},
- write: function(a) {
- var b;
- GeoGlobe.Format.XML.supportActiveX ? this.xmldom = b = new ActiveXObject("Microsoft.XMLDOM") : b = document.implementation.createDocument("", "", null);
- a = this.writeNode("wps:Execute", a, b);
- this.setAttributeNS(a, this.namespaces.xsi, "xsi:schemaLocation", this.schemaLocation);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [a])
- },
- read: function(a) {
- typeof a ==
- "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- this.readNode(a, b);
- return b
- },
- writers: {
- wps: {
- Execute: function(a) {
- var b = this.createElementNSPlus("wps:Execute", {
- attributes: {
- version: this.VERSION,
- service: "WPS"
- }
- });
- this.writeNode("ows:Identifier", a.identifier, b);
- this.writeNode("wps:DataInputs", a.dataInputs, b);
- this.writeNode("wps:ResponseForm", a.responseForm, b);
- return b
- },
- ResponseForm: function(a) {
- var b = this.createElementNSPlus("wps:ResponseForm", {});
- a.rawDataOutput && this.writeNode("wps:RawDataOutput", a.rawDataOutput, b);
- a.responseDocument && this.writeNode("wps:ResponseDocument", a.responseDocument, b);
- return b
- },
- ResponseDocument: function(a) {
- var b = this.createElementNSPlus("wps:ResponseDocument", {
- attributes: {
- storeExecuteResponse: a.storeExecuteResponse,
- lineage: a.lineage,
- status: a.status
- }
- });
- if (a.outputs)
- for (var c = 0, d = a.outputs.length; c < d; c++) this.writeNode("wps:Output", a.outputs[c], b);
- return b
- },
- Output: function(a) {
- var b = this.createElementNSPlus("wps:Output", {
- attributes: {
- asReference: a.asReference,
- mimeType: a.mimeType,
- encoding: a.encoding,
- schema: a.schema
- }
- });
- this.writeNode("ows:Identifier", a.identifier, b);
- this.writeNode("ows:Title", a.title, b);
- this.writeNode("ows:Abstract", a["abstract"], b);
- return b
- },
- RawDataOutput: function(a) {
- var b = this.createElementNSPlus("wps:RawDataOutput", {
- attributes: {
- mimeType: a.mimeType,
- encoding: a.encoding,
- schema: a.schema
- }
- });
- this.writeNode("ows:Identifier", a.identifier, b);
- return b
- },
- DataInputs: function(a) {
- for (var b = this.createElementNSPlus("wps:DataInputs", {}), c = 0, d = a.length; c < d; ++c) this.writeNode("wps:Input", a[c], b);
- return b
- },
- Input: function(a) {
- var b = this.createElementNSPlus("wps:Input", {});
- this.writeNode("ows:Identifier", a.identifier, b);
- a.title && this.writeNode("ows:Title", a.title, b);
- a.data && this.writeNode("wps:Data", a.data, b);
- a.reference && this.writeNode("wps:Reference", a.reference, b);
- a.boundingBoxData && this.writeNode("wps:BoundingBoxData", a.boundingBoxData, b);
- return b
- },
- Data: function(a) {
- var b = this.createElementNSPlus("wps:Data", {});
- a.literalData ? this.writeNode("wps:LiteralData",
- a.literalData, b) : a.complexData ? this.writeNode("wps:ComplexData", a.complexData, b) : a.boundingBoxData && this.writeNode("ows:BoundingBox", a.boundingBoxData, b);
- return b
- },
- LiteralData: function(a) {
- return this.createElementNSPlus("wps:LiteralData", {
- attributes: {
- uom: a.uom
- },
- value: a.value
- })
- },
- ComplexData: function(a) {
- var b = this.createElementNSPlus("wps:ComplexData", {
- attributes: {
- mimeType: a.mimeType,
- encoding: a.encoding,
- schema: a.schema
- }
- }),
- c = a.value;
- typeof c === "string" ? b.appendChild(this.getXMLDoc().createCDATASection(a.value)) :
- b.appendChild(c);
- return b
- },
- Reference: function(a) {
- var b = this.createElementNSPlus("wps:Reference", {
- attributes: {
- mimeType: a.mimeType,
- "xlink:href": a.href,
- method: a.method,
- encoding: a.encoding,
- schema: a.schema
- }
- });
- a.body && this.writeNode("wps:Body", a.body, b);
- return b
- },
- BoundingBoxData: function(a, b) {
- this.writers.ows.BoundingBox.apply(this, [a, b, "wps:BoundingBoxData"])
- },
- Body: function(a) {
- var b = this.createElementNSPlus("wps:Body", {});
- a.wcs ? this.writeNode("wcs:GetCoverage", a.wcs, b) : a.wfs ? (this.featureType = a.wfs.featureType,
- this.version = a.wfs.version, this.writeNode("wfs:GetFeature", a.wfs, b)) : this.writeNode("wps:Execute", a, b);
- return b
- }
- },
- wcs: GeoGlobe.Format.WCSGetCoverage.prototype.writers.wcs,
- wfs: GeoGlobe.Format.WFST.v1_1_0.prototype.writers.wfs,
- ogc: GeoGlobe.Format.Filter.v1_1_0.prototype.writers.ogc,
- ows: GeoGlobe.Format.OWSCommon.v1_1_0.prototype.writers.ows
- },
- readers: {
- wps: {
- ExecuteResponse: function(a, b) {
- b.executeResponse = {
- lang: a.getAttribute("lang"),
- statusLocation: a.getAttribute("statusLocation"),
- serviceInstance: a.getAttribute("serviceInstance"),
- service: a.getAttribute("service")
- };
- this.readChildNodes(a, b.executeResponse)
- },
- Process: function(a, b) {
- b.process = {};
- this.readChildNodes(a, b.process)
- },
- Status: function(a, b) {
- b.status = {
- creationTime: a.getAttribute("creationTime")
- };
- this.readChildNodes(a, b.status)
- },
- ProcessSucceeded: function(a, b) {
- b.processSucceeded = !0
- },
- ProcessOutputs: function(a, b) {
- b.processOutputs = [];
- this.readChildNodes(a, b.processOutputs)
- },
- Output: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.push(c)
- },
- Reference: function(a, b) {
- b.reference = {
- href: a.getAttribute("href"),
- mimeType: a.getAttribute("mimeType"),
- encoding: a.getAttribute("encoding"),
- schema: a.getAttribute("schema")
- }
- },
- Data: function(a, b) {
- b.data = {};
- this.readChildNodes(a, b)
- },
- LiteralData: function(a, b) {
- b.literalData = {
- dataType: a.getAttribute("dataType"),
- uom: a.getAttribute("uom"),
- value: this.getChildValue(a)
- }
- },
- ComplexData: function(a, b) {
- b.complexData = {
- mimeType: a.getAttribute("mimeType"),
- schema: a.getAttribute("schema"),
- encoding: a.getAttribute("encoding"),
- value: ""
- };
- if (this.isSimpleContent(a)) {
- var c;
- for (c = a.firstChild; c; c = c.nextSibling) switch (c.nodeType) {
- case 3:
- case 4:
- b.complexData.value += c.nodeValue
- }
- } else
- for (c = a.firstChild; c; c = c.nextSibling)
- if (c.nodeType == 1) b.complexData.value = c
- },
- BoundingBox: function(a, b) {
- b.boundingBoxData = {
- dimensions: a.getAttribute("dimensions"),
- crs: a.getAttribute("crs")
- };
- this.readChildNodes(a, b.boundingBoxData)
- }
- },
- ows: GeoGlobe.Format.OWSCommon.v1_1_0.prototype.readers.ows
- },
- CLASS_NAME: "GeoGlobe.Format.WPSExecute"
- });
- GeoGlobe.Format.OGCExceptionReport = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- ogc: "http://www.opengis.net/ogc"
- },
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- defaultPrefix: "ogc",
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- var b = {
- exceptionReport: null
- };
- a.documentElement && (this.readChildNodes(a, b), b.exceptionReport === null && (b = (new GeoGlobe.Format.OWSCommon).read(a)));
- return b
- },
- readers: {
- ogc: {
- ServiceExceptionReport: function(a,
- b) {
- b.exceptionReport = {
- exceptions: []
- };
- this.readChildNodes(a, b.exceptionReport)
- },
- ServiceException: function(a, b) {
- var c = {
- code: a.getAttribute("code"),
- locator: a.getAttribute("locator"),
- text: this.getChildValue(a)
- };
- b.exceptions.push(c)
- }
- }
- },
- CLASS_NAME: "GeoGlobe.Format.OGCExceptionReport"
- });
- GeoGlobe.Format.QueryStringFilter = function() {
- function a(a) {
- a = a.replace(/%/g, "\\%");
- a = a.replace(/\\\\\.(\*)?/g, function(a, b) {
- return b ? a : "\\\\_"
- });
- a = a.replace(/\\\\\.\*/g, "\\\\%");
- a = a.replace(/(\\)?\.(\*)?/g, function(a, b, c) {
- return b || c ? a : "_"
- });
- a = a.replace(/(\\)?\.\*/g, function(a, b) {
- return b ? a : "%"
- });
- a = a.replace(/\\\./g, ".");
- return a = a.replace(/(\\)?\\\*/g, function(a, b) {
- return b ? a : "*"
- })
- }
- var b = {};
- b[GeoGlobe.Filter.Comparison.EQUAL_TO] = "eq";
- b[GeoGlobe.Filter.Comparison.NOT_EQUAL_TO] = "ne";
- b[GeoGlobe.Filter.Comparison.LESS_THAN] =
- "lt";
- b[GeoGlobe.Filter.Comparison.LESS_THAN_OR_EQUAL_TO] = "lte";
- b[GeoGlobe.Filter.Comparison.GREATER_THAN] = "gt";
- b[GeoGlobe.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO] = "gte";
- b[GeoGlobe.Filter.Comparison.LIKE] = "ilike";
- return GeoGlobe.Class4OL(GeoGlobe.Format, {
- wildcarded: !1,
- srsInBBOX: !1,
- write: function(c, d) {
- var d = d || {},
- e = c.CLASS_NAME,
- e = e.substring(e.lastIndexOf(".") + 1);
- switch (e) {
- case "Spatial":
- switch (c.type) {
- case GeoGlobe.Filter.Spatial.BBOX:
- d.bbox = c.value.toArray();
- this.srsInBBOX && c.projection && d.bbox.push(c.projection.getCode());
- break;
- case GeoGlobe.Filter.Spatial.DWITHIN:
- d.tolerance = c.distance;
- case GeoGlobe.Filter.Spatial.WITHIN:
- d.lon = c.value.x;
- d.lat = c.value.y;
- break;
- default:
- GeoGlobe.Console.warn("Unknown spatial filter type " + c.type)
- }
- break;
- case "Comparison":
- e = b[c.type];
- if (e !== void 0) {
- var f = c.value;
- c.type == GeoGlobe.Filter.Comparison.LIKE && (f = a(f), this.wildcarded && (f = "%" + f + "%"));
- d[c.property + "__" + e] = f;
- d.queryable = d.queryable || [];
- d.queryable.push(c.property)
- } else GeoGlobe.Console.warn("Unknown comparison filter type " + c.type);
- break;
- case "Logical":
- if (c.type === GeoGlobe.Filter.Logical.AND) {
- e = 0;
- for (f = c.filters.length; e < f; e++) d = this.write(c.filters[e], d)
- } else GeoGlobe.Console.warn("Unsupported logical filter type " + c.type);
- break;
- default:
- GeoGlobe.Console.warn("Unknown filter type " + e)
- }
- return d
- },
- CLASS_NAME: "GeoGolobe.Format.QueryStringFilter"
- })
- }();
- GeoGlobe.Format.BusCapabilities = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- tagName: "NETWORK_Capabilities",
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- var a = a.nodeName != this.tagName ? a.getElementsByTagName(this.tagName) : [a],
- b = {};
- a.length > 0 && this.runChildNodes(b, a[0]);
- return b
- },
- runChildNodes: function(a, b, c) {
- for (var b = b.childNodes, d, e, f = 0; f < b.length; ++f) d = b[f], d.nodeType == 1 && (e = c ? this["read_" + c + "_" + d.nodeName] : this["read_" + d.nodeName]) && e.apply(this, [a, d])
- },
- read_Service: function(a, b) {
- var c = {};
- this.runChildNodes(c, b, "Service");
- a.service = c
- },
- read_Service_Name: function(a, b) {
- var c = this.getChildValue(b);
- if (c) a.name = c
- },
- read_Service_Title: function(a, b) {
- var c = this.getChildValue(b);
- if (c) a.title = c
- },
- read_Service_Abstract: function(a, b) {
- var c = this.getChildValue(b);
- if (c) a.serviceAbstract = c
- },
- read_Service_KeywordList: function() {},
- read_Service_OnlineResource: function(a, b) {
- var c = this.getChildValue(b);
- if (a) a.onlineResource = c
- },
- read_Capability: function(a, b) {
- var c = {};
- this.runChildNodes(c,
- b, "Capability");
- a.capability = c
- },
- read_Capability_Request: function(a, b) {
- var c = {};
- this.runChildNodes(c, b, "Capability_Request");
- a.request = c
- },
- read_Capability_Request_GetCapabilities: function(a, b) {
- var c = b.getElementsByTagName("HTTP"),
- d = {};
- c[0] && this.runChildNodes(d, c[0], "Capability_Request_GetCapabilities_DCPType_HTTP");
- a.getCapabilities = d
- },
- read_Capability_Request_GetCapabilities_DCPType_HTTP_Get: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.getUrl = c
- },
- read_Capability_Request_GetCapabilities_DCPType_HTTP_Post: function(a,
- b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.postUrl = c
- },
- read_Capability_Request_queryStation: function(a, b) {
- var c = b.getElementsByTagName("HTTP"),
- d = {};
- c[0] && this.runChildNodes(d, c[0], "Capability_Request_queryStation_DCPType_HTTP");
- a.queryStation = d
- },
- read_Capability_Request_queryStation_DCPType_HTTP_Get: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.getUrl = c
- },
- read_Capability_Request_queryStation_DCPType_HTTP_Post: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.postUrl = c
- },
- read_Capability_Request_queryLine: function(a, b) {
- var c = b.getElementsByTagName("HTTP"),
- d = {};
- c[0] && this.runChildNodes(d, c[0], "Capability_Request_queryLine_DCPType_HTTP");
- a.queryLine = d
- },
- read_Capability_Request_queryLine_DCPType_HTTP_Get: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.getUrl = c
- },
- read_Capability_Request_queryLine_DCPType_HTTP_Post: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.postUrl = c
- },
- read_Capability_Request_queryChange: function(a, b) {
- var c = b.getElementsByTagName("HTTP"),
- d = {};
- c[0] && this.runChildNodes(d, c[0], "Capability_Request_queryChange_DCPType_HTTP")
- },
- read_Capability_Request_queryChange_DCPType_HTTP_Get: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.getUrl = c
- },
- read_Capability_Request_queryChange_DCPType_HTTP_Post: function(a, b) {
- var c = b.getAttribute("onlineResource");
- if (c) a.postUrl = c
- },
- read_Capability_Networks: function(a, b) {
- for (var c = b.getElementsByTagName("Name"), d = [], e = 0; e < c.length; e++) {
- var f = this.getChildValue(c[e]);
- f && d.push(f)
- }
- a.networks = d
- },
- CLASS_NAME: "GeoGlobe.Format.BusCapabilities"
- });
- GeoGlobe.Format.XML2JSON = GeoGlobe.Class4OL({
- initialize: function() {},
- read: function(a, b, c) {
- b || (b = "");
- a = a.replace(/\s*\/>/g, "/>");
- a = a.replace(/<\?[^>]*>/g, "").replace(/<\![^>]*>/g, "");
- b.sort || (b = b.split(","));
- for (var a = this.no_fast_endings(a), a = this.attris_to_tags(a), a = escape(a), a = a.split("%3C").join("<").split("%3E").join(">").split("%3D").join("=").split("%22").join('"'), d = 0; d < b.length; d++) a = a.replace(RegExp("<" + b[d] + ">", "g"), "*$**" + b[d] + "**$*"), a = a.replace(RegExp("</" + b[d] + ">", "g"), "*$***" + b[d] + "**$*");
- this.xmlobject = {};
- b = this.xml_to_object("<JSONTAGWRAPPER>" + a + "</JSONTAGWRAPPER>").JSONTAGWRAPPER;
- c && (b = this.show_json_structure(b, c));
- return b
- },
- xml_to_object: function(a) {
- for (var b = a.replace(/<\//g, "?"), b = b.split("<"), a = [], c = 0, d = [], e = 1; e < b.length; e++) {
- var f = b[e].split(">")[0];
- d.push(f);
- c++;
- for (a.push(c + "<" + b[e].split("?")[0]); b[e].indexOf("?" + d[d.length - 1] + ">") >= 0;) c--, d.pop()
- }
- for (var g = -1, b = "this.xmlobject", e = 0; e < a.length; e++) {
- var c = "",
- d = a[e].split("<")[0],
- h = a[e].split("<")[1].split(">")[0],
- h = h.replace(/%3A/,
- "_"),
- f = a[e].split(">")[1];
- if (d <= g)
- for (var g = g - d + 1, j = 0; j < g; j++) b = b.substring(0, b.lastIndexOf("."));
- b += "." + h;
- g = b.substring(0, b.lastIndexOf("."));
- eval("typeof " + g) != "object" && (c += g + "={value:" + g + "};\n");
- j = b.substring(b.lastIndexOf(".") + 1);
- h = !1;
- for (k in eval(g)) k == j && (h = !0);
- g = !0;
- for (j = 0; j < f.length; j += 3) f.charAt(j) != "%" && (g = !1);
- f != "" && !g ? f / 1 != f && (f = "'" + f.replace(/\'/g, "\\'") + "'", f = f.replace(/\*\$\*\*\*/g, "</"), f = f.replace(/\*\$\*\*/g, "<"), f = f.replace(/\*\*\$\*/g, ">")) : f = "{}";
- f.charAt(0) == "'" && (f = "unescape(" +
- f + ")");
- h && !eval(b + ".sort") && (c += b + "=[" + b + "];\n");
- g = "=";
- after = "";
- h && (g = ".push(", after = ")");
- eval(c + b + g + f + after);
- eval(b + ".sort") && (b += "[" + eval(b + ".length-1") + "]");
- g = d
- }
- return this.xmlobject
- },
- show_json_structure: function(a, b, c) {
- var d = "";
- d += a.sort ? "[\n" : "{\n";
- for (var e in a) a.sort || (d += e + ":"), d += typeof a[e] == "object" ? this.show_json_structure(a[e], !1, 1) : typeof a[e] == "function" ? a[e] + "" : typeof a[e] != "string" ? a[e] + ",\n" : "'" + a[e].replace(/\'/g, "\\'").replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/\r/g, "\\r") +
- "',\n";
- d += a.sort ? "],\n" : "},\n";
- if (!c) {
- d = d.substring(0, d.lastIndexOf(","));
- d = d.replace(RegExp(",\n}", "g"), "\n}");
- d = d.replace(RegExp(",\n]", "g"), "\n]");
- a = d.split("\n");
- d = "";
- for (e = c = 0; e < a.length; e++) {
- (a[e].indexOf("}") >= 0 || a[e].indexOf("]") >= 0) && c--;
- tabs = "";
- for (var f = 0; f < c; f++) tabs += "\t";
- d += tabs + a[e] + "\n";
- (a[e].indexOf("{") >= 0 || a[e].indexOf("[") >= 0) && c++
- }
- b == "html" && (d = d.replace(/</g, "<").replace(/>/g, ">"), d = d.replace(/\n/g, "<BR>").replace(/\t/g, " "));
- b == "compact" && (d = d.replace(/\n/g,
- "").replace(/\t/g, ""))
- }
- return d
- },
- no_fast_endings: function(a) {
- for (var a = a.split("/>"), b = 1; b < a.length; b++) {
- var c = a[b - 1].substring(a[b - 1].lastIndexOf("<") + 1).split(" ")[0];
- a[b] = "></" + c + ">" + a[b]
- }
- return a = a.join("")
- },
- attris_to_tags: function(a) {
- for (var b = " =\"'".split(""), a = a.split(">"), c = 0; c < a.length; c++) {
- for (var d = a[c].split("<"), e = 0; e < 4; e++) d[0] = d[0].replace(RegExp(b[e], "g"), "_jsonconvtemp" + e + "_");
- if (d[1]) {
- d[1] = d[1].replace(/'/g, '"');
- d[1] = d[1].split('"');
- for (var f = 1; f < d[1].length; f += 2)
- for (e = 0; e < 4; e++) d[1][f] =
- d[1][f].replace(RegExp(b[e], "g"), "_jsonconvtemp" + e + "_");
- d[1] = d[1].join('"')
- }
- a[c] = d.join("<")
- }
- a = a.join(">");
- a = a.replace(/ ([^=]*)=([^ |>]*)/g, "><$1>$2</$1");
- a = a.replace(/>"/g, ">").replace(/"</g, "<");
- for (e = 0; e < 4; e++) a = a.replace(RegExp("_jsonconvtemp" + e + "_", "g"), b[e]);
- return a
- },
- CLASS_NAME: "GeoGlobe.Format.XML2JSON"
- });
- GeoGlobe.Format.CSWGetRecords = function(a) {
- var a = GeoGlobe.Util.applyDefaults(a, GeoGlobe.Format.CSWGetRecords.DEFAULTS),
- b = GeoGlobe.Format.CSWGetRecords["v" + a.version.replace(/\./g, "_")];
- if (!b) throw "Unsupported CSWGetRecords version: " + a.version;
- return new b(a)
- };
- GeoGlobe.Format.CSWGetRecords.DEFAULTS = {
- version: "2.0.2"
- };
- GeoGlobe.Format.CSWGetRecords.v2_0_2 = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- namespaces: {
- csw: "http://www.opengis.net/cat/csw/2.0.2",
- dc: "http://purl.org/dc/elements/1.1/",
- dct: "http://purl.org/dc/terms/",
- gmd: "http://www.isotc211.org/2005/gmd",
- geonet: "http://www.fao.org/geonetwork",
- ogc: "http://www.opengis.net/ogc",
- ows: "http://www.opengis.net/ows",
- xlink: "http://www.w3.org/1999/xlink",
- xsi: "http://www.w3.org/2001/XMLSchema-instance"
- },
- defaultPrefix: "csw",
- version: "2.0.2",
- schemaLocation: "http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd",
- requestId: null,
- resultType: null,
- outputFormat: null,
- outputSchema: null,
- startPosition: null,
- maxRecords: null,
- DistributedSearch: null,
- ResponseHandler: null,
- Query: null,
- regExes: {
- trimSpace: /^\s*|\s*$/g,
- removeSpace: /\s*/g,
- splitSpace: /\s+/,
- trimComma: /\s*,\s*/g
- },
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) a = a.documentElement;
- var b = {};
- this.readNode(a, b);
- return b
- },
- readers: {
- csw: {
- GetRecordsResponse: function(a,
- b) {
- b.records = [];
- this.readChildNodes(a, b);
- var c = this.getAttributeNS(a, "", "version");
- if (c != "") b.version = c
- },
- RequestId: function(a, b) {
- b.RequestId = this.getChildValue(a)
- },
- SearchStatus: function(a, b) {
- b.SearchStatus = {};
- var c = this.getAttributeNS(a, "", "timestamp");
- if (c != "") b.SearchStatus.timestamp = c
- },
- SearchResults: function(a, b) {
- this.readChildNodes(a, b);
- for (var c = a.attributes, d = {}, e = 0, f = c.length; e < f; ++e) d[c[e].name] = c[e].name == "numberOfRecordsMatched" || c[e].name == "numberOfRecordsReturned" || c[e].name == "nextRecord" ?
- parseInt(c[e].nodeValue) : c[e].nodeValue;
- b.SearchResults = d
- },
- SummaryRecord: function(a, b) {
- var c = {
- type: "SummaryRecord"
- };
- this.readChildNodes(a, c);
- b.records.push(c)
- },
- BriefRecord: function(a, b) {
- var c = {
- type: "BriefRecord"
- };
- this.readChildNodes(a, c);
- b.records.push(c)
- },
- DCMIRecord: function(a, b) {
- var c = {
- type: "DCMIRecord"
- };
- this.readChildNodes(a, c);
- b.records.push(c)
- },
- Record: function(a, b) {
- var c = {
- type: "Record"
- };
- this.readChildNodes(a, c);
- b.records.push(c)
- },
- "*": function(a, b) {
- var c = a.localName || a.nodeName.split(":").pop();
- b[c] = this.getChildValue(a)
- }
- },
- geonet: {
- info: function(a, b) {
- var c = {};
- this.readChildNodes(a, c);
- b.gninfo = c
- }
- },
- dc: {
- "*": function(a, b) {
- var c = a.localName || a.nodeName.split(":").pop();
- GeoGlobe.Util.isArray(b[c]) || (b[c] = []);
- for (var d = {}, e = a.attributes, f = 0, g = e.length; f < g; ++f) d[e[f].name] = e[f].nodeValue;
- d.value = this.getChildValue(a);
- d.value != "" && b[c].push(d)
- }
- },
- dct: {
- "*": function(a, b) {
- var c = a.localName || a.nodeName.split(":").pop();
- GeoGlobe.Util.isArray(b[c]) || (b[c] = []);
- b[c].push(this.getChildValue(a))
- }
- },
- ows: GeoGlobe.Util.applyDefaults({
- BoundingBox: function(a,
- b) {
- if (b.bounds) b.BoundingBox = [{
- crs: b.projection,
- value: [b.bounds._sw.lng, b.bounds._sw.lat, b.bounds._ne.lng, b.bounds._ne.lat]
- }], delete b.projection, delete b.bounds;
- GeoGlobe.Format.OWSCommon.v1_0_0.prototype.readers.ows.BoundingBox.apply(this, arguments)
- }
- }, GeoGlobe.Format.OWSCommon.v1_0_0.prototype.readers.ows)
- },
- write: function(a) {
- a = this.writeNode("csw:GetRecords", a);
- a.setAttribute("xmlns:gmd", this.namespaces.gmd);
- return GeoGlobe.Format.XML.prototype.write.apply(this, [a])
- },
- writers: {
- csw: {
- GetRecords: function(a) {
- a ||
- (a = {});
- var b = this.createElementNSPlus("csw:GetRecords", {
- attributes: {
- service: "CSW",
- version: this.version,
- requestId: a.requestId || this.requestId,
- resultType: a.resultType || this.resultType,
- outputFormat: a.outputFormat || this.outputFormat,
- outputSchema: a.outputSchema || this.outputSchema,
- startPosition: a.startPosition || this.startPosition,
- maxRecords: a.maxRecords || this.maxRecords
- }
- });
- if (a.DistributedSearch || this.DistributedSearch) this.writeNode("csw:DistributedSearch", a.DistributedSearch || this.DistributedSearch, b);
- var c = a.ResponseHandler || this.ResponseHandler;
- if (GeoGlobe.Util.isArray(c) && c.length > 0)
- for (var d = 0, e = c.length; d < e; d++) this.writeNode("csw:ResponseHandler", c[d], b);
- this.writeNode("Query", a.Query || this.Query, b);
- return b
- },
- DistributedSearch: function(a) {
- return this.createElementNSPlus("csw:DistributedSearch", {
- attributes: {
- hopCount: a.hopCount
- }
- })
- },
- ResponseHandler: function(a) {
- return this.createElementNSPlus("csw:ResponseHandler", {
- value: a.value
- })
- },
- Query: function(a) {
- a || (a = {});
- var b = this.createElementNSPlus("csw:Query", {
- attributes: {
- typeNames: a.typeNames || "csw:Record"
- }
- }),
- c = a.ElementName;
- if (GeoGlobe.Util.isArray(c) && c.length > 0)
- for (var d = 0, e = c.length; d < e; d++) this.writeNode("csw:ElementName", c[d], b);
- else this.writeNode("csw:ElementSetName", a.ElementSetName || {
- value: "summary"
- }, b);
- a.Constraint && this.writeNode("csw:Constraint", a.Constraint, b);
- a.SortBy && this.writeNode("ogc:SortBy", a.SortBy, b);
- return b
- },
- ElementName: function(a) {
- return this.createElementNSPlus("csw:ElementName", {
- value: a.value
- })
- },
- ElementSetName: function(a) {
- return this.createElementNSPlus("csw:ElementSetName", {
- attributes: {
- typeNames: a.typeNames
- },
- value: a.value
- })
- },
- Constraint: function(a) {
- var b = this.createElementNSPlus("csw:Constraint", {
- attributes: {
- version: a.version
- }
- });
- if (a.Filter) {
- var c = new GeoGlobe.Format.Filter({
- version: a.version
- });
- b.appendChild(c.write(a.Filter))
- } else a.CqlText && (a = this.createElementNSPlus("CqlText", {
- value: a.CqlText.value
- }), b.appendChild(a));
- return b
- }
- },
- ogc: GeoGlobe.Format.Filter.v1_1_0.prototype.writers.ogc
- },
- CLASS_NAME: "GeoGlobe.Format.CSWGetRecords.v2_0_2"
- });
- (function(a, b) {
- a.GeoGlobe.Format.X2JS = b();
- a.GeoGlobe.Format.X2JS.CLASS_NAME = "GeoGlobe.Format.X2JS"
- })(window, function() {
- return function(a) {
- function b(a) {
- var b = a.localName;
- if (b == null) b = a.baseName;
- if (b == null || b == "") b = a.nodeName;
- return b
- }
- function c(a) {
- return typeof a == "string" ? a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'") : a
- }
- function d(a, b, c, d) {
- for (var e = 0; e < a.length; e++) {
- var f = a[e];
- if (typeof f === "string") {
- if (f == d) break
- } else if (f instanceof RegExp) {
- if (f.test(d)) break
- } else if (typeof f === "function" && f(b, c, d)) break
- }
- return e != a.length
- }
- function e(b, c, e) {
- switch (a.arrayAccessForm) {
- case "property":
- b[c + "_asArray"] = b[c] instanceof Array ? b[c] : [b[c]]
- }!(b[c] instanceof Array) && a.arrayAccessFormPaths.length > 0 && d(a.arrayAccessFormPaths, b, c, e) && (b[c] = [b[c]])
- }
- function f(a) {
- var b = a.split(/[-T:+Z]/g),
- c = new Date(b[0], b[1] - 1, b[2]),
- d = b[5].split(".");
- c.setHours(b[3], b[4], d[0]);
- d.length > 1 && c.setMilliseconds(d[1]);
- b[6] && b[7] ? (b = b[6] * 60 + Number(b[7]), b = 0 + ((/\d\d-\d\d:\d\d$/.test(a) ?
- "-" : "+") == "-" ? -1 * b : b), c.setMinutes(c.getMinutes() - b - c.getTimezoneOffset())) : a.indexOf("Z", a.length - 1) !== -1 && (c = new Date(Date.UTC(c.getFullYear(), c.getMonth(), c.getDate(), c.getHours(), c.getMinutes(), c.getSeconds(), c.getMilliseconds())));
- return c
- }
- function g(b, c, e) {
- return a.datetimeAccessFormPaths.length > 0 ? (e = e.split(".#")[0], d(a.datetimeAccessFormPaths, b, c, e) ? f(b) : b) : b
- }
- function h(c, f) {
- if (c.nodeType == s.DOCUMENT_NODE) {
- for (var j = {}, l = c.childNodes, m = 0; m < l.length; m++) {
- var n = l.item(m);
- if (n.nodeType == s.ELEMENT_NODE) {
- var o =
- b(n);
- j[o] = h(n, o)
- }
- }
- return j
- } else if (c.nodeType == s.ELEMENT_NODE) {
- j = {};
- j.__cnt = 0;
- l = c.childNodes;
- for (m = 0; m < l.length; m++)
- if (n = l.item(m), o = b(n), n.nodeType != s.COMMENT_NODE) {
- var p = f + "." + o;
- if (n.nodeType == s.ELEMENT_NODE && a.xmlElementsFilter.length > 0 ? d(a.xmlElementsFilter, j, o, p) : 1) j.__cnt++, j[o] == null ? (j[o] = h(n, p), e(j, o, p)) : (j[o] != null && !(j[o] instanceof Array) && (j[o] = [j[o]], e(j, o, p)), j[o][j[o].length] = h(n, p))
- }
- for (l = 0; l < c.attributes.length; l++) m = c.attributes.item(l), j.__cnt++, j[a.attributePrefix + m.name] = m.value;
- l = c.prefix;
- if (l != null && l != "") j.__cnt++, j.__prefix = l;
- if (j["#text"] != null) {
- j.__text = j["#text"];
- if (j.__text instanceof Array) j.__text = j.__text.join("\n");
- if (a.stripWhitespaces) j.__text = j.__text.trim();
- delete j["#text"];
- a.arrayAccessForm == "property" && delete j["#text_asArray"];
- j.__text = g(j.__text, o, f + "." + o)
- }
- if (j["#cdata-section"] != null) j.__cdata = j["#cdata-section"], delete j["#cdata-section"], a.arrayAccessForm == "property" && delete j["#cdata-section_asArray"];
- j.__cnt == 0 && a.emptyNodeForm == "text" ? j = "" : j.__cnt ==
- 1 && j.__text != null ? j = j.__text : j.__cnt == 1 && j.__cdata != null && !a.keepCData ? j = j.__cdata : j.__cnt > 1 && j.__text != null && a.skipEmptyTextNodesForObj && (a.stripWhitespaces && j.__text == "" || j.__text.trim() == "") && delete j.__text;
- delete j.__cnt;
- if (a.enableToStringFunc && (j.__text != null || j.__cdata != null)) j.toString = function() {
- return (this.__text != null ? this.__text : "") + (this.__cdata != null ? this.__cdata : "")
- };
- return j
- } else if (c.nodeType == s.TEXT_NODE || c.nodeType == s.CDATA_SECTION_NODE) return c.nodeValue
- }
- function j(b, d, e, f) {
- d =
- "<" + (b != null && b.__prefix != null ? b.__prefix + ":" : "") + d;
- if (e != null)
- for (var g = 0; g < e.length; g++) {
- var h = e[g],
- j = b[h];
- a.escapeMode && (j = c(j));
- d += " " + h.substr(a.attributePrefix.length) + "=";
- d += a.useDoubleQuotes ? '"' + j + '"' : "'" + j + "'"
- }
- d += f ? "/>" : ">";
- return d
- }
- function l(a, b) {
- return "</" + (a.__prefix != null ? a.__prefix + ":" : "") + b + ">"
- }
- function m(b, c) {
- return a.arrayAccessForm == "property" && c.toString().indexOf("_asArray", c.toString().length - 8) !== -1 || c.toString().indexOf(a.attributePrefix) == 0 || c.toString().indexOf("__") == 0 ||
- b[c] instanceof Function ? !0 : !1
- }
- function n(a) {
- var b = 0;
- if (a instanceof Object)
- for (var c in a) m(a, c) || b++;
- return b
- }
- function p(b) {
- var c = [];
- if (b instanceof Object)
- for (var d in b) d.toString().indexOf("__") == -1 && d.toString().indexOf(a.attributePrefix) == 0 && c.push(d);
- return c
- }
- function q(b) {
- var d = "";
- if (b instanceof Object) {
- var e = "";
- b.__cdata != null && (e += "<![CDATA[" + b.__cdata + "]]\>");
- b.__text != null && (e += a.escapeMode ? c(b.__text) : b.__text);
- d += e
- } else b != null && (d += a.escapeMode ? c(b) : b);
- return d
- }
- function o(b, c) {
- var e =
- "";
- if (n(b) > 0)
- for (var f in b) {
- var g;
- if (!(g = m(b, f)))
- if (g = c != "") g = c === "" ? f : c + "." + f, g = !(a.jsonPropertiesFilter.length == 0 || g == "" || d(a.jsonPropertiesFilter, b, f, g));
- if (!g) {
- var h = b[f];
- g = p(h);
- if (h == null || h == void 0) e += j(h, f, g, !0);
- else if (h instanceof Object)
- if (h instanceof Array) {
- var s = f,
- x = c,
- w = "";
- if (h.length == 0) w += j(h, s, g, !0);
- else
- for (g = 0; g < h.length; g++) w += j(h[g], s, p(h[g]), !1), w += o(h[g], x === "" ? s : x + "." + s), w += l(h[g], s);
- e += w
- } else h instanceof Date ? (e += j(h, f, g, !1), e += h.toISOString(), e += l(h, f)) : n(h) > 0 || h.__text !=
- null || h.__cdata != null ? (e += j(h, f, g, !1), e += o(h, c === "" ? f : c + "." + f), e += l(h, f)) : e += j(h, f, g, !0);
- else e += j(h, f, g, !1), e += q(h), e += l(h, f)
- }
- }
- e += q(b);
- return e
- }
- a = a || {};
- if (a.escapeMode === void 0) a.escapeMode = !0;
- a.attributePrefix = a.attributePrefix || "_";
- a.arrayAccessForm = a.arrayAccessForm || "none";
- a.emptyNodeForm = a.emptyNodeForm || "text";
- if (a.enableToStringFunc === void 0) a.enableToStringFunc = !0;
- a.arrayAccessFormPaths = a.arrayAccessFormPaths || [];
- if (a.skipEmptyTextNodesForObj === void 0) a.skipEmptyTextNodesForObj = !0;
- if (a.stripWhitespaces ===
- void 0) a.stripWhitespaces = !0;
- a.datetimeAccessFormPaths = a.datetimeAccessFormPaths || [];
- if (a.useDoubleQuotes === void 0) a.useDoubleQuotes = !1;
- a.xmlElementsFilter = a.xmlElementsFilter || [];
- a.jsonPropertiesFilter = a.jsonPropertiesFilter || [];
- if (a.keepCData === void 0) a.keepCData = !1;
- var s = {
- ELEMENT_NODE: 1,
- TEXT_NODE: 3,
- CDATA_SECTION_NODE: 4,
- COMMENT_NODE: 8,
- DOCUMENT_NODE: 9
- };
- this.parseXmlString = function(a) {
- var b = window.ActiveXObject || "ActiveXObject" in window;
- if (a === void 0) return null;
- var c;
- if (window.DOMParser) {
- var d = new window.DOMParser,
- e = null;
- if (!b) try {
- e = d.parseFromString("INVALID", "text/xml").getElementsByTagName("parsererror")[0].namespaceURI
- } catch (f) {
- e = null
- }
- try {
- c = d.parseFromString(a, "text/xml"), e != null && c.getElementsByTagNameNS(e, "parsererror").length > 0 && (c = null)
- } catch (g) {
- c = null
- }
- } else a.indexOf("<?") == 0 && (a = a.substr(a.indexOf("?>") + 2)), c = new ActiveXObject("Microsoft.XMLDOM"), c.async = "false", c.loadXML(a);
- return c
- };
- this.asArray = function(a) {
- return a === void 0 || a == null ? [] : a instanceof Array ? a : [a]
- };
- this.toXmlDateTime = function(a) {
- return a instanceof
- Date ? a.toISOString() : typeof a === "number" ? (new Date(a)).toISOString() : null
- };
- this.asDateTime = function(a) {
- return typeof a == "string" ? f(a) : a
- };
- this.xml2json = function(a) {
- return h(a)
- };
- this.xml_str2json = function(a) {
- a = this.parseXmlString(a);
- return a != null ? this.xml2json(a) : null
- };
- this.json2xml_str = function(a) {
- return o(a, "")
- };
- this.json2xml = function(a) {
- return this.parseXmlString(this.json2xml_str(a))
- };
- this.getVersion = function() {
- return "1.2.0"
- }
- }
- });
- GeoGlobe.Format.GeoJSONUtil = GeoGlobe.Class4OL({
- initialize: function() {},
- read: function(a, b) {
- var c = null;
- if (this._isValidType(b)) c = this._manyToFeatures(a, b);
- else throw "type \u7c7b\u578b\u9519\u8bef! Point|LineString|Polygon";
- return c
- },
- _isValidType: function(a) {
- var b = !1;
- switch (a) {
- case "Point":
- b = !0;
- break;
- case "LineString":
- b = !0;
- break;
- case "Polygon":
- b = !0;
- break;
- default:
- b = !1
- }
- return b
- },
- _manyToFeatures: function(a, b) {
- var c = {
- type: "geojson",
- data: {
- type: "FeatureCollection",
- features: []
- }
- };
- try {
- for (var d = 0; d < a.length; d++) c.data.features.push({
- type: "Feature",
- properties: {},
- geometry: {
- type: b,
- coordinates: a[d]
- }
- })
- } catch (e) {
- throw "arr \u6570\u636e\u9519\u8bef! [Point]|[[LineString]]|[[[Polygon]]]";
- }
- return c
- },
- _oneToFeatures: function(a, b) {
- return {
- type: "geojson",
- data: {
- type: "Feature",
- properties: {},
- geometry: {
- type: b,
- coordinates: a
- }
- }
- }
- },
- point: function(a) {
- return this._oneToFeatures(a, "Point")
- },
- line: function(a) {
- return this._oneToFeatures(a, "LineString")
- },
- polygon: function(a) {
- return this._oneToFeatures(a, "Polygon")
- },
- points: function(a) {
- return this._manyToFeatures(a, "Point")
- },
- lines: function(a) {
- return this._manyToFeatures(a, "LineString")
- },
- polygons: function(a) {
- return this._manyToFeatures(a, "Polygon")
- },
- geoProperties: function(a) {
- return a instanceof Array ? this._setFeatureCollection(a) : this._setFeature(a)
- },
- _setFeature: function(a) {
- return {
- type: "geojson",
- data: {
- type: "Feature",
- properties: a.properties || {},
- geometry: a.geometry
- }
- }
- },
- _setFeatureCollection: function(a) {
- var b = {
- type: "geojson",
- data: {
- type: "FeatureCollection",
- features: []
- }
- };
- try {
- for (var c = 0; c < a.length; c++) b.data.features.push({
- type: "Feature",
- properties: a[c].properties || {},
- geometry: a[c].geometry
- })
- } catch (d) {
- throw "arr \u6570\u636e\u9519\u8bef! [Point]|[[LineString]]|[[[Polygon]]]";
- }
- return b
- },
- CLASS_NAME: "GeoGlobe.Format.GeoJSONUtil"
- });
- GeoGlobe.Analysis.BufferAnalysis = GeoGlobe.Class4OL({
- url: null,
- type: 1,
- accuracy: 32,
- initialize: function(a, b) {
- this.url = a;
- GeoGlobe.Util.extend(this, b)
- },
- _buildPostXML: function(a, b) {
- return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><wps:Execute service="WPS" version="1.0.0" xmlns:gml="http://www.opengis.net/gml" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 ../wpsExecute_request.xsd"><ows:Identifier>Buffer</ows:Identifier><wps:DataInputs><wps:Input><ows:Identifier>InputPolygon</ows:Identifier><wps:Data><wps:ComplexData schema="http://foo.bar/MyComplexValueSchema.xsd" mimeType="text/xml" encoding="UTF-8">' + (new GeoGlobe.Format.GML).write(a) +
- "</wps:ComplexData></wps:Data></wps:Input><wps:Input><ows:Identifier>BufferDistance</ows:Identifier><wps:Data><wps:LiteralData>" + b + "</wps:LiteralData></wps:Data></wps:Input><wps:Input><ows:Identifier>BufferType</ows:Identifier><wps:Data><wps:LiteralData>" + this.type + "</wps:LiteralData></wps:Data></wps:Input><wps:Input><ows:Identifier>BufferAccuracy</ows:Identifier><wps:Data><wps:LiteralData>" + this.accuracy + "</wps:LiteralData></wps:Data></wps:Input></wps:DataInputs><wps:ResponseForm><wps:RawDataOutput><ows:Identifier>BufferedPolygon</ows:Identifier></wps:RawDataOutput></wps:ResponseForm></wps:Execute>"
- },
- _getFeaturesCenter: function(a) {
- return this._getFeaturesExtent(a).getCenterLonLat()
- },
- _getFeaturesExtent: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- var b = null;
- if (a && a.length > 0)
- for (var b = new GeoGlobe.LngLatBounds, c = null, d = 0, e = a.length; d < e; d++)(c = a[d].geometry) && b.extend(c.getBounds());
- return b
- },
- startAnalysis: function(a, b, c) {
- var d = ["m", "km", "degree"],
- a = (new GeoGlobe.Format.GeoJSON).read(a),
- e = this._getFeaturesCenter(a);
- if (!c || GeoGlobe.Util.indexOf(d, c) == -1) c = "m";
- switch (c) {
- case "km":
- b *= 1E3;
- case "m":
- b =
- this._meterToDegree(b, e)
- }
- b = this._buildPostXML(a, b);
- new GeoGlobe.Request.POST({
- url: this.url,
- data: b,
- scope: this,
- success: function(a) {
- "" == a.responseText || null == a.responseText ? this.failFn() : (a = this._parserResult(a), a = (new GeoGlobe.Format.GeoJSON).write(a), this.successFn((new GeoGlobe.Format.JSON).read(a)))
- },
- failure: this.failFn
- })
- },
- _meterToDegree: function(a, b) {
- return a * (8.99E-6 / Math.cos(GeoGlobe.Util.rad(b.lat)))
- },
- successFn: function() {},
- failFn: function() {
- alert("\u7f13\u51b2\u5206\u6790\u64cd\u4f5c\u5931\u8d25\uff0c\u8bf7\u68c0\u6d4b\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002")
- },
- _parserResult: function(a) {
- var b = null,
- b = new GeoGlobe.Format.XML;
- if (!a.responseXML) a.responseXML = b.read(a.responseText);
- return b = (new GeoGlobe.Format.GML).read(a.responseXML)
- },
- CLASS_NAME: "GeoGlobe.Analysis.BufferAnalysis"
- });
- GeoGlobe.Analysis.BufferAnalysis.CAP_ROUND = 1;
- GeoGlobe.Analysis.BufferAnalysis.CAP_BUTT = 2;
- GeoGlobe.Analysis.BufferAnalysis.CAP_SQUARE = 3;
- GeoGlobe.Analysis.GetFeature = GeoGlobe.Class4OL({
- url: null,
- type: "intersection",
- _reqStrTemplate: "{'GetFeature': {'service': 'OverlapService','version': '1.0.0','dataSource':'${sourceInputs}','Query': [{'typeName':'${dataInputs}'}],'maxFeatures': '','startPosition': '','outPutFormat': 'GeoJSON','resultType': ''}}",
- initialize: function(a, b) {
- this.url = a;
- GeoGlobe.Util.extend(this, b)
- },
- _buildReqStr: function() {
- return GeoGlobe.String.format(this._reqStrTemplate, {
- type: this.type,
- dataInputs: this.typeName,
- sourceInputs: this.DataSource
- })
- },
- startAnalysis: function() {
- if (this._checkSet()) return !1;
- var a = this._buildReqStr();
- new GeoGlobe.Request.POST({
- url: this.url,
- data: a,
- scope: this,
- success: function(a) {
- "" == a.responseText || null == a.responseText ? this.failFn() : this.successFn(a)
- },
- failure: this.failFn
- })
- },
- _checkSet: function() {
- if (!this.url) return !1
- },
- successFn: function() {},
- failFn: function() {
- alert("\u670d\u52a1\u8bf7\u6c42\u64cd\u4f5c\u5931\u8d25\uff0c\u8bf7\u68c0\u6d4b\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002")
- },
- CLASS_NAME: "GeoGlobe.Analysis.GetFeature"
- });
- GeoGlobe.Analysis.SpatialAnalysis = GeoGlobe.Class({
- url: null,
- type: "intersection",
- _requestStrTemplate: "{'SpatialAnalysis': {'service': 'OverlapService','version': '1.0.0','origionLayerNames': ['${origionLayerNames}'],'targetLayerNames': ['${targetLayerNames}'],'outPutFormat': 'GeoJSON','operator': '${dataInputs}','isSynchronization': 'true','tolerance': '${tolerance}'}}",
- initialize: function(a, b) {
- this.url = a;
- GeoGlobe.Util.extend(this, b)
- },
- _buildRequestStr: function() {
- return GeoGlobe.String.format(this._requestStrTemplate, {
- type: this.type,
- dataInputs: this.operator,
- origionLayerNames: this.origionLayerNames,
- targetLayerNames: this.targetLayerNames,
- tolerance: this.tolerance
- })
- },
- startAnalysis: function(a) {
- if (this._checkSet()) return !1;
- var b = this._buildRequestStr();
- new GeoGlobe.Request.POST({
- url: this.url,
- data: b,
- scope: this,
- success: function(b) {
- "" == b.responseText || null == b.responseText ? this.failFn() : this.successFn(b, a)
- },
- failure: this.failFn
- })
- },
- _checkSet: function() {
- if (!this.url) return !1
- },
- successFn: function() {},
- failFn: function() {
- alert("\u53e0\u7f6e\u5206\u6790\u64cd\u4f5c\u5931\u8d25\uff0c\u8bf7\u68c0\u6d4b\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002")
- },
- CLASS_NAME: "GeoGlobe.Analysis.SpatialAnalysis"
- });
- GeoGlobe.Analysis.CoreBufferAnalysis = GeoGlobe.Class({
- url: null,
- type: "intersection",
- _requestStrTemplate: "{'BufferAnalysis': {'service': 'OverlapService','version': '1.0.0','layerName': '${layerName}','bufferRadius': '${bufferRadius}','bufferStyle':'${bufferStyle}','outPutFormat': 'JSON','bufferType': '${bufferType}','isSynchronization': 'true'}}",
- initialize: function(a, b) {
- this.url = a;
- GeoGlobe.Util.extend(this, b)
- },
- _buildRequestStr: function() {
- return GeoGlobe.String.format(this._requestStrTemplate, {
- type: this.type,
- layerName: this.layerName,
- bufferRadius: this.bufferRadius,
- bufferStyle: this.bufferStyle,
- bufferType: this.bufferType
- })
- },
- startAnalysis: function(a) {
- if (this._checkSet()) return !1;
- var b = this._buildRequestStr();
- new GeoGlobe.Request.POST({
- url: this.url,
- data: b,
- scope: this,
- success: function(b) {
- "" == b.responseText || null == b.responseText ? this.failFn() : this.successFn(b, a)
- },
- failure: this.failFn
- })
- },
- _checkSet: function() {
- if (!this.url) return !1
- },
- successFn: function() {},
- failFn: function() {
- alert("\u7f13\u51b2\u5206\u6790\u64cd\u4f5c\u5931\u8d25\uff0c\u8bf7\u68c0\u6d4b\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c")
- },
- CLASS_NAME: "GeoGlobe.Analysis.CoreBufferAnalysis"
- });
- GeoGlobe.Query.Service = GeoGlobe.Class4OL({
- name: null,
- url: null,
- version: null,
- userid: "test@liferay.com",
- initialize: function(a, b, c) {
- this.name = a;
- this.url = b;
- GeoGlobe.Util.extend(this, c)
- },
- getCapabilities: function() {},
- isExist: function() {},
- failFn: function(a) {
- alert("\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + this.url + "\n\u64cd\u4f5c\u7c7b\u578b\uff1a" +
- a)
- },
- _parseToXML: function(a) {
- var b = a.responseXML;
- if (!b || !b.documentElement) b = a.responseText;
- return (new GeoGlobe.Format.XML).read(b)
- },
- _checkIsError: function(a) {
- if ((new GeoGlobe.Format.XML).read(a).selectNodes("ServiceExceptionReport").length > 0) return this._parseToJSON(a);
- return null
- },
- _isException: function(a) {
- if (a && a.ServiceExceptionReport) return !0;
- return !1
- },
- _parseToJSON: function(a) {
- return (new GeoGlobe.Util.Format.XML2JSON).read(a)
- },
- CLASS_NAME: "GeoGlobe.Query.Service"
- });
- GeoGlobe.Query.RouteQuery = GeoGlobe.Class4OL(GeoGlobe.Query.Service, {
- _format: null,
- initialize: function(a, b, c) {
- this.name = a;
- this.url = b;
- this._format = new GeoGlobe.Format.RouteQuery;
- GeoGlobe.Util.extend(this, c)
- },
- getCapabilities: function(a, b) {
- GeoGlobe.loadURL(this.url, {
- REQUEST: "GetCapabilities"
- }, this, a, b)
- },
- findRoute: function(a, b, c) {
- var d = {
- data: !0,
- orig: !0,
- dest: !0
- },
- e;
- for (e in d)
- if (!(e in a)) throw Error("Missing property '" + e + "'");
- a = GeoGlobe.Util.pick(a, ["data", "orig", "dest", "service ", "version ", "radius ",
- "queryType", "midpos ", "avoidPos", "filterRoute", "resultCount"
- ], !0);
- GeoGlobe.Util.applyDefaults(a, {
- REQUEST: "FindRoute",
- SERVICE: "ROUTE",
- VERSION: "1.0.0"
- });
- GeoGlobe.Request.GET({
- url: this.url,
- params: a,
- async: !1,
- scope: this,
- success: function(a) {
- a = this._format.read(a.responseText);
- if (typeof a.exceptionInfo !== "string") {
- var a = new GeoGlobe.Query.RoutesResult(a),
- c = a.routes,
- c = (new GeoGlobe.Format.GeoJSON).write(c);
- geojsonRoute = (new GeoGlobe.Format.JSON).read(c);
- a.geojsonRoute = geojsonRoute
- }
- b(a)
- },
- failure: c
- })
- },
- getRouteInfo: function(a,
- b, c) {
- var d = {
- REQUEST: "GetRouteInfo",
- SERVICE: "ROUTE",
- VERSION: "1.0.0"
- };
- if (!a.data || !a.id) throw "Error!Not data and id for bus query.";
- d.DATA = a.data;
- d.ID = a.id;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- success: function(a) {
- a = this._format.read(a.responseText);
- typeof a.exceptionInfo !== "string" && (a = new GeoGlobe.Query.RouteInfoResult(a));
- b(a)
- },
- failure: c
- })
- },
- CLASS_NAME: "GeoGlobe.Query.RouteQuery"
- });
- GeoGlobe.Format.RouteQuery = new GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- initialize: function(a) {
- GeoGlobe.Format.XML.prototype.initialize.apply(this, [a])
- },
- read: function(a) {
- var b = {},
- c = [];
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- if (a && a.nodeType == 9) {
- var c = [],
- d = GeoGlobe.Format.XML.prototype.getChildEl.apply(this, [a]).nodeName;
- if ("ServiceExceptionReport" === d) return c = GeoGlobe.Format.XML.prototype.getElementsByTagNameNS(a, "*", "ServiceException")[0], b = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [c]), c = c.getAttribute("code"), {
- exceptionInfo: b,
- exceptionCode: c
- };
- for (var a = a.getElementsByTagName(d)[0].childNodes, e = 0; e < a.length; e++) {
- var f = a[e],
- g = f.nodeName;
- this._resultPaser[d][g] && this._resultPaser[d][g].apply(this, [f, c])
- }
- }
- d = d.toLowerCase();
- "routeinfo" === d ? b.items = c : b[d] = c;
- return b
- },
- _resultPaser: {
- RouteInfo: {
- Item: function(a, b) {
- var c = a.childNodes,
- d = a.getAttribute("id"),
- e = {};
- d && (e = {
- id: d
- });
- for (d = 0; d < c.length; d++) {
- var a = c[d],
- f = a.nodeName;
- this._resultPaser.RouteInfo[f] && this._resultPaser.RouteInfo[f].apply(this, [a, e])
- }
- b.push(e)
- },
- Name: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- if (c) b.name = c
- },
- Toll: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.toll = c
- },
- Level: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.level = c
- },
- Length: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.length = c
- },
- Geometry: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getElementsByTagNameNS(a, "*", "LineString")[0];
- if (c && (c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [c]), typeof c === "string" && c.length > 0)) {
- for (var c = c.split(" "), d = [], e = 0, f = c.length; e < f; e++) {
- var g = c[e].split(",");
- d.push(new GeoGlobe.Geometry.Point(new Number(g[0]), new Number(g[1])))
- }
- c = new GeoGlobe.Geometry.LineString(d);
- b.geometry = c
- }
- },
- Directions: function(a, b) {
- b.directions = [];
- for (var c = a.childNodes, d = 0; d < c.length; d++) {
- var a = c[d],
- e = a.nodeName;
- if (this._resultPaser.RouteInfo[e]) this._resultPaser.RouteInfo[e](a, b.directions)
- }
- },
- Direction: function(a,
- b) {
- var c = {},
- d = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- c.direction = d;
- c.nextID = a.getAttribute("nextID");
- c.nextItem = a.getAttribute("nextItem");
- b.push(c)
- }
- },
- Routes: {
- Route: function(a, b) {
- for (var c = a.childNodes, d = {}, e = 0; e < c.length; e++) {
- var a = c[e],
- f = a.nodeName;
- this._resultPaser.Routes[f] && this._resultPaser.Routes[f].apply(this, [a, d])
- }
- b.push(d)
- },
- Item: function(a, b) {
- if (!GeoGlobe.Util.isArray(b.items)) b.items = [];
- var c = a.childNodes,
- d = a.getAttribute("id"),
- e = {};
- d && (e = {
- id: d
- });
- for (d = 0; d < c.length; d++) {
- var a =
- c[d],
- f = a.nodeName;
- this._resultPaser.Routes[f] && this._resultPaser.Routes[f].apply(this, [a, e])
- }
- b.items.push(e)
- },
- Distance: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.distance = c
- },
- Name: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- if (c) b.name = c
- },
- Length: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.length = c
- },
- Direction: function(a, b) {
- var c = {},
- d = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- c.direction = d;
- c.nextID = a.getAttribute("nextID");
- c.nextItem = a.getAttribute("nextItem");
- b.direction = c
- },
- Geometry: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getElementsByTagNameNS(a, "*", "LineString")[0];
- if (c && (c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [c]), typeof c === "string" && c.length > 0)) {
- for (var c = c.split(" "), d = [], e = 0, f = c.length; e < f; e++) {
- var g = c[e].split(",");
- d.push(new GeoGlobe.Geometry.Point(new Number(g[0]), new Number(g[1])))
- }
- c = new GeoGlobe.Geometry.LineString(d);
- b.geometry =
- c
- }
- },
- Duration: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.duration = c
- },
- BoundingBox: function(a, b) {
- for (var c = a.childNodes, d = 0; d < c.length; d++) {
- var a = c[d],
- e = a.nodeName;
- this._resultPaser.Routes[e] && this._resultPaser.Routes[e].apply(this, [a, b])
- }
- },
- LowerCorner: function(a, b) {
- if (a.parentNode.tagName === "ows:BoundingBox") {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]).replace(/^\s*|\s*$/g, ""),
- c = c.replace(/\s*,\s*/g, ","),
- c = c.split(",");
- b.left = c[0];
- b.bottom =
- c[1]
- }
- },
- UpperCorner: function(a, b) {
- if (a.parentNode.tagName === "ows:BoundingBox") {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]).replace(/^\s*|\s*$/g, ""),
- c = c.replace(/\s*,\s*/g, ","),
- c = c.split(",");
- b.right = c[0];
- b.top = c[1];
- b.bounds = new GeoGlobe.LngLatBounds(new GeoGlobe.LngLat(b.left, b.bottom), new GeoGlobe.LngLat(b.right, b.top));
- delete b.left;
- delete b.bottom;
- delete b.right;
- delete b.top
- }
- },
- Count: function(a, b) {
- var c = GeoGlobe.Format.XML.prototype.getChildValue.apply(this, [a]);
- b.count = c
- }
- }
- }
- });
- GeoGlobe.Query.RoutesResult = GeoGlobe.Class4OL({
- data: null,
- routes: null,
- initialize: function(a) {
- this.routes = [];
- var b = null;
- if (a && a.routes) this.data = a, b = a.routes;
- if (GeoGlobe.Util.isArray(b))
- for (var a = 0, c = b.length; a < c; a++) {
- var d = new GeoGlobe.Query.RouteResult,
- e;
- for (e in b[a]) d[e] = b[a][e];
- this.routes.push(d)
- }
- },
- CLASS_NAME: "GeoGlobe.Query.RoutesResult"
- });
- GeoGlobe.Query.RouteResult = GeoGlobe.Class4OL({
- bounds: null,
- count: null,
- distance: null,
- duration: null,
- geometry: null,
- items: null,
- initialize: function() {},
- CLASS_NAME: "GeoGlobe.Query.RouteResult"
- });
- GeoGlobe.Query.RouteInfoResult = GeoGlobe.Class4OL({
- data: null,
- items: null,
- initialize: function(a) {
- this.items = [];
- if (a && a.items) {
- this.data = a;
- var b = a.items
- }
- if (GeoGlobe.Util.isArray(b))
- for (var a = 0, c = b.length; a < c; a++) {
- var d = new GeoGlobe.Query.RouteInfoItem,
- e;
- for (e in b[a]) d[e] = b[a][e];
- this.items.push(d)
- }
- },
- CLASS_NAME: "GeoGlobe.Query.RouteInfoResult"
- });
- GeoGlobe.Query.RouteInfoItem = GeoGlobe.Class4OL({
- id: null,
- name: null,
- toll: null,
- length: null,
- geometry: null,
- level: null,
- directions: null,
- initialize: function() {},
- CLASS_NAME: "GeoGlobe.Query.RouteInfoItem"
- });
- GeoGlobe.Query.BusQuery = GeoGlobe.Class4OL(GeoGlobe.Query.Service, {
- networkName: null,
- transferScheme: null,
- initialize: function(a, b, c) {
- this.name = a;
- this.url = b;
- GeoGlobe.Util.extend(this, c)
- },
- getCapabilities: function(a, b) {
- typeof b != "function" && (b = function() {
- alert("\u516c\u4ea4\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + this.url + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities"
- },
- scope: this,
- async: !1,
- success: function(b) {
- typeof a == "function" && a(b)
- },
- failure: b
- })
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- queryStation: function(a, b, c) {
- var d = {
- REQUEST: "QueryStation"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- d.NETWORKNAME = a.networkName;
- if (a.stationId !== null && a.stationId !== void 0) d.STATIONID = a.stationId;
- if (a.stationName !==
- null && a.stationName !== void 0) d.STATIONNAME = a.stationName;
- if (a.lineId !== null && a.lineId !== void 0) d.LINEID = a.lineId;
- if (a.lineName !== null && a.lineName !== void 0) d.LINENAME = a.lineName;
- if (a.coordinate !== null && a.coordinate !== void 0) d.COORDINATE = a.coordinate;
- if (a.bbox !== null && a.bbox !== void 0) d.BOX = a.bbox;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- success: function(a) {
- a = this._parserFeatures(a.responseText);
- b(a)
- },
- failure: c
- })
- },
- queryLine: function(a, b, c) {
- var d = {
- REQUEST: "QueryLine"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- d.NETWORKNAME = a.networkName;
- if (a.lineName !== null && a.lineName !== void 0) d.LINENAME = a.lineName;
- if (a.lineId !== null && a.lineId !== void 0) d.LINEID = a.lineId;
- if (a.stationName !== null && a.stationName !== void 0) d.STATIONNAME = a.stationName;
- if (a.stationId !== null && a.stationId !== void 0) d.STATIONID = a.stationId;
- if (a.coordinate !== null && a.coordinate !== void 0) d.COORDINATE = a.coordinate;
- if (a.bbox !== null && a.bbox !== void 0) d.BOX = a.bbox;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- success: function(a) {
- a = this._parserFeatures(a.responseText);
- b(a)
- },
- failure: c
- })
- },
- queryChange: function(a, b, c) {
- var d = {
- REQUEST: "QueryChange"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- d.NETWORKNAME = a.networkName;
- if (a.startStationId !== null && a.startStationId !== void 0) d.STARTSTATIONID = a.startStationId;
- if (a.endStationId !== null && a.endStationId !== void 0) d.ENDSTATIONID = a.endStationId;
- if (a.orderType !== null && a.orderType !== void 0) d.ORDERTYPE = a.orderType;
- if (a.startCoordinate !== null && a.startCoordinate !== void 0) d.STARTCOORDINATE = a.startCoordinate;
- if (a.endCoordinate !==
- null && a.endCoordinate !== void 0) d.ENDCOORDINATE = a.endCoordinate;
- if (a.maxDepth !== null && a.maxDepth !== void 0) d.MAXDEPTH = a.maxDepth;
- if (a.maxCost !== null && a.maxCost !== void 0) d.MAXCOST = a.maxCost;
- if (a.maxSolutions !== null && a.maxSolutions !== void 0) d.MAXSOLUTIONS = a.maxSolutions;
- if (a.ChangeCount !== null && a.ChangeCount !== void 0) d.CHANGECOUNT = a.ChangeCount;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- success: function(a) {
- for (var c = [], a = (a.responseXML.documentElement ? a.responseXML : format.read(a.responseText)).selectNodes("/Features/FeatureCollection"),
- d = new GeoGlobe.Format.XML, h = 0; h < a.length; h++) {
- var j = a[h],
- l = this._getAttibutionOfNode(j, ["cost", "price", "walkingDistance", "transferTimes"]),
- m = this._parserFeatures(d.write(a[h]));
- m.attributes = l;
- j = j.selectNodes("featureMember");
- for (l = 0; l < j.length; l++) {
- var n = j[l].selectNodes("Road");
- m[l].isOnFoot = n[0].getAttribute("isOnFoot")
- }
- c.push(m)
- }
- b(c)
- },
- failure: c
- })
- },
- _getAttibutionOfNode: function(a, b) {
- var c = {};
- if (a.tagName)
- for (var d = 0; d < b.length; d++) c[b[d]] = a.getAttribute(b[d]);
- return c
- },
- _getGeometryType: function() {
- return "polygon"
- },
- _pagingToString: function(a, b) {
- b = b || this.maxPerPage;
- return "<numPerPage>" + b + "</numPerPage><curPage>" + (a || 1) + "</curPage>"
- },
- _orderByToString: function(a) {
- return a ? "<orderBy><PropertyName>" + a + "</PropertyName></orderBy>" : ""
- },
- _geometryToString: function() {
- return '<geometry><Polygon><outerBoundaryIs><LinearRing><coordinates decimal="." cs="," ts=" ">20,30 21,41 52,42 53,33 20,30</coordinates></LinearRing></outerBoundaryIs></Polygon></geometry>'
- },
- _stringToGeometry: function() {
- return GeoGlobe.Geometry.Polygon.createRegularPolygon(new GeoGlobe.Geometry.Point(Math.random() *
- 360 - 160, Math.random() * 90 - 70), Math.round(Math.random() * 20), Math.round(Math.random() * 10))
- },
- _parserFeatures: function(a) {
- var b = new GeoGlobe.Format.GML;
- b.gmlns = "*";
- return b.read(a)
- },
- _parserResponseText: function(a, b) {
- if (b) var c = RegExp("</" + b + ">", ["g"]),
- a = a.replace(RegExp("<" + b + ">", ["g"]), "<featureMember><" + b + ">"),
- a = a.replace(c, "</" + b + "></featureMember>");
- a = a.replace(/<gml:LineString>/g, "<gml:LineString><gml:coordinates>");
- a = a.replace(/<\/gml:LineString>/g, "</gml:coordinates></gml:LineString>");
- a = a.replace(/<gml:Point>/g,
- "<gml:Point><gml:coordinates>");
- return a = a.replace(/<\/gml:Point>/g, "</gml:coordinates></gml:Point>")
- },
- _parserFeaturesNew: function(a, b) {
- var c = new GeoGlobe.Format.GML;
- c.gmlns = "*";
- if (b) c.featureName = b;
- return c.read(a)
- },
- _parserSuccessResult: function(a) {
- return (new GeoGlobe.Util.Format.XML2JSON).read(a)
- },
- _parseToXML: function(a) {
- var b = a.responseXML;
- if (!b || !b.documentElement) b = a.responseText;
- return (new GeoGlobe.Format.XML).read(b)
- },
- _parseToJSON: function(a) {
- return (new GeoGlobe.Format.XML2JSON).read(a)
- },
- queryTransferScheme: function(a,
- b, c) {
- var d = {
- request: "QueryTransferScheme",
- SERVICE: "BUS",
- VERSION: "1.0.0"
- },
- e = {
- networkName: !0,
- transferMode: !0,
- startInput: !0,
- endInput: !0
- },
- f;
- for (f in e)
- if (!(f in a)) throw Error("\u7f3a\u5c11\u5fc5\u9009\u5c5e\u6027\uff1a'" + f + "'\u3002");
- d.networkName = a.networkName;
- if (a.service !== null && a.service !== void 0) d.SERVICE = a.service;
- if (a.version !== null && a.version !== void 0) d.VERSION = a.version;
- if (a.transferMode !== null && a.transferMode !== void 0) d.TRANSFERMODE = a.transferMode;
- if (a.startInput !== null && a.startInput !== void 0) d.STARTINPUT =
- a.startInput;
- if (a.endInput !== null && a.endInput !== void 0) d.ENDINPUT = a.endInput;
- if (a.inputMode !== null && a.inputMode !== void 0) d.INPUTMODEL = a.inputMode;
- if (a.ExistGoTime !== null && a.ExistGoTime !== void 0) d.EXISTGOTIME = a.ExistGoTime;
- if (a.StartTime !== null && a.StartTime !== void 0) d.STARTTIME = a.StartTime;
- if (a.MaxSearchDistance !== null && a.MaxSearchDistance !== void 0) d.MAXSEARCHDISTANCE = a.MaxSearchDistance;
- if (a.PrioritySubset !== null && a.PrioritySubset !== void 0) d.PRIORITYSUBSET = a.PrioritySubset;
- if (a.ExistAbsolutePriority !==
- null && a.ExistAbsolutePriority !== void 0) d.EXISTABSOLUTEPRIORITY = a.ExistAbsolutePriority;
- if (a.LagSubset !== null && a.LagSubset !== void 0) d.LAGSUBSET = a.LagSubset;
- if (a.OutputPage !== null && a.OutputPage !== void 0) d.OUTPUTPAGE = a.OutputPage;
- if (a.PageSize !== null && a.PageSize !== void 0) d.PAGESIZE = a.PageSize;
- if (a.ChangeCount !== null && a.ChangeCount !== void 0) d.CHANGECOUNT = a.ChangeCount;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- async: !1,
- scope: this,
- success: GeoGlobe.Function.bind(function(a) {
- var c = a.responseXML,
- d = {
- startPoint: [],
- transferScheme: [],
- endPoint: []
- };
- if (!c) return b(d), d;
- var a = new GeoGlobe.Format.XML,
- e = c.selectNodes("/ServiceExceptionReport/ServiceExceptionMessage");
- if (e && e.length > 0) return b(d), d;
- c = c.selectNodes("/QueryTransferSchemeResponse");
- a = this._parseToJSON(a.write(c[0]));
- d = a.QueryTransferSchemeResponse.StartPoint;
- GeoGlobe.Util.isArray(d) || (d = [d]);
- c = a.QueryTransferSchemeResponse.EndPoint;
- GeoGlobe.Util.isArray(c) || (c = [c]);
- a = a.QueryTransferSchemeResponse.TransferScheme;
- d = this._getPointGeometryByGMLPointStr(d[0].Geometry.gml_Point);
- d = new GeoGlobe.Feature(d);
- c = this._getPointGeometryByGMLPointStr(c[0].Geometry.gml_Point);
- c = new GeoGlobe.Feature(c);
- a = this._parserTransferScheme(a);
- d = {
- startPoint: d,
- transferScheme: a,
- endPoint: c
- };
- b(d)
- }, this),
- failure: c
- })
- },
- _parserTransferScheme: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- for (var b = [], c = 0; c < a.length; c++) {
- var d = a[c],
- e = this._parserSectionInfo(d.SectionInfo),
- d = this._parserSectionRouting(d.SectionRouting);
- b.push({
- Cost: a[c].Cost,
- SectionInfo: e,
- SectionRouting: d,
- TotalDistance: a[c].TotalDistance,
- TransferCount: a[c].TransferCount
- })
- }
- return b
- },
- _parserSectionInfo: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- for (var b = [], c = 0; c < a.length; c++) {
- var d = this._getPointFeatureByObj(a[c].FromStation);
- if (a[c].FromStation.PassagewayRouting) {
- var e = this._getPointFeatureByObj(a[c].FromStation.PassagewayRouting);
- if (e.SectionRouting) e.attributes.SectionRouting = e.data.SectionRouting = this._parserSectionRouting(e.SectionRouting);
- d.attributes.PassagewayRouting = d.data.PassagewayRouting = e
- }
- var f = this._getPointFeatureByObj(a[c].ToStation);
- if (a[c].ToStation.PassagewayRouting) {
- e = this._getPointFeatureByObj(a[c].ToStation.PassagewayRouting);
- if (e.SectionRouting) e.attributes.SectionRouting = e.data.SectionRouting = this._parserSectionRouting(e.SectionRouting);
- f.attributes.PassagewayRouting = f.data.PassagewayRouting = e
- }
- var e = this._parserSectionLines(a[c].SectionLines.SectionLine),
- g = this._parserSectionRouting(a[c].SectionRouting);
- b.push({
- FromStation: d,
- SectionLine: e,
- ToStation: f,
- SectionRouting: g
- })
- }
- return b
- },
- _parserSectionLines: function(a) {
- GeoGlobe.Util.isArray(a) ||
- (a = [a]);
- for (var b = [], c = 0; c < a.length; c++) {
- var d = new GeoGlobe.Feature(null, a[c]);
- b.push(d)
- }
- return b
- },
- _parserSectionRouting: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- for (var b = [], c = 0; c < a.length; c++) b.push(a[c]);
- return b
- },
- _getPointGeometryByGMLPointStr: function(a) {
- a = a.split(",");
- return new GeoGlobe.Geometry.Point(parseFloat(a[0]), parseFloat(a[1]))
- },
- _getPointFeatureByObj: function(a) {
- var b = null;
- a.Geometry && a.Geometry.gml_Point && (b = this._getPointGeometryByGMLPointStr(a.Geometry.gml_Point));
- return new GeoGlobe.Feature(b,
- a)
- },
- _getLineGeometryByGMLLineStr: function(a) {
- if (!a) return null;
- for (var a = a.split(" "), b = [], c = 0, d = a.length; c < d; c++) {
- var e = this._getPointGeometryByGMLPointStr(a[c]);
- b.push(e)
- }
- return new GeoGlobe.Geometry.LineString(b)
- },
- queryTransferGeometry: function(a, b, c) {
- var d = {
- request: "QueryTransferGeometry",
- SERVICE: "BUS",
- VERSION: "1.0.0"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- if (a.parameterInfo === null || a.parameterInfo === void 0 || a.parameterInfo === "") throw "Error!Not parameterInfo for bus query.";
- d.networkName = a.networkName;
- d.PARAMETERINFO = "";
- for (var e = 0; e < a.parameterInfo.length; e++) d.PARAMETERINFO += a.parameterInfo[e].toString(), e != a.parameterInfo.length - 1 && (d.PARAMETERINFO += "_");
- if (a.service !== null && a.service !== void 0) d.SERVICE = a.service;
- if (a.version !== null && a.version !== void 0) d.VERSION = a.version;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- async: !1,
- success: GeoGlobe.Function.bind(function(a) {
- a = this._parseQueryTransferGeometryResult(a);
- b(a)
- }, this),
- failure: c
- })
- },
- _parseQueryTransferGeometryResult: function(a) {
- resXML =
- a.responseXML;
- a = [];
- if (!resXML) return a;
- var b = new GeoGlobe.Format.XML,
- c = resXML.selectNodes("/QueryTransferGeometryResponse");
- if (c && c.length <= 0) return a;
- if (b = this._parseToJSON(b.write(c[0])).QueryTransferGeometryResponse.SectionGeometry) {
- GeoGlobe.Util.isArray(b) || (b = [b]);
- for (c = 0; c < b.length; c++) {
- var d = this._getLineGeometryByGMLLineStr(b[c].Geometry.gml_LineString),
- d = new GeoGlobe.Feature(d, {
- ID: b[c].ID
- });
- a.push(d)
- }
- }
- return a
- },
- queryKeyWord: function(a, b, c) {
- var d = {
- REQUEST: "QueryKeyWord",
- SERVICE: "BUS",
- VERSION: "1.0.0",
- SEARCHTYPE: 2
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- if (a.keyWord === null || a.keyWord === void 0 || a.keyWord === "") throw "Error!Not keyWord for bus query.";
- d.NETWORKNAME = a.networkName;
- d.KEYWORD = a.keyWord;
- if (a.service !== null && a.service !== void 0) d.SERVICE = a.service;
- if (a.version !== null && a.version !== void 0) d.VERSION = a.version;
- if (a.searchType !== null && a.searchType !== void 0) d.SEARCHTYPE = a.searchType;
- if (a.keyWordType !== null && a.keyWordType !== void 0) d.KEYWORDTYPE = a.keyWordType;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- async: !1,
- scope: this,
- success: GeoGlobe.Function.bind(function(c) {
- c = this._parserQueryKeyWordResult(c, a.keyWordType);
- b(c)
- }, this),
- failure: c
- })
- },
- _parserQueryKeyWordResult: function(a, b) {
- var c = a.responseXML,
- d = [];
- if (!c) return d;
- var e = new GeoGlobe.Format.XML,
- f = c.selectNodes("/ServiceExceptionReport/ServiceExceptionMessage");
- if (f && f.length > 0) return d;
- c = c.selectNodes("/QueryKeyWordResponse");
- e = this._parseToJSON(e.write(c[0]));
- if (b === 1) {
- (f = e.QueryKeyWordResponse.Stations.Station) && !GeoGlobe.Util.isArray(f) &&
- (f = [f]);
- for (e = 0; e < f.length; e++) c = this._getPointFeatureByObj(f[e]), d.push(c)
- } else if (b === 2) {
- (f = e.QueryKeyWordResponse.Passageways.Passageway) && !GeoGlobe.Util.isArray(f) && (f = [f]);
- for (e = 0; e < f.length; e++) c = this._getPointFeatureByObj(f[e]), d.push(c)
- } else {
- (c = e.QueryKeyWordResponse.Lines.Line) && !GeoGlobe.Util.isArray(c) && (c = [c]);
- for (e = 0; e < c.length; e++) f = new GeoGlobe.Feature(null, c[e]), d.push(f)
- }
- return d
- },
- queryStationInfo: function(a, b, c) {
- var d = {
- REQUEST: "QueryStationInfo",
- SERVICE: "BUS",
- VERSION: "1.0.0"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- if (a.stationId === null || a.stationId === void 0 || a.stationId === "") throw "Error!Not stationId for bus query.";
- d.NETWORKNAME = a.networkName;
- if (a.service !== null && a.service !== void 0) d.SERVICE = a.service;
- if (a.version !== null && a.version !== void 0) d.VERSION = a.version;
- if (a.stationId !== null && a.stationId !== void 0) d.STATIONID = a.stationId;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- success: function(a) {
- if (resXML = a.responseXML) {
- for (var c = new GeoGlobe.Format.XML, a = this._parserQueryStationInfoNode("Lines", c, resXML),
- c = this._parserQueryStationInfoNode("Passageways", c, resXML), d = [], h = 0; h < c.length; h++) {
- var j = this._getPointFeatureByObj(c[h]);
- d.push(j)
- }
- a = {
- lines: a,
- passageways: d
- }
- } else a = {
- lines: [],
- passageways: []
- };
- b(a)
- },
- failure: c
- })
- },
- _parserQueryStationInfoNode: function(a, b, c) {
- switch (a) {
- case "Lines":
- c = c.selectNodes("/QueryStationInfoResponse/StationInfo/Lines");
- a = [];
- if (c.length > 0) b = b.write(c[0]), b = this._parseToJSON(b), a = b.Lines.Line, GeoGlobe.Util.isArray(a) || (a = [a]);
- return a;
- case "Passageways":
- c = c.selectNodes("/QueryStationInfoResponse");
- a = [];
- if (c.length > 0 && (b = b.write(c[0]), b = this._parseToJSON(b), b = b.QueryStationInfoResponse.StationInfo.Passageways)) a = b.Passageway, GeoGlobe.Util.isArray(a) || (a = [a]);
- return a;
- default:
- return []
- }
- },
- queryLineInfo: function(a, b, c) {
- var d = {
- REQUEST: "QueryLineInfo",
- SERVICE: "BUS",
- VERSION: "1.0.0"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- if (a.lineId === null || a.lineId === void 0 || a.lineId === "") throw "Error!Not lineId for bus query.";
- d.NETWORKNAME = a.networkName;
- if (a.service !== null && a.service !== void 0) d.SERVICE =
- a.service;
- if (a.version !== null && a.version !== void 0) d.VERSION = a.version;
- if (a.lineId !== null && a.lineId !== void 0) d.LINEID = a.lineId;
- if (a.startNodeNumber !== null && a.startNodeNumber !== void 0) d.STARTNODENUMBER = a.startNodeNumber;
- if (a.endNodeNumber !== null && a.endNodeNumber !== void 0) d.ENDNODENUMBER = a.endNodeNumber;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- success: function(a) {
- var c = [],
- d = null;
- if (a.responseXML) {
- d = a.responseXML;
- if ((a = d.selectNodes("/ServiceExceptionReport/ServiceExceptionMessage")) && a.length >
- 0) {
- b(c);
- return
- }
- c = this._parserQueryLineInfoNode("Line", new GeoGlobe.Format.XML, d);
- d = [];
- for (a = 0; a < c.length; a++) {
- for (var h = [], j = 0; j < c[a].VIAStations.Station.length; j++) {
- var l = this._getPointFeatureByObj(c[a].VIAStations.Station[j]);
- h.push(l)
- }
- c[a].Stations = h;
- h = this._getLineGeometryByGMLLineStr(c[a].Geometry.gml_LineString);
- h = new GeoGlobe.Feature(h, c[a]);
- d.push(h)
- }
- c = d
- }
- b(c)
- },
- failure: c
- })
- },
- _parserQueryLineInfoNode: function(a, b, c) {
- switch (a) {
- case "Line":
- return a = c.selectNodes("/QueryLineInfoResponse"), b = this._parseToJSON(b.write(a[0])).QueryLineInfoResponse.Line,
- a = [], a = b && !GeoGlobe.Util.isArray(b) ? [b] : b;
- default:
- return []
- }
- },
- queryPassagewayInfo: function(a, b) {
- var c = {
- REQUEST: "QueryPassagewayInfo",
- SERVICE: "BUS",
- VERSION: "1.0.0"
- };
- if (!a.networkName) throw "Error!Not network name for bus query.";
- if (a.passagewayId === null || a.passagewayId === void 0 || a.passagewayId === "") throw "Error!Not passagewayId for bus query.";
- c.NETWORKNAME = a.networkName;
- if (a.service !== null && a.service !== void 0) c.SERVICE = a.service;
- if (a.version !== null && a.version !== void 0) c.VERSION = a.version;
- if (a.passagewayId !==
- null && a.passagewayId !== void 0) c.PASSAGEWAYID = a.passagewayId;
- GeoGlobe.Request.GET({
- url: this.url,
- params: c,
- scope: this,
- success: function(a) {
- var c = a.responseXML,
- f = [];
- if (!c) return b(f), f;
- new GeoGlobe.Format.XML;
- if ((c = c.selectNodes("/ServiceExceptionReport/ServiceExceptionMessage")) && c.length > 0) return b(f), f;
- f = this._parserFeaturesNew(this._parserResponseText(a.responseText), "Stations");
- b(f)
- }
- })
- },
- _queryByName: function(a, b, c) {
- var d = this,
- e = null;
- d.queryKeyWord({
- networkName: d.networkName,
- keyWord: a,
- keyWordType: 1,
- SEARCHTYPE: 2
- }, function(a) {
- if (a.length == 0) alert("\u6ca1\u6709\u67e5\u8be2\u5230\u8d77\u70b9");
- else {
- var g = a[0].geometry.x + " " + a[0].geometry.y;
- d.queryKeyWord({
- networkName: d.networkName,
- keyWord: b,
- keyWordType: 1,
- SEARCHTYPE: 2
- }, function(a) {
- a.length == 0 ? alert("\u6ca1\u6709\u67e5\u8be2\u5230\u7ec8\u70b9") : e = d._queryTransferScheme(g, a[0].geometry.x + " " + a[0].geometry.y, c)
- })
- }
- });
- return e
- },
- queryBus: function(a, b, c) {
- var d = this,
- e = null;
- d.getCapabilities(GeoGlobe.Function.bind(function(f) {
- var g = f.responseXML;
- if (!g || !g.documentElement) g =
- f.responseText;
- f = (new GeoGlobe.Format.BusCapabilities).read(g);
- f.capability ? (d.networkName = f.capability.networks[0], e = typeof a == "string" && typeof b == "string" ? d._queryByName(a, b, c) : d._queryTransferScheme(a.lng + " " + a.lat, b.lng + " " + b.lat, c)) : alert("\u516c\u4ea4\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + url + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- },
- this), function() {
- alert("\u516c\u4ea4\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + url + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- });
- return {
- flag: e ? !0 : !1,
- featuresInfo: e
- }
- },
- failFn: function() {
- alert("\u516c\u4ea4\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" +
- url + "\n\u64cd\u4f5c\u7c7b\u578b\uff1aGetCapabilities")
- },
- _queryTransferScheme: function(a, b, c) {
- this.queryTransferScheme({
- networkName: this.networkName,
- transferMode: c ? c : 0,
- inputMode: 0,
- startInput: a,
- endInput: b
- }, function(a) {
- featuresInfo = a
- });
- this.transferScheme = featuresInfo.transferScheme;
- return featuresInfo
- },
- queryBusTransferSchemeByIndex: function(a) {
- var b = null,
- a = this.transferScheme[parseInt(a)].SectionInfo,
- c = [],
- d = [];
- for (i = 0; i < a.length; i++) {
- var e = a[i].SectionLine[0];
- c.push([0, e.data.ID, e.data.FromOrdinal,
- e.data.ToOrdinal
- ]);
- d.push(a[i].FromStation);
- d.push(a[i].ToStation)
- }
- this.queryTransferGeometry({
- networkName: this.networkName,
- parameterInfo: c
- }, function(a) {
- var c = new GeoGlobe.Format.GeoJSON,
- e = c.write(a),
- c = c.write(d),
- j = new GeoGlobe.Format.JSON,
- e = j.read(e),
- c = j.read(c);
- b = {
- lineFeatures: a,
- geojsonRoute: e,
- stationFeatures: d,
- geojsonStation: c
- }
- });
- return b
- },
- CLASS_NAME: "GeoGlobe.Query.BusQuery"
- });
- (function() {
- if (document.implementation.hasFeature("XPath", "3.0")) XMLDocument.prototype.selectNodes = function(a, b) {
- b || (b = this);
- for (var c = this.evaluate(a, b, function(a) {
- return {
- csw: "http://www.opengis.net/cat/csw",
- smmd: "http://data.sbsm.gov.cn/smmd/2007",
- wfs: "http://www.opengis.net/wfs",
- gml: "http://www.opengis.net/gml",
- geoglobe: "http://www.geostar.com.cn/geoglobe"
- }[a] || null
- }, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), d = [], e = 0; e < c.snapshotLength; e++) d[e] = c.snapshotItem(e);
- return d
- }, Element.prototype.selectNodes =
- function(a) {
- if (this.ownerDocument.selectNodes) return this.ownerDocument.selectNodes(a, this);
- else throw "For XML Elements Only";
- };
- if (document.implementation.hasFeature("XPath", "3.0")) XMLDocument.prototype.selectSingleNode = function(a, b) {
- b || (b = this);
- var c = this.selectNodes(a, b);
- return c.length > 0 ? c[0] : null
- }, Element.prototype.selectSingleNode = function(a) {
- if (this.ownerDocument.selectSingleNode) return this.ownerDocument.selectSingleNode(a, this);
- else throw "For XML Elements Only";
- }
- })();
- GeoGlobe.Query.WFSQuery = GeoGlobe.Class4OL({
- url: null,
- version: "1.0.0",
- featureNS: null,
- isReverse: !1,
- featurePrefix: "",
- featureType: "",
- maxFeatures: 10,
- filter: null,
- geometryName: "the_geom",
- protocol: null,
- format: null,
- outputFormat: "GML",
- formatOptions: null,
- isSeparate: !1,
- srsName: "EPSG:4326",
- time: null,
- userecent: !0,
- sortBy: null,
- groupBy: null,
- resultType: "Results",
- startPosition: null,
- initialize: function(a, b, c) {
- this.url = a;
- this.featureType = b;
- a = null;
- if (c) c.isReverse === !0 ? (this.isReverse = c.isReverse, a = !c.isReverse) : c.isReverse ===
- !1 ? (this.isReverse = c.isReverse, a = !c.isReverse) : a = !this.isReverse, c.format ? (c.format instanceof GeoGlobe.Format.GML.v2 || c.format instanceof GeoGlobe.Format.GML.v3) && c.format.setFeatureType_(b) : this.format = new GeoGlobe.Format.GML({
- xy: a
- });
- GeoGlobe.Util.extend(this, c);
- this.format instanceof GeoGlobe.Format.GeoJSON ? (this.outputFormat = "GeoJson", this.version = "1.0.0") : this.outputFormat = "GML"
- },
- query: function(a, b, c) {
- this.protocol = new GeoGlobe.Protocol.WFS({
- readFormat: this.format,
- formatOptions: this.formatOptions,
- propertyNames: this.propertyNames,
- maxFeatures: this.maxFeatures,
- featurePrefix: this.featurePrefix,
- featureNS: this.featureNS,
- url: this.url,
- version: this.version,
- geometryName: this.geometryName,
- featureType: this.featureType,
- time: this.time,
- userecent: this.userecent,
- srsName: this.srsName
- });
- var a = a || this.filter,
- d = b || this.successFn,
- e = c || this.failFn,
- b = GeoGlobe.Function.bind(function(a) {
- if (a.success()) {
- var b = a.features;
- this.isSeparate && (b = this._separateFeatures(b));
- (a = this._read_trueName(a)) && (b.trueNames = a);
- a = (new GeoGlobe.Format.GeoJSON).write(b);
- a = (new GeoGlobe.Format.JSON).read(a);
- d({
- features: b,
- geojson: a
- })
- } else e()
- }, this);
- this.response = this.protocol.read({
- outputFormat: this.outputFormat,
- sortBy: this.sortBy,
- filter: a,
- callback: b
- })
- },
- queryPage: function(a, b, c, d) {
- var e = d && d.perPageNumber || 15;
- this.protocol = new GeoGlobe.Protocol.WFS({
- readFormat: this.format,
- multi: !0,
- formatOptions: this.formatOptions,
- propertyNames: this.propertyNames,
- maxFeatures: e,
- startPosition: ((d && d.pageNumber || 1) - 1) * e + 1,
- featurePrefix: this.featurePrefix,
- url: this.url,
- featureNS: this.featureNS,
- version: this.version,
- geometryName: this.geometryName,
- featureType: this.featureType,
- time: this.time,
- userecent: this.userecent,
- srsName: this.srsName
- });
- var a = a || this.filter,
- f = b || this.successFn,
- g = c || this.failFn,
- b = GeoGlobe.Function.bind(function(a) {
- if (a.success()) {
- var b = a.features;
- this.isSeparate && (b = this._separateFeatures(b));
- a = this._read_trueName(a);
- b.trueNames = a;
- a = (new GeoGlobe.Format.GeoJSON).write(b);
- a = (new GeoGlobe.Format.JSON).read(a);
- f({
- features: b,
- geojson: a
- })
- } else g()
- }, this);
- this.response = this.protocol.read({
- outputFormat: this.outputFormat,
- sortBy: this.sortBy,
- filter: a,
- callback: b
- })
- },
- queryTotalNumber: function(a, b, c) {
- var d = new GeoGlobe.Format.WFSHits;
- this.protocol = new GeoGlobe.Protocol.WFS({
- readFormat: d,
- propertyNames: this.propertyNames,
- resultType: "hits",
- maxFeatures: this.maxFeatures,
- featurePrefix: this.featurePrefix,
- featureNS: this.featureNS,
- url: this.url,
- version: this.version,
- geometryName: this.geometryName,
- featureType: this.featureType,
- time: this.time,
- userecent: this.userecent
- });
- var a = a || this.filter,
- e = b || this.successFn,
- f = c || this.failFn,
- b = GeoGlobe.Function.bind(function(a) {
- a.success() ?
- e(a.features) : f()
- }, this);
- this.response = this.protocol.read({
- outputFormat: this.outputFormat,
- filter: a,
- callback: b
- })
- },
- _read_trueName: function(a) {
- if (this.outputFormat !== "GML") return null;
- var b = [];
- if (a.priv && a.priv.responseText) {
- if (null == this.format) return null;
- a = this.format.getXMLDoc().getElementsByTagName("trueName");
- if (a == null || a.length == 0) return null;
- for (var c = 0; c < a.length; c++) b.push(a[c].text)
- }
- return b
- },
- getBufferRegion: function(a, b, c) {
- var d = this._getFeaturesCenter(a);
- switch (c) {
- case "km":
- b *= 1E3;
- case "m":
- b =
- this._meterToDegree(b, d)
- }
- return GeoGlobe.Geometry.Polygon.createRegularPolygon(a.geometry, b, 40, 360)
- },
- _getFeaturesCenter: function(a) {
- return this._getFeaturesExtent(a).getCenterLonLat()
- },
- _getFeaturesExtent: function(a) {
- GeoGlobe.Util.isArray(a) || (a = [a]);
- var b = null;
- if (a && a.length > 0)
- for (var b = new GeoGlobe.LngLatBounds, c = null, d = 0, e = a.length; d < e; d++)(c = a[d].geometry) && b.extend(c.getBounds());
- return b
- },
- _meterToDegree: function(a, b) {
- return a * (8.99E-6 / Math.cos(GeoGlobe.Util.rad(b.lat)))
- },
- pointQuery: function(a,
- b, c, d, e) {
- this.query(new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.DWITHIN,
- property: this.geometryName,
- distance: b || 0,
- distanceUnits: c || "degree",
- value: a
- }), d, e)
- },
- pathQuery: function(a, b, c, d, e) {
- this.query(new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.DWITHIN,
- property: this.geometryName,
- distance: b || 0,
- distanceUnits: c || "degree",
- value: a
- }), d, e)
- },
- polygonQuery: function(a, b, c, d) {
- this.query(new GeoGlobe.Filter.Spatial({
- type: b ? GeoGlobe.Filter.Spatial.CONTAINS : GeoGlobe.Filter.Spatial.INTERSECTS,
- property: this.geometryName,
- value: a
- }), c, d)
- },
- bboxQuery: function(a, b, c) {
- this.query(new GeoGlobe.Filter.Spatial({
- type: GeoGlobe.Filter.Spatial.BBOX,
- property: this.geometryName,
- value: a
- }), b, c)
- },
- attributeQuery: function(a, b, c, d, e, f) {
- this.query(new GeoGlobe.Filter.Comparison({
- type: a,
- property: b,
- value: c,
- matchCase: d && d.matchCase,
- lowerBoundary: d ? d.lowerBoundary : null,
- upperBoundary: d ? d.upperBoundary : null
- }), e, f)
- },
- statisticsQuery: function(a, b, c) {
- this.protocol = new GeoGlobe.Protocol.WFS({
- readFormat: this.format,
- formatOptions: this.formatOptions,
- propertyNames: this.propertyNames,
- resultType: "statistics",
- maxFeatures: this.maxFeatures,
- featurePrefix: this.featurePrefix,
- featureNS: this.featureNS,
- url: this.url,
- version: this.version,
- geometryName: this.geometryName,
- featureType: this.featureType,
- time: this.time,
- userecent: this.userecent
- });
- var a = a || this.filter,
- d = b || this.successFn,
- e = c || this.failFn,
- b = GeoGlobe.Function.bind(function(a) {
- if (a.success()) {
- try {
- var b = this._analysis_StatisticsResult(a.priv.responseXML)
- } catch (c) {
- d(a.priv.responseText);
- return
- }
- d(b)
- } else e()
- },
- this);
- this.response = this.protocol.read({
- sortBy: this.sortBy,
- groupBy: this.groupBy,
- filter: a,
- callback: b
- })
- },
- _analysis_StatisticsResult: function(a) {
- var b = {},
- a = a.documentElement.firstChild.childNodes;
- if (0 < a.length) b.layers = this._analysis_StatisticsResult_results(a);
- return b
- },
- _analysis_StatisticsResult_results: function(a) {
- for (var b = [], c = 0; c < a.length; c++) {
- for (var d = {}, e = [], f = a[c].childNodes, g = 0; g < f.length; g++) {
- var h = {};
- h.layerName = f[g].parentNode.nodeName;
- h.result = navigator.appName == "Microsoft Internet Explorer" ?
- this._analysis_StatisticsResult_results_result_IE(f[g]) : this._analysis_StatisticsResult_results_result_google(f[g]);
- e.push(h)
- }
- d.results = e;
- b.push(d)
- }
- return b
- },
- _analysis_StatisticsResult_results_result_IE: function(a) {
- var b = {},
- c = 0;
- if ("Key" == a.childNodes[0].nodeName) b.Key = a.childNodes[0].text, c = 1;
- for (var d = [], e = []; c < a.childNodes.length; c++) {
- var f = {},
- g = {};
- f.name = a.childNodes[c].getAttribute("name");
- g.Value = a.childNodes[c].text;
- d.push(f);
- e.push(g)
- }
- b.name = d;
- b.values = e;
- return b
- },
- _analysis_StatisticsResult_results_result_google: function(a) {
- var b = {},
- c = 0;
- if ("Key" == a.childNodes[0].nodeName) b.Key = a.childNodes[0].innerHTML, c = 1;
- for (var d = [], e = []; c < a.childNodes.length; c++) {
- var f = {},
- g = {};
- f.name = a.childNodes[c].getAttribute("name");
- g.Value = a.childNodes[c].innerHTML;
- d.push(f);
- e.push(g)
- }
- b.name = d;
- b.values = e;
- return b
- },
- successFn: function() {},
- failFn: function() {
- alert("\u5bf9\u4e0d\u8d77,\u67e5\u8be2\u5931\u8d25,\u8bf7\u67e5\u8be2\u670d\u52a1\u662f\u5426\u6b63\u5e38\u3002")
- },
- _separateFeatures: function(a) {
- for (var b = {}, c = 0; c < a.length; c++) {
- var d = a[c],
- e;
- e = d.gml ?
- d.gml.featureType : d.type;
- b[e] || (b[e] = []);
- b[e].push(d)
- }
- return b
- },
- setTime: function(a) {
- this.time = a
- },
- setUserecent: function(a) {
- this.userecent = a
- },
- CLASS_NAME: "GeoGlobe.Query.WFSQuery"
- });
- GeoGlobe.Query.WFSQuery.reverseGeometryXY = function(a) {
- var b = {
- Point: function(a) {
- var b = a.x,
- e = a.y,
- a = a.clone(a);
- a.x = e;
- a.y = b;
- return a
- },
- LineString: function(a, b) {
- for (var e = a.clone(a), f = 0; f < e.components.length; f++) {
- var g = b.Point(e.components[f]);
- e.components[f] = g
- }
- return e
- },
- Polygon: function(a, b) {
- for (var e = a.clone(a), f = 0; f < e.components.length; f++)
- for (var g = 0; g < e.components[f].components.length - 1; g++) {
- var h = b.Point(e.components[f].components[g]);
- e.components[f].components[g] = h
- }
- return e
- }
- };
- return b[{
- "GeoGlobe.Geometry.Point": "Point",
- "GeoGlobe.Geometry.MultiPoint": "MultiPoint",
- "GeoGlobe.Geometry.LineString": "LineString",
- "GeoGlobe.Geometry.MultiLineString": "MultiLineString",
- "GeoGlobe.Geometry.Polygon": "Polygon",
- "GeoGlobe.Geometry.MultiPolygon": "MultiPolygon",
- "GeoGlobe.Geometry.Collection": "GeometryCollection"
- }[a.CLASS_NAME]](a, b)
- };
- GeoGlobe.Format.WFSHits = GeoGlobe.Class4OL(GeoGlobe.Format.XML, {
- wfsns: "http://www.opengis.net/wfs",
- featureCollection: "FeatureCollection",
- read: function(a) {
- typeof a == "string" && (a = GeoGlobe.Format.XML.prototype.read.apply(this, [a]));
- return {
- numberOfFeatures: parseInt(a.documentElement.getAttribute("numberOfFeatures"))
- }
- }
- });
- GeoGlobe.Query.GeoCodingQuery = function(a, b) {
- var b = GeoGlobe.Util.applyDefaults(b, GeoGlobe.Query.GeoCodingQuery.DEFAULTS),
- c = GeoGlobe.Query.GeoCodingQuery["v" + b.version.replace(/\./g, "_")];
- if (!c) throw "\u4e0d\u652f\u6301\u7684\u5730\u5740\u5339\u914d\u670d\u52a1\u7248\u672c: " + b.version;
- return new c(a, b)
- };
- GeoGlobe.Query.GeoCodingQuery.DEFAULTS = {
- version: "1.0.0"
- };
- GeoGlobe.Query.GeoCodingQuery.v1 = GeoGlobe.Class4OL({
- version: "1.0.0",
- url: null,
- initialize: function(a, b) {
- this.url = a;
- GeoGlobe.Util.extend(this, b);
- this.format = new GeoGlobe.Format.JSON
- },
- getCommonParams: function(a) {
- var b = {
- request: "GetCategory",
- service: "GeoCoding",
- version: this.version,
- output: "json"
- };
- GeoGlobe.Util.extend(b, a);
- return b
- },
- getCategoryByName: function(a, b, c) {
- var d = this.getCommonParams();
- if (typeof a === "string" && a.length !== 0) d.categoryName = a;
- c = c || this.failFn;
- GeoGlobe.Function.bind(this._requestCategory,
- this)(d, b, c)
- },
- getCategoryByCode: function(a, b, c) {
- var d = this.getCommonParams();
- if (typeof a === "number") d.categoryCode = a;
- GeoGlobe.Function.bind(this._requestCategory, this)(d, b, c)
- },
- getAllCategory: function(a, b) {
- var c = this.getCommonParams();
- GeoGlobe.Function.bind(this._requestCategory, this)(c, a, b)
- },
- _requestCategory: function(a, b, c) {
- c = c || this.failFn;
- GeoGlobe.loadURL(this.url, a, this, function(a) {
- try {
- var c = this.format.read(a.responseText)
- } catch (f) {
- b(a.responseText);
- return
- }
- b(c)
- }, c)
- },
- _analysis_GeoCodeResult: function(a) {
- var b = {
- status: a.status
- };
- switch (a.status) {
- case "OK":
- if (a = a.results) b.results = this._analysis_GeoCodeResult_results(a);
- break;
- case "INVALID_REQUEST":
- break;
- case "NO_RESULTS":
- break;
- case "UNKNOWN_ERROR":
- break;
- default:
- if (b = {
- requestKeyWord: a.requestKeyWord,
- count: a.count,
- statisticsLevel: a.statisticsLevel,
- statisticsLevelName: a.statisticsLevelName
- }, a && a.count > 0 && (a = a.results)) b.results = this._analysis_GeoCodeResult_statistics(a)
- }
- return b
- },
- _analysis_GeoCodeResult_results: function(a) {
- var b = [];
- if (GeoGlobe.Util.isArray(a)) {
- for (var c =
- 0, d = a.length; c < d; c++) {
- var e = {};
- e.requestKeyWord = a[c].requestKeyWord;
- if (a[c].errorCorrectionTips) e.errorCorrectionTips = a[c].errorCorrectionTips;
- e.count = a[c].count;
- if (a[c].result) e.result = this._analysis_GeoCodeResult_results_result(a[c].result);
- b.push(e)
- }
- return b
- }
- },
- _analysis_GeoCodeResult_statistics: function(a) {
- var b = [];
- if (GeoGlobe.Util.isArray(a)) {
- for (var c = 0, d = a.length; c < d; c++) {
- var e = {};
- if (a[c].errorCorrectionTips) e.errorCorrectionTips = a[c].errorCorrectionTips;
- if (a[c]) e.name = a[c].name, e.value = a[c].value,
- e.remark = a[c].remark;
- b.push(e)
- }
- return b
- }
- },
- _analysis_GeoCodeResult_results_result: function(a) {
- for (var b = [], c = 0, d = a.length; c < d; c++) {
- var e = {},
- f = {};
- e.resultType = a[c].resultType;
- e.precise = a[c].precise;
- e.isBrief = a[c].isBrief;
- e.score = a[c].score;
- if (a[c].addressComponent.street) f = a[c].addressComponent.street;
- if (e.isBrief == !1) e.addressComponent = this._analysis_GeoCodeResult_results_result_address(a[c].addressComponent, e.resultType);
- e.poiArray = this._analysispoiArray(a[c].poiArray);
- if (a[c].location) e.location =
- a[c].location;
- if (e.precise == 0) e.referenceAddressArray = a[c].referenceAddressArray;
- if (f) e.street_path = f;
- b.push(e)
- }
- return b
- },
- _analysis_GeoCodeResult_results_result_address: function(a, b) {
- var c = {
- country: a.country
- };
- if (a.province) c.province = a.province;
- if (a.city) c.city = a.city;
- if (a.district) c.district = a.district;
- if (a.town) c.town = a.town;
- if (a.street && (c.street = {
- name: a.street.name
- }, b === "street" && a.street.geometry)) {
- var d = this.format.read(a.street.geometry),
- e = null;
- if (d.paths) e = this._getGeometry(d), c.street.geometry =
- e;
- else if (d.rings) e = this._getGeometry(d), c.street.geometry = e;
- else if (d.x && d.y) e = this._getGeometry(d), c.street.geometry = e
- }
- if (a.streetNumber) c.streetNumber = a.streetNumber;
- if (a.buildingNumber) c.buildingNumber = a.buildingNumber;
- if (b === "adminArea") {
- if (a.geometry)
- if (d = this.format.read(a.geometry), e = null, d.rings) e = this._getGeometry(d), c.geometry = e;
- else if (d.paths) e = this._getGeometry(d), c.geometry = e;
- else if (typeof d.x === "number" && typeof d.y === "number") c.geometry = this._getGeometry(d);
- if (a.subordinate) c.subordinate =
- a.subordinate;
- if (a.zipCode) c.zipCode = a.zipCode;
- if (a.callingCode) c.callingCode = a.callingCode
- }
- return c
- },
- _analysispoiArray: function(a) {
- for (var b = [], c = 0, d = a.length; c < d; c++) {
- var e = {},
- f;
- for (f in a[c]) e[f] = a[c][f];
- if ("" != e.geometry && void 0 != e.geometry) {
- var g = this.format.read(e.geometry);
- e.geometry = this._getGeometry(g)
- }
- b.push(e)
- }
- return b
- },
- _analysisLocation: function() {},
- _getGeometry: function(a) {
- for (var b in a) {
- if ("spatialReference" == b) break;
- return a = a.hasOwnProperty("x") && a.hasOwnProperty("y") ? new GeoGlobe.Geometry.Point(a.x,
- a.y) : a.hasOwnProperty("xmin") && a.hasOwnProperty("ymin") && a.hasOwnProperty("xmax") && a.hasOwnProperty("ymax") ? (new GeoGlobe.LngLatBounds(a.xmin, a.ymin, a.xmax, a.ymax)).toGeometry() : this._geometryType[b](a[b])
- }
- },
- _geometryType: {
- points: function(a) {
- var b = [];
- if (GeoGlobe.Util.isArray(a))
- for (var c = 0, d = a.length; c < d; c++) {
- var e = new GeoGlobe.Geometry.Point(a[c][0], a[c][1]);
- b.push(e)
- }
- return b
- },
- paths: function(a) {
- var b = [];
- if (GeoGlobe.Util.isArray(a)) {
- for (var c = 0, d = a.length; c < d; c++) {
- for (var e = [], f = 0, g = a[c].length; f <
- g; f++) e.push(new GeoGlobe.Geometry.Point(a[c][f][0], a[c][f][1]));
- e = new GeoGlobe.Geometry.LineString(e);
- b.push(e)
- }
- c = new GeoGlobe.Geometry.MultiLineString(b)
- }
- return c
- },
- rings: function(a) {
- var b = [];
- if (GeoGlobe.Util.isArray(a)) {
- for (var c = 0, d = a.length; c < d; c++) {
- for (var e = [], f = 0, g = a[c].length; f < g; f++) e.push(new GeoGlobe.Geometry.Point(a[c][f][0], a[c][f][1]));
- e = new GeoGlobe.Geometry.LinearRing(e);
- b.push(e)
- }
- c = new GeoGlobe.Geometry.Polygon(b)
- }
- return c
- }
- },
- failFn: function(a) {
- typeof a == "string" && alert(a);
- alert("\u5bf9\u4e0d\u8d77\uff0c\u67e5\u8be2\u8bf7\u6c42\u5931\u8d25\uff01\u8bf7\u68c0\u67e5\u5730\u5740\u5339\u914d\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002\n\u5f53\u524d\u670d\u52a1\u5730\u5740\u4e3a\uff1a" +
- this.url)
- },
- CLASS_NAME: "GeoGlobe.Query.GeoCodingQuery.v1"
- });
- GeoGlobe.Query.GeoCodingQuery.v1_0_0 = GeoGlobe.Class4OL(GeoGlobe.Query.GeoCodingQuery.v1, {
- addressesToLocations: function(a, b) {
- var c = this.getCommonParams({
- request: "GeoCoder"
- });
- if (typeof a.address === "string") c.address = a.address;
- else if (GeoGlobe.Util.isArray(a.address)) {
- for (var d = "", e = 0; e < a.address.length; e++) d += a.address[e] + ",";
- d = d.substr(0, d.length - 1);
- c.address = d
- } else if (a.address == void 0 || a.address == null) throw "address\u662f\u5fc5\u9009\u53c2\u6570\uff01";
- if (typeof a.categoryCode === "number") c.categoryCode =
- a.categoryCode;
- if (a.extent instanceof mapboxgl.LngLatBounds) c.bbox = a.extent.toBBOX(null, !0);
- else if (a.extent instanceof GeoGlobe.Geometry.Polygon) {
- for (var d = a.extent, f = [], e = 0, g = d.components.length; e < g; e++)
- for (var h = d.components[e].components, j = 0; j < h.length; j++) f.push(h[j].toShortString());
- c.bbox = f.join(",")
- }
- if (typeof a.fuzzyMatch === "boolean") c.fuzzyMatch = a.fuzzyMatch;
- if (typeof a.resultType === "string") c.resultType = a.resultType;
- if (typeof a.maxCount === "number") c.maxCount = a.maxCount;
- if (typeof a.startPosition ===
- "number") c.startPosition = a.startPosition;
- GeoGlobe.loadURL(this.url, c, this, function(a) {
- try {
- var d = this.format.read(a.responseText),
- e = c.resultType == "result" ? this._parseQueryResultToFeature(d) : this._analysis_GeoCodeResult(d)
- } catch (f) {
- b(a.responseText);
- return
- }
- b(e)
- }, this.failFn)
- },
- locationToAddresses: function(a, b) {
- var c = this.getCommonParams({
- request: "GeoCoder"
- });
- if (a.lonlat) c.latlng = a.lonlat.lat + "," + a.lonlat.lng;
- else throw "address\u662f\u5fc5\u9009\u53c2\u6570\uff01\u8bf7\u586b\u5199\u6b63\u786e\u7684\u6570\u636e\u7c7b\u578b\uff01";
- if (typeof a.tolerance === "number") c.tolerance = a.tolerance;
- if (typeof a.unit === "string") c.unit = a.unit;
- if (typeof a.resultType === "string") c.resultType = a.resultType;
- if (typeof a.maxCount === "number") c.maxCount = a.maxCount;
- if (typeof a.startPosition === "number") c.startPosition = a.startPosition;
- GeoGlobe.loadURL(this.url, c, this, function(a) {
- try {
- var e = this.format.read(a.responseText),
- f = c.resultType == "result" ? this._parseQueryResultToFeature(e) : this._analysis_GeoCodeResult(e)
- } catch (g) {
- b(a.responseText);
- return
- }
- b(f, e)
- },
- this.failFn)
- },
- getLocations: function(a, b, c) {
- this.addressesToLocations(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, total))
- }, this), c)
- },
- getLocationsByPage: function(a, b, c) {
- a.resultType = "hits";
- this.addressesToLocations(a, GeoGlobe.Function.bind(function(d) {
- if (d.status == "OK") {
- a.resultType = "result";
- var e = d.results[0].count;
- if (a.maxCount == void 0 || a.maxCount == null) a.maxCount = 3;
- a.startPosition = (a.startPosition - 1) * a.maxCount + 1;
- this.addressesToLocations(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a,
- e))
- }, this), c)
- } else alert("\u6ca1\u6709\u67e5\u8be2\u5230\u4efb\u4f55\u6570\u636e")
- }, this), c)
- },
- getAddresses: function(a, b, c) {
- this.locationToAddresses(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, total))
- }, this), c)
- },
- getAddressesByPage: function(a, b, c) {
- a.resultType = "hits";
- this.locationToAddresses(a, GeoGlobe.Function.bind(function(d) {
- if (d.status == "OK") {
- a.resultType = "result";
- var e = d.results[0].count;
- if (a.maxCount == void 0 || a.maxCount == null) a.maxCount = 3;
- a.startPosition = (a.startPosition -
- 1) * a.maxCount + 1;
- this.locationToAddresses(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, e))
- }, this), c)
- } else alert("\u6ca1\u6709\u67e5\u8be2\u5230\u4efb\u4f55\u6570\u636e")
- }, this), c)
- },
- _parseQueryResultToFeature: function(a) {
- var b = [];
- if (a.status == "OK" && a.results)
- for (var c = 0; c < a.results.length; c++) {
- var d = a.results[c].result;
- if (d)
- for (var e = 0; e < d.length; e++) {
- var f = {},
- g = null;
- f.requestKeyWord = a.results[c].requestKeyWord;
- if (GeoGlobe.Util.isArray(d[e].poiArray))
- for (var h = 0; h < d[e].poiArray.length; h++) f.CONTINENT =
- d[e].poiArray[h].CONTINENT, f.GBCODE = d[e].poiArray[h].GBCODE, f.STANDARDNAME = d[e].poiArray[h].STANDARDNAME, f.name = d[e].poiArray[h].name;
- if (d[e].addressComponent) f.address = this._getAddress(d[e].addressComponent, f.name), f.country = d[e].addressComponent.country, f.province = d[e].addressComponent.province, f.city = d[e].addressComponent.city, f.district = d[e].addressComponent.district, d[e].addressComponent.street ? (f.streetName = d[e].addressComponent.street.name, f.streetgeometry = d[e].addressComponent.street.geometry) :
- f.streetName = "", f.streetNumber = d[e].addressComponent.streetNumber;
- if (d[e].location) {
- if (d[e].location.lng) f.lng = d[e].location.lng;
- if (d[e].location.lat) f.lat = d[e].location.lat;
- g = new GeoGlobe.Geometry.Point(d[e].location.lng, d[e].location.lat)
- }
- f.isBrief = d[e].isBrief;
- f.precise = d[e].precise;
- f.resultType = d[e].resultType;
- f.score = d[e].score;
- f = new GeoGlobe.Feature(g, f);
- b.push(f)
- }
- }
- c = (new GeoGlobe.Format.GeoJSON).write(b);
- c = (new GeoGlobe.Format.JSON).read(c);
- return {
- status: a.status,
- features: b,
- geojsonFeatures: c
- }
- },
- _getAddress: function(a, b) {
- var c = "";
- a.country && (c += a.country);
- a.province && (c += a.province);
- a.city && (c += a.city);
- a.district && (c += a.district);
- a.street && (a.street.name && (c += a.street.name), a.streetNumber && (c += a.streetNumber + "\u53f7"));
- b && (c += b);
- return c
- },
- CLASS_NAME: "GeoGlobe.Query.GeoCodingQuery.v1_0_0"
- });
- GeoGlobe.Query.GeoCodingQuery.v1_1_0 = GeoGlobe.Class4OL(GeoGlobe.Query.GeoCodingQuery.v1, {
- method: "get",
- initialize: function(a, b) {
- GeoGlobe.Util.extend(this, b);
- this.filterFormat = new GeoGlobe.Format.Filter;
- GeoGlobe.Query.GeoCodingQuery.v1.prototype.initialize.apply(this, arguments)
- },
- addressesToLocations: function(a, b, c) {
- var d = this.getCommonParams({
- request: "GeoCoder"
- });
- d.reverseMatch = !1;
- if (typeof a.address === "string") d.keyword = a.address;
- if (typeof a.categoryCode === "number") d.categoryCode = a.categoryCode;
- if ((a.address ==
- void 0 || a.address == null) && (a.categoryCode == void 0 || a.categoryCode == null)) throw "address\u662f\u5fc5\u9009\u53c2\u6570\uff01";
- if (a.extent instanceof mapboxgl.LngLatBounds) d.bbox = a.extent.toBBOX(null, !0);
- else if (a.extent instanceof GeoGlobe.Geometry.Polygon) {
- for (var e = a.extent, f = [], g = 0, h = e.components.length; g < h; g++)
- for (var j = e.components[g].components, l = 0; l < j.length; l++) f.push(j[l].toShortString());
- d.bbox = f.join(",")
- }
- if (a.filter instanceof GeoGlobe.Filter) e = this.filterFormat.write(a.filter), e = GeoGlobe.Format.XML.prototype.write.apply(this.filterFormat, [e]), d.filter = e;
- if (typeof a.resultType === "string") d.resultType = a.resultType;
- if (a.resultType == "statistics") d.statisticsLevel = a.statisticsLevel;
- if (typeof a.maxCount === "number") d.maxCount = a.maxCount;
- if (typeof a.startPosition === "number") d.startPosition = a.startPosition;
- if (typeof a.semanticAnalysis === "boolean") d.semanticAnalysis = a.semanticAnalysis;
- if (typeof a.customWeight === "boolean") d.customWeight = a.customWeight;
- this._setGeoCoderCommonProperty(d, a);
- this._getCodingRequest(d, b, c)
- },
- _getCodingRequest: function(a,
- b) {
- if (this.method == "get") GeoGlobe.loadURL(this.url, a, this, function(c) {
- try {
- var e = this.format.read(c.responseText),
- f = a.resultType == "result" ? this._parseQueryResultToFeature(e) : this._analysis_GeoCodeResult(e)
- } catch (g) {
- b(c.responseText);
- return
- }
- b(f)
- }, this.failFn);
- else {
- var c = GeoGlobe.Util.getParameterString(a, !0);
- GeoGlobe.Request.POST({
- url: this.url,
- data: c,
- success: function(a) {
- try {
- var c = this._analysis_GeoCodeResult(this.format.read(a.responseText))
- } catch (f) {
- b(a.responseText);
- return
- }
- b(c)
- },
- failure: this.failFn,
- scope: this
- })
- }
- },
- _setGeoCoderCommonProperty: function(a, b) {
- if (typeof b.sortFields === "string") a.sortFields = b.sortFields;
- if (typeof b.scoreFilter === "string") a.scoreFilter = b.scoreFilter
- },
- locationToAddresses: function(a, b, c) {
- var d = this.getCommonParams({
- request: "GeoCoder"
- });
- d.reverseMatch = !0;
- if (a.lonlat) d.keyword = a.lonlat.lat + "," + a.lonlat.lng;
- else throw "address\u662f\u5fc5\u9009\u53c2\u6570\uff01\u8bf7\u586b\u5199\u6b63\u786e\u7684\u6570\u636e\u7c7b\u578b\uff01";
- if (typeof a.tolerance === "number") d.tolerance =
- a.tolerance;
- if (typeof a.unit === "string") d.unit = a.unit;
- if (typeof a.resultType === "string") d.resultType = a.resultType;
- if (a.resultType == "statistics") d.statisticsLevel = a.statisticsLevel;
- if (typeof a.maxCount === "number") d.maxCount = a.maxCount;
- if (typeof a.startPosition === "number") d.startPosition = a.startPosition;
- if (typeof a.customWeight === "boolean") d.customWeight = a.customWeight;
- this._setGeoCoderCommonProperty(d, a);
- this._getCodingRequest(d, b, c)
- },
- batchAddressesToLocations: function(a, b, c) {
- var d = this.getCommonParams({
- request: "BatchGeoCoder",
- service: "GeoCoding"
- });
- d.reverseMatch = !1;
- if (GeoGlobe.Util.isArray(a.address)) {
- for (var e = "", f = 0; f < a.address.length; f++) e += a.address[f] + ",";
- e = e.substr(0, e.length - 1);
- d.keywords = e
- } else if (a.address == void 0 || a.address == null) throw "address\u662f\u5fc5\u9009\u53c2\u6570\uff01";
- if (typeof a.singleKeywordResultCount === "number") d.singleKeywordResultCount = a.singleKeywordResultCount;
- if (a.filter instanceof GeoGlobe.Filter) e = this.filterFormat.write(a.filter), e = GeoGlobe.Format.XML.prototype.write.apply(this.filterFormat, [e]), d.filter = e;
- this._setGeoCoderCommonProperty(d, a);
- this._getCodingRequest(d, b, c)
- },
- batchLocationToAddresses: function(a, b, c) {
- var d = this.getCommonParams({
- request: "BatchGeoCoder",
- service: "GeoCoding"
- });
- d.reverseMatch = !0;
- if (a.lonlats instanceof GeoGlobe.LonLat) a.lonlats = [a.lonlats];
- else if (!GeoGlobe.Util.isArray(a.lonlats)) throw "address\u662f\u5fc5\u9009\u53c2\u6570\uff01\u8bf7\u586b\u5199\u6b63\u786e\u7684\u6570\u636e\u7c7b\u578b\uff01";
- if (GeoGlobe.Util.isArray(a.lonlats)) {
- for (var e = "", f = 0; f < a.lonlats.length; f++) e +=
- a.lonlats[f].lat + "," + a.lonlats[f].lng + ";";
- e = e.substr(0, e.length - 1);
- d.keywords = e
- }
- if (typeof a.tolerance === "number") d.tolerance = a.tolerance;
- if (typeof a.unit === "string") d.unit = a.unit;
- if (typeof a.singleKeywordResultCount === "number") d.singleKeywordResultCount = a.singleKeywordResultCount;
- this._setGeoCoderCommonProperty(d, a);
- this._getCodingRequest(d, b, c)
- },
- _getAddress: function(a, b) {
- var c = "";
- a.country && (c += a.country);
- a.province && (c += a.province);
- a.city && (c += a.city);
- a.district && (c += a.district);
- a.street && (a.street.name &&
- (c += a.street.name), a.streetNumber && (c += a.streetNumber + "\u53f7"));
- b && (c += b);
- return c
- },
- getLocations: function(a, b, c) {
- this.addressesToLocations(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, total))
- }, this), c)
- },
- getLocationsByPage: function(a, b, c) {
- a.resultType = "hits";
- this.addressesToLocations(a, GeoGlobe.Function.bind(function(d) {
- if (d.status == "OK") {
- a.resultType = "result";
- var e = d.results[0].count;
- if (a.maxCount == void 0 || a.maxCount == null) a.maxCount = 3;
- a.startPosition = (a.startPosition -
- 1) * a.maxCount + 1;
- this.addressesToLocations(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, e))
- }, this), c)
- } else alert("\u6ca1\u6709\u67e5\u8be2\u5230\u4efb\u4f55\u6570\u636e")
- }, this), c)
- },
- getAddresses: function(a, b, c) {
- this.locationToAddresses(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, total))
- }, this), c)
- },
- getAddressesByPage: function(a, b, c) {
- a.resultType = "hits";
- this.locationToAddresses(a, GeoGlobe.Function.bind(function(d) {
- if (d.status == "OK") {
- a.resultType =
- "result";
- var e = d.results[0].count;
- if (a.maxCount == void 0 || a.maxCount == null) a.maxCount = 3;
- a.startPosition = (a.startPosition - 1) * a.maxCount + 1;
- this.locationToAddresses(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a, e))
- }, this), c)
- } else alert("\u6ca1\u6709\u67e5\u8be2\u5230\u4efb\u4f55\u6570\u636e")
- }, this), c)
- },
- batchGetAddresses: function(a, b, c) {
- this.batchLocationToAddresses(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a))
- }, this), c)
- },
- batchGetLocations: function(a,
- b, c) {
- this.batchAddressesToLocations(a, GeoGlobe.Function.bind(function(a) {
- b(this._parseQueryResultToFeature(a))
- }, this), c)
- },
- _parseQueryResultToFeature: function(a) {
- var b = [];
- if (a.status == "OK" && a.results)
- for (var c = 0; c < a.results.length; c++) {
- var d = a.results[c].result;
- if (d)
- for (var e = 0; e < d.length; e++) {
- var f = {},
- g = null;
- f.requestKeyWord = a.results[c].requestKeyWord;
- if (GeoGlobe.Util.isArray(d[e].poiArray))
- for (var h = 0; h < d[e].poiArray.length; h++) f.CONTINENT = d[e].poiArray[h].CONTINENT, f.GBCODE = d[e].poiArray[h].GBCODE,
- f.STANDARDNAME = d[e].poiArray[h].STANDARDNAME, f.name = d[e].poiArray[h].name;
- if (d[e].addressComponent) f.address = this._getAddress(d[e].addressComponent, f.name), f.country = d[e].addressComponent.country, f.province = d[e].addressComponent.province, f.city = d[e].addressComponent.city, f.district = d[e].addressComponent.district, d[e].addressComponent.street ? (f.streetName = d[e].addressComponent.street.name, f.streetgeometry = d[e].addressComponent.street.geometry) : f.streetName = "", f.streetNumber = d[e].addressComponent.streetNumber;
- if (d[e].location) {
- if (d[e].location.lng) f.lng = d[e].location.lng;
- if (d[e].location.lat) f.lat = d[e].location.lat;
- g = new GeoGlobe.Geometry.Point(d[e].location.lng, d[e].location.lat)
- }
- f.isBrief = d[e].isBrief;
- f.precise = d[e].precise;
- f.resultType = d[e].resultType;
- f.score = d[e].score;
- f = new GeoGlobe.Feature(g, f);
- b.push(f)
- }
- }
- c = (new GeoGlobe.Format.GeoJSON).write(b);
- c = (new GeoGlobe.Format.JSON).read(c);
- return {
- status: a.status,
- features: b,
- geojsonFeatures: c
- }
- },
- CLASS_NAME: "GeoGlobe.Query.GeoCodingQuery.v1_1_0"
- });
- GeoGlobe.Query.DQSQuery = GeoGlobe.Class4OL({
- url: null,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- getCapabilities: function(a, b, c) {
- GeoGlobe.loadURL(this.url, {
- SERVICE: "DataQueryService",
- VERSION: "1.0.0",
- REQUEST: "GetCapabilities"
- }, this, function(a) {
- b && (a = JSON.parse(a.responseText), b(a))
- }, function(a) {
- c && c(a)
- })
- },
- getDataSetList: function(a, b, c) {
- var d = this.url,
- e = {
- SERVICE: "DataQueryService",
- VERSION: "1.0.0",
- REQUEST: "GetDataSetList"
- };
- if (a && a.startPosition) e.STARTPOSITION = a.startPosition;
- if (a && a.maxCount) e.MAXCOUNT =
- a.maxCount;
- GeoGlobe.loadURL(d, e, this, function(a) {
- a = JSON.parse(a.responseText);
- b && b(a)
- }, function(a) {
- c && c(a)
- })
- },
- describeDataSet: function(a, b, c) {
- GeoGlobe.loadURL(this.url, {
- SERVICE: "DataQueryService",
- VERSION: "1.0.0",
- REQUEST: "DescribeDataSet",
- DATASETID: a.dataSetId
- }, this, function(a) {
- a = JSON.parse(a.responseText);
- b && b(a)
- }, function(a) {
- c && c(a)
- })
- },
- query: function(a, b, c) {
- var d = this.url,
- e = {
- SERVICE: "DataQueryService",
- VERSION: "1.0.0",
- REQUEST: "Query",
- DATASETID: a.dataSetId
- };
- if (a && a.startPosition) e.STARTPOSITION = a.startPosition;
- if (a && a.maxCount) e.MAXCOUNT = a.maxCount;
- if (a && a.rowFilter) e.ROWFILTER = this._makeSQLFilter(a.rowFilter);
- if (a && a.colFilter) e.COLFILTER = a.colFilter;
- a && e && GeoGlobe.loadURL(d, e, this, function(a) {
- a = JSON.parse(a.responseText);
- b && b(a)
- }, function(a) {
- c && c(a)
- })
- },
- _makeSQLFilter: function(a, b) {
- if (a && a.length) {
- var c = "",
- b = b || " AND ";
- a.forEach(function(a) {
- a.type && a.type.indexOf(" ") > -1 && (c = c.substr(0, c.length - b.length));
- c += [a.name, " ", a.type || "=", " '", a.value, "'", b].join("")
- });
- return c.substr(0, c.length - b.length).trim()
- } else return ""
- },
- CLASS_NAME: "GeoGlobe.Query.DQSQuery"
- });
- GeoGlobe.Query.TDTCodingQuery = GeoGlobe.Class4OL({
- url: "https://api.tianditu.gov.cn/search",
- token: "e90d56e5a09d1767899ad45846b0cefd",
- queryType: 1,
- start: 0,
- count: 10,
- initialize: function(a) {
- this.token = a || this.token
- },
- query: function(a, b, c) {
- if (!a || !a.keyWord) throw Error("\u67e5\u8be2\u53c2\u6570\u9519\u8bef -- keyWord\u5fc5\u4f20");
- if (!a.mapBound) {
- var d = map.getBounds();
- a.mapBound = d._ne.lng + "," + d._ne.lat + "," + d._sw.lng + "," + d._sw.lat
- }
- if (!a.level) a.level = Math.round(map.getZoom());
- if (!a.queryType) a.queryType = this.queryType;
- if (!a.start) a.start = this.start;
- if (!a.count) a.count = this.count;
- a = {
- postStr: JSON.stringify(a),
- type: "query",
- tk: this.token
- };
- GeoGlobe.Request.GET({
- url: this.url,
- params: a,
- scope: this,
- async: !1,
- noProxy: !0,
- success: function(a) {
- a = this._compositionData(JSON.parse(a.responseText));
- b(a)
- },
- failure: c
- })
- },
- _compositionData: function(a) {
- var b;
- switch (Number(a.resultType)) {
- case 1:
- b = this._compositionDataByPois(a.pois);
- break;
- case 2:
- b = this._compositionDataByStatistics(a.statistics);
- break;
- case 3:
- this._renderCity(a);
- b = a;
- break;
- case 4:
- b =
- a.suggests;
- break;
- case 5:
- b = a;
- break;
- default:
- b = []
- }
- return {
- resultType: a.resultType,
- features: b,
- count: a.count,
- possess: a
- }
- },
- _compositionDataByPois: function(a) {
- try {
- for (var b = [], c = 0; c < a.length; c++) {
- var d = a[c].lonlat.split(" "),
- e = {
- lng: d[0],
- lat: d[1]
- };
- a[c].location = e;
- var f = new GeoGlobe.Geometry.Point(e.lng, e.lat),
- g = new GeoGlobe.Feature(f, a[c]);
- b.push(g)
- }
- return b
- } catch (h) {}
- },
- _compositionDataByStatistics: function(a) {
- try {
- for (var b = {
- allAdmins: [],
- priorityCitys: []
- }, c = 0; c < a.priorityCitys.length; c++) {
- var d = {
- lng: a.priorityCitys[c].lon,
- lat: a.priorityCitys[c].lat
- };
- a.priorityCitys[c].location = d;
- var e = new GeoGlobe.Geometry.Point(d.lng, d.lat),
- f = new GeoGlobe.Feature(e, a.priorityCitys[c]);
- b.priorityCitys.push(f)
- }
- for (c = 0; c < a.allAdmins.length; c++) {
- var g = a.allAdmins[c].childAdmins;
- if (g)
- for (var h = 0; h < g.length; h++) d = {
- lng: g[h].lon,
- lat: g[h].lat
- }, g[h].location = d, e = new GeoGlobe.Geometry.Point(d.lng, d.lat), g[h] = new GeoGlobe.Feature(e, g[h]);
- d = {
- lng: a.allAdmins[c].lon,
- lat: a.allAdmins[c].lat
- };
- a.allAdmins[c].location = d;
- e = new GeoGlobe.Geometry.Point(d.lng,
- d.lat);
- f = new GeoGlobe.Feature(e, a.allAdmins[c]);
- b.allAdmins.push(f)
- }
- return b
- } catch (j) {}
- },
- _renderCity: function(a) {
- var b = GeoGlobe.LngLatBounds.fromString(a.area.bound);
- b.getCenterLonLat();
- b && map.fitBounds(b);
- if (a.area.points[0]) {
- for (var b = a.area.points[0].region.split(","), a = [], c = 0; c < b.length; c++) a.push(b[c].replace(/[ ]/g, ","));
- b = [];
- for (c = 0; c < a.length; c++) b.push([eval(a[c].split(",")[0]), eval(a[c].split(",")[1])]);
- map.addSource("polygon_xzq_query", {
- type: "geojson",
- data: {
- type: "Feature",
- geometry: {
- type: "Polygon",
- coordinates: [b]
- }
- }
- });
- map.addLayer({
- id: "polygon_xzq_query",
- type: "fill",
- source: "polygon_xzq_query",
- layout: {},
- paint: {
- "fill-color": "#022CFF",
- "fill-outline-color": "#0027EB",
- "fill-opacity": 0.2
- }
- })
- }
- },
- CLASS_NAME: "GeoGlobe.Query.TDTCodingQuery"
- });
- GeoGlobe.Query.TDTGeoCoderQuery = GeoGlobe.Class4OL({
- url: "https://api.tianditu.gov.cn/geocoder",
- token: "e90d56e5a09d1767899ad45846b0cefd",
- initialize: function(a) {
- this.token = a || this.token
- },
- dsToLonLatQuery: function(a, b, c) {
- if (!a || !a.keyWord) throw Error("\u67e5\u8be2\u53c2\u6570\u9519\u8bef -- keyWord\u5fc5\u4f20");
- a = {
- ds: JSON.stringify(a),
- tk: this.token
- };
- GeoGlobe.Request.GET({
- url: this.url,
- params: a,
- scope: this,
- async: !1,
- noProxy: !0,
- success: function(a) {
- a = JSON.parse(a.responseText);
- b(a)
- },
- failure: c
- })
- },
- lonLatToDsQuery: function(a,
- b, c) {
- if (!a || !a.lon || !a.lat) throw Error("\u67e5\u8be2\u53c2\u6570\u9519\u8bef -- lon,lat\u5fc5\u4f20");
- a.ver = 1;
- a = {
- postStr: JSON.stringify(a),
- tk: this.token,
- type: "geocode"
- };
- GeoGlobe.Request.GET({
- url: this.url,
- params: a,
- scope: this,
- async: !1,
- noProxy: !0,
- success: function(a) {
- a = JSON.parse(a.responseText);
- b(a)
- },
- failure: c
- })
- },
- CLASS_NAME: "GeoGlobe.Query.TDTGeoCoderQuery"
- });
- GeoGlobe.Query.TDTRouteQuery = GeoGlobe.Class4OL({
- initialize: function(a) {
- this.token = a || "e90d56e5a09d1767899ad45846b0cefd"
- },
- searchByDrive: function(a, b, c) {
- var d = this;
- if (!a.start) throw Error("\u8d77\u70b9\u4e3a\u7a7a");
- if (!a.end) throw Error("\u7ec8\u70b9\u4e3a\u7a7a");
- var e = {
- orig: a.start.join(","),
- dest: a.end.join(","),
- style: a.style || 0
- };
- if (a.mid) e.mid = a.mid.join(";");
- a = {
- postStr: JSON.stringify(e),
- type: "search",
- tk: this.token
- };
- GeoGlobe.loadURL("https://api.tianditu.gov.cn/drive", a, this, function(a) {
- var c = d.parseXML(a.responseText),
- c = c.result,
- e = [];
- c.mid && c.mid.split(";").forEach(function(a) {
- e.push(a.split(","))
- });
- var a = c.routelatlon.split(";"),
- j = [];
- a.pop();
- a.forEach(function(a) {
- j.push(a.split(","))
- });
- var l = [];
- Object.prototype.toString.call(c.simple) == "[object Object]" && c.simple.item.forEach(function(a) {
- var b = a.streetLatLon.split(";"),
- d = [];
- b.pop();
- b.forEach(function(a) {
- d.push(a.split(","))
- });
- var b = {
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: d
- },
- properties: a,
- items: []
- },
- e = a.segmentNumber.split("-");
- if (e.length >= 2) {
- a =
- 1 + Number(e[1]);
- for (e = e[0]; e < a; e++) b.items.push(c.routes.item[e])
- } else b.items.push(c.routes.item[e[0]]);
- l.push(b)
- });
- a = {
- startLngLat: c.orig.split(","),
- midLngLat: e,
- endLngLat: c.dest.split(","),
- distance: c.distance,
- times: c.duration,
- mapinfo: {
- center: c.mapinfo.center.split(","),
- zoom: c.mapinfo.scale
- },
- routeLngLat: j,
- geojsonRoute: {
- type: "FeatureCollection",
- features: l
- }
- };
- a = {
- originalData: c,
- processedData: a
- };
- b && b(a)
- }, function(a) {
- c && c(a)
- })
- },
- searchByBus: function(a, b, c) {
- if (!a.start) throw Error("\u8d77\u70b9\u4e3a\u7a7a");
- if (!a.end) throw Error("\u7ec8\u70b9\u4e3a\u7a7a");
- var d = {
- startposition: a.start.join(","),
- endposition: a.end.join(","),
- linetype: a.style || 1
- };
- a.mid && a.mid.join(";");
- a = {
- type: "busline",
- postStr: JSON.stringify(d),
- tk: this.token
- };
- GeoGlobe.loadURL("https://api.tianditu.gov.cn/transit", a, this, function(a) {
- if (b) {
- var a = JSON.parse(a.responseText),
- c = "";
- a.resultCode == 1 ? c = "\u627e\u4e0d\u5230\u8d77\u70b9\u3002" : a.resultCode == 2 ? c = "\u627e\u4e0d\u5230\u7ec8\u70b9\u3002" : a.resultCode == 3 ? c = "\u89c4\u5212\u7ebf\u8def\u5931\u8d25\u3002" :
- a.resultCode == 4 ? c = "\u8d77\u7ec8\u70b9\u8ddd\u79bb200\u7c73\u4ee5\u5185\uff0c\u4e0d\u89c4\u5212\u7ebf\u8def\uff0c\u5efa\u8bae\u6b65\u884c\u3002" : a.resultCode == 5 ? c = "\u8d77\u7ec8\u70b9\u8ddd\u79bb500\u7c73\u5185\uff0c\u8fd4\u56de\u7ebf\u8def\u3002" : a.resultCode == 6 && (c = "\u8f93\u5165\u53c2\u6570\u9519\u8bef\u3002");
- c = {
- resultCode: a.resultCode,
- errorMsg: c,
- data: []
- };
- if (a.resultCode == 0 && a.results.length) {
- var d = [];
- a.results[0].lines.forEach(function(a) {
- var b = a.lineName.split("|");
- b.pop();
- var c = [],
- e = 0,
- f = 0,
- p = 0;
- a.segments.forEach(function(a) {
- var b = a.segmentLine[0],
- d = [];
- b.linePoint.split(";").forEach(function(a) {
- d.push(a.split(","))
- });
- d.pop();
- e += b.segmentTime;
- f += b.segmentDistance;
- a.segmentType == 1 && (p += b.segmentDistance);
- c.push({
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: d
- },
- properties: {
- segmentType: a.segmentType,
- stationStart: a.stationStart,
- stationEnd: a.stationEnd,
- SEndTime: b.SEndTime,
- byuuid: b.byuuid,
- segmentTransferTime: b.segmentTransferTime,
- direction: b.direction,
- lineName: b.lineName,
- segmentDistance: b.segmentDistance,
- segmentStationCount: b.segmentStationCount,
- segmentTime: b.segmentTime
- }
- })
- });
- d.push({
- nameArr: b,
- lineItems: {
- type: "FeatureCollection",
- features: c
- },
- allTimes: e,
- walkingDistance: p,
- allDistance: f
- })
- });
- c.data = d
- }
- b({
- originalData: a,
- processedData: c
- })
- }
- }, function(a) {
- c && c(a)
- })
- },
- searchLineOrStation: function(a, b, c) {
- if (!a.uuid) throw Error("uuid\u4e3a\u7a7a");
- a = {
- type: "busline",
- postStr: JSON.stringify({
- uuid: a.uuid
- }),
- tk: this.token
- };
- GeoGlobe.loadURL("https://api.tianditu.gov.cn/transit", a, this, function(a) {
- if (b) {
- var a = JSON.parse(a.responseText),
- c = a.linepoint.split(";"),
- f = [];
- c.pop();
- c.forEach(function(a) {
- f.push(a.split(","))
- });
- a.geojsonLine = {
- type: "FeatureCollection",
- features: [{
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: f
- }
- }]
- };
- var g = {
- type: "FeatureCollection",
- features: []
- };
- a.station.forEach(function(a) {
- g.features.push({
- type: "Feature",
- geometry: {
- type: "Point",
- coordinates: a.lonlat.split(",")
- },
- properties: a
- })
- });
- a.geojsonStation = g;
- b(a)
- }
- }, function(a) {
- c && c(a)
- })
- },
- searchBackRoute: function(a, b, c) {
- if (!a.lineUuid) throw Error("lineUuid\u4e3a\u7a7a");
- if (!a.stationUuid) throw Error("stationUuid\u4e3a\u7a7a");
- a = {
- type: "busline",
- postStr: JSON.stringify({
- uuid: a.lineUuid,
- stationUuid: a.stationUuid
- }),
- tk: this.token
- };
- GeoGlobe.loadURL("https://api.tianditu.gov.cn/transit", a, this, function(a) {
- if (b) {
- var a = JSON.parse(a.responseText),
- c = a.linepoint.split(";"),
- f = [];
- c.pop();
- c.forEach(function(a) {
- f.push(a.split(","))
- });
- a.geojsonLine = {
- type: "FeatureCollection",
- features: [{
- type: "Feature",
- geometry: {
- type: "LineString",
- coordinates: f
- }
- }]
- };
- var g = {
- type: "FeatureCollection",
- features: []
- };
- a.station.forEach(function(a) {
- g.features.push({
- type: "Feature",
- geometry: {
- type: "Point",
- coordinates: a.lonlat.split(",")
- },
- properties: a
- })
- });
- a.geojsonStation = g;
- b(a)
- }
- }, function(a) {
- c && c(a)
- })
- },
- parseXML: function(a) {
- var b;
- if (window.DOMParser) {
- b = new DOMParser;
- a = b.parseFromString(a, "application/xml");
- if (!a) return;
- b = a.documentElement
- } else if (window.ActiveXObject) b = new ActiveXObject("Microsoft.XMLDOM"), b.async = !1, b.loadXML(a), b = b.documentElement;
- if (b) return this._parseDOM(b)
- },
- _parseDOM: function(a) {
- if (a) {
- this.__force_array = {};
- if (this.force_array)
- for (var b = 0; b < this.force_array.length; b++) this.__force_array[this.force_array[b]] = 1;
- b = this._parseElement(a);
- this.__force_array[a.nodeName] && (b = [b]);
- if (a.nodeType != 11) {
- var c = {};
- c[a.nodeName] = b;
- b = c
- }
- return b
- }
- },
- _parseElement: function(a) {
- if (a.nodeType != 7) {
- if (a.nodeType == 3 || a.nodeType == 4) {
- if (a.nodeValue.match(/[^\x00-\x20]/) == null) return;
- return a.nodeValue
- }
- var b, c = {};
- if (a.attributes && a.attributes.length) {
- b = {};
- for (var d = 0; d < a.attributes.length; d++) {
- var e = a.attributes[d].nodeName;
- if (typeof e ==
- "string") {
- var f = a.attributes[d].nodeValue;
- f && (typeof c[e] == "undefined" && (c[e] = 0), c[e]++, this._addNode(b, e, c[e], f))
- }
- }
- }
- if (a.childNodes && a.childNodes.length) {
- e = !0;
- b && (e = !1);
- for (d = 0; d < a.childNodes.length && e; d++) f = a.childNodes[d].nodeType, f == 3 || f == 4 || (e = !1);
- if (e) {
- b || (b = "");
- for (d = 0; d < a.childNodes.length; d++) b += a.childNodes[d].nodeValue
- } else {
- b || (b = {});
- for (d = 0; d < a.childNodes.length; d++)
- if (e = a.childNodes[d].nodeName, typeof e == "string" && (f = this._parseElement(a.childNodes[d]))) typeof c[e] == "undefined" && (c[e] =
- 0), c[e]++, this._addNode(b, e, c[e], f)
- }
- }
- return b
- }
- },
- _addNode: function(a, b, c, d) {
- this.__force_array[b] ? (c == 1 && (a[b] = []), a[b][a[b].length] = d) : c == 1 ? a[b] = d : c == 2 ? a[b] = [a[b], d] : a[b][a[b].length] = d
- },
- CLASS_NAME: "GeoGlobe.Query.TDTRouteQuery"
- });
- GeoGlobe.LayerGroup = GeoGlobe.Class4OL({
- map: null,
- initialize: function() {},
- addGroup: function(a, b, c, d) {
- mapboxgl.LayerGroup.addGroup(a, b, c, d)
- },
- addLayerToGroup: function(a, b, c, d) {
- mapboxgl.LayerGroup.addLayerToGroup(a, b, c, d)
- },
- removeLayerFromGroup: function(a, b, c) {
- for (var d = a.getStyle().layers, e = 0; e < d.length; e++) d[e].metadata && d[e].metadata.group === c && d[e].id == b && a.removeLayer(d[e].id)
- },
- removeGroup: function(a, b) {
- mapboxgl.LayerGroup.removeGroup(a, b)
- },
- moveGroup: function(a, b, c) {
- mapboxgl.LayerGroup.moveGroup(a,
- b, c)
- },
- getGroupFirstLayerId: function(a, b) {
- return mapboxgl.LayerGroup.getGroupFirstLayerId(a, b)
- },
- getGroupLastLayerId: function(a, b) {
- return mapboxgl.LayerGroup.getGroupLastLayerId(a, b)
- },
- CLASS_NAME: "GeoGlobe.LayerGroup"
- });
- GeoGlobe.Service = GeoGlobe.Class({
- name: null,
- url: null,
- version: null,
- userid: "test@liferay.com",
- initialize: function(a, b, c) {
- this.name = a;
- this.url = b;
- GeoGlobe.Util.extend(this, c)
- },
- getCapabilities: function() {},
- isExist: function() {},
- failFn: function(a) {
- alert("\u670d\u52a1\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u6216\u8bf7\u6c42\u5730\u5740\u662f\u5426\u6b63\u786e\u3002\n\u8bf7\u6c42\u5730\u5740\uff1a" + this.url + "\n\u64cd\u4f5c\u7c7b\u578b\uff1a" + a)
- },
- _parseToXML: function(a) {
- var b =
- a.responseXML;
- if (!b || !b.documentElement) b = a.responseText;
- return (new GeoGlobe.Format.XML).read(b)
- },
- _checkIsError: function(a) {
- if ((new GeoGlobe.Format.XML).read(a).selectNodes("ServiceExceptionReport").length > 0) return this._parseToJSON(a);
- return null
- },
- _isException: function(a) {
- if (a && a.ServiceExceptionReport) return !0;
- return !1
- },
- _parseToJSON: function(a) {
- return (new GeoGlobe.Util.Format.XML2JSON).read(a)
- },
- xmltoJson: function(a) {
- var b = {};
- if (a.nodeType == 1) {
- if (a.attributes.length > 0) {
- b.attributes = {};
- for (var c =
- 0; c < a.attributes.length; c++) {
- var d = a.attributes.item(c);
- b.attributes[d.nodeName] = d.nodeValue
- }
- }
- } else if (a.nodeType == 3) b = a.nodeValue;
- if (a.hasChildNodes())
- for (c = 0; c < a.childNodes.length; c++) {
- var d = a.childNodes.item(c),
- e = d.nodeName.replace("ows:", ""),
- e = e.replace("#", "");
- if (typeof b[e] == "undefined") b[e] = this.xmltoJson(d);
- else {
- if (typeof b[e].push == "undefined") {
- var f = b[e];
- b[e] = [];
- b[e].push(f)
- }
- b[e].push(this.xmltoJson(d))
- }
- }
- return b
- },
- CLASS_NAME: "GeoGlobe.Service"
- });
- GeoGlobe.Service.WFST = GeoGlobe.Class4OL(GeoGlobe.Service, {
- xy: !0,
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "WFS",
- VERSION: "1.0.0"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- a(b)
- }, b)
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WFS"
- },
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- describeFeatureType: function(a, b, c) {
- var d = this.url;
- GeoGlobe.Util.applyDefaults(a, {
- SERVICE: "WFS",
- VERSION: "1.0.0",
- REQUEST: "DescribeFeatureType"
- });
- c || (c = function() {
- this.failFn(a.REQUEST)
- });
- GeoGlobe.loadURL(d, a, this, function(a) {
- b(a)
- }, c)
- },
- getFeature: function(a, b, c) {
- var d = this.url;
- GeoGlobe.Util.applyDefaults(a, {
- SERVICE: "WFS",
- VERSION: "1.0.0",
- REQUEST: "GetFeature"
- });
- c || (c = function() {
- this.failFn(a.REQUEST)
- });
- GeoGlobe.loadURL(d, a, this, function(a) {
- b(a)
- }, c)
- },
- lockFeature: function(a, b, c) {
- GeoGlobe.Util.applyDefaults(a, {
- service: "WFS",
- version: "1.0.0",
- request: "LockFeature",
- expiry: 1,
- lockAction: "ALL"
- });
- var d = this._parserFilterToString(a.filter),
- d = GeoGlobe.String.format('<?xml version="1.0" encoding="UTF-8"?><LockFeature version="${version}" service="${service}" lockAction="${lockAction}" expiry="${expiry}" xmlns:wfs=" http://www.opengis.net/wfs" xmlns:gml=" http://www.opengis.net/gml" xmlns:myns=" http://www.someserver.com/myns" xmlns:ogc=" http://www.opengis.net/ogc" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd"><Lock typeName="${typeName}">${filterXMLString}</Lock></LockFeature>', {
- version: a.version,
- service: a.service,
- lockAction: a.lockAction,
- expiry: a.expiry,
- typeName: a.typeName,
- filterXMLString: d
- });
- c || (c = function() {
- this.failFn(a.request)
- });
- new GeoGlobe.Request.POST({
- url: this.url,
- data: d,
- scope: this,
- success: b,
- failure: c
- })
- },
- transaction: function(a, b, c, d, e, f) {
- var g = this.url;
- GeoGlobe.Util.applyDefaults(a, {
- service: "WFS",
- version: "1.0.0",
- request: "Transaction",
- releaseAction: "ALL"
- });
- var h = a.lockId,
- j = "";
- h && (j += "<LockId>" + h + "</LockId>");
- h = "";
- b && (h += this._getInsertString(b));
- c && (h += this._getUpdateString(c));
- d && (h += this._getDeleteString(d));
- b = GeoGlobe.String.format('<?xml version="1.0" encoding="UTF-8"?><wfs:Transaction releaseAction="${releaseAction}" handle="Transaction 01" version="${version}" service="${service}" xmlns="http://www.someserver.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">${lockIdString}${transactionString}</wfs:Transaction>', {
- releaseAction: a.releaseAction,
- version: a.version,
- service: a.service,
- lockIdString: j,
- transactionString: h
- });
- f || (f = function() {
- this.failFn(a.request)
- });
- new GeoGlobe.Request.POST({
- url: g,
- data: b,
- scope: this,
- success: e,
- failure: f
- })
- },
- parseTransactionResult: function(a) {
- var b = (new GeoGlobe.Format.XML2JSON).read(a.responseText),
- a = [],
- c = this._objToArray(b.wfs_WFS_TransactionResponse.wfs_TransactionResult.wfs_Status),
- b = this._objToArray(b.wfs_WFS_TransactionResponse.wfs_InsertResults);
- if (!c) return a;
- for (var d = 0; d < c.length; d++) c[d].wfs_SUCCESS !== void 0 ?
- a.push({
- status: "SUCCESS",
- fid: b && b[d] ? b[d].ogc_FeatureId.fid : null
- }) : a.push({
- status: "FAILED",
- fid: null
- });
- return a
- },
- _objToArray: function(a) {
- a && !(a instanceof Array) && (a = [a]);
- return a
- },
- _getInsertString: function(a) {
- for (var b = a.features, a = a.typeName, c = "", d = 0; d < b.length; d++) c += '<wfs:Insert handle="Insert ' + d + '">' + this._getInsertFeatureString(b[d], a) + "</wfs:Insert>";
- return c
- },
- _getInsertFeatureString: function(a, b) {
- var c = "",
- d;
- for (d in a.attributes) d != "OID" && (c += GeoGlobe.String.format("<${tag}><![CDATA[${value}]]\></${tag}>", {
- value: a.attributes[d] ? a.attributes[d] : "",
- tag: d
- }));
- c += GeoGlobe.String.format("<GEOMETRY>${geometry}</GEOMETRY>", {
- geometry: this._getGeometryStringByFeature(a)
- });
- return c = GeoGlobe.String.format("<${typeName}>${content}</${typeName}>", {
- typeName: b,
- content: c
- })
- },
- _getUpdateString: function(a) {
- for (var b = a.typeName, a = a.features, c = "", d = 0; d < a.length; d++)
- if (a[d].geometry) {
- var e = this._getUpdatePropertyString(a[d]),
- f = this._parserFilterToString(new GeoGlobe.Filter.FeatureId({
- fids: [b + "." + a[d].attributes.OID]
- }));
- c +=
- '<wfs:Update typeName="' + b + '" handle="Update ' + d + '">' + e + f + "</wfs:Update>"
- }
- return c
- },
- _getUpdatePropertyString: function(a) {
- var b = "",
- c;
- for (c in a.data) c != "OID" && a.data[c] && (b += "<wfs:Property><wfs:Name><![CDATA[" + c + "]]\></wfs:Name><wfs:Value><![CDATA[" + (a.data[c] ? a.data[c] : "") + "]]\></wfs:Value></wfs:Property>");
- b += "<wfs:Property><wfs:Name>Geometry</wfs:Name><wfs:Value>" + this._getGeometryStringByFeature(a) + "</wfs:Value></wfs:Property>";
- return b
- },
- _getGeometryStringByFeature: function(a) {
- var b = new GeoGlobe.Format.GML({
- xy: this.xy
- });
- b.buildCoordinatesNode = GeoGlobe.Function.bind(function(a) {
- var b = this.createElementNS(this.gmlns, "gml:coordinates");
- b.setAttribute("decimal", ".");
- b.setAttribute("cs", ",");
- b.setAttribute("ts", " ");
- var e = [];
- if (a instanceof GeoGlobe.LngLatBounds) this.xy ? (e.push(a.left + "," + a.bottom), e.push(a.right + "," + a.top)) : (e.push(a.bottom + "," + a.left), e.push(a.top + "," + a.right));
- else
- for (var a = a.components ? a.components : [a], f = 0; f < a.length; f++) this.xy ? e.push(a[f].x + "," + a[f].y) : e.push(a[f].y + "," + a[f].x);
- e = this.createTextNode(e.join(" "));
- b.appendChild(e);
- return b
- }, b);
- a = b.buildGeometryNode(a.geometry);
- return (new GeoGlobe.Format.XML).write(a)
- },
- _getDeleteString: function(a) {
- for (var b = a.filter, a = a.typeName, c = "", d = 0; d < b.fids.length; d++) {
- c += '<wfs:Delete typeName="' + a + '" handle="Delete ' + d + '">';
- var e = new GeoGlobe.Filter.FeatureId({
- fids: [b.fids[d]]
- });
- c += this._parserFilterToString(e);
- c += "</wfs:Delete>"
- }
- return c
- },
- _parserFilterToString: function(a) {
- var b = "";
- a && (a = (new GeoGlobe.Format.Filter.v1).write(a), b = (new GeoGlobe.Format.XML).write(a));
- return b
- },
- CLASS_NAME: "GeoGlobe.Service.WFST"
- });
- GeoGlobe.Service.CTS = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "CTS"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- a(b)
- }, b)
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "CTS"
- },
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- TransCoords: function(a,
- b, c) {
- var d = this.url;
- GeoGlobe.Util.applyDefaults(a, {
- SERVICE: "CTS",
- REQUEST: "TransCoords"
- });
- c || (c = function() {
- this.failFn(a.REQUEST)
- });
- GeoGlobe.loadURL(d, a, this, function(c) {
- if (a.FORMAT == "xml") {
- var d = {},
- c = this.xmltoJson(c.responseXML);
- d.attributes = c.CTS_TransResult["cts:Coordinate"].attributes.dim;
- for (var c = c.CTS_TransResult["cts:Coordinate"].text.split(","), g = [], h = 0; h < c.length; h++) g.push(c[h]);
- d.coordvalue = g
- } else if (a.FORMAT == "json") d = {}, c = c.responseText, c = (new GeoGlobe.Format.JSON).read(c), d.attributes =
- c.CTS_TransResult.dim, d.coordvalue = c.CTS_TransResult.Coordinate;
- b(d)
- }, c)
- },
- AffineTransform: function(a, b, c) {
- var d = this.url;
- GeoGlobe.Util.applyDefaults(a, {
- SERVICE: "CTS",
- REQUEST: "AffineTransform"
- });
- c || (c = function() {
- this.failFn(a.REQUEST)
- });
- GeoGlobe.loadURL(d, a, this, function(c) {
- if (a.FORMAT == "xml") {
- var d = {},
- c = this.xmltoJson(c.responseXML);
- d.attributes = c.CTS_AffineTransResult["cts:Coordinate"].attributes.dim;
- for (var c = c.CTS_AffineTransResult["cts:Coordinate"].text.split(","), g = [], h = 0; h < c.length; h++) g.push(c[h]);
- d.coordvalue = g
- } else if (a.FORMAT == "json") d = {}, c = c.responseText, c = (new GeoGlobe.Format.JSON).read(c), d.attributes = c.CTS_AffineTransResult.dim, d.coordvalue = c.CTS_AffineTransResult.Coordinate;
- b(d)
- }, c)
- },
- CLASS_NAME: "GeoGlobe.Service.CTS"
- });
- GeoGlobe.Service.VTS = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "WMTS",
- VERSION: "1.0.0"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- var b = this.xmlToJson(b.responseXML),
- c = [],
- d, h = [],
- b = b.Capabilities;
- if (b.Contents.Layer.length)
- for (var j = 0; j < b.Contents.Layer.length; j++) h.push(b.Contents.Layer[j]);
- else h.push(b.Contents.Layer);
- for (var l = 0; l < h.length; l++) {
- d = {};
- d.version = b.attributes.version;
- d.format = h[l].Format[4].text;
- d.LayerIdentifier = h[l].Identifier.text;
- d.StyleIdentifier = h[l].Style.Identifier.text;
- d.MatrixSet = h[l].TileMatrixSetLink[0].TileMatrixSet.text;
- if (h[l].BoundingBox) d.Bounding = h[l].BoundingBox;
- for (var m = "", j = 0; j < b.Contents.TileMatrixSet.length; j++)
- if (b.Contents.TileMatrixSet[j].Identifier.text == d.MatrixSet) var n = b.Contents.TileMatrixSet[j];
- d.mapCRS = n.SupportedCRS.text;
- var p = n.TileMatrix[0];
- d.initZoom = p.Identifier.text;
- if (p.length > 0) {
- for (var j = 0, q = p.length; j < q; j++) {
- if (j == q) break;
- m += p[j].ScaleDenominator.text + ","
- }
- d.Scales = m.substr(0, m.length - 1);
- d.zoomOffset = p[0].Identifier.text
- } else if (p) m += p.ScaleDenominator.text + ",", d.Scales = m.substr(0, m.length - 1), d.zoomOffset = p.Identifier.text;
- c[l] = d
- }
- a(c, b)
- }, b)
- },
- GetTile: function(a) {
- var b = {
- REQUEST: "GetTile",
- SERVICE: "WMTS",
- VERSION: "1.0.0"
- };
- if (a.layer) b.LAYER = a.layer;
- if (a.format) b.FORMAT = a.format;
- if (a.tileMatrixSet) b.TILEMATRIXSET = a.tileMatrixSet;
- if (a.width) b.WIDTH = a.width;
- if (a.height) b.HEIGHT =
- a.height;
- if (a.TILEMATRIX) b.TILEMATRIX = a.TILEMATRIX;
- if (a.TILEROW) b.TILEROW = a.TILEROW;
- if (a.TILECOL) b.TILECOL = a.TILECOL;
- a = {};
- a.url = this.url;
- a.param = b;
- return GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(a.param || {}))
- },
- GetStyleName: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetStyle",
- SERVICE: "WMTS",
- VERSION: "1.0.0"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.Request.GET({
- url: c,
- params: d,
- scope: this,
- async: this.async,
- success: function(c) {
- c = c.responseText;
- if (!c) return b(), !1;
- var c = (new GeoGlobe.Format.JSON).read(c),
- d = [];
- if (c.style)
- for (var g = 0; g < c.style.length; g++) d.push(c.style[g].styleName);
- else if (c.styleName)
- for (g = 0; g < c.styleName.length; g++) d.push(c.styleName[g]);
- a(d)
- },
- failure: b
- })
- },
- GetStyle: function(a, b, c) {
- var d = this.url;
- if (a == "" || a == void 0) alert("\u8bf7\u67e5\u770b\u6837\u5f0f\u540d\u79f0\u662f\u5426\u5b58\u5728");
- else {
- var e = {
- REQUEST: "GetStyle",
- SERVICE: "WMTS",
- VERSION: "1.0.0",
- STYLENAME: a
- };
- c || (c = function() {
- this.failFn(e.REQUEST)
- });
- GeoGlobe.Request.GET({
- url: d,
- params: e,
- scope: this,
- async: this.async,
- success: function(a) {
- a =
- a.responseText;
- if (!a) return c(), !1;
- a = (new GeoGlobe.Format.JSON).read(a);
- b(a)
- },
- failure: c
- })
- }
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WFS"
- },
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- CLASS_NAME: "GeoGlobe.Service.VTS"
- });
- GeoGlobe.Service.WMS = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "WMS"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- var b = this.xmlToJson(b.responseXML),
- c = {},
- d = b.WMT_MS_Capabilities,
- h = d.Capability.Layer.Layer,
- j = d.Capability.Request,
- h = h.length ? h[0] : h;
- c.version = d.attributes.version;
- c.format = j.GetMap.Format[1].text;
- c.layer = h.Title.text;
- c.bbox = h.BoundingBox.attributes.SRS;
- c.maxExtent = d.Capability.Layer.LatLonBoundingBox.attributes;
- a(c, b)
- }, b)
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WMS"
- },
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- getMap: function(a) {
- var b = this.url,
- b = {};
- if (a.layers) b.LAYERS = a.layers;
- if (a.format) b.FORMAT = a.format;
- if (a.bbox) b.BBOX = "{bbox-epsg-3857}";
- if (a.width) b.WIDTH = a.width;
- if (a.height) b.HEIGHT = a.height;
- if (a.version) b.VERSION =
- a.version;
- if (a.SRS) b.SRS = a.SRS;
- GeoGlobe.Util.applyDefaults(b, {
- service: "WMS",
- request: "GetMap",
- TRANSPARENT: !0
- });
- return b = GeoGlobe.Util.urlAppend(this.url, GeoGlobe.Util.getParameterString(b || {}))
- },
- CLASS_NAME: "GeoGlobe.Service.WMS"
- });
- GeoGlobe.Service.WMTS = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "WMTS"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- var b = this.xmlToJson(b.responseXML),
- c = b.Capabilities,
- d = {},
- h = c.Contents.Layer;
- h.length && (h = h[0]);
- d.version = c.attributes.version;
- c = c.Contents;
- d.layer = h.Title.text;
- d.LayerIdentifier = h.Identifier.text;
- d.StyleIdentifier = h.Style.Identifier.text;
- d.MatrixSet = h.TileMatrixSetLink[0].TileMatrixSet.text;
- d.Format = h.Format[1].text;
- d.Bounding = h.BoundingBox;
- h = "";
- c = c.TileMatrixSet[0].TileMatrix;
- if (c.length > 0)
- for (var j = 0, l = c.length; j < l; j++) {
- if (j == l) break;
- h += c[j].ScaleDenominator.text + ","
- }
- d.Scales = h.substr(0, h.length - 1);
- d.zoomOffset = c[0].Identifier.text;
- a(d, b)
- }, b)
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "WMTS"
- },
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- getTile: function(a) {
- var b = {};
- if (a.layer) b.LAYER = a.layer;
- if (a.format) b.FORMAT = a.format;
- if (a.tileMatrixSet) b.TILEMATRIXSET = a.tileMatrixSet;
- if (a.TILEMATRIX) b.TILEMATRIX = a.TILEMATRIX;
- if (a.TILEROW) b.TILEROW = a.TILEROW;
- if (a.TILECOL) b.TILECOL = a.TILECOL;
- if (a.version) b.VERSION = a.version;
- if (a.style) b.STYLE = a.style;
- GeoGlobe.Util.applyDefaults(b, {
- service: "WMTS",
- request: "GetTile"
- });
- return GeoGlobe.Util.urlAppend(this.url, GeoGlobe.Util.getParameterString(b || {}))
- },
- getCapabilitiesForRest: function(a,
- b) {
- var c = this.url;
- c.match(/\/$/) || (c += "/");
- c += "1.0.0/WMTSCapabilities.xml";
- b || (b = function() {
- this.failFn("GetCapabilities")
- });
- GeoGlobe.loadURL(c, null, this, function(b) {
- a(b)
- }, b)
- },
- getTileForRest: function(a) {
- var b = a.layer,
- c = a.style,
- d = a.tileMatrixSet,
- e = a.tileMatrix,
- f = a.tileRow,
- g = a.tileCol,
- h = null,
- a = a.format ? a.format : "image/png",
- j = {
- "image/png": "png",
- "image/png8": "png",
- "image/png24": "png",
- "image/png32": "png",
- png: "png",
- "image/jpeg": "jpg",
- "image/jpg": "jpg",
- jpeg: "jpg",
- jpg: "jpg"
- };
- h || (h = j[a] || a.split("/").pop());
- b = b + "/" + c + "/" + d + "/" + e + "/" + f + "/" + g + "." + h;
- c = this.url;
- c.match(/\/$/) || (c += "/");
- c += b;
- return c
- },
- CLASS_NAME: "GeoGlobe.Service.WMTS"
- });
- GeoGlobe.Service.DTJ = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "WMS"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- b = this.xmlToJson(b.responseXML);
- a(b)
- }, b)
- },
- getMap: function(a) {
- var b = {};
- if (a.layers) b.LAYERS = a.layers;
- if (a.format) b.FORMAT = a.format;
- if (a.bbox) b.BBOX = "{bbox-epsg-3857}";
- if (a.width) b.WIDTH = a.width;
- if (a.height) b.HEIGHT = a.height;
- if (a.interval) b.INTERVAL = a.interval;
- if (a.GRADSIZE) b.GRADSIZE = a.GRADSIZE;
- if (a.simplitymethod) b.SIMPLIFYMETHOD = a.simplitymethod;
- if (a.intervalcolor) b.INTERVALCOLOR = a.intervalcolor;
- if (a.SIMPLIFYSIZE) b.SIMPLIFYSIZE = a.SIMPLIFYSIZE;
- if (a.INTERPOLAION) b.INTERPOLATIONMETHOD = a.INTERPOLAION;
- if (a.RADIUS) b.RADIUS = a.RADIUS;
- GeoGlobe.Util.applyDefaults(b, {
- request: "GetMap",
- service: "WMS",
- version: "1.1.1"
- });
- return GeoGlobe.Util.urlAppend(this.url, GeoGlobe.Util.getParameterString(b || {}))
- },
- getStatisticInfo: function(a, b, c) {
- var d = {};
- if (a.layers) d.LAYERNAME = a.layers;
- if (a.lnglat) d.X = a.lnglat.lng, d.Y = a.lnglat.lat;
- if (a.simplitymethod) d.SIMPLIFYMETHOD = a.simplitymethod;
- if (a.INTERPOLATIONMETHOD) d.INTERPOLATIONMETHOD = a.INTERPOLATIONMETHOD;
- if (a.SIMPLIFYSIZE) d.SIMPLIFYSIZE = a.SIMPLIFYSIZE;
- if (a.INTERPOLAION) d.INTERPOLAION = a.INTERPOLAION;
- if (a.RADIUS) d.RADIUS = a.RADIUS;
- GeoGlobe.Util.applyDefaults(d, {
- request: "GetStatisticalValue",
- service: "WMS",
- version: "1.1.1"
- });
- a = GeoGlobe.Util.urlAppend(this.url, GeoGlobe.Util.getParameterString(d || {}));
- GeoGlobe.loadURL(a, d, this, function(a) {
- a = this.xmlToJson(a.responseXML);
- a.FeatureCollection.featureMember && b(a.FeatureCollection.featureMember)
- }, c)
- },
- getParams: function(a) {
- var b = {
- request: "GetMap",
- service: "WMS",
- version: "1.1.1"
- };
- GeoGlobe.Util.extend(b, a);
- return b
- },
- CLASS_NAME: "GeoGlobe.Service.DTJ"
- });
- GeoGlobe.Service.Fonts = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function() {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments)
- },
- getCapabilities: function(a, b) {
- var c = this.url,
- d = {
- REQUEST: "GetCapabilities",
- SERVICE: "FLS",
- VERSION: "1.0"
- };
- b || (b = function() {
- this.failFn(d.REQUEST)
- });
- GeoGlobe.loadURL(c, d, this, function(b) {
- var b = b.responseText,
- c = new GeoGlobe.Format.JSON,
- b = b ? c.read(b) : {};
- a(b)
- }, b)
- },
- isExist: function() {
- var a = !1;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- REQUEST: "GetCapabilities",
- SERVICE: "FLS"
- },
- scope: this,
- async: !1,
- success: function() {
- a = !0
- }
- });
- return a
- },
- GetFont: function(a, b) {
- var c = {
- REQUEST: "GetFont",
- SERVICE: "FLS",
- VERSION: "1.0"
- };
- b || (b = function() {
- this.failFn(c.REQUEST)
- })
- },
- CLASS_NAME: "GeoGlobe.Service.Fonts"
- });
- GeoGlobe.Service.RTDS = GeoGlobe.Class4OL(GeoGlobe.Service, {
- service: "RTDS",
- version: "1.0.0",
- format: "json",
- callback: "",
- initialize: function(a, b, c) {
- GeoGlobe.Service.prototype.initialize.apply(this, arguments);
- GeoGlobe.Util.extend(this, c)
- },
- getCapabilities: function(a, b) {
- var c = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "GetCapabilities",
- FORMAT: this.format,
- CALLBACK: this.callback
- },
- scope: this,
- async: this.async,
- success: function(d) {
- var e = {};
- try {
- e = JSON.parse(d.responseText)
- } catch (f) {
- console.error("RTDS GetCapabilities Error : " +
- d.responseText);
- b(d.responseText);
- return
- }
- a(e, c)
- },
- failure: b
- });
- return this
- },
- describeFeatureDataSet: function(a, b, c) {
- var d = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "DescribeFeatureDataSet",
- FORMAT: this.format,
- CALLBACK: this.callback,
- OBSOBJSETNAME: a
- },
- scope: this,
- async: this.async,
- success: function(a) {
- var f = {};
- try {
- f = JSON.parse(a.responseText)
- } catch (g) {
- console.error("RTDS DescribeFeatureDataSet Error : " + a.responseText);
- c(a.responseText);
- return
- }
- b(f, d)
- },
- failure: c
- });
- return this
- },
- describeObservationDataSet: function(a, b, c) {
- var d = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "DescribeObservationDataSet",
- FORMAT: this.format,
- CALLBACK: this.callback,
- DATASETNAME: a
- },
- scope: this,
- async: this.async,
- success: function(a) {
- var f = {};
- try {
- f = JSON.parse(a.responseText)
- } catch (g) {
- console.error("RTDS DescribeObservationDataSet Error : " + a.responseText);
- c(a.responseText);
- return
- }
- b(f, d)
- },
- failure: c
- });
- return this
- },
- queryFeature: function(a,
- b, c) {
- var d = {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "QueryFeature",
- FORMAT: this.format,
- CALLBACK: this.callback,
- OBSOBJSETNAME: a.obsobjsetname
- };
- a.externalid && (d.EXTERNALID = a.externalid);
- a.bbox && (d.BBOX = a.bbox);
- a.geometry && (d.GEOMETRY = a.geometry);
- typeof a.startposition != "undefined" && (d.STARTPOSITION = a.startposition);
- typeof a.maxcount != "undefined" && (d.MAXCOUNT = a.maxcount);
- var e = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- async: this.async,
- success: function(a) {
- var d = {};
- try {
- d = JSON.parse(a.responseText)
- } catch (h) {
- console.error("RTDS QueryFeature Error : " +
- a.responseText);
- c(a.responseText);
- return
- }
- b(d, e)
- },
- failure: c
- });
- return this
- },
- getObservation: function(a, b, c) {
- var d = {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "GetObservation",
- FORMAT: this.format,
- CALLBACK: this.callback,
- DATASETNAME: a.datasetname
- };
- a.externalid && (d.EXTERNALID = a.externalid);
- a.observationproperty && (d.OBSERVATIONPROPERTY = a.observationproperty);
- a.bbox && (d.BBOX = a.bbox);
- a.geometry && (d.GEOMETRY = a.geometry);
- typeof a.startposition != "undefined" && (d.STARTPOSITION = a.startposition);
- typeof a.maxcount !=
- "undefined" && (d.MAXCOUNT = a.maxcount);
- var e = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- async: this.async,
- success: function(a) {
- var d = {};
- try {
- d = JSON.parse(a.responseText)
- } catch (h) {
- console.error("RTDS GetObservation Error : " + a.responseText);
- c(a.responseText);
- return
- }
- b(d, e)
- },
- failure: c
- });
- return this
- },
- getObservationByCursor: function(a, b, c) {
- var d = {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "GetObservation",
- FORMAT: this.format,
- CALLBACK: this.callback,
- DATASETNAME: a.datasetname
- };
- a.externalid &&
- (d.EXTERNALID = a.externalid);
- a.observationproperty && (d.OBSERVATIONPROPERTY = a.observationproperty);
- a.bbox && (d.BBOX = a.bbox);
- a.geometry && (d.GEOMETRY = a.geometry);
- if (typeof a.maxcount == "undefined") console.error("RTDS GetObservationByCursor\u4e2dmaxcount\u4e3a\u5fc5\u987b\u53c2\u6570\uff01");
- else {
- d.MAXCOUNT = a.maxcount;
- var e = d.SCROLLID = "GETSCROLL",
- f = !1,
- g = this,
- h = function() {
- GeoGlobe.Request.GET({
- url: g.url,
- params: d,
- scope: g,
- async: g.async,
- success: function(a) {
- var h = {};
- try {
- h = JSON.parse(a.responseText)
- } catch (m) {
- console.error("RTDS GetObservation Error : " +
- a.responseText);
- f = !0;
- c(a.responseText);
- return
- }
- d.SCROLLID == e && !h.scrollId ? (console.error("RTDS GetObservationByCursor \u83b7\u53d6\u6e38\u6807\u5931\u8d25\uff01"), f = !0) : (h.features.length == 0 && (f = !0), d.SCROLLID = h.scrollId, b(h, g))
- },
- failure: c
- })
- };
- h();
- return {
- next: function() {
- var a = this;
- f || (d.SCROLLID == e ? setTimeout(function() {
- a.next()
- }, 300) : h());
- return !f
- }
- }
- }
- },
- getObservationHistory: function(a, b, c) {
- var d = {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "GetObservationHistory",
- FORMAT: this.format,
- CALLBACK: this.callback,
- DATASETNAME: a.datasetname,
- EXTERNALID: a.externalid,
- STARTTIME: a.starttime,
- ENDTIME: a.endtime
- };
- a.observationproperty && (d.OBSERVATIONPROPERTY = a.observationproperty);
- typeof a.samplemethod != "undefined" && (d.SAMPLEMETHOD = a.samplemethod);
- typeof a.samplecount != "undefined" && (d.SAMPLECOUNT = a.samplecount);
- var e = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- async: this.async,
- success: function(a) {
- var d = {};
- try {
- d = JSON.parse(a.responseText)
- } catch (h) {
- console.error("RTDS GetObservationHistory Error : " + a.responseText);
- c(a.responseText);
- return
- }
- b(d, e)
- },
- failure: c
- });
- return this
- },
- featureAggs: function(a, b, c) {
- var d = {
- SERVICE: this.service,
- VERSION: this.version,
- REQUEST: "FeatureAggs",
- FORMAT: this.format,
- CALLBACK: this.callback,
- DATASETNAME: a.datasetname,
- STARTTIME: a.starttime,
- ENDTIME: a.endtime
- };
- typeof a.precision != "undefined" && (d.PRECISION = a.precision);
- a.aggtype && (d.AGGTYPE = a.aggtype);
- a.groupbypro && (d.GROUPBYPRO = a.groupbypro);
- a.statisticspro && (d.STATISTICSPRO = a.statisticspro);
- a.profilter && (d.PROFILTER = a.profilter);
- a.bbox && (d.BBOX =
- a.bbox);
- var e = this;
- GeoGlobe.Request.GET({
- url: this.url,
- params: d,
- scope: this,
- async: this.async,
- success: function(a) {
- var d = {};
- try {
- d = JSON.parse(a.responseText)
- } catch (h) {
- console.error("RTDS FeatureAggs Error : " + a.responseText);
- c(a.responseText);
- return
- }
- b(d, e)
- },
- failure: c
- });
- return this
- },
- CLASS_NAME: "GeoGlobe.Service.RTDS"
- });
- GeoGlobe.Service.DSS = GeoGlobe.Class4OL(GeoGlobe.Service, {
- initialize: function(a, b) {
- GeoGlobe.Service.prototype.initialize.apply(this, [b, a])
- },
- getCapabilities: function(a, b) {
- return this._commit({
- method: "GET",
- params: {
- REQUEST: "GetCapabilities"
- }
- }, a, b)
- },
- describeFeatureType: function(a, b, c) {
- return this._commit({
- method: "GET",
- params: {
- REQUEST: "DescribeFeatureType",
- DATASETNAME: a,
- FORMAT: "json"
- }
- }, b, c)
- },
- getFeature: function(a, b, c) {
- a instanceof GeoGlobe.DSS.Query && (a = [a]);
- a = a.map(function(a) {
- return a.serialize()
- });
- a =
- "[" + a.join(",") + "]";
- return this._commit({
- data: ["SERVICE=DSS&VERSION=1.0.0&REQUEST=GetFeature", "QUERIES=" + a].join("&")
- }, b, c)
- },
- analysisFeature: function(a, b, c) {
- return this._commit({
- data: "SERVICE=DSS&VERSION=1.0.0&REQUEST=AnalysisFeature&" + a.serialize()
- }, b, c)
- },
- _commit: function(a, b, c) {
- var d = a.method || "POST",
- e = GeoGlobe.Util.extend(a.params, {
- SERVICE: "DSS",
- VERSION: "1.0.0"
- }),
- a = a.data,
- f = {};
- d === "POST" && a && (f = GeoGlobe.Util.extend(f, {
- "Content-Type": "application/x-www-form-urlencoded"
- }));
- return GeoGlobe.Request.issue({
- method: d,
- url: this.url,
- params: e,
- data: a,
- headers: f,
- success: function(a) {
- a = a.responseText;
- try {
- var d = (new GeoGlobe.Format.JSON).read(a);
- typeof d === "object" && "error" in d ? c(d.error) : b && b(d)
- } catch (e) {
- c && c(e)
- }
- },
- failure: function(a) {
- c && c(a)
- }
- })
- },
- CLASS_NAME: "GeoGlobe.Service.DSS"
- });
- GeoGlobe.DSS.Query = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- DATASETNAME: null,
- FILTER: null,
- SORTBY: null,
- STARTINDEX: null,
- COUNT: null,
- SCROLLID: null,
- PROPERTYNAME: null,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, GeoGlobe.Util.pick(a, ["DATASETNAME", "FILTER", "SORTBY", "STARTINDEX", "COUNT", "SCROLLID", "PROPERTYNAME"], !0))
- },
- serialize: function() {
- var a = GeoGlobe.Util.pick(this, ["DATASETNAME", "FILTER", "SORTBY", "STARTINDEX", "COUNT", "SCROLLID", "PROPERTYNAME"]),
- b;
- for (b in a) {
- var c = a[b];
- c === null ? delete a[b] : c instanceof
- GeoGlobe.Serializable && (a[b] = c.serialize())
- }
- return (new GeoGlobe.Format.JSON).write(a)
- },
- CLASS_NAME: "GeoGlobe.DSS.Query"
- });
- GeoGlobe.DSS.Analysis = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- DATASETNAME: null,
- FILTER: null,
- GROUPBY: null,
- SORTBY: null,
- AGGREGATIONS: null,
- PRECISION: null,
- SPATIALPROPERTYNAME: null,
- initialize: function(a) {
- GeoGlobe.Util.extend(this, GeoGlobe.Util.pick(a, ["DATASETNAME", "FILTER", "GROUPBY", "SORTBY", "AGGREGATIONS", "PRECISION", "SPATIALPROPERTYNAME"], !0))
- },
- serialize: function() {
- var a = GeoGlobe.Util.pick(this, ["DATASETNAME", "FILTER", "GROUPBY", "SORTBY", "AGGREGATIONS", "PRECISION", "SPATIALPROPERTYNAME"]),
- b = [],
- c;
- for (c in a) {
- var d =
- a[c];
- d === null ? delete a[c] : (d instanceof GeoGlobe.Serializable && (d = d.serialize()), b.push(c + "=" + d))
- }
- return b.join("&")
- },
- CLASS_NAME: "GeoGlobe.DSS.Analysis"
- });
- GeoGlobe.DSS.Filter = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- initialize: function(a) {
- GeoGlobe.Util.extend(this, a)
- },
- CLASS_NAME: "GeoGlobe.DSS.Filter"
- });
- GeoGlobe.DSS.Filter.Comparison = GeoGlobe.Class4OL(GeoGlobe.DSS.Filter, {
- type: null,
- property: null,
- value: null,
- initialize: function(a) {
- this.type = GeoGlobe.DSS.Filter.Comparison.LIKE;
- GeoGlobe.DSS.Filter.prototype.initialize.apply(this, [a])
- },
- serialize: function() {
- var a = this.property;
- a.indexOf(".") !== -1 && (a = "nested(" + a + ")");
- var b = this.value;
- GeoGlobe.Util.getType(b) !== "number" && (b = "'" + String(b) + "'");
- return a + " " + this.type + " " + b
- },
- CLASS_NAME: "GeoGlobe.DSS.Filter.Comparison"
- });
- GeoGlobe.DSS.Filter.Comparison.EQUAL_TO = "=";
- GeoGlobe.DSS.Filter.Comparison.LESS_THAN = "<";
- GeoGlobe.DSS.Filter.Comparison.GREATER_THAN = ">";
- GeoGlobe.DSS.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
- GeoGlobe.DSS.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
- GeoGlobe.DSS.Filter.Comparison.LIKE = "like";
- GeoGlobe.DSS.Filter.Spatial = GeoGlobe.Class4OL(GeoGlobe.DSS.Filter, {
- type: null,
- property: null,
- value: null,
- distance: null,
- distanceUnits: "km",
- serialize: function() {
- var a = this.value;
- a && a.toGeometry ? a = new GeoGlobe.Feature(a.toGeometry()) : a && a.getBounds && (a = new GeoGlobe.Feature(a));
- a = this.serializes[this.type].call(this, a);
- return this.type + "(" + this.property + "," + a + ")"
- },
- serializes: {
- GEO_BOUNDING_BOX: function(a) {
- a = a.geometry.getBounds().toBBOX().split(",");
- return [a[0], a[3], a[1], a[2]].join(",")
- },
- GEO_POLYGON: function(a) {
- return a.geometry.getVertices().map(function(a) {
- return a.x +
- "," + a.y
- }).join(",")
- },
- GEO_INTERSECTS: function(a) {
- return "'" + a.geometry.toString() + "'"
- },
- GEO_DISTANCE: function(a) {
- a = a.geometry.getBounds().getCenter();
- return ["'" + this.distance + this.distanceUnits + "'", a.lng, a.lat].join(",")
- }
- },
- CLASS_NAME: "GeoGlobe.DSS.Filter.Spatial"
- });
- GeoGlobe.DSS.Filter.Spatial.GEO_BOUNDING_BOX = "GEO_BOUNDING_BOX";
- GeoGlobe.DSS.Filter.Spatial.GEO_POLYGON = "GEO_POLYGON";
- GeoGlobe.DSS.Filter.Spatial.GEO_INTERSECTS = "GEO_INTERSECTS";
- GeoGlobe.DSS.Filter.Spatial.GEO_DISTANCE = "GEO_DISTANCE";
- GeoGlobe.DSS.Filter.Logical = GeoGlobe.Class4OL(GeoGlobe.DSS.Filter, {
- type: null,
- filters: null,
- initialize: function(a) {
- this.filters = [];
- GeoGlobe.DSS.Filter.prototype.initialize.apply(this, [a])
- },
- serialize: function() {
- return "(" + this.filters.map(function(a) {
- return a.serialize()
- }).join(" " + this.type + " ") + ")"
- },
- CLASS_NAME: "GeoGlobe.DSS.Filter.Logical"
- });
- GeoGlobe.DSS.Filter.Logical.AND = "and";
- GeoGlobe.DSS.Filter.Logical.OR = "or";
- GeoGlobe.DSS.PropertyName = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- type: null,
- properties: null,
- initialize: function(a) {
- this.type = GeoGlobe.DSS.PropertyName.INCLUDE;
- this.properties = [];
- GeoGlobe.Util.extend(this, a)
- },
- serialize: function() {
- return this.type + "(" + this.properties.join(",") + ")"
- }
- });
- GeoGlobe.DSS.PropertyName.INCLUDE = "include";
- GeoGlobe.DSS.PropertyName.EXCLUDE = "exclude";
- GeoGlobe.DSS.SortBy = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- sorts: null,
- initialize: function(a) {
- this.sorts = [];
- GeoGlobe.Util.extend(this, a)
- },
- serialize: function() {
- return this.sorts.map(function(a) {
- var b = a,
- c = GeoGlobe.DSS.SortBy.ASC;
- a && a.length && (b = a[0], a[1] && (c = a[1]));
- b.indexOf(".") !== -1 && (b = "nested(" + b + ")");
- return b + "/" + c
- }).join(",")
- },
- CLASS_NAME: "GeoGlobe.DSS.SortBy"
- });
- GeoGlobe.DSS.SortBy.ASC = "ASC";
- GeoGlobe.DSS.SortBy.DESC = "DESC";
- GeoGlobe.DSS.GroupBy = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- groups: null,
- initialize: function(a) {
- this.groups = [];
- GeoGlobe.Util.extend(this, a)
- },
- serialize: function() {
- return this.groups.map(function(a) {
- a.indexOf(".") !== -1 && (a = "nested(" + a + ")");
- return a
- }).join(",")
- },
- CLASS_NAME: "GeoGlobe.DSS.GroupBy"
- });
- GeoGlobe.DSS.Aggregations = GeoGlobe.Class4OL(GeoGlobe.Serializable, {
- aggregations: null,
- initialize: function(a) {
- this.aggregations = [];
- GeoGlobe.Util.extend(this, a)
- },
- serialize: function() {
- var a = this.aggregations.map(function(a) {
- var c = a[0],
- a = a[1];
- c.indexOf(".") !== -1 && (c = "nested(" + c + ")");
- return {
- aggtype: a,
- field: c
- }
- });
- return (new GeoGlobe.Format.JSON).write(a)
- },
- CLASS_NAME: "GeoGlobe.DSS.Aggregations"
- });
- GeoGlobe.DSS.Aggregations.COUNT = "count";
- GeoGlobe.DSS.Aggregations.SUM = "sum";
- GeoGlobe.DSS.Aggregations.AVG = "avg";
- GeoGlobe.DSS.Aggregations.MIN = "min";
- GeoGlobe.DSS.Aggregations.MAX = "max";
- GeoGlobe.Statistic = GeoGlobe.Class({
- url: null,
- type: "intersection",
- initialize: function(a, b) {
- this.url = a;
- GeoGlobe.Util.extend(this, b)
- },
- paramUrl: function(a) {
- var b = this.getParams({
- request: "GetMap"
- });
- if (a.layers) b.LAYERS = a.layers;
- if (a.format) b.FORMAT = a.format;
- if (a.bbox) b.BBOX = "{bbox-epsg-3857}";
- if (a.width) b.WIDTH = a.width;
- if (a.height) b.HEIGHT = a.height;
- if (a.interval) b.INTERVAL = a.interval;
- if (a.GRADSIZE) b.GRADSIZE = a.GRADSIZE;
- if (a.simplitymethod) b.SIMPLIFYMETHOD = a.simplitymethod;
- if (a.intervalcolor) b.INTERVALCOLOR =
- a.intervalcolor;
- if (a.SIMPLIFYSIZE) b.SIMPLIFYSIZE = a.SIMPLIFYSIZE;
- if (a.INTERPOLAION) b.INTERPOLATIONMETHOD = a.INTERPOLAION;
- if (a.RADIUS) b.RADIUS = a.RADIUS;
- a = {};
- a.url = this.url;
- a.param = b;
- return GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(a.param || {}))
- },
- getStatisticInfo: function(a) {
- var b = this.getParams({
- request: "GetStatisticalValue"
- });
- if (a.layers) b.LAYERNAME = a.layers;
- if (a.lnglat) b.X = a.lnglat.lng, b.Y = a.lnglat.lat;
- if (a.simplitymethod) b.SIMPLIFYMETHOD = a.simplitymethod;
- if (a.INTERPOLATIONMETHOD) b.INTERPOLATIONMETHOD =
- a.INTERPOLATIONMETHOD;
- if (a.SIMPLIFYSIZE) b.SIMPLIFYSIZE = a.SIMPLIFYSIZE;
- if (a.INTERPOLAION) b.INTERPOLAION = a.INTERPOLAION;
- if (a.RADIUS) b.RADIUS = a.RADIUS;
- a = {};
- a.url = this.url;
- a.param = b;
- return this.getStatisticValue(GeoGlobe.Util.urlAppend(a.url, GeoGlobe.Util.getParameterString(a.param || {})))
- },
- getParams: function(a) {
- var b = {
- request: "GetMap",
- service: "WMS",
- version: "1.1.1"
- };
- GeoGlobe.Util.extend(b, a);
- return b
- },
- getStatisticValue: function(a) {
- var b = Cfg.proxyHostUrl + a;
- Cfg.url = a;
- var a = sendAjaxRequest(b, dataChange),
- b = a.responseXML,
- c = (new GeoGlobe.Util.Format.XML2JSON).read(b);
- if (!b || !b.documentElement) b = a.responseText;
- if (b)
- if (c.FeatureCollection.featureMember) return c.FeatureCollection.featureMember;
- else alert("\u670d\u52a1\u4e0d\u53ef\u7528!");
- else alert("\u670d\u52a1\u4e0d\u53ef\u7528!")
- },
- CLASS_NAME: "GeoGlobe.Statistic"
- });
- GeoGlobe.Lang = {
- code: null,
- defaultCode: "zh-CN",
- getCode: function() {
- GeoGlobe.Lang.code || GeoGlobe.Lang.setCode();
- return GeoGlobe.Lang.code
- },
- setCode: function(a) {
- var b;
- a || (a = GeoGlobe.BROWSER_NAME == "msie" ? navigator.userLanguage : navigator.language);
- a = a.split("-");
- a[0] = a[0].toLowerCase();
- typeof GeoGlobe.Lang[a[0]] == "object" && (b = a[0]);
- if (a[1]) {
- var c = a[0] + "-" + a[1].toUpperCase();
- typeof GeoGlobe.Lang[c] == "object" && (b = c)
- }
- if (!b) GeoGlobe.Console.warn("Failed to find GeoGlobe.Lang." + a.join("-") + " dictionary, falling back to default language"),
- b = GeoGlobe.Lang.defaultCode;
- GeoGlobe.Lang.code = b
- },
- translate: function(a, b) {
- var c = GeoGlobe.Lang[GeoGlobe.Lang.getCode()];
- (c = c && c[a]) || (c = a);
- b && (c = GeoGlobe.String.format(c, b));
- return c
- }
- };
- GeoGlobe.i18n = GeoGlobe.Lang.translate;
- GeoGlobe.Lang.en = {
- unhandledRequest: "Unhandled request return ${statusText}",
- end: ""
- };
- GeoGlobe.Lang["zh-CN"] = {
- unhandledRequest: "\u672a\u5904\u7406\u7684\u8bf7\u6c42\uff0c\u8fd4\u56de\u503c\u4e3a ${statusText}",
- end: ""
- };
- GeoGlobe.Convertor = GeoGlobe.Class4OL({
- initialize: function() {},
- baiduTogcj: function(a) {
- var b = a[0] - 0.0065,
- c = a[1] - 0.006,
- a = Math.sqrt(b * b + c * c) - 2.0E-5 * Math.sin(c * 52.35987755982988),
- b = Math.atan2(c, b) - 3.0E-6 * Math.cos(b * 52.35987755982988);
- return [a * Math.cos(b), a * Math.sin(b)]
- },
- gcjTobaidu: function(a) {
- var b = a[0],
- c = a[1],
- a = Math.sqrt(b * b + c * c) + 2.0E-5 * Math.sin(c * 52.35987755982988),
- b = Math.atan2(c, b) + 3.0E-6 * Math.cos(b * 52.35987755982988);
- return [a * Math.cos(b) + 0.0065, a * Math.sin(b) + 0.006]
- },
- outOfChina: function(a, b) {
- return (a <
- 72.004 || a > 137.8347) && (b < 0.8293 || b > 55.8271) ? !0 : !1
- },
- transformLat: function(a, b) {
- var c = -100 + 2 * a + 3 * b + 0.2 * b * b + 0.1 * a * b + 0.2 * Math.sqrt(Math.abs(a));
- c += (20 * Math.sin(6 * a * Math.PI) + 20 * Math.sin(2 * a * Math.PI)) * 2 / 3;
- c += (20 * Math.sin(b * Math.PI) + 40 * Math.sin(b / 3 * Math.PI)) * 2 / 3;
- c += (160 * Math.sin(b / 12 * Math.PI) + 320 * Math.sin(b * Math.PI / 30)) * 2 / 3;
- return c
- },
- transformLon: function(a, b) {
- var c = 300 + a + 2 * b + 0.1 * a * a + 0.1 * a * b + 0.1 * Math.sqrt(Math.abs(a));
- c += (20 * Math.sin(6 * a * Math.PI) + 20 * Math.sin(2 * a * Math.PI)) * 2 / 3;
- c += (20 * Math.sin(a * Math.PI) + 40 *
- Math.sin(a / 3 * Math.PI)) * 2 / 3;
- c += (150 * Math.sin(a / 12 * Math.PI) + 300 * Math.sin(a / 30 * Math.PI)) * 2 / 3;
- return c
- },
- wgs2gcj: function(a) {
- var b = a[0],
- c = a[1];
- if (this.outOfChina(b, c)) return console.warn("\u5750\u6807\u5728\u4e2d\u56fd\u4ee5\u5916\uff0c\u65e0\u9700\u505a\u504f\u79fb\u5904\u7406!"), a;
- var a = this.transformLat(b - 105, c - 35),
- d = this.transformLon(b - 105, c - 35),
- e = c / 180 * Math.PI,
- f = Math.sin(e),
- f = 1 - 0.006693421622965943 * f * f,
- g = Math.sqrt(f),
- a = a * 180 / (6335552.717000426 / (f * g) * Math.PI),
- d = d * 180 / (6378245 / g * Math.cos(e) * Math.PI);
- return [b + d, c + a]
- },
- delta: function(a, b) {
- var c = this.transformLat(a - 105, b - 35),
- d = this.transformLon(a - 105, b - 35),
- e = b / 180 * Math.PI,
- f = Math.sin(e),
- f = 1 - 0.006693421622965943 * f * f,
- g = Math.sqrt(f),
- c = c * 180 / (6335552.717000426 / (f * g) * Math.PI),
- d = d * 180 / (6378245 / g * Math.cos(e) * Math.PI);
- return [d, c]
- },
- gcj2wgs: function(a) {
- var b = this.delta(a[0], a[1]);
- return [a[0] - b[0], a[1] - b[1]]
- },
- convertor: function(a, b) {
- if (!a || !b) return null;
- var c = b[0] + b[1] * Math.abs(a.x),
- d = Math.abs(a.y) / b[9],
- d = b[2] + b[3] * d + b[4] * d * d + b[5] * d * d * d + b[6] * d * d * d * d + b[7] * d *
- d * d * d * d + b[8] * d * d * d * d * d * d;
- c *= a.x < 0 ? -1 : 1;
- d *= a.y < 0 ? -1 : 1;
- return [c, d]
- },
- baiduMercatorTobaiduBL: function(a) {
- for (var b = [1.289059486E7, 8362377.87, 5591021, 3481989.83, 1678043.12, 0], c = [
- [1.410526172116255E-8, 8.98305509648872E-6, -1.9939833816331, 200.9824383106796, -187.2403703815547, 91.6087516669843, -23.38765649603339, 2.57121317296198, -0.03801003308653, 1.73379812E7],
- [-7.435856389565537E-9, 8.983055097726239E-6, -0.78625201886289, 96.32687599759846, -1.85204757529826, -59.36935905485877, 47.40033549296737, -16.50741931063887,
- 2.28786674699375, 1.026014486E7
- ],
- [-3.030883460898826E-8, 8.98305509983578E-6, 0.30071316287616, 59.74293618442277, 7.357984074871, -25.38371002664745, 13.45380521110908, -3.29883767235584, 0.32710905363475, 6856817.37],
- [-1.981981304930552E-8, 8.983055099779535E-6, 0.03278182852591, 40.31678527705744, 0.65659298677277, -4.44255534477492, 0.85341911805263, 0.12923347998204, -0.04625736007561, 4482777.06],
- [3.09191371068437E-9, 8.983055096812155E-6, 6.995724062E-5, 23.10934304144901, -2.3663490511E-4, -0.6321817810242, -0.00663494467273,
- 0.03430082397953, -0.00466043876332, 2555164.4
- ],
- [2.890871144776878E-9, 8.983055095805407E-6, -3.068298E-8, 7.47137025468032, -3.53937994E-6, -0.02145144861037, -1.234426596E-5, 1.0322952773E-4, -3.23890364E-6, 826088.5]
- ], d = {
- x: Math.abs(a[0]),
- y: Math.abs(a[1])
- }, e, f = 0, g = b.length; f < g; f++)
- if (d.y >= b[f]) {
- e = c[f];
- break
- }
- return this.convertor({
- x: a[0],
- y: a[1]
- }, e)
- },
- getRange: function(a, b, c) {
- b != null && (a = Math.max(a, b));
- c != null && (a = Math.min(a, c));
- return a
- },
- getLoop: function(a, b, c) {
- for (; a > c;) a -= c - b;
- for (; a < b;) a += c - b;
- return a
- },
- baiduBLTobaiduMercator: function(a) {
- var b = [75, 60, 45, 30, 15, 0],
- c = [
- [-0.0015702102444, 111320.7020616939, 1704480524535203, -10338987376042340, 26112667856603880, -35149669176653700, 26595700718403920, -10725012454188240, 1800819912950474, 82.5],
- [8.277824516172526E-4, 111320.7020463578, 6.477955746671607E8, -4.082003173641316E9, 1.077490566351142E10, -1.517187553151559E10, 1.205306533862167E10, -5.124939663577472E9, 9.133119359512032E8, 67.5],
- [0.00337398766765, 111320.7020202162, 4481351.045890365, -2.339375119931662E7, 7.968221547186455E7, -1.159649932797253E8, 9.723671115602145E7, -4.366194633752821E7, 8477230.501135234, 52.5],
- [0.00220636496208, 111320.7020209128, 51751.86112841131, 3796837.749470245, 992013.7397791013, -1221952.21711287, 1340652.697009075, -620943.6990984312, 144416.9293806241, 37.5],
- [-3.441963504368392E-4, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5],
- [-3.218135878613132E-4, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292, 1.58060784298199,
- 8.77738589078284, 0.37238884252424, 7.45
- ]
- ],
- a = {
- x: a[0],
- y: a[1]
- },
- d, e, f;
- a.x = this.getLoop(a.x, -180, 180);
- a.y = this.getRange(a.y, -74, 74);
- e = 0;
- for (f = b.length; e < f; e++)
- if (a.y >= b[e]) {
- d = c[e];
- break
- }
- if (!d)
- for (e = b.length - 1; e >= 0; e--)
- if (a.y <= -b[e]) {
- d = c[e];
- break
- }
- return this.convertor(a, d)
- },
- wgsBL2wgsMercator: function(a) {
- var b = a[0] * 2.003750834E7 / 180,
- a = Math.log(Math.tan((90 + a[1]) * Math.PI / 360)) / (Math.PI / 180);
- return [b, a * 2.003750834E7 / 180]
- },
- wgsMercator2wgsBL: function(a) {
- var b = a[0] / 2.003750834E7 * 180,
- a = a[1] / 2.003750834E7 * 180,
- a =
- 180 / Math.PI * (2 * Math.atan(Math.exp(a * Math.PI / 180)) - Math.PI / 2);
- return [b, a]
- },
- translate: function(a, b, c) {
- for (var d = 0; d < a.length; d++)
- if (typeof a[d][0] === "string" || typeof a[d][1] === "string") {
- console.error("string\u7c7b\u578b\u5750\u6807\u4e0d\u88ab\u652f\u6301\uff0c\u8bf7\u4f7f\u7528Number\u7c7b\u578b");
- break
- }
- var e = [];
- switch (b + "-" + c) {
- case "1-2":
- for (d = 0; d < a.length; d++) b = this.wgsBL2wgsMercator(a[d]), e.push(b);
- break;
- case "1-3":
- for (d = 0; d < a.length; d++) b = this.wgs2gcj(a[d]), e.push(b);
- break;
- case "1-4":
- for (d = 0; d <
- a.length; d++) b = this.wgs2gcj(a[d]), b = this.gcjTobaidu(b), e.push(b);
- break;
- case "1-5":
- for (d = 0; d < a.length; d++) b = this.wgs2gcj(a[d]), b = this.gcjTobaidu(b), b = this.baiduBLTobaiduMercator(b), e.push(b);
- break;
- case "2-1":
- for (d = 0; d < a.length; d++) b = this.wgsMercator2wgsBL(a[d]), e.push(b);
- break;
- case "2-3":
- for (d = 0; d < a.length; d++) b = this.wgsMercator2wgsBL(a[d]), b = this.wgs2gcj(b), e.push(b);
- break;
- case "2-4":
- for (d = 0; d < a.length; d++) b = this.wgsMercator2wgsBL(a[d]), b = this.wgs2gcj(b), b = this.gcjTobaidu(b), e.push(b);
- break;
- case "2-5":
- for (d =
- 0; d < a.length; d++) b = this.wgsMercator2wgsBL(a[d]), b = this.wgs2gcj(b), b = this.gcjTobaidu(b), b = this.baiduBLTobaiduMercator(b), e.push(b);
- break;
- case "3-1":
- for (d = 0; d < a.length; d++) b = this.gcj2wgs(a[d]), e.push(b);
- break;
- case "3-2":
- for (d = 0; d < a.length; d++) b = this.gcj2wgs(a[d]), b = this.wgsBL2wgsMercator(b), e.push(b);
- break;
- case "3-4":
- for (d = 0; d < a.length; d++) b = this.gcjTobaidu(a[d]), e.push(b);
- break;
- case "3-5":
- for (d = 0; d < a.length; d++) b = this.gcjTobaidu(a[d]), b = this.baiduBLTobaiduMercator(b), e.push(b);
- break;
- case "4-1":
- for (d =
- 0; d < a.length; d++) b = this.baiduTogcj(a[d]), b = this.gcj2wgs(b), e.push(b);
- break;
- case "4-2":
- for (d = 0; d < a.length; d++) b = this.baiduTogcj(a[d]), b = this.gcj2wgs(b), b = this.wgsBL2wgsMercator(b), e.push(b);
- break;
- case "4-3":
- for (d = 0; d < a.length; d++) b = this.baiduTogcj(a[d]), e.push(b);
- break;
- case "4-5":
- for (d = 0; d < a.length; d++) b = this.baiduBLTobaiduMercator(a[d]), e.push(b);
- break;
- case "5-1":
- for (d = 0; d < a.length; d++) b = this.baiduMercatorTobaiduBL(a[d]), b = this.baiduTogcj(b), b = this.gcj2wgs(b), e.push(b);
- break;
- case "5-2":
- for (d = 0; d <
- a.length; d++) b = this.baiduMercatorTobaiduBL(a[d]), b = this.baiduTogcj(b), b = this.gcj2wgs(b), b = this.wgsBL2wgsMercator(b), e.push(b);
- break;
- case "5-3":
- for (d = 0; d < a.length; d++) b = this.baiduMercatorTobaiduBL(a[d]), b = this.baiduTogcj(b), e.push(b);
- break;
- case "5-4":
- for (d = 0; d < a.length; d++) b = this.baiduMercatorTobaiduBL(a[d]), e.push(b);
- break;
- default:
- console.warn("from " + b + "\u6216to " + c + "\u4e0d\u5728\u89c4\u5b9a\u7684\u7f16\u53f7\u5185\uff01")
- }
- return e
- },
- CLASS_NAME: "GeoGlobe.Convertor"
- });
- GeoGlobe.Widget.Base = GeoGlobe.Class4OL({
- map: null,
- container: null,
- options: null,
- positon: null,
- initialize: function(a, b) {
- this.container = document.getElementById(a) || a;
- if (!(this.container instanceof HTMLElement)) this.container = document.createElement("div");
- this.container.parentElement && this.container.parentElement.removeChild(this.container);
- this.options = b || {}
- },
- render: function() {},
- updatePosition: function(a) {
- if (a)
- for (var b in GeoGlobe.Util.applyDefaults(a, {
- left: "",
- right: "",
- top: "",
- bottom: ""
- }), this.positon =
- GeoGlobe.Util.pick(a, ["left", "right", "top", "bottom"]), this.container.style.position = "absolute", this.positon) a = this.positon[b], a !== "" && typeof a === "number" && (a += "px"), this.container.style[b] = a
- },
- onAdd: function(a, b) {
- if (!this.map && a) this.map = a, a.getContainer().appendChild(this.container), this.render(), this.updatePosition(b)
- },
- onRemove: function() {
- if (this.map) map.getContainer().removeChild(this.container), this.map = null
- },
- CLASS_NAME: "GeoGlobe.Widget.Base"
- });
- GeoGlobe.Widget.Html = GeoGlobe.Class4OL(GeoGlobe.Widget.Base, {
- options: null,
- render: function() {
- this.container.innerHTML = this.options
- },
- CLASS_NAME: "GeoGlobe.Widget.Html"
- });
- GeoGlobe.Widget.MapSwitch = GeoGlobe.Class4OL(GeoGlobe.Widget.Base, {
- options: null,
- baseMaps: null,
- render: function() {
- var a = this,
- b = [{
- layers: [new GeoGlobe.TDTLayer("vec_c"), new GeoGlobe.TDTLayer("cva_c")],
- icon: "./\u5929\u5730\u56fe\u77e2\u91cf.png",
- text: "\u5929\u5730\u56fe\u77e2\u91cf"
- }, {
- layers: [new GeoGlobe.TDTLayer("img_c"), new GeoGlobe.TDTLayer("cia_c")],
- icon: "./\u5929\u5730\u56fe\u5f71\u50cf.png",
- text: "\u5929\u5730\u56fe\u5f71\u50cf"
- }],
- c = this.baseMaps = function(a) {
- for (var b in a) return !1;
- return !0
- }(this.options) ?
- b : this.options,
- d = document.createElement("div");
- d.id = "mapType";
- d.style.width = (c.length - 1) * 5 + 106 + "px";
- for (b = 0; b < c.length; b++) {
- var e = document.createElement("div");
- e.classList.add("mapTypeCard");
- e.style.right = 10 + b * 5 + "px";
- e.style.zIndex = c.length + 1 - b;
- e.setAttribute("layerIndex", b);
- e.style.backgroundImage = "url(" + c[b].icon + ")";
- if (b == 0) {
- var f = e;
- a.initMap().then(function() {
- for (var b = c[0].layers, d = 0; d < b.length; d++) a.map.addLayer(b[d]);
- f.classList.add("active")
- })
- }
- e.onclick = function() {
- var b = this;
- this.parentNode.prepend(this);
- for (var d = this.parentNode.children, e = 0; e < d.length; e++) d[e].classList.remove("active"), d[e].style.right = 10 + e * 5 + "px", d[e].style.zIndex = d.length + 1 - e;
- this.classList.add("active");
- a.initMap().then(function() {
- for (var d = b.getAttribute("layerIndex"), d = c[d].layers, e = 0; e < d.length; e++) a.map.addLayer(d[e])
- })
- };
- var g = document.createElement("span");
- g.innerHTML = c[b].text;
- e.appendChild(g);
- d.appendChild(e)
- }
- d.onmouseover = function() {
- d.style.width = (c.length + 1) * 10 + c.length * 86 + "px";
- d.classList.add("expand");
- for (var a = d.children,
- b = 0; b < a.length; b++) a[b].style.right = b * 96 + 10 + "px"
- };
- d.onmouseout = function() {
- d.style.width = (c.length - 1) * 5 + 106 + "px";
- d.classList.remove("expand");
- for (var a = d.children, b = 0; b < a.length; b++) a[b].style.right = b * 5 + 10 + "px"
- };
- this.container.appendChild(d)
- },
- initMap: function() {
- var a = this.map;
- return new Promise(function(b) {
- var c = setInterval(function() {
- if (a.loaded()) {
- for (var d = a.getStyle().layers, e = 0; e < d.length; e++) d[e].type === "raster" && (this.map.removeLayer(d[e].id), this.map.removeSource(d[e].source));
- clearInterval(c);
- b("ok")
- }
- }, 100)
- })
- },
- createStyle: function() {
- var a = document.createElement("style");
- a.setAttribute("type", "text/css");
- if (a.styleSheet) a.styleSheet.cssText = "#mapType {height: 80px;/* width: 110px; */cursor: pointer;-webkit-transition-property: width, background-color;transition-property: width, background-color;-webkit-transition-duration: 0.4s;transition-duration: 0.4s;background-color: rgba(255, 255, 255, 0);}#mapType.expand {background-color: #fff;background-color: rgba(255, 255, 255, 0.8);}.mapTypeCard {height: 60px;width: 86px;position: absolute;border-radius: 2px;top: 10px;box-sizing: border-box;border: 1px solid transparent;border: 1px solid rgba(153, 153, 153, 0.42);background-size: cover;background-repeat: no-repeat;-webkit-transition-property: right, background-image;transition-property: right, background-image;-webkit-transition-duration: 0.4s;transition-duration: 0.4s;}#mapType .mapTypeCard.active span,#mapType .mapTypeCard:hover span {background-color: #3385ff;}.mapTypeCard span {position: absolute;bottom: 0;right: 0;display: inline-block;padding: 3px 0px 2px;font-size: 12px;height: 12px;width: 100%;text-align: center;line-height: 12px;color: #fff;border-top-left-radius: 2px;}";
- else {
- var b = document.createTextNode("#mapType {height: 80px;/* width: 110px; */cursor: pointer;-webkit-transition-property: width, background-color;transition-property: width, background-color;-webkit-transition-duration: 0.4s;transition-duration: 0.4s;background-color: rgba(255, 255, 255, 0);}#mapType.expand {background-color: #fff;background-color: rgba(255, 255, 255, 0.8);}.mapTypeCard {height: 60px;width: 86px;position: absolute;border-radius: 2px;top: 10px;box-sizing: border-box;border: 1px solid transparent;border: 1px solid rgba(153, 153, 153, 0.42);background-size: cover;background-repeat: no-repeat;-webkit-transition-property: right, background-image;transition-property: right, background-image;-webkit-transition-duration: 0.4s;transition-duration: 0.4s;}#mapType .mapTypeCard.active span,#mapType .mapTypeCard:hover span {background-color: #3385ff;}.mapTypeCard span {position: absolute;bottom: 0;right: 0;display: inline-block;padding: 3px 0px 2px;font-size: 12px;height: 12px;width: 100%;text-align: center;line-height: 12px;color: #fff;border-top-left-radius: 2px;}");
- a.appendChild(b)
- }
- b = document.getElementsByTagName("head");
- b.length ? b[0].appendChild(a) : document.documentElement.appendChild(a)
- },
- CLASS_NAME: "GeoGlobe.Widget.MapSwitch"
- });
- GeoGlobe.Widget.AreaLocation = GeoGlobe.Class4OL(GeoGlobe.Widget.Base, {
- options: null,
- render: function() {
- this.opt_options = this.options;
- if (this.options.data) {
- if (!this.options.defaultName) this.options.defaultName = this.options.data[0].name;
- var a = '<div id="area-change-btn">' + this.options.defaultName + "</div>";
- a += this._appendPanel();
- this.container.innerHTML = a;
- this._bindEvent()
- } else throw Error("\u672a\u4f20\u5165\u6570\u636e");
- this._createCss()
- },
- _createCss: function() {
- var a = this.options.direction,
- b = "";
- document.getElementById("area-location-panel").style.cssText =
- a == "top-left" ? "left:0px;bottom: 40px;" : a == "top-right" ? "right:0px;bottom: 40px;" : a == "top-center" ? "right:-143px;bottom: 40px;" : a == "bottom-left" ? "left:0px;" : a == "bottom-center" ? "left:-143px;" : "right:0px;"
- },
- _appendPanel: function() {
- var a = this,
- b = '<div id="area-location-panel">';
- b += '<div class="area-location-title"><span>\u57ce\u5e02\u5217\u8868</span><span class="close">\u00d7</span></div>';
- b += '<div class="area-location-search"><input type="text" id="location-search-input"><button>\u641c\u7d22</button></div>';
- b += "<dl>";
- this.options.data.forEach(function(c) {
- var d = a.random(10);
- c.id = d;
- b += "<div>";
- var e, f, g = "";
- c.center && (e = c.center[0], f = c.center[1]);
- if (c.zoom) g = c.zoom;
- b += '<dt class="area-location-parent" id=' + d + " lng=" + e + " lat=" + f + " zoom=" + g + ">" + c.name + "</dt>";
- c.children && c.children.length && (b += "<dd>", c.children.forEach(function(c) {
- c.pId = d;
- var j = a.random(10);
- c.id = j;
- c.center && (e = c.center[0], f = c.center[1]);
- if (c.zoom) g = c.zoom;
- b += '<li class="area-location-children" id=' + j + " lng=" + e + " lat=" + f + " zoom=" + g + ">" + c.name +
- "</li>"
- }), b += "</dd>");
- b += "</div>"
- });
- b += "</dl>";
- b += "</div>";
- return b
- },
- _bindEvent: function() {
- var a = this;
- document.body.onclick = function() {
- var b = b || window.event,
- b = b.target || b.srcElement;
- if (b.id == "area-change-btn") {
- var c = document.getElementById("area-location-panel");
- c.style.display = c.style.display == "block" ? "none" : "block"
- }
- b.className == "area-location-parent" && a._onClick(b);
- b.className == "area-location-children" && a._onClick(b);
- b.className == "keywords-search-detail-li" && a._onClick(b);
- if (b.className == "close") c =
- document.getElementById("area-location-panel"), c.style.display = "none"
- };
- document.body.oninput = function() {
- var b = b || window.event,
- b = b.target || b.srcElement;
- b.id == "location-search-input" && a._search(b)
- }
- },
- _onClick: function(a) {
- var b = a.textContent;
- document.getElementById("area-change-btn").innerHTML = b;
- var b = this.map,
- a = this._keySearch(a.getAttribute("id"))[0],
- c = {};
- if (window.turf && turf && a.geometry && a.geometry.type == "Polygon") {
- var d = turf.centroid({
- geometry: a.geometry,
- properties: {},
- type: "Feature"
- });
- c.center = d.geometry.coordinates
- }
- if (a.center) c.center =
- a.center;
- if (a.zoom) c.zoom = a.zoom;
- (c.center || c.zoom) && b.flyTo(c);
- if (this.opt_options.onClick) this.opt_options.onClick(a);
- b = document.getElementsByClassName("keywords-search-detail");
- b.length && b[0].remove();
- document.getElementById("area-location-panel").style.display = "none"
- },
- _search: function(a) {
- var a = this._fuzzySearch(a.value),
- b = document.getElementsByClassName("keywords-search-detail");
- b.length && b[0].remove();
- if (a.length) {
- var c = "";
- a.forEach(function(a, b) {
- if (b < 10) {
- var f, g, h = "";
- a.center && (f = a.center[0],
- g = a.center[1]);
- if (a.zoom) h = a.zoom;
- c += '<li class="keywords-search-detail-li" id=' + a.id + " lng=" + f + " lat=" + g + " zoom=" + h + ">" + a.name + "</li>"
- }
- });
- a = document.createElement("ul");
- a.classList.add("keywords-search-detail");
- a.innerHTML = c;
- document.getElementsByClassName("area-location-search")[0].appendChild(a)
- }
- },
- _fuzzySearch: function(a) {
- var b = [];
- a && this.opt_options.data.forEach(function(c) {
- c.name.indexOf(a) != -1 && b.push(c);
- c.children && c.children.length && c.children.forEach(function(c) {
- c.name.indexOf(a) != -1 && b.push(c)
- })
- });
- return b
- },
- _keySearch: function(a) {
- var b = [];
- a && this.opt_options.data.forEach(function(c) {
- c.id == a && b.push(c);
- c.children && c.children.length && c.children.forEach(function(c) {
- c.id == a && b.push(c)
- })
- });
- return b
- },
- random: function(a) {
- for (var b = "", c = [], d = 0; d < a; d++) c.push(String.fromCharCode(97 + Math.ceil(Math.random() * 25)));
- for (d = 0; d < a; d++) b += c[d];
- return b
- },
- CLASS_NAME: "GeoGlobe.Widget.AreaLocation"
- });
|