@loaders.gl/shapefile 4.2.0-alpha.4 → 4.2.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/dbf-loader.js +24 -19
  2. package/dist/dist.dev.js +227 -247
  3. package/dist/dist.min.js +12 -0
  4. package/dist/index.cjs +49 -57
  5. package/dist/index.cjs.map +7 -0
  6. package/dist/index.d.ts +6 -6
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/lib/parsers/parse-dbf.d.ts +1 -1
  10. package/dist/lib/parsers/parse-dbf.d.ts.map +1 -1
  11. package/dist/lib/parsers/parse-dbf.js +300 -259
  12. package/dist/lib/parsers/parse-shapefile.d.ts +3 -3
  13. package/dist/lib/parsers/parse-shapefile.d.ts.map +1 -1
  14. package/dist/lib/parsers/parse-shapefile.js +225 -184
  15. package/dist/lib/parsers/parse-shp-geometry.d.ts +1 -1
  16. package/dist/lib/parsers/parse-shp-geometry.d.ts.map +1 -1
  17. package/dist/lib/parsers/parse-shp-geometry.js +260 -168
  18. package/dist/lib/parsers/parse-shp-header.js +33 -23
  19. package/dist/lib/parsers/parse-shp.d.ts +1 -1
  20. package/dist/lib/parsers/parse-shp.d.ts.map +1 -1
  21. package/dist/lib/parsers/parse-shp.js +147 -110
  22. package/dist/lib/parsers/parse-shx.js +19 -15
  23. package/dist/lib/parsers/types.js +0 -1
  24. package/dist/lib/streaming/binary-chunk-reader.js +150 -95
  25. package/dist/lib/streaming/binary-reader.js +49 -23
  26. package/dist/lib/streaming/zip-batch-iterators.js +61 -45
  27. package/dist/shapefile-loader.js +25 -18
  28. package/dist/shp-loader.js +24 -18
  29. package/dist/workers/dbf-worker.js +0 -1
  30. package/dist/workers/shp-worker.js +0 -1
  31. package/package.json +11 -7
  32. package/dist/dbf-loader.js.map +0 -1
  33. package/dist/index.js.map +0 -1
  34. package/dist/lib/parsers/parse-dbf.js.map +0 -1
  35. package/dist/lib/parsers/parse-shapefile.js.map +0 -1
  36. package/dist/lib/parsers/parse-shp-geometry.js.map +0 -1
  37. package/dist/lib/parsers/parse-shp-header.js.map +0 -1
  38. package/dist/lib/parsers/parse-shp.js.map +0 -1
  39. package/dist/lib/parsers/parse-shx.js.map +0 -1
  40. package/dist/lib/parsers/types.js.map +0 -1
  41. package/dist/lib/streaming/binary-chunk-reader.js.map +0 -1
  42. package/dist/lib/streaming/binary-reader.js.map +0 -1
  43. package/dist/lib/streaming/zip-batch-iterators.js.map +0 -1
  44. package/dist/shapefile-loader.js.map +0 -1
  45. package/dist/shp-loader.js.map +0 -1
  46. package/dist/workers/dbf-worker.js.map +0 -1
  47. package/dist/workers/shp-worker.js.map +0 -1
