proj4.js 185 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488
  1. !function (e) { if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else { var f; "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self), f.proj4 = e() } }(function () {
  2. var define, module, exports; return (function e(t, n, r) { function s(o, u) { if (!n[o]) { if (!t[o]) { var a = typeof require == "function" && require; if (!u && a) return a(o, !0); if (i) return i(o, !0); throw new Error("Cannot find module '" + o + "'") } var f = n[o] = { exports: {} }; t[o][0].call(f.exports, function (e) { var n = t[o][1][e]; return s(n ? n : e) }, f, f.exports, e, t, n, r) } return n[o].exports } var i = typeof require == "function" && require; for (var o = 0; o < r.length; o++)s(r[o]); return s })({
  3. 1: [function (_dereq_, module, exports) {
  4. var mgrs = _dereq_('mgrs');
  5. function Point(x, y, z) {
  6. if (!(this instanceof Point)) {
  7. return new Point(x, y, z);
  8. }
  9. if (Array.isArray(x)) {
  10. this.x = x[0];
  11. this.y = x[1];
  12. this.z = x[2] || 0.0;
  13. } else if (typeof x === 'object') {
  14. this.x = x.x;
  15. this.y = x.y;
  16. this.z = x.z || 0.0;
  17. } else if (typeof x === 'string' && typeof y === 'undefined') {
  18. var coords = x.split(',');
  19. this.x = parseFloat(coords[0], 10);
  20. this.y = parseFloat(coords[1], 10);
  21. this.z = parseFloat(coords[2], 10) || 0.0;
  22. } else {
  23. this.x = x;
  24. this.y = y;
  25. this.z = z || 0.0;
  26. }
  27. console.warn('proj4.Point will be removed in version 3, use proj4.toPoint');
  28. }
  29. Point.fromMGRS = function (mgrsStr) {
  30. return new Point(mgrs.toPoint(mgrsStr));
  31. };
  32. Point.prototype.toMGRS = function (accuracy) {
  33. return mgrs.forward([this.x, this.y], accuracy);
  34. };
  35. module.exports = Point;
  36. }, { "mgrs": 67 }], 2: [function (_dereq_, module, exports) {
  37. var parseCode = _dereq_("./parseCode");
  38. var extend = _dereq_('./extend');
  39. var projections = _dereq_('./projections');
  40. var deriveConstants = _dereq_('./deriveConstants');
  41. function Projection(srsCode, callback) {
  42. if (!(this instanceof Projection)) {
  43. return new Projection(srsCode);
  44. }
  45. callback = callback || function (error) {
  46. if (error) {
  47. throw error;
  48. }
  49. };
  50. var json = parseCode(srsCode);
  51. if (typeof json !== 'object') {
  52. callback(srsCode);
  53. return;
  54. }
  55. var modifiedJSON = deriveConstants(json);
  56. var ourProj = Projection.projections.get(modifiedJSON.projName);
  57. if (ourProj) {
  58. extend(this, modifiedJSON);
  59. extend(this, ourProj);
  60. this.init();
  61. callback(null, this);
  62. } else {
  63. callback(srsCode);
  64. }
  65. }
  66. Projection.projections = projections;
  67. Projection.projections.start();
  68. module.exports = Projection;
  69. }, { "./deriveConstants": 33, "./extend": 34, "./parseCode": 37, "./projections": 39 }], 3: [function (_dereq_, module, exports) {
  70. module.exports = function (crs, denorm, point) {
  71. var xin = point.x,
  72. yin = point.y,
  73. zin = point.z || 0.0;
  74. var v, t, i;
  75. for (i = 0; i < 3; i++) {
  76. if (denorm && i === 2 && point.z === undefined) {
  77. continue;
  78. }
  79. if (i === 0) {
  80. v = xin;
  81. t = 'x';
  82. }
  83. else if (i === 1) {
  84. v = yin;
  85. t = 'y';
  86. }
  87. else {
  88. v = zin;
  89. t = 'z';
  90. }
  91. switch (crs.axis[i]) {
  92. case 'e':
  93. point[t] = v;
  94. break;
  95. case 'w':
  96. point[t] = -v;
  97. break;
  98. case 'n':
  99. point[t] = v;
  100. break;
  101. case 's':
  102. point[t] = -v;
  103. break;
  104. case 'u':
  105. if (point[t] !== undefined) {
  106. point.z = v;
  107. }
  108. break;
  109. case 'd':
  110. if (point[t] !== undefined) {
  111. point.z = -v;
  112. }
  113. break;
  114. default:
  115. //console.log("ERROR: unknow axis ("+crs.axis[i]+") - check definition of "+crs.projName);
  116. return null;
  117. }
  118. }
  119. return point;
  120. };
  121. }, {}], 4: [function (_dereq_, module, exports) {
  122. var HALF_PI = Math.PI / 2;
  123. var sign = _dereq_('./sign');
  124. module.exports = function (x) {
  125. return (Math.abs(x) < HALF_PI) ? x : (x - (sign(x) * Math.PI));
  126. };
  127. }, { "./sign": 21 }], 5: [function (_dereq_, module, exports) {
  128. var TWO_PI = Math.PI * 2;
  129. // SPI is slightly greater than Math.PI, so values that exceed the -180..180
  130. // degree range by a tiny amount don't get wrapped. This prevents points that
  131. // have drifted from their original location along the 180th meridian (due to
  132. // floating point error) from changing their sign.
  133. var SPI = 3.14159265359;
  134. var sign = _dereq_('./sign');
  135. module.exports = function (x) {
  136. return (Math.abs(x) <= SPI) ? x : (x - (sign(x) * TWO_PI));
  137. };
  138. }, { "./sign": 21 }], 6: [function (_dereq_, module, exports) {
  139. module.exports = function (x) {
  140. if (Math.abs(x) > 1) {
  141. x = (x > 1) ? 1 : -1;
  142. }
  143. return Math.asin(x);
  144. };
  145. }, {}], 7: [function (_dereq_, module, exports) {
  146. module.exports = function (x) {
  147. return (1 - 0.25 * x * (1 + x / 16 * (3 + 1.25 * x)));
  148. };
  149. }, {}], 8: [function (_dereq_, module, exports) {
  150. module.exports = function (x) {
  151. return (0.375 * x * (1 + 0.25 * x * (1 + 0.46875 * x)));
  152. };
  153. }, {}], 9: [function (_dereq_, module, exports) {
  154. module.exports = function (x) {
  155. return (0.05859375 * x * x * (1 + 0.75 * x));
  156. };
  157. }, {}], 10: [function (_dereq_, module, exports) {
  158. module.exports = function (x) {
  159. return (x * x * x * (35 / 3072));
  160. };
  161. }, {}], 11: [function (_dereq_, module, exports) {
  162. module.exports = function (a, e, sinphi) {
  163. var temp = e * sinphi;
  164. return a / Math.sqrt(1 - temp * temp);
  165. };
  166. }, {}], 12: [function (_dereq_, module, exports) {
  167. module.exports = function (ml, e0, e1, e2, e3) {
  168. var phi;
  169. var dphi;
  170. phi = ml / e0;
  171. for (var i = 0; i < 15; i++) {
  172. dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi));
  173. phi += dphi;
  174. if (Math.abs(dphi) <= 0.0000000001) {
  175. return phi;
  176. }
  177. }
  178. //..reportError("IMLFN-CONV:Latitude failed to converge after 15 iterations");
  179. return NaN;
  180. };
  181. }, {}], 13: [function (_dereq_, module, exports) {
  182. var HALF_PI = Math.PI / 2;
  183. module.exports = function (eccent, q) {
  184. var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent));
  185. if (Math.abs(Math.abs(q) - temp) < 1.0E-6) {
  186. if (q < 0) {
  187. return (-1 * HALF_PI);
  188. }
  189. else {
  190. return HALF_PI;
  191. }
  192. }
  193. //var phi = 0.5* q/(1-eccent*eccent);
  194. var phi = Math.asin(0.5 * q);
  195. var dphi;
  196. var sin_phi;
  197. var cos_phi;
  198. var con;
  199. for (var i = 0; i < 30; i++) {
  200. sin_phi = Math.sin(phi);
  201. cos_phi = Math.cos(phi);
  202. con = eccent * sin_phi;
  203. dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
  204. phi += dphi;
  205. if (Math.abs(dphi) <= 0.0000000001) {
  206. return phi;
  207. }
  208. }
  209. //console.log("IQSFN-CONV:Latitude failed to converge after 30 iterations");
  210. return NaN;
  211. };
  212. }, {}], 14: [function (_dereq_, module, exports) {
  213. module.exports = function (e0, e1, e2, e3, phi) {
  214. return (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi));
  215. };
  216. }, {}], 15: [function (_dereq_, module, exports) {
  217. module.exports = function (eccent, sinphi, cosphi) {
  218. var con = eccent * sinphi;
  219. return cosphi / (Math.sqrt(1 - con * con));
  220. };
  221. }, {}], 16: [function (_dereq_, module, exports) {
  222. var HALF_PI = Math.PI / 2;
  223. module.exports = function (eccent, ts) {
  224. var eccnth = 0.5 * eccent;
  225. var con, dphi;
  226. var phi = HALF_PI - 2 * Math.atan(ts);
  227. for (var i = 0; i <= 15; i++) {
  228. con = eccent * Math.sin(phi);
  229. dphi = HALF_PI - 2 * Math.atan(ts * (Math.pow(((1 - con) / (1 + con)), eccnth))) - phi;
  230. phi += dphi;
  231. if (Math.abs(dphi) <= 0.0000000001) {
  232. return phi;
  233. }
  234. }
  235. //console.log("phi2z has NoConvergence");
  236. return -9999;
  237. };
  238. }, {}], 17: [function (_dereq_, module, exports) {
  239. var C00 = 1;
  240. var C02 = 0.25;
  241. var C04 = 0.046875;
  242. var C06 = 0.01953125;
  243. var C08 = 0.01068115234375;
  244. var C22 = 0.75;
  245. var C44 = 0.46875;
  246. var C46 = 0.01302083333333333333;
  247. var C48 = 0.00712076822916666666;
  248. var C66 = 0.36458333333333333333;
  249. var C68 = 0.00569661458333333333;
  250. var C88 = 0.3076171875;
  251. module.exports = function (es) {
  252. var en = [];
  253. en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08)));
  254. en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08)));
  255. var t = es * es;
  256. en[2] = t * (C44 - es * (C46 + es * C48));
  257. t *= es;
  258. en[3] = t * (C66 - es * C68);
  259. en[4] = t * es * C88;
  260. return en;
  261. };
  262. }, {}], 18: [function (_dereq_, module, exports) {
  263. var pj_mlfn = _dereq_("./pj_mlfn");
  264. var EPSLN = 1.0e-10;
  265. var MAX_ITER = 20;
  266. module.exports = function (arg, es, en) {
  267. var k = 1 / (1 - es);
  268. var phi = arg;
  269. for (var i = MAX_ITER; i; --i) { /* rarely goes over 2 iterations */
  270. var s = Math.sin(phi);
  271. var t = 1 - es * s * s;
  272. //t = this.pj_mlfn(phi, s, Math.cos(phi), en) - arg;
  273. //phi -= t * (t * Math.sqrt(t)) * k;
  274. t = (pj_mlfn(phi, s, Math.cos(phi), en) - arg) * (t * Math.sqrt(t)) * k;
  275. phi -= t;
  276. if (Math.abs(t) < EPSLN) {
  277. return phi;
  278. }
  279. }
  280. //..reportError("cass:pj_inv_mlfn: Convergence error");
  281. return phi;
  282. };
  283. }, { "./pj_mlfn": 19 }], 19: [function (_dereq_, module, exports) {
  284. module.exports = function (phi, sphi, cphi, en) {
  285. cphi *= sphi;
  286. sphi *= sphi;
  287. return (en[0] * phi - cphi * (en[1] + sphi * (en[2] + sphi * (en[3] + sphi * en[4]))));
  288. };
  289. }, {}], 20: [function (_dereq_, module, exports) {
  290. module.exports = function (eccent, sinphi) {
  291. var con;
  292. if (eccent > 1.0e-7) {
  293. con = eccent * sinphi;
  294. return ((1 - eccent * eccent) * (sinphi / (1 - con * con) - (0.5 / eccent) * Math.log((1 - con) / (1 + con))));
  295. }
  296. else {
  297. return (2 * sinphi);
  298. }
  299. };
  300. }, {}], 21: [function (_dereq_, module, exports) {
  301. module.exports = function (x) {
  302. return x < 0 ? -1 : 1;
  303. };
  304. }, {}], 22: [function (_dereq_, module, exports) {
  305. module.exports = function (esinp, exp) {
  306. return (Math.pow((1 - esinp) / (1 + esinp), exp));
  307. };
  308. }, {}], 23: [function (_dereq_, module, exports) {
  309. module.exports = function (array) {
  310. var out = {
  311. x: array[0],
  312. y: array[1]
  313. };
  314. if (array.length > 2) {
  315. out.z = array[2];
  316. }
  317. if (array.length > 3) {
  318. out.m = array[3];
  319. }
  320. return out;
  321. };
  322. }, {}], 24: [function (_dereq_, module, exports) {
  323. var HALF_PI = Math.PI / 2;
  324. module.exports = function (eccent, phi, sinphi) {
  325. var con = eccent * sinphi;
  326. var com = 0.5 * eccent;
  327. con = Math.pow(((1 - con) / (1 + con)), com);
  328. return (Math.tan(0.5 * (HALF_PI - phi)) / con);
  329. };
  330. }, {}], 25: [function (_dereq_, module, exports) {
  331. exports.wgs84 = {
  332. towgs84: "0,0,0",
  333. ellipse: "WGS84",
  334. datumName: "WGS84"
  335. };
  336. exports.ch1903 = {
  337. towgs84: "674.374,15.056,405.346",
  338. ellipse: "bessel",
  339. datumName: "swiss"
  340. };
  341. exports.ggrs87 = {
  342. towgs84: "-199.87,74.79,246.62",
  343. ellipse: "GRS80",
  344. datumName: "Greek_Geodetic_Reference_System_1987"
  345. };
  346. exports.nad83 = {
  347. towgs84: "0,0,0",
  348. ellipse: "GRS80",
  349. datumName: "North_American_Datum_1983"
  350. };
  351. exports.nad27 = {
  352. nadgrids: "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",
  353. ellipse: "clrk66",
  354. datumName: "North_American_Datum_1927"
  355. };
  356. exports.potsdam = {
  357. towgs84: "606.0,23.0,413.0",
  358. ellipse: "bessel",
  359. datumName: "Potsdam Rauenberg 1950 DHDN"
  360. };
  361. exports.carthage = {
  362. towgs84: "-263.0,6.0,431.0",
  363. ellipse: "clark80",
  364. datumName: "Carthage 1934 Tunisia"
  365. };
  366. exports.hermannskogel = {
  367. towgs84: "653.0,-212.0,449.0",
  368. ellipse: "bessel",
  369. datumName: "Hermannskogel"
  370. };
  371. exports.ire65 = {
  372. towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
  373. ellipse: "mod_airy",
  374. datumName: "Ireland 1965"
  375. };
  376. exports.rassadiran = {
  377. towgs84: "-133.63,-157.5,-158.62",
  378. ellipse: "intl",
  379. datumName: "Rassadiran"
  380. };
  381. exports.nzgd49 = {
  382. towgs84: "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
  383. ellipse: "intl",
  384. datumName: "New Zealand Geodetic Datum 1949"
  385. };
  386. exports.osgb36 = {
  387. towgs84: "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
  388. ellipse: "airy",
  389. datumName: "Airy 1830"
  390. };
  391. exports.s_jtsk = {
  392. towgs84: "589,76,480",
  393. ellipse: 'bessel',
  394. datumName: 'S-JTSK (Ferro)'
  395. };
  396. exports.beduaram = {
  397. towgs84: '-106,-87,188',
  398. ellipse: 'clrk80',
  399. datumName: 'Beduaram'
  400. };
  401. exports.gunung_segara = {
  402. towgs84: '-403,684,41',
  403. ellipse: 'bessel',
  404. datumName: 'Gunung Segara Jakarta'
  405. };
  406. exports.rnb72 = {
  407. towgs84: "106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",
  408. ellipse: "intl",
  409. datumName: "Reseau National Belge 1972"
  410. };
  411. }, {}], 26: [function (_dereq_, module, exports) {
  412. exports.MERIT = {
  413. a: 6378137.0,
  414. rf: 298.257,
  415. ellipseName: "MERIT 1983"
  416. };
  417. exports.SGS85 = {
  418. a: 6378136.0,
  419. rf: 298.257,
  420. ellipseName: "Soviet Geodetic System 85"
  421. };
  422. exports.GRS80 = {
  423. a: 6378137.0,
  424. rf: 298.257222101,
  425. ellipseName: "GRS 1980(IUGG, 1980)"
  426. };
  427. exports.IAU76 = {
  428. a: 6378140.0,
  429. rf: 298.257,
  430. ellipseName: "IAU 1976"
  431. };
  432. exports.airy = {
  433. a: 6377563.396,
  434. b: 6356256.910,
  435. ellipseName: "Airy 1830"
  436. };
  437. exports.APL4 = {
  438. a: 6378137,
  439. rf: 298.25,
  440. ellipseName: "Appl. Physics. 1965"
  441. };
  442. exports.NWL9D = {
  443. a: 6378145.0,
  444. rf: 298.25,
  445. ellipseName: "Naval Weapons Lab., 1965"
  446. };
  447. exports.mod_airy = {
  448. a: 6377340.189,
  449. b: 6356034.446,
  450. ellipseName: "Modified Airy"
  451. };
  452. exports.andrae = {
  453. a: 6377104.43,
  454. rf: 300.0,
  455. ellipseName: "Andrae 1876 (Den., Iclnd.)"
  456. };
  457. exports.aust_SA = {
  458. a: 6378160.0,
  459. rf: 298.25,
  460. ellipseName: "Australian Natl & S. Amer. 1969"
  461. };
  462. exports.GRS67 = {
  463. a: 6378160.0,
  464. rf: 298.2471674270,
  465. ellipseName: "GRS 67(IUGG 1967)"
  466. };
  467. exports.bessel = {
  468. a: 6377397.155,
  469. rf: 299.1528128,
  470. ellipseName: "Bessel 1841"
  471. };
  472. exports.bess_nam = {
  473. a: 6377483.865,
  474. rf: 299.1528128,
  475. ellipseName: "Bessel 1841 (Namibia)"
  476. };
  477. exports.clrk66 = {
  478. a: 6378206.4,
  479. b: 6356583.8,
  480. ellipseName: "Clarke 1866"
  481. };
  482. exports.clrk80 = {
  483. a: 6378249.145,
  484. rf: 293.4663,
  485. ellipseName: "Clarke 1880 mod."
  486. };
  487. exports.clrk58 = {
  488. a: 6378293.645208759,
  489. rf: 294.2606763692654,
  490. ellipseName: "Clarke 1858"
  491. };
  492. exports.CPM = {
  493. a: 6375738.7,
  494. rf: 334.29,
  495. ellipseName: "Comm. des Poids et Mesures 1799"
  496. };
  497. exports.delmbr = {
  498. a: 6376428.0,
  499. rf: 311.5,
  500. ellipseName: "Delambre 1810 (Belgium)"
  501. };
  502. exports.engelis = {
  503. a: 6378136.05,
  504. rf: 298.2566,
  505. ellipseName: "Engelis 1985"
  506. };
  507. exports.evrst30 = {
  508. a: 6377276.345,
  509. rf: 300.8017,
  510. ellipseName: "Everest 1830"
  511. };
  512. exports.evrst48 = {
  513. a: 6377304.063,
  514. rf: 300.8017,
  515. ellipseName: "Everest 1948"
  516. };
  517. exports.evrst56 = {
  518. a: 6377301.243,
  519. rf: 300.8017,
  520. ellipseName: "Everest 1956"
  521. };
  522. exports.evrst69 = {
  523. a: 6377295.664,
  524. rf: 300.8017,
  525. ellipseName: "Everest 1969"
  526. };
  527. exports.evrstSS = {
  528. a: 6377298.556,
  529. rf: 300.8017,
  530. ellipseName: "Everest (Sabah & Sarawak)"
  531. };
  532. exports.fschr60 = {
  533. a: 6378166.0,
  534. rf: 298.3,
  535. ellipseName: "Fischer (Mercury Datum) 1960"
  536. };
  537. exports.fschr60m = {
  538. a: 6378155.0,
  539. rf: 298.3,
  540. ellipseName: "Fischer 1960"
  541. };
  542. exports.fschr68 = {
  543. a: 6378150.0,
  544. rf: 298.3,
  545. ellipseName: "Fischer 1968"
  546. };
  547. exports.helmert = {
  548. a: 6378200.0,
  549. rf: 298.3,
  550. ellipseName: "Helmert 1906"
  551. };
  552. exports.hough = {
  553. a: 6378270.0,
  554. rf: 297.0,
  555. ellipseName: "Hough"
  556. };
  557. exports.intl = {
  558. a: 6378388.0,
  559. rf: 297.0,
  560. ellipseName: "International 1909 (Hayford)"
  561. };
  562. exports.kaula = {
  563. a: 6378163.0,
  564. rf: 298.24,
  565. ellipseName: "Kaula 1961"
  566. };
  567. exports.lerch = {
  568. a: 6378139.0,
  569. rf: 298.257,
  570. ellipseName: "Lerch 1979"
  571. };
  572. exports.mprts = {
  573. a: 6397300.0,
  574. rf: 191.0,
  575. ellipseName: "Maupertius 1738"
  576. };
  577. exports.new_intl = {
  578. a: 6378157.5,
  579. b: 6356772.2,
  580. ellipseName: "New International 1967"
  581. };
  582. exports.plessis = {
  583. a: 6376523.0,
  584. rf: 6355863.0,
  585. ellipseName: "Plessis 1817 (France)"
  586. };
  587. exports.krass = {
  588. a: 6378245.0,
  589. rf: 298.3,
  590. ellipseName: "Krassovsky, 1942"
  591. };
  592. exports.SEasia = {
  593. a: 6378155.0,
  594. b: 6356773.3205,
  595. ellipseName: "Southeast Asia"
  596. };
  597. exports.walbeck = {
  598. a: 6376896.0,
  599. b: 6355834.8467,
  600. ellipseName: "Walbeck"
  601. };
  602. exports.WGS60 = {
  603. a: 6378165.0,
  604. rf: 298.3,
  605. ellipseName: "WGS 60"
  606. };
  607. exports.WGS66 = {
  608. a: 6378145.0,
  609. rf: 298.25,
  610. ellipseName: "WGS 66"
  611. };
  612. exports.WGS7 = {
  613. a: 6378135.0,
  614. rf: 298.26,
  615. ellipseName: "WGS 72"
  616. };
  617. exports.WGS84 = {
  618. a: 6378137.0,
  619. rf: 298.257223563,
  620. ellipseName: "WGS 84"
  621. };
  622. exports.sphere = {
  623. a: 6370997.0,
  624. b: 6370997.0,
  625. ellipseName: "Normal Sphere (r=6370997)"
  626. };
  627. }, {}], 27: [function (_dereq_, module, exports) {
  628. exports.greenwich = 0.0; //"0dE",
  629. exports.lisbon = -9.131906111111; //"9d07'54.862\"W",
  630. exports.paris = 2.337229166667; //"2d20'14.025\"E",
  631. exports.bogota = -74.080916666667; //"74d04'51.3\"W",
  632. exports.madrid = -3.687938888889; //"3d41'16.58\"W",
  633. exports.rome = 12.452333333333; //"12d27'8.4\"E",
  634. exports.bern = 7.439583333333; //"7d26'22.5\"E",
  635. exports.jakarta = 106.807719444444; //"106d48'27.79\"E",
  636. exports.ferro = -17.666666666667; //"17d40'W",
  637. exports.brussels = 4.367975; //"4d22'4.71\"E",
  638. exports.stockholm = 18.058277777778; //"18d3'29.8\"E",
  639. exports.athens = 23.7163375; //"23d42'58.815\"E",
  640. exports.oslo = 10.722916666667; //"10d43'22.5\"E"
  641. }, {}], 28: [function (_dereq_, module, exports) {
  642. exports.ft = { to_meter: 0.3048 };
  643. exports['us-ft'] = { to_meter: 1200 / 3937 };
  644. }, {}], 29: [function (_dereq_, module, exports) {
  645. var proj = _dereq_('./Proj');
  646. var transform = _dereq_('./transform');
  647. var wgs84 = proj('WGS84');
  648. function transformer(from, to, coords) {
  649. var transformedArray;
  650. if (Array.isArray(coords)) {
  651. transformedArray = transform(from, to, coords);
  652. if (coords.length === 3) {
  653. return [transformedArray.x, transformedArray.y, transformedArray.z];
  654. }
  655. else {
  656. return [transformedArray.x, transformedArray.y];
  657. }
  658. }
  659. else {
  660. return transform(from, to, coords);
  661. }
  662. }
  663. function checkProj(item) {
  664. if (item instanceof proj) {
  665. return item;
  666. }
  667. if (item.oProj) {
  668. return item.oProj;
  669. }
  670. return proj(item);
  671. }
  672. function proj4(fromProj, toProj, coord) {
  673. fromProj = checkProj(fromProj);
  674. var single = false;
  675. var obj;
  676. if (typeof toProj === 'undefined') {
  677. toProj = fromProj;
  678. fromProj = wgs84;
  679. single = true;
  680. }
  681. else if (typeof toProj.x !== 'undefined' || Array.isArray(toProj)) {
  682. coord = toProj;
  683. toProj = fromProj;
  684. fromProj = wgs84;
  685. single = true;
  686. }
  687. toProj = checkProj(toProj);
  688. if (coord) {
  689. return transformer(fromProj, toProj, coord);
  690. }
  691. else {
  692. obj = {
  693. forward: function (coords) {
  694. return transformer(fromProj, toProj, coords);
  695. },
  696. inverse: function (coords) {
  697. return transformer(toProj, fromProj, coords);
  698. }
  699. };
  700. if (single) {
  701. obj.oProj = toProj;
  702. }
  703. return obj;
  704. }
  705. }
  706. module.exports = proj4;
  707. }, { "./Proj": 2, "./transform": 65 }], 30: [function (_dereq_, module, exports) {
  708. var HALF_PI = Math.PI / 2;
  709. var PJD_3PARAM = 1;
  710. var PJD_7PARAM = 2;
  711. var PJD_GRIDSHIFT = 3;
  712. var PJD_WGS84 = 4; // WGS84 or equivalent
  713. var PJD_NODATUM = 5; // WGS84 or equivalent
  714. var SEC_TO_RAD = 4.84813681109535993589914102357e-6;
  715. var AD_C = 1.0026000;
  716. var COS_67P5 = 0.38268343236508977;
  717. var datum = function (proj) {
  718. if (!(this instanceof datum)) {
  719. return new datum(proj);
  720. }
  721. this.datum_type = PJD_WGS84; //default setting
  722. if (!proj) {
  723. return;
  724. }
  725. if (proj.datumCode && proj.datumCode === 'none') {
  726. this.datum_type = PJD_NODATUM;
  727. }
  728. if (proj.datum_params) {
  729. this.datum_params = proj.datum_params.map(parseFloat);
  730. if (this.datum_params[0] !== 0 || this.datum_params[1] !== 0 || this.datum_params[2] !== 0) {
  731. this.datum_type = PJD_3PARAM;
  732. }
  733. if (this.datum_params.length > 3) {
  734. if (this.datum_params[3] !== 0 || this.datum_params[4] !== 0 || this.datum_params[5] !== 0 || this.datum_params[6] !== 0) {
  735. this.datum_type = PJD_7PARAM;
  736. this.datum_params[3] *= SEC_TO_RAD;
  737. this.datum_params[4] *= SEC_TO_RAD;
  738. this.datum_params[5] *= SEC_TO_RAD;
  739. this.datum_params[6] = (this.datum_params[6] / 1000000.0) + 1.0;
  740. }
  741. }
  742. }
  743. // DGR 2011-03-21 : nadgrids support
  744. this.datum_type = proj.grids ? PJD_GRIDSHIFT : this.datum_type;
  745. this.a = proj.a; //datum object also uses these values
  746. this.b = proj.b;
  747. this.es = proj.es;
  748. this.ep2 = proj.ep2;
  749. if (this.datum_type === PJD_GRIDSHIFT) {
  750. this.grids = proj.grids;
  751. }
  752. };
  753. datum.prototype = {
  754. /****************************************************************/
  755. // cs_compare_datums()
  756. // Returns TRUE if the two datums match, otherwise FALSE.
  757. compare_datums: function (dest) {
  758. if (this.datum_type !== dest.datum_type) {
  759. return false; // false, datums are not equal
  760. }
  761. else if (this.a !== dest.a || Math.abs(this.es - dest.es) > 0.000000000050) {
  762. // the tolerence for es is to ensure that GRS80 and WGS84
  763. // are considered identical
  764. return false;
  765. }
  766. else if (this.datum_type === PJD_3PARAM) {
  767. return (this.datum_params[0] === dest.datum_params[0] && this.datum_params[1] === dest.datum_params[1] && this.datum_params[2] === dest.datum_params[2]);
  768. }
  769. else if (this.datum_type === PJD_7PARAM) {
  770. return (this.datum_params[0] === dest.datum_params[0] && this.datum_params[1] === dest.datum_params[1] && this.datum_params[2] === dest.datum_params[2] && this.datum_params[3] === dest.datum_params[3] && this.datum_params[4] === dest.datum_params[4] && this.datum_params[5] === dest.datum_params[5] && this.datum_params[6] === dest.datum_params[6]);
  771. }
  772. else if (this.datum_type === PJD_GRIDSHIFT || dest.datum_type === PJD_GRIDSHIFT) {
  773. //alert("ERROR: Grid shift transformations are not implemented.");
  774. //return false
  775. //DGR 2012-07-29 lazy ...
  776. return this.nadgrids === dest.nadgrids;
  777. }
  778. else {
  779. return true; // datums are equal
  780. }
  781. }, // cs_compare_datums()
  782. /*
  783. * The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
  784. * (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
  785. * according to the current ellipsoid parameters.
  786. *
  787. * Latitude : Geodetic latitude in radians (input)
  788. * Longitude : Geodetic longitude in radians (input)
  789. * Height : Geodetic height, in meters (input)
  790. * X : Calculated Geocentric X coordinate, in meters (output)
  791. * Y : Calculated Geocentric Y coordinate, in meters (output)
  792. * Z : Calculated Geocentric Z coordinate, in meters (output)
  793. *
  794. */
  795. geodetic_to_geocentric: function (p) {
  796. var Longitude = p.x;
  797. var Latitude = p.y;
  798. var Height = p.z ? p.z : 0; //Z value not always supplied
  799. var X; // output
  800. var Y;
  801. var Z;
  802. var Error_Code = 0; // GEOCENT_NO_ERROR;
  803. var Rn; /* Earth radius at location */
  804. var Sin_Lat; /* Math.sin(Latitude) */
  805. var Sin2_Lat; /* Square of Math.sin(Latitude) */
  806. var Cos_Lat; /* Math.cos(Latitude) */
  807. /*
  808. ** Don't blow up if Latitude is just a little out of the value
  809. ** range as it may just be a rounding issue. Also removed longitude
  810. ** test, it should be wrapped by Math.cos() and Math.sin(). NFW for PROJ.4, Sep/2001.
  811. */
  812. if (Latitude < -HALF_PI && Latitude > -1.001 * HALF_PI) {
  813. Latitude = -HALF_PI;
  814. }
  815. else if (Latitude > HALF_PI && Latitude < 1.001 * HALF_PI) {
  816. Latitude = HALF_PI;
  817. }
  818. else if ((Latitude < -HALF_PI) || (Latitude > HALF_PI)) {
  819. /* Latitude out of range */
  820. //..reportError('geocent:lat out of range:' + Latitude);
  821. return null;
  822. }
  823. if (Longitude > Math.PI) {
  824. Longitude -= (2 * Math.PI);
  825. }
  826. Sin_Lat = Math.sin(Latitude);
  827. Cos_Lat = Math.cos(Latitude);
  828. Sin2_Lat = Sin_Lat * Sin_Lat;
  829. Rn = this.a / (Math.sqrt(1.0e0 - this.es * Sin2_Lat));
  830. X = (Rn + Height) * Cos_Lat * Math.cos(Longitude);
  831. Y = (Rn + Height) * Cos_Lat * Math.sin(Longitude);
  832. Z = ((Rn * (1 - this.es)) + Height) * Sin_Lat;
  833. p.x = X;
  834. p.y = Y;
  835. p.z = Z;
  836. return Error_Code;
  837. }, // cs_geodetic_to_geocentric()
  838. geocentric_to_geodetic: function (p) {
  839. /* local defintions and variables */
  840. /* end-criterium of loop, accuracy of sin(Latitude) */
  841. var genau = 1e-12;
  842. var genau2 = (genau * genau);
  843. var maxiter = 30;
  844. var P; /* distance between semi-minor axis and location */
  845. var RR; /* distance between center and location */
  846. var CT; /* sin of geocentric latitude */
  847. var ST; /* cos of geocentric latitude */
  848. var RX;
  849. var RK;
  850. var RN; /* Earth radius at location */
  851. var CPHI0; /* cos of start or old geodetic latitude in iterations */
  852. var SPHI0; /* sin of start or old geodetic latitude in iterations */
  853. var CPHI; /* cos of searched geodetic latitude */
  854. var SPHI; /* sin of searched geodetic latitude */
  855. var SDPHI; /* end-criterium: addition-theorem of sin(Latitude(iter)-Latitude(iter-1)) */
  856. var At_Pole; /* indicates location is in polar region */
  857. var iter; /* # of continous iteration, max. 30 is always enough (s.a.) */
  858. var X = p.x;
  859. var Y = p.y;
  860. var Z = p.z ? p.z : 0.0; //Z value not always supplied
  861. var Longitude;
  862. var Latitude;
  863. var Height;
  864. At_Pole = false;
  865. P = Math.sqrt(X * X + Y * Y);
  866. RR = Math.sqrt(X * X + Y * Y + Z * Z);
  867. /* special cases for latitude and longitude */
  868. if (P / this.a < genau) {
  869. /* special case, if P=0. (X=0., Y=0.) */
  870. At_Pole = true;
  871. Longitude = 0.0;
  872. /* if (X,Y,Z)=(0.,0.,0.) then Height becomes semi-minor axis
  873. * of ellipsoid (=center of mass), Latitude becomes PI/2 */
  874. if (RR / this.a < genau) {
  875. Latitude = HALF_PI;
  876. Height = -this.b;
  877. return;
  878. }
  879. }
  880. else {
  881. /* ellipsoidal (geodetic) longitude
  882. * interval: -PI < Longitude <= +PI */
  883. Longitude = Math.atan2(Y, X);
  884. }
  885. /* --------------------------------------------------------------
  886. * Following iterative algorithm was developped by
  887. * "Institut for Erdmessung", University of Hannover, July 1988.
  888. * Internet: www.ife.uni-hannover.de
  889. * Iterative computation of CPHI,SPHI and Height.
  890. * Iteration of CPHI and SPHI to 10**-12 radian resp.
  891. * 2*10**-7 arcsec.
  892. * --------------------------------------------------------------
  893. */
  894. CT = Z / RR;
  895. ST = P / RR;
  896. RX = 1.0 / Math.sqrt(1.0 - this.es * (2.0 - this.es) * ST * ST);
  897. CPHI0 = ST * (1.0 - this.es) * RX;
  898. SPHI0 = CT * RX;
  899. iter = 0;
  900. /* loop to find sin(Latitude) resp. Latitude
  901. * until |sin(Latitude(iter)-Latitude(iter-1))| < genau */
  902. do {
  903. iter++;
  904. RN = this.a / Math.sqrt(1.0 - this.es * SPHI0 * SPHI0);
  905. /* ellipsoidal (geodetic) height */
  906. Height = P * CPHI0 + Z * SPHI0 - RN * (1.0 - this.es * SPHI0 * SPHI0);
  907. RK = this.es * RN / (RN + Height);
  908. RX = 1.0 / Math.sqrt(1.0 - RK * (2.0 - RK) * ST * ST);
  909. CPHI = ST * (1.0 - RK) * RX;
  910. SPHI = CT * RX;
  911. SDPHI = SPHI * CPHI0 - CPHI * SPHI0;
  912. CPHI0 = CPHI;
  913. SPHI0 = SPHI;
  914. }
  915. while (SDPHI * SDPHI > genau2 && iter < maxiter);
  916. /* ellipsoidal (geodetic) latitude */
  917. Latitude = Math.atan(SPHI / Math.abs(CPHI));
  918. p.x = Longitude;
  919. p.y = Latitude;
  920. p.z = Height;
  921. return p;
  922. }, // cs_geocentric_to_geodetic()
  923. /** Convert_Geocentric_To_Geodetic
  924. * The method used here is derived from 'An Improved Algorithm for
  925. * Geocentric to Geodetic Coordinate Conversion', by Ralph Toms, Feb 1996
  926. */
  927. geocentric_to_geodetic_noniter: function (p) {
  928. var X = p.x;
  929. var Y = p.y;
  930. var Z = p.z ? p.z : 0; //Z value not always supplied
  931. var Longitude;
  932. var Latitude;
  933. var Height;
  934. var W; /* distance from Z axis */
  935. var W2; /* square of distance from Z axis */
  936. var T0; /* initial estimate of vertical component */
  937. var T1; /* corrected estimate of vertical component */
  938. var S0; /* initial estimate of horizontal component */
  939. var S1; /* corrected estimate of horizontal component */
  940. var Sin_B0; /* Math.sin(B0), B0 is estimate of Bowring aux variable */
  941. var Sin3_B0; /* cube of Math.sin(B0) */
  942. var Cos_B0; /* Math.cos(B0) */
  943. var Sin_p1; /* Math.sin(phi1), phi1 is estimated latitude */
  944. var Cos_p1; /* Math.cos(phi1) */
  945. var Rn; /* Earth radius at location */
  946. var Sum; /* numerator of Math.cos(phi1) */
  947. var At_Pole; /* indicates location is in polar region */
  948. X = parseFloat(X); // cast from string to float
  949. Y = parseFloat(Y);
  950. Z = parseFloat(Z);
  951. At_Pole = false;
  952. if (X !== 0.0) {
  953. Longitude = Math.atan2(Y, X);
  954. }
  955. else {
  956. if (Y > 0) {
  957. Longitude = HALF_PI;
  958. }
  959. else if (Y < 0) {
  960. Longitude = -HALF_PI;
  961. }
  962. else {
  963. At_Pole = true;
  964. Longitude = 0.0;
  965. if (Z > 0.0) { /* north pole */
  966. Latitude = HALF_PI;
  967. }
  968. else if (Z < 0.0) { /* south pole */
  969. Latitude = -HALF_PI;
  970. }
  971. else { /* center of earth */
  972. Latitude = HALF_PI;
  973. Height = -this.b;
  974. return;
  975. }
  976. }
  977. }
  978. W2 = X * X + Y * Y;
  979. W = Math.sqrt(W2);
  980. T0 = Z * AD_C;
  981. S0 = Math.sqrt(T0 * T0 + W2);
  982. Sin_B0 = T0 / S0;
  983. Cos_B0 = W / S0;
  984. Sin3_B0 = Sin_B0 * Sin_B0 * Sin_B0;
  985. T1 = Z + this.b * this.ep2 * Sin3_B0;
  986. Sum = W - this.a * this.es * Cos_B0 * Cos_B0 * Cos_B0;
  987. S1 = Math.sqrt(T1 * T1 + Sum * Sum);
  988. Sin_p1 = T1 / S1;
  989. Cos_p1 = Sum / S1;
  990. Rn = this.a / Math.sqrt(1.0 - this.es * Sin_p1 * Sin_p1);
  991. if (Cos_p1 >= COS_67P5) {
  992. Height = W / Cos_p1 - Rn;
  993. }
  994. else if (Cos_p1 <= -COS_67P5) {
  995. Height = W / -Cos_p1 - Rn;
  996. }
  997. else {
  998. Height = Z / Sin_p1 + Rn * (this.es - 1.0);
  999. }
  1000. if (At_Pole === false) {
  1001. Latitude = Math.atan(Sin_p1 / Cos_p1);
  1002. }
  1003. p.x = Longitude;
  1004. p.y = Latitude;
  1005. p.z = Height;
  1006. return p;
  1007. }, // geocentric_to_geodetic_noniter()
  1008. /****************************************************************/
  1009. // pj_geocentic_to_wgs84( p )
  1010. // p = point to transform in geocentric coordinates (x,y,z)
  1011. geocentric_to_wgs84: function (p) {
  1012. if (this.datum_type === PJD_3PARAM) {
  1013. // if( x[io] === HUGE_VAL )
  1014. // continue;
  1015. p.x += this.datum_params[0];
  1016. p.y += this.datum_params[1];
  1017. p.z += this.datum_params[2];
  1018. }
  1019. else if (this.datum_type === PJD_7PARAM) {
  1020. var Dx_BF = this.datum_params[0];
  1021. var Dy_BF = this.datum_params[1];
  1022. var Dz_BF = this.datum_params[2];
  1023. var Rx_BF = this.datum_params[3];
  1024. var Ry_BF = this.datum_params[4];
  1025. var Rz_BF = this.datum_params[5];
  1026. var M_BF = this.datum_params[6];
  1027. // if( x[io] === HUGE_VAL )
  1028. // continue;
  1029. var x_out = M_BF * (p.x - Rz_BF * p.y + Ry_BF * p.z) + Dx_BF;
  1030. var y_out = M_BF * (Rz_BF * p.x + p.y - Rx_BF * p.z) + Dy_BF;
  1031. var z_out = M_BF * (-Ry_BF * p.x + Rx_BF * p.y + p.z) + Dz_BF;
  1032. p.x = x_out;
  1033. p.y = y_out;
  1034. p.z = z_out;
  1035. }
  1036. }, // cs_geocentric_to_wgs84
  1037. /****************************************************************/
  1038. // pj_geocentic_from_wgs84()
  1039. // coordinate system definition,
  1040. // point to transform in geocentric coordinates (x,y,z)
  1041. geocentric_from_wgs84: function (p) {
  1042. if (this.datum_type === PJD_3PARAM) {
  1043. //if( x[io] === HUGE_VAL )
  1044. // continue;
  1045. p.x -= this.datum_params[0];
  1046. p.y -= this.datum_params[1];
  1047. p.z -= this.datum_params[2];
  1048. }
  1049. else if (this.datum_type === PJD_7PARAM) {
  1050. var Dx_BF = this.datum_params[0];
  1051. var Dy_BF = this.datum_params[1];
  1052. var Dz_BF = this.datum_params[2];
  1053. var Rx_BF = this.datum_params[3];
  1054. var Ry_BF = this.datum_params[4];
  1055. var Rz_BF = this.datum_params[5];
  1056. var M_BF = this.datum_params[6];
  1057. var x_tmp = (p.x - Dx_BF) / M_BF;
  1058. var y_tmp = (p.y - Dy_BF) / M_BF;
  1059. var z_tmp = (p.z - Dz_BF) / M_BF;
  1060. //if( x[io] === HUGE_VAL )
  1061. // continue;
  1062. p.x = x_tmp + Rz_BF * y_tmp - Ry_BF * z_tmp;
  1063. p.y = -Rz_BF * x_tmp + y_tmp + Rx_BF * z_tmp;
  1064. p.z = Ry_BF * x_tmp - Rx_BF * y_tmp + z_tmp;
  1065. } //cs_geocentric_from_wgs84()
  1066. }
  1067. };
  1068. /** point object, nothing fancy, just allows values to be
  1069. passed back and forth by reference rather than by value.
  1070. Other point classes may be used as long as they have
  1071. x and y properties, which will get modified in the transform method.
  1072. */
  1073. module.exports = datum;
  1074. }, {}], 31: [function (_dereq_, module, exports) {
  1075. var PJD_3PARAM = 1;
  1076. var PJD_7PARAM = 2;
  1077. var PJD_GRIDSHIFT = 3;
  1078. var PJD_NODATUM = 5; // WGS84 or equivalent
  1079. var SRS_WGS84_SEMIMAJOR = 6378137; // only used in grid shift transforms
  1080. var SRS_WGS84_ESQUARED = 0.006694379990141316; //DGR: 2012-07-29
  1081. module.exports = function (source, dest, point) {
  1082. var wp, i, l;
  1083. function checkParams(fallback) {
  1084. return (fallback === PJD_3PARAM || fallback === PJD_7PARAM);
  1085. }
  1086. // Short cut if the datums are identical.
  1087. if (source.compare_datums(dest)) {
  1088. return point; // in this case, zero is sucess,
  1089. // whereas cs_compare_datums returns 1 to indicate TRUE
  1090. // confusing, should fix this
  1091. }
  1092. // Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest
  1093. if (source.datum_type === PJD_NODATUM || dest.datum_type === PJD_NODATUM) {
  1094. return point;
  1095. }
  1096. //DGR: 2012-07-29 : add nadgrids support (begin)
  1097. var src_a = source.a;
  1098. var src_es = source.es;
  1099. var dst_a = dest.a;
  1100. var dst_es = dest.es;
  1101. var fallback = source.datum_type;
  1102. // If this datum requires grid shifts, then apply it to geodetic coordinates.
  1103. if (fallback === PJD_GRIDSHIFT) {
  1104. if (this.apply_gridshift(source, 0, point) === 0) {
  1105. source.a = SRS_WGS84_SEMIMAJOR;
  1106. source.es = SRS_WGS84_ESQUARED;
  1107. }
  1108. else {
  1109. // try 3 or 7 params transformation or nothing ?
  1110. if (!source.datum_params) {
  1111. source.a = src_a;
  1112. source.es = source.es;
  1113. return point;
  1114. }
  1115. wp = 1;
  1116. for (i = 0, l = source.datum_params.length; i < l; i++) {
  1117. wp *= source.datum_params[i];
  1118. }
  1119. if (wp === 0) {
  1120. source.a = src_a;
  1121. source.es = source.es;
  1122. return point;
  1123. }
  1124. if (source.datum_params.length > 3) {
  1125. fallback = PJD_7PARAM;
  1126. }
  1127. else {
  1128. fallback = PJD_3PARAM;
  1129. }
  1130. }
  1131. }
  1132. if (dest.datum_type === PJD_GRIDSHIFT) {
  1133. dest.a = SRS_WGS84_SEMIMAJOR;
  1134. dest.es = SRS_WGS84_ESQUARED;
  1135. }
  1136. // Do we need to go through geocentric coordinates?
  1137. if (source.es !== dest.es || source.a !== dest.a || checkParams(fallback) || checkParams(dest.datum_type)) {
  1138. //DGR: 2012-07-29 : add nadgrids support (end)
  1139. // Convert to geocentric coordinates.
  1140. source.geodetic_to_geocentric(point);
  1141. // CHECK_RETURN;
  1142. // Convert between datums
  1143. if (checkParams(source.datum_type)) {
  1144. source.geocentric_to_wgs84(point);
  1145. // CHECK_RETURN;
  1146. }
  1147. if (checkParams(dest.datum_type)) {
  1148. dest.geocentric_from_wgs84(point);
  1149. // CHECK_RETURN;
  1150. }
  1151. // Convert back to geodetic coordinates
  1152. dest.geocentric_to_geodetic(point);
  1153. // CHECK_RETURN;
  1154. }
  1155. // Apply grid shift to destination if required
  1156. if (dest.datum_type === PJD_GRIDSHIFT) {
  1157. this.apply_gridshift(dest, 1, point);
  1158. // CHECK_RETURN;
  1159. }
  1160. source.a = src_a;
  1161. source.es = src_es;
  1162. dest.a = dst_a;
  1163. dest.es = dst_es;
  1164. return point;
  1165. };
  1166. }, {}], 32: [function (_dereq_, module, exports) {
  1167. var globals = _dereq_('./global');
  1168. var parseProj = _dereq_('./projString');
  1169. var wkt = _dereq_('./wkt');
  1170. function defs(name) {
  1171. /*global console*/
  1172. var that = this;
  1173. if (arguments.length === 2) {
  1174. var def = arguments[1];
  1175. if (typeof def === 'string') {
  1176. if (def.charAt(0) === '+') {
  1177. defs[name] = parseProj(arguments[1]);
  1178. }
  1179. else {
  1180. defs[name] = wkt(arguments[1]);
  1181. }
  1182. } else {
  1183. defs[name] = def;
  1184. }
  1185. }
  1186. else if (arguments.length === 1) {
  1187. if (Array.isArray(name)) {
  1188. return name.map(function (v) {
  1189. if (Array.isArray(v)) {
  1190. defs.apply(that, v);
  1191. }
  1192. else {
  1193. defs(v);
  1194. }
  1195. });
  1196. }
  1197. else if (typeof name === 'string') {
  1198. if (name in defs) {
  1199. return defs[name];
  1200. }
  1201. }
  1202. else if ('EPSG' in name) {
  1203. defs['EPSG:' + name.EPSG] = name;
  1204. }
  1205. else if ('ESRI' in name) {
  1206. defs['ESRI:' + name.ESRI] = name;
  1207. }
  1208. else if ('IAU2000' in name) {
  1209. defs['IAU2000:' + name.IAU2000] = name;
  1210. }
  1211. else {
  1212. // console.log(name);
  1213. }
  1214. return;
  1215. }
  1216. }
  1217. globals(defs);
  1218. module.exports = defs;
  1219. }, { "./global": 35, "./projString": 38, "./wkt": 66 }], 33: [function (_dereq_, module, exports) {
  1220. var Datum = _dereq_('./constants/Datum');
  1221. var Ellipsoid = _dereq_('./constants/Ellipsoid');
  1222. var extend = _dereq_('./extend');
  1223. var datum = _dereq_('./datum');
  1224. var EPSLN = 1.0e-10;
  1225. // ellipoid pj_set_ell.c
  1226. var SIXTH = 0.1666666666666666667;
  1227. /* 1/6 */
  1228. var RA4 = 0.04722222222222222222;
  1229. /* 17/360 */
  1230. var RA6 = 0.02215608465608465608;
  1231. module.exports = function (json) {
  1232. // DGR 2011-03-20 : nagrids -> nadgrids
  1233. if (json.datumCode && json.datumCode !== 'none') {
  1234. var datumDef = Datum[json.datumCode];
  1235. if (datumDef) {
  1236. json.datum_params = datumDef.towgs84 ? datumDef.towgs84.split(',') : null;
  1237. json.ellps = datumDef.ellipse;
  1238. json.datumName = datumDef.datumName ? datumDef.datumName : json.datumCode;
  1239. }
  1240. }
  1241. if (!json.a) { // do we have an ellipsoid?
  1242. var ellipse = Ellipsoid[json.ellps] ? Ellipsoid[json.ellps] : Ellipsoid.WGS84;
  1243. extend(json, ellipse);
  1244. }
  1245. if (json.rf && !json.b) {
  1246. json.b = (1.0 - 1.0 / json.rf) * json.a;
  1247. }
  1248. if (json.rf === 0 || Math.abs(json.a - json.b) < EPSLN) {
  1249. json.sphere = true;
  1250. json.b = json.a;
  1251. }
  1252. json.a2 = json.a * json.a; // used in geocentric
  1253. json.b2 = json.b * json.b; // used in geocentric
  1254. json.es = (json.a2 - json.b2) / json.a2; // e ^ 2
  1255. json.e = Math.sqrt(json.es); // eccentricity
  1256. if (json.R_A) {
  1257. json.a *= 1 - json.es * (SIXTH + json.es * (RA4 + json.es * RA6));
  1258. json.a2 = json.a * json.a;
  1259. json.b2 = json.b * json.b;
  1260. json.es = 0;
  1261. }
  1262. json.ep2 = (json.a2 - json.b2) / json.b2; // used in geocentric
  1263. if (!json.k0) {
  1264. json.k0 = 1.0; //default value
  1265. }
  1266. //DGR 2010-11-12: axis
  1267. if (!json.axis) {
  1268. json.axis = "enu";
  1269. }
  1270. if (!json.datum) {
  1271. json.datum = datum(json);
  1272. }
  1273. return json;
  1274. };
  1275. }, { "./constants/Datum": 25, "./constants/Ellipsoid": 26, "./datum": 30, "./extend": 34 }], 34: [function (_dereq_, module, exports) {
  1276. module.exports = function (destination, source) {
  1277. destination = destination || {};
  1278. var value, property;
  1279. if (!source) {
  1280. return destination;
  1281. }
  1282. for (property in source) {
  1283. value = source[property];
  1284. if (value !== undefined) {
  1285. destination[property] = value;
  1286. }
  1287. }
  1288. return destination;
  1289. };
  1290. }, {}], 35: [function (_dereq_, module, exports) {
  1291. module.exports = function (defs) {
  1292. defs('EPSG:4326', "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
  1293. defs('EPSG:4269', "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees");
  1294. defs('EPSG:3857', "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
  1295. defs.WGS84 = defs['EPSG:4326'];
  1296. defs['EPSG:3785'] = defs['EPSG:3857']; // maintain backward compat, official code is 3857
  1297. defs.GOOGLE = defs['EPSG:3857'];
  1298. defs['EPSG:900913'] = defs['EPSG:3857'];
  1299. defs['EPSG:102113'] = defs['EPSG:3857'];
  1300. };
  1301. }, {}], 36: [function (_dereq_, module, exports) {
  1302. var proj4 = _dereq_('./core');
  1303. proj4.defaultDatum = 'WGS84'; //default datum
  1304. proj4.Proj = _dereq_('./Proj');
  1305. proj4.WGS84 = new proj4.Proj('WGS84');
  1306. proj4.Point = _dereq_('./Point');
  1307. proj4.toPoint = _dereq_("./common/toPoint");
  1308. proj4.defs = _dereq_('./defs');
  1309. proj4.transform = _dereq_('./transform');
  1310. proj4.mgrs = _dereq_('mgrs');
  1311. proj4.version = _dereq_('../package.json').version;
  1312. _dereq_('./includedProjections')(proj4);
  1313. module.exports = proj4;
  1314. }, { "../package.json": 68, "./Point": 1, "./Proj": 2, "./common/toPoint": 23, "./core": 29, "./defs": 32, "./includedProjections": "hTEDpn", "./transform": 65, "mgrs": 67 }], 37: [function (_dereq_, module, exports) {
  1315. var defs = _dereq_('./defs');
  1316. var wkt = _dereq_('./wkt');
  1317. var projStr = _dereq_('./projString');
  1318. function testObj(code) {
  1319. return typeof code === 'string';
  1320. }
  1321. function testDef(code) {
  1322. return code in defs;
  1323. }
  1324. function testWKT(code) {
  1325. var codeWords = ['GEOGCS', 'GEOCCS', 'PROJCS', 'LOCAL_CS'];
  1326. return codeWords.reduce(function (a, b) {
  1327. return a + 1 + code.indexOf(b);
  1328. }, 0);
  1329. }
  1330. function testProj(code) {
  1331. return code[0] === '+';
  1332. }
  1333. function parse(code) {
  1334. if (testObj(code)) {
  1335. //check to see if this is a WKT string
  1336. if (testDef(code)) {
  1337. return defs[code];
  1338. }
  1339. else if (testWKT(code)) {
  1340. return wkt(code);
  1341. }
  1342. else if (testProj(code)) {
  1343. return projStr(code);
  1344. }
  1345. } else {
  1346. return code;
  1347. }
  1348. }
  1349. module.exports = parse;
  1350. }, { "./defs": 32, "./projString": 38, "./wkt": 66 }], 38: [function (_dereq_, module, exports) {
  1351. var D2R = 0.01745329251994329577;
  1352. var PrimeMeridian = _dereq_('./constants/PrimeMeridian');
  1353. var units = _dereq_('./constants/units');
  1354. module.exports = function (defData) {
  1355. var self = {};
  1356. var paramObj = {};
  1357. defData.split("+").map(function (v) {
  1358. return v.trim();
  1359. }).filter(function (a) {
  1360. return a;
  1361. }).forEach(function (a) {
  1362. var split = a.split("=");
  1363. split.push(true);
  1364. paramObj[split[0].toLowerCase()] = split[1];
  1365. });
  1366. var paramName, paramVal, paramOutname;
  1367. var params = {
  1368. proj: 'projName',
  1369. datum: 'datumCode',
  1370. rf: function (v) {
  1371. self.rf = parseFloat(v);
  1372. },
  1373. lat_0: function (v) {
  1374. self.lat0 = v * D2R;
  1375. },
  1376. lat_1: function (v) {
  1377. self.lat1 = v * D2R;
  1378. },
  1379. lat_2: function (v) {
  1380. self.lat2 = v * D2R;
  1381. },
  1382. lat_ts: function (v) {
  1383. self.lat_ts = v * D2R;
  1384. },
  1385. lon_0: function (v) {
  1386. self.long0 = v * D2R;
  1387. },
  1388. lon_1: function (v) {
  1389. self.long1 = v * D2R;
  1390. },
  1391. lon_2: function (v) {
  1392. self.long2 = v * D2R;
  1393. },
  1394. alpha: function (v) {
  1395. self.alpha = parseFloat(v) * D2R;
  1396. },
  1397. lonc: function (v) {
  1398. self.longc = v * D2R;
  1399. },
  1400. x_0: function (v) {
  1401. self.x0 = parseFloat(v);
  1402. },
  1403. y_0: function (v) {
  1404. self.y0 = parseFloat(v);
  1405. },
  1406. k_0: function (v) {
  1407. self.k0 = parseFloat(v);
  1408. },
  1409. k: function (v) {
  1410. self.k0 = parseFloat(v);
  1411. },
  1412. a: function (v) {
  1413. self.a = parseFloat(v);
  1414. },
  1415. b: function (v) {
  1416. self.b = parseFloat(v);
  1417. },
  1418. r_a: function () {
  1419. self.R_A = true;
  1420. },
  1421. zone: function (v) {
  1422. self.zone = parseInt(v, 10);
  1423. },
  1424. south: function () {
  1425. self.utmSouth = true;
  1426. },
  1427. towgs84: function (v) {
  1428. self.datum_params = v.split(",").map(function (a) {
  1429. return parseFloat(a);
  1430. });
  1431. },
  1432. to_meter: function (v) {
  1433. self.to_meter = parseFloat(v);
  1434. },
  1435. units: function (v) {
  1436. self.units = v;
  1437. if (units[v]) {
  1438. self.to_meter = units[v].to_meter;
  1439. }
  1440. },
  1441. from_greenwich: function (v) {
  1442. self.from_greenwich = v * D2R;
  1443. },
  1444. pm: function (v) {
  1445. self.from_greenwich = (PrimeMeridian[v] ? PrimeMeridian[v] : parseFloat(v)) * D2R;
  1446. },
  1447. nadgrids: function (v) {
  1448. if (v === '@null') {
  1449. self.datumCode = 'none';
  1450. }
  1451. else {
  1452. self.nadgrids = v;
  1453. }
  1454. },
  1455. axis: function (v) {
  1456. var legalAxis = "ewnsud";
  1457. if (v.length === 3 && legalAxis.indexOf(v.substr(0, 1)) !== -1 && legalAxis.indexOf(v.substr(1, 1)) !== -1 && legalAxis.indexOf(v.substr(2, 1)) !== -1) {
  1458. self.axis = v;
  1459. }
  1460. }
  1461. };
  1462. for (paramName in paramObj) {
  1463. paramVal = paramObj[paramName];
  1464. if (paramName in params) {
  1465. paramOutname = params[paramName];
  1466. if (typeof paramOutname === 'function') {
  1467. paramOutname(paramVal);
  1468. }
  1469. else {
  1470. self[paramOutname] = paramVal;
  1471. }
  1472. }
  1473. else {
  1474. self[paramName] = paramVal;
  1475. }
  1476. }
  1477. if (typeof self.datumCode === 'string' && self.datumCode !== "WGS84") {
  1478. self.datumCode = self.datumCode.toLowerCase();
  1479. }
  1480. return self;
  1481. };
  1482. }, { "./constants/PrimeMeridian": 27, "./constants/units": 28 }], 39: [function (_dereq_, module, exports) {
  1483. var projs = [
  1484. _dereq_('./projections/merc'),
  1485. _dereq_('./projections/longlat')
  1486. ];
  1487. var names = {};
  1488. var projStore = [];
  1489. function add(proj, i) {
  1490. var len = projStore.length;
  1491. if (!proj.names) {
  1492. // console.log(i);
  1493. return true;
  1494. }
  1495. projStore[len] = proj;
  1496. proj.names.forEach(function (n) {
  1497. names[n.toLowerCase()] = len;
  1498. });
  1499. return this;
  1500. }
  1501. exports.add = add;
  1502. exports.get = function (name) {
  1503. if (!name) {
  1504. return false;
  1505. }
  1506. var n = name.toLowerCase();
  1507. if (typeof names[n] !== 'undefined' && projStore[names[n]]) {
  1508. return projStore[names[n]];
  1509. }
  1510. };
  1511. exports.start = function () {
  1512. projs.forEach(add);
  1513. };
  1514. }, { "./projections/longlat": 51, "./projections/merc": 52 }], 40: [function (_dereq_, module, exports) {
  1515. var EPSLN = 1.0e-10;
  1516. var msfnz = _dereq_('../common/msfnz');
  1517. var qsfnz = _dereq_('../common/qsfnz');
  1518. var adjust_lon = _dereq_('../common/adjust_lon');
  1519. var asinz = _dereq_('../common/asinz');
  1520. exports.init = function () {
  1521. if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
  1522. return;
  1523. }
  1524. this.temp = this.b / this.a;
  1525. this.es = 1 - Math.pow(this.temp, 2);
  1526. this.e3 = Math.sqrt(this.es);
  1527. this.sin_po = Math.sin(this.lat1);
  1528. this.cos_po = Math.cos(this.lat1);
  1529. this.t1 = this.sin_po;
  1530. this.con = this.sin_po;
  1531. this.ms1 = msfnz(this.e3, this.sin_po, this.cos_po);
  1532. this.qs1 = qsfnz(this.e3, this.sin_po, this.cos_po);
  1533. this.sin_po = Math.sin(this.lat2);
  1534. this.cos_po = Math.cos(this.lat2);
  1535. this.t2 = this.sin_po;
  1536. this.ms2 = msfnz(this.e3, this.sin_po, this.cos_po);
  1537. this.qs2 = qsfnz(this.e3, this.sin_po, this.cos_po);
  1538. this.sin_po = Math.sin(this.lat0);
  1539. this.cos_po = Math.cos(this.lat0);
  1540. this.t3 = this.sin_po;
  1541. this.qs0 = qsfnz(this.e3, this.sin_po, this.cos_po);
  1542. if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
  1543. this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1);
  1544. }
  1545. else {
  1546. this.ns0 = this.con;
  1547. }
  1548. this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;
  1549. this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0;
  1550. };
  1551. /* Albers Conical Equal Area forward equations--mapping lat,long to x,y
  1552. -------------------------------------------------------------------*/
  1553. exports.forward = function (p) {
  1554. var lon = p.x;
  1555. var lat = p.y;
  1556. this.sin_phi = Math.sin(lat);
  1557. this.cos_phi = Math.cos(lat);
  1558. var qs = qsfnz(this.e3, this.sin_phi, this.cos_phi);
  1559. var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0;
  1560. var theta = this.ns0 * adjust_lon(lon - this.long0);
  1561. var x = rh1 * Math.sin(theta) + this.x0;
  1562. var y = this.rh - rh1 * Math.cos(theta) + this.y0;
  1563. p.x = x;
  1564. p.y = y;
  1565. return p;
  1566. };
  1567. exports.inverse = function (p) {
  1568. var rh1, qs, con, theta, lon, lat;
  1569. p.x -= this.x0;
  1570. p.y = this.rh - p.y + this.y0;
  1571. if (this.ns0 >= 0) {
  1572. rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
  1573. con = 1;
  1574. }
  1575. else {
  1576. rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
  1577. con = -1;
  1578. }
  1579. theta = 0;
  1580. if (rh1 !== 0) {
  1581. theta = Math.atan2(con * p.x, con * p.y);
  1582. }
  1583. con = rh1 * this.ns0 / this.a;
  1584. if (this.sphere) {
  1585. lat = Math.asin((this.c - con * con) / (2 * this.ns0));
  1586. }
  1587. else {
  1588. qs = (this.c - con * con) / this.ns0;
  1589. lat = this.phi1z(this.e3, qs);
  1590. }
  1591. lon = adjust_lon(theta / this.ns0 + this.long0);
  1592. p.x = lon;
  1593. p.y = lat;
  1594. return p;
  1595. };
  1596. /* Function to compute phi1, the latitude for the inverse of the
  1597. Albers Conical Equal-Area projection.
  1598. -------------------------------------------*/
  1599. exports.phi1z = function (eccent, qs) {
  1600. var sinphi, cosphi, con, com, dphi;
  1601. var phi = asinz(0.5 * qs);
  1602. if (eccent < EPSLN) {
  1603. return phi;
  1604. }
  1605. var eccnts = eccent * eccent;
  1606. for (var i = 1; i <= 25; i++) {
  1607. sinphi = Math.sin(phi);
  1608. cosphi = Math.cos(phi);
  1609. con = eccent * sinphi;
  1610. com = 1 - con * con;
  1611. dphi = 0.5 * com * com / cosphi * (qs / (1 - eccnts) - sinphi / com + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
  1612. phi = phi + dphi;
  1613. if (Math.abs(dphi) <= 1e-7) {
  1614. return phi;
  1615. }
  1616. }
  1617. return null;
  1618. };
  1619. exports.names = ["Albers_Conic_Equal_Area", "Albers", "aea"];
  1620. }, { "../common/adjust_lon": 5, "../common/asinz": 6, "../common/msfnz": 15, "../common/qsfnz": 20 }], 41: [function (_dereq_, module, exports) {
  1621. var adjust_lon = _dereq_('../common/adjust_lon');
  1622. var HALF_PI = Math.PI / 2;
  1623. var EPSLN = 1.0e-10;
  1624. var mlfn = _dereq_('../common/mlfn');
  1625. var e0fn = _dereq_('../common/e0fn');
  1626. var e1fn = _dereq_('../common/e1fn');
  1627. var e2fn = _dereq_('../common/e2fn');
  1628. var e3fn = _dereq_('../common/e3fn');
  1629. var gN = _dereq_('../common/gN');
  1630. var asinz = _dereq_('../common/asinz');
  1631. var imlfn = _dereq_('../common/imlfn');
  1632. exports.init = function () {
  1633. this.sin_p12 = Math.sin(this.lat0);
  1634. this.cos_p12 = Math.cos(this.lat0);
  1635. };
  1636. exports.forward = function (p) {
  1637. var lon = p.x;
  1638. var lat = p.y;
  1639. var sinphi = Math.sin(p.y);
  1640. var cosphi = Math.cos(p.y);
  1641. var dlon = adjust_lon(lon - this.long0);
  1642. var e0, e1, e2, e3, Mlp, Ml, tanphi, Nl1, Nl, psi, Az, G, H, GH, Hs, c, kp, cos_c, s, s2, s3, s4, s5;
  1643. if (this.sphere) {
  1644. if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
  1645. //North Pole case
  1646. p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon);
  1647. p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon);
  1648. return p;
  1649. }
  1650. else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
  1651. //South Pole case
  1652. p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon);
  1653. p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon);
  1654. return p;
  1655. }
  1656. else {
  1657. //default case
  1658. cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon);
  1659. c = Math.acos(cos_c);
  1660. kp = c / Math.sin(c);
  1661. p.x = this.x0 + this.a * kp * cosphi * Math.sin(dlon);
  1662. p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon));
  1663. return p;
  1664. }
  1665. }
  1666. else {
  1667. e0 = e0fn(this.es);
  1668. e1 = e1fn(this.es);
  1669. e2 = e2fn(this.es);
  1670. e3 = e3fn(this.es);
  1671. if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
  1672. //North Pole case
  1673. Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
  1674. Ml = this.a * mlfn(e0, e1, e2, e3, lat);
  1675. p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon);
  1676. p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon);
  1677. return p;
  1678. }
  1679. else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
  1680. //South Pole case
  1681. Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
  1682. Ml = this.a * mlfn(e0, e1, e2, e3, lat);
  1683. p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon);
  1684. p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon);
  1685. return p;
  1686. }
  1687. else {
  1688. //Default case
  1689. tanphi = sinphi / cosphi;
  1690. Nl1 = gN(this.a, this.e, this.sin_p12);
  1691. Nl = gN(this.a, this.e, sinphi);
  1692. psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi));
  1693. Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon));
  1694. if (Az === 0) {
  1695. s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
  1696. }
  1697. else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) {
  1698. s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
  1699. }
  1700. else {
  1701. s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az));
  1702. }
  1703. G = this.e * this.sin_p12 / Math.sqrt(1 - this.es);
  1704. H = this.e * this.cos_p12 * Math.cos(Az) / Math.sqrt(1 - this.es);
  1705. GH = G * H;
  1706. Hs = H * H;
  1707. s2 = s * s;
  1708. s3 = s2 * s;
  1709. s4 = s3 * s;
  1710. s5 = s4 * s;
  1711. c = Nl1 * s * (1 - s2 * Hs * (1 - Hs) / 6 + s3 / 8 * GH * (1 - 2 * Hs) + s4 / 120 * (Hs * (4 - 7 * Hs) - 3 * G * G * (1 - 7 * Hs)) - s5 / 48 * GH);
  1712. p.x = this.x0 + c * Math.sin(Az);
  1713. p.y = this.y0 + c * Math.cos(Az);
  1714. return p;
  1715. }
  1716. }
  1717. };
  1718. exports.inverse = function (p) {
  1719. p.x -= this.x0;
  1720. p.y -= this.y0;
  1721. var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, N1, psi, Az, cosAz, tmp, A, B, D, Ee, F;
  1722. if (this.sphere) {
  1723. rh = Math.sqrt(p.x * p.x + p.y * p.y);
  1724. if (rh > (2 * HALF_PI * this.a)) {
  1725. return;
  1726. }
  1727. z = rh / this.a;
  1728. sinz = Math.sin(z);
  1729. cosz = Math.cos(z);
  1730. lon = this.long0;
  1731. if (Math.abs(rh) <= EPSLN) {
  1732. lat = this.lat0;
  1733. }
  1734. else {
  1735. lat = asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh);
  1736. con = Math.abs(this.lat0) - HALF_PI;
  1737. if (Math.abs(con) <= EPSLN) {
  1738. if (this.lat0 >= 0) {
  1739. lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));
  1740. }
  1741. else {
  1742. lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
  1743. }
  1744. }
  1745. else {
  1746. /*con = cosz - this.sin_p12 * Math.sin(lat);
  1747. if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
  1748. //no-op, just keep the lon value as is
  1749. } else {
  1750. var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
  1751. lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
  1752. }*/
  1753. lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
  1754. }
  1755. }
  1756. p.x = lon;
  1757. p.y = lat;
  1758. return p;
  1759. }
  1760. else {
  1761. e0 = e0fn(this.es);
  1762. e1 = e1fn(this.es);
  1763. e2 = e2fn(this.es);
  1764. e3 = e3fn(this.es);
  1765. if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
  1766. //North pole case
  1767. Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
  1768. rh = Math.sqrt(p.x * p.x + p.y * p.y);
  1769. M = Mlp - rh;
  1770. lat = imlfn(M / this.a, e0, e1, e2, e3);
  1771. lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));
  1772. p.x = lon;
  1773. p.y = lat;
  1774. return p;
  1775. }
  1776. else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
  1777. //South pole case
  1778. Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
  1779. rh = Math.sqrt(p.x * p.x + p.y * p.y);
  1780. M = rh - Mlp;
  1781. lat = imlfn(M / this.a, e0, e1, e2, e3);
  1782. lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
  1783. p.x = lon;
  1784. p.y = lat;
  1785. return p;
  1786. }
  1787. else {
  1788. //default case
  1789. rh = Math.sqrt(p.x * p.x + p.y * p.y);
  1790. Az = Math.atan2(p.x, p.y);
  1791. N1 = gN(this.a, this.e, this.sin_p12);
  1792. cosAz = Math.cos(Az);
  1793. tmp = this.e * this.cos_p12 * cosAz;
  1794. A = -tmp * tmp / (1 - this.es);
  1795. B = 3 * this.es * (1 - A) * this.sin_p12 * this.cos_p12 * cosAz / (1 - this.es);
  1796. D = rh / N1;
  1797. Ee = D - A * (1 + A) * Math.pow(D, 3) / 6 - B * (1 + 3 * A) * Math.pow(D, 4) / 24;
  1798. F = 1 - A * Ee * Ee / 2 - D * Ee * Ee * Ee / 6;
  1799. psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz);
  1800. lon = adjust_lon(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi)));
  1801. lat = Math.atan((1 - this.es * F * this.sin_p12 / Math.sin(psi)) * Math.tan(psi) / (1 - this.es));
  1802. p.x = lon;
  1803. p.y = lat;
  1804. return p;
  1805. }
  1806. }
  1807. };
  1808. exports.names = ["Azimuthal_Equidistant", "aeqd"];
  1809. }, { "../common/adjust_lon": 5, "../common/asinz": 6, "../common/e0fn": 7, "../common/e1fn": 8, "../common/e2fn": 9, "../common/e3fn": 10, "../common/gN": 11, "../common/imlfn": 12, "../common/mlfn": 14 }], 42: [function (_dereq_, module, exports) {
  1810. var mlfn = _dereq_('../common/mlfn');
  1811. var e0fn = _dereq_('../common/e0fn');
  1812. var e1fn = _dereq_('../common/e1fn');
  1813. var e2fn = _dereq_('../common/e2fn');
  1814. var e3fn = _dereq_('../common/e3fn');
  1815. var gN = _dereq_('../common/gN');
  1816. var adjust_lon = _dereq_('../common/adjust_lon');
  1817. var adjust_lat = _dereq_('../common/adjust_lat');
  1818. var imlfn = _dereq_('../common/imlfn');
  1819. var HALF_PI = Math.PI / 2;
  1820. var EPSLN = 1.0e-10;
  1821. exports.init = function () {
  1822. if (!this.sphere) {
  1823. this.e0 = e0fn(this.es);
  1824. this.e1 = e1fn(this.es);
  1825. this.e2 = e2fn(this.es);
  1826. this.e3 = e3fn(this.es);
  1827. this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
  1828. }
  1829. };
  1830. /* Cassini forward equations--mapping lat,long to x,y
  1831. -----------------------------------------------------------------------*/
  1832. exports.forward = function (p) {
  1833. /* Forward equations
  1834. -----------------*/
  1835. var x, y;
  1836. var lam = p.x;
  1837. var phi = p.y;
  1838. lam = adjust_lon(lam - this.long0);
  1839. if (this.sphere) {
  1840. x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));
  1841. y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);
  1842. }
  1843. else {
  1844. //ellipsoid
  1845. var sinphi = Math.sin(phi);
  1846. var cosphi = Math.cos(phi);
  1847. var nl = gN(this.a, this.e, sinphi);
  1848. var tl = Math.tan(phi) * Math.tan(phi);
  1849. var al = lam * Math.cos(phi);
  1850. var asq = al * al;
  1851. var cl = this.es * cosphi * cosphi / (1 - this.es);
  1852. var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
  1853. x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));
  1854. y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);
  1855. }
  1856. p.x = x + this.x0;
  1857. p.y = y + this.y0;
  1858. return p;
  1859. };
  1860. /* Inverse equations
  1861. -----------------*/
  1862. exports.inverse = function (p) {
  1863. p.x -= this.x0;
  1864. p.y -= this.y0;
  1865. var x = p.x / this.a;
  1866. var y = p.y / this.a;
  1867. var phi, lam;
  1868. if (this.sphere) {
  1869. var dd = y + this.lat0;
  1870. phi = Math.asin(Math.sin(dd) * Math.cos(x));
  1871. lam = Math.atan2(Math.tan(x), Math.cos(dd));
  1872. }
  1873. else {
  1874. /* ellipsoid */
  1875. var ml1 = this.ml0 / this.a + y;
  1876. var phi1 = imlfn(ml1, this.e0, this.e1, this.e2, this.e3);
  1877. if (Math.abs(Math.abs(phi1) - HALF_PI) <= EPSLN) {
  1878. p.x = this.long0;
  1879. p.y = HALF_PI;
  1880. if (y < 0) {
  1881. p.y *= -1;
  1882. }
  1883. return p;
  1884. }
  1885. var nl1 = gN(this.a, this.e, Math.sin(phi1));
  1886. var rl1 = nl1 * nl1 * nl1 / this.a / this.a * (1 - this.es);
  1887. var tl1 = Math.pow(Math.tan(phi1), 2);
  1888. var dl = x * this.a / nl1;
  1889. var dsq = dl * dl;
  1890. phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24);
  1891. lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1);
  1892. }
  1893. p.x = adjust_lon(lam + this.long0);
  1894. p.y = adjust_lat(phi);
  1895. return p;
  1896. };
  1897. exports.names = ["Cassini", "Cassini_Soldner", "cass"];
  1898. }, { "../common/adjust_lat": 4, "../common/adjust_lon": 5, "../common/e0fn": 7, "../common/e1fn": 8, "../common/e2fn": 9, "../common/e3fn": 10, "../common/gN": 11, "../common/imlfn": 12, "../common/mlfn": 14 }], 43: [function (_dereq_, module, exports) {
  1899. var adjust_lon = _dereq_('../common/adjust_lon');
  1900. var qsfnz = _dereq_('../common/qsfnz');
  1901. var msfnz = _dereq_('../common/msfnz');
  1902. var iqsfnz = _dereq_('../common/iqsfnz');
  1903. /*
  1904. reference:
  1905. "Cartographic Projection Procedures for the UNIX Environment-
  1906. A User's Manual" by Gerald I. Evenden,
  1907. USGS Open File Report 90-284and Release 4 Interim Reports (2003)
  1908. */
  1909. exports.init = function () {
  1910. //no-op
  1911. if (!this.sphere) {
  1912. this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
  1913. }
  1914. };
  1915. /* Cylindrical Equal Area forward equations--mapping lat,long to x,y
  1916. ------------------------------------------------------------*/
  1917. exports.forward = function (p) {
  1918. var lon = p.x;
  1919. var lat = p.y;
  1920. var x, y;
  1921. /* Forward equations
  1922. -----------------*/
  1923. var dlon = adjust_lon(lon - this.long0);
  1924. if (this.sphere) {
  1925. x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
  1926. y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
  1927. }
  1928. else {
  1929. var qs = qsfnz(this.e, Math.sin(lat));
  1930. x = this.x0 + this.a * this.k0 * dlon;
  1931. y = this.y0 + this.a * qs * 0.5 / this.k0;
  1932. }
  1933. p.x = x;
  1934. p.y = y;
  1935. return p;
  1936. };
  1937. /* Cylindrical Equal Area inverse equations--mapping x,y to lat/long
  1938. ------------------------------------------------------------*/
  1939. exports.inverse = function (p) {
  1940. p.x -= this.x0;
  1941. p.y -= this.y0;
  1942. var lon, lat;
  1943. if (this.sphere) {
  1944. lon = adjust_lon(this.long0 + (p.x / this.a) / Math.cos(this.lat_ts));
  1945. lat = Math.asin((p.y / this.a) * Math.cos(this.lat_ts));
  1946. }
  1947. else {
  1948. lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);
  1949. lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));
  1950. }
  1951. p.x = lon;
  1952. p.y = lat;
  1953. return p;
  1954. };
  1955. exports.names = ["cea"];
  1956. }, { "../common/adjust_lon": 5, "../common/iqsfnz": 13, "../common/msfnz": 15, "../common/qsfnz": 20 }], 44: [function (_dereq_, module, exports) {
  1957. var adjust_lon = _dereq_('../common/adjust_lon');
  1958. var adjust_lat = _dereq_('../common/adjust_lat');
  1959. exports.init = function () {
  1960. this.x0 = this.x0 || 0;
  1961. this.y0 = this.y0 || 0;
  1962. this.lat0 = this.lat0 || 0;
  1963. this.long0 = this.long0 || 0;
  1964. this.lat_ts = this.lat_ts || 0;
  1965. this.title = this.title || "Equidistant Cylindrical (Plate Carre)";
  1966. this.rc = Math.cos(this.lat_ts);
  1967. };
  1968. // forward equations--mapping lat,long to x,y
  1969. // -----------------------------------------------------------------
  1970. exports.forward = function (p) {
  1971. var lon = p.x;
  1972. var lat = p.y;
  1973. var dlon = adjust_lon(lon - this.long0);
  1974. var dlat = adjust_lat(lat - this.lat0);
  1975. p.x = this.x0 + (this.a * dlon * this.rc);
  1976. p.y = this.y0 + (this.a * dlat);
  1977. return p;
  1978. };
  1979. // inverse equations--mapping x,y to lat/long
  1980. // -----------------------------------------------------------------
  1981. exports.inverse = function (p) {
  1982. var x = p.x;
  1983. var y = p.y;
  1984. p.x = adjust_lon(this.long0 + ((x - this.x0) / (this.a * this.rc)));
  1985. p.y = adjust_lat(this.lat0 + ((y - this.y0) / (this.a)));
  1986. return p;
  1987. };
  1988. exports.names = ["Equirectangular", "Equidistant_Cylindrical", "eqc"];
  1989. }, { "../common/adjust_lat": 4, "../common/adjust_lon": 5 }], 45: [function (_dereq_, module, exports) {
  1990. var e0fn = _dereq_('../common/e0fn');
  1991. var e1fn = _dereq_('../common/e1fn');
  1992. var e2fn = _dereq_('../common/e2fn');
  1993. var e3fn = _dereq_('../common/e3fn');
  1994. var msfnz = _dereq_('../common/msfnz');
  1995. var mlfn = _dereq_('../common/mlfn');
  1996. var adjust_lon = _dereq_('../common/adjust_lon');
  1997. var adjust_lat = _dereq_('../common/adjust_lat');
  1998. var imlfn = _dereq_('../common/imlfn');
  1999. var EPSLN = 1.0e-10;
  2000. exports.init = function () {
  2001. /* Place parameters in static storage for common use
  2002. -------------------------------------------------*/
  2003. // Standard Parallels cannot be equal and on opposite sides of the equator
  2004. if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
  2005. return;
  2006. }
  2007. this.lat2 = this.lat2 || this.lat1;
  2008. this.temp = this.b / this.a;
  2009. this.es = 1 - Math.pow(this.temp, 2);
  2010. this.e = Math.sqrt(this.es);
  2011. this.e0 = e0fn(this.es);
  2012. this.e1 = e1fn(this.es);
  2013. this.e2 = e2fn(this.es);
  2014. this.e3 = e3fn(this.es);
  2015. this.sinphi = Math.sin(this.lat1);
  2016. this.cosphi = Math.cos(this.lat1);
  2017. this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);
  2018. this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
  2019. if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
  2020. this.ns = this.sinphi;
  2021. }
  2022. else {
  2023. this.sinphi = Math.sin(this.lat2);
  2024. this.cosphi = Math.cos(this.lat2);
  2025. this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);
  2026. this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
  2027. this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
  2028. }
  2029. this.g = this.ml1 + this.ms1 / this.ns;
  2030. this.ml0 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
  2031. this.rh = this.a * (this.g - this.ml0);
  2032. };
  2033. /* Equidistant Conic forward equations--mapping lat,long to x,y
  2034. -----------------------------------------------------------*/
  2035. exports.forward = function (p) {
  2036. var lon = p.x;
  2037. var lat = p.y;
  2038. var rh1;
  2039. /* Forward equations
  2040. -----------------*/
  2041. if (this.sphere) {
  2042. rh1 = this.a * (this.g - lat);
  2043. }
  2044. else {
  2045. var ml = mlfn(this.e0, this.e1, this.e2, this.e3, lat);
  2046. rh1 = this.a * (this.g - ml);
  2047. }
  2048. var theta = this.ns * adjust_lon(lon - this.long0);
  2049. var x = this.x0 + rh1 * Math.sin(theta);
  2050. var y = this.y0 + this.rh - rh1 * Math.cos(theta);
  2051. p.x = x;
  2052. p.y = y;
  2053. return p;
  2054. };
  2055. /* Inverse equations
  2056. -----------------*/
  2057. exports.inverse = function (p) {
  2058. p.x -= this.x0;
  2059. p.y = this.rh - p.y + this.y0;
  2060. var con, rh1, lat, lon;
  2061. if (this.ns >= 0) {
  2062. rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
  2063. con = 1;
  2064. }
  2065. else {
  2066. rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
  2067. con = -1;
  2068. }
  2069. var theta = 0;
  2070. if (rh1 !== 0) {
  2071. theta = Math.atan2(con * p.x, con * p.y);
  2072. }
  2073. if (this.sphere) {
  2074. lon = adjust_lon(this.long0 + theta / this.ns);
  2075. lat = adjust_lat(this.g - rh1 / this.a);
  2076. p.x = lon;
  2077. p.y = lat;
  2078. return p;
  2079. }
  2080. else {
  2081. var ml = this.g - rh1 / this.a;
  2082. lat = imlfn(ml, this.e0, this.e1, this.e2, this.e3);
  2083. lon = adjust_lon(this.long0 + theta / this.ns);
  2084. p.x = lon;
  2085. p.y = lat;
  2086. return p;
  2087. }
  2088. };
  2089. exports.names = ["Equidistant_Conic", "eqdc"];
  2090. }, { "../common/adjust_lat": 4, "../common/adjust_lon": 5, "../common/e0fn": 7, "../common/e1fn": 8, "../common/e2fn": 9, "../common/e3fn": 10, "../common/imlfn": 12, "../common/mlfn": 14, "../common/msfnz": 15 }], 46: [function (_dereq_, module, exports) {
  2091. var FORTPI = Math.PI / 4;
  2092. var srat = _dereq_('../common/srat');
  2093. var HALF_PI = Math.PI / 2;
  2094. var MAX_ITER = 20;
  2095. exports.init = function () {
  2096. var sphi = Math.sin(this.lat0);
  2097. var cphi = Math.cos(this.lat0);
  2098. cphi *= cphi;
  2099. this.rc = Math.sqrt(1 - this.es) / (1 - this.es * sphi * sphi);
  2100. this.C = Math.sqrt(1 + this.es * cphi * cphi / (1 - this.es));
  2101. this.phic0 = Math.asin(sphi / this.C);
  2102. this.ratexp = 0.5 * this.C * this.e;
  2103. this.K = Math.tan(0.5 * this.phic0 + FORTPI) / (Math.pow(Math.tan(0.5 * this.lat0 + FORTPI), this.C) * srat(this.e * sphi, this.ratexp));
  2104. };
  2105. exports.forward = function (p) {
  2106. var lon = p.x;
  2107. var lat = p.y;
  2108. p.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * lat + FORTPI), this.C) * srat(this.e * Math.sin(lat), this.ratexp)) - HALF_PI;
  2109. p.x = this.C * lon;
  2110. return p;
  2111. };
  2112. exports.inverse = function (p) {
  2113. var DEL_TOL = 1e-14;
  2114. var lon = p.x / this.C;
  2115. var lat = p.y;
  2116. var num = Math.pow(Math.tan(0.5 * lat + FORTPI) / this.K, 1 / this.C);
  2117. for (var i = MAX_ITER; i > 0; --i) {
  2118. lat = 2 * Math.atan(num * srat(this.e * Math.sin(p.y), - 0.5 * this.e)) - HALF_PI;
  2119. if (Math.abs(lat - p.y) < DEL_TOL) {
  2120. break;
  2121. }
  2122. p.y = lat;
  2123. }
  2124. /* convergence failed */
  2125. if (!i) {
  2126. return null;
  2127. }
  2128. p.x = lon;
  2129. p.y = lat;
  2130. return p;
  2131. };
  2132. exports.names = ["gauss"];
  2133. }, { "../common/srat": 22 }], 47: [function (_dereq_, module, exports) {
  2134. var adjust_lon = _dereq_('../common/adjust_lon');
  2135. var EPSLN = 1.0e-10;
  2136. var asinz = _dereq_('../common/asinz');
  2137. /*
  2138. reference:
  2139. Wolfram Mathworld "Gnomonic Projection"
  2140. http://mathworld.wolfram.com/GnomonicProjection.html
  2141. Accessed: 12th November 2009
  2142. */
  2143. exports.init = function () {
  2144. /* Place parameters in static storage for common use
  2145. -------------------------------------------------*/
  2146. this.sin_p14 = Math.sin(this.lat0);
  2147. this.cos_p14 = Math.cos(this.lat0);
  2148. // Approximation for projecting points to the horizon (infinity)
  2149. this.infinity_dist = 1000 * this.a;
  2150. this.rc = 1;
  2151. };
  2152. /* Gnomonic forward equations--mapping lat,long to x,y
  2153. ---------------------------------------------------*/
  2154. exports.forward = function (p) {
  2155. var sinphi, cosphi; /* sin and cos value */
  2156. var dlon; /* delta longitude value */
  2157. var coslon; /* cos of longitude */
  2158. var ksp; /* scale factor */
  2159. var g;
  2160. var x, y;
  2161. var lon = p.x;
  2162. var lat = p.y;
  2163. /* Forward equations
  2164. -----------------*/
  2165. dlon = adjust_lon(lon - this.long0);
  2166. sinphi = Math.sin(lat);
  2167. cosphi = Math.cos(lat);
  2168. coslon = Math.cos(dlon);
  2169. g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;
  2170. ksp = 1;
  2171. if ((g > 0) || (Math.abs(g) <= EPSLN)) {
  2172. x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon) / g;
  2173. y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon) / g;
  2174. }
  2175. else {
  2176. // Point is in the opposing hemisphere and is unprojectable
  2177. // We still need to return a reasonable point, so we project
  2178. // to infinity, on a bearing
  2179. // equivalent to the northern hemisphere equivalent
  2180. // This is a reasonable approximation for short shapes and lines that
  2181. // straddle the horizon.
  2182. x = this.x0 + this.infinity_dist * cosphi * Math.sin(dlon);
  2183. y = this.y0 + this.infinity_dist * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
  2184. }
  2185. p.x = x;
  2186. p.y = y;
  2187. return p;
  2188. };
  2189. exports.inverse = function (p) {
  2190. var rh; /* Rho */
  2191. var sinc, cosc;
  2192. var c;
  2193. var lon, lat;
  2194. /* Inverse equations
  2195. -----------------*/
  2196. p.x = (p.x - this.x0) / this.a;
  2197. p.y = (p.y - this.y0) / this.a;
  2198. p.x /= this.k0;
  2199. p.y /= this.k0;
  2200. if ((rh = Math.sqrt(p.x * p.x + p.y * p.y))) {
  2201. c = Math.atan2(rh, this.rc);
  2202. sinc = Math.sin(c);
  2203. cosc = Math.cos(c);
  2204. lat = asinz(cosc * this.sin_p14 + (p.y * sinc * this.cos_p14) / rh);
  2205. lon = Math.atan2(p.x * sinc, rh * this.cos_p14 * cosc - p.y * this.sin_p14 * sinc);
  2206. lon = adjust_lon(this.long0 + lon);
  2207. }
  2208. else {
  2209. lat = this.phic0;
  2210. lon = 0;
  2211. }
  2212. p.x = lon;
  2213. p.y = lat;
  2214. return p;
  2215. };
  2216. exports.names = ["gnom"];
  2217. }, { "../common/adjust_lon": 5, "../common/asinz": 6 }], 48: [function (_dereq_, module, exports) {
  2218. var adjust_lon = _dereq_('../common/adjust_lon');
  2219. exports.init = function () {
  2220. this.a = 6377397.155;
  2221. this.es = 0.006674372230614;
  2222. this.e = Math.sqrt(this.es);
  2223. if (!this.lat0) {
  2224. this.lat0 = 0.863937979737193;
  2225. }
  2226. if (!this.long0) {
  2227. this.long0 = 0.7417649320975901 - 0.308341501185665;
  2228. }
  2229. /* if scale not set default to 0.9999 */
  2230. if (!this.k0) {
  2231. this.k0 = 0.9999;
  2232. }
  2233. this.s45 = 0.785398163397448; /* 45 */
  2234. this.s90 = 2 * this.s45;
  2235. this.fi0 = this.lat0;
  2236. this.e2 = this.es;
  2237. this.e = Math.sqrt(this.e2);
  2238. this.alfa = Math.sqrt(1 + (this.e2 * Math.pow(Math.cos(this.fi0), 4)) / (1 - this.e2));
  2239. this.uq = 1.04216856380474;
  2240. this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa);
  2241. this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2);
  2242. this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g;
  2243. this.k1 = this.k0;
  2244. this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2));
  2245. this.s0 = 1.37008346281555;
  2246. this.n = Math.sin(this.s0);
  2247. this.ro0 = this.k1 * this.n0 / Math.tan(this.s0);
  2248. this.ad = this.s90 - this.uq;
  2249. };
  2250. /* ellipsoid */
  2251. /* calculate xy from lat/lon */
  2252. /* Constants, identical to inverse transform function */
  2253. exports.forward = function (p) {
  2254. var gfi, u, deltav, s, d, eps, ro;
  2255. var lon = p.x;
  2256. var lat = p.y;
  2257. var delta_lon = adjust_lon(lon - this.long0);
  2258. /* Transformation */
  2259. gfi = Math.pow(((1 + this.e * Math.sin(lat)) / (1 - this.e * Math.sin(lat))), (this.alfa * this.e / 2));
  2260. u = 2 * (Math.atan(this.k * Math.pow(Math.tan(lat / 2 + this.s45), this.alfa) / gfi) - this.s45);
  2261. deltav = -delta_lon * this.alfa;
  2262. s = Math.asin(Math.cos(this.ad) * Math.sin(u) + Math.sin(this.ad) * Math.cos(u) * Math.cos(deltav));
  2263. d = Math.asin(Math.cos(u) * Math.sin(deltav) / Math.cos(s));
  2264. eps = this.n * d;
  2265. ro = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n);
  2266. p.y = ro * Math.cos(eps) / 1;
  2267. p.x = ro * Math.sin(eps) / 1;
  2268. if (!this.czech) {
  2269. p.y *= -1;
  2270. p.x *= -1;
  2271. }
  2272. return (p);
  2273. };
  2274. /* calculate lat/lon from xy */
  2275. exports.inverse = function (p) {
  2276. var u, deltav, s, d, eps, ro, fi1;
  2277. var ok;
  2278. /* Transformation */
  2279. /* revert y, x*/
  2280. var tmp = p.x;
  2281. p.x = p.y;
  2282. p.y = tmp;
  2283. if (!this.czech) {
  2284. p.y *= -1;
  2285. p.x *= -1;
  2286. }
  2287. ro = Math.sqrt(p.x * p.x + p.y * p.y);
  2288. eps = Math.atan2(p.y, p.x);
  2289. d = eps / Math.sin(this.s0);
  2290. s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45);
  2291. u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d));
  2292. deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u));
  2293. p.x = this.long0 - deltav / this.alfa;
  2294. fi1 = u;
  2295. ok = 0;
  2296. var iter = 0;
  2297. do {
  2298. p.y = 2 * (Math.atan(Math.pow(this.k, - 1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45);
  2299. if (Math.abs(fi1 - p.y) < 0.0000000001) {
  2300. ok = 1;
  2301. }
  2302. fi1 = p.y;
  2303. iter += 1;
  2304. } while (ok === 0 && iter < 15);
  2305. if (iter >= 15) {
  2306. return null;
  2307. }
  2308. return (p);
  2309. };
  2310. exports.names = ["Krovak", "krovak"];
  2311. }, { "../common/adjust_lon": 5 }], 49: [function (_dereq_, module, exports) {
  2312. var HALF_PI = Math.PI / 2;
  2313. var FORTPI = Math.PI / 4;
  2314. var EPSLN = 1.0e-10;
  2315. var qsfnz = _dereq_('../common/qsfnz');
  2316. var adjust_lon = _dereq_('../common/adjust_lon');
  2317. /*
  2318. reference
  2319. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
  2320. The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
  2321. */
  2322. exports.S_POLE = 1;
  2323. exports.N_POLE = 2;
  2324. exports.EQUIT = 3;
  2325. exports.OBLIQ = 4;
  2326. /* Initialize the Lambert Azimuthal Equal Area projection
  2327. ------------------------------------------------------*/
  2328. exports.init = function () {
  2329. var t = Math.abs(this.lat0);
  2330. if (Math.abs(t - HALF_PI) < EPSLN) {
  2331. this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE;
  2332. }
  2333. else if (Math.abs(t) < EPSLN) {
  2334. this.mode = this.EQUIT;
  2335. }
  2336. else {
  2337. this.mode = this.OBLIQ;
  2338. }
  2339. if (this.es > 0) {
  2340. var sinphi;
  2341. this.qp = qsfnz(this.e, 1);
  2342. this.mmf = 0.5 / (1 - this.es);
  2343. this.apa = this.authset(this.es);
  2344. switch (this.mode) {
  2345. case this.N_POLE:
  2346. this.dd = 1;
  2347. break;
  2348. case this.S_POLE:
  2349. this.dd = 1;
  2350. break;
  2351. case this.EQUIT:
  2352. this.rq = Math.sqrt(0.5 * this.qp);
  2353. this.dd = 1 / this.rq;
  2354. this.xmf = 1;
  2355. this.ymf = 0.5 * this.qp;
  2356. break;
  2357. case this.OBLIQ:
  2358. this.rq = Math.sqrt(0.5 * this.qp);
  2359. sinphi = Math.sin(this.lat0);
  2360. this.sinb1 = qsfnz(this.e, sinphi) / this.qp;
  2361. this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1);
  2362. this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1);
  2363. this.ymf = (this.xmf = this.rq) / this.dd;
  2364. this.xmf *= this.dd;
  2365. break;
  2366. }
  2367. }
  2368. else {
  2369. if (this.mode === this.OBLIQ) {
  2370. this.sinph0 = Math.sin(this.lat0);
  2371. this.cosph0 = Math.cos(this.lat0);
  2372. }
  2373. }
  2374. };
  2375. /* Lambert Azimuthal Equal Area forward equations--mapping lat,long to x,y
  2376. -----------------------------------------------------------------------*/
  2377. exports.forward = function (p) {
  2378. /* Forward equations
  2379. -----------------*/
  2380. var x, y, coslam, sinlam, sinphi, q, sinb, cosb, b, cosphi;
  2381. var lam = p.x;
  2382. var phi = p.y;
  2383. lam = adjust_lon(lam - this.long0);
  2384. if (this.sphere) {
  2385. sinphi = Math.sin(phi);
  2386. cosphi = Math.cos(phi);
  2387. coslam = Math.cos(lam);
  2388. if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
  2389. y = (this.mode === this.EQUIT) ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;
  2390. if (y <= EPSLN) {
  2391. return null;
  2392. }
  2393. y = Math.sqrt(2 / y);
  2394. x = y * cosphi * Math.sin(lam);
  2395. y *= (this.mode === this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;
  2396. }
  2397. else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
  2398. if (this.mode === this.N_POLE) {
  2399. coslam = -coslam;
  2400. }
  2401. if (Math.abs(phi + this.phi0) < EPSLN) {
  2402. return null;
  2403. }
  2404. y = FORTPI - phi * 0.5;
  2405. y = 2 * ((this.mode === this.S_POLE) ? Math.cos(y) : Math.sin(y));
  2406. x = y * Math.sin(lam);
  2407. y *= coslam;
  2408. }
  2409. }
  2410. else {
  2411. sinb = 0;
  2412. cosb = 0;
  2413. b = 0;
  2414. coslam = Math.cos(lam);
  2415. sinlam = Math.sin(lam);
  2416. sinphi = Math.sin(phi);
  2417. q = qsfnz(this.e, sinphi);
  2418. if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
  2419. sinb = q / this.qp;
  2420. cosb = Math.sqrt(1 - sinb * sinb);
  2421. }
  2422. switch (this.mode) {
  2423. case this.OBLIQ:
  2424. b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam;
  2425. break;
  2426. case this.EQUIT:
  2427. b = 1 + cosb * coslam;
  2428. break;
  2429. case this.N_POLE:
  2430. b = HALF_PI + phi;
  2431. q = this.qp - q;
  2432. break;
  2433. case this.S_POLE:
  2434. b = phi - HALF_PI;
  2435. q = this.qp + q;
  2436. break;
  2437. }
  2438. if (Math.abs(b) < EPSLN) {
  2439. return null;
  2440. }
  2441. switch (this.mode) {
  2442. case this.OBLIQ:
  2443. case this.EQUIT:
  2444. b = Math.sqrt(2 / b);
  2445. if (this.mode === this.OBLIQ) {
  2446. y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam);
  2447. }
  2448. else {
  2449. y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf;
  2450. }
  2451. x = this.xmf * b * cosb * sinlam;
  2452. break;
  2453. case this.N_POLE:
  2454. case this.S_POLE:
  2455. if (q >= 0) {
  2456. x = (b = Math.sqrt(q)) * sinlam;
  2457. y = coslam * ((this.mode === this.S_POLE) ? b : -b);
  2458. }
  2459. else {
  2460. x = y = 0;
  2461. }
  2462. break;
  2463. }
  2464. }
  2465. p.x = this.a * x + this.x0;
  2466. p.y = this.a * y + this.y0;
  2467. return p;
  2468. };
  2469. /* Inverse equations
  2470. -----------------*/
  2471. exports.inverse = function (p) {
  2472. p.x -= this.x0;
  2473. p.y -= this.y0;
  2474. var x = p.x / this.a;
  2475. var y = p.y / this.a;
  2476. var lam, phi, cCe, sCe, q, rho, ab;
  2477. if (this.sphere) {
  2478. var cosz = 0,
  2479. rh, sinz = 0;
  2480. rh = Math.sqrt(x * x + y * y);
  2481. phi = rh * 0.5;
  2482. if (phi > 1) {
  2483. return null;
  2484. }
  2485. phi = 2 * Math.asin(phi);
  2486. if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
  2487. sinz = Math.sin(phi);
  2488. cosz = Math.cos(phi);
  2489. }
  2490. switch (this.mode) {
  2491. case this.EQUIT:
  2492. phi = (Math.abs(rh) <= EPSLN) ? 0 : Math.asin(y * sinz / rh);
  2493. x *= sinz;
  2494. y = cosz * rh;
  2495. break;
  2496. case this.OBLIQ:
  2497. phi = (Math.abs(rh) <= EPSLN) ? this.phi0 : Math.asin(cosz * this.sinph0 + y * sinz * this.cosph0 / rh);
  2498. x *= sinz * this.cosph0;
  2499. y = (cosz - Math.sin(phi) * this.sinph0) * rh;
  2500. break;
  2501. case this.N_POLE:
  2502. y = -y;
  2503. phi = HALF_PI - phi;
  2504. break;
  2505. case this.S_POLE:
  2506. phi -= HALF_PI;
  2507. break;
  2508. }
  2509. lam = (y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ)) ? 0 : Math.atan2(x, y);
  2510. }
  2511. else {
  2512. ab = 0;
  2513. if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
  2514. x /= this.dd;
  2515. y *= this.dd;
  2516. rho = Math.sqrt(x * x + y * y);
  2517. if (rho < EPSLN) {
  2518. p.x = 0;
  2519. p.y = this.phi0;
  2520. return p;
  2521. }
  2522. sCe = 2 * Math.asin(0.5 * rho / this.rq);
  2523. cCe = Math.cos(sCe);
  2524. x *= (sCe = Math.sin(sCe));
  2525. if (this.mode === this.OBLIQ) {
  2526. ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho;
  2527. q = this.qp * ab;
  2528. y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe;
  2529. }
  2530. else {
  2531. ab = y * sCe / rho;
  2532. q = this.qp * ab;
  2533. y = rho * cCe;
  2534. }
  2535. }
  2536. else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
  2537. if (this.mode === this.N_POLE) {
  2538. y = -y;
  2539. }
  2540. q = (x * x + y * y);
  2541. if (!q) {
  2542. p.x = 0;
  2543. p.y = this.phi0;
  2544. return p;
  2545. }
  2546. ab = 1 - q / this.qp;
  2547. if (this.mode === this.S_POLE) {
  2548. ab = -ab;
  2549. }
  2550. }
  2551. lam = Math.atan2(x, y);
  2552. phi = this.authlat(Math.asin(ab), this.apa);
  2553. }
  2554. p.x = adjust_lon(this.long0 + lam);
  2555. p.y = phi;
  2556. return p;
  2557. };
  2558. /* determine latitude from authalic latitude */
  2559. exports.P00 = 0.33333333333333333333;
  2560. exports.P01 = 0.17222222222222222222;
  2561. exports.P02 = 0.10257936507936507936;
  2562. exports.P10 = 0.06388888888888888888;
  2563. exports.P11 = 0.06640211640211640211;
  2564. exports.P20 = 0.01641501294219154443;
  2565. exports.authset = function (es) {
  2566. var t;
  2567. var APA = [];
  2568. APA[0] = es * this.P00;
  2569. t = es * es;
  2570. APA[0] += t * this.P01;
  2571. APA[1] = t * this.P10;
  2572. t *= es;
  2573. APA[0] += t * this.P02;
  2574. APA[1] += t * this.P11;
  2575. APA[2] = t * this.P20;
  2576. return APA;
  2577. };
  2578. exports.authlat = function (beta, APA) {
  2579. var t = beta + beta;
  2580. return (beta + APA[0] * Math.sin(t) + APA[1] * Math.sin(t + t) + APA[2] * Math.sin(t + t + t));
  2581. };
  2582. exports.names = ["Lambert Azimuthal Equal Area", "Lambert_Azimuthal_Equal_Area", "laea"];
  2583. }, { "../common/adjust_lon": 5, "../common/qsfnz": 20 }], 50: [function (_dereq_, module, exports) {
  2584. var EPSLN = 1.0e-10;
  2585. var msfnz = _dereq_('../common/msfnz');
  2586. var tsfnz = _dereq_('../common/tsfnz');
  2587. var HALF_PI = Math.PI / 2;
  2588. var sign = _dereq_('../common/sign');
  2589. var adjust_lon = _dereq_('../common/adjust_lon');
  2590. var phi2z = _dereq_('../common/phi2z');
  2591. exports.init = function () {
  2592. // array of: r_maj,r_min,lat1,lat2,c_lon,c_lat,false_east,false_north
  2593. //double c_lat; /* center latitude */
  2594. //double c_lon; /* center longitude */
  2595. //double lat1; /* first standard parallel */
  2596. //double lat2; /* second standard parallel */
  2597. //double r_maj; /* major axis */
  2598. //double r_min; /* minor axis */
  2599. //double false_east; /* x offset in meters */
  2600. //double false_north; /* y offset in meters */
  2601. if (!this.lat2) {
  2602. this.lat2 = this.lat1;
  2603. } //if lat2 is not defined
  2604. if (!this.k0) {
  2605. this.k0 = 1;
  2606. }
  2607. this.x0 = this.x0 || 0;
  2608. this.y0 = this.y0 || 0;
  2609. // Standard Parallels cannot be equal and on opposite sides of the equator
  2610. if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
  2611. return;
  2612. }
  2613. var temp = this.b / this.a;
  2614. this.e = Math.sqrt(1 - temp * temp);
  2615. var sin1 = Math.sin(this.lat1);
  2616. var cos1 = Math.cos(this.lat1);
  2617. var ms1 = msfnz(this.e, sin1, cos1);
  2618. var ts1 = tsfnz(this.e, this.lat1, sin1);
  2619. var sin2 = Math.sin(this.lat2);
  2620. var cos2 = Math.cos(this.lat2);
  2621. var ms2 = msfnz(this.e, sin2, cos2);
  2622. var ts2 = tsfnz(this.e, this.lat2, sin2);
  2623. var ts0 = tsfnz(this.e, this.lat0, Math.sin(this.lat0));
  2624. if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
  2625. this.ns = Math.log(ms1 / ms2) / Math.log(ts1 / ts2);
  2626. }
  2627. else {
  2628. this.ns = sin1;
  2629. }
  2630. if (isNaN(this.ns)) {
  2631. this.ns = sin1;
  2632. }
  2633. this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns));
  2634. this.rh = this.a * this.f0 * Math.pow(ts0, this.ns);
  2635. if (!this.title) {
  2636. this.title = "Lambert Conformal Conic";
  2637. }
  2638. };
  2639. // Lambert Conformal conic forward equations--mapping lat,long to x,y
  2640. // -----------------------------------------------------------------
  2641. exports.forward = function (p) {
  2642. var lon = p.x;
  2643. var lat = p.y;
  2644. // singular cases :
  2645. if (Math.abs(2 * Math.abs(lat) - Math.PI) <= EPSLN) {
  2646. lat = sign(lat) * (HALF_PI - 2 * EPSLN);
  2647. }
  2648. var con = Math.abs(Math.abs(lat) - HALF_PI);
  2649. var ts, rh1;
  2650. if (con > EPSLN) {
  2651. ts = tsfnz(this.e, lat, Math.sin(lat));
  2652. rh1 = this.a * this.f0 * Math.pow(ts, this.ns);
  2653. }
  2654. else {
  2655. con = lat * this.ns;
  2656. if (con <= 0) {
  2657. return null;
  2658. }
  2659. rh1 = 0;
  2660. }
  2661. var theta = this.ns * adjust_lon(lon - this.long0);
  2662. p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0;
  2663. p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0;
  2664. return p;
  2665. };
  2666. // Lambert Conformal Conic inverse equations--mapping x,y to lat/long
  2667. // -----------------------------------------------------------------
  2668. exports.inverse = function (p) {
  2669. var rh1, con, ts;
  2670. var lat, lon;
  2671. var x = (p.x - this.x0) / this.k0;
  2672. var y = (this.rh - (p.y - this.y0) / this.k0);
  2673. if (this.ns > 0) {
  2674. rh1 = Math.sqrt(x * x + y * y);
  2675. con = 1;
  2676. }
  2677. else {
  2678. rh1 = -Math.sqrt(x * x + y * y);
  2679. con = -1;
  2680. }
  2681. var theta = 0;
  2682. if (rh1 !== 0) {
  2683. theta = Math.atan2((con * x), (con * y));
  2684. }
  2685. if ((rh1 !== 0) || (this.ns > 0)) {
  2686. con = 1 / this.ns;
  2687. ts = Math.pow((rh1 / (this.a * this.f0)), con);
  2688. lat = phi2z(this.e, ts);
  2689. if (lat === -9999) {
  2690. return null;
  2691. }
  2692. }
  2693. else {
  2694. lat = -HALF_PI;
  2695. }
  2696. lon = adjust_lon(theta / this.ns + this.long0);
  2697. p.x = lon;
  2698. p.y = lat;
  2699. return p;
  2700. };
  2701. exports.names = ["Lambert Tangential Conformal Conic Projection", "Lambert_Conformal_Conic", "Lambert_Conformal_Conic_2SP", "lcc"];
  2702. }, { "../common/adjust_lon": 5, "../common/msfnz": 15, "../common/phi2z": 16, "../common/sign": 21, "../common/tsfnz": 24 }], 51: [function (_dereq_, module, exports) {
  2703. exports.init = function () {
  2704. //no-op for longlat
  2705. };
  2706. function identity(pt) {
  2707. return pt;
  2708. }
  2709. exports.forward = identity;
  2710. exports.inverse = identity;
  2711. exports.names = ["longlat", "identity"];
  2712. }, {}], 52: [function (_dereq_, module, exports) {
  2713. var msfnz = _dereq_('../common/msfnz');
  2714. var HALF_PI = Math.PI / 2;
  2715. var EPSLN = 1.0e-10;
  2716. var R2D = 57.29577951308232088;
  2717. var adjust_lon = _dereq_('../common/adjust_lon');
  2718. var FORTPI = Math.PI / 4;
  2719. var tsfnz = _dereq_('../common/tsfnz');
  2720. var phi2z = _dereq_('../common/phi2z');
  2721. exports.init = function () {
  2722. var con = this.b / this.a;
  2723. this.es = 1 - con * con;
  2724. if (!('x0' in this)) {
  2725. this.x0 = 0;
  2726. }
  2727. if (!('y0' in this)) {
  2728. this.y0 = 0;
  2729. }
  2730. this.e = Math.sqrt(this.es);
  2731. if (this.lat_ts) {
  2732. if (this.sphere) {
  2733. this.k0 = Math.cos(this.lat_ts);
  2734. }
  2735. else {
  2736. this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
  2737. }
  2738. }
  2739. else {
  2740. if (!this.k0) {
  2741. if (this.k) {
  2742. this.k0 = this.k;
  2743. }
  2744. else {
  2745. this.k0 = 1;
  2746. }
  2747. }
  2748. }
  2749. };
  2750. /* Mercator forward equations--mapping lat,long to x,y
  2751. --------------------------------------------------*/
  2752. exports.forward = function (p) {
  2753. var lon = p.x;
  2754. var lat = p.y;
  2755. // convert to radians
  2756. if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) {
  2757. return null;
  2758. }
  2759. var x, y;
  2760. if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
  2761. return null;
  2762. }
  2763. else {
  2764. if (this.sphere) {
  2765. x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
  2766. y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat));
  2767. }
  2768. else {
  2769. var sinphi = Math.sin(lat);
  2770. var ts = tsfnz(this.e, lat, sinphi);
  2771. x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
  2772. y = this.y0 - this.a * this.k0 * Math.log(ts);
  2773. }
  2774. p.x = x;
  2775. p.y = y;
  2776. return p;
  2777. }
  2778. };
  2779. /* Mercator inverse equations--mapping x,y to lat/long
  2780. --------------------------------------------------*/
  2781. exports.inverse = function (p) {
  2782. var x = p.x - this.x0;
  2783. var y = p.y - this.y0;
  2784. var lon, lat;
  2785. if (this.sphere) {
  2786. lat = HALF_PI - 2 * Math.atan(Math.exp(-y / (this.a * this.k0)));
  2787. }
  2788. else {
  2789. var ts = Math.exp(-y / (this.a * this.k0));
  2790. lat = phi2z(this.e, ts);
  2791. if (lat === -9999) {
  2792. return null;
  2793. }
  2794. }
  2795. lon = adjust_lon(this.long0 + x / (this.a * this.k0));
  2796. p.x = lon;
  2797. p.y = lat;
  2798. return p;
  2799. };
  2800. exports.names = ["Mercator", "Popular Visualisation Pseudo Mercator", "Mercator_1SP", "Mercator_Auxiliary_Sphere", "merc"];
  2801. }, { "../common/adjust_lon": 5, "../common/msfnz": 15, "../common/phi2z": 16, "../common/tsfnz": 24 }], 53: [function (_dereq_, module, exports) {
  2802. var adjust_lon = _dereq_('../common/adjust_lon');
  2803. /*
  2804. reference
  2805. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
  2806. The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
  2807. */
  2808. /* Initialize the Miller Cylindrical projection
  2809. -------------------------------------------*/
  2810. exports.init = function () {
  2811. //no-op
  2812. };
  2813. /* Miller Cylindrical forward equations--mapping lat,long to x,y
  2814. ------------------------------------------------------------*/
  2815. exports.forward = function (p) {
  2816. var lon = p.x;
  2817. var lat = p.y;
  2818. /* Forward equations
  2819. -----------------*/
  2820. var dlon = adjust_lon(lon - this.long0);
  2821. var x = this.x0 + this.a * dlon;
  2822. var y = this.y0 + this.a * Math.log(Math.tan((Math.PI / 4) + (lat / 2.5))) * 1.25;
  2823. p.x = x;
  2824. p.y = y;
  2825. return p;
  2826. };
  2827. /* Miller Cylindrical inverse equations--mapping x,y to lat/long
  2828. ------------------------------------------------------------*/
  2829. exports.inverse = function (p) {
  2830. p.x -= this.x0;
  2831. p.y -= this.y0;
  2832. var lon = adjust_lon(this.long0 + p.x / this.a);
  2833. var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4);
  2834. p.x = lon;
  2835. p.y = lat;
  2836. return p;
  2837. };
  2838. exports.names = ["Miller_Cylindrical", "mill"];
  2839. }, { "../common/adjust_lon": 5 }], 54: [function (_dereq_, module, exports) {
  2840. var adjust_lon = _dereq_('../common/adjust_lon');
  2841. var EPSLN = 1.0e-10;
  2842. exports.init = function () { };
  2843. /* Mollweide forward equations--mapping lat,long to x,y
  2844. ----------------------------------------------------*/
  2845. exports.forward = function (p) {
  2846. /* Forward equations
  2847. -----------------*/
  2848. var lon = p.x;
  2849. var lat = p.y;
  2850. var delta_lon = adjust_lon(lon - this.long0);
  2851. var theta = lat;
  2852. var con = Math.PI * Math.sin(lat);
  2853. /* Iterate using the Newton-Raphson method to find theta
  2854. -----------------------------------------------------*/
  2855. for (var i = 0; true; i++) {
  2856. var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta));
  2857. theta += delta_theta;
  2858. if (Math.abs(delta_theta) < EPSLN) {
  2859. break;
  2860. }
  2861. }
  2862. theta /= 2;
  2863. /* If the latitude is 90 deg, force the x coordinate to be "0 + false easting"
  2864. this is done here because of precision problems with "cos(theta)"
  2865. --------------------------------------------------------------------------*/
  2866. if (Math.PI / 2 - Math.abs(lat) < EPSLN) {
  2867. delta_lon = 0;
  2868. }
  2869. var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;
  2870. var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;
  2871. p.x = x;
  2872. p.y = y;
  2873. return p;
  2874. };
  2875. exports.inverse = function (p) {
  2876. var theta;
  2877. var arg;
  2878. /* Inverse equations
  2879. -----------------*/
  2880. p.x -= this.x0;
  2881. p.y -= this.y0;
  2882. arg = p.y / (1.4142135623731 * this.a);
  2883. /* Because of division by zero problems, 'arg' can not be 1. Therefore
  2884. a number very close to one is used instead.
  2885. -------------------------------------------------------------------*/
  2886. if (Math.abs(arg) > 0.999999999999) {
  2887. arg = 0.999999999999;
  2888. }
  2889. theta = Math.asin(arg);
  2890. var lon = adjust_lon(this.long0 + (p.x / (0.900316316158 * this.a * Math.cos(theta))));
  2891. if (lon < (-Math.PI)) {
  2892. lon = -Math.PI;
  2893. }
  2894. if (lon > Math.PI) {
  2895. lon = Math.PI;
  2896. }
  2897. arg = (2 * theta + Math.sin(2 * theta)) / Math.PI;
  2898. if (Math.abs(arg) > 1) {
  2899. arg = 1;
  2900. }
  2901. var lat = Math.asin(arg);
  2902. p.x = lon;
  2903. p.y = lat;
  2904. return p;
  2905. };
  2906. exports.names = ["Mollweide", "moll"];
  2907. }, { "../common/adjust_lon": 5 }], 55: [function (_dereq_, module, exports) {
  2908. var SEC_TO_RAD = 4.84813681109535993589914102357e-6;
  2909. /*
  2910. reference
  2911. Department of Land and Survey Technical Circular 1973/32
  2912. http://www.linz.govt.nz/docs/miscellaneous/nz-map-definition.pdf
  2913. OSG Technical Report 4.1
  2914. http://www.linz.govt.nz/docs/miscellaneous/nzmg.pdf
  2915. */
  2916. /**
  2917. * iterations: Number of iterations to refine inverse transform.
  2918. * 0 -> km accuracy
  2919. * 1 -> m accuracy -- suitable for most mapping applications
  2920. * 2 -> mm accuracy
  2921. */
  2922. exports.iterations = 1;
  2923. exports.init = function () {
  2924. this.A = [];
  2925. this.A[1] = 0.6399175073;
  2926. this.A[2] = -0.1358797613;
  2927. this.A[3] = 0.063294409;
  2928. this.A[4] = -0.02526853;
  2929. this.A[5] = 0.0117879;
  2930. this.A[6] = -0.0055161;
  2931. this.A[7] = 0.0026906;
  2932. this.A[8] = -0.001333;
  2933. this.A[9] = 0.00067;
  2934. this.A[10] = -0.00034;
  2935. this.B_re = [];
  2936. this.B_im = [];
  2937. this.B_re[1] = 0.7557853228;
  2938. this.B_im[1] = 0;
  2939. this.B_re[2] = 0.249204646;
  2940. this.B_im[2] = 0.003371507;
  2941. this.B_re[3] = -0.001541739;
  2942. this.B_im[3] = 0.041058560;
  2943. this.B_re[4] = -0.10162907;
  2944. this.B_im[4] = 0.01727609;
  2945. this.B_re[5] = -0.26623489;
  2946. this.B_im[5] = -0.36249218;
  2947. this.B_re[6] = -0.6870983;
  2948. this.B_im[6] = -1.1651967;
  2949. this.C_re = [];
  2950. this.C_im = [];
  2951. this.C_re[1] = 1.3231270439;
  2952. this.C_im[1] = 0;
  2953. this.C_re[2] = -0.577245789;
  2954. this.C_im[2] = -0.007809598;
  2955. this.C_re[3] = 0.508307513;
  2956. this.C_im[3] = -0.112208952;
  2957. this.C_re[4] = -0.15094762;
  2958. this.C_im[4] = 0.18200602;
  2959. this.C_re[5] = 1.01418179;
  2960. this.C_im[5] = 1.64497696;
  2961. this.C_re[6] = 1.9660549;
  2962. this.C_im[6] = 2.5127645;
  2963. this.D = [];
  2964. this.D[1] = 1.5627014243;
  2965. this.D[2] = 0.5185406398;
  2966. this.D[3] = -0.03333098;
  2967. this.D[4] = -0.1052906;
  2968. this.D[5] = -0.0368594;
  2969. this.D[6] = 0.007317;
  2970. this.D[7] = 0.01220;
  2971. this.D[8] = 0.00394;
  2972. this.D[9] = -0.0013;
  2973. };
  2974. /**
  2975. New Zealand Map Grid Forward - long/lat to x/y
  2976. long/lat in radians
  2977. */
  2978. exports.forward = function (p) {
  2979. var n;
  2980. var lon = p.x;
  2981. var lat = p.y;
  2982. var delta_lat = lat - this.lat0;
  2983. var delta_lon = lon - this.long0;
  2984. // 1. Calculate d_phi and d_psi ... // and d_lambda
  2985. // For this algorithm, delta_latitude is in seconds of arc x 10-5, so we need to scale to those units. Longitude is radians.
  2986. var d_phi = delta_lat / SEC_TO_RAD * 1E-5;
  2987. var d_lambda = delta_lon;
  2988. var d_phi_n = 1; // d_phi^0
  2989. var d_psi = 0;
  2990. for (n = 1; n <= 10; n++) {
  2991. d_phi_n = d_phi_n * d_phi;
  2992. d_psi = d_psi + this.A[n] * d_phi_n;
  2993. }
  2994. // 2. Calculate theta
  2995. var th_re = d_psi;
  2996. var th_im = d_lambda;
  2997. // 3. Calculate z
  2998. var th_n_re = 1;
  2999. var th_n_im = 0; // theta^0
  3000. var th_n_re1;
  3001. var th_n_im1;
  3002. var z_re = 0;
  3003. var z_im = 0;
  3004. for (n = 1; n <= 6; n++) {
  3005. th_n_re1 = th_n_re * th_re - th_n_im * th_im;
  3006. th_n_im1 = th_n_im * th_re + th_n_re * th_im;
  3007. th_n_re = th_n_re1;
  3008. th_n_im = th_n_im1;
  3009. z_re = z_re + this.B_re[n] * th_n_re - this.B_im[n] * th_n_im;
  3010. z_im = z_im + this.B_im[n] * th_n_re + this.B_re[n] * th_n_im;
  3011. }
  3012. // 4. Calculate easting and northing
  3013. p.x = (z_im * this.a) + this.x0;
  3014. p.y = (z_re * this.a) + this.y0;
  3015. return p;
  3016. };
  3017. /**
  3018. New Zealand Map Grid Inverse - x/y to long/lat
  3019. */
  3020. exports.inverse = function (p) {
  3021. var n;
  3022. var x = p.x;
  3023. var y = p.y;
  3024. var delta_x = x - this.x0;
  3025. var delta_y = y - this.y0;
  3026. // 1. Calculate z
  3027. var z_re = delta_y / this.a;
  3028. var z_im = delta_x / this.a;
  3029. // 2a. Calculate theta - first approximation gives km accuracy
  3030. var z_n_re = 1;
  3031. var z_n_im = 0; // z^0
  3032. var z_n_re1;
  3033. var z_n_im1;
  3034. var th_re = 0;
  3035. var th_im = 0;
  3036. for (n = 1; n <= 6; n++) {
  3037. z_n_re1 = z_n_re * z_re - z_n_im * z_im;
  3038. z_n_im1 = z_n_im * z_re + z_n_re * z_im;
  3039. z_n_re = z_n_re1;
  3040. z_n_im = z_n_im1;
  3041. th_re = th_re + this.C_re[n] * z_n_re - this.C_im[n] * z_n_im;
  3042. th_im = th_im + this.C_im[n] * z_n_re + this.C_re[n] * z_n_im;
  3043. }
  3044. // 2b. Iterate to refine the accuracy of the calculation
  3045. // 0 iterations gives km accuracy
  3046. // 1 iteration gives m accuracy -- good enough for most mapping applications
  3047. // 2 iterations bives mm accuracy
  3048. for (var i = 0; i < this.iterations; i++) {
  3049. var th_n_re = th_re;
  3050. var th_n_im = th_im;
  3051. var th_n_re1;
  3052. var th_n_im1;
  3053. var num_re = z_re;
  3054. var num_im = z_im;
  3055. for (n = 2; n <= 6; n++) {
  3056. th_n_re1 = th_n_re * th_re - th_n_im * th_im;
  3057. th_n_im1 = th_n_im * th_re + th_n_re * th_im;
  3058. th_n_re = th_n_re1;
  3059. th_n_im = th_n_im1;
  3060. num_re = num_re + (n - 1) * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
  3061. num_im = num_im + (n - 1) * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
  3062. }
  3063. th_n_re = 1;
  3064. th_n_im = 0;
  3065. var den_re = this.B_re[1];
  3066. var den_im = this.B_im[1];
  3067. for (n = 2; n <= 6; n++) {
  3068. th_n_re1 = th_n_re * th_re - th_n_im * th_im;
  3069. th_n_im1 = th_n_im * th_re + th_n_re * th_im;
  3070. th_n_re = th_n_re1;
  3071. th_n_im = th_n_im1;
  3072. den_re = den_re + n * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
  3073. den_im = den_im + n * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
  3074. }
  3075. // Complex division
  3076. var den2 = den_re * den_re + den_im * den_im;
  3077. th_re = (num_re * den_re + num_im * den_im) / den2;
  3078. th_im = (num_im * den_re - num_re * den_im) / den2;
  3079. }
  3080. // 3. Calculate d_phi ... // and d_lambda
  3081. var d_psi = th_re;
  3082. var d_lambda = th_im;
  3083. var d_psi_n = 1; // d_psi^0
  3084. var d_phi = 0;
  3085. for (n = 1; n <= 9; n++) {
  3086. d_psi_n = d_psi_n * d_psi;
  3087. d_phi = d_phi + this.D[n] * d_psi_n;
  3088. }
  3089. // 4. Calculate latitude and longitude
  3090. // d_phi is calcuated in second of arc * 10^-5, so we need to scale back to radians. d_lambda is in radians.
  3091. var lat = this.lat0 + (d_phi * SEC_TO_RAD * 1E5);
  3092. var lon = this.long0 + d_lambda;
  3093. p.x = lon;
  3094. p.y = lat;
  3095. return p;
  3096. };
  3097. exports.names = ["New_Zealand_Map_Grid", "nzmg"];
  3098. }, {}], 56: [function (_dereq_, module, exports) {
  3099. var tsfnz = _dereq_('../common/tsfnz');
  3100. var adjust_lon = _dereq_('../common/adjust_lon');
  3101. var phi2z = _dereq_('../common/phi2z');
  3102. var HALF_PI = Math.PI / 2;
  3103. var FORTPI = Math.PI / 4;
  3104. var EPSLN = 1.0e-10;
  3105. /* Initialize the Oblique Mercator projection
  3106. ------------------------------------------*/
  3107. exports.init = function () {
  3108. this.no_off = this.no_off || false;
  3109. this.no_rot = this.no_rot || false;
  3110. if (isNaN(this.k0)) {
  3111. this.k0 = 1;
  3112. }
  3113. var sinlat = Math.sin(this.lat0);
  3114. var coslat = Math.cos(this.lat0);
  3115. var con = this.e * sinlat;
  3116. this.bl = Math.sqrt(1 + this.es / (1 - this.es) * Math.pow(coslat, 4));
  3117. this.al = this.a * this.bl * this.k0 * Math.sqrt(1 - this.es) / (1 - con * con);
  3118. var t0 = tsfnz(this.e, this.lat0, sinlat);
  3119. var dl = this.bl / coslat * Math.sqrt((1 - this.es) / (1 - con * con));
  3120. if (dl * dl < 1) {
  3121. dl = 1;
  3122. }
  3123. var fl;
  3124. var gl;
  3125. if (!isNaN(this.longc)) {
  3126. //Central point and azimuth method
  3127. if (this.lat0 >= 0) {
  3128. fl = dl + Math.sqrt(dl * dl - 1);
  3129. }
  3130. else {
  3131. fl = dl - Math.sqrt(dl * dl - 1);
  3132. }
  3133. this.el = fl * Math.pow(t0, this.bl);
  3134. gl = 0.5 * (fl - 1 / fl);
  3135. this.gamma0 = Math.asin(Math.sin(this.alpha) / dl);
  3136. this.long0 = this.longc - Math.asin(gl * Math.tan(this.gamma0)) / this.bl;
  3137. }
  3138. else {
  3139. //2 points method
  3140. var t1 = tsfnz(this.e, this.lat1, Math.sin(this.lat1));
  3141. var t2 = tsfnz(this.e, this.lat2, Math.sin(this.lat2));
  3142. if (this.lat0 >= 0) {
  3143. this.el = (dl + Math.sqrt(dl * dl - 1)) * Math.pow(t0, this.bl);
  3144. }
  3145. else {
  3146. this.el = (dl - Math.sqrt(dl * dl - 1)) * Math.pow(t0, this.bl);
  3147. }
  3148. var hl = Math.pow(t1, this.bl);
  3149. var ll = Math.pow(t2, this.bl);
  3150. fl = this.el / hl;
  3151. gl = 0.5 * (fl - 1 / fl);
  3152. var jl = (this.el * this.el - ll * hl) / (this.el * this.el + ll * hl);
  3153. var pl = (ll - hl) / (ll + hl);
  3154. var dlon12 = adjust_lon(this.long1 - this.long2);
  3155. this.long0 = 0.5 * (this.long1 + this.long2) - Math.atan(jl * Math.tan(0.5 * this.bl * (dlon12)) / pl) / this.bl;
  3156. this.long0 = adjust_lon(this.long0);
  3157. var dlon10 = adjust_lon(this.long1 - this.long0);
  3158. this.gamma0 = Math.atan(Math.sin(this.bl * (dlon10)) / gl);
  3159. this.alpha = Math.asin(dl * Math.sin(this.gamma0));
  3160. }
  3161. if (this.no_off) {
  3162. this.uc = 0;
  3163. }
  3164. else {
  3165. if (this.lat0 >= 0) {
  3166. this.uc = this.al / this.bl * Math.atan2(Math.sqrt(dl * dl - 1), Math.cos(this.alpha));
  3167. }
  3168. else {
  3169. this.uc = -1 * this.al / this.bl * Math.atan2(Math.sqrt(dl * dl - 1), Math.cos(this.alpha));
  3170. }
  3171. }
  3172. };
  3173. /* Oblique Mercator forward equations--mapping lat,long to x,y
  3174. ----------------------------------------------------------*/
  3175. exports.forward = function (p) {
  3176. var lon = p.x;
  3177. var lat = p.y;
  3178. var dlon = adjust_lon(lon - this.long0);
  3179. var us, vs;
  3180. var con;
  3181. if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
  3182. if (lat > 0) {
  3183. con = -1;
  3184. }
  3185. else {
  3186. con = 1;
  3187. }
  3188. vs = this.al / this.bl * Math.log(Math.tan(FORTPI + con * this.gamma0 * 0.5));
  3189. us = -1 * con * HALF_PI * this.al / this.bl;
  3190. }
  3191. else {
  3192. var t = tsfnz(this.e, lat, Math.sin(lat));
  3193. var ql = this.el / Math.pow(t, this.bl);
  3194. var sl = 0.5 * (ql - 1 / ql);
  3195. var tl = 0.5 * (ql + 1 / ql);
  3196. var vl = Math.sin(this.bl * (dlon));
  3197. var ul = (sl * Math.sin(this.gamma0) - vl * Math.cos(this.gamma0)) / tl;
  3198. if (Math.abs(Math.abs(ul) - 1) <= EPSLN) {
  3199. vs = Number.POSITIVE_INFINITY;
  3200. }
  3201. else {
  3202. vs = 0.5 * this.al * Math.log((1 - ul) / (1 + ul)) / this.bl;
  3203. }
  3204. if (Math.abs(Math.cos(this.bl * (dlon))) <= EPSLN) {
  3205. us = this.al * this.bl * (dlon);
  3206. }
  3207. else {
  3208. us = this.al * Math.atan2(sl * Math.cos(this.gamma0) + vl * Math.sin(this.gamma0), Math.cos(this.bl * dlon)) / this.bl;
  3209. }
  3210. }
  3211. if (this.no_rot) {
  3212. p.x = this.x0 + us;
  3213. p.y = this.y0 + vs;
  3214. }
  3215. else {
  3216. us -= this.uc;
  3217. p.x = this.x0 + vs * Math.cos(this.alpha) + us * Math.sin(this.alpha);
  3218. p.y = this.y0 + us * Math.cos(this.alpha) - vs * Math.sin(this.alpha);
  3219. }
  3220. return p;
  3221. };
  3222. exports.inverse = function (p) {
  3223. var us, vs;
  3224. if (this.no_rot) {
  3225. vs = p.y - this.y0;
  3226. us = p.x - this.x0;
  3227. }
  3228. else {
  3229. vs = (p.x - this.x0) * Math.cos(this.alpha) - (p.y - this.y0) * Math.sin(this.alpha);
  3230. us = (p.y - this.y0) * Math.cos(this.alpha) + (p.x - this.x0) * Math.sin(this.alpha);
  3231. us += this.uc;
  3232. }
  3233. var qp = Math.exp(-1 * this.bl * vs / this.al);
  3234. var sp = 0.5 * (qp - 1 / qp);
  3235. var tp = 0.5 * (qp + 1 / qp);
  3236. var vp = Math.sin(this.bl * us / this.al);
  3237. var up = (vp * Math.cos(this.gamma0) + sp * Math.sin(this.gamma0)) / tp;
  3238. var ts = Math.pow(this.el / Math.sqrt((1 + up) / (1 - up)), 1 / this.bl);
  3239. if (Math.abs(up - 1) < EPSLN) {
  3240. p.x = this.long0;
  3241. p.y = HALF_PI;
  3242. }
  3243. else if (Math.abs(up + 1) < EPSLN) {
  3244. p.x = this.long0;
  3245. p.y = -1 * HALF_PI;
  3246. }
  3247. else {
  3248. p.y = phi2z(this.e, ts);
  3249. p.x = adjust_lon(this.long0 - Math.atan2(sp * Math.cos(this.gamma0) - vp * Math.sin(this.gamma0), Math.cos(this.bl * us / this.al)) / this.bl);
  3250. }
  3251. return p;
  3252. };
  3253. exports.names = ["Hotine_Oblique_Mercator", "Hotine Oblique Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "Hotine_Oblique_Mercator_Azimuth_Center", "omerc"];
  3254. }, { "../common/adjust_lon": 5, "../common/phi2z": 16, "../common/tsfnz": 24 }], 57: [function (_dereq_, module, exports) {
  3255. var e0fn = _dereq_('../common/e0fn');
  3256. var e1fn = _dereq_('../common/e1fn');
  3257. var e2fn = _dereq_('../common/e2fn');
  3258. var e3fn = _dereq_('../common/e3fn');
  3259. var adjust_lon = _dereq_('../common/adjust_lon');
  3260. var adjust_lat = _dereq_('../common/adjust_lat');
  3261. var mlfn = _dereq_('../common/mlfn');
  3262. var EPSLN = 1.0e-10;
  3263. var gN = _dereq_('../common/gN');
  3264. var MAX_ITER = 20;
  3265. exports.init = function () {
  3266. /* Place parameters in static storage for common use
  3267. -------------------------------------------------*/
  3268. this.temp = this.b / this.a;
  3269. this.es = 1 - Math.pow(this.temp, 2); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles
  3270. this.e = Math.sqrt(this.es);
  3271. this.e0 = e0fn(this.es);
  3272. this.e1 = e1fn(this.es);
  3273. this.e2 = e2fn(this.es);
  3274. this.e3 = e3fn(this.es);
  3275. this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0); //si que des zeros le calcul ne se fait pas
  3276. };
  3277. /* Polyconic forward equations--mapping lat,long to x,y
  3278. ---------------------------------------------------*/
  3279. exports.forward = function (p) {
  3280. var lon = p.x;
  3281. var lat = p.y;
  3282. var x, y, el;
  3283. var dlon = adjust_lon(lon - this.long0);
  3284. el = dlon * Math.sin(lat);
  3285. if (this.sphere) {
  3286. if (Math.abs(lat) <= EPSLN) {
  3287. x = this.a * dlon;
  3288. y = -1 * this.a * this.lat0;
  3289. }
  3290. else {
  3291. x = this.a * Math.sin(el) / Math.tan(lat);
  3292. y = this.a * (adjust_lat(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat));
  3293. }
  3294. }
  3295. else {
  3296. if (Math.abs(lat) <= EPSLN) {
  3297. x = this.a * dlon;
  3298. y = -1 * this.ml0;
  3299. }
  3300. else {
  3301. var nl = gN(this.a, this.e, Math.sin(lat)) / Math.tan(lat);
  3302. x = nl * Math.sin(el);
  3303. y = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el));
  3304. }
  3305. }
  3306. p.x = x + this.x0;
  3307. p.y = y + this.y0;
  3308. return p;
  3309. };
  3310. /* Inverse equations
  3311. -----------------*/
  3312. exports.inverse = function (p) {
  3313. var lon, lat, x, y, i;
  3314. var al, bl;
  3315. var phi, dphi;
  3316. x = p.x - this.x0;
  3317. y = p.y - this.y0;
  3318. if (this.sphere) {
  3319. if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
  3320. lon = adjust_lon(x / this.a + this.long0);
  3321. lat = 0;
  3322. }
  3323. else {
  3324. al = this.lat0 + y / this.a;
  3325. bl = x * x / this.a / this.a + al * al;
  3326. phi = al;
  3327. var tanphi;
  3328. for (i = MAX_ITER; i; --i) {
  3329. tanphi = Math.tan(phi);
  3330. dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1);
  3331. phi += dphi;
  3332. if (Math.abs(dphi) <= EPSLN) {
  3333. lat = phi;
  3334. break;
  3335. }
  3336. }
  3337. lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));
  3338. }
  3339. }
  3340. else {
  3341. if (Math.abs(y + this.ml0) <= EPSLN) {
  3342. lat = 0;
  3343. lon = adjust_lon(this.long0 + x / this.a);
  3344. }
  3345. else {
  3346. al = (this.ml0 + y) / this.a;
  3347. bl = x * x / this.a / this.a + al * al;
  3348. phi = al;
  3349. var cl, mln, mlnp, ma;
  3350. var con;
  3351. for (i = MAX_ITER; i; --i) {
  3352. con = this.e * Math.sin(phi);
  3353. cl = Math.sqrt(1 - con * con) * Math.tan(phi);
  3354. mln = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
  3355. mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi);
  3356. ma = mln / this.a;
  3357. dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp);
  3358. phi -= dphi;
  3359. if (Math.abs(dphi) <= EPSLN) {
  3360. lat = phi;
  3361. break;
  3362. }
  3363. }
  3364. //lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
  3365. cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
  3366. lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
  3367. }
  3368. }
  3369. p.x = lon;
  3370. p.y = lat;
  3371. return p;
  3372. };
  3373. exports.names = ["Polyconic", "poly"];
  3374. }, { "../common/adjust_lat": 4, "../common/adjust_lon": 5, "../common/e0fn": 7, "../common/e1fn": 8, "../common/e2fn": 9, "../common/e3fn": 10, "../common/gN": 11, "../common/mlfn": 14 }], 58: [function (_dereq_, module, exports) {
  3375. var adjust_lon = _dereq_('../common/adjust_lon');
  3376. var adjust_lat = _dereq_('../common/adjust_lat');
  3377. var pj_enfn = _dereq_('../common/pj_enfn');
  3378. var MAX_ITER = 20;
  3379. var pj_mlfn = _dereq_('../common/pj_mlfn');
  3380. var pj_inv_mlfn = _dereq_('../common/pj_inv_mlfn');
  3381. var HALF_PI = Math.PI / 2;
  3382. var EPSLN = 1.0e-10;
  3383. var asinz = _dereq_('../common/asinz');
  3384. exports.init = function () {
  3385. /* Place parameters in static storage for common use
  3386. -------------------------------------------------*/
  3387. if (!this.sphere) {
  3388. this.en = pj_enfn(this.es);
  3389. }
  3390. else {
  3391. this.n = 1;
  3392. this.m = 0;
  3393. this.es = 0;
  3394. this.C_y = Math.sqrt((this.m + 1) / this.n);
  3395. this.C_x = this.C_y / (this.m + 1);
  3396. }
  3397. };
  3398. /* Sinusoidal forward equations--mapping lat,long to x,y
  3399. -----------------------------------------------------*/
  3400. exports.forward = function (p) {
  3401. var x, y;
  3402. var lon = p.x;
  3403. var lat = p.y;
  3404. /* Forward equations
  3405. -----------------*/
  3406. lon = adjust_lon(lon - this.long0);
  3407. if (this.sphere) {
  3408. if (!this.m) {
  3409. lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat;
  3410. }
  3411. else {
  3412. var k = this.n * Math.sin(lat);
  3413. for (var i = MAX_ITER; i; --i) {
  3414. var V = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat));
  3415. lat -= V;
  3416. if (Math.abs(V) < EPSLN) {
  3417. break;
  3418. }
  3419. }
  3420. }
  3421. x = this.a * this.C_x * lon * (this.m + Math.cos(lat));
  3422. y = this.a * this.C_y * lat;
  3423. }
  3424. else {
  3425. var s = Math.sin(lat);
  3426. var c = Math.cos(lat);
  3427. y = this.a * pj_mlfn(lat, s, c, this.en);
  3428. x = this.a * lon * c / Math.sqrt(1 - this.es * s * s);
  3429. }
  3430. p.x = x;
  3431. p.y = y;
  3432. return p;
  3433. };
  3434. exports.inverse = function (p) {
  3435. var lat, temp, lon, s;
  3436. p.x -= this.x0;
  3437. lon = p.x / this.a;
  3438. p.y -= this.y0;
  3439. lat = p.y / this.a;
  3440. if (this.sphere) {
  3441. lat /= this.C_y;
  3442. lon = lon / (this.C_x * (this.m + Math.cos(lat)));
  3443. if (this.m) {
  3444. lat = asinz((this.m * lat + Math.sin(lat)) / this.n);
  3445. }
  3446. else if (this.n !== 1) {
  3447. lat = asinz(Math.sin(lat) / this.n);
  3448. }
  3449. lon = adjust_lon(lon + this.long0);
  3450. lat = adjust_lat(lat);
  3451. }
  3452. else {
  3453. lat = pj_inv_mlfn(p.y / this.a, this.es, this.en);
  3454. s = Math.abs(lat);
  3455. if (s < HALF_PI) {
  3456. s = Math.sin(lat);
  3457. temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));
  3458. //temp = this.long0 + p.x / (this.a * Math.cos(lat));
  3459. lon = adjust_lon(temp);
  3460. }
  3461. else if ((s - EPSLN) < HALF_PI) {
  3462. lon = this.long0;
  3463. }
  3464. }
  3465. p.x = lon;
  3466. p.y = lat;
  3467. return p;
  3468. };
  3469. exports.names = ["Sinusoidal", "sinu"];
  3470. }, { "../common/adjust_lat": 4, "../common/adjust_lon": 5, "../common/asinz": 6, "../common/pj_enfn": 17, "../common/pj_inv_mlfn": 18, "../common/pj_mlfn": 19 }], 59: [function (_dereq_, module, exports) {
  3471. /*
  3472. references:
  3473. Formules et constantes pour le Calcul pour la
  3474. projection cylindrique conforme à axe oblique et pour la transformation entre
  3475. des systèmes de référence.
  3476. http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
  3477. */
  3478. exports.init = function () {
  3479. var phy0 = this.lat0;
  3480. this.lambda0 = this.long0;
  3481. var sinPhy0 = Math.sin(phy0);
  3482. var semiMajorAxis = this.a;
  3483. var invF = this.rf;
  3484. var flattening = 1 / invF;
  3485. var e2 = 2 * flattening - Math.pow(flattening, 2);
  3486. var e = this.e = Math.sqrt(e2);
  3487. this.R = this.k0 * semiMajorAxis * Math.sqrt(1 - e2) / (1 - e2 * Math.pow(sinPhy0, 2));
  3488. this.alpha = Math.sqrt(1 + e2 / (1 - e2) * Math.pow(Math.cos(phy0), 4));
  3489. this.b0 = Math.asin(sinPhy0 / this.alpha);
  3490. var k1 = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2));
  3491. var k2 = Math.log(Math.tan(Math.PI / 4 + phy0 / 2));
  3492. var k3 = Math.log((1 + e * sinPhy0) / (1 - e * sinPhy0));
  3493. this.K = k1 - this.alpha * k2 + this.alpha * e / 2 * k3;
  3494. };
  3495. exports.forward = function (p) {
  3496. var Sa1 = Math.log(Math.tan(Math.PI / 4 - p.y / 2));
  3497. var Sa2 = this.e / 2 * Math.log((1 + this.e * Math.sin(p.y)) / (1 - this.e * Math.sin(p.y)));
  3498. var S = -this.alpha * (Sa1 + Sa2) + this.K;
  3499. // spheric latitude
  3500. var b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4);
  3501. // spheric longitude
  3502. var I = this.alpha * (p.x - this.lambda0);
  3503. // psoeudo equatorial rotation
  3504. var rotI = Math.atan(Math.sin(I) / (Math.sin(this.b0) * Math.tan(b) + Math.cos(this.b0) * Math.cos(I)));
  3505. var rotB = Math.asin(Math.cos(this.b0) * Math.sin(b) - Math.sin(this.b0) * Math.cos(b) * Math.cos(I));
  3506. p.y = this.R / 2 * Math.log((1 + Math.sin(rotB)) / (1 - Math.sin(rotB))) + this.y0;
  3507. p.x = this.R * rotI + this.x0;
  3508. return p;
  3509. };
  3510. exports.inverse = function (p) {
  3511. var Y = p.x - this.x0;
  3512. var X = p.y - this.y0;
  3513. var rotI = Y / this.R;
  3514. var rotB = 2 * (Math.atan(Math.exp(X / this.R)) - Math.PI / 4);
  3515. var b = Math.asin(Math.cos(this.b0) * Math.sin(rotB) + Math.sin(this.b0) * Math.cos(rotB) * Math.cos(rotI));
  3516. var I = Math.atan(Math.sin(rotI) / (Math.cos(this.b0) * Math.cos(rotI) - Math.sin(this.b0) * Math.tan(rotB)));
  3517. var lambda = this.lambda0 + I / this.alpha;
  3518. var S = 0;
  3519. var phy = b;
  3520. var prevPhy = -1000;
  3521. var iteration = 0;
  3522. while (Math.abs(phy - prevPhy) > 0.0000001) {
  3523. if (++iteration > 20) {
  3524. //...reportError("omercFwdInfinity");
  3525. return;
  3526. }
  3527. //S = Math.log(Math.tan(Math.PI / 4 + phy / 2));
  3528. S = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(phy)) / 2));
  3529. prevPhy = phy;
  3530. phy = 2 * Math.atan(Math.exp(S)) - Math.PI / 2;
  3531. }
  3532. p.x = lambda;
  3533. p.y = phy;
  3534. return p;
  3535. };
  3536. exports.names = ["somerc"];
  3537. }, {}], 60: [function (_dereq_, module, exports) {
  3538. var HALF_PI = Math.PI / 2;
  3539. var EPSLN = 1.0e-10;
  3540. var sign = _dereq_('../common/sign');
  3541. var msfnz = _dereq_('../common/msfnz');
  3542. var tsfnz = _dereq_('../common/tsfnz');
  3543. var phi2z = _dereq_('../common/phi2z');
  3544. var adjust_lon = _dereq_('../common/adjust_lon');
  3545. exports.ssfn_ = function (phit, sinphi, eccen) {
  3546. sinphi *= eccen;
  3547. return (Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen));
  3548. };
  3549. exports.init = function () {
  3550. this.coslat0 = Math.cos(this.lat0);
  3551. this.sinlat0 = Math.sin(this.lat0);
  3552. if (this.sphere) {
  3553. if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
  3554. this.k0 = 0.5 * (1 + sign(this.lat0) * Math.sin(this.lat_ts));
  3555. }
  3556. }
  3557. else {
  3558. if (Math.abs(this.coslat0) <= EPSLN) {
  3559. if (this.lat0 > 0) {
  3560. //North pole
  3561. //trace('stere:north pole');
  3562. this.con = 1;
  3563. }
  3564. else {
  3565. //South pole
  3566. //trace('stere:south pole');
  3567. this.con = -1;
  3568. }
  3569. }
  3570. this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e));
  3571. if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
  3572. this.k0 = 0.5 * this.cons * msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts));
  3573. }
  3574. this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
  3575. this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
  3576. this.cosX0 = Math.cos(this.X0);
  3577. this.sinX0 = Math.sin(this.X0);
  3578. }
  3579. };
  3580. // Stereographic forward equations--mapping lat,long to x,y
  3581. exports.forward = function (p) {
  3582. var lon = p.x;
  3583. var lat = p.y;
  3584. var sinlat = Math.sin(lat);
  3585. var coslat = Math.cos(lat);
  3586. var A, X, sinX, cosX, ts, rh;
  3587. var dlon = adjust_lon(lon - this.long0);
  3588. if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) {
  3589. //case of the origine point
  3590. //trace('stere:this is the origin point');
  3591. p.x = NaN;
  3592. p.y = NaN;
  3593. return p;
  3594. }
  3595. if (this.sphere) {
  3596. //trace('stere:sphere case');
  3597. A = 2 * this.k0 / (1 + this.sinlat0 * sinlat + this.coslat0 * coslat * Math.cos(dlon));
  3598. p.x = this.a * A * coslat * Math.sin(dlon) + this.x0;
  3599. p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;
  3600. return p;
  3601. }
  3602. else {
  3603. X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI;
  3604. cosX = Math.cos(X);
  3605. sinX = Math.sin(X);
  3606. if (Math.abs(this.coslat0) <= EPSLN) {
  3607. ts = tsfnz(this.e, lat * this.con, this.con * sinlat);
  3608. rh = 2 * this.a * this.k0 * ts / this.cons;
  3609. p.x = this.x0 + rh * Math.sin(lon - this.long0);
  3610. p.y = this.y0 - this.con * rh * Math.cos(lon - this.long0);
  3611. //trace(p.toString());
  3612. return p;
  3613. }
  3614. else if (Math.abs(this.sinlat0) < EPSLN) {
  3615. //Eq
  3616. //trace('stere:equateur');
  3617. A = 2 * this.a * this.k0 / (1 + cosX * Math.cos(dlon));
  3618. p.y = A * sinX;
  3619. }
  3620. else {
  3621. //other case
  3622. //trace('stere:normal case');
  3623. A = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * sinX + this.cosX0 * cosX * Math.cos(dlon)));
  3624. p.y = A * (this.cosX0 * sinX - this.sinX0 * cosX * Math.cos(dlon)) + this.y0;
  3625. }
  3626. p.x = A * cosX * Math.sin(dlon) + this.x0;
  3627. }
  3628. //trace(p.toString());
  3629. return p;
  3630. };
  3631. //* Stereographic inverse equations--mapping x,y to lat/long
  3632. exports.inverse = function (p) {
  3633. p.x -= this.x0;
  3634. p.y -= this.y0;
  3635. var lon, lat, ts, ce, Chi;
  3636. var rh = Math.sqrt(p.x * p.x + p.y * p.y);
  3637. if (this.sphere) {
  3638. var c = 2 * Math.atan(rh / (0.5 * this.a * this.k0));
  3639. lon = this.long0;
  3640. lat = this.lat0;
  3641. if (rh <= EPSLN) {
  3642. p.x = lon;
  3643. p.y = lat;
  3644. return p;
  3645. }
  3646. lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh);
  3647. if (Math.abs(this.coslat0) < EPSLN) {
  3648. if (this.lat0 > 0) {
  3649. lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));
  3650. }
  3651. else {
  3652. lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
  3653. }
  3654. }
  3655. else {
  3656. lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)));
  3657. }
  3658. p.x = lon;
  3659. p.y = lat;
  3660. return p;
  3661. }
  3662. else {
  3663. if (Math.abs(this.coslat0) <= EPSLN) {
  3664. if (rh <= EPSLN) {
  3665. lat = this.lat0;
  3666. lon = this.long0;
  3667. p.x = lon;
  3668. p.y = lat;
  3669. //trace(p.toString());
  3670. return p;
  3671. }
  3672. p.x *= this.con;
  3673. p.y *= this.con;
  3674. ts = rh * this.cons / (2 * this.a * this.k0);
  3675. lat = this.con * phi2z(this.e, ts);
  3676. lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, - 1 * p.y));
  3677. }
  3678. else {
  3679. ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1));
  3680. lon = this.long0;
  3681. if (rh <= EPSLN) {
  3682. Chi = this.X0;
  3683. }
  3684. else {
  3685. Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh);
  3686. lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)));
  3687. }
  3688. lat = -1 * phi2z(this.e, Math.tan(0.5 * (HALF_PI + Chi)));
  3689. }
  3690. }
  3691. p.x = lon;
  3692. p.y = lat;
  3693. //trace(p.toString());
  3694. return p;
  3695. };
  3696. exports.names = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)"];
  3697. }, { "../common/adjust_lon": 5, "../common/msfnz": 15, "../common/phi2z": 16, "../common/sign": 21, "../common/tsfnz": 24 }], 61: [function (_dereq_, module, exports) {
  3698. var gauss = _dereq_('./gauss');
  3699. var adjust_lon = _dereq_('../common/adjust_lon');
  3700. exports.init = function () {
  3701. gauss.init.apply(this);
  3702. if (!this.rc) {
  3703. return;
  3704. }
  3705. this.sinc0 = Math.sin(this.phic0);
  3706. this.cosc0 = Math.cos(this.phic0);
  3707. this.R2 = 2 * this.rc;
  3708. if (!this.title) {
  3709. this.title = "Oblique Stereographic Alternative";
  3710. }
  3711. };
  3712. exports.forward = function (p) {
  3713. var sinc, cosc, cosl, k;
  3714. p.x = adjust_lon(p.x - this.long0);
  3715. gauss.forward.apply(this, [p]);
  3716. sinc = Math.sin(p.y);
  3717. cosc = Math.cos(p.y);
  3718. cosl = Math.cos(p.x);
  3719. k = this.k0 * this.R2 / (1 + this.sinc0 * sinc + this.cosc0 * cosc * cosl);
  3720. p.x = k * cosc * Math.sin(p.x);
  3721. p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl);
  3722. p.x = this.a * p.x + this.x0;
  3723. p.y = this.a * p.y + this.y0;
  3724. return p;
  3725. };
  3726. exports.inverse = function (p) {
  3727. var sinc, cosc, lon, lat, rho;
  3728. p.x = (p.x - this.x0) / this.a;
  3729. p.y = (p.y - this.y0) / this.a;
  3730. p.x /= this.k0;
  3731. p.y /= this.k0;
  3732. if ((rho = Math.sqrt(p.x * p.x + p.y * p.y))) {
  3733. var c = 2 * Math.atan2(rho, this.R2);
  3734. sinc = Math.sin(c);
  3735. cosc = Math.cos(c);
  3736. lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho);
  3737. lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc);
  3738. }
  3739. else {
  3740. lat = this.phic0;
  3741. lon = 0;
  3742. }
  3743. p.x = lon;
  3744. p.y = lat;
  3745. gauss.inverse.apply(this, [p]);
  3746. p.x = adjust_lon(p.x + this.long0);
  3747. return p;
  3748. };
  3749. exports.names = ["Stereographic_North_Pole", "Oblique_Stereographic", "Polar_Stereographic", "sterea", "Oblique Stereographic Alternative"];
  3750. }, { "../common/adjust_lon": 5, "./gauss": 46 }], 62: [function (_dereq_, module, exports) {
  3751. var e0fn = _dereq_('../common/e0fn');
  3752. var e1fn = _dereq_('../common/e1fn');
  3753. var e2fn = _dereq_('../common/e2fn');
  3754. var e3fn = _dereq_('../common/e3fn');
  3755. var mlfn = _dereq_('../common/mlfn');
  3756. var adjust_lon = _dereq_('../common/adjust_lon');
  3757. var HALF_PI = Math.PI / 2;
  3758. var EPSLN = 1.0e-10;
  3759. var sign = _dereq_('../common/sign');
  3760. var asinz = _dereq_('../common/asinz');
  3761. exports.init = function () {
  3762. this.e0 = e0fn(this.es);
  3763. this.e1 = e1fn(this.es);
  3764. this.e2 = e2fn(this.es);
  3765. this.e3 = e3fn(this.es);
  3766. this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
  3767. };
  3768. /**
  3769. Transverse Mercator Forward - long/lat to x/y
  3770. long/lat in radians
  3771. */
  3772. exports.forward = function (p) {
  3773. var lon = p.x;
  3774. var lat = p.y;
  3775. var delta_lon = adjust_lon(lon - this.long0);
  3776. var con;
  3777. var x, y;
  3778. var sin_phi = Math.sin(lat);
  3779. var cos_phi = Math.cos(lat);
  3780. if (this.sphere) {
  3781. var b = cos_phi * Math.sin(delta_lon);
  3782. if ((Math.abs(Math.abs(b) - 1)) < 0.0000000001) {
  3783. return (93);
  3784. }
  3785. else {
  3786. x = 0.5 * this.a * this.k0 * Math.log((1 + b) / (1 - b));
  3787. con = Math.acos(cos_phi * Math.cos(delta_lon) / Math.sqrt(1 - b * b));
  3788. if (lat < 0) {
  3789. con = -con;
  3790. }
  3791. y = this.a * this.k0 * (con - this.lat0);
  3792. }
  3793. }
  3794. else {
  3795. var al = cos_phi * delta_lon;
  3796. var als = Math.pow(al, 2);
  3797. var c = this.ep2 * Math.pow(cos_phi, 2);
  3798. var tq = Math.tan(lat);
  3799. var t = Math.pow(tq, 2);
  3800. con = 1 - this.es * Math.pow(sin_phi, 2);
  3801. var n = this.a / Math.sqrt(con);
  3802. var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat);
  3803. x = this.k0 * n * al * (1 + als / 6 * (1 - t + c + als / 20 * (5 - 18 * t + Math.pow(t, 2) + 72 * c - 58 * this.ep2))) + this.x0;
  3804. y = this.k0 * (ml - this.ml0 + n * tq * (als * (0.5 + als / 24 * (5 - t + 9 * c + 4 * Math.pow(c, 2) + als / 30 * (61 - 58 * t + Math.pow(t, 2) + 600 * c - 330 * this.ep2))))) + this.y0;
  3805. }
  3806. p.x = x;
  3807. p.y = y;
  3808. return p;
  3809. };
  3810. /**
  3811. Transverse Mercator Inverse - x/y to long/lat
  3812. */
  3813. exports.inverse = function (p) {
  3814. var con, phi;
  3815. var delta_phi;
  3816. var i;
  3817. var max_iter = 6;
  3818. var lat, lon;
  3819. if (this.sphere) {
  3820. var f = Math.exp(p.x / (this.a * this.k0));
  3821. var g = 0.5 * (f - 1 / f);
  3822. var temp = this.lat0 + p.y / (this.a * this.k0);
  3823. var h = Math.cos(temp);
  3824. con = Math.sqrt((1 - h * h) / (1 + g * g));
  3825. lat = asinz(con);
  3826. if (temp < 0) {
  3827. lat = -lat;
  3828. }
  3829. if ((g === 0) && (h === 0)) {
  3830. lon = this.long0;
  3831. }
  3832. else {
  3833. lon = adjust_lon(Math.atan2(g, h) + this.long0);
  3834. }
  3835. }
  3836. else { // ellipsoidal form
  3837. var x = p.x - this.x0;
  3838. var y = p.y - this.y0;
  3839. con = (this.ml0 + y / this.k0) / this.a;
  3840. phi = con;
  3841. for (i = 0; true; i++) {
  3842. delta_phi = ((con + this.e1 * Math.sin(2 * phi) - this.e2 * Math.sin(4 * phi) + this.e3 * Math.sin(6 * phi)) / this.e0) - phi;
  3843. phi += delta_phi;
  3844. if (Math.abs(delta_phi) <= EPSLN) {
  3845. break;
  3846. }
  3847. if (i >= max_iter) {
  3848. return (95);
  3849. }
  3850. } // for()
  3851. if (Math.abs(phi) < HALF_PI) {
  3852. var sin_phi = Math.sin(phi);
  3853. var cos_phi = Math.cos(phi);
  3854. var tan_phi = Math.tan(phi);
  3855. var c = this.ep2 * Math.pow(cos_phi, 2);
  3856. var cs = Math.pow(c, 2);
  3857. var t = Math.pow(tan_phi, 2);
  3858. var ts = Math.pow(t, 2);
  3859. con = 1 - this.es * Math.pow(sin_phi, 2);
  3860. var n = this.a / Math.sqrt(con);
  3861. var r = n * (1 - this.es) / con;
  3862. var d = x / (n * this.k0);
  3863. var ds = Math.pow(d, 2);
  3864. lat = phi - (n * tan_phi * ds / r) * (0.5 - ds / 24 * (5 + 3 * t + 10 * c - 4 * cs - 9 * this.ep2 - ds / 30 * (61 + 90 * t + 298 * c + 45 * ts - 252 * this.ep2 - 3 * cs)));
  3865. lon = adjust_lon(this.long0 + (d * (1 - ds / 6 * (1 + 2 * t + c - ds / 20 * (5 - 2 * c + 28 * t - 3 * cs + 8 * this.ep2 + 24 * ts))) / cos_phi));
  3866. }
  3867. else {
  3868. lat = HALF_PI * sign(y);
  3869. lon = this.long0;
  3870. }
  3871. }
  3872. p.x = lon;
  3873. p.y = lat;
  3874. return p;
  3875. };
  3876. exports.names = ["Transverse_Mercator", "Transverse Mercator", "tmerc"];
  3877. }, { "../common/adjust_lon": 5, "../common/asinz": 6, "../common/e0fn": 7, "../common/e1fn": 8, "../common/e2fn": 9, "../common/e3fn": 10, "../common/mlfn": 14, "../common/sign": 21 }], 63: [function (_dereq_, module, exports) {
  3878. var D2R = 0.01745329251994329577;
  3879. var tmerc = _dereq_('./tmerc');
  3880. exports.dependsOn = 'tmerc';
  3881. exports.init = function () {
  3882. if (!this.zone) {
  3883. return;
  3884. }
  3885. this.lat0 = 0;
  3886. this.long0 = ((6 * Math.abs(this.zone)) - 183) * D2R;
  3887. this.x0 = 500000;
  3888. this.y0 = this.utmSouth ? 10000000 : 0;
  3889. this.k0 = 0.9996;
  3890. tmerc.init.apply(this);
  3891. this.forward = tmerc.forward;
  3892. this.inverse = tmerc.inverse;
  3893. };
  3894. exports.names = ["Universal Transverse Mercator System", "utm"];
  3895. }, { "./tmerc": 62 }], 64: [function (_dereq_, module, exports) {
  3896. var adjust_lon = _dereq_('../common/adjust_lon');
  3897. var HALF_PI = Math.PI / 2;
  3898. var EPSLN = 1.0e-10;
  3899. var asinz = _dereq_('../common/asinz');
  3900. /* Initialize the Van Der Grinten projection
  3901. ----------------------------------------*/
  3902. exports.init = function () {
  3903. //this.R = 6370997; //Radius of earth
  3904. this.R = this.a;
  3905. };
  3906. exports.forward = function (p) {
  3907. var lon = p.x;
  3908. var lat = p.y;
  3909. /* Forward equations
  3910. -----------------*/
  3911. var dlon = adjust_lon(lon - this.long0);
  3912. var x, y;
  3913. if (Math.abs(lat) <= EPSLN) {
  3914. x = this.x0 + this.R * dlon;
  3915. y = this.y0;
  3916. }
  3917. var theta = asinz(2 * Math.abs(lat / Math.PI));
  3918. if ((Math.abs(dlon) <= EPSLN) || (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN)) {
  3919. x = this.x0;
  3920. if (lat >= 0) {
  3921. y = this.y0 + Math.PI * this.R * Math.tan(0.5 * theta);
  3922. }
  3923. else {
  3924. y = this.y0 + Math.PI * this.R * -Math.tan(0.5 * theta);
  3925. }
  3926. // return(OK);
  3927. }
  3928. var al = 0.5 * Math.abs((Math.PI / dlon) - (dlon / Math.PI));
  3929. var asq = al * al;
  3930. var sinth = Math.sin(theta);
  3931. var costh = Math.cos(theta);
  3932. var g = costh / (sinth + costh - 1);
  3933. var gsq = g * g;
  3934. var m = g * (2 / sinth - 1);
  3935. var msq = m * m;
  3936. var con = Math.PI * this.R * (al * (g - msq) + Math.sqrt(asq * (g - msq) * (g - msq) - (msq + asq) * (gsq - msq))) / (msq + asq);
  3937. if (dlon < 0) {
  3938. con = -con;
  3939. }
  3940. x = this.x0 + con;
  3941. //con = Math.abs(con / (Math.PI * this.R));
  3942. var q = asq + g;
  3943. con = Math.PI * this.R * (m * q - al * Math.sqrt((msq + asq) * (asq + 1) - q * q)) / (msq + asq);
  3944. if (lat >= 0) {
  3945. //y = this.y0 + Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);
  3946. y = this.y0 + con;
  3947. }
  3948. else {
  3949. //y = this.y0 - Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);
  3950. y = this.y0 - con;
  3951. }
  3952. p.x = x;
  3953. p.y = y;
  3954. return p;
  3955. };
  3956. /* Van Der Grinten inverse equations--mapping x,y to lat/long
  3957. ---------------------------------------------------------*/
  3958. exports.inverse = function (p) {
  3959. var lon, lat;
  3960. var xx, yy, xys, c1, c2, c3;
  3961. var a1;
  3962. var m1;
  3963. var con;
  3964. var th1;
  3965. var d;
  3966. /* inverse equations
  3967. -----------------*/
  3968. p.x -= this.x0;
  3969. p.y -= this.y0;
  3970. con = Math.PI * this.R;
  3971. xx = p.x / con;
  3972. yy = p.y / con;
  3973. xys = xx * xx + yy * yy;
  3974. c1 = -Math.abs(yy) * (1 + xys);
  3975. c2 = c1 - 2 * yy * yy + xx * xx;
  3976. c3 = -2 * c1 + 1 + 2 * yy * yy + xys * xys;
  3977. d = yy * yy / c3 + (2 * c2 * c2 * c2 / c3 / c3 / c3 - 9 * c1 * c2 / c3 / c3) / 27;
  3978. a1 = (c1 - c2 * c2 / 3 / c3) / c3;
  3979. m1 = 2 * Math.sqrt(-a1 / 3);
  3980. con = ((3 * d) / a1) / m1;
  3981. if (Math.abs(con) > 1) {
  3982. if (con >= 0) {
  3983. con = 1;
  3984. }
  3985. else {
  3986. con = -1;
  3987. }
  3988. }
  3989. th1 = Math.acos(con) / 3;
  3990. if (p.y >= 0) {
  3991. lat = (-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
  3992. }
  3993. else {
  3994. lat = -(-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
  3995. }
  3996. if (Math.abs(xx) < EPSLN) {
  3997. lon = this.long0;
  3998. }
  3999. else {
  4000. lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx);
  4001. }
  4002. p.x = lon;
  4003. p.y = lat;
  4004. return p;
  4005. };
  4006. exports.names = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
  4007. }, { "../common/adjust_lon": 5, "../common/asinz": 6 }], 65: [function (_dereq_, module, exports) {
  4008. var D2R = 0.01745329251994329577;
  4009. var R2D = 57.29577951308232088;
  4010. var PJD_3PARAM = 1;
  4011. var PJD_7PARAM = 2;
  4012. var datum_transform = _dereq_('./datum_transform');
  4013. var adjust_axis = _dereq_('./adjust_axis');
  4014. var proj = _dereq_('./Proj');
  4015. var toPoint = _dereq_('./common/toPoint');
  4016. module.exports = function transform(source, dest, point) {
  4017. var wgs84;
  4018. if (Array.isArray(point)) {
  4019. point = toPoint(point);
  4020. }
  4021. function checkNotWGS(source, dest) {
  4022. return ((source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM) && dest.datumCode !== "WGS84");
  4023. }
  4024. // Workaround for datum shifts towgs84, if either source or destination projection is not wgs84
  4025. if (source.datum && dest.datum && (checkNotWGS(source, dest) || checkNotWGS(dest, source))) {
  4026. wgs84 = new proj('WGS84');
  4027. transform(source, wgs84, point);
  4028. source = wgs84;
  4029. }
  4030. // DGR, 2010/11/12
  4031. if (source.axis !== "enu") {
  4032. adjust_axis(source, false, point);
  4033. }
  4034. // Transform source points to long/lat, if they aren't already.
  4035. if (source.projName === "longlat") {
  4036. point.x *= D2R; // convert degrees to radians
  4037. point.y *= D2R;
  4038. }
  4039. else {
  4040. if (source.to_meter) {
  4041. point.x *= source.to_meter;
  4042. point.y *= source.to_meter;
  4043. }
  4044. source.inverse(point); // Convert Cartesian to longlat
  4045. }
  4046. // Adjust for the prime meridian if necessary
  4047. if (source.from_greenwich) {
  4048. point.x += source.from_greenwich;
  4049. }
  4050. // Convert datums if needed, and if possible.
  4051. point = datum_transform(source.datum, dest.datum, point);
  4052. // Adjust for the prime meridian if necessary
  4053. if (dest.from_greenwich) {
  4054. point.x -= dest.from_greenwich;
  4055. }
  4056. if (dest.projName === "longlat") {
  4057. // convert radians to decimal degrees
  4058. point.x *= R2D;
  4059. point.y *= R2D;
  4060. }
  4061. else { // else project
  4062. dest.forward(point);
  4063. if (dest.to_meter) {
  4064. point.x /= dest.to_meter;
  4065. point.y /= dest.to_meter;
  4066. }
  4067. }
  4068. // DGR, 2010/11/12
  4069. if (dest.axis !== "enu") {
  4070. adjust_axis(dest, true, point);
  4071. }
  4072. return point;
  4073. };
  4074. }, { "./Proj": 2, "./adjust_axis": 3, "./common/toPoint": 23, "./datum_transform": 31 }], 66: [function (_dereq_, module, exports) {
  4075. var D2R = 0.01745329251994329577;
  4076. var extend = _dereq_('./extend');
  4077. function mapit(obj, key, v) {
  4078. obj[key] = v.map(function (aa) {
  4079. var o = {};
  4080. sExpr(aa, o);
  4081. return o;
  4082. }).reduce(function (a, b) {
  4083. return extend(a, b);
  4084. }, {});
  4085. }
  4086. function sExpr(v, obj) {
  4087. var key;
  4088. if (!Array.isArray(v)) {
  4089. obj[v] = true;
  4090. return;
  4091. }
  4092. else {
  4093. key = v.shift();
  4094. if (key === 'PARAMETER') {
  4095. key = v.shift();
  4096. }
  4097. if (v.length === 1) {
  4098. if (Array.isArray(v[0])) {
  4099. obj[key] = {};
  4100. sExpr(v[0], obj[key]);
  4101. }
  4102. else {
  4103. obj[key] = v[0];
  4104. }
  4105. }
  4106. else if (!v.length) {
  4107. obj[key] = true;
  4108. }
  4109. else if (key === 'TOWGS84') {
  4110. obj[key] = v;
  4111. }
  4112. else {
  4113. obj[key] = {};
  4114. if (['UNIT', 'PRIMEM', 'VERT_DATUM'].indexOf(key) > -1) {
  4115. obj[key] = {
  4116. name: v[0].toLowerCase(),
  4117. convert: v[1]
  4118. };
  4119. if (v.length === 3) {
  4120. obj[key].auth = v[2];
  4121. }
  4122. }
  4123. else if (key === 'SPHEROID') {
  4124. obj[key] = {
  4125. name: v[0],
  4126. a: v[1],
  4127. rf: v[2]
  4128. };
  4129. if (v.length === 4) {
  4130. obj[key].auth = v[3];
  4131. }
  4132. }
  4133. else if (['GEOGCS', 'GEOCCS', 'DATUM', 'VERT_CS', 'COMPD_CS', 'LOCAL_CS', 'FITTED_CS', 'LOCAL_DATUM'].indexOf(key) > -1) {
  4134. v[0] = ['name', v[0]];
  4135. mapit(obj, key, v);
  4136. }
  4137. else if (v.every(function (aa) {
  4138. return Array.isArray(aa);
  4139. })) {
  4140. mapit(obj, key, v);
  4141. }
  4142. else {
  4143. sExpr(v, obj[key]);
  4144. }
  4145. }
  4146. }
  4147. }
  4148. function rename(obj, params) {
  4149. var outName = params[0];
  4150. var inName = params[1];
  4151. if (!(outName in obj) && (inName in obj)) {
  4152. obj[outName] = obj[inName];
  4153. if (params.length === 3) {
  4154. obj[outName] = params[2](obj[outName]);
  4155. }
  4156. }
  4157. }
  4158. function d2r(input) {
  4159. return input * D2R;
  4160. }
  4161. function cleanWKT(wkt) {
  4162. if (wkt.type === 'GEOGCS') {
  4163. wkt.projName = 'longlat';
  4164. }
  4165. else if (wkt.type === 'LOCAL_CS') {
  4166. wkt.projName = 'identity';
  4167. wkt.local = true;
  4168. }
  4169. else {
  4170. if (typeof wkt.PROJECTION === "object") {
  4171. wkt.projName = Object.keys(wkt.PROJECTION)[0];
  4172. }
  4173. else {
  4174. wkt.projName = wkt.PROJECTION;
  4175. }
  4176. }
  4177. if (wkt.UNIT) {
  4178. wkt.units = wkt.UNIT.name.toLowerCase();
  4179. if (wkt.units === 'metre') {
  4180. wkt.units = 'meter';
  4181. }
  4182. if (wkt.UNIT.convert) {
  4183. if (wkt.type === 'GEOGCS') {
  4184. if (wkt.DATUM && wkt.DATUM.SPHEROID) {
  4185. wkt.to_meter = parseFloat(wkt.UNIT.convert, 10) * wkt.DATUM.SPHEROID.a;
  4186. }
  4187. } else {
  4188. wkt.to_meter = parseFloat(wkt.UNIT.convert, 10);
  4189. }
  4190. }
  4191. }
  4192. if (wkt.GEOGCS) {
  4193. //if(wkt.GEOGCS.PRIMEM&&wkt.GEOGCS.PRIMEM.convert){
  4194. // wkt.from_greenwich=wkt.GEOGCS.PRIMEM.convert*D2R;
  4195. //}
  4196. if (wkt.GEOGCS.DATUM) {
  4197. wkt.datumCode = wkt.GEOGCS.DATUM.name.toLowerCase();
  4198. }
  4199. else {
  4200. wkt.datumCode = wkt.GEOGCS.name.toLowerCase();
  4201. }
  4202. if (wkt.datumCode.slice(0, 2) === 'd_') {
  4203. wkt.datumCode = wkt.datumCode.slice(2);
  4204. }
  4205. if (wkt.datumCode === 'new_zealand_geodetic_datum_1949' || wkt.datumCode === 'new_zealand_1949') {
  4206. wkt.datumCode = 'nzgd49';
  4207. }
  4208. if (wkt.datumCode === "wgs_1984") {
  4209. if (wkt.PROJECTION === 'Mercator_Auxiliary_Sphere') {
  4210. wkt.sphere = true;
  4211. }
  4212. wkt.datumCode = 'wgs84';
  4213. }
  4214. if (wkt.datumCode.slice(-6) === '_ferro') {
  4215. wkt.datumCode = wkt.datumCode.slice(0, - 6);
  4216. }
  4217. if (wkt.datumCode.slice(-8) === '_jakarta') {
  4218. wkt.datumCode = wkt.datumCode.slice(0, - 8);
  4219. }
  4220. if (~wkt.datumCode.indexOf('belge')) {
  4221. wkt.datumCode = "rnb72";
  4222. }
  4223. if (wkt.GEOGCS.DATUM && wkt.GEOGCS.DATUM.SPHEROID) {
  4224. wkt.ellps = wkt.GEOGCS.DATUM.SPHEROID.name.replace('_19', '').replace(/[Cc]larke\_18/, 'clrk');
  4225. if (wkt.ellps.toLowerCase().slice(0, 13) === "international") {
  4226. wkt.ellps = 'intl';
  4227. }
  4228. wkt.a = wkt.GEOGCS.DATUM.SPHEROID.a;
  4229. wkt.rf = parseFloat(wkt.GEOGCS.DATUM.SPHEROID.rf, 10);
  4230. }
  4231. if (~wkt.datumCode.indexOf('osgb_1936')) {
  4232. wkt.datumCode = "osgb36";
  4233. }
  4234. }
  4235. if (wkt.b && !isFinite(wkt.b)) {
  4236. wkt.b = wkt.a;
  4237. }
  4238. function toMeter(input) {
  4239. var ratio = wkt.to_meter || 1;
  4240. return parseFloat(input, 10) * ratio;
  4241. }
  4242. var renamer = function (a) {
  4243. return rename(wkt, a);
  4244. };
  4245. var list = [
  4246. ['standard_parallel_1', 'Standard_Parallel_1'],
  4247. ['standard_parallel_2', 'Standard_Parallel_2'],
  4248. ['false_easting', 'False_Easting'],
  4249. ['false_northing', 'False_Northing'],
  4250. ['central_meridian', 'Central_Meridian'],
  4251. ['latitude_of_origin', 'Latitude_Of_Origin'],
  4252. ['latitude_of_origin', 'Central_Parallel'],
  4253. ['scale_factor', 'Scale_Factor'],
  4254. ['k0', 'scale_factor'],
  4255. ['latitude_of_center', 'Latitude_of_center'],
  4256. ['lat0', 'latitude_of_center', d2r],
  4257. ['longitude_of_center', 'Longitude_Of_Center'],
  4258. ['longc', 'longitude_of_center', d2r],
  4259. ['x0', 'false_easting', toMeter],
  4260. ['y0', 'false_northing', toMeter],
  4261. ['long0', 'central_meridian', d2r],
  4262. ['lat0', 'latitude_of_origin', d2r],
  4263. ['lat0', 'standard_parallel_1', d2r],
  4264. ['lat1', 'standard_parallel_1', d2r],
  4265. ['lat2', 'standard_parallel_2', d2r],
  4266. ['alpha', 'azimuth', d2r],
  4267. ['srsCode', 'name']
  4268. ];
  4269. list.forEach(renamer);
  4270. if (!wkt.long0 && wkt.longc && (wkt.projName === 'Albers_Conic_Equal_Area' || wkt.projName === "Lambert_Azimuthal_Equal_Area")) {
  4271. wkt.long0 = wkt.longc;
  4272. }
  4273. if (!wkt.lat_ts && wkt.lat1 && (wkt.projName === 'Stereographic_South_Pole' || wkt.projName === 'Polar Stereographic (variant B)')) {
  4274. wkt.lat0 = d2r(wkt.lat1 > 0 ? 90 : -90);
  4275. wkt.lat_ts = wkt.lat1;
  4276. }
  4277. }
  4278. module.exports = function (wkt, self) {
  4279. var lisp = JSON.parse(("," + wkt).replace(/\s*\,\s*([A-Z_0-9]+?)(\[)/g, ',["$1",').slice(1).replace(/\s*\,\s*([A-Z_0-9]+?)\]/g, ',"$1"]').replace(/,\["VERTCS".+/, ''));
  4280. var type = lisp.shift();
  4281. var name = lisp.shift();
  4282. lisp.unshift(['name', name]);
  4283. lisp.unshift(['type', type]);
  4284. lisp.unshift('output');
  4285. var obj = {};
  4286. sExpr(lisp, obj);
  4287. cleanWKT(obj.output);
  4288. return extend(self, obj.output);
  4289. };
  4290. }, { "./extend": 34 }], 67: [function (_dereq_, module, exports) {
  4291. /**
  4292. * UTM zones are grouped, and assigned to one of a group of 6
  4293. * sets.
  4294. *
  4295. * {int} @private
  4296. */
  4297. var NUM_100K_SETS = 6;
  4298. /**
  4299. * The column letters (for easting) of the lower left value, per
  4300. * set.
  4301. *
  4302. * {string} @private
  4303. */
  4304. var SET_ORIGIN_COLUMN_LETTERS = 'AJSAJS';
  4305. /**
  4306. * The row letters (for northing) of the lower left value, per
  4307. * set.
  4308. *
  4309. * {string} @private
  4310. */
  4311. var SET_ORIGIN_ROW_LETTERS = 'AFAFAF';
  4312. var A = 65; // A
  4313. var I = 73; // I
  4314. var O = 79; // O
  4315. var V = 86; // V
  4316. var Z = 90; // Z
  4317. /**
  4318. * Conversion of lat/lon to MGRS.
  4319. *
  4320. * @param {object} ll Object literal with lat and lon properties on a
  4321. * WGS84 ellipsoid.
  4322. * @param {int} accuracy Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for
  4323. * 100 m, 2 for 1000 m or 1 for 10000 m). Optional, default is 5.
  4324. * @return {string} the MGRS string for the given location and accuracy.
  4325. */
  4326. exports.forward = function (ll, accuracy) {
  4327. accuracy = accuracy || 5; // default accuracy 1m
  4328. return encode(LLtoUTM({
  4329. lat: ll[1],
  4330. lon: ll[0]
  4331. }), accuracy);
  4332. };
  4333. /**
  4334. * Conversion of MGRS to lat/lon.
  4335. *
  4336. * @param {string} mgrs MGRS string.
  4337. * @return {array} An array with left (longitude), bottom (latitude), right
  4338. * (longitude) and top (latitude) values in WGS84, representing the
  4339. * bounding box for the provided MGRS reference.
  4340. */
  4341. exports.inverse = function (mgrs) {
  4342. var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
  4343. if (bbox.lat && bbox.lon) {
  4344. return [bbox.lon, bbox.lat, bbox.lon, bbox.lat];
  4345. }
  4346. return [bbox.left, bbox.bottom, bbox.right, bbox.top];
  4347. };
  4348. exports.toPoint = function (mgrs) {
  4349. var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
  4350. if (bbox.lat && bbox.lon) {
  4351. return [bbox.lon, bbox.lat];
  4352. }
  4353. return [(bbox.left + bbox.right) / 2, (bbox.top + bbox.bottom) / 2];
  4354. };
  4355. /**
  4356. * Conversion from degrees to radians.
  4357. *
  4358. * @private
  4359. * @param {number} deg the angle in degrees.
  4360. * @return {number} the angle in radians.
  4361. */
  4362. function degToRad(deg) {
  4363. return (deg * (Math.PI / 180.0));
  4364. }
  4365. /**
  4366. * Conversion from radians to degrees.
  4367. *
  4368. * @private
  4369. * @param {number} rad the angle in radians.
  4370. * @return {number} the angle in degrees.
  4371. */
  4372. function radToDeg(rad) {
  4373. return (180.0 * (rad / Math.PI));
  4374. }
  4375. /**
  4376. * Converts a set of Longitude and Latitude co-ordinates to UTM
  4377. * using the WGS84 ellipsoid.
  4378. *
  4379. * @private
  4380. * @param {object} ll Object literal with lat and lon properties
  4381. * representing the WGS84 coordinate to be converted.
  4382. * @return {object} Object literal containing the UTM value with easting,
  4383. * northing, zoneNumber and zoneLetter properties, and an optional
  4384. * accuracy property in digits. Returns null if the conversion failed.
  4385. */
  4386. function LLtoUTM(ll) {
  4387. var Lat = ll.lat;
  4388. var Long = ll.lon;
  4389. var a = 6378137.0; //ellip.radius;
  4390. var eccSquared = 0.00669438; //ellip.eccsq;
  4391. var k0 = 0.9996;
  4392. var LongOrigin;
  4393. var eccPrimeSquared;
  4394. var N, T, C, A, M;
  4395. var LatRad = degToRad(Lat);
  4396. var LongRad = degToRad(Long);
  4397. var LongOriginRad;
  4398. var ZoneNumber;
  4399. // (int)
  4400. ZoneNumber = Math.floor((Long + 180) / 6) + 1;
  4401. //Make sure the longitude 180.00 is in Zone 60
  4402. if (Long === 180) {
  4403. ZoneNumber = 60;
  4404. }
  4405. // Special zone for Norway
  4406. if (Lat >= 56.0 && Lat < 64.0 && Long >= 3.0 && Long < 12.0) {
  4407. ZoneNumber = 32;
  4408. }
  4409. // Special zones for Svalbard
  4410. if (Lat >= 72.0 && Lat < 84.0) {
  4411. if (Long >= 0.0 && Long < 9.0) {
  4412. ZoneNumber = 31;
  4413. }
  4414. else if (Long >= 9.0 && Long < 21.0) {
  4415. ZoneNumber = 33;
  4416. }
  4417. else if (Long >= 21.0 && Long < 33.0) {
  4418. ZoneNumber = 35;
  4419. }
  4420. else if (Long >= 33.0 && Long < 42.0) {
  4421. ZoneNumber = 37;
  4422. }
  4423. }
  4424. LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; //+3 puts origin
  4425. // in middle of
  4426. // zone
  4427. LongOriginRad = degToRad(LongOrigin);
  4428. eccPrimeSquared = (eccSquared) / (1 - eccSquared);
  4429. N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad));
  4430. T = Math.tan(LatRad) * Math.tan(LatRad);
  4431. C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);
  4432. A = Math.cos(LatRad) * (LongRad - LongOriginRad);
  4433. M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - (35 * eccSquared * eccSquared * eccSquared / 3072) * Math.sin(6 * LatRad));
  4434. var UTMEasting = (k0 * N * (A + (1 - T + C) * A * A * A / 6.0 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120.0) + 500000.0);
  4435. var UTMNorthing = (k0 * (M + N * Math.tan(LatRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24.0 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720.0)));
  4436. if (Lat < 0.0) {
  4437. UTMNorthing += 10000000.0; //10000000 meter offset for
  4438. // southern hemisphere
  4439. }
  4440. return {
  4441. northing: Math.round(UTMNorthing),
  4442. easting: Math.round(UTMEasting),
  4443. zoneNumber: ZoneNumber,
  4444. zoneLetter: getLetterDesignator(Lat)
  4445. };
  4446. }
  4447. /**
  4448. * Converts UTM coords to lat/long, using the WGS84 ellipsoid. This is a convenience
  4449. * class where the Zone can be specified as a single string eg."60N" which
  4450. * is then broken down into the ZoneNumber and ZoneLetter.
  4451. *
  4452. * @private
  4453. * @param {object} utm An object literal with northing, easting, zoneNumber
  4454. * and zoneLetter properties. If an optional accuracy property is
  4455. * provided (in meters), a bounding box will be returned instead of
  4456. * latitude and longitude.
  4457. * @return {object} An object literal containing either lat and lon values
  4458. * (if no accuracy was provided), or top, right, bottom and left values
  4459. * for the bounding box calculated according to the provided accuracy.
  4460. * Returns null if the conversion failed.
  4461. */
  4462. function UTMtoLL(utm) {
  4463. var UTMNorthing = utm.northing;
  4464. var UTMEasting = utm.easting;
  4465. var zoneLetter = utm.zoneLetter;
  4466. var zoneNumber = utm.zoneNumber;
  4467. // check the ZoneNummber is valid
  4468. if (zoneNumber < 0 || zoneNumber > 60) {
  4469. return null;
  4470. }
  4471. var k0 = 0.9996;
  4472. var a = 6378137.0; //ellip.radius;
  4473. var eccSquared = 0.00669438; //ellip.eccsq;
  4474. var eccPrimeSquared;
  4475. var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared));
  4476. var N1, T1, C1, R1, D, M;
  4477. var LongOrigin;
  4478. var mu, phi1Rad;
  4479. // remove 500,000 meter offset for longitude
  4480. var x = UTMEasting - 500000.0;
  4481. var y = UTMNorthing;
  4482. // We must know somehow if we are in the Northern or Southern
  4483. // hemisphere, this is the only time we use the letter So even
  4484. // if the Zone letter isn't exactly correct it should indicate
  4485. // the hemisphere correctly
  4486. if (zoneLetter < 'N') {
  4487. y -= 10000000.0; // remove 10,000,000 meter offset used
  4488. // for southern hemisphere
  4489. }
  4490. // There are 60 zones with zone 1 being at West -180 to -174
  4491. LongOrigin = (zoneNumber - 1) * 6 - 180 + 3; // +3 puts origin
  4492. // in middle of
  4493. // zone
  4494. eccPrimeSquared = (eccSquared) / (1 - eccSquared);
  4495. M = y / k0;
  4496. mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));
  4497. phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * Math.sin(6 * mu);
  4498. // double phi1 = ProjMath.radToDeg(phi1Rad);
  4499. N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad));
  4500. T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad);
  4501. C1 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad);
  4502. R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5);
  4503. D = x / (N1 * k0);
  4504. var lat = phi1Rad - (N1 * Math.tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720);
  4505. lat = radToDeg(lat);
  4506. var lon = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad);
  4507. lon = LongOrigin + radToDeg(lon);
  4508. var result;
  4509. if (utm.accuracy) {
  4510. var topRight = UTMtoLL({
  4511. northing: utm.northing + utm.accuracy,
  4512. easting: utm.easting + utm.accuracy,
  4513. zoneLetter: utm.zoneLetter,
  4514. zoneNumber: utm.zoneNumber
  4515. });
  4516. result = {
  4517. top: topRight.lat,
  4518. right: topRight.lon,
  4519. bottom: lat,
  4520. left: lon
  4521. };
  4522. }
  4523. else {
  4524. result = {
  4525. lat: lat,
  4526. lon: lon
  4527. };
  4528. }
  4529. return result;
  4530. }
  4531. /**
  4532. * Calculates the MGRS letter designator for the given latitude.
  4533. *
  4534. * @private
  4535. * @param {number} lat The latitude in WGS84 to get the letter designator
  4536. * for.
  4537. * @return {char} The letter designator.
  4538. */
  4539. function getLetterDesignator(lat) {
  4540. //This is here as an error flag to show that the Latitude is
  4541. //outside MGRS limits
  4542. var LetterDesignator = 'Z';
  4543. if ((84 >= lat) && (lat >= 72)) {
  4544. LetterDesignator = 'X';
  4545. }
  4546. else if ((72 > lat) && (lat >= 64)) {
  4547. LetterDesignator = 'W';
  4548. }
  4549. else if ((64 > lat) && (lat >= 56)) {
  4550. LetterDesignator = 'V';
  4551. }
  4552. else if ((56 > lat) && (lat >= 48)) {
  4553. LetterDesignator = 'U';
  4554. }
  4555. else if ((48 > lat) && (lat >= 40)) {
  4556. LetterDesignator = 'T';
  4557. }
  4558. else if ((40 > lat) && (lat >= 32)) {
  4559. LetterDesignator = 'S';
  4560. }
  4561. else if ((32 > lat) && (lat >= 24)) {
  4562. LetterDesignator = 'R';
  4563. }
  4564. else if ((24 > lat) && (lat >= 16)) {
  4565. LetterDesignator = 'Q';
  4566. }
  4567. else if ((16 > lat) && (lat >= 8)) {
  4568. LetterDesignator = 'P';
  4569. }
  4570. else if ((8 > lat) && (lat >= 0)) {
  4571. LetterDesignator = 'N';
  4572. }
  4573. else if ((0 > lat) && (lat >= -8)) {
  4574. LetterDesignator = 'M';
  4575. }
  4576. else if ((-8 > lat) && (lat >= -16)) {
  4577. LetterDesignator = 'L';
  4578. }
  4579. else if ((-16 > lat) && (lat >= -24)) {
  4580. LetterDesignator = 'K';
  4581. }
  4582. else if ((-24 > lat) && (lat >= -32)) {
  4583. LetterDesignator = 'J';
  4584. }
  4585. else if ((-32 > lat) && (lat >= -40)) {
  4586. LetterDesignator = 'H';
  4587. }
  4588. else if ((-40 > lat) && (lat >= -48)) {
  4589. LetterDesignator = 'G';
  4590. }
  4591. else if ((-48 > lat) && (lat >= -56)) {
  4592. LetterDesignator = 'F';
  4593. }
  4594. else if ((-56 > lat) && (lat >= -64)) {
  4595. LetterDesignator = 'E';
  4596. }
  4597. else if ((-64 > lat) && (lat >= -72)) {
  4598. LetterDesignator = 'D';
  4599. }
  4600. else if ((-72 > lat) && (lat >= -80)) {
  4601. LetterDesignator = 'C';
  4602. }
  4603. return LetterDesignator;
  4604. }
  4605. /**
  4606. * Encodes a UTM location as MGRS string.
  4607. *
  4608. * @private
  4609. * @param {object} utm An object literal with easting, northing,
  4610. * zoneLetter, zoneNumber
  4611. * @param {number} accuracy Accuracy in digits (1-5).
  4612. * @return {string} MGRS string for the given UTM location.
  4613. */
  4614. function encode(utm, accuracy) {
  4615. // prepend with leading zeroes
  4616. var seasting = "00000" + utm.easting,
  4617. snorthing = "00000" + utm.northing;
  4618. return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);
  4619. }
  4620. /**
  4621. * Get the two letter 100k designator for a given UTM easting,
  4622. * northing and zone number value.
  4623. *
  4624. * @private
  4625. * @param {number} easting
  4626. * @param {number} northing
  4627. * @param {number} zoneNumber
  4628. * @return the two letter 100k designator for the given UTM location.
  4629. */
  4630. function get100kID(easting, northing, zoneNumber) {
  4631. var setParm = get100kSetForZone(zoneNumber);
  4632. var setColumn = Math.floor(easting / 100000);
  4633. var setRow = Math.floor(northing / 100000) % 20;
  4634. return getLetter100kID(setColumn, setRow, setParm);
  4635. }
  4636. /**
  4637. * Given a UTM zone number, figure out the MGRS 100K set it is in.
  4638. *
  4639. * @private
  4640. * @param {number} i An UTM zone number.
  4641. * @return {number} the 100k set the UTM zone is in.
  4642. */
  4643. function get100kSetForZone(i) {
  4644. var setParm = i % NUM_100K_SETS;
  4645. if (setParm === 0) {
  4646. setParm = NUM_100K_SETS;
  4647. }
  4648. return setParm;
  4649. }
  4650. /**
  4651. * Get the two-letter MGRS 100k designator given information
  4652. * translated from the UTM northing, easting and zone number.
  4653. *
  4654. * @private
  4655. * @param {number} column the column index as it relates to the MGRS
  4656. * 100k set spreadsheet, created from the UTM easting.
  4657. * Values are 1-8.
  4658. * @param {number} row the row index as it relates to the MGRS 100k set
  4659. * spreadsheet, created from the UTM northing value. Values
  4660. * are from 0-19.
  4661. * @param {number} parm the set block, as it relates to the MGRS 100k set
  4662. * spreadsheet, created from the UTM zone. Values are from
  4663. * 1-60.
  4664. * @return two letter MGRS 100k code.
  4665. */
  4666. function getLetter100kID(column, row, parm) {
  4667. // colOrigin and rowOrigin are the letters at the origin of the set
  4668. var index = parm - 1;
  4669. var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index);
  4670. var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index);
  4671. // colInt and rowInt are the letters to build to return
  4672. var colInt = colOrigin + column - 1;
  4673. var rowInt = rowOrigin + row;
  4674. var rollover = false;
  4675. if (colInt > Z) {
  4676. colInt = colInt - Z + A - 1;
  4677. rollover = true;
  4678. }
  4679. if (colInt === I || (colOrigin < I && colInt > I) || ((colInt > I || colOrigin < I) && rollover)) {
  4680. colInt++;
  4681. }
  4682. if (colInt === O || (colOrigin < O && colInt > O) || ((colInt > O || colOrigin < O) && rollover)) {
  4683. colInt++;
  4684. if (colInt === I) {
  4685. colInt++;
  4686. }
  4687. }
  4688. if (colInt > Z) {
  4689. colInt = colInt - Z + A - 1;
  4690. }
  4691. if (rowInt > V) {
  4692. rowInt = rowInt - V + A - 1;
  4693. rollover = true;
  4694. }
  4695. else {
  4696. rollover = false;
  4697. }
  4698. if (((rowInt === I) || ((rowOrigin < I) && (rowInt > I))) || (((rowInt > I) || (rowOrigin < I)) && rollover)) {
  4699. rowInt++;
  4700. }
  4701. if (((rowInt === O) || ((rowOrigin < O) && (rowInt > O))) || (((rowInt > O) || (rowOrigin < O)) && rollover)) {
  4702. rowInt++;
  4703. if (rowInt === I) {
  4704. rowInt++;
  4705. }
  4706. }
  4707. if (rowInt > V) {
  4708. rowInt = rowInt - V + A - 1;
  4709. }
  4710. var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt);
  4711. return twoLetter;
  4712. }
  4713. /**
  4714. * Decode the UTM parameters from a MGRS string.
  4715. *
  4716. * @private
  4717. * @param {string} mgrsString an UPPERCASE coordinate string is expected.
  4718. * @return {object} An object literal with easting, northing, zoneLetter,
  4719. * zoneNumber and accuracy (in meters) properties.
  4720. */
  4721. function decode(mgrsString) {
  4722. if (mgrsString && mgrsString.length === 0) {
  4723. throw ("MGRSPoint coverting from nothing");
  4724. }
  4725. var length = mgrsString.length;
  4726. var hunK = null;
  4727. var sb = "";
  4728. var testChar;
  4729. var i = 0;
  4730. // get Zone number
  4731. while (!(/[A-Z]/).test(testChar = mgrsString.charAt(i))) {
  4732. if (i >= 2) {
  4733. throw ("MGRSPoint bad conversion from: " + mgrsString);
  4734. }
  4735. sb += testChar;
  4736. i++;
  4737. }
  4738. var zoneNumber = parseInt(sb, 10);
  4739. if (i === 0 || i + 3 > length) {
  4740. // A good MGRS string has to be 4-5 digits long,
  4741. // ##AAA/#AAA at least.
  4742. throw ("MGRSPoint bad conversion from: " + mgrsString);
  4743. }
  4744. var zoneLetter = mgrsString.charAt(i++);
  4745. // Should we check the zone letter here? Why not.
  4746. if (zoneLetter <= 'A' || zoneLetter === 'B' || zoneLetter === 'Y' || zoneLetter >= 'Z' || zoneLetter === 'I' || zoneLetter === 'O') {
  4747. throw ("MGRSPoint zone letter " + zoneLetter + " not handled: " + mgrsString);
  4748. }
  4749. hunK = mgrsString.substring(i, i += 2);
  4750. var set = get100kSetForZone(zoneNumber);
  4751. var east100k = getEastingFromChar(hunK.charAt(0), set);
  4752. var north100k = getNorthingFromChar(hunK.charAt(1), set);
  4753. // We have a bug where the northing may be 2000000 too low.
  4754. // How
  4755. // do we know when to roll over?
  4756. while (north100k < getMinNorthing(zoneLetter)) {
  4757. north100k += 2000000;
  4758. }
  4759. // calculate the char index for easting/northing separator
  4760. var remainder = length - i;
  4761. if (remainder % 2 !== 0) {
  4762. throw ("MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters" + mgrsString);
  4763. }
  4764. var sep = remainder / 2;
  4765. var sepEasting = 0.0;
  4766. var sepNorthing = 0.0;
  4767. var accuracyBonus, sepEastingString, sepNorthingString, easting, northing;
  4768. if (sep > 0) {
  4769. accuracyBonus = 100000.0 / Math.pow(10, sep);
  4770. sepEastingString = mgrsString.substring(i, i + sep);
  4771. sepEasting = parseFloat(sepEastingString) * accuracyBonus;
  4772. sepNorthingString = mgrsString.substring(i + sep);
  4773. sepNorthing = parseFloat(sepNorthingString) * accuracyBonus;
  4774. }
  4775. easting = sepEasting + east100k;
  4776. northing = sepNorthing + north100k;
  4777. return {
  4778. easting: easting,
  4779. northing: northing,
  4780. zoneLetter: zoneLetter,
  4781. zoneNumber: zoneNumber,
  4782. accuracy: accuracyBonus
  4783. };
  4784. }
  4785. /**
  4786. * Given the first letter from a two-letter MGRS 100k zone, and given the
  4787. * MGRS table set for the zone number, figure out the easting value that
  4788. * should be added to the other, secondary easting value.
  4789. *
  4790. * @private
  4791. * @param {char} e The first letter from a two-letter MGRS 100´k zone.
  4792. * @param {number} set The MGRS table set for the zone number.
  4793. * @return {number} The easting value for the given letter and set.
  4794. */
  4795. function getEastingFromChar(e, set) {
  4796. // colOrigin is the letter at the origin of the set for the
  4797. // column
  4798. var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1);
  4799. var eastingValue = 100000.0;
  4800. var rewindMarker = false;
  4801. while (curCol !== e.charCodeAt(0)) {
  4802. curCol++;
  4803. if (curCol === I) {
  4804. curCol++;
  4805. }
  4806. if (curCol === O) {
  4807. curCol++;
  4808. }
  4809. if (curCol > Z) {
  4810. if (rewindMarker) {
  4811. throw ("Bad character: " + e);
  4812. }
  4813. curCol = A;
  4814. rewindMarker = true;
  4815. }
  4816. eastingValue += 100000.0;
  4817. }
  4818. return eastingValue;
  4819. }
  4820. /**
  4821. * Given the second letter from a two-letter MGRS 100k zone, and given the
  4822. * MGRS table set for the zone number, figure out the northing value that
  4823. * should be added to the other, secondary northing value. You have to
  4824. * remember that Northings are determined from the equator, and the vertical
  4825. * cycle of letters mean a 2000000 additional northing meters. This happens
  4826. * approx. every 18 degrees of latitude. This method does *NOT* count any
  4827. * additional northings. You have to figure out how many 2000000 meters need
  4828. * to be added for the zone letter of the MGRS coordinate.
  4829. *
  4830. * @private
  4831. * @param {char} n Second letter of the MGRS 100k zone
  4832. * @param {number} set The MGRS table set number, which is dependent on the
  4833. * UTM zone number.
  4834. * @return {number} The northing value for the given letter and set.
  4835. */
  4836. function getNorthingFromChar(n, set) {
  4837. if (n > 'V') {
  4838. throw ("MGRSPoint given invalid Northing " + n);
  4839. }
  4840. // rowOrigin is the letter at the origin of the set for the
  4841. // column
  4842. var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1);
  4843. var northingValue = 0.0;
  4844. var rewindMarker = false;
  4845. while (curRow !== n.charCodeAt(0)) {
  4846. curRow++;
  4847. if (curRow === I) {
  4848. curRow++;
  4849. }
  4850. if (curRow === O) {
  4851. curRow++;
  4852. }
  4853. // fixing a bug making whole application hang in this loop
  4854. // when 'n' is a wrong character
  4855. if (curRow > V) {
  4856. if (rewindMarker) { // making sure that this loop ends
  4857. throw ("Bad character: " + n);
  4858. }
  4859. curRow = A;
  4860. rewindMarker = true;
  4861. }
  4862. northingValue += 100000.0;
  4863. }
  4864. return northingValue;
  4865. }
  4866. /**
  4867. * The function getMinNorthing returns the minimum northing value of a MGRS
  4868. * zone.
  4869. *
  4870. * Ported from Geotrans' c Lattitude_Band_Value structure table.
  4871. *
  4872. * @private
  4873. * @param {char} zoneLetter The MGRS zone to get the min northing for.
  4874. * @return {number}
  4875. */
  4876. function getMinNorthing(zoneLetter) {
  4877. var northing;
  4878. switch (zoneLetter) {
  4879. case 'C':
  4880. northing = 1100000.0;
  4881. break;
  4882. case 'D':
  4883. northing = 2000000.0;
  4884. break;
  4885. case 'E':
  4886. northing = 2800000.0;
  4887. break;
  4888. case 'F':
  4889. northing = 3700000.0;
  4890. break;
  4891. case 'G':
  4892. northing = 4600000.0;
  4893. break;
  4894. case 'H':
  4895. northing = 5500000.0;
  4896. break;
  4897. case 'J':
  4898. northing = 6400000.0;
  4899. break;
  4900. case 'K':
  4901. northing = 7300000.0;
  4902. break;
  4903. case 'L':
  4904. northing = 8200000.0;
  4905. break;
  4906. case 'M':
  4907. northing = 9100000.0;
  4908. break;
  4909. case 'N':
  4910. northing = 0.0;
  4911. break;
  4912. case 'P':
  4913. northing = 800000.0;
  4914. break;
  4915. case 'Q':
  4916. northing = 1700000.0;
  4917. break;
  4918. case 'R':
  4919. northing = 2600000.0;
  4920. break;
  4921. case 'S':
  4922. northing = 3500000.0;
  4923. break;
  4924. case 'T':
  4925. northing = 4400000.0;
  4926. break;
  4927. case 'U':
  4928. northing = 5300000.0;
  4929. break;
  4930. case 'V':
  4931. northing = 6200000.0;
  4932. break;
  4933. case 'W':
  4934. northing = 7000000.0;
  4935. break;
  4936. case 'X':
  4937. northing = 7900000.0;
  4938. break;
  4939. default:
  4940. northing = -1.0;
  4941. }
  4942. if (northing >= 0.0) {
  4943. return northing;
  4944. }
  4945. else {
  4946. throw ("Invalid zone letter: " + zoneLetter);
  4947. }
  4948. }
  4949. }, {}], 68: [function (_dereq_, module, exports) {
  4950. module.exports = {
  4951. "name": "proj4",
  4952. "version": "2.3.14",
  4953. "description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
  4954. "main": "lib/index.js",
  4955. "directories": {
  4956. "test": "test",
  4957. "doc": "docs"
  4958. },
  4959. "scripts": {
  4960. "test": "./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"
  4961. },
  4962. "repository": {
  4963. "type": "git",
  4964. "url": "git://github.com/proj4js/proj4js.git"
  4965. },
  4966. "author": "",
  4967. "license": "MIT",
  4968. "jam": {
  4969. "main": "dist/proj4.js",
  4970. "include": [
  4971. "dist/proj4.js",
  4972. "README.md",
  4973. "AUTHORS",
  4974. "LICENSE.md"
  4975. ]
  4976. },
  4977. "devDependencies": {
  4978. "grunt-cli": "~0.1.13",
  4979. "grunt": "~0.4.2",
  4980. "grunt-contrib-connect": "~0.6.0",
  4981. "grunt-contrib-jshint": "~0.8.0",
  4982. "chai": "~1.8.1",
  4983. "mocha": "~1.17.1",
  4984. "grunt-mocha-phantomjs": "~0.4.0",
  4985. "browserify": "~12.0.1",
  4986. "grunt-browserify": "~4.0.1",
  4987. "grunt-contrib-uglify": "~0.11.1",
  4988. "curl": "git://github.com/cujojs/curl.git",
  4989. "istanbul": "~0.2.4",
  4990. "tin": "~0.4.0"
  4991. },
  4992. "dependencies": {
  4993. "mgrs": "~0.0.2"
  4994. }
  4995. }
  4996. }, {}], "./includedProjections": [function (_dereq_, module, exports) {
  4997. module.exports = _dereq_('hTEDpn');
  4998. }, {}], "hTEDpn": [function (_dereq_, module, exports) {
  4999. var projs = [
  5000. _dereq_('./lib/projections/tmerc'),
  5001. _dereq_('./lib/projections/utm'),
  5002. _dereq_('./lib/projections/sterea'),
  5003. _dereq_('./lib/projections/stere'),
  5004. _dereq_('./lib/projections/somerc'),
  5005. _dereq_('./lib/projections/omerc'),
  5006. _dereq_('./lib/projections/lcc'),
  5007. _dereq_('./lib/projections/krovak'),
  5008. _dereq_('./lib/projections/cass'),
  5009. _dereq_('./lib/projections/laea'),
  5010. _dereq_('./lib/projections/aea'),
  5011. _dereq_('./lib/projections/gnom'),
  5012. _dereq_('./lib/projections/cea'),
  5013. _dereq_('./lib/projections/eqc'),
  5014. _dereq_('./lib/projections/poly'),
  5015. _dereq_('./lib/projections/nzmg'),
  5016. _dereq_('./lib/projections/mill'),
  5017. _dereq_('./lib/projections/sinu'),
  5018. _dereq_('./lib/projections/moll'),
  5019. _dereq_('./lib/projections/eqdc'),
  5020. _dereq_('./lib/projections/vandg'),
  5021. _dereq_('./lib/projections/aeqd')
  5022. ];
  5023. module.exports = function (proj4) {
  5024. projs.forEach(function (proj) {
  5025. proj4.Proj.projections.add(proj);
  5026. });
  5027. }
  5028. }, { "./lib/projections/aea": 40, "./lib/projections/aeqd": 41, "./lib/projections/cass": 42, "./lib/projections/cea": 43, "./lib/projections/eqc": 44, "./lib/projections/eqdc": 45, "./lib/projections/gnom": 47, "./lib/projections/krovak": 48, "./lib/projections/laea": 49, "./lib/projections/lcc": 50, "./lib/projections/mill": 53, "./lib/projections/moll": 54, "./lib/projections/nzmg": 55, "./lib/projections/omerc": 56, "./lib/projections/poly": 57, "./lib/projections/sinu": 58, "./lib/projections/somerc": 59, "./lib/projections/stere": 60, "./lib/projections/sterea": 61, "./lib/projections/tmerc": 62, "./lib/projections/utm": 63, "./lib/projections/vandg": 64 }]
  5029. }, {}, [36])
  5030. (36)
  5031. });