@loaders.gl/shapefile 4.3.1 → 4.3.2

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.
@@ -4,7 +4,7 @@
4
4
  import { parseDBF, parseDBFInBatches } from "./lib/parsers/parse-dbf.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0" !== 'undefined' ? "4.3.0" : 'latest';
7
+ const VERSION = typeof "4.3.1" !== 'undefined' ? "4.3.1" : 'latest';
8
8
  /**
9
9
  * DBFLoader - DBF files are used to contain non-geometry columns in Shapefiles
10
10
  */
@@ -377,7 +377,7 @@
377
377
  }
378
378
 
379
379
  // src/dbf-loader.ts
380
- var VERSION = true ? "4.3.0" : "latest";
380
+ var VERSION = true ? "4.3.1" : "latest";
381
381
  var DBFWorkerLoader = {
382
382
  name: "DBF",
383
383
  dataType: null,
package/dist/dist.min.js CHANGED
@@ -4,9 +4,9 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var Cs=Object.create;var kt=Object.defineProperty;var Ls=Object.getOwnPropertyDescriptor;var Ts=Object.getOwnPropertyNames;var Ds=Object.getPrototypeOf,Os=Object.prototype.hasOwnProperty;var Bs=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Gs=(t,e)=>{for(var a in e)kt(t,a,{get:e[a],enumerable:!0})},jt=(t,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ts(e))!Os.call(t,s)&&s!==a&&kt(t,s,{get:()=>e[s],enumerable:!(i=Ls(e,s))||i.enumerable});return t},Ht=(t,e,a)=>(jt(t,e,"default"),a&&jt(a,e,"default")),Fs=(t,e,a)=>(a=t!=null?Cs(Ds(t)):{},jt(e||!t||!t.__esModule?kt(a,"default",{value:t,enumerable:!0}):a,t)),qs=t=>jt(kt({},"__esModule",{value:!0}),t);var qe=Bs((Ah,Fe)=>{Fe.exports=globalThis.loaders});var qt={};Gs(qt,{DBFLoader:()=>Gt,DBFWorkerLoader:()=>Ge,SHPLoader:()=>Nt,SHPWorkerLoader:()=>ge,ShapefileLoader:()=>Rs,_BinaryChunkReader:()=>ot,_BinaryReader:()=>de,_zipBatchIterators:()=>ce});Ht(qt,Fs(qe(),1));var ot=class{offset;arrayBuffers;ended;maxRewindBytes;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 i of this.arrayBuffers)if(a+=i.byteLength,a>=e)return!0;return!1}findBufferOffsets(e){let a=-this.offset,i=[];for(let s=0;s<this.arrayBuffers.length;s++){let r=this.arrayBuffers[s];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,i.push([s,[n,h]]),i;h=r.byteLength,i.push([s,[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[s,[r,n]]=a[0],h=this.arrayBuffers[s],o=new DataView(h,r,n-r);return this.offset+=e,this.disposeBuffers(),o}let i=new DataView(this._combineArrayBuffers(a));return this.offset+=e,this.disposeBuffers(),i}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 i=new Uint8Array(a),s=0;for(let r of e){let[n,[h,o]]=r,l=new Uint8Array(this.arrayBuffers[n]);i.set(l.subarray(h,o),s),s+=o-h}return i.buffer}skip(e){this.offset+=e}rewind(e){this.offset-=e}};function Ut(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 ze(t,e){let{_maxDimensions:a=4}=e?.shp||{},i=0,s=t.getInt32(i,!0);switch(i+=Int32Array.BYTES_PER_ELEMENT,s){case 0:return zs();case 1:return pe(t,i,Math.min(2,a));case 3:return yt(t,i,Math.min(2,a),"LineString");case 5:return yt(t,i,Math.min(2,a),"Polygon");case 8:return ve(t,i,Math.min(2,a));case 11:return pe(t,i,Math.min(4,a));case 13:return yt(t,i,Math.min(4,a),"LineString");case 15:return yt(t,i,Math.min(4,a),"Polygon");case 18:return ve(t,i,Math.min(4,a));case 21:return pe(t,i,Math.min(3,a));case 23:return yt(t,i,Math.min(3,a),"LineString");case 25:return yt(t,i,Math.min(3,a),"Polygon");case 28:return ve(t,i,Math.min(3,a));default:throw new Error(`unsupported shape type: ${s}`)}}function zs(){return null}function pe(t,e,a){let i;return[i,e]=ct(t,e,1,a),{positions:{value:i,size:a},type:"Point"}}function ve(t,e,a){e+=4*Float64Array.BYTES_PER_ELEMENT;let i=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let s=null,r=null,n=null;return[s,e]=ct(t,e,i,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[n,e]=ct(t,e,i,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[r,e]=ct(t,e,i,1)),{positions:{value:je(s,r,n),size:a},type:"Point"}}function yt(t,e,a,i){e+=4*Float64Array.BYTES_PER_ELEMENT;let s=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=s*Int32Array.BYTES_PER_ELEMENT,o=new Int32Array(s+1);o.set(new Int32Array(t.buffer.slice(n,n+h))),o[s]=r,e+=s*Int32Array.BYTES_PER_ELEMENT;let l=null,u=null,f=null;[l,e]=ct(t,e,r,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[f,e]=ct(t,e,r,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[u,e]=ct(t,e,r,1));let c=je(l,u,f);if(i==="LineString")return{type:i,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);js(g)>0&&M.push(y)}return M.push(r),{type:i,positions:{value:c,size:a},primitivePolygonIndices:{value:o,size:1},polygonIndices:{value:new Uint32Array(M),size:1}}}function ct(t,e,a,i){let s=t.byteOffset+e,r=a*i*Float64Array.BYTES_PER_ELEMENT;return[new Float64Array(t.buffer.slice(s,s+r)),e+r]}function je(t,e,a){if(!(e||a))return t;let i=t.length,s=2;a&&a.length&&(i+=a.length,s++),e&&e.length&&(i+=e.length,s++);let r=new Float64Array(i);for(let n=0;n<t.length/2;n++)r[s*n]=t[n*2],r[s*n+1]=t[n*2+1];if(a&&a.length)for(let n=0;n<a.length;n++)r[s*n+2]=a[n];if(e&&e.length)for(let n=0;n<e.length;n++)r[s*n+(s-1)]=e[n];return r}function js(t){return Math.sign(ks(t))}function ks(t){let e=0,a=t.length/2-1;for(let i=0;i<a;i++)e+=(t[i*2]+t[(i+1)*2])*(t[i*2+1]-t[(i+1)*2+1]);return e/2}var Hs=!0,ke=!1,Us=100,Pt=12,J={EXPECTING_HEADER:0,EXPECTING_RECORD:1,END:2,ERROR:3},Wt=class{options={};binaryReader=new ot({maxRewindBytes:Pt});state=J.EXPECTING_HEADER;result={geometries:[],progress:{bytesTotal:NaN,bytesUsed:NaN,rows:NaN},currentIndex:NaN};constructor(e){this.options=e}write(e){this.binaryReader.write(e),this.state=He(this.state,this.result,this.binaryReader,this.options)}end(){this.binaryReader.end(),this.state=He(this.state,this.result,this.binaryReader,this.options),this.state!==J.END&&(this.state=J.ERROR,this.result.error="SHP incomplete file")}};function ye(t,e){let a=new Wt(e);return a.write(t),a.end(),a.result}async function*Ue(t,e){let a=new Wt(e),i=!1;for await(let s of t)a.write(s),!i&&a.result.header&&(i=!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 He(t,e,a,i){for(;;)try{switch(t){case J.ERROR:case J.END:return t;case J.EXPECTING_HEADER:let s=a.getDataView(Us);if(!s)return t;e.header=Ut(s),e.progress={bytesUsed:0,bytesTotal:e.header.length,rows:0},e.currentIndex=1,t=J.EXPECTING_RECORD;break;case J.EXPECTING_RECORD:for(;a.hasAvailableBytes(Pt);){let r=a.getDataView(Pt),n={recordNumber:r.getInt32(0,ke),byteLength:r.getInt32(4,ke)*2,type:r.getInt32(8,Hs)};if(!a.hasAvailableBytes(n.byteLength-4))return a.rewind(Pt),t;if(n.byteLength<4||n.type!==e.header?.type||n.recordNumber!==e.currentIndex)a.rewind(Pt-4);else{a.rewind(4);let o=a.getDataView(n.byteLength),l=ze(o,i);e.geometries.push(l),e.currentIndex++,e.progress.rows=e.currentIndex-1}}return a.ended&&(t=J.END),t;default:return t=J.ERROR,e.error=`illegal parser state ${t}`,t}}catch(s){return t=J.ERROR,e.error=`SHP parsing failed: ${s?.message}`,t}}var Ws="4.3.0",xe=[0,0,39,10],ge={dataType:null,batchType:null,name:"SHP",id:"shp",module:"shapefile",version:Ws,worker:!0,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(xe).buffer],options:{shp:{_maxDimensions:4}}},Nt={...ge,parse:async(t,e)=>ye(t,e),parseSync:ye,parseInBatches:(t,e)=>Ue(t,e)};async function Jt(t,e,a,i){return i._parse(t,e,a,i)}async function Xt(t,e,a,i){if(!i._parseInBatches)throw new Error("parseInBatches");return i._parseInBatches(t,e,a,i)}function _e(t,e,a){switch(t.type){case"Point":return Xs(t,e,a);case"LineString":return Js(t,e,a);case"Polygon":return We(t,e,a);default:let i=t;throw new Error(`Unsupported geometry type: ${i?.type}`)}}function We(t,e=-1/0,a=1/0){let{positions:i}=t,s=t.polygonIndices.value.filter(o=>o>=e&&o<=a),r=t.primitivePolygonIndices.value.filter(o=>o>=e&&o<=a);if(!(s.length>2)){let o=[];for(let l=0;l<r.length-1;l++){let u=r[l],f=r[l+1],c=Qt(i,u,f);o.push(c)}return{type:"Polygon",coordinates:o}}let h=[];for(let o=0;o<s.length-1;o++){let l=s[o],u=s[o+1],f=We(t,l,u).coordinates;h.push(f)}return{type:"MultiPolygon",coordinates:h}}function Js(t,e=-1/0,a=1/0){let{positions:i}=t,s=t.pathIndices.value.filter(h=>h>=e&&h<=a);if(!(s.length>2))return{type:"LineString",coordinates:Qt(i,s[0],s[1])};let n=[];for(let h=0;h<s.length-1;h++){let o=Qt(i,s[h],s[h+1]);n.push(o)}return{type:"MultiLineString",coordinates:n}}function Xs(t,e,a){let{positions:i}=t,s=Qt(i,e,a);return s.length>1?{type:"MultiPoint",coordinates:s}:{type:"Point",coordinates:s[0]}}function Qt(t,e,a){e=e||0,a=a||t.value.length/t.size;let i=[];for(let s=e;s<a;s++){let r=Array();for(let n=s*t.size;n<(s+1)*t.size;n++)r.push(Number(t.value[n]));i.push(r)}return i}function be(t,e){for(let a of t)a.geometry.coordinates=Je(a.geometry.coordinates,e);return t}function Je(t,e){return Qs(t)?e(t):t.map(a=>Je(a,e))}function Qs(t){return Array.isArray(t)&&Number.isFinite(t[0])&&Number.isFinite(t[1])}function Xe(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 X=1,Q=2,Qe=4,St=5,mt=484813681109536e-20,m=Math.PI/2,Ve=.16666666666666666,Ke=.04722222222222222,Ye=.022156084656084655,p=1e-10,L=.017453292519943295,V=57.29577951308232,I=Math.PI/4,Rt=Math.PI*2,R=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 Ze={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}};var $e=/[\s_\-\/\(\)]/g;function k(t,e){if(t[e])return t[e];for(var a=Object.keys(t),i=e.toLowerCase().replace($e,""),s=-1,r,n;++s<a.length;)if(r=a[s],n=r.toLowerCase().replace($e,""),n===i)return t[r]}function wt(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},{}),i,s,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(Ze,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(i in a)s=a[i],i in n?(r=n[i],typeof r=="function"?r(s):e[r]=s):e[i]=s;return typeof e.datumCode=="string"&&e.datumCode!=="WGS84"&&(e.datumCode=e.datumCode.toLowerCase()),e}var ta=Zs,Ct=1,ea=2,aa=3,Vt=4,sa=5,Ee=-1,Vs=/\s/,Ks=/[A-Za-z]/,Ys=/[A-Za-z84_]/,Kt=/[,\]]/,ia=/[\d\.E\-\+]/;function et(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=Ct}et.prototype.readCharicter=function(){var t=this.text[this.place++];if(this.state!==Vt)for(;Vs.test(t);){if(this.place>=this.text.length)return;t=this.text[this.place++]}switch(this.state){case Ct:return this.neutral(t);case ea:return this.keyword(t);case Vt:return this.quoted(t);case sa:return this.afterquote(t);case aa:return this.number(t);case Ee:return}};et.prototype.afterquote=function(t){if(t==='"'){this.word+='"',this.state=Vt;return}if(Kt.test(t)){this.word=this.word.trim(),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in afterquote yet, index '+this.place)};et.prototype.afterItem=function(t){if(t===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=Ct;return}if(t==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Ct,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Ee);return}};et.prototype.number=function(t){if(ia.test(t)){this.word+=t;return}if(Kt.test(t)){this.word=parseFloat(this.word),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in number yet, index '+this.place)};et.prototype.quoted=function(t){if(t==='"'){this.state=sa;return}this.word+=t};et.prototype.keyword=function(t){if(Ys.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=Ct;return}if(Kt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in keyword yet, index '+this.place)};et.prototype.neutral=function(t){if(Ks.test(t)){this.word=t,this.state=ea;return}if(t==='"'){this.word="",this.state=Vt;return}if(ia.test(t)){this.word=t,this.state=aa;return}if(Kt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in neutral yet, index '+this.place)};et.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Ee)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function Zs(t){var e=new et(t);return e.output()}function ra(t,e,a){Array.isArray(e)&&(a.unshift(e),e=null);var i=e?{}:t,s=a.reduce(function(r,n){return Mt(n,r),r},i);e&&(t[e]=s)}function Mt(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]={},Mt(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 i;switch(a){case"UNIT":case"PRIMEM":case"VERT_DATUM":e[a]={name:t[0].toLowerCase(),convert:t[1]},t.length===3&&Mt(t[2],e[a]);return;case"SPHEROID":case"ELLIPSOID":e[a]={name:t[0],a:t[1],rf:t[2]},t.length===4&&Mt(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]],ra(e,a,t);return;default:for(i=-1;++i<t.length;)if(!Array.isArray(t[i]))return Mt(t,e[a]);return ra(e,a,t)}}var $s=.017453292519943295;function ti(t,e){var a=e[0],i=e[1];!(a in t)&&i in t&&(t[a]=t[i],e.length===3&&(t[a]=e[2](t[a])))}function $(t){return t*$s}function ei(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,i=t.AXIS.length;a<i;++a){var s=[t.AXIS[a][0].toLowerCase(),t.AXIS[a][1].toLowerCase()];s[0].indexOf("north")!==-1||(s[0]==="y"||s[0]==="lat")&&s[1]==="north"?e+="n":s[0].indexOf("south")!==-1||(s[0]==="y"||s[0]==="lat")&&s[1]==="south"?e+="s":s[0].indexOf("east")!==-1||(s[0]==="x"||s[0]==="lon")&&s[1]==="east"?e+="e":(s[0].indexOf("west")!==-1||(s[0]==="x"||s[0]==="lon")&&s[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 ti(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",$],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",$],["x0","false_easting",n],["y0","false_northing",n],["long0","central_meridian",$],["lat0","latitude_of_origin",$],["lat0","standard_parallel_1",$],["lat1","standard_parallel_1",$],["lat2","standard_parallel_2",$],["azimuth","Azimuth"],["alpha","azimuth",$],["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=$(t.lat1>0?90:-90),t.lat_ts=t.lat1):!t.lat_ts&&t.lat0&&t.projName==="Polar_Stereographic"&&(t.lat_ts=t.lat0,t.lat0=$(t.lat0>0?90:-90))}function Yt(t){var e=ta(t),a=e.shift(),i=e.shift();e.unshift(["name",i]),e.unshift(["type",a]);var s={};return Mt(e,s),ei(s),s}function U(t){var e=this;if(arguments.length===2){var a=arguments[1];typeof a=="string"?a.charAt(0)==="+"?U[t]=wt(arguments[1]):U[t]=Yt(arguments[1]):U[t]=a}else if(arguments.length===1){if(Array.isArray(t))return t.map(function(i){Array.isArray(i)?U.apply(e,i):U(i)});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}}Xe(U);var xt=U;function ai(t){return typeof t=="string"}function si(t){return t in xt}var ii=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function ri(t){return ii.some(function(e){return t.indexOf(e)>-1})}var ni=["3857","900913","3785","102113"];function hi(t){var e=k(t,"authority");if(e){var a=k(e,"epsg");return a&&ni.indexOf(a)>-1}}function oi(t){var e=k(t,"extension");if(e)return k(e,"proj4")}function li(t){return t[0]==="+"}function fi(t){if(ai(t)){if(si(t))return xt[t];if(ri(t)){var e=Yt(t);if(hi(e))return xt["EPSG:3857"];var a=oi(e);return a?wt(a):e}if(li(t))return wt(t)}else return t}var na=fi;function Ie(t,e){t=t||{};var a,i;if(!e)return t;for(i in e)a=e[i],a!==void 0&&(t[i]=a);return t}function B(t,e,a){var i=t*e;return a/Math.sqrt(1-i*i)}function tt(t){return t<0?-1:1}function v(t){return Math.abs(t)<=R?t:t-tt(t)*Rt}function F(t,e,a){var i=t*a,s=.5*t;return i=Math.pow((1-i)/(1+i),s),Math.tan(.5*(m-e))/i}function at(t,e){for(var a=.5*t,i,s,r=m-2*Math.atan(e),n=0;n<=15;n++)if(i=t*Math.sin(r),s=m-2*Math.atan(e*Math.pow((1-i)/(1+i),a))-r,r+=s,Math.abs(s)<=1e-10)return r;return-9999}function ui(){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 ci(t){var e=t.x,a=t.y;if(a*V>90&&a*V<-90&&e*V>180&&e*V<-180)return null;var i,s;if(Math.abs(Math.abs(a)-m)<=p)return null;if(this.sphere)i=this.x0+this.a*this.k0*v(e-this.long0),s=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);i=this.x0+this.a*this.k0*v(e-this.long0),s=this.y0-this.a*this.k0*Math.log(n)}return t.x=i,t.y=s,t}function mi(t){var e=t.x-this.x0,a=t.y-this.y0,i,s;if(this.sphere)s=m-2*Math.atan(Math.exp(-a/(this.a*this.k0)));else{var r=Math.exp(-a/(this.a*this.k0));if(s=at(this.e,r),s===-9999)return null}return i=v(this.long0+e/(this.a*this.k0)),t.x=i,t.y=s,t}var Mi=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"],ha={init:ui,forward:ci,inverse:mi,names:Mi};function di(){}function oa(t){return t}var pi=["longlat","identity"],la={init:di,forward:oa,inverse:oa,names:pi};var vi=[ha,la],Zt={},$t=[];function fa(t,e){var a=$t.length;return t.names?($t[a]=t,t.names.forEach(function(i){Zt[i.toLowerCase()]=a}),this):(console.log(e),!0)}function yi(t){if(!t)return!1;var e=t.toLowerCase();if(typeof Zt[e]<"u"&&$t[Zt[e]])return $t[Zt[e]]}function xi(){vi.forEach(fa)}var ua={start:xi,add:fa,get:yi};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 ca=_.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};_.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};function ma(t,e,a,i){var s=t*t,r=e*e,n=(s-r)/s,h=0;i?(t*=1-n*(Ve+n*(Ke+n*Ye)),s=t*t,n=0):h=Math.sqrt(n);var o=(s-r)/r;return{es:n,e:h,ep2:o}}function Ma(t,e,a,i,s){if(!t){var r=k(_,i);r||(r=ca),t=r.a,e=r.b,a=r.rf}return a&&!e&&(e=(1-1/a)*t),(a===0||Math.abs(t-e)<p)&&(s=!0,e=t),{a:t,b:e,rf:a,sphere:s}}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 gi(t,e,a,i,s,r){var n={};return t===void 0||t==="none"?n.datum_type=St:n.datum_type=Qe,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=X),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=i,n.es=s,n.ep2=r,n}var da=gi;function gt(t,e){if(!(this instanceof gt))return new gt(t);e=e||function(o){if(o)throw o};var a=na(t);if(typeof a!="object"){e(t);return}var i=gt.projections.get(a.projName);if(!i){e(t);return}if(a.datumCode&&a.datumCode!=="none"){var s=k(T,a.datumCode);s&&(a.datum_params=s.towgs84?s.towgs84.split(","):null,a.ellps=s.ellipse,a.datumName=s.datumName?s.datumName:a.datumCode)}a.k0=a.k0||1,a.axis=a.axis||"enu",a.ellps=a.ellps||"wgs84";var r=Ma(a.a,a.b,a.rf,a.ellps,a.sphere),n=ma(r.a,r.b,r.rf,a.R_A),h=a.datum||da(a.datumCode,a.datum_params,r.a,r.b,n.es,n.ep2);Ie(this,a),Ie(this,i),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)}gt.projections=ua;gt.projections.start();var lt=gt;function pa(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===X?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 te(t,e,a){var i=t.x,s=t.y,r=t.z?t.z:0,n,h,o,l;if(s<-m&&s>-1.001*m)s=-m;else if(s>m&&s<1.001*m)s=m;else{if(s<-m)return{x:-1/0,y:-1/0,z:t.z};if(s>m)return{x:1/0,y:1/0,z:t.z}}return i>Math.PI&&(i-=2*Math.PI),h=Math.sin(s),l=Math.cos(s),o=h*h,n=a/Math.sqrt(1-e*o),{x:(n+r)*l*Math.cos(i),y:(n+r)*l*Math.sin(i),z:(n*(1-e)+r)*h}}function ee(t,e,a,i){var s=1e-12,r=s*s,n=30,h,o,l,u,f,c,M,d,y,x,g,b,E,S=t.x,A=t.y,P=t.z?t.z:0,O,C,Z;if(h=Math.sqrt(S*S+A*A),o=Math.sqrt(S*S+A*A+P*P),h/a<s){if(O=0,o/a<s)return C=m,Z=-i,{x:t.x,y:t.y,z:t.z}}else O=Math.atan2(A,S);l=P/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+P*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 va(t,e,a){if(e===X)return{x:t.x+a[0],y:t.y+a[1],z:t.z+a[2]};if(e===Q){var i=a[0],s=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)+i,y:l*(o*t.x+t.y-n*t.z)+s,z:l*(-h*t.x+n*t.y+t.z)+r}}}function ya(t,e,a){if(e===X)return{x:t.x-a[0],y:t.y-a[1],z:t.z-a[2]};if(e===Q){var i=a[0],s=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6],u=(t.x-i)/l,f=(t.y-s)/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 ae(t){return t===X||t===Q}function xa(t,e,a){return pa(t,e)||t.datum_type===St||e.datum_type===St||t.es===e.es&&t.a===e.a&&!ae(t.datum_type)&&!ae(e.datum_type)?a:(a=te(a,t.es,t.a),ae(t.datum_type)&&(a=va(a,t.datum_type,t.datum_params)),ae(e.datum_type)&&(a=ya(a,e.datum_type,e.datum_params)),ee(a,e.es,e.a,e.b))}function Ae(t,e,a){var i=a.x,s=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=i,"ew".indexOf(t.axis[o])!==-1?h="x":h="y"):o===1?(n=s,"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 _a(t){ga(t.x),ga(t.y)}function ga(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 _i(t,e){return(t.datum.datum_type===X||t.datum.datum_type===Q)&&e.datumCode!=="WGS84"||(e.datum.datum_type===X||e.datum.datum_type===Q)&&t.datumCode!=="WGS84"}function dt(t,e,a){var i;if(Array.isArray(a)&&(a=se(a)),_a(a),t.datum&&e.datum&&_i(t,e)&&(i=new lt("WGS84"),a=dt(t,i,a),t=i),t.axis!=="enu"&&(a=Ae(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=xa(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"?Ae(e,!0,a):a}var ba=lt("WGS84");function Pe(t,e,a){var i,s,r;return Array.isArray(a)?(i=dt(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 i.z=="number"?[i.x,i.y,i.z].concat(a.splice(3)):[i.x,i.y,a[2]].concat(a.splice(3)):[i.x,i.y].concat(a.splice(2)):[i.x,i.y]):(s=dt(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;s[n]=a[n]}),s)}function Ea(t){return t instanceof lt?t:t.oProj?t.oProj:lt(t)}function bi(t,e,a){t=Ea(t);var i=!1,s;return typeof e>"u"?(e=t,t=ba,i=!0):(typeof e.x<"u"||Array.isArray(e))&&(a=e,e=t,t=ba,i=!0),e=Ea(e),a?Pe(t,e,a):(s={forward:function(r){return Pe(t,e,r)},inverse:function(r){return Pe(e,t,r)}},i&&(s.oProj=e),s)}var H=bi;var Ia=6,Pa="AJSAJS",Na="AFAFAF",_t=65,z=73,W=79,Lt=86,Tt=90,Sa={forward:Se,inverse:Ei,toPoint:Re};function Se(t,e){return e=e||5,Pi(Ii({lat:t[1],lon:t[0]}),e)}function Ei(t){var e=we(wa(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat,e.lon,e.lat]:[e.left,e.bottom,e.right,e.top]}function Re(t){var e=we(wa(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function Ne(t){return t*(Math.PI/180)}function Aa(t){return 180*(t/Math.PI)}function Ii(t){var e=t.lat,a=t.lon,i=6378137,s=.00669438,r=.9996,n,h,o,l,u,f,c,M=Ne(e),d=Ne(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=Ne(n),h=s/(1-s),o=i/Math.sqrt(1-s*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=i*((1-s/4-3*s*s/64-5*s*s*s/256)*M-(3*s/8+3*s*s/32+45*s*s*s/1024)*Math.sin(2*M)+(15*s*s/256+45*s*s*s/1024)*Math.sin(4*M)-35*s*s*s/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:Ai(e)}}function we(t){var e=t.northing,a=t.easting,i=t.zoneLetter,s=t.zoneNumber;if(s<0||s>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,S=e;i<"N"&&(S-=1e7),x=(s-1)*6-180+3,o=h/(1-h),y=S/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 A=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);A=Aa(A);var P=(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);P=x+Aa(P);var O;if(t.accuracy){var C=we({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});O={top:C.lat,right:C.lon,bottom:A,left:P}}else O={lat:A,lon:P};return O}function Ai(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 Pi(t,e){var a="00000"+t.easting,i="00000"+t.northing;return t.zoneNumber+t.zoneLetter+Ni(t.easting,t.northing,t.zoneNumber)+a.substr(a.length-5,e)+i.substr(i.length-5,e)}function Ni(t,e,a){var i=Ra(a),s=Math.floor(t/1e5),r=Math.floor(e/1e5)%20;return Si(s,r,i)}function Ra(t){var e=t%Ia;return e===0&&(e=Ia),e}function Si(t,e,a){var i=a-1,s=Pa.charCodeAt(i),r=Na.charCodeAt(i),n=s+t-1,h=r+e,o=!1;n>Tt&&(n=n-Tt+_t-1,o=!0),(n===z||s<z&&n>z||(n>z||s<z)&&o)&&n++,(n===W||s<W&&n>W||(n>W||s<W)&&o)&&(n++,n===z&&n++),n>Tt&&(n=n-Tt+_t-1),h>Lt?(h=h-Lt+_t-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>Lt&&(h=h-Lt+_t-1);var l=String.fromCharCode(n)+String.fromCharCode(h);return l}function wa(t){if(t&&t.length===0)throw"MGRSPoint coverting from nothing";for(var e=t.length,a=null,i="",s,r=0;!/[A-Z]/.test(s=t.charAt(r));){if(r>=2)throw"MGRSPoint bad conversion from: "+t;i+=s,r++}var n=parseInt(i,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=Ra(n),l=Ri(a.charAt(0),o),u=wi(a.charAt(1),o);u<Ci(h);)u+=2e6;var f=e-r;if(f%2!==0)throw`MGRSPoint has to have an even number
7
+ "use strict";var __exports__=(()=>{var Cs=Object.create;var kt=Object.defineProperty;var Ls=Object.getOwnPropertyDescriptor;var Ts=Object.getOwnPropertyNames;var Ds=Object.getPrototypeOf,Os=Object.prototype.hasOwnProperty;var Bs=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Gs=(t,e)=>{for(var a in e)kt(t,a,{get:e[a],enumerable:!0})},jt=(t,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ts(e))!Os.call(t,s)&&s!==a&&kt(t,s,{get:()=>e[s],enumerable:!(i=Ls(e,s))||i.enumerable});return t},Ht=(t,e,a)=>(jt(t,e,"default"),a&&jt(a,e,"default")),Fs=(t,e,a)=>(a=t!=null?Cs(Ds(t)):{},jt(e||!t||!t.__esModule?kt(a,"default",{value:t,enumerable:!0}):a,t)),qs=t=>jt(kt({},"__esModule",{value:!0}),t);var qe=Bs((Ah,Fe)=>{Fe.exports=globalThis.loaders});var qt={};Gs(qt,{DBFLoader:()=>Gt,DBFWorkerLoader:()=>Ge,SHPLoader:()=>Nt,SHPWorkerLoader:()=>ge,ShapefileLoader:()=>Rs,_BinaryChunkReader:()=>ot,_BinaryReader:()=>de,_zipBatchIterators:()=>ce});Ht(qt,Fs(qe(),1));var ot=class{offset;arrayBuffers;ended;maxRewindBytes;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 i of this.arrayBuffers)if(a+=i.byteLength,a>=e)return!0;return!1}findBufferOffsets(e){let a=-this.offset,i=[];for(let s=0;s<this.arrayBuffers.length;s++){let r=this.arrayBuffers[s];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,i.push([s,[n,h]]),i;h=r.byteLength,i.push([s,[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[s,[r,n]]=a[0],h=this.arrayBuffers[s],o=new DataView(h,r,n-r);return this.offset+=e,this.disposeBuffers(),o}let i=new DataView(this._combineArrayBuffers(a));return this.offset+=e,this.disposeBuffers(),i}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 i=new Uint8Array(a),s=0;for(let r of e){let[n,[h,o]]=r,l=new Uint8Array(this.arrayBuffers[n]);i.set(l.subarray(h,o),s),s+=o-h}return i.buffer}skip(e){this.offset+=e}rewind(e){this.offset-=e}};function Ut(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 ze(t,e){let{_maxDimensions:a=4}=e?.shp||{},i=0,s=t.getInt32(i,!0);switch(i+=Int32Array.BYTES_PER_ELEMENT,s){case 0:return zs();case 1:return pe(t,i,Math.min(2,a));case 3:return yt(t,i,Math.min(2,a),"LineString");case 5:return yt(t,i,Math.min(2,a),"Polygon");case 8:return ve(t,i,Math.min(2,a));case 11:return pe(t,i,Math.min(4,a));case 13:return yt(t,i,Math.min(4,a),"LineString");case 15:return yt(t,i,Math.min(4,a),"Polygon");case 18:return ve(t,i,Math.min(4,a));case 21:return pe(t,i,Math.min(3,a));case 23:return yt(t,i,Math.min(3,a),"LineString");case 25:return yt(t,i,Math.min(3,a),"Polygon");case 28:return ve(t,i,Math.min(3,a));default:throw new Error(`unsupported shape type: ${s}`)}}function zs(){return null}function pe(t,e,a){let i;return[i,e]=ct(t,e,1,a),{positions:{value:i,size:a},type:"Point"}}function ve(t,e,a){e+=4*Float64Array.BYTES_PER_ELEMENT;let i=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let s=null,r=null,n=null;return[s,e]=ct(t,e,i,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[n,e]=ct(t,e,i,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[r,e]=ct(t,e,i,1)),{positions:{value:je(s,r,n),size:a},type:"Point"}}function yt(t,e,a,i){e+=4*Float64Array.BYTES_PER_ELEMENT;let s=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=s*Int32Array.BYTES_PER_ELEMENT,o=new Int32Array(s+1);o.set(new Int32Array(t.buffer.slice(n,n+h))),o[s]=r,e+=s*Int32Array.BYTES_PER_ELEMENT;let l=null,u=null,f=null;[l,e]=ct(t,e,r,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[f,e]=ct(t,e,r,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[u,e]=ct(t,e,r,1));let c=je(l,u,f);if(i==="LineString")return{type:i,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);js(g)>0&&M.push(y)}return M.push(r),{type:i,positions:{value:c,size:a},primitivePolygonIndices:{value:o,size:1},polygonIndices:{value:new Uint32Array(M),size:1}}}function ct(t,e,a,i){let s=t.byteOffset+e,r=a*i*Float64Array.BYTES_PER_ELEMENT;return[new Float64Array(t.buffer.slice(s,s+r)),e+r]}function je(t,e,a){if(!(e||a))return t;let i=t.length,s=2;a&&a.length&&(i+=a.length,s++),e&&e.length&&(i+=e.length,s++);let r=new Float64Array(i);for(let n=0;n<t.length/2;n++)r[s*n]=t[n*2],r[s*n+1]=t[n*2+1];if(a&&a.length)for(let n=0;n<a.length;n++)r[s*n+2]=a[n];if(e&&e.length)for(let n=0;n<e.length;n++)r[s*n+(s-1)]=e[n];return r}function js(t){return Math.sign(ks(t))}function ks(t){let e=0,a=t.length/2-1;for(let i=0;i<a;i++)e+=(t[i*2]+t[(i+1)*2])*(t[i*2+1]-t[(i+1)*2+1]);return e/2}var Hs=!0,ke=!1,Us=100,Pt=12,J={EXPECTING_HEADER:0,EXPECTING_RECORD:1,END:2,ERROR:3},Wt=class{options={};binaryReader=new ot({maxRewindBytes:Pt});state=J.EXPECTING_HEADER;result={geometries:[],progress:{bytesTotal:NaN,bytesUsed:NaN,rows:NaN},currentIndex:NaN};constructor(e){this.options=e}write(e){this.binaryReader.write(e),this.state=He(this.state,this.result,this.binaryReader,this.options)}end(){this.binaryReader.end(),this.state=He(this.state,this.result,this.binaryReader,this.options),this.state!==J.END&&(this.state=J.ERROR,this.result.error="SHP incomplete file")}};function ye(t,e){let a=new Wt(e);return a.write(t),a.end(),a.result}async function*Ue(t,e){let a=new Wt(e),i=!1;for await(let s of t)a.write(s),!i&&a.result.header&&(i=!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 He(t,e,a,i){for(;;)try{switch(t){case J.ERROR:case J.END:return t;case J.EXPECTING_HEADER:let s=a.getDataView(Us);if(!s)return t;e.header=Ut(s),e.progress={bytesUsed:0,bytesTotal:e.header.length,rows:0},e.currentIndex=1,t=J.EXPECTING_RECORD;break;case J.EXPECTING_RECORD:for(;a.hasAvailableBytes(Pt);){let r=a.getDataView(Pt),n={recordNumber:r.getInt32(0,ke),byteLength:r.getInt32(4,ke)*2,type:r.getInt32(8,Hs)};if(!a.hasAvailableBytes(n.byteLength-4))return a.rewind(Pt),t;if(n.byteLength<4||n.type!==e.header?.type||n.recordNumber!==e.currentIndex)a.rewind(Pt-4);else{a.rewind(4);let o=a.getDataView(n.byteLength),l=ze(o,i);e.geometries.push(l),e.currentIndex++,e.progress.rows=e.currentIndex-1}}return a.ended&&(t=J.END),t;default:return t=J.ERROR,e.error=`illegal parser state ${t}`,t}}catch(s){return t=J.ERROR,e.error=`SHP parsing failed: ${s?.message}`,t}}var Ws="4.3.1",xe=[0,0,39,10],ge={dataType:null,batchType:null,name:"SHP",id:"shp",module:"shapefile",version:Ws,worker:!0,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(xe).buffer],options:{shp:{_maxDimensions:4}}},Nt={...ge,parse:async(t,e)=>ye(t,e),parseSync:ye,parseInBatches:(t,e)=>Ue(t,e)};async function Jt(t,e,a,i){return i._parse(t,e,a,i)}async function Xt(t,e,a,i){if(!i._parseInBatches)throw new Error("parseInBatches");return i._parseInBatches(t,e,a,i)}function _e(t,e,a){switch(t.type){case"Point":return Xs(t,e,a);case"LineString":return Js(t,e,a);case"Polygon":return We(t,e,a);default:let i=t;throw new Error(`Unsupported geometry type: ${i?.type}`)}}function We(t,e=-1/0,a=1/0){let{positions:i}=t,s=t.polygonIndices.value.filter(o=>o>=e&&o<=a),r=t.primitivePolygonIndices.value.filter(o=>o>=e&&o<=a);if(!(s.length>2)){let o=[];for(let l=0;l<r.length-1;l++){let u=r[l],f=r[l+1],c=Qt(i,u,f);o.push(c)}return{type:"Polygon",coordinates:o}}let h=[];for(let o=0;o<s.length-1;o++){let l=s[o],u=s[o+1],f=We(t,l,u).coordinates;h.push(f)}return{type:"MultiPolygon",coordinates:h}}function Js(t,e=-1/0,a=1/0){let{positions:i}=t,s=t.pathIndices.value.filter(h=>h>=e&&h<=a);if(!(s.length>2))return{type:"LineString",coordinates:Qt(i,s[0],s[1])};let n=[];for(let h=0;h<s.length-1;h++){let o=Qt(i,s[h],s[h+1]);n.push(o)}return{type:"MultiLineString",coordinates:n}}function Xs(t,e,a){let{positions:i}=t,s=Qt(i,e,a);return s.length>1?{type:"MultiPoint",coordinates:s}:{type:"Point",coordinates:s[0]}}function Qt(t,e,a){e=e||0,a=a||t.value.length/t.size;let i=[];for(let s=e;s<a;s++){let r=Array();for(let n=s*t.size;n<(s+1)*t.size;n++)r.push(Number(t.value[n]));i.push(r)}return i}function be(t,e){for(let a of t)a.geometry.coordinates=Je(a.geometry.coordinates,e);return t}function Je(t,e){return Qs(t)?e(t):t.map(a=>Je(a,e))}function Qs(t){return Array.isArray(t)&&Number.isFinite(t[0])&&Number.isFinite(t[1])}function Xe(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 X=1,Q=2,Qe=4,St=5,mt=484813681109536e-20,m=Math.PI/2,Ve=.16666666666666666,Ke=.04722222222222222,Ye=.022156084656084655,p=1e-10,L=.017453292519943295,V=57.29577951308232,I=Math.PI/4,Rt=Math.PI*2,R=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 Ze={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}};var $e=/[\s_\-\/\(\)]/g;function k(t,e){if(t[e])return t[e];for(var a=Object.keys(t),i=e.toLowerCase().replace($e,""),s=-1,r,n;++s<a.length;)if(r=a[s],n=r.toLowerCase().replace($e,""),n===i)return t[r]}function wt(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},{}),i,s,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(Ze,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(i in a)s=a[i],i in n?(r=n[i],typeof r=="function"?r(s):e[r]=s):e[i]=s;return typeof e.datumCode=="string"&&e.datumCode!=="WGS84"&&(e.datumCode=e.datumCode.toLowerCase()),e}var ta=Zs,Ct=1,ea=2,aa=3,Vt=4,sa=5,Ee=-1,Vs=/\s/,Ks=/[A-Za-z]/,Ys=/[A-Za-z84_]/,Kt=/[,\]]/,ia=/[\d\.E\-\+]/;function et(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=Ct}et.prototype.readCharicter=function(){var t=this.text[this.place++];if(this.state!==Vt)for(;Vs.test(t);){if(this.place>=this.text.length)return;t=this.text[this.place++]}switch(this.state){case Ct:return this.neutral(t);case ea:return this.keyword(t);case Vt:return this.quoted(t);case sa:return this.afterquote(t);case aa:return this.number(t);case Ee:return}};et.prototype.afterquote=function(t){if(t==='"'){this.word+='"',this.state=Vt;return}if(Kt.test(t)){this.word=this.word.trim(),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in afterquote yet, index '+this.place)};et.prototype.afterItem=function(t){if(t===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=Ct;return}if(t==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Ct,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Ee);return}};et.prototype.number=function(t){if(ia.test(t)){this.word+=t;return}if(Kt.test(t)){this.word=parseFloat(this.word),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in number yet, index '+this.place)};et.prototype.quoted=function(t){if(t==='"'){this.state=sa;return}this.word+=t};et.prototype.keyword=function(t){if(Ys.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=Ct;return}if(Kt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in keyword yet, index '+this.place)};et.prototype.neutral=function(t){if(Ks.test(t)){this.word=t,this.state=ea;return}if(t==='"'){this.word="",this.state=Vt;return}if(ia.test(t)){this.word=t,this.state=aa;return}if(Kt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in neutral yet, index '+this.place)};et.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Ee)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function Zs(t){var e=new et(t);return e.output()}function ra(t,e,a){Array.isArray(e)&&(a.unshift(e),e=null);var i=e?{}:t,s=a.reduce(function(r,n){return Mt(n,r),r},i);e&&(t[e]=s)}function Mt(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]={},Mt(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 i;switch(a){case"UNIT":case"PRIMEM":case"VERT_DATUM":e[a]={name:t[0].toLowerCase(),convert:t[1]},t.length===3&&Mt(t[2],e[a]);return;case"SPHEROID":case"ELLIPSOID":e[a]={name:t[0],a:t[1],rf:t[2]},t.length===4&&Mt(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]],ra(e,a,t);return;default:for(i=-1;++i<t.length;)if(!Array.isArray(t[i]))return Mt(t,e[a]);return ra(e,a,t)}}var $s=.017453292519943295;function ti(t,e){var a=e[0],i=e[1];!(a in t)&&i in t&&(t[a]=t[i],e.length===3&&(t[a]=e[2](t[a])))}function $(t){return t*$s}function ei(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,i=t.AXIS.length;a<i;++a){var s=[t.AXIS[a][0].toLowerCase(),t.AXIS[a][1].toLowerCase()];s[0].indexOf("north")!==-1||(s[0]==="y"||s[0]==="lat")&&s[1]==="north"?e+="n":s[0].indexOf("south")!==-1||(s[0]==="y"||s[0]==="lat")&&s[1]==="south"?e+="s":s[0].indexOf("east")!==-1||(s[0]==="x"||s[0]==="lon")&&s[1]==="east"?e+="e":(s[0].indexOf("west")!==-1||(s[0]==="x"||s[0]==="lon")&&s[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 ti(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",$],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",$],["x0","false_easting",n],["y0","false_northing",n],["long0","central_meridian",$],["lat0","latitude_of_origin",$],["lat0","standard_parallel_1",$],["lat1","standard_parallel_1",$],["lat2","standard_parallel_2",$],["azimuth","Azimuth"],["alpha","azimuth",$],["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=$(t.lat1>0?90:-90),t.lat_ts=t.lat1):!t.lat_ts&&t.lat0&&t.projName==="Polar_Stereographic"&&(t.lat_ts=t.lat0,t.lat0=$(t.lat0>0?90:-90))}function Yt(t){var e=ta(t),a=e.shift(),i=e.shift();e.unshift(["name",i]),e.unshift(["type",a]);var s={};return Mt(e,s),ei(s),s}function U(t){var e=this;if(arguments.length===2){var a=arguments[1];typeof a=="string"?a.charAt(0)==="+"?U[t]=wt(arguments[1]):U[t]=Yt(arguments[1]):U[t]=a}else if(arguments.length===1){if(Array.isArray(t))return t.map(function(i){Array.isArray(i)?U.apply(e,i):U(i)});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}}Xe(U);var xt=U;function ai(t){return typeof t=="string"}function si(t){return t in xt}var ii=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function ri(t){return ii.some(function(e){return t.indexOf(e)>-1})}var ni=["3857","900913","3785","102113"];function hi(t){var e=k(t,"authority");if(e){var a=k(e,"epsg");return a&&ni.indexOf(a)>-1}}function oi(t){var e=k(t,"extension");if(e)return k(e,"proj4")}function li(t){return t[0]==="+"}function fi(t){if(ai(t)){if(si(t))return xt[t];if(ri(t)){var e=Yt(t);if(hi(e))return xt["EPSG:3857"];var a=oi(e);return a?wt(a):e}if(li(t))return wt(t)}else return t}var na=fi;function Ie(t,e){t=t||{};var a,i;if(!e)return t;for(i in e)a=e[i],a!==void 0&&(t[i]=a);return t}function B(t,e,a){var i=t*e;return a/Math.sqrt(1-i*i)}function tt(t){return t<0?-1:1}function v(t){return Math.abs(t)<=R?t:t-tt(t)*Rt}function F(t,e,a){var i=t*a,s=.5*t;return i=Math.pow((1-i)/(1+i),s),Math.tan(.5*(m-e))/i}function at(t,e){for(var a=.5*t,i,s,r=m-2*Math.atan(e),n=0;n<=15;n++)if(i=t*Math.sin(r),s=m-2*Math.atan(e*Math.pow((1-i)/(1+i),a))-r,r+=s,Math.abs(s)<=1e-10)return r;return-9999}function ui(){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 ci(t){var e=t.x,a=t.y;if(a*V>90&&a*V<-90&&e*V>180&&e*V<-180)return null;var i,s;if(Math.abs(Math.abs(a)-m)<=p)return null;if(this.sphere)i=this.x0+this.a*this.k0*v(e-this.long0),s=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);i=this.x0+this.a*this.k0*v(e-this.long0),s=this.y0-this.a*this.k0*Math.log(n)}return t.x=i,t.y=s,t}function mi(t){var e=t.x-this.x0,a=t.y-this.y0,i,s;if(this.sphere)s=m-2*Math.atan(Math.exp(-a/(this.a*this.k0)));else{var r=Math.exp(-a/(this.a*this.k0));if(s=at(this.e,r),s===-9999)return null}return i=v(this.long0+e/(this.a*this.k0)),t.x=i,t.y=s,t}var Mi=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"],ha={init:ui,forward:ci,inverse:mi,names:Mi};function di(){}function oa(t){return t}var pi=["longlat","identity"],la={init:di,forward:oa,inverse:oa,names:pi};var vi=[ha,la],Zt={},$t=[];function fa(t,e){var a=$t.length;return t.names?($t[a]=t,t.names.forEach(function(i){Zt[i.toLowerCase()]=a}),this):(console.log(e),!0)}function yi(t){if(!t)return!1;var e=t.toLowerCase();if(typeof Zt[e]<"u"&&$t[Zt[e]])return $t[Zt[e]]}function xi(){vi.forEach(fa)}var ua={start:xi,add:fa,get:yi};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 ca=_.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};_.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};function ma(t,e,a,i){var s=t*t,r=e*e,n=(s-r)/s,h=0;i?(t*=1-n*(Ve+n*(Ke+n*Ye)),s=t*t,n=0):h=Math.sqrt(n);var o=(s-r)/r;return{es:n,e:h,ep2:o}}function Ma(t,e,a,i,s){if(!t){var r=k(_,i);r||(r=ca),t=r.a,e=r.b,a=r.rf}return a&&!e&&(e=(1-1/a)*t),(a===0||Math.abs(t-e)<p)&&(s=!0,e=t),{a:t,b:e,rf:a,sphere:s}}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 gi(t,e,a,i,s,r){var n={};return t===void 0||t==="none"?n.datum_type=St:n.datum_type=Qe,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=X),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=i,n.es=s,n.ep2=r,n}var da=gi;function gt(t,e){if(!(this instanceof gt))return new gt(t);e=e||function(o){if(o)throw o};var a=na(t);if(typeof a!="object"){e(t);return}var i=gt.projections.get(a.projName);if(!i){e(t);return}if(a.datumCode&&a.datumCode!=="none"){var s=k(T,a.datumCode);s&&(a.datum_params=s.towgs84?s.towgs84.split(","):null,a.ellps=s.ellipse,a.datumName=s.datumName?s.datumName:a.datumCode)}a.k0=a.k0||1,a.axis=a.axis||"enu",a.ellps=a.ellps||"wgs84";var r=Ma(a.a,a.b,a.rf,a.ellps,a.sphere),n=ma(r.a,r.b,r.rf,a.R_A),h=a.datum||da(a.datumCode,a.datum_params,r.a,r.b,n.es,n.ep2);Ie(this,a),Ie(this,i),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)}gt.projections=ua;gt.projections.start();var lt=gt;function pa(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===X?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 te(t,e,a){var i=t.x,s=t.y,r=t.z?t.z:0,n,h,o,l;if(s<-m&&s>-1.001*m)s=-m;else if(s>m&&s<1.001*m)s=m;else{if(s<-m)return{x:-1/0,y:-1/0,z:t.z};if(s>m)return{x:1/0,y:1/0,z:t.z}}return i>Math.PI&&(i-=2*Math.PI),h=Math.sin(s),l=Math.cos(s),o=h*h,n=a/Math.sqrt(1-e*o),{x:(n+r)*l*Math.cos(i),y:(n+r)*l*Math.sin(i),z:(n*(1-e)+r)*h}}function ee(t,e,a,i){var s=1e-12,r=s*s,n=30,h,o,l,u,f,c,M,d,y,x,g,b,E,S=t.x,A=t.y,P=t.z?t.z:0,O,C,Z;if(h=Math.sqrt(S*S+A*A),o=Math.sqrt(S*S+A*A+P*P),h/a<s){if(O=0,o/a<s)return C=m,Z=-i,{x:t.x,y:t.y,z:t.z}}else O=Math.atan2(A,S);l=P/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+P*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 va(t,e,a){if(e===X)return{x:t.x+a[0],y:t.y+a[1],z:t.z+a[2]};if(e===Q){var i=a[0],s=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)+i,y:l*(o*t.x+t.y-n*t.z)+s,z:l*(-h*t.x+n*t.y+t.z)+r}}}function ya(t,e,a){if(e===X)return{x:t.x-a[0],y:t.y-a[1],z:t.z-a[2]};if(e===Q){var i=a[0],s=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6],u=(t.x-i)/l,f=(t.y-s)/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 ae(t){return t===X||t===Q}function xa(t,e,a){return pa(t,e)||t.datum_type===St||e.datum_type===St||t.es===e.es&&t.a===e.a&&!ae(t.datum_type)&&!ae(e.datum_type)?a:(a=te(a,t.es,t.a),ae(t.datum_type)&&(a=va(a,t.datum_type,t.datum_params)),ae(e.datum_type)&&(a=ya(a,e.datum_type,e.datum_params)),ee(a,e.es,e.a,e.b))}function Ae(t,e,a){var i=a.x,s=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=i,"ew".indexOf(t.axis[o])!==-1?h="x":h="y"):o===1?(n=s,"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 _a(t){ga(t.x),ga(t.y)}function ga(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 _i(t,e){return(t.datum.datum_type===X||t.datum.datum_type===Q)&&e.datumCode!=="WGS84"||(e.datum.datum_type===X||e.datum.datum_type===Q)&&t.datumCode!=="WGS84"}function dt(t,e,a){var i;if(Array.isArray(a)&&(a=se(a)),_a(a),t.datum&&e.datum&&_i(t,e)&&(i=new lt("WGS84"),a=dt(t,i,a),t=i),t.axis!=="enu"&&(a=Ae(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=xa(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"?Ae(e,!0,a):a}var ba=lt("WGS84");function Pe(t,e,a){var i,s,r;return Array.isArray(a)?(i=dt(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 i.z=="number"?[i.x,i.y,i.z].concat(a.splice(3)):[i.x,i.y,a[2]].concat(a.splice(3)):[i.x,i.y].concat(a.splice(2)):[i.x,i.y]):(s=dt(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;s[n]=a[n]}),s)}function Ea(t){return t instanceof lt?t:t.oProj?t.oProj:lt(t)}function bi(t,e,a){t=Ea(t);var i=!1,s;return typeof e>"u"?(e=t,t=ba,i=!0):(typeof e.x<"u"||Array.isArray(e))&&(a=e,e=t,t=ba,i=!0),e=Ea(e),a?Pe(t,e,a):(s={forward:function(r){return Pe(t,e,r)},inverse:function(r){return Pe(e,t,r)}},i&&(s.oProj=e),s)}var H=bi;var Ia=6,Pa="AJSAJS",Na="AFAFAF",_t=65,z=73,W=79,Lt=86,Tt=90,Sa={forward:Se,inverse:Ei,toPoint:Re};function Se(t,e){return e=e||5,Pi(Ii({lat:t[1],lon:t[0]}),e)}function Ei(t){var e=we(wa(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat,e.lon,e.lat]:[e.left,e.bottom,e.right,e.top]}function Re(t){var e=we(wa(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function Ne(t){return t*(Math.PI/180)}function Aa(t){return 180*(t/Math.PI)}function Ii(t){var e=t.lat,a=t.lon,i=6378137,s=.00669438,r=.9996,n,h,o,l,u,f,c,M=Ne(e),d=Ne(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=Ne(n),h=s/(1-s),o=i/Math.sqrt(1-s*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=i*((1-s/4-3*s*s/64-5*s*s*s/256)*M-(3*s/8+3*s*s/32+45*s*s*s/1024)*Math.sin(2*M)+(15*s*s/256+45*s*s*s/1024)*Math.sin(4*M)-35*s*s*s/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:Ai(e)}}function we(t){var e=t.northing,a=t.easting,i=t.zoneLetter,s=t.zoneNumber;if(s<0||s>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,S=e;i<"N"&&(S-=1e7),x=(s-1)*6-180+3,o=h/(1-h),y=S/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 A=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);A=Aa(A);var P=(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);P=x+Aa(P);var O;if(t.accuracy){var C=we({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});O={top:C.lat,right:C.lon,bottom:A,left:P}}else O={lat:A,lon:P};return O}function Ai(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 Pi(t,e){var a="00000"+t.easting,i="00000"+t.northing;return t.zoneNumber+t.zoneLetter+Ni(t.easting,t.northing,t.zoneNumber)+a.substr(a.length-5,e)+i.substr(i.length-5,e)}function Ni(t,e,a){var i=Ra(a),s=Math.floor(t/1e5),r=Math.floor(e/1e5)%20;return Si(s,r,i)}function Ra(t){var e=t%Ia;return e===0&&(e=Ia),e}function Si(t,e,a){var i=a-1,s=Pa.charCodeAt(i),r=Na.charCodeAt(i),n=s+t-1,h=r+e,o=!1;n>Tt&&(n=n-Tt+_t-1,o=!0),(n===z||s<z&&n>z||(n>z||s<z)&&o)&&n++,(n===W||s<W&&n>W||(n>W||s<W)&&o)&&(n++,n===z&&n++),n>Tt&&(n=n-Tt+_t-1),h>Lt?(h=h-Lt+_t-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>Lt&&(h=h-Lt+_t-1);var l=String.fromCharCode(n)+String.fromCharCode(h);return l}function wa(t){if(t&&t.length===0)throw"MGRSPoint coverting from nothing";for(var e=t.length,a=null,i="",s,r=0;!/[A-Z]/.test(s=t.charAt(r));){if(r>=2)throw"MGRSPoint bad conversion from: "+t;i+=s,r++}var n=parseInt(i,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=Ra(n),l=Ri(a.charAt(0),o),u=wi(a.charAt(1),o);u<Ci(h);)u+=2e6;var f=e-r;if(f%2!==0)throw`MGRSPoint has to have an even number
8
8
  of digits after the zone letter and two 100km letters - front
9
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 Ri(t,e){for(var a=Pa.charCodeAt(e-1),i=1e5,s=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Tt){if(s)throw"Bad character: "+t;a=_t,s=!0}i+=1e5}return i}function wi(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;for(var a=Na.charCodeAt(e-1),i=0,s=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Lt){if(s)throw"Bad character: "+t;a=_t,s=!0}i+=1e5}return i}function Ci(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 bt(t,e,a){if(!(this instanceof bt))return new bt(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 i=t.split(",");this.x=parseFloat(i[0],10),this.y=parseFloat(i[1],10),this.z=parseFloat(i[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")}bt.fromMGRS=function(t){return new bt(Re(t))};bt.prototype.toMGRS=function(t){return Se([this.x,this.y],t)};var Ca=bt;var Li=1,Ti=.25,La=.046875,Ta=.01953125,Da=.01068115234375,Di=.75,Oi=.46875,Bi=.013020833333333334,Gi=.007120768229166667,Fi=.3645833333333333,qi=.005696614583333333,zi=.3076171875;function ie(t){var e=[];e[0]=Li-t*(Ti+t*(La+t*(Ta+t*Da))),e[1]=t*(Di-t*(La+t*(Ta+t*Da)));var a=t*t;return e[2]=a*(Oi-t*(Bi+t*Gi)),a*=t,e[3]=a*(Fi-t*qi),e[4]=a*t*zi,e}function pt(t,e,a,i){return a*=e,e*=e,i[0]*t-a*(i[1]+e*(i[2]+e*(i[3]+e*i[4])))}var ji=20;function re(t,e,a){for(var i=1/(1-e),s=t,r=ji;r;--r){var n=Math.sin(s),h=1-e*n*n;if(h=(pt(s,n,Math.cos(s),a)-t)*(h*Math.sqrt(h))*i,s-=h,Math.abs(h)<p)return s}return s}function ki(){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=ie(this.es),this.ml0=pt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Hi(t){var e=t.x,a=t.y,i=v(e-this.long0),s,r,n,h=Math.sin(a),o=Math.cos(a);if(this.es){var u=o*i,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);s=1-this.es*Math.pow(h,2),u=u/Math.sqrt(s);var g=pt(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*i*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(i);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(i)/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 Ui(t){var e,a,i,s,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=re(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,i=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)))),s=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 i=m*tt(n),s=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))),i=Math.asin(e),n<0&&(i=-i),o===0&&u===0?s=0:s=v(Math.atan2(o,u)+this.long0)}return t.x=s,t.y=i,t}var Wi=["Transverse_Mercator","Transverse Mercator","tmerc"],Oa={init:ki,forward:Hi,inverse:Ui,names:Wi};function ne(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Dt(t,e){t=Math.abs(t),e=Math.abs(e);var a=Math.max(t,e),i=Math.min(t,e)/(a||1);return a*Math.sqrt(1+Math.pow(i,2))}function Ba(t){var e=1+t,a=e-1;return a===0?t:t*Math.log(e)/a}function Ga(t){var e=Math.abs(t);return e=Ba(e*(1+e/(Dt(1,e)+1))),t<0?-e:e}function he(t,e){for(var a=2*Math.cos(2*e),i=t.length-1,s=t[i],r=0,n;--i>=0;)n=-r+a*s+t[i],r=s,s=n;return e+n*Math.sin(2*e)}function Fa(t,e){for(var a=2*Math.cos(e),i=t.length-1,s=t[i],r=0,n;--i>=0;)n=-r+a*s+t[i],r=s,s=n;return Math.sin(e)*n}function qa(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function Ce(t,e,a){for(var i=Math.sin(e),s=Math.cos(e),r=ne(a),n=qa(a),h=2*s*n,o=-2*i*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=i*n,o=s*r,[h*u-o*M,h*M+o*u]}function Ji(){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 i=he(this.cbg,this.lat0);this.Zb=-this.Qn*(i+Fa(this.gtu,2*i))}function Xi(t){var e=v(t.x-this.long0),a=t.y;a=he(this.cbg,a);var i=Math.sin(a),s=Math.cos(a),r=Math.sin(e),n=Math.cos(e);a=Math.atan2(i,n*s),e=Math.atan2(r*s,Dt(i,s*n)),e=Ga(Math.tan(e));var h=Ce(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 Qi(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 i,s;if(Math.abs(e)<=2.623395162778){var r=Ce(this.utg,2*a,2*e);a=a+r[0],e=e+r[1],e=Math.atan(ne(e));var n=Math.sin(a),h=Math.cos(a),o=Math.sin(e),l=Math.cos(e);a=Math.atan2(n*l,Dt(o,l*h)),e=Math.atan2(o,l*h),i=v(e+this.long0),s=he(this.cgb,a)}else i=1/0,s=1/0;return t.x=i,t.y=s,t}var Vi=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"],Et={init:Ji,forward:Xi,inverse:Qi,names:Vi};function za(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 Ki="etmerc";function Yi(){var t=za(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,Et.init.apply(this),this.forward=Et.forward,this.inverse=Et.inverse}var Zi=["Universal Transverse Mercator System","utm"],ja={init:Yi,names:Zi,dependsOn:Ki};function oe(t,e){return Math.pow((1-t)/(1+t),e)}var $i=20;function tr(){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)*oe(this.e*t,this.ratexp))}function er(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)*oe(this.e*Math.sin(a),this.ratexp))-m,t.x=this.C*e,t}function ar(t){for(var e=1e-14,a=t.x/this.C,i=t.y,s=Math.pow(Math.tan(.5*i+I)/this.K,1/this.C),r=$i;r>0&&(i=2*Math.atan(s*oe(this.e*Math.sin(t.y),-.5*this.e))-m,!(Math.abs(i-t.y)<e));--r)t.y=i;return r?(t.x=a,t.y=i,t):null}var sr=["gauss"],le={init:tr,forward:er,inverse:ar,names:sr};function ir(){le.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 rr(t){var e,a,i,s;return t.x=v(t.x-this.long0),le.forward.apply(this,[t]),e=Math.sin(t.y),a=Math.cos(t.y),i=Math.cos(t.x),s=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*a*i),t.x=s*a*Math.sin(t.x),t.y=s*(this.cosc0*e-this.sinc0*a*i),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function nr(t){var e,a,i,s,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),s=Math.asin(a*this.sinc0+t.y*e*this.cosc0/r),i=Math.atan2(t.x*e,r*this.cosc0*a-t.y*this.sinc0*e)}else s=this.phic0,i=0;return t.x=i,t.y=s,le.inverse.apply(this,[t]),t.x=v(t.x+this.long0),t}var hr=["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],ka={init:ir,forward:rr,inverse:nr,names:hr};function or(t,e,a){return e*=a,Math.tan(.5*(m+t))*Math.pow((1-e)/(1+e),.5*a)}function lr(){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+tt(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 fr(t){var e=t.x,a=t.y,i=Math.sin(a),s=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*i+this.coslat0*s*Math.cos(f)),t.x=this.a*r*s*Math.sin(f)+this.x0,t.y=this.a*r*(this.coslat0*i-this.sinlat0*s*Math.cos(f))+this.y0,t):(n=2*Math.atan(this.ssfn_(a,i,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*i),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 ur(t){t.x-=this.x0,t.y-=this.y0;var e,a,i,s,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,i=n*this.cons/(2*this.a*this.k0),a=this.con*at(this.e,i),e=this.con*v(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else s=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(s)*this.sinX0+t.y*Math.sin(s)*this.cosX0/n),e=v(this.long0+Math.atan2(t.x*Math.sin(s),n*this.cosX0*Math.cos(s)-t.y*this.sinX0*Math.sin(s)))),a=-1*at(this.e,Math.tan(.5*(m+r)));return t.x=e,t.y=a,t}var cr=["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],Ha={init:lr,forward:fr,inverse:ur,names:cr,ssfn_:or};function mr(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),a=this.a,i=this.rf,s=1/i,r=2*s-Math.pow(s,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 Mr(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))),i=-this.alpha*(e+a)+this.K,s=2*(Math.atan(Math.exp(i))-Math.PI/4),r=this.alpha*(t.x-this.lambda0),n=Math.atan(Math.sin(r)/(Math.sin(this.b0)*Math.tan(s)+Math.cos(this.b0)*Math.cos(r))),h=Math.asin(Math.cos(this.b0)*Math.sin(s)-Math.sin(this.b0)*Math.cos(s)*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 dr(t){for(var e=t.x-this.x0,a=t.y-this.y0,i=e/this.R,s=2*(Math.atan(Math.exp(a/this.R))-Math.PI/4),r=Math.asin(Math.cos(this.b0)*Math.sin(s)+Math.sin(this.b0)*Math.cos(s)*Math.cos(i)),n=Math.atan(Math.sin(i)/(Math.cos(this.b0)*Math.cos(i)-Math.sin(this.b0)*Math.tan(s))),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 pr=["somerc"],Ua={init:mr,forward:Mr,inverse:dr,names:pr};function vr(){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 i=F(this.e,this.lat0,t),s=this.bl/e*Math.sqrt((1-this.es)/(1-a*a));s*s<1&&(s=1);var r,n;if(!isNaN(this.longc))this.lat0>=0?r=s+Math.sqrt(s*s-1):r=s-Math.sqrt(s*s-1),this.el=r*Math.pow(i,this.bl),n=.5*(r-1/r),this.gamma0=Math.asin(Math.sin(this.alpha)/s),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=(s+Math.sqrt(s*s-1))*Math.pow(i,this.bl):this.el=(s-Math.sqrt(s*s-1))*Math.pow(i,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(s*Math.sin(this.gamma0))}this.no_off?this.uc=0:this.lat0>=0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(s*s-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(s*s-1),Math.cos(this.alpha))}function yr(t){var e=t.x,a=t.y,i=v(e-this.long0),s,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)),s=-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*i),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*i))<=p?s=this.al*this.bl*i:s=this.al*Math.atan2(l*Math.cos(this.gamma0)+f*Math.sin(this.gamma0),Math.cos(this.bl*i))/this.bl}return this.no_rot?(t.x=this.x0+s,t.y=this.y0+r):(s-=this.uc,t.x=this.x0+r*Math.cos(this.alpha)+s*Math.sin(this.alpha),t.y=this.y0+s*Math.cos(this.alpha)-r*Math.sin(this.alpha)),t}function xr(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 i=Math.exp(-1*this.bl*a/this.al),s=.5*(i-1/i),r=.5*(i+1/i),n=Math.sin(this.bl*e/this.al),h=(n*Math.cos(this.gamma0)+s*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(s*Math.cos(this.gamma0)-n*Math.sin(this.gamma0),Math.cos(this.bl*e/this.al))/this.bl)),t}var gr=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"],Wa={init:vr,forward:yr,inverse:xr,names:gr};function _r(){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),i=B(this.e,e,a),s=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(i/h)/Math.log(s/o):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=i/(this.ns*Math.pow(s,this.ns)),this.rh=this.a*this.f0*Math.pow(l,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function br(t){var e=t.x,a=t.y;Math.abs(2*Math.abs(a)-Math.PI)<=p&&(a=tt(a)*(m-2*p));var i=Math.abs(Math.abs(a)-m),s,r;if(i>p)s=F(this.e,a,Math.sin(a)),r=this.a*this.f0*Math.pow(s,this.ns);else{if(i=a*this.ns,i<=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 Er(t){var e,a,i,s,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,i=Math.pow(e/(this.a*this.f0),a),s=at(this.e,i),s===-9999)return null}else s=-m;return r=v(o/this.ns+this.long0),t.x=r,t.y=s,t}var Ir=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"],Ja={init:_r,forward:br,inverse:Er,names:Ir};function Ar(){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 Pr(t){var e,a,i,s,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),i=-u*this.alfa,s=Math.asin(Math.cos(this.ad)*Math.sin(a)+Math.sin(this.ad)*Math.cos(a)*Math.cos(i)),r=Math.asin(Math.cos(a)*Math.sin(i)/Math.cos(s)),n=this.n*r,h=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(s/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 Nr(t){var e,a,i,s,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),s=r/Math.sin(this.s0),i=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(i)-Math.sin(this.ad)*Math.cos(i)*Math.cos(s)),a=Math.asin(Math.cos(i)*Math.sin(s)/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 Sr=["Krovak","krovak"],Xa={init:Ar,forward:Pr,inverse:Nr,names:Sr};function D(t,e,a,i,s){return t*s-e*Math.sin(2*s)+a*Math.sin(4*s)-i*Math.sin(6*s)}function st(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function it(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 i=e*a;return t/Math.sqrt(1-i*i)}function K(t){return Math.abs(t)<m?t:t-tt(t)*Math.PI}function vt(t,e,a,i,s){var r,n;r=t/e;for(var h=0;h<15;h++)if(n=(t-(e*r-a*Math.sin(2*r)+i*Math.sin(4*r)-s*Math.sin(6*r)))/(e-2*a*Math.cos(2*r)+4*i*Math.cos(4*r)-6*s*Math.cos(6*r)),r+=n,Math.abs(n)<=1e-10)return r;return NaN}function Rr(){this.sphere||(this.e0=st(this.es),this.e1=it(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 wr(t){var e,a,i=t.x,s=t.y;if(i=v(i-this.long0),this.sphere)e=this.a*Math.asin(Math.cos(s)*Math.sin(i)),a=this.a*(Math.atan2(Math.tan(s),Math.cos(i))-this.lat0);else{var r=Math.sin(s),n=Math.cos(s),h=ht(this.a,this.e,r),o=Math.tan(s)*Math.tan(s),l=i*Math.cos(s),u=l*l,f=this.es*n*n/(1-this.es),c=this.a*D(this.e0,this.e1,this.e2,this.e3,s);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 Cr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,i,s;if(this.sphere){var r=a+this.lat0;i=Math.asin(Math.sin(r)*Math.cos(e)),s=Math.atan2(Math.tan(e),Math.cos(r))}else{var n=this.ml0/this.a+a,h=vt(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;i=h-o*Math.tan(h)/l*f*f*(.5-(1+3*u)*f*f/24),s=f*(1-c*(u/3+(1+3*u)*u*c/15))/Math.cos(h)}return t.x=v(s+this.long0),t.y=K(i),t}var Lr=["Cassini","Cassini_Soldner","cass"],Qa={init:Rr,forward:wr,inverse:Cr,names:Lr};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 Tr=1,Dr=2,Or=3,Br=4;function Gr(){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=Jr(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 Fr(t){var e,a,i,s,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),i=Math.cos(f),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(a=this.mode===this.EQUIT?1+u*i:1+this.sinph0*r+this.cosph0*u*i,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*i}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(i=-i),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*=i}}else{switch(h=0,o=0,l=0,i=Math.cos(f),s=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*i;break;case this.EQUIT:l=1+o*i;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*i):a=(l=Math.sqrt(2/(1+o*i)))*h*this.ymf,e=this.xmf*l*o*s;break;case this.N_POLE:case this.S_POLE:n>=0?(e=(l=Math.sqrt(n))*s,a=i*(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 qr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,i,s,r,n,h,o,l;if(this.sphere){var u=0,f,c=0;if(f=Math.sqrt(e*e+a*a),s=f*.5,s>1)return null;switch(s=2*Math.asin(s),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(c=Math.sin(s),u=Math.cos(s)),this.mode){case this.EQUIT:s=Math.abs(f)<=p?0:Math.asin(a*c/f),e*=c,a=u*f;break;case this.OBLIQ:s=Math.abs(f)<=p?this.lat0:Math.asin(u*this.sinph0+a*c*this.cosph0/f),e*=c*this.cosph0,a=(u-Math.sin(s)*this.sinph0)*f;break;case this.N_POLE:a=-a,s=m-s;break;case this.S_POLE:s-=m;break}i=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)}i=Math.atan2(e,a),s=Xr(Math.asin(l),this.apa)}return t.x=v(this.long0+i),t.y=s,t}var zr=.3333333333333333,jr=.17222222222222222,kr=.10257936507936508,Hr=.06388888888888888,Ur=.0664021164021164,Wr=.016415012942191543;function Jr(t){var e,a=[];return a[0]=t*zr,e=t*t,a[0]+=e*jr,a[1]=e*Hr,e*=t,a[0]+=e*kr,a[1]+=e*Ur,a[2]=e*Wr,a}function Xr(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 Qr=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],Va={init:Gr,forward:Fr,inverse:qr,names:Qr,S_POLE:Tr,N_POLE:Dr,EQUIT:Or,OBLIQ:Br};function j(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function Vr(){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 Kr(t){var e=t.x,a=t.y;this.sin_phi=Math.sin(a),this.cos_phi=Math.cos(a);var i=Y(this.e3,this.sin_phi,this.cos_phi),s=this.a*Math.sqrt(this.c-this.ns0*i)/this.ns0,r=this.ns0*v(e-this.long0),n=s*Math.sin(r)+this.x0,h=this.rh-s*Math.cos(r)+this.y0;return t.x=n,t.y=h,t}function Yr(t){var e,a,i,s,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),i=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),i=-1),s=0,e!==0&&(s=Math.atan2(i*t.x,i*t.y)),i=e*this.ns0/this.a,this.sphere?n=Math.asin((this.c-i*i)/(2*this.ns0)):(a=(this.c-i*i)/this.ns0,n=this.phi1z(this.e3,a)),r=v(s/this.ns0+this.long0),t.x=r,t.y=n,t}function Zr(t,e){var a,i,s,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),i=Math.cos(h),s=t*a,r=1-s*s,n=.5*r*r/i*(e/(1-o)-a/r+.5/t*Math.log((1-s)/(1+s))),h=h+n,Math.abs(n)<=1e-7)return h;return null}var $r=["Albers_Conic_Equal_Area","Albers","aea"],Ka={init:Vr,forward:Kr,inverse:Yr,names:$r,phi1z:Zr};function tn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function en(t){var e,a,i,s,r,n,h,o,l=t.x,u=t.y;return i=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),s=Math.cos(i),n=this.sin_p14*e+this.cos_p14*a*s,r=1,n>0||Math.abs(n)<=p?(h=this.x0+this.a*r*a*Math.sin(i)/n,o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*s)/n):(h=this.x0+this.infinity_dist*a*Math.sin(i),o=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*a*s)),t.x=h,t.y=o,t}function an(t){var e,a,i,s,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))?(s=Math.atan2(e,this.rc),a=Math.sin(s),i=Math.cos(s),n=j(i*this.sin_p14+t.y*a*this.cos_p14/e),r=Math.atan2(t.x*a,e*this.cos_p14*i-t.y*this.sin_p14*a),r=v(this.long0+r)):(n=this.phic0,r=0),t.x=r,t.y=n,t}var sn=["gnom"],Ya={init:tn,forward:en,inverse:an,names:sn};function Za(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 i=Math.asin(.5*e),s,r,n,h,o=0;o<30;o++)if(r=Math.sin(i),n=Math.cos(i),h=t*r,s=Math.pow(1-h*h,2)/(2*n)*(e/(1-t*t)-r/(1-h*h)+.5/t*Math.log((1-h)/(1+h))),i+=s,Math.abs(s)<=1e-10)return i;return NaN}function rn(){this.sphere||(this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function nn(t){var e=t.x,a=t.y,i,s,r=v(e-this.long0);if(this.sphere)i=this.x0+this.a*r*Math.cos(this.lat_ts),s=this.y0+this.a*Math.sin(a)/Math.cos(this.lat_ts);else{var n=Y(this.e,Math.sin(a));i=this.x0+this.a*this.k0*r,s=this.y0+this.a*n*.5/this.k0}return t.x=i,t.y=s,t}function hn(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=Za(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 on=["cea"],$a={init:rn,forward:nn,inverse:hn,names:on};function ln(){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 fn(t){var e=t.x,a=t.y,i=v(e-this.long0),s=K(a-this.lat0);return t.x=this.x0+this.a*i*this.rc,t.y=this.y0+this.a*s,t}function un(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 cn=["Equirectangular","Equidistant_Cylindrical","eqc"],ts={init:ln,forward:fn,inverse:un,names:cn};var es=20;function mn(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=st(this.es),this.e1=it(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 Mn(t){var e=t.x,a=t.y,i,s,r,n=v(e-this.long0);if(r=n*Math.sin(a),this.sphere)Math.abs(a)<=p?(i=this.a*n,s=-1*this.a*this.lat0):(i=this.a*Math.sin(r)/Math.tan(a),s=this.a*(K(a-this.lat0)+(1-Math.cos(r))/Math.tan(a)));else if(Math.abs(a)<=p)i=this.a*n,s=-1*this.ml0;else{var h=ht(this.a,this.e,Math.sin(a))/Math.tan(a);i=h*Math.sin(r),s=this.a*D(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+h*(1-Math.cos(r))}return t.x=i+this.x0,t.y=s+this.y0,t}function dn(t){var e,a,i,s,r,n,h,o,l;if(i=t.x-this.x0,s=t.y-this.y0,this.sphere)if(Math.abs(s+this.a*this.lat0)<=p)e=v(i/this.a+this.long0),a=0;else{n=this.lat0+s/this.a,h=i*i/this.a/this.a+n*n,o=n;var u;for(r=es;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(i*Math.tan(o)/this.a)/Math.sin(a))}else if(Math.abs(s+this.ml0)<=p)a=0,e=v(this.long0+i/this.a);else{n=(this.ml0+s)/this.a,h=i*i/this.a/this.a+n*n,o=n;var f,c,M,d,y;for(r=es;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(i*f/this.a)/Math.sin(a))}return t.x=e,t.y=a,t}var pn=["Polyconic","poly"],as={init:mn,forward:Mn,inverse:dn,names:pn};function vn(){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 yn(t){var e,a=t.x,i=t.y,s=i-this.lat0,r=a-this.long0,n=s/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 xn(t){var e,a=t.x,i=t.y,s=a-this.x0,r=i-this.y0,n=r/this.a,h=s/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,S=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),S=S+(e-1)*(this.B_im[e]*y+this.B_re[e]*x);y=1,x=0;var A=this.B_re[1],P=this.B_im[1];for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,A=A+e*(this.B_re[e]*y-this.B_im[e]*x),P=P+e*(this.B_im[e]*y+this.B_re[e]*x);var O=A*A+P*P;c=(E*A+S*P)/O,M=(S*A-E*P)/O}var C=c,Z=M,ft=1,ut=0;for(e=1;e<=9;e++)ft=ft*C,ut=ut+this.D[e]*ft;var zt=this.lat0+ut*mt*1e5,ws=this.long0+Z;return t.x=ws,t.y=zt,t}var gn=["New_Zealand_Map_Grid","nzmg"],ss={init:vn,forward:yn,inverse:xn,names:gn};function _n(){}function bn(t){var e=t.x,a=t.y,i=v(e-this.long0),s=this.x0+this.a*i,r=this.y0+this.a*Math.log(Math.tan(Math.PI/4+a/2.5))*1.25;return t.x=s,t.y=r,t}function En(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 In=["Miller_Cylindrical","mill"],is={init:_n,forward:bn,inverse:En,names:In};var An=20;function Pn(){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=ie(this.es)}function Nn(t){var e,a,i=t.x,s=t.y;if(i=v(i-this.long0),this.sphere){if(!this.m)s=this.n!==1?Math.asin(this.n*Math.sin(s)):s;else for(var r=this.n*Math.sin(s),n=An;n;--n){var h=(this.m*s+Math.sin(s)-r)/(this.m+Math.cos(s));if(s-=h,Math.abs(h)<p)break}e=this.a*this.C_x*i*(this.m+Math.cos(s)),a=this.a*this.C_y*s}else{var o=Math.sin(s),l=Math.cos(s);a=this.a*pt(s,o,l,this.en),e=this.a*i*l/Math.sqrt(1-this.es*o*o)}return t.x=e,t.y=a,t}function Sn(t){var e,a,i,s;return t.x-=this.x0,i=t.x/this.a,t.y-=this.y0,e=t.y/this.a,this.sphere?(e/=this.C_y,i=i/(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)),i=v(i+this.long0),e=K(e)):(e=re(t.y/this.a,this.es,this.en),s=Math.abs(e),s<m?(s=Math.sin(e),a=this.long0+t.x*Math.sqrt(1-this.es*s*s)/(this.a*Math.cos(e)),i=v(a)):s-p<m&&(i=this.long0)),t.x=i,t.y=e,t}var Rn=["Sinusoidal","sinu"],rs={init:Pn,forward:Nn,inverse:Sn,names:Rn};function wn(){}function Cn(t){for(var e=t.x,a=t.y,i=v(e-this.long0),s=a,r=Math.PI*Math.sin(a);;){var n=-(s+Math.sin(s)-r)/(1+Math.cos(s));if(s+=n,Math.abs(n)<p)break}s/=2,Math.PI/2-Math.abs(a)<p&&(i=0);var h=.900316316158*this.a*i*Math.cos(s)+this.x0,o=1.4142135623731*this.a*Math.sin(s)+this.y0;return t.x=h,t.y=o,t}function Ln(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 i=v(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));i<-Math.PI&&(i=-Math.PI),i>Math.PI&&(i=Math.PI),a=(2*e+Math.sin(2*e))/Math.PI,Math.abs(a)>1&&(a=1);var s=Math.asin(a);return t.x=i,t.y=s,t}var Tn=["Mollweide","moll"],ns={init:wn,forward:Cn,inverse:Ln,names:Tn};function Dn(){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=st(this.es),this.e1=it(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 On(t){var e=t.x,a=t.y,i;if(this.sphere)i=this.a*(this.g-a);else{var s=D(this.e0,this.e1,this.e2,this.e3,a);i=this.a*(this.g-s)}var r=this.ns*v(e-this.long0),n=this.x0+i*Math.sin(r),h=this.y0+this.rh-i*Math.cos(r);return t.x=n,t.y=h,t}function Bn(t){t.x-=this.x0,t.y=this.rh-t.y+this.y0;var e,a,i,s;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 s=v(this.long0+r/this.ns),i=K(this.g-a/this.a),t.x=s,t.y=i,t;var n=this.g-a/this.a;return i=vt(n,this.e0,this.e1,this.e2,this.e3),s=v(this.long0+r/this.ns),t.x=s,t.y=i,t}var Gn=["Equidistant_Conic","eqdc"],hs={init:Dn,forward:On,inverse:Bn,names:Gn};function Fn(){this.R=this.a}function qn(t){var e=t.x,a=t.y,i=v(e-this.long0),s,r;Math.abs(a)<=p&&(s=this.x0+this.R*i,r=this.y0);var n=j(2*Math.abs(a/Math.PI));(Math.abs(i)<=p||Math.abs(Math.abs(a)-m)<=p)&&(s=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/i-i/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);i<0&&(y=-y),s=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=s,t.y=r,t}function zn(t){var e,a,i,s,r,n,h,o,l,u,f,c,M;return t.x-=this.x0,t.y-=this.y0,f=Math.PI*this.R,i=t.x/f,s=t.y/f,r=i*i+s*s,n=-Math.abs(s)*(1+r),h=n-2*s*s+i*i,o=-2*n+1+2*s*s+r*r,M=s*s/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(i)<p?e=this.long0:e=v(this.long0+Math.PI*(r-1+Math.sqrt(1+2*(i*i-s*s)+r*r))/2/i),t.x=e,t.y=a,t}var jn=["Van_der_Grinten_I","VanDerGrinten","vandg"],os={init:Fn,forward:qn,inverse:zn,names:jn};function kn(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)}function Hn(t){var e=t.x,a=t.y,i=Math.sin(t.y),s=Math.cos(t.y),r=v(e-this.long0),n,h,o,l,u,f,c,M,d,y,x,g,b,E,S,A,P,O,C,Z,ft,ut,zt;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*i+this.cos_p12*s*Math.cos(r),A=Math.acos(O),P=A?A/Math.sin(A):1,t.x=this.x0+this.a*P*s*Math.sin(r),t.y=this.y0+this.a*P*(this.cos_p12*i-this.sin_p12*s*Math.cos(r)),t):(n=st(this.es),h=it(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=i/s,M=ht(this.a,this.e,this.sin_p12),d=ht(this.a,this.e,i),y=Math.atan((1-this.es)*c+this.es*M*this.sin_p12/(d*s)),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,S=b*b,Z=C*C,ft=Z*C,ut=ft*C,zt=ut*C,A=M*C*(1-Z*S*(1-S)/6+ft/8*E*(1-2*S)+ut/120*(S*(4-7*S)-3*g*g*(1-7*S))-zt/48*E),t.x=this.x0+A*Math.sin(x),t.y=this.y0+A*Math.cos(x),t))}function Un(t){t.x-=this.x0,t.y-=this.y0;var e,a,i,s,r,n,h,o,l,u,f,c,M,d,y,x,g,b,E,S,A,P,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,i=Math.sin(a),s=Math.cos(a),r=this.long0,Math.abs(e)<=p?n=this.lat0:(n=j(s*this.sin_p12+t.y*i*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*i,e*this.cos_p12*s-t.y*this.sin_p12*i))),t.x=r,t.y=n,t)):(o=st(this.es),l=it(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=vt(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=vt(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),S=3*this.es*(1-E)*this.sin_p12*this.cos_p12*g/(1-this.es),A=e/d,P=A-E*(1+E)*Math.pow(A,3)/6-S*(1+3*E)*Math.pow(A,4)/24,O=1-E*P*P/2-A*P*P*P/6,y=Math.asin(this.sin_p12*Math.cos(P)+this.cos_p12*Math.sin(P)*g),r=v(this.long0+Math.asin(Math.sin(x)*Math.sin(P)/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 Wn=["Azimuthal_Equidistant","aeqd"],ls={init:kn,forward:Hn,inverse:Un,names:Wn};function Jn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)}function Xn(t){var e,a,i,s,r,n,h,o,l=t.x,u=t.y;return i=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),s=Math.cos(i),n=this.sin_p14*e+this.cos_p14*a*s,r=1,(n>0||Math.abs(n)<=p)&&(h=this.a*r*a*Math.sin(i),o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*s)),t.x=h,t.y=o,t}function Qn(t){var e,a,i,s,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),i=Math.sin(a),s=Math.cos(a),n=this.long0,Math.abs(e)<=p?(h=this.lat0,t.x=n,t.y=h,t):(h=j(s*this.sin_p14+t.y*i*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*i,e*this.cos_p14*s-t.y*this.sin_p14*i)),t.x=n,t.y=h,t))}var Vn=["ortho"],fs={init:Jn,forward:Xn,inverse:Qn,names:Vn};var w={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},N={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Kn(){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=w.TOP:this.lat0<=-(m-I/2)?this.face=w.BOTTOM:Math.abs(this.long0)<=I?this.face=w.FRONT:Math.abs(this.long0)<=m+I?this.face=this.long0>0?w.RIGHT:w.LEFT:this.face=w.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 Yn(t){var e={x:0,y:0},a,i,s,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,i=t.x,this.face===w.TOP)r=m-a,i>=I&&i<=m+I?(o.value=N.AREA_0,s=i-m):i>m+I||i<=-(m+I)?(o.value=N.AREA_1,s=i>0?i-R:i+R):i>-(m+I)&&i<=-I?(o.value=N.AREA_2,s=i+m):(o.value=N.AREA_3,s=i);else if(this.face===w.BOTTOM)r=m+a,i>=I&&i<=m+I?(o.value=N.AREA_0,s=-i+m):i<I&&i>=-I?(o.value=N.AREA_1,s=-i):i<-I&&i>=-(m+I)?(o.value=N.AREA_2,s=-i-m):(o.value=N.AREA_3,s=i>0?-i+R:-i-R);else{var l,u,f,c,M,d,y;this.face===w.RIGHT?i=It(i,+m):this.face===w.BACK?i=It(i,+R):this.face===w.LEFT&&(i=It(i,-m)),c=Math.sin(a),M=Math.cos(a),d=Math.sin(i),y=Math.cos(i),l=M*y,u=M*d,f=c,this.face===w.FRONT?(r=Math.acos(l),s=fe(r,f,u,o)):this.face===w.RIGHT?(r=Math.acos(u),s=fe(r,f,-l,o)):this.face===w.BACK?(r=Math.acos(-l),s=fe(r,f,-u,o)):this.face===w.LEFT?(r=Math.acos(-u),s=fe(r,f,l,o)):(r=s=0,o.value=N.AREA_0)}return h=Math.atan(12/R*(s+Math.acos(Math.sin(s)*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(s))))),o.value===N.AREA_1?h+=m:o.value===N.AREA_2?h+=R:o.value===N.AREA_3&&(h+=1.5*R),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 Zn(t){var e={lam:0,phi:0},a,i,s,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,i=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=N.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(f.value=N.AREA_1,a-=m):t.x<0&&-t.x>=Math.abs(t.y)?(f.value=N.AREA_2,a=a<0?a+R:a-R):(f.value=N.AREA_3,a+=m),u=R/12*Math.tan(a),n=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),h=Math.atan(n),s=Math.cos(a),r=Math.tan(i),o=1-s*s*r*r*(1-Math.cos(Math.atan(1/Math.cos(h)))),o<-1?o=-1:o>1&&(o=1),this.face===w.TOP)l=Math.acos(o),e.phi=m-l,f.value===N.AREA_0?e.lam=h+m:f.value===N.AREA_1?e.lam=h<0?h+R:h-R:f.value===N.AREA_2?e.lam=h-m:e.lam=h;else if(this.face===w.BOTTOM)l=Math.acos(o),e.phi=l-m,f.value===N.AREA_0?e.lam=-h+m:f.value===N.AREA_1?e.lam=-h:f.value===N.AREA_2?e.lam=-h-m:e.lam=h<0?-h-R:-h+R;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===N.AREA_1?(u=M,M=-d,d=u):f.value===N.AREA_2?(M=-M,d=-d):f.value===N.AREA_3&&(u=M,M=d,d=-u),this.face===w.RIGHT?(u=c,c=-M,M=u):this.face===w.BACK?(c=-c,M=-M):this.face===w.LEFT&&(u=c,c=M,M=-u),e.phi=Math.acos(-d)-m,e.lam=Math.atan2(M,c),this.face===w.RIGHT?e.lam=It(e.lam,-m):this.face===w.BACK?e.lam=It(e.lam,-R):this.face===w.LEFT&&(e.lam=It(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 fe(t,e,a,i){var s;return t<p?(i.value=N.AREA_0,s=0):(s=Math.atan2(e,a),Math.abs(s)<=I?i.value=N.AREA_0:s>I&&s<=m+I?(i.value=N.AREA_1,s-=m):s>m+I||s<=-(m+I)?(i.value=N.AREA_2,s=s>=0?s-R:s+R):(i.value=N.AREA_3,s+=m)),s}function It(t,e){var a=t+e;return a<-R?a+=Rt:a>+R&&(a-=Rt),a}var $n=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],us={init:Kn,forward:Yn,inverse:Zn,names:$n};var Le=[[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]],Ot=[[-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]],cs=.8487,ms=1.3523,Ms=V/5,th=1/Ms,At=18,ue=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},eh=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function ah(t,e,a,i){for(var s=e;i;--i){var r=t(s);if(s-=r,Math.abs(r)<a)break}return s}function sh(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function ih(t){var e=v(t.x-this.long0),a=Math.abs(t.y),i=Math.floor(a*Ms);i<0?i=0:i>=At&&(i=At-1),a=V*(a-th*i);var s={x:ue(Le[i],a)*e,y:ue(Ot[i],a)};return t.y<0&&(s.y=-s.y),s.x=s.x*this.a*cs+this.x0,s.y=s.y*this.a*ms+this.y0,s}function rh(t){var e={x:(t.x-this.x0)/(this.a*cs),y:Math.abs(t.y-this.y0)/(this.a*ms)};if(e.y>=1)e.x/=Le[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(Ot[a][0]>e.y)--a;else if(Ot[a+1][0]<=e.y)++a;else break;var i=Ot[a],s=5*(e.y-i[0])/(Ot[a+1][0]-i[0]);s=ah(function(r){return(ue(i,r)-e.y)/eh(i,r)},s,p,100),e.x/=ue(Le[a],s),e.y=(5*a+s)*L,t.y<0&&(e.y=-e.y)}return e.x=v(e.x+this.long0),e}var nh=["Robinson","robin"],ds={init:sh,forward:ih,inverse:rh,names:nh};function hh(){this.name="geocent"}function oh(t){var e=te(t,this.es,this.a);return e}function lh(t){var e=ee(t,this.es,this.a,this.b);return e}var fh=["Geocentric","geocentric","geocent","Geocent"],ps={init:hh,forward:oh,inverse:lh,names:fh};function vs(t){t.Proj.projections.add(Oa),t.Proj.projections.add(Et),t.Proj.projections.add(ja),t.Proj.projections.add(ka),t.Proj.projections.add(Ha),t.Proj.projections.add(Ua),t.Proj.projections.add(Wa),t.Proj.projections.add(Ja),t.Proj.projections.add(Xa),t.Proj.projections.add(Qa),t.Proj.projections.add(Va),t.Proj.projections.add(Ka),t.Proj.projections.add(Ya),t.Proj.projections.add($a),t.Proj.projections.add(ts),t.Proj.projections.add(as),t.Proj.projections.add(ss),t.Proj.projections.add(is),t.Proj.projections.add(rs),t.Proj.projections.add(ns),t.Proj.projections.add(hs),t.Proj.projections.add(os),t.Proj.projections.add(ls),t.Proj.projections.add(fs),t.Proj.projections.add(us),t.Proj.projections.add(ds),t.Proj.projections.add(ps)}H.defaultDatum="WGS84";H.Proj=lt;H.WGS84=new H.Proj("WGS84");H.Point=Ca;H.toPoint=se;H.defs=xt;H.transform=dt;H.mgrs=Sa;H.version="__VERSION__";vs(H);var Te=H;var Bt=class{static defineProjectionAliases(e){let a=[];for(let i in e)a.push([i,e[i]]);Te.defs(a)}constructor({from:e="WGS84",to:a="WGS84"}){if(this._projection=Te(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 De=100,ys=!1;function xs(t){let e=new DataView(t,0,De),i=Ut(e).length-De,s=new DataView(t,De,i),r=new Int32Array(i),n=new Int32Array(i);for(let h=0;h<i/8;h++)r[h]=s.getInt32(h*8,ys),n[h]=s.getInt32(h*8+4,ys);return{offsets:r,lengths:n}}async function*ce(t,e,a){let i=[],s=[],r=!1,n=!1;for(;!r&&!n;){if(i.length===0&&!r){let{value:o,done:l}=await t.next();l?r=!0:i.push(...o)}if(s.length===0&&!n){let{value:o,done:l}=await e.next();l?n=!0:s.push(...o)}let h=uh(i,s);h&&(yield{batchType:"data",shape:a,length:h.length,data:h})}}function uh(t,e){let a=Math.min(t.length,e.length);if(a===0)return null;let i=[t.slice(0,a),e.slice(0,a)];return t.splice(0,a),e.splice(0,a),i}var Oe=!0,gs=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 Me=class{binaryReader=new ot;textDecoder;state=q.START;result={data:[]};constructor(e){this.textDecoder=new TextDecoder(e.encoding)}write(e){this.binaryReader.write(e),this.state=_s(this.state,this.result,this.binaryReader,this.textDecoder)}end(){this.binaryReader.end(),this.state=_s(this.state,this.result,this.binaryReader,this.textDecoder),this.state!==q.END&&(this.state=q.ERROR,this.result.error="DBF incomplete file")}};function Be(t,e={}){let{encoding:a="latin1"}=e.dbf||{},i=new Me({encoding:a});i.write(t),i.end();let{data:s,schema:r}=i.result;switch(e?.dbf?.shape){case"object-row-table":return{shape:"object-row-table",schema:r,data:s};case"table":return{schema:r,rows:s};case"rows":default:return s}}async function*bs(t,e={}){let{encoding:a="latin1"}=e.dbf||{},i=new Me({encoding:a}),s=!1;for await(let r of t)i.write(r),!s&&i.result.dbfHeader&&(s=!0,yield i.result.dbfHeader),i.result.data.length>0&&(yield i.result.data,i.result.data=[]);i.end(),i.result.data.length>0&&(yield i.result.data)}function _s(t,e,a,i){for(;;)try{switch(t){case q.ERROR:case q.END:return t;case q.START:let s=a.getDataView(gs);if(!s)return t;e.dbfHeader=ch(s),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-gs);if(!r)return t;e.dbfFields=mh(r,i),e.schema={fields:e.dbfFields.map(o=>xh(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=Mh(o,e.dbfFields,i);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(s){return t=q.ERROR,e.error=`DBF parsing failed: ${s.message}`,t}}function ch(t){return{year:t.getUint8(1)+1900,month:t.getUint8(2),day:t.getUint8(3),nRecords:t.getUint32(4,Oe),headerLength:t.getUint16(8,Oe),recordLength:t.getUint16(10,Oe),languageDriver:t.getUint8(29)}}function mh(t,e){let a=(t.byteLength-1)/32,i=[],s=0;for(let r=0;r<a;r++){let n=e.decode(new Uint8Array(t.buffer,t.byteOffset+s,11)).replace(/\u0000/g,"");i.push({name:n,dataType:String.fromCharCode(t.getUint8(s+11)),fieldLength:t.getUint8(s+16),decimal:t.getUint8(s+17)}),s+=32}return i}function Mh(t,e,a){let i={},s=0;for(let r of e){let n=a.decode(new Uint8Array(t.buffer,t.byteOffset+s,r.fieldLength));i[r.name]=dh(n,r.dataType),s+=r.fieldLength}return i}function dh(t,e){switch(e){case"B":return me(t);case"C":return yh(t);case"F":return me(t);case"N":return me(t);case"O":return me(t);case"D":return ph(t);case"L":return vh(t);default:throw new Error("Unsupported data type")}}function ph(t){return Date.UTC(t.slice(0,4),parseInt(t.slice(4,6),10)-1,t.slice(6,8))}function vh(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 yh(t){return t.trim()||null}function xh({name:t,dataType:e,fieldLength:a,decimal:i}){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 gh="4.3.0",Ge={name:"DBF",dataType:null,batchType:null,id:"dbf",module:"shapefile",version:gh,worker:!0,category:"table",extensions:["dbf"],mimeTypes:["application/x-dbf"],options:{dbf:{encoding:"latin1"}}},Gt={...Ge,parse:async(t,e)=>Be(t,e),parseSync:Be,parseInBatches(t,e){return bs(t,e)}};async function*Es(t,e,a){let{reproject:i=!1,_targetCrs:s="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Ss(e,a),o=await Xt(t,Nt,e,a),l=o[Symbol.asyncIterator]?.()||o[Symbol.iterator]?.(),u=null,f=await a?.fetch(Ft(a?.url||"","dbf"));if(f?.ok){let x=await Xt(f,Gt,{...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?ce(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=As(g),S=Ps(E,b);i&&(S=Ns(S,h,s)),yield{encoding:n,prj:h,shx:r,header:c,data:S}}}async function Is(t,e,a){let{reproject:i=!1,_targetCrs:s="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Ss(e,a),{header:o,geometries:l}=await Jt(t,Nt,e,a),u=As(l),f,c=await a?.fetch(Ft(a?.url,"dbf"));c?.ok&&(f=await Jt(c,Gt,{dbf:{shape:"object-row-table",encoding:n||"latin1"}},a));let M=Ps(u,f?.data||[]);switch(i&&(M=Ns(M,h,s)),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 As(t){let e=[];for(let a of t)e.push(_e(a));return e}function Ps(t,e){let a=[];for(let i=0;i<t.length;i++){let r={type:"Feature",geometry:t[i],properties:e&&e[i]||{}};a.push(r)}return a}function Ns(t,e,a){if(!e&&!a)return t;let i=new Bt({from:e||"WGS84",to:a||"WGS84"});return be(t,s=>i.project(s))}async function Ss(t,e){let{url:a,fetch:i}=e,s=i(Ft(a,"shx")),r=i(Ft(a,"cpg")),n=i(Ft(a,"prj"));await Promise.all([s,r,n]);let h,o,l,u=await s;if(u.ok){let M=await u.arrayBuffer();h=xs(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 Ft(t,e){let a=_h(t),i=bh(t);return i===i.toUpperCase()&&(e=e.toUpperCase()),`${a}.${e}`}function _h(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(0,e):"":e}function bh(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(e+1):"":e}var Eh="4.3.0",Rs={name:"Shapefile",id:"shapefile",module:"shapefile",version:Eh,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(xe).buffer],options:{shapefile:{shape:"v3"},shp:{_maxDimensions:4}},parse:Is,parseInBatches:Es};var de=class{offset;arrayBuffer;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 qs(qt);})();
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 Ri(t,e){for(var a=Pa.charCodeAt(e-1),i=1e5,s=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Tt){if(s)throw"Bad character: "+t;a=_t,s=!0}i+=1e5}return i}function wi(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;for(var a=Na.charCodeAt(e-1),i=0,s=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Lt){if(s)throw"Bad character: "+t;a=_t,s=!0}i+=1e5}return i}function Ci(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 bt(t,e,a){if(!(this instanceof bt))return new bt(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 i=t.split(",");this.x=parseFloat(i[0],10),this.y=parseFloat(i[1],10),this.z=parseFloat(i[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")}bt.fromMGRS=function(t){return new bt(Re(t))};bt.prototype.toMGRS=function(t){return Se([this.x,this.y],t)};var Ca=bt;var Li=1,Ti=.25,La=.046875,Ta=.01953125,Da=.01068115234375,Di=.75,Oi=.46875,Bi=.013020833333333334,Gi=.007120768229166667,Fi=.3645833333333333,qi=.005696614583333333,zi=.3076171875;function ie(t){var e=[];e[0]=Li-t*(Ti+t*(La+t*(Ta+t*Da))),e[1]=t*(Di-t*(La+t*(Ta+t*Da)));var a=t*t;return e[2]=a*(Oi-t*(Bi+t*Gi)),a*=t,e[3]=a*(Fi-t*qi),e[4]=a*t*zi,e}function pt(t,e,a,i){return a*=e,e*=e,i[0]*t-a*(i[1]+e*(i[2]+e*(i[3]+e*i[4])))}var ji=20;function re(t,e,a){for(var i=1/(1-e),s=t,r=ji;r;--r){var n=Math.sin(s),h=1-e*n*n;if(h=(pt(s,n,Math.cos(s),a)-t)*(h*Math.sqrt(h))*i,s-=h,Math.abs(h)<p)return s}return s}function ki(){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=ie(this.es),this.ml0=pt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Hi(t){var e=t.x,a=t.y,i=v(e-this.long0),s,r,n,h=Math.sin(a),o=Math.cos(a);if(this.es){var u=o*i,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);s=1-this.es*Math.pow(h,2),u=u/Math.sqrt(s);var g=pt(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*i*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(i);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(i)/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 Ui(t){var e,a,i,s,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=re(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,i=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)))),s=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 i=m*tt(n),s=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))),i=Math.asin(e),n<0&&(i=-i),o===0&&u===0?s=0:s=v(Math.atan2(o,u)+this.long0)}return t.x=s,t.y=i,t}var Wi=["Transverse_Mercator","Transverse Mercator","tmerc"],Oa={init:ki,forward:Hi,inverse:Ui,names:Wi};function ne(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Dt(t,e){t=Math.abs(t),e=Math.abs(e);var a=Math.max(t,e),i=Math.min(t,e)/(a||1);return a*Math.sqrt(1+Math.pow(i,2))}function Ba(t){var e=1+t,a=e-1;return a===0?t:t*Math.log(e)/a}function Ga(t){var e=Math.abs(t);return e=Ba(e*(1+e/(Dt(1,e)+1))),t<0?-e:e}function he(t,e){for(var a=2*Math.cos(2*e),i=t.length-1,s=t[i],r=0,n;--i>=0;)n=-r+a*s+t[i],r=s,s=n;return e+n*Math.sin(2*e)}function Fa(t,e){for(var a=2*Math.cos(e),i=t.length-1,s=t[i],r=0,n;--i>=0;)n=-r+a*s+t[i],r=s,s=n;return Math.sin(e)*n}function qa(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function Ce(t,e,a){for(var i=Math.sin(e),s=Math.cos(e),r=ne(a),n=qa(a),h=2*s*n,o=-2*i*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=i*n,o=s*r,[h*u-o*M,h*M+o*u]}function Ji(){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 i=he(this.cbg,this.lat0);this.Zb=-this.Qn*(i+Fa(this.gtu,2*i))}function Xi(t){var e=v(t.x-this.long0),a=t.y;a=he(this.cbg,a);var i=Math.sin(a),s=Math.cos(a),r=Math.sin(e),n=Math.cos(e);a=Math.atan2(i,n*s),e=Math.atan2(r*s,Dt(i,s*n)),e=Ga(Math.tan(e));var h=Ce(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 Qi(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 i,s;if(Math.abs(e)<=2.623395162778){var r=Ce(this.utg,2*a,2*e);a=a+r[0],e=e+r[1],e=Math.atan(ne(e));var n=Math.sin(a),h=Math.cos(a),o=Math.sin(e),l=Math.cos(e);a=Math.atan2(n*l,Dt(o,l*h)),e=Math.atan2(o,l*h),i=v(e+this.long0),s=he(this.cgb,a)}else i=1/0,s=1/0;return t.x=i,t.y=s,t}var Vi=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"],Et={init:Ji,forward:Xi,inverse:Qi,names:Vi};function za(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 Ki="etmerc";function Yi(){var t=za(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,Et.init.apply(this),this.forward=Et.forward,this.inverse=Et.inverse}var Zi=["Universal Transverse Mercator System","utm"],ja={init:Yi,names:Zi,dependsOn:Ki};function oe(t,e){return Math.pow((1-t)/(1+t),e)}var $i=20;function tr(){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)*oe(this.e*t,this.ratexp))}function er(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)*oe(this.e*Math.sin(a),this.ratexp))-m,t.x=this.C*e,t}function ar(t){for(var e=1e-14,a=t.x/this.C,i=t.y,s=Math.pow(Math.tan(.5*i+I)/this.K,1/this.C),r=$i;r>0&&(i=2*Math.atan(s*oe(this.e*Math.sin(t.y),-.5*this.e))-m,!(Math.abs(i-t.y)<e));--r)t.y=i;return r?(t.x=a,t.y=i,t):null}var sr=["gauss"],le={init:tr,forward:er,inverse:ar,names:sr};function ir(){le.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 rr(t){var e,a,i,s;return t.x=v(t.x-this.long0),le.forward.apply(this,[t]),e=Math.sin(t.y),a=Math.cos(t.y),i=Math.cos(t.x),s=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*a*i),t.x=s*a*Math.sin(t.x),t.y=s*(this.cosc0*e-this.sinc0*a*i),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function nr(t){var e,a,i,s,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),s=Math.asin(a*this.sinc0+t.y*e*this.cosc0/r),i=Math.atan2(t.x*e,r*this.cosc0*a-t.y*this.sinc0*e)}else s=this.phic0,i=0;return t.x=i,t.y=s,le.inverse.apply(this,[t]),t.x=v(t.x+this.long0),t}var hr=["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],ka={init:ir,forward:rr,inverse:nr,names:hr};function or(t,e,a){return e*=a,Math.tan(.5*(m+t))*Math.pow((1-e)/(1+e),.5*a)}function lr(){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+tt(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 fr(t){var e=t.x,a=t.y,i=Math.sin(a),s=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*i+this.coslat0*s*Math.cos(f)),t.x=this.a*r*s*Math.sin(f)+this.x0,t.y=this.a*r*(this.coslat0*i-this.sinlat0*s*Math.cos(f))+this.y0,t):(n=2*Math.atan(this.ssfn_(a,i,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*i),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 ur(t){t.x-=this.x0,t.y-=this.y0;var e,a,i,s,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,i=n*this.cons/(2*this.a*this.k0),a=this.con*at(this.e,i),e=this.con*v(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else s=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(s)*this.sinX0+t.y*Math.sin(s)*this.cosX0/n),e=v(this.long0+Math.atan2(t.x*Math.sin(s),n*this.cosX0*Math.cos(s)-t.y*this.sinX0*Math.sin(s)))),a=-1*at(this.e,Math.tan(.5*(m+r)));return t.x=e,t.y=a,t}var cr=["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],Ha={init:lr,forward:fr,inverse:ur,names:cr,ssfn_:or};function mr(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),a=this.a,i=this.rf,s=1/i,r=2*s-Math.pow(s,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 Mr(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))),i=-this.alpha*(e+a)+this.K,s=2*(Math.atan(Math.exp(i))-Math.PI/4),r=this.alpha*(t.x-this.lambda0),n=Math.atan(Math.sin(r)/(Math.sin(this.b0)*Math.tan(s)+Math.cos(this.b0)*Math.cos(r))),h=Math.asin(Math.cos(this.b0)*Math.sin(s)-Math.sin(this.b0)*Math.cos(s)*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 dr(t){for(var e=t.x-this.x0,a=t.y-this.y0,i=e/this.R,s=2*(Math.atan(Math.exp(a/this.R))-Math.PI/4),r=Math.asin(Math.cos(this.b0)*Math.sin(s)+Math.sin(this.b0)*Math.cos(s)*Math.cos(i)),n=Math.atan(Math.sin(i)/(Math.cos(this.b0)*Math.cos(i)-Math.sin(this.b0)*Math.tan(s))),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 pr=["somerc"],Ua={init:mr,forward:Mr,inverse:dr,names:pr};function vr(){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 i=F(this.e,this.lat0,t),s=this.bl/e*Math.sqrt((1-this.es)/(1-a*a));s*s<1&&(s=1);var r,n;if(!isNaN(this.longc))this.lat0>=0?r=s+Math.sqrt(s*s-1):r=s-Math.sqrt(s*s-1),this.el=r*Math.pow(i,this.bl),n=.5*(r-1/r),this.gamma0=Math.asin(Math.sin(this.alpha)/s),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=(s+Math.sqrt(s*s-1))*Math.pow(i,this.bl):this.el=(s-Math.sqrt(s*s-1))*Math.pow(i,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(s*Math.sin(this.gamma0))}this.no_off?this.uc=0:this.lat0>=0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(s*s-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(s*s-1),Math.cos(this.alpha))}function yr(t){var e=t.x,a=t.y,i=v(e-this.long0),s,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)),s=-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*i),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*i))<=p?s=this.al*this.bl*i:s=this.al*Math.atan2(l*Math.cos(this.gamma0)+f*Math.sin(this.gamma0),Math.cos(this.bl*i))/this.bl}return this.no_rot?(t.x=this.x0+s,t.y=this.y0+r):(s-=this.uc,t.x=this.x0+r*Math.cos(this.alpha)+s*Math.sin(this.alpha),t.y=this.y0+s*Math.cos(this.alpha)-r*Math.sin(this.alpha)),t}function xr(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 i=Math.exp(-1*this.bl*a/this.al),s=.5*(i-1/i),r=.5*(i+1/i),n=Math.sin(this.bl*e/this.al),h=(n*Math.cos(this.gamma0)+s*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(s*Math.cos(this.gamma0)-n*Math.sin(this.gamma0),Math.cos(this.bl*e/this.al))/this.bl)),t}var gr=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"],Wa={init:vr,forward:yr,inverse:xr,names:gr};function _r(){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),i=B(this.e,e,a),s=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(i/h)/Math.log(s/o):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=i/(this.ns*Math.pow(s,this.ns)),this.rh=this.a*this.f0*Math.pow(l,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function br(t){var e=t.x,a=t.y;Math.abs(2*Math.abs(a)-Math.PI)<=p&&(a=tt(a)*(m-2*p));var i=Math.abs(Math.abs(a)-m),s,r;if(i>p)s=F(this.e,a,Math.sin(a)),r=this.a*this.f0*Math.pow(s,this.ns);else{if(i=a*this.ns,i<=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 Er(t){var e,a,i,s,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,i=Math.pow(e/(this.a*this.f0),a),s=at(this.e,i),s===-9999)return null}else s=-m;return r=v(o/this.ns+this.long0),t.x=r,t.y=s,t}var Ir=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"],Ja={init:_r,forward:br,inverse:Er,names:Ir};function Ar(){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 Pr(t){var e,a,i,s,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),i=-u*this.alfa,s=Math.asin(Math.cos(this.ad)*Math.sin(a)+Math.sin(this.ad)*Math.cos(a)*Math.cos(i)),r=Math.asin(Math.cos(a)*Math.sin(i)/Math.cos(s)),n=this.n*r,h=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(s/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 Nr(t){var e,a,i,s,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),s=r/Math.sin(this.s0),i=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(i)-Math.sin(this.ad)*Math.cos(i)*Math.cos(s)),a=Math.asin(Math.cos(i)*Math.sin(s)/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 Sr=["Krovak","krovak"],Xa={init:Ar,forward:Pr,inverse:Nr,names:Sr};function D(t,e,a,i,s){return t*s-e*Math.sin(2*s)+a*Math.sin(4*s)-i*Math.sin(6*s)}function st(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function it(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 i=e*a;return t/Math.sqrt(1-i*i)}function K(t){return Math.abs(t)<m?t:t-tt(t)*Math.PI}function vt(t,e,a,i,s){var r,n;r=t/e;for(var h=0;h<15;h++)if(n=(t-(e*r-a*Math.sin(2*r)+i*Math.sin(4*r)-s*Math.sin(6*r)))/(e-2*a*Math.cos(2*r)+4*i*Math.cos(4*r)-6*s*Math.cos(6*r)),r+=n,Math.abs(n)<=1e-10)return r;return NaN}function Rr(){this.sphere||(this.e0=st(this.es),this.e1=it(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 wr(t){var e,a,i=t.x,s=t.y;if(i=v(i-this.long0),this.sphere)e=this.a*Math.asin(Math.cos(s)*Math.sin(i)),a=this.a*(Math.atan2(Math.tan(s),Math.cos(i))-this.lat0);else{var r=Math.sin(s),n=Math.cos(s),h=ht(this.a,this.e,r),o=Math.tan(s)*Math.tan(s),l=i*Math.cos(s),u=l*l,f=this.es*n*n/(1-this.es),c=this.a*D(this.e0,this.e1,this.e2,this.e3,s);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 Cr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,i,s;if(this.sphere){var r=a+this.lat0;i=Math.asin(Math.sin(r)*Math.cos(e)),s=Math.atan2(Math.tan(e),Math.cos(r))}else{var n=this.ml0/this.a+a,h=vt(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;i=h-o*Math.tan(h)/l*f*f*(.5-(1+3*u)*f*f/24),s=f*(1-c*(u/3+(1+3*u)*u*c/15))/Math.cos(h)}return t.x=v(s+this.long0),t.y=K(i),t}var Lr=["Cassini","Cassini_Soldner","cass"],Qa={init:Rr,forward:wr,inverse:Cr,names:Lr};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 Tr=1,Dr=2,Or=3,Br=4;function Gr(){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=Jr(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 Fr(t){var e,a,i,s,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),i=Math.cos(f),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(a=this.mode===this.EQUIT?1+u*i:1+this.sinph0*r+this.cosph0*u*i,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*i}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(i=-i),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*=i}}else{switch(h=0,o=0,l=0,i=Math.cos(f),s=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*i;break;case this.EQUIT:l=1+o*i;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*i):a=(l=Math.sqrt(2/(1+o*i)))*h*this.ymf,e=this.xmf*l*o*s;break;case this.N_POLE:case this.S_POLE:n>=0?(e=(l=Math.sqrt(n))*s,a=i*(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 qr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,i,s,r,n,h,o,l;if(this.sphere){var u=0,f,c=0;if(f=Math.sqrt(e*e+a*a),s=f*.5,s>1)return null;switch(s=2*Math.asin(s),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(c=Math.sin(s),u=Math.cos(s)),this.mode){case this.EQUIT:s=Math.abs(f)<=p?0:Math.asin(a*c/f),e*=c,a=u*f;break;case this.OBLIQ:s=Math.abs(f)<=p?this.lat0:Math.asin(u*this.sinph0+a*c*this.cosph0/f),e*=c*this.cosph0,a=(u-Math.sin(s)*this.sinph0)*f;break;case this.N_POLE:a=-a,s=m-s;break;case this.S_POLE:s-=m;break}i=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)}i=Math.atan2(e,a),s=Xr(Math.asin(l),this.apa)}return t.x=v(this.long0+i),t.y=s,t}var zr=.3333333333333333,jr=.17222222222222222,kr=.10257936507936508,Hr=.06388888888888888,Ur=.0664021164021164,Wr=.016415012942191543;function Jr(t){var e,a=[];return a[0]=t*zr,e=t*t,a[0]+=e*jr,a[1]=e*Hr,e*=t,a[0]+=e*kr,a[1]+=e*Ur,a[2]=e*Wr,a}function Xr(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 Qr=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],Va={init:Gr,forward:Fr,inverse:qr,names:Qr,S_POLE:Tr,N_POLE:Dr,EQUIT:Or,OBLIQ:Br};function j(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function Vr(){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 Kr(t){var e=t.x,a=t.y;this.sin_phi=Math.sin(a),this.cos_phi=Math.cos(a);var i=Y(this.e3,this.sin_phi,this.cos_phi),s=this.a*Math.sqrt(this.c-this.ns0*i)/this.ns0,r=this.ns0*v(e-this.long0),n=s*Math.sin(r)+this.x0,h=this.rh-s*Math.cos(r)+this.y0;return t.x=n,t.y=h,t}function Yr(t){var e,a,i,s,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),i=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),i=-1),s=0,e!==0&&(s=Math.atan2(i*t.x,i*t.y)),i=e*this.ns0/this.a,this.sphere?n=Math.asin((this.c-i*i)/(2*this.ns0)):(a=(this.c-i*i)/this.ns0,n=this.phi1z(this.e3,a)),r=v(s/this.ns0+this.long0),t.x=r,t.y=n,t}function Zr(t,e){var a,i,s,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),i=Math.cos(h),s=t*a,r=1-s*s,n=.5*r*r/i*(e/(1-o)-a/r+.5/t*Math.log((1-s)/(1+s))),h=h+n,Math.abs(n)<=1e-7)return h;return null}var $r=["Albers_Conic_Equal_Area","Albers","aea"],Ka={init:Vr,forward:Kr,inverse:Yr,names:$r,phi1z:Zr};function tn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function en(t){var e,a,i,s,r,n,h,o,l=t.x,u=t.y;return i=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),s=Math.cos(i),n=this.sin_p14*e+this.cos_p14*a*s,r=1,n>0||Math.abs(n)<=p?(h=this.x0+this.a*r*a*Math.sin(i)/n,o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*s)/n):(h=this.x0+this.infinity_dist*a*Math.sin(i),o=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*a*s)),t.x=h,t.y=o,t}function an(t){var e,a,i,s,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))?(s=Math.atan2(e,this.rc),a=Math.sin(s),i=Math.cos(s),n=j(i*this.sin_p14+t.y*a*this.cos_p14/e),r=Math.atan2(t.x*a,e*this.cos_p14*i-t.y*this.sin_p14*a),r=v(this.long0+r)):(n=this.phic0,r=0),t.x=r,t.y=n,t}var sn=["gnom"],Ya={init:tn,forward:en,inverse:an,names:sn};function Za(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 i=Math.asin(.5*e),s,r,n,h,o=0;o<30;o++)if(r=Math.sin(i),n=Math.cos(i),h=t*r,s=Math.pow(1-h*h,2)/(2*n)*(e/(1-t*t)-r/(1-h*h)+.5/t*Math.log((1-h)/(1+h))),i+=s,Math.abs(s)<=1e-10)return i;return NaN}function rn(){this.sphere||(this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function nn(t){var e=t.x,a=t.y,i,s,r=v(e-this.long0);if(this.sphere)i=this.x0+this.a*r*Math.cos(this.lat_ts),s=this.y0+this.a*Math.sin(a)/Math.cos(this.lat_ts);else{var n=Y(this.e,Math.sin(a));i=this.x0+this.a*this.k0*r,s=this.y0+this.a*n*.5/this.k0}return t.x=i,t.y=s,t}function hn(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=Za(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 on=["cea"],$a={init:rn,forward:nn,inverse:hn,names:on};function ln(){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 fn(t){var e=t.x,a=t.y,i=v(e-this.long0),s=K(a-this.lat0);return t.x=this.x0+this.a*i*this.rc,t.y=this.y0+this.a*s,t}function un(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 cn=["Equirectangular","Equidistant_Cylindrical","eqc"],ts={init:ln,forward:fn,inverse:un,names:cn};var es=20;function mn(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=st(this.es),this.e1=it(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 Mn(t){var e=t.x,a=t.y,i,s,r,n=v(e-this.long0);if(r=n*Math.sin(a),this.sphere)Math.abs(a)<=p?(i=this.a*n,s=-1*this.a*this.lat0):(i=this.a*Math.sin(r)/Math.tan(a),s=this.a*(K(a-this.lat0)+(1-Math.cos(r))/Math.tan(a)));else if(Math.abs(a)<=p)i=this.a*n,s=-1*this.ml0;else{var h=ht(this.a,this.e,Math.sin(a))/Math.tan(a);i=h*Math.sin(r),s=this.a*D(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+h*(1-Math.cos(r))}return t.x=i+this.x0,t.y=s+this.y0,t}function dn(t){var e,a,i,s,r,n,h,o,l;if(i=t.x-this.x0,s=t.y-this.y0,this.sphere)if(Math.abs(s+this.a*this.lat0)<=p)e=v(i/this.a+this.long0),a=0;else{n=this.lat0+s/this.a,h=i*i/this.a/this.a+n*n,o=n;var u;for(r=es;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(i*Math.tan(o)/this.a)/Math.sin(a))}else if(Math.abs(s+this.ml0)<=p)a=0,e=v(this.long0+i/this.a);else{n=(this.ml0+s)/this.a,h=i*i/this.a/this.a+n*n,o=n;var f,c,M,d,y;for(r=es;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(i*f/this.a)/Math.sin(a))}return t.x=e,t.y=a,t}var pn=["Polyconic","poly"],as={init:mn,forward:Mn,inverse:dn,names:pn};function vn(){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 yn(t){var e,a=t.x,i=t.y,s=i-this.lat0,r=a-this.long0,n=s/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 xn(t){var e,a=t.x,i=t.y,s=a-this.x0,r=i-this.y0,n=r/this.a,h=s/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,S=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),S=S+(e-1)*(this.B_im[e]*y+this.B_re[e]*x);y=1,x=0;var A=this.B_re[1],P=this.B_im[1];for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,A=A+e*(this.B_re[e]*y-this.B_im[e]*x),P=P+e*(this.B_im[e]*y+this.B_re[e]*x);var O=A*A+P*P;c=(E*A+S*P)/O,M=(S*A-E*P)/O}var C=c,Z=M,ft=1,ut=0;for(e=1;e<=9;e++)ft=ft*C,ut=ut+this.D[e]*ft;var zt=this.lat0+ut*mt*1e5,ws=this.long0+Z;return t.x=ws,t.y=zt,t}var gn=["New_Zealand_Map_Grid","nzmg"],ss={init:vn,forward:yn,inverse:xn,names:gn};function _n(){}function bn(t){var e=t.x,a=t.y,i=v(e-this.long0),s=this.x0+this.a*i,r=this.y0+this.a*Math.log(Math.tan(Math.PI/4+a/2.5))*1.25;return t.x=s,t.y=r,t}function En(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 In=["Miller_Cylindrical","mill"],is={init:_n,forward:bn,inverse:En,names:In};var An=20;function Pn(){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=ie(this.es)}function Nn(t){var e,a,i=t.x,s=t.y;if(i=v(i-this.long0),this.sphere){if(!this.m)s=this.n!==1?Math.asin(this.n*Math.sin(s)):s;else for(var r=this.n*Math.sin(s),n=An;n;--n){var h=(this.m*s+Math.sin(s)-r)/(this.m+Math.cos(s));if(s-=h,Math.abs(h)<p)break}e=this.a*this.C_x*i*(this.m+Math.cos(s)),a=this.a*this.C_y*s}else{var o=Math.sin(s),l=Math.cos(s);a=this.a*pt(s,o,l,this.en),e=this.a*i*l/Math.sqrt(1-this.es*o*o)}return t.x=e,t.y=a,t}function Sn(t){var e,a,i,s;return t.x-=this.x0,i=t.x/this.a,t.y-=this.y0,e=t.y/this.a,this.sphere?(e/=this.C_y,i=i/(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)),i=v(i+this.long0),e=K(e)):(e=re(t.y/this.a,this.es,this.en),s=Math.abs(e),s<m?(s=Math.sin(e),a=this.long0+t.x*Math.sqrt(1-this.es*s*s)/(this.a*Math.cos(e)),i=v(a)):s-p<m&&(i=this.long0)),t.x=i,t.y=e,t}var Rn=["Sinusoidal","sinu"],rs={init:Pn,forward:Nn,inverse:Sn,names:Rn};function wn(){}function Cn(t){for(var e=t.x,a=t.y,i=v(e-this.long0),s=a,r=Math.PI*Math.sin(a);;){var n=-(s+Math.sin(s)-r)/(1+Math.cos(s));if(s+=n,Math.abs(n)<p)break}s/=2,Math.PI/2-Math.abs(a)<p&&(i=0);var h=.900316316158*this.a*i*Math.cos(s)+this.x0,o=1.4142135623731*this.a*Math.sin(s)+this.y0;return t.x=h,t.y=o,t}function Ln(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 i=v(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));i<-Math.PI&&(i=-Math.PI),i>Math.PI&&(i=Math.PI),a=(2*e+Math.sin(2*e))/Math.PI,Math.abs(a)>1&&(a=1);var s=Math.asin(a);return t.x=i,t.y=s,t}var Tn=["Mollweide","moll"],ns={init:wn,forward:Cn,inverse:Ln,names:Tn};function Dn(){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=st(this.es),this.e1=it(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 On(t){var e=t.x,a=t.y,i;if(this.sphere)i=this.a*(this.g-a);else{var s=D(this.e0,this.e1,this.e2,this.e3,a);i=this.a*(this.g-s)}var r=this.ns*v(e-this.long0),n=this.x0+i*Math.sin(r),h=this.y0+this.rh-i*Math.cos(r);return t.x=n,t.y=h,t}function Bn(t){t.x-=this.x0,t.y=this.rh-t.y+this.y0;var e,a,i,s;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 s=v(this.long0+r/this.ns),i=K(this.g-a/this.a),t.x=s,t.y=i,t;var n=this.g-a/this.a;return i=vt(n,this.e0,this.e1,this.e2,this.e3),s=v(this.long0+r/this.ns),t.x=s,t.y=i,t}var Gn=["Equidistant_Conic","eqdc"],hs={init:Dn,forward:On,inverse:Bn,names:Gn};function Fn(){this.R=this.a}function qn(t){var e=t.x,a=t.y,i=v(e-this.long0),s,r;Math.abs(a)<=p&&(s=this.x0+this.R*i,r=this.y0);var n=j(2*Math.abs(a/Math.PI));(Math.abs(i)<=p||Math.abs(Math.abs(a)-m)<=p)&&(s=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/i-i/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);i<0&&(y=-y),s=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=s,t.y=r,t}function zn(t){var e,a,i,s,r,n,h,o,l,u,f,c,M;return t.x-=this.x0,t.y-=this.y0,f=Math.PI*this.R,i=t.x/f,s=t.y/f,r=i*i+s*s,n=-Math.abs(s)*(1+r),h=n-2*s*s+i*i,o=-2*n+1+2*s*s+r*r,M=s*s/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(i)<p?e=this.long0:e=v(this.long0+Math.PI*(r-1+Math.sqrt(1+2*(i*i-s*s)+r*r))/2/i),t.x=e,t.y=a,t}var jn=["Van_der_Grinten_I","VanDerGrinten","vandg"],os={init:Fn,forward:qn,inverse:zn,names:jn};function kn(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)}function Hn(t){var e=t.x,a=t.y,i=Math.sin(t.y),s=Math.cos(t.y),r=v(e-this.long0),n,h,o,l,u,f,c,M,d,y,x,g,b,E,S,A,P,O,C,Z,ft,ut,zt;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*i+this.cos_p12*s*Math.cos(r),A=Math.acos(O),P=A?A/Math.sin(A):1,t.x=this.x0+this.a*P*s*Math.sin(r),t.y=this.y0+this.a*P*(this.cos_p12*i-this.sin_p12*s*Math.cos(r)),t):(n=st(this.es),h=it(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=i/s,M=ht(this.a,this.e,this.sin_p12),d=ht(this.a,this.e,i),y=Math.atan((1-this.es)*c+this.es*M*this.sin_p12/(d*s)),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,S=b*b,Z=C*C,ft=Z*C,ut=ft*C,zt=ut*C,A=M*C*(1-Z*S*(1-S)/6+ft/8*E*(1-2*S)+ut/120*(S*(4-7*S)-3*g*g*(1-7*S))-zt/48*E),t.x=this.x0+A*Math.sin(x),t.y=this.y0+A*Math.cos(x),t))}function Un(t){t.x-=this.x0,t.y-=this.y0;var e,a,i,s,r,n,h,o,l,u,f,c,M,d,y,x,g,b,E,S,A,P,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,i=Math.sin(a),s=Math.cos(a),r=this.long0,Math.abs(e)<=p?n=this.lat0:(n=j(s*this.sin_p12+t.y*i*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*i,e*this.cos_p12*s-t.y*this.sin_p12*i))),t.x=r,t.y=n,t)):(o=st(this.es),l=it(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=vt(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=vt(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),S=3*this.es*(1-E)*this.sin_p12*this.cos_p12*g/(1-this.es),A=e/d,P=A-E*(1+E)*Math.pow(A,3)/6-S*(1+3*E)*Math.pow(A,4)/24,O=1-E*P*P/2-A*P*P*P/6,y=Math.asin(this.sin_p12*Math.cos(P)+this.cos_p12*Math.sin(P)*g),r=v(this.long0+Math.asin(Math.sin(x)*Math.sin(P)/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 Wn=["Azimuthal_Equidistant","aeqd"],ls={init:kn,forward:Hn,inverse:Un,names:Wn};function Jn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)}function Xn(t){var e,a,i,s,r,n,h,o,l=t.x,u=t.y;return i=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),s=Math.cos(i),n=this.sin_p14*e+this.cos_p14*a*s,r=1,(n>0||Math.abs(n)<=p)&&(h=this.a*r*a*Math.sin(i),o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*s)),t.x=h,t.y=o,t}function Qn(t){var e,a,i,s,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),i=Math.sin(a),s=Math.cos(a),n=this.long0,Math.abs(e)<=p?(h=this.lat0,t.x=n,t.y=h,t):(h=j(s*this.sin_p14+t.y*i*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*i,e*this.cos_p14*s-t.y*this.sin_p14*i)),t.x=n,t.y=h,t))}var Vn=["ortho"],fs={init:Jn,forward:Xn,inverse:Qn,names:Vn};var w={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},N={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Kn(){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=w.TOP:this.lat0<=-(m-I/2)?this.face=w.BOTTOM:Math.abs(this.long0)<=I?this.face=w.FRONT:Math.abs(this.long0)<=m+I?this.face=this.long0>0?w.RIGHT:w.LEFT:this.face=w.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 Yn(t){var e={x:0,y:0},a,i,s,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,i=t.x,this.face===w.TOP)r=m-a,i>=I&&i<=m+I?(o.value=N.AREA_0,s=i-m):i>m+I||i<=-(m+I)?(o.value=N.AREA_1,s=i>0?i-R:i+R):i>-(m+I)&&i<=-I?(o.value=N.AREA_2,s=i+m):(o.value=N.AREA_3,s=i);else if(this.face===w.BOTTOM)r=m+a,i>=I&&i<=m+I?(o.value=N.AREA_0,s=-i+m):i<I&&i>=-I?(o.value=N.AREA_1,s=-i):i<-I&&i>=-(m+I)?(o.value=N.AREA_2,s=-i-m):(o.value=N.AREA_3,s=i>0?-i+R:-i-R);else{var l,u,f,c,M,d,y;this.face===w.RIGHT?i=It(i,+m):this.face===w.BACK?i=It(i,+R):this.face===w.LEFT&&(i=It(i,-m)),c=Math.sin(a),M=Math.cos(a),d=Math.sin(i),y=Math.cos(i),l=M*y,u=M*d,f=c,this.face===w.FRONT?(r=Math.acos(l),s=fe(r,f,u,o)):this.face===w.RIGHT?(r=Math.acos(u),s=fe(r,f,-l,o)):this.face===w.BACK?(r=Math.acos(-l),s=fe(r,f,-u,o)):this.face===w.LEFT?(r=Math.acos(-u),s=fe(r,f,l,o)):(r=s=0,o.value=N.AREA_0)}return h=Math.atan(12/R*(s+Math.acos(Math.sin(s)*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(s))))),o.value===N.AREA_1?h+=m:o.value===N.AREA_2?h+=R:o.value===N.AREA_3&&(h+=1.5*R),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 Zn(t){var e={lam:0,phi:0},a,i,s,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,i=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=N.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(f.value=N.AREA_1,a-=m):t.x<0&&-t.x>=Math.abs(t.y)?(f.value=N.AREA_2,a=a<0?a+R:a-R):(f.value=N.AREA_3,a+=m),u=R/12*Math.tan(a),n=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),h=Math.atan(n),s=Math.cos(a),r=Math.tan(i),o=1-s*s*r*r*(1-Math.cos(Math.atan(1/Math.cos(h)))),o<-1?o=-1:o>1&&(o=1),this.face===w.TOP)l=Math.acos(o),e.phi=m-l,f.value===N.AREA_0?e.lam=h+m:f.value===N.AREA_1?e.lam=h<0?h+R:h-R:f.value===N.AREA_2?e.lam=h-m:e.lam=h;else if(this.face===w.BOTTOM)l=Math.acos(o),e.phi=l-m,f.value===N.AREA_0?e.lam=-h+m:f.value===N.AREA_1?e.lam=-h:f.value===N.AREA_2?e.lam=-h-m:e.lam=h<0?-h-R:-h+R;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===N.AREA_1?(u=M,M=-d,d=u):f.value===N.AREA_2?(M=-M,d=-d):f.value===N.AREA_3&&(u=M,M=d,d=-u),this.face===w.RIGHT?(u=c,c=-M,M=u):this.face===w.BACK?(c=-c,M=-M):this.face===w.LEFT&&(u=c,c=M,M=-u),e.phi=Math.acos(-d)-m,e.lam=Math.atan2(M,c),this.face===w.RIGHT?e.lam=It(e.lam,-m):this.face===w.BACK?e.lam=It(e.lam,-R):this.face===w.LEFT&&(e.lam=It(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 fe(t,e,a,i){var s;return t<p?(i.value=N.AREA_0,s=0):(s=Math.atan2(e,a),Math.abs(s)<=I?i.value=N.AREA_0:s>I&&s<=m+I?(i.value=N.AREA_1,s-=m):s>m+I||s<=-(m+I)?(i.value=N.AREA_2,s=s>=0?s-R:s+R):(i.value=N.AREA_3,s+=m)),s}function It(t,e){var a=t+e;return a<-R?a+=Rt:a>+R&&(a-=Rt),a}var $n=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],us={init:Kn,forward:Yn,inverse:Zn,names:$n};var Le=[[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]],Ot=[[-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]],cs=.8487,ms=1.3523,Ms=V/5,th=1/Ms,At=18,ue=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},eh=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function ah(t,e,a,i){for(var s=e;i;--i){var r=t(s);if(s-=r,Math.abs(r)<a)break}return s}function sh(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function ih(t){var e=v(t.x-this.long0),a=Math.abs(t.y),i=Math.floor(a*Ms);i<0?i=0:i>=At&&(i=At-1),a=V*(a-th*i);var s={x:ue(Le[i],a)*e,y:ue(Ot[i],a)};return t.y<0&&(s.y=-s.y),s.x=s.x*this.a*cs+this.x0,s.y=s.y*this.a*ms+this.y0,s}function rh(t){var e={x:(t.x-this.x0)/(this.a*cs),y:Math.abs(t.y-this.y0)/(this.a*ms)};if(e.y>=1)e.x/=Le[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(Ot[a][0]>e.y)--a;else if(Ot[a+1][0]<=e.y)++a;else break;var i=Ot[a],s=5*(e.y-i[0])/(Ot[a+1][0]-i[0]);s=ah(function(r){return(ue(i,r)-e.y)/eh(i,r)},s,p,100),e.x/=ue(Le[a],s),e.y=(5*a+s)*L,t.y<0&&(e.y=-e.y)}return e.x=v(e.x+this.long0),e}var nh=["Robinson","robin"],ds={init:sh,forward:ih,inverse:rh,names:nh};function hh(){this.name="geocent"}function oh(t){var e=te(t,this.es,this.a);return e}function lh(t){var e=ee(t,this.es,this.a,this.b);return e}var fh=["Geocentric","geocentric","geocent","Geocent"],ps={init:hh,forward:oh,inverse:lh,names:fh};function vs(t){t.Proj.projections.add(Oa),t.Proj.projections.add(Et),t.Proj.projections.add(ja),t.Proj.projections.add(ka),t.Proj.projections.add(Ha),t.Proj.projections.add(Ua),t.Proj.projections.add(Wa),t.Proj.projections.add(Ja),t.Proj.projections.add(Xa),t.Proj.projections.add(Qa),t.Proj.projections.add(Va),t.Proj.projections.add(Ka),t.Proj.projections.add(Ya),t.Proj.projections.add($a),t.Proj.projections.add(ts),t.Proj.projections.add(as),t.Proj.projections.add(ss),t.Proj.projections.add(is),t.Proj.projections.add(rs),t.Proj.projections.add(ns),t.Proj.projections.add(hs),t.Proj.projections.add(os),t.Proj.projections.add(ls),t.Proj.projections.add(fs),t.Proj.projections.add(us),t.Proj.projections.add(ds),t.Proj.projections.add(ps)}H.defaultDatum="WGS84";H.Proj=lt;H.WGS84=new H.Proj("WGS84");H.Point=Ca;H.toPoint=se;H.defs=xt;H.transform=dt;H.mgrs=Sa;H.version="__VERSION__";vs(H);var Te=H;var Bt=class{static defineProjectionAliases(e){let a=[];for(let i in e)a.push([i,e[i]]);Te.defs(a)}constructor({from:e="WGS84",to:a="WGS84"}){if(this._projection=Te(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 De=100,ys=!1;function xs(t){let e=new DataView(t,0,De),i=Ut(e).length-De,s=new DataView(t,De,i),r=new Int32Array(i),n=new Int32Array(i);for(let h=0;h<i/8;h++)r[h]=s.getInt32(h*8,ys),n[h]=s.getInt32(h*8+4,ys);return{offsets:r,lengths:n}}async function*ce(t,e,a){let i=[],s=[],r=!1,n=!1;for(;!r&&!n;){if(i.length===0&&!r){let{value:o,done:l}=await t.next();l?r=!0:i.push(...o)}if(s.length===0&&!n){let{value:o,done:l}=await e.next();l?n=!0:s.push(...o)}let h=uh(i,s);h&&(yield{batchType:"data",shape:a,length:h.length,data:h})}}function uh(t,e){let a=Math.min(t.length,e.length);if(a===0)return null;let i=[t.slice(0,a),e.slice(0,a)];return t.splice(0,a),e.splice(0,a),i}var Oe=!0,gs=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 Me=class{binaryReader=new ot;textDecoder;state=q.START;result={data:[]};constructor(e){this.textDecoder=new TextDecoder(e.encoding)}write(e){this.binaryReader.write(e),this.state=_s(this.state,this.result,this.binaryReader,this.textDecoder)}end(){this.binaryReader.end(),this.state=_s(this.state,this.result,this.binaryReader,this.textDecoder),this.state!==q.END&&(this.state=q.ERROR,this.result.error="DBF incomplete file")}};function Be(t,e={}){let{encoding:a="latin1"}=e.dbf||{},i=new Me({encoding:a});i.write(t),i.end();let{data:s,schema:r}=i.result;switch(e?.dbf?.shape){case"object-row-table":return{shape:"object-row-table",schema:r,data:s};case"table":return{schema:r,rows:s};case"rows":default:return s}}async function*bs(t,e={}){let{encoding:a="latin1"}=e.dbf||{},i=new Me({encoding:a}),s=!1;for await(let r of t)i.write(r),!s&&i.result.dbfHeader&&(s=!0,yield i.result.dbfHeader),i.result.data.length>0&&(yield i.result.data,i.result.data=[]);i.end(),i.result.data.length>0&&(yield i.result.data)}function _s(t,e,a,i){for(;;)try{switch(t){case q.ERROR:case q.END:return t;case q.START:let s=a.getDataView(gs);if(!s)return t;e.dbfHeader=ch(s),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-gs);if(!r)return t;e.dbfFields=mh(r,i),e.schema={fields:e.dbfFields.map(o=>xh(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=Mh(o,e.dbfFields,i);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(s){return t=q.ERROR,e.error=`DBF parsing failed: ${s.message}`,t}}function ch(t){return{year:t.getUint8(1)+1900,month:t.getUint8(2),day:t.getUint8(3),nRecords:t.getUint32(4,Oe),headerLength:t.getUint16(8,Oe),recordLength:t.getUint16(10,Oe),languageDriver:t.getUint8(29)}}function mh(t,e){let a=(t.byteLength-1)/32,i=[],s=0;for(let r=0;r<a;r++){let n=e.decode(new Uint8Array(t.buffer,t.byteOffset+s,11)).replace(/\u0000/g,"");i.push({name:n,dataType:String.fromCharCode(t.getUint8(s+11)),fieldLength:t.getUint8(s+16),decimal:t.getUint8(s+17)}),s+=32}return i}function Mh(t,e,a){let i={},s=0;for(let r of e){let n=a.decode(new Uint8Array(t.buffer,t.byteOffset+s,r.fieldLength));i[r.name]=dh(n,r.dataType),s+=r.fieldLength}return i}function dh(t,e){switch(e){case"B":return me(t);case"C":return yh(t);case"F":return me(t);case"N":return me(t);case"O":return me(t);case"D":return ph(t);case"L":return vh(t);default:throw new Error("Unsupported data type")}}function ph(t){return Date.UTC(t.slice(0,4),parseInt(t.slice(4,6),10)-1,t.slice(6,8))}function vh(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 yh(t){return t.trim()||null}function xh({name:t,dataType:e,fieldLength:a,decimal:i}){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 gh="4.3.1",Ge={name:"DBF",dataType:null,batchType:null,id:"dbf",module:"shapefile",version:gh,worker:!0,category:"table",extensions:["dbf"],mimeTypes:["application/x-dbf"],options:{dbf:{encoding:"latin1"}}},Gt={...Ge,parse:async(t,e)=>Be(t,e),parseSync:Be,parseInBatches(t,e){return bs(t,e)}};async function*Es(t,e,a){let{reproject:i=!1,_targetCrs:s="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Ss(e,a),o=await Xt(t,Nt,e,a),l=o[Symbol.asyncIterator]?.()||o[Symbol.iterator]?.(),u=null,f=await a?.fetch(Ft(a?.url||"","dbf"));if(f?.ok){let x=await Xt(f,Gt,{...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?ce(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=As(g),S=Ps(E,b);i&&(S=Ns(S,h,s)),yield{encoding:n,prj:h,shx:r,header:c,data:S}}}async function Is(t,e,a){let{reproject:i=!1,_targetCrs:s="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Ss(e,a),{header:o,geometries:l}=await Jt(t,Nt,e,a),u=As(l),f,c=await a?.fetch(Ft(a?.url,"dbf"));c?.ok&&(f=await Jt(c,Gt,{dbf:{shape:"object-row-table",encoding:n||"latin1"}},a));let M=Ps(u,f?.data||[]);switch(i&&(M=Ns(M,h,s)),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 As(t){let e=[];for(let a of t)e.push(_e(a));return e}function Ps(t,e){let a=[];for(let i=0;i<t.length;i++){let r={type:"Feature",geometry:t[i],properties:e&&e[i]||{}};a.push(r)}return a}function Ns(t,e,a){if(!e&&!a)return t;let i=new Bt({from:e||"WGS84",to:a||"WGS84"});return be(t,s=>i.project(s))}async function Ss(t,e){let{url:a,fetch:i}=e,s=i(Ft(a,"shx")),r=i(Ft(a,"cpg")),n=i(Ft(a,"prj"));await Promise.all([s,r,n]);let h,o,l,u=await s;if(u.ok){let M=await u.arrayBuffer();h=xs(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 Ft(t,e){let a=_h(t),i=bh(t);return i===i.toUpperCase()&&(e=e.toUpperCase()),`${a}.${e}`}function _h(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(0,e):"":e}function bh(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(e+1):"":e}var Eh="4.3.1",Rs={name:"Shapefile",id:"shapefile",module:"shapefile",version:Eh,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(xe).buffer],options:{shapefile:{shape:"v3"},shp:{_maxDimensions:4}},parse:Is,parseInBatches:Es};var de=class{offset;arrayBuffer;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 qs(qt);})();
11
11
  return __exports__;
12
12
  });
package/dist/index.cjs CHANGED
@@ -516,7 +516,7 @@ function parseState(state, result, binaryReader, options) {
516
516
  }
517
517
 
518
518
  // dist/shp-loader.js
519
- var VERSION = true ? "4.3.0" : "latest";
519
+ var VERSION = true ? "4.3.1" : "latest";
520
520
  var SHP_MAGIC_NUMBER2 = [0, 0, 39, 10];
521
521
  var SHPWorkerLoader = {
522
522
  dataType: null,
@@ -854,7 +854,7 @@ function makeField({ name, dataType, fieldLength, decimal }) {
854
854
  }
855
855
 
856
856
  // dist/dbf-loader.js
857
- var VERSION2 = true ? "4.3.0" : "latest";
857
+ var VERSION2 = true ? "4.3.1" : "latest";
858
858
  var DBFWorkerLoader = {
859
859
  name: "DBF",
860
860
  dataType: null,
@@ -1055,7 +1055,7 @@ function extname(url) {
1055
1055
  }
1056
1056
 
1057
1057
  // dist/shapefile-loader.js
1058
- var VERSION3 = true ? "4.3.0" : "latest";
1058
+ var VERSION3 = true ? "4.3.1" : "latest";
1059
1059
  var ShapefileLoader = {
1060
1060
  name: "Shapefile",
1061
1061
  id: "shapefile",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "lib/streaming/binary-chunk-reader.js", "lib/parsers/parse-shp-header.js", "lib/parsers/parse-shp-geometry.js", "lib/parsers/parse-shp.js", "shp-loader.js", "lib/parsers/parse-shapefile.js", "lib/parsers/parse-shx.js", "lib/streaming/zip-batch-iterators.js", "lib/parsers/parse-dbf.js", "dbf-loader.js", "shapefile-loader.js", "lib/streaming/binary-reader.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { ShapefileLoader } from \"./shapefile-loader.js\";\nexport { DBFLoader, DBFWorkerLoader } from \"./dbf-loader.js\";\nexport { SHPLoader, SHPWorkerLoader } from \"./shp-loader.js\";\n// EXPERIMENTAL\nexport { BinaryReader as _BinaryReader } from \"./lib/streaming/binary-reader.js\";\nexport { BinaryChunkReader as _BinaryChunkReader } from \"./lib/streaming/binary-chunk-reader.js\";\nexport { zipBatchIterators as _zipBatchIterators } from \"./lib/streaming/zip-batch-iterators.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport class BinaryChunkReader {\n offset;\n arrayBuffers;\n ended;\n maxRewindBytes;\n constructor(options) {\n const { maxRewindBytes = 0 } = options || {};\n /** current global offset into current array buffer*/\n this.offset = 0;\n /** current buffer from iterator */\n this.arrayBuffers = [];\n this.ended = false;\n /** bytes behind offset to hold on to */\n this.maxRewindBytes = maxRewindBytes;\n }\n /**\n * @param arrayBuffer\n */\n write(arrayBuffer) {\n this.arrayBuffers.push(arrayBuffer);\n }\n end() {\n this.arrayBuffers = [];\n this.ended = true;\n }\n /**\n * Has enough bytes available in array buffers\n *\n * @param bytes Number of bytes\n * @return boolean\n */\n hasAvailableBytes(bytes) {\n let bytesAvailable = -this.offset;\n for (const arrayBuffer of this.arrayBuffers) {\n bytesAvailable += arrayBuffer.byteLength;\n if (bytesAvailable >= bytes) {\n return true;\n }\n }\n return false;\n }\n /**\n * Find offsets of byte ranges within this.arrayBuffers\n *\n * @param bytes Byte length to read\n * @return Arrays with byte ranges pointing to this.arrayBuffers, Output type is nested array, e.g. [ [0, [1, 2]], ...]\n */\n findBufferOffsets(bytes) {\n let offset = -this.offset;\n const selectedBuffers = [];\n for (let i = 0; i < this.arrayBuffers.length; i++) {\n const buf = this.arrayBuffers[i];\n // Current buffer isn't long enough to reach global offset\n if (offset + buf.byteLength <= 0) {\n offset += buf.byteLength;\n // eslint-disable-next-line no-continue\n continue;\n }\n // Find start/end offsets for this buffer\n // When offset < 0, need to skip over Math.abs(offset) bytes\n // When offset > 0, implies bytes in previous buffer, start at 0\n const start = offset <= 0 ? Math.abs(offset) : 0;\n let end;\n // Length of requested bytes is contained in current buffer\n if (start + bytes <= buf.byteLength) {\n end = start + bytes;\n selectedBuffers.push([i, [start, end]]);\n return selectedBuffers;\n }\n // Will need to look into next buffer\n end = buf.byteLength;\n selectedBuffers.push([i, [start, end]]);\n // Need to read fewer bytes in next iter\n bytes -= buf.byteLength - start;\n offset += buf.byteLength;\n }\n // Should only finish loop if exhausted all arrays\n return null;\n }\n /**\n * Get the required number of bytes from the iterator\n *\n * @param bytes Number of bytes\n * @return DataView with data\n */\n getDataView(bytes) {\n const bufferOffsets = this.findBufferOffsets(bytes);\n // return `null` if not enough data, except if end() already called, in\n // which case throw an error.\n if (!bufferOffsets && this.ended) {\n throw new Error('binary data exhausted');\n }\n if (!bufferOffsets) {\n return null;\n }\n // If only one arrayBuffer needed, return DataView directly\n if (bufferOffsets.length === 1) {\n const [bufferIndex, [start, end]] = bufferOffsets[0];\n const arrayBuffer = this.arrayBuffers[bufferIndex];\n const view = new DataView(arrayBuffer, start, end - start);\n this.offset += bytes;\n this.disposeBuffers();\n return view;\n }\n // Concatenate portions of multiple ArrayBuffers\n const view = new DataView(this._combineArrayBuffers(bufferOffsets));\n this.offset += bytes;\n this.disposeBuffers();\n return view;\n }\n /**\n * Dispose of old array buffers\n */\n disposeBuffers() {\n while (this.arrayBuffers.length > 0 &&\n this.offset - this.maxRewindBytes >= this.arrayBuffers[0].byteLength) {\n this.offset -= this.arrayBuffers[0].byteLength;\n this.arrayBuffers.shift();\n }\n }\n /**\n * Copy multiple ArrayBuffers into one contiguous ArrayBuffer\n *\n * In contrast to concatenateArrayBuffers, this only copies the necessary\n * portions of the source arrays, rather than first copying the entire arrays\n * then taking a part of them.\n *\n * @param bufferOffsets List of internal array offsets\n * @return New contiguous ArrayBuffer\n */\n _combineArrayBuffers(bufferOffsets) {\n let byteLength = 0;\n for (const bufferOffset of bufferOffsets) {\n const [start, end] = bufferOffset[1];\n byteLength += end - start;\n }\n const result = new Uint8Array(byteLength);\n // Copy the subarrays\n let resultOffset = 0;\n for (const bufferOffset of bufferOffsets) {\n const [bufferIndex, [start, end]] = bufferOffset;\n const sourceArray = new Uint8Array(this.arrayBuffers[bufferIndex]);\n result.set(sourceArray.subarray(start, end), resultOffset);\n resultOffset += end - start;\n }\n return result.buffer;\n }\n /**\n * @param bytes\n */\n skip(bytes) {\n this.offset += bytes;\n }\n /**\n * @param bytes\n */\n rewind(bytes) {\n // TODO - only works if offset is already set\n this.offset -= bytes;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst LITTLE_ENDIAN = true;\nconst BIG_ENDIAN = false;\nconst SHP_MAGIC_NUMBER = 0x0000270a;\n/**\n * Extract the binary header\n * Note: Also used by SHX\n * @param headerView\n * @returns SHPHeader\n */\nexport function parseSHPHeader(headerView) {\n // Note: The SHP format switches endianness between fields!\n // https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf\n const header = {\n magic: headerView.getInt32(0, BIG_ENDIAN),\n // Length is stored as # of 2-byte words; multiply by 2 to get # of bytes\n length: headerView.getInt32(24, BIG_ENDIAN) * 2,\n version: headerView.getInt32(28, LITTLE_ENDIAN),\n type: headerView.getInt32(32, LITTLE_ENDIAN),\n bbox: {\n minX: headerView.getFloat64(36, LITTLE_ENDIAN),\n minY: headerView.getFloat64(44, LITTLE_ENDIAN),\n minZ: headerView.getFloat64(68, LITTLE_ENDIAN),\n minM: headerView.getFloat64(84, LITTLE_ENDIAN),\n maxX: headerView.getFloat64(52, LITTLE_ENDIAN),\n maxY: headerView.getFloat64(60, LITTLE_ENDIAN),\n maxZ: headerView.getFloat64(76, LITTLE_ENDIAN),\n maxM: headerView.getFloat64(92, LITTLE_ENDIAN)\n }\n };\n if (header.magic !== SHP_MAGIC_NUMBER) {\n // eslint-disable-next-line\n console.error(`SHP file: bad magic number ${header.magic}`);\n }\n if (header.version !== 1000) {\n // eslint-disable-next-line\n console.error(`SHP file: bad version ${header.version}`);\n }\n return header;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst LITTLE_ENDIAN = true;\n/**\n * Parse individual record\n *\n * @param view Record data\n * @return Binary Geometry Object\n */\n// eslint-disable-next-line complexity\nexport function parseRecord(view, options) {\n const { _maxDimensions = 4 } = options?.shp || {};\n let offset = 0;\n const type = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n switch (type) {\n case 0:\n // Null Shape\n return parseNull();\n case 1:\n // Point\n return parsePoint(view, offset, Math.min(2, _maxDimensions));\n case 3:\n // PolyLine\n return parsePoly(view, offset, Math.min(2, _maxDimensions), 'LineString');\n case 5:\n // Polygon\n return parsePoly(view, offset, Math.min(2, _maxDimensions), 'Polygon');\n case 8:\n // MultiPoint\n return parseMultiPoint(view, offset, Math.min(2, _maxDimensions));\n // GeometryZ can have 3 or 4 dimensions, since the M is not required to\n // exist\n case 11:\n // PointZ\n return parsePoint(view, offset, Math.min(4, _maxDimensions));\n case 13:\n // PolyLineZ\n return parsePoly(view, offset, Math.min(4, _maxDimensions), 'LineString');\n case 15:\n // PolygonZ\n return parsePoly(view, offset, Math.min(4, _maxDimensions), 'Polygon');\n case 18:\n // MultiPointZ\n return parseMultiPoint(view, offset, Math.min(4, _maxDimensions));\n case 21:\n // PointM\n return parsePoint(view, offset, Math.min(3, _maxDimensions));\n case 23:\n // PolyLineM\n return parsePoly(view, offset, Math.min(3, _maxDimensions), 'LineString');\n case 25:\n // PolygonM\n return parsePoly(view, offset, Math.min(3, _maxDimensions), 'Polygon');\n case 28:\n // MultiPointM\n return parseMultiPoint(view, offset, Math.min(3, _maxDimensions));\n default:\n throw new Error(`unsupported shape type: ${type}`);\n }\n}\n// TODO handle null\n/**\n * Parse Null geometry\n *\n * @return null\n */\nfunction parseNull() {\n return null;\n}\n/**\n * Parse point geometry\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param dim Dimension size\n */\nfunction parsePoint(view, offset, dim) {\n let positions;\n [positions, offset] = parsePositions(view, offset, 1, dim);\n return {\n positions: { value: positions, size: dim },\n type: 'Point'\n };\n}\n/**\n * Parse MultiPoint geometry\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param dim Input dimension\n * @return Binary geometry object\n */\nfunction parseMultiPoint(view, offset, dim) {\n // skip parsing box\n offset += 4 * Float64Array.BYTES_PER_ELEMENT;\n const nPoints = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n let xyPositions = null;\n let mPositions = null;\n let zPositions = null;\n [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);\n // Parse Z coordinates\n if (dim === 4) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [zPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n // Parse M coordinates\n if (dim >= 3) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [mPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n const positions = concatPositions(xyPositions, mPositions, zPositions);\n return {\n positions: { value: positions, size: dim },\n type: 'Point'\n };\n}\n/**\n * Polygon and PolyLine parsing\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param dim Input dimension\n * @param type Either 'Polygon' or 'Polyline'\n * @return Binary geometry object\n */\n// eslint-disable-next-line max-statements\nfunction parsePoly(view, offset, dim, type) {\n // skip parsing bounding box\n offset += 4 * Float64Array.BYTES_PER_ELEMENT;\n const nParts = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n const nPoints = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n // Create longer indices array by 1 because output format is expected to\n // include the last index as the total number of positions\n const bufferOffset = view.byteOffset + offset;\n const bufferLength = nParts * Int32Array.BYTES_PER_ELEMENT;\n const ringIndices = new Int32Array(nParts + 1);\n ringIndices.set(new Int32Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)));\n ringIndices[nParts] = nPoints;\n offset += nParts * Int32Array.BYTES_PER_ELEMENT;\n let xyPositions = null;\n let mPositions = null;\n let zPositions = null;\n [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);\n // Parse Z coordinates\n if (dim === 4) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [zPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n // Parse M coordinates\n if (dim >= 3) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [mPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n const positions = concatPositions(xyPositions, mPositions, zPositions);\n // parsePoly only accepts type = LineString or Polygon\n if (type === 'LineString') {\n return {\n type,\n positions: { value: positions, size: dim },\n pathIndices: { value: ringIndices, size: 1 }\n };\n }\n // for every ring, determine sign of polygon\n // Use only 2D positions for ring calc\n const polygonIndices = [];\n for (let i = 1; i < ringIndices.length; i++) {\n const startRingIndex = ringIndices[i - 1];\n const endRingIndex = ringIndices[i];\n // @ts-ignore\n const ring = xyPositions.subarray(startRingIndex * 2, endRingIndex * 2);\n const sign = getWindingDirection(ring);\n // A positive sign implies clockwise\n // A clockwise ring is a filled ring\n if (sign > 0) {\n polygonIndices.push(startRingIndex);\n }\n }\n polygonIndices.push(nPoints);\n return {\n type,\n positions: { value: positions, size: dim },\n primitivePolygonIndices: { value: ringIndices, size: 1 },\n // TODO: Dynamically choose Uint32Array over Uint16Array only when\n // necessary. I believe the implementation requires nPoints to be the\n // largest value in the array, so you should be able to use Uint32Array only\n // when nPoints > 65535.\n polygonIndices: { value: new Uint32Array(polygonIndices), size: 1 }\n };\n}\n/**\n * Parse a contiguous block of positions into a Float64Array\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param nPoints Number of points\n * @param dim Input dimension\n * @return Data and offset\n */\nfunction parsePositions(view, offset, nPoints, dim) {\n const bufferOffset = view.byteOffset + offset;\n const bufferLength = nPoints * dim * Float64Array.BYTES_PER_ELEMENT;\n return [\n new Float64Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)),\n offset + bufferLength\n ];\n}\n/**\n * Concatenate and interleave positions arrays\n * xy positions are interleaved; mPositions, zPositions are their own arrays\n *\n * @param xyPositions 2d positions\n * @param mPositions M positions\n * @param zPositions Z positions\n * @return Combined interleaved positions\n */\n// eslint-disable-next-line complexity\nfunction concatPositions(xyPositions, mPositions, zPositions) {\n if (!(mPositions || zPositions)) {\n return xyPositions;\n }\n let arrayLength = xyPositions.length;\n let nDim = 2;\n if (zPositions && zPositions.length) {\n arrayLength += zPositions.length;\n nDim++;\n }\n if (mPositions && mPositions.length) {\n arrayLength += mPositions.length;\n nDim++;\n }\n const positions = new Float64Array(arrayLength);\n for (let i = 0; i < xyPositions.length / 2; i++) {\n positions[nDim * i] = xyPositions[i * 2];\n positions[nDim * i + 1] = xyPositions[i * 2 + 1];\n }\n if (zPositions && zPositions.length) {\n for (let i = 0; i < zPositions.length; i++) {\n // If Z coordinates exist; used as third coord in positions array\n positions[nDim * i + 2] = zPositions[i];\n }\n }\n if (mPositions && mPositions.length) {\n for (let i = 0; i < mPositions.length; i++) {\n // M is always last, either 3rd or 4th depending on if Z exists\n positions[nDim * i + (nDim - 1)] = mPositions[i];\n }\n }\n return positions;\n}\n/**\n * Returns the direction of the polygon path\n * A positive number is clockwise.\n * A negative number is counter clockwise.\n *\n * @param positions\n * @return Sign of polygon ring\n */\nfunction getWindingDirection(positions) {\n return Math.sign(getSignedArea(positions));\n}\n/**\n * Get signed area of flat typed array of 2d positions\n *\n * @param positions\n * @return Signed area of polygon ring\n */\nfunction getSignedArea(positions) {\n let area = 0;\n // Rings are closed according to shapefile spec\n const nCoords = positions.length / 2 - 1;\n for (let i = 0; i < nCoords; i++) {\n area +=\n (positions[i * 2] + positions[(i + 1) * 2]) *\n (positions[i * 2 + 1] - positions[(i + 1) * 2 + 1]);\n }\n return area / 2;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { BinaryChunkReader } from \"../streaming/binary-chunk-reader.js\";\nimport { parseSHPHeader } from \"./parse-shp-header.js\";\nimport { parseRecord } from \"./parse-shp-geometry.js\";\nconst LITTLE_ENDIAN = true;\nconst BIG_ENDIAN = false;\nconst SHP_HEADER_SIZE = 100;\n// According to the spec, the record header is just 8 bytes, but here we set it\n// to 12 so that we can also access the record's type\nconst SHP_RECORD_HEADER_SIZE = 12;\nconst STATE = {\n EXPECTING_HEADER: 0,\n EXPECTING_RECORD: 1,\n END: 2,\n ERROR: 3\n};\nclass SHPParser {\n options = {};\n binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });\n state = STATE.EXPECTING_HEADER;\n result = {\n geometries: [],\n // Initialize with number values to make TS happy\n // These are initialized for real in STATE.EXPECTING_HEADER\n progress: {\n bytesTotal: NaN,\n bytesUsed: NaN,\n rows: NaN\n },\n currentIndex: NaN\n };\n constructor(options) {\n this.options = options;\n }\n write(arrayBuffer) {\n this.binaryReader.write(arrayBuffer);\n this.state = parseState(this.state, this.result, this.binaryReader, this.options);\n }\n end() {\n this.binaryReader.end();\n this.state = parseState(this.state, this.result, this.binaryReader, this.options);\n // this.result.progress.bytesUsed = this.binaryReader.bytesUsed();\n if (this.state !== STATE.END) {\n this.state = STATE.ERROR;\n this.result.error = 'SHP incomplete file';\n }\n }\n}\nexport function parseSHP(arrayBuffer, options) {\n const shpParser = new SHPParser(options);\n shpParser.write(arrayBuffer);\n shpParser.end();\n // @ts-ignore\n return shpParser.result;\n}\n/**\n * @param asyncIterator\n * @param options\n * @returns\n */\nexport async function* parseSHPInBatches(asyncIterator, options) {\n const parser = new SHPParser(options);\n let headerReturned = false;\n for await (const arrayBuffer of asyncIterator) {\n parser.write(arrayBuffer);\n if (!headerReturned && parser.result.header) {\n headerReturned = true;\n yield parser.result.header;\n }\n if (parser.result.geometries.length > 0) {\n yield parser.result.geometries;\n parser.result.geometries = [];\n }\n }\n parser.end();\n if (parser.result.geometries.length > 0) {\n yield parser.result.geometries;\n }\n return;\n}\n/**\n * State-machine parser for SHP data\n *\n * Note that whenever more data is needed, a `return`, not a `break`, is\n * necessary, as the `break` keeps the context within `parseState`, while\n * `return` releases context so that more data can be written into the\n * BinaryChunkReader.\n *\n * @param state Current state\n * @param result An object to hold result data\n * @param binaryReader\n * @return State at end of current parsing\n */\n/* eslint-disable complexity, max-depth */\nfunction parseState(state, result, binaryReader, options) {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n switch (state) {\n case STATE.ERROR:\n case STATE.END:\n return state;\n case STATE.EXPECTING_HEADER:\n // Parse initial file header\n const dataView = binaryReader.getDataView(SHP_HEADER_SIZE);\n if (!dataView) {\n return state;\n }\n result.header = parseSHPHeader(dataView);\n result.progress = {\n bytesUsed: 0,\n bytesTotal: result.header.length,\n rows: 0\n };\n // index numbering starts at 1\n result.currentIndex = 1;\n state = STATE.EXPECTING_RECORD;\n break;\n case STATE.EXPECTING_RECORD:\n while (binaryReader.hasAvailableBytes(SHP_RECORD_HEADER_SIZE)) {\n const recordHeaderView = binaryReader.getDataView(SHP_RECORD_HEADER_SIZE);\n const recordHeader = {\n recordNumber: recordHeaderView.getInt32(0, BIG_ENDIAN),\n // 2 byte words; includes the four words of record header\n byteLength: recordHeaderView.getInt32(4, BIG_ENDIAN) * 2,\n // This is actually part of the record, not the header...\n type: recordHeaderView.getInt32(8, LITTLE_ENDIAN)\n };\n if (!binaryReader.hasAvailableBytes(recordHeader.byteLength - 4)) {\n binaryReader.rewind(SHP_RECORD_HEADER_SIZE);\n return state;\n }\n const invalidRecord = recordHeader.byteLength < 4 ||\n recordHeader.type !== result.header?.type ||\n recordHeader.recordNumber !== result.currentIndex;\n // All records must have at least four bytes (for the record shape type)\n if (invalidRecord) {\n // Malformed record, try again, advancing just 4 bytes\n // Note: this is a rewind because binaryReader.getDataView above\n // moved the pointer forward 12 bytes, so rewinding 8 bytes still\n // leaves us 4 bytes ahead\n binaryReader.rewind(SHP_RECORD_HEADER_SIZE - 4);\n }\n else {\n // Note: type is actually part of the record, not the header, so\n // rewind 4 bytes before reading record\n binaryReader.rewind(4);\n const recordView = binaryReader.getDataView(recordHeader.byteLength);\n const geometry = parseRecord(recordView, options);\n result.geometries.push(geometry);\n result.currentIndex++;\n result.progress.rows = result.currentIndex - 1;\n }\n }\n if (binaryReader.ended) {\n state = STATE.END;\n }\n return state;\n default:\n state = STATE.ERROR;\n result.error = `illegal parser state ${state}`;\n return state;\n }\n }\n catch (error) {\n state = STATE.ERROR;\n result.error = `SHP parsing failed: ${error?.message}`;\n return state;\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseSHP, parseSHPInBatches } from \"./lib/parsers/parse-shp.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0\" !== 'undefined' ? \"4.3.0\" : 'latest';\nexport const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];\n/**\n * SHP file loader\n */\nexport const SHPWorkerLoader = {\n dataType: null,\n batchType: null,\n name: 'SHP',\n id: 'shp',\n module: 'shapefile',\n version: VERSION,\n worker: true,\n category: 'geometry',\n extensions: ['shp'],\n mimeTypes: ['application/octet-stream'],\n // ISSUE: This also identifies SHX files, which are identical to SHP for the first 100 bytes...\n tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],\n options: {\n shp: {\n _maxDimensions: 4\n }\n }\n};\n/** SHP file loader */\nexport const SHPLoader = {\n ...SHPWorkerLoader,\n parse: async (arrayBuffer, options) => parseSHP(arrayBuffer, options),\n parseSync: parseSHP,\n parseInBatches: (arrayBufferIterator, options) => parseSHPInBatches(arrayBufferIterator, options)\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// import type {Feature} from '@loaders.gl/gis';\nimport { parseInBatchesFromContext, parseFromContext } from '@loaders.gl/loader-utils';\nimport { binaryToGeometry, transformGeoJsonCoords } from '@loaders.gl/gis';\nimport { Proj4Projection } from '@math.gl/proj4';\nimport { parseShx } from \"./parse-shx.js\";\nimport { zipBatchIterators } from \"../streaming/zip-batch-iterators.js\";\nimport { SHPLoader } from \"../../shp-loader.js\";\nimport { DBFLoader } from \"../../dbf-loader.js\";\n/**\n * Parsing of file in batches\n */\n// eslint-disable-next-line max-statements, complexity\nexport async function* parseShapefileInBatches(asyncIterator, options, context) {\n const { reproject = false, _targetCrs = 'WGS84' } = options?.gis || {};\n const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);\n // parse geometries\n const shapeIterable = await parseInBatchesFromContext(asyncIterator, SHPLoader, options, context);\n const shapeIterator = shapeIterable[Symbol.asyncIterator]?.() || shapeIterable[Symbol.iterator]?.();\n // parse properties\n let propertyIterator = null;\n const dbfResponse = await context?.fetch(replaceExtension(context?.url || '', 'dbf'));\n if (dbfResponse?.ok) {\n const propertyIterable = await parseInBatchesFromContext(dbfResponse, DBFLoader, {\n ...options,\n dbf: { encoding: cpg || 'latin1' }\n }, context);\n propertyIterator =\n propertyIterable[Symbol.asyncIterator]?.() || propertyIterable[Symbol.iterator]();\n }\n // When `options.metadata` is `true`, there's an extra initial `metadata`\n // object before the iterator starts. zipBatchIterators expects to receive\n // batches of Array objects, and will fail with non-iterable batches, so it's\n // important to skip over the first batch.\n let shapeHeader = (await shapeIterator.next()).value;\n if (shapeHeader && shapeHeader.batchType === 'metadata') {\n shapeHeader = (await shapeIterator.next()).value;\n }\n let dbfHeader = {};\n if (propertyIterator) {\n dbfHeader = (await propertyIterator.next()).value;\n if (dbfHeader && dbfHeader.batchType === 'metadata') {\n dbfHeader = (await propertyIterator.next()).value;\n }\n }\n const zippedIterator = propertyIterator\n ? zipBatchIterators(shapeIterator, propertyIterator, 'object-row-table')\n : shapeIterator;\n const zippedBatchIterable = {\n [Symbol.asyncIterator]() {\n return zippedIterator;\n }\n };\n for await (const batch of zippedBatchIterable) {\n let geometries;\n let properties;\n if (!propertyIterator) {\n geometries = batch;\n }\n else {\n [geometries, properties] = batch.data;\n }\n const geojsonGeometries = parseGeometries(geometries);\n let features = joinProperties(geojsonGeometries, properties);\n if (reproject) {\n // @ts-ignore\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n yield {\n encoding: cpg,\n prj,\n shx,\n header: shapeHeader,\n data: features\n };\n }\n}\n/**\n * Parse shapefile\n *\n * @param arrayBuffer\n * @param options\n * @param context\n * @returns output of shapefile\n */\nexport async function parseShapefile(arrayBuffer, options, context) {\n const { reproject = false, _targetCrs = 'WGS84' } = options?.gis || {};\n const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);\n // parse geometries\n const { header, geometries } = await parseFromContext(arrayBuffer, SHPLoader, options, context); // {shp: shx}\n const geojsonGeometries = parseGeometries(geometries);\n // parse properties\n let propertyTable;\n const dbfResponse = await context?.fetch(replaceExtension(context?.url, 'dbf'));\n if (dbfResponse?.ok) {\n propertyTable = await parseFromContext(dbfResponse, DBFLoader, { dbf: { shape: 'object-row-table', encoding: cpg || 'latin1' } }, context);\n }\n let features = joinProperties(geojsonGeometries, propertyTable?.data || []);\n if (reproject) {\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n switch (options?.shapefile?.shape) {\n case 'geojson-table':\n return {\n // @ts-expect-error\n shape: 'geojson-table',\n type: 'FeatureCollection',\n encoding: cpg,\n schema: propertyTable?.schema || { metadata: {}, fields: [] },\n prj,\n shx,\n header,\n features\n };\n default:\n return {\n encoding: cpg,\n prj,\n shx,\n header,\n data: features\n };\n }\n}\n/**\n * Parse geometries\n *\n * @param geometries\n * @returns geometries as an array\n */\nfunction parseGeometries(geometries) {\n const geojsonGeometries = [];\n for (const geom of geometries) {\n geojsonGeometries.push(binaryToGeometry(geom));\n }\n return geojsonGeometries;\n}\n/**\n * Join properties and geometries into features\n *\n * @param geometries [description]\n * @param properties [description]\n * @return [description]\n */\nfunction joinProperties(geometries, properties) {\n const features = [];\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n const feature = {\n type: 'Feature',\n geometry,\n // properties can be undefined if dbfResponse above was empty\n properties: (properties && properties[i]) || {}\n };\n features.push(feature);\n }\n return features;\n}\n/**\n * Reproject GeoJSON features to output CRS\n *\n * @param features parsed GeoJSON features\n * @param sourceCrs source coordinate reference system\n * @param targetCrs \u2020arget coordinate reference system\n * @return Reprojected Features\n */\nfunction reprojectFeatures(features, sourceCrs, targetCrs) {\n if (!sourceCrs && !targetCrs) {\n return features;\n }\n const projection = new Proj4Projection({ from: sourceCrs || 'WGS84', to: targetCrs || 'WGS84' });\n return transformGeoJsonCoords(features, (coord) => projection.project(coord));\n}\n/**\n *\n * @param options\n * @param context\n * @returns Promise\n */\n// eslint-disable-next-line max-statements\nexport async function loadShapefileSidecarFiles(options, context) {\n // Attempt a parallel load of the small sidecar files\n // @ts-ignore context must be defined\n const { url, fetch } = context;\n const shxPromise = fetch(replaceExtension(url, 'shx'));\n const cpgPromise = fetch(replaceExtension(url, 'cpg'));\n const prjPromise = fetch(replaceExtension(url, 'prj'));\n await Promise.all([shxPromise, cpgPromise, prjPromise]);\n let shx;\n let cpg;\n let prj;\n const shxResponse = await shxPromise;\n if (shxResponse.ok) {\n const arrayBuffer = await shxResponse.arrayBuffer();\n shx = parseShx(arrayBuffer);\n }\n const cpgResponse = await cpgPromise;\n if (cpgResponse.ok) {\n cpg = await cpgResponse.text();\n }\n const prjResponse = await prjPromise;\n if (prjResponse.ok) {\n prj = await prjResponse.text();\n }\n return {\n shx,\n cpg,\n prj\n };\n}\n/**\n * Replace the extension at the end of a path.\n *\n * Matches the case of new extension with the case of the original file extension,\n * to increase the chance of finding files without firing off a request storm looking for various case combinations\n *\n * NOTE: Extensions can be both lower and uppercase\n * per spec, extensions should be lower case, but that doesn't mean they always are. See:\n * calvinmetcalf/shapefile-js#64, mapserver/mapserver#4712\n * https://trac.osgeo.org/mapserver/ticket/166\n */\nexport function replaceExtension(url, newExtension) {\n const baseName = basename(url);\n const extension = extname(url);\n const isUpperCase = extension === extension.toUpperCase();\n if (isUpperCase) {\n newExtension = newExtension.toUpperCase();\n }\n return `${baseName}.${newExtension}`;\n}\n// NOTE - this gives the entire path minus extension (i.e. NOT same as path.basename)\n/**\n * @param url\n * @returns string\n */\nfunction basename(url) {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(0, extIndex) : '';\n }\n return extIndex;\n}\n/**\n * @param url\n * @returns string\n */\nfunction extname(url) {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(extIndex + 1) : '';\n }\n return extIndex;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseSHPHeader } from \"./parse-shp-header.js\";\nconst SHX_HEADER_SIZE = 100;\nconst BIG_ENDIAN = false;\n/**\n * @param arrayBuffer\n * @returns SHXOutput\n */\nexport function parseShx(arrayBuffer) {\n // SHX header is identical to SHP Header\n const headerView = new DataView(arrayBuffer, 0, SHX_HEADER_SIZE);\n const header = parseSHPHeader(headerView);\n const contentLength = header.length - SHX_HEADER_SIZE;\n const contentView = new DataView(arrayBuffer, SHX_HEADER_SIZE, contentLength);\n const offsets = new Int32Array(contentLength);\n const lengths = new Int32Array(contentLength);\n for (let i = 0; i < contentLength / 8; i++) {\n offsets[i] = contentView.getInt32(i * 8, BIG_ENDIAN);\n lengths[i] = contentView.getInt32(i * 8 + 4, BIG_ENDIAN);\n }\n return {\n offsets,\n lengths\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Zip two iterators together\n *\n * @param iterator1\n * @param iterator2\n */\nexport async function* zipBatchIterators(iterator1, iterator2, shape) {\n const batch1Data = [];\n const batch2Data = [];\n let iterator1Done = false;\n let iterator2Done = false;\n // TODO - one could let all iterators flow at full speed using `Promise.race`\n // however we might end up with a big temporary buffer\n while (!iterator1Done && !iterator2Done) {\n if (batch1Data.length === 0 && !iterator1Done) {\n const { value, done } = await iterator1.next();\n if (done) {\n iterator1Done = true;\n }\n else {\n // @ts-expect-error\n batch1Data.push(...value);\n }\n }\n if (batch2Data.length === 0 && !iterator2Done) {\n const { value, done } = await iterator2.next();\n if (done) {\n iterator2Done = true;\n }\n else {\n batch2Data.push(...value);\n }\n }\n const batchData = extractBatchData(batch1Data, batch2Data);\n if (batchData) {\n yield {\n batchType: 'data',\n shape,\n length: batchData.length,\n data: batchData\n };\n }\n }\n}\n/**\n * Extract batch of same length from two batches\n *\n * @param batch1\n * @param batch2\n * @return array | null\n */\nfunction extractBatchData(batch1, batch2) {\n const batchLength = Math.min(batch1.length, batch2.length);\n if (batchLength === 0) {\n return null;\n }\n // Non interleaved arrays\n const batch = [batch1.slice(0, batchLength), batch2.slice(0, batchLength)];\n // Modify the 2 batches\n batch1.splice(0, batchLength);\n batch2.splice(0, batchLength);\n return batch;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { BinaryChunkReader } from \"../streaming/binary-chunk-reader.js\";\nconst LITTLE_ENDIAN = true;\nconst DBF_HEADER_SIZE = 32;\nvar STATE;\n(function (STATE) {\n STATE[STATE[\"START\"] = 0] = \"START\";\n STATE[STATE[\"FIELD_DESCRIPTORS\"] = 1] = \"FIELD_DESCRIPTORS\";\n STATE[STATE[\"FIELD_PROPERTIES\"] = 2] = \"FIELD_PROPERTIES\";\n STATE[STATE[\"END\"] = 3] = \"END\";\n STATE[STATE[\"ERROR\"] = 4] = \"ERROR\";\n})(STATE || (STATE = {}));\nclass DBFParser {\n binaryReader = new BinaryChunkReader();\n textDecoder;\n state = STATE.START;\n result = {\n data: []\n };\n constructor(options) {\n this.textDecoder = new TextDecoder(options.encoding);\n }\n /**\n * @param arrayBuffer\n */\n write(arrayBuffer) {\n this.binaryReader.write(arrayBuffer);\n this.state = parseState(this.state, this.result, this.binaryReader, this.textDecoder);\n // this.result.progress.bytesUsed = this.binaryReader.bytesUsed();\n // important events:\n // - schema available\n // - first rows available\n // - all rows available\n }\n end() {\n this.binaryReader.end();\n this.state = parseState(this.state, this.result, this.binaryReader, this.textDecoder);\n // this.result.progress.bytesUsed = this.binaryReader.bytesUsed();\n if (this.state !== STATE.END) {\n this.state = STATE.ERROR;\n this.result.error = 'DBF incomplete file';\n }\n }\n}\n/**\n * @param arrayBuffer\n * @param options\n * @returns DBFTable or rows\n */\nexport function parseDBF(arrayBuffer, options = {}) {\n const { encoding = 'latin1' } = options.dbf || {};\n const dbfParser = new DBFParser({ encoding });\n dbfParser.write(arrayBuffer);\n dbfParser.end();\n const { data, schema } = dbfParser.result;\n const shape = options?.dbf?.shape;\n switch (shape) {\n case 'object-row-table': {\n const table = {\n shape: 'object-row-table',\n schema,\n data\n };\n return table;\n }\n case 'table':\n return { schema, rows: data };\n case 'rows':\n default:\n return data;\n }\n}\n/**\n * @param asyncIterator\n * @param options\n */\nexport async function* parseDBFInBatches(asyncIterator, options = {}) {\n const { encoding = 'latin1' } = options.dbf || {};\n const parser = new DBFParser({ encoding });\n let headerReturned = false;\n for await (const arrayBuffer of asyncIterator) {\n parser.write(arrayBuffer);\n if (!headerReturned && parser.result.dbfHeader) {\n headerReturned = true;\n yield parser.result.dbfHeader;\n }\n if (parser.result.data.length > 0) {\n yield parser.result.data;\n parser.result.data = [];\n }\n }\n parser.end();\n if (parser.result.data.length > 0) {\n yield parser.result.data;\n }\n}\n/**\n * https://www.dbase.com/Knowledgebase/INT/db7_file_fmt.htm\n * @param state\n * @param result\n * @param binaryReader\n * @param textDecoder\n * @returns\n */\n/* eslint-disable complexity, max-depth */\nfunction parseState(state, result, binaryReader, textDecoder) {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n switch (state) {\n case STATE.ERROR:\n case STATE.END:\n return state;\n case STATE.START:\n // Parse initial file header\n // DBF Header\n const dataView = binaryReader.getDataView(DBF_HEADER_SIZE);\n if (!dataView) {\n return state;\n }\n result.dbfHeader = parseDBFHeader(dataView);\n result.progress = {\n bytesUsed: 0,\n rowsTotal: result.dbfHeader.nRecords,\n rows: 0\n };\n state = STATE.FIELD_DESCRIPTORS;\n break;\n case STATE.FIELD_DESCRIPTORS:\n // Parse DBF field descriptors (schema)\n const fieldDescriptorView = binaryReader.getDataView(\n // @ts-ignore\n result.dbfHeader.headerLength - DBF_HEADER_SIZE);\n if (!fieldDescriptorView) {\n return state;\n }\n result.dbfFields = parseFieldDescriptors(fieldDescriptorView, textDecoder);\n result.schema = {\n fields: result.dbfFields.map((dbfField) => makeField(dbfField)),\n metadata: {}\n };\n state = STATE.FIELD_PROPERTIES;\n // TODO(kyle) Not exactly sure why start offset needs to be headerLength + 1?\n // parsedbf uses ((fields.length + 1) << 5) + 2;\n binaryReader.skip(1);\n break;\n case STATE.FIELD_PROPERTIES:\n const { recordLength = 0, nRecords = 0 } = result?.dbfHeader || {};\n while (result.data.length < nRecords) {\n const recordView = binaryReader.getDataView(recordLength - 1);\n if (!recordView) {\n return state;\n }\n // Note: Avoid actually reading the last byte, which may not be present\n binaryReader.skip(1);\n // @ts-ignore\n const row = parseRow(recordView, result.dbfFields, textDecoder);\n result.data.push(row);\n // @ts-ignore\n result.progress.rows = result.data.length;\n }\n state = STATE.END;\n break;\n default:\n state = STATE.ERROR;\n result.error = `illegal parser state ${state}`;\n return state;\n }\n }\n catch (error) {\n state = STATE.ERROR;\n result.error = `DBF parsing failed: ${error.message}`;\n return state;\n }\n }\n}\n/**\n * @param headerView\n */\nfunction parseDBFHeader(headerView) {\n return {\n // Last updated date\n year: headerView.getUint8(1) + 1900,\n month: headerView.getUint8(2),\n day: headerView.getUint8(3),\n // Number of records in data file\n nRecords: headerView.getUint32(4, LITTLE_ENDIAN),\n // Length of header in bytes\n headerLength: headerView.getUint16(8, LITTLE_ENDIAN),\n // Length of each record\n recordLength: headerView.getUint16(10, LITTLE_ENDIAN),\n // Not sure if this is usually set\n languageDriver: headerView.getUint8(29)\n };\n}\n/**\n * @param view\n */\nfunction parseFieldDescriptors(view, textDecoder) {\n // NOTE: this might overestimate the number of fields if the \"Database\n // Container\" container exists and is included in the headerLength\n const nFields = (view.byteLength - 1) / 32;\n const fields = [];\n let offset = 0;\n for (let i = 0; i < nFields; i++) {\n const name = textDecoder\n .decode(new Uint8Array(view.buffer, view.byteOffset + offset, 11))\n // eslint-disable-next-line no-control-regex\n .replace(/\\u0000/g, '');\n fields.push({\n name,\n dataType: String.fromCharCode(view.getUint8(offset + 11)),\n fieldLength: view.getUint8(offset + 16),\n decimal: view.getUint8(offset + 17)\n });\n offset += 32;\n }\n return fields;\n}\n/*\n * @param {BinaryChunkReader} binaryReader\nfunction parseRows(binaryReader, fields, nRecords, recordLength, textDecoder) {\n const rows = [];\n for (let i = 0; i < nRecords; i++) {\n const recordView = binaryReader.getDataView(recordLength - 1);\n binaryReader.skip(1);\n // @ts-ignore\n rows.push(parseRow(recordView, fields, textDecoder));\n }\n return rows;\n}\n */\n/**\n *\n * @param view\n * @param fields\n * @param textDecoder\n * @returns\n */\nfunction parseRow(view, fields, textDecoder) {\n const out = {};\n let offset = 0;\n for (const field of fields) {\n const text = textDecoder.decode(new Uint8Array(view.buffer, view.byteOffset + offset, field.fieldLength));\n out[field.name] = parseField(text, field.dataType);\n offset += field.fieldLength;\n }\n return out;\n}\n/**\n * Should NaN be coerced to null?\n * @param text\n * @param dataType\n * @returns Field depends on a type of the data\n */\nfunction parseField(text, dataType) {\n switch (dataType) {\n case 'B':\n return parseNumber(text);\n case 'C':\n return parseCharacter(text);\n case 'F':\n return parseNumber(text);\n case 'N':\n return parseNumber(text);\n case 'O':\n return parseNumber(text);\n case 'D':\n return parseDate(text);\n case 'L':\n return parseBoolean(text);\n default:\n throw new Error('Unsupported data type');\n }\n}\n/**\n * Parse YYYYMMDD to date in milliseconds\n * @param str YYYYMMDD\n * @returns new Date as a number\n */\nfunction parseDate(str) {\n return Date.UTC(str.slice(0, 4), parseInt(str.slice(4, 6), 10) - 1, str.slice(6, 8));\n}\n/**\n * Read boolean value\n * any of Y, y, T, t coerce to true\n * any of N, n, F, f coerce to false\n * otherwise null\n * @param value\n * @returns boolean | null\n */\nfunction parseBoolean(value) {\n return /^[nf]$/i.test(value) ? false : /^[yt]$/i.test(value) ? true : null;\n}\n/**\n * Return null instead of NaN\n * @param text\n * @returns number | null\n */\nfunction parseNumber(text) {\n const number = parseFloat(text);\n return isNaN(number) ? null : number;\n}\n/**\n *\n * @param text\n * @returns string | null\n */\nfunction parseCharacter(text) {\n return text.trim() || null;\n}\n/**\n * Create a standard Arrow-style `Field` from field descriptor.\n * TODO - use `fieldLength` and `decimal` to generate smaller types?\n * @param param0\n * @returns Field\n */\n// eslint-disable\nfunction makeField({ name, dataType, fieldLength, decimal }) {\n switch (dataType) {\n case 'B':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'C':\n return { name, type: 'utf8', nullable: true, metadata: {} };\n case 'F':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'N':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'O':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'D':\n return { name, type: 'timestamp-millisecond', nullable: true, metadata: {} };\n case 'L':\n return { name, type: 'bool', nullable: true, metadata: {} };\n default:\n throw new Error('Unsupported data type');\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseDBF, parseDBFInBatches } from \"./lib/parsers/parse-dbf.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0\" !== 'undefined' ? \"4.3.0\" : 'latest';\n/**\n * DBFLoader - DBF files are used to contain non-geometry columns in Shapefiles\n */\nexport const DBFWorkerLoader = {\n name: 'DBF',\n dataType: null,\n batchType: null,\n id: 'dbf',\n module: 'shapefile',\n version: VERSION,\n worker: true,\n category: 'table',\n extensions: ['dbf'],\n mimeTypes: ['application/x-dbf'],\n options: {\n dbf: {\n encoding: 'latin1'\n }\n }\n};\n/** DBF file loader */\nexport const DBFLoader = {\n ...DBFWorkerLoader,\n parse: async (arrayBuffer, options) => parseDBF(arrayBuffer, options),\n parseSync: parseDBF,\n parseInBatches(arrayBufferIterator, options) {\n return parseDBFInBatches(arrayBufferIterator, options);\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { SHP_MAGIC_NUMBER } from \"./shp-loader.js\";\nimport { parseShapefile, parseShapefileInBatches } from \"./lib/parsers/parse-shapefile.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0\" !== 'undefined' ? \"4.3.0\" : 'latest';\n/**\n * Shapefile loader\n * @note Shapefile is multifile format and requires providing additional files\n */\nexport const ShapefileLoader = {\n name: 'Shapefile',\n id: 'shapefile',\n module: 'shapefile',\n version: VERSION,\n category: 'geometry',\n extensions: ['shp'],\n mimeTypes: ['application/octet-stream'],\n tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],\n options: {\n shapefile: {\n shape: 'v3'\n },\n shp: {\n _maxDimensions: 4\n }\n },\n // @ts-expect-error\n parse: parseShapefile,\n // @ts-expect-error\n parseInBatches: parseShapefileInBatches\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport class BinaryReader {\n offset;\n arrayBuffer;\n constructor(arrayBuffer) {\n /** current global (stream) offset */\n this.offset = 0;\n /** current buffer from iterator */\n this.arrayBuffer = arrayBuffer;\n }\n /**\n * Checks if there are available bytes in data\n *\n * @param bytes\n * @returns boolean\n */\n hasAvailableBytes(bytes) {\n return this.arrayBuffer.byteLength - this.offset >= bytes;\n }\n /**\n * Get the required number of bytes from the iterator\n *\n * @param bytes\n * @returns Dataview\n */\n getDataView(bytes) {\n if (bytes && !this.hasAvailableBytes(bytes)) {\n throw new Error('binary data exhausted');\n }\n const dataView = bytes\n ? new DataView(this.arrayBuffer, this.offset, bytes)\n : new DataView(this.arrayBuffer, this.offset);\n this.offset += bytes;\n return dataView;\n }\n /**\n * Skipping\n *\n * @param bytes\n */\n skip(bytes) {\n this.offset += bytes;\n }\n /**\n * Rewinding\n *\n * @param bytes\n */\n rewind(bytes) {\n this.offset -= bytes;\n }\n}\n"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { ShapefileLoader } from \"./shapefile-loader.js\";\nexport { DBFLoader, DBFWorkerLoader } from \"./dbf-loader.js\";\nexport { SHPLoader, SHPWorkerLoader } from \"./shp-loader.js\";\n// EXPERIMENTAL\nexport { BinaryReader as _BinaryReader } from \"./lib/streaming/binary-reader.js\";\nexport { BinaryChunkReader as _BinaryChunkReader } from \"./lib/streaming/binary-chunk-reader.js\";\nexport { zipBatchIterators as _zipBatchIterators } from \"./lib/streaming/zip-batch-iterators.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport class BinaryChunkReader {\n offset;\n arrayBuffers;\n ended;\n maxRewindBytes;\n constructor(options) {\n const { maxRewindBytes = 0 } = options || {};\n /** current global offset into current array buffer*/\n this.offset = 0;\n /** current buffer from iterator */\n this.arrayBuffers = [];\n this.ended = false;\n /** bytes behind offset to hold on to */\n this.maxRewindBytes = maxRewindBytes;\n }\n /**\n * @param arrayBuffer\n */\n write(arrayBuffer) {\n this.arrayBuffers.push(arrayBuffer);\n }\n end() {\n this.arrayBuffers = [];\n this.ended = true;\n }\n /**\n * Has enough bytes available in array buffers\n *\n * @param bytes Number of bytes\n * @return boolean\n */\n hasAvailableBytes(bytes) {\n let bytesAvailable = -this.offset;\n for (const arrayBuffer of this.arrayBuffers) {\n bytesAvailable += arrayBuffer.byteLength;\n if (bytesAvailable >= bytes) {\n return true;\n }\n }\n return false;\n }\n /**\n * Find offsets of byte ranges within this.arrayBuffers\n *\n * @param bytes Byte length to read\n * @return Arrays with byte ranges pointing to this.arrayBuffers, Output type is nested array, e.g. [ [0, [1, 2]], ...]\n */\n findBufferOffsets(bytes) {\n let offset = -this.offset;\n const selectedBuffers = [];\n for (let i = 0; i < this.arrayBuffers.length; i++) {\n const buf = this.arrayBuffers[i];\n // Current buffer isn't long enough to reach global offset\n if (offset + buf.byteLength <= 0) {\n offset += buf.byteLength;\n // eslint-disable-next-line no-continue\n continue;\n }\n // Find start/end offsets for this buffer\n // When offset < 0, need to skip over Math.abs(offset) bytes\n // When offset > 0, implies bytes in previous buffer, start at 0\n const start = offset <= 0 ? Math.abs(offset) : 0;\n let end;\n // Length of requested bytes is contained in current buffer\n if (start + bytes <= buf.byteLength) {\n end = start + bytes;\n selectedBuffers.push([i, [start, end]]);\n return selectedBuffers;\n }\n // Will need to look into next buffer\n end = buf.byteLength;\n selectedBuffers.push([i, [start, end]]);\n // Need to read fewer bytes in next iter\n bytes -= buf.byteLength - start;\n offset += buf.byteLength;\n }\n // Should only finish loop if exhausted all arrays\n return null;\n }\n /**\n * Get the required number of bytes from the iterator\n *\n * @param bytes Number of bytes\n * @return DataView with data\n */\n getDataView(bytes) {\n const bufferOffsets = this.findBufferOffsets(bytes);\n // return `null` if not enough data, except if end() already called, in\n // which case throw an error.\n if (!bufferOffsets && this.ended) {\n throw new Error('binary data exhausted');\n }\n if (!bufferOffsets) {\n return null;\n }\n // If only one arrayBuffer needed, return DataView directly\n if (bufferOffsets.length === 1) {\n const [bufferIndex, [start, end]] = bufferOffsets[0];\n const arrayBuffer = this.arrayBuffers[bufferIndex];\n const view = new DataView(arrayBuffer, start, end - start);\n this.offset += bytes;\n this.disposeBuffers();\n return view;\n }\n // Concatenate portions of multiple ArrayBuffers\n const view = new DataView(this._combineArrayBuffers(bufferOffsets));\n this.offset += bytes;\n this.disposeBuffers();\n return view;\n }\n /**\n * Dispose of old array buffers\n */\n disposeBuffers() {\n while (this.arrayBuffers.length > 0 &&\n this.offset - this.maxRewindBytes >= this.arrayBuffers[0].byteLength) {\n this.offset -= this.arrayBuffers[0].byteLength;\n this.arrayBuffers.shift();\n }\n }\n /**\n * Copy multiple ArrayBuffers into one contiguous ArrayBuffer\n *\n * In contrast to concatenateArrayBuffers, this only copies the necessary\n * portions of the source arrays, rather than first copying the entire arrays\n * then taking a part of them.\n *\n * @param bufferOffsets List of internal array offsets\n * @return New contiguous ArrayBuffer\n */\n _combineArrayBuffers(bufferOffsets) {\n let byteLength = 0;\n for (const bufferOffset of bufferOffsets) {\n const [start, end] = bufferOffset[1];\n byteLength += end - start;\n }\n const result = new Uint8Array(byteLength);\n // Copy the subarrays\n let resultOffset = 0;\n for (const bufferOffset of bufferOffsets) {\n const [bufferIndex, [start, end]] = bufferOffset;\n const sourceArray = new Uint8Array(this.arrayBuffers[bufferIndex]);\n result.set(sourceArray.subarray(start, end), resultOffset);\n resultOffset += end - start;\n }\n return result.buffer;\n }\n /**\n * @param bytes\n */\n skip(bytes) {\n this.offset += bytes;\n }\n /**\n * @param bytes\n */\n rewind(bytes) {\n // TODO - only works if offset is already set\n this.offset -= bytes;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst LITTLE_ENDIAN = true;\nconst BIG_ENDIAN = false;\nconst SHP_MAGIC_NUMBER = 0x0000270a;\n/**\n * Extract the binary header\n * Note: Also used by SHX\n * @param headerView\n * @returns SHPHeader\n */\nexport function parseSHPHeader(headerView) {\n // Note: The SHP format switches endianness between fields!\n // https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf\n const header = {\n magic: headerView.getInt32(0, BIG_ENDIAN),\n // Length is stored as # of 2-byte words; multiply by 2 to get # of bytes\n length: headerView.getInt32(24, BIG_ENDIAN) * 2,\n version: headerView.getInt32(28, LITTLE_ENDIAN),\n type: headerView.getInt32(32, LITTLE_ENDIAN),\n bbox: {\n minX: headerView.getFloat64(36, LITTLE_ENDIAN),\n minY: headerView.getFloat64(44, LITTLE_ENDIAN),\n minZ: headerView.getFloat64(68, LITTLE_ENDIAN),\n minM: headerView.getFloat64(84, LITTLE_ENDIAN),\n maxX: headerView.getFloat64(52, LITTLE_ENDIAN),\n maxY: headerView.getFloat64(60, LITTLE_ENDIAN),\n maxZ: headerView.getFloat64(76, LITTLE_ENDIAN),\n maxM: headerView.getFloat64(92, LITTLE_ENDIAN)\n }\n };\n if (header.magic !== SHP_MAGIC_NUMBER) {\n // eslint-disable-next-line\n console.error(`SHP file: bad magic number ${header.magic}`);\n }\n if (header.version !== 1000) {\n // eslint-disable-next-line\n console.error(`SHP file: bad version ${header.version}`);\n }\n return header;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst LITTLE_ENDIAN = true;\n/**\n * Parse individual record\n *\n * @param view Record data\n * @return Binary Geometry Object\n */\n// eslint-disable-next-line complexity\nexport function parseRecord(view, options) {\n const { _maxDimensions = 4 } = options?.shp || {};\n let offset = 0;\n const type = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n switch (type) {\n case 0:\n // Null Shape\n return parseNull();\n case 1:\n // Point\n return parsePoint(view, offset, Math.min(2, _maxDimensions));\n case 3:\n // PolyLine\n return parsePoly(view, offset, Math.min(2, _maxDimensions), 'LineString');\n case 5:\n // Polygon\n return parsePoly(view, offset, Math.min(2, _maxDimensions), 'Polygon');\n case 8:\n // MultiPoint\n return parseMultiPoint(view, offset, Math.min(2, _maxDimensions));\n // GeometryZ can have 3 or 4 dimensions, since the M is not required to\n // exist\n case 11:\n // PointZ\n return parsePoint(view, offset, Math.min(4, _maxDimensions));\n case 13:\n // PolyLineZ\n return parsePoly(view, offset, Math.min(4, _maxDimensions), 'LineString');\n case 15:\n // PolygonZ\n return parsePoly(view, offset, Math.min(4, _maxDimensions), 'Polygon');\n case 18:\n // MultiPointZ\n return parseMultiPoint(view, offset, Math.min(4, _maxDimensions));\n case 21:\n // PointM\n return parsePoint(view, offset, Math.min(3, _maxDimensions));\n case 23:\n // PolyLineM\n return parsePoly(view, offset, Math.min(3, _maxDimensions), 'LineString');\n case 25:\n // PolygonM\n return parsePoly(view, offset, Math.min(3, _maxDimensions), 'Polygon');\n case 28:\n // MultiPointM\n return parseMultiPoint(view, offset, Math.min(3, _maxDimensions));\n default:\n throw new Error(`unsupported shape type: ${type}`);\n }\n}\n// TODO handle null\n/**\n * Parse Null geometry\n *\n * @return null\n */\nfunction parseNull() {\n return null;\n}\n/**\n * Parse point geometry\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param dim Dimension size\n */\nfunction parsePoint(view, offset, dim) {\n let positions;\n [positions, offset] = parsePositions(view, offset, 1, dim);\n return {\n positions: { value: positions, size: dim },\n type: 'Point'\n };\n}\n/**\n * Parse MultiPoint geometry\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param dim Input dimension\n * @return Binary geometry object\n */\nfunction parseMultiPoint(view, offset, dim) {\n // skip parsing box\n offset += 4 * Float64Array.BYTES_PER_ELEMENT;\n const nPoints = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n let xyPositions = null;\n let mPositions = null;\n let zPositions = null;\n [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);\n // Parse Z coordinates\n if (dim === 4) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [zPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n // Parse M coordinates\n if (dim >= 3) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [mPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n const positions = concatPositions(xyPositions, mPositions, zPositions);\n return {\n positions: { value: positions, size: dim },\n type: 'Point'\n };\n}\n/**\n * Polygon and PolyLine parsing\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param dim Input dimension\n * @param type Either 'Polygon' or 'Polyline'\n * @return Binary geometry object\n */\n// eslint-disable-next-line max-statements\nfunction parsePoly(view, offset, dim, type) {\n // skip parsing bounding box\n offset += 4 * Float64Array.BYTES_PER_ELEMENT;\n const nParts = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n const nPoints = view.getInt32(offset, LITTLE_ENDIAN);\n offset += Int32Array.BYTES_PER_ELEMENT;\n // Create longer indices array by 1 because output format is expected to\n // include the last index as the total number of positions\n const bufferOffset = view.byteOffset + offset;\n const bufferLength = nParts * Int32Array.BYTES_PER_ELEMENT;\n const ringIndices = new Int32Array(nParts + 1);\n ringIndices.set(new Int32Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)));\n ringIndices[nParts] = nPoints;\n offset += nParts * Int32Array.BYTES_PER_ELEMENT;\n let xyPositions = null;\n let mPositions = null;\n let zPositions = null;\n [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);\n // Parse Z coordinates\n if (dim === 4) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [zPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n // Parse M coordinates\n if (dim >= 3) {\n // skip parsing range\n offset += 2 * Float64Array.BYTES_PER_ELEMENT;\n [mPositions, offset] = parsePositions(view, offset, nPoints, 1);\n }\n const positions = concatPositions(xyPositions, mPositions, zPositions);\n // parsePoly only accepts type = LineString or Polygon\n if (type === 'LineString') {\n return {\n type,\n positions: { value: positions, size: dim },\n pathIndices: { value: ringIndices, size: 1 }\n };\n }\n // for every ring, determine sign of polygon\n // Use only 2D positions for ring calc\n const polygonIndices = [];\n for (let i = 1; i < ringIndices.length; i++) {\n const startRingIndex = ringIndices[i - 1];\n const endRingIndex = ringIndices[i];\n // @ts-ignore\n const ring = xyPositions.subarray(startRingIndex * 2, endRingIndex * 2);\n const sign = getWindingDirection(ring);\n // A positive sign implies clockwise\n // A clockwise ring is a filled ring\n if (sign > 0) {\n polygonIndices.push(startRingIndex);\n }\n }\n polygonIndices.push(nPoints);\n return {\n type,\n positions: { value: positions, size: dim },\n primitivePolygonIndices: { value: ringIndices, size: 1 },\n // TODO: Dynamically choose Uint32Array over Uint16Array only when\n // necessary. I believe the implementation requires nPoints to be the\n // largest value in the array, so you should be able to use Uint32Array only\n // when nPoints > 65535.\n polygonIndices: { value: new Uint32Array(polygonIndices), size: 1 }\n };\n}\n/**\n * Parse a contiguous block of positions into a Float64Array\n *\n * @param view Geometry data\n * @param offset Offset in view\n * @param nPoints Number of points\n * @param dim Input dimension\n * @return Data and offset\n */\nfunction parsePositions(view, offset, nPoints, dim) {\n const bufferOffset = view.byteOffset + offset;\n const bufferLength = nPoints * dim * Float64Array.BYTES_PER_ELEMENT;\n return [\n new Float64Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)),\n offset + bufferLength\n ];\n}\n/**\n * Concatenate and interleave positions arrays\n * xy positions are interleaved; mPositions, zPositions are their own arrays\n *\n * @param xyPositions 2d positions\n * @param mPositions M positions\n * @param zPositions Z positions\n * @return Combined interleaved positions\n */\n// eslint-disable-next-line complexity\nfunction concatPositions(xyPositions, mPositions, zPositions) {\n if (!(mPositions || zPositions)) {\n return xyPositions;\n }\n let arrayLength = xyPositions.length;\n let nDim = 2;\n if (zPositions && zPositions.length) {\n arrayLength += zPositions.length;\n nDim++;\n }\n if (mPositions && mPositions.length) {\n arrayLength += mPositions.length;\n nDim++;\n }\n const positions = new Float64Array(arrayLength);\n for (let i = 0; i < xyPositions.length / 2; i++) {\n positions[nDim * i] = xyPositions[i * 2];\n positions[nDim * i + 1] = xyPositions[i * 2 + 1];\n }\n if (zPositions && zPositions.length) {\n for (let i = 0; i < zPositions.length; i++) {\n // If Z coordinates exist; used as third coord in positions array\n positions[nDim * i + 2] = zPositions[i];\n }\n }\n if (mPositions && mPositions.length) {\n for (let i = 0; i < mPositions.length; i++) {\n // M is always last, either 3rd or 4th depending on if Z exists\n positions[nDim * i + (nDim - 1)] = mPositions[i];\n }\n }\n return positions;\n}\n/**\n * Returns the direction of the polygon path\n * A positive number is clockwise.\n * A negative number is counter clockwise.\n *\n * @param positions\n * @return Sign of polygon ring\n */\nfunction getWindingDirection(positions) {\n return Math.sign(getSignedArea(positions));\n}\n/**\n * Get signed area of flat typed array of 2d positions\n *\n * @param positions\n * @return Signed area of polygon ring\n */\nfunction getSignedArea(positions) {\n let area = 0;\n // Rings are closed according to shapefile spec\n const nCoords = positions.length / 2 - 1;\n for (let i = 0; i < nCoords; i++) {\n area +=\n (positions[i * 2] + positions[(i + 1) * 2]) *\n (positions[i * 2 + 1] - positions[(i + 1) * 2 + 1]);\n }\n return area / 2;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { BinaryChunkReader } from \"../streaming/binary-chunk-reader.js\";\nimport { parseSHPHeader } from \"./parse-shp-header.js\";\nimport { parseRecord } from \"./parse-shp-geometry.js\";\nconst LITTLE_ENDIAN = true;\nconst BIG_ENDIAN = false;\nconst SHP_HEADER_SIZE = 100;\n// According to the spec, the record header is just 8 bytes, but here we set it\n// to 12 so that we can also access the record's type\nconst SHP_RECORD_HEADER_SIZE = 12;\nconst STATE = {\n EXPECTING_HEADER: 0,\n EXPECTING_RECORD: 1,\n END: 2,\n ERROR: 3\n};\nclass SHPParser {\n options = {};\n binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });\n state = STATE.EXPECTING_HEADER;\n result = {\n geometries: [],\n // Initialize with number values to make TS happy\n // These are initialized for real in STATE.EXPECTING_HEADER\n progress: {\n bytesTotal: NaN,\n bytesUsed: NaN,\n rows: NaN\n },\n currentIndex: NaN\n };\n constructor(options) {\n this.options = options;\n }\n write(arrayBuffer) {\n this.binaryReader.write(arrayBuffer);\n this.state = parseState(this.state, this.result, this.binaryReader, this.options);\n }\n end() {\n this.binaryReader.end();\n this.state = parseState(this.state, this.result, this.binaryReader, this.options);\n // this.result.progress.bytesUsed = this.binaryReader.bytesUsed();\n if (this.state !== STATE.END) {\n this.state = STATE.ERROR;\n this.result.error = 'SHP incomplete file';\n }\n }\n}\nexport function parseSHP(arrayBuffer, options) {\n const shpParser = new SHPParser(options);\n shpParser.write(arrayBuffer);\n shpParser.end();\n // @ts-ignore\n return shpParser.result;\n}\n/**\n * @param asyncIterator\n * @param options\n * @returns\n */\nexport async function* parseSHPInBatches(asyncIterator, options) {\n const parser = new SHPParser(options);\n let headerReturned = false;\n for await (const arrayBuffer of asyncIterator) {\n parser.write(arrayBuffer);\n if (!headerReturned && parser.result.header) {\n headerReturned = true;\n yield parser.result.header;\n }\n if (parser.result.geometries.length > 0) {\n yield parser.result.geometries;\n parser.result.geometries = [];\n }\n }\n parser.end();\n if (parser.result.geometries.length > 0) {\n yield parser.result.geometries;\n }\n return;\n}\n/**\n * State-machine parser for SHP data\n *\n * Note that whenever more data is needed, a `return`, not a `break`, is\n * necessary, as the `break` keeps the context within `parseState`, while\n * `return` releases context so that more data can be written into the\n * BinaryChunkReader.\n *\n * @param state Current state\n * @param result An object to hold result data\n * @param binaryReader\n * @return State at end of current parsing\n */\n/* eslint-disable complexity, max-depth */\nfunction parseState(state, result, binaryReader, options) {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n switch (state) {\n case STATE.ERROR:\n case STATE.END:\n return state;\n case STATE.EXPECTING_HEADER:\n // Parse initial file header\n const dataView = binaryReader.getDataView(SHP_HEADER_SIZE);\n if (!dataView) {\n return state;\n }\n result.header = parseSHPHeader(dataView);\n result.progress = {\n bytesUsed: 0,\n bytesTotal: result.header.length,\n rows: 0\n };\n // index numbering starts at 1\n result.currentIndex = 1;\n state = STATE.EXPECTING_RECORD;\n break;\n case STATE.EXPECTING_RECORD:\n while (binaryReader.hasAvailableBytes(SHP_RECORD_HEADER_SIZE)) {\n const recordHeaderView = binaryReader.getDataView(SHP_RECORD_HEADER_SIZE);\n const recordHeader = {\n recordNumber: recordHeaderView.getInt32(0, BIG_ENDIAN),\n // 2 byte words; includes the four words of record header\n byteLength: recordHeaderView.getInt32(4, BIG_ENDIAN) * 2,\n // This is actually part of the record, not the header...\n type: recordHeaderView.getInt32(8, LITTLE_ENDIAN)\n };\n if (!binaryReader.hasAvailableBytes(recordHeader.byteLength - 4)) {\n binaryReader.rewind(SHP_RECORD_HEADER_SIZE);\n return state;\n }\n const invalidRecord = recordHeader.byteLength < 4 ||\n recordHeader.type !== result.header?.type ||\n recordHeader.recordNumber !== result.currentIndex;\n // All records must have at least four bytes (for the record shape type)\n if (invalidRecord) {\n // Malformed record, try again, advancing just 4 bytes\n // Note: this is a rewind because binaryReader.getDataView above\n // moved the pointer forward 12 bytes, so rewinding 8 bytes still\n // leaves us 4 bytes ahead\n binaryReader.rewind(SHP_RECORD_HEADER_SIZE - 4);\n }\n else {\n // Note: type is actually part of the record, not the header, so\n // rewind 4 bytes before reading record\n binaryReader.rewind(4);\n const recordView = binaryReader.getDataView(recordHeader.byteLength);\n const geometry = parseRecord(recordView, options);\n result.geometries.push(geometry);\n result.currentIndex++;\n result.progress.rows = result.currentIndex - 1;\n }\n }\n if (binaryReader.ended) {\n state = STATE.END;\n }\n return state;\n default:\n state = STATE.ERROR;\n result.error = `illegal parser state ${state}`;\n return state;\n }\n }\n catch (error) {\n state = STATE.ERROR;\n result.error = `SHP parsing failed: ${error?.message}`;\n return state;\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseSHP, parseSHPInBatches } from \"./lib/parsers/parse-shp.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.1\" !== 'undefined' ? \"4.3.1\" : 'latest';\nexport const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];\n/**\n * SHP file loader\n */\nexport const SHPWorkerLoader = {\n dataType: null,\n batchType: null,\n name: 'SHP',\n id: 'shp',\n module: 'shapefile',\n version: VERSION,\n worker: true,\n category: 'geometry',\n extensions: ['shp'],\n mimeTypes: ['application/octet-stream'],\n // ISSUE: This also identifies SHX files, which are identical to SHP for the first 100 bytes...\n tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],\n options: {\n shp: {\n _maxDimensions: 4\n }\n }\n};\n/** SHP file loader */\nexport const SHPLoader = {\n ...SHPWorkerLoader,\n parse: async (arrayBuffer, options) => parseSHP(arrayBuffer, options),\n parseSync: parseSHP,\n parseInBatches: (arrayBufferIterator, options) => parseSHPInBatches(arrayBufferIterator, options)\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// import type {Feature} from '@loaders.gl/gis';\nimport { parseInBatchesFromContext, parseFromContext } from '@loaders.gl/loader-utils';\nimport { binaryToGeometry, transformGeoJsonCoords } from '@loaders.gl/gis';\nimport { Proj4Projection } from '@math.gl/proj4';\nimport { parseShx } from \"./parse-shx.js\";\nimport { zipBatchIterators } from \"../streaming/zip-batch-iterators.js\";\nimport { SHPLoader } from \"../../shp-loader.js\";\nimport { DBFLoader } from \"../../dbf-loader.js\";\n/**\n * Parsing of file in batches\n */\n// eslint-disable-next-line max-statements, complexity\nexport async function* parseShapefileInBatches(asyncIterator, options, context) {\n const { reproject = false, _targetCrs = 'WGS84' } = options?.gis || {};\n const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);\n // parse geometries\n const shapeIterable = await parseInBatchesFromContext(asyncIterator, SHPLoader, options, context);\n const shapeIterator = shapeIterable[Symbol.asyncIterator]?.() || shapeIterable[Symbol.iterator]?.();\n // parse properties\n let propertyIterator = null;\n const dbfResponse = await context?.fetch(replaceExtension(context?.url || '', 'dbf'));\n if (dbfResponse?.ok) {\n const propertyIterable = await parseInBatchesFromContext(dbfResponse, DBFLoader, {\n ...options,\n dbf: { encoding: cpg || 'latin1' }\n }, context);\n propertyIterator =\n propertyIterable[Symbol.asyncIterator]?.() || propertyIterable[Symbol.iterator]();\n }\n // When `options.metadata` is `true`, there's an extra initial `metadata`\n // object before the iterator starts. zipBatchIterators expects to receive\n // batches of Array objects, and will fail with non-iterable batches, so it's\n // important to skip over the first batch.\n let shapeHeader = (await shapeIterator.next()).value;\n if (shapeHeader && shapeHeader.batchType === 'metadata') {\n shapeHeader = (await shapeIterator.next()).value;\n }\n let dbfHeader = {};\n if (propertyIterator) {\n dbfHeader = (await propertyIterator.next()).value;\n if (dbfHeader && dbfHeader.batchType === 'metadata') {\n dbfHeader = (await propertyIterator.next()).value;\n }\n }\n const zippedIterator = propertyIterator\n ? zipBatchIterators(shapeIterator, propertyIterator, 'object-row-table')\n : shapeIterator;\n const zippedBatchIterable = {\n [Symbol.asyncIterator]() {\n return zippedIterator;\n }\n };\n for await (const batch of zippedBatchIterable) {\n let geometries;\n let properties;\n if (!propertyIterator) {\n geometries = batch;\n }\n else {\n [geometries, properties] = batch.data;\n }\n const geojsonGeometries = parseGeometries(geometries);\n let features = joinProperties(geojsonGeometries, properties);\n if (reproject) {\n // @ts-ignore\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n yield {\n encoding: cpg,\n prj,\n shx,\n header: shapeHeader,\n data: features\n };\n }\n}\n/**\n * Parse shapefile\n *\n * @param arrayBuffer\n * @param options\n * @param context\n * @returns output of shapefile\n */\nexport async function parseShapefile(arrayBuffer, options, context) {\n const { reproject = false, _targetCrs = 'WGS84' } = options?.gis || {};\n const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);\n // parse geometries\n const { header, geometries } = await parseFromContext(arrayBuffer, SHPLoader, options, context); // {shp: shx}\n const geojsonGeometries = parseGeometries(geometries);\n // parse properties\n let propertyTable;\n const dbfResponse = await context?.fetch(replaceExtension(context?.url, 'dbf'));\n if (dbfResponse?.ok) {\n propertyTable = await parseFromContext(dbfResponse, DBFLoader, { dbf: { shape: 'object-row-table', encoding: cpg || 'latin1' } }, context);\n }\n let features = joinProperties(geojsonGeometries, propertyTable?.data || []);\n if (reproject) {\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n switch (options?.shapefile?.shape) {\n case 'geojson-table':\n return {\n // @ts-expect-error\n shape: 'geojson-table',\n type: 'FeatureCollection',\n encoding: cpg,\n schema: propertyTable?.schema || { metadata: {}, fields: [] },\n prj,\n shx,\n header,\n features\n };\n default:\n return {\n encoding: cpg,\n prj,\n shx,\n header,\n data: features\n };\n }\n}\n/**\n * Parse geometries\n *\n * @param geometries\n * @returns geometries as an array\n */\nfunction parseGeometries(geometries) {\n const geojsonGeometries = [];\n for (const geom of geometries) {\n geojsonGeometries.push(binaryToGeometry(geom));\n }\n return geojsonGeometries;\n}\n/**\n * Join properties and geometries into features\n *\n * @param geometries [description]\n * @param properties [description]\n * @return [description]\n */\nfunction joinProperties(geometries, properties) {\n const features = [];\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n const feature = {\n type: 'Feature',\n geometry,\n // properties can be undefined if dbfResponse above was empty\n properties: (properties && properties[i]) || {}\n };\n features.push(feature);\n }\n return features;\n}\n/**\n * Reproject GeoJSON features to output CRS\n *\n * @param features parsed GeoJSON features\n * @param sourceCrs source coordinate reference system\n * @param targetCrs \u2020arget coordinate reference system\n * @return Reprojected Features\n */\nfunction reprojectFeatures(features, sourceCrs, targetCrs) {\n if (!sourceCrs && !targetCrs) {\n return features;\n }\n const projection = new Proj4Projection({ from: sourceCrs || 'WGS84', to: targetCrs || 'WGS84' });\n return transformGeoJsonCoords(features, (coord) => projection.project(coord));\n}\n/**\n *\n * @param options\n * @param context\n * @returns Promise\n */\n// eslint-disable-next-line max-statements\nexport async function loadShapefileSidecarFiles(options, context) {\n // Attempt a parallel load of the small sidecar files\n // @ts-ignore context must be defined\n const { url, fetch } = context;\n const shxPromise = fetch(replaceExtension(url, 'shx'));\n const cpgPromise = fetch(replaceExtension(url, 'cpg'));\n const prjPromise = fetch(replaceExtension(url, 'prj'));\n await Promise.all([shxPromise, cpgPromise, prjPromise]);\n let shx;\n let cpg;\n let prj;\n const shxResponse = await shxPromise;\n if (shxResponse.ok) {\n const arrayBuffer = await shxResponse.arrayBuffer();\n shx = parseShx(arrayBuffer);\n }\n const cpgResponse = await cpgPromise;\n if (cpgResponse.ok) {\n cpg = await cpgResponse.text();\n }\n const prjResponse = await prjPromise;\n if (prjResponse.ok) {\n prj = await prjResponse.text();\n }\n return {\n shx,\n cpg,\n prj\n };\n}\n/**\n * Replace the extension at the end of a path.\n *\n * Matches the case of new extension with the case of the original file extension,\n * to increase the chance of finding files without firing off a request storm looking for various case combinations\n *\n * NOTE: Extensions can be both lower and uppercase\n * per spec, extensions should be lower case, but that doesn't mean they always are. See:\n * calvinmetcalf/shapefile-js#64, mapserver/mapserver#4712\n * https://trac.osgeo.org/mapserver/ticket/166\n */\nexport function replaceExtension(url, newExtension) {\n const baseName = basename(url);\n const extension = extname(url);\n const isUpperCase = extension === extension.toUpperCase();\n if (isUpperCase) {\n newExtension = newExtension.toUpperCase();\n }\n return `${baseName}.${newExtension}`;\n}\n// NOTE - this gives the entire path minus extension (i.e. NOT same as path.basename)\n/**\n * @param url\n * @returns string\n */\nfunction basename(url) {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(0, extIndex) : '';\n }\n return extIndex;\n}\n/**\n * @param url\n * @returns string\n */\nfunction extname(url) {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(extIndex + 1) : '';\n }\n return extIndex;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseSHPHeader } from \"./parse-shp-header.js\";\nconst SHX_HEADER_SIZE = 100;\nconst BIG_ENDIAN = false;\n/**\n * @param arrayBuffer\n * @returns SHXOutput\n */\nexport function parseShx(arrayBuffer) {\n // SHX header is identical to SHP Header\n const headerView = new DataView(arrayBuffer, 0, SHX_HEADER_SIZE);\n const header = parseSHPHeader(headerView);\n const contentLength = header.length - SHX_HEADER_SIZE;\n const contentView = new DataView(arrayBuffer, SHX_HEADER_SIZE, contentLength);\n const offsets = new Int32Array(contentLength);\n const lengths = new Int32Array(contentLength);\n for (let i = 0; i < contentLength / 8; i++) {\n offsets[i] = contentView.getInt32(i * 8, BIG_ENDIAN);\n lengths[i] = contentView.getInt32(i * 8 + 4, BIG_ENDIAN);\n }\n return {\n offsets,\n lengths\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Zip two iterators together\n *\n * @param iterator1\n * @param iterator2\n */\nexport async function* zipBatchIterators(iterator1, iterator2, shape) {\n const batch1Data = [];\n const batch2Data = [];\n let iterator1Done = false;\n let iterator2Done = false;\n // TODO - one could let all iterators flow at full speed using `Promise.race`\n // however we might end up with a big temporary buffer\n while (!iterator1Done && !iterator2Done) {\n if (batch1Data.length === 0 && !iterator1Done) {\n const { value, done } = await iterator1.next();\n if (done) {\n iterator1Done = true;\n }\n else {\n // @ts-expect-error\n batch1Data.push(...value);\n }\n }\n if (batch2Data.length === 0 && !iterator2Done) {\n const { value, done } = await iterator2.next();\n if (done) {\n iterator2Done = true;\n }\n else {\n batch2Data.push(...value);\n }\n }\n const batchData = extractBatchData(batch1Data, batch2Data);\n if (batchData) {\n yield {\n batchType: 'data',\n shape,\n length: batchData.length,\n data: batchData\n };\n }\n }\n}\n/**\n * Extract batch of same length from two batches\n *\n * @param batch1\n * @param batch2\n * @return array | null\n */\nfunction extractBatchData(batch1, batch2) {\n const batchLength = Math.min(batch1.length, batch2.length);\n if (batchLength === 0) {\n return null;\n }\n // Non interleaved arrays\n const batch = [batch1.slice(0, batchLength), batch2.slice(0, batchLength)];\n // Modify the 2 batches\n batch1.splice(0, batchLength);\n batch2.splice(0, batchLength);\n return batch;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { BinaryChunkReader } from \"../streaming/binary-chunk-reader.js\";\nconst LITTLE_ENDIAN = true;\nconst DBF_HEADER_SIZE = 32;\nvar STATE;\n(function (STATE) {\n STATE[STATE[\"START\"] = 0] = \"START\";\n STATE[STATE[\"FIELD_DESCRIPTORS\"] = 1] = \"FIELD_DESCRIPTORS\";\n STATE[STATE[\"FIELD_PROPERTIES\"] = 2] = \"FIELD_PROPERTIES\";\n STATE[STATE[\"END\"] = 3] = \"END\";\n STATE[STATE[\"ERROR\"] = 4] = \"ERROR\";\n})(STATE || (STATE = {}));\nclass DBFParser {\n binaryReader = new BinaryChunkReader();\n textDecoder;\n state = STATE.START;\n result = {\n data: []\n };\n constructor(options) {\n this.textDecoder = new TextDecoder(options.encoding);\n }\n /**\n * @param arrayBuffer\n */\n write(arrayBuffer) {\n this.binaryReader.write(arrayBuffer);\n this.state = parseState(this.state, this.result, this.binaryReader, this.textDecoder);\n // this.result.progress.bytesUsed = this.binaryReader.bytesUsed();\n // important events:\n // - schema available\n // - first rows available\n // - all rows available\n }\n end() {\n this.binaryReader.end();\n this.state = parseState(this.state, this.result, this.binaryReader, this.textDecoder);\n // this.result.progress.bytesUsed = this.binaryReader.bytesUsed();\n if (this.state !== STATE.END) {\n this.state = STATE.ERROR;\n this.result.error = 'DBF incomplete file';\n }\n }\n}\n/**\n * @param arrayBuffer\n * @param options\n * @returns DBFTable or rows\n */\nexport function parseDBF(arrayBuffer, options = {}) {\n const { encoding = 'latin1' } = options.dbf || {};\n const dbfParser = new DBFParser({ encoding });\n dbfParser.write(arrayBuffer);\n dbfParser.end();\n const { data, schema } = dbfParser.result;\n const shape = options?.dbf?.shape;\n switch (shape) {\n case 'object-row-table': {\n const table = {\n shape: 'object-row-table',\n schema,\n data\n };\n return table;\n }\n case 'table':\n return { schema, rows: data };\n case 'rows':\n default:\n return data;\n }\n}\n/**\n * @param asyncIterator\n * @param options\n */\nexport async function* parseDBFInBatches(asyncIterator, options = {}) {\n const { encoding = 'latin1' } = options.dbf || {};\n const parser = new DBFParser({ encoding });\n let headerReturned = false;\n for await (const arrayBuffer of asyncIterator) {\n parser.write(arrayBuffer);\n if (!headerReturned && parser.result.dbfHeader) {\n headerReturned = true;\n yield parser.result.dbfHeader;\n }\n if (parser.result.data.length > 0) {\n yield parser.result.data;\n parser.result.data = [];\n }\n }\n parser.end();\n if (parser.result.data.length > 0) {\n yield parser.result.data;\n }\n}\n/**\n * https://www.dbase.com/Knowledgebase/INT/db7_file_fmt.htm\n * @param state\n * @param result\n * @param binaryReader\n * @param textDecoder\n * @returns\n */\n/* eslint-disable complexity, max-depth */\nfunction parseState(state, result, binaryReader, textDecoder) {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n switch (state) {\n case STATE.ERROR:\n case STATE.END:\n return state;\n case STATE.START:\n // Parse initial file header\n // DBF Header\n const dataView = binaryReader.getDataView(DBF_HEADER_SIZE);\n if (!dataView) {\n return state;\n }\n result.dbfHeader = parseDBFHeader(dataView);\n result.progress = {\n bytesUsed: 0,\n rowsTotal: result.dbfHeader.nRecords,\n rows: 0\n };\n state = STATE.FIELD_DESCRIPTORS;\n break;\n case STATE.FIELD_DESCRIPTORS:\n // Parse DBF field descriptors (schema)\n const fieldDescriptorView = binaryReader.getDataView(\n // @ts-ignore\n result.dbfHeader.headerLength - DBF_HEADER_SIZE);\n if (!fieldDescriptorView) {\n return state;\n }\n result.dbfFields = parseFieldDescriptors(fieldDescriptorView, textDecoder);\n result.schema = {\n fields: result.dbfFields.map((dbfField) => makeField(dbfField)),\n metadata: {}\n };\n state = STATE.FIELD_PROPERTIES;\n // TODO(kyle) Not exactly sure why start offset needs to be headerLength + 1?\n // parsedbf uses ((fields.length + 1) << 5) + 2;\n binaryReader.skip(1);\n break;\n case STATE.FIELD_PROPERTIES:\n const { recordLength = 0, nRecords = 0 } = result?.dbfHeader || {};\n while (result.data.length < nRecords) {\n const recordView = binaryReader.getDataView(recordLength - 1);\n if (!recordView) {\n return state;\n }\n // Note: Avoid actually reading the last byte, which may not be present\n binaryReader.skip(1);\n // @ts-ignore\n const row = parseRow(recordView, result.dbfFields, textDecoder);\n result.data.push(row);\n // @ts-ignore\n result.progress.rows = result.data.length;\n }\n state = STATE.END;\n break;\n default:\n state = STATE.ERROR;\n result.error = `illegal parser state ${state}`;\n return state;\n }\n }\n catch (error) {\n state = STATE.ERROR;\n result.error = `DBF parsing failed: ${error.message}`;\n return state;\n }\n }\n}\n/**\n * @param headerView\n */\nfunction parseDBFHeader(headerView) {\n return {\n // Last updated date\n year: headerView.getUint8(1) + 1900,\n month: headerView.getUint8(2),\n day: headerView.getUint8(3),\n // Number of records in data file\n nRecords: headerView.getUint32(4, LITTLE_ENDIAN),\n // Length of header in bytes\n headerLength: headerView.getUint16(8, LITTLE_ENDIAN),\n // Length of each record\n recordLength: headerView.getUint16(10, LITTLE_ENDIAN),\n // Not sure if this is usually set\n languageDriver: headerView.getUint8(29)\n };\n}\n/**\n * @param view\n */\nfunction parseFieldDescriptors(view, textDecoder) {\n // NOTE: this might overestimate the number of fields if the \"Database\n // Container\" container exists and is included in the headerLength\n const nFields = (view.byteLength - 1) / 32;\n const fields = [];\n let offset = 0;\n for (let i = 0; i < nFields; i++) {\n const name = textDecoder\n .decode(new Uint8Array(view.buffer, view.byteOffset + offset, 11))\n // eslint-disable-next-line no-control-regex\n .replace(/\\u0000/g, '');\n fields.push({\n name,\n dataType: String.fromCharCode(view.getUint8(offset + 11)),\n fieldLength: view.getUint8(offset + 16),\n decimal: view.getUint8(offset + 17)\n });\n offset += 32;\n }\n return fields;\n}\n/*\n * @param {BinaryChunkReader} binaryReader\nfunction parseRows(binaryReader, fields, nRecords, recordLength, textDecoder) {\n const rows = [];\n for (let i = 0; i < nRecords; i++) {\n const recordView = binaryReader.getDataView(recordLength - 1);\n binaryReader.skip(1);\n // @ts-ignore\n rows.push(parseRow(recordView, fields, textDecoder));\n }\n return rows;\n}\n */\n/**\n *\n * @param view\n * @param fields\n * @param textDecoder\n * @returns\n */\nfunction parseRow(view, fields, textDecoder) {\n const out = {};\n let offset = 0;\n for (const field of fields) {\n const text = textDecoder.decode(new Uint8Array(view.buffer, view.byteOffset + offset, field.fieldLength));\n out[field.name] = parseField(text, field.dataType);\n offset += field.fieldLength;\n }\n return out;\n}\n/**\n * Should NaN be coerced to null?\n * @param text\n * @param dataType\n * @returns Field depends on a type of the data\n */\nfunction parseField(text, dataType) {\n switch (dataType) {\n case 'B':\n return parseNumber(text);\n case 'C':\n return parseCharacter(text);\n case 'F':\n return parseNumber(text);\n case 'N':\n return parseNumber(text);\n case 'O':\n return parseNumber(text);\n case 'D':\n return parseDate(text);\n case 'L':\n return parseBoolean(text);\n default:\n throw new Error('Unsupported data type');\n }\n}\n/**\n * Parse YYYYMMDD to date in milliseconds\n * @param str YYYYMMDD\n * @returns new Date as a number\n */\nfunction parseDate(str) {\n return Date.UTC(str.slice(0, 4), parseInt(str.slice(4, 6), 10) - 1, str.slice(6, 8));\n}\n/**\n * Read boolean value\n * any of Y, y, T, t coerce to true\n * any of N, n, F, f coerce to false\n * otherwise null\n * @param value\n * @returns boolean | null\n */\nfunction parseBoolean(value) {\n return /^[nf]$/i.test(value) ? false : /^[yt]$/i.test(value) ? true : null;\n}\n/**\n * Return null instead of NaN\n * @param text\n * @returns number | null\n */\nfunction parseNumber(text) {\n const number = parseFloat(text);\n return isNaN(number) ? null : number;\n}\n/**\n *\n * @param text\n * @returns string | null\n */\nfunction parseCharacter(text) {\n return text.trim() || null;\n}\n/**\n * Create a standard Arrow-style `Field` from field descriptor.\n * TODO - use `fieldLength` and `decimal` to generate smaller types?\n * @param param0\n * @returns Field\n */\n// eslint-disable\nfunction makeField({ name, dataType, fieldLength, decimal }) {\n switch (dataType) {\n case 'B':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'C':\n return { name, type: 'utf8', nullable: true, metadata: {} };\n case 'F':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'N':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'O':\n return { name, type: 'float64', nullable: true, metadata: {} };\n case 'D':\n return { name, type: 'timestamp-millisecond', nullable: true, metadata: {} };\n case 'L':\n return { name, type: 'bool', nullable: true, metadata: {} };\n default:\n throw new Error('Unsupported data type');\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseDBF, parseDBFInBatches } from \"./lib/parsers/parse-dbf.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.1\" !== 'undefined' ? \"4.3.1\" : 'latest';\n/**\n * DBFLoader - DBF files are used to contain non-geometry columns in Shapefiles\n */\nexport const DBFWorkerLoader = {\n name: 'DBF',\n dataType: null,\n batchType: null,\n id: 'dbf',\n module: 'shapefile',\n version: VERSION,\n worker: true,\n category: 'table',\n extensions: ['dbf'],\n mimeTypes: ['application/x-dbf'],\n options: {\n dbf: {\n encoding: 'latin1'\n }\n }\n};\n/** DBF file loader */\nexport const DBFLoader = {\n ...DBFWorkerLoader,\n parse: async (arrayBuffer, options) => parseDBF(arrayBuffer, options),\n parseSync: parseDBF,\n parseInBatches(arrayBufferIterator, options) {\n return parseDBFInBatches(arrayBufferIterator, options);\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { SHP_MAGIC_NUMBER } from \"./shp-loader.js\";\nimport { parseShapefile, parseShapefileInBatches } from \"./lib/parsers/parse-shapefile.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.1\" !== 'undefined' ? \"4.3.1\" : 'latest';\n/**\n * Shapefile loader\n * @note Shapefile is multifile format and requires providing additional files\n */\nexport const ShapefileLoader = {\n name: 'Shapefile',\n id: 'shapefile',\n module: 'shapefile',\n version: VERSION,\n category: 'geometry',\n extensions: ['shp'],\n mimeTypes: ['application/octet-stream'],\n tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],\n options: {\n shapefile: {\n shape: 'v3'\n },\n shp: {\n _maxDimensions: 4\n }\n },\n // @ts-expect-error\n parse: parseShapefile,\n // @ts-expect-error\n parseInBatches: parseShapefileInBatches\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport class BinaryReader {\n offset;\n arrayBuffer;\n constructor(arrayBuffer) {\n /** current global (stream) offset */\n this.offset = 0;\n /** current buffer from iterator */\n this.arrayBuffer = arrayBuffer;\n }\n /**\n * Checks if there are available bytes in data\n *\n * @param bytes\n * @returns boolean\n */\n hasAvailableBytes(bytes) {\n return this.arrayBuffer.byteLength - this.offset >= bytes;\n }\n /**\n * Get the required number of bytes from the iterator\n *\n * @param bytes\n * @returns Dataview\n */\n getDataView(bytes) {\n if (bytes && !this.hasAvailableBytes(bytes)) {\n throw new Error('binary data exhausted');\n }\n const dataView = bytes\n ? new DataView(this.arrayBuffer, this.offset, bytes)\n : new DataView(this.arrayBuffer, this.offset);\n this.offset += bytes;\n return dataView;\n }\n /**\n * Skipping\n *\n * @param bytes\n */\n skip(bytes) {\n this.offset += bytes;\n }\n /**\n * Rewinding\n *\n * @param bytes\n */\n rewind(bytes) {\n this.offset -= bytes;\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAA,EAOA,kBAAkB,OAAO;AACrB,WAAO,KAAK,YAAY,aAAa,KAAK,UAAU;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,OAAO;AACf,QAAI,SAAS,CAAC,KAAK,kBAAkB,KAAK,GAAG;AACzC,YAAM,IAAI,MAAM,uBAAuB;AAAA,IAC3C;AACA,UAAM,WAAW,QACX,IAAI,SAAS,KAAK,aAAa,KAAK,QAAQ,KAAK,IACjD,IAAI,SAAS,KAAK,aAAa,KAAK,MAAM;AAChD,SAAK,UAAU;AACf,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAK,OAAO;AACR,SAAK,UAAU;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,OAAO;AACV,SAAK,UAAU;AAAA,EACnB;AACJ;",
6
6
  "names": ["view", "LITTLE_ENDIAN", "LITTLE_ENDIAN", "BIG_ENDIAN", "SHP_MAGIC_NUMBER", "BIG_ENDIAN", "LITTLE_ENDIAN", "STATE", "parseState", "VERSION", "VERSION", "SHP_MAGIC_NUMBER"]
7
7
  }
@@ -5,7 +5,7 @@ import { SHP_MAGIC_NUMBER } from "./shp-loader.js";
5
5
  import { parseShapefile, parseShapefileInBatches } from "./lib/parsers/parse-shapefile.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.3.0" !== 'undefined' ? "4.3.0" : 'latest';
8
+ const VERSION = typeof "4.3.1" !== 'undefined' ? "4.3.1" : 'latest';
9
9
  /**
10
10
  * Shapefile loader
11
11
  * @note Shapefile is multifile format and requires providing additional files
@@ -4,7 +4,7 @@
4
4
  import { parseSHP, parseSHPInBatches } from "./lib/parsers/parse-shp.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0" !== 'undefined' ? "4.3.0" : 'latest';
7
+ const VERSION = typeof "4.3.1" !== 'undefined' ? "4.3.1" : 'latest';
8
8
  export const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];
9
9
  /**
10
10
  * SHP file loader
@@ -484,7 +484,7 @@
484
484
  }
485
485
 
486
486
  // src/shp-loader.ts
487
- var VERSION = true ? "4.3.0" : "latest";
487
+ var VERSION = true ? "4.3.1" : "latest";
488
488
  var SHP_MAGIC_NUMBER2 = [0, 0, 39, 10];
489
489
  var SHPWorkerLoader = {
490
490
  dataType: null,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/shapefile",
3
3
  "description": "Loader for the Shapefile Format",
4
- "version": "4.3.1",
4
+ "version": "4.3.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -45,13 +45,13 @@
45
45
  "build-worker-dbf": "esbuild src/workers/dbf-worker.ts --bundle --outfile=dist/dbf-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
46
46
  },
47
47
  "dependencies": {
48
- "@loaders.gl/gis": "4.3.1",
49
- "@loaders.gl/loader-utils": "4.3.1",
50
- "@loaders.gl/schema": "4.3.1",
48
+ "@loaders.gl/gis": "4.3.2",
49
+ "@loaders.gl/loader-utils": "4.3.2",
50
+ "@loaders.gl/schema": "4.3.2",
51
51
  "@math.gl/proj4": "^4.1.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@loaders.gl/core": "^4.3.0"
55
55
  },
56
- "gitHead": "70a883ab6bc84647c49963215dd6ff62d4d61de3"
56
+ "gitHead": "b4203b8703f64a38d6f79a3113bc7bb51d45c93a"
57
57
  }