@@ -0,0 +1,12 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
+ "use strict";var __exports__=(()=>{var Oi=Object.create;var Ht=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var Gi=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,qi=Object.prototype.hasOwnProperty;var zi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ji=(t,e)=>{for(var a in e)Ht(t,a,{get:e[a],enumerable:!0})},kt=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gi(e))!qi.call(t,i)&&i!==a&&Ht(t,i,{get:()=>e[i],enumerable:!(s=Bi(e,i))||s.enumerable});return t},Ut=(t,e,a)=>(kt(t,e,"default"),a&&kt(a,e,"default")),ki=(t,e,a)=>(a=t!=null?Oi(Fi(t)):{},kt(e||!t||!t.__esModule?Ht(a,"default",{value:t,enumerable:!0}):a,t)),Hi=t=>kt(Ht({},"__esModule",{value:!0}),t);var He=zi((wh,ke)=>{ke.exports=globalThis.loaders});var zt={};ji(zt,{DBFLoader:()=>Ft,DBFWorkerLoader:()=>je,SHPLoader:()=>Nt,SHPWorkerLoader:()=>_e,ShapefileLoader:()=>Ti,_BinaryChunkReader:()=>ot,_BinaryReader:()=>pe,_zipBatchIterators:()=>me});Ut(zt,ki(He(),1));var ot=class{constructor(e){let{maxRewindBytes:a=0}=e||{};this.offset=0,this.arrayBuffers=[],this.ended=!1,this.maxRewindBytes=a}write(e){this.arrayBuffers.push(e)}end(){this.arrayBuffers=[],this.ended=!0}hasAvailableBytes(e){let a=-this.offset;for(let s of this.arrayBuffers)if(a+=s.byteLength,a>=e)return!0;return!1}findBufferOffsets(e){let a=-this.offset,s=[];for(let i=0;i<this.arrayBuffers.length;i++){let r=this.arrayBuffers[i];if(a+r.byteLength<=0){a+=r.byteLength;continue}let n=a<=0?Math.abs(a):0,h;if(n+e<=r.byteLength)return h=n+e,s.push([i,[n,h]]),s;h=r.byteLength,s.push([i,[n,h]]),e-=r.byteLength-n,a+=r.byteLength}return null}getDataView(e){let a=this.findBufferOffsets(e);if(!a&&this.ended)throw new Error("binary data exhausted");if(!a)return null;if(a.length===1){let[i,[r,n]]=a[0],h=this.arrayBuffers[i],o=new DataView(h,r,n-r);return this.offset+=e,this.disposeBuffers(),o}let s=new DataView(this._combineArrayBuffers(a));return this.offset+=e,this.disposeBuffers(),s}disposeBuffers(){for(;this.arrayBuffers.length>0&&this.offset-this.maxRewindBytes>=this.arrayBuffers[0].byteLength;)this.offset-=this.arrayBuffers[0].byteLength,this.arrayBuffers.shift()}_combineArrayBuffers(e){let a=0;for(let r of e){let[n,h]=r[1];a+=h-n}let s=new Uint8Array(a),i=0;for(let r of e){let[n,[h,o]]=r,l=new Uint8Array(this.arrayBuffers[n]);s.set(l.subarray(h,o),i),i+=o-h}return s.buffer}skip(e){this.offset+=e}rewind(e){this.offset-=e}};function Wt(t){let e={magic:t.getInt32(0,!1),length:t.getInt32(24,!1)*2,version:t.getInt32(28,!0),type:t.getInt32(32,!0),bbox:{minX:t.getFloat64(36,!0),minY:t.getFloat64(44,!0),minZ:t.getFloat64(68,!0),minM:t.getFloat64(84,!0),maxX:t.getFloat64(52,!0),maxY:t.getFloat64(60,!0),maxZ:t.getFloat64(76,!0),maxM:t.getFloat64(92,!0)}};return e.magic!==9994&&console.error(`SHP file: bad magic number ${e.magic}`),e.version!==1e3&&console.error(`SHP file: bad version ${e.version}`),e}function Ue(t,e){let{_maxDimensions:a=4}=e?.shp||{},s=0,i=t.getInt32(s,!0);switch(s+=Int32Array.BYTES_PER_ELEMENT,i){case 0:return Ui();case 1:return ve(t,s,Math.min(2,a));case 3:return xt(t,s,Math.min(2,a),"LineString");case 5:return xt(t,s,Math.min(2,a),"Polygon");case 8:return ye(t,s,Math.min(2,a));case 11:return ve(t,s,Math.min(4,a));case 13:return xt(t,s,Math.min(4,a),"LineString");case 15:return xt(t,s,Math.min(4,a),"Polygon");case 18:return ye(t,s,Math.min(4,a));case 21:return ve(t,s,Math.min(3,a));case 23:return xt(t,s,Math.min(3,a),"LineString");case 25:return xt(t,s,Math.min(3,a),"Polygon");case 28:return ye(t,s,Math.min(3,a));default:throw new Error(`unsupported shape type: ${i}`)}}function Ui(){return null}function ve(t,e,a){let s;return[s,e]=mt(t,e,1,a),{positions:{value:s,size:a},type:"Point"}}function ye(t,e,a){e+=4*Float64Array.BYTES_PER_ELEMENT;let s=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let i=null,r=null,n=null;return[i,e]=mt(t,e,s,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[n,e]=mt(t,e,s,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[r,e]=mt(t,e,s,1)),{positions:{value:We(i,r,n),size:a},type:"Point"}}function xt(t,e,a,s){e+=4*Float64Array.BYTES_PER_ELEMENT;let i=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let r=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let n=t.byteOffset+e,h=i*Int32Array.BYTES_PER_ELEMENT,o=new Int32Array(i+1);o.set(new Int32Array(t.buffer.slice(n,n+h))),o[i]=r,e+=i*Int32Array.BYTES_PER_ELEMENT;let l=null,u=null,f=null;[l,e]=mt(t,e,r,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[f,e]=mt(t,e,r,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[u,e]=mt(t,e,r,1));let c=We(l,u,f);if(s==="LineString")return{type:s,positions:{value:c,size:a},pathIndices:{value:o,size:1}};let M=[];for(let d=1;d<o.length;d++){let y=o[d-1],x=o[d],g=l.subarray(y*2,x*2);Wi(g)>0&&M.push(y)}return M.push(r),{type:s,positions:{value:c,size:a},primitivePolygonIndices:{value:o,size:1},polygonIndices:{value:new Uint32Array(M),size:1}}}function mt(t,e,a,s){let i=t.byteOffset+e,r=a*s*Float64Array.BYTES_PER_ELEMENT;return[new Float64Array(t.buffer.slice(i,i+r)),e+r]}function We(t,e,a){if(!(e||a))return t;let s=t.length,i=2;a&&a.length&&(s+=a.length,i++),e&&e.length&&(s+=e.length,i++);let r=new Float64Array(s);for(let n=0;n<t.length/2;n++)r[i*n]=t[n*2],r[i*n+1]=t[n*2+1];if(a&&a.length)for(let n=0;n<a.length;n++)r[i*n+2]=a[n];if(e&&e.length)for(let n=0;n<e.length;n++)r[i*n+(i-1)]=e[n];return r}function Wi(t){return Math.sign(Xi(t))}function Xi(t){let e=0,a=t.length/2-1;for(let s=0;s<a;s++)e+=(t[s*2]+t[(s+1)*2])*(t[s*2+1]-t[(s+1)*2+1]);return e/2}var Ji=!0,Xe=!1,Qi=100,St=12,X={EXPECTING_HEADER:0,EXPECTING_RECORD:1,END:2,ERROR:3},Xt=class{constructor(e){this.options={},this.binaryReader=new ot({maxRewindBytes:St}),this.state=X.EXPECTING_HEADER,this.result={geometries:[],progress:{bytesTotal:NaN,bytesUsed:NaN,rows:NaN},currentIndex:NaN},this.options=e}write(e){this.binaryReader.write(e),this.state=Je(this.state,this.result,this.binaryReader,this.options)}end(){this.binaryReader.end(),this.state=Je(this.state,this.result,this.binaryReader,this.options),this.state!==X.END&&(this.state=X.ERROR,this.result.error="SHP incomplete file")}};function xe(t,e){let a=new Xt(e);return a.write(t),a.end(),a.result}async function*Qe(t,e){let a=new Xt(e),s=!1;for await(let i of t)a.write(i),!s&&a.result.header&&(s=!0,yield a.result.header),a.result.geometries.length>0&&(yield a.result.geometries,a.result.geometries=[]);a.end(),a.result.geometries.length>0&&(yield a.result.geometries)}function Je(t,e,a,s){for(;;)try{switch(t){case X.ERROR:case X.END:return t;case X.EXPECTING_HEADER:let i=a.getDataView(Qi);if(!i)return t;e.header=Wt(i),e.progress={bytesUsed:0,bytesTotal:e.header.length,rows:0},e.currentIndex=1,t=X.EXPECTING_RECORD;break;case X.EXPECTING_RECORD:for(;a.hasAvailableBytes(St);){let r=a.getDataView(St),n={recordNumber:r.getInt32(0,Xe),byteLength:r.getInt32(4,Xe)*2,type:r.getInt32(8,Ji)};if(!a.hasAvailableBytes(n.byteLength-4))return a.rewind(St),t;if(n.byteLength<4||n.type!==e.header?.type||n.recordNumber!==e.currentIndex)a.rewind(St-4);else{a.rewind(4);let o=a.getDataView(n.byteLength),l=Ue(o,s);e.geometries.push(l),e.currentIndex++,e.progress.rows=e.currentIndex-1}}return a.ended&&(t=X.END),t;default:return t=X.ERROR,e.error=`illegal parser state ${t}`,t}}catch(i){return t=X.ERROR,e.error=`SHP parsing failed: ${i?.message}`,t}}var Vi="4.2.0-alpha.4",ge=[0,0,39,10],_e={name:"SHP",id:"shp",module:"shapefile",version:Vi,worker:!0,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(ge).buffer],options:{shp:{_maxDimensions:4}}},Nt={..._e,parse:async(t,e)=>xe(t,e),parseSync:xe,parseInBatches:(t,e)=>Qe(t,e)};async function Jt(t,e,a,s){return s._parse(t,e,a,s)}async function Qt(t,e,a,s){if(!s._parseInBatches)throw new Error("parseInBatches");return s._parseInBatches(t,e,a,s)}function lt(t){return lt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lt(t)}function be(t,e){if(lt(t)!=="object"||t===null)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var s=a.call(t,e||"default");if(lt(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ee(t){var e=be(t,"string");return lt(e)==="symbol"?e:String(e)}function Ie(t,e,a){return e=Ee(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function Pe(t,e,a){switch(t.type){case"Point":return Yi(t,e,a);case"LineString":return Ki(t,e,a);case"Polygon":return Ve(t,e,a);default:let s=t;throw new Error(`Unsupported geometry type: ${s?.type}`)}}function Ve(t,e=-1/0,a=1/0){let{positions:s}=t,i=t.polygonIndices.value.filter(o=>o>=e&&o<=a),r=t.primitivePolygonIndices.value.filter(o=>o>=e&&o<=a);if(!(i.length>2)){let o=[];for(let l=0;l<r.length-1;l++){let u=r[l],f=r[l+1],c=Vt(s,u,f);o.push(c)}return{type:"Polygon",coordinates:o}}let h=[];for(let o=0;o<i.length-1;o++){let l=i[o],u=i[o+1],f=Ve(t,l,u).coordinates;h.push(f)}return{type:"MultiPolygon",coordinates:h}}function Ki(t,e=-1/0,a=1/0){let{positions:s}=t,i=t.pathIndices.value.filter(h=>h>=e&&h<=a);if(!(i.length>2))return{type:"LineString",coordinates:Vt(s,i[0],i[1])};let n=[];for(let h=0;h<i.length-1;h++){let o=Vt(s,i[h],i[h+1]);n.push(o)}return{type:"MultiLineString",coordinates:n}}function Yi(t,e,a){let{positions:s}=t,i=Vt(s,e,a);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Vt(t,e,a){e=e||0,a=a||t.value.length/t.size;let s=[];for(let i=e;i<a;i++){let r=Array();for(let n=i*t.size;n<(i+1)*t.size;n++)r.push(Number(t.value[n]));s.push(r)}return s}function Ae(t,e){for(let a of t)a.geometry.coordinates=Ke(a.geometry.coordinates,e);return t}function Ke(t,e){return Zi(t)?e(t):t.map(a=>Ke(a,e))}function Zi(t){return Array.isArray(t)&&Number.isFinite(t[0])&&Number.isFinite(t[1])}function Ye(t){t("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),t("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),t("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"),t.WGS84=t["EPSG:4326"],t["EPSG:3785"]=t["EPSG:3857"],t.GOOGLE=t["EPSG:3857"],t["EPSG:900913"]=t["EPSG:3857"],t["EPSG:102113"]=t["EPSG:3857"]}var J=1,Q=2,Ze=4,wt=5,Mt=484813681109536e-20,m=Math.PI/2,$e=.16666666666666666,ta=.04722222222222222,ea=.022156084656084655,p=1e-10,L=.017453292519943295,V=57.29577951308232,I=Math.PI/4,Rt=Math.PI*2,w=3.14159265359;var G={};G.greenwich=0;G.lisbon=-9.131906111111;G.paris=2.337229166667;G.bogota=-74.080916666667;G.madrid=-3.687938888889;G.rome=12.452333333333;G.bern=7.439583333333;G.jakarta=106.807719444444;G.ferro=-17.666666666667;G.brussels=4.367975;G.stockholm=18.058277777778;G.athens=23.7163375;G.oslo=10.722916666667;var aa={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}};var ia=/[\s_\-\/\(\)]/g;function k(t,e){if(t[e])return t[e];for(var a=Object.keys(t),s=e.toLowerCase().replace(ia,""),i=-1,r,n;++i<a.length;)if(r=a[i],n=r.toLowerCase().replace(ia,""),n===s)return t[r]}function Ct(t){var e={},a=t.split("+").map(function(h){return h.trim()}).filter(function(h){return h}).reduce(function(h,o){var l=o.split("=");return l.push(!0),h[l[0].toLowerCase()]=l[1],h},{}),s,i,r,n={proj:"projName",datum:"datumCode",rf:function(h){e.rf=parseFloat(h)},lat_0:function(h){e.lat0=h*L},lat_1:function(h){e.lat1=h*L},lat_2:function(h){e.lat2=h*L},lat_ts:function(h){e.lat_ts=h*L},lon_0:function(h){e.long0=h*L},lon_1:function(h){e.long1=h*L},lon_2:function(h){e.long2=h*L},alpha:function(h){e.alpha=parseFloat(h)*L},lonc:function(h){e.longc=h*L},x_0:function(h){e.x0=parseFloat(h)},y_0:function(h){e.y0=parseFloat(h)},k_0:function(h){e.k0=parseFloat(h)},k:function(h){e.k0=parseFloat(h)},a:function(h){e.a=parseFloat(h)},b:function(h){e.b=parseFloat(h)},r_a:function(){e.R_A=!0},zone:function(h){e.zone=parseInt(h,10)},south:function(){e.utmSouth=!0},towgs84:function(h){e.datum_params=h.split(",").map(function(o){return parseFloat(o)})},to_meter:function(h){e.to_meter=parseFloat(h)},units:function(h){e.units=h;var o=k(aa,h);o&&(e.to_meter=o.to_meter)},from_greenwich:function(h){e.from_greenwich=h*L},pm:function(h){var o=k(G,h);e.from_greenwich=(o||parseFloat(h))*L},nadgrids:function(h){h==="@null"?e.datumCode="none":e.nadgrids=h},axis:function(h){var o="ewnsud";h.length===3&&o.indexOf(h.substr(0,1))!==-1&&o.indexOf(h.substr(1,1))!==-1&&o.indexOf(h.substr(2,1))!==-1&&(e.axis=h)}};for(s in a)i=a[s],s in n?(r=n[s],typeof r=="function"?r(i):e[r]=i):e[s]=i;return typeof e.datumCode=="string"&&e.datumCode!=="WGS84"&&(e.datumCode=e.datumCode.toLowerCase()),e}var sa=as,Lt=1,ra=2,na=3,Kt=4,ha=5,Se=-1,$i=/\s/,ts=/[A-Za-z]/,es=/[A-Za-z84_]/,Yt=/[,\]]/,oa=/[\d\.E\-\+]/;function tt(t){if(typeof t!="string")throw new Error("not a string");this.text=t.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=Lt}tt.prototype.readCharicter=function(){var t=this.text[this.place++];if(this.state!==Kt)for(;$i.test(t);){if(this.place>=this.text.length)return;t=this.text[this.place++]}switch(this.state){case Lt:return this.neutral(t);case ra:return this.keyword(t);case Kt:return this.quoted(t);case ha:return this.afterquote(t);case na:return this.number(t);case Se:return}};tt.prototype.afterquote=function(t){if(t==='"'){this.word+='"',this.state=Kt;return}if(Yt.test(t)){this.word=this.word.trim(),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in afterquote yet, index '+this.place)};tt.prototype.afterItem=function(t){if(t===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=Lt;return}if(t==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Lt,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Se);return}};tt.prototype.number=function(t){if(oa.test(t)){this.word+=t;return}if(Yt.test(t)){this.word=parseFloat(this.word),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in number yet, index '+this.place)};tt.prototype.quoted=function(t){if(t==='"'){this.state=ha;return}this.word+=t};tt.prototype.keyword=function(t){if(es.test(t)){this.word+=t;return}if(t==="["){var e=[];e.push(this.word),this.level++,this.root===null?this.root=e:this.currentObject.push(e),this.stack.push(this.currentObject),this.currentObject=e,this.state=Lt;return}if(Yt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in keyword yet, index '+this.place)};tt.prototype.neutral=function(t){if(ts.test(t)){this.word=t,this.state=ra;return}if(t==='"'){this.word="",this.state=Kt;return}if(oa.test(t)){this.word=t,this.state=na;return}if(Yt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in neutral yet, index '+this.place)};tt.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Se)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function as(t){var e=new tt(t);return e.output()}function la(t,e,a){Array.isArray(e)&&(a.unshift(e),e=null);var s=e?{}:t,i=a.reduce(function(r,n){return dt(n,r),r},s);e&&(t[e]=i)}function dt(t,e){if(!Array.isArray(t)){e[t]=!0;return}var a=t.shift();if(a==="PARAMETER"&&(a=t.shift()),t.length===1){if(Array.isArray(t[0])){e[a]={},dt(t[0],e[a]);return}e[a]=t[0];return}if(!t.length){e[a]=!0;return}if(a==="TOWGS84"){e[a]=t;return}if(a==="AXIS"){a in e||(e[a]=[]),e[a].push(t);return}Array.isArray(a)||(e[a]={});var s;switch(a){case"UNIT":case"PRIMEM":case"VERT_DATUM":e[a]={name:t[0].toLowerCase(),convert:t[1]},t.length===3&&dt(t[2],e[a]);return;case"SPHEROID":case"ELLIPSOID":e[a]={name:t[0],a:t[1],rf:t[2]},t.length===4&&dt(t[3],e[a]);return;case"PROJECTEDCRS":case"PROJCRS":case"GEOGCS":case"GEOCCS":case"PROJCS":case"LOCAL_CS":case"GEODCRS":case"GEODETICCRS":case"GEODETICDATUM":case"EDATUM":case"ENGINEERINGDATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":case"COMPD_CS":case"COMPOUNDCRS":case"ENGINEERINGCRS":case"ENGCRS":case"FITTED_CS":case"LOCAL_DATUM":case"DATUM":t[0]=["name",t[0]],la(e,a,t);return;default:for(s=-1;++s<t.length;)if(!Array.isArray(t[s]))return dt(t,e[a]);return la(e,a,t)}}var is=.017453292519943295;function ss(t,e){var a=e[0],s=e[1];!(a in t)&&s in t&&(t[a]=t[s],e.length===3&&(t[a]=e[2](t[a])))}function et(t){return t*is}function rs(t){if(t.type==="GEOGCS"?t.projName="longlat":t.type==="LOCAL_CS"?(t.projName="identity",t.local=!0):typeof t.PROJECTION=="object"?t.projName=Object.keys(t.PROJECTION)[0]:t.projName=t.PROJECTION,t.AXIS){for(var e="",a=0,s=t.AXIS.length;a<s;++a){var i=[t.AXIS[a][0].toLowerCase(),t.AXIS[a][1].toLowerCase()];i[0].indexOf("north")!==-1||(i[0]==="y"||i[0]==="lat")&&i[1]==="north"?e+="n":i[0].indexOf("south")!==-1||(i[0]==="y"||i[0]==="lat")&&i[1]==="south"?e+="s":i[0].indexOf("east")!==-1||(i[0]==="x"||i[0]==="lon")&&i[1]==="east"?e+="e":(i[0].indexOf("west")!==-1||(i[0]==="x"||i[0]==="lon")&&i[1]==="west")&&(e+="w")}e.length===2&&(e+="u"),e.length===3&&(t.axis=e)}t.UNIT&&(t.units=t.UNIT.name.toLowerCase(),t.units==="metre"&&(t.units="meter"),t.UNIT.convert&&(t.type==="GEOGCS"?t.DATUM&&t.DATUM.SPHEROID&&(t.to_meter=t.UNIT.convert*t.DATUM.SPHEROID.a):t.to_meter=t.UNIT.convert));var r=t.GEOGCS;t.type==="GEOGCS"&&(r=t),r&&(r.DATUM?t.datumCode=r.DATUM.name.toLowerCase():t.datumCode=r.name.toLowerCase(),t.datumCode.slice(0,2)==="d_"&&(t.datumCode=t.datumCode.slice(2)),(t.datumCode==="new_zealand_geodetic_datum_1949"||t.datumCode==="new_zealand_1949")&&(t.datumCode="nzgd49"),(t.datumCode==="wgs_1984"||t.datumCode==="world_geodetic_system_1984")&&(t.PROJECTION==="Mercator_Auxiliary_Sphere"&&(t.sphere=!0),t.datumCode="wgs84"),t.datumCode.slice(-6)==="_ferro"&&(t.datumCode=t.datumCode.slice(0,-6)),t.datumCode.slice(-8)==="_jakarta"&&(t.datumCode=t.datumCode.slice(0,-8)),~t.datumCode.indexOf("belge")&&(t.datumCode="rnb72"),r.DATUM&&r.DATUM.SPHEROID&&(t.ellps=r.DATUM.SPHEROID.name.replace("_19","").replace(/[Cc]larke\_18/,"clrk"),t.ellps.toLowerCase().slice(0,13)==="international"&&(t.ellps="intl"),t.a=r.DATUM.SPHEROID.a,t.rf=parseFloat(r.DATUM.SPHEROID.rf,10)),r.DATUM&&r.DATUM.TOWGS84&&(t.datum_params=r.DATUM.TOWGS84),~t.datumCode.indexOf("osgb_1936")&&(t.datumCode="osgb36"),~t.datumCode.indexOf("osni_1952")&&(t.datumCode="osni52"),(~t.datumCode.indexOf("tm65")||~t.datumCode.indexOf("geodetic_datum_of_1965"))&&(t.datumCode="ire65"),t.datumCode==="ch1903+"&&(t.datumCode="ch1903"),~t.datumCode.indexOf("israel")&&(t.datumCode="isr93")),t.b&&!isFinite(t.b)&&(t.b=t.a);function n(l){var u=t.to_meter||1;return l*u}var h=function(l){return ss(t,l)},o=[["standard_parallel_1","Standard_Parallel_1"],["standard_parallel_1","Latitude of 1st standard parallel"],["standard_parallel_2","Standard_Parallel_2"],["standard_parallel_2","Latitude of 2nd standard parallel"],["false_easting","False_Easting"],["false_easting","False easting"],["false-easting","Easting at false origin"],["false_northing","False_Northing"],["false_northing","False northing"],["false_northing","Northing at false origin"],["central_meridian","Central_Meridian"],["central_meridian","Longitude of natural origin"],["central_meridian","Longitude of false origin"],["latitude_of_origin","Latitude_Of_Origin"],["latitude_of_origin","Central_Parallel"],["latitude_of_origin","Latitude of natural origin"],["latitude_of_origin","Latitude of false origin"],["scale_factor","Scale_Factor"],["k0","scale_factor"],["latitude_of_center","Latitude_Of_Center"],["latitude_of_center","Latitude_of_center"],["lat0","latitude_of_center",et],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",et],["x0","false_easting",n],["y0","false_northing",n],["long0","central_meridian",et],["lat0","latitude_of_origin",et],["lat0","standard_parallel_1",et],["lat1","standard_parallel_1",et],["lat2","standard_parallel_2",et],["azimuth","Azimuth"],["alpha","azimuth",et],["srsCode","name"]];o.forEach(h),!t.long0&&t.longc&&(t.projName==="Albers_Conic_Equal_Area"||t.projName==="Lambert_Azimuthal_Equal_Area")&&(t.long0=t.longc),!t.lat_ts&&t.lat1&&(t.projName==="Stereographic_South_Pole"||t.projName==="Polar Stereographic (variant B)")&&(t.lat0=et(t.lat1>0?90:-90),t.lat_ts=t.lat1)}function Zt(t){var e=sa(t),a=e.shift(),s=e.shift();e.unshift(["name",s]),e.unshift(["type",a]);var i={};return dt(e,i),rs(i),i}function U(t){var e=this;if(arguments.length===2){var a=arguments[1];typeof a=="string"?a.charAt(0)==="+"?U[t]=Ct(arguments[1]):U[t]=Zt(arguments[1]):U[t]=a}else if(arguments.length===1){if(Array.isArray(t))return t.map(function(s){Array.isArray(s)?U.apply(e,s):U(s)});if(typeof t=="string"){if(t in U)return U[t]}else"EPSG"in t?U["EPSG:"+t.EPSG]=t:"ESRI"in t?U["ESRI:"+t.ESRI]=t:"IAU2000"in t?U["IAU2000:"+t.IAU2000]=t:console.log(t);return}}Ye(U);var gt=U;function ns(t){return typeof t=="string"}function hs(t){return t in gt}var os=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function ls(t){return os.some(function(e){return t.indexOf(e)>-1})}var fs=["3857","900913","3785","102113"];function us(t){var e=k(t,"authority");if(e){var a=k(e,"epsg");return a&&fs.indexOf(a)>-1}}function cs(t){var e=k(t,"extension");if(e)return k(e,"proj4")}function ms(t){return t[0]==="+"}function Ms(t){if(ns(t)){if(hs(t))return gt[t];if(ls(t)){var e=Zt(t);if(us(e))return gt["EPSG:3857"];var a=cs(e);return a?Ct(a):e}if(ms(t))return Ct(t)}else return t}var fa=Ms;function Ne(t,e){t=t||{};var a,s;if(!e)return t;for(s in e)a=e[s],a!==void 0&&(t[s]=a);return t}function B(t,e,a){var s=t*e;return a/Math.sqrt(1-s*s)}function $(t){return t<0?-1:1}function v(t){return Math.abs(t)<=w?t:t-$(t)*Rt}function F(t,e,a){var s=t*a,i=.5*t;return s=Math.pow((1-s)/(1+s),i),Math.tan(.5*(m-e))/s}function at(t,e){for(var a=.5*t,s,i,r=m-2*Math.atan(e),n=0;n<=15;n++)if(s=t*Math.sin(r),i=m-2*Math.atan(e*Math.pow((1-s)/(1+s),a))-r,r+=i,Math.abs(i)<=1e-10)return r;return-9999}function ds(){var t=this.b/this.a;this.es=1-t*t,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function ps(t){var e=t.x,a=t.y;if(a*V>90&&a*V<-90&&e*V>180&&e*V<-180)return null;var s,i;if(Math.abs(Math.abs(a)-m)<=p)return null;if(this.sphere)s=this.x0+this.a*this.k0*v(e-this.long0),i=this.y0+this.a*this.k0*Math.log(Math.tan(I+.5*a));else{var r=Math.sin(a),n=F(this.e,a,r);s=this.x0+this.a*this.k0*v(e-this.long0),i=this.y0-this.a*this.k0*Math.log(n)}return t.x=s,t.y=i,t}function vs(t){var e=t.x-this.x0,a=t.y-this.y0,s,i;if(this.sphere)i=m-2*Math.atan(Math.exp(-a/(this.a*this.k0)));else{var r=Math.exp(-a/(this.a*this.k0));if(i=at(this.e,r),i===-9999)return null}return s=v(this.long0+e/(this.a*this.k0)),t.x=s,t.y=i,t}var ys=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"],ua={init:ds,forward:ps,inverse:vs,names:ys};function xs(){}function ca(t){return t}var gs=["longlat","identity"],ma={init:xs,forward:ca,inverse:ca,names:gs};var _s=[ua,ma],$t={},te=[];function Ma(t,e){var a=te.length;return t.names?(te[a]=t,t.names.forEach(function(s){$t[s.toLowerCase()]=a}),this):(console.log(e),!0)}function bs(t){if(!t)return!1;var e=t.toLowerCase();if(typeof $t[e]<"u"&&te[$t[e]])return te[$t[e]]}function Es(){_s.forEach(Ma)}var da={start:Es,add:Ma,get:bs};var _={};_.MERIT={a:6378137,rf:298.257,ellipseName:"MERIT 1983"};_.SGS85={a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"};_.GRS80={a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"};_.IAU76={a:6378140,rf:298.257,ellipseName:"IAU 1976"};_.airy={a:6377563396e-3,b:635625691e-2,ellipseName:"Airy 1830"};_.APL4={a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"};_.NWL9D={a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"};_.mod_airy={a:6377340189e-3,b:6356034446e-3,ellipseName:"Modified Airy"};_.andrae={a:637710443e-2,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"};_.aust_SA={a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"};_.GRS67={a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"};_.bessel={a:6377397155e-3,rf:299.1528128,ellipseName:"Bessel 1841"};_.bess_nam={a:6377483865e-3,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"};_.clrk66={a:63782064e-1,b:63565838e-1,ellipseName:"Clarke 1866"};_.clrk80={a:6378249145e-3,rf:293.4663,ellipseName:"Clarke 1880 mod."};_.clrk58={a:6378293645208759e-9,rf:294.2606763692654,ellipseName:"Clarke 1858"};_.CPM={a:63757387e-1,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"};_.delmbr={a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"};_.engelis={a:637813605e-2,rf:298.2566,ellipseName:"Engelis 1985"};_.evrst30={a:6377276345e-3,rf:300.8017,ellipseName:"Everest 1830"};_.evrst48={a:6377304063e-3,rf:300.8017,ellipseName:"Everest 1948"};_.evrst56={a:6377301243e-3,rf:300.8017,ellipseName:"Everest 1956"};_.evrst69={a:6377295664e-3,rf:300.8017,ellipseName:"Everest 1969"};_.evrstSS={a:6377298556e-3,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"};_.fschr60={a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"};_.fschr60m={a:6378155,rf:298.3,ellipseName:"Fischer 1960"};_.fschr68={a:6378150,rf:298.3,ellipseName:"Fischer 1968"};_.helmert={a:6378200,rf:298.3,ellipseName:"Helmert 1906"};_.hough={a:6378270,rf:297,ellipseName:"Hough"};_.intl={a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"};_.kaula={a:6378163,rf:298.24,ellipseName:"Kaula 1961"};_.lerch={a:6378139,rf:298.257,ellipseName:"Lerch 1979"};_.mprts={a:6397300,rf:191,ellipseName:"Maupertius 1738"};_.new_intl={a:63781575e-1,b:63567722e-1,ellipseName:"New International 1967"};_.plessis={a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"};_.krass={a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"};_.SEasia={a:6378155,b:63567733205e-4,ellipseName:"Southeast Asia"};_.walbeck={a:6376896,b:63558348467e-4,ellipseName:"Walbeck"};_.WGS60={a:6378165,rf:298.3,ellipseName:"WGS 60"};_.WGS66={a:6378145,rf:298.25,ellipseName:"WGS 66"};_.WGS7={a:6378135,rf:298.26,ellipseName:"WGS 72"};var pa=_.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};_.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};function va(t,e,a,s){var i=t*t,r=e*e,n=(i-r)/i,h=0;s?(t*=1-n*($e+n*(ta+n*ea)),i=t*t,n=0):h=Math.sqrt(n);var o=(i-r)/r;return{es:n,e:h,ep2:o}}function ya(t,e,a,s,i){if(!t){var r=k(_,s);r||(r=pa),t=r.a,e=r.b,a=r.rf}return a&&!e&&(e=(1-1/a)*t),(a===0||Math.abs(t-e)<p)&&(i=!0,e=t),{a:t,b:e,rf:a,sphere:i}}var T={};T.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"};T.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"};T.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"};T.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"};T.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"};T.potsdam={towgs84:"606.0,23.0,413.0",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"};T.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"};T.hermannskogel={towgs84:"653.0,-212.0,449.0",ellipse:"bessel",datumName:"Hermannskogel"};T.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"};T.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"};T.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"};T.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"};T.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"};T.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"};T.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"};T.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"};T.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};function Is(t,e,a,s,i,r){var n={};return t===void 0||t==="none"?n.datum_type=wt:n.datum_type=Ze,e&&(n.datum_params=e.map(parseFloat),(n.datum_params[0]!==0||n.datum_params[1]!==0||n.datum_params[2]!==0)&&(n.datum_type=J),n.datum_params.length>3&&(n.datum_params[3]!==0||n.datum_params[4]!==0||n.datum_params[5]!==0||n.datum_params[6]!==0)&&(n.datum_type=Q,n.datum_params[3]*=Mt,n.datum_params[4]*=Mt,n.datum_params[5]*=Mt,n.datum_params[6]=n.datum_params[6]/1e6+1)),n.a=a,n.b=s,n.es=i,n.ep2=r,n}var xa=Is;function _t(t,e){if(!(this instanceof _t))return new _t(t);e=e||function(o){if(o)throw o};var a=fa(t);if(typeof a!="object"){e(t);return}var s=_t.projections.get(a.projName);if(!s){e(t);return}if(a.datumCode&&a.datumCode!=="none"){var i=k(T,a.datumCode);i&&(a.datum_params=i.towgs84?i.towgs84.split(","):null,a.ellps=i.ellipse,a.datumName=i.datumName?i.datumName:a.datumCode)}a.k0=a.k0||1,a.axis=a.axis||"enu",a.ellps=a.ellps||"wgs84";var r=ya(a.a,a.b,a.rf,a.ellps,a.sphere),n=va(r.a,r.b,r.rf,a.R_A),h=a.datum||xa(a.datumCode,a.datum_params,r.a,r.b,n.es,n.ep2);Ne(this,a),Ne(this,s),this.a=r.a,this.b=r.b,this.rf=r.rf,this.sphere=r.sphere,this.es=n.es,this.e=n.e,this.ep2=n.ep2,this.datum=h,this.init(),e(null,this)}_t.projections=da;_t.projections.start();var ft=_t;function ga(t,e){return t.datum_type!==e.datum_type||t.a!==e.a||Math.abs(t.es-e.es)>5e-11?!1:t.datum_type===J?t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]:t.datum_type===Q?t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]&&t.datum_params[3]===e.datum_params[3]&&t.datum_params[4]===e.datum_params[4]&&t.datum_params[5]===e.datum_params[5]&&t.datum_params[6]===e.datum_params[6]:!0}function ee(t,e,a){var s=t.x,i=t.y,r=t.z?t.z:0,n,h,o,l;if(i<-m&&i>-1.001*m)i=-m;else if(i>m&&i<1.001*m)i=m;else{if(i<-m)return{x:-1/0,y:-1/0,z:t.z};if(i>m)return{x:1/0,y:1/0,z:t.z}}return s>Math.PI&&(s-=2*Math.PI),h=Math.sin(i),l=Math.cos(i),o=h*h,n=a/Math.sqrt(1-e*o),{x:(n+r)*l*Math.cos(s),y:(n+r)*l*Math.sin(s),z:(n*(1-e)+r)*h}}function ae(t,e,a,s){var i=1e-12,r=i*i,n=30,h,o,l,u,f,c,M,d,y,x,g,b,E,N=t.x,P=t.y,A=t.z?t.z:0,O,C,Z;if(h=Math.sqrt(N*N+P*P),o=Math.sqrt(N*N+P*P+A*A),h/a<i){if(O=0,o/a<i)return C=m,Z=-s,{x:t.x,y:t.y,z:t.z}}else O=Math.atan2(P,N);l=A/o,u=h/o,f=1/Math.sqrt(1-e*(2-e)*u*u),d=u*(1-e)*f,y=l*f,E=0;do E++,M=a/Math.sqrt(1-e*y*y),Z=h*d+A*y-M*(1-e*y*y),c=e*M/(M+Z),f=1/Math.sqrt(1-c*(2-c)*u*u),x=u*(1-c)*f,g=l*f,b=g*d-x*y,d=x,y=g;while(b*b>r&&E<n);return C=Math.atan(g/Math.abs(x)),{x:O,y:C,z:Z}}function _a(t,e,a){if(e===J)return{x:t.x+a[0],y:t.y+a[1],z:t.z+a[2]};if(e===Q){var s=a[0],i=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6];return{x:l*(t.x-o*t.y+h*t.z)+s,y:l*(o*t.x+t.y-n*t.z)+i,z:l*(-h*t.x+n*t.y+t.z)+r}}}function ba(t,e,a){if(e===J)return{x:t.x-a[0],y:t.y-a[1],z:t.z-a[2]};if(e===Q){var s=a[0],i=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6],u=(t.x-s)/l,f=(t.y-i)/l,c=(t.z-r)/l;return{x:u+o*f-h*c,y:-o*u+f+n*c,z:h*u-n*f+c}}}function ie(t){return t===J||t===Q}function Ea(t,e,a){return ga(t,e)||t.datum_type===wt||e.datum_type===wt||t.es===e.es&&t.a===e.a&&!ie(t.datum_type)&&!ie(e.datum_type)?a:(a=ee(a,t.es,t.a),ie(t.datum_type)&&(a=_a(a,t.datum_type,t.datum_params)),ie(e.datum_type)&&(a=ba(a,e.datum_type,e.datum_params)),ae(a,e.es,e.a,e.b))}function we(t,e,a){var s=a.x,i=a.y,r=a.z||0,n,h,o,l={};for(o=0;o<3;o++)if(!(e&&o===2&&a.z===void 0))switch(o===0?(n=s,"ew".indexOf(t.axis[o])!==-1?h="x":h="y"):o===1?(n=i,"ns".indexOf(t.axis[o])!==-1?h="y":h="x"):(n=r,h="z"),t.axis[o]){case"e":case"w":case"n":case"s":l[h]=n;break;case"u":a[h]!==void 0&&(l.z=n);break;case"d":a[h]!==void 0&&(l.z=-n);break;default:return null}return l}function se(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e}function Pa(t){Ia(t.x),Ia(t.y)}function Ia(t){if(typeof Number.isFinite=="function"){if(Number.isFinite(t))return;throw new TypeError("coordinates must be finite numbers")}if(typeof t!="number"||t!==t||!isFinite(t))throw new TypeError("coordinates must be finite numbers")}function Ps(t,e){return(t.datum.datum_type===J||t.datum.datum_type===Q)&&e.datumCode!=="WGS84"||(e.datum.datum_type===J||e.datum.datum_type===Q)&&t.datumCode!=="WGS84"}function pt(t,e,a){var s;if(Array.isArray(a)&&(a=se(a)),Pa(a),t.datum&&e.datum&&Ps(t,e)&&(s=new ft("WGS84"),a=pt(t,s,a),t=s),t.axis!=="enu"&&(a=we(t,!1,a)),t.projName==="longlat")a={x:a.x*L,y:a.y*L,z:a.z||0};else if(t.to_meter&&(a={x:a.x*t.to_meter,y:a.y*t.to_meter,z:a.z||0}),a=t.inverse(a),!a)return;return t.from_greenwich&&(a.x+=t.from_greenwich),a=Ea(t.datum,e.datum,a),e.from_greenwich&&(a={x:a.x-e.from_greenwich,y:a.y,z:a.z||0}),e.projName==="longlat"?a={x:a.x*V,y:a.y*V,z:a.z||0}:(a=e.forward(a),e.to_meter&&(a={x:a.x/e.to_meter,y:a.y/e.to_meter,z:a.z||0})),e.axis!=="enu"?we(e,!0,a):a}var Aa=ft("WGS84");function Re(t,e,a){var s,i,r;return Array.isArray(a)?(s=pt(t,e,a)||{x:NaN,y:NaN},a.length>2?typeof t.name<"u"&&t.name==="geocent"||typeof e.name<"u"&&e.name==="geocent"?typeof s.z=="number"?[s.x,s.y,s.z].concat(a.splice(3)):[s.x,s.y,a[2]].concat(a.splice(3)):[s.x,s.y].concat(a.splice(2)):[s.x,s.y]):(i=pt(t,e,a),r=Object.keys(a),r.length===2||r.forEach(function(n){if(typeof t.name<"u"&&t.name==="geocent"||typeof e.name<"u"&&e.name==="geocent"){if(n==="x"||n==="y"||n==="z")return}else if(n==="x"||n==="y")return;i[n]=a[n]}),i)}function Sa(t){return t instanceof ft?t:t.oProj?t.oProj:ft(t)}function As(t,e,a){t=Sa(t);var s=!1,i;return typeof e>"u"?(e=t,t=Aa,s=!0):(typeof e.x<"u"||Array.isArray(e))&&(a=e,e=t,t=Aa,s=!0),e=Sa(e),a?Re(t,e,a):(i={forward:function(r){return Re(t,e,r)},inverse:function(r){return Re(e,t,r)}},s&&(i.oProj=e),i)}var H=As;var Na=6,Ra="AJSAJS",Ca="AFAFAF",bt=65,z=73,W=79,Tt=86,Dt=90,La={forward:Le,inverse:Ss,toPoint:Te};function Le(t,e){return e=e||5,Rs(Ns({lat:t[1],lon:t[0]}),e)}function Ss(t){var e=De(Da(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat,e.lon,e.lat]:[e.left,e.bottom,e.right,e.top]}function Te(t){var e=De(Da(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function Ce(t){return t*(Math.PI/180)}function wa(t){return 180*(t/Math.PI)}function Ns(t){var e=t.lat,a=t.lon,s=6378137,i=.00669438,r=.9996,n,h,o,l,u,f,c,M=Ce(e),d=Ce(a),y,x;x=Math.floor((a+180)/6)+1,a===180&&(x=60),e>=56&&e<64&&a>=3&&a<12&&(x=32),e>=72&&e<84&&(a>=0&&a<9?x=31:a>=9&&a<21?x=33:a>=21&&a<33?x=35:a>=33&&a<42&&(x=37)),n=(x-1)*6-180+3,y=Ce(n),h=i/(1-i),o=s/Math.sqrt(1-i*Math.sin(M)*Math.sin(M)),l=Math.tan(M)*Math.tan(M),u=h*Math.cos(M)*Math.cos(M),f=Math.cos(M)*(d-y),c=s*((1-i/4-3*i*i/64-5*i*i*i/256)*M-(3*i/8+3*i*i/32+45*i*i*i/1024)*Math.sin(2*M)+(15*i*i/256+45*i*i*i/1024)*Math.sin(4*M)-35*i*i*i/3072*Math.sin(6*M));var g=r*o*(f+(1-l+u)*f*f*f/6+(5-18*l+l*l+72*u-58*h)*f*f*f*f*f/120)+5e5,b=r*(c+o*Math.tan(M)*(f*f/2+(5-l+9*u+4*u*u)*f*f*f*f/24+(61-58*l+l*l+600*u-330*h)*f*f*f*f*f*f/720));return e<0&&(b+=1e7),{northing:Math.round(b),easting:Math.round(g),zoneNumber:x,zoneLetter:ws(e)}}function De(t){var e=t.northing,a=t.easting,s=t.zoneLetter,i=t.zoneNumber;if(i<0||i>60)return null;var r=.9996,n=6378137,h=.00669438,o,l=(1-Math.sqrt(1-h))/(1+Math.sqrt(1-h)),u,f,c,M,d,y,x,g,b,E=a-5e5,N=e;s<"N"&&(N-=1e7),x=(i-1)*6-180+3,o=h/(1-h),y=N/r,g=y/(n*(1-h/4-3*h*h/64-5*h*h*h/256)),b=g+(3*l/2-27*l*l*l/32)*Math.sin(2*g)+(21*l*l/16-55*l*l*l*l/32)*Math.sin(4*g)+151*l*l*l/96*Math.sin(6*g),u=n/Math.sqrt(1-h*Math.sin(b)*Math.sin(b)),f=Math.tan(b)*Math.tan(b),c=o*Math.cos(b)*Math.cos(b),M=n*(1-h)/Math.pow(1-h*Math.sin(b)*Math.sin(b),1.5),d=E/(u*r);var P=b-u*Math.tan(b)/M*(d*d/2-(5+3*f+10*c-4*c*c-9*o)*d*d*d*d/24+(61+90*f+298*c+45*f*f-252*o-3*c*c)*d*d*d*d*d*d/720);P=wa(P);var A=(d-(1+2*f+c)*d*d*d/6+(5-2*c+28*f-3*c*c+8*o+24*f*f)*d*d*d*d*d/120)/Math.cos(b);A=x+wa(A);var O;if(t.accuracy){var C=De({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});O={top:C.lat,right:C.lon,bottom:P,left:A}}else O={lat:P,lon:A};return O}function ws(t){var e="Z";return 84>=t&&t>=72?e="X":72>t&&t>=64?e="W":64>t&&t>=56?e="V":56>t&&t>=48?e="U":48>t&&t>=40?e="T":40>t&&t>=32?e="S":32>t&&t>=24?e="R":24>t&&t>=16?e="Q":16>t&&t>=8?e="P":8>t&&t>=0?e="N":0>t&&t>=-8?e="M":-8>t&&t>=-16?e="L":-16>t&&t>=-24?e="K":-24>t&&t>=-32?e="J":-32>t&&t>=-40?e="H":-40>t&&t>=-48?e="G":-48>t&&t>=-56?e="F":-56>t&&t>=-64?e="E":-64>t&&t>=-72?e="D":-72>t&&t>=-80&&(e="C"),e}function Rs(t,e){var a="00000"+t.easting,s="00000"+t.northing;return t.zoneNumber+t.zoneLetter+Cs(t.easting,t.northing,t.zoneNumber)+a.substr(a.length-5,e)+s.substr(s.length-5,e)}function Cs(t,e,a){var s=Ta(a),i=Math.floor(t/1e5),r=Math.floor(e/1e5)%20;return Ls(i,r,s)}function Ta(t){var e=t%Na;return e===0&&(e=Na),e}function Ls(t,e,a){var s=a-1,i=Ra.charCodeAt(s),r=Ca.charCodeAt(s),n=i+t-1,h=r+e,o=!1;n>Dt&&(n=n-Dt+bt-1,o=!0),(n===z||i<z&&n>z||(n>z||i<z)&&o)&&n++,(n===W||i<W&&n>W||(n>W||i<W)&&o)&&(n++,n===z&&n++),n>Dt&&(n=n-Dt+bt-1),h>Tt?(h=h-Tt+bt-1,o=!0):o=!1,(h===z||r<z&&h>z||(h>z||r<z)&&o)&&h++,(h===W||r<W&&h>W||(h>W||r<W)&&o)&&(h++,h===z&&h++),h>Tt&&(h=h-Tt+bt-1);var l=String.fromCharCode(n)+String.fromCharCode(h);return l}function Da(t){if(t&&t.length===0)throw"MGRSPoint coverting from nothing";for(var e=t.length,a=null,s="",i,r=0;!/[A-Z]/.test(i=t.charAt(r));){if(r>=2)throw"MGRSPoint bad conversion from: "+t;s+=i,r++}var n=parseInt(s,10);if(r===0||r+3>e)throw"MGRSPoint bad conversion from: "+t;var h=t.charAt(r++);if(h<="A"||h==="B"||h==="Y"||h>="Z"||h==="I"||h==="O")throw"MGRSPoint zone letter "+h+" not handled: "+t;a=t.substring(r,r+=2);for(var o=Ta(n),l=Ts(a.charAt(0),o),u=Ds(a.charAt(1),o);u<Os(h);)u+=2e6;var f=e-r;if(f%2!==0)throw`MGRSPoint has to have an even number
8
+ of digits after the zone letter and two 100km letters - front
9
+ half for easting meters, second half for
10
+ northing meters`+t;var c=f/2,M=0,d=0,y,x,g,b,E;return c>0&&(y=1e5/Math.pow(10,c),x=t.substring(r,r+c),M=parseFloat(x)*y,g=t.substring(r+c),d=parseFloat(g)*y),b=M+l,E=d+u,{easting:b,northing:E,zoneLetter:h,zoneNumber:n,accuracy:y}}function Ts(t,e){for(var a=Ra.charCodeAt(e-1),s=1e5,i=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Dt){if(i)throw"Bad character: "+t;a=bt,i=!0}s+=1e5}return s}function Ds(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;for(var a=Ca.charCodeAt(e-1),s=0,i=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Tt){if(i)throw"Bad character: "+t;a=bt,i=!0}s+=1e5}return s}function Os(t){var e;switch(t){case"C":e=11e5;break;case"D":e=2e6;break;case"E":e=28e5;break;case"F":e=37e5;break;case"G":e=46e5;break;case"H":e=55e5;break;case"J":e=64e5;break;case"K":e=73e5;break;case"L":e=82e5;break;case"M":e=91e5;break;case"N":e=0;break;case"P":e=8e5;break;case"Q":e=17e5;break;case"R":e=26e5;break;case"S":e=35e5;break;case"T":e=44e5;break;case"U":e=53e5;break;case"V":e=62e5;break;case"W":e=7e6;break;case"X":e=79e5;break;default:e=-1}if(e>=0)return e;throw"Invalid zone letter: "+t}function Et(t,e,a){if(!(this instanceof Et))return new Et(t,e,a);if(Array.isArray(t))this.x=t[0],this.y=t[1],this.z=t[2]||0;else if(typeof t=="object")this.x=t.x,this.y=t.y,this.z=t.z||0;else if(typeof t=="string"&&typeof e>"u"){var s=t.split(",");this.x=parseFloat(s[0],10),this.y=parseFloat(s[1],10),this.z=parseFloat(s[2],10)||0}else this.x=t,this.y=e,this.z=a||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Et.fromMGRS=function(t){return new Et(Te(t))};Et.prototype.toMGRS=function(t){return Le([this.x,this.y],t)};var Oa=Et;var Bs=1,Gs=.25,Ba=.046875,Ga=.01953125,Fa=.01068115234375,Fs=.75,qs=.46875,zs=.013020833333333334,js=.007120768229166667,ks=.3645833333333333,Hs=.005696614583333333,Us=.3076171875;function re(t){var e=[];e[0]=Bs-t*(Gs+t*(Ba+t*(Ga+t*Fa))),e[1]=t*(Fs-t*(Ba+t*(Ga+t*Fa)));var a=t*t;return e[2]=a*(qs-t*(zs+t*js)),a*=t,e[3]=a*(ks-t*Hs),e[4]=a*t*Us,e}function vt(t,e,a,s){return a*=e,e*=e,s[0]*t-a*(s[1]+e*(s[2]+e*(s[3]+e*s[4])))}var Ws=20;function ne(t,e,a){for(var s=1/(1-e),i=t,r=Ws;r;--r){var n=Math.sin(i),h=1-e*n*n;if(h=(vt(i,n,Math.cos(i),a)-t)*(h*Math.sqrt(h))*s,i-=h,Math.abs(h)<p)return i}return i}function Xs(){this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.es&&(this.en=re(this.es),this.ml0=vt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Js(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r,n,h=Math.sin(a),o=Math.cos(a);if(this.es){var u=o*s,f=Math.pow(u,2),c=this.ep2*Math.pow(o,2),M=Math.pow(c,2),d=Math.abs(o)>p?Math.tan(a):0,y=Math.pow(d,2),x=Math.pow(y,2);i=1-this.es*Math.pow(h,2),u=u/Math.sqrt(i);var g=vt(a,h,o,this.en);r=this.a*(this.k0*u*(1+f/6*(1-y+c+f/20*(5-18*y+x+14*c-58*y*c+f/42*(61+179*x-x*y-479*y)))))+this.x0,n=this.a*(this.k0*(g-this.ml0+h*s*u/2*(1+f/12*(5-y+9*c+4*M+f/30*(61+x-58*y+270*c-330*y*c+f/56*(1385+543*x-x*y-3111*y))))))+this.y0}else{var l=o*Math.sin(s);if(Math.abs(Math.abs(l)-1)<p)return 93;if(r=.5*this.a*this.k0*Math.log((1+l)/(1-l))+this.x0,n=o*Math.cos(s)/Math.sqrt(1-Math.pow(l,2)),l=Math.abs(n),l>=1){if(l-1>p)return 93;n=0}else n=Math.acos(n);a<0&&(n=-n),n=this.a*this.k0*(n-this.lat0)+this.y0}return t.x=r,t.y=n,t}function Qs(t){var e,a,s,i,r=(t.x-this.x0)*(1/this.a),n=(t.y-this.y0)*(1/this.a);if(this.es)if(e=this.ml0+n/this.k0,a=ne(e,this.es,this.en),Math.abs(a)<m){var f=Math.sin(a),c=Math.cos(a),M=Math.abs(c)>p?Math.tan(a):0,d=this.ep2*Math.pow(c,2),y=Math.pow(d,2),x=Math.pow(M,2),g=Math.pow(x,2);e=1-this.es*Math.pow(f,2);var b=r*Math.sqrt(e)/this.k0,E=Math.pow(b,2);e=e*M,s=a-e*E/(1-this.es)*.5*(1-E/12*(5+3*x-9*d*x+d-4*y-E/30*(61+90*x-252*d*x+45*g+46*d-E/56*(1385+3633*x+4095*g+1574*g*x)))),i=v(this.long0+b*(1-E/6*(1+2*x+d-E/20*(5+28*x+24*g+8*d*x+6*d-E/42*(61+662*x+1320*g+720*g*x))))/c)}else s=m*$(n),i=0;else{var h=Math.exp(r/this.k0),o=.5*(h-1/h),l=this.lat0+n/this.k0,u=Math.cos(l);e=Math.sqrt((1-Math.pow(u,2))/(1+Math.pow(o,2))),s=Math.asin(e),n<0&&(s=-s),o===0&&u===0?i=0:i=v(Math.atan2(o,u)+this.long0)}return t.x=i,t.y=s,t}var Vs=["Transverse_Mercator","Transverse Mercator","tmerc"],qa={init:Xs,forward:Js,inverse:Qs,names:Vs};function he(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Ot(t,e){t=Math.abs(t),e=Math.abs(e);var a=Math.max(t,e),s=Math.min(t,e)/(a||1);return a*Math.sqrt(1+Math.pow(s,2))}function za(t){var e=1+t,a=e-1;return a===0?t:t*Math.log(e)/a}function ja(t){var e=Math.abs(t);return e=za(e*(1+e/(Ot(1,e)+1))),t<0?-e:e}function oe(t,e){for(var a=2*Math.cos(2*e),s=t.length-1,i=t[s],r=0,n;--s>=0;)n=-r+a*i+t[s],r=i,i=n;return e+n*Math.sin(2*e)}function ka(t,e){for(var a=2*Math.cos(e),s=t.length-1,i=t[s],r=0,n;--s>=0;)n=-r+a*i+t[s],r=i,i=n;return Math.sin(e)*n}function Ha(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function Oe(t,e,a){for(var s=Math.sin(e),i=Math.cos(e),r=he(a),n=Ha(a),h=2*i*n,o=-2*s*r,l=t.length-1,u=t[l],f=0,c=0,M=0,d,y;--l>=0;)d=c,y=f,c=u,f=M,u=-d+h*c-o*f+t[l],M=-y+o*c+h*f;return h=s*n,o=i*r,[h*u-o*M,h*M+o*u]}function Ks(){if(this.es===void 0||this.es<=0)throw new Error("incorrect elliptical usage");this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=this.es/(1+Math.sqrt(1-this.es)),e=t/(2-t),a=e;this.cgb[0]=e*(2+e*(-2/3+e*(-2+e*(116/45+e*(26/45+e*(-2854/675)))))),this.cbg[0]=e*(-2+e*(2/3+e*(4/3+e*(-82/45+e*(32/45+e*(4642/4725)))))),a=a*e,this.cgb[1]=a*(7/3+e*(-8/5+e*(-227/45+e*(2704/315+e*(2323/945))))),this.cbg[1]=a*(5/3+e*(-16/15+e*(-13/9+e*(904/315+e*(-1522/945))))),a=a*e,this.cgb[2]=a*(56/15+e*(-136/35+e*(-1262/105+e*(73814/2835)))),this.cbg[2]=a*(-26/15+e*(34/21+e*(8/5+e*(-12686/2835)))),a=a*e,this.cgb[3]=a*(4279/630+e*(-332/35+e*(-399572/14175))),this.cbg[3]=a*(1237/630+e*(-12/5+e*(-24832/14175))),a=a*e,this.cgb[4]=a*(4174/315+e*(-144838/6237)),this.cbg[4]=a*(-734/315+e*(109598/31185)),a=a*e,this.cgb[5]=a*(601676/22275),this.cbg[5]=a*(444337/155925),a=Math.pow(e,2),this.Qn=this.k0/(1+e)*(1+a*(1/4+a*(1/64+a/256))),this.utg[0]=e*(-.5+e*(2/3+e*(-37/96+e*(1/360+e*(81/512+e*(-96199/604800)))))),this.gtu[0]=e*(.5+e*(-2/3+e*(5/16+e*(41/180+e*(-127/288+e*(7891/37800)))))),this.utg[1]=a*(-1/48+e*(-1/15+e*(437/1440+e*(-46/105+e*(1118711/3870720))))),this.gtu[1]=a*(13/48+e*(-3/5+e*(557/1440+e*(281/630+e*(-1983433/1935360))))),a=a*e,this.utg[2]=a*(-17/480+e*(37/840+e*(209/4480+e*(-5569/90720)))),this.gtu[2]=a*(61/240+e*(-103/140+e*(15061/26880+e*(167603/181440)))),a=a*e,this.utg[3]=a*(-4397/161280+e*(11/504+e*(830251/7257600))),this.gtu[3]=a*(49561/161280+e*(-179/168+e*(6601661/7257600))),a=a*e,this.utg[4]=a*(-4583/161280+e*(108847/3991680)),this.gtu[4]=a*(34729/80640+e*(-3418889/1995840)),a=a*e,this.utg[5]=a*(-20648693/638668800),this.gtu[5]=a*(212378941/319334400);var s=oe(this.cbg,this.lat0);this.Zb=-this.Qn*(s+ka(this.gtu,2*s))}function Ys(t){var e=v(t.x-this.long0),a=t.y;a=oe(this.cbg,a);var s=Math.sin(a),i=Math.cos(a),r=Math.sin(e),n=Math.cos(e);a=Math.atan2(s,n*i),e=Math.atan2(r*i,Ot(s,i*n)),e=ja(Math.tan(e));var h=Oe(this.gtu,2*a,2*e);a=a+h[0],e=e+h[1];var o,l;return Math.abs(e)<=2.623395162778?(o=this.a*(this.Qn*e)+this.x0,l=this.a*(this.Qn*a+this.Zb)+this.y0):(o=1/0,l=1/0),t.x=o,t.y=l,t}function Zs(t){var e=(t.x-this.x0)*(1/this.a),a=(t.y-this.y0)*(1/this.a);a=(a-this.Zb)/this.Qn,e=e/this.Qn;var s,i;if(Math.abs(e)<=2.623395162778){var r=Oe(this.utg,2*a,2*e);a=a+r[0],e=e+r[1],e=Math.atan(he(e));var n=Math.sin(a),h=Math.cos(a),o=Math.sin(e),l=Math.cos(e);a=Math.atan2(n*l,Ot(o,l*h)),e=Math.atan2(o,l*h),s=v(e+this.long0),i=oe(this.cgb,a)}else s=1/0,i=1/0;return t.x=s,t.y=i,t}var $s=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"],It={init:Ks,forward:Ys,inverse:Zs,names:$s};function Ua(t,e){if(t===void 0){if(t=Math.floor((v(e)+Math.PI)*30/Math.PI)+1,t<0)return 0;if(t>60)return 60}return t}var tr="etmerc";function er(){var t=Ua(this.zone,this.long0);if(t===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(t)-183)*L,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,It.init.apply(this),this.forward=It.forward,this.inverse=It.inverse}var ar=["Universal Transverse Mercator System","utm"],Wa={init:er,names:ar,dependsOn:tr};function le(t,e){return Math.pow((1-t)/(1+t),e)}var ir=20;function sr(){var t=Math.sin(this.lat0),e=Math.cos(this.lat0);e*=e,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*e*e/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+I)/(Math.pow(Math.tan(.5*this.lat0+I),this.C)*le(this.e*t,this.ratexp))}function rr(t){var e=t.x,a=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*a+I),this.C)*le(this.e*Math.sin(a),this.ratexp))-m,t.x=this.C*e,t}function nr(t){for(var e=1e-14,a=t.x/this.C,s=t.y,i=Math.pow(Math.tan(.5*s+I)/this.K,1/this.C),r=ir;r>0&&(s=2*Math.atan(i*le(this.e*Math.sin(t.y),-.5*this.e))-m,!(Math.abs(s-t.y)<e));--r)t.y=s;return r?(t.x=a,t.y=s,t):null}var hr=["gauss"],fe={init:sr,forward:rr,inverse:nr,names:hr};function or(){fe.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))}function lr(t){var e,a,s,i;return t.x=v(t.x-this.long0),fe.forward.apply(this,[t]),e=Math.sin(t.y),a=Math.cos(t.y),s=Math.cos(t.x),i=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*a*s),t.x=i*a*Math.sin(t.x),t.y=i*(this.cosc0*e-this.sinc0*a*s),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function fr(t){var e,a,s,i,r;if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,r=Math.sqrt(t.x*t.x+t.y*t.y)){var n=2*Math.atan2(r,this.R2);e=Math.sin(n),a=Math.cos(n),i=Math.asin(a*this.sinc0+t.y*e*this.cosc0/r),s=Math.atan2(t.x*e,r*this.cosc0*a-t.y*this.sinc0*e)}else i=this.phic0,s=0;return t.x=s,t.y=i,fe.inverse.apply(this,[t]),t.x=v(t.x+this.long0),t}var ur=["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],Xa={init:or,forward:lr,inverse:fr,names:ur};function cr(t,e,a){return e*=a,Math.tan(.5*(m+t))*Math.pow((1-e)/(1+e),.5*a)}function mr(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=p&&(this.k0=.5*(1+$(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=p&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=p&&(this.k0=.5*this.cons*B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/F(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=B(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-m,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function Mr(t){var e=t.x,a=t.y,s=Math.sin(a),i=Math.cos(a),r,n,h,o,l,u,f=v(e-this.long0);return Math.abs(Math.abs(e-this.long0)-Math.PI)<=p&&Math.abs(a+this.lat0)<=p?(t.x=NaN,t.y=NaN,t):this.sphere?(r=2*this.k0/(1+this.sinlat0*s+this.coslat0*i*Math.cos(f)),t.x=this.a*r*i*Math.sin(f)+this.x0,t.y=this.a*r*(this.coslat0*s-this.sinlat0*i*Math.cos(f))+this.y0,t):(n=2*Math.atan(this.ssfn_(a,s,this.e))-m,o=Math.cos(n),h=Math.sin(n),Math.abs(this.coslat0)<=p?(l=F(this.e,a*this.con,this.con*s),u=2*this.a*this.k0*l/this.cons,t.x=this.x0+u*Math.sin(e-this.long0),t.y=this.y0-this.con*u*Math.cos(e-this.long0),t):(Math.abs(this.sinlat0)<p?(r=2*this.a*this.k0/(1+o*Math.cos(f)),t.y=r*h):(r=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*h+this.cosX0*o*Math.cos(f))),t.y=r*(this.cosX0*h-this.sinX0*o*Math.cos(f))+this.y0),t.x=r*o*Math.sin(f)+this.x0,t))}function dr(t){t.x-=this.x0,t.y-=this.y0;var e,a,s,i,r,n=Math.sqrt(t.x*t.x+t.y*t.y);if(this.sphere){var h=2*Math.atan(n/(2*this.a*this.k0));return e=this.long0,a=this.lat0,n<=p?(t.x=e,t.y=a,t):(a=Math.asin(Math.cos(h)*this.sinlat0+t.y*Math.sin(h)*this.coslat0/n),Math.abs(this.coslat0)<p?this.lat0>0?e=v(this.long0+Math.atan2(t.x,-1*t.y)):e=v(this.long0+Math.atan2(t.x,t.y)):e=v(this.long0+Math.atan2(t.x*Math.sin(h),n*this.coslat0*Math.cos(h)-t.y*this.sinlat0*Math.sin(h))),t.x=e,t.y=a,t)}else if(Math.abs(this.coslat0)<=p){if(n<=p)return a=this.lat0,e=this.long0,t.x=e,t.y=a,t;t.x*=this.con,t.y*=this.con,s=n*this.cons/(2*this.a*this.k0),a=this.con*at(this.e,s),e=this.con*v(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else i=2*Math.atan(n*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,n<=p?r=this.X0:(r=Math.asin(Math.cos(i)*this.sinX0+t.y*Math.sin(i)*this.cosX0/n),e=v(this.long0+Math.atan2(t.x*Math.sin(i),n*this.cosX0*Math.cos(i)-t.y*this.sinX0*Math.sin(i)))),a=-1*at(this.e,Math.tan(.5*(m+r)));return t.x=e,t.y=a,t}var pr=["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],Ja={init:mr,forward:Mr,inverse:dr,names:pr,ssfn_:cr};function vr(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),a=this.a,s=this.rf,i=1/s,r=2*i-Math.pow(i,2),n=this.e=Math.sqrt(r);this.R=this.k0*a*Math.sqrt(1-r)/(1-r*Math.pow(e,2)),this.alpha=Math.sqrt(1+r/(1-r)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(e/this.alpha);var h=Math.log(Math.tan(Math.PI/4+this.b0/2)),o=Math.log(Math.tan(Math.PI/4+t/2)),l=Math.log((1+n*e)/(1-n*e));this.K=h-this.alpha*o+this.alpha*n/2*l}function yr(t){var e=Math.log(Math.tan(Math.PI/4-t.y/2)),a=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),s=-this.alpha*(e+a)+this.K,i=2*(Math.atan(Math.exp(s))-Math.PI/4),r=this.alpha*(t.x-this.lambda0),n=Math.atan(Math.sin(r)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(r))),h=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(r));return t.y=this.R/2*Math.log((1+Math.sin(h))/(1-Math.sin(h)))+this.y0,t.x=this.R*n+this.x0,t}function xr(t){for(var e=t.x-this.x0,a=t.y-this.y0,s=e/this.R,i=2*(Math.atan(Math.exp(a/this.R))-Math.PI/4),r=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(s)),n=Math.atan(Math.sin(s)/(Math.cos(this.b0)*Math.cos(s)-Math.sin(this.b0)*Math.tan(i))),h=this.lambda0+n/this.alpha,o=0,l=r,u=-1e3,f=0;Math.abs(l-u)>1e-7;){if(++f>20)return;o=1/this.alpha*(Math.log(Math.tan(Math.PI/4+r/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(l))/2)),u=l,l=2*Math.atan(Math.exp(o))-Math.PI/2}return t.x=h,t.y=l,t}var gr=["somerc"],Qa={init:vr,forward:yr,inverse:xr,names:gr};function _r(){this.no_off=this.no_off||!1,this.no_rot=this.no_rot||!1,isNaN(this.k0)&&(this.k0=1);var t=Math.sin(this.lat0),e=Math.cos(this.lat0),a=this.e*t;this.bl=Math.sqrt(1+this.es/(1-this.es)*Math.pow(e,4)),this.al=this.a*this.bl*this.k0*Math.sqrt(1-this.es)/(1-a*a);var s=F(this.e,this.lat0,t),i=this.bl/e*Math.sqrt((1-this.es)/(1-a*a));i*i<1&&(i=1);var r,n;if(!isNaN(this.longc))this.lat0>=0?r=i+Math.sqrt(i*i-1):r=i-Math.sqrt(i*i-1),this.el=r*Math.pow(s,this.bl),n=.5*(r-1/r),this.gamma0=Math.asin(Math.sin(this.alpha)/i),this.long0=this.longc-Math.asin(n*Math.tan(this.gamma0))/this.bl;else{var h=F(this.e,this.lat1,Math.sin(this.lat1)),o=F(this.e,this.lat2,Math.sin(this.lat2));this.lat0>=0?this.el=(i+Math.sqrt(i*i-1))*Math.pow(s,this.bl):this.el=(i-Math.sqrt(i*i-1))*Math.pow(s,this.bl);var l=Math.pow(h,this.bl),u=Math.pow(o,this.bl);r=this.el/l,n=.5*(r-1/r);var f=(this.el*this.el-u*l)/(this.el*this.el+u*l),c=(u-l)/(u+l),M=v(this.long1-this.long2);this.long0=.5*(this.long1+this.long2)-Math.atan(f*Math.tan(.5*this.bl*M)/c)/this.bl,this.long0=v(this.long0);var d=v(this.long1-this.long0);this.gamma0=Math.atan(Math.sin(this.bl*d)/n),this.alpha=Math.asin(i*Math.sin(this.gamma0))}this.no_off?this.uc=0:this.lat0>=0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(i*i-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(i*i-1),Math.cos(this.alpha))}function br(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r,n;if(Math.abs(Math.abs(a)-m)<=p)a>0?n=-1:n=1,r=this.al/this.bl*Math.log(Math.tan(I+n*this.gamma0*.5)),i=-1*n*m*this.al/this.bl;else{var h=F(this.e,a,Math.sin(a)),o=this.el/Math.pow(h,this.bl),l=.5*(o-1/o),u=.5*(o+1/o),f=Math.sin(this.bl*s),c=(l*Math.sin(this.gamma0)-f*Math.cos(this.gamma0))/u;Math.abs(Math.abs(c)-1)<=p?r=Number.POSITIVE_INFINITY:r=.5*this.al*Math.log((1-c)/(1+c))/this.bl,Math.abs(Math.cos(this.bl*s))<=p?i=this.al*this.bl*s:i=this.al*Math.atan2(l*Math.cos(this.gamma0)+f*Math.sin(this.gamma0),Math.cos(this.bl*s))/this.bl}return this.no_rot?(t.x=this.x0+i,t.y=this.y0+r):(i-=this.uc,t.x=this.x0+r*Math.cos(this.alpha)+i*Math.sin(this.alpha),t.y=this.y0+i*Math.cos(this.alpha)-r*Math.sin(this.alpha)),t}function Er(t){var e,a;this.no_rot?(a=t.y-this.y0,e=t.x-this.x0):(a=(t.x-this.x0)*Math.cos(this.alpha)-(t.y-this.y0)*Math.sin(this.alpha),e=(t.y-this.y0)*Math.cos(this.alpha)+(t.x-this.x0)*Math.sin(this.alpha),e+=this.uc);var s=Math.exp(-1*this.bl*a/this.al),i=.5*(s-1/s),r=.5*(s+1/s),n=Math.sin(this.bl*e/this.al),h=(n*Math.cos(this.gamma0)+i*Math.sin(this.gamma0))/r,o=Math.pow(this.el/Math.sqrt((1+h)/(1-h)),1/this.bl);return Math.abs(h-1)<p?(t.x=this.long0,t.y=m):Math.abs(h+1)<p?(t.x=this.long0,t.y=-1*m):(t.y=at(this.e,o),t.x=v(this.long0-Math.atan2(i*Math.cos(this.gamma0)-n*Math.sin(this.gamma0),Math.cos(this.bl*e/this.al))/this.bl)),t}var Ir=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"],Va={init:_r,forward:br,inverse:Er,names:Ir};function Pr(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<p)){var t=this.b/this.a;this.e=Math.sqrt(1-t*t);var e=Math.sin(this.lat1),a=Math.cos(this.lat1),s=B(this.e,e,a),i=F(this.e,this.lat1,e),r=Math.sin(this.lat2),n=Math.cos(this.lat2),h=B(this.e,r,n),o=F(this.e,this.lat2,r),l=F(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>p?this.ns=Math.log(s/h)/Math.log(i/o):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=s/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(l,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function Ar(t){var e=t.x,a=t.y;Math.abs(2*Math.abs(a)-Math.PI)<=p&&(a=$(a)*(m-2*p));var s=Math.abs(Math.abs(a)-m),i,r;if(s>p)i=F(this.e,a,Math.sin(a)),r=this.a*this.f0*Math.pow(i,this.ns);else{if(s=a*this.ns,s<=0)return null;r=0}var n=this.ns*v(e-this.long0);return t.x=this.k0*(r*Math.sin(n))+this.x0,t.y=this.k0*(this.rh-r*Math.cos(n))+this.y0,t}function Sr(t){var e,a,s,i,r,n=(t.x-this.x0)/this.k0,h=this.rh-(t.y-this.y0)/this.k0;this.ns>0?(e=Math.sqrt(n*n+h*h),a=1):(e=-Math.sqrt(n*n+h*h),a=-1);var o=0;if(e!==0&&(o=Math.atan2(a*n,a*h)),e!==0||this.ns>0){if(a=1/this.ns,s=Math.pow(e/(this.a*this.f0),a),i=at(this.e,s),i===-9999)return null}else i=-m;return r=v(o/this.ns+this.long0),t.x=r,t.y=i,t}var Nr=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"],Ka={init:Pr,forward:Ar,inverse:Sr,names:Nr};function wr(){this.a=6377397155e-3,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.7417649320975901-.308341501185665),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq}function Rr(t){var e,a,s,i,r,n,h,o=t.x,l=t.y,u=v(o-this.long0);return e=Math.pow((1+this.e*Math.sin(l))/(1-this.e*Math.sin(l)),this.alfa*this.e/2),a=2*(Math.atan(this.k*Math.pow(Math.tan(l/2+this.s45),this.alfa)/e)-this.s45),s=-u*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(a)+Math.sin(this.ad)*Math.cos(a)*Math.cos(s)),r=Math.asin(Math.cos(a)*Math.sin(s)/Math.cos(i)),n=this.n*r,h=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(i/2+this.s45),this.n),t.y=h*Math.cos(n)/1,t.x=h*Math.sin(n)/1,this.czech||(t.y*=-1,t.x*=-1),t}function Cr(t){var e,a,s,i,r,n,h,o,l=t.x;t.x=t.y,t.y=l,this.czech||(t.y*=-1,t.x*=-1),n=Math.sqrt(t.x*t.x+t.y*t.y),r=Math.atan2(t.y,t.x),i=r/Math.sin(this.s0),s=2*(Math.atan(Math.pow(this.ro0/n,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),e=Math.asin(Math.cos(this.ad)*Math.sin(s)-Math.sin(this.ad)*Math.cos(s)*Math.cos(i)),a=Math.asin(Math.cos(s)*Math.sin(i)/Math.cos(e)),t.x=this.long0-a/this.alfa,h=e,o=0;var u=0;do t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(e/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(h))/(1-this.e*Math.sin(h)),this.e/2))-this.s45),Math.abs(h-t.y)<1e-10&&(o=1),h=t.y,u+=1;while(o===0&&u<15);return u>=15?null:t}var Lr=["Krovak","krovak"],Ya={init:wr,forward:Rr,inverse:Cr,names:Lr};function D(t,e,a,s,i){return t*i-e*Math.sin(2*i)+a*Math.sin(4*i)-s*Math.sin(6*i)}function it(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function st(t){return .375*t*(1+.25*t*(1+.46875*t))}function rt(t){return .05859375*t*t*(1+.75*t)}function nt(t){return t*t*t*(35/3072)}function ht(t,e,a){var s=e*a;return t/Math.sqrt(1-s*s)}function K(t){return Math.abs(t)<m?t:t-$(t)*Math.PI}function yt(t,e,a,s,i){var r,n;r=t/e;for(var h=0;h<15;h++)if(n=(t-(e*r-a*Math.sin(2*r)+s*Math.sin(4*r)-i*Math.sin(6*r)))/(e-2*a*Math.cos(2*r)+4*s*Math.cos(4*r)-6*i*Math.cos(6*r)),r+=n,Math.abs(n)<=1e-10)return r;return NaN}function Tr(){this.sphere||(this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.ml0=this.a*D(this.e0,this.e1,this.e2,this.e3,this.lat0))}function Dr(t){var e,a,s=t.x,i=t.y;if(s=v(s-this.long0),this.sphere)e=this.a*Math.asin(Math.cos(i)*Math.sin(s)),a=this.a*(Math.atan2(Math.tan(i),Math.cos(s))-this.lat0);else{var r=Math.sin(i),n=Math.cos(i),h=ht(this.a,this.e,r),o=Math.tan(i)*Math.tan(i),l=s*Math.cos(i),u=l*l,f=this.es*n*n/(1-this.es),c=this.a*D(this.e0,this.e1,this.e2,this.e3,i);e=h*l*(1-u*o*(1/6-(8-o+8*f)*u/120)),a=c-this.ml0+h*r/n*u*(.5+(5-o+6*f)*u/24)}return t.x=e+this.x0,t.y=a+this.y0,t}function Or(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,s,i;if(this.sphere){var r=a+this.lat0;s=Math.asin(Math.sin(r)*Math.cos(e)),i=Math.atan2(Math.tan(e),Math.cos(r))}else{var n=this.ml0/this.a+a,h=yt(n,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(h)-m)<=p)return t.x=this.long0,t.y=m,a<0&&(t.y*=-1),t;var o=ht(this.a,this.e,Math.sin(h)),l=o*o*o/this.a/this.a*(1-this.es),u=Math.pow(Math.tan(h),2),f=e*this.a/o,c=f*f;s=h-o*Math.tan(h)/l*f*f*(.5-(1+3*u)*f*f/24),i=f*(1-c*(u/3+(1+3*u)*u*c/15))/Math.cos(h)}return t.x=v(i+this.long0),t.y=K(s),t}var Br=["Cassini","Cassini_Soldner","cass"],Za={init:Tr,forward:Dr,inverse:Or,names:Br};function Y(t,e){var a;return t>1e-7?(a=t*e,(1-t*t)*(e/(1-a*a)-.5/t*Math.log((1-a)/(1+a)))):2*e}var Gr=1,Fr=2,qr=3,zr=4;function jr(){var t=Math.abs(this.lat0);if(Math.abs(t-m)<p?this.mode=this.lat0<0?this.S_POLE:this.N_POLE:Math.abs(t)<p?this.mode=this.EQUIT:this.mode=this.OBLIQ,this.es>0){var e;switch(this.qp=Y(this.e,1),this.mmf=.5/(1-this.es),this.apa=Kr(this.es),this.mode){case this.N_POLE:this.dd=1;break;case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),e=Math.sin(this.lat0),this.sinb1=Y(this.e,e)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*e*e)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd;break}}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function kr(t){var e,a,s,i,r,n,h,o,l,u,f=t.x,c=t.y;if(f=v(f-this.long0),this.sphere){if(r=Math.sin(c),u=Math.cos(c),s=Math.cos(f),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(a=this.mode===this.EQUIT?1+u*s:1+this.sinph0*r+this.cosph0*u*s,a<=p)return null;a=Math.sqrt(2/a),e=a*u*Math.sin(f),a*=this.mode===this.EQUIT?r:this.cosph0*r-this.sinph0*u*s}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(s=-s),Math.abs(c+this.lat0)<p)return null;a=I-c*.5,a=2*(this.mode===this.S_POLE?Math.cos(a):Math.sin(a)),e=a*Math.sin(f),a*=s}}else{switch(h=0,o=0,l=0,s=Math.cos(f),i=Math.sin(f),r=Math.sin(c),n=Y(this.e,r),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(h=n/this.qp,o=Math.sqrt(1-h*h)),this.mode){case this.OBLIQ:l=1+this.sinb1*h+this.cosb1*o*s;break;case this.EQUIT:l=1+o*s;break;case this.N_POLE:l=m+c,n=this.qp-n;break;case this.S_POLE:l=c-m,n=this.qp+n;break}if(Math.abs(l)<p)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:l=Math.sqrt(2/l),this.mode===this.OBLIQ?a=this.ymf*l*(this.cosb1*h-this.sinb1*o*s):a=(l=Math.sqrt(2/(1+o*s)))*h*this.ymf,e=this.xmf*l*o*i;break;case this.N_POLE:case this.S_POLE:n>=0?(e=(l=Math.sqrt(n))*i,a=s*(this.mode===this.S_POLE?l:-l)):e=a=0;break}}return t.x=this.a*e+this.x0,t.y=this.a*a+this.y0,t}function Hr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,s,i,r,n,h,o,l;if(this.sphere){var u=0,f,c=0;if(f=Math.sqrt(e*e+a*a),i=f*.5,i>1)return null;switch(i=2*Math.asin(i),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(c=Math.sin(i),u=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(f)<=p?0:Math.asin(a*c/f),e*=c,a=u*f;break;case this.OBLIQ:i=Math.abs(f)<=p?this.lat0:Math.asin(u*this.sinph0+a*c*this.cosph0/f),e*=c*this.cosph0,a=(u-Math.sin(i)*this.sinph0)*f;break;case this.N_POLE:a=-a,i=m-i;break;case this.S_POLE:i-=m;break}s=a===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(e,a)}else{if(l=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(e/=this.dd,a*=this.dd,o=Math.sqrt(e*e+a*a),o<p)return t.x=this.long0,t.y=this.lat0,t;n=2*Math.asin(.5*o/this.rq),r=Math.cos(n),e*=n=Math.sin(n),this.mode===this.OBLIQ?(l=r*this.sinb1+a*n*this.cosb1/o,h=this.qp*l,a=o*this.cosb1*r-a*this.sinb1*n):(l=a*n/o,h=this.qp*l,a=o*r)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(a=-a),h=e*e+a*a,!h)return t.x=this.long0,t.y=this.lat0,t;l=1-h/this.qp,this.mode===this.S_POLE&&(l=-l)}s=Math.atan2(e,a),i=Yr(Math.asin(l),this.apa)}return t.x=v(this.long0+s),t.y=i,t}var Ur=.3333333333333333,Wr=.17222222222222222,Xr=.10257936507936508,Jr=.06388888888888888,Qr=.0664021164021164,Vr=.016415012942191543;function Kr(t){var e,a=[];return a[0]=t*Ur,e=t*t,a[0]+=e*Wr,a[1]=e*Jr,e*=t,a[0]+=e*Xr,a[1]+=e*Qr,a[2]=e*Vr,a}function Yr(t,e){var a=t+t;return t+e[0]*Math.sin(a)+e[1]*Math.sin(a+a)+e[2]*Math.sin(a+a+a)}var Zr=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],$a={init:jr,forward:kr,inverse:Hr,names:Zr,S_POLE:Gr,N_POLE:Fr,EQUIT:qr,OBLIQ:zr};function j(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function $r(){Math.abs(this.lat1+this.lat2)<p||(this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=B(this.e3,this.sin_po,this.cos_po),this.qs1=Y(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=B(this.e3,this.sin_po,this.cos_po),this.qs2=Y(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=Y(this.e3,this.sin_po,this.cos_po),Math.abs(this.lat1-this.lat2)>p?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)}function tn(t){var e=t.x,a=t.y;this.sin_phi=Math.sin(a),this.cos_phi=Math.cos(a);var s=Y(this.e3,this.sin_phi,this.cos_phi),i=this.a*Math.sqrt(this.c-this.ns0*s)/this.ns0,r=this.ns0*v(e-this.long0),n=i*Math.sin(r)+this.x0,h=this.rh-i*Math.cos(r)+this.y0;return t.x=n,t.y=h,t}function en(t){var e,a,s,i,r,n;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns0>=0?(e=Math.sqrt(t.x*t.x+t.y*t.y),s=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),s=-1),i=0,e!==0&&(i=Math.atan2(s*t.x,s*t.y)),s=e*this.ns0/this.a,this.sphere?n=Math.asin((this.c-s*s)/(2*this.ns0)):(a=(this.c-s*s)/this.ns0,n=this.phi1z(this.e3,a)),r=v(i/this.ns0+this.long0),t.x=r,t.y=n,t}function an(t,e){var a,s,i,r,n,h=j(.5*e);if(t<p)return h;for(var o=t*t,l=1;l<=25;l++)if(a=Math.sin(h),s=Math.cos(h),i=t*a,r=1-i*i,n=.5*r*r/s*(e/(1-o)-a/r+.5/t*Math.log((1-i)/(1+i))),h=h+n,Math.abs(n)<=1e-7)return h;return null}var sn=["Albers_Conic_Equal_Area","Albers","aea"],ti={init:$r,forward:tn,inverse:en,names:sn,phi1z:an};function rn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function nn(t){var e,a,s,i,r,n,h,o,l=t.x,u=t.y;return s=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),i=Math.cos(s),n=this.sin_p14*e+this.cos_p14*a*i,r=1,n>0||Math.abs(n)<=p?(h=this.x0+this.a*r*a*Math.sin(s)/n,o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*i)/n):(h=this.x0+this.infinity_dist*a*Math.sin(s),o=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*a*i)),t.x=h,t.y=o,t}function hn(t){var e,a,s,i,r,n;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,(e=Math.sqrt(t.x*t.x+t.y*t.y))?(i=Math.atan2(e,this.rc),a=Math.sin(i),s=Math.cos(i),n=j(s*this.sin_p14+t.y*a*this.cos_p14/e),r=Math.atan2(t.x*a,e*this.cos_p14*s-t.y*this.sin_p14*a),r=v(this.long0+r)):(n=this.phic0,r=0),t.x=r,t.y=n,t}var on=["gnom"],ei={init:rn,forward:nn,inverse:hn,names:on};function ai(t,e){var a=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(e)-a)<1e-6)return e<0?-1*m:m;for(var s=Math.asin(.5*e),i,r,n,h,o=0;o<30;o++)if(r=Math.sin(s),n=Math.cos(s),h=t*r,i=Math.pow(1-h*h,2)/(2*n)*(e/(1-t*t)-r/(1-h*h)+.5/t*Math.log((1-h)/(1+h))),s+=i,Math.abs(i)<=1e-10)return s;return NaN}function ln(){this.sphere||(this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function fn(t){var e=t.x,a=t.y,s,i,r=v(e-this.long0);if(this.sphere)s=this.x0+this.a*r*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(a)/Math.cos(this.lat_ts);else{var n=Y(this.e,Math.sin(a));s=this.x0+this.a*this.k0*r,i=this.y0+this.a*n*.5/this.k0}return t.x=s,t.y=i,t}function un(t){t.x-=this.x0,t.y-=this.y0;var e,a;return this.sphere?(e=v(this.long0+t.x/this.a/Math.cos(this.lat_ts)),a=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(a=ai(this.e,2*t.y*this.k0/this.a),e=v(this.long0+t.x/(this.a*this.k0))),t.x=e,t.y=a,t}var cn=["cea"],ii={init:ln,forward:fn,inverse:un,names:cn};function mn(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)}function Mn(t){var e=t.x,a=t.y,s=v(e-this.long0),i=K(a-this.lat0);return t.x=this.x0+this.a*s*this.rc,t.y=this.y0+this.a*i,t}function dn(t){var e=t.x,a=t.y;return t.x=v(this.long0+(e-this.x0)/(this.a*this.rc)),t.y=K(this.lat0+(a-this.y0)/this.a),t}var pn=["Equirectangular","Equidistant_Cylindrical","eqc"],si={init:mn,forward:Mn,inverse:dn,names:pn};var ri=20;function vn(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.ml0=this.a*D(this.e0,this.e1,this.e2,this.e3,this.lat0)}function yn(t){var e=t.x,a=t.y,s,i,r,n=v(e-this.long0);if(r=n*Math.sin(a),this.sphere)Math.abs(a)<=p?(s=this.a*n,i=-1*this.a*this.lat0):(s=this.a*Math.sin(r)/Math.tan(a),i=this.a*(K(a-this.lat0)+(1-Math.cos(r))/Math.tan(a)));else if(Math.abs(a)<=p)s=this.a*n,i=-1*this.ml0;else{var h=ht(this.a,this.e,Math.sin(a))/Math.tan(a);s=h*Math.sin(r),i=this.a*D(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+h*(1-Math.cos(r))}return t.x=s+this.x0,t.y=i+this.y0,t}function xn(t){var e,a,s,i,r,n,h,o,l;if(s=t.x-this.x0,i=t.y-this.y0,this.sphere)if(Math.abs(i+this.a*this.lat0)<=p)e=v(s/this.a+this.long0),a=0;else{n=this.lat0+i/this.a,h=s*s/this.a/this.a+n*n,o=n;var u;for(r=ri;r;--r)if(u=Math.tan(o),l=-1*(n*(o*u+1)-o-.5*(o*o+h)*u)/((o-n)/u-1),o+=l,Math.abs(l)<=p){a=o;break}e=v(this.long0+Math.asin(s*Math.tan(o)/this.a)/Math.sin(a))}else if(Math.abs(i+this.ml0)<=p)a=0,e=v(this.long0+s/this.a);else{n=(this.ml0+i)/this.a,h=s*s/this.a/this.a+n*n,o=n;var f,c,M,d,y;for(r=ri;r;--r)if(y=this.e*Math.sin(o),f=Math.sqrt(1-y*y)*Math.tan(o),c=this.a*D(this.e0,this.e1,this.e2,this.e3,o),M=this.e0-2*this.e1*Math.cos(2*o)+4*this.e2*Math.cos(4*o)-6*this.e3*Math.cos(6*o),d=c/this.a,l=(n*(f*d+1)-d-.5*f*(d*d+h))/(this.es*Math.sin(2*o)*(d*d+h-2*n*d)/(4*f)+(n-d)*(f*M-2/Math.sin(2*o))-M),o-=l,Math.abs(l)<=p){a=o;break}f=Math.sqrt(1-this.es*Math.pow(Math.sin(a),2))*Math.tan(a),e=v(this.long0+Math.asin(s*f/this.a)/Math.sin(a))}return t.x=e,t.y=a,t}var gn=["Polyconic","poly"],ni={init:vn,forward:yn,inverse:xn,names:gn};function _n(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013}function bn(t){var e,a=t.x,s=t.y,i=s-this.lat0,r=a-this.long0,n=i/Mt*1e-5,h=r,o=1,l=0;for(e=1;e<=10;e++)o=o*n,l=l+this.A[e]*o;var u=l,f=h,c=1,M=0,d,y,x=0,g=0;for(e=1;e<=6;e++)d=c*u-M*f,y=M*u+c*f,c=d,M=y,x=x+this.B_re[e]*c-this.B_im[e]*M,g=g+this.B_im[e]*c+this.B_re[e]*M;return t.x=g*this.a+this.x0,t.y=x*this.a+this.y0,t}function En(t){var e,a=t.x,s=t.y,i=a-this.x0,r=s-this.y0,n=r/this.a,h=i/this.a,o=1,l=0,u,f,c=0,M=0;for(e=1;e<=6;e++)u=o*n-l*h,f=l*n+o*h,o=u,l=f,c=c+this.C_re[e]*o-this.C_im[e]*l,M=M+this.C_im[e]*o+this.C_re[e]*l;for(var d=0;d<this.iterations;d++){var y=c,x=M,g,b,E=n,N=h;for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,E=E+(e-1)*(this.B_re[e]*y-this.B_im[e]*x),N=N+(e-1)*(this.B_im[e]*y+this.B_re[e]*x);y=1,x=0;var P=this.B_re[1],A=this.B_im[1];for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,P=P+e*(this.B_re[e]*y-this.B_im[e]*x),A=A+e*(this.B_im[e]*y+this.B_re[e]*x);var O=P*P+A*A;c=(E*P+N*A)/O,M=(N*P-E*A)/O}var C=c,Z=M,ut=1,ct=0;for(e=1;e<=9;e++)ut=ut*C,ct=ct+this.D[e]*ut;var jt=this.lat0+ct*Mt*1e5,Di=this.long0+Z;return t.x=Di,t.y=jt,t}var In=["New_Zealand_Map_Grid","nzmg"],hi={init:_n,forward:bn,inverse:En,names:In};function Pn(){}function An(t){var e=t.x,a=t.y,s=v(e-this.long0),i=this.x0+this.a*s,r=this.y0+this.a*Math.log(Math.tan(Math.PI/4+a/2.5))*1.25;return t.x=i,t.y=r,t}function Sn(t){t.x-=this.x0,t.y-=this.y0;var e=v(this.long0+t.x/this.a),a=2.5*(Math.atan(Math.exp(.8*t.y/this.a))-Math.PI/4);return t.x=e,t.y=a,t}var Nn=["Miller_Cylindrical","mill"],oi={init:Pn,forward:An,inverse:Sn,names:Nn};var wn=20;function Rn(){this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=re(this.es)}function Cn(t){var e,a,s=t.x,i=t.y;if(s=v(s-this.long0),this.sphere){if(!this.m)i=this.n!==1?Math.asin(this.n*Math.sin(i)):i;else for(var r=this.n*Math.sin(i),n=wn;n;--n){var h=(this.m*i+Math.sin(i)-r)/(this.m+Math.cos(i));if(i-=h,Math.abs(h)<p)break}e=this.a*this.C_x*s*(this.m+Math.cos(i)),a=this.a*this.C_y*i}else{var o=Math.sin(i),l=Math.cos(i);a=this.a*vt(i,o,l,this.en),e=this.a*s*l/Math.sqrt(1-this.es*o*o)}return t.x=e,t.y=a,t}function Ln(t){var e,a,s,i;return t.x-=this.x0,s=t.x/this.a,t.y-=this.y0,e=t.y/this.a,this.sphere?(e/=this.C_y,s=s/(this.C_x*(this.m+Math.cos(e))),this.m?e=j((this.m*e+Math.sin(e))/this.n):this.n!==1&&(e=j(Math.sin(e)/this.n)),s=v(s+this.long0),e=K(e)):(e=ne(t.y/this.a,this.es,this.en),i=Math.abs(e),i<m?(i=Math.sin(e),a=this.long0+t.x*Math.sqrt(1-this.es*i*i)/(this.a*Math.cos(e)),s=v(a)):i-p<m&&(s=this.long0)),t.x=s,t.y=e,t}var Tn=["Sinusoidal","sinu"],li={init:Rn,forward:Cn,inverse:Ln,names:Tn};function Dn(){}function On(t){for(var e=t.x,a=t.y,s=v(e-this.long0),i=a,r=Math.PI*Math.sin(a);;){var n=-(i+Math.sin(i)-r)/(1+Math.cos(i));if(i+=n,Math.abs(n)<p)break}i/=2,Math.PI/2-Math.abs(a)<p&&(s=0);var h=.900316316158*this.a*s*Math.cos(i)+this.x0,o=1.4142135623731*this.a*Math.sin(i)+this.y0;return t.x=h,t.y=o,t}function Bn(t){var e,a;t.x-=this.x0,t.y-=this.y0,a=t.y/(1.4142135623731*this.a),Math.abs(a)>.999999999999&&(a=.999999999999),e=Math.asin(a);var s=v(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));s<-Math.PI&&(s=-Math.PI),s>Math.PI&&(s=Math.PI),a=(2*e+Math.sin(2*e))/Math.PI,Math.abs(a)>1&&(a=1);var i=Math.asin(a);return t.x=s,t.y=i,t}var Gn=["Mollweide","moll"],fi={init:Dn,forward:On,inverse:Bn,names:Gn};function Fn(){Math.abs(this.lat1+this.lat2)<p||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.sinphi=Math.sin(this.lat1),this.cosphi=Math.cos(this.lat1),this.ms1=B(this.e,this.sinphi,this.cosphi),this.ml1=D(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<p?this.ns=this.sinphi:(this.sinphi=Math.sin(this.lat2),this.cosphi=Math.cos(this.lat2),this.ms2=B(this.e,this.sinphi,this.cosphi),this.ml2=D(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=D(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function qn(t){var e=t.x,a=t.y,s;if(this.sphere)s=this.a*(this.g-a);else{var i=D(this.e0,this.e1,this.e2,this.e3,a);s=this.a*(this.g-i)}var r=this.ns*v(e-this.long0),n=this.x0+s*Math.sin(r),h=this.y0+this.rh-s*Math.cos(r);return t.x=n,t.y=h,t}function zn(t){t.x-=this.x0,t.y=this.rh-t.y+this.y0;var e,a,s,i;this.ns>=0?(a=Math.sqrt(t.x*t.x+t.y*t.y),e=1):(a=-Math.sqrt(t.x*t.x+t.y*t.y),e=-1);var r=0;if(a!==0&&(r=Math.atan2(e*t.x,e*t.y)),this.sphere)return i=v(this.long0+r/this.ns),s=K(this.g-a/this.a),t.x=i,t.y=s,t;var n=this.g-a/this.a;return s=yt(n,this.e0,this.e1,this.e2,this.e3),i=v(this.long0+r/this.ns),t.x=i,t.y=s,t}var jn=["Equidistant_Conic","eqdc"],ui={init:Fn,forward:qn,inverse:zn,names:jn};function kn(){this.R=this.a}function Hn(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r;Math.abs(a)<=p&&(i=this.x0+this.R*s,r=this.y0);var n=j(2*Math.abs(a/Math.PI));(Math.abs(s)<=p||Math.abs(Math.abs(a)-m)<=p)&&(i=this.x0,a>=0?r=this.y0+Math.PI*this.R*Math.tan(.5*n):r=this.y0+Math.PI*this.R*-Math.tan(.5*n));var h=.5*Math.abs(Math.PI/s-s/Math.PI),o=h*h,l=Math.sin(n),u=Math.cos(n),f=u/(l+u-1),c=f*f,M=f*(2/l-1),d=M*M,y=Math.PI*this.R*(h*(f-d)+Math.sqrt(o*(f-d)*(f-d)-(d+o)*(c-d)))/(d+o);s<0&&(y=-y),i=this.x0+y;var x=o+f;return y=Math.PI*this.R*(M*x-h*Math.sqrt((d+o)*(o+1)-x*x))/(d+o),a>=0?r=this.y0+y:r=this.y0-y,t.x=i,t.y=r,t}function Un(t){var e,a,s,i,r,n,h,o,l,u,f,c,M;return t.x-=this.x0,t.y-=this.y0,f=Math.PI*this.R,s=t.x/f,i=t.y/f,r=s*s+i*i,n=-Math.abs(i)*(1+r),h=n-2*i*i+s*s,o=-2*n+1+2*i*i+r*r,M=i*i/o+(2*h*h*h/o/o/o-9*n*h/o/o)/27,l=(n-h*h/3/o)/o,u=2*Math.sqrt(-l/3),f=3*M/l/u,Math.abs(f)>1&&(f>=0?f=1:f=-1),c=Math.acos(f)/3,t.y>=0?a=(-u*Math.cos(c+Math.PI/3)-h/3/o)*Math.PI:a=-(-u*Math.cos(c+Math.PI/3)-h/3/o)*Math.PI,Math.abs(s)<p?e=this.long0:e=v(this.long0+Math.PI*(r-1+Math.sqrt(1+2*(s*s-i*i)+r*r))/2/s),t.x=e,t.y=a,t}var Wn=["Van_der_Grinten_I","VanDerGrinten","vandg"],ci={init:kn,forward:Hn,inverse:Un,names:Wn};function Xn(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)}function Jn(t){var e=t.x,a=t.y,s=Math.sin(t.y),i=Math.cos(t.y),r=v(e-this.long0),n,h,o,l,u,f,c,M,d,y,x,g,b,E,N,P,A,O,C,Z,ut,ct,jt;return this.sphere?Math.abs(this.sin_p12-1)<=p?(t.x=this.x0+this.a*(m-a)*Math.sin(r),t.y=this.y0-this.a*(m-a)*Math.cos(r),t):Math.abs(this.sin_p12+1)<=p?(t.x=this.x0+this.a*(m+a)*Math.sin(r),t.y=this.y0+this.a*(m+a)*Math.cos(r),t):(O=this.sin_p12*s+this.cos_p12*i*Math.cos(r),P=Math.acos(O),A=P?P/Math.sin(P):1,t.x=this.x0+this.a*A*i*Math.sin(r),t.y=this.y0+this.a*A*(this.cos_p12*s-this.sin_p12*i*Math.cos(r)),t):(n=it(this.es),h=st(this.es),o=rt(this.es),l=nt(this.es),Math.abs(this.sin_p12-1)<=p?(u=this.a*D(n,h,o,l,m),f=this.a*D(n,h,o,l,a),t.x=this.x0+(u-f)*Math.sin(r),t.y=this.y0-(u-f)*Math.cos(r),t):Math.abs(this.sin_p12+1)<=p?(u=this.a*D(n,h,o,l,m),f=this.a*D(n,h,o,l,a),t.x=this.x0+(u+f)*Math.sin(r),t.y=this.y0+(u+f)*Math.cos(r),t):(c=s/i,M=ht(this.a,this.e,this.sin_p12),d=ht(this.a,this.e,s),y=Math.atan((1-this.es)*c+this.es*M*this.sin_p12/(d*i)),x=Math.atan2(Math.sin(r),this.cos_p12*Math.tan(y)-this.sin_p12*Math.cos(r)),x===0?C=Math.asin(this.cos_p12*Math.sin(y)-this.sin_p12*Math.cos(y)):Math.abs(Math.abs(x)-Math.PI)<=p?C=-Math.asin(this.cos_p12*Math.sin(y)-this.sin_p12*Math.cos(y)):C=Math.asin(Math.sin(r)*Math.cos(y)/Math.sin(x)),g=this.e*this.sin_p12/Math.sqrt(1-this.es),b=this.e*this.cos_p12*Math.cos(x)/Math.sqrt(1-this.es),E=g*b,N=b*b,Z=C*C,ut=Z*C,ct=ut*C,jt=ct*C,P=M*C*(1-Z*N*(1-N)/6+ut/8*E*(1-2*N)+ct/120*(N*(4-7*N)-3*g*g*(1-7*N))-jt/48*E),t.x=this.x0+P*Math.sin(x),t.y=this.y0+P*Math.cos(x),t))}function Qn(t){t.x-=this.x0,t.y-=this.y0;var e,a,s,i,r,n,h,o,l,u,f,c,M,d,y,x,g,b,E,N,P,A,O,C;return this.sphere?(e=Math.sqrt(t.x*t.x+t.y*t.y),e>2*m*this.a?void 0:(a=e/this.a,s=Math.sin(a),i=Math.cos(a),r=this.long0,Math.abs(e)<=p?n=this.lat0:(n=j(i*this.sin_p12+t.y*s*this.cos_p12/e),h=Math.abs(this.lat0)-m,Math.abs(h)<=p?this.lat0>=0?r=v(this.long0+Math.atan2(t.x,-t.y)):r=v(this.long0-Math.atan2(-t.x,t.y)):r=v(this.long0+Math.atan2(t.x*s,e*this.cos_p12*i-t.y*this.sin_p12*s))),t.x=r,t.y=n,t)):(o=it(this.es),l=st(this.es),u=rt(this.es),f=nt(this.es),Math.abs(this.sin_p12-1)<=p?(c=this.a*D(o,l,u,f,m),e=Math.sqrt(t.x*t.x+t.y*t.y),M=c-e,n=yt(M/this.a,o,l,u,f),r=v(this.long0+Math.atan2(t.x,-1*t.y)),t.x=r,t.y=n,t):Math.abs(this.sin_p12+1)<=p?(c=this.a*D(o,l,u,f,m),e=Math.sqrt(t.x*t.x+t.y*t.y),M=e-c,n=yt(M/this.a,o,l,u,f),r=v(this.long0+Math.atan2(t.x,t.y)),t.x=r,t.y=n,t):(e=Math.sqrt(t.x*t.x+t.y*t.y),x=Math.atan2(t.x,t.y),d=ht(this.a,this.e,this.sin_p12),g=Math.cos(x),b=this.e*this.cos_p12*g,E=-b*b/(1-this.es),N=3*this.es*(1-E)*this.sin_p12*this.cos_p12*g/(1-this.es),P=e/d,A=P-E*(1+E)*Math.pow(P,3)/6-N*(1+3*E)*Math.pow(P,4)/24,O=1-E*A*A/2-P*A*A*A/6,y=Math.asin(this.sin_p12*Math.cos(A)+this.cos_p12*Math.sin(A)*g),r=v(this.long0+Math.asin(Math.sin(x)*Math.sin(A)/Math.cos(y))),C=Math.sin(y),n=Math.atan2((C-this.es*O*this.sin_p12)*Math.tan(y),C*(1-this.es)),t.x=r,t.y=n,t))}var Vn=["Azimuthal_Equidistant","aeqd"],mi={init:Xn,forward:Jn,inverse:Qn,names:Vn};function Kn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)}function Yn(t){var e,a,s,i,r,n,h,o,l=t.x,u=t.y;return s=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),i=Math.cos(s),n=this.sin_p14*e+this.cos_p14*a*i,r=1,(n>0||Math.abs(n)<=p)&&(h=this.a*r*a*Math.sin(s),o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*i)),t.x=h,t.y=o,t}function Zn(t){var e,a,s,i,r,n,h;return t.x-=this.x0,t.y-=this.y0,e=Math.sqrt(t.x*t.x+t.y*t.y),a=j(e/this.a),s=Math.sin(a),i=Math.cos(a),n=this.long0,Math.abs(e)<=p?(h=this.lat0,t.x=n,t.y=h,t):(h=j(i*this.sin_p14+t.y*s*this.cos_p14/e),r=Math.abs(this.lat0)-m,Math.abs(r)<=p?(this.lat0>=0?n=v(this.long0+Math.atan2(t.x,-t.y)):n=v(this.long0-Math.atan2(-t.x,t.y)),t.x=n,t.y=h,t):(n=v(this.long0+Math.atan2(t.x*s,e*this.cos_p14*i-t.y*this.sin_p14*s)),t.x=n,t.y=h,t))}var $n=["ortho"],Mi={init:Kn,forward:Yn,inverse:Zn,names:$n};var R={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},S={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function th(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=m-I/2?this.face=R.TOP:this.lat0<=-(m-I/2)?this.face=R.BOTTOM:Math.abs(this.long0)<=I?this.face=R.FRONT:Math.abs(this.long0)<=m+I?this.face=this.long0>0?R.RIGHT:R.LEFT:this.face=R.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)}function eh(t){var e={x:0,y:0},a,s,i,r,n,h,o={value:0};if(t.x-=this.long0,this.es!==0?a=Math.atan(this.one_minus_f_squared*Math.tan(t.y)):a=t.y,s=t.x,this.face===R.TOP)r=m-a,s>=I&&s<=m+I?(o.value=S.AREA_0,i=s-m):s>m+I||s<=-(m+I)?(o.value=S.AREA_1,i=s>0?s-w:s+w):s>-(m+I)&&s<=-I?(o.value=S.AREA_2,i=s+m):(o.value=S.AREA_3,i=s);else if(this.face===R.BOTTOM)r=m+a,s>=I&&s<=m+I?(o.value=S.AREA_0,i=-s+m):s<I&&s>=-I?(o.value=S.AREA_1,i=-s):s<-I&&s>=-(m+I)?(o.value=S.AREA_2,i=-s-m):(o.value=S.AREA_3,i=s>0?-s+w:-s-w);else{var l,u,f,c,M,d,y;this.face===R.RIGHT?s=Pt(s,+m):this.face===R.BACK?s=Pt(s,+w):this.face===R.LEFT&&(s=Pt(s,-m)),c=Math.sin(a),M=Math.cos(a),d=Math.sin(s),y=Math.cos(s),l=M*y,u=M*d,f=c,this.face===R.FRONT?(r=Math.acos(l),i=ue(r,f,u,o)):this.face===R.RIGHT?(r=Math.acos(u),i=ue(r,f,-l,o)):this.face===R.BACK?(r=Math.acos(-l),i=ue(r,f,-u,o)):this.face===R.LEFT?(r=Math.acos(-u),i=ue(r,f,l,o)):(r=i=0,o.value=S.AREA_0)}return h=Math.atan(12/w*(i+Math.acos(Math.sin(i)*Math.cos(I))-m)),n=Math.sqrt((1-Math.cos(r))/(Math.cos(h)*Math.cos(h))/(1-Math.cos(Math.atan(1/Math.cos(i))))),o.value===S.AREA_1?h+=m:o.value===S.AREA_2?h+=w:o.value===S.AREA_3&&(h+=1.5*w),e.x=n*Math.cos(h),e.y=n*Math.sin(h),e.x=e.x*this.a+this.x0,e.y=e.y*this.a+this.y0,t.x=e.x,t.y=e.y,t}function ah(t){var e={lam:0,phi:0},a,s,i,r,n,h,o,l,u,f={value:0};if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,s=Math.atan(Math.sqrt(t.x*t.x+t.y*t.y)),a=Math.atan2(t.y,t.x),t.x>=0&&t.x>=Math.abs(t.y)?f.value=S.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(f.value=S.AREA_1,a-=m):t.x<0&&-t.x>=Math.abs(t.y)?(f.value=S.AREA_2,a=a<0?a+w:a-w):(f.value=S.AREA_3,a+=m),u=w/12*Math.tan(a),n=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),h=Math.atan(n),i=Math.cos(a),r=Math.tan(s),o=1-i*i*r*r*(1-Math.cos(Math.atan(1/Math.cos(h)))),o<-1?o=-1:o>1&&(o=1),this.face===R.TOP)l=Math.acos(o),e.phi=m-l,f.value===S.AREA_0?e.lam=h+m:f.value===S.AREA_1?e.lam=h<0?h+w:h-w:f.value===S.AREA_2?e.lam=h-m:e.lam=h;else if(this.face===R.BOTTOM)l=Math.acos(o),e.phi=l-m,f.value===S.AREA_0?e.lam=-h+m:f.value===S.AREA_1?e.lam=-h:f.value===S.AREA_2?e.lam=-h-m:e.lam=h<0?-h-w:-h+w;else{var c,M,d;c=o,u=c*c,u>=1?d=0:d=Math.sqrt(1-u)*Math.sin(h),u+=d*d,u>=1?M=0:M=Math.sqrt(1-u),f.value===S.AREA_1?(u=M,M=-d,d=u):f.value===S.AREA_2?(M=-M,d=-d):f.value===S.AREA_3&&(u=M,M=d,d=-u),this.face===R.RIGHT?(u=c,c=-M,M=u):this.face===R.BACK?(c=-c,M=-M):this.face===R.LEFT&&(u=c,c=M,M=-u),e.phi=Math.acos(-d)-m,e.lam=Math.atan2(M,c),this.face===R.RIGHT?e.lam=Pt(e.lam,-m):this.face===R.BACK?e.lam=Pt(e.lam,-w):this.face===R.LEFT&&(e.lam=Pt(e.lam,+m))}if(this.es!==0){var y,x,g;y=e.phi<0?1:0,x=Math.tan(e.phi),g=this.b/Math.sqrt(x*x+this.one_minus_f_squared),e.phi=Math.atan(Math.sqrt(this.a*this.a-g*g)/(this.one_minus_f*g)),y&&(e.phi=-e.phi)}return e.lam+=this.long0,t.x=e.lam,t.y=e.phi,t}function ue(t,e,a,s){var i;return t<p?(s.value=S.AREA_0,i=0):(i=Math.atan2(e,a),Math.abs(i)<=I?s.value=S.AREA_0:i>I&&i<=m+I?(s.value=S.AREA_1,i-=m):i>m+I||i<=-(m+I)?(s.value=S.AREA_2,i=i>=0?i-w:i+w):(s.value=S.AREA_3,i+=m)),i}function Pt(t,e){var a=t+e;return a<-w?a+=Rt:a>+w&&(a-=Rt),a}var ih=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],di={init:th,forward:eh,inverse:ah,names:ih};var Be=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-986701e-12],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,18736e-12],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,934959e-12],[.7986,-.00755338,-500009e-10,935324e-12],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],Bt=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-126793e-14,422642e-15],[.124,.0124,507171e-14,-160604e-14],[.186,.0123999,-190189e-13,600152e-14],[.248,.0124002,710039e-13,-224e-10],[.31,.0123992,-264997e-12,835986e-13],[.372,.0124029,988983e-12,-311994e-12],[.434,.0123893,-369093e-11,-435621e-12],[.4958,.0123198,-102252e-10,-345523e-12],[.5571,.0121916,-154081e-10,-582288e-12],[.6176,.0119938,-241424e-10,-525327e-12],[.6769,.011713,-320223e-10,-516405e-12],[.7346,.0113541,-397684e-10,-609052e-12],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-140374e-14],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],pi=.8487,vi=1.3523,yi=V/5,sh=1/yi,At=18,ce=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},rh=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function nh(t,e,a,s){for(var i=e;s;--s){var r=t(i);if(i-=r,Math.abs(r)<a)break}return i}function hh(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function oh(t){var e=v(t.x-this.long0),a=Math.abs(t.y),s=Math.floor(a*yi);s<0?s=0:s>=At&&(s=At-1),a=V*(a-sh*s);var i={x:ce(Be[s],a)*e,y:ce(Bt[s],a)};return t.y<0&&(i.y=-i.y),i.x=i.x*this.a*pi+this.x0,i.y=i.y*this.a*vi+this.y0,i}function lh(t){var e={x:(t.x-this.x0)/(this.a*pi),y:Math.abs(t.y-this.y0)/(this.a*vi)};if(e.y>=1)e.x/=Be[At][0],e.y=t.y<0?-m:m;else{var a=Math.floor(e.y*At);for(a<0?a=0:a>=At&&(a=At-1);;)if(Bt[a][0]>e.y)--a;else if(Bt[a+1][0]<=e.y)++a;else break;var s=Bt[a],i=5*(e.y-s[0])/(Bt[a+1][0]-s[0]);i=nh(function(r){return(ce(s,r)-e.y)/rh(s,r)},i,p,100),e.x/=ce(Be[a],i),e.y=(5*a+i)*L,t.y<0&&(e.y=-e.y)}return e.x=v(e.x+this.long0),e}var fh=["Robinson","robin"],xi={init:hh,forward:oh,inverse:lh,names:fh};function uh(){this.name="geocent"}function ch(t){var e=ee(t,this.es,this.a);return e}function mh(t){var e=ae(t,this.es,this.a,this.b);return e}var Mh=["Geocentric","geocentric","geocent","Geocent"],gi={init:uh,forward:ch,inverse:mh,names:Mh};function _i(t){t.Proj.projections.add(qa),t.Proj.projections.add(It),t.Proj.projections.add(Wa),t.Proj.projections.add(Xa),t.Proj.projections.add(Ja),t.Proj.projections.add(Qa),t.Proj.projections.add(Va),t.Proj.projections.add(Ka),t.Proj.projections.add(Ya),t.Proj.projections.add(Za),t.Proj.projections.add($a),t.Proj.projections.add(ti),t.Proj.projections.add(ei),t.Proj.projections.add(ii),t.Proj.projections.add(si),t.Proj.projections.add(ni),t.Proj.projections.add(hi),t.Proj.projections.add(oi),t.Proj.projections.add(li),t.Proj.projections.add(fi),t.Proj.projections.add(ui),t.Proj.projections.add(ci),t.Proj.projections.add(mi),t.Proj.projections.add(Mi),t.Proj.projections.add(di),t.Proj.projections.add(xi),t.Proj.projections.add(gi)}H.defaultDatum="WGS84";H.Proj=ft;H.WGS84=new H.Proj("WGS84");H.Point=Oa;H.toPoint=se;H.defs=gt;H.transform=pt;H.mgrs=La;H.version="__VERSION__";_i(H);var Ge=H;var Gt=class{static defineProjectionAliases(e){let a=[];for(let s in e)a.push([s,e[s]]);Ge.defs(a)}constructor({from:e="WGS84",to:a="WGS84"}){if(Ie(this,"_projection",void 0),this._projection=Ge(e,a),!this._projection)throw new Error("Invalid projection");this.project=this.project.bind(this),this.unproject=this.unproject.bind(this)}project(e){return this._projection.forward(e)}unproject(e){return this._projection.inverse(e)}};var Fe=100,bi=!1;function Ei(t){let e=new DataView(t,0,Fe),s=Wt(e).length-Fe,i=new DataView(t,Fe,s),r=new Int32Array(s),n=new Int32Array(s);for(let h=0;h<s/8;h++)r[h]=i.getInt32(h*8,bi),n[h]=i.getInt32(h*8+4,bi);return{offsets:r,lengths:n}}async function*me(t,e,a){let s=[],i=[],r=!1,n=!1;for(;!r&&!n;){if(s.length===0&&!r){let{value:o,done:l}=await t.next();l?r=!0:s.push(...o)}if(i.length===0&&!n){let{value:o,done:l}=await e.next();l?n=!0:i.push(...o)}let h=dh(s,i);h&&(yield{batchType:"data",shape:a,length:h.length,data:h})}}function dh(t,e){let a=Math.min(t.length,e.length);if(a===0)return null;let s=[t.slice(0,a),e.slice(0,a)];return t.splice(0,a),e.splice(0,a),s}var qe=!0,Ii=32,q;(function(t){t[t.START=0]="START",t[t.FIELD_DESCRIPTORS=1]="FIELD_DESCRIPTORS",t[t.FIELD_PROPERTIES=2]="FIELD_PROPERTIES",t[t.END=3]="END",t[t.ERROR=4]="ERROR"})(q||(q={}));var de=class{constructor(e){this.binaryReader=new ot,this.state=q.START,this.result={data:[]},this.textDecoder=new TextDecoder(e.encoding)}write(e){this.binaryReader.write(e),this.state=Pi(this.state,this.result,this.binaryReader,this.textDecoder)}end(){this.binaryReader.end(),this.state=Pi(this.state,this.result,this.binaryReader,this.textDecoder),this.state!==q.END&&(this.state=q.ERROR,this.result.error="DBF incomplete file")}};function ze(t,e={}){let{encoding:a="latin1"}=e.dbf||{},s=new de({encoding:a});s.write(t),s.end();let{data:i,schema:r}=s.result;switch(e?.dbf?.shape){case"object-row-table":return{shape:"object-row-table",schema:r,data:i};case"table":return{schema:r,rows:i};case"rows":default:return i}}async function*Ai(t,e={}){let{encoding:a="latin1"}=e.dbf||{},s=new de({encoding:a}),i=!1;for await(let r of t)s.write(r),!i&&s.result.dbfHeader&&(i=!0,yield s.result.dbfHeader),s.result.data.length>0&&(yield s.result.data,s.result.data=[]);s.end(),s.result.data.length>0&&(yield s.result.data)}function Pi(t,e,a,s){for(;;)try{switch(t){case q.ERROR:case q.END:return t;case q.START:let i=a.getDataView(Ii);if(!i)return t;e.dbfHeader=ph(i),e.progress={bytesUsed:0,rowsTotal:e.dbfHeader.nRecords,rows:0},t=q.FIELD_DESCRIPTORS;break;case q.FIELD_DESCRIPTORS:let r=a.getDataView(e.dbfHeader.headerLength-Ii);if(!r)return t;e.dbfFields=vh(r,s),e.schema={fields:e.dbfFields.map(o=>Eh(o)),metadata:{}},t=q.FIELD_PROPERTIES,a.skip(1);break;case q.FIELD_PROPERTIES:let{recordLength:n=0,nRecords:h=0}=e?.dbfHeader||{};for(;e.data.length<h;){let o=a.getDataView(n-1);if(!o)return t;a.skip(1);let l=yh(o,e.dbfFields,s);e.data.push(l),e.progress.rows=e.data.length}t=q.END;break;default:return t=q.ERROR,e.error=`illegal parser state ${t}`,t}}catch(i){return t=q.ERROR,e.error=`DBF parsing failed: ${i.message}`,t}}function ph(t){return{year:t.getUint8(1)+1900,month:t.getUint8(2),day:t.getUint8(3),nRecords:t.getUint32(4,qe),headerLength:t.getUint16(8,qe),recordLength:t.getUint16(10,qe),languageDriver:t.getUint8(29)}}function vh(t,e){let a=(t.byteLength-1)/32,s=[],i=0;for(let r=0;r<a;r++){let n=e.decode(new Uint8Array(t.buffer,t.byteOffset+i,11)).replace(/\u0000/g,"");s.push({name:n,dataType:String.fromCharCode(t.getUint8(i+11)),fieldLength:t.getUint8(i+16),decimal:t.getUint8(i+17)}),i+=32}return s}function yh(t,e,a){let s={},i=0;for(let r of e){let n=a.decode(new Uint8Array(t.buffer,t.byteOffset+i,r.fieldLength));s[r.name]=xh(n,r.dataType),i+=r.fieldLength}return s}function xh(t,e){switch(e){case"B":return Me(t);case"C":return bh(t);case"F":return Me(t);case"N":return Me(t);case"O":return Me(t);case"D":return gh(t);case"L":return _h(t);default:throw new Error("Unsupported data type")}}function gh(t){return Date.UTC(t.slice(0,4),parseInt(t.slice(4,6),10)-1,t.slice(6,8))}function _h(t){return/^[nf]$/i.test(t)?!1:/^[yt]$/i.test(t)?!0:null}function Me(t){let e=parseFloat(t);return isNaN(e)?null:e}function bh(t){return t.trim()||null}function Eh({name:t,dataType:e,fieldLength:a,decimal:s}){switch(e){case"B":return{name:t,type:"float64",nullable:!0,metadata:{}};case"C":return{name:t,type:"utf8",nullable:!0,metadata:{}};case"F":return{name:t,type:"float64",nullable:!0,metadata:{}};case"N":return{name:t,type:"float64",nullable:!0,metadata:{}};case"O":return{name:t,type:"float64",nullable:!0,metadata:{}};case"D":return{name:t,type:"timestamp-millisecond",nullable:!0,metadata:{}};case"L":return{name:t,type:"bool",nullable:!0,metadata:{}};default:throw new Error("Unsupported data type")}}var Ih="4.2.0-alpha.4",je={name:"DBF",id:"dbf",module:"shapefile",version:Ih,worker:!0,category:"table",extensions:["dbf"],mimeTypes:["application/x-dbf"],options:{dbf:{encoding:"latin1"}}},Ft={...je,parse:async(t,e)=>ze(t,e),parseSync:ze,parseInBatches(t,e){return Ai(t,e)}};async function*Si(t,e,a){let{reproject:s=!1,_targetCrs:i="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Li(e,a),o=await Qt(t,Nt,e,a),l=o[Symbol.asyncIterator]?.()||o[Symbol.iterator]?.(),u=null,f=await a?.fetch(qt(a?.url||"","dbf"));if(f?.ok){let x=await Qt(f,Ft,{...e,dbf:{encoding:n||"latin1"}},a);u=x[Symbol.asyncIterator]?.()||x[Symbol.iterator]()}let c=(await l.next()).value;c&&c.batchType==="metadata"&&(c=(await l.next()).value);let M={};u&&(M=(await u.next()).value,M&&M.batchType==="metadata"&&(M=(await u.next()).value));let d=u?me(l,u,"object-row-table"):l,y={[Symbol.asyncIterator](){return d}};for await(let x of y){let g,b;u?[g,b]=x.data:g=x;let E=wi(g),N=Ri(E,b);s&&(N=Ci(N,h,i)),yield{encoding:n,prj:h,shx:r,header:c,data:N}}}async function Ni(t,e,a){let{reproject:s=!1,_targetCrs:i="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Li(e,a),{header:o,geometries:l}=await Jt(t,Nt,e,a),u=wi(l),f,c=await a?.fetch(qt(a?.url,"dbf"));c?.ok&&(f=await Jt(c,Ft,{dbf:{shape:"object-row-table",encoding:n||"latin1"}},a));let M=Ri(u,f?.data||[]);switch(s&&(M=Ci(M,h,i)),e?.shapefile?.shape){case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",encoding:n,schema:f?.schema||{metadata:{},fields:[]},prj:h,shx:r,header:o,features:M};default:return{encoding:n,prj:h,shx:r,header:o,data:M}}}function wi(t){let e=[];for(let a of t)e.push(Pe(a));return e}function Ri(t,e){let a=[];for(let s=0;s<t.length;s++){let r={type:"Feature",geometry:t[s],properties:e&&e[s]||{}};a.push(r)}return a}function Ci(t,e,a){if(!e&&!a)return t;let s=new Gt({from:e||"WGS84",to:a||"WGS84"});return Ae(t,i=>s.project(i))}async function Li(t,e){let{url:a,fetch:s}=e,i=s(qt(a,"shx")),r=s(qt(a,"cpg")),n=s(qt(a,"prj"));await Promise.all([i,r,n]);let h,o,l,u=await i;if(u.ok){let M=await u.arrayBuffer();h=Ei(M)}let f=await r;f.ok&&(o=await f.text());let c=await n;return c.ok&&(l=await c.text()),{shx:h,cpg:o,prj:l}}function qt(t,e){let a=Ph(t),s=Ah(t);return s===s.toUpperCase()&&(e=e.toUpperCase()),`${a}.${e}`}function Ph(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(0,e):"":e}function Ah(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(e+1):"":e}var Sh="4.2.0-alpha.4",Ti={name:"Shapefile",id:"shapefile",module:"shapefile",version:Sh,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(ge).buffer],options:{shapefile:{shape:"v3"},shp:{_maxDimensions:4}},parse:Ni,parseInBatches:Si};var pe=class{constructor(e){this.offset=0,this.arrayBuffer=e}hasAvailableBytes(e){return this.arrayBuffer.byteLength-this.offset>=e}getDataView(e){if(e&&!this.hasAvailableBytes(e))throw new Error("binary data exhausted");let a=e?new DataView(this.arrayBuffer,this.offset,e):new DataView(this.arrayBuffer,this.offset);return this.offset+=e,a}skip(e){this.offset+=e}rewind(e){this.offset-=e}};return Hi(zt);})();
11
+ return __exports__;
12
+ });
package/dist/index.cjs CHANGED
@@ -17,9 +17,9 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
20
+ // dist/index.js
21
+ var dist_exports = {};
22
+ __export(dist_exports, {
23
23
  DBFLoader: () => DBFLoader,
24
24
  DBFWorkerLoader: () => DBFWorkerLoader,
25
25
  SHPLoader: () => SHPLoader,
@@ -29,9 +29,9 @@ __export(src_exports, {
29
29
  _BinaryReader: () => BinaryReader,
30
30
  _zipBatchIterators: () => zipBatchIterators
31
31
  });
32
- module.exports = __toCommonJS(src_exports);
32
+ module.exports = __toCommonJS(dist_exports);
33
33
 
34
- // src/lib/streaming/binary-chunk-reader.ts
34
+ // dist/lib/streaming/binary-chunk-reader.js
35
35
  var BinaryChunkReader = class {
36
36
  constructor(options) {
37
37
  const { maxRewindBytes = 0 } = options || {};
@@ -171,7 +171,7 @@ var BinaryChunkReader = class {
171
171
  }
172
172
  };
173
173
 
174
- // src/lib/parsers/parse-shp-header.ts
174
+ // dist/lib/parsers/parse-shp-header.js
175
175
  var LITTLE_ENDIAN = true;
176
176
  var BIG_ENDIAN = false;
177
177
  var SHP_MAGIC_NUMBER = 9994;
@@ -202,7 +202,7 @@ function parseSHPHeader(headerView) {
202
202
  return header;
203
203
  }
204
204
 
205
- // src/lib/parsers/parse-shp-geometry.ts
205
+ // dist/lib/parsers/parse-shp-geometry.js
206
206
  var LITTLE_ENDIAN2 = true;
207
207
  function parseRecord(view, options) {
208
208
  const { _maxDimensions = 4 } = (options == null ? void 0 : options.shp) || {};
@@ -378,7 +378,7 @@ function getSignedArea(positions) {
378
378
  return area / 2;
379
379
  }
380
380
 
381
- // src/lib/parsers/parse-shp.ts
381
+ // dist/lib/parsers/parse-shp.js
382
382
  var LITTLE_ENDIAN3 = true;
383
383
  var BIG_ENDIAN2 = false;
384
384
  var SHP_HEADER_SIZE = 100;
@@ -511,8 +511,8 @@ function parseState(state, result, binaryReader, options) {
511
511
  }
512
512
  }
513
513
 
514
- // src/shp-loader.ts
515
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
514
+ // dist/shp-loader.js
515
+ var VERSION = true ? "4.2.0-alpha.4" : "latest";
516
516
  var SHP_MAGIC_NUMBER2 = [0, 0, 39, 10];
517
517
  var SHPWorkerLoader = {
518
518
  name: "SHP",
@@ -538,12 +538,12 @@ var SHPLoader = {
538
538
  parseInBatches: (arrayBufferIterator, options) => parseSHPInBatches(arrayBufferIterator, options)
539
539
  };
540
540
 
541
- // src/lib/parsers/parse-shapefile.ts
541
+ // dist/lib/parsers/parse-shapefile.js
542
542
  var import_loader_utils = require("@loaders.gl/loader-utils");
543
543
  var import_gis = require("@loaders.gl/gis");
544
544
  var import_proj4 = require("@math.gl/proj4");
545
545
 
546
- // src/lib/parsers/parse-shx.ts
546
+ // dist/lib/parsers/parse-shx.js
547
547
  var SHX_HEADER_SIZE = 100;
548
548
  var BIG_ENDIAN3 = false;
549
549
  function parseShx(arrayBuffer) {
@@ -563,7 +563,7 @@ function parseShx(arrayBuffer) {
563
563
  };
564
564
  }
565
565
 
566
- // src/lib/streaming/zip-batch-iterators.ts
566
+ // dist/lib/streaming/zip-batch-iterators.js
567
567
  async function* zipBatchIterators(iterator1, iterator2, shape) {
568
568
  const batch1Data = [];
569
569
  const batch2Data = [];
@@ -608,13 +608,21 @@ function extractBatchData(batch1, batch2) {
608
608
  return batch;
609
609
  }
610
610
 
611
- // src/lib/parsers/parse-dbf.ts
611
+ // dist/lib/parsers/parse-dbf.js
612
612
  var LITTLE_ENDIAN4 = true;
613
613
  var DBF_HEADER_SIZE = 32;
614
+ var STATE2;
615
+ (function(STATE3) {
616
+ STATE3[STATE3["START"] = 0] = "START";
617
+ STATE3[STATE3["FIELD_DESCRIPTORS"] = 1] = "FIELD_DESCRIPTORS";
618
+ STATE3[STATE3["FIELD_PROPERTIES"] = 2] = "FIELD_PROPERTIES";
619
+ STATE3[STATE3["END"] = 3] = "END";
620
+ STATE3[STATE3["ERROR"] = 4] = "ERROR";
621
+ })(STATE2 || (STATE2 = {}));
614
622
  var DBFParser = class {
615
623
  constructor(options) {
616
624
  this.binaryReader = new BinaryChunkReader();
617
- this.state = 0 /* START */;
625
+ this.state = STATE2.START;
618
626
  this.result = {
619
627
  data: []
620
628
  };
@@ -630,8 +638,8 @@ var DBFParser = class {
630
638
  end() {
631
639
  this.binaryReader.end();
632
640
  this.state = parseState2(this.state, this.result, this.binaryReader, this.textDecoder);
633
- if (this.state !== 3 /* END */) {
634
- this.state = 4 /* ERROR */;
641
+ if (this.state !== STATE2.END) {
642
+ this.state = STATE2.ERROR;
635
643
  this.result.error = "DBF incomplete file";
636
644
  }
637
645
  }
@@ -684,10 +692,10 @@ function parseState2(state, result, binaryReader, textDecoder) {
684
692
  while (true) {
685
693
  try {
686
694
  switch (state) {
687
- case 4 /* ERROR */:
688
- case 3 /* END */:
695
+ case STATE2.ERROR:
696
+ case STATE2.END:
689
697
  return state;
690
- case 0 /* START */:
698
+ case STATE2.START:
691
699
  const dataView = binaryReader.getDataView(DBF_HEADER_SIZE);
692
700
  if (!dataView) {
693
701
  return state;
@@ -698,9 +706,9 @@ function parseState2(state, result, binaryReader, textDecoder) {
698
706
  rowsTotal: result.dbfHeader.nRecords,
699
707
  rows: 0
700
708
  };
701
- state = 1 /* FIELD_DESCRIPTORS */;
709
+ state = STATE2.FIELD_DESCRIPTORS;
702
710
  break;
703
- case 1 /* FIELD_DESCRIPTORS */:
711
+ case STATE2.FIELD_DESCRIPTORS:
704
712
  const fieldDescriptorView = binaryReader.getDataView(
705
713
  // @ts-ignore
706
714
  result.dbfHeader.headerLength - DBF_HEADER_SIZE
@@ -713,10 +721,10 @@ function parseState2(state, result, binaryReader, textDecoder) {
713
721
  fields: result.dbfFields.map((dbfField) => makeField(dbfField)),
714
722
  metadata: {}
715
723
  };
716
- state = 2 /* FIELD_PROPERTIES */;
724
+ state = STATE2.FIELD_PROPERTIES;
717
725
  binaryReader.skip(1);
718
726
  break;
719
- case 2 /* FIELD_PROPERTIES */:
727
+ case STATE2.FIELD_PROPERTIES:
720
728
  const { recordLength = 0, nRecords = 0 } = (result == null ? void 0 : result.dbfHeader) || {};
721
729
  while (result.data.length < nRecords) {
722
730
  const recordView = binaryReader.getDataView(recordLength - 1);
@@ -728,15 +736,15 @@ function parseState2(state, result, binaryReader, textDecoder) {
728
736
  result.data.push(row);
729
737
  result.progress.rows = result.data.length;
730
738
  }
731
- state = 3 /* END */;
739
+ state = STATE2.END;
732
740
  break;
733
741
  default:
734
- state = 4 /* ERROR */;
742
+ state = STATE2.ERROR;
735
743
  result.error = `illegal parser state ${state}`;
736
744
  return state;
737
745
  }
738
746
  } catch (error) {
739
- state = 4 /* ERROR */;
747
+ state = STATE2.ERROR;
740
748
  result.error = `DBF parsing failed: ${error.message}`;
741
749
  return state;
742
750
  }
@@ -778,9 +786,7 @@ function parseRow(view, fields, textDecoder) {
778
786
  const out = {};
779
787
  let offset = 0;
780
788
  for (const field of fields) {
781
- const text = textDecoder.decode(
782
- new Uint8Array(view.buffer, view.byteOffset + offset, field.fieldLength)
783
- );
789
+ const text = textDecoder.decode(new Uint8Array(view.buffer, view.byteOffset + offset, field.fieldLength));
784
790
  out[field.name] = parseField(text, field.dataType);
785
791
  offset += field.fieldLength;
786
792
  }
@@ -840,8 +846,8 @@ function makeField({ name, dataType, fieldLength, decimal }) {
840
846
  }
841
847
  }
842
848
 
843
- // src/dbf-loader.ts
844
- var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
849
+ // dist/dbf-loader.js
850
+ var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
845
851
  var DBFWorkerLoader = {
846
852
  name: "DBF",
847
853
  id: "dbf",
@@ -866,30 +872,20 @@ var DBFLoader = {
866
872
  }
867
873
  };
868
874
 
869
- // src/lib/parsers/parse-shapefile.ts
875
+ // dist/lib/parsers/parse-shapefile.js
870
876
  async function* parseShapefileInBatches(asyncIterator, options, context) {
871
877
  var _a, _b, _c;
872
878
  const { reproject = false, _targetCrs = "WGS84" } = (options == null ? void 0 : options.gis) || {};
873
879
  const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);
874
- const shapeIterable = await (0, import_loader_utils.parseInBatchesFromContext)(
875
- asyncIterator,
876
- SHPLoader,
877
- options,
878
- context
879
- );
880
+ const shapeIterable = await (0, import_loader_utils.parseInBatchesFromContext)(asyncIterator, SHPLoader, options, context);
880
881
  const shapeIterator = ((_a = shapeIterable[Symbol.asyncIterator]) == null ? void 0 : _a.call(shapeIterable)) || ((_b = shapeIterable[Symbol.iterator]) == null ? void 0 : _b.call(shapeIterable));
881
882
  let propertyIterator = null;
882
883
  const dbfResponse = await (context == null ? void 0 : context.fetch(replaceExtension((context == null ? void 0 : context.url) || "", "dbf")));
883
884
  if (dbfResponse == null ? void 0 : dbfResponse.ok) {
884
- const propertyIterable = await (0, import_loader_utils.parseInBatchesFromContext)(
885
- dbfResponse,
886
- DBFLoader,
887
- {
888
- ...options,
889
- dbf: { encoding: cpg || "latin1" }
890
- },
891
- context
892
- );
885
+ const propertyIterable = await (0, import_loader_utils.parseInBatchesFromContext)(dbfResponse, DBFLoader, {
886
+ ...options,
887
+ dbf: { encoding: cpg || "latin1" }
888
+ }, context);
893
889
  propertyIterator = ((_c = propertyIterable[Symbol.asyncIterator]) == null ? void 0 : _c.call(propertyIterable)) || propertyIterable[Symbol.iterator]();
894
890
  }
895
891
  let shapeHeader = (await shapeIterator.next()).value;
@@ -940,12 +936,7 @@ async function parseShapefile(arrayBuffer, options, context) {
940
936
  let propertyTable;
941
937
  const dbfResponse = await (context == null ? void 0 : context.fetch(replaceExtension(context == null ? void 0 : context.url, "dbf")));
942
938
  if (dbfResponse == null ? void 0 : dbfResponse.ok) {
943
- propertyTable = await (0, import_loader_utils.parseFromContext)(
944
- dbfResponse,
945
- DBFLoader,
946
- { dbf: { shape: "object-row-table", encoding: cpg || "latin1" } },
947
- context
948
- );
939
+ propertyTable = await (0, import_loader_utils.parseFromContext)(dbfResponse, DBFLoader, { dbf: { shape: "object-row-table", encoding: cpg || "latin1" } }, context);
949
940
  }
950
941
  let features = joinProperties(geojsonGeometries, (propertyTable == null ? void 0 : propertyTable.data) || []);
951
942
  if (reproject) {
@@ -1054,8 +1045,8 @@ function extname(url) {
1054
1045
  return extIndex;
1055
1046
  }
1056
1047
 
1057
- // src/shapefile-loader.ts
1058
- var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1048
+ // dist/shapefile-loader.js
1049
+ var VERSION3 = true ? "4.2.0-alpha.4" : "latest";
1059
1050
  var ShapefileLoader = {
1060
1051
  name: "Shapefile",
1061
1052
  id: "shapefile",
@@ -1079,7 +1070,7 @@ var ShapefileLoader = {
1079
1070
  parseInBatches: parseShapefileInBatches
1080
1071
  };
1081
1072
 
1082
- // src/lib/streaming/binary-reader.ts
1073
+ // dist/lib/streaming/binary-reader.js
1083
1074
  var BinaryReader = class {
1084
1075
  constructor(arrayBuffer) {
1085
1076
  this.offset = 0;
@@ -1125,3 +1116,4 @@ var BinaryReader = class {
1125
1116
  this.offset -= bytes;
1126
1117
  }
1127
1118
  };
1119
+ //# sourceMappingURL=index.cjs.map